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_ELEMENT_VALUE1_DOWN,
439 GADGET_ID_ELEMENT_VALUE1_TEXT,
440 GADGET_ID_ELEMENT_VALUE1_UP,
441 GADGET_ID_ELEMENT_VALUE2_DOWN,
442 GADGET_ID_ELEMENT_VALUE2_TEXT,
443 GADGET_ID_ELEMENT_VALUE2_UP,
444 GADGET_ID_ELEMENT_VALUE3_DOWN,
445 GADGET_ID_ELEMENT_VALUE3_TEXT,
446 GADGET_ID_ELEMENT_VALUE3_UP,
447 GADGET_ID_ELEMENT_VALUE4_DOWN,
448 GADGET_ID_ELEMENT_VALUE4_TEXT,
449 GADGET_ID_ELEMENT_VALUE4_UP,
450 GADGET_ID_YAMYAM_CONTENT_DOWN,
451 GADGET_ID_YAMYAM_CONTENT_TEXT,
452 GADGET_ID_YAMYAM_CONTENT_UP,
453 GADGET_ID_BALL_CONTENT_DOWN,
454 GADGET_ID_BALL_CONTENT_TEXT,
455 GADGET_ID_BALL_CONTENT_UP,
456 GADGET_ID_ANDROID_CONTENT_DOWN,
457 GADGET_ID_ANDROID_CONTENT_TEXT,
458 GADGET_ID_ANDROID_CONTENT_UP,
459 GADGET_ID_ENVELOPE_XSIZE_DOWN,
460 GADGET_ID_ENVELOPE_XSIZE_TEXT,
461 GADGET_ID_ENVELOPE_XSIZE_UP,
462 GADGET_ID_ENVELOPE_YSIZE_DOWN,
463 GADGET_ID_ENVELOPE_YSIZE_TEXT,
464 GADGET_ID_ENVELOPE_YSIZE_UP,
465 GADGET_ID_INVENTORY_SIZE_DOWN,
466 GADGET_ID_INVENTORY_SIZE_TEXT,
467 GADGET_ID_INVENTORY_SIZE_UP,
468 GADGET_ID_MM_BALL_CONTENT_DOWN,
469 GADGET_ID_MM_BALL_CONTENT_TEXT,
470 GADGET_ID_MM_BALL_CONTENT_UP,
471 GADGET_ID_CUSTOM_SCORE_DOWN,
472 GADGET_ID_CUSTOM_SCORE_TEXT,
473 GADGET_ID_CUSTOM_SCORE_UP,
474 GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
475 GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
476 GADGET_ID_CUSTOM_GEMCOUNT_UP,
477 GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
478 GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
479 GADGET_ID_CUSTOM_VALUE_FIX_UP,
480 GADGET_ID_CUSTOM_VALUE_RND_DOWN,
481 GADGET_ID_CUSTOM_VALUE_RND_TEXT,
482 GADGET_ID_CUSTOM_VALUE_RND_UP,
483 GADGET_ID_PUSH_DELAY_FIX_DOWN,
484 GADGET_ID_PUSH_DELAY_FIX_TEXT,
485 GADGET_ID_PUSH_DELAY_FIX_UP,
486 GADGET_ID_PUSH_DELAY_RND_DOWN,
487 GADGET_ID_PUSH_DELAY_RND_TEXT,
488 GADGET_ID_PUSH_DELAY_RND_UP,
489 GADGET_ID_DROP_DELAY_FIX_DOWN,
490 GADGET_ID_DROP_DELAY_FIX_TEXT,
491 GADGET_ID_DROP_DELAY_FIX_UP,
492 GADGET_ID_DROP_DELAY_RND_DOWN,
493 GADGET_ID_DROP_DELAY_RND_TEXT,
494 GADGET_ID_DROP_DELAY_RND_UP,
495 GADGET_ID_MOVE_DELAY_FIX_DOWN,
496 GADGET_ID_MOVE_DELAY_FIX_TEXT,
497 GADGET_ID_MOVE_DELAY_FIX_UP,
498 GADGET_ID_MOVE_DELAY_RND_DOWN,
499 GADGET_ID_MOVE_DELAY_RND_TEXT,
500 GADGET_ID_MOVE_DELAY_RND_UP,
501 GADGET_ID_STEP_DELAY_FIX_DOWN,
502 GADGET_ID_STEP_DELAY_FIX_TEXT,
503 GADGET_ID_STEP_DELAY_FIX_UP,
504 GADGET_ID_STEP_DELAY_RND_DOWN,
505 GADGET_ID_STEP_DELAY_RND_TEXT,
506 GADGET_ID_STEP_DELAY_RND_UP,
507 GADGET_ID_EXPLOSION_DELAY_DOWN,
508 GADGET_ID_EXPLOSION_DELAY_TEXT,
509 GADGET_ID_EXPLOSION_DELAY_UP,
510 GADGET_ID_IGNITION_DELAY_DOWN,
511 GADGET_ID_IGNITION_DELAY_TEXT,
512 GADGET_ID_IGNITION_DELAY_UP,
513 GADGET_ID_CHANGE_DELAY_FIX_DOWN,
514 GADGET_ID_CHANGE_DELAY_FIX_TEXT,
515 GADGET_ID_CHANGE_DELAY_FIX_UP,
516 GADGET_ID_CHANGE_DELAY_RND_DOWN,
517 GADGET_ID_CHANGE_DELAY_RND_TEXT,
518 GADGET_ID_CHANGE_DELAY_RND_UP,
519 GADGET_ID_CHANGE_CONT_RND_DOWN,
520 GADGET_ID_CHANGE_CONT_RND_TEXT,
521 GADGET_ID_CHANGE_CONT_RND_UP,
522 GADGET_ID_GROUP_CONTENT_DOWN,
523 GADGET_ID_GROUP_CONTENT_TEXT,
524 GADGET_ID_GROUP_CONTENT_UP,
526 // drawing area identifiers
528 GADGET_ID_DRAWING_LEVEL,
529 GADGET_ID_YAMYAM_CONTENT_0,
530 GADGET_ID_YAMYAM_CONTENT_1,
531 GADGET_ID_YAMYAM_CONTENT_2,
532 GADGET_ID_YAMYAM_CONTENT_3,
533 GADGET_ID_YAMYAM_CONTENT_4,
534 GADGET_ID_YAMYAM_CONTENT_5,
535 GADGET_ID_YAMYAM_CONTENT_6,
536 GADGET_ID_YAMYAM_CONTENT_7,
537 GADGET_ID_MAGIC_BALL_CONTENT_0,
538 GADGET_ID_MAGIC_BALL_CONTENT_1,
539 GADGET_ID_MAGIC_BALL_CONTENT_2,
540 GADGET_ID_MAGIC_BALL_CONTENT_3,
541 GADGET_ID_MAGIC_BALL_CONTENT_4,
542 GADGET_ID_MAGIC_BALL_CONTENT_5,
543 GADGET_ID_MAGIC_BALL_CONTENT_6,
544 GADGET_ID_MAGIC_BALL_CONTENT_7,
545 GADGET_ID_ANDROID_CONTENT,
546 GADGET_ID_AMOEBA_CONTENT,
547 GADGET_ID_START_ELEMENT,
548 GADGET_ID_ARTWORK_ELEMENT,
549 GADGET_ID_EXPLOSION_ELEMENT,
550 GADGET_ID_INVENTORY_CONTENT,
551 GADGET_ID_MM_BALL_CONTENT,
552 GADGET_ID_CUSTOM_GRAPHIC,
553 GADGET_ID_CUSTOM_CONTENT,
554 GADGET_ID_CUSTOM_MOVE_ENTER,
555 GADGET_ID_CUSTOM_MOVE_LEAVE,
556 GADGET_ID_CUSTOM_CHANGE_TARGET,
557 GADGET_ID_CUSTOM_CHANGE_CONTENT,
558 GADGET_ID_CUSTOM_CHANGE_TRIGGER,
559 GADGET_ID_CUSTOM_CHANGE_ACTION,
560 GADGET_ID_GROUP_CONTENT,
561 GADGET_ID_RANDOM_BACKGROUND,
563 // text input identifiers
565 GADGET_ID_LEVEL_NAME,
566 GADGET_ID_LEVEL_AUTHOR,
567 GADGET_ID_LEVELSET_NAME,
568 GADGET_ID_LEVELSET_AUTHOR,
569 GADGET_ID_ELEMENT_NAME,
571 // text area identifiers
573 GADGET_ID_ENVELOPE_INFO,
575 // selectbox identifiers
577 GADGET_ID_TIME_OR_STEPS,
578 GADGET_ID_TIME_SCORE_BASE,
579 GADGET_ID_GAME_ENGINE_TYPE,
580 GADGET_ID_BD_SCHEDULING_TYPE,
581 GADGET_ID_LEVELSET_SAVE_MODE,
582 GADGET_ID_WIND_DIRECTION,
583 GADGET_ID_PLAYER_SPEED,
584 GADGET_ID_MM_BALL_CHOICE_MODE,
585 GADGET_ID_CUSTOM_WALK_TO_ACTION,
586 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
587 GADGET_ID_CUSTOM_DEADLINESS,
588 GADGET_ID_CUSTOM_MOVE_PATTERN,
589 GADGET_ID_CUSTOM_MOVE_DIRECTION,
590 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
591 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
592 GADGET_ID_CUSTOM_SMASH_TARGETS,
593 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
594 GADGET_ID_CUSTOM_ACCESS_TYPE,
595 GADGET_ID_CUSTOM_ACCESS_LAYER,
596 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
597 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
598 GADGET_ID_CHANGE_TIME_UNITS,
599 GADGET_ID_CHANGE_DIRECT_ACTION,
600 GADGET_ID_CHANGE_OTHER_ACTION,
601 GADGET_ID_CHANGE_SIDE,
602 GADGET_ID_CHANGE_PLAYER,
603 GADGET_ID_CHANGE_PAGE,
604 GADGET_ID_CHANGE_REPLACE_WHEN,
605 GADGET_ID_ACTION_TYPE,
606 GADGET_ID_ACTION_MODE,
607 GADGET_ID_ACTION_ARG,
608 GADGET_ID_SELECT_CHANGE_PAGE,
609 GADGET_ID_GROUP_CHOICE_MODE,
611 // textbutton identifiers
613 GADGET_ID_LEVELCONFIG_LEVEL,
614 GADGET_ID_LEVELCONFIG_LEVELSET,
615 GADGET_ID_LEVELCONFIG_EDITOR,
616 GADGET_ID_LEVELCONFIG_ENGINE,
617 GADGET_ID_PROPERTIES_INFO,
618 GADGET_ID_PROPERTIES_CONFIG,
619 GADGET_ID_PROPERTIES_CONFIG_1,
620 GADGET_ID_PROPERTIES_CONFIG_2,
621 GADGET_ID_PROPERTIES_CHANGE,
622 GADGET_ID_SAVE_AS_TEMPLATE_1,
623 GADGET_ID_SAVE_AS_TEMPLATE_2,
624 GADGET_ID_SAVE_LEVELSET,
625 GADGET_ID_ADD_CHANGE_PAGE,
626 GADGET_ID_DEL_CHANGE_PAGE,
628 // graphicbutton identifiers
630 GADGET_ID_PREV_CHANGE_PAGE,
631 GADGET_ID_NEXT_CHANGE_PAGE,
632 GADGET_ID_COPY_CHANGE_PAGE,
633 GADGET_ID_PASTE_CHANGE_PAGE,
635 // gadgets for scrolling of drawing area
638 GADGET_ID_SCROLL_DOWN,
639 GADGET_ID_SCROLL_LEFT,
640 GADGET_ID_SCROLL_RIGHT,
641 GADGET_ID_SCROLL_HORIZONTAL,
642 GADGET_ID_SCROLL_VERTICAL,
644 // gadgets for scrolling element list
646 GADGET_ID_SCROLL_LIST_UP,
647 GADGET_ID_SCROLL_LIST_DOWN,
648 GADGET_ID_SCROLL_LIST_VERTICAL,
650 // checkbuttons/radiobuttons for level/element properties
652 GADGET_ID_AUTO_COUNT_GEMS,
653 GADGET_ID_RATE_TIME_OVER_SCORE,
654 GADGET_ID_USE_LEVELSET_ARTWORK,
655 GADGET_ID_COPY_LEVEL_TEMPLATE,
656 GADGET_ID_RANDOM_PERCENTAGE,
657 GADGET_ID_RANDOM_QUANTITY,
658 GADGET_ID_RANDOM_RESTRICTED,
659 GADGET_ID_BD_INTERMISSION,
660 GADGET_ID_BD_PAL_TIMING,
661 GADGET_ID_STICK_ELEMENT,
662 GADGET_ID_EM_SLIPPERY_GEMS,
663 GADGET_ID_EM_EXPLODES_BY_FIRE,
664 GADGET_ID_USE_SPRING_BUG,
665 GADGET_ID_USE_TIME_ORB_BUG,
666 GADGET_ID_USE_LIFE_BUGS,
667 GADGET_ID_RANDOM_BALL_CONTENT,
668 GADGET_ID_INITIAL_BALL_ACTIVE,
669 GADGET_ID_GROW_INTO_DIGGABLE,
670 GADGET_ID_SB_FIELDS_NEEDED,
671 GADGET_ID_SB_OBJECTS_NEEDED,
672 GADGET_ID_AUTO_EXIT_SOKOBAN,
673 GADGET_ID_SOLVED_BY_ONE_PLAYER,
674 GADGET_ID_FINISH_DIG_COLLECT,
675 GADGET_ID_KEEP_WALKABLE_CE,
676 GADGET_ID_CONTINUOUS_SNAPPING,
677 GADGET_ID_BLOCK_SNAP_FIELD,
678 GADGET_ID_BLOCK_LAST_FIELD,
679 GADGET_ID_SP_BLOCK_LAST_FIELD,
680 GADGET_ID_INSTANT_RELOCATION,
681 GADGET_ID_SHIFTED_RELOCATION,
682 GADGET_ID_LAZY_RELOCATION,
683 GADGET_ID_USE_START_ELEMENT,
684 GADGET_ID_USE_ARTWORK_ELEMENT,
685 GADGET_ID_USE_EXPLOSION_ELEMENT,
686 GADGET_ID_INITIAL_GRAVITY,
687 GADGET_ID_USE_INITIAL_INVENTORY,
688 GADGET_ID_CAN_PASS_TO_WALKABLE,
689 GADGET_ID_CAN_FALL_INTO_ACID,
690 GADGET_ID_CAN_MOVE_INTO_ACID,
691 GADGET_ID_DONT_COLLIDE_WITH,
692 GADGET_ID_BD_DIAGONAL_MOVEMENTS,
693 GADGET_ID_ENVELOPE_AUTOWRAP,
694 GADGET_ID_ENVELOPE_CENTERED,
695 GADGET_ID_MM_LASER_RED,
696 GADGET_ID_MM_LASER_GREEN,
697 GADGET_ID_MM_LASER_BLUE,
698 GADGET_ID_DF_LASER_RED,
699 GADGET_ID_DF_LASER_GREEN,
700 GADGET_ID_DF_LASER_BLUE,
701 GADGET_ID_ROTATE_MM_BALL_CONTENT,
702 GADGET_ID_EXPLODE_MM_BALL,
703 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
704 GADGET_ID_CUSTOM_CAN_EXPLODE,
705 GADGET_ID_CUSTOM_EXPLODE_FIRE,
706 GADGET_ID_CUSTOM_EXPLODE_SMASH,
707 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
708 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
709 GADGET_ID_CUSTOM_DEADLY,
710 GADGET_ID_CUSTOM_CAN_MOVE,
711 GADGET_ID_CUSTOM_CAN_FALL,
712 GADGET_ID_CUSTOM_CAN_SMASH,
713 GADGET_ID_CUSTOM_SLIPPERY,
714 GADGET_ID_CUSTOM_ACCESSIBLE,
715 GADGET_ID_CUSTOM_GRAV_REACHABLE,
716 GADGET_ID_CUSTOM_USE_LAST_VALUE,
717 GADGET_ID_CUSTOM_USE_GRAPHIC,
718 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
719 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
720 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
721 GADGET_ID_CUSTOM_CAN_CHANGE,
722 GADGET_ID_CHANGE_USE_CONTENT,
723 GADGET_ID_CHANGE_USE_EXPLOSION,
724 GADGET_ID_CHANGE_ONLY_COMPLETE,
725 GADGET_ID_CHANGE_USE_RANDOM,
726 GADGET_ID_CHANGE_HAS_ACTION,
727 GADGET_ID_CHANGE_DELAY,
728 GADGET_ID_CHANGE_BY_DIRECT_ACT,
729 GADGET_ID_CHANGE_BY_OTHER_ACT,
731 NUM_STATIC_GADGET_IDS
734 // gadgets for buttons in element list (dynamic)
735 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
736 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
737 ED_NUM_ELEMENTLIST_BUTTONS - 1)
739 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
741 // radio button numbers
745 RADIO_NR_DRAWING_TOOLBOX,
746 RADIO_NR_RANDOM_ELEMENTS
749 // values for counter gadgets
752 ED_COUNTER_ID_SELECT_LEVEL,
753 ED_COUNTER_ID_LEVEL_XSIZE,
754 ED_COUNTER_ID_LEVEL_YSIZE,
755 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
756 ED_COUNTER_ID_LEVEL_TIMELIMIT,
757 ED_COUNTER_ID_LEVEL_TIMESCORE,
758 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
759 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
760 ED_COUNTER_ID_LEVEL_RANDOM,
761 ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
762 ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
763 ED_COUNTER_ID_ELEMENT_VALUE1,
764 ED_COUNTER_ID_ELEMENT_VALUE2,
765 ED_COUNTER_ID_ELEMENT_VALUE3,
766 ED_COUNTER_ID_ELEMENT_VALUE4,
767 ED_COUNTER_ID_YAMYAM_CONTENT,
768 ED_COUNTER_ID_BALL_CONTENT,
769 ED_COUNTER_ID_ANDROID_CONTENT,
770 ED_COUNTER_ID_ENVELOPE_XSIZE,
771 ED_COUNTER_ID_ENVELOPE_YSIZE,
772 ED_COUNTER_ID_INVENTORY_SIZE,
773 ED_COUNTER_ID_MM_BALL_CONTENT,
774 ED_COUNTER_ID_CUSTOM_SCORE,
775 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
776 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
777 ED_COUNTER_ID_CUSTOM_VALUE_RND,
778 ED_COUNTER_ID_PUSH_DELAY_FIX,
779 ED_COUNTER_ID_PUSH_DELAY_RND,
780 ED_COUNTER_ID_DROP_DELAY_FIX,
781 ED_COUNTER_ID_DROP_DELAY_RND,
782 ED_COUNTER_ID_MOVE_DELAY_FIX,
783 ED_COUNTER_ID_MOVE_DELAY_RND,
784 ED_COUNTER_ID_STEP_DELAY_FIX,
785 ED_COUNTER_ID_STEP_DELAY_RND,
786 ED_COUNTER_ID_EXPLOSION_DELAY,
787 ED_COUNTER_ID_IGNITION_DELAY,
788 ED_COUNTER_ID_GROUP_CONTENT,
789 ED_COUNTER_ID_CHANGE_DELAY_FIX,
790 ED_COUNTER_ID_CHANGE_DELAY_RND,
791 ED_COUNTER_ID_CHANGE_CONT_RND,
793 ED_NUM_COUNTERBUTTONS
796 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
797 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
798 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
799 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
800 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
801 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
803 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
804 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
805 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
806 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
807 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
808 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
810 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
811 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
813 // values for scrollbutton gadgets
816 ED_SCROLLBUTTON_ID_AREA_UP,
817 ED_SCROLLBUTTON_ID_AREA_DOWN,
818 ED_SCROLLBUTTON_ID_AREA_LEFT,
819 ED_SCROLLBUTTON_ID_AREA_RIGHT,
820 ED_SCROLLBUTTON_ID_LIST_UP,
821 ED_SCROLLBUTTON_ID_LIST_DOWN,
826 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
827 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
829 // values for scrollbar gadgets
832 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
833 ED_SCROLLBAR_ID_AREA_VERTICAL,
834 ED_SCROLLBAR_ID_LIST_VERTICAL,
839 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
840 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
842 // values for text input gadgets
845 ED_TEXTINPUT_ID_LEVEL_NAME,
846 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
847 ED_TEXTINPUT_ID_LEVELSET_NAME,
848 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
849 ED_TEXTINPUT_ID_ELEMENT_NAME,
854 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
855 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
857 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
858 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
860 // values for text area gadgets
863 ED_TEXTAREA_ID_ENVELOPE_INFO,
868 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
869 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
871 // values for selectbox gadgets
874 ED_SELECTBOX_ID_TIME_OR_STEPS,
875 ED_SELECTBOX_ID_TIME_SCORE_BASE,
876 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
877 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
878 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
879 ED_SELECTBOX_ID_WIND_DIRECTION,
880 ED_SELECTBOX_ID_PLAYER_SPEED,
881 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
882 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
883 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
884 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
885 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
886 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
887 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
888 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
889 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
890 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
891 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
892 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
893 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
894 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
895 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
896 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
897 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
898 ED_SELECTBOX_ID_CHANGE_SIDE,
899 ED_SELECTBOX_ID_CHANGE_PLAYER,
900 ED_SELECTBOX_ID_CHANGE_PAGE,
901 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
902 ED_SELECTBOX_ID_ACTION_TYPE,
903 ED_SELECTBOX_ID_ACTION_MODE,
904 ED_SELECTBOX_ID_ACTION_ARG,
905 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
906 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
911 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
912 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
914 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
915 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
917 #define ED_SELECTBOX_ID_ENGINE_FIRST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
918 #define ED_SELECTBOX_ID_ENGINE_LAST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
920 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
921 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
922 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
923 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
924 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
925 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
927 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
928 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
930 // values for textbutton gadgets
933 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
934 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
935 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
936 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
937 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
938 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
939 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
940 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
941 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
942 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
943 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
944 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
945 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
946 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
951 #define ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
952 #define ED_TAB_BUTTON_ID_LEVELCONFIG_LAST ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
954 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
955 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
957 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
958 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
960 // values for graphicbutton gadgets
963 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
964 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
965 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
966 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
968 ED_NUM_GRAPHICBUTTONS
971 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
972 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
974 // values for checkbutton gadgets
977 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
978 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
979 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
980 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
981 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
982 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
983 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
984 ED_CHECKBUTTON_ID_BD_INTERMISSION,
985 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
986 ED_CHECKBUTTON_ID_STICK_ELEMENT,
987 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
988 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
989 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
990 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
991 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
992 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
993 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
994 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
995 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
996 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
997 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
998 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
999 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
1000 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
1001 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
1002 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
1003 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
1004 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
1005 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
1006 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
1007 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
1008 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
1009 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
1010 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
1011 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
1012 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
1013 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
1014 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
1015 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
1016 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
1017 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
1018 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
1019 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
1020 ED_CHECKBUTTON_ID_MM_LASER_RED,
1021 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
1022 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1023 ED_CHECKBUTTON_ID_DF_LASER_RED,
1024 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1025 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1026 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
1027 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
1028 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1029 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1030 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1031 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1032 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1033 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1034 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1035 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1036 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1037 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1038 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1039 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1040 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1041 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1042 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1043 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1044 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1045 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1046 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1047 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1048 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1049 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1050 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1051 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1052 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1057 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1058 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1060 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1061 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1063 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1064 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1066 #define ED_CHECKBUTTON_ID_ENGINE_FIRST ED_CHECKBUTTON_ID_BD_INTERMISSION
1067 #define ED_CHECKBUTTON_ID_ENGINE_LAST ED_CHECKBUTTON_ID_BD_PAL_TIMING
1069 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1070 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1071 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1072 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1073 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1074 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1076 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1077 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1079 // values for radiobutton gadgets
1082 ED_RADIOBUTTON_ID_PERCENTAGE,
1083 ED_RADIOBUTTON_ID_QUANTITY,
1088 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1089 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1091 // values for drawing area gadgets
1094 ED_DRAWING_ID_DRAWING_LEVEL,
1095 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1096 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1097 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1098 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1099 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1100 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1101 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1102 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1103 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1104 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1105 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1106 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1107 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1108 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1109 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1110 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1111 ED_DRAWING_ID_ANDROID_CONTENT,
1112 ED_DRAWING_ID_AMOEBA_CONTENT,
1113 ED_DRAWING_ID_START_ELEMENT,
1114 ED_DRAWING_ID_ARTWORK_ELEMENT,
1115 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1116 ED_DRAWING_ID_INVENTORY_CONTENT,
1117 ED_DRAWING_ID_MM_BALL_CONTENT,
1118 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1119 ED_DRAWING_ID_CUSTOM_CONTENT,
1120 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1121 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1122 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1123 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1124 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1125 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1126 ED_DRAWING_ID_GROUP_CONTENT,
1127 ED_DRAWING_ID_RANDOM_BACKGROUND,
1129 ED_NUM_DRAWING_AREAS
1132 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1133 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1136 // ----------------------------------------------------------------------------
1137 // some internally used definitions
1138 // ----------------------------------------------------------------------------
1140 // values for CopyLevelToUndoBuffer()
1141 #define UNDO_IMMEDIATE 0
1142 #define UNDO_ACCUMULATE 1
1144 // values for scrollbars
1145 #define ED_SCROLL_NO 0
1146 #define ED_SCROLL_LEFT 1
1147 #define ED_SCROLL_RIGHT 2
1148 #define ED_SCROLL_UP 4
1149 #define ED_SCROLL_DOWN 8
1151 // screens in the level editor
1152 #define ED_MODE_DRAWING 0
1153 #define ED_MODE_LEVELCONFIG 1
1154 #define ED_MODE_PROPERTIES 2
1155 #define ED_MODE_PALETTE 3
1157 // sub-screens in the global settings section
1158 #define ED_MODE_LEVELCONFIG_LEVEL ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
1159 #define ED_MODE_LEVELCONFIG_LEVELSET ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET
1160 #define ED_MODE_LEVELCONFIG_EDITOR ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
1161 #define ED_MODE_LEVELCONFIG_ENGINE ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
1163 // sub-screens in the element properties section
1164 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1165 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1166 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1167 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1168 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1170 // how many steps can be cancelled
1171 #define NUM_UNDO_STEPS (64 + 1)
1173 // values for elements with score for certain actions
1175 #define MAX_SCORE 999
1177 // values for elements with count for collecting
1178 #define MIN_COLLECT_COUNT 0
1179 #define MAX_COLLECT_COUNT 999
1181 // values for random placement
1182 #define RANDOM_USE_PERCENTAGE 0
1183 #define RANDOM_USE_QUANTITY 1
1185 // values for level set save mode
1186 #define LEVELSET_SAVE_MODE_UPDATE 0
1187 #define LEVELSET_SAVE_MODE_CREATE 1
1189 // default value for element tile size in drawing area
1190 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1191 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1194 // ----------------------------------------------------------------------------
1195 // some internally used data structure definitions
1196 // ----------------------------------------------------------------------------
1202 struct XYTileSize *pos;
1206 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1208 // note: some additional characters are already reserved for "cheat mode"
1209 // shortcuts (":XYZ" style) -- for details, see "events.c"
1211 // ---------- toolbox control buttons ---------------------------------------
1214 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1215 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1216 "draw single items", 's'
1219 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1220 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1221 "draw connected items", 'd'
1224 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1225 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1229 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1230 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1234 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1235 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1236 "draw outline rectangles", 'r'
1239 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1240 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1241 "draw filled rectangles", 'R'
1244 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1245 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1246 "wrap (rotate) level up", 0
1249 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1250 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1251 "enter text elements", 't'
1254 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1255 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1259 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1260 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1261 "wrap (rotate) level left", 0
1264 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1265 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1266 "zoom level tile size", '+'
1269 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1270 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1271 "wrap (rotate) level right", 0
1274 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1275 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1276 "random element placement", 0
1279 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1280 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1284 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1285 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1286 "wrap (rotate) level down", 0
1289 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1290 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1291 "pick drawing element", ','
1294 // ---------- level control buttons -----------------------------------------
1297 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1298 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1299 "undo/redo last operation", 'u'
1302 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_CONF,
1303 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1304 "level and editor settings", 'I'
1307 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1308 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1312 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1313 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1317 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1318 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1322 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1323 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1324 "exit level editor", 'E'
1327 // ---------- CE and GE control buttons -------------------------------------
1330 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1331 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1332 "copy settings from other element", 0
1335 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1336 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1337 "copy settings to other element", 0
1340 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1341 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1342 "exchange element with other element", 0
1345 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1346 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1347 "copy settings from this element", 0
1350 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1351 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1352 "paste settings to this element", 0
1355 // ---------- palette control buttons ---------------------------------------
1358 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1359 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1360 "properties of drawing element", 'p'
1363 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1364 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1365 "properties of drawing element 1", '1'
1368 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1369 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1370 "properties of drawing element 2", '2'
1373 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1374 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1375 "properties of drawing element 3", '3'
1378 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1379 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1380 "show list of elements", 'e'
1384 static int random_placement_value = 10;
1385 static int random_placement_method = RANDOM_USE_QUANTITY;
1386 static int random_placement_background_element = EL_SAND;
1387 static boolean random_placement_background_restricted = FALSE;
1388 static boolean stick_element_properties_window = FALSE;
1389 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1390 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1391 static struct ElementChangeInfo custom_element_change;
1392 static struct ElementGroupInfo group_element_info;
1393 static struct ElementInfo custom_element;
1395 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1396 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1397 static int levelset_num_levels = 100;
1398 static boolean levelset_use_levelset_artwork = FALSE;
1399 static boolean levelset_copy_level_template = FALSE;
1400 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1406 int min_value, max_value;
1407 int gadget_id_down, gadget_id_up;
1409 int gadget_id_align;
1411 char *text_above, *text_left, *text_right;
1412 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1414 // ---------- current level number ------------------------------------------
1417 ED_COUNTER_ID_SELECT_LEVEL,
1418 -1, -1, // these values are not constant, but can change at runtime
1420 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1421 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1426 // ---------- level and editor settings -------------------------------------
1429 ED_COUNTER_ID_LEVEL_XSIZE,
1430 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1431 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1432 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1433 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1435 "playfield size:", NULL, "width",
1438 ED_COUNTER_ID_LEVEL_YSIZE,
1439 -1, ED_LEVEL_SETTINGS_YPOS(4),
1440 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1441 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1442 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1444 NULL, " ", "height",
1447 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
1448 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1450 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1451 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1453 NULL, "number of gems to collect:", NULL
1456 ED_COUNTER_ID_LEVEL_TIMELIMIT,
1457 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1459 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1460 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1462 "time or step limit to solve level:", NULL, NULL
1465 ED_COUNTER_ID_LEVEL_TIMESCORE,
1466 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1468 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1469 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1470 &level.score[SC_TIME_BONUS],
1471 "score for time or steps left:", NULL, NULL
1474 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
1475 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1477 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1478 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1480 NULL, "random seed:", "(0 => random)"
1483 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
1484 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1486 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1487 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1488 &levelset_num_levels,
1489 "number of levels:", NULL, NULL,
1492 ED_COUNTER_ID_LEVEL_RANDOM,
1493 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1495 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1496 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1497 &random_placement_value,
1498 "random element placement:", NULL, "in"
1501 ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
1502 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3),
1504 GADGET_ID_BD_CYCLE_DELAY_MS_DOWN, GADGET_ID_BD_CYCLE_DELAY_MS_UP,
1505 GADGET_ID_BD_CYCLE_DELAY_MS_TEXT, GADGET_ID_NONE,
1506 &level.bd_cycle_delay_ms,
1507 NULL, NULL, "game cycle delay (ms)"
1510 ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
1511 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3),
1513 GADGET_ID_BD_CYCLE_DELAY_C64_DOWN, GADGET_ID_BD_CYCLE_DELAY_C64_UP,
1514 GADGET_ID_BD_CYCLE_DELAY_C64_TEXT, GADGET_ID_NONE,
1515 &level.bd_cycle_delay_c64,
1516 NULL, NULL, "game cycle delay (C64-style)"
1519 // ---------- element settings: configure (various elements) ----------------
1522 ED_COUNTER_ID_ELEMENT_VALUE1,
1523 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1524 MIN_SCORE, MAX_SCORE,
1525 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1526 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1527 NULL, // will be set when used
1531 ED_COUNTER_ID_ELEMENT_VALUE2,
1532 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1533 MIN_SCORE, MAX_SCORE,
1534 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1535 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1536 NULL, // will be set when used
1540 ED_COUNTER_ID_ELEMENT_VALUE3,
1541 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1542 MIN_SCORE, MAX_SCORE,
1543 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1544 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1545 NULL, // will be set when used
1549 ED_COUNTER_ID_ELEMENT_VALUE4,
1550 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1551 MIN_SCORE, MAX_SCORE,
1552 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1553 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1554 NULL, // will be set when used
1558 ED_COUNTER_ID_YAMYAM_CONTENT,
1559 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1560 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1561 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1562 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1563 &level.num_yamyam_contents,
1564 NULL, NULL, "number of content areas"
1567 ED_COUNTER_ID_BALL_CONTENT,
1568 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1569 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1570 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1571 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1572 &level.num_ball_contents,
1573 NULL, NULL, "number of content areas"
1576 ED_COUNTER_ID_ANDROID_CONTENT,
1577 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1578 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1579 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1580 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1581 &level.num_android_clone_elements,
1582 NULL, NULL, "number of clonable elements"
1585 ED_COUNTER_ID_ENVELOPE_XSIZE,
1586 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1587 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1588 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1589 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1590 NULL, // will be set when used
1591 NULL, NULL, "width",
1594 ED_COUNTER_ID_ENVELOPE_YSIZE,
1595 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1596 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1597 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1598 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1599 NULL, // will be set when used
1600 NULL, " ", "height",
1603 ED_COUNTER_ID_INVENTORY_SIZE,
1604 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1605 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1606 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1607 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1608 &level.initial_inventory_size[0],
1609 NULL, NULL, "number of inventory elements"
1612 ED_COUNTER_ID_MM_BALL_CONTENT,
1613 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1614 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1615 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1616 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1617 &level.num_mm_ball_contents,
1618 NULL, NULL, "number of content elements"
1621 // ---------- element settings: configure 1 (custom elements) ---------------
1624 ED_COUNTER_ID_CUSTOM_SCORE,
1625 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1626 MIN_SCORE, MAX_SCORE,
1627 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1628 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1629 &custom_element.collect_score_initial,
1630 NULL, "CE score", " "
1633 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
1634 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1635 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1636 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1637 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1638 &custom_element.collect_count_initial,
1639 NULL, "CE count", NULL
1642 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
1643 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1645 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1646 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1647 &custom_element.ce_value_fixed_initial,
1648 NULL, "CE value", NULL
1651 ED_COUNTER_ID_CUSTOM_VALUE_RND,
1652 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1654 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1655 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1656 &custom_element.ce_value_random_initial,
1657 NULL, "+random", NULL
1660 ED_COUNTER_ID_PUSH_DELAY_FIX,
1661 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1663 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1664 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1665 &custom_element.push_delay_fixed,
1666 NULL, "push delay", NULL
1669 ED_COUNTER_ID_PUSH_DELAY_RND,
1670 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1672 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1673 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1674 &custom_element.push_delay_random,
1675 NULL, "+random", NULL
1678 ED_COUNTER_ID_DROP_DELAY_FIX,
1679 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1681 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1682 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1683 &custom_element.drop_delay_fixed,
1684 NULL, "drop delay", NULL
1687 ED_COUNTER_ID_DROP_DELAY_RND,
1688 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1690 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1691 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1692 &custom_element.drop_delay_random,
1693 NULL, "+random", NULL
1696 // ---------- element settings: configure 2 (custom elements) ---------------
1699 ED_COUNTER_ID_MOVE_DELAY_FIX,
1700 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1702 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1703 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1704 &custom_element.move_delay_fixed,
1705 NULL, "move delay", NULL
1708 ED_COUNTER_ID_MOVE_DELAY_RND,
1709 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1711 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1712 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1713 &custom_element.move_delay_random,
1714 NULL, "+random", NULL
1717 ED_COUNTER_ID_STEP_DELAY_FIX,
1718 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1720 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1721 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1722 &custom_element.step_delay_fixed,
1723 NULL, "step delay", NULL
1726 ED_COUNTER_ID_STEP_DELAY_RND,
1727 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1729 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1730 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1731 &custom_element.step_delay_random,
1732 NULL, "+random", NULL
1735 ED_COUNTER_ID_EXPLOSION_DELAY,
1736 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1738 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1739 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1740 &custom_element.explosion_delay,
1741 NULL, "explosion delay", NULL
1744 ED_COUNTER_ID_IGNITION_DELAY,
1745 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1747 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1748 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1749 &custom_element.ignition_delay,
1750 NULL, "ignition delay", "(by fire)"
1753 // ---------- element settings: configure (group elements) ------------------
1756 ED_COUNTER_ID_GROUP_CONTENT,
1757 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1758 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1759 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1760 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1761 &group_element_info.num_elements,
1762 NULL, NULL, "number of elements in group"
1765 // ---------- element settings: advanced (custom elements) ------------------
1768 ED_COUNTER_ID_CHANGE_DELAY_FIX,
1769 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1771 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1772 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1773 &custom_element_change.delay_fixed,
1774 NULL, "CE delay", NULL,
1777 ED_COUNTER_ID_CHANGE_DELAY_RND,
1778 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1780 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1781 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1782 &custom_element_change.delay_random,
1783 NULL, "+random", NULL
1786 ED_COUNTER_ID_CHANGE_CONT_RND,
1787 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1789 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1790 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1791 &custom_element_change.random_percentage,
1792 NULL, "use random replace:", "%"
1803 char *text_above, *infotext;
1804 } textinput_info[ED_NUM_TEXTINPUT] =
1807 ED_TEXTINPUT_ID_LEVEL_NAME,
1808 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1809 GADGET_ID_LEVEL_NAME,
1812 "Title:", "Title for this level"
1815 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
1816 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1817 GADGET_ID_LEVEL_AUTHOR,
1818 MAX_LEVEL_AUTHOR_LEN,
1820 "Author:", "Author for this level"
1823 ED_TEXTINPUT_ID_LEVELSET_NAME,
1824 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1825 GADGET_ID_LEVELSET_NAME,
1828 "Title:", "Title for this or new level set"
1831 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
1832 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1833 GADGET_ID_LEVELSET_AUTHOR,
1834 MAX_LEVEL_AUTHOR_LEN,
1836 "Author:", "Author for this or new level set"
1839 ED_TEXTINPUT_ID_ELEMENT_NAME,
1840 -1, -1, // these values are not constant, but can change at runtime
1841 GADGET_ID_ELEMENT_NAME,
1842 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1843 custom_element.description,
1844 NULL, "Element name"
1855 char *text_above, *text_above_cropped, *infotext;
1856 } textarea_info[ED_NUM_TEXTAREAS] =
1859 ED_TEXTAREA_ID_ENVELOPE_INFO,
1860 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1861 GADGET_ID_ENVELOPE_INFO,
1862 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1864 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1868 static struct ValueTextInfo options_time_or_steps[] =
1876 static struct ValueTextInfo options_time_score_base[] =
1878 { 1, "per second/step" },
1879 { 10, "per 10 seconds/steps" },
1884 static struct ValueTextInfo options_game_engine_type[] =
1886 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1887 { GAME_ENGINE_TYPE_BD, "Boulder Dash" },
1888 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1889 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1890 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1895 static struct ValueTextInfo options_levelset_save_mode[] =
1897 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1898 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1903 static struct ValueTextInfo options_wind_direction[] =
1905 { MV_START_NONE, "none" },
1906 { MV_START_LEFT, "left" },
1907 { MV_START_RIGHT, "right" },
1908 { MV_START_UP, "up" },
1909 { MV_START_DOWN, "down" },
1914 static struct ValueTextInfo options_player_speed[] =
1921 { 16, "very fast" },
1922 { 32, "ultrafast" },
1927 static struct ValueTextInfo options_access_type[] =
1929 { EP_WALKABLE, "walkable" },
1930 { EP_PASSABLE, "passable" },
1935 static struct ValueTextInfo options_access_layer[] =
1937 { EP_ACCESSIBLE_OVER, "over" },
1938 { EP_ACCESSIBLE_INSIDE, "inside" },
1939 { EP_ACCESSIBLE_UNDER, "under" },
1944 static struct ValueTextInfo options_access_protected[] =
1946 { 0, "unprotected" },
1952 static struct ValueTextInfo options_access_direction[] =
1954 { MV_NO_DIRECTION, "no direction" },
1955 { MV_LEFT, "left" },
1956 { MV_RIGHT, "right" },
1958 { MV_DOWN, "down" },
1959 { MV_LEFT | MV_UP, "left + up" },
1960 { MV_LEFT | MV_DOWN, "left + down" },
1961 { MV_RIGHT | MV_UP, "right + up" },
1962 { MV_RIGHT | MV_DOWN, "right + down" },
1963 { MV_HORIZONTAL, "horizontal" },
1964 { MV_VERTICAL, "vertical" },
1965 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1966 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1967 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1968 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1969 { MV_ALL_DIRECTIONS, "all directions" },
1974 static struct ValueTextInfo options_walk_to_action[] =
1976 { EP_DIGGABLE, "diggable" },
1977 { EP_COLLECTIBLE_ONLY, "collectible" },
1978 { EP_DROPPABLE, "collectible & droppable" },
1979 { EP_THROWABLE, "collectible & throwable" },
1980 { EP_PUSHABLE, "pushable" },
1985 static struct ValueTextInfo options_move_pattern[] =
1987 { MV_LEFT, "left" },
1988 { MV_RIGHT, "right" },
1990 { MV_DOWN, "down" },
1991 { MV_HORIZONTAL, "horizontal" },
1992 { MV_VERTICAL, "vertical" },
1993 { MV_ALL_DIRECTIONS, "all directions" },
1994 { MV_WIND_DIRECTION, "wind direction" },
1995 { MV_TOWARDS_PLAYER, "towards player" },
1996 { MV_AWAY_FROM_PLAYER, "away from player" },
1997 { MV_ALONG_LEFT_SIDE, "along left side" },
1998 { MV_ALONG_RIGHT_SIDE, "along right side" },
1999 { MV_TURNING_LEFT, "turning left" },
2000 { MV_TURNING_RIGHT, "turning right" },
2001 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
2002 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
2003 { MV_TURNING_RANDOM, "turning random" },
2004 { MV_MAZE_RUNNER, "maze runner style" },
2005 { MV_MAZE_HUNTER, "maze hunter style" },
2006 { MV_WHEN_PUSHED, "when pushed" },
2007 { MV_WHEN_DROPPED, "when dropped/thrown" },
2012 static struct ValueTextInfo options_move_direction[] =
2014 { MV_START_AUTOMATIC, "automatic" },
2015 { MV_START_LEFT, "left" },
2016 { MV_START_RIGHT, "right" },
2017 { MV_START_UP, "up" },
2018 { MV_START_DOWN, "down" },
2019 { MV_START_RANDOM, "random" },
2020 { MV_START_PREVIOUS, "previous" },
2025 static struct ValueTextInfo options_move_stepsize[] =
2027 { 0, "not moving" },
2032 { 16, "very fast" },
2033 { 32, "even faster" },
2038 static struct ValueTextInfo options_move_leave_type[] =
2040 { LEAVE_TYPE_UNLIMITED, "leave behind" },
2041 { LEAVE_TYPE_LIMITED, "change it to" },
2046 static struct ValueTextInfo options_smash_targets[] =
2048 { EP_CAN_SMASH_PLAYER, "player" },
2050 { EP_CAN_SMASH_ENEMIES, "enemies" },
2052 { EP_CAN_SMASH_EVERYTHING, "everything" },
2057 static struct ValueTextInfo options_slippery_type[] =
2059 { SLIPPERY_ANY_RANDOM, "random" },
2060 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
2061 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
2062 { SLIPPERY_ONLY_LEFT, "only left" },
2063 { SLIPPERY_ONLY_RIGHT, "only right" },
2068 static struct ValueTextInfo options_deadliness[] =
2070 { EP_DONT_RUN_INTO, "running into" },
2071 { EP_DONT_COLLIDE_WITH, "colliding with" },
2072 { EP_DONT_GET_HIT_BY, "getting hit by" },
2073 { EP_DONT_TOUCH, "touching" },
2078 static struct ValueTextInfo options_explosion_type[] =
2080 { EXPLODES_3X3, "3x3" },
2081 { EXPLODES_CROSS, "3+3" },
2082 { EXPLODES_1X1, "1x1" },
2087 static struct ValueTextInfo options_time_units[] =
2090 { FRAMES_PER_SECOND, "seconds" },
2095 static struct ValueTextInfo options_change_direct_action[] =
2097 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2098 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2099 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2100 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2101 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2102 { CE_ENTERED_BY_PLAYER, "entered by player" },
2103 { CE_LEFT_BY_PLAYER, "left by player" },
2104 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2105 { CE_SWITCHED, "switched" },
2106 { CE_HITTING_SOMETHING, "hitting something" },
2107 { CE_HIT_BY_SOMETHING, "hit by something" },
2109 { CE_BLOCKED, "blocked" },
2111 { CE_IMPACT, "impact (on something)" },
2112 { CE_SMASHED, "smashed (from above)" },
2114 { CE_VALUE_CHANGES, "CE value changes" },
2115 { CE_SCORE_CHANGES, "CE score changes" },
2117 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2118 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2119 { CE_UNDEFINED, " " },
2120 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2121 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2122 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2123 { CE_UNDEFINED, " " },
2124 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2125 { CE_NEXT_TO_PLAYER, "next to player" },
2130 static struct ValueTextInfo options_change_other_action[] =
2132 { CE_PLAYER_TOUCHES_X, "player touches" },
2133 { CE_PLAYER_PRESSES_X, "player presses" },
2134 { CE_PLAYER_SWITCHES_X, "player switches" },
2135 { CE_PLAYER_SNAPS_X, "player snaps" },
2136 { CE_PLAYER_PUSHES_X, "player pushes" },
2137 { CE_PLAYER_ENTERS_X, "player enters" },
2138 { CE_PLAYER_LEAVES_X, "player leaves" },
2139 { CE_PLAYER_DIGS_X, "player digs" },
2140 { CE_PLAYER_COLLECTS_X, "player collects" },
2141 { CE_PLAYER_DROPS_X, "player drops/throws" },
2142 { CE_TOUCHING_X, "touching" },
2143 { CE_HITTING_X, "hitting" },
2144 { CE_DIGGING_X, "digging" },
2145 { CE_HIT_BY_X, "hit by" },
2146 { CE_SWITCH_OF_X, "switch of" },
2147 { CE_CHANGE_OF_X, "change by page of" },
2148 { CE_EXPLOSION_OF_X, "explosion of" },
2149 { CE_MOVE_OF_X, "move of" },
2150 { CE_CREATION_OF_X, "creation of" },
2151 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2152 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2153 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2154 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2155 { CE_UNDEFINED, " " },
2156 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2157 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2158 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2159 { CE_UNDEFINED, " " },
2160 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2161 { CE_PLAYER_NEXT_TO_X, "player next to" },
2162 { CE_NEXT_TO_X, "next to" },
2167 static struct ValueTextInfo options_change_trigger_side[] =
2169 { CH_SIDE_LEFT, "left" },
2170 { CH_SIDE_RIGHT, "right" },
2171 { CH_SIDE_TOP, "top" },
2172 { CH_SIDE_BOTTOM, "bottom" },
2173 { CH_SIDE_LEFT_RIGHT, "left/right" },
2174 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2175 { CH_SIDE_ANY, "any" },
2180 static struct ValueTextInfo options_change_trigger_player[] =
2182 { CH_PLAYER_1, "1" },
2183 { CH_PLAYER_2, "2" },
2184 { CH_PLAYER_3, "3" },
2185 { CH_PLAYER_4, "4" },
2186 { CH_PLAYER_ANY, "any" },
2191 static struct ValueTextInfo options_change_trigger_page[] =
2202 { (1u << 9), "10" },
2203 { (1u << 10), "11" },
2204 { (1u << 11), "12" },
2205 { (1u << 12), "13" },
2206 { (1u << 13), "14" },
2207 { (1u << 14), "15" },
2208 { (1u << 15), "16" },
2209 { (1u << 16), "17" },
2210 { (1u << 17), "18" },
2211 { (1u << 18), "19" },
2212 { (1u << 19), "20" },
2213 { (1u << 20), "21" },
2214 { (1u << 21), "22" },
2215 { (1u << 22), "23" },
2216 { (1u << 23), "24" },
2217 { (1u << 24), "25" },
2218 { (1u << 25), "26" },
2219 { (1u << 26), "27" },
2220 { (1u << 27), "28" },
2221 { (1u << 28), "29" },
2222 { (1u << 29), "30" },
2223 { (1u << 30), "31" },
2224 { (1u << 31), "32" },
2225 { CH_PAGE_ANY, "any" },
2230 static struct ValueTextInfo options_change_replace_when[] =
2232 { CP_WHEN_EMPTY, "empty" },
2233 { CP_WHEN_WALKABLE, "walkable" },
2234 { CP_WHEN_DIGGABLE, "diggable" },
2235 { CP_WHEN_COLLECTIBLE, "collectible" },
2236 { CP_WHEN_REMOVABLE, "removable" },
2237 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2242 static struct ValueTextInfo options_action_type[] =
2244 { CA_NO_ACTION, "no action" },
2245 { CA_UNDEFINED, " " },
2246 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2247 { CA_RESTART_LEVEL, "restart level" },
2248 { CA_SHOW_ENVELOPE, "show envelope" },
2249 { CA_SET_LEVEL_TIME, "set time" },
2250 { CA_SET_LEVEL_SCORE, "set score" },
2251 { CA_SET_LEVEL_GEMS, "set gems" },
2252 { CA_SET_LEVEL_WIND, "set wind dir." },
2253 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2254 { CA_UNDEFINED, " " },
2255 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2256 { CA_MOVE_PLAYER, "move player" },
2257 { CA_MOVE_PLAYER_NEW, "move player new" },
2258 { CA_EXIT_PLAYER, "exit player" },
2259 { CA_KILL_PLAYER, "kill player" },
2260 { CA_SET_PLAYER_KEYS, "set keys" },
2261 { CA_SET_PLAYER_SPEED, "set speed" },
2262 { CA_SET_PLAYER_SHIELD, "set shield" },
2263 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2264 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2265 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2266 { CA_UNDEFINED, " " },
2267 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2268 { CA_SET_CE_VALUE, "set CE value" },
2269 { CA_SET_CE_SCORE, "set CE score" },
2270 { CA_SET_CE_ARTWORK, "set CE artwork" },
2271 { CA_UNDEFINED, " " },
2272 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2273 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2278 static struct ValueTextInfo options_action_mode_none[] =
2280 { CA_MODE_UNDEFINED, " " },
2285 static struct ValueTextInfo options_action_mode_assign[] =
2287 { CA_MODE_SET, "=" },
2292 static struct ValueTextInfo options_action_mode_add_remove[] =
2294 { CA_MODE_ADD, "+" },
2295 { CA_MODE_SUBTRACT, "-" },
2300 static struct ValueTextInfo options_action_mode_calculate[] =
2302 { CA_MODE_SET, "=" },
2303 { CA_MODE_ADD, "+" },
2304 { CA_MODE_SUBTRACT, "-" },
2305 { CA_MODE_MULTIPLY, "*" },
2306 { CA_MODE_DIVIDE, "/" },
2307 { CA_MODE_MODULO, "%" },
2312 static struct ValueTextInfo options_action_arg_none[] =
2314 { CA_ARG_UNDEFINED, " " },
2319 static struct ValueTextInfo options_action_arg_player[] =
2321 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2322 { CA_ARG_PLAYER_1, "1" },
2323 { CA_ARG_PLAYER_2, "2" },
2324 { CA_ARG_PLAYER_3, "3" },
2325 { CA_ARG_PLAYER_4, "4" },
2326 { CA_ARG_PLAYER_ANY, "any" },
2327 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2328 { CA_ARG_PLAYER_ACTION, "action ->" },
2333 static struct ValueTextInfo options_action_arg_number[] =
2335 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2342 { CA_ARG_10, "10" },
2343 { CA_ARG_100, "100" },
2344 { CA_ARG_1000, "1000" },
2345 { CA_ARG_UNDEFINED, " " },
2346 { CA_ARG_NUMBER_MIN, "min" },
2347 { CA_ARG_NUMBER_MAX, "max" },
2348 { CA_ARG_UNDEFINED, " " },
2349 { CA_ARG_NUMBER_RESET, "reset" },
2350 { CA_ARG_UNDEFINED, " " },
2351 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2352 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2353 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2354 { CA_ARG_UNDEFINED, " " },
2355 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2356 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2357 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2358 { CA_ARG_UNDEFINED, " " },
2359 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2360 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2361 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2362 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2363 { CA_ARG_UNDEFINED, " " },
2364 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2365 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2366 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2367 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2372 static struct ValueTextInfo options_action_arg_value[] =
2374 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2381 { CA_ARG_10, "10" },
2382 { CA_ARG_100, "100" },
2383 { CA_ARG_1000, "1000" },
2384 { CA_ARG_UNDEFINED, " " },
2385 { CA_ARG_NUMBER_MIN, "min" },
2386 { CA_ARG_NUMBER_MAX, "max" },
2387 { CA_ARG_UNDEFINED, " " },
2388 { CA_ARG_NUMBER_RESET, "reset" },
2389 { CA_ARG_UNDEFINED, " " },
2390 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2391 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2392 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2393 { CA_ARG_UNDEFINED, " " },
2394 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2395 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2396 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2397 { CA_ARG_UNDEFINED, " " },
2398 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2399 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2400 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2401 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2402 { CA_ARG_UNDEFINED, " " },
2403 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2404 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2405 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2406 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2407 { CA_ARG_UNDEFINED, " " },
2408 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2409 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2410 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2411 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2416 static struct ValueTextInfo options_action_arg_envelope[] =
2418 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2423 { CA_ARG_UNDEFINED, " " },
2424 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2425 { CA_ARG_ELEMENT_TARGET, "target" },
2426 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2427 { CA_ARG_ELEMENT_ACTION, "action ->" },
2432 static struct ValueTextInfo options_action_arg_key[] =
2434 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2443 { CA_ARG_UNDEFINED, " " },
2444 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2445 { CA_ARG_ELEMENT_TARGET, "target" },
2446 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2447 { CA_ARG_ELEMENT_ACTION, "action ->" },
2452 static struct ValueTextInfo options_action_arg_speed[] =
2454 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2455 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2456 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2457 { CA_ARG_SPEED_SLOW, "slow" },
2458 { CA_ARG_SPEED_NORMAL, "normal" },
2459 { CA_ARG_SPEED_FAST, "fast" },
2460 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2461 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2462 { CA_ARG_UNDEFINED, " " },
2463 { CA_ARG_SPEED_SLOWER, "slower" },
2464 { CA_ARG_SPEED_FASTER, "faster" },
2465 { CA_ARG_UNDEFINED, " " },
2466 { CA_ARG_SPEED_RESET, "reset" },
2471 static struct ValueTextInfo options_action_arg_shield[] =
2473 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2474 { CA_ARG_SHIELD_OFF, "off" },
2475 { CA_ARG_SHIELD_NORMAL, "normal" },
2476 { CA_ARG_SHIELD_DEADLY, "deadly" },
2481 static struct ValueTextInfo options_action_arg_artwork[] =
2483 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2484 { CA_ARG_ELEMENT_TARGET, "target" },
2485 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2486 { CA_ARG_ELEMENT_ACTION, "action ->" },
2487 { CA_ARG_UNDEFINED, " " },
2488 { CA_ARG_ELEMENT_RESET, "reset" },
2493 static struct ValueTextInfo options_action_arg_gravity[] =
2495 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2496 { CA_ARG_GRAVITY_ON, "on" },
2497 { CA_ARG_GRAVITY_OFF, "off" },
2498 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2503 static struct ValueTextInfo options_action_arg_direction[] =
2505 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2506 { CA_ARG_DIRECTION_NONE, "none" },
2507 { CA_ARG_DIRECTION_LEFT, "left" },
2508 { CA_ARG_DIRECTION_RIGHT, "right" },
2509 { CA_ARG_DIRECTION_UP, "up" },
2510 { CA_ARG_DIRECTION_DOWN, "down" },
2511 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2512 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2517 static struct ValueTextInfo options_action_arg_scan_mode[] =
2519 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2520 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2521 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2526 static struct ValueTextInfo options_action_arg_inventory[] =
2528 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2529 { CA_ARG_ELEMENT_TARGET, "+ target" },
2530 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2531 { CA_ARG_ELEMENT_ACTION, "+ action" },
2532 { CA_ARG_UNDEFINED, " " },
2533 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2534 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2535 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2536 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2537 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2538 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2539 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2540 { CA_ARG_UNDEFINED, " " },
2541 { CA_ARG_INVENTORY_RESET, "reset" },
2546 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2547 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2552 static struct ValueTextInfo options_group_choice_mode[] =
2554 { ANIM_RANDOM, "random" },
2555 { ANIM_LOOP, "loop" },
2556 { ANIM_LINEAR, "linear" },
2557 { ANIM_PINGPONG, "pingpong" },
2558 { ANIM_PINGPONG2, "pingpong 2" },
2559 { ANIM_LEVEL_NR, "level number" },
2564 static struct ValueTextInfo options_bd_scheduling_type[] =
2566 { GD_SCHEDULING_MILLISECONDS, "Milliseconds" },
2567 { GD_SCHEDULING_BD1, "BD1" },
2568 { GD_SCHEDULING_BD2, "BD2" },
2569 { GD_SCHEDULING_PLCK, "Construction Kit" },
2570 { GD_SCHEDULING_CRDR, "Crazy Dream 7" },
2571 { GD_SCHEDULING_BD1_ATARI, "Atari BD1" },
2572 { GD_SCHEDULING_BD2_PLCK_ATARI, "Atari BD2 / PLCK" },
2577 static struct ValueTextInfo *action_arg_modes[] =
2579 options_action_mode_none,
2580 options_action_mode_assign,
2581 options_action_mode_add_remove,
2582 options_action_mode_calculate,
2589 struct ValueTextInfo *options;
2591 action_arg_options[] =
2593 { CA_NO_ACTION, 0, options_action_arg_none, },
2594 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2595 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2596 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2597 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2598 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2599 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2600 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2601 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2602 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2603 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2604 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2605 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2606 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2607 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2608 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2609 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2610 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2611 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2612 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2613 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2614 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2624 int gadget_id_align;
2625 int size; // char size of selectbox or '-1' (dynamically determined)
2626 struct ValueTextInfo *options;
2628 char *text_above, *text_left, *text_right, *infotext;
2629 } selectbox_info[ED_NUM_SELECTBOX] =
2631 // ---------- level and editor settings -------------------------------------
2634 ED_SELECTBOX_ID_TIME_OR_STEPS,
2635 -1, ED_LEVEL_SETTINGS_YPOS(8),
2636 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2638 options_time_or_steps,
2639 &level.use_step_counter,
2640 NULL, NULL, "(0 => no limit)", "time or step limit"
2643 ED_SELECTBOX_ID_TIME_SCORE_BASE,
2644 -1, ED_LEVEL_SETTINGS_YPOS(10),
2645 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2647 options_time_score_base,
2648 &level.time_score_base,
2649 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2652 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
2653 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2654 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2656 options_game_engine_type,
2657 &level.game_engine_type,
2658 NULL, "game engine:", NULL, "game engine"
2661 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
2662 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2663 GADGET_ID_BD_SCHEDULING_TYPE, GADGET_ID_NONE,
2665 options_bd_scheduling_type,
2666 &level.bd_scheduling_type,
2667 NULL, "scheduling type:", NULL, "level timing"
2670 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
2671 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2672 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2674 options_levelset_save_mode,
2675 &levelset_save_mode,
2676 "Action:", NULL, NULL, "action when saving level set"
2679 // ---------- element settings: configure (several elements) ----------------
2682 ED_SELECTBOX_ID_WIND_DIRECTION,
2683 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2684 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2686 options_wind_direction,
2687 &level.wind_direction_initial,
2688 NULL, "initial wind direction:", NULL, "initial wind direction"
2691 ED_SELECTBOX_ID_PLAYER_SPEED,
2692 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2693 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2695 options_player_speed,
2696 &level.initial_player_stepsize[0],
2697 NULL, "initial player speed:", NULL, "initial player speed"
2700 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
2701 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2702 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2704 options_group_choice_mode,
2705 &level.mm_ball_choice_mode,
2706 NULL, "choice type:", NULL, "type of content choice"
2709 // ---------- element settings: configure 1 (custom elements) ---------------
2712 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
2713 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2714 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2716 options_access_type,
2717 &custom_element.access_type,
2718 NULL, NULL, NULL, "type of access to this field"
2721 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
2722 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2723 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2725 options_access_layer,
2726 &custom_element.access_layer,
2727 NULL, NULL, NULL, "layer of access for this field"
2730 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
2731 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2732 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2734 options_access_protected,
2735 &custom_element.access_protected,
2736 NULL, NULL, NULL, "protected access for this field"
2739 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
2740 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2741 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2743 options_access_direction,
2744 &custom_element.access_direction,
2745 NULL, "from", NULL, "access direction for this field"
2748 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
2749 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2750 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2752 options_walk_to_action,
2753 &custom_element.walk_to_action,
2754 NULL, NULL, NULL, "diggable/collectible/pushable"
2757 // ---------- element settings: configure 2 (custom elements) ---------------
2760 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
2761 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2762 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2764 options_move_pattern,
2765 &custom_element.move_pattern,
2766 NULL, "can move", NULL, "element move pattern"
2769 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
2770 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2771 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2773 options_move_direction,
2774 &custom_element.move_direction_initial,
2775 NULL, "starts moving", NULL, "initial element move direction"
2778 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
2779 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2780 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2782 options_move_stepsize,
2783 &custom_element.move_stepsize,
2784 NULL, "move/fall speed", NULL, "speed of element movement"
2787 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
2788 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2789 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2791 options_move_leave_type,
2792 &custom_element.move_leave_type,
2793 // left text with leading spaces to place gadget next to "can dig" gadget
2794 // (needed because drawing area gadgets created after selectbox gadgets)
2795 // NULL, "can dig: can", ":", "leave behind or change element"
2796 NULL, " can", ":", "leave behind or change element"
2799 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
2800 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2801 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2803 options_smash_targets,
2804 &custom_element.smash_targets,
2805 NULL, "can smash", NULL, "elements that can be smashed"
2808 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
2809 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2810 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2812 options_slippery_type,
2813 &custom_element.slippery_type,
2814 NULL, "slippery", NULL, "where other elements fall down"
2817 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
2818 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2819 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2822 &custom_element.deadliness,
2823 NULL, "deadly when", NULL, "deadliness of element"
2826 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
2827 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2828 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2830 options_explosion_type,
2831 &custom_element.explosion_type,
2832 NULL, "can explode", NULL, "explosion type"
2835 // ---------- element settings: advanced (custom elements) ------------------
2838 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
2839 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2840 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2843 &custom_element_change.delay_frames,
2844 NULL, "delay time given in", NULL, "delay time units for change"
2847 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
2848 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2849 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2851 options_change_direct_action,
2852 &custom_element_change.direct_action,
2853 NULL, NULL, NULL, "type of direct action"
2856 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
2857 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2858 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2860 options_change_other_action,
2861 &custom_element_change.other_action,
2862 NULL, NULL, "element:", "type of other element action"
2865 ED_SELECTBOX_ID_CHANGE_SIDE,
2866 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2867 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2869 options_change_trigger_side,
2870 &custom_element_change.trigger_side,
2871 NULL, "at", "side", "element side triggering change"
2874 ED_SELECTBOX_ID_CHANGE_PLAYER,
2875 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2876 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2878 options_change_trigger_player,
2879 &custom_element_change.trigger_player,
2880 NULL, "player:", " ", "player that causes change"
2883 ED_SELECTBOX_ID_CHANGE_PAGE,
2884 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2885 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2887 options_change_trigger_page,
2888 &custom_element_change.trigger_page,
2889 NULL, "page:", NULL, "change page that causes change"
2892 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
2893 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2894 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2896 options_change_replace_when,
2897 &custom_element_change.replace_when,
2898 NULL, "replace when", NULL, "which elements can be replaced"
2901 ED_SELECTBOX_ID_ACTION_TYPE,
2902 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2903 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2905 options_action_type,
2906 &custom_element_change.action_type,
2907 NULL, NULL, NULL, "action on specified condition"
2910 ED_SELECTBOX_ID_ACTION_MODE,
2911 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2912 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2914 options_action_mode_none,
2915 &custom_element_change.action_mode,
2916 NULL, NULL, NULL, "action operator"
2919 ED_SELECTBOX_ID_ACTION_ARG,
2920 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2921 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2923 options_action_arg_none,
2924 &custom_element_change.action_arg,
2925 NULL, NULL, NULL, "action parameter"
2928 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
2929 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2930 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2932 options_change_page,
2933 &custom_element.current_change_page,
2934 NULL, NULL, NULL, "element change page"
2937 // ---------- element settings: configure (group elements) ------------------
2940 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
2941 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2942 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2944 options_group_choice_mode,
2945 &group_element_info.choice_mode,
2946 NULL, "choice type:", NULL, "type of group element choice"
2955 int gadget_id_align;
2958 char *text_above, *text_left, *text_right, *infotext;
2959 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2961 // ---------- level and editor settings (tabs) ------------------------------
2964 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
2965 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2966 GADGET_ID_LEVELCONFIG_LEVEL, GADGET_ID_NONE,
2968 NULL, NULL, NULL, "Configure level settings"
2971 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
2973 GADGET_ID_LEVELCONFIG_LEVELSET, GADGET_ID_LEVELCONFIG_LEVEL,
2975 NULL, NULL, NULL, "Update this or create new level set"
2978 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
2980 GADGET_ID_LEVELCONFIG_EDITOR, GADGET_ID_LEVELCONFIG_LEVELSET,
2982 NULL, NULL, NULL, "Configure editor settings"
2985 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
2987 GADGET_ID_LEVELCONFIG_ENGINE, GADGET_ID_LEVELCONFIG_EDITOR,
2989 NULL, NULL, NULL, "Configure engine settings"
2992 // ---------- element settings (tabs) ---------------------------------------
2995 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
2996 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2997 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2999 NULL, NULL, NULL, "Show information about element"
3002 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
3004 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
3006 NULL, NULL, NULL, "Configure element properties"
3009 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
3011 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
3013 NULL, NULL, NULL, "Configure element properties, part 1"
3016 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
3018 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
3020 NULL, NULL, NULL, "Configure element properties, part 2"
3023 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
3025 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
3027 NULL, NULL, NULL, "Configure custom element change pages"
3030 // ---------- level and editor settings (buttons) ---------------------------
3033 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
3034 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
3035 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
3037 NULL, NULL, NULL, "Update or create level set"
3040 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
3041 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3042 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
3044 NULL, NULL, "this level as level template",
3045 "Save current settings as new template"
3048 // ---------- element settings (buttons) ------------------------------------
3051 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
3053 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
3055 NULL, " ", "As Template",
3056 "Save current settings as new template"
3059 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
3061 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
3063 NULL, NULL, NULL, "Add new change page"
3066 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
3068 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
3070 NULL, NULL, NULL, "Delete current change page"
3080 int gadget_id_align;
3081 char *text_left, *text_right, *infotext;
3082 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
3085 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
3086 IMG_EDITOR_COUNTER_DOWN,
3087 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3088 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
3089 NULL, NULL, "select previous change page"
3092 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
3093 IMG_EDITOR_COUNTER_UP,
3094 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3095 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
3096 NULL, "change page", "select next change page"
3099 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
3100 IMG_GFX_EDITOR_BUTTON_CP_COPY,
3101 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3102 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
3103 " ", NULL, "copy settings from this change page"
3106 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
3107 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
3108 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3109 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
3110 NULL, NULL, "paste settings to this change page"
3117 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
3125 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
3128 ED_SCROLLBUTTON_ID_AREA_UP,
3129 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
3130 GADGET_ID_SCROLL_UP,
3131 "scroll level editing area up"
3134 ED_SCROLLBUTTON_ID_AREA_DOWN,
3135 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
3136 GADGET_ID_SCROLL_DOWN,
3137 "scroll level editing area down"
3140 ED_SCROLLBUTTON_ID_AREA_LEFT,
3141 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
3142 GADGET_ID_SCROLL_LEFT,
3143 "scroll level editing area left"
3146 ED_SCROLLBUTTON_ID_AREA_RIGHT,
3147 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
3148 GADGET_ID_SCROLL_RIGHT,
3149 "scroll level editing area right"
3152 ED_SCROLLBUTTON_ID_LIST_UP,
3153 IMG_EDITOR_PALETTE_SCROLL_UP,
3154 GADGET_ID_SCROLL_LIST_UP,
3155 "scroll element list up ('Page Up')"
3158 ED_SCROLLBUTTON_ID_LIST_DOWN,
3159 IMG_EDITOR_PALETTE_SCROLL_DOWN,
3160 GADGET_ID_SCROLL_LIST_DOWN,
3161 "scroll element list down ('Page Down')"
3169 int wheel_x, wheel_y;
3170 int wheel_width, wheel_height;
3171 } scrollbar_pos[ED_NUM_SCROLLBARS];
3180 } scrollbar_info[ED_NUM_SCROLLBARS] =
3183 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
3184 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3185 GD_TYPE_SCROLLBAR_HORIZONTAL,
3186 GADGET_ID_SCROLL_HORIZONTAL,
3187 "scroll level editing area horizontally"
3190 ED_SCROLLBAR_ID_AREA_VERTICAL,
3191 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3192 GD_TYPE_SCROLLBAR_VERTICAL,
3193 GADGET_ID_SCROLL_VERTICAL,
3194 "scroll level editing area vertically"
3197 ED_SCROLLBAR_ID_LIST_VERTICAL,
3198 IMG_EDITOR_PALETTE_SCROLLBAR,
3199 GD_TYPE_SCROLLBAR_VERTICAL,
3200 GADGET_ID_SCROLL_LIST_VERTICAL,
3201 "scroll element list vertically"
3211 int gadget_id_align;
3212 int radio_button_nr;
3215 char *text_left, *text_right, *infotext;
3216 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3219 ED_RADIOBUTTON_ID_PERCENTAGE,
3220 -1, ED_LEVEL_SETTINGS_YPOS(0),
3221 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3222 RADIO_NR_RANDOM_ELEMENTS,
3223 &random_placement_method, RANDOM_USE_PERCENTAGE,
3224 " ", "percentage", "use percentage for random elements"
3227 ED_RADIOBUTTON_ID_QUANTITY,
3228 -1, ED_LEVEL_SETTINGS_YPOS(0),
3229 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3230 RADIO_NR_RANDOM_ELEMENTS,
3231 &random_placement_method, RANDOM_USE_QUANTITY,
3232 " ", "quantity", "use quantity for random elements"
3241 int gadget_id_align;
3243 char *text_above, *text_left, *text_right, *infotext;
3244 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3246 // ---------- level and editor settings -------------------------------------
3249 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
3250 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3251 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3252 &level.auto_count_gems,
3254 "automatically count gems needed", "set counter to number of gems"
3257 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
3258 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3259 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3260 &level.rate_time_over_score,
3262 "rate time/steps used over score", "sort high scores by playing time/steps"
3265 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
3266 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3267 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3268 &levelset_use_levelset_artwork,
3270 "use current custom artwork", "use custom artwork of this level set"
3273 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
3274 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3275 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3276 &levelset_copy_level_template,
3278 "copy current level template", "copy level template of this level set"
3281 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
3282 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3283 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3284 &random_placement_background_restricted,
3286 "restrict random placement to:", "set random placement restriction"
3289 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
3290 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3291 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3292 &setup.editor.use_template_for_new_levels,
3293 "Template for new levels and CE/GE:", NULL,
3294 "use template for new levels", "use template for level properties"
3297 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
3298 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3299 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3300 &level.use_custom_template,
3302 "use template for custom elements", "use template for custom properties"
3305 ED_CHECKBUTTON_ID_BD_INTERMISSION,
3306 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
3307 GADGET_ID_BD_INTERMISSION, GADGET_ID_NONE,
3308 &level.bd_intermission,
3309 "Boulder Dash game engine settings:", NULL,
3310 "intermission", "level is an intermission level"
3313 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
3314 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
3315 GADGET_ID_BD_PAL_TIMING, GADGET_ID_NONE,
3316 &level.bd_pal_timing,
3318 "PAL timing", "use slower timer (like PAL C64)"
3321 // ---------- element settings: configure (various elements) ----------------
3324 ED_CHECKBUTTON_ID_STICK_ELEMENT,
3325 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3326 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3327 &stick_element_properties_window,
3329 "stick this screen to edit content","stick this screen to edit content"
3332 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
3333 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3334 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3335 &level.em_slippery_gems,
3337 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3340 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
3341 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3342 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3343 &level.em_explodes_by_fire,
3345 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3348 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
3349 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3350 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3351 &level.use_spring_bug,
3353 "use spring pushing bug", "use odd spring pushing behaviour"
3356 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
3357 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3358 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3359 &level.use_time_orb_bug,
3361 "use time orb bug", "use odd time orb behaviour"
3364 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
3365 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3366 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3367 &level.use_life_bugs,
3369 "use buggy element behaviour", "use odd (historic) element behaviour"
3372 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
3373 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3374 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3377 "create single random element", "only create one element from content"
3380 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
3381 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3382 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3383 &level.ball_active_initial,
3385 "magic ball initially activated", "activate magic ball after level start"
3388 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
3389 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3390 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3391 &level.grow_into_diggable,
3393 "can grow into anything diggable", "grow into more than just sand"
3396 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
3397 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3398 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3399 &level.sb_fields_needed,
3401 "all fields need to be filled", "require all SB fields to be solved"
3404 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
3405 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3406 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3407 &level.sb_objects_needed,
3409 "all objects need to be placed", "require all SB objects to be solved"
3412 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
3413 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3414 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3415 &level.auto_exit_sokoban,
3417 "exit level if all tasks solved", "automatically finish Sokoban levels"
3420 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
3421 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3422 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3423 &level.solved_by_one_player,
3425 "only one player must enter exit", "level solved by first player in exit"
3428 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
3429 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3430 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3431 &level.finish_dig_collect,
3433 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3436 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
3437 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3438 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3439 &level.keep_walkable_ce,
3441 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3444 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
3445 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3446 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3447 &level.continuous_snapping,
3449 "continuous snapping", "use snapping without releasing key"
3452 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
3453 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3454 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3455 &level.block_snap_field,
3457 "block snapped field when snapping", "use snapping delay to show animation"
3460 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
3461 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3462 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3463 &level.block_last_field,
3465 "block last field when moving", "player blocks last field when moving"
3468 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
3469 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3470 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3471 &level.sp_block_last_field,
3473 "block last field when moving", "player blocks last field when moving"
3476 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
3477 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3478 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3479 &level.instant_relocation,
3481 "no scrolling when relocating", "player gets relocated without delay"
3484 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
3485 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3486 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3487 &level.shifted_relocation,
3489 "no centering when relocating", "level not centered after relocation"
3492 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
3493 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3494 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3495 &level.lazy_relocation,
3497 "only redraw off-screen relocation","no redraw if relocation target visible"
3500 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
3501 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3502 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3503 &level.use_start_element[0],
3505 "use level start element:", "start level at this element's position"
3508 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
3509 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3510 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3511 &level.use_artwork_element[0],
3513 "use artwork from element:", "use player artwork from other element"
3516 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
3517 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3518 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3519 &level.use_explosion_element[0],
3521 "use explosion from element:", "use explosion properties from element"
3524 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
3525 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3526 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3527 &level.initial_player_gravity[0],
3529 "use initial gravity", "set initial player gravity"
3532 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
3533 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3534 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3535 &level.use_initial_inventory[0],
3537 "use initial inventory:", "use collected elements on level start"
3540 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
3541 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3542 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3543 &level.can_pass_to_walkable,
3545 "can pass to walkable element", "player can pass to empty or walkable"
3548 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
3549 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3550 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3551 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3553 "can fall into acid (with gravity)","player can fall into acid pool"
3556 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
3557 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3558 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3559 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3561 "can move into acid", "element can move into acid pool"
3564 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
3565 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3566 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3567 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3569 "deadly when colliding with", "element is deadly when hitting player"
3572 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
3573 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3574 GADGET_ID_BD_DIAGONAL_MOVEMENTS, GADGET_ID_NONE,
3575 &level.bd_diagonal_movements,
3577 "can move diagonally", "player can move diagonally"
3580 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
3581 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3582 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3583 &level.envelope[0].autowrap,
3585 "auto-wrap", "automatically wrap envelope text"
3588 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
3589 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3590 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3591 &level.envelope[0].centered,
3593 "centered", "automatically center envelope text"
3596 ED_CHECKBUTTON_ID_MM_LASER_RED,
3597 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3598 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3599 &level.mm_laser_red,
3600 "choose color components for laser:", NULL,
3601 "red", "use red color components in laser"
3604 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
3605 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3606 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3607 &level.mm_laser_green,
3609 "green", "use green color components in laser"
3612 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
3613 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3614 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3615 &level.mm_laser_blue,
3617 "blue", "use blue color components in laser"
3620 ED_CHECKBUTTON_ID_DF_LASER_RED,
3621 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3622 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3623 &level.df_laser_red,
3624 "choose color components for laser:", NULL,
3625 "red", "use red color components in laser"
3628 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
3629 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3630 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3631 &level.df_laser_green,
3633 "green", "use green color components in laser"
3636 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
3637 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3638 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3639 &level.df_laser_blue,
3641 "blue", "use blue color components in laser"
3644 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
3645 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3646 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3647 &level.rotate_mm_ball_content,
3649 "randomly rotate created content", "randomly rotate newly created content"
3652 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
3653 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3654 GADGET_ID_EXPLODE_MM_BALL, GADGET_ID_NONE,
3655 &level.explode_mm_ball,
3657 "explode ball instead of melting", "use explosion to release ball content"
3660 // ---------- element settings: configure 1 (custom elements) ---------------
3663 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
3664 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3665 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3666 &custom_element.use_gfx_element,
3668 "use graphic of element:", "use existing element graphic"
3671 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
3672 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3673 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3674 &level.use_custom_template,
3676 "use template", "use template for custom properties"
3679 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
3680 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3681 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3682 &custom_element_properties[EP_ACCESSIBLE],
3684 NULL, "player can walk to or pass this field"
3687 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
3688 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3689 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3690 &custom_element_properties[EP_GRAVITY_REACHABLE],
3692 "reachable despite gravity", "player can walk/dig despite gravity"
3695 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
3696 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3697 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3698 &custom_element.use_last_ce_value,
3700 "use last CE value after change", "use last CE value after change"
3703 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
3704 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3705 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3706 &custom_element_properties[EP_WALK_TO_OBJECT],
3708 NULL, "player can dig/collect/push element"
3711 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
3712 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3713 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3714 &custom_element_properties[EP_INDESTRUCTIBLE],
3716 "indestructible", "element is indestructible"
3719 // ---------- element settings: configure 2 (custom elements) ---------------
3722 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
3723 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3724 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3725 &custom_element_properties[EP_CAN_MOVE],
3727 NULL, "element can move with some pattern"
3730 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
3731 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3732 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3733 &custom_element_properties[EP_CAN_FALL],
3735 "can fall", "element can fall down"
3738 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
3739 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3740 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3741 &custom_element_properties[EP_CAN_SMASH],
3743 NULL, "element can smash other elements"
3746 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
3747 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3748 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3749 &custom_element_properties[EP_SLIPPERY],
3751 NULL, "other elements can fall down from it"
3754 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
3755 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3756 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3757 &custom_element_properties[EP_DEADLY],
3759 NULL, "element can kill the player"
3762 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
3763 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3764 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3765 &custom_element_properties[EP_CAN_EXPLODE],
3767 NULL, "element can explode"
3770 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
3771 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3772 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3773 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3775 "by fire", "element can explode by fire/explosion"
3778 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
3779 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3780 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3781 &custom_element_properties[EP_EXPLODES_SMASHED],
3783 "smashed", "element can explode when smashed"
3786 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
3787 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3788 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3789 &custom_element_properties[EP_EXPLODES_IMPACT],
3791 "impact", "element can explode on impact"
3794 // ---------- element settings: advanced (custom elements) ------------------
3797 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
3798 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3799 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3800 &custom_element_change.can_change,
3802 "element changes to:", "change element on specified condition"
3805 ED_CHECKBUTTON_ID_CHANGE_DELAY,
3806 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3807 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3808 &custom_element_change_events[CE_DELAY],
3810 NULL, "element changes after delay"
3813 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
3814 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3815 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3816 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3818 NULL, "element changes by direct action"
3821 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
3822 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3823 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3824 &custom_element_change_events[CE_BY_OTHER_ACTION],
3826 NULL, "element changes by other element"
3829 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
3830 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3831 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3832 &custom_element_change.explode,
3834 "explode instead of change", "element explodes instead of change"
3837 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
3838 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3839 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3840 &custom_element_change.use_target_content,
3842 "use extended change target:", "element changes to more elements"
3845 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
3846 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3847 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3848 &custom_element_change.only_if_complete,
3850 "replace all or nothing", "only replace when all can be changed"
3853 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
3854 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3855 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3856 &custom_element_change.use_random_replace,
3858 NULL, "use percentage for random replace"
3861 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
3862 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3863 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3864 &custom_element_change.has_action,
3866 NULL, "execute action on specified condition"
3874 int xoffset, yoffset;
3876 int gadget_id_align;
3878 int area_xsize, area_ysize;
3879 char *text_left, *text_right, *text_above, *text_below, *infotext;
3880 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3882 // ---------- level playfield content ---------------------------------------
3885 ED_DRAWING_ID_DRAWING_LEVEL,
3888 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3890 -1, -1, // these values are not constant, but can change at runtime
3891 NULL, NULL, NULL, NULL, NULL
3894 // ---------- yam yam content -----------------------------------------------
3897 ED_DRAWING_ID_YAMYAM_CONTENT_0,
3898 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3899 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3900 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3901 &level.yamyam_content[0].e[0][0], 3, 3,
3902 NULL, NULL, NULL, "1", NULL
3905 ED_DRAWING_ID_YAMYAM_CONTENT_1,
3906 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3907 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3908 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3909 &level.yamyam_content[1].e[0][0], 3, 3,
3910 NULL, NULL, NULL, "2", NULL
3913 ED_DRAWING_ID_YAMYAM_CONTENT_2,
3914 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3915 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3916 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3917 &level.yamyam_content[2].e[0][0], 3, 3,
3918 NULL, NULL, NULL, "3", NULL
3921 ED_DRAWING_ID_YAMYAM_CONTENT_3,
3922 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3923 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3924 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3925 &level.yamyam_content[3].e[0][0], 3, 3,
3926 NULL, NULL, NULL, "4", NULL
3929 ED_DRAWING_ID_YAMYAM_CONTENT_4,
3930 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3931 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3932 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3933 &level.yamyam_content[4].e[0][0], 3, 3,
3934 NULL, NULL, NULL, "5", NULL
3937 ED_DRAWING_ID_YAMYAM_CONTENT_5,
3938 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3939 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3940 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3941 &level.yamyam_content[5].e[0][0], 3, 3,
3942 NULL, NULL, NULL, "6", NULL
3945 ED_DRAWING_ID_YAMYAM_CONTENT_6,
3946 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3947 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3948 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3949 &level.yamyam_content[6].e[0][0], 3, 3,
3950 NULL, NULL, NULL, "7", NULL
3953 ED_DRAWING_ID_YAMYAM_CONTENT_7,
3954 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3955 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3956 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3957 &level.yamyam_content[7].e[0][0], 3, 3,
3958 NULL, NULL, NULL, "8", NULL
3961 // ---------- magic ball content --------------------------------------------
3964 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
3965 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3966 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3967 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3968 &level.ball_content[0].e[0][0], 3, 3,
3969 NULL, NULL, NULL, "1", NULL
3972 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
3973 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3974 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3975 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3976 &level.ball_content[1].e[0][0], 3, 3,
3977 NULL, NULL, NULL, "2", NULL
3980 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
3981 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3982 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3983 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3984 &level.ball_content[2].e[0][0], 3, 3,
3985 NULL, NULL, NULL, "3", NULL
3988 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
3989 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3990 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3991 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3992 &level.ball_content[3].e[0][0], 3, 3,
3993 NULL, NULL, NULL, "4", NULL
3996 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
3997 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3998 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3999 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
4000 &level.ball_content[4].e[0][0], 3, 3,
4001 NULL, NULL, NULL, "5", NULL
4004 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
4005 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4006 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
4007 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
4008 &level.ball_content[5].e[0][0], 3, 3,
4009 NULL, NULL, NULL, "6", NULL
4012 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
4013 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4014 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
4015 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
4016 &level.ball_content[6].e[0][0], 3, 3,
4017 NULL, NULL, NULL, "7", NULL
4020 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
4021 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4022 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
4023 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
4024 &level.ball_content[7].e[0][0], 3, 3,
4025 NULL, NULL, NULL, "8", NULL
4028 // ---------- android content -----------------------------------------------
4031 ED_DRAWING_ID_ANDROID_CONTENT,
4032 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
4033 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4034 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
4035 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
4036 NULL, NULL, "elements:", NULL, "elements android can clone"
4039 // ---------- amoeba content ------------------------------------------------
4042 ED_DRAWING_ID_AMOEBA_CONTENT,
4043 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
4044 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4045 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
4046 &level.amoeba_content, 1, 1,
4047 "content:", NULL, NULL, NULL, "amoeba content"
4050 // ---------- level start element -------------------------------------------
4053 ED_DRAWING_ID_START_ELEMENT,
4054 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
4055 0, ED_AREA_1X1_SETTINGS_YOFF,
4056 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
4057 &level.start_element[0], 1, 1,
4058 NULL, NULL, NULL, NULL, "level start element"
4061 // ---------- player artwork element ----------------------------------------
4064 ED_DRAWING_ID_ARTWORK_ELEMENT,
4065 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
4066 0, ED_AREA_1X1_SETTINGS_YOFF,
4067 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
4068 &level.artwork_element[0], 1, 1,
4069 NULL, NULL, NULL, NULL, "element for player artwork"
4072 // ---------- player explosion element --------------------------------------
4075 ED_DRAWING_ID_EXPLOSION_ELEMENT,
4076 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
4077 0, ED_AREA_1X1_SETTINGS_YOFF,
4078 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
4079 &level.explosion_element[0], 1, 1,
4080 NULL, NULL, NULL, NULL, "element for player explosion"
4083 // ---------- player initial inventory --------------------------------------
4086 ED_DRAWING_ID_INVENTORY_CONTENT,
4087 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4088 0, ED_AREA_1X1_SETTINGS_YOFF,
4089 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
4090 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
4091 NULL, NULL, NULL, NULL, "content for initial inventory"
4094 // ---------- gray ball content -----------------------------------------
4097 ED_DRAWING_ID_MM_BALL_CONTENT,
4098 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4099 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4100 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
4101 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
4102 "content:", NULL, NULL, NULL, "content for gray ball"
4105 // ---------- element settings: configure 1 (custom elements) ---------------
4107 // ---------- custom graphic ------------------------------------------------
4110 ED_DRAWING_ID_CUSTOM_GRAPHIC,
4111 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4112 0, ED_AREA_1X1_SETTINGS_YOFF,
4113 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
4114 &custom_element.gfx_element_initial, 1, 1,
4115 NULL, NULL, NULL, NULL, "custom graphic element"
4118 // ---------- element settings: configure 2 (custom elements) ---------------
4120 // ---------- custom content (when exploding) -------------------------------
4123 ED_DRAWING_ID_CUSTOM_CONTENT,
4124 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
4125 0, ED_AREA_3X3_SETTINGS_YOFF,
4126 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
4127 &custom_element.content.e[0][0], 3, 3,
4128 "content:", NULL, NULL, NULL, NULL
4131 // ---------- custom enter and leave element (when moving) ------------------
4134 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
4135 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
4136 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4137 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
4138 &custom_element.move_enter_element, 1, 1,
4139 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
4142 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
4143 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
4144 0, ED_AREA_1X1_SETTINGS_YOFF,
4145 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
4146 &custom_element.move_leave_element, 1, 1,
4147 NULL, NULL, NULL, NULL, "element that will be left behind"
4150 // ---------- element settings: advanced (custom elements) ------------------
4152 // ---------- custom change target ------------------------------------------
4155 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
4156 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4157 0, ED_AREA_1X1_SETTINGS_YOFF,
4158 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
4159 &custom_element_change.target_element, 1, 1,
4160 NULL, "after/when:", NULL, NULL, "new target element after change"
4163 // ---------- custom change content (extended change target) ----------------
4166 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
4167 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
4168 0, ED_AREA_3X3_SETTINGS_YOFF,
4169 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
4170 &custom_element_change.target_content.e[0][0], 3, 3,
4171 NULL, NULL, NULL, NULL, "new extended elements after change"
4174 // ---------- custom change trigger (element causing change) ----------------
4177 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
4178 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
4179 0, ED_AREA_1X1_SETTINGS_YOFF,
4180 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
4181 &custom_element_change.initial_trigger_element, 1, 1,
4182 NULL, NULL, NULL, NULL, "other element triggering change"
4185 // ---------- custom change action (element used for action) ----------------
4188 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
4189 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
4190 0, ED_AREA_1X1_SETTINGS_YOFF,
4191 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
4192 &custom_element_change.action_element, 1, 1,
4193 NULL, NULL, NULL, NULL, "element used as action parameter"
4196 // ---------- group element content -----------------------------------------
4199 ED_DRAWING_ID_GROUP_CONTENT,
4200 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4201 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4202 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
4203 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
4204 "content:", NULL, NULL, NULL, NULL
4207 // ---------- random background (for random painting) -----------------------
4210 ED_DRAWING_ID_RANDOM_BACKGROUND,
4211 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
4212 0, ED_AREA_1X1_LSETTINGS_YOFF,
4213 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
4214 &random_placement_background_element, 1, 1,
4215 NULL, NULL, NULL, NULL, "random placement background"
4220 // ----------------------------------------------------------------------------
4221 // some internally used variables
4222 // ----------------------------------------------------------------------------
4224 // maximal size of level editor drawing area
4225 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
4227 // actual size of level editor drawing area
4228 static int ed_fieldx, ed_fieldy;
4230 // actual position of level editor drawing area in level playfield
4231 static int level_xpos = -1, level_ypos = -1;
4233 // actual tile size used to display playfield drawing area
4234 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
4235 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
4237 #define IN_ED_FIELD(x, y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
4239 // drawing elements on the three mouse buttons
4240 static int new_element1 = EL_WALL;
4241 static int new_element2 = EL_EMPTY;
4242 static int new_element3 = EL_SAND;
4244 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
4245 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
4246 (button) == 2 ? new_element2 : \
4247 (button) == 3 ? new_element3 : EL_EMPTY)
4249 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
4251 static int use_permanent_palette = TRUE;
4253 #define PX (use_permanent_palette ? DX : SX)
4254 #define PY (use_permanent_palette ? DY : SY)
4255 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
4256 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
4258 // forward declaration for internal use
4259 static void CopyBrushToCursor(int, int);
4260 static void DeleteBrushFromCursor(void);
4261 static void ModifyEditorCounterValue(int, int);
4262 static void ModifyEditorCounterLimits(int, int, int);
4263 static void ModifyEditorSelectboxValue(int, int);
4264 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
4265 static void ModifyEditorDrawingArea(int, int, int);
4266 static void ModifyEditorElementList(void);
4267 static void AdjustElementListScrollbar(void);
4268 static void RedrawDrawingElements(void);
4269 static void DrawDrawingWindowExt(boolean);
4270 static void DrawDrawingWindow(void);
4271 static void DrawLevelConfigWindow(void);
4272 static void DrawPropertiesWindow(void);
4273 static void DrawPaletteWindow(void);
4274 static void UpdateCustomElementGraphicGadgets(void);
4275 static boolean checkPropertiesConfig(int);
4276 static void SetAutomaticNumberOfGemsNeeded(void);
4277 static void ClearEditorGadgetInfoText(void);
4278 static void CopyLevelToUndoBuffer(int);
4279 static void HandleDrawingAreas(struct GadgetInfo *);
4280 static void HandleCounterButtons(struct GadgetInfo *);
4281 static void HandleTextInputGadgets(struct GadgetInfo *);
4282 static void HandleTextAreaGadgets(struct GadgetInfo *);
4283 static void HandleSelectboxGadgets(struct GadgetInfo *);
4284 static void HandleTextbuttonGadgets(struct GadgetInfo *);
4285 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
4286 static void HandleRadiobuttons(struct GadgetInfo *);
4287 static void HandleCheckbuttons(struct GadgetInfo *);
4288 static void HandleControlButtons(struct GadgetInfo *);
4289 static void HandleDrawingAreaInfo(struct GadgetInfo *);
4290 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
4291 static boolean AskToCopyAndModifyLevelTemplate(void);
4292 static boolean getDrawModeHiRes(void);
4293 static int getTabulatorBarWidth(void);
4294 static int getTabulatorBarHeight(void);
4295 static Pixel getTabulatorBarColor(void);
4296 static int numHiresTiles(int);
4298 static int num_editor_gadgets = 0; // dynamically determined
4300 static struct GadgetInfo **level_editor_gadget = NULL;
4301 static int *right_gadget_border = NULL;
4303 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
4304 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
4305 static boolean draw_with_brush = FALSE;
4306 static int properties_element = 0;
4308 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4309 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4310 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4311 static int undo_buffer_position = 0;
4312 static int undo_buffer_steps = 0;
4313 static int redo_buffer_steps = 0;
4315 static int edit_mode;
4316 static int edit_mode_levelconfig;
4317 static int edit_mode_properties;
4319 static int element_shift = 0;
4321 static int editor_el_players[] =
4328 static int *editor_el_players_ptr = editor_el_players;
4329 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4331 static int editor_hl_boulderdash[] =
4333 EL_INTERNAL_CASCADE_BD_ACTIVE,
4339 static int editor_el_boulderdash[] =
4348 EL_BD_EXPANDABLE_WALL,
4356 EL_BD_BUTTERFLY_LEFT,
4358 EL_BD_BUTTERFLY_RIGHT,
4359 EL_BD_FIREFLY_RIGHT,
4362 EL_BD_BUTTERFLY_DOWN,
4366 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4367 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4368 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4369 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4371 static int editor_hl_boulderdash_native[] =
4373 EL_INTERNAL_CASCADE_BD_NATIVE_ACTIVE,
4379 static int editor_el_boulderdash_native[] =
4396 EL_BD_BUTTERFLY_LEFT,
4398 EL_BD_BUTTERFLY_RIGHT,
4399 EL_BD_FIREFLY_RIGHT,
4402 EL_BD_BUTTERFLY_DOWN,
4407 EL_BD_BUTTERFLY_2_UP,
4411 EL_BD_BUTTERFLY_2_LEFT,
4412 EL_BD_FIREFLY_2_LEFT,
4413 EL_BD_BUTTERFLY_2_RIGHT,
4414 EL_BD_FIREFLY_2_RIGHT,
4417 EL_BD_BUTTERFLY_2_DOWN,
4418 EL_BD_FIREFLY_2_DOWN,
4426 EL_BD_DRAGONFLY_LEFT,
4427 EL_BD_STONEFLY_LEFT,
4428 EL_BD_DRAGONFLY_RIGHT,
4429 EL_BD_STONEFLY_RIGHT,
4432 EL_BD_DRAGONFLY_DOWN,
4433 EL_BD_STONEFLY_DOWN,
4456 EL_BD_SAND_SLOPED_UP_LEFT,
4457 EL_BD_SAND_SLOPED_UP_RIGHT,
4458 EL_BD_WALL_SLOPED_UP_LEFT,
4459 EL_BD_WALL_SLOPED_UP_RIGHT,
4461 EL_BD_SAND_SLOPED_DOWN_LEFT,
4462 EL_BD_SAND_SLOPED_DOWN_RIGHT,
4463 EL_BD_WALL_SLOPED_DOWN_LEFT,
4464 EL_BD_WALL_SLOPED_DOWN_RIGHT,
4466 EL_BD_FLYING_DIAMOND,
4468 EL_BD_STEELWALL_SLOPED_UP_LEFT,
4469 EL_BD_STEELWALL_SLOPED_UP_RIGHT,
4473 EL_BD_STEELWALL_SLOPED_DOWN_LEFT,
4474 EL_BD_STEELWALL_SLOPED_DOWN_RIGHT,
4477 EL_BD_WALL_NON_SLOPED,
4483 EL_BD_INVISIBLE_EXIT_CLOSED,
4484 EL_BD_INVISIBLE_EXIT_OPEN,
4487 EL_BD_STEELWALL_EXPLODABLE,
4488 EL_BD_STEELWALL_DIGGABLE,
4489 EL_BD_WALL_DIGGABLE,
4491 EL_BD_EXPANDABLE_WALL_HORIZONTAL,
4492 EL_BD_EXPANDABLE_WALL_VERTICAL,
4493 EL_BD_EXPANDABLE_WALL_ANY,
4494 EL_BD_CREATURE_SWITCH,
4496 EL_BD_EXPANDABLE_STEELWALL_HORIZONTAL,
4497 EL_BD_EXPANDABLE_STEELWALL_VERTICAL,
4498 EL_BD_EXPANDABLE_STEELWALL_ANY,
4499 EL_BD_EXPANDABLE_WALL_SWITCH_HORIZONTAL,
4501 EL_BD_BITER_SWITCH_1,
4502 EL_BD_REPLICATOR_SWITCH,
4503 EL_BD_CONVEYOR_SWITCH,
4504 EL_BD_CONVEYOR_DIR_SWITCH_RIGHT,
4513 EL_BD_DIAMOND_GLUED,
4516 EL_BD_TRAPPED_DIAMOND,
4536 EL_BD_GRAVITY_SWITCH,
4537 EL_BD_PNEUMATIC_HAMMER,
4544 EL_BD_BLADDER_SPENDER,
4546 EL_BD_CONVEYOR_LEFT,
4547 EL_BD_CONVEYOR_RIGHT,
4562 EL_BD_PLAYER_WITH_BOMB,
4564 EL_BD_PLAYER_STIRRING,
4566 static int *editor_hl_boulderdash_native_ptr = editor_hl_boulderdash_native;
4567 static int *editor_el_boulderdash_native_ptr = editor_el_boulderdash_native;
4568 static int num_editor_hl_boulderdash_native = ARRAY_SIZE(editor_hl_boulderdash_native);
4569 static int num_editor_el_boulderdash_native = ARRAY_SIZE(editor_el_boulderdash_native);
4571 static int editor_hl_emerald_mine[] =
4573 EL_INTERNAL_CASCADE_EM_ACTIVE,
4579 static int editor_el_emerald_mine[] =
4597 EL_EM_DYNAMITE_ACTIVE,
4616 EL_ACID_POOL_TOPLEFT,
4618 EL_ACID_POOL_TOPRIGHT,
4621 EL_ACID_POOL_BOTTOMLEFT,
4622 EL_ACID_POOL_BOTTOM,
4623 EL_ACID_POOL_BOTTOMRIGHT,
4641 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4642 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4643 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4644 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4646 static int editor_hl_emerald_mine_club[] =
4648 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4654 static int editor_el_emerald_mine_club[] =
4681 EL_EMC_WALL_SLIPPERY_1,
4682 EL_EMC_WALL_SLIPPERY_2,
4683 EL_EMC_WALL_SLIPPERY_3,
4684 EL_EMC_WALL_SLIPPERY_4,
4707 EL_EMC_MAGIC_BALL_SWITCH,
4714 EL_EMC_SPRING_BUMPER,
4718 EL_BALLOON_SWITCH_UP,
4719 EL_BALLOON_SWITCH_ANY,
4722 EL_BALLOON_SWITCH_LEFT,
4724 EL_BALLOON_SWITCH_RIGHT,
4728 EL_BALLOON_SWITCH_DOWN,
4729 EL_BALLOON_SWITCH_NONE,
4731 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4732 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4733 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4734 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4736 static int editor_hl_rnd[] =
4738 EL_INTERNAL_CASCADE_RND_ACTIVE,
4744 static int editor_el_rnd[] =
4747 EL_DYNAMITE_ACTIVE, // RND
4781 EL_WALL_EMERALD_YELLOW,
4782 EL_WALL_EMERALD_RED,
4783 EL_WALL_EMERALD_PURPLE,
4801 EL_DYNABOMB_INCREASE_NUMBER,
4802 EL_DYNABOMB_INCREASE_SIZE,
4803 EL_DYNABOMB_INCREASE_POWER,
4823 EL_INVISIBLE_STEELWALL,
4827 EL_EXPANDABLE_WALL_HORIZONTAL,
4828 EL_EXPANDABLE_WALL_VERTICAL,
4829 EL_EXPANDABLE_WALL_ANY,
4831 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4832 static int *editor_el_rnd_ptr = editor_el_rnd;
4833 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4834 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4836 static int editor_hl_sokoban[] =
4838 EL_INTERNAL_CASCADE_SB_ACTIVE,
4844 static int editor_el_sokoban[] =
4847 EL_SOKOBAN_FIELD_EMPTY,
4848 EL_SOKOBAN_FIELD_FULL,
4849 EL_SOKOBAN_FIELD_PLAYER,
4851 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4852 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4853 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4854 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4856 static int editor_hl_supaplex[] =
4858 EL_INTERNAL_CASCADE_SP_ACTIVE,
4864 static int editor_el_supaplex[] =
4882 EL_SP_PORT_HORIZONTAL,
4883 EL_SP_PORT_VERTICAL,
4891 EL_SP_GRAVITY_PORT_LEFT,
4892 EL_SP_GRAVITY_PORT_RIGHT,
4893 EL_SP_GRAVITY_PORT_UP,
4894 EL_SP_GRAVITY_PORT_DOWN,
4896 EL_SP_GRAVITY_ON_PORT_LEFT,
4897 EL_SP_GRAVITY_ON_PORT_RIGHT,
4898 EL_SP_GRAVITY_ON_PORT_UP,
4899 EL_SP_GRAVITY_ON_PORT_DOWN,
4901 EL_SP_GRAVITY_OFF_PORT_LEFT,
4902 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4903 EL_SP_GRAVITY_OFF_PORT_UP,
4904 EL_SP_GRAVITY_OFF_PORT_DOWN,
4906 EL_SP_HARDWARE_GRAY,
4907 EL_SP_HARDWARE_GREEN,
4908 EL_SP_HARDWARE_BLUE,
4911 EL_SP_HARDWARE_BASE_1,
4912 EL_SP_HARDWARE_BASE_2,
4913 EL_SP_HARDWARE_BASE_3,
4914 EL_SP_HARDWARE_BASE_4,
4916 EL_SP_HARDWARE_BASE_5,
4917 EL_SP_HARDWARE_BASE_6,
4918 EL_SP_HARDWARE_YELLOW,
4926 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4927 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4928 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4929 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4931 static int editor_hl_diamond_caves[] =
4933 EL_INTERNAL_CASCADE_DC_ACTIVE,
4939 static int editor_el_diamond_caves[] =
4941 EL_EM_STEEL_EXIT_CLOSED, // DC2
4942 EL_EM_STEEL_EXIT_OPEN, // DC2
4943 EL_WALL_EMERALD, // DC2
4944 EL_WALL_DIAMOND, // DC2
4951 EL_CONVEYOR_BELT_1_LEFT,
4952 EL_CONVEYOR_BELT_1_MIDDLE,
4953 EL_CONVEYOR_BELT_1_RIGHT,
4954 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4956 EL_CONVEYOR_BELT_2_LEFT,
4957 EL_CONVEYOR_BELT_2_MIDDLE,
4958 EL_CONVEYOR_BELT_2_RIGHT,
4959 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4961 EL_CONVEYOR_BELT_3_LEFT,
4962 EL_CONVEYOR_BELT_3_MIDDLE,
4963 EL_CONVEYOR_BELT_3_RIGHT,
4964 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4966 EL_CONVEYOR_BELT_4_LEFT,
4967 EL_CONVEYOR_BELT_4_MIDDLE,
4968 EL_CONVEYOR_BELT_4_RIGHT,
4969 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4971 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4972 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4973 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4974 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4976 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4977 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4978 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4979 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4984 EL_DC_TIMEGATE_SWITCH,
4986 EL_SWITCHGATE_CLOSED,
4988 EL_SWITCHGATE_SWITCH_UP,
4989 EL_SWITCHGATE_SWITCH_DOWN,
4992 EL_LIGHT_SWITCH_ACTIVE,
4993 EL_DC_SWITCHGATE_SWITCH_UP,
4994 EL_DC_SWITCHGATE_SWITCH_DOWN,
4996 EL_STEEL_EXIT_CLOSED,
4998 EL_STEELWALL_SLIPPERY,
5001 EL_QUICKSAND_FAST_EMPTY,
5002 EL_QUICKSAND_FAST_FULL,
5016 EL_SIGN_RADIOACTIVITY,
5022 EL_SIGN_ENTRY_FORBIDDEN,
5023 EL_SIGN_EMERGENCY_EXIT,
5048 EL_DC_STEELWALL_2_SINGLE,
5049 EL_DC_STEELWALL_2_TOP,
5050 EL_SIGN_EXCLAMATION,
5053 EL_DC_STEELWALL_2_LEFT,
5054 EL_DC_STEELWALL_2_MIDDLE,
5055 EL_DC_STEELWALL_2_HORIZONTAL,
5056 EL_DC_STEELWALL_2_RIGHT,
5058 EL_DC_STEELWALL_1_TOPLEFT,
5059 EL_DC_STEELWALL_2_VERTICAL,
5060 EL_DC_STEELWALL_1_TOPRIGHT,
5063 EL_DC_STEELWALL_1_VERTICAL,
5064 EL_DC_STEELWALL_2_BOTTOM,
5066 EL_DC_GATE_WHITE_GRAY,
5068 EL_DC_STEELWALL_1_BOTTOMLEFT,
5069 EL_DC_STEELWALL_1_HORIZONTAL,
5070 EL_DC_STEELWALL_1_BOTTOMRIGHT,
5071 EL_DC_GATE_FAKE_GRAY,
5073 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
5074 EL_DC_STEELWALL_1_BOTTOM,
5075 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
5076 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
5078 EL_DC_STEELWALL_1_RIGHT,
5080 EL_DC_STEELWALL_1_LEFT,
5081 EL_EXPANDABLE_STEELWALL_VERTICAL,
5083 EL_DC_STEELWALL_1_TOPRIGHT_2,
5084 EL_DC_STEELWALL_1_TOP,
5085 EL_DC_STEELWALL_1_TOPLEFT_2,
5086 EL_EXPANDABLE_STEELWALL_ANY,
5088 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
5089 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
5090 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
5091 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
5093 static int editor_hl_dx_boulderdash[] =
5095 EL_INTERNAL_CASCADE_DX_ACTIVE,
5101 static int editor_el_dx_boulderdash[] =
5105 EL_TUBE_HORIZONTAL_DOWN,
5109 EL_TUBE_VERTICAL_RIGHT,
5111 EL_TUBE_VERTICAL_LEFT,
5115 EL_TUBE_HORIZONTAL_UP,
5123 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
5124 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
5125 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
5126 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
5128 static int editor_hl_mirror_magic[] =
5130 EL_INTERNAL_CASCADE_MM_ACTIVE,
5136 static int editor_el_mirror_magic[] =
5138 EL_MM_MCDUFFIN_RIGHT,
5140 EL_MM_MCDUFFIN_LEFT,
5141 EL_MM_MCDUFFIN_DOWN,
5144 EL_MM_MIRROR_FIXED_START,
5145 EL_MM_POLARIZER_START,
5146 EL_MM_POLARIZER_CROSS_START,
5148 EL_MM_TELEPORTER_RED_START,
5149 EL_MM_TELEPORTER_YELLOW_START,
5150 EL_MM_TELEPORTER_GREEN_START,
5151 EL_MM_TELEPORTER_BLUE_START,
5164 EL_MM_LIGHTBULB_ACTIVE,
5178 EL_MM_STEEL_GRID_FIXED_1,
5179 EL_MM_STEEL_GRID_FIXED_2,
5180 EL_MM_STEEL_GRID_FIXED_3,
5181 EL_MM_STEEL_GRID_FIXED_4,
5183 EL_MM_WOODEN_GRID_FIXED_1,
5184 EL_MM_WOODEN_GRID_FIXED_2,
5185 EL_MM_WOODEN_GRID_FIXED_3,
5186 EL_MM_WOODEN_GRID_FIXED_4,
5193 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
5194 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
5195 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
5196 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
5198 static int editor_hl_deflektor[] =
5200 EL_INTERNAL_CASCADE_DF_ACTIVE,
5206 static int editor_el_deflektor[] =
5213 EL_DF_RECEIVER_RIGHT,
5215 EL_DF_RECEIVER_LEFT,
5216 EL_DF_RECEIVER_DOWN,
5219 EL_DF_MIRROR_ROTATING_START,
5220 EL_DF_MIRROR_FIXED_START,
5223 EL_DF_FIBRE_OPTIC_RED_1,
5224 EL_DF_FIBRE_OPTIC_YELLOW_1,
5225 EL_DF_FIBRE_OPTIC_GREEN_1,
5226 EL_DF_FIBRE_OPTIC_BLUE_1,
5228 EL_DF_STEEL_GRID_FIXED_START,
5229 EL_DF_STEEL_GRID_ROTATING_START,
5230 EL_DF_WOODEN_GRID_FIXED_START,
5231 EL_DF_WOODEN_GRID_ROTATING_START,
5243 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
5244 static int *editor_el_deflektor_ptr = editor_el_deflektor;
5245 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
5246 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
5248 static int editor_hl_chars[] =
5250 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
5256 static int editor_el_chars[] =
5338 EL_CHAR(CHAR_BYTE_COPYRIGHT),
5339 EL_CHAR(CHAR_BYTE_UMLAUT_A),
5340 EL_CHAR(CHAR_BYTE_UMLAUT_O),
5341 EL_CHAR(CHAR_BYTE_UMLAUT_U),
5343 EL_CHAR(CHAR_BYTE_DEGREE),
5344 EL_CHAR(CHAR_BYTE_REGISTERED),
5345 EL_CHAR(FONT_ASCII_CURSOR),
5346 EL_CHAR(FONT_ASCII_BUTTON),
5348 EL_CHAR(FONT_ASCII_UP),
5349 EL_CHAR(FONT_ASCII_DOWN),
5353 static int *editor_hl_chars_ptr = editor_hl_chars;
5354 static int *editor_el_chars_ptr = editor_el_chars;
5355 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
5356 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
5358 static int editor_hl_steel_chars[] =
5360 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
5366 static int editor_el_steel_chars[] =
5376 EL_STEEL_CHAR('\''),
5443 EL_STEEL_CHAR('\\'),
5448 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
5449 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
5450 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
5451 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
5453 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
5454 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
5455 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
5456 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
5458 EL_STEEL_CHAR(FONT_ASCII_UP),
5459 EL_STEEL_CHAR(FONT_ASCII_DOWN),
5463 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
5464 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
5465 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
5466 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
5468 static int editor_hl_custom[] =
5470 EL_INTERNAL_CASCADE_CE_ACTIVE,
5476 static int editor_el_custom[] =
5478 EL_CUSTOM_START + 0,
5479 EL_CUSTOM_START + 1,
5480 EL_CUSTOM_START + 2,
5481 EL_CUSTOM_START + 3,
5483 EL_CUSTOM_START + 4,
5484 EL_CUSTOM_START + 5,
5485 EL_CUSTOM_START + 6,
5486 EL_CUSTOM_START + 7,
5488 EL_CUSTOM_START + 8,
5489 EL_CUSTOM_START + 9,
5490 EL_CUSTOM_START + 10,
5491 EL_CUSTOM_START + 11,
5493 EL_CUSTOM_START + 12,
5494 EL_CUSTOM_START + 13,
5495 EL_CUSTOM_START + 14,
5496 EL_CUSTOM_START + 15,
5498 EL_CUSTOM_START + 16,
5499 EL_CUSTOM_START + 17,
5500 EL_CUSTOM_START + 18,
5501 EL_CUSTOM_START + 19,
5503 EL_CUSTOM_START + 20,
5504 EL_CUSTOM_START + 21,
5505 EL_CUSTOM_START + 22,
5506 EL_CUSTOM_START + 23,
5508 EL_CUSTOM_START + 24,
5509 EL_CUSTOM_START + 25,
5510 EL_CUSTOM_START + 26,
5511 EL_CUSTOM_START + 27,
5513 EL_CUSTOM_START + 28,
5514 EL_CUSTOM_START + 29,
5515 EL_CUSTOM_START + 30,
5516 EL_CUSTOM_START + 31,
5518 EL_CUSTOM_START + 32,
5519 EL_CUSTOM_START + 33,
5520 EL_CUSTOM_START + 34,
5521 EL_CUSTOM_START + 35,
5523 EL_CUSTOM_START + 36,
5524 EL_CUSTOM_START + 37,
5525 EL_CUSTOM_START + 38,
5526 EL_CUSTOM_START + 39,
5528 EL_CUSTOM_START + 40,
5529 EL_CUSTOM_START + 41,
5530 EL_CUSTOM_START + 42,
5531 EL_CUSTOM_START + 43,
5533 EL_CUSTOM_START + 44,
5534 EL_CUSTOM_START + 45,
5535 EL_CUSTOM_START + 46,
5536 EL_CUSTOM_START + 47,
5538 EL_CUSTOM_START + 48,
5539 EL_CUSTOM_START + 49,
5540 EL_CUSTOM_START + 50,
5541 EL_CUSTOM_START + 51,
5543 EL_CUSTOM_START + 52,
5544 EL_CUSTOM_START + 53,
5545 EL_CUSTOM_START + 54,
5546 EL_CUSTOM_START + 55,
5548 EL_CUSTOM_START + 56,
5549 EL_CUSTOM_START + 57,
5550 EL_CUSTOM_START + 58,
5551 EL_CUSTOM_START + 59,
5553 EL_CUSTOM_START + 60,
5554 EL_CUSTOM_START + 61,
5555 EL_CUSTOM_START + 62,
5556 EL_CUSTOM_START + 63,
5558 EL_CUSTOM_START + 64,
5559 EL_CUSTOM_START + 65,
5560 EL_CUSTOM_START + 66,
5561 EL_CUSTOM_START + 67,
5563 EL_CUSTOM_START + 68,
5564 EL_CUSTOM_START + 69,
5565 EL_CUSTOM_START + 70,
5566 EL_CUSTOM_START + 71,
5568 EL_CUSTOM_START + 72,
5569 EL_CUSTOM_START + 73,
5570 EL_CUSTOM_START + 74,
5571 EL_CUSTOM_START + 75,
5573 EL_CUSTOM_START + 76,
5574 EL_CUSTOM_START + 77,
5575 EL_CUSTOM_START + 78,
5576 EL_CUSTOM_START + 79,
5578 EL_CUSTOM_START + 80,
5579 EL_CUSTOM_START + 81,
5580 EL_CUSTOM_START + 82,
5581 EL_CUSTOM_START + 83,
5583 EL_CUSTOM_START + 84,
5584 EL_CUSTOM_START + 85,
5585 EL_CUSTOM_START + 86,
5586 EL_CUSTOM_START + 87,
5588 EL_CUSTOM_START + 88,
5589 EL_CUSTOM_START + 89,
5590 EL_CUSTOM_START + 90,
5591 EL_CUSTOM_START + 91,
5593 EL_CUSTOM_START + 92,
5594 EL_CUSTOM_START + 93,
5595 EL_CUSTOM_START + 94,
5596 EL_CUSTOM_START + 95,
5598 EL_CUSTOM_START + 96,
5599 EL_CUSTOM_START + 97,
5600 EL_CUSTOM_START + 98,
5601 EL_CUSTOM_START + 99,
5603 EL_CUSTOM_START + 100,
5604 EL_CUSTOM_START + 101,
5605 EL_CUSTOM_START + 102,
5606 EL_CUSTOM_START + 103,
5608 EL_CUSTOM_START + 104,
5609 EL_CUSTOM_START + 105,
5610 EL_CUSTOM_START + 106,
5611 EL_CUSTOM_START + 107,
5613 EL_CUSTOM_START + 108,
5614 EL_CUSTOM_START + 109,
5615 EL_CUSTOM_START + 110,
5616 EL_CUSTOM_START + 111,
5618 EL_CUSTOM_START + 112,
5619 EL_CUSTOM_START + 113,
5620 EL_CUSTOM_START + 114,
5621 EL_CUSTOM_START + 115,
5623 EL_CUSTOM_START + 116,
5624 EL_CUSTOM_START + 117,
5625 EL_CUSTOM_START + 118,
5626 EL_CUSTOM_START + 119,
5628 EL_CUSTOM_START + 120,
5629 EL_CUSTOM_START + 121,
5630 EL_CUSTOM_START + 122,
5631 EL_CUSTOM_START + 123,
5633 EL_CUSTOM_START + 124,
5634 EL_CUSTOM_START + 125,
5635 EL_CUSTOM_START + 126,
5636 EL_CUSTOM_START + 127,
5638 EL_CUSTOM_START + 128,
5639 EL_CUSTOM_START + 129,
5640 EL_CUSTOM_START + 130,
5641 EL_CUSTOM_START + 131,
5643 EL_CUSTOM_START + 132,
5644 EL_CUSTOM_START + 133,
5645 EL_CUSTOM_START + 134,
5646 EL_CUSTOM_START + 135,
5648 EL_CUSTOM_START + 136,
5649 EL_CUSTOM_START + 137,
5650 EL_CUSTOM_START + 138,
5651 EL_CUSTOM_START + 139,
5653 EL_CUSTOM_START + 140,
5654 EL_CUSTOM_START + 141,
5655 EL_CUSTOM_START + 142,
5656 EL_CUSTOM_START + 143,
5658 EL_CUSTOM_START + 144,
5659 EL_CUSTOM_START + 145,
5660 EL_CUSTOM_START + 146,
5661 EL_CUSTOM_START + 147,
5663 EL_CUSTOM_START + 148,
5664 EL_CUSTOM_START + 149,
5665 EL_CUSTOM_START + 150,
5666 EL_CUSTOM_START + 151,
5668 EL_CUSTOM_START + 152,
5669 EL_CUSTOM_START + 153,
5670 EL_CUSTOM_START + 154,
5671 EL_CUSTOM_START + 155,
5673 EL_CUSTOM_START + 156,
5674 EL_CUSTOM_START + 157,
5675 EL_CUSTOM_START + 158,
5676 EL_CUSTOM_START + 159,
5678 EL_CUSTOM_START + 160,
5679 EL_CUSTOM_START + 161,
5680 EL_CUSTOM_START + 162,
5681 EL_CUSTOM_START + 163,
5683 EL_CUSTOM_START + 164,
5684 EL_CUSTOM_START + 165,
5685 EL_CUSTOM_START + 166,
5686 EL_CUSTOM_START + 167,
5688 EL_CUSTOM_START + 168,
5689 EL_CUSTOM_START + 169,
5690 EL_CUSTOM_START + 170,
5691 EL_CUSTOM_START + 171,
5693 EL_CUSTOM_START + 172,
5694 EL_CUSTOM_START + 173,
5695 EL_CUSTOM_START + 174,
5696 EL_CUSTOM_START + 175,
5698 EL_CUSTOM_START + 176,
5699 EL_CUSTOM_START + 177,
5700 EL_CUSTOM_START + 178,
5701 EL_CUSTOM_START + 179,
5703 EL_CUSTOM_START + 180,
5704 EL_CUSTOM_START + 181,
5705 EL_CUSTOM_START + 182,
5706 EL_CUSTOM_START + 183,
5708 EL_CUSTOM_START + 184,
5709 EL_CUSTOM_START + 185,
5710 EL_CUSTOM_START + 186,
5711 EL_CUSTOM_START + 187,
5713 EL_CUSTOM_START + 188,
5714 EL_CUSTOM_START + 189,
5715 EL_CUSTOM_START + 190,
5716 EL_CUSTOM_START + 191,
5718 EL_CUSTOM_START + 192,
5719 EL_CUSTOM_START + 193,
5720 EL_CUSTOM_START + 194,
5721 EL_CUSTOM_START + 195,
5723 EL_CUSTOM_START + 196,
5724 EL_CUSTOM_START + 197,
5725 EL_CUSTOM_START + 198,
5726 EL_CUSTOM_START + 199,
5728 EL_CUSTOM_START + 200,
5729 EL_CUSTOM_START + 201,
5730 EL_CUSTOM_START + 202,
5731 EL_CUSTOM_START + 203,
5733 EL_CUSTOM_START + 204,
5734 EL_CUSTOM_START + 205,
5735 EL_CUSTOM_START + 206,
5736 EL_CUSTOM_START + 207,
5738 EL_CUSTOM_START + 208,
5739 EL_CUSTOM_START + 209,
5740 EL_CUSTOM_START + 210,
5741 EL_CUSTOM_START + 211,
5743 EL_CUSTOM_START + 212,
5744 EL_CUSTOM_START + 213,
5745 EL_CUSTOM_START + 214,
5746 EL_CUSTOM_START + 215,
5748 EL_CUSTOM_START + 216,
5749 EL_CUSTOM_START + 217,
5750 EL_CUSTOM_START + 218,
5751 EL_CUSTOM_START + 219,
5753 EL_CUSTOM_START + 220,
5754 EL_CUSTOM_START + 221,
5755 EL_CUSTOM_START + 222,
5756 EL_CUSTOM_START + 223,
5758 EL_CUSTOM_START + 224,
5759 EL_CUSTOM_START + 225,
5760 EL_CUSTOM_START + 226,
5761 EL_CUSTOM_START + 227,
5763 EL_CUSTOM_START + 228,
5764 EL_CUSTOM_START + 229,
5765 EL_CUSTOM_START + 230,
5766 EL_CUSTOM_START + 231,
5768 EL_CUSTOM_START + 232,
5769 EL_CUSTOM_START + 233,
5770 EL_CUSTOM_START + 234,
5771 EL_CUSTOM_START + 235,
5773 EL_CUSTOM_START + 236,
5774 EL_CUSTOM_START + 237,
5775 EL_CUSTOM_START + 238,
5776 EL_CUSTOM_START + 239,
5778 EL_CUSTOM_START + 240,
5779 EL_CUSTOM_START + 241,
5780 EL_CUSTOM_START + 242,
5781 EL_CUSTOM_START + 243,
5783 EL_CUSTOM_START + 244,
5784 EL_CUSTOM_START + 245,
5785 EL_CUSTOM_START + 246,
5786 EL_CUSTOM_START + 247,
5788 EL_CUSTOM_START + 248,
5789 EL_CUSTOM_START + 249,
5790 EL_CUSTOM_START + 250,
5791 EL_CUSTOM_START + 251,
5793 EL_CUSTOM_START + 252,
5794 EL_CUSTOM_START + 253,
5795 EL_CUSTOM_START + 254,
5796 EL_CUSTOM_START + 255
5798 static int *editor_hl_custom_ptr = editor_hl_custom;
5799 static int *editor_el_custom_ptr = editor_el_custom;
5800 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5801 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5803 static int editor_hl_group[] =
5805 EL_INTERNAL_CASCADE_GE_ACTIVE,
5811 static int editor_el_group[] =
5825 EL_GROUP_START + 10,
5826 EL_GROUP_START + 11,
5828 EL_GROUP_START + 12,
5829 EL_GROUP_START + 13,
5830 EL_GROUP_START + 14,
5831 EL_GROUP_START + 15,
5833 EL_GROUP_START + 16,
5834 EL_GROUP_START + 17,
5835 EL_GROUP_START + 18,
5836 EL_GROUP_START + 19,
5838 EL_GROUP_START + 20,
5839 EL_GROUP_START + 21,
5840 EL_GROUP_START + 22,
5841 EL_GROUP_START + 23,
5843 EL_GROUP_START + 24,
5844 EL_GROUP_START + 25,
5845 EL_GROUP_START + 26,
5846 EL_GROUP_START + 27,
5848 EL_GROUP_START + 28,
5849 EL_GROUP_START + 29,
5850 EL_GROUP_START + 30,
5853 static int *editor_hl_group_ptr = editor_hl_group;
5854 static int *editor_el_group_ptr = editor_el_group;
5855 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5856 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5858 static int editor_hl_empty_space[] =
5860 EL_INTERNAL_CASCADE_ES_ACTIVE,
5866 static int editor_el_empty_space[] =
5888 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
5889 static int *editor_el_empty_space_ptr = editor_el_empty_space;
5890 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
5891 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
5893 static int editor_hl_reference[] =
5895 EL_INTERNAL_CASCADE_REF_ACTIVE,
5901 static int editor_el_reference[] =
5905 EL_TRIGGER_CE_VALUE,
5906 EL_TRIGGER_CE_SCORE,
5910 EL_CURRENT_CE_VALUE,
5911 EL_CURRENT_CE_SCORE,
5933 static int *editor_hl_reference_ptr = editor_hl_reference;
5934 static int *editor_el_reference_ptr = editor_el_reference;
5935 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5936 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5938 static int editor_hl_user_defined[] =
5940 EL_INTERNAL_CASCADE_USER_ACTIVE,
5946 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5947 static int *editor_el_user_defined_ptr = NULL;
5948 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5949 static int num_editor_el_user_defined = 0;
5951 static int editor_hl_dynamic[] =
5953 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5959 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5960 static int *editor_el_dynamic_ptr = NULL;
5961 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5962 static int num_editor_el_dynamic = 0;
5964 static int editor_hl_empty[] = { EL_EMPTY };
5965 static int *editor_el_empty = NULL; // dynamically allocated
5967 static int *editor_hl_empty_ptr = editor_hl_empty;
5968 static int *editor_el_empty_ptr = NULL;
5969 static int num_editor_hl_empty = 0;
5970 static int num_editor_el_empty = 0; // dynamically determined, if needed
5972 static boolean use_el_empty = FALSE;
5974 static int *editor_elements = NULL; // dynamically allocated
5975 static int num_editor_elements = 0; // dynamically determined
5977 static boolean setup_editor_cascade_never = FALSE;
5979 static boolean setup_editor_el_players = TRUE;
5980 static boolean setup_editor_el_boulderdash = TRUE;
5981 static boolean setup_editor_el_boulderdash_native = TRUE;
5982 static boolean setup_editor_el_emerald_mine = TRUE;
5983 static boolean setup_editor_el_emerald_mine_club = TRUE;
5984 static boolean setup_editor_el_more = TRUE;
5985 static boolean setup_editor_el_sokoban = TRUE;
5986 static boolean setup_editor_el_supaplex = TRUE;
5987 static boolean setup_editor_el_diamond_caves = TRUE;
5988 static boolean setup_editor_el_dx_boulderdash = TRUE;
5989 static boolean setup_editor_el_mirror_magic = TRUE;
5990 static boolean setup_editor_el_deflektor = TRUE;
5991 static boolean setup_editor_el_chars = TRUE;
5992 static boolean setup_editor_el_steel_chars = TRUE;
5993 static boolean setup_editor_el_custom = TRUE;
5994 static boolean setup_editor_el_user_defined = TRUE;
5995 static boolean setup_editor_el_dynamic = TRUE;
5997 static int editor_hl_unused[] = { EL_EMPTY };
5998 static int *editor_hl_unused_ptr = editor_hl_unused;
5999 static int num_editor_hl_unused = 0;
6003 boolean *setup_value;
6004 boolean *setup_cascade_value;
6006 int **headline_list;
6007 int *headline_list_size;
6010 int *element_list_size;
6012 boolean last_setup_value;
6014 editor_elements_info[] =
6017 &setup_editor_el_players,
6018 &setup_editor_cascade_never,
6019 &editor_hl_unused_ptr, &num_editor_hl_unused,
6020 &editor_el_players_ptr, &num_editor_el_players
6023 &setup_editor_el_boulderdash,
6024 &setup.editor_cascade.el_bd,
6025 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
6026 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
6029 &setup_editor_el_boulderdash_native,
6030 &setup.editor_cascade.el_bd_native,
6031 &editor_hl_boulderdash_native_ptr, &num_editor_hl_boulderdash_native,
6032 &editor_el_boulderdash_native_ptr, &num_editor_el_boulderdash_native
6035 &setup_editor_el_emerald_mine,
6036 &setup.editor_cascade.el_em,
6037 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
6038 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
6041 &setup_editor_el_emerald_mine_club,
6042 &setup.editor_cascade.el_emc,
6043 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
6044 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
6047 &setup_editor_el_more,
6048 &setup.editor_cascade.el_rnd,
6049 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
6050 &editor_el_rnd_ptr, &num_editor_el_rnd
6053 &setup_editor_el_sokoban,
6054 &setup.editor_cascade.el_sb,
6055 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
6056 &editor_el_sokoban_ptr, &num_editor_el_sokoban
6059 &setup_editor_el_supaplex,
6060 &setup.editor_cascade.el_sp,
6061 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
6062 &editor_el_supaplex_ptr, &num_editor_el_supaplex
6065 &setup_editor_el_diamond_caves,
6066 &setup.editor_cascade.el_dc,
6067 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
6068 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
6071 &setup_editor_el_dx_boulderdash,
6072 &setup.editor_cascade.el_dx,
6073 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
6074 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
6077 &setup_editor_el_mirror_magic,
6078 &setup.editor_cascade.el_mm,
6079 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
6080 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
6083 &setup_editor_el_deflektor,
6084 &setup.editor_cascade.el_df,
6085 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
6086 &editor_el_deflektor_ptr, &num_editor_el_deflektor
6089 &setup_editor_el_chars,
6090 &setup.editor_cascade.el_chars,
6091 &editor_hl_chars_ptr, &num_editor_hl_chars,
6092 &editor_el_chars_ptr, &num_editor_el_chars
6095 &setup_editor_el_steel_chars,
6096 &setup.editor_cascade.el_steel_chars,
6097 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
6098 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
6101 &setup_editor_el_custom,
6102 &setup.editor_cascade.el_ce,
6103 &editor_hl_custom_ptr, &num_editor_hl_custom,
6104 &editor_el_custom_ptr, &num_editor_el_custom
6107 &setup_editor_el_custom,
6108 &setup.editor_cascade.el_ge,
6109 &editor_hl_group_ptr, &num_editor_hl_group,
6110 &editor_el_group_ptr, &num_editor_el_group
6113 &setup_editor_el_custom,
6114 &setup.editor_cascade.el_es,
6115 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
6116 &editor_el_empty_space_ptr, &num_editor_el_empty_space
6119 &setup_editor_el_custom,
6120 &setup.editor_cascade.el_ref,
6121 &editor_hl_reference_ptr, &num_editor_hl_reference,
6122 &editor_el_reference_ptr, &num_editor_el_reference
6125 &setup_editor_el_user_defined,
6126 &setup.editor_cascade.el_user,
6127 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
6128 &editor_el_user_defined_ptr, &num_editor_el_user_defined
6131 &setup_editor_el_dynamic,
6132 &setup.editor_cascade.el_dynamic,
6133 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
6134 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
6139 &editor_hl_empty_ptr, &num_editor_hl_empty,
6140 &editor_el_empty_ptr, &num_editor_el_empty,
6150 static struct XY xy_directions[] =
6159 // ----------------------------------------------------------------------------
6161 // ----------------------------------------------------------------------------
6163 static int getMaxInfoTextLength(void)
6165 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
6168 static int getTextWidthForGadget(char *text)
6173 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
6176 static int getTextWidthForDrawingArea(char *text)
6181 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
6184 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
6186 return (gi->x + gi->width + getTextWidthForGadget(text));
6189 static char *getElementInfoText(int element)
6191 char *info_text = NULL;
6193 if (element < MAX_NUM_ELEMENTS)
6195 if (strlen(element_info[element].description) > 0)
6196 info_text = element_info[element].description;
6197 else if (element_info[element].custom_description != NULL)
6198 info_text = element_info[element].custom_description;
6199 else if (element_info[element].editor_description != NULL)
6200 info_text = element_info[element].editor_description;
6203 if (info_text == NULL)
6204 info_text = INFOTEXT_UNKNOWN_ELEMENT;
6209 static char *getElementDescriptionFilenameExt(char *basename)
6211 char *elements_subdir = ELEMENTS_DIRECTORY;
6212 static char *elements_subdir2 = NULL;
6213 static char *filename = NULL;
6215 if (elements_subdir2 == NULL)
6216 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
6218 checked_free(filename);
6220 // 1st try: look for element description in current level set directory
6221 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
6222 if (fileExists(filename))
6227 // 2nd try: look for element description in the game's base directory
6228 filename = getPath3(options.docs_directory, elements_subdir, basename);
6229 if (fileExists(filename))
6235 static char *getElementDescriptionFilename(int element)
6237 char basename[MAX_FILENAME_LEN];
6240 // 1st try: look for element description file for exactly this element
6241 sprintf(basename, "%s.txt", element_info[element].token_name);
6242 filename = getElementDescriptionFilenameExt(basename);
6243 if (filename != NULL)
6246 // 2nd try: look for element description file for this element's class
6247 sprintf(basename, "%s.txt", element_info[element].class_name);
6248 filename = getElementDescriptionFilenameExt(basename);
6249 if (filename != NULL)
6252 // 3rd try: look for generic fallback text file for any element
6253 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
6254 if (filename != NULL)
6260 static boolean suppressBorderElement(void)
6262 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
6263 lev_fieldx <= MAX_ED_FIELDX &&
6264 lev_fieldy <= MAX_ED_FIELDY);
6267 static void InitDynamicEditorElementList(int **elements, int *num_elements)
6269 boolean element_found[NUM_FILE_ELEMENTS];
6272 // initialize list of used elements to "not used"
6273 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6274 element_found[i] = FALSE;
6276 // find all elements used in current level
6277 for (y = 0; y < lev_fieldy; y++)
6279 for (x = 0; x < lev_fieldx; x++)
6281 if (Tile[x][y] >= NUM_FILE_ELEMENTS) // should never happen
6284 if (IS_MM_WALL(Tile[x][y]))
6285 element_found[map_mm_wall_element(Tile[x][y])] = TRUE;
6287 element_found[Tile[x][y]] = TRUE;
6293 // count number of elements used in current level
6294 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6295 if (element_found[i])
6298 // add space for up to 3 more elements for padding that may be needed
6301 // free memory for old list of elements, if needed
6302 checked_free(*elements);
6304 // allocate memory for new list of elements
6305 *elements = checked_malloc(*num_elements * sizeof(int));
6309 // add all elements used in current level (non-custom/group/empty elements)
6310 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6311 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) ||
6312 IS_GROUP_ELEMENT(i) ||
6313 IS_EMPTY_ELEMENT(i)))
6314 (*elements)[(*num_elements)++] = i;
6316 // add all elements used in current level (custom/group/empty elements)
6317 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6318 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) ||
6319 IS_GROUP_ELEMENT(i) ||
6320 IS_EMPTY_ELEMENT(i)))
6321 (*elements)[(*num_elements)++] = i;
6323 while (*num_elements % 4) // pad with empty elements, if needed
6324 (*elements)[(*num_elements)++] = EL_EMPTY;
6327 static void ReinitializeElementList_EnableSections(void)
6329 // default: enable all element sections
6331 setup_editor_el_players = TRUE;
6332 setup_editor_el_boulderdash = TRUE;
6333 setup_editor_el_boulderdash_native = TRUE;
6334 setup_editor_el_emerald_mine = TRUE;
6335 setup_editor_el_emerald_mine_club = TRUE;
6336 setup_editor_el_more = TRUE;
6337 setup_editor_el_sokoban = TRUE;
6338 setup_editor_el_supaplex = TRUE;
6339 setup_editor_el_diamond_caves = TRUE;
6340 setup_editor_el_dx_boulderdash = TRUE;
6341 setup_editor_el_mirror_magic = TRUE;
6342 setup_editor_el_deflektor = TRUE;
6343 setup_editor_el_chars = TRUE;
6344 setup_editor_el_steel_chars = TRUE;
6346 setup_editor_el_custom = TRUE;
6347 setup_editor_el_user_defined = TRUE;
6348 setup_editor_el_dynamic = TRUE;
6350 // now disable all element sections not to be displayed
6352 if (!setup.editor.el_classic)
6354 setup_editor_el_players = FALSE;
6355 setup_editor_el_boulderdash = FALSE;
6356 setup_editor_el_boulderdash_native = FALSE;
6357 setup_editor_el_emerald_mine = FALSE;
6358 setup_editor_el_emerald_mine_club = FALSE;
6359 setup_editor_el_more = FALSE;
6360 setup_editor_el_sokoban = FALSE;
6361 setup_editor_el_supaplex = FALSE;
6362 setup_editor_el_diamond_caves = FALSE;
6363 setup_editor_el_dx_boulderdash = FALSE;
6364 setup_editor_el_mirror_magic = FALSE;
6365 setup_editor_el_deflektor = FALSE;
6366 setup_editor_el_chars = FALSE;
6367 setup_editor_el_steel_chars = FALSE;
6370 if (!setup.editor.el_custom)
6372 setup_editor_el_custom = FALSE;
6375 if (!setup.editor.el_user_defined)
6377 setup_editor_el_user_defined = FALSE;
6380 if (!setup.editor.el_dynamic)
6382 setup_editor_el_dynamic = FALSE;
6385 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
6387 setup_editor_el_boulderdash_native = FALSE;
6388 setup_editor_el_mirror_magic = FALSE;
6389 setup_editor_el_deflektor = FALSE;
6391 else if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
6393 setup_editor_el_players = FALSE;
6394 setup_editor_el_boulderdash = FALSE;
6395 setup_editor_el_emerald_mine = FALSE;
6396 setup_editor_el_emerald_mine_club = FALSE;
6397 setup_editor_el_more = FALSE;
6398 setup_editor_el_sokoban = FALSE;
6399 setup_editor_el_supaplex = FALSE;
6400 setup_editor_el_diamond_caves = FALSE;
6401 setup_editor_el_dx_boulderdash = FALSE;
6402 setup_editor_el_mirror_magic = FALSE;
6403 setup_editor_el_deflektor = FALSE;
6404 setup_editor_el_chars = FALSE;
6405 setup_editor_el_steel_chars = FALSE;
6407 setup_editor_el_custom = FALSE;
6409 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
6411 setup_editor_el_boulderdash = FALSE;
6412 setup_editor_el_boulderdash_native = FALSE;
6413 setup_editor_el_more = FALSE;
6414 setup_editor_el_sokoban = FALSE;
6415 setup_editor_el_supaplex = FALSE;
6416 setup_editor_el_diamond_caves = FALSE;
6417 setup_editor_el_dx_boulderdash = FALSE;
6418 setup_editor_el_mirror_magic = FALSE;
6419 setup_editor_el_deflektor = FALSE;
6420 setup_editor_el_steel_chars = FALSE;
6422 setup_editor_el_custom = FALSE;
6424 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
6426 setup_editor_el_players = FALSE;
6427 setup_editor_el_boulderdash = FALSE;
6428 setup_editor_el_boulderdash_native = FALSE;
6429 setup_editor_el_emerald_mine = FALSE;
6430 setup_editor_el_emerald_mine_club = FALSE;
6431 setup_editor_el_more = FALSE;
6432 setup_editor_el_sokoban = FALSE;
6433 setup_editor_el_diamond_caves = FALSE;
6434 setup_editor_el_dx_boulderdash = FALSE;
6435 setup_editor_el_mirror_magic = FALSE;
6436 setup_editor_el_deflektor = FALSE;
6437 setup_editor_el_chars = FALSE;
6438 setup_editor_el_steel_chars = FALSE;
6440 setup_editor_el_custom = FALSE;
6442 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
6444 setup_editor_el_players = FALSE;
6445 setup_editor_el_boulderdash = FALSE;
6446 setup_editor_el_boulderdash_native = FALSE;
6447 setup_editor_el_emerald_mine = FALSE;
6448 setup_editor_el_emerald_mine_club = FALSE;
6449 setup_editor_el_more = FALSE;
6450 setup_editor_el_sokoban = FALSE;
6451 setup_editor_el_supaplex = FALSE;
6452 setup_editor_el_diamond_caves = FALSE;
6453 setup_editor_el_dx_boulderdash = FALSE;
6454 setup_editor_el_steel_chars = FALSE;
6456 setup_editor_el_custom = FALSE;
6460 static void ReinitializeElementList(void)
6462 static boolean initialization_needed = TRUE;
6466 ReinitializeElementList_EnableSections();
6468 if (initialization_needed)
6470 LoadSetup_EditorCascade(); // load last editor cascade state
6472 // initialize editor cascade element from saved cascade state
6473 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6475 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
6476 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
6478 if (IS_EDITOR_CASCADE(*cascade_element))
6480 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
6481 EL_CASCADE_INACTIVE(*cascade_element));
6484 initialization_needed = FALSE;
6487 checked_free(editor_elements);
6489 // reload optional user defined element list for each invocation of editor
6490 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
6491 &num_editor_el_user_defined);
6493 // initialize dynamic level element list for each invocation of editor
6494 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
6495 &num_editor_el_dynamic);
6497 // initialize list of empty elements (used for padding, if needed)
6498 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6499 editor_el_empty[i] = EL_EMPTY;
6501 // do some sanity checks for each element from element list
6502 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6504 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6506 int element = (*editor_elements_info[i].element_list)[j];
6508 if (element >= NUM_FILE_ELEMENTS)
6509 Warn("editor element %d is runtime element", element);
6511 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
6512 Warn("no element description text for element %d", element);
6516 num_editor_elements = 0;
6517 use_el_empty = FALSE;
6519 // determine size of element list
6520 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6522 if (*editor_elements_info[i].setup_value)
6524 boolean found_inactive_cascade = FALSE;
6526 if (setup.editor.el_headlines)
6528 // required for correct padding of palette headline buttons
6529 if (*editor_elements_info[i].headline_list_size > 0)
6530 num_editor_elements += ED_ELEMENTLIST_COLS;
6532 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6534 int element = (*editor_elements_info[i].headline_list)[j];
6536 if (IS_EDITOR_CASCADE_INACTIVE(element))
6537 found_inactive_cascade = TRUE;
6541 if (found_inactive_cascade)
6544 // required for correct padding of palette element buttons
6545 int element_list_size = *editor_elements_info[i].element_list_size;
6547 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6548 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6550 num_editor_elements += element_buttons;
6554 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
6556 // offer at least as many elements as element buttons exist
6557 use_el_empty = TRUE;
6558 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
6560 num_editor_elements += num_editor_el_empty;
6564 num_editor_el_empty = 0;
6567 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
6569 // fill element list
6570 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6572 boolean found_inactive_cascade = FALSE;
6574 if (*editor_elements_info[i].setup_value)
6576 if (setup.editor.el_headlines)
6578 // required for correct padding of palette headline buttons
6579 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6580 ED_ELEMENTLIST_COLS : 0);
6582 for (j = 0; j < headline_size; j++)
6584 // use empty elements for padding of palette headline buttons
6585 int element = (j < *editor_elements_info[i].headline_list_size ?
6586 (*editor_elements_info[i].headline_list)[j] :
6587 editor_el_empty[0]);
6589 editor_elements[pos++] = element;
6591 if (IS_EDITOR_CASCADE_INACTIVE(element))
6592 found_inactive_cascade = TRUE;
6596 if (found_inactive_cascade)
6599 // required for correct padding of palette element buttons
6600 int element_list_size = *editor_elements_info[i].element_list_size;
6602 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6603 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6605 // copy all elements from element list
6606 for (j = 0; j < element_list_size; j++)
6607 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6609 // use empty elements for padding of palette element buttons
6610 for (j = 0; j < element_buttons - element_list_size; j++)
6611 editor_elements[pos++] = editor_el_empty[0];
6615 // (this function is also called before editor gadgets are initialized!)
6616 AdjustElementListScrollbar();
6619 void PrintEditorElementList(void)
6621 boolean *stop = &setup_editor_el_user_defined;
6624 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6626 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6628 if (IS_EDITOR_CASCADE(cascade_element))
6630 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6631 char *headline = element_info[cascade_element_show].editor_description;
6633 PrintLineWithPrefix("# ", "-", 77);
6634 Print("# %s\n", headline);
6635 PrintLineWithPrefix("# ", "-", 77);
6638 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6640 int element = (*editor_elements_info[i].headline_list)[j];
6642 if (IS_EDITOR_CASCADE(element))
6643 element = EL_CHAR_MINUS;
6645 Print("# %s\n", element_info[element].token_name);
6651 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6653 int element = (*editor_elements_info[i].element_list)[j];
6655 Print("# %s\n", element_info[element].token_name);
6663 static void ReinitializeElementListButtons(void)
6665 static boolean last_setup_value_headlines = FALSE;
6666 static boolean initialization_needed = TRUE;
6669 if (!initialization_needed) // check if editor element setup has changed
6671 if (last_setup_value_headlines != setup.editor.el_headlines)
6672 initialization_needed = TRUE;
6674 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6675 if (editor_elements_info[i].last_setup_value !=
6676 *editor_elements_info[i].setup_value)
6677 initialization_needed = TRUE;
6680 if (!initialization_needed)
6683 FreeLevelEditorGadgets();
6684 CreateLevelEditorGadgets();
6686 // store current setup values for next invocation of this function
6687 last_setup_value_headlines = setup.editor.el_headlines;
6688 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6689 editor_elements_info[i].last_setup_value =
6690 *editor_elements_info[i].setup_value;
6692 initialization_needed = FALSE;
6695 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6698 int border_graphic =
6699 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6700 struct GraphicInfo *g = &graphic_info[border_graphic];
6701 Bitmap *src_bitmap = g->bitmap;
6702 int src_x = g->src_x;
6703 int src_y = g->src_y;
6704 int border_size = g->border_size;
6705 int border_xpos = g->width - border_size;
6706 int border_ypos = g->height - border_size;
6707 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6710 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6711 border_size, border_size,
6712 dest_x - border_size, dest_y - border_size);
6713 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6714 border_size, border_size,
6715 dest_x + width, dest_y - border_size);
6716 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6717 border_size, border_size,
6718 dest_x - border_size, dest_y + height);
6719 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6720 border_size, border_size,
6721 dest_x + width, dest_y + height);
6723 for (i = 0; i < width / tilesize; i++)
6725 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6726 tilesize, border_size,
6727 dest_x + i * tilesize, dest_y - border_size);
6728 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6729 tilesize, border_size,
6730 dest_x + i * tilesize, dest_y + height);
6733 for (i = 0; i < height / tilesize; i++)
6735 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6736 border_size, tilesize,
6737 dest_x - border_size, dest_y + i * tilesize);
6738 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6739 border_size, tilesize,
6740 dest_x + width, dest_y + i * tilesize);
6743 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6746 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6748 int xsize_tile = MAX(ed_tilesize, xsize);
6749 int ysize_tile = MAX(ed_tilesize, ysize);
6750 int xsize_full = xsize + 1;
6751 int ysize_full = ysize + 1;
6752 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6753 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6754 Pixel line_color = getTabulatorBarColor();
6756 if (line_color == BLACK_PIXEL) // black => transparent
6759 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6760 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6761 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6764 static void DrawEditorLevelBorderLinesIfNeeded(void)
6766 int xsize = lev_fieldx * ed_tilesize;
6767 int ysize = lev_fieldy * ed_tilesize;
6768 int line_size = getTabulatorBarHeight();
6770 if (!suppressBorderElement())
6773 // draw little border line around editable level playfield
6776 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6779 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6781 if (xsize < SXSIZE && ysize < SYSIZE)
6782 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6785 static void DrawEditorElement(int x, int y, int element)
6787 DrawSizedElement(x, y, element, ed_tilesize);
6790 static void DrawEditorElementThruMask(int x, int y, int element)
6792 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6795 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6797 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6800 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6802 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6803 DrawEditorLevelBorderLinesIfNeeded();
6806 static void DrawDrawingArea(int id)
6808 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6811 int *value = drawingarea_info[id].value;
6812 int area_xsize = drawingarea_info[id].area_xsize;
6813 int area_ysize = drawingarea_info[id].area_ysize;
6814 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6816 for (x = 0; x < area_xsize; x++)
6817 for (y = 0; y < area_ysize; y++)
6818 DrawSizedGraphicExt(drawto,
6819 gi->x + x * tilesize,
6820 gi->y + y * tilesize,
6821 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6824 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6827 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6828 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6830 BlitBitmap(drawto, drawto,
6831 SX + (dx == -1 ? ed_tilesize : 0),
6832 SY + (dy == -1 ? ed_tilesize : 0),
6833 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6834 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6835 SX + (dx == +1 ? ed_tilesize : 0),
6836 SY + (dy == +1 ? ed_tilesize : 0));
6840 x = (dx == 1 ? 0 : ed_fieldx - 1);
6841 for (y = 0; y < ed_fieldy; y++)
6842 DrawEditorElementOrWall(x, y, from_x, from_y);
6846 y = (dy == 1 ? 0 : ed_fieldy - 1);
6847 for (x = 0; x < ed_fieldx; x++)
6848 DrawEditorElementOrWall(x, y, from_x, from_y);
6851 redraw_mask |= REDRAW_FIELD;
6855 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6858 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6861 static void CreateControlButtons(void)
6863 struct GadgetInfo *gi;
6866 // create toolbox buttons
6867 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6869 int type_id = controlbutton_info[i].gadget_id; // same as gadget ID here
6870 int id = controlbutton_info[i].gadget_id;
6871 int type = controlbutton_info[i].gadget_type;
6872 int graphic = controlbutton_info[i].graphic;
6873 struct XYTileSize *pos = controlbutton_info[i].pos;
6874 struct GraphicInfo *gd = &graphic_info[graphic];
6875 Bitmap *deco_bitmap = NULL;
6876 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6877 int tile_size = 0, deco_shift = 0;
6878 boolean deco_masked = FALSE;
6879 int gd_x1 = gd->src_x;
6880 int gd_y1 = gd->src_y;
6881 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6882 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6883 int gd_x1a = gd->src_x + gd->active_xoffset;
6884 int gd_y1a = gd->src_y + gd->active_yoffset;
6885 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6886 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6889 unsigned int event_mask;
6890 int radio_button_nr = RADIO_NR_NONE;
6891 boolean checked = FALSE;
6894 Fail("'controlbutton_info' structure corrupted at index %d -- please fix", i);
6896 if (type == GD_TYPE_RADIO_BUTTON)
6898 event_mask = GD_EVENT_PRESSED;
6899 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6901 if (id == drawing_function)
6906 if (id == GADGET_ID_WRAP_LEFT ||
6907 id == GADGET_ID_WRAP_RIGHT ||
6908 id == GADGET_ID_WRAP_UP ||
6909 id == GADGET_ID_WRAP_DOWN)
6910 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6912 event_mask = GD_EVENT_RELEASED;
6915 if (id == GADGET_ID_PROPERTIES ||
6916 id == GADGET_ID_PALETTE)
6921 else if (id == GADGET_ID_ELEMENT_LEFT ||
6922 id == GADGET_ID_ELEMENT_MIDDLE ||
6923 id == GADGET_ID_ELEMENT_RIGHT)
6928 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6929 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6930 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6932 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6933 editor.button.element_left.tile_size :
6934 id == GADGET_ID_ELEMENT_MIDDLE ?
6935 editor.button.element_middle.tile_size :
6936 id == GADGET_ID_ELEMENT_RIGHT ?
6937 editor.button.element_right.tile_size : 0);
6939 // make sure that decoration does not overlap gadget border
6940 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6942 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6944 deco_xpos = (gd->width - tile_size) / 2;
6945 deco_ypos = (gd->height - tile_size) / 2;
6947 deco_masked = gd->draw_masked;
6955 gi = CreateGadget(GDI_CUSTOM_ID, id,
6956 GDI_CUSTOM_TYPE_ID, type_id,
6957 GDI_IMAGE_ID, graphic,
6958 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6961 GDI_WIDTH, gd->width,
6962 GDI_HEIGHT, gd->height,
6964 GDI_STATE, GD_BUTTON_UNPRESSED,
6965 GDI_RADIO_NR, radio_button_nr,
6966 GDI_CHECKED, checked,
6967 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6968 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6969 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6970 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6971 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6972 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6973 GDI_DECORATION_SIZE, tile_size, tile_size,
6974 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6975 GDI_DECORATION_MASKED, deco_masked,
6976 GDI_EVENT_MASK, event_mask,
6977 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6978 GDI_CALLBACK_ACTION, HandleControlButtons,
6982 Fail("cannot create gadget");
6984 level_editor_gadget[id] = gi;
6987 // these values are not constant, but can change at runtime
6988 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6989 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6990 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6991 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6992 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6993 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6994 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6995 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6996 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6997 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6998 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6999 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
7001 // create buttons for scrolling of drawing area and element list
7002 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
7004 int id = scrollbutton_info[i].gadget_id;
7005 int type_id = scrollbutton_info[i].gadget_type_id;
7006 int graphic = scrollbutton_info[i].graphic;
7007 struct GraphicInfo *gd = &graphic_info[graphic];
7008 Bitmap *gd_bitmap = gd->bitmap;
7009 int gd_x1 = gd->src_x;
7010 int gd_y1 = gd->src_y;
7011 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7012 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7013 int width = gd->width;
7014 int height = gd->height;
7015 int x = scrollbutton_pos[i].x;
7016 int y = scrollbutton_pos[i].y;
7017 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7020 Fail("'scrollbutton_info' structure corrupted at index %d -- please fix", i);
7022 if (id == GADGET_ID_SCROLL_LIST_UP ||
7023 id == GADGET_ID_SCROLL_LIST_DOWN)
7034 gi = CreateGadget(GDI_CUSTOM_ID, id,
7035 GDI_CUSTOM_TYPE_ID, type_id,
7036 GDI_IMAGE_ID, graphic,
7037 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
7042 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7043 GDI_STATE, GD_BUTTON_UNPRESSED,
7044 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7045 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7046 GDI_EVENT_MASK, event_mask,
7047 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7048 GDI_CALLBACK_ACTION, HandleControlButtons,
7052 Fail("cannot create gadget");
7054 level_editor_gadget[id] = gi;
7057 // create buttons for element list
7058 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7061 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
7062 int graphic = IMG_EDITOR_PALETTE_BUTTON;
7063 struct GraphicInfo *gd = &graphic_info[graphic];
7064 Bitmap *gd_bitmap = gd->bitmap;
7065 Bitmap *deco_bitmap;
7066 int deco_x, deco_y, deco_xpos, deco_ypos;
7067 int gd_x1 = gd->src_x;
7068 int gd_y1 = gd->src_y;
7069 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7070 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7071 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
7072 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
7073 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
7074 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
7075 int element = editor_elements[i];
7076 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
7077 unsigned int event_mask = GD_EVENT_RELEASED;
7079 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
7081 deco_xpos = (gd->width - tile_size) / 2;
7082 deco_ypos = (gd->height - tile_size) / 2;
7084 gi = CreateGadget(GDI_CUSTOM_ID, id,
7085 GDI_CUSTOM_TYPE_ID, type_id,
7086 GDI_IMAGE_ID, graphic,
7087 GDI_INFO_TEXT, getElementInfoText(element),
7090 GDI_WIDTH, gd->width,
7091 GDI_HEIGHT, gd->height,
7092 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7093 GDI_STATE, GD_BUTTON_UNPRESSED,
7094 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7095 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7096 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7097 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7098 GDI_DECORATION_SIZE, tile_size, tile_size,
7099 GDI_DECORATION_SHIFTING, 1, 1,
7100 GDI_EVENT_MASK, event_mask,
7101 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7102 GDI_CALLBACK_ACTION, HandleControlButtons,
7106 Fail("cannot create gadget");
7108 level_editor_gadget[id] = gi;
7112 static void CreateCounterButtons(void)
7114 int max_infotext_len = getMaxInfoTextLength();
7117 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
7119 int type_id = counterbutton_info[i].gadget_type_id;
7120 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
7121 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
7125 Fail("'counterbutton_info' structure corrupted at index %d -- please fix", i);
7127 // determine horizontal position to the right of specified gadget
7128 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7129 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
7130 ED_GADGET_TEXT_DISTANCE);
7132 // determine horizontal offset for leading text
7133 if (counterbutton_info[i].text_left != NULL)
7134 x += getTextWidthForGadget(counterbutton_info[i].text_left);
7136 for (j = 0; j < 2; j++)
7138 struct GadgetInfo *gi;
7140 counterbutton_info[i].gadget_id_down :
7141 counterbutton_info[i].gadget_id_up);
7143 struct GraphicInfo *gd;
7144 int gd_x1, gd_x2, gd_y1, gd_y2;
7145 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7146 char infotext[max_infotext_len + 1];
7148 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7151 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
7152 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
7154 event_mask |= GD_EVENT_RELEASED;
7158 x = DX + editor.button.prev_level.x;
7159 y = DY + editor.button.prev_level.y;
7163 x = DX + editor.button.next_level.x;
7164 y = DY + editor.button.next_level.y;
7170 IMG_EDITOR_COUNTER_DOWN :
7171 IMG_EDITOR_COUNTER_UP);
7174 gd = &graphic_info[graphic];
7178 gd_x2 = gd->src_x + gd->pressed_xoffset;
7179 gd_y2 = gd->src_y + gd->pressed_yoffset;
7181 sprintf(infotext, "%s counter value by 1, 5 or 10",
7182 (j == 0 ? "decrease" : "increase"));
7184 gi = CreateGadget(GDI_CUSTOM_ID, id,
7185 GDI_CUSTOM_TYPE_ID, type_id,
7186 GDI_IMAGE_ID, graphic,
7187 GDI_INFO_TEXT, infotext,
7190 GDI_WIDTH, gd->width,
7191 GDI_HEIGHT, gd->height,
7192 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7193 GDI_STATE, GD_BUTTON_UNPRESSED,
7194 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7195 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7196 GDI_EVENT_MASK, event_mask,
7197 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7198 GDI_CALLBACK_ACTION, HandleCounterButtons,
7202 Fail("cannot create gadget");
7204 level_editor_gadget[id] = gi;
7205 right_gadget_border[id] =
7206 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7208 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
7212 int font_type = FONT_INPUT_1;
7213 int font_type_active = FONT_INPUT_1_ACTIVE;
7215 id = counterbutton_info[i].gadget_id_text;
7217 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7219 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7221 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
7223 font_type = FONT_LEVEL_NUMBER;
7224 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
7226 x = DX + editor.input.level_number.x;
7227 y = DY + editor.input.level_number.y;
7231 graphic = IMG_EDITOR_COUNTER_INPUT;
7234 gd = &graphic_info[graphic];
7238 gd_x2 = gd->src_x + gd->active_xoffset;
7239 gd_y2 = gd->src_y + gd->active_yoffset;
7241 gi = CreateGadget(GDI_CUSTOM_ID, id,
7242 GDI_CUSTOM_TYPE_ID, type_id,
7243 GDI_IMAGE_ID, graphic,
7244 GDI_INFO_TEXT, "enter counter value",
7247 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
7248 GDI_NUMBER_VALUE, 0,
7249 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
7250 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
7251 GDI_TEXT_SIZE, 3, // minimal counter text size
7252 GDI_TEXT_FONT, font_type,
7253 GDI_TEXT_FONT_ACTIVE, font_type_active,
7254 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7255 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7256 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7257 GDI_DESIGN_WIDTH, gd->width,
7258 GDI_EVENT_MASK, event_mask,
7259 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7260 GDI_CALLBACK_ACTION, HandleCounterButtons,
7264 Fail("cannot create gadget");
7266 level_editor_gadget[id] = gi;
7267 right_gadget_border[id] =
7268 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7270 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
7276 static void CreateDrawingAreas(void)
7280 // these values are not constant, but can change at runtime
7281 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
7282 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
7284 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
7286 struct GadgetInfo *gi;
7287 int id = drawingarea_info[i].gadget_id;
7288 int type_id = drawingarea_info[i].gadget_type_id;
7289 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
7290 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
7291 int area_xsize = drawingarea_info[i].area_xsize;
7292 int area_ysize = drawingarea_info[i].area_ysize;
7293 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
7294 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
7295 unsigned int event_mask =
7296 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
7297 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
7300 Fail("'drawingarea_info' structure corrupted at index %d -- please fix", i);
7302 // determine horizontal position to the right of specified gadget
7303 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
7304 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
7305 ED_DRAWINGAREA_TEXT_DISTANCE);
7307 // determine horizontal offset for leading text
7308 if (drawingarea_info[i].text_left != NULL)
7309 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
7311 gi = CreateGadget(GDI_CUSTOM_ID, id,
7312 GDI_CUSTOM_TYPE_ID, type_id,
7315 GDI_TYPE, GD_TYPE_DRAWING_AREA,
7316 GDI_AREA_SIZE, area_xsize, area_ysize,
7317 GDI_ITEM_SIZE, item_size, item_size,
7318 GDI_EVENT_MASK, event_mask,
7319 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
7320 GDI_CALLBACK_ACTION, HandleDrawingAreas,
7324 Fail("cannot create gadget");
7326 level_editor_gadget[id] = gi;
7327 right_gadget_border[id] =
7328 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
7332 static void CreateTextInputGadgets(void)
7334 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
7335 int max_infotext_len = getMaxInfoTextLength();
7338 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
7340 int gd_x1 = gd->src_x;
7341 int gd_y1 = gd->src_y;
7342 int gd_x2 = gd->src_x + gd->active_xoffset;
7343 int gd_y2 = gd->src_y + gd->active_yoffset;
7344 struct GadgetInfo *gi;
7345 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7346 char infotext[MAX_OUTPUT_LINESIZE + 1];
7347 int id = textinput_info[i].gadget_id;
7348 int type_id = textinput_info[i].gadget_type_id;
7352 Fail("'textinput_info' structure corrupted at index %d -- please fix", i);
7354 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
7356 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
7357 int border_size = gd->border_size;
7358 int font_nr = FONT_INPUT_1;
7359 int font_height = getFontHeight(font_nr);
7360 int xoffset = element_border + TILEX + element_border + 3 * border_size;
7361 int yoffset = element_border + (TILEY - font_height) / 2;
7363 x = (editor.settings.element_name.x != -1 ?
7364 editor.settings.element_name.x :
7365 editor.settings.element_graphic.x + xoffset) - border_size;
7366 y = (editor.settings.element_name.y != -1 ?
7367 editor.settings.element_name.y :
7368 editor.settings.element_graphic.y + yoffset) - border_size;
7372 x = ED_SETTINGS_X(textinput_info[i].x);
7373 y = ED_SETTINGS_Y(textinput_info[i].y);
7376 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
7377 infotext[max_infotext_len] = '\0';
7379 gi = CreateGadget(GDI_CUSTOM_ID, id,
7380 GDI_CUSTOM_TYPE_ID, type_id,
7381 GDI_INFO_TEXT, infotext,
7384 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
7385 GDI_TEXT_VALUE, textinput_info[i].value,
7386 GDI_TEXT_SIZE, textinput_info[i].size,
7387 GDI_TEXT_FONT, FONT_INPUT_1,
7388 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7389 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7390 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7391 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7392 GDI_DESIGN_WIDTH, gd->width,
7393 GDI_EVENT_MASK, event_mask,
7394 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7395 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
7399 Fail("cannot create gadget");
7401 level_editor_gadget[id] = gi;
7405 static void CreateTextAreaGadgets(void)
7407 int max_infotext_len = getMaxInfoTextLength();
7410 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
7412 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
7413 int gd_x1 = gd->src_x;
7414 int gd_y1 = gd->src_y;
7415 int gd_x2 = gd->src_x + gd->active_xoffset;
7416 int gd_y2 = gd->src_y + gd->active_yoffset;
7417 struct GadgetInfo *gi;
7418 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
7419 char infotext[MAX_OUTPUT_LINESIZE + 1];
7420 int id = textarea_info[i].gadget_id;
7421 int type_id = textarea_info[i].gadget_type_id;
7422 int area_xsize = textarea_info[i].xsize;
7423 int area_ysize = textarea_info[i].ysize;
7426 Fail("'textarea_info' structure corrupted at index %d -- please fix", i);
7428 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
7429 infotext[max_infotext_len] = '\0';
7431 gi = CreateGadget(GDI_CUSTOM_ID, id,
7432 GDI_CUSTOM_TYPE_ID, type_id,
7433 GDI_INFO_TEXT, infotext,
7434 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
7435 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
7436 GDI_TYPE, GD_TYPE_TEXT_AREA,
7437 GDI_AREA_SIZE, area_xsize, area_ysize,
7438 GDI_TEXT_FONT, FONT_INPUT_1,
7439 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7440 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7441 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7442 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7443 GDI_DESIGN_WIDTH, gd->width,
7444 GDI_EVENT_MASK, event_mask,
7445 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7446 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
7450 Fail("cannot create gadget");
7452 level_editor_gadget[id] = gi;
7456 static void CreateSelectboxGadgets(void)
7458 int max_infotext_len = getMaxInfoTextLength();
7461 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7463 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
7464 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
7465 int gd_x1 = gd->src_x;
7466 int gd_y1 = gd->src_y;
7467 int gd_x2 = gd->src_x + gd->active_xoffset;
7468 int gd_y2 = gd->src_y + gd->active_yoffset;
7469 int selectbox_button_xsize = gd2->width;
7470 struct GadgetInfo *gi;
7471 char infotext[MAX_OUTPUT_LINESIZE + 1];
7472 int id = selectbox_info[i].gadget_id;
7473 int type_id = selectbox_info[i].gadget_type_id;
7474 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
7475 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
7476 unsigned int event_mask =
7477 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7480 Fail("'selectbox_info' structure corrupted at index %d -- please fix", i);
7482 if (selectbox_info[i].size == -1) // dynamically determine size
7484 // (we cannot use -1 for uninitialized values if we directly compare
7485 // with results from strlen(), because the '<' and '>' operation will
7486 // implicitely cast -1 to an unsigned integer value!)
7487 selectbox_info[i].size = 0;
7489 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
7490 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
7491 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
7493 selectbox_info[i].size++; // add one character empty space
7496 // determine horizontal position to the right of specified gadget
7497 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
7498 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
7499 ED_GADGET_TEXT_DISTANCE);
7501 // determine horizontal offset for leading text
7502 if (selectbox_info[i].text_left != NULL)
7503 x += getTextWidthForGadget(selectbox_info[i].text_left);
7505 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
7506 infotext[max_infotext_len] = '\0';
7508 gi = CreateGadget(GDI_CUSTOM_ID, id,
7509 GDI_CUSTOM_TYPE_ID, type_id,
7510 GDI_INFO_TEXT, infotext,
7513 GDI_TYPE, GD_TYPE_SELECTBOX,
7514 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
7515 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
7516 GDI_TEXT_SIZE, selectbox_info[i].size,
7517 GDI_TEXT_FONT, FONT_INPUT_1,
7518 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7519 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
7520 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7521 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7522 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7523 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
7524 GDI_DESIGN_WIDTH, gd->width,
7525 GDI_EVENT_MASK, event_mask,
7526 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7527 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
7531 Fail("cannot create gadget");
7533 level_editor_gadget[id] = gi;
7534 right_gadget_border[id] =
7535 getRightGadgetBorder(gi, selectbox_info[i].text_right);
7539 static void CreateTextbuttonGadgets(void)
7541 int max_infotext_len = getMaxInfoTextLength();
7544 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
7546 int id = textbutton_info[i].gadget_id;
7547 int type_id = textbutton_info[i].gadget_type_id;
7549 ((id >= GADGET_ID_LEVELCONFIG_LEVEL && id <= GADGET_ID_LEVELCONFIG_ENGINE) ||
7550 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
7552 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
7553 int gadget_distance =
7554 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
7555 struct GraphicInfo *gd = &graphic_info[graphic];
7556 int gd_x1 = gd->src_x;
7557 int gd_y1 = gd->src_y;
7558 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7559 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7560 int gd_x1a = gd->src_x + gd->active_xoffset;
7561 int gd_y1a = gd->src_y + gd->active_yoffset;
7562 int border_xsize = gd->border_size + gd->draw_xoffset;
7563 int border_ysize = gd->border_size;
7564 struct GadgetInfo *gi;
7565 unsigned int event_mask = GD_EVENT_RELEASED;
7566 char infotext[MAX_OUTPUT_LINESIZE + 1];
7567 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
7568 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
7571 Fail("'textbutton_info' structure corrupted at index %d -- please fix", i);
7573 if (textbutton_info[i].size == -1) // dynamically determine size
7574 textbutton_info[i].size = strlen(textbutton_info[i].text);
7576 sprintf(infotext, "%s", textbutton_info[i].infotext);
7577 infotext[max_infotext_len] = '\0';
7579 // determine horizontal position to the right of specified gadget
7580 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7582 int gadget_id_align = textbutton_info[i].gadget_id_align;
7584 x = right_gadget_border[gadget_id_align] + gadget_distance;
7586 if (textbutton_info[i].y == -1)
7587 y = level_editor_gadget[gadget_id_align]->y;
7590 // determine horizontal offset for leading text
7591 if (textbutton_info[i].text_left != NULL)
7592 x += getTextWidthForGadget(textbutton_info[i].text_left);
7594 gi = CreateGadget(GDI_CUSTOM_ID, id,
7595 GDI_CUSTOM_TYPE_ID, type_id,
7596 GDI_IMAGE_ID, graphic,
7597 GDI_INFO_TEXT, infotext,
7600 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
7601 GDI_TEXT_VALUE, textbutton_info[i].text,
7602 GDI_TEXT_SIZE, textbutton_info[i].size,
7603 GDI_TEXT_FONT, FONT_INPUT_2,
7604 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
7605 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7606 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7607 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7608 GDI_BORDER_SIZE, border_xsize, border_ysize,
7609 GDI_DESIGN_WIDTH, gd->width,
7610 GDI_DECORATION_SHIFTING, 1, 1,
7611 GDI_EVENT_MASK, event_mask,
7612 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7613 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7617 Fail("cannot create gadget");
7619 level_editor_gadget[id] = gi;
7620 right_gadget_border[id] =
7621 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7625 static void CreateGraphicbuttonGadgets(void)
7627 struct GadgetInfo *gi;
7630 // create buttons for scrolling of drawing area and element list
7631 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7633 int id = graphicbutton_info[i].gadget_id;
7634 int type_id = graphicbutton_info[i].gadget_type_id;
7635 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7636 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7637 int graphic = graphicbutton_info[i].graphic;
7638 struct GraphicInfo *gd = &graphic_info[graphic];
7639 int gd_x1 = gd->src_x;
7640 int gd_y1 = gd->src_y;
7641 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7642 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7643 unsigned int event_mask = GD_EVENT_RELEASED;
7646 Fail("'graphicbutton_info' structure corrupted at index %d -- please fix", i);
7648 // determine horizontal position to the right of specified gadget
7649 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7650 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7651 ED_GADGET_TEXT_DISTANCE);
7653 // determine horizontal offset for leading text
7654 if (graphicbutton_info[i].text_left != NULL)
7655 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7657 gi = CreateGadget(GDI_CUSTOM_ID, id,
7658 GDI_CUSTOM_TYPE_ID, type_id,
7659 GDI_IMAGE_ID, graphic,
7660 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7663 GDI_WIDTH, gd->width,
7664 GDI_HEIGHT, gd->height,
7665 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7666 GDI_STATE, GD_BUTTON_UNPRESSED,
7667 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7668 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7669 GDI_EVENT_MASK, event_mask,
7670 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7671 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7675 Fail("cannot create gadget");
7677 level_editor_gadget[id] = gi;
7678 right_gadget_border[id] =
7679 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7683 static void CreateScrollbarGadgets(void)
7687 // these values are not constant, but can change at runtime
7688 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7689 SX + ED_SCROLL_HORIZONTAL_XPOS;
7690 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7691 SY + ED_SCROLL_HORIZONTAL_YPOS;
7692 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7693 ED_SCROLL_HORIZONTAL_XSIZE;
7694 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7695 ED_SCROLL_HORIZONTAL_YSIZE;
7696 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7697 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7698 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7699 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7701 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7702 SX + ED_SCROLL_VERTICAL_XPOS;
7703 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7704 SY + ED_SCROLL_VERTICAL_YPOS;
7705 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7706 ED_SCROLL_VERTICAL_XSIZE;
7707 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7708 ED_SCROLL_VERTICAL_YSIZE;
7709 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7710 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7711 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7712 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7714 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7715 PX + ED_SCROLL2_VERTICAL_XPOS;
7716 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7717 PY + ED_SCROLL2_VERTICAL_YPOS;
7718 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7719 ED_SCROLL2_VERTICAL_XSIZE;
7720 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7721 ED_SCROLL2_VERTICAL_YSIZE;
7722 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7723 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7724 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7725 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7727 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7729 int id = scrollbar_info[i].gadget_id;
7730 int type_id = scrollbar_info[i].gadget_type_id;
7731 int graphic = scrollbar_info[i].graphic;
7732 struct GraphicInfo *gd = &graphic_info[graphic];
7733 int gd_x1 = gd->src_x;
7734 int gd_y1 = gd->src_y;
7735 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7736 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7737 struct GadgetInfo *gi;
7738 int items_max, items_visible, item_position;
7739 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7742 Fail("'scrollbar_info' structure corrupted at index %d -- please fix", i);
7744 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7746 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7747 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7748 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7750 else // drawing area scrollbars
7752 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7754 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7755 items_visible = ed_fieldx;
7760 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7761 items_visible = ed_fieldy;
7766 gi = CreateGadget(GDI_CUSTOM_ID, id,
7767 GDI_CUSTOM_TYPE_ID, type_id,
7768 GDI_IMAGE_ID, graphic,
7769 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7770 GDI_X, scrollbar_pos[i].x,
7771 GDI_Y, scrollbar_pos[i].y,
7772 GDI_WIDTH, scrollbar_pos[i].width,
7773 GDI_HEIGHT, scrollbar_pos[i].height,
7774 GDI_TYPE, scrollbar_info[i].type,
7775 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7776 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7777 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7778 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7779 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7780 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7781 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7782 GDI_STATE, GD_BUTTON_UNPRESSED,
7783 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7784 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7785 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7786 GDI_EVENT_MASK, event_mask,
7787 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7788 GDI_CALLBACK_ACTION, HandleControlButtons,
7792 Fail("cannot create gadget");
7794 level_editor_gadget[id] = gi;
7798 static void CreateCheckbuttonGadgets(void)
7800 struct GadgetInfo *gi;
7803 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7805 int id = checkbutton_info[i].gadget_id;
7806 int type_id = checkbutton_info[i].gadget_type_id;
7807 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7808 IMG_EDITOR_CHECKBOX);
7809 struct GraphicInfo *gd = &graphic_info[graphic];
7810 int gd_x1 = gd->src_x;
7811 int gd_y1 = gd->src_y;
7812 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7813 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7814 int gd_x1a = gd->src_x + gd->active_xoffset;
7815 int gd_y1a = gd->src_y + gd->active_yoffset;
7816 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7817 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7818 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7819 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7820 unsigned int event_mask = GD_EVENT_PRESSED;
7823 Fail("'checkbutton_info' structure corrupted at index %d -- please fix", i);
7825 // determine horizontal position to the right of specified gadget
7826 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7827 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7828 ED_GADGET_TEXT_DISTANCE);
7830 // determine horizontal offset for leading text
7831 if (checkbutton_info[i].text_left != NULL)
7832 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7834 gi = CreateGadget(GDI_CUSTOM_ID, id,
7835 GDI_CUSTOM_TYPE_ID, type_id,
7836 GDI_IMAGE_ID, graphic,
7837 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7840 GDI_WIDTH, gd->width,
7841 GDI_HEIGHT, gd->height,
7842 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7843 GDI_CHECKED, *checkbutton_info[i].value,
7844 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7845 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7846 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7847 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7848 GDI_EVENT_MASK, event_mask,
7849 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7850 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7854 Fail("cannot create gadget");
7856 level_editor_gadget[id] = gi;
7857 right_gadget_border[id] =
7858 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7862 static void CreateRadiobuttonGadgets(void)
7864 int graphic = IMG_EDITOR_RADIOBUTTON;
7865 struct GraphicInfo *gd = &graphic_info[graphic];
7866 int gd_x1 = gd->src_x;
7867 int gd_y1 = gd->src_y;
7868 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7869 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7870 int gd_x1a = gd->src_x + gd->active_xoffset;
7871 int gd_y1a = gd->src_y + gd->active_yoffset;
7872 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7873 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7874 struct GadgetInfo *gi;
7877 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7879 int id = radiobutton_info[i].gadget_id;
7880 int type_id = radiobutton_info[i].gadget_type_id;
7881 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7882 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7883 unsigned int event_mask = GD_EVENT_PRESSED;
7886 Fail("'radiobutton_info' structure corrupted at index %d -- please fix", i);
7889 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7891 // determine horizontal position to the right of specified gadget
7892 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7893 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7894 ED_GADGET_TEXT_DISTANCE);
7896 // determine horizontal offset for leading text
7897 if (radiobutton_info[i].text_left != NULL)
7898 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7900 gi = CreateGadget(GDI_CUSTOM_ID, id,
7901 GDI_CUSTOM_TYPE_ID, type_id,
7902 GDI_IMAGE_ID, graphic,
7903 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7906 GDI_WIDTH, gd->width,
7907 GDI_HEIGHT, gd->height,
7908 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7909 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7910 GDI_CHECKED, checked,
7911 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7912 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7913 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7914 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7915 GDI_EVENT_MASK, event_mask,
7916 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7917 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7921 Fail("cannot create gadget");
7923 level_editor_gadget[id] = gi;
7924 right_gadget_border[id] =
7925 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7929 void CreateLevelEditorGadgets(void)
7931 // force EDITOR font inside level editor
7932 SetFontStatus(GAME_MODE_EDITOR);
7934 // these values are not constant, but can change at runtime
7935 ed_fieldx = MAX_ED_FIELDX - 1;
7936 ed_fieldy = MAX_ED_FIELDY - 1;
7938 num_editor_gadgets = NUM_EDITOR_GADGETS;
7940 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7942 level_editor_gadget =
7943 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7944 right_gadget_border =
7945 checked_calloc(num_editor_gadgets * sizeof(int));
7947 // set number of empty (padding) element buttons to maximum number of buttons
7948 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7950 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7951 editor_el_empty_ptr = editor_el_empty;
7953 use_permanent_palette = !editor.palette.show_as_separate_screen;
7955 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
7957 ReinitializeElementList();
7959 CreateControlButtons();
7960 CreateScrollbarGadgets();
7962 // order of function calls is important because of cross-references
7963 CreateCheckbuttonGadgets();
7964 CreateCounterButtons();
7965 CreateRadiobuttonGadgets();
7966 CreateTextInputGadgets();
7967 CreateTextAreaGadgets();
7968 CreateSelectboxGadgets();
7969 CreateGraphicbuttonGadgets();
7970 CreateTextbuttonGadgets();
7971 CreateDrawingAreas();
7976 void FreeLevelEditorGadgets(void)
7980 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
7982 for (i = 0; i < num_editor_gadgets; i++)
7984 FreeGadget(level_editor_gadget[i]);
7986 level_editor_gadget[i] = NULL;
7989 checked_free(level_editor_gadget);
7990 checked_free(right_gadget_border);
7992 checked_free(editor_el_empty);
7995 static void MapCounterButtons(int id)
7997 int font_nr = FONT_TEXT_1;
7998 int font_height = getFontHeight(font_nr);
7999 int gadget_id_down = counterbutton_info[id].gadget_id_down;
8000 int gadget_id_text = counterbutton_info[id].gadget_id_text;
8001 int gadget_id_up = counterbutton_info[id].gadget_id_up;
8002 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
8003 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
8004 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8005 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
8006 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8007 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8008 int yoffset = (gi_down->height - font_height) / 2;
8009 int x_left = gi_down->x - xoffset_left;
8010 int x_right; // set after gadget position was modified
8011 int y_above = gi_down->y - yoffset_above;
8013 int y; // set after gadget position was modified
8015 // counter limits must be changed first to prevent value truncation
8016 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
8017 counterbutton_info[id].max_value);
8019 // right text position might have changed after setting position above
8020 x_right = gi_up->x + gi_up->width + xoffset_right;
8022 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
8024 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
8025 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
8026 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
8028 ModifyGadget(gi_down, GDI_Y,
8029 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8030 ModifyGadget(gi_text, GDI_Y,
8031 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8032 ModifyGadget(gi_up, GDI_Y,
8033 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8036 // vertical position might have changed after setting position above
8037 y = gi_up->y + yoffset;
8039 if (counterbutton_info[id].text_above)
8040 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
8042 if (counterbutton_info[id].text_left)
8043 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
8045 if (counterbutton_info[id].text_right)
8046 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
8053 static void MapControlButtons(void)
8058 // map toolbox buttons (excluding special CE toolbox buttons)
8059 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
8060 MapGadget(level_editor_gadget[i]);
8062 // map toolbox buttons (element properties buttons)
8063 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
8064 MapGadget(level_editor_gadget[i]);
8066 if (use_permanent_palette)
8068 // map buttons to select elements
8069 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8070 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
8071 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
8072 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
8073 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
8076 // map buttons to select level
8077 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
8078 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
8079 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
8080 MapCounterButtons(counter_id);
8083 static void MapDrawingArea(int id)
8085 int font_nr = FONT_TEXT_1;
8086 int font_height = getFontHeight(font_nr);
8087 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8088 int area_xsize = gi->drawing.area_xsize;
8089 int area_ysize = gi->drawing.area_ysize;
8090 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8091 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
8092 int x_left = gi->x - xoffset_left;
8093 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
8094 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
8095 int x_below = gi->x + (gi->width - xoffset_below) / 2;
8096 int y_side = gi->y + (gi->height - font_height) / 2;
8097 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
8098 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
8100 if (drawingarea_info[id].text_left)
8101 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
8103 if (drawingarea_info[id].text_right)
8104 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
8106 if (drawingarea_info[id].text_above)
8107 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
8109 if (drawingarea_info[id].text_below)
8110 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
8112 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
8114 DrawElementBorder(gi->x, gi->y,
8115 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
8116 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
8118 DrawDrawingArea(id);
8124 static void MapTextInputGadget(int id)
8126 int font_nr = FONT_TEXT_1;
8127 int font_height = getFontHeight(font_nr);
8128 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
8129 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8130 int x_above = ED_SETTINGS_X(textinput_info[id].x);
8131 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
8133 if (textinput_info[id].text_above)
8134 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
8136 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
8141 static void MapTextAreaGadget(int id)
8143 int font_nr = FONT_TEXT_1;
8144 int font_height = getFontHeight(font_nr);
8145 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8146 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8147 int x_above = ED_SETTINGS_X(textarea_info[id].x);
8148 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
8149 char *text_above = textarea_info[id].text_above;
8151 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
8152 text_above = textarea_info[id].text_above_cropped;
8155 DrawTextS(x_above, y_above, font_nr, text_above);
8157 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
8162 static void MapSelectboxGadget(int id)
8164 int font_nr = FONT_TEXT_1;
8165 int font_height = getFontHeight(font_nr);
8166 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
8167 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
8168 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8169 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8170 int yoffset = (gi->height - font_height) / 2;
8171 int x_left = gi->x - xoffset_left;
8172 int x_right = gi->x + gi->width + xoffset_right;
8173 int y_above = gi->y - yoffset_above;
8175 int y = gi->y + yoffset;
8177 if (selectbox_info[id].text_above)
8178 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
8180 if (selectbox_info[id].text_left)
8181 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
8183 if (selectbox_info[id].text_right)
8184 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
8186 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
8191 static void MapTextbuttonGadget(int id)
8193 int font_nr = FONT_TEXT_1;
8194 int font_height = getFontHeight(font_nr);
8195 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
8196 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
8197 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8198 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8199 int yoffset = (gi->height - font_height) / 2;
8200 int x_left = gi->x - xoffset_left;
8201 int x_right = gi->x + gi->width + xoffset_right;
8202 int y_above = gi->y - yoffset_above;
8204 int y = gi->y + yoffset;
8206 // only show button to delete change pages when more than minimum pages
8207 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
8208 custom_element.num_change_pages == MIN_CHANGE_PAGES)
8211 if (textbutton_info[id].text_above)
8212 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
8214 if (textbutton_info[id].text_left)
8215 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
8217 if (textbutton_info[id].text_right)
8218 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
8223 static void MapGraphicbuttonGadget(int id)
8225 int font_nr = FONT_TEXT_1;
8226 int font_height = getFontHeight(font_nr);
8227 struct GadgetInfo *gi = level_editor_gadget[graphicbutton_info[id].gadget_id];
8228 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
8229 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8230 int yoffset = (gi->height - font_height) / 2;
8231 int x_left = gi->x - xoffset_left;
8232 int x_right = gi->x + gi->width + xoffset_right;
8233 int y = gi->y + yoffset;
8235 if (graphicbutton_info[id].text_left)
8236 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
8238 if (graphicbutton_info[id].text_right)
8239 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
8244 static void MapRadiobuttonGadget(int id)
8246 int font_nr = FONT_TEXT_1;
8247 int font_height = getFontHeight(font_nr);
8248 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
8249 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8250 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8251 int yoffset = (gi->height - font_height) / 2;
8252 int x_left = gi->x - xoffset_left;
8253 int x_right = gi->x + gi->width + xoffset_right;
8254 int y = gi->y + yoffset;
8256 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
8258 if (radiobutton_info[id].text_left)
8259 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
8261 if (radiobutton_info[id].text_right)
8262 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
8264 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
8269 static void MapCheckbuttonGadget(int id)
8271 int font_nr = FONT_TEXT_1;
8272 int font_height = getFontHeight(font_nr);
8273 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
8274 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8275 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8276 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8277 int yoffset = (gi->height - font_height) / 2;
8278 int y_above = gi->y - yoffset_above;
8280 int x_left, x_right, y; // set after gadget position was modified
8282 // set position for gadgets with dynamically determined position
8283 if (checkbutton_info[id].x != -1) // do not change dynamic positions
8284 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x), GDI_END);
8285 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
8287 x_left = gi->x - xoffset_left;
8288 x_right = gi->x + gi->width + xoffset_right;
8289 y = gi->y + yoffset;
8291 if (checkbutton_info[id].text_above)
8292 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
8294 if (checkbutton_info[id].text_left)
8295 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
8297 if (checkbutton_info[id].text_right)
8298 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
8300 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
8305 static void MapMainDrawingArea(void)
8307 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
8308 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
8311 if (suppressBorderElement())
8313 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
8314 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
8317 for (i = ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
8319 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
8320 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
8321 no_horizontal_scrollbar) ||
8322 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
8323 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
8324 no_vertical_scrollbar))
8327 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
8330 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
8332 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
8333 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
8336 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
8339 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
8342 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
8346 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
8348 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
8349 i == GADGET_ID_CUSTOM_COPY_TO ||
8350 i == GADGET_ID_CUSTOM_EXCHANGE ||
8351 i == GADGET_ID_CUSTOM_COPY ||
8352 i == GADGET_ID_CUSTOM_PASTE)
8355 MapGadget(level_editor_gadget[i]);
8357 UnmapGadget(level_editor_gadget[i]);
8362 static void MapLevelEditorToolboxCustomGadgets(void)
8364 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
8367 static void MapLevelEditorToolboxCustomGadgetsIfNeeded(void)
8369 if (IS_CUSTOM_ELEMENT(properties_element) ||
8370 IS_GROUP_ELEMENT(properties_element) ||
8371 IS_EMPTY_ELEMENT(properties_element))
8372 MapLevelEditorToolboxCustomGadgets();
8375 static void UnmapLevelEditorToolboxCustomGadgets(void)
8377 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
8380 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
8384 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
8386 if (i != GADGET_ID_SINGLE_ITEMS &&
8387 i != GADGET_ID_PICK_ELEMENT)
8389 struct GadgetInfo *gi = level_editor_gadget[i];
8397 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
8398 struct GraphicInfo *gd = &graphic_info[graphic];
8402 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
8403 gi->width, gi->height, gi->x, gi->y);
8405 redraw_mask |= REDRAW_DOOR_3;
8411 static void MapLevelEditorToolboxDrawingGadgets(void)
8413 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
8416 static void UnmapLevelEditorToolboxDrawingGadgets(void)
8418 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
8421 static void UnmapDrawingArea(int id)
8423 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
8426 static void UnmapLevelEditorFieldGadgets(void)
8430 for (i = 0; i < num_editor_gadgets; i++)
8431 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
8432 level_editor_gadget[i]->y))
8433 UnmapGadget(level_editor_gadget[i]);
8436 void UnmapLevelEditorGadgets(void)
8440 for (i = 0; i < num_editor_gadgets; i++)
8441 UnmapGadget(level_editor_gadget[i]);
8444 static void ResetUndoBuffer(void)
8446 undo_buffer_position = -1;
8447 undo_buffer_steps = -1;
8448 redo_buffer_steps = 0;
8450 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8452 level.changed = FALSE;
8455 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
8457 if (remap_toolbox_gadgets)
8459 ModifyEditorElementList();
8460 RedrawDrawingElements();
8463 if (edit_mode == ED_MODE_LEVELCONFIG)
8464 DrawLevelConfigWindow();
8465 else if (edit_mode == ED_MODE_PROPERTIES)
8466 DrawPropertiesWindow();
8467 else if (edit_mode == ED_MODE_PALETTE)
8468 DrawPaletteWindow();
8469 else // edit_mode == ED_MODE_DRAWING
8470 DrawDrawingWindowExt(remap_toolbox_gadgets);
8473 static void DrawEditModeWindow(void)
8475 DrawEditModeWindowExt(TRUE);
8478 static void DrawEditModeWindow_PlayfieldOnly(void)
8480 DrawEditModeWindowExt(FALSE);
8483 static void ChangeEditModeWindow(int new_edit_mode)
8485 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
8487 DrawEditModeWindow();
8490 static boolean LevelChanged(void)
8492 boolean field_changed = FALSE;
8495 for (y = 0; y < lev_fieldy; y++)
8496 for (x = 0; x < lev_fieldx; x++)
8497 if (Tile[x][y] != level.field[x][y])
8498 field_changed = TRUE;
8500 return (level.changed || field_changed);
8503 static boolean PrepareSavingIntoPersonalLevelSet(void)
8505 static LevelDirTree *last_copied_leveldir = NULL;
8506 static LevelDirTree *last_written_leveldir = NULL;
8507 static int last_copied_level_nr = -1;
8508 static int last_written_level_nr = -1;
8509 LevelDirTree *leveldir_former = leveldir_current;
8510 int level_nr_former = level_nr;
8513 // remember last mod/save so that for current session, we write
8514 // back to the same personal copy, asking only about overwrite.
8515 if (leveldir_current == last_copied_leveldir &&
8516 level_nr == last_copied_level_nr)
8518 // "cd" to personal level set dir (as used when writing last copy)
8519 leveldir_current = last_written_leveldir;
8520 level_nr = last_written_level_nr;
8525 if (!Request("This level is read-only! "
8526 "Save into personal level set?", REQ_ASK))
8529 // "cd" to personal level set dir (for writing copy the first time)
8531 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
8533 // this may happen if "setup.internal.create_user_levelset" is FALSE
8534 // or if file "levelinfo.conf" is missing in personal user level set
8535 if (leveldir_current == NULL)
8537 Request("Cannot find personal level set?!", REQ_CONFIRM);
8539 leveldir_current = leveldir_former;
8544 // find unused level number
8545 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
8547 static char *level_filename = NULL;
8549 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
8551 if (!fileExists(level_filename))
8555 last_copied_leveldir = leveldir_former;
8556 last_copied_level_nr = level_nr_former;
8558 last_written_leveldir = leveldir_current;
8559 last_written_level_nr = level_nr = new_level_nr;
8564 static void ModifyLevelConfigForSavingIntoPersonalLevelSet(char *former_name)
8566 static char *filename_levelinfo = NULL, *mod_name = NULL;
8569 // annotate this copy-and-mod in personal levelinfo.conf
8570 setString(&filename_levelinfo,
8571 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
8573 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
8575 fprintf(file, "\n");
8576 fprintf(file, "# level %d was modified from:\n", level_nr);
8577 fprintf(file, "# - previous level set name: %s\n",
8579 fprintf(file, "# - level within previous set: %d \"%s\"\n",
8580 level.file_info.nr, level.name);
8581 fprintf(file, "# - previous author: %s\n",
8583 fprintf(file, "# - previous save date: ");
8585 if (level.creation_date.src == DATE_SRC_LEVELFILE)
8587 fprintf(file, "%04d-%02d-%02d\n",
8588 level.creation_date.year,
8589 level.creation_date.month,
8590 level.creation_date.day);
8594 fprintf(file, "not recorded\n");
8600 if (level_nr > leveldir_current->last_level)
8601 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
8603 // else: allow the save even if annotation failed
8605 // now... spray graffiti on the old level vital statistics
8606 // user can change these; just trying to set a good baseline
8608 // don't truncate names for fear of making offensive or silly:
8609 // long-named original author only recorded in levelinfo.conf.
8610 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
8611 if (!strEqual(level.author, leveldir_current->author))
8613 setString(&mod_name, getStringCat3(leveldir_current->author,
8614 " after ", level.author));
8616 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8617 setString(&mod_name,
8618 getStringCat2(leveldir_current->author, " (ed.)"));
8620 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8621 setString(&mod_name, leveldir_current->author);
8623 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
8625 // less worried about truncation here
8626 setString(&mod_name, getStringCat2("Mod: ", level.name));
8627 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
8631 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
8632 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8636 for (x = 0; x < lev_fieldx; x++)
8637 for (y = 0; y < lev_fieldy; y++)
8638 dst[x][y] = src[x][y];
8641 static int setSelectboxValue(int selectbox_id, int new_value)
8643 int new_index_value = 0;
8646 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8647 if (selectbox_info[selectbox_id].options[i].value == new_value)
8648 new_index_value = i;
8650 *selectbox_info[selectbox_id].value =
8651 selectbox_info[selectbox_id].options[new_index_value].value;
8653 return new_index_value;
8656 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8660 // change action mode and arg variables according to action type variable
8661 for (i = 0; action_arg_options[i].value != -1; i++)
8663 if (action_arg_options[i].value == custom_element_change.action_type)
8665 int mode = action_arg_options[i].mode;
8667 // only change if corresponding selectbox has changed
8668 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8669 action_arg_modes[mode])
8670 custom_element_change.action_mode = -1;
8672 // only change if corresponding selectbox has changed
8673 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8674 action_arg_options[i].options)
8675 custom_element_change.action_arg = -1;
8682 static void setSelectboxSpecialActionOptions(void)
8686 // change action mode and arg selectbox according to action type selectbox
8687 for (i = 0; action_arg_options[i].value != -1; i++)
8689 if (action_arg_options[i].value == custom_element_change.action_type)
8691 int mode = action_arg_options[i].mode;
8693 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8694 action_arg_modes[mode]);
8695 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8696 custom_element_change.action_mode);
8698 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8699 action_arg_options[i].options);
8700 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8701 custom_element_change.action_arg);
8707 static void copy_custom_element_settings(int element_from, int element_to)
8709 struct ElementInfo *ei_from = &element_info[element_from];
8710 struct ElementInfo *ei_to = &element_info[element_to];
8712 copyElementInfo(ei_from, ei_to);
8715 static void replace_custom_element_in_settings(int element_from,
8720 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8722 struct ElementInfo *ei = &element_info[i];
8724 for (y = 0; y < 3; y++)
8725 for (x = 0; x < 3; x++)
8726 if (ei->content.e[x][y] == element_from)
8727 ei->content.e[x][y] = element_to;
8729 for (j = 0; j < ei->num_change_pages; j++)
8731 struct ElementChangeInfo *change = &ei->change_page[j];
8733 if (change->target_element == element_from)
8734 change->target_element = element_to;
8736 if (change->initial_trigger_element == element_from)
8737 change->initial_trigger_element = element_to;
8739 if (change->action_element == element_from)
8740 change->action_element = element_to;
8742 for (y = 0; y < 3; y++)
8743 for (x = 0; x < 3; x++)
8744 if (change->target_content.e[x][y] == element_from)
8745 change->target_content.e[x][y] = element_to;
8748 if (ei->group != NULL) // group or internal
8749 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8750 if (ei->group->element[j] == element_from)
8751 ei->group->element[j] = element_to;
8755 static void replace_custom_element_in_playfield(int element_from,
8760 for (x = 0; x < lev_fieldx; x++)
8761 for (y = 0; y < lev_fieldy; y++)
8762 if (Tile[x][y] == element_from)
8763 Tile[x][y] = element_to;
8766 static boolean CopyCustomElement(int element_old, int element_new,
8769 int copy_mode_orig = copy_mode;
8771 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8773 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8774 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8775 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8777 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8779 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8780 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8781 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8783 level.changed = TRUE;
8785 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8787 Request("Please choose custom element!", REQ_CONFIRM);
8791 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8793 Request("Please choose group element!", REQ_CONFIRM);
8797 else if (IS_EMPTY_ELEMENT(element_old) && !IS_EMPTY_ELEMENT(element_new))
8799 Request("Please choose empty element!", REQ_CONFIRM);
8805 level.changed = TRUE;
8808 // when modifying custom/group element, ask for copying level template
8809 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8811 if (!AskToCopyAndModifyLevelTemplate())
8815 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8817 copy_custom_element_settings(element_new, element_old);
8819 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8821 copy_custom_element_settings(element_old, element_new);
8823 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8825 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8826 copy_custom_element_settings(element_new, element_old);
8827 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8829 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8830 replace_custom_element_in_settings(element_new, element_old);
8831 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8833 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8834 replace_custom_element_in_playfield(element_new, element_old);
8835 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8838 UpdateCustomElementGraphicGadgets();
8839 DrawPropertiesWindow();
8844 static void CopyCustomElementPropertiesToEditor(int element)
8847 int current_change_page = element_info[element].current_change_page;
8849 // dynamically (re)build selectbox for selecting change page
8850 for (i = 0; i < element_info[element].num_change_pages; i++)
8852 sprintf(options_change_page_strings[i], "%d", i + 1);
8854 options_change_page[i].value = i;
8855 options_change_page[i].text = options_change_page_strings[i];
8858 options_change_page[i].value = -1;
8859 options_change_page[i].text = NULL;
8861 // needed here to initialize combined element properties
8862 InitElementPropertiesEngine(level.game_version);
8864 element_info[element].change =
8865 &element_info[element].change_page[current_change_page];
8867 custom_element = element_info[element];
8868 custom_element_change = *element_info[element].change;
8870 // needed to initially set selectbox options for special action options
8871 setSelectboxSpecialActionOptions();
8873 // needed to initially set selectbox value variables to reliable defaults
8874 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8875 setSelectboxValue(i, *selectbox_info[i].value);
8877 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8878 custom_element_properties[i] = HAS_PROPERTY(element, i);
8880 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8881 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8883 // ---------- element settings: configure (custom elements) -----------------
8885 // set accessible layer selectbox help value
8886 custom_element.access_type =
8887 (IS_WALKABLE(element) ? EP_WALKABLE :
8888 IS_PASSABLE(element) ? EP_PASSABLE :
8889 custom_element.access_type);
8890 custom_element.access_layer =
8891 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8892 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8893 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8894 custom_element.access_layer);
8895 custom_element.access_protected =
8896 (IS_PROTECTED(element) ? 1 : 0);
8897 custom_element_properties[EP_ACCESSIBLE] =
8898 (IS_ACCESSIBLE_OVER(element) ||
8899 IS_ACCESSIBLE_INSIDE(element) ||
8900 IS_ACCESSIBLE_UNDER(element));
8902 // set walk-to-object action selectbox help value
8903 custom_element.walk_to_action =
8904 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8905 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8906 IS_DROPPABLE(element) ? EP_DROPPABLE :
8907 IS_THROWABLE(element) ? EP_THROWABLE :
8908 IS_PUSHABLE(element) ? EP_PUSHABLE :
8909 custom_element.walk_to_action);
8910 custom_element_properties[EP_WALK_TO_OBJECT] =
8911 (IS_DIGGABLE(element) ||
8912 IS_COLLECTIBLE_ONLY(element) ||
8913 IS_DROPPABLE(element) ||
8914 IS_THROWABLE(element) ||
8915 IS_PUSHABLE(element));
8917 // set smash targets selectbox help value
8918 custom_element.smash_targets =
8919 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8920 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8921 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8922 custom_element.smash_targets);
8923 custom_element_properties[EP_CAN_SMASH] =
8924 (CAN_SMASH_EVERYTHING(element) ||
8925 CAN_SMASH_ENEMIES(element) ||
8926 CAN_SMASH_PLAYER(element));
8928 // set deadliness selectbox help value
8929 custom_element.deadliness =
8930 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8931 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8932 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8933 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8934 custom_element.deadliness);
8935 custom_element_properties[EP_DEADLY] =
8936 (DONT_TOUCH(element) ||
8937 DONT_GET_HIT_BY(element) ||
8938 DONT_COLLIDE_WITH(element) ||
8939 DONT_RUN_INTO(element));
8941 // ---------- element settings: advanced (custom elements) ------------------
8943 // set "change by direct action" selectbox help value
8944 custom_element_change.direct_action =
8945 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
8946 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8947 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8948 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8949 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8950 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8951 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8952 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8953 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8954 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8955 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8956 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8957 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8958 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8959 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8960 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8961 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8962 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8963 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8964 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
8965 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
8966 custom_element_change.direct_action);
8968 // set "change by other element action" selectbox help value
8969 custom_element_change.other_action =
8970 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
8971 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8972 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8973 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8974 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8975 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8976 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8977 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8978 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8979 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8980 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8981 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
8982 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8983 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8984 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8985 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8986 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8987 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8988 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8989 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8990 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8991 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8992 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8993 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8994 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8995 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
8996 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
8997 custom_element_change.other_action);
9000 static void CopyGroupElementPropertiesToEditor(int element)
9002 group_element_info = *element_info[element].group;
9003 custom_element = element_info[element]; // needed for description
9006 static void CopyEmptyElementPropertiesToEditor(int element)
9008 custom_element = element_info[element];
9011 static void CopyClassicElementPropertiesToEditor(int element)
9013 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9014 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
9015 getMoveIntoAcidProperty(&level, element);
9017 if (MAYBE_DONT_COLLIDE_WITH(element))
9018 custom_element_properties[EP_DONT_COLLIDE_WITH] =
9019 getDontCollideWithProperty(&level, element);
9022 static void CopyElementPropertiesToEditor(int element)
9024 if (IS_CUSTOM_ELEMENT(element))
9025 CopyCustomElementPropertiesToEditor(element);
9026 else if (IS_GROUP_ELEMENT(element))
9027 CopyGroupElementPropertiesToEditor(element);
9028 else if (IS_EMPTY_ELEMENT(element))
9029 CopyEmptyElementPropertiesToEditor(element);
9031 CopyClassicElementPropertiesToEditor(element);
9034 static boolean AskToCopyAndModifyLevelTemplate(void)
9036 if (Request("Copy and modify settings from level template?", REQ_ASK))
9038 level.use_custom_template = FALSE;
9040 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
9041 GDI_CHECKED, FALSE, GDI_END);
9042 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
9043 GDI_CHECKED, FALSE, GDI_END);
9049 LoadLevelTemplate(-1); // this resets all element modifications ...
9051 DrawEditModeWindow(); // ... and copies them to 'custom_element'
9057 static void CopyCustomElementPropertiesToGame(int element)
9060 int access_type_and_layer;
9062 // mark that this custom element has been modified
9063 custom_element.modified_settings = TRUE;
9064 level.changed = TRUE;
9066 if (level.use_custom_template)
9067 AskToCopyAndModifyLevelTemplate();
9069 element_info[element] = custom_element;
9070 *element_info[element].change = custom_element_change;
9072 // ---------- element settings: configure (custom elements) -----------------
9074 // set accessible property from checkbox and selectbox
9075 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
9076 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
9077 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
9078 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
9079 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
9080 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
9081 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
9082 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
9083 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
9084 custom_element_properties[access_type_and_layer] =
9085 custom_element_properties[EP_ACCESSIBLE];
9086 custom_element_properties[EP_PROTECTED] =
9087 (custom_element.access_protected != 0 &&
9088 custom_element_properties[EP_ACCESSIBLE]);
9090 // set walk-to-object property from checkbox and selectbox
9091 custom_element_properties[EP_DIGGABLE] = FALSE;
9092 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
9093 custom_element_properties[EP_DROPPABLE] = FALSE;
9094 custom_element_properties[EP_THROWABLE] = FALSE;
9095 custom_element_properties[EP_PUSHABLE] = FALSE;
9096 custom_element_properties[custom_element.walk_to_action] =
9097 custom_element_properties[EP_WALK_TO_OBJECT];
9099 // set smash property from checkbox and selectbox
9100 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
9101 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
9102 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
9103 custom_element_properties[custom_element.smash_targets] =
9104 custom_element_properties[EP_CAN_SMASH];
9106 // set deadliness property from checkbox and selectbox
9107 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
9108 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
9109 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
9110 custom_element_properties[EP_DONT_TOUCH] = FALSE;
9111 custom_element_properties[custom_element.deadliness] =
9112 custom_element_properties[EP_DEADLY];
9114 // ---------- element settings: advanced (custom elements) ------------------
9116 // set player change event from checkbox and selectbox
9117 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
9118 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
9119 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
9120 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
9121 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
9122 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
9123 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
9124 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
9125 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
9126 custom_element_change_events[CE_SWITCHED] = FALSE;
9127 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
9128 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
9129 custom_element_change_events[CE_BLOCKED] = FALSE;
9130 custom_element_change_events[CE_IMPACT] = FALSE;
9131 custom_element_change_events[CE_SMASHED] = FALSE;
9132 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
9133 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
9134 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
9135 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
9136 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
9137 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
9138 custom_element_change_events[custom_element_change.direct_action] =
9139 custom_element_change_events[CE_BY_DIRECT_ACTION];
9141 // set other element action change event from checkbox and selectbox
9142 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
9143 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
9144 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
9145 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
9146 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
9147 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
9148 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
9149 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
9150 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
9151 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
9152 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
9153 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
9154 custom_element_change_events[CE_TOUCHING_X] = FALSE;
9155 custom_element_change_events[CE_HITTING_X] = FALSE;
9156 custom_element_change_events[CE_DIGGING_X] = FALSE;
9157 custom_element_change_events[CE_HIT_BY_X] = FALSE;
9158 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
9159 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
9160 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
9161 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
9162 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
9163 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
9164 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
9165 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
9166 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
9167 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
9168 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
9169 custom_element_change_events[custom_element_change.other_action] =
9170 custom_element_change_events[CE_BY_OTHER_ACTION];
9172 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
9173 SET_PROPERTY(element, i, custom_element_properties[i]);
9175 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
9176 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
9178 // copy change events also to special level editor variable
9179 custom_element = element_info[element];
9180 custom_element_change = *element_info[element].change;
9182 // needed here to restore runtime value "element_info[element].gfx_element"
9183 InitElementPropertiesGfxElement();
9186 static void CopyGroupElementPropertiesToGame(int element)
9188 // mark that this group element has been modified
9189 custom_element.modified_settings = TRUE;
9190 level.changed = TRUE;
9192 if (level.use_custom_template)
9193 AskToCopyAndModifyLevelTemplate();
9195 element_info[element] = custom_element;
9196 *element_info[element].group = group_element_info;
9198 // needed here to restore runtime value "element_info[element].gfx_element"
9199 InitElementPropertiesGfxElement();
9202 static void CopyEmptyElementPropertiesToGame(int element)
9204 // mark that this empty element has been modified
9205 custom_element.modified_settings = TRUE;
9206 level.changed = TRUE;
9208 if (level.use_custom_template)
9209 AskToCopyAndModifyLevelTemplate();
9211 element_info[element] = custom_element;
9213 // needed here to restore runtime value "element_info[element].gfx_element"
9214 InitElementPropertiesGfxElement();
9217 static void CopyClassicElementPropertiesToGame(int element)
9219 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9220 setMoveIntoAcidProperty(&level, element,
9221 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
9223 if (MAYBE_DONT_COLLIDE_WITH(element))
9224 setDontCollideWithProperty(&level, element,
9225 custom_element_properties[EP_DONT_COLLIDE_WITH]);
9228 static void CopyElementPropertiesToGame(int element)
9230 if (IS_CUSTOM_ELEMENT(element))
9231 CopyCustomElementPropertiesToGame(element);
9232 else if (IS_GROUP_ELEMENT(element))
9233 CopyGroupElementPropertiesToGame(element);
9234 else if (IS_EMPTY_ELEMENT(element))
9235 CopyEmptyElementPropertiesToGame(element);
9237 CopyClassicElementPropertiesToGame(element);
9241 static void CheckElementDescriptions(void)
9245 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
9246 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
9247 Warn("no element description file for element '%s'", EL_NAME(i));
9251 static int getMaxEdFieldX(boolean has_scrollbar)
9253 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
9254 int sxsize = SXSIZE - scrollbar_width;
9255 int max_ed_fieldx = sxsize / ed_tilesize;
9257 return max_ed_fieldx;
9260 static int getMaxEdFieldY(boolean has_scrollbar)
9262 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
9263 INFOTEXT_YSIZE_FULL : 0);
9264 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
9265 int sysize = SYSIZE - scrollbar_height - infotext_height;
9266 int max_ed_fieldy = sysize / ed_tilesize;
9268 return max_ed_fieldy;
9271 static void InitZoomLevelSettings(int zoom_tilesize)
9273 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
9275 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
9277 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
9278 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
9280 // make sure that tile size is always a power of 2
9281 ed_tilesize = (1 << log_2(ed_tilesize));
9283 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9285 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
9286 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
9290 last_game_engine_type = level.game_engine_type;
9292 // limit zoom tilesize by upper and lower bound
9293 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
9295 // store zoom tilesize in auto setup file only if it was manually changed
9296 if (zoom_tilesize != -1)
9297 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
9299 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
9300 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
9303 static void InitDrawingElements(void)
9305 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
9307 if (level.game_engine_type == game_engine_type_last)
9310 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9312 new_element1 = EL_BD_WALL;
9313 new_element2 = EL_EMPTY;
9314 new_element3 = EL_BD_SAND;
9316 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
9318 new_element1 = EL_SP_CHIP_SINGLE;
9319 new_element2 = EL_EMPTY;
9320 new_element3 = EL_SP_BASE;
9322 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9324 new_element1 = EL_MM_MIRROR_START;
9325 new_element2 = EL_EMPTY;
9326 new_element3 = EL_MM_WOODEN_WALL;
9330 new_element1 = EL_WALL;
9331 new_element2 = EL_EMPTY;
9332 new_element3 = EL_SAND;
9335 game_engine_type_last = level.game_engine_type;
9338 static void InitLevelSetInfo(void)
9340 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
9341 "%s", leveldir_current->name);
9342 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
9343 "%s", leveldir_current->author);
9345 levelset_num_levels = leveldir_current->levels;
9347 levelset_use_levelset_artwork = FALSE;
9348 levelset_copy_level_template = FALSE;
9350 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
9353 static void ChangeEditorToLevelSet(char *levelset_subdir)
9355 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
9357 // the previous level set might have used custom artwork
9358 ReloadCustomArtwork(0);
9360 LoadLevelSetup_SeriesInfo();
9362 SaveLevelSetup_LastSeries();
9363 SaveLevelSetup_SeriesInfo();
9367 LoadLevel(level_nr);
9368 LoadScore(level_nr);
9373 static boolean useEditorDoorAnimation(void)
9375 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
9376 boolean door_1_viewport_unchanged =
9377 (vp_door_1->x == DX &&
9378 vp_door_1->y == DY &&
9379 vp_door_1->width == DXSIZE &&
9380 vp_door_1->height == DYSIZE);
9381 boolean door_1_contains_toolbox =
9384 EX + EXSIZE <= DX + DXSIZE &&
9385 EY + EYSIZE <= DY + DYSIZE);
9387 return (door_1_viewport_unchanged && door_1_contains_toolbox);
9390 static void DrawEditorDoorBackground(int graphic, int x, int y,
9391 int width, int height)
9393 struct GraphicInfo *g = &graphic_info[graphic];
9395 if (g->bitmap != NULL)
9396 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
9397 MIN(width, g->width), MIN(height, g->height), x, y);
9399 ClearRectangle(drawto, x, y, width, height);
9402 static void DrawEditorDoorContent(void)
9404 // needed for gadgets drawn on background (like palette scrollbar)
9405 SetDoorBackgroundImage(IMG_UNDEFINED);
9407 // copy default editor door content to main double buffer
9408 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
9411 DrawSpecialEditorDoor();
9413 // draw new control window
9414 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
9416 // draw all toolbox gadgets to editor doors
9417 MapControlButtons();
9419 // when returning from test game to properties page, redraw toolbox gadgets
9420 if (edit_mode == ED_MODE_PROPERTIES)
9422 UnmapLevelEditorToolboxDrawingGadgets();
9423 UnmapLevelEditorToolboxCustomGadgets();
9425 MapLevelEditorToolboxCustomGadgetsIfNeeded();
9428 // draw all palette gadgets to editor doors
9429 ModifyEditorElementList();
9430 RedrawDrawingElements();
9432 // copy actual editor door content to door double buffer for OpenDoor()
9433 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
9436 void DrawLevelEd(void)
9438 int fade_mask = REDRAW_FIELD;
9440 FadeSoundsAndMusic();
9443 fade_mask = REDRAW_ALL;
9447 // needed if different viewport properties defined for editor
9448 ChangeViewportPropertiesIfNeeded();
9452 InitZoomLevelSettings(-1);
9453 InitDrawingElements();
9457 CheckElementDescriptions();
9460 if (level_editor_test_game)
9462 CopyPlayfield(level.field, Tile);
9463 CopyPlayfield(TileBackup, level.field);
9465 level_editor_test_game = FALSE;
9469 edit_mode = ED_MODE_DRAWING;
9470 edit_mode_levelconfig = ED_MODE_LEVELCONFIG_LEVEL;
9471 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
9479 // redraw_mask |= REDRAW_ALL;
9481 FreeLevelEditorGadgets();
9482 CreateLevelEditorGadgets();
9484 ReinitializeElementList(); // update dynamic level element list
9485 ReinitializeElementListButtons(); // custom element may look different
9487 InitElementPropertiesGfxElement();
9491 DrawEditModeWindow_PlayfieldOnly();
9493 DrawMaskedBorder(fade_mask);
9495 // use door animation if door 1 viewport is unchanged and contains toolbox
9496 if (useEditorDoorAnimation())
9500 DrawEditorDoorContent();
9502 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
9506 DrawEditorDoorContent();
9511 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
9514 static void AdjustDrawingAreaGadgets(void)
9516 int ed_xsize = lev_fieldx + 2;
9517 int ed_ysize = lev_fieldy + 2;
9518 int max_ed_fieldx = MAX_ED_FIELDX;
9519 int max_ed_fieldy = MAX_ED_FIELDY;
9520 boolean horizontal_scrollbar_needed;
9521 boolean vertical_scrollbar_needed;
9522 int x, y, width, height;
9524 if (suppressBorderElement())
9526 ed_xsize = lev_fieldx;
9527 ed_ysize = lev_fieldy;
9530 // check if we need any scrollbars
9531 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9532 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9534 // check if we have a smaller editor field because of scrollbars
9535 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9536 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9538 // check again if we now need more scrollbars because of less space
9539 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9540 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9542 // check if editor field gets even smaller after adding new scrollbars
9543 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9544 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9546 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
9547 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
9549 x = SX + ed_fieldx * ed_tilesize;
9550 y = SY + ed_fieldy * ed_tilesize;
9552 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
9553 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
9555 // adjust drawing area gadget
9556 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
9557 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
9558 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
9561 // adjust horizontal scrollbar gadgets
9562 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
9565 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
9566 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
9569 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9572 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
9575 // adjust vertical scrollbar gadgets
9576 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
9579 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
9581 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
9583 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9586 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
9590 static void AdjustLevelScrollPosition(void)
9592 if (level_xpos < -1)
9594 if (level_xpos > lev_fieldx - ed_fieldx + 1)
9595 level_xpos = lev_fieldx - ed_fieldx + 1;
9596 if (lev_fieldx < ed_fieldx - 2)
9599 if (level_ypos < -1)
9601 if (level_ypos > lev_fieldy - ed_fieldy + 1)
9602 level_ypos = lev_fieldy - ed_fieldy + 1;
9603 if (lev_fieldy < ed_fieldy - 2)
9606 if (suppressBorderElement())
9613 static void AdjustEditorScrollbar(int id)
9615 struct GadgetInfo *gi = level_editor_gadget[id];
9616 int items_max, items_visible, item_position;
9618 if (id == GADGET_ID_SCROLL_HORIZONTAL)
9620 items_max = MAX(lev_fieldx + 2, ed_fieldx);
9621 items_visible = ed_fieldx;
9622 item_position = level_xpos + 1;
9626 items_max = MAX(lev_fieldy + 2, ed_fieldy);
9627 items_visible = ed_fieldy;
9628 item_position = level_ypos + 1;
9631 if (item_position > items_max - items_visible)
9632 item_position = items_max - items_visible;
9634 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9635 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9638 static void AdjustElementListScrollbar(void)
9640 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
9641 int items_max, items_visible, item_position;
9643 // correct position of element list scrollbar
9644 if (element_shift < 0)
9646 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9647 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9649 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
9650 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
9651 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
9653 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9654 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
9655 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9658 static void ModifyEditorCounterValue(int counter_id, int new_value)
9660 int *counter_value = counterbutton_info[counter_id].value;
9661 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9662 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9664 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9666 if (counter_value != NULL)
9667 *counter_value = gi->textinput.number_value;
9670 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9672 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9673 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9675 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9677 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9678 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9680 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9681 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9683 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9684 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9689 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9691 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9692 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9693 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9695 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9698 static void ModifyEditorSelectboxOptions(int selectbox_id,
9699 struct ValueTextInfo *options)
9701 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9702 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9704 selectbox_info[selectbox_id].options = options;
9706 // set index to zero -- list may be shorter now (correct later, if needed)
9707 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9708 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9711 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9713 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9714 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9716 drawingarea_info[drawingarea_id].area_xsize = xsize;
9717 drawingarea_info[drawingarea_id].area_ysize = ysize;
9719 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9722 static void ModifyEditorElementList(void)
9726 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9729 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9731 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9732 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9733 struct GadgetDesign *gd = &gi->deco.design;
9734 int element = editor_elements[element_shift + i];
9735 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9739 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9741 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9747 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9749 int graphic = el2edimg(element);
9750 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9756 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9759 static void ModifyDrawingElementButton(int element, int id)
9761 struct GadgetInfo *gi = level_editor_gadget[id];
9762 Bitmap *deco_bitmap;
9764 int tile_size = gi->deco.width;
9766 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9768 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9771 static void PickDrawingElement(int button, int element)
9776 struct XYTileSize *pos;
9778 } de, drawing_elements[] =
9780 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9781 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9782 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9785 if (button < 1 || button > 3)
9788 if (IS_MM_WALL(element))
9789 element = map_mm_wall_element(element);
9791 de = drawing_elements[button - 1];
9793 *de.new_element = element; // update global drawing element variable
9795 DrawDrawingElementGraphic(element, de.pos);
9796 ModifyDrawingElementButton(element, de.id);
9798 redraw_mask |= REDRAW_DOOR_1;
9801 static void RedrawDrawingElements(void)
9803 PickDrawingElement(1, new_element1);
9804 PickDrawingElement(2, new_element2);
9805 PickDrawingElement(3, new_element3);
9808 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9810 stick_element_properties_window = FALSE;
9812 SetMainBackgroundImage(IMG_UNDEFINED);
9815 UnmapLevelEditorFieldGadgets();
9817 AdjustDrawingAreaGadgets();
9818 AdjustLevelScrollPosition();
9819 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9820 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9822 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9824 MapMainDrawingArea();
9826 if (remap_toolbox_gadgets)
9828 UnmapLevelEditorToolboxCustomGadgets();
9829 MapLevelEditorToolboxDrawingGadgets();
9833 static void DrawDrawingWindow(void)
9835 DrawDrawingWindowExt(TRUE);
9838 static int getTabulatorBarWidth(void)
9840 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9841 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9843 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9846 static int getTabulatorBarHeight(void)
9848 return ED_TAB_BAR_HEIGHT;
9851 static Pixel getTabulatorBarColor(void)
9853 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9854 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9855 int gd_x = gd->x + gd_gi1->border.width / 2;
9856 int gd_y = gd->y + gd_gi1->height - 1;
9858 return GetPixel(gd->bitmap, gd_x, gd_y);
9861 static void DrawLevelConfigTabulatorGadgets(void)
9863 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9864 Pixel tab_color = getTabulatorBarColor();
9865 int id_first = ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL;
9866 int id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR;
9869 // draw additional "engine" tabulator when using native BD engine
9870 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9871 id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE;
9873 for (i = id_first; i <= id_last; i++)
9875 int gadget_id = textbutton_info[i].gadget_id;
9876 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9877 boolean active = (i != edit_mode_levelconfig);
9879 // draw background line below tabulator button
9880 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9882 // draw solid line below inactive tabulator buttons
9883 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9884 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9885 ED_GADGET_TINY_DISTANCE, tab_color);
9887 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9888 MapTextbuttonGadget(i);
9891 // draw little border line below tabulator buttons
9892 if (tab_color != BLACK_PIXEL) // black => transparent
9893 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9894 ED_GADGET_TINY_DISTANCE,
9895 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9898 static void DrawPropertiesTabulatorGadgets(void)
9900 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9901 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9902 int gd_x = gd->x + gd_gi1->border.width / 2;
9903 int gd_y = gd->y + gd_gi1->height - 1;
9904 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9905 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9906 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9909 // draw two config tabulators for player elements
9910 if (IS_PLAYER_ELEMENT(properties_element))
9911 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9913 // draw two config and one "change" tabulator for custom elements
9914 if (IS_CUSTOM_ELEMENT(properties_element))
9915 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9917 for (i = id_first; i <= id_last; i++)
9919 int gadget_id = textbutton_info[i].gadget_id;
9920 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9921 boolean active = (i != edit_mode_properties);
9923 // use "config 1" and "config 2" instead of "config" for players and CEs
9924 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9925 (IS_PLAYER_ELEMENT(properties_element) ||
9926 IS_CUSTOM_ELEMENT(properties_element)))
9929 // draw background line below tabulator button
9930 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9932 // draw solid line below inactive tabulator buttons
9933 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9934 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9935 ED_GADGET_TINY_DISTANCE, tab_color);
9937 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9938 MapTextbuttonGadget(i);
9941 // draw little border line below tabulator buttons
9942 if (tab_color != BLACK_PIXEL) // black => transparent
9943 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9944 ED_GADGET_TINY_DISTANCE,
9945 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9948 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9950 DrawText(SX + xpos, SY + ypos, text, font_nr);
9953 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9956 int font_width = getFontWidth(font_nr);
9957 int font_height = getFontHeight(font_nr);
9958 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9959 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9961 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9962 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9963 TRUE, FALSE, FALSE);
9966 static void DrawLevelConfigLevel(void)
9970 // draw counter gadgets
9971 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9972 MapCounterButtons(i);
9974 // draw checkbutton gadgets
9975 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9976 MapCheckbuttonGadget(i);
9978 // draw selectbox gadgets
9979 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9980 MapSelectboxGadget(i);
9982 // draw text input gadgets
9983 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9984 MapTextInputGadget(i);
9987 static char *getLevelSubdirFromSaveMode(int save_mode)
9989 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9990 return getNewUserLevelSubdir();
9992 return leveldir_current->subdir;
9995 static void DrawLevelConfigLevelSet_DirectoryInfo(void)
9997 char *directory_text = "Level set directory:";
9998 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9999 int font1_nr = FONT_TEXT_1;
10000 int font2_nr = FONT_TEXT_2;
10001 int font1_height = getFontHeight(font1_nr);
10002 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
10003 int x = ED_LEVEL_SETTINGS_X(0);
10004 int y = ED_LEVEL_SETTINGS_Y(6);
10006 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
10007 PrintInfoText(directory_name, font2_nr, x, y);
10010 static void DrawLevelConfigLevelSet(void)
10012 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
10013 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
10016 // draw counter gadgets
10017 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
10018 MapCounterButtons(i);
10020 // draw checkbutton gadgets
10021 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
10023 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
10024 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
10025 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
10028 MapCheckbuttonGadget(i);
10031 // draw selectbox gadgets
10032 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
10033 MapSelectboxGadget(i);
10035 // draw text input gadgets
10036 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
10037 MapTextInputGadget(i);
10039 // draw textbutton gadgets
10040 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
10043 DrawLevelConfigLevelSet_DirectoryInfo();
10046 static void DrawLevelConfigEditor(void)
10050 // draw counter gadgets
10051 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
10052 MapCounterButtons(i);
10054 // draw checkbutton gadgets
10055 for (i = ED_CHECKBUTTON_ID_EDITOR_FIRST; i <= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
10056 MapCheckbuttonGadget(i);
10058 // draw radiobutton gadgets
10059 for (i = ED_RADIOBUTTON_ID_EDITOR_FIRST; i <= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
10060 MapRadiobuttonGadget(i);
10062 // draw drawing area
10063 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
10065 // draw textbutton gadgets
10066 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
10069 static void DrawLevelConfigEngine(void)
10073 // draw counter gadgets
10074 if (level.bd_scheduling_type == GD_SCHEDULING_MILLISECONDS)
10075 MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_MS);
10077 MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_C64);
10079 // draw checkbutton gadgets
10080 for (i = ED_CHECKBUTTON_ID_ENGINE_FIRST; i <= ED_CHECKBUTTON_ID_ENGINE_LAST; i++)
10081 MapCheckbuttonGadget(i);
10083 // draw selectbox gadgets
10084 for (i = ED_SELECTBOX_ID_ENGINE_FIRST; i <= ED_SELECTBOX_ID_ENGINE_LAST; i++)
10085 MapSelectboxGadget(i);
10088 static void DrawLevelConfigWindow(void)
10090 char *text = "Global Settings";
10091 int font_nr = FONT_TITLE_1;
10092 struct MenuPosInfo *pos = &editor.settings.headline;
10093 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
10094 int sy = SY + pos->y;
10096 stick_element_properties_window = FALSE;
10098 SetAutomaticNumberOfGemsNeeded();
10100 UnmapLevelEditorFieldGadgets();
10102 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10105 DrawText(sx, sy, text, font_nr);
10107 DrawLevelConfigTabulatorGadgets();
10109 if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVEL)
10110 DrawLevelConfigLevel();
10111 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVELSET)
10112 DrawLevelConfigLevelSet();
10113 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_EDITOR)
10114 DrawLevelConfigEditor();
10115 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_ENGINE)
10116 DrawLevelConfigEngine();
10119 static void DrawCustomContentArea(void)
10121 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
10122 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10123 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
10124 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
10125 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
10126 int xoffset = ED_GADGET_SPACE_DISTANCE;
10128 // add distance for potential left text (without drawing area border)
10129 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
10131 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10133 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
10136 static void DrawCustomChangeContentArea(void)
10138 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
10139 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10140 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
10141 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
10142 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
10143 int xoffset = ED_GADGET_SPACE_DISTANCE;
10145 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10147 MapDrawingArea(id);
10150 static void RemoveElementContentArea(int id, int font_height)
10152 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10154 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
10155 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
10156 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10157 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
10158 ED_GADGET_TEXT_DISTANCE + font_height);
10161 static void DrawYamYamContentAreas(void)
10163 int font_nr = FONT_TEXT_1;
10164 int font_height = getFontHeight(font_nr);
10165 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10166 int yoffset = (tilesize - font_height) / 2;
10167 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
10168 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
10171 // display counter to choose number of element content areas
10172 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
10174 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10176 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
10178 if (i < level.num_yamyam_contents)
10180 MapDrawingArea(id);
10184 UnmapDrawingArea(id);
10186 // delete content areas in case of reducing number of them
10187 RemoveElementContentArea(id, font_height);
10191 DrawText(x, y + 0 * tilesize, "content", font_nr);
10192 DrawText(x, y + 1 * tilesize, "when", font_nr);
10193 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
10196 static void DrawMagicBallContentAreas(void)
10198 int font_nr = FONT_TEXT_1;
10199 int font_height = getFontHeight(font_nr);
10200 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10201 int yoffset = (tilesize - font_height) / 2;
10202 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
10203 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
10206 // display counter to choose number of element content areas
10207 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
10209 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10211 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
10213 if (i < level.num_ball_contents)
10215 MapDrawingArea(id);
10219 UnmapDrawingArea(id);
10221 // delete content areas in case of reducing number of them
10222 RemoveElementContentArea(id, font_height);
10226 DrawText(x, y + 0 * tilesize, "generated", font_nr);
10227 DrawText(x, y + 1 * tilesize, "when", font_nr);
10228 DrawText(x, y + 2 * tilesize, "active", font_nr);
10231 static void DrawAndroidElementArea(void)
10233 int id = ED_DRAWING_ID_ANDROID_CONTENT;
10234 int num_elements = level.num_android_clone_elements;
10235 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10236 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10237 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10238 int xsize = MAX_ANDROID_ELEMENTS;
10241 // display counter to choose number of element areas
10242 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
10244 if (drawingarea_info[id].text_left != NULL)
10245 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10247 UnmapDrawingArea(id);
10249 ModifyEditorDrawingArea(id, num_elements, 1);
10251 // delete content areas in case of reducing number of them
10252 DrawBackground(sx, sy,
10253 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10254 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10256 MapDrawingArea(id);
10259 static void DrawGroupElementArea(void)
10261 int id = ED_DRAWING_ID_GROUP_CONTENT;
10262 int num_elements = group_element_info.num_elements;
10263 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10264 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10265 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10266 int xsize = MAX_ELEMENTS_IN_GROUP;
10269 if (drawingarea_info[id].text_left != NULL)
10270 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10272 UnmapDrawingArea(id);
10274 ModifyEditorDrawingArea(id, num_elements, 1);
10276 // delete content areas in case of reducing number of them
10277 DrawBackground(sx, sy,
10278 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10279 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10281 MapDrawingArea(id);
10284 static void DrawPlayerInitialInventoryArea(int element)
10286 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
10287 int player_nr = GET_PLAYER_NR(element);
10288 int num_elements = level.initial_inventory_size[player_nr];
10289 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10290 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10291 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10292 int xsize = MAX_INITIAL_INVENTORY_SIZE;
10295 // determine horizontal position to the right of specified gadget
10296 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
10297 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
10298 ED_DRAWINGAREA_TEXT_DISTANCE);
10300 // determine horizontal offset for leading text
10301 if (drawingarea_info[id].text_left != NULL)
10302 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10304 UnmapDrawingArea(id);
10306 ModifyEditorDrawingArea(id, num_elements, 1);
10308 // delete content areas in case of reducing number of them
10309 DrawBackground(sx, sy,
10310 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10311 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10313 MapDrawingArea(id);
10316 static void DrawMMBallContentArea(void)
10318 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
10319 int num_elements = level.num_mm_ball_contents;
10320 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10321 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10322 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10323 int xsize = MAX_MM_BALL_CONTENTS;
10326 if (drawingarea_info[id].text_left != NULL)
10327 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10329 UnmapDrawingArea(id);
10331 ModifyEditorDrawingArea(id, num_elements, 1);
10333 // delete content areas in case of reducing number of them
10334 DrawBackground(sx, sy,
10335 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10336 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10338 MapDrawingArea(id);
10341 static void DrawEnvelopeTextArea(int envelope_nr)
10343 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
10344 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
10348 DrawBackground(gi->x, gi->y,
10349 gi->textarea.crop_width, gi->textarea.crop_height);
10351 if (envelope_nr != -1)
10352 textarea_info[id].value = level.envelope[envelope_nr].text;
10354 ModifyGadget(gi, GDI_AREA_SIZE,
10355 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
10356 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
10359 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
10362 static void DrawPropertiesInfo(void)
10371 // configurable properties
10373 { EP_WALKABLE_OVER, "- player can walk over it" },
10374 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
10375 { EP_WALKABLE_UNDER, "- player can walk under it" },
10376 { EP_PASSABLE_OVER, "- player can pass over it" },
10377 { EP_PASSABLE_INSIDE, "- player can pass through it" },
10378 { EP_PASSABLE_UNDER, "- player can pass under it" },
10379 { EP_PROTECTED, "- player is protected by it" },
10381 { EP_DIGGABLE, "- can be digged away" },
10382 { EP_COLLECTIBLE, "- can be collected" },
10383 { EP_DROPPABLE, "- can be dropped after collecting" },
10384 { EP_THROWABLE, "- can be thrown after collecting" },
10385 { EP_PUSHABLE, "- can be pushed" },
10387 { EP_CAN_FALL, "- can fall" },
10388 { EP_CAN_MOVE, "- can move" },
10390 { EP_CAN_SMASH_PLAYER, "- can smash player" },
10392 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
10394 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
10396 { EP_SLIPPERY, "- slippery for falling elements" },
10397 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
10399 { EP_DONT_RUN_INTO, "- deadly when running into" },
10400 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
10401 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
10402 { EP_DONT_TOUCH, "- deadly when touching" },
10404 { EP_INDESTRUCTIBLE, "- indestructible" },
10406 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
10407 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
10408 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
10410 { EP_CAN_CHANGE, "- can change to other element" },
10412 // pre-defined properties
10413 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
10414 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
10415 { EP_SWITCHABLE, "- can be switched" },
10417 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
10422 char *filename = getElementDescriptionFilename(properties_element);
10423 char *num_elements_text = "In this level: ";
10424 char *num_similar_text = "Similar tiles: ";
10425 char *properties_text = "Standard properties: ";
10426 char *description_text = "Description:";
10427 char *no_description_text = "No description available.";
10428 char *none_text = "None";
10430 int num_elements_in_level = 0;
10431 int num_similar_in_level = 0;
10432 int num_hires_tiles_in_level = 0;
10433 int num_standard_properties = 0;
10434 int font1_nr = FONT_TEXT_1;
10435 int font2_nr = FONT_TEXT_2;
10436 int font1_width = getFontWidth(font1_nr);
10437 int font1_height = getFontHeight(font1_nr);
10438 int font2_height = getFontHeight(font2_nr);
10439 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
10440 int font2_yoffset = (font1_height - font2_height) / 2;
10441 int num_elements_text_len = strlen(num_elements_text) * font1_width;
10442 int num_similar_text_len = strlen(num_similar_text) * font1_width;
10443 int properties_text_len = strlen(properties_text) * font1_width;
10444 int xpos = ED_ELEMENT_SETTINGS_X(0);
10445 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10448 if (setup.editor.show_element_token)
10450 int font3_nr = FONT_TEXT_3;
10451 int font3_height = getFontHeight(font3_nr);
10453 DrawTextF(xpos, ypos, font3_nr,
10454 "[%s]", element_info[properties_element].token_name);
10456 ypos += 2 * font3_height;
10459 // ----- print number of elements / percentage of this element in level
10461 for (y = 0; y < lev_fieldy; y++)
10463 for (x = 0; x < lev_fieldx; x++)
10465 if (Tile[x][y] == properties_element)
10467 num_elements_in_level++;
10469 else if (IS_MM_WALL(Tile[x][y]) &&
10470 map_mm_wall_element(Tile[x][y]) == properties_element)
10472 num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
10477 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10479 DrawTextS(xpos, ypos, font1_nr, num_elements_text);
10481 if (num_hires_tiles_in_level > 0)
10482 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10483 "%d wall tiles", num_hires_tiles_in_level);
10484 else if (num_elements_in_level > 0)
10485 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10486 "%d (%.2f %%)", num_elements_in_level, percentage);
10488 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10491 // ----- print number of similar elements / percentage of them in level
10493 for (y = 0; y < lev_fieldy; y++)
10495 for (x = 0; x < lev_fieldx; x++)
10497 if (strEqual(element_info[Tile[x][y]].class_name,
10498 element_info[properties_element].class_name))
10500 num_similar_in_level++;
10505 if (num_similar_in_level != num_elements_in_level)
10507 ypos += 1 * MAX(font1_height, font2_height);
10509 percentage = num_similar_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10511 DrawTextS(xpos, ypos, font1_nr, num_similar_text);
10513 if (num_similar_in_level > 0)
10514 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10515 "%d (%.2f %%)", num_similar_in_level, percentage);
10517 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10521 ypos += 2 * MAX(font1_height, font2_height);
10523 // ----- print standard properties of this element
10525 DrawTextS(xpos, ypos, font1_nr, properties_text);
10527 ypos += line1_height;
10529 for (i = 0; properties[i].value != -1; i++)
10531 if (!HAS_PROPERTY(properties_element, properties[i].value))
10534 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
10536 ypos += font2_height;
10538 num_standard_properties++;
10541 if (num_standard_properties == 0)
10543 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
10544 font2_nr, none_text);
10546 ypos -= (line1_height - font1_height);
10549 ypos += MAX(font1_height, font2_height);
10551 // ----- print special description of this element
10553 PrintInfoText(description_text, font1_nr, xpos, ypos);
10555 ypos += line1_height;
10557 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
10558 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
10561 #define TEXT_COLLECTING "Score for collecting"
10562 #define TEXT_COLLECTING_EXTRA "Score for extra diamonds"
10563 #define TEXT_SMASHING "Score for smashing"
10564 #define TEXT_SLURPING "Score for slurping robot"
10565 #define TEXT_CRACKING "Score for cracking"
10566 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
10567 #define TEXT_DURATION "Duration when activated"
10568 #define TEXT_DELAY_ON "Delay before activating"
10569 #define TEXT_DELAY_OFF "Delay before deactivating"
10570 #define TEXT_DELAY_CHANGING "Delay before changing"
10571 #define TEXT_DELAY_EXPLODING "Delay before exploding"
10572 #define TEXT_DELAY_MOVING "Delay before moving"
10573 #define TEXT_BALL_DELAY "Element generation delay"
10574 #define TEXT_MOVE_SPEED "Speed of android moving"
10575 #define TEXT_CLONE_SPEED "Speed of android cloning"
10576 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
10577 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
10578 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
10579 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
10580 #define TEXT_TIME_BONUS "Extra time to solve level"
10587 } elements_with_counter[] =
10589 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
10590 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
10591 { EL_BD_DIAMOND, &level.score[SC_DIAMOND_EXTRA], TEXT_COLLECTING_EXTRA },
10592 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
10593 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
10594 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10595 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
10596 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
10597 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
10598 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
10599 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
10600 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10601 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
10602 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10603 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10604 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
10605 { EL_BD_BUTTERFLY_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10606 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
10607 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10608 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10609 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
10610 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10611 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10612 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10613 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10614 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10615 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10616 { EL_BD_FIREFLY_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10617 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10618 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10619 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10620 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10621 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10622 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10623 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10624 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
10625 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
10626 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10627 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
10628 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10629 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10630 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10631 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10632 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10633 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
10634 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10635 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10636 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE], TEXT_COLLECTING },
10637 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10638 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10639 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
10640 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
10641 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
10642 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10643 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10644 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10645 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10646 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10647 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10648 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10649 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10650 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
10651 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
10652 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
10653 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
10654 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
10655 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10656 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
10657 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
10658 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
10659 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10660 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10661 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10662 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10663 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10664 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10665 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10666 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10667 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10668 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10669 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10670 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10671 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10672 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
10673 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10674 { EL_DC_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10675 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
10676 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
10677 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
10678 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
10679 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
10680 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
10681 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
10682 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
10683 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
10684 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
10685 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
10686 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
10687 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
10688 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
10689 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
10690 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
10691 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
10692 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
10693 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
10694 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
10695 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
10696 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
10697 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
10698 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
10699 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
10700 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
10701 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_CHANGING },
10702 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10703 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10708 static boolean checkPropertiesConfig(int element)
10712 // special case: empty space customization only available in R'n'D game engine
10713 if (element == EL_EMPTY_SPACE && level.game_engine_type != GAME_ENGINE_TYPE_RND)
10716 if (IS_GEM(element) ||
10717 IS_CUSTOM_ELEMENT(element) ||
10718 IS_GROUP_ELEMENT(element) ||
10719 IS_EMPTY_ELEMENT(element) ||
10720 IS_BALLOON_ELEMENT(element) ||
10721 IS_ENVELOPE(element) ||
10722 IS_MM_ENVELOPE(element) ||
10723 IS_MM_MCDUFFIN(element) ||
10724 IS_DF_LASER(element) ||
10725 IS_PLAYER_ELEMENT(element) ||
10726 IS_BD_PLAYER_ELEMENT(element) ||
10727 IS_SOKOBAN_OBJECT_OR_FIELD(element) ||
10728 HAS_EDITOR_CONTENT(element) ||
10729 CAN_GROW(element) ||
10730 COULD_MOVE_INTO_ACID(element) ||
10731 MAYBE_DONT_COLLIDE_WITH(element))
10734 for (i = 0; elements_with_counter[i].element != -1; i++)
10735 if (elements_with_counter[i].element == element)
10741 static void SetAutomaticNumberOfGemsNeeded(void)
10745 if (!level.auto_count_gems)
10748 level.gems_needed = 0;
10750 for (x = 0; x < lev_fieldx; x++)
10752 for (y = 0; y < lev_fieldy; y++)
10754 int element = Tile[x][y];
10759 case EL_EMERALD_YELLOW:
10760 case EL_EMERALD_RED:
10761 case EL_EMERALD_PURPLE:
10762 case EL_BD_DIAMOND:
10763 case EL_WALL_EMERALD:
10764 case EL_WALL_EMERALD_YELLOW:
10765 case EL_WALL_EMERALD_RED:
10766 case EL_WALL_EMERALD_PURPLE:
10767 case EL_WALL_BD_DIAMOND:
10769 case EL_SP_INFOTRON:
10772 level.gems_needed++;
10776 case EL_WALL_DIAMOND:
10777 level.gems_needed += 3;
10781 case EL_WALL_PEARL:
10782 level.gems_needed += 5;
10786 case EL_WALL_CRYSTAL:
10787 level.gems_needed += 8;
10796 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10799 static void DrawPropertiesConfig(void)
10801 boolean draw_footer_line = FALSE;
10802 int max_num_element_counters = 4;
10803 int num_element_counters = 0;
10806 if (!checkPropertiesConfig(properties_element))
10808 int xpos = ED_ELEMENT_SETTINGS_X(0);
10809 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10811 PrintInfoText("No configuration options available.",
10812 FONT_TEXT_1, xpos, ypos);
10817 // check if there are elements where a value can be chosen for
10818 for (i = 0; elements_with_counter[i].element != -1; i++)
10820 if (elements_with_counter[i].element == properties_element)
10822 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10824 counterbutton_info[counter_id].y =
10825 ED_ELEMENT_SETTINGS_YPOS(
10826 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10827 (CAN_GROW(properties_element) ? 1 : 0) +
10828 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10829 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10830 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10831 num_element_counters);
10833 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10834 counterbutton_info[counter_id].text_right = elements_with_counter[i].text;
10836 if (properties_element == EL_GAME_OF_LIFE ||
10837 properties_element == EL_BIOMAZE)
10839 counterbutton_info[counter_id].min_value = 0; // min neighbours
10840 counterbutton_info[counter_id].max_value = 8; // max neighbours
10844 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10845 counterbutton_info[counter_id].min_value = MIN_SCORE;
10846 counterbutton_info[counter_id].max_value = MAX_SCORE;
10849 MapCounterButtons(counter_id);
10851 num_element_counters++;
10852 if (num_element_counters >= max_num_element_counters)
10857 if (HAS_EDITOR_CONTENT(properties_element))
10859 // draw stickybutton gadget
10860 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10862 if (IS_AMOEBOID(properties_element))
10863 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10864 else if (properties_element == EL_YAMYAM ||
10865 properties_element == EL_YAMYAM_LEFT ||
10866 properties_element == EL_YAMYAM_RIGHT ||
10867 properties_element == EL_YAMYAM_UP ||
10868 properties_element == EL_YAMYAM_DOWN)
10869 DrawYamYamContentAreas();
10870 else if (properties_element == EL_EMC_MAGIC_BALL)
10872 DrawMagicBallContentAreas();
10874 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10875 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10877 else if (properties_element == EL_EMC_ANDROID)
10878 DrawAndroidElementArea();
10879 else if (properties_element == EL_MM_GRAY_BALL)
10881 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
10882 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
10883 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
10884 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EXPLODE_MM_BALL);
10886 DrawMMBallContentArea();
10890 if (IS_PLAYER_ELEMENT(properties_element))
10892 int player_nr = GET_PLAYER_NR(properties_element);
10894 // these properties can be set for every player individually
10896 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10898 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
10899 &level.start_element[player_nr];
10900 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
10901 &level.artwork_element[player_nr];
10902 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
10903 &level.explosion_element[player_nr];
10905 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10906 &level.use_start_element[player_nr];
10907 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10908 &level.use_artwork_element[player_nr];
10909 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10910 &level.use_explosion_element[player_nr];
10911 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10912 &level.initial_player_gravity[player_nr];
10914 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10915 &level.initial_player_stepsize[player_nr];
10917 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
10918 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
10919 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
10920 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
10921 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
10922 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
10923 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
10924 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
10925 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
10926 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
10927 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
10928 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
10929 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
10930 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
10931 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
10933 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
10934 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
10935 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
10937 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
10939 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10941 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
10942 &level.initial_inventory_content[player_nr][0];
10944 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
10945 &level.initial_inventory_size[player_nr];
10947 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
10948 &level.use_initial_inventory[player_nr];
10950 // draw checkbutton gadgets
10951 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
10952 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
10953 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
10955 // draw counter gadgets
10956 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
10958 // draw drawing area gadgets
10959 DrawPlayerInitialInventoryArea(properties_element);
10963 if (IS_BD_PLAYER_ELEMENT(properties_element))
10964 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS);
10966 // special case: slippery walls option for gems only available in R'n'D game engine
10967 if (IS_GEM(properties_element) && level.game_engine_type == GAME_ENGINE_TYPE_RND)
10969 checkbutton_info[ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS].y =
10970 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_BD_DIAMOND ? 2 : 1);
10972 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
10975 if (properties_element == EL_EM_DYNAMITE)
10976 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
10978 if (COULD_MOVE_INTO_ACID(properties_element) &&
10979 !IS_PLAYER_ELEMENT(properties_element) &&
10980 (!IS_CUSTOM_ELEMENT(properties_element) ||
10981 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
10983 // set position for checkbutton for "can move into acid"
10984 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
10985 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
10986 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
10987 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
10988 IS_BALLOON_ELEMENT(properties_element) ||
10989 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10991 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
10994 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
10995 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
10997 if (properties_element == EL_SPRING ||
10998 properties_element == EL_SPRING_LEFT ||
10999 properties_element == EL_SPRING_RIGHT)
11000 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
11002 if (properties_element == EL_TIME_ORB_FULL)
11003 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
11005 if (properties_element == EL_GAME_OF_LIFE ||
11006 properties_element == EL_BIOMAZE)
11007 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
11009 if (CAN_GROW(properties_element))
11011 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
11012 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
11014 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
11017 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
11018 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
11020 if (properties_element == EL_SOKOBAN_OBJECT)
11021 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
11023 if (properties_element == EL_SOKOBAN_OBJECT ||
11024 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
11025 properties_element == EL_SOKOBAN_FIELD_FULL)
11027 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
11028 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
11031 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
11034 if (IS_BALLOON_ELEMENT(properties_element))
11035 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
11037 if (IS_ENVELOPE(properties_element) ||
11038 IS_MM_ENVELOPE(properties_element))
11040 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
11041 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
11042 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
11043 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
11044 int envelope_nr = ENVELOPE_NR(properties_element);
11046 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
11047 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
11049 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
11050 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
11052 // display counter to choose size of envelope text area
11053 MapCounterButtons(counter1_id);
11054 MapCounterButtons(counter2_id);
11056 // display checkbuttons to choose auto-wrap and alignment properties
11057 MapCheckbuttonGadget(button1_id);
11058 MapCheckbuttonGadget(button2_id);
11060 DrawEnvelopeTextArea(envelope_nr);
11063 if (IS_MM_MCDUFFIN(properties_element))
11065 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
11066 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
11067 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
11070 if (IS_DF_LASER(properties_element))
11072 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
11073 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
11074 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
11077 if (IS_CUSTOM_ELEMENT(properties_element))
11079 // draw stickybutton gadget
11080 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11082 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
11084 // draw checkbutton gadgets
11085 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
11086 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
11087 MapCheckbuttonGadget(i);
11089 // draw counter gadgets
11090 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
11091 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
11092 MapCounterButtons(i);
11094 // draw selectbox gadgets
11095 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
11096 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
11097 MapSelectboxGadget(i);
11099 // draw textbutton gadgets
11100 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11102 // draw text input gadgets
11103 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11105 // draw drawing area gadgets
11106 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11108 draw_footer_line = TRUE;
11110 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
11112 // draw checkbutton gadgets
11113 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
11114 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
11115 MapCheckbuttonGadget(i);
11117 // draw counter gadgets
11118 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
11119 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
11120 MapCounterButtons(i);
11122 // draw selectbox gadgets
11123 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
11124 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
11125 MapSelectboxGadget(i);
11127 // draw drawing area gadgets
11128 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
11129 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
11130 DrawCustomContentArea();
11133 else if (IS_GROUP_ELEMENT(properties_element))
11135 // draw stickybutton gadget
11136 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11138 // draw checkbutton gadgets
11139 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11140 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11142 // draw counter gadgets
11143 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
11145 // draw selectbox gadgets
11146 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
11148 // draw textbutton gadgets
11149 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11151 // draw drawing area gadgets
11152 DrawGroupElementArea();
11154 // draw text input gadgets
11155 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11157 // draw drawing area gadgets
11158 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11160 draw_footer_line = TRUE;
11162 else if (IS_EMPTY_ELEMENT(properties_element))
11164 // draw stickybutton gadget
11165 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11167 // draw checkbutton gadgets
11168 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11169 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11171 // draw textbutton gadgets
11172 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11174 // draw drawing area gadgets
11175 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11177 draw_footer_line = TRUE;
11180 // draw little footer border line above CE/GE use/save template gadgets
11181 if (draw_footer_line)
11183 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
11184 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
11185 int gd_x = gd->x + gd_gi1->border.width / 2;
11186 int gd_y = gd->y + gd_gi1->height - 1;
11187 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
11189 if (tab_color != BLACK_PIXEL) // black => transparent
11190 FillRectangle(drawto,
11191 SX + ED_ELEMENT_SETTINGS_X(0),
11192 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
11194 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
11198 static void DrawPropertiesChangeDrawingAreas(void)
11200 if (IS_CUSTOM_ELEMENT(properties_element))
11202 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
11203 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
11204 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
11206 DrawCustomChangeContentArea();
11209 redraw_mask |= REDRAW_FIELD;
11212 static void DrawPropertiesChange(void)
11216 // needed to initially set selectbox options for special action options
11217 setSelectboxSpecialActionOptions();
11219 // draw stickybutton gadget
11220 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11222 // draw checkbutton gadgets
11223 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
11224 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
11225 MapCheckbuttonGadget(i);
11227 // draw counter gadgets
11228 for (i = ED_COUNTER_ID_CHANGE_FIRST;
11229 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
11230 MapCounterButtons(i);
11232 // draw selectbox gadgets
11233 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
11234 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
11235 MapSelectboxGadget(i);
11237 // draw textbutton gadgets
11238 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
11239 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
11240 MapTextbuttonGadget(i);
11242 // draw graphicbutton gadgets
11243 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
11244 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
11245 MapGraphicbuttonGadget(i);
11247 // draw drawing area gadgets
11248 DrawPropertiesChangeDrawingAreas();
11251 static void DrawEditorElementAnimation(int x, int y)
11253 int graphic = el2img(properties_element);
11254 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
11255 custom_element.ce_value_fixed_initial :
11256 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
11257 custom_element.collect_score_initial : FrameCounter);
11259 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
11262 static void DrawEditorElementName(int x, int y, int font_nr)
11264 char *element_name = getElementInfoText(properties_element);
11265 int font_width = getFontWidth(font_nr);
11266 int font_height = getFontHeight(font_nr);
11267 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
11268 int max_chars_per_line = max_text_width / font_width;
11270 if (strlen(element_name) <= max_chars_per_line)
11271 DrawTextS(x, y, font_nr, element_name);
11274 char buffer[max_chars_per_line + 1];
11275 int next_pos = max_chars_per_line;
11277 strncpy(buffer, element_name, max_chars_per_line);
11278 buffer[max_chars_per_line] = '\0';
11280 if (element_name[max_chars_per_line] == ' ')
11286 for (i = max_chars_per_line - 1; i >= 0; i--)
11287 if (buffer[i] == ' ')
11290 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
11297 DrawTextS(x, y - font_height / 2, font_nr, buffer);
11299 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
11300 buffer[max_chars_per_line] = '\0';
11302 DrawTextS(x, y + font_height / 2, font_nr, buffer);
11306 static void DrawPropertiesWindow(void)
11308 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
11309 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
11310 int border_size = gd->border_size;
11311 int font_nr = FONT_TEXT_1;
11312 int font_height = getFontHeight(font_nr);
11313 int xoffset = TILEX + element_border + 3 * border_size;
11314 int yoffset = (TILEY - font_height) / 2;
11315 int x1 = editor.settings.element_graphic.x + element_border;
11316 int y1 = editor.settings.element_graphic.y + element_border;
11317 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
11318 editor.settings.element_name.x);
11319 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
11320 editor.settings.element_name.y);
11321 char *text = "Element Settings";
11322 int font2_nr = FONT_TITLE_1;
11323 struct MenuPosInfo *pos = &editor.settings.headline;
11324 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
11325 int sy = SY + pos->y;
11327 stick_element_properties_window = FALSE;
11329 // make sure that previous properties edit mode exists for this element
11330 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
11331 !IS_CUSTOM_ELEMENT(properties_element))
11332 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
11334 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
11335 !IS_PLAYER_ELEMENT(properties_element) &&
11336 !IS_CUSTOM_ELEMENT(properties_element))
11337 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
11339 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
11340 (IS_PLAYER_ELEMENT(properties_element) ||
11341 IS_CUSTOM_ELEMENT(properties_element)))
11342 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
11344 CopyElementPropertiesToEditor(properties_element);
11346 UnmapLevelEditorFieldGadgets();
11347 UnmapLevelEditorToolboxDrawingGadgets();
11348 UnmapLevelEditorToolboxCustomGadgets();
11350 MapLevelEditorToolboxCustomGadgetsIfNeeded();
11352 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11355 DrawText(sx, sy, text, font2_nr);
11357 FrameCounter = 0; // restart animation frame counter
11359 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
11360 DrawEditorElementAnimation(SX + x1, SY + y1);
11361 DrawEditorElementName(x2, y2, font_nr);
11363 DrawPropertiesTabulatorGadgets();
11365 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
11366 DrawPropertiesInfo();
11367 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
11368 DrawPropertiesChange();
11369 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
11370 DrawPropertiesConfig();
11373 static void DrawPaletteWindow(void)
11377 UnmapLevelEditorFieldGadgets();
11379 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11382 // map buttons to select elements
11383 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
11384 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
11385 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
11386 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
11387 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
11390 static void UpdateCustomElementGraphicGadgets(void)
11394 InitElementPropertiesGfxElement();
11396 ModifyEditorElementList();
11397 RedrawDrawingElements();
11399 // force redraw of all mapped drawing area gadgets
11400 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
11402 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
11409 static int getOpenDirectionFromTube(int element)
11413 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
11414 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
11415 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
11416 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
11417 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
11418 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
11419 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
11420 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
11421 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
11422 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
11423 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
11429 static int getTubeFromOpenDirection(int direction)
11433 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
11434 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
11435 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
11436 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
11437 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
11438 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
11439 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
11440 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
11441 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
11442 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
11443 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
11445 // if only one direction, fall back to simple tube with that direction
11446 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
11447 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
11448 case (MV_UP): return EL_TUBE_VERTICAL;
11449 case (MV_DOWN): return EL_TUBE_VERTICAL;
11455 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
11457 int element_new = getTubeFromOpenDirection(direction);
11459 return (element_new != EL_EMPTY ? element_new : element_old);
11462 static int getOpenDirectionFromBelt(int element)
11464 int belt_dir = getBeltDirFromBeltElement(element);
11466 return (belt_dir == MV_LEFT ? MV_RIGHT :
11467 belt_dir == MV_RIGHT ? MV_LEFT :
11468 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
11471 static int getBeltFromNrAndOpenDirection(int nr, int direction)
11473 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
11474 direction == MV_RIGHT ? MV_LEFT :
11475 direction == MV_HORIZONTAL ? MV_NONE : direction);
11477 if (direction == MV_NONE)
11480 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
11483 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
11486 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
11488 return (element_new != EL_EMPTY ? element_new : element_old);
11491 static int getOpenDirectionFromPool(int element)
11495 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
11496 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
11497 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
11498 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
11499 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
11500 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
11506 static int getPoolFromOpenDirection(int direction)
11510 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
11511 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
11512 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
11513 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
11514 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
11515 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
11521 static int getPoolFromOpenDirectionExt(int direction, int help_element)
11523 int element = getPoolFromOpenDirection(direction);
11524 int help_direction = getOpenDirectionFromPool(help_element);
11526 if (element == EL_EMPTY)
11528 int help_direction_vertical = help_direction & MV_VERTICAL;
11530 element = getPoolFromOpenDirection(direction | help_direction_vertical);
11533 if (element == EL_EMPTY)
11535 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
11537 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
11543 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
11545 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
11547 return (element_new != EL_EMPTY ? element_new : element_old);
11550 static int getOpenDirectionFromPillar(int element)
11554 case EL_EMC_WALL_1: return (MV_DOWN);
11555 case EL_EMC_WALL_2: return (MV_VERTICAL);
11556 case EL_EMC_WALL_3: return (MV_UP);
11562 static int getPillarFromOpenDirection(int direction)
11566 case (MV_DOWN): return EL_EMC_WALL_1;
11567 case (MV_VERTICAL): return EL_EMC_WALL_2;
11568 case (MV_UP): return EL_EMC_WALL_3;
11574 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
11576 int element_new = getPillarFromOpenDirection(direction);
11578 return (element_new != EL_EMPTY ? element_new : element_old);
11581 static int getOpenDirectionFromSteel2(int element)
11585 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
11586 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
11587 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
11588 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
11589 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
11590 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
11591 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
11592 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
11598 static int getSteel2FromOpenDirection(int direction)
11602 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
11603 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
11604 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
11605 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
11606 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
11607 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
11608 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
11609 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
11615 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
11617 int element_new = getSteel2FromOpenDirection(direction);
11619 return (element_new != EL_EMPTY ? element_new : element_old);
11622 static int getOpenDirectionFromChip(int element)
11626 case EL_SP_CHIP_SINGLE: return (MV_NONE);
11627 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
11628 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
11629 case EL_SP_CHIP_TOP: return (MV_DOWN);
11630 case EL_SP_CHIP_BOTTOM: return (MV_UP);
11636 static int getChipFromOpenDirection(int direction)
11640 case (MV_NONE): return EL_SP_CHIP_SINGLE;
11641 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
11642 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
11643 case (MV_UP): return EL_SP_CHIP_BOTTOM;
11644 case (MV_DOWN): return EL_SP_CHIP_TOP;
11650 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
11652 int element_new = getChipFromOpenDirection(direction);
11654 return (element_new != EL_EMPTY ? element_new : element_old);
11657 static int getClosedTube(int x, int y)
11659 struct XY *xy = xy_directions;
11660 int element_old = IntelliDrawBuffer[x][y];
11661 int direction_old = getOpenDirectionFromTube(element_old);
11662 int direction_new = MV_NONE;
11665 for (i = 0; i < NUM_DIRECTIONS; i++)
11667 int xx = x + xy[i].x;
11668 int yy = y + xy[i].y;
11669 int dir = MV_DIR_FROM_BIT(i);
11670 int dir_opposite = MV_DIR_OPPOSITE(dir);
11672 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
11673 (direction_old & dir) &&
11674 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11675 direction_new |= dir;
11678 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
11681 static int getClosedBelt(int x, int y)
11683 struct XY *xy = xy_directions;
11684 int element_old = IntelliDrawBuffer[x][y];
11685 int nr = getBeltNrFromBeltElement(element_old);
11686 int direction_old = getOpenDirectionFromBelt(element_old);
11687 int direction_new = MV_NONE;
11690 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11692 int xx = x + xy[i].x;
11693 int yy = y + xy[i].y;
11694 int dir = MV_DIR_FROM_BIT(i);
11695 int dir_opposite = MV_DIR_OPPOSITE(dir);
11697 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
11698 (direction_old & dir) &&
11699 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11700 direction_new |= dir;
11703 return getBeltFromNrAndOpenDirection(nr, direction_new);
11706 static int getClosedPool(int x, int y)
11708 struct XY *xy = xy_directions;
11709 int element_old = IntelliDrawBuffer[x][y];
11710 int direction_old = getOpenDirectionFromPool(element_old);
11711 int direction_new = MV_NONE;
11714 for (i = 0; i < NUM_DIRECTIONS; i++)
11716 int xx = x + xy[i].x;
11717 int yy = y + xy[i].y;
11718 int dir = MV_DIR_FROM_BIT(i);
11719 int dir_opposite = MV_DIR_OPPOSITE(dir);
11721 if (IN_LEV_FIELD(xx, yy) &&
11722 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
11723 (direction_old & dir) &&
11724 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11725 direction_new |= dir;
11728 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
11731 static int getClosedPillar(int x, int y)
11733 struct XY *xy = xy_directions;
11734 int element_old = IntelliDrawBuffer[x][y];
11735 int direction_old = getOpenDirectionFromPillar(element_old);
11736 int direction_new = MV_NONE;
11739 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11741 int xx = x + xy[i].x;
11742 int yy = y + xy[i].y;
11743 int dir = MV_DIR_FROM_BIT(i);
11744 int dir_opposite = MV_DIR_OPPOSITE(dir);
11746 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11747 (direction_old & dir) &&
11748 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11749 direction_new |= dir;
11752 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11755 static int getClosedSteel2(int x, int y)
11757 struct XY *xy = xy_directions;
11758 int element_old = IntelliDrawBuffer[x][y];
11759 int direction_old = getOpenDirectionFromSteel2(element_old);
11760 int direction_new = MV_NONE;
11763 for (i = 0; i < NUM_DIRECTIONS; i++)
11765 int xx = x + xy[i].x;
11766 int yy = y + xy[i].y;
11767 int dir = MV_DIR_FROM_BIT(i);
11768 int dir_opposite = MV_DIR_OPPOSITE(dir);
11770 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11771 (direction_old & dir) &&
11772 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11773 direction_new |= dir;
11776 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11779 static int getClosedChip(int x, int y)
11781 struct XY *xy = xy_directions;
11782 int element_old = IntelliDrawBuffer[x][y];
11783 int direction_old = getOpenDirectionFromChip(element_old);
11784 int direction_new = MV_NONE;
11787 for (i = 0; i < NUM_DIRECTIONS; i++)
11789 int xx = x + xy[i].x;
11790 int yy = y + xy[i].y;
11791 int dir = MV_DIR_FROM_BIT(i);
11792 int dir_opposite = MV_DIR_OPPOSITE(dir);
11794 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11795 (direction_old & dir) &&
11796 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11797 direction_new |= dir;
11800 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11803 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11804 boolean change_level)
11806 int sx = x - level_xpos;
11807 int sy = y - level_ypos;
11808 int old_element = Tile[x][y];
11809 int new_element = element;
11810 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11811 boolean draw_masked = FALSE;
11813 if (IS_MM_WALL_EDITOR(element))
11815 element = map_mm_wall_element_editor(element) | new_bitmask;
11817 if (IS_MM_WALL(old_element))
11818 element |= MM_WALL_BITS(old_element);
11821 draw_masked = TRUE;
11823 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11825 int element_changed = old_element & ~new_bitmask;
11827 if (MM_WALL_BITS(element_changed) != 0)
11828 element = element_changed;
11831 IntelliDrawBuffer[x][y] = element;
11834 Tile[x][y] = element;
11836 if (IN_ED_FIELD(sx, sy))
11838 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11839 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11840 else if (draw_masked)
11841 DrawEditorElementThruMask(sx, sy, element);
11843 DrawEditorElement(sx, sy, element);
11847 static void SetElementSimple(int x, int y, int element, boolean change_level)
11849 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11852 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11853 int x2, int y2, int *element2,
11854 int (*close_function)(int, int),
11855 boolean change_level)
11857 // set neighbour elements to newly determined connections
11858 SetElementSimple(x1, y1, *element1, change_level);
11859 SetElementSimple(x2, y2, *element2, change_level);
11861 // remove all open connections of neighbour elements
11862 *element1 = close_function(x1, y1);
11863 *element2 = close_function(x2, y2);
11865 // set neighbour elements to new, minimized connections
11866 SetElementSimple(x1, y1, *element1, change_level);
11867 SetElementSimple(x2, y2, *element2, change_level);
11870 static void SetElementIntelliDraw(int x, int y, int dx, int dy, int new_element,
11871 boolean change_level, int button)
11873 struct XY *xy = xy_directions;
11874 static int last_x = -1;
11875 static int last_y = -1;
11877 if (new_element == EL_UNDEFINED)
11885 int old_element = IntelliDrawBuffer[x][y];
11887 if (IS_TUBE(new_element))
11889 int last_element_new = EL_UNDEFINED;
11890 int direction = MV_NONE;
11893 // if old element is of same kind, keep all existing directions
11894 if (IS_TUBE(old_element))
11895 direction |= getOpenDirectionFromTube(old_element);
11897 for (i = 0; i < NUM_DIRECTIONS; i++)
11899 int xx = x + xy[i].x;
11900 int yy = y + xy[i].y;
11902 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11903 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11905 int dir = MV_DIR_FROM_BIT(i);
11906 int dir_opposite = MV_DIR_OPPOSITE(dir);
11907 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11908 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11909 int last_direction_new = last_direction_old | dir_opposite;
11911 last_element_new = getTubeFromOpenDirection(last_direction_new);
11917 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
11919 if (last_element_new != EL_UNDEFINED)
11920 MergeAndCloseNeighbourElements(x, y, &new_element,
11921 last_x, last_y, &last_element_new,
11922 getClosedTube, change_level);
11924 else if (IS_BELT(new_element))
11926 int belt_nr = getBeltNrFromBeltElement(new_element);
11927 int last_element_new = EL_UNDEFINED;
11928 int direction = MV_NONE;
11931 // if old element is of same kind, keep all existing directions
11932 if (IS_BELT(old_element))
11933 direction |= getOpenDirectionFromBelt(old_element);
11935 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11937 int xx = x + xy[i].x;
11938 int yy = y + xy[i].y;
11940 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11941 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
11943 int dir = MV_DIR_FROM_BIT(i);
11944 int dir_opposite = MV_DIR_OPPOSITE(dir);
11945 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11946 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
11947 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
11948 int last_direction_new = last_direction_old | dir_opposite;
11950 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11951 last_direction_new);
11956 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
11958 if (last_element_new != EL_UNDEFINED)
11959 MergeAndCloseNeighbourElements(x, y, &new_element,
11960 last_x, last_y, &last_element_new,
11961 getClosedBelt, change_level);
11963 else if (IS_ACID_POOL_OR_ACID(new_element))
11965 int last_element_new = EL_UNDEFINED;
11966 int direction = MV_NONE;
11969 // if old element is of same kind, keep all existing directions
11970 if (IS_ACID_POOL_OR_ACID(old_element))
11971 direction |= getOpenDirectionFromPool(old_element);
11973 for (i = 0; i < NUM_DIRECTIONS; i++)
11975 int xx = x + xy[i].x;
11976 int yy = y + xy[i].y;
11978 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11979 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
11981 int dir = MV_DIR_FROM_BIT(i);
11982 int dir_opposite = MV_DIR_OPPOSITE(dir);
11983 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11984 int last_direction_old = getOpenDirectionFromPool(last_element_old);
11985 int last_direction_new = last_direction_old | dir_opposite;
11987 last_element_new = getPoolFromOpenDirection(last_direction_new);
11993 // special corrections needed for intuitively correct acid pool drawing
11994 if (last_element_new == EL_EMPTY)
11995 last_element_new = new_element;
11996 else if (last_element_new != EL_UNDEFINED)
11997 new_element = last_element_new;
11999 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
12001 if (last_element_new != EL_UNDEFINED)
12002 MergeAndCloseNeighbourElements(x, y, &new_element,
12003 last_x, last_y, &last_element_new,
12004 getClosedPool, change_level);
12006 else if (IS_EMC_PILLAR(new_element))
12008 int last_element_new = EL_UNDEFINED;
12009 int direction = MV_NONE;
12012 // if old element is of same kind, keep all existing directions
12013 if (IS_EMC_PILLAR(old_element))
12014 direction |= getOpenDirectionFromPillar(old_element);
12016 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
12018 int xx = x + xy[i].x;
12019 int yy = y + xy[i].y;
12021 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12022 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
12024 int dir = MV_DIR_FROM_BIT(i);
12025 int dir_opposite = MV_DIR_OPPOSITE(dir);
12026 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12027 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
12028 int last_direction_new = last_direction_old | dir_opposite;
12030 last_element_new = getPillarFromOpenDirection(last_direction_new);
12036 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
12038 if (last_element_new != EL_UNDEFINED)
12039 MergeAndCloseNeighbourElements(x, y, &new_element,
12040 last_x, last_y, &last_element_new,
12041 getClosedPillar, change_level);
12043 else if (IS_DC_STEELWALL_2(new_element))
12045 int last_element_new = EL_UNDEFINED;
12046 int direction = MV_NONE;
12049 // if old element is of same kind, keep all existing directions
12050 if (IS_DC_STEELWALL_2(old_element))
12051 direction |= getOpenDirectionFromSteel2(old_element);
12053 for (i = 0; i < NUM_DIRECTIONS; i++)
12055 int xx = x + xy[i].x;
12056 int yy = y + xy[i].y;
12058 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12059 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
12061 int dir = MV_DIR_FROM_BIT(i);
12062 int dir_opposite = MV_DIR_OPPOSITE(dir);
12063 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12064 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
12065 int last_direction_new = last_direction_old | dir_opposite;
12067 last_element_new = getSteel2FromOpenDirection(last_direction_new);
12073 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
12075 if (last_element_new != EL_UNDEFINED)
12076 MergeAndCloseNeighbourElements(x, y, &new_element,
12077 last_x, last_y, &last_element_new,
12078 getClosedSteel2, change_level);
12080 else if (IS_SP_CHIP(new_element))
12082 int last_element_new = EL_UNDEFINED;
12083 int direction = MV_NONE;
12086 // (do not keep existing directions, regardless of kind of old element)
12088 for (i = 0; i < NUM_DIRECTIONS; i++)
12090 int xx = x + xy[i].x;
12091 int yy = y + xy[i].y;
12093 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12094 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
12096 int dir = MV_DIR_FROM_BIT(i);
12097 int dir_opposite = MV_DIR_OPPOSITE(dir);
12098 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12099 int last_direction_old = getOpenDirectionFromChip(last_element_old);
12100 int last_direction_new = last_direction_old | dir_opposite;
12102 if (last_direction_old == MV_NONE)
12104 last_element_new = getChipFromOpenDirection(last_direction_new);
12107 else if (last_direction_old & (dir | dir_opposite))
12109 direction |= MV_DIR_OPPOSITE(last_direction_old);
12113 direction |= MV_DIR_OPPOSITE(dir);
12118 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
12120 if (last_element_new != EL_UNDEFINED)
12121 MergeAndCloseNeighbourElements(x, y, &new_element,
12122 last_x, last_y, &last_element_new,
12123 getClosedChip, change_level);
12125 else if (IS_SP_HARDWARE_BASE(new_element))
12127 int nr = GetSimpleRandom(6);
12129 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
12130 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
12131 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
12132 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
12133 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
12135 else if (new_element == EL_SP_HARDWARE_GREEN ||
12136 new_element == EL_SP_HARDWARE_BLUE ||
12137 new_element == EL_SP_HARDWARE_RED)
12139 int nr = GetSimpleRandom(3);
12141 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
12142 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
12144 else if (IS_GROUP_ELEMENT(new_element))
12146 boolean connected_drawing = FALSE;
12149 for (i = 0; i < NUM_DIRECTIONS; i++)
12151 int xx = x + xy[i].x;
12152 int yy = y + xy[i].y;
12154 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12155 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
12156 connected_drawing = TRUE;
12159 if (!connected_drawing)
12160 ResolveGroupElement(new_element);
12162 new_element = GetElementFromGroupElement(new_element);
12164 else if (IS_BELT_SWITCH(old_element))
12166 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
12167 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
12169 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
12170 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
12172 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
12176 static int swappable_elements[][2] =
12178 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
12179 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
12180 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
12181 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
12182 { EL_EMERALD, EL_WALL_EMERALD },
12183 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
12184 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
12185 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
12186 { EL_DIAMOND, EL_WALL_DIAMOND },
12187 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
12188 { EL_GATE_1, EL_GATE_1_GRAY },
12189 { EL_GATE_2, EL_GATE_2_GRAY },
12190 { EL_GATE_3, EL_GATE_3_GRAY },
12191 { EL_GATE_4, EL_GATE_4_GRAY },
12192 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
12193 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
12194 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
12195 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
12196 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
12197 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
12198 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
12199 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
12200 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
12201 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
12202 { EL_LAMP, EL_LAMP_ACTIVE },
12203 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
12204 { EL_SP_BASE, EL_SP_BUGGY_BASE },
12205 { EL_PEARL, EL_WALL_PEARL },
12206 { EL_CRYSTAL, EL_WALL_CRYSTAL },
12207 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
12208 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
12209 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
12210 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
12211 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
12212 { EL_LANDMINE, EL_DC_LANDMINE },
12213 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
12214 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
12215 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
12216 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
12217 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
12218 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
12219 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
12220 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
12221 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
12225 static int rotatable_elements_4[][4] =
12235 EL_SPACESHIP_RIGHT,
12240 EL_BD_BUTTERFLY_UP,
12241 EL_BD_BUTTERFLY_RIGHT,
12242 EL_BD_BUTTERFLY_DOWN,
12243 EL_BD_BUTTERFLY_LEFT
12247 EL_BD_FIREFLY_RIGHT,
12248 EL_BD_FIREFLY_DOWN,
12276 EL_SP_GRAVITY_PORT_UP,
12277 EL_SP_GRAVITY_PORT_RIGHT,
12278 EL_SP_GRAVITY_PORT_DOWN,
12279 EL_SP_GRAVITY_PORT_LEFT
12282 EL_SP_GRAVITY_ON_PORT_UP,
12283 EL_SP_GRAVITY_ON_PORT_RIGHT,
12284 EL_SP_GRAVITY_ON_PORT_DOWN,
12285 EL_SP_GRAVITY_ON_PORT_LEFT
12288 EL_SP_GRAVITY_OFF_PORT_UP,
12289 EL_SP_GRAVITY_OFF_PORT_RIGHT,
12290 EL_SP_GRAVITY_OFF_PORT_DOWN,
12291 EL_SP_GRAVITY_OFF_PORT_LEFT
12300 EL_BALLOON_SWITCH_UP,
12301 EL_BALLOON_SWITCH_RIGHT,
12302 EL_BALLOON_SWITCH_DOWN,
12303 EL_BALLOON_SWITCH_LEFT
12307 EL_MM_MCDUFFIN_RIGHT,
12308 EL_MM_MCDUFFIN_DOWN,
12309 EL_MM_MCDUFFIN_LEFT
12312 EL_MM_MIRROR_FIXED_1,
12313 EL_MM_MIRROR_FIXED_4,
12314 EL_MM_MIRROR_FIXED_3,
12315 EL_MM_MIRROR_FIXED_2
12318 EL_MM_STEEL_GRID_FIXED_1,
12319 EL_MM_STEEL_GRID_FIXED_4,
12320 EL_MM_STEEL_GRID_FIXED_2,
12321 EL_MM_STEEL_GRID_FIXED_3
12324 EL_MM_WOODEN_GRID_FIXED_1,
12325 EL_MM_WOODEN_GRID_FIXED_4,
12326 EL_MM_WOODEN_GRID_FIXED_2,
12327 EL_MM_WOODEN_GRID_FIXED_3
12330 EL_MM_POLARIZER_CROSS_1,
12331 EL_MM_POLARIZER_CROSS_4,
12332 EL_MM_POLARIZER_CROSS_3,
12333 EL_MM_POLARIZER_CROSS_2
12337 EL_MM_PACMAN_RIGHT,
12349 EL_DF_RECEIVER_RIGHT,
12350 EL_DF_RECEIVER_DOWN,
12351 EL_DF_RECEIVER_LEFT
12364 static int rotatable_elements_8[][8] =
12367 EL_DF_STEEL_GRID_FIXED_1,
12368 EL_DF_STEEL_GRID_FIXED_8,
12369 EL_DF_STEEL_GRID_FIXED_7,
12370 EL_DF_STEEL_GRID_FIXED_6,
12371 EL_DF_STEEL_GRID_FIXED_5,
12372 EL_DF_STEEL_GRID_FIXED_4,
12373 EL_DF_STEEL_GRID_FIXED_3,
12374 EL_DF_STEEL_GRID_FIXED_2
12377 EL_DF_WOODEN_GRID_FIXED_1,
12378 EL_DF_WOODEN_GRID_FIXED_8,
12379 EL_DF_WOODEN_GRID_FIXED_7,
12380 EL_DF_WOODEN_GRID_FIXED_6,
12381 EL_DF_WOODEN_GRID_FIXED_5,
12382 EL_DF_WOODEN_GRID_FIXED_4,
12383 EL_DF_WOODEN_GRID_FIXED_3,
12384 EL_DF_WOODEN_GRID_FIXED_2
12387 EL_DF_STEEL_GRID_ROTATING_1,
12388 EL_DF_STEEL_GRID_ROTATING_8,
12389 EL_DF_STEEL_GRID_ROTATING_7,
12390 EL_DF_STEEL_GRID_ROTATING_6,
12391 EL_DF_STEEL_GRID_ROTATING_5,
12392 EL_DF_STEEL_GRID_ROTATING_4,
12393 EL_DF_STEEL_GRID_ROTATING_3,
12394 EL_DF_STEEL_GRID_ROTATING_2
12397 EL_DF_WOODEN_GRID_ROTATING_1,
12398 EL_DF_WOODEN_GRID_ROTATING_8,
12399 EL_DF_WOODEN_GRID_ROTATING_7,
12400 EL_DF_WOODEN_GRID_ROTATING_6,
12401 EL_DF_WOODEN_GRID_ROTATING_5,
12402 EL_DF_WOODEN_GRID_ROTATING_4,
12403 EL_DF_WOODEN_GRID_ROTATING_3,
12404 EL_DF_WOODEN_GRID_ROTATING_2
12411 static int rotatable_elements_16[][16] =
12432 EL_MM_TELEPORTER_5,
12433 EL_MM_TELEPORTER_4,
12434 EL_MM_TELEPORTER_3,
12435 EL_MM_TELEPORTER_2,
12436 EL_MM_TELEPORTER_1,
12437 EL_MM_TELEPORTER_16,
12438 EL_MM_TELEPORTER_15,
12439 EL_MM_TELEPORTER_14,
12440 EL_MM_TELEPORTER_13,
12441 EL_MM_TELEPORTER_12,
12442 EL_MM_TELEPORTER_11,
12443 EL_MM_TELEPORTER_10,
12444 EL_MM_TELEPORTER_9,
12445 EL_MM_TELEPORTER_8,
12446 EL_MM_TELEPORTER_7,
12450 EL_MM_TELEPORTER_RED_5,
12451 EL_MM_TELEPORTER_RED_4,
12452 EL_MM_TELEPORTER_RED_3,
12453 EL_MM_TELEPORTER_RED_2,
12454 EL_MM_TELEPORTER_RED_1,
12455 EL_MM_TELEPORTER_RED_16,
12456 EL_MM_TELEPORTER_RED_15,
12457 EL_MM_TELEPORTER_RED_14,
12458 EL_MM_TELEPORTER_RED_13,
12459 EL_MM_TELEPORTER_RED_12,
12460 EL_MM_TELEPORTER_RED_11,
12461 EL_MM_TELEPORTER_RED_10,
12462 EL_MM_TELEPORTER_RED_9,
12463 EL_MM_TELEPORTER_RED_8,
12464 EL_MM_TELEPORTER_RED_7,
12465 EL_MM_TELEPORTER_RED_6
12468 EL_MM_TELEPORTER_YELLOW_5,
12469 EL_MM_TELEPORTER_YELLOW_4,
12470 EL_MM_TELEPORTER_YELLOW_3,
12471 EL_MM_TELEPORTER_YELLOW_2,
12472 EL_MM_TELEPORTER_YELLOW_1,
12473 EL_MM_TELEPORTER_YELLOW_16,
12474 EL_MM_TELEPORTER_YELLOW_15,
12475 EL_MM_TELEPORTER_YELLOW_14,
12476 EL_MM_TELEPORTER_YELLOW_13,
12477 EL_MM_TELEPORTER_YELLOW_12,
12478 EL_MM_TELEPORTER_YELLOW_11,
12479 EL_MM_TELEPORTER_YELLOW_10,
12480 EL_MM_TELEPORTER_YELLOW_9,
12481 EL_MM_TELEPORTER_YELLOW_8,
12482 EL_MM_TELEPORTER_YELLOW_7,
12483 EL_MM_TELEPORTER_YELLOW_6
12486 EL_MM_TELEPORTER_GREEN_5,
12487 EL_MM_TELEPORTER_GREEN_4,
12488 EL_MM_TELEPORTER_GREEN_3,
12489 EL_MM_TELEPORTER_GREEN_2,
12490 EL_MM_TELEPORTER_GREEN_1,
12491 EL_MM_TELEPORTER_GREEN_16,
12492 EL_MM_TELEPORTER_GREEN_15,
12493 EL_MM_TELEPORTER_GREEN_14,
12494 EL_MM_TELEPORTER_GREEN_13,
12495 EL_MM_TELEPORTER_GREEN_12,
12496 EL_MM_TELEPORTER_GREEN_11,
12497 EL_MM_TELEPORTER_GREEN_10,
12498 EL_MM_TELEPORTER_GREEN_9,
12499 EL_MM_TELEPORTER_GREEN_8,
12500 EL_MM_TELEPORTER_GREEN_7,
12501 EL_MM_TELEPORTER_GREEN_6
12504 EL_MM_TELEPORTER_BLUE_5,
12505 EL_MM_TELEPORTER_BLUE_4,
12506 EL_MM_TELEPORTER_BLUE_3,
12507 EL_MM_TELEPORTER_BLUE_2,
12508 EL_MM_TELEPORTER_BLUE_1,
12509 EL_MM_TELEPORTER_BLUE_16,
12510 EL_MM_TELEPORTER_BLUE_15,
12511 EL_MM_TELEPORTER_BLUE_14,
12512 EL_MM_TELEPORTER_BLUE_13,
12513 EL_MM_TELEPORTER_BLUE_12,
12514 EL_MM_TELEPORTER_BLUE_11,
12515 EL_MM_TELEPORTER_BLUE_10,
12516 EL_MM_TELEPORTER_BLUE_9,
12517 EL_MM_TELEPORTER_BLUE_8,
12518 EL_MM_TELEPORTER_BLUE_7,
12519 EL_MM_TELEPORTER_BLUE_6
12523 EL_MM_POLARIZER_16,
12524 EL_MM_POLARIZER_15,
12525 EL_MM_POLARIZER_14,
12526 EL_MM_POLARIZER_13,
12527 EL_MM_POLARIZER_12,
12528 EL_MM_POLARIZER_11,
12529 EL_MM_POLARIZER_10,
12558 EL_DF_MIRROR_ROTATING_1,
12559 EL_DF_MIRROR_ROTATING_16,
12560 EL_DF_MIRROR_ROTATING_15,
12561 EL_DF_MIRROR_ROTATING_14,
12562 EL_DF_MIRROR_ROTATING_13,
12563 EL_DF_MIRROR_ROTATING_12,
12564 EL_DF_MIRROR_ROTATING_11,
12565 EL_DF_MIRROR_ROTATING_10,
12566 EL_DF_MIRROR_ROTATING_9,
12567 EL_DF_MIRROR_ROTATING_8,
12568 EL_DF_MIRROR_ROTATING_7,
12569 EL_DF_MIRROR_ROTATING_6,
12570 EL_DF_MIRROR_ROTATING_5,
12571 EL_DF_MIRROR_ROTATING_4,
12572 EL_DF_MIRROR_ROTATING_3,
12573 EL_DF_MIRROR_ROTATING_2
12576 EL_DF_MIRROR_FIXED_1,
12577 EL_DF_MIRROR_FIXED_16,
12578 EL_DF_MIRROR_FIXED_15,
12579 EL_DF_MIRROR_FIXED_14,
12580 EL_DF_MIRROR_FIXED_13,
12581 EL_DF_MIRROR_FIXED_12,
12582 EL_DF_MIRROR_FIXED_11,
12583 EL_DF_MIRROR_FIXED_10,
12584 EL_DF_MIRROR_FIXED_9,
12585 EL_DF_MIRROR_FIXED_8,
12586 EL_DF_MIRROR_FIXED_7,
12587 EL_DF_MIRROR_FIXED_6,
12588 EL_DF_MIRROR_FIXED_5,
12589 EL_DF_MIRROR_FIXED_4,
12590 EL_DF_MIRROR_FIXED_3,
12591 EL_DF_MIRROR_FIXED_2
12600 for (i = 0; swappable_elements[i][0] != -1; i++)
12602 int element1 = swappable_elements[i][0];
12603 int element2 = swappable_elements[i][1];
12605 if (old_element == element1 || old_element == element2)
12606 new_element = (old_element == element1 ? element2 : element1);
12609 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
12611 for (j = 0; j < 4; j++)
12613 int element = rotatable_elements_4[i][j];
12615 if (old_element == element)
12616 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
12617 button == 2 ? rotatable_elements_4[i][0] :
12618 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
12623 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
12625 for (j = 0; j < 8; j++)
12627 int element = rotatable_elements_8[i][j];
12629 if (old_element == element)
12630 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
12631 button == 2 ? rotatable_elements_8[i][0] :
12632 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
12637 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
12639 for (j = 0; j < 16; j++)
12641 int element = rotatable_elements_16[i][j];
12643 if (old_element == element)
12644 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
12645 button == 2 ? rotatable_elements_16[i][0] :
12646 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
12651 if (old_element != new_element)
12653 int max_infotext_len = getMaxInfoTextLength();
12654 char infotext[MAX_OUTPUT_LINESIZE + 1];
12656 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
12657 infotext[max_infotext_len] = '\0';
12659 ClearEditorGadgetInfoText();
12661 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
12666 if (IS_MM_WALL_EDITOR(new_element))
12667 SetElementSimpleExt(x, y, dx, dy, new_element, change_level);
12669 SetElementSimple(x, y, new_element, change_level);
12675 static void ResetIntelliDraw(void)
12679 for (x = 0; x < lev_fieldx; x++)
12680 for (y = 0; y < lev_fieldy; y++)
12681 IntelliDrawBuffer[x][y] = Tile[x][y];
12683 SetElementIntelliDraw(-1, -1, -1, -1, EL_UNDEFINED, FALSE, -1);
12686 static boolean draw_mode_hires = FALSE;
12688 static boolean isHiresTileElement(int element)
12690 return (IS_MM_WALL(element) || element == EL_EMPTY);
12693 static boolean isHiresDrawElement(int element)
12695 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
12698 static int numHiresTiles(int element)
12700 if (IS_MM_WALL(element))
12701 return get_number_of_bits(MM_WALL_BITS(element));
12706 static void SetDrawModeHiRes(int element)
12709 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12710 isHiresDrawElement(element));
12713 static boolean getDrawModeHiRes(void)
12715 return draw_mode_hires;
12718 static int getLoResScreenPos(int pos)
12720 return (getDrawModeHiRes() ? pos / 2 : pos);
12723 static int getLoResScreenMod(int pos)
12725 return (getDrawModeHiRes() ? pos % 2 : 0);
12728 static void SetElementExt(int x, int y, int dx, int dy, int element,
12729 boolean change_level, int button)
12732 SetElementSimple(x, y, Tile[x][y], change_level);
12733 else if (GetKeyModState() & KMOD_Shift)
12734 SetElementIntelliDraw(x, y, dx, dy, element, change_level, button);
12736 SetElementSimpleExt(x, y, dx, dy, element, change_level);
12739 static void SetElement(int x, int y, int element)
12741 SetElementExt(x, y, 0, 0, element, TRUE, -1);
12744 static void SetElementButton(int x, int y, int dx, int dy, int element,
12747 SetElementExt(x, y, dx, dy, element, TRUE, button);
12750 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
12752 int lx = getLoResScreenPos(sx2) + level_xpos;
12753 int ly = getLoResScreenPos(sy2) + level_ypos;
12754 int dx = getLoResScreenMod(sx2);
12755 int dy = getLoResScreenMod(sy2);
12757 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
12760 static void SetLevelElementHiRes(int lx2, int ly2, int element)
12767 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
12770 static int getLevelElementHiRes(int lx2, int ly2)
12776 int element = Tile[lx][ly];
12777 unsigned int bitmask = (dx + 1) << (dy * 2);
12779 if (IS_MM_WALL(element))
12781 if (element & bitmask)
12782 return map_mm_wall_element(element);
12790 static void DrawLineElement(int x, int y, int element, boolean change_level)
12792 SetElementHiRes(x, y, element, change_level);
12795 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12796 int element, boolean change_level)
12798 int xsize = ABS(to_x - from_x);
12799 int ysize = ABS(to_y - from_y);
12800 int dx = (to_x < from_x ? -1 : +1);
12801 int dy = (to_y < from_y ? -1 : +1);
12804 if (from_y == to_y) // horizontal line
12806 for (i = 0; i <= xsize; i++)
12807 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12809 else if (from_x == to_x) // vertical line
12811 for (i = 0; i <= ysize; i++)
12812 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12814 else // diagonal line
12816 if (ysize < xsize) // a < 1
12818 float a = (float)ysize / (float)xsize;
12820 for (i = 0; i <= xsize; i++)
12823 int y = dy * (int)(a * i + 0.5);
12825 DrawLineElement(from_x + x, from_y + y, element, change_level);
12830 float a = (float)xsize / (float)ysize;
12832 for (i = 0; i <= ysize; i++)
12834 int x = dx * (int)(a * i + 0.5);
12837 DrawLineElement(from_x + x, from_y + y, element, change_level);
12843 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12844 int element, boolean change_level)
12846 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12847 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12848 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12849 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12852 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12853 int element, boolean change_level)
12858 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12860 for (y = from_y; y <= to_y; y++)
12861 DrawLine(from_x, y, to_x, y, element, change_level);
12864 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12865 int element, boolean change_level)
12867 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12868 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12869 int len_x = ABS(to_x - from_x);
12870 int len_y = ABS(to_y - from_y);
12873 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
12875 // not optimal (some points get drawn twice) but simple,
12876 // and fast enough for the few points we are drawing
12878 for (x = 0; x <= radius; x++)
12880 int sx, sy, sx2, sy2, lx, ly;
12882 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
12884 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12885 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12886 sx = getLoResScreenPos(sx2);
12887 sy = getLoResScreenPos(sy2);
12888 lx = sx + level_xpos;
12889 ly = sy + level_ypos;
12891 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12892 DrawLineElement(sx2, sy2, element, change_level);
12895 for (y = 0; y <= radius; y++)
12897 int sx, sy, sx2, sy2, lx, ly;
12899 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
12901 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12902 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12903 sx = getLoResScreenPos(sx2);
12904 sy = getLoResScreenPos(sy2);
12905 lx = sx + level_xpos;
12906 ly = sy + level_ypos;
12908 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12909 DrawLineElement(sx2, sy2, element, change_level);
12913 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
12914 int element, boolean change_level)
12916 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12917 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12919 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12922 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
12924 #if DRAW_CIRCLES_BUTTON_AVAILABLE
12925 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
12926 int element, boolean change_level)
12928 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12929 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12930 int mirror_to_x2 = from_x - (to_x2 - from_x);
12931 int mirror_to_y2 = from_y - (to_y2 - from_y);
12933 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12934 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
12935 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
12936 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element, change_level);
12940 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
12942 int from_sx, from_sy;
12946 swap_numbers(&from_x, &to_x);
12949 swap_numbers(&from_y, &to_y);
12951 from_sx = SX + from_x * ed_tilesize;
12952 from_sy = SY + from_y * ed_tilesize;
12953 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
12954 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
12956 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12957 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12958 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12959 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12961 if (from_x == to_x && from_y == to_y)
12962 MarkTileDirty(from_x/2, from_y/2);
12964 redraw_mask |= REDRAW_FIELD;
12967 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
12968 int element, boolean change_level)
12970 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
12973 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
12974 int element, boolean change_level)
12976 if (element == -1 || change_level)
12977 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
12979 DrawAreaBorder(from_x, from_y, to_x, to_y);
12982 // values for CopyBrushExt()
12983 #define CB_AREA_TO_BRUSH 0
12984 #define CB_BRUSH_TO_CURSOR 1
12985 #define CB_BRUSH_TO_LEVEL 2
12986 #define CB_DELETE_OLD_CURSOR 3
12987 #define CB_DUMP_BRUSH 4
12988 #define CB_DUMP_BRUSH_SMALL 5
12989 #define CB_CLIPBOARD_TO_BRUSH 6
12990 #define CB_BRUSH_TO_CLIPBOARD 7
12991 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
12992 #define CB_UPDATE_BRUSH_POSITION 9
12993 #define CB_FLIP_BRUSH_X 10
12994 #define CB_FLIP_BRUSH_Y 11
12995 #define CB_FLIP_BRUSH_XY 12
12997 #define MAX_CB_PART_SIZE 10
12998 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
12999 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
13000 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
13001 MAX_CB_NUM_LINES * \
13004 static int getFlippedTileExt(int map[], int element)
13008 for (i = 0; map[i] != -1; i++)
13009 if (map[i] == element)
13010 return map[i ^ 1]; // get flipped element by flipping LSB of index
13015 static int getFlippedTileX(int element)
13019 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_RIGHT,
13020 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_RIGHT,
13021 EL_BUG_LEFT, EL_BUG_RIGHT,
13022 EL_SPACESHIP_LEFT, EL_SPACESHIP_RIGHT,
13023 EL_PACMAN_LEFT, EL_PACMAN_RIGHT,
13024 EL_ARROW_LEFT, EL_ARROW_RIGHT,
13025 EL_MOLE_LEFT, EL_MOLE_RIGHT,
13026 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_RIGHT,
13027 EL_YAMYAM_LEFT, EL_YAMYAM_RIGHT,
13028 EL_SP_PORT_LEFT, EL_SP_PORT_RIGHT,
13029 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_RIGHT,
13030 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_RIGHT,
13031 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_RIGHT,
13032 EL_CONVEYOR_BELT_1_LEFT, EL_CONVEYOR_BELT_1_RIGHT,
13033 EL_CONVEYOR_BELT_2_LEFT, EL_CONVEYOR_BELT_2_RIGHT,
13034 EL_CONVEYOR_BELT_3_LEFT, EL_CONVEYOR_BELT_3_RIGHT,
13035 EL_CONVEYOR_BELT_4_LEFT, EL_CONVEYOR_BELT_4_RIGHT,
13036 EL_SPRING_LEFT, EL_SPRING_RIGHT,
13037 EL_SP_CHIP_LEFT, EL_SP_CHIP_RIGHT,
13038 EL_TUBE_VERTICAL_LEFT, EL_TUBE_VERTICAL_RIGHT,
13039 EL_TUBE_LEFT_UP, EL_TUBE_RIGHT_UP,
13040 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_DOWN,
13041 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_RIGHT,
13042 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_TOPRIGHT,
13043 EL_DC_STEELWALL_1_BOTTOMLEFT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13044 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_TOPRIGHT_2,
13045 EL_DC_STEELWALL_1_BOTTOMLEFT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13046 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_RIGHT,
13047 EL_ACID_POOL_TOPLEFT, EL_ACID_POOL_TOPRIGHT,
13048 EL_ACID_POOL_BOTTOMLEFT, EL_ACID_POOL_BOTTOMRIGHT,
13053 return getFlippedTileExt(map, element);
13056 static int getFlippedTileY(int element)
13060 EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY_DOWN,
13061 EL_BD_FIREFLY_UP, EL_BD_FIREFLY_DOWN,
13062 EL_BUG_UP, EL_BUG_DOWN,
13063 EL_SPACESHIP_UP, EL_SPACESHIP_DOWN,
13064 EL_PACMAN_UP, EL_PACMAN_DOWN,
13065 EL_ARROW_UP, EL_ARROW_DOWN,
13066 EL_MOLE_UP, EL_MOLE_DOWN,
13067 EL_BALLOON_SWITCH_UP, EL_BALLOON_SWITCH_DOWN,
13068 EL_YAMYAM_UP, EL_YAMYAM_DOWN,
13069 EL_SP_PORT_UP, EL_SP_PORT_DOWN,
13070 EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN,
13071 EL_SP_GRAVITY_ON_PORT_UP, EL_SP_GRAVITY_ON_PORT_DOWN,
13072 EL_SP_GRAVITY_OFF_PORT_UP, EL_SP_GRAVITY_OFF_PORT_DOWN,
13073 EL_SP_CHIP_TOP, EL_SP_CHIP_BOTTOM,
13074 EL_TUBE_HORIZONTAL_UP, EL_TUBE_HORIZONTAL_DOWN,
13075 EL_TUBE_LEFT_UP, EL_TUBE_LEFT_DOWN,
13076 EL_TUBE_RIGHT_UP, EL_TUBE_RIGHT_DOWN,
13077 EL_DC_STEELWALL_1_TOP, EL_DC_STEELWALL_1_BOTTOM,
13078 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13079 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13080 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13081 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13082 EL_DC_STEELWALL_2_TOP, EL_DC_STEELWALL_2_BOTTOM,
13083 EL_EMC_WALL_1, EL_EMC_WALL_3,
13088 return getFlippedTileExt(map, element);
13091 static int getFlippedTileXY(int element)
13095 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_UP,
13096 EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY_DOWN,
13097 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_UP,
13098 EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY_DOWN,
13099 EL_BUG_LEFT, EL_BUG_UP,
13100 EL_BUG_RIGHT, EL_BUG_DOWN,
13101 EL_SPACESHIP_LEFT, EL_SPACESHIP_UP,
13102 EL_SPACESHIP_RIGHT, EL_SPACESHIP_DOWN,
13103 EL_PACMAN_LEFT, EL_PACMAN_UP,
13104 EL_PACMAN_RIGHT, EL_PACMAN_DOWN,
13105 EL_ARROW_LEFT, EL_ARROW_UP,
13106 EL_ARROW_RIGHT, EL_ARROW_DOWN,
13107 EL_MOLE_LEFT, EL_MOLE_UP,
13108 EL_MOLE_RIGHT, EL_MOLE_DOWN,
13109 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_UP,
13110 EL_BALLOON_SWITCH_RIGHT, EL_BALLOON_SWITCH_DOWN,
13111 EL_YAMYAM_LEFT, EL_YAMYAM_UP,
13112 EL_YAMYAM_RIGHT, EL_YAMYAM_DOWN,
13113 EL_SP_PORT_LEFT, EL_SP_PORT_UP,
13114 EL_SP_PORT_RIGHT, EL_SP_PORT_DOWN,
13115 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_UP,
13116 EL_SP_GRAVITY_PORT_RIGHT, EL_SP_GRAVITY_PORT_DOWN,
13117 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_UP,
13118 EL_SP_GRAVITY_ON_PORT_RIGHT, EL_SP_GRAVITY_ON_PORT_DOWN,
13119 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_UP,
13120 EL_SP_GRAVITY_OFF_PORT_RIGHT, EL_SP_GRAVITY_OFF_PORT_DOWN,
13121 EL_SP_CHIP_LEFT, EL_SP_CHIP_TOP,
13122 EL_SP_CHIP_RIGHT, EL_SP_CHIP_BOTTOM,
13123 EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL,
13124 EL_TUBE_VERTICAL_LEFT, EL_TUBE_HORIZONTAL_UP,
13125 EL_TUBE_VERTICAL_RIGHT, EL_TUBE_HORIZONTAL_DOWN,
13126 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_UP,
13127 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_TOP,
13128 EL_DC_STEELWALL_1_RIGHT, EL_DC_STEELWALL_1_BOTTOM,
13129 EL_DC_STEELWALL_1_HORIZONTAL, EL_DC_STEELWALL_1_VERTICAL,
13130 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13131 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13132 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_TOP,
13133 EL_DC_STEELWALL_2_RIGHT, EL_DC_STEELWALL_2_BOTTOM,
13134 EL_DC_STEELWALL_2_HORIZONTAL, EL_DC_STEELWALL_2_VERTICAL,
13135 EL_EXPANDABLE_WALL_HORIZONTAL, EL_EXPANDABLE_WALL_VERTICAL,
13136 EL_EXPANDABLE_STEELWALL_HORIZONTAL, EL_EXPANDABLE_STEELWALL_VERTICAL,
13141 return getFlippedTileExt(map, element);
13144 static int getFlippedTile(int element, int mode)
13146 if (IS_MM_ELEMENT(element))
13148 // get MM game element
13149 element = map_element_RND_to_MM(element);
13151 // get flipped game element
13152 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX_MM(element) :
13153 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY_MM(element) :
13154 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY_MM(element) :
13157 // get RND game element again
13158 element = map_element_MM_to_RND(element);
13162 // get flipped game element
13163 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX(element) :
13164 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY(element) :
13165 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY(element) :
13172 static void SwapFlippedTiles(short *tile1, short *tile2, int mode)
13175 short tile1_flipped = getFlippedTile(*tile1, mode);
13176 short tile2_flipped = getFlippedTile(*tile2, mode);
13179 *tile1 = tile2_flipped;
13180 *tile2 = tile1_flipped;
13183 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
13185 DrawLineElement(sx, sy, element, change_level);
13188 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
13189 int button, int mode)
13191 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13192 static int brush_width, brush_height;
13193 static int last_cursor_x = -1, last_cursor_y = -1;
13194 static boolean delete_old_brush = FALSE;
13195 int new_element = BUTTON_ELEMENT(button);
13198 if (mode == CB_DUMP_BRUSH ||
13199 mode == CB_DUMP_BRUSH_SMALL ||
13200 mode == CB_BRUSH_TO_CLIPBOARD ||
13201 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13203 if (edit_mode != ED_MODE_DRAWING)
13206 char part[MAX_CB_PART_SIZE + 1] = "";
13207 char text[MAX_CB_TEXT_SIZE + 1] = "";
13208 int width = (draw_with_brush ? brush_width : lev_fieldx);
13209 int height = (draw_with_brush ? brush_height : lev_fieldy);
13210 char *format = "%s%03d";
13212 for (y = 0; y < height; y++)
13213 for (x = 0; x < width; x++)
13214 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
13217 for (y = 0; y < height; y++)
13219 for (x = 0; x < width; x++)
13221 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
13222 char *prefix = (mode == CB_DUMP_BRUSH ||
13223 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
13225 if (element >= NUM_FILE_ELEMENTS)
13226 element = EL_UNKNOWN;
13228 // copy brush to level sketch text buffer for the R'n'D forum:
13229 // - large tiles: `xxx or `xxxx (0x60 ASCII)
13230 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
13231 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
13232 strcat(text, part);
13235 strcat(text, "\n");
13238 if (mode == CB_BRUSH_TO_CLIPBOARD ||
13239 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13240 SDL_SetClipboardText(text);
13242 Print("%s", text); // print brush data to console and log file
13247 if (mode == CB_CLIPBOARD_TO_BRUSH)
13249 if (edit_mode != ED_MODE_DRAWING)
13252 if (!SDL_HasClipboardText())
13254 Request("Clipboard is empty!", REQ_CONFIRM);
13259 boolean copy_to_brush = (draw_with_brush ||
13260 drawing_function == GADGET_ID_GRAB_BRUSH);
13262 // this will delete the old brush, if already drawing with a brush
13264 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
13266 // initialization is required for "odd" (incomplete) clipboard content
13267 for (x = 0; x < MAX_LEV_FIELDX; x++)
13268 for (y = 0; y < MAX_LEV_FIELDY; y++)
13269 brush_buffer[x][y] = EL_EMPTY;
13276 char *clipboard_text = SDL_GetClipboardText();
13277 char *ptr = clipboard_text;
13278 boolean allow_new_row = FALSE;
13279 boolean stop = FALSE;
13281 while (*ptr && !stop)
13283 boolean prefix_found = FALSE;
13284 boolean start_new_row = FALSE;
13286 // level sketch element number prefixes (may be multi-byte characters)
13287 char *prefix_list[] = { "`", "¸" };
13290 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
13292 char *prefix = prefix_list[i];
13294 // check if string is large enough for prefix
13295 if (strlen(ptr) < strlen(prefix))
13302 // check if string starts with prefix
13303 if (strPrefix(ptr, prefix))
13305 ptr += strlen(prefix);
13307 prefix_found = TRUE;
13313 // check if prefix found and followed by (at least) three digits
13314 if (prefix_found &&
13315 strlen(ptr) >= 3 &&
13316 ptr[0] >= '0' && ptr[0] <= '9' &&
13317 ptr[1] >= '0' && ptr[1] <= '9' &&
13318 ptr[2] >= '0' && ptr[2] <= '9')
13320 int element = ((ptr[0] - '0') * 100 +
13321 (ptr[1] - '0') * 10 +
13326 // level sketch element number might consist of four digits
13327 if (ptr[0] >= '0' && ptr[0] <= '9')
13329 element = element * 10 + (ptr[0] - '0');
13333 // remap some (historic, now obsolete) elements
13334 element = getMappedElement(element);
13336 if (element >= NUM_FILE_ELEMENTS)
13337 element = EL_UNKNOWN;
13339 brush_buffer[x][y] = element;
13341 brush_width = MAX(x + 1, brush_width);
13342 brush_height = MAX(y + 1, brush_height);
13346 if (x >= MAX_LEV_FIELDX)
13347 start_new_row = TRUE;
13349 allow_new_row = TRUE;
13353 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
13354 start_new_row = TRUE;
13356 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
13364 if (y >= MAX_LEV_FIELDY)
13367 allow_new_row = FALSE;
13371 SDL_free(clipboard_text);
13373 if (brush_width == 0 || brush_height == 0)
13375 Request("No level sketch found in clipboard!", REQ_CONFIRM);
13382 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
13385 SDL_GetMouseState(&mx, &my);
13387 // if inside drawing area, activate and draw brush at last mouse position
13388 if (mx >= gi->x && mx < gi->x + gi->width &&
13389 my >= gi->y && my < gi->y + gi->height)
13390 CopyBrushToCursor(last_cursor_x, last_cursor_y);
13392 draw_with_brush = TRUE;
13398 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
13399 brush_width, brush_height);
13401 if (!Request(request, REQ_ASK))
13404 for (x = 0; x < MAX_LEV_FIELDX; x++)
13405 for (y = 0; y < MAX_LEV_FIELDY; y++)
13406 Tile[x][y] = brush_buffer[x][y];
13408 lev_fieldx = level.fieldx = brush_width;
13409 lev_fieldy = level.fieldy = brush_height;
13411 boolean use_bd_engine = TRUE;
13412 boolean use_em_engine = TRUE;
13413 boolean use_sp_engine = TRUE;
13414 boolean use_mm_engine = TRUE;
13416 for (x = 0; x < MAX_LEV_FIELDX; x++)
13418 for (y = 0; y < MAX_LEV_FIELDY; y++)
13420 int element = Tile[x][y];
13422 if (!IS_BD_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13423 use_bd_engine = FALSE;
13425 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13426 use_em_engine = FALSE;
13428 if (!IS_SP_ELEMENT(element))
13429 use_sp_engine = FALSE;
13431 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
13432 use_mm_engine = FALSE;
13436 level.game_engine_type = (use_bd_engine ? GAME_ENGINE_TYPE_BD :
13437 use_em_engine ? GAME_ENGINE_TYPE_EM :
13438 use_sp_engine ? GAME_ENGINE_TYPE_SP :
13439 use_mm_engine ? GAME_ENGINE_TYPE_MM :
13440 GAME_ENGINE_TYPE_RND);
13442 // update element selection list
13443 ReinitializeElementList();
13444 ModifyEditorElementList();
13446 SetBorderElement();
13448 DrawEditModeWindow();
13449 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13455 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
13458 if (mode == CB_AREA_TO_BRUSH)
13460 int from_lx, from_ly;
13463 swap_numbers(&from_x, &to_x);
13466 swap_numbers(&from_y, &to_y);
13468 brush_width = to_x - from_x + 1;
13469 brush_height = to_y - from_y + 1;
13471 from_lx = from_x + level_xpos;
13472 from_ly = from_y + level_ypos;
13474 for (y = 0; y < brush_height; y++)
13476 for (x = 0; x < brush_width; x++)
13478 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
13481 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
13486 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13488 delete_old_brush = FALSE;
13490 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
13491 mode == CB_BRUSH_TO_LEVEL)
13493 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
13494 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
13495 int cursor_from_x = cursor_x - brush_width / 2;
13496 int cursor_from_y = cursor_y - brush_height / 2;
13497 int border_from_x = cursor_x, border_from_y = cursor_y;
13498 int border_to_x = cursor_x, border_to_y = cursor_y;
13500 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
13501 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13503 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
13504 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
13506 delete_old_brush = FALSE;
13511 for (y = 0; y < brush_height; y++)
13513 for (x = 0; x < brush_width; x++)
13515 int sx = cursor_from_x + x;
13516 int sy = cursor_from_y + y;
13517 int lx = sx + level_xpos;
13518 int ly = sy + level_ypos;
13519 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
13520 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
13521 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
13522 brush_buffer[x][y] : new_element);
13524 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13526 if (sx < border_from_x)
13527 border_from_x = sx;
13528 else if (sx > border_to_x)
13530 if (sy < border_from_y)
13531 border_from_y = sy;
13532 else if (sy > border_to_y)
13535 DrawBrushElement(sx, sy, element, change_level);
13540 if (mode != CB_DELETE_OLD_CURSOR)
13541 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
13543 last_cursor_x = cursor_x;
13544 last_cursor_y = cursor_y;
13546 delete_old_brush = TRUE;
13548 else if (mode == CB_FLIP_BRUSH_X)
13550 for (y = 0; y < brush_height; y++)
13551 for (x = 0; x < (brush_width + 1) / 2; x++)
13552 SwapFlippedTiles(&brush_buffer[x][y],
13553 &brush_buffer[brush_width - x - 1][y], mode);
13555 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13557 else if (mode == CB_FLIP_BRUSH_Y)
13559 for (y = 0; y < (brush_height + 1) / 2; y++)
13560 for (x = 0; x < brush_width; x++)
13561 SwapFlippedTiles(&brush_buffer[x][y],
13562 &brush_buffer[x][brush_height - y - 1], mode);
13564 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13566 else if (mode == CB_FLIP_BRUSH_XY)
13568 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13570 for (y = 0; y < MAX(brush_width, brush_height); y++)
13571 for (x = 0; x <= y; x++)
13572 SwapFlippedTiles(&brush_buffer[x][y],
13573 &brush_buffer[y][x], mode);
13575 swap_numbers(&brush_width, &brush_height);
13577 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13580 if (mode == CB_UPDATE_BRUSH_POSITION)
13582 last_cursor_x = from_x;
13583 last_cursor_y = from_y;
13587 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
13590 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
13593 static void CopyBrushToLevel(int x, int y, int button)
13595 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
13598 static void CopyBrushToCursor(int x, int y)
13600 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13603 static void UpdateBrushPosition(int x, int y)
13605 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
13608 static void DeleteBrushFromCursor(void)
13610 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13613 static void FlipBrushX(void)
13615 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13618 static void FlipBrushY(void)
13620 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_Y);
13623 static void RotateBrush(void)
13625 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_XY);
13626 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13629 void DumpBrush(void)
13631 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
13634 void DumpBrush_Small(void)
13636 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
13639 void CopyClipboardToBrush(void)
13641 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
13644 void CopyBrushToClipboard(void)
13646 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
13649 void CopyBrushToClipboard_Small(void)
13651 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
13654 void UndoLevelEditorOperation(void)
13656 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
13659 void RedoLevelEditorOperation(void)
13661 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13664 static void FloodFill(int from_x, int from_y, int fill_element)
13666 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
13669 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
13671 int from_x = from_sx2 + 2 * level_xpos;
13672 int from_y = from_sy2 + 2 * level_ypos;
13673 int max_fillx = lev_fieldx * 2;
13674 int max_filly = lev_fieldy * 2;
13675 short Fill[max_fillx][max_filly];
13678 for (x = 0; x < max_fillx; x++)
13679 for (y = 0; y < max_filly; y++)
13680 Fill[x][y] = getLevelElementHiRes(x, y);
13682 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
13683 Fill, max_fillx, max_filly);
13685 for (x = 0; x < max_fillx; x++)
13686 for (y = 0; y < max_filly; y++)
13687 if (Fill[x][y] == fill_element)
13688 SetLevelElementHiRes(x, y, Fill[x][y]);
13691 // values for DrawLevelText() modes
13692 #define TEXT_INIT 0
13693 #define TEXT_SETCURSOR 1
13694 #define TEXT_WRITECHAR 2
13695 #define TEXT_BACKSPACE 3
13696 #define TEXT_NEWLINE 4
13698 #define TEXT_QUERY_TYPING 6
13700 static int DrawLevelText(int sx, int sy, char letter, int mode)
13702 static short delete_buffer[MAX_LEV_FIELDX];
13703 static int start_sx;
13704 static int last_sx, last_sy;
13705 static boolean typing = FALSE;
13706 int letter_element;
13707 int lx = 0, ly = 0;
13709 // map lower case letters to upper case and convert special characters
13710 if (letter >= 'a' && letter <= 'z')
13711 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
13712 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
13713 letter_element = EL_CHAR_AUMLAUT;
13714 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
13715 letter_element = EL_CHAR_OUMLAUT;
13716 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
13717 letter_element = EL_CHAR_UUMLAUT;
13718 else if (letter == '^')
13719 letter_element = EL_CHAR_COPYRIGHT;
13721 letter_element = EL_CHAR_ASCII0 + letter;
13723 if (mode != TEXT_INIT)
13728 if (mode != TEXT_SETCURSOR)
13734 lx = last_sx + level_xpos;
13735 ly = last_sy + level_ypos;
13742 DrawLevelText(0, 0, 0, TEXT_END);
13748 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
13751 case TEXT_SETCURSOR:
13752 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
13753 DrawAreaBorder(sx, sy, sx, sy);
13754 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
13755 ed_tilesize, ed_tilesize);
13760 case TEXT_WRITECHAR:
13761 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
13763 if (new_element1 >= EL_STEEL_CHAR_START &&
13764 new_element1 <= EL_STEEL_CHAR_END)
13765 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
13767 delete_buffer[sx - start_sx] = Tile[lx][ly];
13768 Tile[lx][ly] = letter_element;
13770 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
13771 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
13772 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13773 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13775 DrawLevelText(0, 0, 0, TEXT_END);
13777 level.changed = TRUE;
13781 case TEXT_BACKSPACE:
13784 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
13785 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
13786 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
13791 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13792 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13794 DrawLevelText(0, 0, 0, TEXT_END);
13798 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13799 DrawEditorElement(sx, sy, Tile[lx][ly]);
13804 case TEXT_QUERY_TYPING:
13814 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
13815 int element, boolean change_level)
13817 int lx = sx + level_xpos;
13818 int ly = sy + level_ypos;
13821 DrawEditorElement(sx, sy, Tile[lx][ly]);
13823 DrawAreaBorder(sx, sy, sx, sy);
13826 static void CheckLevelBorderElement(boolean redraw_playfield)
13828 int last_border_element = BorderElement;
13830 SetBorderElement();
13832 if (redraw_playfield && BorderElement != last_border_element)
13833 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13836 static void CopyLevelToUndoBuffer(int mode)
13838 static boolean accumulated_undo = FALSE;
13839 boolean new_undo_buffer_position = TRUE;
13842 if (undo_buffer_steps == 0)
13843 accumulated_undo = FALSE;
13847 case UNDO_IMMEDIATE:
13848 accumulated_undo = FALSE;
13851 case UNDO_ACCUMULATE:
13852 if (accumulated_undo)
13853 new_undo_buffer_position = FALSE;
13854 accumulated_undo = TRUE;
13861 if (new_undo_buffer_position)
13863 // advance position in undo buffer ring
13864 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13866 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
13867 undo_buffer_steps++;
13870 // always reset redo buffer when storing level change into undo buffer
13871 redo_buffer_steps = 0;
13873 for (x = 0; x < lev_fieldx; x++)
13874 for (y = 0; y < lev_fieldy; y++)
13875 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
13877 // check if drawing operation forces change of border style
13878 CheckLevelBorderElement(TRUE);
13880 level.changed = TRUE;
13883 static void RandomPlacement(int new_element)
13885 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13886 int num_free_positions = 0;
13887 int num_percentage, num_elements;
13890 ResetIntelliDraw();
13892 // determine number of free positions for randomly placing the new element
13893 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
13895 free_position[x][y] =
13896 (random_placement_background_restricted ?
13897 Tile[x][y] == random_placement_background_element :
13898 Tile[x][y] != new_element);
13900 if (free_position[x][y])
13901 num_free_positions++;
13904 // determine number of new elements to place there
13905 num_percentage = num_free_positions * random_placement_value / 100;
13906 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
13907 num_percentage : random_placement_value);
13909 // if less free positions than elements to place, fill all these positions
13910 if (num_free_positions < num_elements)
13912 for (x = 0; x < lev_fieldx; x++)
13913 for (y = 0; y < lev_fieldy; y++)
13914 if (free_position[x][y])
13915 SetElement(x, y, new_element);
13919 while (num_elements > 0)
13921 x = GetSimpleRandom(lev_fieldx);
13922 y = GetSimpleRandom(lev_fieldy);
13924 // don't place element at the same position twice
13925 if (free_position[x][y])
13927 free_position[x][y] = FALSE;
13928 SetElement(x, y, new_element);
13934 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13935 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13938 static void WrapLevel(int dx, int dy)
13940 int wrap_dx = lev_fieldx - dx;
13941 int wrap_dy = lev_fieldy - dy;
13944 for (x = 0; x < lev_fieldx; x++)
13945 for (y = 0; y < lev_fieldy; y++)
13946 TileBackup[x][y] = Tile[x][y];
13948 for (x = 0; x < lev_fieldx; x++)
13949 for (y = 0; y < lev_fieldy; y++)
13951 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
13953 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13954 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
13957 static void DrawAreaElementHighlight(boolean highlighted,
13958 boolean highlighted_similar)
13960 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13967 for (x = 0; x < ed_fieldx; x++)
13969 for (y = 0; y < ed_fieldy; y++)
13971 boolean highlight = FALSE;
13972 int lx = x + level_xpos;
13973 int ly = y + level_ypos;
13975 if (!IN_LEV_FIELD(lx, ly))
13978 // check if element is the same
13979 if (Tile[lx][ly] == new_element1)
13982 // check if element is similar
13983 if (highlighted_similar &&
13984 strEqual(element_info[Tile[lx][ly]].class_name,
13985 element_info[new_element1].class_name))
13988 // check if element is matching MM style wall
13989 if (IS_MM_WALL(Tile[lx][ly]) &&
13990 map_mm_wall_element(Tile[lx][ly]) == new_element1)
13996 if (IS_MM_WALL(Tile[lx][ly]) && !highlighted_similar)
14000 for (i = 0; i < 4; i++)
14002 if (!(MM_WALL_BITS(Tile[lx][ly]) & (1 << i)))
14005 int xx = x * 2 + (i % 2);
14006 int yy = y * 2 + (i / 2);
14007 int sx = SX + xx * ed_tilesize / 2;
14008 int sy = SY + yy * ed_tilesize / 2;
14011 int to_sx = sx + ed_tilesize / 2 - 1;
14012 int to_sy = sy + ed_tilesize / 2 - 1;
14014 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
14015 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
14016 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14017 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14022 int sx = SX + x * ed_tilesize;
14023 int sy = SY + y * ed_tilesize;
14026 int to_sx = sx + ed_tilesize - 1;
14027 int to_sy = sy + ed_tilesize - 1;
14029 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
14030 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
14031 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14032 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14038 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
14040 char *template_filename_old = getLocalLevelTemplateFilename();
14041 char *template_filename_new =
14042 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
14044 if (copyFile(template_filename_old, template_filename_new) != 0)
14045 Request("Cannot copy level template!", REQ_CONFIRM);
14047 free(template_filename_new);
14050 static void HandleDrawingAreas(struct GadgetInfo *gi)
14052 static boolean started_inside_drawing_area = FALSE;
14053 static int last_sx = -1;
14054 static int last_sy = -1;
14055 static int last_sx2 = -1;
14056 static int last_sy2 = -1;
14057 int id = gi->custom_id;
14058 int type_id = gi->custom_type_id;
14059 boolean button_press_event;
14060 boolean button_release_event;
14061 boolean inside_drawing_area = !gi->event.off_borders;
14062 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
14063 int actual_drawing_function;
14064 int button = gi->event.button;
14065 int new_element = BUTTON_ELEMENT(button);
14066 int sx = gi->event.x, sy = gi->event.y;
14067 int min_sx = 0, min_sy = 0;
14068 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
14069 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
14070 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
14071 int sx2 = gi->event.mx / mini_item_xsize;
14072 int sy2 = gi->event.my / mini_item_ysize;
14075 int lx = 0, ly = 0;
14078 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
14079 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
14081 // make sure to stay inside drawing area boundaries
14082 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14083 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14087 int min_lx = 0, min_ly = 0;
14088 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14090 // get positions inside level field
14091 lx = sx + level_xpos;
14092 ly = sy + level_ypos;
14094 if (!IN_LEV_FIELD(lx, ly))
14095 inside_drawing_area = FALSE;
14097 // make sure to stay inside level field boundaries
14098 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14099 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14101 // correct drawing area positions accordingly
14102 sx = lx - level_xpos;
14103 sy = ly - level_ypos;
14106 // also correct MM wall-sized (double) drawing area positions accordingly
14107 if (sx2 / 2 < sx || sx2 / 2 > sx)
14109 dx = (sx2 / 2 < sx ? 0 : 1);
14112 if (sy2 / 2 < sy || sy2 / 2 > sy)
14114 dy = (sy2 / 2 < sy ? 0 : 1);
14118 if (!button_press_event && !button_release_event)
14120 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
14121 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
14122 isHiresTileElement(old_element) &&
14123 isHiresDrawElement(new_element));
14125 // prevent handling events for every pixel position when moving mouse
14126 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
14127 (sx2 == last_sx2 && sy2 == last_sy2))
14136 if (button_press_event)
14137 started_inside_drawing_area = inside_drawing_area;
14139 if (!started_inside_drawing_area)
14142 if (!IS_VALID_BUTTON(button))
14145 // handle info callback for each invocation of action callback
14146 gi->callback_info(gi);
14148 // automatically switch to 'single item' drawing mode, if needed
14149 actual_drawing_function =
14150 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
14151 drawing_function : GADGET_ID_SINGLE_ITEMS);
14153 // clicking into drawing area with pressed Control key picks element
14154 if (GetKeyModState() & KMOD_Control)
14156 last_drawing_function = drawing_function;
14157 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14160 if (GetKeyModState() & KMOD_Shift)
14162 if (button_press_event || button_release_event)
14163 ResetIntelliDraw();
14166 SetDrawModeHiRes(-1); // reset to normal draw mode
14168 switch (actual_drawing_function)
14170 case GADGET_ID_SINGLE_ITEMS:
14173 if (button_release_event)
14175 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14177 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
14178 !inside_drawing_area)
14179 DeleteBrushFromCursor();
14184 if (draw_with_brush)
14186 CopyBrushToLevel(sx, sy, button);
14190 SetDrawModeHiRes(new_element);
14192 if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
14194 // remove player at old position
14195 for (y = 0; y < lev_fieldy; y++)
14197 for (x = 0; x < lev_fieldx; x++)
14199 int old_element = Tile[x][y];
14201 if (IS_PLAYER_ELEMENT(old_element) &&
14202 IS_PLAYER_ELEMENT(new_element))
14204 int replaced_with_element =
14205 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
14206 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
14208 old_element == EL_SOKOBAN_FIELD_PLAYER &&
14209 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
14211 new_element == EL_SOKOBAN_FIELD_PLAYER &&
14212 old_element == EL_PLAYER_1 ? EL_EMPTY :
14214 new_element >= EL_PLAYER_1 &&
14215 new_element <= EL_PLAYER_4 &&
14216 new_element == old_element ? EL_EMPTY :
14220 SetElement(x, y, replaced_with_element);
14222 else if (IS_MM_MCDUFFIN(old_element) &&
14223 IS_MM_MCDUFFIN(new_element))
14225 // remove McDuffin at old position
14226 SetElement(x, y, EL_EMPTY);
14232 SetElementButton(lx, ly, dx, dy, new_element, button);
14235 else if (!button_release_event)
14237 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14239 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
14240 DrawMiniGraphicExt(drawto,
14241 gi->x + sx * MINI_TILEX,
14242 gi->y + sy * MINI_TILEY,
14243 el2edimg(new_element));
14245 DrawFixedGraphicExt(drawto,
14246 gi->x + sx * TILEX,
14247 gi->y + sy * TILEY,
14248 el2edimg(new_element), 0);
14250 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14251 new_element = GFX_ELEMENT(new_element);
14253 drawingarea_info[type_id].value[pos] = new_element;
14255 CopyElementPropertiesToGame(properties_element);
14257 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14259 UpdateCustomElementGraphicGadgets();
14261 FrameCounter = 0; // restart animation frame counter
14266 case GADGET_ID_CONNECTED_ITEMS:
14268 static int last_sx = -1;
14269 static int last_sy = -1;
14271 if (button_release_event)
14272 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14274 SetDrawModeHiRes(new_element);
14276 if (getDrawModeHiRes())
14282 if (!button_press_event)
14283 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
14290 case GADGET_ID_LINE:
14291 case GADGET_ID_ARC:
14292 case GADGET_ID_RECTANGLE:
14293 case GADGET_ID_FILLED_BOX:
14294 SetDrawModeHiRes(new_element);
14296 if (getDrawModeHiRes())
14302 case GADGET_ID_GRAB_BRUSH:
14303 case GADGET_ID_TEXT:
14305 static int last_sx = -1;
14306 static int last_sy = -1;
14307 static int start_sx = -1;
14308 static int start_sy = -1;
14309 void (*draw_func)(int, int, int, int, int, boolean);
14311 if (drawing_function == GADGET_ID_LINE)
14312 draw_func = DrawLine;
14313 else if (drawing_function == GADGET_ID_ARC)
14314 draw_func = DrawArc;
14315 else if (drawing_function == GADGET_ID_RECTANGLE)
14316 draw_func = DrawBox;
14317 else if (drawing_function == GADGET_ID_FILLED_BOX)
14318 draw_func = DrawFilledBox;
14319 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
14320 draw_func = SelectArea;
14321 else // (drawing_function == GADGET_ID_TEXT)
14322 draw_func = SetTextCursor;
14324 if (button_press_event)
14326 draw_func(sx, sy, sx, sy, new_element, FALSE);
14327 start_sx = last_sx = sx;
14328 start_sy = last_sy = sy;
14330 if (drawing_function == GADGET_ID_TEXT)
14331 DrawLevelText(0, 0, 0, TEXT_END);
14333 else if (button_release_event)
14335 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
14336 if (drawing_function == GADGET_ID_GRAB_BRUSH)
14338 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
14339 CopyBrushToCursor(sx, sy);
14340 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14342 draw_with_brush = TRUE;
14344 else if (drawing_function == GADGET_ID_TEXT)
14345 DrawLevelText(sx, sy, 0, TEXT_INIT);
14347 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14349 else if (last_sx != sx || last_sy != sy)
14351 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
14352 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
14353 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
14354 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
14361 case GADGET_ID_FLOOD_FILL:
14362 if (button_press_event && Tile[lx][ly] != new_element)
14364 if (IS_MM_WALL_EDITOR(new_element))
14365 FloodFillWall_MM(sx2, sy2, new_element);
14367 FloodFill(lx, ly, new_element);
14369 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14370 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14374 case GADGET_ID_PICK_ELEMENT:
14375 if (button_release_event)
14376 ClickOnGadget(level_editor_gadget[last_drawing_function],
14378 else if (draw_level)
14379 PickDrawingElement(button, Tile[lx][ly]);
14382 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14384 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
14391 // do not mark level as modified for certain non-level-changing gadgets
14392 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
14393 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
14394 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
14395 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14398 level.changed = TRUE;
14401 static void HandleCounterButtons(struct GadgetInfo *gi)
14403 int gadget_id = gi->custom_id;
14404 int counter_id = gi->custom_type_id;
14405 int button = gi->event.button;
14406 int *counter_value = counterbutton_info[counter_id].value;
14407 int step = BUTTON_STEPSIZE(button) *
14408 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
14410 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14412 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
14413 boolean released = (gi->event.type == GD_EVENT_RELEASED);
14414 boolean level_changed = LevelChanged();
14416 if ((level_changed && pressed) || (!level_changed && released))
14419 if (level_changed && !Request("Level has changed! Discard changes?",
14422 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14423 ModifyEditorCounterValue(counter_id, *counter_value);
14429 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14430 *counter_value = gi->textinput.number_value;
14432 ModifyEditorCounterValue(counter_id, *counter_value + step);
14434 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14436 int last_game_engine_type = level.game_engine_type;
14438 LoadLevel(level_nr);
14439 LoadScore(level_nr);
14441 SaveLevelSetup_SeriesInfo();
14446 DrawEditModeWindow();
14448 if (level.game_engine_type != last_game_engine_type)
14450 // update element selection list
14451 ReinitializeElementList();
14452 ModifyEditorElementList();
14458 switch (counter_id)
14460 case ED_COUNTER_ID_YAMYAM_CONTENT:
14461 DrawYamYamContentAreas();
14464 case ED_COUNTER_ID_BALL_CONTENT:
14465 DrawMagicBallContentAreas();
14468 case ED_COUNTER_ID_ANDROID_CONTENT:
14469 DrawAndroidElementArea();
14472 case ED_COUNTER_ID_GROUP_CONTENT:
14473 DrawGroupElementArea();
14474 CopyGroupElementPropertiesToGame(properties_element);
14477 case ED_COUNTER_ID_INVENTORY_SIZE:
14478 DrawPlayerInitialInventoryArea(properties_element);
14481 case ED_COUNTER_ID_MM_BALL_CONTENT:
14482 DrawMMBallContentArea();
14485 case ED_COUNTER_ID_ENVELOPE_XSIZE:
14486 case ED_COUNTER_ID_ENVELOPE_YSIZE:
14487 DrawEnvelopeTextArea(-1);
14490 case ED_COUNTER_ID_LEVEL_XSIZE:
14491 case ED_COUNTER_ID_LEVEL_YSIZE:
14492 lev_fieldx = level.fieldx;
14493 lev_fieldy = level.fieldy;
14495 // check if resizing of level results in change of border border
14496 SetBorderElement();
14504 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
14505 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
14506 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
14507 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
14508 CopyElementPropertiesToGame(properties_element);
14510 // do not mark level as modified for certain non-level-changing gadgets
14511 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
14512 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
14513 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
14514 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
14517 level.changed = TRUE;
14520 static void HandleTextInputGadgets(struct GadgetInfo *gi)
14522 int type_id = gi->custom_type_id;
14524 strcpy(textinput_info[type_id].value, gi->textinput.value);
14526 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
14528 CopyElementPropertiesToGame(properties_element);
14530 ModifyEditorElementList(); // update changed button info text
14533 // do not mark level as modified for certain non-level-changing gadgets
14534 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
14535 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
14538 level.changed = TRUE;
14541 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
14543 int type_id = gi->custom_type_id;
14545 strncpy(textarea_info[type_id].value, gi->textarea.value,
14546 MAX_ENVELOPE_TEXT_LEN);
14547 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
14549 level.changed = TRUE;
14552 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
14554 int type_id = gi->custom_type_id;
14555 int value_old = *selectbox_info[type_id].value;
14556 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
14558 *selectbox_info[type_id].value = value_new;
14560 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
14562 DrawLevelConfigWindow();
14564 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14566 element_info[properties_element].current_change_page = gi->selectbox.index;
14568 DrawPropertiesWindow();
14570 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
14571 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
14572 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
14573 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
14574 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
14576 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
14578 // when changing action type, also check action mode and action arg
14579 if (value_old != value_new)
14580 setSelectboxSpecialActionVariablesIfNeeded();
14582 DrawPropertiesChange();
14585 CopyElementPropertiesToGame(properties_element);
14587 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
14589 // show or hide "engine" tabulator depending on game engine type
14590 DrawLevelConfigWindow();
14592 // update element selection list depending on game engine type
14593 ReinitializeElementList();
14594 ModifyEditorElementList();
14596 else if (type_id == ED_SELECTBOX_ID_BD_SCHEDULING_TYPE)
14598 // update BD cycle delay counter gadgets depending on BD scheduling type
14599 DrawLevelConfigWindow();
14602 // do not mark level as modified for certain non-level-changing gadgets
14603 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
14604 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14607 level.changed = TRUE;
14610 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
14612 int type_id = gi->custom_type_id;
14615 if (type_id >= ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST &&
14616 type_id <= ED_TAB_BUTTON_ID_LEVELCONFIG_LAST)
14618 edit_mode_levelconfig = gi->custom_type_id;
14620 DrawLevelConfigWindow();
14622 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
14623 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
14625 edit_mode_properties = gi->custom_type_id;
14627 DrawPropertiesWindow();
14629 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
14630 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
14632 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
14634 // backup original "level.field" (needed to track playfield changes)
14635 CopyPlayfield(level.field, TileBackup);
14637 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
14638 CopyPlayfield(Tile, level.field);
14640 if (new_template ||
14641 Request("Save this template and kill the old?", REQ_ASK))
14642 SaveLevelTemplate();
14645 Request("Template saved!", REQ_CONFIRM);
14647 // restore original "level.field" (needed to track playfield changes)
14648 CopyPlayfield(TileBackup, level.field);
14650 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
14652 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
14654 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
14655 leveldir_current->readonly)
14657 Request("This level set is read-only!", REQ_CONFIRM);
14662 if (strEqual(levelset_name, ""))
14664 Request("Please enter level set title!", REQ_CONFIRM);
14669 if (strEqual(levelset_author, ""))
14671 Request("Please enter level set author!", REQ_CONFIRM);
14676 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
14678 if (UpdateUserLevelSet(levelset_subdir,
14681 levelset_num_levels))
14683 Request("Level set updated!", REQ_CONFIRM);
14687 Request("Updating level set failed!", REQ_CONFIRM);
14690 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
14692 if (level.changed && !Request("Level has changed! Discard changes?",
14696 if (CreateUserLevelSet(levelset_subdir,
14699 levelset_num_levels,
14700 levelset_use_levelset_artwork))
14702 if (levelset_copy_level_template)
14703 CopyLevelTemplateToUserLevelSet(levelset_subdir);
14705 Request("New level set created!", REQ_CONFIRM);
14707 AddUserLevelSetToLevelInfo(levelset_subdir);
14708 ChangeEditorToLevelSet(levelset_subdir);
14712 Request("Creating new level set failed!", REQ_CONFIRM);
14716 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
14717 custom_element.num_change_pages < MAX_CHANGE_PAGES)
14719 struct ElementInfo *ei = &element_info[properties_element];
14721 // when modifying custom element, ask for copying level template
14722 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14725 setElementChangePages(ei, ei->num_change_pages + 1);
14727 // set new change page to be new current change page
14728 ei->current_change_page = ei->num_change_pages - 1;
14729 ei->change = &ei->change_page[ei->current_change_page];
14731 setElementChangeInfoToDefaults(ei->change);
14733 DrawPropertiesWindow();
14735 level.changed = TRUE;
14737 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
14738 custom_element.num_change_pages > MIN_CHANGE_PAGES)
14740 struct ElementInfo *ei = &element_info[properties_element];
14742 // when modifying custom element, ask for copying level template
14743 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14746 // copy all change pages after change page to be deleted
14747 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
14748 ei->change_page[i] = ei->change_page[i + 1];
14750 setElementChangePages(ei, ei->num_change_pages - 1);
14752 DrawPropertiesWindow();
14754 level.changed = TRUE;
14758 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
14760 int type_id = gi->custom_type_id;
14762 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
14763 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
14765 struct ElementInfo *ei = &element_info[properties_element];
14766 int step = BUTTON_STEPSIZE(gi->event.button);
14768 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
14769 ei->current_change_page += step;
14771 if (ei->current_change_page < 0)
14772 ei->current_change_page = 0;
14773 else if (ei->current_change_page >= ei->num_change_pages)
14774 ei->current_change_page = ei->num_change_pages - 1;
14776 DrawPropertiesWindow();
14778 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
14779 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14781 struct ElementInfo *ei = &element_info[properties_element];
14782 int current_change_page = ei->current_change_page;
14784 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
14786 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
14787 ei->change_page[current_change_page];
14789 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14791 // when modifying custom element, ask for copying level template
14792 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14795 ei->change_page[current_change_page] =
14796 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
14798 level.changed = TRUE;
14801 DrawPropertiesWindow();
14805 static void HandleRadiobuttons(struct GadgetInfo *gi)
14807 int type_id = gi->custom_type_id;
14809 *radiobutton_info[type_id].value =
14810 radiobutton_info[type_id].checked_value;
14812 // do not mark level as modified for certain non-level-changing gadgets
14813 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
14814 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
14817 level.changed = TRUE;
14820 static void HandleCheckbuttons(struct GadgetInfo *gi)
14822 int type_id = gi->custom_type_id;
14824 *checkbutton_info[type_id].value ^= TRUE;
14826 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
14827 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
14828 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
14829 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
14830 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
14831 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
14832 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
14833 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
14835 CopyElementPropertiesToGame(properties_element);
14838 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
14840 UpdateCustomElementGraphicGadgets();
14842 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
14843 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
14845 boolean template_related_changes_found = FALSE;
14848 // check if any custom, group or empty elements have been changed
14849 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
14850 if ((IS_CUSTOM_ELEMENT(i) ||
14851 IS_GROUP_ELEMENT(i) ||
14852 IS_EMPTY_ELEMENT(i)) &&
14853 element_info[i].modified_settings)
14854 template_related_changes_found = TRUE;
14856 if (level.use_custom_template &&
14857 !fileExists(getGlobalLevelTemplateFilename()))
14859 Request("No level template found!", REQ_CONFIRM);
14861 level.use_custom_template = FALSE;
14863 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14868 if (level.use_custom_template &&
14869 template_related_changes_found &&
14870 !Request("Discard changes and use level template?", REQ_ASK))
14872 level.use_custom_template = FALSE;
14874 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14879 if (!level.use_custom_template &&
14880 Request("Copy settings from level template?", REQ_ASK))
14885 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
14887 DrawEditModeWindow();
14889 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
14891 if (setup.editor.use_template_for_new_levels &&
14892 !fileExists(getGlobalLevelTemplateFilename()))
14894 Request("No level template found!", REQ_CONFIRM);
14899 if (setup.editor.use_template_for_new_levels &&
14901 !Request("Discard level and load template?", REQ_ASK))
14906 if (!setup.editor.use_template_for_new_levels &&
14908 !Request("Discard level and use empty level?", REQ_ASK))
14913 LoadLevel(level_nr);
14914 LoadScore(level_nr);
14919 DrawEditModeWindow();
14921 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
14923 SetAutomaticNumberOfGemsNeeded();
14926 // do not mark level as modified for certain non-level-changing gadgets
14927 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
14928 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
14929 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
14930 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
14931 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
14932 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
14935 level.changed = TRUE;
14938 static void HandleControlButtons(struct GadgetInfo *gi)
14940 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
14941 static int last_edit_mode = ED_MODE_DRAWING;
14942 static int last_custom_copy_mode = -1;
14943 static int last_button = 0;
14944 int id = gi->custom_id;
14945 int button = gi->event.button;
14946 int step = BUTTON_STEPSIZE(button);
14947 int new_element = BUTTON_ELEMENT(button);
14948 int last_properties_element = properties_element;
14951 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
14952 DrawLevelText(0, 0, 0, TEXT_END);
14954 if (id < ED_NUM_CTRL1_BUTTONS &&
14955 id != GADGET_ID_SINGLE_ITEMS &&
14956 id != GADGET_ID_PICK_ELEMENT &&
14957 edit_mode != ED_MODE_DRAWING &&
14958 drawing_function != GADGET_ID_PICK_ELEMENT &&
14959 !(GetKeyModState() & KMOD_Control))
14960 ChangeEditModeWindow(ED_MODE_DRAWING);
14962 // element copy mode active, but no element button pressed => deactivate
14963 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
14964 last_custom_copy_mode = -1;
14966 // when showing palette on element buttons, change element of button used
14967 if (editor.palette.show_on_element_buttons &&
14968 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
14970 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
14972 id = GADGET_ID_PALETTE;
14977 case GADGET_ID_SCROLL_LEFT:
14978 if (level_xpos >= 0)
14980 if (lev_fieldx < ed_fieldx - 2)
14983 level_xpos -= step;
14984 if (level_xpos < -1)
14987 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
14989 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14991 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14992 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14996 case GADGET_ID_SCROLL_RIGHT:
14997 if (level_xpos <= lev_fieldx - ed_fieldx)
14999 if (lev_fieldx < ed_fieldx - 2)
15002 level_xpos += step;
15003 if (level_xpos > lev_fieldx - ed_fieldx + 1)
15004 level_xpos = lev_fieldx - ed_fieldx + 1;
15006 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
15008 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15010 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
15011 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
15015 case GADGET_ID_SCROLL_UP:
15016 if (level_ypos >= 0)
15018 if (lev_fieldy < ed_fieldy - 2)
15021 level_ypos -= step;
15022 if (level_ypos < -1)
15025 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
15027 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15029 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15030 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15034 case GADGET_ID_SCROLL_DOWN:
15035 if (level_ypos <= lev_fieldy - ed_fieldy)
15037 if (lev_fieldy < ed_fieldy - 2)
15040 level_ypos += step;
15041 if (level_ypos > lev_fieldy - ed_fieldy + 1)
15042 level_ypos = lev_fieldy - ed_fieldy + 1;
15044 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
15046 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15048 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15049 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15053 case GADGET_ID_SCROLL_HORIZONTAL:
15054 level_xpos = gi->event.item_position - 1;
15056 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15061 case GADGET_ID_SCROLL_VERTICAL:
15062 level_ypos = gi->event.item_position - 1;
15064 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15069 case GADGET_ID_SCROLL_LIST_UP:
15070 case GADGET_ID_SCROLL_LIST_DOWN:
15071 case GADGET_ID_SCROLL_LIST_VERTICAL:
15072 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
15073 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
15076 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
15077 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15079 if (element_shift < 0)
15081 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15082 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15084 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15085 GDI_SCROLLBAR_ITEM_POSITION,
15086 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15089 ModifyEditorElementList();
15093 case GADGET_ID_PROPERTIES:
15094 // always switch off element properties when they are already displayed
15095 last_properties_element = new_element;
15096 case GADGET_ID_ELEMENT_LEFT:
15097 case GADGET_ID_ELEMENT_MIDDLE:
15098 case GADGET_ID_ELEMENT_RIGHT:
15099 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
15100 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
15101 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
15104 if (edit_mode != ED_MODE_PROPERTIES)
15106 last_edit_mode = edit_mode;
15108 ChangeEditModeWindow(ED_MODE_PROPERTIES);
15110 last_level_drawing_function = drawing_function;
15111 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
15114 else if (properties_element != last_properties_element)
15116 DrawEditModeWindow();
15120 ChangeEditModeWindow(ED_MODE_DRAWING);
15122 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
15127 case GADGET_ID_PALETTE:
15128 if (edit_mode != ED_MODE_PALETTE)
15130 last_edit_mode = edit_mode;
15132 ChangeEditModeWindow(ED_MODE_PALETTE);
15136 ChangeEditModeWindow(last_edit_mode);
15140 case GADGET_ID_WRAP_LEFT:
15141 WrapLevel(-step, 0);
15144 case GADGET_ID_WRAP_RIGHT:
15145 WrapLevel(step, 0);
15148 case GADGET_ID_WRAP_UP:
15149 WrapLevel(0, -step);
15152 case GADGET_ID_WRAP_DOWN:
15153 WrapLevel(0, step);
15156 case GADGET_ID_SINGLE_ITEMS:
15157 case GADGET_ID_CONNECTED_ITEMS:
15158 case GADGET_ID_LINE:
15159 case GADGET_ID_ARC:
15160 case GADGET_ID_TEXT:
15161 case GADGET_ID_RECTANGLE:
15162 case GADGET_ID_FILLED_BOX:
15163 case GADGET_ID_FLOOD_FILL:
15164 case GADGET_ID_GRAB_BRUSH:
15165 case GADGET_ID_PICK_ELEMENT:
15166 if (drawing_function != GADGET_ID_PICK_ELEMENT)
15167 last_drawing_function = drawing_function;
15168 drawing_function = id;
15169 draw_with_brush = FALSE;
15172 case GADGET_ID_RANDOM_PLACEMENT:
15173 RandomPlacement(new_element);
15176 case GADGET_ID_ZOOM:
15177 // zoom level editor tile size in or out (or reset to default size)
15178 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
15179 button == 2 ? ed_tilesize_default :
15180 button == 3 ? ed_tilesize / 2 : ed_tilesize);
15182 // when using touch device, cycle through all zoom tilesizes
15183 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
15184 ed_tilesize = MICRO_TILESIZE;
15186 // limit zoom level by upper and lower bound
15187 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
15189 InitZoomLevelSettings(ed_tilesize);
15191 if (edit_mode == ED_MODE_DRAWING)
15193 DrawDrawingWindow();
15195 // redraw zoom gadget info text
15196 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15199 // save current editor zoom tilesize
15200 SaveSetup_AutoSetup();
15204 case GADGET_ID_CUSTOM_COPY_FROM:
15205 case GADGET_ID_CUSTOM_COPY_TO:
15206 case GADGET_ID_CUSTOM_EXCHANGE:
15207 last_custom_copy_mode = id;
15208 last_drawing_function = drawing_function;
15211 case GADGET_ID_CUSTOM_COPY:
15212 CopyCustomElement(properties_element, -1, id);
15215 case GADGET_ID_CUSTOM_PASTE:
15216 CopyCustomElement(-1, properties_element, id);
15219 case GADGET_ID_UNDO:
15220 if (button < 0) // keep button value (even if modifier keys are pressed)
15222 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
15225 if (button == 1 && undo_buffer_steps == 0)
15227 Request("Undo buffer empty!", REQ_CONFIRM);
15231 else if (button == 2)
15235 else if (button == 3 && redo_buffer_steps == 0)
15237 Request("Redo buffer empty!", REQ_CONFIRM);
15242 if (edit_mode != ED_MODE_DRAWING)
15243 ChangeEditModeWindow(ED_MODE_DRAWING);
15249 undo_buffer_position =
15250 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
15252 undo_buffer_steps--;
15253 redo_buffer_steps++;
15259 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
15261 undo_buffer_steps++;
15262 redo_buffer_steps--;
15265 for (x = 0; x < lev_fieldx; x++)
15266 for (y = 0; y < lev_fieldy; y++)
15267 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
15269 // check if undo operation forces change of border style
15270 CheckLevelBorderElement(FALSE);
15272 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15276 case GADGET_ID_CONF:
15277 if (edit_mode != ED_MODE_LEVELCONFIG)
15279 last_edit_mode = edit_mode;
15281 ChangeEditModeWindow(ED_MODE_LEVELCONFIG);
15285 ChangeEditModeWindow(ED_MODE_DRAWING);
15289 case GADGET_ID_CLEAR:
15290 if (edit_mode != ED_MODE_DRAWING)
15291 ChangeEditModeWindow(ED_MODE_DRAWING);
15293 for (x = 0; x < MAX_LEV_FIELDX; x++)
15294 for (y = 0; y < MAX_LEV_FIELDY; y++)
15295 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
15297 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
15299 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15302 case GADGET_ID_SAVE:
15304 // saving read-only levels into personal level set modifies global vars
15305 // "leveldir_current" and "level_nr"; restore them after saving level
15306 LevelDirTree *leveldir_former = leveldir_current;
15307 int level_nr_former = level_nr;
15308 char *level_filename;
15311 if (leveldir_current->readonly &&
15312 !PrepareSavingIntoPersonalLevelSet())
15315 level_filename = getDefaultLevelFilename(level_nr);
15316 new_level = !fileExists(level_filename);
15319 Request("Save this level and kill the old?", REQ_ASK))
15321 if (leveldir_former->readonly)
15322 ModifyLevelConfigForSavingIntoPersonalLevelSet(leveldir_former->name);
15324 SetAutomaticNumberOfGemsNeeded();
15326 CopyPlayfield(Tile, level.field);
15327 SaveLevel(level_nr);
15329 level.changed = FALSE;
15333 char level_saved_msg[64];
15335 if (leveldir_former->readonly)
15336 sprintf(level_saved_msg,
15337 "Level saved as level %d into personal level set!",
15340 strcpy(level_saved_msg, "Level saved!");
15342 Request(level_saved_msg, REQ_CONFIRM);
15346 // "cd" back to copied-from levelset (in case of saved read-only level)
15347 leveldir_current = leveldir_former;
15348 level_nr = level_nr_former;
15353 case GADGET_ID_TEST:
15354 if (LevelChanged())
15355 level.game_version = GAME_VERSION_ACTUAL;
15357 CopyPlayfield(level.field, TileBackup);
15358 CopyPlayfield(Tile, level.field);
15360 CopyNativeLevel_RND_to_Native(&level);
15362 UnmapLevelEditorGadgets();
15363 UndrawSpecialEditorDoor();
15365 CloseDoor(DOOR_CLOSE_ALL);
15367 // needed before playing if editor playfield area has different size
15368 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
15370 // redraw_mask = REDRAW_ALL;
15372 level_editor_test_game = TRUE;
15374 StartGameActions(FALSE, setup.autorecord, level.random_seed);
15378 case GADGET_ID_EXIT:
15379 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
15383 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
15384 id <= GADGET_ID_ELEMENTLIST_LAST)
15386 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
15388 new_element = editor_elements[element_position + element_shift];
15390 if (IS_EDITOR_CASCADE(new_element))
15394 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
15396 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
15397 boolean *cascade_value = editor_elements_info[i].setup_cascade_value;
15399 if (*cascade_element == new_element)
15401 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
15402 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
15404 // update element selection list
15405 ReinitializeElementList();
15406 ModifyEditorElementList();
15408 // update cascading gadget info text
15409 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15411 // save current editor cascading state
15412 SaveSetup_EditorCascade();
15421 if (last_custom_copy_mode != -1)
15423 if (CopyCustomElement(properties_element, new_element,
15424 last_custom_copy_mode))
15426 ClickOnGadget(level_editor_gadget[last_drawing_function],
15429 last_custom_copy_mode = -1;
15435 // change element of button used to show palette
15436 if (editor.palette.show_on_element_buttons)
15437 button = last_button;
15439 PickDrawingElement(button, new_element);
15441 if (!stick_element_properties_window &&
15442 drawing_function != GADGET_ID_PICK_ELEMENT &&
15443 !(GetKeyModState() & KMOD_Control))
15445 properties_element = new_element;
15446 if (edit_mode == ED_MODE_PROPERTIES)
15447 DrawPropertiesWindow();
15450 if (drawing_function == GADGET_ID_PICK_ELEMENT)
15451 ClickOnGadget(level_editor_gadget[last_drawing_function],
15454 if (!use_permanent_palette)
15455 ChangeEditModeWindow(last_edit_mode);
15458 else if (gi->event.type == GD_EVENT_PRESSED)
15459 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
15460 else if (gi->event.type == GD_EVENT_RELEASED)
15461 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
15462 else if (gi->event.type == GD_EVENT_MOVING)
15463 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
15465 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
15471 void HandleLevelEditorKeyInput(Key key)
15473 char letter = getCharFromKey(key);
15475 if (drawing_function == GADGET_ID_TEXT &&
15476 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
15479 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
15480 else if (key == KSYM_Delete || key == KSYM_BackSpace)
15481 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
15482 else if (key == KSYM_Return)
15483 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
15484 else if (key == KSYM_Escape)
15485 DrawLevelText(0, 0, 0, TEXT_END);
15490 int id = GADGET_ID_NONE;
15491 int new_element_shift = element_shift;
15492 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
15493 int button = MB_LEFTBUTTON;
15499 id = GADGET_ID_SCROLL_LEFT;
15502 id = GADGET_ID_SCROLL_RIGHT;
15505 id = GADGET_ID_SCROLL_UP;
15508 id = GADGET_ID_SCROLL_DOWN;
15512 case KSYM_Page_Down:
15513 step *= (key == KSYM_Page_Up ? -1 : +1);
15514 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15516 if (element_shift < 0)
15518 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15519 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15521 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15522 GDI_SCROLLBAR_ITEM_POSITION,
15523 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15525 ModifyEditorElementList();
15531 element_shift = (key == KSYM_Home ? 0 :
15532 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
15534 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15535 GDI_SCROLLBAR_ITEM_POSITION,
15536 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15538 ModifyEditorElementList();
15545 // this is needed to prevent interference with running "True X-Mouse"
15546 if (GetKeyModStateFromEvents() & KMOD_Control)
15549 // check for last or next editor cascade block in element list
15550 for (i = 0; i < num_editor_elements; i++)
15552 if ((key == KSYM_Insert && i == element_shift) ||
15553 (key == KSYM_Delete && new_element_shift > element_shift))
15556 // jump to next cascade block (or to start of element list)
15557 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
15558 new_element_shift = i;
15561 if (i < num_editor_elements)
15562 element_shift = new_element_shift;
15564 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15565 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15567 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15568 GDI_SCROLLBAR_ITEM_POSITION,
15569 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15571 ModifyEditorElementList();
15576 if (edit_mode == ED_MODE_DRAWING)
15577 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
15578 else if (edit_mode == ED_MODE_LEVELCONFIG)
15579 HandleControlButtons(level_editor_gadget[GADGET_ID_CONF]);
15580 else if (edit_mode == ED_MODE_PROPERTIES)
15581 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
15582 else if (edit_mode == ED_MODE_PALETTE)
15583 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
15584 else // should never happen
15585 ChangeEditModeWindow(ED_MODE_DRAWING);
15593 if (id != GADGET_ID_NONE)
15594 ClickOnGadget(level_editor_gadget[id], button);
15595 else if (letter == '1' || letter == '?')
15596 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
15597 else if (letter == '2')
15598 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
15599 else if (letter == '3')
15600 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
15601 else if (letter == '.')
15602 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
15603 else if (letter == 'U')
15604 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
15605 else if (letter == '-' || key == KSYM_KP_Subtract)
15606 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
15607 else if (letter == '0' || key == KSYM_KP_0)
15608 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
15609 else if (letter == '+' || key == KSYM_KP_Add ||
15610 letter == '=') // ("Shift-=" is "+" on US keyboards)
15611 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
15612 else if (key == KSYM_Return ||
15613 key == KSYM_space ||
15614 key == setup.shortcut.toggle_pause)
15615 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
15617 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
15618 if (letter && letter == controlbutton_info[i].shortcut)
15619 if (!anyTextGadgetActive())
15620 ClickOnGadget(level_editor_gadget[i], button);
15622 if (draw_with_brush)
15626 else if (letter == 'y')
15628 else if (letter == 'z')
15633 static void HandleLevelEditorIdle_Properties(void)
15635 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
15636 int x = editor.settings.element_graphic.x + element_border;
15637 int y = editor.settings.element_graphic.y + element_border;
15638 static DelayCounter action_delay = { 0 };
15641 action_delay.value = GameFrameDelay;
15643 if (!DelayReached(&action_delay))
15646 for (i = 0; i < ED_NUM_SELECTBOX; i++)
15648 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
15650 if (gi->mapped && gi->active && gi->selectbox.open)
15654 DrawEditorElementAnimation(SX + x, SY + y);
15656 redraw_mask |= REDRAW_FIELD;
15658 FrameCounter++; // increase animation frame counter
15661 static void HandleLevelEditorIdle_Drawing(void)
15663 static boolean last_highlighted = FALSE;
15664 static boolean last_highlighted_similar = FALSE;
15665 boolean highlighted = (GetKeyModState() & KMOD_Alt);
15666 boolean highlighted_similar = (GetKeyModState() & KMOD_Shift);
15668 if (highlighted != last_highlighted ||
15669 (highlighted && highlighted_similar != last_highlighted_similar))
15671 DrawAreaElementHighlight(highlighted, highlighted_similar);
15673 redraw_mask |= REDRAW_FIELD;
15676 last_highlighted = highlighted;
15677 last_highlighted_similar = highlighted_similar;
15680 void HandleLevelEditorIdle(void)
15682 if (edit_mode == ED_MODE_PROPERTIES)
15683 HandleLevelEditorIdle_Properties();
15684 else if (edit_mode == ED_MODE_DRAWING)
15685 HandleLevelEditorIdle_Drawing();
15688 static void ClearEditorGadgetInfoText(void)
15690 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
15693 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
15695 char infotext[MAX_OUTPUT_LINESIZE + 1];
15696 int max_infotext_len = getMaxInfoTextLength();
15698 if (gi == NULL || strlen(gi->info_text) == 0)
15701 strncpy(infotext, gi->info_text, max_infotext_len);
15702 infotext[max_infotext_len] = '\0';
15704 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
15706 int key = controlbutton_info[gi->custom_id].shortcut;
15710 char shortcut[MAX_OUTPUT_LINESIZE + 1];
15712 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
15713 sprintf(shortcut, " ('.' or '%c')", key);
15714 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
15715 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
15716 else if (gi->custom_id == GADGET_ID_TEST)
15717 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
15718 else if (gi->custom_id == GADGET_ID_UNDO)
15719 sprintf(shortcut, " ('%c/Shift-U')", key);
15720 else if (gi->custom_id == GADGET_ID_ZOOM)
15721 sprintf(shortcut, " ('%c', '0', '-')", key);
15723 sprintf(shortcut, " ('%s%c')",
15724 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
15726 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
15727 strcat(infotext, shortcut);
15731 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
15734 void HandleEditorGadgetInfoText(void *ptr)
15736 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
15738 if (game_status != GAME_MODE_EDITOR)
15741 ClearEditorGadgetInfoText();
15743 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
15746 // misuse this function to delete brush cursor, if needed
15747 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
15748 DeleteBrushFromCursor();
15750 PrintEditorGadgetInfoText(gi);
15753 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
15755 int id = gi->custom_id;
15756 int type_id = gi->custom_type_id;
15757 int sx = gi->event.x;
15758 int sy = gi->event.y;
15759 int lx = sx + level_xpos;
15760 int ly = sy + level_ypos;
15761 int min_sx = 0, min_sy = 0;
15762 int max_sx = gi->drawing.area_xsize - 1;
15763 int max_sy = gi->drawing.area_ysize - 1;
15764 int actual_drawing_function = drawing_function;
15765 int max_infotext_len = getMaxInfoTextLength();
15766 char infotext[MAX_OUTPUT_LINESIZE + 1];
15768 infotext[0] = '\0'; // start with empty info text
15770 // pressed Control key: simulate picking element
15771 if (GetKeyModState() & KMOD_Control)
15772 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
15774 ClearEditorGadgetInfoText();
15776 if (gi->event.type == GD_EVENT_INFO_LEAVING)
15779 // make sure to stay inside drawing area boundaries
15780 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
15781 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
15783 if (id == GADGET_ID_DRAWING_LEVEL)
15787 int min_lx = 0, min_ly = 0;
15788 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
15790 // get positions inside level field
15791 lx = sx + level_xpos;
15792 ly = sy + level_ypos;
15794 // make sure to stay inside level field boundaries
15795 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
15796 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
15798 // correct drawing area positions accordingly
15799 sx = lx - level_xpos;
15800 sy = ly - level_ypos;
15803 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15805 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
15807 static int start_lx = 0;
15808 static int start_ly = 0;
15811 if (gi->event.type == GD_EVENT_PRESSED)
15817 switch (actual_drawing_function)
15819 case GADGET_ID_SINGLE_ITEMS:
15820 text = "Drawing single items";
15822 case GADGET_ID_CONNECTED_ITEMS:
15823 text = "Drawing connected items";
15825 case GADGET_ID_LINE:
15826 text = "Drawing line";
15828 case GADGET_ID_ARC:
15829 text = "Drawing arc";
15831 case GADGET_ID_TEXT:
15832 text = "Setting text cursor";
15834 case GADGET_ID_RECTANGLE:
15835 text = "Drawing rectangle";
15837 case GADGET_ID_FILLED_BOX:
15838 text = "Drawing filled box";
15840 case GADGET_ID_FLOOD_FILL:
15841 text = "Flood fill";
15843 case GADGET_ID_GRAB_BRUSH:
15844 text = "Grabbing brush";
15846 case GADGET_ID_PICK_ELEMENT:
15847 text = "Picking element";
15851 text = "Drawing position";
15855 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15856 sprintf(infotext, "%s: %d, %d", text, lx, ly);
15858 sprintf(infotext, "%s: %d, %d", text,
15859 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
15861 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15862 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
15864 sprintf(infotext, "Level position: %d, %d", lx, ly);
15867 // misuse this function to draw brush cursor, if needed
15868 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
15870 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15871 CopyBrushToCursor(sx, sy);
15873 DeleteBrushFromCursor();
15876 if (!draw_with_brush)
15877 UpdateBrushPosition(sx, sy);
15879 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15881 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
15882 int element = drawingarea_info[type_id].value[pos];
15884 strncpy(infotext, getElementInfoText(element), max_infotext_len);
15888 if (id == GADGET_ID_CUSTOM_CONTENT)
15889 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
15890 else if (id == GADGET_ID_GROUP_CONTENT)
15891 sprintf(infotext, "group element position: %d", sx + 1);
15892 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
15893 id <= GADGET_ID_YAMYAM_CONTENT_7)
15894 sprintf(infotext, "content area %d position: %d, %d",
15895 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
15896 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
15897 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
15898 sprintf(infotext, "content area %d position: %d, %d",
15899 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
15900 else if (id == GADGET_ID_ANDROID_CONTENT)
15901 sprintf(infotext, "android element position: %d", sx + 1);
15902 else if (drawingarea_info[type_id].infotext != NULL)
15903 strcpy(infotext, drawingarea_info[type_id].infotext);
15906 infotext[max_infotext_len] = '\0';
15908 if (strlen(infotext) > 0)
15909 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
15912 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
15913 boolean quick_quit)
15915 if (!ask_if_level_has_changed ||
15917 Request("Level has changed! Exit without saving?",
15918 REQ_ASK | REQ_STAY_OPEN))
15920 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
15921 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
15923 // draw normal door
15924 UndrawSpecialEditorDoor();
15926 // use door animation if door 1 viewport is unchanged and contains toolbox
15927 if (useEditorDoorAnimation())
15928 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
15930 // close editor doors if viewport definition is the same as in main menu
15931 if (vp_door_1->x == DX &&
15932 vp_door_1->y == DY &&
15933 vp_door_1->width == DXSIZE &&
15934 vp_door_1->height == DYSIZE &&
15935 vp_door_2->x == VX &&
15936 vp_door_2->y == VY &&
15937 vp_door_2->width == VXSIZE &&
15938 vp_door_2->height == VYSIZE)
15939 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
15941 SetDoorState(DOOR_CLOSE_ALL);
15946 FadeSkipNextFadeIn();
15948 SetGameStatus(GAME_MODE_MAIN);
15954 if (!global.use_envelope_request)
15956 CloseDoor(DOOR_CLOSE_1);
15957 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);