1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
14 #include "libgame/libgame.h"
25 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
28 // ----------------------------------------------------------------------------
29 // screen and artwork graphic pixel position definitions
30 // ----------------------------------------------------------------------------
32 // values for the control window
33 #define ED_CTRL1_BUTTONS_HORIZ 4 // toolbox
34 #define ED_CTRL1_BUTTONS_VERT 4
35 #define ED_CTRL2_BUTTONS_HORIZ 3 // level
36 #define ED_CTRL2_BUTTONS_VERT 2
37 #define ED_CTRL3_BUTTONS_HORIZ 3 // CE and GE
38 #define ED_CTRL3_BUTTONS_VERT 1
39 #define ED_CTRL4_BUTTONS_HORIZ 2 // CE and GE
40 #define ED_CTRL4_BUTTONS_VERT 1
41 #define ED_CTRL5_BUTTONS_HORIZ 1 // properties
42 #define ED_CTRL5_BUTTONS_VERT 1
43 #define ED_CTRL6_BUTTONS_HORIZ 3 // properties
44 #define ED_CTRL6_BUTTONS_VERT 1
45 #define ED_CTRL7_BUTTONS_HORIZ 1 // palette
46 #define ED_CTRL7_BUTTONS_VERT 1
48 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
49 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
50 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
51 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
52 #define ED_NUM_CTRL5_BUTTONS (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT)
53 #define ED_NUM_CTRL6_BUTTONS (ED_CTRL6_BUTTONS_HORIZ * ED_CTRL6_BUTTONS_VERT)
54 #define ED_NUM_CTRL7_BUTTONS (ED_CTRL7_BUTTONS_HORIZ * ED_CTRL7_BUTTONS_VERT)
55 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
56 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
57 #define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS)
58 #define ED_NUM_CTRL1_5_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS)
59 #define ED_NUM_CTRL1_6_BUTTONS (ED_NUM_CTRL1_5_BUTTONS + ED_NUM_CTRL6_BUTTONS)
60 #define ED_NUM_CTRL1_7_BUTTONS (ED_NUM_CTRL1_6_BUTTONS + ED_NUM_CTRL7_BUTTONS)
61 #define ED_NUM_CTRL_BUTTONS ED_NUM_CTRL1_7_BUTTONS
63 // values for the element list
64 #define ED_ELEMENTLIST_XPOS (editor.palette.x)
65 #define ED_ELEMENTLIST_YPOS (editor.palette.y)
66 #define ED_ELEMENTLIST_XSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
67 #define ED_ELEMENTLIST_YSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
68 #define ED_ELEMENTLIST_COLS MAX(1, editor.palette.cols)
69 #define ED_ELEMENTLIST_ROWS MAX(1, editor.palette.rows)
70 #define ED_ELEMENTLIST_BUTTONS_HORIZ (ED_ELEMENTLIST_COLS)
71 #define ED_ELEMENTLIST_BUTTONS_VERT (ED_ELEMENTLIST_ROWS)
72 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
73 ED_ELEMENTLIST_BUTTONS_VERT)
76 #define ED_GADGET_NORMAL_DISTANCE (editor.gadget.normal_spacing)
77 #define ED_GADGET_SMALL_DISTANCE (editor.gadget.small_spacing)
78 #define ED_GADGET_TINY_DISTANCE (editor.gadget.tiny_spacing)
79 #define ED_GADGET_LINE_DISTANCE (editor.gadget.line_spacing)
80 #define ED_GADGET_TEXT_DISTANCE (editor.gadget.text_spacing)
81 #define ED_TAB_BAR_HEIGHT (editor.gadget.separator_line.height)
82 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
83 ED_DRAWINGAREA_BORDER_SIZE)
84 #define ED_GADGET_SPACE_DISTANCE (getFontWidth(FONT_TEXT_1))
86 // values for drawingarea gadgets
87 #define IMG_BORDER_1 IMG_EDITOR_ELEMENT_BORDER
88 #define IMG_BORDER_2 IMG_EDITOR_ELEMENT_BORDER_INPUT
89 #define ED_ELEMENT_BORDER (graphic_info[IMG_BORDER_1].border_size)
90 #define ED_DRAWINGAREA_BORDER_SIZE (graphic_info[IMG_BORDER_2].border_size)
91 #define ED_DRAWINGAREA_TILE_SIZE (editor.drawingarea.tile_size)
93 // values for checkbutton gadgets
94 #define ED_CHECKBUTTON_XSIZE (graphic_info[IMG_EDITOR_CHECKBOX].width)
95 #define ED_CHECKBUTTON_YSIZE (graphic_info[IMG_EDITOR_CHECKBOX].height)
97 #define ED_TABBUTTON_XSIZE (graphic_info[IMG_EDITOR_TABBUTTON].width)
98 #define ED_TABBUTTON_YSIZE (graphic_info[IMG_EDITOR_TABBUTTON].height)
100 #define ED_SETTINGS_LEVEL_TABS_X (editor.settings.tabs.x)
101 #define ED_SETTINGS_LEVEL_TABS_Y (editor.settings.tabs.y)
102 #define ED_SETTINGS_ELEMENT_TABS_X (editor.settings.tabs.x)
103 #define ED_SETTINGS_ELEMENT_TABS_Y (editor.settings.tabs.y + \
104 editor.settings.tabs.yoffset2)
106 #define ED_SETTINGS_TABS_XOFFSET (editor.settings.tabs.draw_xoffset)
107 #define ED_SETTINGS_TABS_YOFFSET (editor.settings.tabs.draw_yoffset)
109 #define ED_LEVEL_TABS_XSTART (ED_SETTINGS_LEVEL_TABS_X)
110 #define ED_LEVEL_TABS_YSTART (ED_SETTINGS_LEVEL_TABS_Y)
111 #define ED_LEVEL_SETTINGS_XSTART (ED_SETTINGS_LEVEL_TABS_X + \
112 ED_SETTINGS_TABS_XOFFSET)
113 #define ED_LEVEL_SETTINGS_YSTART (ED_SETTINGS_LEVEL_TABS_Y + \
114 ED_TABBUTTON_YSIZE + \
115 ED_GADGET_TINY_DISTANCE + \
116 ED_TAB_BAR_HEIGHT + \
117 ED_SETTINGS_TABS_YOFFSET + \
118 getFontHeight(FONT_TEXT_1) + \
119 ED_GADGET_TEXT_DISTANCE)
120 #define ED_ELEMENT_TABS_XSTART (ED_SETTINGS_ELEMENT_TABS_X)
121 #define ED_ELEMENT_TABS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y)
122 #define ED_ELEMENT_SETTINGS_XSTART (ED_SETTINGS_ELEMENT_TABS_X + \
123 ED_SETTINGS_TABS_XOFFSET)
124 #define ED_ELEMENT_SETTINGS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y + \
125 ED_TABBUTTON_YSIZE + \
126 ED_GADGET_TINY_DISTANCE + \
127 ED_TAB_BAR_HEIGHT + \
128 ED_SETTINGS_TABS_YOFFSET)
130 #define ED_SETTINGS_XOFFSET (ED_CHECKBUTTON_XSIZE + \
131 ED_GADGET_TEXT_DISTANCE)
132 #define ED_SETTINGS_YOFFSET (ED_CHECKBUTTON_YSIZE + \
133 ED_GADGET_LINE_DISTANCE)
135 #define ED_POS_RANGE (10000)
136 #define ED_POS_LEVEL_TABS_FIRST (1 * ED_POS_RANGE)
137 #define ED_POS_LEVEL_TABS_LAST (2 * ED_POS_RANGE - 1)
138 #define ED_POS_LEVEL_SETTINGS_FIRST (2 * ED_POS_RANGE)
139 #define ED_POS_LEVEL_SETTINGS_LAST (3 * ED_POS_RANGE - 1)
140 #define ED_POS_ELEMENT_TABS_FIRST (3 * ED_POS_RANGE)
141 #define ED_POS_ELEMENT_TABS_LAST (4 * ED_POS_RANGE - 1)
142 #define ED_POS_ELEMENT_SETTINGS_FIRST (4 * ED_POS_RANGE)
143 #define ED_POS_ELEMENT_SETTINGS_LAST (5 * ED_POS_RANGE - 1)
145 #define ED_LEVEL_TABS_XPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
146 #define ED_LEVEL_TABS_YPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
148 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
149 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
151 #define ED_ELEMENT_TABS_XPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
152 #define ED_ELEMENT_TABS_YPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
154 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
155 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
157 #define IS_POS_LEVEL_TABS(n) ((n) >= ED_POS_LEVEL_TABS_FIRST && \
158 (n) <= ED_POS_LEVEL_TABS_LAST)
159 #define IS_POS_LEVEL_SETTINGS(n) ((n) >= ED_POS_LEVEL_SETTINGS_FIRST && \
160 (n) <= ED_POS_LEVEL_SETTINGS_LAST)
161 #define IS_POS_ELEMENT_TABS(n) ((n) >= ED_POS_ELEMENT_TABS_FIRST && \
162 (n) <= ED_POS_ELEMENT_TABS_LAST)
163 #define IS_POS_ELEMENT_SETTINGS(n) ((n) >= ED_POS_ELEMENT_SETTINGS_FIRST && \
164 (n) <= ED_POS_ELEMENT_SETTINGS_LAST)
166 #define ED_LEVEL_TABS_LINE(n) ((n) - ED_POS_LEVEL_TABS_FIRST)
167 #define ED_LEVEL_SETTINGS_LINE(n) ((n) - ED_POS_LEVEL_SETTINGS_FIRST)
168 #define ED_ELEMENT_TABS_LINE(n) ((n) - ED_POS_ELEMENT_TABS_FIRST)
169 #define ED_ELEMENT_SETTINGS_LINE(n) ((n) - ED_POS_ELEMENT_SETTINGS_FIRST)
171 #define ED_LEVEL_TABS_X(n) (ED_LEVEL_TABS_XSTART + \
172 (n) * ED_SETTINGS_TABS_XOFFSET)
173 #define ED_LEVEL_TABS_Y(n) (ED_LEVEL_TABS_YSTART + \
174 (n) * ED_SETTINGS_TABS_YOFFSET)
176 #define ED_LEVEL_SETTINGS_X(n) (ED_LEVEL_SETTINGS_XSTART + \
177 (n) * ED_SETTINGS_XOFFSET)
178 #define ED_LEVEL_SETTINGS_Y(n) (ED_LEVEL_SETTINGS_YSTART + \
179 (n) * ED_SETTINGS_YOFFSET)
181 #define ED_ELEMENT_TABS_X(n) (ED_ELEMENT_TABS_XSTART + \
182 (n) * ED_SETTINGS_TABS_XOFFSET)
183 #define ED_ELEMENT_TABS_Y(n) (ED_ELEMENT_TABS_YSTART + \
184 (n) * ED_SETTINGS_TABS_YOFFSET)
186 #define ED_ELEMENT_SETTINGS_X(n) (ED_ELEMENT_SETTINGS_XSTART + \
187 (n) * ED_SETTINGS_XOFFSET)
188 #define ED_ELEMENT_SETTINGS_Y(n) (ED_ELEMENT_SETTINGS_YSTART + \
189 (n) * ED_SETTINGS_YOFFSET)
191 #define ED_POS_TO_LEVEL_TABS_X(n) \
192 (ED_LEVEL_TABS_X(ED_LEVEL_TABS_LINE(n)))
193 #define ED_POS_TO_LEVEL_TABS_Y(n) \
194 (ED_LEVEL_TABS_Y(ED_LEVEL_TABS_LINE(n)))
196 #define ED_POS_TO_LEVEL_SETTINGS_X(n) \
197 (ED_LEVEL_SETTINGS_X(ED_LEVEL_SETTINGS_LINE(n)))
198 #define ED_POS_TO_LEVEL_SETTINGS_Y(n) \
199 (ED_LEVEL_SETTINGS_Y(ED_LEVEL_SETTINGS_LINE(n)))
201 #define ED_POS_TO_ELEMENT_TABS_X(n) \
202 (ED_ELEMENT_TABS_X(ED_ELEMENT_TABS_LINE(n)))
203 #define ED_POS_TO_ELEMENT_TABS_Y(n) \
204 (ED_ELEMENT_TABS_Y(ED_ELEMENT_TABS_LINE(n)))
206 #define ED_POS_TO_ELEMENT_SETTINGS_X(n) \
207 (ED_ELEMENT_SETTINGS_X(ED_ELEMENT_SETTINGS_LINE(n)))
208 #define ED_POS_TO_ELEMENT_SETTINGS_Y(n) \
209 (ED_ELEMENT_SETTINGS_Y(ED_ELEMENT_SETTINGS_LINE(n)))
211 #define ED_SETTINGS_X(n) (IS_POS_LEVEL_TABS(n) ? \
212 ED_POS_TO_LEVEL_TABS_X(n) : \
213 IS_POS_LEVEL_SETTINGS(n) ? \
214 ED_POS_TO_LEVEL_SETTINGS_X(n) : \
215 IS_POS_ELEMENT_TABS(n) ? \
216 ED_POS_TO_ELEMENT_TABS_X(n) : \
217 IS_POS_ELEMENT_SETTINGS(n) ? \
218 ED_POS_TO_ELEMENT_SETTINGS_X(n) : (n))
219 #define ED_SETTINGS_Y(n) (IS_POS_LEVEL_TABS(n) ? \
220 ED_POS_TO_LEVEL_TABS_Y(n) : \
221 IS_POS_LEVEL_SETTINGS(n) ? \
222 ED_POS_TO_LEVEL_SETTINGS_Y(n) : \
223 IS_POS_ELEMENT_TABS(n) ? \
224 ED_POS_TO_ELEMENT_TABS_Y(n) : \
225 IS_POS_ELEMENT_SETTINGS(n) ? \
226 ED_POS_TO_ELEMENT_SETTINGS_Y(n) : (n))
228 #define ED_SETTINGS_XOFF(n) (5 * ((n) % 4) * \
229 ED_DRAWINGAREA_TILE_SIZE)
230 #define ED_SETTINGS_YOFF(n) (5 * ((n) / 4) * \
231 ED_DRAWINGAREA_TILE_SIZE)
233 #define ED_AREA_XOFFSET_1(n) ((n) != 0 ? \
234 ED_DRAWINGAREA_BORDER_SIZE : 0)
235 #define ED_AREA_YOFFSET_1(n) ((n) != 0 ? \
236 (ED_CHECKBUTTON_YSIZE - \
237 ED_DRAWINGAREA_TILE_SIZE) / 2 : 0)
239 #define ED_AREA_XOFFSET_2(n) (0)
240 #define ED_AREA_YOFFSET_2(n) ((n) == 3 ? \
241 ((n) - 1) * ED_DRAWINGAREA_TILE_SIZE / 2 : 0)
243 #define ED_AREA_SETTINGS_X(i) (ED_SETTINGS_X((i).x) + \
244 ED_SETTINGS_XOFF((i).xoffset) + \
245 ED_AREA_XOFFSET_1((i).x) - \
246 ED_AREA_XOFFSET_2((i).area_xsize))
247 #define ED_AREA_SETTINGS_Y(i) (ED_SETTINGS_Y((i).y) + \
248 ED_SETTINGS_YOFF((i).yoffset) + \
249 ED_AREA_YOFFSET_1((i).y) - \
250 ED_AREA_YOFFSET_2((i).area_ysize))
252 // values for element content drawing areas
253 #define ED_AREA_1X1_LSETTINGS_XPOS(n) ED_LEVEL_SETTINGS_XPOS(n)
254 #define ED_AREA_1X1_LSETTINGS_YPOS(n) ED_LEVEL_SETTINGS_YPOS(n)
255 #define ED_AREA_1X1_LSETTINGS_XOFF (0)
256 #define ED_AREA_1X1_LSETTINGS_YOFF (0)
258 #define ED_AREA_1X1_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
259 #define ED_AREA_1X1_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
260 #define ED_AREA_1X1_SETTINGS_XOFF (0)
261 #define ED_AREA_1X1_SETTINGS_YOFF (0)
263 #define ED_AREA_3X3_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
264 #define ED_AREA_3X3_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
265 #define ED_AREA_3X3_SETTINGS_XOFF (0)
266 #define ED_AREA_3X3_SETTINGS_YOFF (0)
269 #define ED_AREA_ELEMENT_CONTENT_XOFF(n) (n)
270 #define ED_AREA_ELEMENT_CONTENT_YOFF(n) (n)
273 #define ED_XPOS_YAM 0
274 #define ED_YPOS_YAM 5
275 #define ED_AREA_YAMYAM_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_YAM)
276 #define ED_AREA_YAMYAM_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_YAM)
277 #define ED_AREA_YAMYAM_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
278 #define ED_AREA_YAMYAM_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
279 #define ED_AREA_YAMYAM_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_YAM) + \
281 #define ED_AREA_YAMYAM_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_YAM) + \
282 ED_SETTINGS_YOFF(n) + \
283 ED_AREA_YOFFSET_1(ED_YPOS_YAM) - \
284 ED_AREA_YOFFSET_2(3))
286 // magic ball content
287 #define ED_XPOS_BALL 0
288 #define ED_YPOS_BALL 6
289 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_BALL)
290 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_BALL)
291 #define ED_AREA_MAGIC_BALL_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
292 #define ED_AREA_MAGIC_BALL_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
293 #define ED_AREA_MAGIC_BALL_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_BALL) + \
295 #define ED_AREA_MAGIC_BALL_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_BALL) + \
296 ED_SETTINGS_YOFF(n) + \
297 ED_AREA_YOFFSET_1(ED_YPOS_BALL) - \
298 ED_AREA_YOFFSET_2(3))
300 // values for scrolling gadgets for drawing area
301 #define ED_SCROLLBUTTON_XSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].width)
302 #define ED_SCROLLBUTTON_YSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].height)
304 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
305 #define ED_SCROLL_UP_YPOS (0)
306 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
307 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
308 #define ED_SCROLL_LEFT_XPOS (0)
309 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
310 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
311 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
312 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
313 ED_SCROLLBUTTON_XSIZE)
314 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
315 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
316 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
317 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
318 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
319 ED_SCROLLBUTTON_YSIZE)
320 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
321 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
323 // values for scrolling gadgets for element list
324 #define ED_SCROLLBUTTON2_XSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
325 #define ED_SCROLLBUTTON2_YSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
327 #define ED_SCROLL2_UP_XPOS (ED_ELEMENTLIST_XPOS + \
328 ED_ELEMENTLIST_BUTTONS_HORIZ * \
329 ED_ELEMENTLIST_XSIZE)
330 #define ED_SCROLL2_UP_YPOS ED_ELEMENTLIST_YPOS
331 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
332 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
333 ED_ELEMENTLIST_BUTTONS_VERT * \
334 ED_ELEMENTLIST_YSIZE - \
335 ED_SCROLLBUTTON2_YSIZE)
336 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
337 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
338 ED_SCROLLBUTTON2_YSIZE)
339 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
340 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
341 ED_ELEMENTLIST_YSIZE - \
342 2 * ED_SCROLLBUTTON2_YSIZE)
344 // values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText()
345 #define INFOTEXT_FONT FONT_TEXT_2
346 #define INFOTEXT_XSIZE SXSIZE
347 #define INFOTEXT_YSIZE getFontHeight(INFOTEXT_FONT)
348 #define INFOTEXT_YSIZE_FULL (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE)
349 #define INFOTEXT_X (editor.settings.tooltip.x)
350 #define INFOTEXT_Y (editor.settings.tooltip.y)
351 #define INFOTEXT_XY_REDEFINED (INFOTEXT_X != -1 || INFOTEXT_Y != -1)
352 #define INFOTEXT_XPOS SX + (INFOTEXT_XY_REDEFINED ? INFOTEXT_X : 0)
353 #define INFOTEXT_YPOS SY + (INFOTEXT_XY_REDEFINED ? INFOTEXT_Y : \
354 SYSIZE - INFOTEXT_YSIZE)
357 // ----------------------------------------------------------------------------
358 // editor gadget definitions
359 // ----------------------------------------------------------------------------
365 // drawing toolbox buttons
367 GADGET_ID_SINGLE_ITEMS,
368 GADGET_ID_CONNECTED_ITEMS,
372 GADGET_ID_FILLED_BOX,
375 GADGET_ID_FLOOD_FILL,
378 GADGET_ID_WRAP_RIGHT,
379 GADGET_ID_RANDOM_PLACEMENT,
380 GADGET_ID_GRAB_BRUSH,
382 GADGET_ID_PICK_ELEMENT,
391 GADGET_ID_CUSTOM_COPY_FROM,
392 GADGET_ID_CUSTOM_COPY_TO,
393 GADGET_ID_CUSTOM_EXCHANGE,
394 GADGET_ID_CUSTOM_COPY,
395 GADGET_ID_CUSTOM_PASTE,
397 GADGET_ID_PROPERTIES,
398 GADGET_ID_ELEMENT_LEFT,
399 GADGET_ID_ELEMENT_MIDDLE,
400 GADGET_ID_ELEMENT_RIGHT,
403 // counter gadget identifiers
405 GADGET_ID_SELECT_LEVEL_DOWN,
406 GADGET_ID_SELECT_LEVEL_TEXT,
407 GADGET_ID_SELECT_LEVEL_UP,
408 GADGET_ID_LEVEL_XSIZE_DOWN,
409 GADGET_ID_LEVEL_XSIZE_TEXT,
410 GADGET_ID_LEVEL_XSIZE_UP,
411 GADGET_ID_LEVEL_YSIZE_DOWN,
412 GADGET_ID_LEVEL_YSIZE_TEXT,
413 GADGET_ID_LEVEL_YSIZE_UP,
414 GADGET_ID_LEVEL_RANDOM_DOWN,
415 GADGET_ID_LEVEL_RANDOM_TEXT,
416 GADGET_ID_LEVEL_RANDOM_UP,
417 GADGET_ID_LEVEL_GEMSLIMIT_DOWN,
418 GADGET_ID_LEVEL_GEMSLIMIT_TEXT,
419 GADGET_ID_LEVEL_GEMSLIMIT_UP,
420 GADGET_ID_LEVEL_TIMELIMIT_DOWN,
421 GADGET_ID_LEVEL_TIMELIMIT_TEXT,
422 GADGET_ID_LEVEL_TIMELIMIT_UP,
423 GADGET_ID_LEVEL_TIMESCORE_DOWN,
424 GADGET_ID_LEVEL_TIMESCORE_TEXT,
425 GADGET_ID_LEVEL_TIMESCORE_UP,
426 GADGET_ID_LEVEL_RANDOM_SEED_DOWN,
427 GADGET_ID_LEVEL_RANDOM_SEED_TEXT,
428 GADGET_ID_LEVEL_RANDOM_SEED_UP,
429 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN,
430 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT,
431 GADGET_ID_LEVELSET_NUM_LEVELS_UP,
432 GADGET_ID_BD_CYCLE_DELAY_MS_DOWN,
433 GADGET_ID_BD_CYCLE_DELAY_MS_TEXT,
434 GADGET_ID_BD_CYCLE_DELAY_MS_UP,
435 GADGET_ID_BD_CYCLE_DELAY_C64_DOWN,
436 GADGET_ID_BD_CYCLE_DELAY_C64_TEXT,
437 GADGET_ID_BD_CYCLE_DELAY_C64_UP,
438 GADGET_ID_BD_HATCHING_DELAY_CYCLES_DOWN,
439 GADGET_ID_BD_HATCHING_DELAY_CYCLES_TEXT,
440 GADGET_ID_BD_HATCHING_DELAY_CYCLES_UP,
441 GADGET_ID_BD_HATCHING_DELAY_SECONDS_DOWN,
442 GADGET_ID_BD_HATCHING_DELAY_SECONDS_TEXT,
443 GADGET_ID_BD_HATCHING_DELAY_SECONDS_UP,
444 GADGET_ID_ELEMENT_VALUE1_DOWN,
445 GADGET_ID_ELEMENT_VALUE1_TEXT,
446 GADGET_ID_ELEMENT_VALUE1_UP,
447 GADGET_ID_ELEMENT_VALUE2_DOWN,
448 GADGET_ID_ELEMENT_VALUE2_TEXT,
449 GADGET_ID_ELEMENT_VALUE2_UP,
450 GADGET_ID_ELEMENT_VALUE3_DOWN,
451 GADGET_ID_ELEMENT_VALUE3_TEXT,
452 GADGET_ID_ELEMENT_VALUE3_UP,
453 GADGET_ID_ELEMENT_VALUE4_DOWN,
454 GADGET_ID_ELEMENT_VALUE4_TEXT,
455 GADGET_ID_ELEMENT_VALUE4_UP,
456 GADGET_ID_YAMYAM_CONTENT_DOWN,
457 GADGET_ID_YAMYAM_CONTENT_TEXT,
458 GADGET_ID_YAMYAM_CONTENT_UP,
459 GADGET_ID_BALL_CONTENT_DOWN,
460 GADGET_ID_BALL_CONTENT_TEXT,
461 GADGET_ID_BALL_CONTENT_UP,
462 GADGET_ID_ANDROID_CONTENT_DOWN,
463 GADGET_ID_ANDROID_CONTENT_TEXT,
464 GADGET_ID_ANDROID_CONTENT_UP,
465 GADGET_ID_ENVELOPE_XSIZE_DOWN,
466 GADGET_ID_ENVELOPE_XSIZE_TEXT,
467 GADGET_ID_ENVELOPE_XSIZE_UP,
468 GADGET_ID_ENVELOPE_YSIZE_DOWN,
469 GADGET_ID_ENVELOPE_YSIZE_TEXT,
470 GADGET_ID_ENVELOPE_YSIZE_UP,
471 GADGET_ID_INVENTORY_SIZE_DOWN,
472 GADGET_ID_INVENTORY_SIZE_TEXT,
473 GADGET_ID_INVENTORY_SIZE_UP,
474 GADGET_ID_MM_BALL_CONTENT_DOWN,
475 GADGET_ID_MM_BALL_CONTENT_TEXT,
476 GADGET_ID_MM_BALL_CONTENT_UP,
477 GADGET_ID_CUSTOM_SCORE_DOWN,
478 GADGET_ID_CUSTOM_SCORE_TEXT,
479 GADGET_ID_CUSTOM_SCORE_UP,
480 GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
481 GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
482 GADGET_ID_CUSTOM_GEMCOUNT_UP,
483 GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
484 GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
485 GADGET_ID_CUSTOM_VALUE_FIX_UP,
486 GADGET_ID_CUSTOM_VALUE_RND_DOWN,
487 GADGET_ID_CUSTOM_VALUE_RND_TEXT,
488 GADGET_ID_CUSTOM_VALUE_RND_UP,
489 GADGET_ID_PUSH_DELAY_FIX_DOWN,
490 GADGET_ID_PUSH_DELAY_FIX_TEXT,
491 GADGET_ID_PUSH_DELAY_FIX_UP,
492 GADGET_ID_PUSH_DELAY_RND_DOWN,
493 GADGET_ID_PUSH_DELAY_RND_TEXT,
494 GADGET_ID_PUSH_DELAY_RND_UP,
495 GADGET_ID_DROP_DELAY_FIX_DOWN,
496 GADGET_ID_DROP_DELAY_FIX_TEXT,
497 GADGET_ID_DROP_DELAY_FIX_UP,
498 GADGET_ID_DROP_DELAY_RND_DOWN,
499 GADGET_ID_DROP_DELAY_RND_TEXT,
500 GADGET_ID_DROP_DELAY_RND_UP,
501 GADGET_ID_MOVE_DELAY_FIX_DOWN,
502 GADGET_ID_MOVE_DELAY_FIX_TEXT,
503 GADGET_ID_MOVE_DELAY_FIX_UP,
504 GADGET_ID_MOVE_DELAY_RND_DOWN,
505 GADGET_ID_MOVE_DELAY_RND_TEXT,
506 GADGET_ID_MOVE_DELAY_RND_UP,
507 GADGET_ID_STEP_DELAY_FIX_DOWN,
508 GADGET_ID_STEP_DELAY_FIX_TEXT,
509 GADGET_ID_STEP_DELAY_FIX_UP,
510 GADGET_ID_STEP_DELAY_RND_DOWN,
511 GADGET_ID_STEP_DELAY_RND_TEXT,
512 GADGET_ID_STEP_DELAY_RND_UP,
513 GADGET_ID_EXPLOSION_DELAY_DOWN,
514 GADGET_ID_EXPLOSION_DELAY_TEXT,
515 GADGET_ID_EXPLOSION_DELAY_UP,
516 GADGET_ID_IGNITION_DELAY_DOWN,
517 GADGET_ID_IGNITION_DELAY_TEXT,
518 GADGET_ID_IGNITION_DELAY_UP,
519 GADGET_ID_CHANGE_DELAY_FIX_DOWN,
520 GADGET_ID_CHANGE_DELAY_FIX_TEXT,
521 GADGET_ID_CHANGE_DELAY_FIX_UP,
522 GADGET_ID_CHANGE_DELAY_RND_DOWN,
523 GADGET_ID_CHANGE_DELAY_RND_TEXT,
524 GADGET_ID_CHANGE_DELAY_RND_UP,
525 GADGET_ID_CHANGE_CONT_RND_DOWN,
526 GADGET_ID_CHANGE_CONT_RND_TEXT,
527 GADGET_ID_CHANGE_CONT_RND_UP,
528 GADGET_ID_GROUP_CONTENT_DOWN,
529 GADGET_ID_GROUP_CONTENT_TEXT,
530 GADGET_ID_GROUP_CONTENT_UP,
532 // drawing area identifiers
534 GADGET_ID_DRAWING_LEVEL,
535 GADGET_ID_YAMYAM_CONTENT_0,
536 GADGET_ID_YAMYAM_CONTENT_1,
537 GADGET_ID_YAMYAM_CONTENT_2,
538 GADGET_ID_YAMYAM_CONTENT_3,
539 GADGET_ID_YAMYAM_CONTENT_4,
540 GADGET_ID_YAMYAM_CONTENT_5,
541 GADGET_ID_YAMYAM_CONTENT_6,
542 GADGET_ID_YAMYAM_CONTENT_7,
543 GADGET_ID_MAGIC_BALL_CONTENT_0,
544 GADGET_ID_MAGIC_BALL_CONTENT_1,
545 GADGET_ID_MAGIC_BALL_CONTENT_2,
546 GADGET_ID_MAGIC_BALL_CONTENT_3,
547 GADGET_ID_MAGIC_BALL_CONTENT_4,
548 GADGET_ID_MAGIC_BALL_CONTENT_5,
549 GADGET_ID_MAGIC_BALL_CONTENT_6,
550 GADGET_ID_MAGIC_BALL_CONTENT_7,
551 GADGET_ID_ANDROID_CONTENT,
552 GADGET_ID_AMOEBA_CONTENT,
553 GADGET_ID_START_ELEMENT,
554 GADGET_ID_ARTWORK_ELEMENT,
555 GADGET_ID_EXPLOSION_ELEMENT,
556 GADGET_ID_INVENTORY_CONTENT,
557 GADGET_ID_MM_BALL_CONTENT,
558 GADGET_ID_CUSTOM_GRAPHIC,
559 GADGET_ID_CUSTOM_CONTENT,
560 GADGET_ID_CUSTOM_MOVE_ENTER,
561 GADGET_ID_CUSTOM_MOVE_LEAVE,
562 GADGET_ID_CUSTOM_CHANGE_TARGET,
563 GADGET_ID_CUSTOM_CHANGE_CONTENT,
564 GADGET_ID_CUSTOM_CHANGE_TRIGGER,
565 GADGET_ID_CUSTOM_CHANGE_ACTION,
566 GADGET_ID_GROUP_CONTENT,
567 GADGET_ID_RANDOM_BACKGROUND,
569 // text input identifiers
571 GADGET_ID_LEVEL_NAME,
572 GADGET_ID_LEVEL_AUTHOR,
573 GADGET_ID_LEVELSET_NAME,
574 GADGET_ID_LEVELSET_AUTHOR,
575 GADGET_ID_ELEMENT_NAME,
577 // text area identifiers
579 GADGET_ID_ENVELOPE_INFO,
581 // selectbox identifiers
583 GADGET_ID_TIME_OR_STEPS,
584 GADGET_ID_TIME_SCORE_BASE,
585 GADGET_ID_GAME_ENGINE_TYPE,
586 GADGET_ID_BD_SCHEDULING_TYPE,
587 GADGET_ID_LEVELSET_SAVE_MODE,
588 GADGET_ID_WIND_DIRECTION,
589 GADGET_ID_PLAYER_SPEED,
590 GADGET_ID_MM_BALL_CHOICE_MODE,
591 GADGET_ID_CUSTOM_WALK_TO_ACTION,
592 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
593 GADGET_ID_CUSTOM_DEADLINESS,
594 GADGET_ID_CUSTOM_MOVE_PATTERN,
595 GADGET_ID_CUSTOM_MOVE_DIRECTION,
596 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
597 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
598 GADGET_ID_CUSTOM_SMASH_TARGETS,
599 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
600 GADGET_ID_CUSTOM_ACCESS_TYPE,
601 GADGET_ID_CUSTOM_ACCESS_LAYER,
602 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
603 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
604 GADGET_ID_CHANGE_TIME_UNITS,
605 GADGET_ID_CHANGE_DIRECT_ACTION,
606 GADGET_ID_CHANGE_OTHER_ACTION,
607 GADGET_ID_CHANGE_SIDE,
608 GADGET_ID_CHANGE_PLAYER,
609 GADGET_ID_CHANGE_PAGE,
610 GADGET_ID_CHANGE_REPLACE_WHEN,
611 GADGET_ID_ACTION_TYPE,
612 GADGET_ID_ACTION_MODE,
613 GADGET_ID_ACTION_ARG,
614 GADGET_ID_SELECT_CHANGE_PAGE,
615 GADGET_ID_GROUP_CHOICE_MODE,
617 // textbutton identifiers
619 GADGET_ID_LEVELCONFIG_LEVEL,
620 GADGET_ID_LEVELCONFIG_LEVELSET,
621 GADGET_ID_LEVELCONFIG_EDITOR,
622 GADGET_ID_LEVELCONFIG_ENGINE,
623 GADGET_ID_PROPERTIES_INFO,
624 GADGET_ID_PROPERTIES_CONFIG,
625 GADGET_ID_PROPERTIES_CONFIG_1,
626 GADGET_ID_PROPERTIES_CONFIG_2,
627 GADGET_ID_PROPERTIES_CHANGE,
628 GADGET_ID_SAVE_AS_TEMPLATE_1,
629 GADGET_ID_SAVE_AS_TEMPLATE_2,
630 GADGET_ID_SAVE_LEVELSET,
631 GADGET_ID_ADD_CHANGE_PAGE,
632 GADGET_ID_DEL_CHANGE_PAGE,
634 // graphicbutton identifiers
636 GADGET_ID_PREV_CHANGE_PAGE,
637 GADGET_ID_NEXT_CHANGE_PAGE,
638 GADGET_ID_COPY_CHANGE_PAGE,
639 GADGET_ID_PASTE_CHANGE_PAGE,
641 // gadgets for scrolling of drawing area
644 GADGET_ID_SCROLL_DOWN,
645 GADGET_ID_SCROLL_LEFT,
646 GADGET_ID_SCROLL_RIGHT,
647 GADGET_ID_SCROLL_HORIZONTAL,
648 GADGET_ID_SCROLL_VERTICAL,
650 // gadgets for scrolling element list
652 GADGET_ID_SCROLL_LIST_UP,
653 GADGET_ID_SCROLL_LIST_DOWN,
654 GADGET_ID_SCROLL_LIST_VERTICAL,
656 // checkbuttons/radiobuttons for level/element properties
658 GADGET_ID_AUTO_COUNT_GEMS,
659 GADGET_ID_RATE_TIME_OVER_SCORE,
660 GADGET_ID_USE_LEVELSET_ARTWORK,
661 GADGET_ID_COPY_LEVEL_TEMPLATE,
662 GADGET_ID_RANDOM_PERCENTAGE,
663 GADGET_ID_RANDOM_QUANTITY,
664 GADGET_ID_RANDOM_RESTRICTED,
665 GADGET_ID_BD_INTERMISSION,
666 GADGET_ID_BD_PAL_TIMING,
667 GADGET_ID_STICK_ELEMENT,
668 GADGET_ID_EM_SLIPPERY_GEMS,
669 GADGET_ID_EM_EXPLODES_BY_FIRE,
670 GADGET_ID_USE_SPRING_BUG,
671 GADGET_ID_USE_TIME_ORB_BUG,
672 GADGET_ID_USE_LIFE_BUGS,
673 GADGET_ID_RANDOM_BALL_CONTENT,
674 GADGET_ID_INITIAL_BALL_ACTIVE,
675 GADGET_ID_GROW_INTO_DIGGABLE,
676 GADGET_ID_SB_FIELDS_NEEDED,
677 GADGET_ID_SB_OBJECTS_NEEDED,
678 GADGET_ID_AUTO_EXIT_SOKOBAN,
679 GADGET_ID_SOLVED_BY_ONE_PLAYER,
680 GADGET_ID_FINISH_DIG_COLLECT,
681 GADGET_ID_KEEP_WALKABLE_CE,
682 GADGET_ID_CONTINUOUS_SNAPPING,
683 GADGET_ID_BLOCK_SNAP_FIELD,
684 GADGET_ID_BLOCK_LAST_FIELD,
685 GADGET_ID_SP_BLOCK_LAST_FIELD,
686 GADGET_ID_INSTANT_RELOCATION,
687 GADGET_ID_SHIFTED_RELOCATION,
688 GADGET_ID_LAZY_RELOCATION,
689 GADGET_ID_USE_START_ELEMENT,
690 GADGET_ID_USE_ARTWORK_ELEMENT,
691 GADGET_ID_USE_EXPLOSION_ELEMENT,
692 GADGET_ID_INITIAL_GRAVITY,
693 GADGET_ID_USE_INITIAL_INVENTORY,
694 GADGET_ID_CAN_PASS_TO_WALKABLE,
695 GADGET_ID_CAN_FALL_INTO_ACID,
696 GADGET_ID_CAN_MOVE_INTO_ACID,
697 GADGET_ID_DONT_COLLIDE_WITH,
698 GADGET_ID_BD_DIAGONAL_MOVEMENTS,
699 GADGET_ID_ENVELOPE_AUTOWRAP,
700 GADGET_ID_ENVELOPE_CENTERED,
701 GADGET_ID_MM_LASER_RED,
702 GADGET_ID_MM_LASER_GREEN,
703 GADGET_ID_MM_LASER_BLUE,
704 GADGET_ID_DF_LASER_RED,
705 GADGET_ID_DF_LASER_GREEN,
706 GADGET_ID_DF_LASER_BLUE,
707 GADGET_ID_ROTATE_MM_BALL_CONTENT,
708 GADGET_ID_EXPLODE_MM_BALL,
709 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
710 GADGET_ID_CUSTOM_CAN_EXPLODE,
711 GADGET_ID_CUSTOM_EXPLODE_FIRE,
712 GADGET_ID_CUSTOM_EXPLODE_SMASH,
713 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
714 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
715 GADGET_ID_CUSTOM_DEADLY,
716 GADGET_ID_CUSTOM_CAN_MOVE,
717 GADGET_ID_CUSTOM_CAN_FALL,
718 GADGET_ID_CUSTOM_CAN_SMASH,
719 GADGET_ID_CUSTOM_SLIPPERY,
720 GADGET_ID_CUSTOM_ACCESSIBLE,
721 GADGET_ID_CUSTOM_GRAV_REACHABLE,
722 GADGET_ID_CUSTOM_USE_LAST_VALUE,
723 GADGET_ID_CUSTOM_USE_GRAPHIC,
724 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
725 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
726 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
727 GADGET_ID_CUSTOM_CAN_CHANGE,
728 GADGET_ID_CHANGE_USE_CONTENT,
729 GADGET_ID_CHANGE_USE_EXPLOSION,
730 GADGET_ID_CHANGE_ONLY_COMPLETE,
731 GADGET_ID_CHANGE_USE_RANDOM,
732 GADGET_ID_CHANGE_HAS_ACTION,
733 GADGET_ID_CHANGE_DELAY,
734 GADGET_ID_CHANGE_BY_DIRECT_ACT,
735 GADGET_ID_CHANGE_BY_OTHER_ACT,
737 NUM_STATIC_GADGET_IDS
740 // gadgets for buttons in element list (dynamic)
741 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
742 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
743 ED_NUM_ELEMENTLIST_BUTTONS - 1)
745 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
747 // radio button numbers
751 RADIO_NR_DRAWING_TOOLBOX,
752 RADIO_NR_RANDOM_ELEMENTS
755 // values for counter gadgets
758 ED_COUNTER_ID_SELECT_LEVEL,
759 ED_COUNTER_ID_LEVEL_XSIZE,
760 ED_COUNTER_ID_LEVEL_YSIZE,
761 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
762 ED_COUNTER_ID_LEVEL_TIMELIMIT,
763 ED_COUNTER_ID_LEVEL_TIMESCORE,
764 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
765 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
766 ED_COUNTER_ID_LEVEL_RANDOM,
767 ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
768 ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
769 ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES,
770 ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS,
771 ED_COUNTER_ID_ELEMENT_VALUE1,
772 ED_COUNTER_ID_ELEMENT_VALUE2,
773 ED_COUNTER_ID_ELEMENT_VALUE3,
774 ED_COUNTER_ID_ELEMENT_VALUE4,
775 ED_COUNTER_ID_YAMYAM_CONTENT,
776 ED_COUNTER_ID_BALL_CONTENT,
777 ED_COUNTER_ID_ANDROID_CONTENT,
778 ED_COUNTER_ID_ENVELOPE_XSIZE,
779 ED_COUNTER_ID_ENVELOPE_YSIZE,
780 ED_COUNTER_ID_INVENTORY_SIZE,
781 ED_COUNTER_ID_MM_BALL_CONTENT,
782 ED_COUNTER_ID_CUSTOM_SCORE,
783 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
784 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
785 ED_COUNTER_ID_CUSTOM_VALUE_RND,
786 ED_COUNTER_ID_PUSH_DELAY_FIX,
787 ED_COUNTER_ID_PUSH_DELAY_RND,
788 ED_COUNTER_ID_DROP_DELAY_FIX,
789 ED_COUNTER_ID_DROP_DELAY_RND,
790 ED_COUNTER_ID_MOVE_DELAY_FIX,
791 ED_COUNTER_ID_MOVE_DELAY_RND,
792 ED_COUNTER_ID_STEP_DELAY_FIX,
793 ED_COUNTER_ID_STEP_DELAY_RND,
794 ED_COUNTER_ID_EXPLOSION_DELAY,
795 ED_COUNTER_ID_IGNITION_DELAY,
796 ED_COUNTER_ID_GROUP_CONTENT,
797 ED_COUNTER_ID_CHANGE_DELAY_FIX,
798 ED_COUNTER_ID_CHANGE_DELAY_RND,
799 ED_COUNTER_ID_CHANGE_CONT_RND,
801 ED_NUM_COUNTERBUTTONS
804 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
805 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
806 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
807 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
808 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
809 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
811 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
812 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
813 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
814 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
815 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
816 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
818 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
819 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
821 // values for scrollbutton gadgets
824 ED_SCROLLBUTTON_ID_AREA_UP,
825 ED_SCROLLBUTTON_ID_AREA_DOWN,
826 ED_SCROLLBUTTON_ID_AREA_LEFT,
827 ED_SCROLLBUTTON_ID_AREA_RIGHT,
828 ED_SCROLLBUTTON_ID_LIST_UP,
829 ED_SCROLLBUTTON_ID_LIST_DOWN,
834 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
835 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
837 // values for scrollbar gadgets
840 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
841 ED_SCROLLBAR_ID_AREA_VERTICAL,
842 ED_SCROLLBAR_ID_LIST_VERTICAL,
847 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
848 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
850 // values for text input gadgets
853 ED_TEXTINPUT_ID_LEVEL_NAME,
854 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
855 ED_TEXTINPUT_ID_LEVELSET_NAME,
856 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
857 ED_TEXTINPUT_ID_ELEMENT_NAME,
862 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
863 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
865 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
866 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
868 // values for text area gadgets
871 ED_TEXTAREA_ID_ENVELOPE_INFO,
876 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
877 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
879 // values for selectbox gadgets
882 ED_SELECTBOX_ID_TIME_OR_STEPS,
883 ED_SELECTBOX_ID_TIME_SCORE_BASE,
884 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
885 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
886 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
887 ED_SELECTBOX_ID_WIND_DIRECTION,
888 ED_SELECTBOX_ID_PLAYER_SPEED,
889 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
890 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
891 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
892 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
893 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
894 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
895 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
896 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
897 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
898 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
899 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
900 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
901 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
902 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
903 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
904 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
905 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
906 ED_SELECTBOX_ID_CHANGE_SIDE,
907 ED_SELECTBOX_ID_CHANGE_PLAYER,
908 ED_SELECTBOX_ID_CHANGE_PAGE,
909 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
910 ED_SELECTBOX_ID_ACTION_TYPE,
911 ED_SELECTBOX_ID_ACTION_MODE,
912 ED_SELECTBOX_ID_ACTION_ARG,
913 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
914 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
919 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
920 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
922 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
923 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
925 #define ED_SELECTBOX_ID_ENGINE_FIRST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
926 #define ED_SELECTBOX_ID_ENGINE_LAST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
928 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
929 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
930 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
931 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
932 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
933 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
935 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
936 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
938 // values for textbutton gadgets
941 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
942 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
943 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
944 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
945 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
946 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
947 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
948 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
949 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
950 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
951 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
952 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
953 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
954 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
959 #define ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
960 #define ED_TAB_BUTTON_ID_LEVELCONFIG_LAST ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
962 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
963 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
965 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
966 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
968 // values for graphicbutton gadgets
971 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
972 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
973 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
974 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
976 ED_NUM_GRAPHICBUTTONS
979 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
980 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
982 // values for checkbutton gadgets
985 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
986 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
987 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
988 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
989 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
990 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
991 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
992 ED_CHECKBUTTON_ID_BD_INTERMISSION,
993 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
994 ED_CHECKBUTTON_ID_STICK_ELEMENT,
995 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
996 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
997 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
998 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
999 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
1000 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
1001 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
1002 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
1003 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
1004 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
1005 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
1006 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
1007 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
1008 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
1009 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
1010 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
1011 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
1012 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
1013 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
1014 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
1015 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
1016 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
1017 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
1018 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
1019 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
1020 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
1021 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
1022 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
1023 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
1024 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
1025 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
1026 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
1027 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
1028 ED_CHECKBUTTON_ID_MM_LASER_RED,
1029 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
1030 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1031 ED_CHECKBUTTON_ID_DF_LASER_RED,
1032 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1033 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1034 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
1035 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
1036 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1037 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1038 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1039 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1040 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1041 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1042 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1043 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1044 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1045 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1046 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1047 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1048 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1049 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1050 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1051 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1052 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1053 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1054 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1055 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1056 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1057 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1058 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1059 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1060 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1065 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1066 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1068 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1069 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1071 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1072 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1074 #define ED_CHECKBUTTON_ID_ENGINE_FIRST ED_CHECKBUTTON_ID_BD_INTERMISSION
1075 #define ED_CHECKBUTTON_ID_ENGINE_LAST ED_CHECKBUTTON_ID_BD_PAL_TIMING
1077 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1078 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1079 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1080 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1081 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1082 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1084 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1085 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1087 // values for radiobutton gadgets
1090 ED_RADIOBUTTON_ID_PERCENTAGE,
1091 ED_RADIOBUTTON_ID_QUANTITY,
1096 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1097 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1099 // values for drawing area gadgets
1102 ED_DRAWING_ID_DRAWING_LEVEL,
1103 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1104 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1105 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1106 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1107 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1108 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1109 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1110 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1111 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1112 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1113 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1114 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1115 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1116 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1117 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1118 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1119 ED_DRAWING_ID_ANDROID_CONTENT,
1120 ED_DRAWING_ID_AMOEBA_CONTENT,
1121 ED_DRAWING_ID_START_ELEMENT,
1122 ED_DRAWING_ID_ARTWORK_ELEMENT,
1123 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1124 ED_DRAWING_ID_INVENTORY_CONTENT,
1125 ED_DRAWING_ID_MM_BALL_CONTENT,
1126 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1127 ED_DRAWING_ID_CUSTOM_CONTENT,
1128 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1129 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1130 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1131 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1132 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1133 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1134 ED_DRAWING_ID_GROUP_CONTENT,
1135 ED_DRAWING_ID_RANDOM_BACKGROUND,
1137 ED_NUM_DRAWING_AREAS
1140 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1141 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1144 // ----------------------------------------------------------------------------
1145 // some internally used definitions
1146 // ----------------------------------------------------------------------------
1148 // values for CopyLevelToUndoBuffer()
1149 #define UNDO_IMMEDIATE 0
1150 #define UNDO_ACCUMULATE 1
1152 // values for scrollbars
1153 #define ED_SCROLL_NO 0
1154 #define ED_SCROLL_LEFT 1
1155 #define ED_SCROLL_RIGHT 2
1156 #define ED_SCROLL_UP 4
1157 #define ED_SCROLL_DOWN 8
1159 // screens in the level editor
1160 #define ED_MODE_DRAWING 0
1161 #define ED_MODE_LEVELCONFIG 1
1162 #define ED_MODE_PROPERTIES 2
1163 #define ED_MODE_PALETTE 3
1165 // sub-screens in the global settings section
1166 #define ED_MODE_LEVELCONFIG_LEVEL ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
1167 #define ED_MODE_LEVELCONFIG_LEVELSET ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET
1168 #define ED_MODE_LEVELCONFIG_EDITOR ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
1169 #define ED_MODE_LEVELCONFIG_ENGINE ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
1171 // sub-screens in the element properties section
1172 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1173 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1174 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1175 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1176 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1178 // how many steps can be cancelled
1179 #define NUM_UNDO_STEPS (64 + 1)
1181 // values for elements with score for certain actions
1183 #define MAX_SCORE 999
1185 // values for elements with count for collecting
1186 #define MIN_COLLECT_COUNT 0
1187 #define MAX_COLLECT_COUNT 999
1189 // values for random placement
1190 #define RANDOM_USE_PERCENTAGE 0
1191 #define RANDOM_USE_QUANTITY 1
1193 // values for level set save mode
1194 #define LEVELSET_SAVE_MODE_UPDATE 0
1195 #define LEVELSET_SAVE_MODE_CREATE 1
1197 // default value for element tile size in drawing area
1198 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1199 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1202 // ----------------------------------------------------------------------------
1203 // some internally used data structure definitions
1204 // ----------------------------------------------------------------------------
1210 struct XYTileSize *pos;
1214 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1216 // note: some additional characters are already reserved for "cheat mode"
1217 // shortcuts (":XYZ" style) -- for details, see "events.c"
1219 // ---------- toolbox control buttons ---------------------------------------
1222 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1223 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1224 "draw single items", 's'
1227 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1228 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1229 "draw connected items", 'd'
1232 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1233 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1237 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1238 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1242 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1243 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1244 "draw outline rectangles", 'r'
1247 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1248 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1249 "draw filled rectangles", 'R'
1252 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1253 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1254 "wrap (rotate) level up", 0
1257 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1258 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1259 "enter text elements", 't'
1262 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1263 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1267 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1268 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1269 "wrap (rotate) level left", 0
1272 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1273 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1274 "zoom level tile size", '+'
1277 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1278 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1279 "wrap (rotate) level right", 0
1282 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1283 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1284 "random element placement", 0
1287 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1288 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1292 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1293 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1294 "wrap (rotate) level down", 0
1297 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1298 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1299 "pick drawing element", ','
1302 // ---------- level control buttons -----------------------------------------
1305 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1306 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1307 "undo/redo last operation", 'u'
1310 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_CONF,
1311 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1312 "level and editor settings", 'I'
1315 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1316 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1320 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1321 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1325 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1326 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1330 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1331 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1332 "exit level editor", 'E'
1335 // ---------- CE and GE control buttons -------------------------------------
1338 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1339 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1340 "copy settings from other element", 0
1343 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1344 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1345 "copy settings to other element", 0
1348 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1349 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1350 "exchange element with other element", 0
1353 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1354 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1355 "copy settings from this element", 0
1358 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1359 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1360 "paste settings to this element", 0
1363 // ---------- palette control buttons ---------------------------------------
1366 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1367 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1368 "properties of drawing element", 'p'
1371 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1372 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1373 "properties of drawing element 1", '1'
1376 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1377 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1378 "properties of drawing element 2", '2'
1381 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1382 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1383 "properties of drawing element 3", '3'
1386 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1387 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1388 "show list of elements", 'e'
1392 static int random_placement_value = 10;
1393 static int random_placement_method = RANDOM_USE_QUANTITY;
1394 static int random_placement_background_element = EL_SAND;
1395 static boolean random_placement_background_restricted = FALSE;
1396 static boolean stick_element_properties_window = FALSE;
1397 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1398 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1399 static struct ElementChangeInfo custom_element_change;
1400 static struct ElementGroupInfo group_element_info;
1401 static struct ElementInfo custom_element;
1403 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1404 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1405 static int levelset_num_levels = 100;
1406 static boolean levelset_use_levelset_artwork = FALSE;
1407 static boolean levelset_copy_level_template = FALSE;
1408 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1414 int min_value, max_value;
1415 int gadget_id_down, gadget_id_up;
1417 int gadget_id_align;
1419 char *text_above, *text_left, *text_right;
1420 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1422 // ---------- current level number ------------------------------------------
1425 ED_COUNTER_ID_SELECT_LEVEL,
1426 -1, -1, // these values are not constant, but can change at runtime
1428 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1429 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1434 // ---------- level and editor settings -------------------------------------
1437 ED_COUNTER_ID_LEVEL_XSIZE,
1438 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1439 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1440 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1441 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1443 "playfield size:", NULL, "width",
1446 ED_COUNTER_ID_LEVEL_YSIZE,
1447 -1, ED_LEVEL_SETTINGS_YPOS(4),
1448 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1449 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1450 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1452 NULL, " ", "height",
1455 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
1456 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1458 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1459 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1461 NULL, "number of gems to collect:", NULL
1464 ED_COUNTER_ID_LEVEL_TIMELIMIT,
1465 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1467 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1468 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1470 "time or step limit to solve level:", NULL, NULL
1473 ED_COUNTER_ID_LEVEL_TIMESCORE,
1474 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1476 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1477 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1478 &level.score[SC_TIME_BONUS],
1479 "score for time or steps left:", NULL, NULL
1482 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
1483 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1485 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1486 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1488 NULL, "random seed:", "(0 => random)"
1491 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
1492 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1494 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1495 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1496 &levelset_num_levels,
1497 "number of levels:", NULL, NULL,
1500 ED_COUNTER_ID_LEVEL_RANDOM,
1501 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1503 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1504 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1505 &random_placement_value,
1506 "random element placement:", NULL, "in"
1509 ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
1510 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3),
1512 GADGET_ID_BD_CYCLE_DELAY_MS_DOWN, GADGET_ID_BD_CYCLE_DELAY_MS_UP,
1513 GADGET_ID_BD_CYCLE_DELAY_MS_TEXT, GADGET_ID_NONE,
1514 &level.bd_cycle_delay_ms,
1515 NULL, NULL, "game cycle delay (ms)"
1518 ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
1519 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3),
1521 GADGET_ID_BD_CYCLE_DELAY_C64_DOWN, GADGET_ID_BD_CYCLE_DELAY_C64_UP,
1522 GADGET_ID_BD_CYCLE_DELAY_C64_TEXT, GADGET_ID_NONE,
1523 &level.bd_cycle_delay_c64,
1524 NULL, NULL, "game cycle delay (C64-style)"
1527 ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES,
1528 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1530 GADGET_ID_BD_HATCHING_DELAY_CYCLES_DOWN, GADGET_ID_BD_HATCHING_DELAY_CYCLES_UP,
1531 GADGET_ID_BD_HATCHING_DELAY_CYCLES_TEXT, GADGET_ID_NONE,
1532 &level.bd_hatching_delay_cycles,
1533 NULL, NULL, "hatching delay (cycles)"
1536 ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS,
1537 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1539 GADGET_ID_BD_HATCHING_DELAY_SECONDS_DOWN, GADGET_ID_BD_HATCHING_DELAY_SECONDS_UP,
1540 GADGET_ID_BD_HATCHING_DELAY_SECONDS_TEXT, GADGET_ID_NONE,
1541 &level.bd_hatching_delay_seconds,
1542 NULL, NULL, "hatching delay (seconds)"
1545 // ---------- element settings: configure (various elements) ----------------
1548 ED_COUNTER_ID_ELEMENT_VALUE1,
1549 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1550 MIN_SCORE, MAX_SCORE,
1551 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1552 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1553 NULL, // will be set when used
1557 ED_COUNTER_ID_ELEMENT_VALUE2,
1558 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1559 MIN_SCORE, MAX_SCORE,
1560 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1561 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1562 NULL, // will be set when used
1566 ED_COUNTER_ID_ELEMENT_VALUE3,
1567 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1568 MIN_SCORE, MAX_SCORE,
1569 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1570 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1571 NULL, // will be set when used
1575 ED_COUNTER_ID_ELEMENT_VALUE4,
1576 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1577 MIN_SCORE, MAX_SCORE,
1578 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1579 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1580 NULL, // will be set when used
1584 ED_COUNTER_ID_YAMYAM_CONTENT,
1585 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1586 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1587 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1588 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1589 &level.num_yamyam_contents,
1590 NULL, NULL, "number of content areas"
1593 ED_COUNTER_ID_BALL_CONTENT,
1594 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1595 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1596 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1597 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1598 &level.num_ball_contents,
1599 NULL, NULL, "number of content areas"
1602 ED_COUNTER_ID_ANDROID_CONTENT,
1603 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1604 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1605 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1606 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1607 &level.num_android_clone_elements,
1608 NULL, NULL, "number of clonable elements"
1611 ED_COUNTER_ID_ENVELOPE_XSIZE,
1612 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1613 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1614 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1615 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1616 NULL, // will be set when used
1617 NULL, NULL, "width",
1620 ED_COUNTER_ID_ENVELOPE_YSIZE,
1621 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1622 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1623 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1624 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1625 NULL, // will be set when used
1626 NULL, " ", "height",
1629 ED_COUNTER_ID_INVENTORY_SIZE,
1630 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1631 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1632 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1633 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1634 &level.initial_inventory_size[0],
1635 NULL, NULL, "number of inventory elements"
1638 ED_COUNTER_ID_MM_BALL_CONTENT,
1639 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1640 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1641 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1642 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1643 &level.num_mm_ball_contents,
1644 NULL, NULL, "number of content elements"
1647 // ---------- element settings: configure 1 (custom elements) ---------------
1650 ED_COUNTER_ID_CUSTOM_SCORE,
1651 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1652 MIN_SCORE, MAX_SCORE,
1653 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1654 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1655 &custom_element.collect_score_initial,
1656 NULL, "CE score", " "
1659 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
1660 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1661 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1662 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1663 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1664 &custom_element.collect_count_initial,
1665 NULL, "CE count", NULL
1668 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
1669 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1671 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1672 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1673 &custom_element.ce_value_fixed_initial,
1674 NULL, "CE value", NULL
1677 ED_COUNTER_ID_CUSTOM_VALUE_RND,
1678 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1680 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1681 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1682 &custom_element.ce_value_random_initial,
1683 NULL, "+random", NULL
1686 ED_COUNTER_ID_PUSH_DELAY_FIX,
1687 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1689 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1690 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1691 &custom_element.push_delay_fixed,
1692 NULL, "push delay", NULL
1695 ED_COUNTER_ID_PUSH_DELAY_RND,
1696 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1698 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1699 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1700 &custom_element.push_delay_random,
1701 NULL, "+random", NULL
1704 ED_COUNTER_ID_DROP_DELAY_FIX,
1705 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1707 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1708 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1709 &custom_element.drop_delay_fixed,
1710 NULL, "drop delay", NULL
1713 ED_COUNTER_ID_DROP_DELAY_RND,
1714 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1716 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1717 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1718 &custom_element.drop_delay_random,
1719 NULL, "+random", NULL
1722 // ---------- element settings: configure 2 (custom elements) ---------------
1725 ED_COUNTER_ID_MOVE_DELAY_FIX,
1726 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1728 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1729 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1730 &custom_element.move_delay_fixed,
1731 NULL, "move delay", NULL
1734 ED_COUNTER_ID_MOVE_DELAY_RND,
1735 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1737 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1738 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1739 &custom_element.move_delay_random,
1740 NULL, "+random", NULL
1743 ED_COUNTER_ID_STEP_DELAY_FIX,
1744 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1746 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1747 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1748 &custom_element.step_delay_fixed,
1749 NULL, "step delay", NULL
1752 ED_COUNTER_ID_STEP_DELAY_RND,
1753 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1755 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1756 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1757 &custom_element.step_delay_random,
1758 NULL, "+random", NULL
1761 ED_COUNTER_ID_EXPLOSION_DELAY,
1762 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1764 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1765 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1766 &custom_element.explosion_delay,
1767 NULL, "explosion delay", NULL
1770 ED_COUNTER_ID_IGNITION_DELAY,
1771 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1773 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1774 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1775 &custom_element.ignition_delay,
1776 NULL, "ignition delay", "(by fire)"
1779 // ---------- element settings: configure (group elements) ------------------
1782 ED_COUNTER_ID_GROUP_CONTENT,
1783 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1784 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1785 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1786 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1787 &group_element_info.num_elements,
1788 NULL, NULL, "number of elements in group"
1791 // ---------- element settings: advanced (custom elements) ------------------
1794 ED_COUNTER_ID_CHANGE_DELAY_FIX,
1795 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1797 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1798 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1799 &custom_element_change.delay_fixed,
1800 NULL, "CE delay", NULL,
1803 ED_COUNTER_ID_CHANGE_DELAY_RND,
1804 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1806 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1807 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1808 &custom_element_change.delay_random,
1809 NULL, "+random", NULL
1812 ED_COUNTER_ID_CHANGE_CONT_RND,
1813 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1815 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1816 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1817 &custom_element_change.random_percentage,
1818 NULL, "use random replace:", "%"
1829 char *text_above, *infotext;
1830 } textinput_info[ED_NUM_TEXTINPUT] =
1833 ED_TEXTINPUT_ID_LEVEL_NAME,
1834 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1835 GADGET_ID_LEVEL_NAME,
1838 "Title:", "Title for this level"
1841 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
1842 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1843 GADGET_ID_LEVEL_AUTHOR,
1844 MAX_LEVEL_AUTHOR_LEN,
1846 "Author:", "Author for this level"
1849 ED_TEXTINPUT_ID_LEVELSET_NAME,
1850 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1851 GADGET_ID_LEVELSET_NAME,
1854 "Title:", "Title for this or new level set"
1857 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
1858 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1859 GADGET_ID_LEVELSET_AUTHOR,
1860 MAX_LEVEL_AUTHOR_LEN,
1862 "Author:", "Author for this or new level set"
1865 ED_TEXTINPUT_ID_ELEMENT_NAME,
1866 -1, -1, // these values are not constant, but can change at runtime
1867 GADGET_ID_ELEMENT_NAME,
1868 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1869 custom_element.description,
1870 NULL, "Element name"
1881 char *text_above, *text_above_cropped, *infotext;
1882 } textarea_info[ED_NUM_TEXTAREAS] =
1885 ED_TEXTAREA_ID_ENVELOPE_INFO,
1886 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1887 GADGET_ID_ENVELOPE_INFO,
1888 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1890 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1894 static struct ValueTextInfo options_time_or_steps[] =
1902 static struct ValueTextInfo options_time_score_base[] =
1904 { 1, "per second/step" },
1905 { 10, "per 10 seconds/steps" },
1910 static struct ValueTextInfo options_game_engine_type[] =
1912 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1913 { GAME_ENGINE_TYPE_BD, "Boulder Dash" },
1914 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1915 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1916 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1921 static struct ValueTextInfo options_levelset_save_mode[] =
1923 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1924 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1929 static struct ValueTextInfo options_wind_direction[] =
1931 { MV_START_NONE, "none" },
1932 { MV_START_LEFT, "left" },
1933 { MV_START_RIGHT, "right" },
1934 { MV_START_UP, "up" },
1935 { MV_START_DOWN, "down" },
1940 static struct ValueTextInfo options_player_speed[] =
1947 { 16, "very fast" },
1948 { 32, "ultrafast" },
1953 static struct ValueTextInfo options_access_type[] =
1955 { EP_WALKABLE, "walkable" },
1956 { EP_PASSABLE, "passable" },
1961 static struct ValueTextInfo options_access_layer[] =
1963 { EP_ACCESSIBLE_OVER, "over" },
1964 { EP_ACCESSIBLE_INSIDE, "inside" },
1965 { EP_ACCESSIBLE_UNDER, "under" },
1970 static struct ValueTextInfo options_access_protected[] =
1972 { 0, "unprotected" },
1978 static struct ValueTextInfo options_access_direction[] =
1980 { MV_NO_DIRECTION, "no direction" },
1981 { MV_LEFT, "left" },
1982 { MV_RIGHT, "right" },
1984 { MV_DOWN, "down" },
1985 { MV_LEFT | MV_UP, "left + up" },
1986 { MV_LEFT | MV_DOWN, "left + down" },
1987 { MV_RIGHT | MV_UP, "right + up" },
1988 { MV_RIGHT | MV_DOWN, "right + down" },
1989 { MV_HORIZONTAL, "horizontal" },
1990 { MV_VERTICAL, "vertical" },
1991 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1992 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1993 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1994 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1995 { MV_ALL_DIRECTIONS, "all directions" },
2000 static struct ValueTextInfo options_walk_to_action[] =
2002 { EP_DIGGABLE, "diggable" },
2003 { EP_COLLECTIBLE_ONLY, "collectible" },
2004 { EP_DROPPABLE, "collectible & droppable" },
2005 { EP_THROWABLE, "collectible & throwable" },
2006 { EP_PUSHABLE, "pushable" },
2011 static struct ValueTextInfo options_move_pattern[] =
2013 { MV_LEFT, "left" },
2014 { MV_RIGHT, "right" },
2016 { MV_DOWN, "down" },
2017 { MV_HORIZONTAL, "horizontal" },
2018 { MV_VERTICAL, "vertical" },
2019 { MV_ALL_DIRECTIONS, "all directions" },
2020 { MV_WIND_DIRECTION, "wind direction" },
2021 { MV_TOWARDS_PLAYER, "towards player" },
2022 { MV_AWAY_FROM_PLAYER, "away from player" },
2023 { MV_ALONG_LEFT_SIDE, "along left side" },
2024 { MV_ALONG_RIGHT_SIDE, "along right side" },
2025 { MV_TURNING_LEFT, "turning left" },
2026 { MV_TURNING_RIGHT, "turning right" },
2027 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
2028 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
2029 { MV_TURNING_RANDOM, "turning random" },
2030 { MV_MAZE_RUNNER, "maze runner style" },
2031 { MV_MAZE_HUNTER, "maze hunter style" },
2032 { MV_WHEN_PUSHED, "when pushed" },
2033 { MV_WHEN_DROPPED, "when dropped/thrown" },
2038 static struct ValueTextInfo options_move_direction[] =
2040 { MV_START_AUTOMATIC, "automatic" },
2041 { MV_START_LEFT, "left" },
2042 { MV_START_RIGHT, "right" },
2043 { MV_START_UP, "up" },
2044 { MV_START_DOWN, "down" },
2045 { MV_START_RANDOM, "random" },
2046 { MV_START_PREVIOUS, "previous" },
2051 static struct ValueTextInfo options_move_stepsize[] =
2053 { 0, "not moving" },
2058 { 16, "very fast" },
2059 { 32, "even faster" },
2064 static struct ValueTextInfo options_move_leave_type[] =
2066 { LEAVE_TYPE_UNLIMITED, "leave behind" },
2067 { LEAVE_TYPE_LIMITED, "change it to" },
2072 static struct ValueTextInfo options_smash_targets[] =
2074 { EP_CAN_SMASH_PLAYER, "player" },
2076 { EP_CAN_SMASH_ENEMIES, "enemies" },
2078 { EP_CAN_SMASH_EVERYTHING, "everything" },
2083 static struct ValueTextInfo options_slippery_type[] =
2085 { SLIPPERY_ANY_RANDOM, "random" },
2086 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
2087 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
2088 { SLIPPERY_ONLY_LEFT, "only left" },
2089 { SLIPPERY_ONLY_RIGHT, "only right" },
2094 static struct ValueTextInfo options_deadliness[] =
2096 { EP_DONT_RUN_INTO, "running into" },
2097 { EP_DONT_COLLIDE_WITH, "colliding with" },
2098 { EP_DONT_GET_HIT_BY, "getting hit by" },
2099 { EP_DONT_TOUCH, "touching" },
2104 static struct ValueTextInfo options_explosion_type[] =
2106 { EXPLODES_3X3, "3x3" },
2107 { EXPLODES_CROSS, "3+3" },
2108 { EXPLODES_1X1, "1x1" },
2113 static struct ValueTextInfo options_time_units[] =
2116 { FRAMES_PER_SECOND, "seconds" },
2121 static struct ValueTextInfo options_change_direct_action[] =
2123 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2124 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2125 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2126 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2127 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2128 { CE_ENTERED_BY_PLAYER, "entered by player" },
2129 { CE_LEFT_BY_PLAYER, "left by player" },
2130 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2131 { CE_SWITCHED, "switched" },
2132 { CE_HITTING_SOMETHING, "hitting something" },
2133 { CE_HIT_BY_SOMETHING, "hit by something" },
2135 { CE_BLOCKED, "blocked" },
2137 { CE_IMPACT, "impact (on something)" },
2138 { CE_SMASHED, "smashed (from above)" },
2140 { CE_VALUE_CHANGES, "CE value changes" },
2141 { CE_SCORE_CHANGES, "CE score changes" },
2143 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2144 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2145 { CE_UNDEFINED, " " },
2146 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2147 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2148 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2149 { CE_UNDEFINED, " " },
2150 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2151 { CE_NEXT_TO_PLAYER, "next to player" },
2156 static struct ValueTextInfo options_change_other_action[] =
2158 { CE_PLAYER_TOUCHES_X, "player touches" },
2159 { CE_PLAYER_PRESSES_X, "player presses" },
2160 { CE_PLAYER_SWITCHES_X, "player switches" },
2161 { CE_PLAYER_SNAPS_X, "player snaps" },
2162 { CE_PLAYER_PUSHES_X, "player pushes" },
2163 { CE_PLAYER_ENTERS_X, "player enters" },
2164 { CE_PLAYER_LEAVES_X, "player leaves" },
2165 { CE_PLAYER_DIGS_X, "player digs" },
2166 { CE_PLAYER_COLLECTS_X, "player collects" },
2167 { CE_PLAYER_DROPS_X, "player drops/throws" },
2168 { CE_TOUCHING_X, "touching" },
2169 { CE_HITTING_X, "hitting" },
2170 { CE_DIGGING_X, "digging" },
2171 { CE_HIT_BY_X, "hit by" },
2172 { CE_SWITCH_OF_X, "switch of" },
2173 { CE_CHANGE_OF_X, "change by page of" },
2174 { CE_EXPLOSION_OF_X, "explosion of" },
2175 { CE_MOVE_OF_X, "move of" },
2176 { CE_CREATION_OF_X, "creation of" },
2177 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2178 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2179 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2180 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2181 { CE_UNDEFINED, " " },
2182 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2183 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2184 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2185 { CE_UNDEFINED, " " },
2186 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2187 { CE_PLAYER_NEXT_TO_X, "player next to" },
2188 { CE_NEXT_TO_X, "next to" },
2193 static struct ValueTextInfo options_change_trigger_side[] =
2195 { CH_SIDE_LEFT, "left" },
2196 { CH_SIDE_RIGHT, "right" },
2197 { CH_SIDE_TOP, "top" },
2198 { CH_SIDE_BOTTOM, "bottom" },
2199 { CH_SIDE_LEFT_RIGHT, "left/right" },
2200 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2201 { CH_SIDE_ANY, "any" },
2206 static struct ValueTextInfo options_change_trigger_player[] =
2208 { CH_PLAYER_1, "1" },
2209 { CH_PLAYER_2, "2" },
2210 { CH_PLAYER_3, "3" },
2211 { CH_PLAYER_4, "4" },
2212 { CH_PLAYER_ANY, "any" },
2217 static struct ValueTextInfo options_change_trigger_page[] =
2228 { (1u << 9), "10" },
2229 { (1u << 10), "11" },
2230 { (1u << 11), "12" },
2231 { (1u << 12), "13" },
2232 { (1u << 13), "14" },
2233 { (1u << 14), "15" },
2234 { (1u << 15), "16" },
2235 { (1u << 16), "17" },
2236 { (1u << 17), "18" },
2237 { (1u << 18), "19" },
2238 { (1u << 19), "20" },
2239 { (1u << 20), "21" },
2240 { (1u << 21), "22" },
2241 { (1u << 22), "23" },
2242 { (1u << 23), "24" },
2243 { (1u << 24), "25" },
2244 { (1u << 25), "26" },
2245 { (1u << 26), "27" },
2246 { (1u << 27), "28" },
2247 { (1u << 28), "29" },
2248 { (1u << 29), "30" },
2249 { (1u << 30), "31" },
2250 { (1u << 31), "32" },
2251 { CH_PAGE_ANY, "any" },
2256 static struct ValueTextInfo options_change_replace_when[] =
2258 { CP_WHEN_EMPTY, "empty" },
2259 { CP_WHEN_WALKABLE, "walkable" },
2260 { CP_WHEN_DIGGABLE, "diggable" },
2261 { CP_WHEN_COLLECTIBLE, "collectible" },
2262 { CP_WHEN_REMOVABLE, "removable" },
2263 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2268 static struct ValueTextInfo options_action_type[] =
2270 { CA_NO_ACTION, "no action" },
2271 { CA_UNDEFINED, " " },
2272 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2273 { CA_RESTART_LEVEL, "restart level" },
2274 { CA_SHOW_ENVELOPE, "show envelope" },
2275 { CA_SET_LEVEL_TIME, "set time" },
2276 { CA_SET_LEVEL_SCORE, "set score" },
2277 { CA_SET_LEVEL_GEMS, "set gems" },
2278 { CA_SET_LEVEL_WIND, "set wind dir." },
2279 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2280 { CA_UNDEFINED, " " },
2281 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2282 { CA_MOVE_PLAYER, "move player" },
2283 { CA_MOVE_PLAYER_NEW, "move player new" },
2284 { CA_EXIT_PLAYER, "exit player" },
2285 { CA_KILL_PLAYER, "kill player" },
2286 { CA_SET_PLAYER_KEYS, "set keys" },
2287 { CA_SET_PLAYER_SPEED, "set speed" },
2288 { CA_SET_PLAYER_SHIELD, "set shield" },
2289 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2290 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2291 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2292 { CA_UNDEFINED, " " },
2293 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2294 { CA_SET_CE_VALUE, "set CE value" },
2295 { CA_SET_CE_SCORE, "set CE score" },
2296 { CA_SET_CE_ARTWORK, "set CE artwork" },
2297 { CA_UNDEFINED, " " },
2298 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2299 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2304 static struct ValueTextInfo options_action_mode_none[] =
2306 { CA_MODE_UNDEFINED, " " },
2311 static struct ValueTextInfo options_action_mode_assign[] =
2313 { CA_MODE_SET, "=" },
2318 static struct ValueTextInfo options_action_mode_add_remove[] =
2320 { CA_MODE_ADD, "+" },
2321 { CA_MODE_SUBTRACT, "-" },
2326 static struct ValueTextInfo options_action_mode_calculate[] =
2328 { CA_MODE_SET, "=" },
2329 { CA_MODE_ADD, "+" },
2330 { CA_MODE_SUBTRACT, "-" },
2331 { CA_MODE_MULTIPLY, "*" },
2332 { CA_MODE_DIVIDE, "/" },
2333 { CA_MODE_MODULO, "%" },
2338 static struct ValueTextInfo options_action_arg_none[] =
2340 { CA_ARG_UNDEFINED, " " },
2345 static struct ValueTextInfo options_action_arg_player[] =
2347 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2348 { CA_ARG_PLAYER_1, "1" },
2349 { CA_ARG_PLAYER_2, "2" },
2350 { CA_ARG_PLAYER_3, "3" },
2351 { CA_ARG_PLAYER_4, "4" },
2352 { CA_ARG_PLAYER_ANY, "any" },
2353 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2354 { CA_ARG_PLAYER_ACTION, "action ->" },
2359 static struct ValueTextInfo options_action_arg_number[] =
2361 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2368 { CA_ARG_10, "10" },
2369 { CA_ARG_100, "100" },
2370 { CA_ARG_1000, "1000" },
2371 { CA_ARG_UNDEFINED, " " },
2372 { CA_ARG_NUMBER_MIN, "min" },
2373 { CA_ARG_NUMBER_MAX, "max" },
2374 { CA_ARG_UNDEFINED, " " },
2375 { CA_ARG_NUMBER_RESET, "reset" },
2376 { CA_ARG_UNDEFINED, " " },
2377 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2378 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2379 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2380 { CA_ARG_UNDEFINED, " " },
2381 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2382 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2383 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2384 { CA_ARG_UNDEFINED, " " },
2385 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2386 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2387 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2388 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2389 { CA_ARG_UNDEFINED, " " },
2390 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2391 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2392 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2393 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2398 static struct ValueTextInfo options_action_arg_value[] =
2400 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2407 { CA_ARG_10, "10" },
2408 { CA_ARG_100, "100" },
2409 { CA_ARG_1000, "1000" },
2410 { CA_ARG_UNDEFINED, " " },
2411 { CA_ARG_NUMBER_MIN, "min" },
2412 { CA_ARG_NUMBER_MAX, "max" },
2413 { CA_ARG_UNDEFINED, " " },
2414 { CA_ARG_NUMBER_RESET, "reset" },
2415 { CA_ARG_UNDEFINED, " " },
2416 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2417 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2418 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2419 { CA_ARG_UNDEFINED, " " },
2420 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2421 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2422 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2423 { CA_ARG_UNDEFINED, " " },
2424 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2425 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2426 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2427 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2428 { CA_ARG_UNDEFINED, " " },
2429 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2430 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2431 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2432 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2433 { CA_ARG_UNDEFINED, " " },
2434 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2435 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2436 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2437 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2442 static struct ValueTextInfo options_action_arg_envelope[] =
2444 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2449 { CA_ARG_UNDEFINED, " " },
2450 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2451 { CA_ARG_ELEMENT_TARGET, "target" },
2452 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2453 { CA_ARG_ELEMENT_ACTION, "action ->" },
2458 static struct ValueTextInfo options_action_arg_key[] =
2460 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2469 { CA_ARG_UNDEFINED, " " },
2470 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2471 { CA_ARG_ELEMENT_TARGET, "target" },
2472 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2473 { CA_ARG_ELEMENT_ACTION, "action ->" },
2478 static struct ValueTextInfo options_action_arg_speed[] =
2480 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2481 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2482 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2483 { CA_ARG_SPEED_SLOW, "slow" },
2484 { CA_ARG_SPEED_NORMAL, "normal" },
2485 { CA_ARG_SPEED_FAST, "fast" },
2486 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2487 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2488 { CA_ARG_UNDEFINED, " " },
2489 { CA_ARG_SPEED_SLOWER, "slower" },
2490 { CA_ARG_SPEED_FASTER, "faster" },
2491 { CA_ARG_UNDEFINED, " " },
2492 { CA_ARG_SPEED_RESET, "reset" },
2497 static struct ValueTextInfo options_action_arg_shield[] =
2499 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2500 { CA_ARG_SHIELD_OFF, "off" },
2501 { CA_ARG_SHIELD_NORMAL, "normal" },
2502 { CA_ARG_SHIELD_DEADLY, "deadly" },
2507 static struct ValueTextInfo options_action_arg_artwork[] =
2509 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2510 { CA_ARG_ELEMENT_TARGET, "target" },
2511 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2512 { CA_ARG_ELEMENT_ACTION, "action ->" },
2513 { CA_ARG_UNDEFINED, " " },
2514 { CA_ARG_ELEMENT_RESET, "reset" },
2519 static struct ValueTextInfo options_action_arg_gravity[] =
2521 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2522 { CA_ARG_GRAVITY_ON, "on" },
2523 { CA_ARG_GRAVITY_OFF, "off" },
2524 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2529 static struct ValueTextInfo options_action_arg_direction[] =
2531 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2532 { CA_ARG_DIRECTION_NONE, "none" },
2533 { CA_ARG_DIRECTION_LEFT, "left" },
2534 { CA_ARG_DIRECTION_RIGHT, "right" },
2535 { CA_ARG_DIRECTION_UP, "up" },
2536 { CA_ARG_DIRECTION_DOWN, "down" },
2537 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2538 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2543 static struct ValueTextInfo options_action_arg_scan_mode[] =
2545 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2546 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2547 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2552 static struct ValueTextInfo options_action_arg_inventory[] =
2554 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2555 { CA_ARG_ELEMENT_TARGET, "+ target" },
2556 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2557 { CA_ARG_ELEMENT_ACTION, "+ action" },
2558 { CA_ARG_UNDEFINED, " " },
2559 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2560 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2561 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2562 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2563 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2564 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2565 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2566 { CA_ARG_UNDEFINED, " " },
2567 { CA_ARG_INVENTORY_RESET, "reset" },
2572 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2573 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2578 static struct ValueTextInfo options_group_choice_mode[] =
2580 { ANIM_RANDOM, "random" },
2581 { ANIM_LOOP, "loop" },
2582 { ANIM_LINEAR, "linear" },
2583 { ANIM_PINGPONG, "pingpong" },
2584 { ANIM_PINGPONG2, "pingpong 2" },
2585 { ANIM_LEVEL_NR, "level number" },
2590 static struct ValueTextInfo options_bd_scheduling_type[] =
2592 { GD_SCHEDULING_MILLISECONDS, "Milliseconds" },
2593 { GD_SCHEDULING_BD1, "BD1" },
2594 { GD_SCHEDULING_BD2, "BD2" },
2595 { GD_SCHEDULING_PLCK, "Construction Kit" },
2596 { GD_SCHEDULING_CRDR, "Crazy Dream 7" },
2597 { GD_SCHEDULING_BD1_ATARI, "Atari BD1" },
2598 { GD_SCHEDULING_BD2_PLCK_ATARI, "Atari BD2 / PLCK" },
2603 static struct ValueTextInfo *action_arg_modes[] =
2605 options_action_mode_none,
2606 options_action_mode_assign,
2607 options_action_mode_add_remove,
2608 options_action_mode_calculate,
2615 struct ValueTextInfo *options;
2617 action_arg_options[] =
2619 { CA_NO_ACTION, 0, options_action_arg_none, },
2620 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2621 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2622 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2623 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2624 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2625 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2626 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2627 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2628 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2629 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2630 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2631 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2632 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2633 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2634 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2635 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2636 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2637 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2638 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2639 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2640 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2650 int gadget_id_align;
2651 int size; // char size of selectbox or '-1' (dynamically determined)
2652 struct ValueTextInfo *options;
2654 char *text_above, *text_left, *text_right, *infotext;
2655 } selectbox_info[ED_NUM_SELECTBOX] =
2657 // ---------- level and editor settings -------------------------------------
2660 ED_SELECTBOX_ID_TIME_OR_STEPS,
2661 -1, ED_LEVEL_SETTINGS_YPOS(8),
2662 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2664 options_time_or_steps,
2665 &level.use_step_counter,
2666 NULL, NULL, "(0 => no limit)", "time or step limit"
2669 ED_SELECTBOX_ID_TIME_SCORE_BASE,
2670 -1, ED_LEVEL_SETTINGS_YPOS(10),
2671 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2673 options_time_score_base,
2674 &level.time_score_base,
2675 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2678 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
2679 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2680 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2682 options_game_engine_type,
2683 &level.game_engine_type,
2684 NULL, "game engine:", NULL, "game engine"
2687 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
2688 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2689 GADGET_ID_BD_SCHEDULING_TYPE, GADGET_ID_NONE,
2691 options_bd_scheduling_type,
2692 &level.bd_scheduling_type,
2693 NULL, "scheduling type:", NULL, "level timing"
2696 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
2697 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2698 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2700 options_levelset_save_mode,
2701 &levelset_save_mode,
2702 "Action:", NULL, NULL, "action when saving level set"
2705 // ---------- element settings: configure (several elements) ----------------
2708 ED_SELECTBOX_ID_WIND_DIRECTION,
2709 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2710 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2712 options_wind_direction,
2713 &level.wind_direction_initial,
2714 NULL, "initial wind direction:", NULL, "initial wind direction"
2717 ED_SELECTBOX_ID_PLAYER_SPEED,
2718 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2719 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2721 options_player_speed,
2722 &level.initial_player_stepsize[0],
2723 NULL, "initial player speed:", NULL, "initial player speed"
2726 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
2727 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2728 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2730 options_group_choice_mode,
2731 &level.mm_ball_choice_mode,
2732 NULL, "choice type:", NULL, "type of content choice"
2735 // ---------- element settings: configure 1 (custom elements) ---------------
2738 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
2739 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2740 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2742 options_access_type,
2743 &custom_element.access_type,
2744 NULL, NULL, NULL, "type of access to this field"
2747 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
2748 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2749 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2751 options_access_layer,
2752 &custom_element.access_layer,
2753 NULL, NULL, NULL, "layer of access for this field"
2756 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
2757 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2758 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2760 options_access_protected,
2761 &custom_element.access_protected,
2762 NULL, NULL, NULL, "protected access for this field"
2765 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
2766 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2767 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2769 options_access_direction,
2770 &custom_element.access_direction,
2771 NULL, "from", NULL, "access direction for this field"
2774 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
2775 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2776 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2778 options_walk_to_action,
2779 &custom_element.walk_to_action,
2780 NULL, NULL, NULL, "diggable/collectible/pushable"
2783 // ---------- element settings: configure 2 (custom elements) ---------------
2786 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
2787 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2788 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2790 options_move_pattern,
2791 &custom_element.move_pattern,
2792 NULL, "can move", NULL, "element move pattern"
2795 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
2796 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2797 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2799 options_move_direction,
2800 &custom_element.move_direction_initial,
2801 NULL, "starts moving", NULL, "initial element move direction"
2804 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
2805 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2806 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2808 options_move_stepsize,
2809 &custom_element.move_stepsize,
2810 NULL, "move/fall speed", NULL, "speed of element movement"
2813 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
2814 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2815 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2817 options_move_leave_type,
2818 &custom_element.move_leave_type,
2819 // left text with leading spaces to place gadget next to "can dig" gadget
2820 // (needed because drawing area gadgets created after selectbox gadgets)
2821 // NULL, "can dig: can", ":", "leave behind or change element"
2822 NULL, " can", ":", "leave behind or change element"
2825 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
2826 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2827 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2829 options_smash_targets,
2830 &custom_element.smash_targets,
2831 NULL, "can smash", NULL, "elements that can be smashed"
2834 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
2835 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2836 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2838 options_slippery_type,
2839 &custom_element.slippery_type,
2840 NULL, "slippery", NULL, "where other elements fall down"
2843 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
2844 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2845 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2848 &custom_element.deadliness,
2849 NULL, "deadly when", NULL, "deadliness of element"
2852 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
2853 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2854 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2856 options_explosion_type,
2857 &custom_element.explosion_type,
2858 NULL, "can explode", NULL, "explosion type"
2861 // ---------- element settings: advanced (custom elements) ------------------
2864 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
2865 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2866 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2869 &custom_element_change.delay_frames,
2870 NULL, "delay time given in", NULL, "delay time units for change"
2873 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
2874 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2875 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2877 options_change_direct_action,
2878 &custom_element_change.direct_action,
2879 NULL, NULL, NULL, "type of direct action"
2882 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
2883 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2884 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2886 options_change_other_action,
2887 &custom_element_change.other_action,
2888 NULL, NULL, "element:", "type of other element action"
2891 ED_SELECTBOX_ID_CHANGE_SIDE,
2892 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2893 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2895 options_change_trigger_side,
2896 &custom_element_change.trigger_side,
2897 NULL, "at", "side", "element side triggering change"
2900 ED_SELECTBOX_ID_CHANGE_PLAYER,
2901 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2902 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2904 options_change_trigger_player,
2905 &custom_element_change.trigger_player,
2906 NULL, "player:", " ", "player that causes change"
2909 ED_SELECTBOX_ID_CHANGE_PAGE,
2910 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2911 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2913 options_change_trigger_page,
2914 &custom_element_change.trigger_page,
2915 NULL, "page:", NULL, "change page that causes change"
2918 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
2919 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2920 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2922 options_change_replace_when,
2923 &custom_element_change.replace_when,
2924 NULL, "replace when", NULL, "which elements can be replaced"
2927 ED_SELECTBOX_ID_ACTION_TYPE,
2928 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2929 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2931 options_action_type,
2932 &custom_element_change.action_type,
2933 NULL, NULL, NULL, "action on specified condition"
2936 ED_SELECTBOX_ID_ACTION_MODE,
2937 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2938 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2940 options_action_mode_none,
2941 &custom_element_change.action_mode,
2942 NULL, NULL, NULL, "action operator"
2945 ED_SELECTBOX_ID_ACTION_ARG,
2946 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2947 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2949 options_action_arg_none,
2950 &custom_element_change.action_arg,
2951 NULL, NULL, NULL, "action parameter"
2954 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
2955 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2956 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2958 options_change_page,
2959 &custom_element.current_change_page,
2960 NULL, NULL, NULL, "element change page"
2963 // ---------- element settings: configure (group elements) ------------------
2966 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
2967 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2968 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2970 options_group_choice_mode,
2971 &group_element_info.choice_mode,
2972 NULL, "choice type:", NULL, "type of group element choice"
2981 int gadget_id_align;
2984 char *text_above, *text_left, *text_right, *infotext;
2985 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2987 // ---------- level and editor settings (tabs) ------------------------------
2990 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
2991 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2992 GADGET_ID_LEVELCONFIG_LEVEL, GADGET_ID_NONE,
2994 NULL, NULL, NULL, "Configure level settings"
2997 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
2999 GADGET_ID_LEVELCONFIG_LEVELSET, GADGET_ID_LEVELCONFIG_LEVEL,
3001 NULL, NULL, NULL, "Update this or create new level set"
3004 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
3006 GADGET_ID_LEVELCONFIG_EDITOR, GADGET_ID_LEVELCONFIG_LEVELSET,
3008 NULL, NULL, NULL, "Configure editor settings"
3011 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
3013 GADGET_ID_LEVELCONFIG_ENGINE, GADGET_ID_LEVELCONFIG_EDITOR,
3015 NULL, NULL, NULL, "Configure engine settings"
3018 // ---------- element settings (tabs) ---------------------------------------
3021 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
3022 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
3023 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
3025 NULL, NULL, NULL, "Show information about element"
3028 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
3030 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
3032 NULL, NULL, NULL, "Configure element properties"
3035 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
3037 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
3039 NULL, NULL, NULL, "Configure element properties, part 1"
3042 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
3044 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
3046 NULL, NULL, NULL, "Configure element properties, part 2"
3049 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
3051 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
3053 NULL, NULL, NULL, "Configure custom element change pages"
3056 // ---------- level and editor settings (buttons) ---------------------------
3059 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
3060 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
3061 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
3063 NULL, NULL, NULL, "Update or create level set"
3066 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
3067 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3068 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
3070 NULL, NULL, "this level as level template",
3071 "Save current settings as new template"
3074 // ---------- element settings (buttons) ------------------------------------
3077 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
3079 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
3081 NULL, " ", "As Template",
3082 "Save current settings as new template"
3085 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
3087 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
3089 NULL, NULL, NULL, "Add new change page"
3092 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
3094 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
3096 NULL, NULL, NULL, "Delete current change page"
3106 int gadget_id_align;
3107 char *text_left, *text_right, *infotext;
3108 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
3111 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
3112 IMG_EDITOR_COUNTER_DOWN,
3113 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3114 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
3115 NULL, NULL, "select previous change page"
3118 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
3119 IMG_EDITOR_COUNTER_UP,
3120 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3121 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
3122 NULL, "change page", "select next change page"
3125 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
3126 IMG_GFX_EDITOR_BUTTON_CP_COPY,
3127 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3128 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
3129 " ", NULL, "copy settings from this change page"
3132 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
3133 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
3134 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3135 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
3136 NULL, NULL, "paste settings to this change page"
3143 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
3151 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
3154 ED_SCROLLBUTTON_ID_AREA_UP,
3155 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
3156 GADGET_ID_SCROLL_UP,
3157 "scroll level editing area up"
3160 ED_SCROLLBUTTON_ID_AREA_DOWN,
3161 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
3162 GADGET_ID_SCROLL_DOWN,
3163 "scroll level editing area down"
3166 ED_SCROLLBUTTON_ID_AREA_LEFT,
3167 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
3168 GADGET_ID_SCROLL_LEFT,
3169 "scroll level editing area left"
3172 ED_SCROLLBUTTON_ID_AREA_RIGHT,
3173 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
3174 GADGET_ID_SCROLL_RIGHT,
3175 "scroll level editing area right"
3178 ED_SCROLLBUTTON_ID_LIST_UP,
3179 IMG_EDITOR_PALETTE_SCROLL_UP,
3180 GADGET_ID_SCROLL_LIST_UP,
3181 "scroll element list up ('Page Up')"
3184 ED_SCROLLBUTTON_ID_LIST_DOWN,
3185 IMG_EDITOR_PALETTE_SCROLL_DOWN,
3186 GADGET_ID_SCROLL_LIST_DOWN,
3187 "scroll element list down ('Page Down')"
3195 int wheel_x, wheel_y;
3196 int wheel_width, wheel_height;
3197 } scrollbar_pos[ED_NUM_SCROLLBARS];
3206 } scrollbar_info[ED_NUM_SCROLLBARS] =
3209 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
3210 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3211 GD_TYPE_SCROLLBAR_HORIZONTAL,
3212 GADGET_ID_SCROLL_HORIZONTAL,
3213 "scroll level editing area horizontally"
3216 ED_SCROLLBAR_ID_AREA_VERTICAL,
3217 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3218 GD_TYPE_SCROLLBAR_VERTICAL,
3219 GADGET_ID_SCROLL_VERTICAL,
3220 "scroll level editing area vertically"
3223 ED_SCROLLBAR_ID_LIST_VERTICAL,
3224 IMG_EDITOR_PALETTE_SCROLLBAR,
3225 GD_TYPE_SCROLLBAR_VERTICAL,
3226 GADGET_ID_SCROLL_LIST_VERTICAL,
3227 "scroll element list vertically"
3237 int gadget_id_align;
3238 int radio_button_nr;
3241 char *text_left, *text_right, *infotext;
3242 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3245 ED_RADIOBUTTON_ID_PERCENTAGE,
3246 -1, ED_LEVEL_SETTINGS_YPOS(0),
3247 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3248 RADIO_NR_RANDOM_ELEMENTS,
3249 &random_placement_method, RANDOM_USE_PERCENTAGE,
3250 " ", "percentage", "use percentage for random elements"
3253 ED_RADIOBUTTON_ID_QUANTITY,
3254 -1, ED_LEVEL_SETTINGS_YPOS(0),
3255 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3256 RADIO_NR_RANDOM_ELEMENTS,
3257 &random_placement_method, RANDOM_USE_QUANTITY,
3258 " ", "quantity", "use quantity for random elements"
3267 int gadget_id_align;
3269 char *text_above, *text_left, *text_right, *infotext;
3270 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3272 // ---------- level and editor settings -------------------------------------
3275 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
3276 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3277 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3278 &level.auto_count_gems,
3280 "automatically count gems needed", "set counter to number of gems"
3283 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
3284 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3285 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3286 &level.rate_time_over_score,
3288 "rate time/steps used over score", "sort high scores by playing time/steps"
3291 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
3292 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3293 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3294 &levelset_use_levelset_artwork,
3296 "use current custom artwork", "use custom artwork of this level set"
3299 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
3300 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3301 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3302 &levelset_copy_level_template,
3304 "copy current level template", "copy level template of this level set"
3307 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
3308 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3309 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3310 &random_placement_background_restricted,
3312 "restrict random placement to:", "set random placement restriction"
3315 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
3316 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3317 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3318 &setup.editor.use_template_for_new_levels,
3319 "Template for new levels and CE/GE:", NULL,
3320 "use template for new levels", "use template for level properties"
3323 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
3324 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3325 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3326 &level.use_custom_template,
3328 "use template for custom elements", "use template for custom properties"
3331 ED_CHECKBUTTON_ID_BD_INTERMISSION,
3332 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
3333 GADGET_ID_BD_INTERMISSION, GADGET_ID_NONE,
3334 &level.bd_intermission,
3335 "Boulder Dash game engine settings:", NULL,
3336 "intermission", "level is an intermission level"
3339 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
3340 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
3341 GADGET_ID_BD_PAL_TIMING, GADGET_ID_NONE,
3342 &level.bd_pal_timing,
3344 "PAL timing", "use slower timer (like PAL C64)"
3347 // ---------- element settings: configure (various elements) ----------------
3350 ED_CHECKBUTTON_ID_STICK_ELEMENT,
3351 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3352 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3353 &stick_element_properties_window,
3355 "stick this screen to edit content","stick this screen to edit content"
3358 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
3359 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3360 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3361 &level.em_slippery_gems,
3363 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3366 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
3367 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3368 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3369 &level.em_explodes_by_fire,
3371 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3374 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
3375 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3376 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3377 &level.use_spring_bug,
3379 "use spring pushing bug", "use odd spring pushing behaviour"
3382 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
3383 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3384 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3385 &level.use_time_orb_bug,
3387 "use time orb bug", "use odd time orb behaviour"
3390 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
3391 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3392 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3393 &level.use_life_bugs,
3395 "use buggy element behaviour", "use odd (historic) element behaviour"
3398 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
3399 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3400 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3403 "create single random element", "only create one element from content"
3406 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
3407 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3408 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3409 &level.ball_active_initial,
3411 "magic ball initially activated", "activate magic ball after level start"
3414 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
3415 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3416 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3417 &level.grow_into_diggable,
3419 "can grow into anything diggable", "grow into more than just sand"
3422 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
3423 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3424 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3425 &level.sb_fields_needed,
3427 "all fields need to be filled", "require all SB fields to be solved"
3430 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
3431 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3432 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3433 &level.sb_objects_needed,
3435 "all objects need to be placed", "require all SB objects to be solved"
3438 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
3439 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3440 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3441 &level.auto_exit_sokoban,
3443 "exit level if all tasks solved", "automatically finish Sokoban levels"
3446 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
3447 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3448 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3449 &level.solved_by_one_player,
3451 "only one player must enter exit", "level solved by first player in exit"
3454 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
3455 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3456 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3457 &level.finish_dig_collect,
3459 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3462 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
3463 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3464 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3465 &level.keep_walkable_ce,
3467 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3470 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
3471 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3472 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3473 &level.continuous_snapping,
3475 "continuous snapping", "use snapping without releasing key"
3478 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
3479 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3480 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3481 &level.block_snap_field,
3483 "block snapped field when snapping", "use snapping delay to show animation"
3486 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
3487 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3488 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3489 &level.block_last_field,
3491 "block last field when moving", "player blocks last field when moving"
3494 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
3495 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3496 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3497 &level.sp_block_last_field,
3499 "block last field when moving", "player blocks last field when moving"
3502 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
3503 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3504 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3505 &level.instant_relocation,
3507 "no scrolling when relocating", "player gets relocated without delay"
3510 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
3511 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3512 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3513 &level.shifted_relocation,
3515 "no centering when relocating", "level not centered after relocation"
3518 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
3519 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3520 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3521 &level.lazy_relocation,
3523 "only redraw off-screen relocation","no redraw if relocation target visible"
3526 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
3527 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3528 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3529 &level.use_start_element[0],
3531 "use level start element:", "start level at this element's position"
3534 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
3535 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3536 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3537 &level.use_artwork_element[0],
3539 "use artwork from element:", "use player artwork from other element"
3542 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
3543 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3544 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3545 &level.use_explosion_element[0],
3547 "use explosion from element:", "use explosion properties from element"
3550 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
3551 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3552 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3553 &level.initial_player_gravity[0],
3555 "use initial gravity", "set initial player gravity"
3558 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
3559 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3560 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3561 &level.use_initial_inventory[0],
3563 "use initial inventory:", "use collected elements on level start"
3566 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
3567 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3568 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3569 &level.can_pass_to_walkable,
3571 "can pass to walkable element", "player can pass to empty or walkable"
3574 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
3575 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3576 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3577 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3579 "can fall into acid (with gravity)","player can fall into acid pool"
3582 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
3583 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3584 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3585 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3587 "can move into acid", "element can move into acid pool"
3590 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
3591 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3592 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3593 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3595 "deadly when colliding with", "element is deadly when hitting player"
3598 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
3599 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3600 GADGET_ID_BD_DIAGONAL_MOVEMENTS, GADGET_ID_NONE,
3601 &level.bd_diagonal_movements,
3603 "can move diagonally", "player can move diagonally"
3606 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
3607 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3608 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3609 &level.envelope[0].autowrap,
3611 "auto-wrap", "automatically wrap envelope text"
3614 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
3615 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3616 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3617 &level.envelope[0].centered,
3619 "centered", "automatically center envelope text"
3622 ED_CHECKBUTTON_ID_MM_LASER_RED,
3623 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3624 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3625 &level.mm_laser_red,
3626 "choose color components for laser:", NULL,
3627 "red", "use red color components in laser"
3630 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
3631 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3632 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3633 &level.mm_laser_green,
3635 "green", "use green color components in laser"
3638 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
3639 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3640 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3641 &level.mm_laser_blue,
3643 "blue", "use blue color components in laser"
3646 ED_CHECKBUTTON_ID_DF_LASER_RED,
3647 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3648 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3649 &level.df_laser_red,
3650 "choose color components for laser:", NULL,
3651 "red", "use red color components in laser"
3654 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
3655 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3656 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3657 &level.df_laser_green,
3659 "green", "use green color components in laser"
3662 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
3663 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3664 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3665 &level.df_laser_blue,
3667 "blue", "use blue color components in laser"
3670 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
3671 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3672 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3673 &level.rotate_mm_ball_content,
3675 "randomly rotate created content", "randomly rotate newly created content"
3678 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
3679 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3680 GADGET_ID_EXPLODE_MM_BALL, GADGET_ID_NONE,
3681 &level.explode_mm_ball,
3683 "explode ball instead of melting", "use explosion to release ball content"
3686 // ---------- element settings: configure 1 (custom elements) ---------------
3689 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
3690 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3691 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3692 &custom_element.use_gfx_element,
3694 "use graphic of element:", "use existing element graphic"
3697 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
3698 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3699 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3700 &level.use_custom_template,
3702 "use template", "use template for custom properties"
3705 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
3706 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3707 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3708 &custom_element_properties[EP_ACCESSIBLE],
3710 NULL, "player can walk to or pass this field"
3713 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
3714 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3715 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3716 &custom_element_properties[EP_GRAVITY_REACHABLE],
3718 "reachable despite gravity", "player can walk/dig despite gravity"
3721 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
3722 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3723 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3724 &custom_element.use_last_ce_value,
3726 "use last CE value after change", "use last CE value after change"
3729 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
3730 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3731 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3732 &custom_element_properties[EP_WALK_TO_OBJECT],
3734 NULL, "player can dig/collect/push element"
3737 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
3738 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3739 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3740 &custom_element_properties[EP_INDESTRUCTIBLE],
3742 "indestructible", "element is indestructible"
3745 // ---------- element settings: configure 2 (custom elements) ---------------
3748 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
3749 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3750 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3751 &custom_element_properties[EP_CAN_MOVE],
3753 NULL, "element can move with some pattern"
3756 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
3757 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3758 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3759 &custom_element_properties[EP_CAN_FALL],
3761 "can fall", "element can fall down"
3764 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
3765 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3766 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3767 &custom_element_properties[EP_CAN_SMASH],
3769 NULL, "element can smash other elements"
3772 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
3773 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3774 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3775 &custom_element_properties[EP_SLIPPERY],
3777 NULL, "other elements can fall down from it"
3780 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
3781 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3782 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3783 &custom_element_properties[EP_DEADLY],
3785 NULL, "element can kill the player"
3788 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
3789 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3790 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3791 &custom_element_properties[EP_CAN_EXPLODE],
3793 NULL, "element can explode"
3796 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
3797 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3798 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3799 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3801 "by fire", "element can explode by fire/explosion"
3804 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
3805 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3806 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3807 &custom_element_properties[EP_EXPLODES_SMASHED],
3809 "smashed", "element can explode when smashed"
3812 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
3813 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3814 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3815 &custom_element_properties[EP_EXPLODES_IMPACT],
3817 "impact", "element can explode on impact"
3820 // ---------- element settings: advanced (custom elements) ------------------
3823 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
3824 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3825 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3826 &custom_element_change.can_change,
3828 "element changes to:", "change element on specified condition"
3831 ED_CHECKBUTTON_ID_CHANGE_DELAY,
3832 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3833 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3834 &custom_element_change_events[CE_DELAY],
3836 NULL, "element changes after delay"
3839 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
3840 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3841 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3842 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3844 NULL, "element changes by direct action"
3847 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
3848 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3849 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3850 &custom_element_change_events[CE_BY_OTHER_ACTION],
3852 NULL, "element changes by other element"
3855 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
3856 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3857 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3858 &custom_element_change.explode,
3860 "explode instead of change", "element explodes instead of change"
3863 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
3864 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3865 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3866 &custom_element_change.use_target_content,
3868 "use extended change target:", "element changes to more elements"
3871 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
3872 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3873 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3874 &custom_element_change.only_if_complete,
3876 "replace all or nothing", "only replace when all can be changed"
3879 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
3880 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3881 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3882 &custom_element_change.use_random_replace,
3884 NULL, "use percentage for random replace"
3887 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
3888 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3889 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3890 &custom_element_change.has_action,
3892 NULL, "execute action on specified condition"
3900 int xoffset, yoffset;
3902 int gadget_id_align;
3904 int area_xsize, area_ysize;
3905 char *text_left, *text_right, *text_above, *text_below, *infotext;
3906 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3908 // ---------- level playfield content ---------------------------------------
3911 ED_DRAWING_ID_DRAWING_LEVEL,
3914 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3916 -1, -1, // these values are not constant, but can change at runtime
3917 NULL, NULL, NULL, NULL, NULL
3920 // ---------- yam yam content -----------------------------------------------
3923 ED_DRAWING_ID_YAMYAM_CONTENT_0,
3924 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3925 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3926 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3927 &level.yamyam_content[0].e[0][0], 3, 3,
3928 NULL, NULL, NULL, "1", NULL
3931 ED_DRAWING_ID_YAMYAM_CONTENT_1,
3932 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3933 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3934 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3935 &level.yamyam_content[1].e[0][0], 3, 3,
3936 NULL, NULL, NULL, "2", NULL
3939 ED_DRAWING_ID_YAMYAM_CONTENT_2,
3940 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3941 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3942 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3943 &level.yamyam_content[2].e[0][0], 3, 3,
3944 NULL, NULL, NULL, "3", NULL
3947 ED_DRAWING_ID_YAMYAM_CONTENT_3,
3948 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3949 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3950 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3951 &level.yamyam_content[3].e[0][0], 3, 3,
3952 NULL, NULL, NULL, "4", NULL
3955 ED_DRAWING_ID_YAMYAM_CONTENT_4,
3956 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3957 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3958 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3959 &level.yamyam_content[4].e[0][0], 3, 3,
3960 NULL, NULL, NULL, "5", NULL
3963 ED_DRAWING_ID_YAMYAM_CONTENT_5,
3964 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3965 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3966 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3967 &level.yamyam_content[5].e[0][0], 3, 3,
3968 NULL, NULL, NULL, "6", NULL
3971 ED_DRAWING_ID_YAMYAM_CONTENT_6,
3972 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3973 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3974 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3975 &level.yamyam_content[6].e[0][0], 3, 3,
3976 NULL, NULL, NULL, "7", NULL
3979 ED_DRAWING_ID_YAMYAM_CONTENT_7,
3980 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3981 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3982 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3983 &level.yamyam_content[7].e[0][0], 3, 3,
3984 NULL, NULL, NULL, "8", NULL
3987 // ---------- magic ball content --------------------------------------------
3990 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
3991 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3992 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3993 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3994 &level.ball_content[0].e[0][0], 3, 3,
3995 NULL, NULL, NULL, "1", NULL
3998 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
3999 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4000 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
4001 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
4002 &level.ball_content[1].e[0][0], 3, 3,
4003 NULL, NULL, NULL, "2", NULL
4006 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
4007 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4008 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
4009 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
4010 &level.ball_content[2].e[0][0], 3, 3,
4011 NULL, NULL, NULL, "3", NULL
4014 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
4015 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4016 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
4017 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
4018 &level.ball_content[3].e[0][0], 3, 3,
4019 NULL, NULL, NULL, "4", NULL
4022 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
4023 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4024 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
4025 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
4026 &level.ball_content[4].e[0][0], 3, 3,
4027 NULL, NULL, NULL, "5", NULL
4030 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
4031 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4032 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
4033 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
4034 &level.ball_content[5].e[0][0], 3, 3,
4035 NULL, NULL, NULL, "6", NULL
4038 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
4039 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4040 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
4041 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
4042 &level.ball_content[6].e[0][0], 3, 3,
4043 NULL, NULL, NULL, "7", NULL
4046 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
4047 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4048 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
4049 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
4050 &level.ball_content[7].e[0][0], 3, 3,
4051 NULL, NULL, NULL, "8", NULL
4054 // ---------- android content -----------------------------------------------
4057 ED_DRAWING_ID_ANDROID_CONTENT,
4058 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
4059 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4060 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
4061 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
4062 NULL, NULL, "elements:", NULL, "elements android can clone"
4065 // ---------- amoeba content ------------------------------------------------
4068 ED_DRAWING_ID_AMOEBA_CONTENT,
4069 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
4070 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4071 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
4072 &level.amoeba_content, 1, 1,
4073 "content:", NULL, NULL, NULL, "amoeba content"
4076 // ---------- level start element -------------------------------------------
4079 ED_DRAWING_ID_START_ELEMENT,
4080 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
4081 0, ED_AREA_1X1_SETTINGS_YOFF,
4082 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
4083 &level.start_element[0], 1, 1,
4084 NULL, NULL, NULL, NULL, "level start element"
4087 // ---------- player artwork element ----------------------------------------
4090 ED_DRAWING_ID_ARTWORK_ELEMENT,
4091 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
4092 0, ED_AREA_1X1_SETTINGS_YOFF,
4093 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
4094 &level.artwork_element[0], 1, 1,
4095 NULL, NULL, NULL, NULL, "element for player artwork"
4098 // ---------- player explosion element --------------------------------------
4101 ED_DRAWING_ID_EXPLOSION_ELEMENT,
4102 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
4103 0, ED_AREA_1X1_SETTINGS_YOFF,
4104 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
4105 &level.explosion_element[0], 1, 1,
4106 NULL, NULL, NULL, NULL, "element for player explosion"
4109 // ---------- player initial inventory --------------------------------------
4112 ED_DRAWING_ID_INVENTORY_CONTENT,
4113 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4114 0, ED_AREA_1X1_SETTINGS_YOFF,
4115 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
4116 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
4117 NULL, NULL, NULL, NULL, "content for initial inventory"
4120 // ---------- gray ball content -----------------------------------------
4123 ED_DRAWING_ID_MM_BALL_CONTENT,
4124 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4125 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4126 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
4127 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
4128 "content:", NULL, NULL, NULL, "content for gray ball"
4131 // ---------- element settings: configure 1 (custom elements) ---------------
4133 // ---------- custom graphic ------------------------------------------------
4136 ED_DRAWING_ID_CUSTOM_GRAPHIC,
4137 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4138 0, ED_AREA_1X1_SETTINGS_YOFF,
4139 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
4140 &custom_element.gfx_element_initial, 1, 1,
4141 NULL, NULL, NULL, NULL, "custom graphic element"
4144 // ---------- element settings: configure 2 (custom elements) ---------------
4146 // ---------- custom content (when exploding) -------------------------------
4149 ED_DRAWING_ID_CUSTOM_CONTENT,
4150 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
4151 0, ED_AREA_3X3_SETTINGS_YOFF,
4152 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
4153 &custom_element.content.e[0][0], 3, 3,
4154 "content:", NULL, NULL, NULL, NULL
4157 // ---------- custom enter and leave element (when moving) ------------------
4160 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
4161 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
4162 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4163 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
4164 &custom_element.move_enter_element, 1, 1,
4165 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
4168 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
4169 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
4170 0, ED_AREA_1X1_SETTINGS_YOFF,
4171 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
4172 &custom_element.move_leave_element, 1, 1,
4173 NULL, NULL, NULL, NULL, "element that will be left behind"
4176 // ---------- element settings: advanced (custom elements) ------------------
4178 // ---------- custom change target ------------------------------------------
4181 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
4182 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4183 0, ED_AREA_1X1_SETTINGS_YOFF,
4184 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
4185 &custom_element_change.target_element, 1, 1,
4186 NULL, "after/when:", NULL, NULL, "new target element after change"
4189 // ---------- custom change content (extended change target) ----------------
4192 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
4193 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
4194 0, ED_AREA_3X3_SETTINGS_YOFF,
4195 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
4196 &custom_element_change.target_content.e[0][0], 3, 3,
4197 NULL, NULL, NULL, NULL, "new extended elements after change"
4200 // ---------- custom change trigger (element causing change) ----------------
4203 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
4204 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
4205 0, ED_AREA_1X1_SETTINGS_YOFF,
4206 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
4207 &custom_element_change.initial_trigger_element, 1, 1,
4208 NULL, NULL, NULL, NULL, "other element triggering change"
4211 // ---------- custom change action (element used for action) ----------------
4214 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
4215 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
4216 0, ED_AREA_1X1_SETTINGS_YOFF,
4217 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
4218 &custom_element_change.action_element, 1, 1,
4219 NULL, NULL, NULL, NULL, "element used as action parameter"
4222 // ---------- group element content -----------------------------------------
4225 ED_DRAWING_ID_GROUP_CONTENT,
4226 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4227 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4228 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
4229 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
4230 "content:", NULL, NULL, NULL, NULL
4233 // ---------- random background (for random painting) -----------------------
4236 ED_DRAWING_ID_RANDOM_BACKGROUND,
4237 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
4238 0, ED_AREA_1X1_LSETTINGS_YOFF,
4239 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
4240 &random_placement_background_element, 1, 1,
4241 NULL, NULL, NULL, NULL, "random placement background"
4246 // ----------------------------------------------------------------------------
4247 // some internally used variables
4248 // ----------------------------------------------------------------------------
4250 // maximal size of level editor drawing area
4251 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
4253 // actual size of level editor drawing area
4254 static int ed_fieldx, ed_fieldy;
4256 // actual position of level editor drawing area in level playfield
4257 static int level_xpos = -1, level_ypos = -1;
4259 // actual tile size used to display playfield drawing area
4260 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
4261 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
4263 #define IN_ED_FIELD(x, y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
4265 // drawing elements on the three mouse buttons
4266 static int new_element1 = EL_WALL;
4267 static int new_element2 = EL_EMPTY;
4268 static int new_element3 = EL_SAND;
4270 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
4271 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
4272 (button) == 2 ? new_element2 : \
4273 (button) == 3 ? new_element3 : EL_EMPTY)
4275 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
4277 static int use_permanent_palette = TRUE;
4279 #define PX (use_permanent_palette ? DX : SX)
4280 #define PY (use_permanent_palette ? DY : SY)
4281 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
4282 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
4284 // forward declaration for internal use
4285 static void CopyBrushToCursor(int, int);
4286 static void DeleteBrushFromCursor(void);
4287 static void ModifyEditorCounterValue(int, int);
4288 static void ModifyEditorCounterLimits(int, int, int);
4289 static void ModifyEditorSelectboxValue(int, int);
4290 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
4291 static void ModifyEditorDrawingArea(int, int, int);
4292 static void ModifyEditorElementList(void);
4293 static void AdjustElementListScrollbar(void);
4294 static void RedrawDrawingElements(void);
4295 static void DrawDrawingWindowExt(boolean);
4296 static void DrawDrawingWindow(void);
4297 static void DrawLevelConfigWindow(void);
4298 static void DrawPropertiesWindow(void);
4299 static void DrawPaletteWindow(void);
4300 static void UpdateCustomElementGraphicGadgets(void);
4301 static boolean checkPropertiesConfig(int);
4302 static void SetAutomaticNumberOfGemsNeeded(void);
4303 static void ClearEditorGadgetInfoText(void);
4304 static void CopyLevelToUndoBuffer(int);
4305 static void HandleDrawingAreas(struct GadgetInfo *);
4306 static void HandleCounterButtons(struct GadgetInfo *);
4307 static void HandleTextInputGadgets(struct GadgetInfo *);
4308 static void HandleTextAreaGadgets(struct GadgetInfo *);
4309 static void HandleSelectboxGadgets(struct GadgetInfo *);
4310 static void HandleTextbuttonGadgets(struct GadgetInfo *);
4311 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
4312 static void HandleRadiobuttons(struct GadgetInfo *);
4313 static void HandleCheckbuttons(struct GadgetInfo *);
4314 static void HandleControlButtons(struct GadgetInfo *);
4315 static void HandleDrawingAreaInfo(struct GadgetInfo *);
4316 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
4317 static boolean AskToCopyAndModifyLevelTemplate(void);
4318 static boolean getDrawModeHiRes(void);
4319 static int getTabulatorBarWidth(void);
4320 static int getTabulatorBarHeight(void);
4321 static Pixel getTabulatorBarColor(void);
4322 static int numHiresTiles(int);
4324 static int num_editor_gadgets = 0; // dynamically determined
4326 static struct GadgetInfo **level_editor_gadget = NULL;
4327 static int *right_gadget_border = NULL;
4329 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
4330 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
4331 static boolean draw_with_brush = FALSE;
4332 static int properties_element = 0;
4334 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4335 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4336 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4337 static int undo_buffer_position = 0;
4338 static int undo_buffer_steps = 0;
4339 static int redo_buffer_steps = 0;
4341 static int edit_mode;
4342 static int edit_mode_levelconfig;
4343 static int edit_mode_properties;
4345 static int element_shift = 0;
4347 static int editor_el_players[] =
4354 static int *editor_el_players_ptr = editor_el_players;
4355 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4357 static int editor_hl_boulderdash[] =
4359 EL_INTERNAL_CASCADE_BD_ACTIVE,
4365 static int editor_el_boulderdash[] =
4374 EL_BD_EXPANDABLE_WALL,
4382 EL_BD_BUTTERFLY_LEFT,
4384 EL_BD_BUTTERFLY_RIGHT,
4385 EL_BD_FIREFLY_RIGHT,
4388 EL_BD_BUTTERFLY_DOWN,
4392 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4393 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4394 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4395 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4397 static int editor_hl_boulderdash_native[] =
4399 EL_INTERNAL_CASCADE_BD_NATIVE_ACTIVE,
4405 static int editor_el_boulderdash_native[] =
4422 EL_BD_BUTTERFLY_LEFT,
4424 EL_BD_BUTTERFLY_RIGHT,
4425 EL_BD_FIREFLY_RIGHT,
4428 EL_BD_BUTTERFLY_DOWN,
4433 EL_BD_BUTTERFLY_2_UP,
4437 EL_BD_BUTTERFLY_2_LEFT,
4438 EL_BD_FIREFLY_2_LEFT,
4439 EL_BD_BUTTERFLY_2_RIGHT,
4440 EL_BD_FIREFLY_2_RIGHT,
4443 EL_BD_BUTTERFLY_2_DOWN,
4444 EL_BD_FIREFLY_2_DOWN,
4452 EL_BD_DRAGONFLY_LEFT,
4453 EL_BD_STONEFLY_LEFT,
4454 EL_BD_DRAGONFLY_RIGHT,
4455 EL_BD_STONEFLY_RIGHT,
4458 EL_BD_DRAGONFLY_DOWN,
4459 EL_BD_STONEFLY_DOWN,
4482 EL_BD_SAND_SLOPED_UP_LEFT,
4483 EL_BD_SAND_SLOPED_UP_RIGHT,
4484 EL_BD_WALL_SLOPED_UP_LEFT,
4485 EL_BD_WALL_SLOPED_UP_RIGHT,
4487 EL_BD_SAND_SLOPED_DOWN_LEFT,
4488 EL_BD_SAND_SLOPED_DOWN_RIGHT,
4489 EL_BD_WALL_SLOPED_DOWN_LEFT,
4490 EL_BD_WALL_SLOPED_DOWN_RIGHT,
4492 EL_BD_FLYING_DIAMOND,
4494 EL_BD_STEELWALL_SLOPED_UP_LEFT,
4495 EL_BD_STEELWALL_SLOPED_UP_RIGHT,
4499 EL_BD_STEELWALL_SLOPED_DOWN_LEFT,
4500 EL_BD_STEELWALL_SLOPED_DOWN_RIGHT,
4503 EL_BD_WALL_NON_SLOPED,
4509 EL_BD_INVISIBLE_EXIT_CLOSED,
4510 EL_BD_INVISIBLE_EXIT_OPEN,
4513 EL_BD_STEELWALL_EXPLODABLE,
4514 EL_BD_STEELWALL_DIGGABLE,
4515 EL_BD_WALL_DIGGABLE,
4517 EL_BD_EXPANDABLE_WALL_HORIZONTAL,
4518 EL_BD_EXPANDABLE_WALL_VERTICAL,
4519 EL_BD_EXPANDABLE_WALL_ANY,
4520 EL_BD_CREATURE_SWITCH,
4522 EL_BD_EXPANDABLE_STEELWALL_HORIZONTAL,
4523 EL_BD_EXPANDABLE_STEELWALL_VERTICAL,
4524 EL_BD_EXPANDABLE_STEELWALL_ANY,
4525 EL_BD_EXPANDABLE_WALL_SWITCH_HORIZONTAL,
4527 EL_BD_BITER_SWITCH_1,
4528 EL_BD_REPLICATOR_SWITCH,
4529 EL_BD_CONVEYOR_SWITCH,
4530 EL_BD_CONVEYOR_DIR_SWITCH_RIGHT,
4539 EL_BD_DIAMOND_GLUED,
4542 EL_BD_TRAPPED_DIAMOND,
4562 EL_BD_GRAVITY_SWITCH,
4563 EL_BD_PNEUMATIC_HAMMER,
4570 EL_BD_BLADDER_SPENDER,
4572 EL_BD_CONVEYOR_LEFT,
4573 EL_BD_CONVEYOR_RIGHT,
4588 EL_BD_PLAYER_WITH_BOMB,
4590 EL_BD_PLAYER_STIRRING,
4592 static int *editor_hl_boulderdash_native_ptr = editor_hl_boulderdash_native;
4593 static int *editor_el_boulderdash_native_ptr = editor_el_boulderdash_native;
4594 static int num_editor_hl_boulderdash_native = ARRAY_SIZE(editor_hl_boulderdash_native);
4595 static int num_editor_el_boulderdash_native = ARRAY_SIZE(editor_el_boulderdash_native);
4597 static int editor_hl_emerald_mine[] =
4599 EL_INTERNAL_CASCADE_EM_ACTIVE,
4605 static int editor_el_emerald_mine[] =
4623 EL_EM_DYNAMITE_ACTIVE,
4642 EL_ACID_POOL_TOPLEFT,
4644 EL_ACID_POOL_TOPRIGHT,
4647 EL_ACID_POOL_BOTTOMLEFT,
4648 EL_ACID_POOL_BOTTOM,
4649 EL_ACID_POOL_BOTTOMRIGHT,
4667 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4668 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4669 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4670 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4672 static int editor_hl_emerald_mine_club[] =
4674 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4680 static int editor_el_emerald_mine_club[] =
4707 EL_EMC_WALL_SLIPPERY_1,
4708 EL_EMC_WALL_SLIPPERY_2,
4709 EL_EMC_WALL_SLIPPERY_3,
4710 EL_EMC_WALL_SLIPPERY_4,
4733 EL_EMC_MAGIC_BALL_SWITCH,
4740 EL_EMC_SPRING_BUMPER,
4744 EL_BALLOON_SWITCH_UP,
4745 EL_BALLOON_SWITCH_ANY,
4748 EL_BALLOON_SWITCH_LEFT,
4750 EL_BALLOON_SWITCH_RIGHT,
4754 EL_BALLOON_SWITCH_DOWN,
4755 EL_BALLOON_SWITCH_NONE,
4757 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4758 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4759 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4760 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4762 static int editor_hl_rnd[] =
4764 EL_INTERNAL_CASCADE_RND_ACTIVE,
4770 static int editor_el_rnd[] =
4773 EL_DYNAMITE_ACTIVE, // RND
4807 EL_WALL_EMERALD_YELLOW,
4808 EL_WALL_EMERALD_RED,
4809 EL_WALL_EMERALD_PURPLE,
4827 EL_DYNABOMB_INCREASE_NUMBER,
4828 EL_DYNABOMB_INCREASE_SIZE,
4829 EL_DYNABOMB_INCREASE_POWER,
4849 EL_INVISIBLE_STEELWALL,
4853 EL_EXPANDABLE_WALL_HORIZONTAL,
4854 EL_EXPANDABLE_WALL_VERTICAL,
4855 EL_EXPANDABLE_WALL_ANY,
4857 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4858 static int *editor_el_rnd_ptr = editor_el_rnd;
4859 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4860 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4862 static int editor_hl_sokoban[] =
4864 EL_INTERNAL_CASCADE_SB_ACTIVE,
4870 static int editor_el_sokoban[] =
4873 EL_SOKOBAN_FIELD_EMPTY,
4874 EL_SOKOBAN_FIELD_FULL,
4875 EL_SOKOBAN_FIELD_PLAYER,
4877 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4878 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4879 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4880 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4882 static int editor_hl_supaplex[] =
4884 EL_INTERNAL_CASCADE_SP_ACTIVE,
4890 static int editor_el_supaplex[] =
4908 EL_SP_PORT_HORIZONTAL,
4909 EL_SP_PORT_VERTICAL,
4917 EL_SP_GRAVITY_PORT_LEFT,
4918 EL_SP_GRAVITY_PORT_RIGHT,
4919 EL_SP_GRAVITY_PORT_UP,
4920 EL_SP_GRAVITY_PORT_DOWN,
4922 EL_SP_GRAVITY_ON_PORT_LEFT,
4923 EL_SP_GRAVITY_ON_PORT_RIGHT,
4924 EL_SP_GRAVITY_ON_PORT_UP,
4925 EL_SP_GRAVITY_ON_PORT_DOWN,
4927 EL_SP_GRAVITY_OFF_PORT_LEFT,
4928 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4929 EL_SP_GRAVITY_OFF_PORT_UP,
4930 EL_SP_GRAVITY_OFF_PORT_DOWN,
4932 EL_SP_HARDWARE_GRAY,
4933 EL_SP_HARDWARE_GREEN,
4934 EL_SP_HARDWARE_BLUE,
4937 EL_SP_HARDWARE_BASE_1,
4938 EL_SP_HARDWARE_BASE_2,
4939 EL_SP_HARDWARE_BASE_3,
4940 EL_SP_HARDWARE_BASE_4,
4942 EL_SP_HARDWARE_BASE_5,
4943 EL_SP_HARDWARE_BASE_6,
4944 EL_SP_HARDWARE_YELLOW,
4952 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4953 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4954 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4955 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4957 static int editor_hl_diamond_caves[] =
4959 EL_INTERNAL_CASCADE_DC_ACTIVE,
4965 static int editor_el_diamond_caves[] =
4967 EL_EM_STEEL_EXIT_CLOSED, // DC2
4968 EL_EM_STEEL_EXIT_OPEN, // DC2
4969 EL_WALL_EMERALD, // DC2
4970 EL_WALL_DIAMOND, // DC2
4977 EL_CONVEYOR_BELT_1_LEFT,
4978 EL_CONVEYOR_BELT_1_MIDDLE,
4979 EL_CONVEYOR_BELT_1_RIGHT,
4980 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4982 EL_CONVEYOR_BELT_2_LEFT,
4983 EL_CONVEYOR_BELT_2_MIDDLE,
4984 EL_CONVEYOR_BELT_2_RIGHT,
4985 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4987 EL_CONVEYOR_BELT_3_LEFT,
4988 EL_CONVEYOR_BELT_3_MIDDLE,
4989 EL_CONVEYOR_BELT_3_RIGHT,
4990 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4992 EL_CONVEYOR_BELT_4_LEFT,
4993 EL_CONVEYOR_BELT_4_MIDDLE,
4994 EL_CONVEYOR_BELT_4_RIGHT,
4995 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4997 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4998 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4999 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
5000 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
5002 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
5003 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
5004 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
5005 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
5010 EL_DC_TIMEGATE_SWITCH,
5012 EL_SWITCHGATE_CLOSED,
5014 EL_SWITCHGATE_SWITCH_UP,
5015 EL_SWITCHGATE_SWITCH_DOWN,
5018 EL_LIGHT_SWITCH_ACTIVE,
5019 EL_DC_SWITCHGATE_SWITCH_UP,
5020 EL_DC_SWITCHGATE_SWITCH_DOWN,
5022 EL_STEEL_EXIT_CLOSED,
5024 EL_STEELWALL_SLIPPERY,
5027 EL_QUICKSAND_FAST_EMPTY,
5028 EL_QUICKSAND_FAST_FULL,
5042 EL_SIGN_RADIOACTIVITY,
5048 EL_SIGN_ENTRY_FORBIDDEN,
5049 EL_SIGN_EMERGENCY_EXIT,
5074 EL_DC_STEELWALL_2_SINGLE,
5075 EL_DC_STEELWALL_2_TOP,
5076 EL_SIGN_EXCLAMATION,
5079 EL_DC_STEELWALL_2_LEFT,
5080 EL_DC_STEELWALL_2_MIDDLE,
5081 EL_DC_STEELWALL_2_HORIZONTAL,
5082 EL_DC_STEELWALL_2_RIGHT,
5084 EL_DC_STEELWALL_1_TOPLEFT,
5085 EL_DC_STEELWALL_2_VERTICAL,
5086 EL_DC_STEELWALL_1_TOPRIGHT,
5089 EL_DC_STEELWALL_1_VERTICAL,
5090 EL_DC_STEELWALL_2_BOTTOM,
5092 EL_DC_GATE_WHITE_GRAY,
5094 EL_DC_STEELWALL_1_BOTTOMLEFT,
5095 EL_DC_STEELWALL_1_HORIZONTAL,
5096 EL_DC_STEELWALL_1_BOTTOMRIGHT,
5097 EL_DC_GATE_FAKE_GRAY,
5099 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
5100 EL_DC_STEELWALL_1_BOTTOM,
5101 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
5102 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
5104 EL_DC_STEELWALL_1_RIGHT,
5106 EL_DC_STEELWALL_1_LEFT,
5107 EL_EXPANDABLE_STEELWALL_VERTICAL,
5109 EL_DC_STEELWALL_1_TOPRIGHT_2,
5110 EL_DC_STEELWALL_1_TOP,
5111 EL_DC_STEELWALL_1_TOPLEFT_2,
5112 EL_EXPANDABLE_STEELWALL_ANY,
5114 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
5115 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
5116 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
5117 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
5119 static int editor_hl_dx_boulderdash[] =
5121 EL_INTERNAL_CASCADE_DX_ACTIVE,
5127 static int editor_el_dx_boulderdash[] =
5131 EL_TUBE_HORIZONTAL_DOWN,
5135 EL_TUBE_VERTICAL_RIGHT,
5137 EL_TUBE_VERTICAL_LEFT,
5141 EL_TUBE_HORIZONTAL_UP,
5149 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
5150 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
5151 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
5152 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
5154 static int editor_hl_mirror_magic[] =
5156 EL_INTERNAL_CASCADE_MM_ACTIVE,
5162 static int editor_el_mirror_magic[] =
5164 EL_MM_MCDUFFIN_RIGHT,
5166 EL_MM_MCDUFFIN_LEFT,
5167 EL_MM_MCDUFFIN_DOWN,
5170 EL_MM_MIRROR_FIXED_START,
5171 EL_MM_POLARIZER_START,
5172 EL_MM_POLARIZER_CROSS_START,
5174 EL_MM_TELEPORTER_RED_START,
5175 EL_MM_TELEPORTER_YELLOW_START,
5176 EL_MM_TELEPORTER_GREEN_START,
5177 EL_MM_TELEPORTER_BLUE_START,
5190 EL_MM_LIGHTBULB_ACTIVE,
5204 EL_MM_STEEL_GRID_FIXED_1,
5205 EL_MM_STEEL_GRID_FIXED_2,
5206 EL_MM_STEEL_GRID_FIXED_3,
5207 EL_MM_STEEL_GRID_FIXED_4,
5209 EL_MM_WOODEN_GRID_FIXED_1,
5210 EL_MM_WOODEN_GRID_FIXED_2,
5211 EL_MM_WOODEN_GRID_FIXED_3,
5212 EL_MM_WOODEN_GRID_FIXED_4,
5219 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
5220 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
5221 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
5222 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
5224 static int editor_hl_deflektor[] =
5226 EL_INTERNAL_CASCADE_DF_ACTIVE,
5232 static int editor_el_deflektor[] =
5239 EL_DF_RECEIVER_RIGHT,
5241 EL_DF_RECEIVER_LEFT,
5242 EL_DF_RECEIVER_DOWN,
5245 EL_DF_MIRROR_ROTATING_START,
5246 EL_DF_MIRROR_FIXED_START,
5249 EL_DF_FIBRE_OPTIC_RED_1,
5250 EL_DF_FIBRE_OPTIC_YELLOW_1,
5251 EL_DF_FIBRE_OPTIC_GREEN_1,
5252 EL_DF_FIBRE_OPTIC_BLUE_1,
5254 EL_DF_STEEL_GRID_FIXED_START,
5255 EL_DF_STEEL_GRID_ROTATING_START,
5256 EL_DF_WOODEN_GRID_FIXED_START,
5257 EL_DF_WOODEN_GRID_ROTATING_START,
5269 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
5270 static int *editor_el_deflektor_ptr = editor_el_deflektor;
5271 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
5272 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
5274 static int editor_hl_chars[] =
5276 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
5282 static int editor_el_chars[] =
5364 EL_CHAR(CHAR_BYTE_COPYRIGHT),
5365 EL_CHAR(CHAR_BYTE_UMLAUT_A),
5366 EL_CHAR(CHAR_BYTE_UMLAUT_O),
5367 EL_CHAR(CHAR_BYTE_UMLAUT_U),
5369 EL_CHAR(CHAR_BYTE_DEGREE),
5370 EL_CHAR(CHAR_BYTE_REGISTERED),
5371 EL_CHAR(FONT_ASCII_CURSOR),
5372 EL_CHAR(FONT_ASCII_BUTTON),
5374 EL_CHAR(FONT_ASCII_UP),
5375 EL_CHAR(FONT_ASCII_DOWN),
5379 static int *editor_hl_chars_ptr = editor_hl_chars;
5380 static int *editor_el_chars_ptr = editor_el_chars;
5381 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
5382 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
5384 static int editor_hl_steel_chars[] =
5386 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
5392 static int editor_el_steel_chars[] =
5402 EL_STEEL_CHAR('\''),
5469 EL_STEEL_CHAR('\\'),
5474 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
5475 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
5476 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
5477 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
5479 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
5480 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
5481 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
5482 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
5484 EL_STEEL_CHAR(FONT_ASCII_UP),
5485 EL_STEEL_CHAR(FONT_ASCII_DOWN),
5489 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
5490 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
5491 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
5492 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
5494 static int editor_hl_custom[] =
5496 EL_INTERNAL_CASCADE_CE_ACTIVE,
5502 static int editor_el_custom[] =
5504 EL_CUSTOM_START + 0,
5505 EL_CUSTOM_START + 1,
5506 EL_CUSTOM_START + 2,
5507 EL_CUSTOM_START + 3,
5509 EL_CUSTOM_START + 4,
5510 EL_CUSTOM_START + 5,
5511 EL_CUSTOM_START + 6,
5512 EL_CUSTOM_START + 7,
5514 EL_CUSTOM_START + 8,
5515 EL_CUSTOM_START + 9,
5516 EL_CUSTOM_START + 10,
5517 EL_CUSTOM_START + 11,
5519 EL_CUSTOM_START + 12,
5520 EL_CUSTOM_START + 13,
5521 EL_CUSTOM_START + 14,
5522 EL_CUSTOM_START + 15,
5524 EL_CUSTOM_START + 16,
5525 EL_CUSTOM_START + 17,
5526 EL_CUSTOM_START + 18,
5527 EL_CUSTOM_START + 19,
5529 EL_CUSTOM_START + 20,
5530 EL_CUSTOM_START + 21,
5531 EL_CUSTOM_START + 22,
5532 EL_CUSTOM_START + 23,
5534 EL_CUSTOM_START + 24,
5535 EL_CUSTOM_START + 25,
5536 EL_CUSTOM_START + 26,
5537 EL_CUSTOM_START + 27,
5539 EL_CUSTOM_START + 28,
5540 EL_CUSTOM_START + 29,
5541 EL_CUSTOM_START + 30,
5542 EL_CUSTOM_START + 31,
5544 EL_CUSTOM_START + 32,
5545 EL_CUSTOM_START + 33,
5546 EL_CUSTOM_START + 34,
5547 EL_CUSTOM_START + 35,
5549 EL_CUSTOM_START + 36,
5550 EL_CUSTOM_START + 37,
5551 EL_CUSTOM_START + 38,
5552 EL_CUSTOM_START + 39,
5554 EL_CUSTOM_START + 40,
5555 EL_CUSTOM_START + 41,
5556 EL_CUSTOM_START + 42,
5557 EL_CUSTOM_START + 43,
5559 EL_CUSTOM_START + 44,
5560 EL_CUSTOM_START + 45,
5561 EL_CUSTOM_START + 46,
5562 EL_CUSTOM_START + 47,
5564 EL_CUSTOM_START + 48,
5565 EL_CUSTOM_START + 49,
5566 EL_CUSTOM_START + 50,
5567 EL_CUSTOM_START + 51,
5569 EL_CUSTOM_START + 52,
5570 EL_CUSTOM_START + 53,
5571 EL_CUSTOM_START + 54,
5572 EL_CUSTOM_START + 55,
5574 EL_CUSTOM_START + 56,
5575 EL_CUSTOM_START + 57,
5576 EL_CUSTOM_START + 58,
5577 EL_CUSTOM_START + 59,
5579 EL_CUSTOM_START + 60,
5580 EL_CUSTOM_START + 61,
5581 EL_CUSTOM_START + 62,
5582 EL_CUSTOM_START + 63,
5584 EL_CUSTOM_START + 64,
5585 EL_CUSTOM_START + 65,
5586 EL_CUSTOM_START + 66,
5587 EL_CUSTOM_START + 67,
5589 EL_CUSTOM_START + 68,
5590 EL_CUSTOM_START + 69,
5591 EL_CUSTOM_START + 70,
5592 EL_CUSTOM_START + 71,
5594 EL_CUSTOM_START + 72,
5595 EL_CUSTOM_START + 73,
5596 EL_CUSTOM_START + 74,
5597 EL_CUSTOM_START + 75,
5599 EL_CUSTOM_START + 76,
5600 EL_CUSTOM_START + 77,
5601 EL_CUSTOM_START + 78,
5602 EL_CUSTOM_START + 79,
5604 EL_CUSTOM_START + 80,
5605 EL_CUSTOM_START + 81,
5606 EL_CUSTOM_START + 82,
5607 EL_CUSTOM_START + 83,
5609 EL_CUSTOM_START + 84,
5610 EL_CUSTOM_START + 85,
5611 EL_CUSTOM_START + 86,
5612 EL_CUSTOM_START + 87,
5614 EL_CUSTOM_START + 88,
5615 EL_CUSTOM_START + 89,
5616 EL_CUSTOM_START + 90,
5617 EL_CUSTOM_START + 91,
5619 EL_CUSTOM_START + 92,
5620 EL_CUSTOM_START + 93,
5621 EL_CUSTOM_START + 94,
5622 EL_CUSTOM_START + 95,
5624 EL_CUSTOM_START + 96,
5625 EL_CUSTOM_START + 97,
5626 EL_CUSTOM_START + 98,
5627 EL_CUSTOM_START + 99,
5629 EL_CUSTOM_START + 100,
5630 EL_CUSTOM_START + 101,
5631 EL_CUSTOM_START + 102,
5632 EL_CUSTOM_START + 103,
5634 EL_CUSTOM_START + 104,
5635 EL_CUSTOM_START + 105,
5636 EL_CUSTOM_START + 106,
5637 EL_CUSTOM_START + 107,
5639 EL_CUSTOM_START + 108,
5640 EL_CUSTOM_START + 109,
5641 EL_CUSTOM_START + 110,
5642 EL_CUSTOM_START + 111,
5644 EL_CUSTOM_START + 112,
5645 EL_CUSTOM_START + 113,
5646 EL_CUSTOM_START + 114,
5647 EL_CUSTOM_START + 115,
5649 EL_CUSTOM_START + 116,
5650 EL_CUSTOM_START + 117,
5651 EL_CUSTOM_START + 118,
5652 EL_CUSTOM_START + 119,
5654 EL_CUSTOM_START + 120,
5655 EL_CUSTOM_START + 121,
5656 EL_CUSTOM_START + 122,
5657 EL_CUSTOM_START + 123,
5659 EL_CUSTOM_START + 124,
5660 EL_CUSTOM_START + 125,
5661 EL_CUSTOM_START + 126,
5662 EL_CUSTOM_START + 127,
5664 EL_CUSTOM_START + 128,
5665 EL_CUSTOM_START + 129,
5666 EL_CUSTOM_START + 130,
5667 EL_CUSTOM_START + 131,
5669 EL_CUSTOM_START + 132,
5670 EL_CUSTOM_START + 133,
5671 EL_CUSTOM_START + 134,
5672 EL_CUSTOM_START + 135,
5674 EL_CUSTOM_START + 136,
5675 EL_CUSTOM_START + 137,
5676 EL_CUSTOM_START + 138,
5677 EL_CUSTOM_START + 139,
5679 EL_CUSTOM_START + 140,
5680 EL_CUSTOM_START + 141,
5681 EL_CUSTOM_START + 142,
5682 EL_CUSTOM_START + 143,
5684 EL_CUSTOM_START + 144,
5685 EL_CUSTOM_START + 145,
5686 EL_CUSTOM_START + 146,
5687 EL_CUSTOM_START + 147,
5689 EL_CUSTOM_START + 148,
5690 EL_CUSTOM_START + 149,
5691 EL_CUSTOM_START + 150,
5692 EL_CUSTOM_START + 151,
5694 EL_CUSTOM_START + 152,
5695 EL_CUSTOM_START + 153,
5696 EL_CUSTOM_START + 154,
5697 EL_CUSTOM_START + 155,
5699 EL_CUSTOM_START + 156,
5700 EL_CUSTOM_START + 157,
5701 EL_CUSTOM_START + 158,
5702 EL_CUSTOM_START + 159,
5704 EL_CUSTOM_START + 160,
5705 EL_CUSTOM_START + 161,
5706 EL_CUSTOM_START + 162,
5707 EL_CUSTOM_START + 163,
5709 EL_CUSTOM_START + 164,
5710 EL_CUSTOM_START + 165,
5711 EL_CUSTOM_START + 166,
5712 EL_CUSTOM_START + 167,
5714 EL_CUSTOM_START + 168,
5715 EL_CUSTOM_START + 169,
5716 EL_CUSTOM_START + 170,
5717 EL_CUSTOM_START + 171,
5719 EL_CUSTOM_START + 172,
5720 EL_CUSTOM_START + 173,
5721 EL_CUSTOM_START + 174,
5722 EL_CUSTOM_START + 175,
5724 EL_CUSTOM_START + 176,
5725 EL_CUSTOM_START + 177,
5726 EL_CUSTOM_START + 178,
5727 EL_CUSTOM_START + 179,
5729 EL_CUSTOM_START + 180,
5730 EL_CUSTOM_START + 181,
5731 EL_CUSTOM_START + 182,
5732 EL_CUSTOM_START + 183,
5734 EL_CUSTOM_START + 184,
5735 EL_CUSTOM_START + 185,
5736 EL_CUSTOM_START + 186,
5737 EL_CUSTOM_START + 187,
5739 EL_CUSTOM_START + 188,
5740 EL_CUSTOM_START + 189,
5741 EL_CUSTOM_START + 190,
5742 EL_CUSTOM_START + 191,
5744 EL_CUSTOM_START + 192,
5745 EL_CUSTOM_START + 193,
5746 EL_CUSTOM_START + 194,
5747 EL_CUSTOM_START + 195,
5749 EL_CUSTOM_START + 196,
5750 EL_CUSTOM_START + 197,
5751 EL_CUSTOM_START + 198,
5752 EL_CUSTOM_START + 199,
5754 EL_CUSTOM_START + 200,
5755 EL_CUSTOM_START + 201,
5756 EL_CUSTOM_START + 202,
5757 EL_CUSTOM_START + 203,
5759 EL_CUSTOM_START + 204,
5760 EL_CUSTOM_START + 205,
5761 EL_CUSTOM_START + 206,
5762 EL_CUSTOM_START + 207,
5764 EL_CUSTOM_START + 208,
5765 EL_CUSTOM_START + 209,
5766 EL_CUSTOM_START + 210,
5767 EL_CUSTOM_START + 211,
5769 EL_CUSTOM_START + 212,
5770 EL_CUSTOM_START + 213,
5771 EL_CUSTOM_START + 214,
5772 EL_CUSTOM_START + 215,
5774 EL_CUSTOM_START + 216,
5775 EL_CUSTOM_START + 217,
5776 EL_CUSTOM_START + 218,
5777 EL_CUSTOM_START + 219,
5779 EL_CUSTOM_START + 220,
5780 EL_CUSTOM_START + 221,
5781 EL_CUSTOM_START + 222,
5782 EL_CUSTOM_START + 223,
5784 EL_CUSTOM_START + 224,
5785 EL_CUSTOM_START + 225,
5786 EL_CUSTOM_START + 226,
5787 EL_CUSTOM_START + 227,
5789 EL_CUSTOM_START + 228,
5790 EL_CUSTOM_START + 229,
5791 EL_CUSTOM_START + 230,
5792 EL_CUSTOM_START + 231,
5794 EL_CUSTOM_START + 232,
5795 EL_CUSTOM_START + 233,
5796 EL_CUSTOM_START + 234,
5797 EL_CUSTOM_START + 235,
5799 EL_CUSTOM_START + 236,
5800 EL_CUSTOM_START + 237,
5801 EL_CUSTOM_START + 238,
5802 EL_CUSTOM_START + 239,
5804 EL_CUSTOM_START + 240,
5805 EL_CUSTOM_START + 241,
5806 EL_CUSTOM_START + 242,
5807 EL_CUSTOM_START + 243,
5809 EL_CUSTOM_START + 244,
5810 EL_CUSTOM_START + 245,
5811 EL_CUSTOM_START + 246,
5812 EL_CUSTOM_START + 247,
5814 EL_CUSTOM_START + 248,
5815 EL_CUSTOM_START + 249,
5816 EL_CUSTOM_START + 250,
5817 EL_CUSTOM_START + 251,
5819 EL_CUSTOM_START + 252,
5820 EL_CUSTOM_START + 253,
5821 EL_CUSTOM_START + 254,
5822 EL_CUSTOM_START + 255
5824 static int *editor_hl_custom_ptr = editor_hl_custom;
5825 static int *editor_el_custom_ptr = editor_el_custom;
5826 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5827 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5829 static int editor_hl_group[] =
5831 EL_INTERNAL_CASCADE_GE_ACTIVE,
5837 static int editor_el_group[] =
5851 EL_GROUP_START + 10,
5852 EL_GROUP_START + 11,
5854 EL_GROUP_START + 12,
5855 EL_GROUP_START + 13,
5856 EL_GROUP_START + 14,
5857 EL_GROUP_START + 15,
5859 EL_GROUP_START + 16,
5860 EL_GROUP_START + 17,
5861 EL_GROUP_START + 18,
5862 EL_GROUP_START + 19,
5864 EL_GROUP_START + 20,
5865 EL_GROUP_START + 21,
5866 EL_GROUP_START + 22,
5867 EL_GROUP_START + 23,
5869 EL_GROUP_START + 24,
5870 EL_GROUP_START + 25,
5871 EL_GROUP_START + 26,
5872 EL_GROUP_START + 27,
5874 EL_GROUP_START + 28,
5875 EL_GROUP_START + 29,
5876 EL_GROUP_START + 30,
5879 static int *editor_hl_group_ptr = editor_hl_group;
5880 static int *editor_el_group_ptr = editor_el_group;
5881 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5882 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5884 static int editor_hl_empty_space[] =
5886 EL_INTERNAL_CASCADE_ES_ACTIVE,
5892 static int editor_el_empty_space[] =
5914 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
5915 static int *editor_el_empty_space_ptr = editor_el_empty_space;
5916 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
5917 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
5919 static int editor_hl_reference[] =
5921 EL_INTERNAL_CASCADE_REF_ACTIVE,
5927 static int editor_el_reference[] =
5931 EL_TRIGGER_CE_VALUE,
5932 EL_TRIGGER_CE_SCORE,
5936 EL_CURRENT_CE_VALUE,
5937 EL_CURRENT_CE_SCORE,
5959 static int *editor_hl_reference_ptr = editor_hl_reference;
5960 static int *editor_el_reference_ptr = editor_el_reference;
5961 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5962 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5964 static int editor_hl_user_defined[] =
5966 EL_INTERNAL_CASCADE_USER_ACTIVE,
5972 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5973 static int *editor_el_user_defined_ptr = NULL;
5974 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5975 static int num_editor_el_user_defined = 0;
5977 static int editor_hl_dynamic[] =
5979 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5985 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5986 static int *editor_el_dynamic_ptr = NULL;
5987 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5988 static int num_editor_el_dynamic = 0;
5990 static int editor_hl_empty[] = { EL_EMPTY };
5991 static int *editor_el_empty = NULL; // dynamically allocated
5993 static int *editor_hl_empty_ptr = editor_hl_empty;
5994 static int *editor_el_empty_ptr = NULL;
5995 static int num_editor_hl_empty = 0;
5996 static int num_editor_el_empty = 0; // dynamically determined, if needed
5998 static boolean use_el_empty = FALSE;
6000 static int *editor_elements = NULL; // dynamically allocated
6001 static int num_editor_elements = 0; // dynamically determined
6003 static boolean setup_editor_cascade_never = FALSE;
6005 static boolean setup_editor_el_players = TRUE;
6006 static boolean setup_editor_el_boulderdash = TRUE;
6007 static boolean setup_editor_el_boulderdash_native = TRUE;
6008 static boolean setup_editor_el_emerald_mine = TRUE;
6009 static boolean setup_editor_el_emerald_mine_club = TRUE;
6010 static boolean setup_editor_el_more = TRUE;
6011 static boolean setup_editor_el_sokoban = TRUE;
6012 static boolean setup_editor_el_supaplex = TRUE;
6013 static boolean setup_editor_el_diamond_caves = TRUE;
6014 static boolean setup_editor_el_dx_boulderdash = TRUE;
6015 static boolean setup_editor_el_mirror_magic = TRUE;
6016 static boolean setup_editor_el_deflektor = TRUE;
6017 static boolean setup_editor_el_chars = TRUE;
6018 static boolean setup_editor_el_steel_chars = TRUE;
6019 static boolean setup_editor_el_custom = TRUE;
6020 static boolean setup_editor_el_user_defined = TRUE;
6021 static boolean setup_editor_el_dynamic = TRUE;
6023 static int editor_hl_unused[] = { EL_EMPTY };
6024 static int *editor_hl_unused_ptr = editor_hl_unused;
6025 static int num_editor_hl_unused = 0;
6029 boolean *setup_value;
6030 boolean *setup_cascade_value;
6032 int **headline_list;
6033 int *headline_list_size;
6036 int *element_list_size;
6038 boolean last_setup_value;
6040 editor_elements_info[] =
6043 &setup_editor_el_players,
6044 &setup_editor_cascade_never,
6045 &editor_hl_unused_ptr, &num_editor_hl_unused,
6046 &editor_el_players_ptr, &num_editor_el_players
6049 &setup_editor_el_boulderdash,
6050 &setup.editor_cascade.el_bd,
6051 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
6052 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
6055 &setup_editor_el_boulderdash_native,
6056 &setup.editor_cascade.el_bd_native,
6057 &editor_hl_boulderdash_native_ptr, &num_editor_hl_boulderdash_native,
6058 &editor_el_boulderdash_native_ptr, &num_editor_el_boulderdash_native
6061 &setup_editor_el_emerald_mine,
6062 &setup.editor_cascade.el_em,
6063 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
6064 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
6067 &setup_editor_el_emerald_mine_club,
6068 &setup.editor_cascade.el_emc,
6069 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
6070 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
6073 &setup_editor_el_more,
6074 &setup.editor_cascade.el_rnd,
6075 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
6076 &editor_el_rnd_ptr, &num_editor_el_rnd
6079 &setup_editor_el_sokoban,
6080 &setup.editor_cascade.el_sb,
6081 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
6082 &editor_el_sokoban_ptr, &num_editor_el_sokoban
6085 &setup_editor_el_supaplex,
6086 &setup.editor_cascade.el_sp,
6087 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
6088 &editor_el_supaplex_ptr, &num_editor_el_supaplex
6091 &setup_editor_el_diamond_caves,
6092 &setup.editor_cascade.el_dc,
6093 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
6094 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
6097 &setup_editor_el_dx_boulderdash,
6098 &setup.editor_cascade.el_dx,
6099 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
6100 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
6103 &setup_editor_el_mirror_magic,
6104 &setup.editor_cascade.el_mm,
6105 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
6106 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
6109 &setup_editor_el_deflektor,
6110 &setup.editor_cascade.el_df,
6111 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
6112 &editor_el_deflektor_ptr, &num_editor_el_deflektor
6115 &setup_editor_el_chars,
6116 &setup.editor_cascade.el_chars,
6117 &editor_hl_chars_ptr, &num_editor_hl_chars,
6118 &editor_el_chars_ptr, &num_editor_el_chars
6121 &setup_editor_el_steel_chars,
6122 &setup.editor_cascade.el_steel_chars,
6123 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
6124 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
6127 &setup_editor_el_custom,
6128 &setup.editor_cascade.el_ce,
6129 &editor_hl_custom_ptr, &num_editor_hl_custom,
6130 &editor_el_custom_ptr, &num_editor_el_custom
6133 &setup_editor_el_custom,
6134 &setup.editor_cascade.el_ge,
6135 &editor_hl_group_ptr, &num_editor_hl_group,
6136 &editor_el_group_ptr, &num_editor_el_group
6139 &setup_editor_el_custom,
6140 &setup.editor_cascade.el_es,
6141 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
6142 &editor_el_empty_space_ptr, &num_editor_el_empty_space
6145 &setup_editor_el_custom,
6146 &setup.editor_cascade.el_ref,
6147 &editor_hl_reference_ptr, &num_editor_hl_reference,
6148 &editor_el_reference_ptr, &num_editor_el_reference
6151 &setup_editor_el_user_defined,
6152 &setup.editor_cascade.el_user,
6153 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
6154 &editor_el_user_defined_ptr, &num_editor_el_user_defined
6157 &setup_editor_el_dynamic,
6158 &setup.editor_cascade.el_dynamic,
6159 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
6160 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
6165 &editor_hl_empty_ptr, &num_editor_hl_empty,
6166 &editor_el_empty_ptr, &num_editor_el_empty,
6176 static struct XY xy_directions[] =
6185 // ----------------------------------------------------------------------------
6187 // ----------------------------------------------------------------------------
6189 static int getMaxInfoTextLength(void)
6191 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
6194 static int getTextWidthForGadget(char *text)
6199 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
6202 static int getTextWidthForDrawingArea(char *text)
6207 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
6210 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
6212 return (gi->x + gi->width + getTextWidthForGadget(text));
6215 static char *getElementInfoText(int element)
6217 char *info_text = NULL;
6219 if (element < MAX_NUM_ELEMENTS)
6221 if (strlen(element_info[element].description) > 0)
6222 info_text = element_info[element].description;
6223 else if (element_info[element].custom_description != NULL)
6224 info_text = element_info[element].custom_description;
6225 else if (element_info[element].editor_description != NULL)
6226 info_text = element_info[element].editor_description;
6229 if (info_text == NULL)
6230 info_text = INFOTEXT_UNKNOWN_ELEMENT;
6235 static char *getElementDescriptionFilenameExt(char *basename)
6237 char *elements_subdir = ELEMENTS_DIRECTORY;
6238 static char *elements_subdir2 = NULL;
6239 static char *filename = NULL;
6241 if (elements_subdir2 == NULL)
6242 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
6244 checked_free(filename);
6246 // 1st try: look for element description in current level set directory
6247 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
6248 if (fileExists(filename))
6253 // 2nd try: look for element description in the game's base directory
6254 filename = getPath3(options.docs_directory, elements_subdir, basename);
6255 if (fileExists(filename))
6261 static char *getElementDescriptionFilename(int element)
6263 char basename[MAX_FILENAME_LEN];
6266 // 1st try: look for element description file for exactly this element
6267 sprintf(basename, "%s.txt", element_info[element].token_name);
6268 filename = getElementDescriptionFilenameExt(basename);
6269 if (filename != NULL)
6272 // 2nd try: look for element description file for this element's class
6273 sprintf(basename, "%s.txt", element_info[element].class_name);
6274 filename = getElementDescriptionFilenameExt(basename);
6275 if (filename != NULL)
6278 // 3rd try: look for generic fallback text file for any element
6279 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
6280 if (filename != NULL)
6286 static boolean suppressBorderElement(void)
6288 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
6289 lev_fieldx <= MAX_ED_FIELDX &&
6290 lev_fieldy <= MAX_ED_FIELDY);
6293 static void InitDynamicEditorElementList(int **elements, int *num_elements)
6295 boolean element_found[NUM_FILE_ELEMENTS];
6298 // initialize list of used elements to "not used"
6299 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6300 element_found[i] = FALSE;
6302 // find all elements used in current level
6303 for (y = 0; y < lev_fieldy; y++)
6305 for (x = 0; x < lev_fieldx; x++)
6307 if (Tile[x][y] >= NUM_FILE_ELEMENTS) // should never happen
6310 if (IS_MM_WALL(Tile[x][y]))
6311 element_found[map_mm_wall_element(Tile[x][y])] = TRUE;
6313 element_found[Tile[x][y]] = TRUE;
6319 // count number of elements used in current level
6320 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6321 if (element_found[i])
6324 // add space for up to 3 more elements for padding that may be needed
6327 // free memory for old list of elements, if needed
6328 checked_free(*elements);
6330 // allocate memory for new list of elements
6331 *elements = checked_malloc(*num_elements * sizeof(int));
6335 // add all elements used in current level (non-custom/group/empty elements)
6336 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6337 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) ||
6338 IS_GROUP_ELEMENT(i) ||
6339 IS_EMPTY_ELEMENT(i)))
6340 (*elements)[(*num_elements)++] = i;
6342 // add all elements used in current level (custom/group/empty elements)
6343 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6344 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) ||
6345 IS_GROUP_ELEMENT(i) ||
6346 IS_EMPTY_ELEMENT(i)))
6347 (*elements)[(*num_elements)++] = i;
6349 while (*num_elements % 4) // pad with empty elements, if needed
6350 (*elements)[(*num_elements)++] = EL_EMPTY;
6353 static void ReinitializeElementList_EnableSections(void)
6355 // default: enable all element sections
6357 setup_editor_el_players = TRUE;
6358 setup_editor_el_boulderdash = TRUE;
6359 setup_editor_el_boulderdash_native = TRUE;
6360 setup_editor_el_emerald_mine = TRUE;
6361 setup_editor_el_emerald_mine_club = TRUE;
6362 setup_editor_el_more = TRUE;
6363 setup_editor_el_sokoban = TRUE;
6364 setup_editor_el_supaplex = TRUE;
6365 setup_editor_el_diamond_caves = TRUE;
6366 setup_editor_el_dx_boulderdash = TRUE;
6367 setup_editor_el_mirror_magic = TRUE;
6368 setup_editor_el_deflektor = TRUE;
6369 setup_editor_el_chars = TRUE;
6370 setup_editor_el_steel_chars = TRUE;
6372 setup_editor_el_custom = TRUE;
6373 setup_editor_el_user_defined = TRUE;
6374 setup_editor_el_dynamic = TRUE;
6376 // now disable all element sections not to be displayed
6378 if (!setup.editor.el_classic)
6380 setup_editor_el_players = FALSE;
6381 setup_editor_el_boulderdash = FALSE;
6382 setup_editor_el_boulderdash_native = FALSE;
6383 setup_editor_el_emerald_mine = FALSE;
6384 setup_editor_el_emerald_mine_club = FALSE;
6385 setup_editor_el_more = FALSE;
6386 setup_editor_el_sokoban = FALSE;
6387 setup_editor_el_supaplex = FALSE;
6388 setup_editor_el_diamond_caves = FALSE;
6389 setup_editor_el_dx_boulderdash = FALSE;
6390 setup_editor_el_mirror_magic = FALSE;
6391 setup_editor_el_deflektor = FALSE;
6392 setup_editor_el_chars = FALSE;
6393 setup_editor_el_steel_chars = FALSE;
6396 if (!setup.editor.el_custom)
6398 setup_editor_el_custom = FALSE;
6401 if (!setup.editor.el_user_defined)
6403 setup_editor_el_user_defined = FALSE;
6406 if (!setup.editor.el_dynamic)
6408 setup_editor_el_dynamic = FALSE;
6411 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
6413 setup_editor_el_boulderdash_native = FALSE;
6414 setup_editor_el_mirror_magic = FALSE;
6415 setup_editor_el_deflektor = FALSE;
6417 else if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
6419 setup_editor_el_players = FALSE;
6420 setup_editor_el_boulderdash = FALSE;
6421 setup_editor_el_emerald_mine = FALSE;
6422 setup_editor_el_emerald_mine_club = FALSE;
6423 setup_editor_el_more = FALSE;
6424 setup_editor_el_sokoban = FALSE;
6425 setup_editor_el_supaplex = FALSE;
6426 setup_editor_el_diamond_caves = FALSE;
6427 setup_editor_el_dx_boulderdash = FALSE;
6428 setup_editor_el_mirror_magic = FALSE;
6429 setup_editor_el_deflektor = FALSE;
6430 setup_editor_el_chars = FALSE;
6431 setup_editor_el_steel_chars = FALSE;
6433 setup_editor_el_custom = FALSE;
6435 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
6437 setup_editor_el_boulderdash = FALSE;
6438 setup_editor_el_boulderdash_native = FALSE;
6439 setup_editor_el_more = FALSE;
6440 setup_editor_el_sokoban = FALSE;
6441 setup_editor_el_supaplex = FALSE;
6442 setup_editor_el_diamond_caves = FALSE;
6443 setup_editor_el_dx_boulderdash = FALSE;
6444 setup_editor_el_mirror_magic = FALSE;
6445 setup_editor_el_deflektor = FALSE;
6446 setup_editor_el_steel_chars = FALSE;
6448 setup_editor_el_custom = FALSE;
6450 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
6452 setup_editor_el_players = FALSE;
6453 setup_editor_el_boulderdash = FALSE;
6454 setup_editor_el_boulderdash_native = FALSE;
6455 setup_editor_el_emerald_mine = FALSE;
6456 setup_editor_el_emerald_mine_club = FALSE;
6457 setup_editor_el_more = FALSE;
6458 setup_editor_el_sokoban = FALSE;
6459 setup_editor_el_diamond_caves = FALSE;
6460 setup_editor_el_dx_boulderdash = FALSE;
6461 setup_editor_el_mirror_magic = FALSE;
6462 setup_editor_el_deflektor = FALSE;
6463 setup_editor_el_chars = FALSE;
6464 setup_editor_el_steel_chars = FALSE;
6466 setup_editor_el_custom = FALSE;
6468 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
6470 setup_editor_el_players = FALSE;
6471 setup_editor_el_boulderdash = FALSE;
6472 setup_editor_el_boulderdash_native = FALSE;
6473 setup_editor_el_emerald_mine = FALSE;
6474 setup_editor_el_emerald_mine_club = FALSE;
6475 setup_editor_el_more = FALSE;
6476 setup_editor_el_sokoban = FALSE;
6477 setup_editor_el_supaplex = FALSE;
6478 setup_editor_el_diamond_caves = FALSE;
6479 setup_editor_el_dx_boulderdash = FALSE;
6480 setup_editor_el_steel_chars = FALSE;
6482 setup_editor_el_custom = FALSE;
6486 static void ReinitializeElementList(void)
6488 static boolean initialization_needed = TRUE;
6492 ReinitializeElementList_EnableSections();
6494 if (initialization_needed)
6496 LoadSetup_EditorCascade(); // load last editor cascade state
6498 // initialize editor cascade element from saved cascade state
6499 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6501 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
6502 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
6504 if (IS_EDITOR_CASCADE(*cascade_element))
6506 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
6507 EL_CASCADE_INACTIVE(*cascade_element));
6510 initialization_needed = FALSE;
6513 checked_free(editor_elements);
6515 // reload optional user defined element list for each invocation of editor
6516 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
6517 &num_editor_el_user_defined);
6519 // initialize dynamic level element list for each invocation of editor
6520 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
6521 &num_editor_el_dynamic);
6523 // initialize list of empty elements (used for padding, if needed)
6524 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6525 editor_el_empty[i] = EL_EMPTY;
6527 // do some sanity checks for each element from element list
6528 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6530 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6532 int element = (*editor_elements_info[i].element_list)[j];
6534 if (element >= NUM_FILE_ELEMENTS)
6535 Warn("editor element %d is runtime element", element);
6537 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
6538 Warn("no element description text for element %d", element);
6542 num_editor_elements = 0;
6543 use_el_empty = FALSE;
6545 // determine size of element list
6546 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6548 if (*editor_elements_info[i].setup_value)
6550 boolean found_inactive_cascade = FALSE;
6552 if (setup.editor.el_headlines)
6554 // required for correct padding of palette headline buttons
6555 if (*editor_elements_info[i].headline_list_size > 0)
6556 num_editor_elements += ED_ELEMENTLIST_COLS;
6558 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6560 int element = (*editor_elements_info[i].headline_list)[j];
6562 if (IS_EDITOR_CASCADE_INACTIVE(element))
6563 found_inactive_cascade = TRUE;
6567 if (found_inactive_cascade)
6570 // required for correct padding of palette element buttons
6571 int element_list_size = *editor_elements_info[i].element_list_size;
6573 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6574 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6576 num_editor_elements += element_buttons;
6580 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
6582 // offer at least as many elements as element buttons exist
6583 use_el_empty = TRUE;
6584 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
6586 num_editor_elements += num_editor_el_empty;
6590 num_editor_el_empty = 0;
6593 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
6595 // fill element list
6596 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6598 boolean found_inactive_cascade = FALSE;
6600 if (*editor_elements_info[i].setup_value)
6602 if (setup.editor.el_headlines)
6604 // required for correct padding of palette headline buttons
6605 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6606 ED_ELEMENTLIST_COLS : 0);
6608 for (j = 0; j < headline_size; j++)
6610 // use empty elements for padding of palette headline buttons
6611 int element = (j < *editor_elements_info[i].headline_list_size ?
6612 (*editor_elements_info[i].headline_list)[j] :
6613 editor_el_empty[0]);
6615 editor_elements[pos++] = element;
6617 if (IS_EDITOR_CASCADE_INACTIVE(element))
6618 found_inactive_cascade = TRUE;
6622 if (found_inactive_cascade)
6625 // required for correct padding of palette element buttons
6626 int element_list_size = *editor_elements_info[i].element_list_size;
6628 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6629 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6631 // copy all elements from element list
6632 for (j = 0; j < element_list_size; j++)
6633 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6635 // use empty elements for padding of palette element buttons
6636 for (j = 0; j < element_buttons - element_list_size; j++)
6637 editor_elements[pos++] = editor_el_empty[0];
6641 // (this function is also called before editor gadgets are initialized!)
6642 AdjustElementListScrollbar();
6645 void PrintEditorElementList(void)
6647 boolean *stop = &setup_editor_el_user_defined;
6650 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6652 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6654 if (IS_EDITOR_CASCADE(cascade_element))
6656 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6657 char *headline = element_info[cascade_element_show].editor_description;
6659 PrintLineWithPrefix("# ", "-", 77);
6660 Print("# %s\n", headline);
6661 PrintLineWithPrefix("# ", "-", 77);
6664 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6666 int element = (*editor_elements_info[i].headline_list)[j];
6668 if (IS_EDITOR_CASCADE(element))
6669 element = EL_CHAR_MINUS;
6671 Print("# %s\n", element_info[element].token_name);
6677 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6679 int element = (*editor_elements_info[i].element_list)[j];
6681 Print("# %s\n", element_info[element].token_name);
6689 static void ReinitializeElementListButtons(void)
6691 static boolean last_setup_value_headlines = FALSE;
6692 static boolean initialization_needed = TRUE;
6695 if (!initialization_needed) // check if editor element setup has changed
6697 if (last_setup_value_headlines != setup.editor.el_headlines)
6698 initialization_needed = TRUE;
6700 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6701 if (editor_elements_info[i].last_setup_value !=
6702 *editor_elements_info[i].setup_value)
6703 initialization_needed = TRUE;
6706 if (!initialization_needed)
6709 FreeLevelEditorGadgets();
6710 CreateLevelEditorGadgets();
6712 // store current setup values for next invocation of this function
6713 last_setup_value_headlines = setup.editor.el_headlines;
6714 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6715 editor_elements_info[i].last_setup_value =
6716 *editor_elements_info[i].setup_value;
6718 initialization_needed = FALSE;
6721 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6724 int border_graphic =
6725 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6726 struct GraphicInfo *g = &graphic_info[border_graphic];
6727 Bitmap *src_bitmap = g->bitmap;
6728 int src_x = g->src_x;
6729 int src_y = g->src_y;
6730 int border_size = g->border_size;
6731 int border_xpos = g->width - border_size;
6732 int border_ypos = g->height - border_size;
6733 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6736 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6737 border_size, border_size,
6738 dest_x - border_size, dest_y - border_size);
6739 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6740 border_size, border_size,
6741 dest_x + width, dest_y - border_size);
6742 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6743 border_size, border_size,
6744 dest_x - border_size, dest_y + height);
6745 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6746 border_size, border_size,
6747 dest_x + width, dest_y + height);
6749 for (i = 0; i < width / tilesize; i++)
6751 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6752 tilesize, border_size,
6753 dest_x + i * tilesize, dest_y - border_size);
6754 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6755 tilesize, border_size,
6756 dest_x + i * tilesize, dest_y + height);
6759 for (i = 0; i < height / tilesize; i++)
6761 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6762 border_size, tilesize,
6763 dest_x - border_size, dest_y + i * tilesize);
6764 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6765 border_size, tilesize,
6766 dest_x + width, dest_y + i * tilesize);
6769 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6772 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6774 int xsize_tile = MAX(ed_tilesize, xsize);
6775 int ysize_tile = MAX(ed_tilesize, ysize);
6776 int xsize_full = xsize + 1;
6777 int ysize_full = ysize + 1;
6778 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6779 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6780 Pixel line_color = getTabulatorBarColor();
6782 if (line_color == BLACK_PIXEL) // black => transparent
6785 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6786 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6787 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6790 static void DrawEditorLevelBorderLinesIfNeeded(void)
6792 int xsize = lev_fieldx * ed_tilesize;
6793 int ysize = lev_fieldy * ed_tilesize;
6794 int line_size = getTabulatorBarHeight();
6796 if (!suppressBorderElement())
6799 // draw little border line around editable level playfield
6802 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6805 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6807 if (xsize < SXSIZE && ysize < SYSIZE)
6808 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6811 static void DrawEditorElement(int x, int y, int element)
6813 DrawSizedElement(x, y, element, ed_tilesize);
6816 static void DrawEditorElementThruMask(int x, int y, int element)
6818 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6821 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6823 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6826 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6828 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6829 DrawEditorLevelBorderLinesIfNeeded();
6832 static void DrawDrawingArea(int id)
6834 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6837 int *value = drawingarea_info[id].value;
6838 int area_xsize = drawingarea_info[id].area_xsize;
6839 int area_ysize = drawingarea_info[id].area_ysize;
6840 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6842 for (x = 0; x < area_xsize; x++)
6843 for (y = 0; y < area_ysize; y++)
6844 DrawSizedGraphicExt(drawto,
6845 gi->x + x * tilesize,
6846 gi->y + y * tilesize,
6847 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6850 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6853 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6854 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6856 BlitBitmap(drawto, drawto,
6857 SX + (dx == -1 ? ed_tilesize : 0),
6858 SY + (dy == -1 ? ed_tilesize : 0),
6859 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6860 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6861 SX + (dx == +1 ? ed_tilesize : 0),
6862 SY + (dy == +1 ? ed_tilesize : 0));
6866 x = (dx == 1 ? 0 : ed_fieldx - 1);
6867 for (y = 0; y < ed_fieldy; y++)
6868 DrawEditorElementOrWall(x, y, from_x, from_y);
6872 y = (dy == 1 ? 0 : ed_fieldy - 1);
6873 for (x = 0; x < ed_fieldx; x++)
6874 DrawEditorElementOrWall(x, y, from_x, from_y);
6877 redraw_mask |= REDRAW_FIELD;
6881 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6884 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6887 static void CreateControlButtons(void)
6889 struct GadgetInfo *gi;
6892 // create toolbox buttons
6893 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6895 int type_id = controlbutton_info[i].gadget_id; // same as gadget ID here
6896 int id = controlbutton_info[i].gadget_id;
6897 int type = controlbutton_info[i].gadget_type;
6898 int graphic = controlbutton_info[i].graphic;
6899 struct XYTileSize *pos = controlbutton_info[i].pos;
6900 struct GraphicInfo *gd = &graphic_info[graphic];
6901 Bitmap *deco_bitmap = NULL;
6902 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6903 int tile_size = 0, deco_shift = 0;
6904 boolean deco_masked = FALSE;
6905 int gd_x1 = gd->src_x;
6906 int gd_y1 = gd->src_y;
6907 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6908 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6909 int gd_x1a = gd->src_x + gd->active_xoffset;
6910 int gd_y1a = gd->src_y + gd->active_yoffset;
6911 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6912 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6915 unsigned int event_mask;
6916 int radio_button_nr = RADIO_NR_NONE;
6917 boolean checked = FALSE;
6920 Fail("'controlbutton_info' structure corrupted at index %d -- please fix", i);
6922 if (type == GD_TYPE_RADIO_BUTTON)
6924 event_mask = GD_EVENT_PRESSED;
6925 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6927 if (id == drawing_function)
6932 if (id == GADGET_ID_WRAP_LEFT ||
6933 id == GADGET_ID_WRAP_RIGHT ||
6934 id == GADGET_ID_WRAP_UP ||
6935 id == GADGET_ID_WRAP_DOWN)
6936 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6938 event_mask = GD_EVENT_RELEASED;
6941 if (id == GADGET_ID_PROPERTIES ||
6942 id == GADGET_ID_PALETTE)
6947 else if (id == GADGET_ID_ELEMENT_LEFT ||
6948 id == GADGET_ID_ELEMENT_MIDDLE ||
6949 id == GADGET_ID_ELEMENT_RIGHT)
6954 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6955 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6956 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6958 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6959 editor.button.element_left.tile_size :
6960 id == GADGET_ID_ELEMENT_MIDDLE ?
6961 editor.button.element_middle.tile_size :
6962 id == GADGET_ID_ELEMENT_RIGHT ?
6963 editor.button.element_right.tile_size : 0);
6965 // make sure that decoration does not overlap gadget border
6966 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6968 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6970 deco_xpos = (gd->width - tile_size) / 2;
6971 deco_ypos = (gd->height - tile_size) / 2;
6973 deco_masked = gd->draw_masked;
6981 gi = CreateGadget(GDI_CUSTOM_ID, id,
6982 GDI_CUSTOM_TYPE_ID, type_id,
6983 GDI_IMAGE_ID, graphic,
6984 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6987 GDI_WIDTH, gd->width,
6988 GDI_HEIGHT, gd->height,
6990 GDI_STATE, GD_BUTTON_UNPRESSED,
6991 GDI_RADIO_NR, radio_button_nr,
6992 GDI_CHECKED, checked,
6993 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6994 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6995 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6996 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6997 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6998 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6999 GDI_DECORATION_SIZE, tile_size, tile_size,
7000 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
7001 GDI_DECORATION_MASKED, deco_masked,
7002 GDI_EVENT_MASK, event_mask,
7003 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7004 GDI_CALLBACK_ACTION, HandleControlButtons,
7008 Fail("cannot create gadget");
7010 level_editor_gadget[id] = gi;
7013 // these values are not constant, but can change at runtime
7014 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
7015 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
7016 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
7017 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
7018 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
7019 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
7020 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
7021 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
7022 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
7023 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
7024 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
7025 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
7027 // create buttons for scrolling of drawing area and element list
7028 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
7030 int id = scrollbutton_info[i].gadget_id;
7031 int type_id = scrollbutton_info[i].gadget_type_id;
7032 int graphic = scrollbutton_info[i].graphic;
7033 struct GraphicInfo *gd = &graphic_info[graphic];
7034 Bitmap *gd_bitmap = gd->bitmap;
7035 int gd_x1 = gd->src_x;
7036 int gd_y1 = gd->src_y;
7037 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7038 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7039 int width = gd->width;
7040 int height = gd->height;
7041 int x = scrollbutton_pos[i].x;
7042 int y = scrollbutton_pos[i].y;
7043 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7046 Fail("'scrollbutton_info' structure corrupted at index %d -- please fix", i);
7048 if (id == GADGET_ID_SCROLL_LIST_UP ||
7049 id == GADGET_ID_SCROLL_LIST_DOWN)
7060 gi = CreateGadget(GDI_CUSTOM_ID, id,
7061 GDI_CUSTOM_TYPE_ID, type_id,
7062 GDI_IMAGE_ID, graphic,
7063 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
7068 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7069 GDI_STATE, GD_BUTTON_UNPRESSED,
7070 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7071 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7072 GDI_EVENT_MASK, event_mask,
7073 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7074 GDI_CALLBACK_ACTION, HandleControlButtons,
7078 Fail("cannot create gadget");
7080 level_editor_gadget[id] = gi;
7083 // create buttons for element list
7084 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7087 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
7088 int graphic = IMG_EDITOR_PALETTE_BUTTON;
7089 struct GraphicInfo *gd = &graphic_info[graphic];
7090 Bitmap *gd_bitmap = gd->bitmap;
7091 Bitmap *deco_bitmap;
7092 int deco_x, deco_y, deco_xpos, deco_ypos;
7093 int gd_x1 = gd->src_x;
7094 int gd_y1 = gd->src_y;
7095 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7096 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7097 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
7098 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
7099 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
7100 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
7101 int element = editor_elements[i];
7102 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
7103 unsigned int event_mask = GD_EVENT_RELEASED;
7105 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
7107 deco_xpos = (gd->width - tile_size) / 2;
7108 deco_ypos = (gd->height - tile_size) / 2;
7110 gi = CreateGadget(GDI_CUSTOM_ID, id,
7111 GDI_CUSTOM_TYPE_ID, type_id,
7112 GDI_IMAGE_ID, graphic,
7113 GDI_INFO_TEXT, getElementInfoText(element),
7116 GDI_WIDTH, gd->width,
7117 GDI_HEIGHT, gd->height,
7118 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7119 GDI_STATE, GD_BUTTON_UNPRESSED,
7120 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7121 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7122 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7123 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7124 GDI_DECORATION_SIZE, tile_size, tile_size,
7125 GDI_DECORATION_SHIFTING, 1, 1,
7126 GDI_EVENT_MASK, event_mask,
7127 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7128 GDI_CALLBACK_ACTION, HandleControlButtons,
7132 Fail("cannot create gadget");
7134 level_editor_gadget[id] = gi;
7138 static void CreateCounterButtons(void)
7140 int max_infotext_len = getMaxInfoTextLength();
7143 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
7145 int type_id = counterbutton_info[i].gadget_type_id;
7146 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
7147 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
7151 Fail("'counterbutton_info' structure corrupted at index %d -- please fix", i);
7153 // determine horizontal position to the right of specified gadget
7154 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7155 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
7156 ED_GADGET_TEXT_DISTANCE);
7158 // determine horizontal offset for leading text
7159 if (counterbutton_info[i].text_left != NULL)
7160 x += getTextWidthForGadget(counterbutton_info[i].text_left);
7162 for (j = 0; j < 2; j++)
7164 struct GadgetInfo *gi;
7166 counterbutton_info[i].gadget_id_down :
7167 counterbutton_info[i].gadget_id_up);
7169 struct GraphicInfo *gd;
7170 int gd_x1, gd_x2, gd_y1, gd_y2;
7171 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7172 char infotext[max_infotext_len + 1];
7174 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7177 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
7178 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
7180 event_mask |= GD_EVENT_RELEASED;
7184 x = DX + editor.button.prev_level.x;
7185 y = DY + editor.button.prev_level.y;
7189 x = DX + editor.button.next_level.x;
7190 y = DY + editor.button.next_level.y;
7196 IMG_EDITOR_COUNTER_DOWN :
7197 IMG_EDITOR_COUNTER_UP);
7200 gd = &graphic_info[graphic];
7204 gd_x2 = gd->src_x + gd->pressed_xoffset;
7205 gd_y2 = gd->src_y + gd->pressed_yoffset;
7207 sprintf(infotext, "%s counter value by 1, 5 or 10",
7208 (j == 0 ? "decrease" : "increase"));
7210 gi = CreateGadget(GDI_CUSTOM_ID, id,
7211 GDI_CUSTOM_TYPE_ID, type_id,
7212 GDI_IMAGE_ID, graphic,
7213 GDI_INFO_TEXT, infotext,
7216 GDI_WIDTH, gd->width,
7217 GDI_HEIGHT, gd->height,
7218 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7219 GDI_STATE, GD_BUTTON_UNPRESSED,
7220 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7221 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7222 GDI_EVENT_MASK, event_mask,
7223 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7224 GDI_CALLBACK_ACTION, HandleCounterButtons,
7228 Fail("cannot create gadget");
7230 level_editor_gadget[id] = gi;
7231 right_gadget_border[id] =
7232 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7234 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
7238 int font_type = FONT_INPUT_1;
7239 int font_type_active = FONT_INPUT_1_ACTIVE;
7241 id = counterbutton_info[i].gadget_id_text;
7243 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7245 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7247 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
7249 font_type = FONT_LEVEL_NUMBER;
7250 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
7252 x = DX + editor.input.level_number.x;
7253 y = DY + editor.input.level_number.y;
7257 graphic = IMG_EDITOR_COUNTER_INPUT;
7260 gd = &graphic_info[graphic];
7264 gd_x2 = gd->src_x + gd->active_xoffset;
7265 gd_y2 = gd->src_y + gd->active_yoffset;
7267 gi = CreateGadget(GDI_CUSTOM_ID, id,
7268 GDI_CUSTOM_TYPE_ID, type_id,
7269 GDI_IMAGE_ID, graphic,
7270 GDI_INFO_TEXT, "enter counter value",
7273 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
7274 GDI_NUMBER_VALUE, 0,
7275 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
7276 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
7277 GDI_TEXT_SIZE, 3, // minimal counter text size
7278 GDI_TEXT_FONT, font_type,
7279 GDI_TEXT_FONT_ACTIVE, font_type_active,
7280 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7281 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7282 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7283 GDI_DESIGN_WIDTH, gd->width,
7284 GDI_EVENT_MASK, event_mask,
7285 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7286 GDI_CALLBACK_ACTION, HandleCounterButtons,
7290 Fail("cannot create gadget");
7292 level_editor_gadget[id] = gi;
7293 right_gadget_border[id] =
7294 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7296 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
7302 static void CreateDrawingAreas(void)
7306 // these values are not constant, but can change at runtime
7307 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
7308 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
7310 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
7312 struct GadgetInfo *gi;
7313 int id = drawingarea_info[i].gadget_id;
7314 int type_id = drawingarea_info[i].gadget_type_id;
7315 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
7316 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
7317 int area_xsize = drawingarea_info[i].area_xsize;
7318 int area_ysize = drawingarea_info[i].area_ysize;
7319 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
7320 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
7321 unsigned int event_mask =
7322 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
7323 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
7326 Fail("'drawingarea_info' structure corrupted at index %d -- please fix", i);
7328 // determine horizontal position to the right of specified gadget
7329 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
7330 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
7331 ED_DRAWINGAREA_TEXT_DISTANCE);
7333 // determine horizontal offset for leading text
7334 if (drawingarea_info[i].text_left != NULL)
7335 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
7337 gi = CreateGadget(GDI_CUSTOM_ID, id,
7338 GDI_CUSTOM_TYPE_ID, type_id,
7341 GDI_TYPE, GD_TYPE_DRAWING_AREA,
7342 GDI_AREA_SIZE, area_xsize, area_ysize,
7343 GDI_ITEM_SIZE, item_size, item_size,
7344 GDI_EVENT_MASK, event_mask,
7345 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
7346 GDI_CALLBACK_ACTION, HandleDrawingAreas,
7350 Fail("cannot create gadget");
7352 level_editor_gadget[id] = gi;
7353 right_gadget_border[id] =
7354 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
7358 static void CreateTextInputGadgets(void)
7360 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
7361 int max_infotext_len = getMaxInfoTextLength();
7364 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
7366 int gd_x1 = gd->src_x;
7367 int gd_y1 = gd->src_y;
7368 int gd_x2 = gd->src_x + gd->active_xoffset;
7369 int gd_y2 = gd->src_y + gd->active_yoffset;
7370 struct GadgetInfo *gi;
7371 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7372 char infotext[MAX_OUTPUT_LINESIZE + 1];
7373 int id = textinput_info[i].gadget_id;
7374 int type_id = textinput_info[i].gadget_type_id;
7378 Fail("'textinput_info' structure corrupted at index %d -- please fix", i);
7380 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
7382 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
7383 int border_size = gd->border_size;
7384 int font_nr = FONT_INPUT_1;
7385 int font_height = getFontHeight(font_nr);
7386 int xoffset = element_border + TILEX + element_border + 3 * border_size;
7387 int yoffset = element_border + (TILEY - font_height) / 2;
7389 x = (editor.settings.element_name.x != -1 ?
7390 editor.settings.element_name.x :
7391 editor.settings.element_graphic.x + xoffset) - border_size;
7392 y = (editor.settings.element_name.y != -1 ?
7393 editor.settings.element_name.y :
7394 editor.settings.element_graphic.y + yoffset) - border_size;
7398 x = ED_SETTINGS_X(textinput_info[i].x);
7399 y = ED_SETTINGS_Y(textinput_info[i].y);
7402 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
7403 infotext[max_infotext_len] = '\0';
7405 gi = CreateGadget(GDI_CUSTOM_ID, id,
7406 GDI_CUSTOM_TYPE_ID, type_id,
7407 GDI_INFO_TEXT, infotext,
7410 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
7411 GDI_TEXT_VALUE, textinput_info[i].value,
7412 GDI_TEXT_SIZE, textinput_info[i].size,
7413 GDI_TEXT_FONT, FONT_INPUT_1,
7414 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7415 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7416 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7417 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7418 GDI_DESIGN_WIDTH, gd->width,
7419 GDI_EVENT_MASK, event_mask,
7420 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7421 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
7425 Fail("cannot create gadget");
7427 level_editor_gadget[id] = gi;
7431 static void CreateTextAreaGadgets(void)
7433 int max_infotext_len = getMaxInfoTextLength();
7436 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
7438 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
7439 int gd_x1 = gd->src_x;
7440 int gd_y1 = gd->src_y;
7441 int gd_x2 = gd->src_x + gd->active_xoffset;
7442 int gd_y2 = gd->src_y + gd->active_yoffset;
7443 struct GadgetInfo *gi;
7444 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
7445 char infotext[MAX_OUTPUT_LINESIZE + 1];
7446 int id = textarea_info[i].gadget_id;
7447 int type_id = textarea_info[i].gadget_type_id;
7448 int area_xsize = textarea_info[i].xsize;
7449 int area_ysize = textarea_info[i].ysize;
7452 Fail("'textarea_info' structure corrupted at index %d -- please fix", i);
7454 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
7455 infotext[max_infotext_len] = '\0';
7457 gi = CreateGadget(GDI_CUSTOM_ID, id,
7458 GDI_CUSTOM_TYPE_ID, type_id,
7459 GDI_INFO_TEXT, infotext,
7460 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
7461 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
7462 GDI_TYPE, GD_TYPE_TEXT_AREA,
7463 GDI_AREA_SIZE, area_xsize, area_ysize,
7464 GDI_TEXT_FONT, FONT_INPUT_1,
7465 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7466 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7467 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7468 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7469 GDI_DESIGN_WIDTH, gd->width,
7470 GDI_EVENT_MASK, event_mask,
7471 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7472 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
7476 Fail("cannot create gadget");
7478 level_editor_gadget[id] = gi;
7482 static void CreateSelectboxGadgets(void)
7484 int max_infotext_len = getMaxInfoTextLength();
7487 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7489 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
7490 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
7491 int gd_x1 = gd->src_x;
7492 int gd_y1 = gd->src_y;
7493 int gd_x2 = gd->src_x + gd->active_xoffset;
7494 int gd_y2 = gd->src_y + gd->active_yoffset;
7495 int selectbox_button_xsize = gd2->width;
7496 struct GadgetInfo *gi;
7497 char infotext[MAX_OUTPUT_LINESIZE + 1];
7498 int id = selectbox_info[i].gadget_id;
7499 int type_id = selectbox_info[i].gadget_type_id;
7500 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
7501 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
7502 unsigned int event_mask =
7503 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7506 Fail("'selectbox_info' structure corrupted at index %d -- please fix", i);
7508 if (selectbox_info[i].size == -1) // dynamically determine size
7510 // (we cannot use -1 for uninitialized values if we directly compare
7511 // with results from strlen(), because the '<' and '>' operation will
7512 // implicitely cast -1 to an unsigned integer value!)
7513 selectbox_info[i].size = 0;
7515 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
7516 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
7517 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
7519 selectbox_info[i].size++; // add one character empty space
7522 // determine horizontal position to the right of specified gadget
7523 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
7524 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
7525 ED_GADGET_TEXT_DISTANCE);
7527 // determine horizontal offset for leading text
7528 if (selectbox_info[i].text_left != NULL)
7529 x += getTextWidthForGadget(selectbox_info[i].text_left);
7531 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
7532 infotext[max_infotext_len] = '\0';
7534 gi = CreateGadget(GDI_CUSTOM_ID, id,
7535 GDI_CUSTOM_TYPE_ID, type_id,
7536 GDI_INFO_TEXT, infotext,
7539 GDI_TYPE, GD_TYPE_SELECTBOX,
7540 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
7541 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
7542 GDI_TEXT_SIZE, selectbox_info[i].size,
7543 GDI_TEXT_FONT, FONT_INPUT_1,
7544 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7545 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
7546 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7547 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7548 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7549 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
7550 GDI_DESIGN_WIDTH, gd->width,
7551 GDI_EVENT_MASK, event_mask,
7552 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7553 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
7557 Fail("cannot create gadget");
7559 level_editor_gadget[id] = gi;
7560 right_gadget_border[id] =
7561 getRightGadgetBorder(gi, selectbox_info[i].text_right);
7565 static void CreateTextbuttonGadgets(void)
7567 int max_infotext_len = getMaxInfoTextLength();
7570 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
7572 int id = textbutton_info[i].gadget_id;
7573 int type_id = textbutton_info[i].gadget_type_id;
7575 ((id >= GADGET_ID_LEVELCONFIG_LEVEL && id <= GADGET_ID_LEVELCONFIG_ENGINE) ||
7576 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
7578 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
7579 int gadget_distance =
7580 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
7581 struct GraphicInfo *gd = &graphic_info[graphic];
7582 int gd_x1 = gd->src_x;
7583 int gd_y1 = gd->src_y;
7584 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7585 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7586 int gd_x1a = gd->src_x + gd->active_xoffset;
7587 int gd_y1a = gd->src_y + gd->active_yoffset;
7588 int border_xsize = gd->border_size + gd->draw_xoffset;
7589 int border_ysize = gd->border_size;
7590 struct GadgetInfo *gi;
7591 unsigned int event_mask = GD_EVENT_RELEASED;
7592 char infotext[MAX_OUTPUT_LINESIZE + 1];
7593 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
7594 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
7597 Fail("'textbutton_info' structure corrupted at index %d -- please fix", i);
7599 if (textbutton_info[i].size == -1) // dynamically determine size
7600 textbutton_info[i].size = strlen(textbutton_info[i].text);
7602 sprintf(infotext, "%s", textbutton_info[i].infotext);
7603 infotext[max_infotext_len] = '\0';
7605 // determine horizontal position to the right of specified gadget
7606 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7608 int gadget_id_align = textbutton_info[i].gadget_id_align;
7610 x = right_gadget_border[gadget_id_align] + gadget_distance;
7612 if (textbutton_info[i].y == -1)
7613 y = level_editor_gadget[gadget_id_align]->y;
7616 // determine horizontal offset for leading text
7617 if (textbutton_info[i].text_left != NULL)
7618 x += getTextWidthForGadget(textbutton_info[i].text_left);
7620 gi = CreateGadget(GDI_CUSTOM_ID, id,
7621 GDI_CUSTOM_TYPE_ID, type_id,
7622 GDI_IMAGE_ID, graphic,
7623 GDI_INFO_TEXT, infotext,
7626 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
7627 GDI_TEXT_VALUE, textbutton_info[i].text,
7628 GDI_TEXT_SIZE, textbutton_info[i].size,
7629 GDI_TEXT_FONT, FONT_INPUT_2,
7630 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
7631 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7632 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7633 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7634 GDI_BORDER_SIZE, border_xsize, border_ysize,
7635 GDI_DESIGN_WIDTH, gd->width,
7636 GDI_DECORATION_SHIFTING, 1, 1,
7637 GDI_EVENT_MASK, event_mask,
7638 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7639 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7643 Fail("cannot create gadget");
7645 level_editor_gadget[id] = gi;
7646 right_gadget_border[id] =
7647 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7651 static void CreateGraphicbuttonGadgets(void)
7653 struct GadgetInfo *gi;
7656 // create buttons for scrolling of drawing area and element list
7657 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7659 int id = graphicbutton_info[i].gadget_id;
7660 int type_id = graphicbutton_info[i].gadget_type_id;
7661 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7662 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7663 int graphic = graphicbutton_info[i].graphic;
7664 struct GraphicInfo *gd = &graphic_info[graphic];
7665 int gd_x1 = gd->src_x;
7666 int gd_y1 = gd->src_y;
7667 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7668 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7669 unsigned int event_mask = GD_EVENT_RELEASED;
7672 Fail("'graphicbutton_info' structure corrupted at index %d -- please fix", i);
7674 // determine horizontal position to the right of specified gadget
7675 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7676 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7677 ED_GADGET_TEXT_DISTANCE);
7679 // determine horizontal offset for leading text
7680 if (graphicbutton_info[i].text_left != NULL)
7681 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7683 gi = CreateGadget(GDI_CUSTOM_ID, id,
7684 GDI_CUSTOM_TYPE_ID, type_id,
7685 GDI_IMAGE_ID, graphic,
7686 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7689 GDI_WIDTH, gd->width,
7690 GDI_HEIGHT, gd->height,
7691 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7692 GDI_STATE, GD_BUTTON_UNPRESSED,
7693 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7694 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7695 GDI_EVENT_MASK, event_mask,
7696 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7697 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7701 Fail("cannot create gadget");
7703 level_editor_gadget[id] = gi;
7704 right_gadget_border[id] =
7705 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7709 static void CreateScrollbarGadgets(void)
7713 // these values are not constant, but can change at runtime
7714 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7715 SX + ED_SCROLL_HORIZONTAL_XPOS;
7716 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7717 SY + ED_SCROLL_HORIZONTAL_YPOS;
7718 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7719 ED_SCROLL_HORIZONTAL_XSIZE;
7720 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7721 ED_SCROLL_HORIZONTAL_YSIZE;
7722 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7723 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7724 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7725 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7727 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7728 SX + ED_SCROLL_VERTICAL_XPOS;
7729 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7730 SY + ED_SCROLL_VERTICAL_YPOS;
7731 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7732 ED_SCROLL_VERTICAL_XSIZE;
7733 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7734 ED_SCROLL_VERTICAL_YSIZE;
7735 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7736 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7737 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7738 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7740 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7741 PX + ED_SCROLL2_VERTICAL_XPOS;
7742 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7743 PY + ED_SCROLL2_VERTICAL_YPOS;
7744 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7745 ED_SCROLL2_VERTICAL_XSIZE;
7746 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7747 ED_SCROLL2_VERTICAL_YSIZE;
7748 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7749 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7750 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7751 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7753 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7755 int id = scrollbar_info[i].gadget_id;
7756 int type_id = scrollbar_info[i].gadget_type_id;
7757 int graphic = scrollbar_info[i].graphic;
7758 struct GraphicInfo *gd = &graphic_info[graphic];
7759 int gd_x1 = gd->src_x;
7760 int gd_y1 = gd->src_y;
7761 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7762 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7763 struct GadgetInfo *gi;
7764 int items_max, items_visible, item_position;
7765 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7768 Fail("'scrollbar_info' structure corrupted at index %d -- please fix", i);
7770 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7772 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7773 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7774 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7776 else // drawing area scrollbars
7778 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7780 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7781 items_visible = ed_fieldx;
7786 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7787 items_visible = ed_fieldy;
7792 gi = CreateGadget(GDI_CUSTOM_ID, id,
7793 GDI_CUSTOM_TYPE_ID, type_id,
7794 GDI_IMAGE_ID, graphic,
7795 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7796 GDI_X, scrollbar_pos[i].x,
7797 GDI_Y, scrollbar_pos[i].y,
7798 GDI_WIDTH, scrollbar_pos[i].width,
7799 GDI_HEIGHT, scrollbar_pos[i].height,
7800 GDI_TYPE, scrollbar_info[i].type,
7801 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7802 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7803 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7804 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7805 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7806 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7807 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7808 GDI_STATE, GD_BUTTON_UNPRESSED,
7809 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7810 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7811 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7812 GDI_EVENT_MASK, event_mask,
7813 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7814 GDI_CALLBACK_ACTION, HandleControlButtons,
7818 Fail("cannot create gadget");
7820 level_editor_gadget[id] = gi;
7824 static void CreateCheckbuttonGadgets(void)
7826 struct GadgetInfo *gi;
7829 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7831 int id = checkbutton_info[i].gadget_id;
7832 int type_id = checkbutton_info[i].gadget_type_id;
7833 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7834 IMG_EDITOR_CHECKBOX);
7835 struct GraphicInfo *gd = &graphic_info[graphic];
7836 int gd_x1 = gd->src_x;
7837 int gd_y1 = gd->src_y;
7838 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7839 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7840 int gd_x1a = gd->src_x + gd->active_xoffset;
7841 int gd_y1a = gd->src_y + gd->active_yoffset;
7842 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7843 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7844 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7845 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7846 unsigned int event_mask = GD_EVENT_PRESSED;
7849 Fail("'checkbutton_info' structure corrupted at index %d -- please fix", i);
7851 // determine horizontal position to the right of specified gadget
7852 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7853 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7854 ED_GADGET_TEXT_DISTANCE);
7856 // determine horizontal offset for leading text
7857 if (checkbutton_info[i].text_left != NULL)
7858 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7860 gi = CreateGadget(GDI_CUSTOM_ID, id,
7861 GDI_CUSTOM_TYPE_ID, type_id,
7862 GDI_IMAGE_ID, graphic,
7863 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7866 GDI_WIDTH, gd->width,
7867 GDI_HEIGHT, gd->height,
7868 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7869 GDI_CHECKED, *checkbutton_info[i].value,
7870 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7871 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7872 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7873 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7874 GDI_EVENT_MASK, event_mask,
7875 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7876 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7880 Fail("cannot create gadget");
7882 level_editor_gadget[id] = gi;
7883 right_gadget_border[id] =
7884 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7888 static void CreateRadiobuttonGadgets(void)
7890 int graphic = IMG_EDITOR_RADIOBUTTON;
7891 struct GraphicInfo *gd = &graphic_info[graphic];
7892 int gd_x1 = gd->src_x;
7893 int gd_y1 = gd->src_y;
7894 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7895 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7896 int gd_x1a = gd->src_x + gd->active_xoffset;
7897 int gd_y1a = gd->src_y + gd->active_yoffset;
7898 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7899 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7900 struct GadgetInfo *gi;
7903 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7905 int id = radiobutton_info[i].gadget_id;
7906 int type_id = radiobutton_info[i].gadget_type_id;
7907 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7908 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7909 unsigned int event_mask = GD_EVENT_PRESSED;
7912 Fail("'radiobutton_info' structure corrupted at index %d -- please fix", i);
7915 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7917 // determine horizontal position to the right of specified gadget
7918 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7919 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7920 ED_GADGET_TEXT_DISTANCE);
7922 // determine horizontal offset for leading text
7923 if (radiobutton_info[i].text_left != NULL)
7924 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7926 gi = CreateGadget(GDI_CUSTOM_ID, id,
7927 GDI_CUSTOM_TYPE_ID, type_id,
7928 GDI_IMAGE_ID, graphic,
7929 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7932 GDI_WIDTH, gd->width,
7933 GDI_HEIGHT, gd->height,
7934 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7935 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7936 GDI_CHECKED, checked,
7937 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7938 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7939 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7940 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7941 GDI_EVENT_MASK, event_mask,
7942 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7943 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7947 Fail("cannot create gadget");
7949 level_editor_gadget[id] = gi;
7950 right_gadget_border[id] =
7951 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7955 void CreateLevelEditorGadgets(void)
7957 // force EDITOR font inside level editor
7958 SetFontStatus(GAME_MODE_EDITOR);
7960 // these values are not constant, but can change at runtime
7961 ed_fieldx = MAX_ED_FIELDX - 1;
7962 ed_fieldy = MAX_ED_FIELDY - 1;
7964 num_editor_gadgets = NUM_EDITOR_GADGETS;
7966 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7968 level_editor_gadget =
7969 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7970 right_gadget_border =
7971 checked_calloc(num_editor_gadgets * sizeof(int));
7973 // set number of empty (padding) element buttons to maximum number of buttons
7974 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7976 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7977 editor_el_empty_ptr = editor_el_empty;
7979 use_permanent_palette = !editor.palette.show_as_separate_screen;
7981 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
7983 ReinitializeElementList();
7985 CreateControlButtons();
7986 CreateScrollbarGadgets();
7988 // order of function calls is important because of cross-references
7989 CreateCheckbuttonGadgets();
7990 CreateCounterButtons();
7991 CreateRadiobuttonGadgets();
7992 CreateTextInputGadgets();
7993 CreateTextAreaGadgets();
7994 CreateSelectboxGadgets();
7995 CreateGraphicbuttonGadgets();
7996 CreateTextbuttonGadgets();
7997 CreateDrawingAreas();
8002 void FreeLevelEditorGadgets(void)
8006 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
8008 for (i = 0; i < num_editor_gadgets; i++)
8010 FreeGadget(level_editor_gadget[i]);
8012 level_editor_gadget[i] = NULL;
8015 checked_free(level_editor_gadget);
8016 checked_free(right_gadget_border);
8018 checked_free(editor_el_empty);
8021 static void MapCounterButtons(int id)
8023 int font_nr = FONT_TEXT_1;
8024 int font_height = getFontHeight(font_nr);
8025 int gadget_id_down = counterbutton_info[id].gadget_id_down;
8026 int gadget_id_text = counterbutton_info[id].gadget_id_text;
8027 int gadget_id_up = counterbutton_info[id].gadget_id_up;
8028 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
8029 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
8030 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8031 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
8032 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8033 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8034 int yoffset = (gi_down->height - font_height) / 2;
8035 int x_left = gi_down->x - xoffset_left;
8036 int x_right; // set after gadget position was modified
8037 int y_above = gi_down->y - yoffset_above;
8039 int y; // set after gadget position was modified
8041 // counter limits must be changed first to prevent value truncation
8042 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
8043 counterbutton_info[id].max_value);
8045 // right text position might have changed after setting position above
8046 x_right = gi_up->x + gi_up->width + xoffset_right;
8048 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
8050 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
8051 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
8052 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
8054 ModifyGadget(gi_down, GDI_Y,
8055 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8056 ModifyGadget(gi_text, GDI_Y,
8057 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8058 ModifyGadget(gi_up, GDI_Y,
8059 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8062 // vertical position might have changed after setting position above
8063 y = gi_up->y + yoffset;
8065 if (counterbutton_info[id].text_above)
8066 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
8068 if (counterbutton_info[id].text_left)
8069 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
8071 if (counterbutton_info[id].text_right)
8072 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
8079 static void MapControlButtons(void)
8084 // map toolbox buttons (excluding special CE toolbox buttons)
8085 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
8086 MapGadget(level_editor_gadget[i]);
8088 // map toolbox buttons (element properties buttons)
8089 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
8090 MapGadget(level_editor_gadget[i]);
8092 if (use_permanent_palette)
8094 // map buttons to select elements
8095 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8096 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
8097 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
8098 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
8099 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
8102 // map buttons to select level
8103 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
8104 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
8105 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
8106 MapCounterButtons(counter_id);
8109 static void MapDrawingArea(int id)
8111 int font_nr = FONT_TEXT_1;
8112 int font_height = getFontHeight(font_nr);
8113 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8114 int area_xsize = gi->drawing.area_xsize;
8115 int area_ysize = gi->drawing.area_ysize;
8116 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8117 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
8118 int x_left = gi->x - xoffset_left;
8119 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
8120 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
8121 int x_below = gi->x + (gi->width - xoffset_below) / 2;
8122 int y_side = gi->y + (gi->height - font_height) / 2;
8123 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
8124 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
8126 if (drawingarea_info[id].text_left)
8127 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
8129 if (drawingarea_info[id].text_right)
8130 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
8132 if (drawingarea_info[id].text_above)
8133 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
8135 if (drawingarea_info[id].text_below)
8136 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
8138 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
8140 DrawElementBorder(gi->x, gi->y,
8141 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
8142 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
8144 DrawDrawingArea(id);
8150 static void MapTextInputGadget(int id)
8152 int font_nr = FONT_TEXT_1;
8153 int font_height = getFontHeight(font_nr);
8154 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
8155 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8156 int x_above = ED_SETTINGS_X(textinput_info[id].x);
8157 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
8159 if (textinput_info[id].text_above)
8160 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
8162 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
8167 static void MapTextAreaGadget(int id)
8169 int font_nr = FONT_TEXT_1;
8170 int font_height = getFontHeight(font_nr);
8171 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8172 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8173 int x_above = ED_SETTINGS_X(textarea_info[id].x);
8174 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
8175 char *text_above = textarea_info[id].text_above;
8177 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
8178 text_above = textarea_info[id].text_above_cropped;
8181 DrawTextS(x_above, y_above, font_nr, text_above);
8183 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
8188 static void MapSelectboxGadget(int id)
8190 int font_nr = FONT_TEXT_1;
8191 int font_height = getFontHeight(font_nr);
8192 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
8193 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
8194 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8195 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8196 int yoffset = (gi->height - font_height) / 2;
8197 int x_left = gi->x - xoffset_left;
8198 int x_right = gi->x + gi->width + xoffset_right;
8199 int y_above = gi->y - yoffset_above;
8201 int y = gi->y + yoffset;
8203 if (selectbox_info[id].text_above)
8204 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
8206 if (selectbox_info[id].text_left)
8207 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
8209 if (selectbox_info[id].text_right)
8210 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
8212 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
8217 static void MapTextbuttonGadget(int id)
8219 int font_nr = FONT_TEXT_1;
8220 int font_height = getFontHeight(font_nr);
8221 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
8222 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
8223 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8224 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8225 int yoffset = (gi->height - font_height) / 2;
8226 int x_left = gi->x - xoffset_left;
8227 int x_right = gi->x + gi->width + xoffset_right;
8228 int y_above = gi->y - yoffset_above;
8230 int y = gi->y + yoffset;
8232 // only show button to delete change pages when more than minimum pages
8233 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
8234 custom_element.num_change_pages == MIN_CHANGE_PAGES)
8237 if (textbutton_info[id].text_above)
8238 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
8240 if (textbutton_info[id].text_left)
8241 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
8243 if (textbutton_info[id].text_right)
8244 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
8249 static void MapGraphicbuttonGadget(int id)
8251 int font_nr = FONT_TEXT_1;
8252 int font_height = getFontHeight(font_nr);
8253 struct GadgetInfo *gi = level_editor_gadget[graphicbutton_info[id].gadget_id];
8254 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
8255 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8256 int yoffset = (gi->height - font_height) / 2;
8257 int x_left = gi->x - xoffset_left;
8258 int x_right = gi->x + gi->width + xoffset_right;
8259 int y = gi->y + yoffset;
8261 if (graphicbutton_info[id].text_left)
8262 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
8264 if (graphicbutton_info[id].text_right)
8265 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
8270 static void MapRadiobuttonGadget(int id)
8272 int font_nr = FONT_TEXT_1;
8273 int font_height = getFontHeight(font_nr);
8274 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
8275 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8276 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8277 int yoffset = (gi->height - font_height) / 2;
8278 int x_left = gi->x - xoffset_left;
8279 int x_right = gi->x + gi->width + xoffset_right;
8280 int y = gi->y + yoffset;
8282 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
8284 if (radiobutton_info[id].text_left)
8285 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
8287 if (radiobutton_info[id].text_right)
8288 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
8290 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
8295 static void MapCheckbuttonGadget(int id)
8297 int font_nr = FONT_TEXT_1;
8298 int font_height = getFontHeight(font_nr);
8299 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
8300 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8301 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8302 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8303 int yoffset = (gi->height - font_height) / 2;
8304 int y_above = gi->y - yoffset_above;
8306 int x_left, x_right, y; // set after gadget position was modified
8308 // set position for gadgets with dynamically determined position
8309 if (checkbutton_info[id].x != -1) // do not change dynamic positions
8310 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x), GDI_END);
8311 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
8313 x_left = gi->x - xoffset_left;
8314 x_right = gi->x + gi->width + xoffset_right;
8315 y = gi->y + yoffset;
8317 if (checkbutton_info[id].text_above)
8318 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
8320 if (checkbutton_info[id].text_left)
8321 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
8323 if (checkbutton_info[id].text_right)
8324 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
8326 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
8331 static void MapMainDrawingArea(void)
8333 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
8334 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
8337 if (suppressBorderElement())
8339 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
8340 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
8343 for (i = ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
8345 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
8346 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
8347 no_horizontal_scrollbar) ||
8348 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
8349 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
8350 no_vertical_scrollbar))
8353 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
8356 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
8358 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
8359 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
8362 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
8365 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
8368 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
8372 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
8374 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
8375 i == GADGET_ID_CUSTOM_COPY_TO ||
8376 i == GADGET_ID_CUSTOM_EXCHANGE ||
8377 i == GADGET_ID_CUSTOM_COPY ||
8378 i == GADGET_ID_CUSTOM_PASTE)
8381 MapGadget(level_editor_gadget[i]);
8383 UnmapGadget(level_editor_gadget[i]);
8388 static void MapLevelEditorToolboxCustomGadgets(void)
8390 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
8393 static void MapLevelEditorToolboxCustomGadgetsIfNeeded(void)
8395 if (IS_CUSTOM_ELEMENT(properties_element) ||
8396 IS_GROUP_ELEMENT(properties_element) ||
8397 IS_EMPTY_ELEMENT(properties_element))
8398 MapLevelEditorToolboxCustomGadgets();
8401 static void UnmapLevelEditorToolboxCustomGadgets(void)
8403 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
8406 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
8410 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
8412 if (i != GADGET_ID_SINGLE_ITEMS &&
8413 i != GADGET_ID_PICK_ELEMENT)
8415 struct GadgetInfo *gi = level_editor_gadget[i];
8423 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
8424 struct GraphicInfo *gd = &graphic_info[graphic];
8428 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
8429 gi->width, gi->height, gi->x, gi->y);
8431 redraw_mask |= REDRAW_DOOR_3;
8437 static void MapLevelEditorToolboxDrawingGadgets(void)
8439 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
8442 static void UnmapLevelEditorToolboxDrawingGadgets(void)
8444 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
8447 static void UnmapDrawingArea(int id)
8449 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
8452 static void UnmapLevelEditorFieldGadgets(void)
8456 for (i = 0; i < num_editor_gadgets; i++)
8457 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
8458 level_editor_gadget[i]->y))
8459 UnmapGadget(level_editor_gadget[i]);
8462 void UnmapLevelEditorGadgets(void)
8466 for (i = 0; i < num_editor_gadgets; i++)
8467 UnmapGadget(level_editor_gadget[i]);
8470 static void ResetUndoBuffer(void)
8472 undo_buffer_position = -1;
8473 undo_buffer_steps = -1;
8474 redo_buffer_steps = 0;
8476 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8478 level.changed = FALSE;
8481 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
8483 if (remap_toolbox_gadgets)
8485 ModifyEditorElementList();
8486 RedrawDrawingElements();
8489 if (edit_mode == ED_MODE_LEVELCONFIG)
8490 DrawLevelConfigWindow();
8491 else if (edit_mode == ED_MODE_PROPERTIES)
8492 DrawPropertiesWindow();
8493 else if (edit_mode == ED_MODE_PALETTE)
8494 DrawPaletteWindow();
8495 else // edit_mode == ED_MODE_DRAWING
8496 DrawDrawingWindowExt(remap_toolbox_gadgets);
8499 static void DrawEditModeWindow(void)
8501 DrawEditModeWindowExt(TRUE);
8504 static void DrawEditModeWindow_PlayfieldOnly(void)
8506 DrawEditModeWindowExt(FALSE);
8509 static void ChangeEditModeWindow(int new_edit_mode)
8511 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
8513 DrawEditModeWindow();
8516 static boolean LevelChanged(void)
8518 boolean field_changed = FALSE;
8521 for (y = 0; y < lev_fieldy; y++)
8522 for (x = 0; x < lev_fieldx; x++)
8523 if (Tile[x][y] != level.field[x][y])
8524 field_changed = TRUE;
8526 return (level.changed || field_changed);
8529 static boolean PrepareSavingIntoPersonalLevelSet(void)
8531 static LevelDirTree *last_copied_leveldir = NULL;
8532 static LevelDirTree *last_written_leveldir = NULL;
8533 static int last_copied_level_nr = -1;
8534 static int last_written_level_nr = -1;
8535 LevelDirTree *leveldir_former = leveldir_current;
8536 int level_nr_former = level_nr;
8539 // remember last mod/save so that for current session, we write
8540 // back to the same personal copy, asking only about overwrite.
8541 if (leveldir_current == last_copied_leveldir &&
8542 level_nr == last_copied_level_nr)
8544 // "cd" to personal level set dir (as used when writing last copy)
8545 leveldir_current = last_written_leveldir;
8546 level_nr = last_written_level_nr;
8551 if (!Request("This level is read-only! "
8552 "Save into personal level set?", REQ_ASK))
8555 // "cd" to personal level set dir (for writing copy the first time)
8557 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
8559 // this may happen if "setup.internal.create_user_levelset" is FALSE
8560 // or if file "levelinfo.conf" is missing in personal user level set
8561 if (leveldir_current == NULL)
8563 Request("Cannot find personal level set?!", REQ_CONFIRM);
8565 leveldir_current = leveldir_former;
8570 // find unused level number
8571 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
8573 static char *level_filename = NULL;
8575 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
8577 if (!fileExists(level_filename))
8581 last_copied_leveldir = leveldir_former;
8582 last_copied_level_nr = level_nr_former;
8584 last_written_leveldir = leveldir_current;
8585 last_written_level_nr = level_nr = new_level_nr;
8590 static void ModifyLevelConfigForSavingIntoPersonalLevelSet(char *former_name)
8592 static char *filename_levelinfo = NULL, *mod_name = NULL;
8595 // annotate this copy-and-mod in personal levelinfo.conf
8596 setString(&filename_levelinfo,
8597 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
8599 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
8601 fprintf(file, "\n");
8602 fprintf(file, "# level %d was modified from:\n", level_nr);
8603 fprintf(file, "# - previous level set name: %s\n",
8605 fprintf(file, "# - level within previous set: %d \"%s\"\n",
8606 level.file_info.nr, level.name);
8607 fprintf(file, "# - previous author: %s\n",
8609 fprintf(file, "# - previous save date: ");
8611 if (level.creation_date.src == DATE_SRC_LEVELFILE)
8613 fprintf(file, "%04d-%02d-%02d\n",
8614 level.creation_date.year,
8615 level.creation_date.month,
8616 level.creation_date.day);
8620 fprintf(file, "not recorded\n");
8626 if (level_nr > leveldir_current->last_level)
8627 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
8629 // else: allow the save even if annotation failed
8631 // now... spray graffiti on the old level vital statistics
8632 // user can change these; just trying to set a good baseline
8634 // don't truncate names for fear of making offensive or silly:
8635 // long-named original author only recorded in levelinfo.conf.
8636 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
8637 if (!strEqual(level.author, leveldir_current->author))
8639 setString(&mod_name, getStringCat3(leveldir_current->author,
8640 " after ", level.author));
8642 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8643 setString(&mod_name,
8644 getStringCat2(leveldir_current->author, " (ed.)"));
8646 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8647 setString(&mod_name, leveldir_current->author);
8649 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
8651 // less worried about truncation here
8652 setString(&mod_name, getStringCat2("Mod: ", level.name));
8653 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
8657 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
8658 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8662 for (x = 0; x < lev_fieldx; x++)
8663 for (y = 0; y < lev_fieldy; y++)
8664 dst[x][y] = src[x][y];
8667 static int setSelectboxValue(int selectbox_id, int new_value)
8669 int new_index_value = 0;
8672 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8673 if (selectbox_info[selectbox_id].options[i].value == new_value)
8674 new_index_value = i;
8676 *selectbox_info[selectbox_id].value =
8677 selectbox_info[selectbox_id].options[new_index_value].value;
8679 return new_index_value;
8682 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8686 // change action mode and arg variables according to action type variable
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 // only change if corresponding selectbox has changed
8694 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8695 action_arg_modes[mode])
8696 custom_element_change.action_mode = -1;
8698 // only change if corresponding selectbox has changed
8699 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8700 action_arg_options[i].options)
8701 custom_element_change.action_arg = -1;
8708 static void setSelectboxSpecialActionOptions(void)
8712 // change action mode and arg selectbox according to action type selectbox
8713 for (i = 0; action_arg_options[i].value != -1; i++)
8715 if (action_arg_options[i].value == custom_element_change.action_type)
8717 int mode = action_arg_options[i].mode;
8719 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8720 action_arg_modes[mode]);
8721 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8722 custom_element_change.action_mode);
8724 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8725 action_arg_options[i].options);
8726 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8727 custom_element_change.action_arg);
8733 static void copy_custom_element_settings(int element_from, int element_to)
8735 struct ElementInfo *ei_from = &element_info[element_from];
8736 struct ElementInfo *ei_to = &element_info[element_to];
8738 copyElementInfo(ei_from, ei_to);
8741 static void replace_custom_element_in_settings(int element_from,
8746 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8748 struct ElementInfo *ei = &element_info[i];
8750 for (y = 0; y < 3; y++)
8751 for (x = 0; x < 3; x++)
8752 if (ei->content.e[x][y] == element_from)
8753 ei->content.e[x][y] = element_to;
8755 for (j = 0; j < ei->num_change_pages; j++)
8757 struct ElementChangeInfo *change = &ei->change_page[j];
8759 if (change->target_element == element_from)
8760 change->target_element = element_to;
8762 if (change->initial_trigger_element == element_from)
8763 change->initial_trigger_element = element_to;
8765 if (change->action_element == element_from)
8766 change->action_element = element_to;
8768 for (y = 0; y < 3; y++)
8769 for (x = 0; x < 3; x++)
8770 if (change->target_content.e[x][y] == element_from)
8771 change->target_content.e[x][y] = element_to;
8774 if (ei->group != NULL) // group or internal
8775 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8776 if (ei->group->element[j] == element_from)
8777 ei->group->element[j] = element_to;
8781 static void replace_custom_element_in_playfield(int element_from,
8786 for (x = 0; x < lev_fieldx; x++)
8787 for (y = 0; y < lev_fieldy; y++)
8788 if (Tile[x][y] == element_from)
8789 Tile[x][y] = element_to;
8792 static boolean CopyCustomElement(int element_old, int element_new,
8795 int copy_mode_orig = copy_mode;
8797 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8799 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8800 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8801 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8803 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8805 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8806 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8807 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8809 level.changed = TRUE;
8811 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8813 Request("Please choose custom element!", REQ_CONFIRM);
8817 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8819 Request("Please choose group element!", REQ_CONFIRM);
8823 else if (IS_EMPTY_ELEMENT(element_old) && !IS_EMPTY_ELEMENT(element_new))
8825 Request("Please choose empty element!", REQ_CONFIRM);
8831 level.changed = TRUE;
8834 // when modifying custom/group element, ask for copying level template
8835 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8837 if (!AskToCopyAndModifyLevelTemplate())
8841 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8843 copy_custom_element_settings(element_new, element_old);
8845 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8847 copy_custom_element_settings(element_old, element_new);
8849 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8851 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8852 copy_custom_element_settings(element_new, element_old);
8853 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8855 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8856 replace_custom_element_in_settings(element_new, element_old);
8857 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8859 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8860 replace_custom_element_in_playfield(element_new, element_old);
8861 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8864 UpdateCustomElementGraphicGadgets();
8865 DrawPropertiesWindow();
8870 static void CopyCustomElementPropertiesToEditor(int element)
8873 int current_change_page = element_info[element].current_change_page;
8875 // dynamically (re)build selectbox for selecting change page
8876 for (i = 0; i < element_info[element].num_change_pages; i++)
8878 sprintf(options_change_page_strings[i], "%d", i + 1);
8880 options_change_page[i].value = i;
8881 options_change_page[i].text = options_change_page_strings[i];
8884 options_change_page[i].value = -1;
8885 options_change_page[i].text = NULL;
8887 // needed here to initialize combined element properties
8888 InitElementPropertiesEngine(level.game_version);
8890 element_info[element].change =
8891 &element_info[element].change_page[current_change_page];
8893 custom_element = element_info[element];
8894 custom_element_change = *element_info[element].change;
8896 // needed to initially set selectbox options for special action options
8897 setSelectboxSpecialActionOptions();
8899 // needed to initially set selectbox value variables to reliable defaults
8900 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8901 setSelectboxValue(i, *selectbox_info[i].value);
8903 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8904 custom_element_properties[i] = HAS_PROPERTY(element, i);
8906 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8907 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8909 // ---------- element settings: configure (custom elements) -----------------
8911 // set accessible layer selectbox help value
8912 custom_element.access_type =
8913 (IS_WALKABLE(element) ? EP_WALKABLE :
8914 IS_PASSABLE(element) ? EP_PASSABLE :
8915 custom_element.access_type);
8916 custom_element.access_layer =
8917 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8918 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8919 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8920 custom_element.access_layer);
8921 custom_element.access_protected =
8922 (IS_PROTECTED(element) ? 1 : 0);
8923 custom_element_properties[EP_ACCESSIBLE] =
8924 (IS_ACCESSIBLE_OVER(element) ||
8925 IS_ACCESSIBLE_INSIDE(element) ||
8926 IS_ACCESSIBLE_UNDER(element));
8928 // set walk-to-object action selectbox help value
8929 custom_element.walk_to_action =
8930 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8931 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8932 IS_DROPPABLE(element) ? EP_DROPPABLE :
8933 IS_THROWABLE(element) ? EP_THROWABLE :
8934 IS_PUSHABLE(element) ? EP_PUSHABLE :
8935 custom_element.walk_to_action);
8936 custom_element_properties[EP_WALK_TO_OBJECT] =
8937 (IS_DIGGABLE(element) ||
8938 IS_COLLECTIBLE_ONLY(element) ||
8939 IS_DROPPABLE(element) ||
8940 IS_THROWABLE(element) ||
8941 IS_PUSHABLE(element));
8943 // set smash targets selectbox help value
8944 custom_element.smash_targets =
8945 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8946 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8947 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8948 custom_element.smash_targets);
8949 custom_element_properties[EP_CAN_SMASH] =
8950 (CAN_SMASH_EVERYTHING(element) ||
8951 CAN_SMASH_ENEMIES(element) ||
8952 CAN_SMASH_PLAYER(element));
8954 // set deadliness selectbox help value
8955 custom_element.deadliness =
8956 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8957 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8958 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8959 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8960 custom_element.deadliness);
8961 custom_element_properties[EP_DEADLY] =
8962 (DONT_TOUCH(element) ||
8963 DONT_GET_HIT_BY(element) ||
8964 DONT_COLLIDE_WITH(element) ||
8965 DONT_RUN_INTO(element));
8967 // ---------- element settings: advanced (custom elements) ------------------
8969 // set "change by direct action" selectbox help value
8970 custom_element_change.direct_action =
8971 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
8972 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8973 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8974 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8975 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8976 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8977 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8978 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8979 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8980 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8981 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8982 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8983 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8984 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8985 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8986 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8987 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8988 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8989 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8990 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
8991 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
8992 custom_element_change.direct_action);
8994 // set "change by other element action" selectbox help value
8995 custom_element_change.other_action =
8996 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
8997 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8998 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8999 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
9000 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
9001 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
9002 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
9003 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
9004 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
9005 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
9006 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
9007 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
9008 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
9009 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
9010 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
9011 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
9012 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
9013 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
9014 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
9015 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
9016 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
9017 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
9018 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
9019 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
9020 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
9021 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
9022 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
9023 custom_element_change.other_action);
9026 static void CopyGroupElementPropertiesToEditor(int element)
9028 group_element_info = *element_info[element].group;
9029 custom_element = element_info[element]; // needed for description
9032 static void CopyEmptyElementPropertiesToEditor(int element)
9034 custom_element = element_info[element];
9037 static void CopyClassicElementPropertiesToEditor(int element)
9039 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9040 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
9041 getMoveIntoAcidProperty(&level, element);
9043 if (MAYBE_DONT_COLLIDE_WITH(element))
9044 custom_element_properties[EP_DONT_COLLIDE_WITH] =
9045 getDontCollideWithProperty(&level, element);
9048 static void CopyElementPropertiesToEditor(int element)
9050 if (IS_CUSTOM_ELEMENT(element))
9051 CopyCustomElementPropertiesToEditor(element);
9052 else if (IS_GROUP_ELEMENT(element))
9053 CopyGroupElementPropertiesToEditor(element);
9054 else if (IS_EMPTY_ELEMENT(element))
9055 CopyEmptyElementPropertiesToEditor(element);
9057 CopyClassicElementPropertiesToEditor(element);
9060 static boolean AskToCopyAndModifyLevelTemplate(void)
9062 if (Request("Copy and modify settings from level template?", REQ_ASK))
9064 level.use_custom_template = FALSE;
9066 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
9067 GDI_CHECKED, FALSE, GDI_END);
9068 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
9069 GDI_CHECKED, FALSE, GDI_END);
9075 LoadLevelTemplate(-1); // this resets all element modifications ...
9077 DrawEditModeWindow(); // ... and copies them to 'custom_element'
9083 static void CopyCustomElementPropertiesToGame(int element)
9086 int access_type_and_layer;
9088 // mark that this custom element has been modified
9089 custom_element.modified_settings = TRUE;
9090 level.changed = TRUE;
9092 if (level.use_custom_template)
9093 AskToCopyAndModifyLevelTemplate();
9095 element_info[element] = custom_element;
9096 *element_info[element].change = custom_element_change;
9098 // ---------- element settings: configure (custom elements) -----------------
9100 // set accessible property from checkbox and selectbox
9101 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
9102 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
9103 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
9104 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
9105 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
9106 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
9107 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
9108 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
9109 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
9110 custom_element_properties[access_type_and_layer] =
9111 custom_element_properties[EP_ACCESSIBLE];
9112 custom_element_properties[EP_PROTECTED] =
9113 (custom_element.access_protected != 0 &&
9114 custom_element_properties[EP_ACCESSIBLE]);
9116 // set walk-to-object property from checkbox and selectbox
9117 custom_element_properties[EP_DIGGABLE] = FALSE;
9118 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
9119 custom_element_properties[EP_DROPPABLE] = FALSE;
9120 custom_element_properties[EP_THROWABLE] = FALSE;
9121 custom_element_properties[EP_PUSHABLE] = FALSE;
9122 custom_element_properties[custom_element.walk_to_action] =
9123 custom_element_properties[EP_WALK_TO_OBJECT];
9125 // set smash property from checkbox and selectbox
9126 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
9127 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
9128 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
9129 custom_element_properties[custom_element.smash_targets] =
9130 custom_element_properties[EP_CAN_SMASH];
9132 // set deadliness property from checkbox and selectbox
9133 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
9134 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
9135 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
9136 custom_element_properties[EP_DONT_TOUCH] = FALSE;
9137 custom_element_properties[custom_element.deadliness] =
9138 custom_element_properties[EP_DEADLY];
9140 // ---------- element settings: advanced (custom elements) ------------------
9142 // set player change event from checkbox and selectbox
9143 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
9144 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
9145 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
9146 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
9147 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
9148 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
9149 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
9150 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
9151 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
9152 custom_element_change_events[CE_SWITCHED] = FALSE;
9153 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
9154 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
9155 custom_element_change_events[CE_BLOCKED] = FALSE;
9156 custom_element_change_events[CE_IMPACT] = FALSE;
9157 custom_element_change_events[CE_SMASHED] = FALSE;
9158 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
9159 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
9160 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
9161 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
9162 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
9163 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
9164 custom_element_change_events[custom_element_change.direct_action] =
9165 custom_element_change_events[CE_BY_DIRECT_ACTION];
9167 // set other element action change event from checkbox and selectbox
9168 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
9169 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
9170 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
9171 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
9172 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
9173 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
9174 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
9175 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
9176 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
9177 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
9178 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
9179 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
9180 custom_element_change_events[CE_TOUCHING_X] = FALSE;
9181 custom_element_change_events[CE_HITTING_X] = FALSE;
9182 custom_element_change_events[CE_DIGGING_X] = FALSE;
9183 custom_element_change_events[CE_HIT_BY_X] = FALSE;
9184 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
9185 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
9186 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
9187 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
9188 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
9189 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
9190 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
9191 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
9192 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
9193 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
9194 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
9195 custom_element_change_events[custom_element_change.other_action] =
9196 custom_element_change_events[CE_BY_OTHER_ACTION];
9198 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
9199 SET_PROPERTY(element, i, custom_element_properties[i]);
9201 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
9202 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
9204 // copy change events also to special level editor variable
9205 custom_element = element_info[element];
9206 custom_element_change = *element_info[element].change;
9208 // needed here to restore runtime value "element_info[element].gfx_element"
9209 InitElementPropertiesGfxElement();
9212 static void CopyGroupElementPropertiesToGame(int element)
9214 // mark that this group element has been modified
9215 custom_element.modified_settings = TRUE;
9216 level.changed = TRUE;
9218 if (level.use_custom_template)
9219 AskToCopyAndModifyLevelTemplate();
9221 element_info[element] = custom_element;
9222 *element_info[element].group = group_element_info;
9224 // needed here to restore runtime value "element_info[element].gfx_element"
9225 InitElementPropertiesGfxElement();
9228 static void CopyEmptyElementPropertiesToGame(int element)
9230 // mark that this empty element has been modified
9231 custom_element.modified_settings = TRUE;
9232 level.changed = TRUE;
9234 if (level.use_custom_template)
9235 AskToCopyAndModifyLevelTemplate();
9237 element_info[element] = custom_element;
9239 // needed here to restore runtime value "element_info[element].gfx_element"
9240 InitElementPropertiesGfxElement();
9243 static void CopyClassicElementPropertiesToGame(int element)
9245 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9246 setMoveIntoAcidProperty(&level, element,
9247 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
9249 if (MAYBE_DONT_COLLIDE_WITH(element))
9250 setDontCollideWithProperty(&level, element,
9251 custom_element_properties[EP_DONT_COLLIDE_WITH]);
9254 static void CopyElementPropertiesToGame(int element)
9256 if (IS_CUSTOM_ELEMENT(element))
9257 CopyCustomElementPropertiesToGame(element);
9258 else if (IS_GROUP_ELEMENT(element))
9259 CopyGroupElementPropertiesToGame(element);
9260 else if (IS_EMPTY_ELEMENT(element))
9261 CopyEmptyElementPropertiesToGame(element);
9263 CopyClassicElementPropertiesToGame(element);
9267 static void CheckElementDescriptions(void)
9271 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
9272 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
9273 Warn("no element description file for element '%s'", EL_NAME(i));
9277 static int getMaxEdFieldX(boolean has_scrollbar)
9279 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
9280 int sxsize = SXSIZE - scrollbar_width;
9281 int max_ed_fieldx = sxsize / ed_tilesize;
9283 return max_ed_fieldx;
9286 static int getMaxEdFieldY(boolean has_scrollbar)
9288 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
9289 INFOTEXT_YSIZE_FULL : 0);
9290 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
9291 int sysize = SYSIZE - scrollbar_height - infotext_height;
9292 int max_ed_fieldy = sysize / ed_tilesize;
9294 return max_ed_fieldy;
9297 static void InitZoomLevelSettings(int zoom_tilesize)
9299 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
9301 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
9303 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
9304 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
9306 // make sure that tile size is always a power of 2
9307 ed_tilesize = (1 << log_2(ed_tilesize));
9309 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9311 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
9312 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
9316 last_game_engine_type = level.game_engine_type;
9318 // limit zoom tilesize by upper and lower bound
9319 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
9321 // store zoom tilesize in auto setup file only if it was manually changed
9322 if (zoom_tilesize != -1)
9323 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
9325 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
9326 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
9329 static void InitDrawingElements(void)
9331 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
9333 if (level.game_engine_type == game_engine_type_last)
9336 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9338 new_element1 = EL_BD_WALL;
9339 new_element2 = EL_EMPTY;
9340 new_element3 = EL_BD_SAND;
9342 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
9344 new_element1 = EL_SP_CHIP_SINGLE;
9345 new_element2 = EL_EMPTY;
9346 new_element3 = EL_SP_BASE;
9348 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9350 new_element1 = EL_MM_MIRROR_START;
9351 new_element2 = EL_EMPTY;
9352 new_element3 = EL_MM_WOODEN_WALL;
9356 new_element1 = EL_WALL;
9357 new_element2 = EL_EMPTY;
9358 new_element3 = EL_SAND;
9361 game_engine_type_last = level.game_engine_type;
9364 static void InitLevelSetInfo(void)
9366 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
9367 "%s", leveldir_current->name);
9368 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
9369 "%s", leveldir_current->author);
9371 levelset_num_levels = leveldir_current->levels;
9373 levelset_use_levelset_artwork = FALSE;
9374 levelset_copy_level_template = FALSE;
9376 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
9379 static void ChangeEditorToLevelSet(char *levelset_subdir)
9381 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
9383 // the previous level set might have used custom artwork
9384 ReloadCustomArtwork(0);
9386 LoadLevelSetup_SeriesInfo();
9388 SaveLevelSetup_LastSeries();
9389 SaveLevelSetup_SeriesInfo();
9393 LoadLevel(level_nr);
9394 LoadScore(level_nr);
9399 static boolean useEditorDoorAnimation(void)
9401 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
9402 boolean door_1_viewport_unchanged =
9403 (vp_door_1->x == DX &&
9404 vp_door_1->y == DY &&
9405 vp_door_1->width == DXSIZE &&
9406 vp_door_1->height == DYSIZE);
9407 boolean door_1_contains_toolbox =
9410 EX + EXSIZE <= DX + DXSIZE &&
9411 EY + EYSIZE <= DY + DYSIZE);
9413 return (door_1_viewport_unchanged && door_1_contains_toolbox);
9416 static void DrawEditorDoorBackground(int graphic, int x, int y,
9417 int width, int height)
9419 struct GraphicInfo *g = &graphic_info[graphic];
9421 if (g->bitmap != NULL)
9422 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
9423 MIN(width, g->width), MIN(height, g->height), x, y);
9425 ClearRectangle(drawto, x, y, width, height);
9428 static void DrawEditorDoorContent(void)
9430 // needed for gadgets drawn on background (like palette scrollbar)
9431 SetDoorBackgroundImage(IMG_UNDEFINED);
9433 // copy default editor door content to main double buffer
9434 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
9437 DrawSpecialEditorDoor();
9439 // draw new control window
9440 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
9442 // draw all toolbox gadgets to editor doors
9443 MapControlButtons();
9445 // when returning from test game to properties page, redraw toolbox gadgets
9446 if (edit_mode == ED_MODE_PROPERTIES)
9448 UnmapLevelEditorToolboxDrawingGadgets();
9449 UnmapLevelEditorToolboxCustomGadgets();
9451 MapLevelEditorToolboxCustomGadgetsIfNeeded();
9454 // draw all palette gadgets to editor doors
9455 ModifyEditorElementList();
9456 RedrawDrawingElements();
9458 // copy actual editor door content to door double buffer for OpenDoor()
9459 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
9462 void DrawLevelEd(void)
9464 int fade_mask = REDRAW_FIELD;
9466 FadeSoundsAndMusic();
9469 fade_mask = REDRAW_ALL;
9473 // needed if different viewport properties defined for editor
9474 ChangeViewportPropertiesIfNeeded();
9478 InitZoomLevelSettings(-1);
9479 InitDrawingElements();
9483 CheckElementDescriptions();
9486 if (level_editor_test_game)
9488 CopyPlayfield(level.field, Tile);
9489 CopyPlayfield(TileBackup, level.field);
9491 level_editor_test_game = FALSE;
9495 edit_mode = ED_MODE_DRAWING;
9496 edit_mode_levelconfig = ED_MODE_LEVELCONFIG_LEVEL;
9497 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
9505 // redraw_mask |= REDRAW_ALL;
9507 FreeLevelEditorGadgets();
9508 CreateLevelEditorGadgets();
9510 ReinitializeElementList(); // update dynamic level element list
9511 ReinitializeElementListButtons(); // custom element may look different
9513 InitElementPropertiesGfxElement();
9517 DrawEditModeWindow_PlayfieldOnly();
9519 DrawMaskedBorder(fade_mask);
9521 // use door animation if door 1 viewport is unchanged and contains toolbox
9522 if (useEditorDoorAnimation())
9526 DrawEditorDoorContent();
9528 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
9532 DrawEditorDoorContent();
9537 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
9540 static void AdjustDrawingAreaGadgets(void)
9542 int ed_xsize = lev_fieldx + 2;
9543 int ed_ysize = lev_fieldy + 2;
9544 int max_ed_fieldx = MAX_ED_FIELDX;
9545 int max_ed_fieldy = MAX_ED_FIELDY;
9546 boolean horizontal_scrollbar_needed;
9547 boolean vertical_scrollbar_needed;
9548 int x, y, width, height;
9550 if (suppressBorderElement())
9552 ed_xsize = lev_fieldx;
9553 ed_ysize = lev_fieldy;
9556 // check if we need any scrollbars
9557 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9558 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9560 // check if we have a smaller editor field because of scrollbars
9561 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9562 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9564 // check again if we now need more scrollbars because of less space
9565 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9566 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9568 // check if editor field gets even smaller after adding new scrollbars
9569 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9570 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9572 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
9573 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
9575 x = SX + ed_fieldx * ed_tilesize;
9576 y = SY + ed_fieldy * ed_tilesize;
9578 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
9579 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
9581 // adjust drawing area gadget
9582 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
9583 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
9584 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
9587 // adjust horizontal scrollbar gadgets
9588 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
9591 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
9592 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
9595 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9598 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
9601 // adjust vertical scrollbar gadgets
9602 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
9605 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
9607 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
9609 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9612 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
9616 static void AdjustLevelScrollPosition(void)
9618 if (level_xpos < -1)
9620 if (level_xpos > lev_fieldx - ed_fieldx + 1)
9621 level_xpos = lev_fieldx - ed_fieldx + 1;
9622 if (lev_fieldx < ed_fieldx - 2)
9625 if (level_ypos < -1)
9627 if (level_ypos > lev_fieldy - ed_fieldy + 1)
9628 level_ypos = lev_fieldy - ed_fieldy + 1;
9629 if (lev_fieldy < ed_fieldy - 2)
9632 if (suppressBorderElement())
9639 static void AdjustEditorScrollbar(int id)
9641 struct GadgetInfo *gi = level_editor_gadget[id];
9642 int items_max, items_visible, item_position;
9644 if (id == GADGET_ID_SCROLL_HORIZONTAL)
9646 items_max = MAX(lev_fieldx + 2, ed_fieldx);
9647 items_visible = ed_fieldx;
9648 item_position = level_xpos + 1;
9652 items_max = MAX(lev_fieldy + 2, ed_fieldy);
9653 items_visible = ed_fieldy;
9654 item_position = level_ypos + 1;
9657 if (item_position > items_max - items_visible)
9658 item_position = items_max - items_visible;
9660 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9661 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9664 static void AdjustElementListScrollbar(void)
9666 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
9667 int items_max, items_visible, item_position;
9669 // correct position of element list scrollbar
9670 if (element_shift < 0)
9672 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9673 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9675 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
9676 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
9677 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
9679 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9680 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
9681 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9684 static void ModifyEditorCounterValue(int counter_id, int new_value)
9686 int *counter_value = counterbutton_info[counter_id].value;
9687 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9688 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9690 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9692 if (counter_value != NULL)
9693 *counter_value = gi->textinput.number_value;
9696 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9698 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9699 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9701 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9703 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9704 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9706 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9707 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9709 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9710 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9715 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9717 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9718 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9719 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9721 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9724 static void ModifyEditorSelectboxOptions(int selectbox_id,
9725 struct ValueTextInfo *options)
9727 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9728 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9730 selectbox_info[selectbox_id].options = options;
9732 // set index to zero -- list may be shorter now (correct later, if needed)
9733 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9734 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9737 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9739 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9740 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9742 drawingarea_info[drawingarea_id].area_xsize = xsize;
9743 drawingarea_info[drawingarea_id].area_ysize = ysize;
9745 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9748 static void ModifyEditorElementList(void)
9752 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9755 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9757 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9758 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9759 struct GadgetDesign *gd = &gi->deco.design;
9760 int element = editor_elements[element_shift + i];
9761 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9765 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9767 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9773 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9775 int graphic = el2edimg(element);
9776 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9782 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9785 static void ModifyDrawingElementButton(int element, int id)
9787 struct GadgetInfo *gi = level_editor_gadget[id];
9788 Bitmap *deco_bitmap;
9790 int tile_size = gi->deco.width;
9792 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9794 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9797 static void PickDrawingElement(int button, int element)
9802 struct XYTileSize *pos;
9804 } de, drawing_elements[] =
9806 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9807 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9808 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9811 if (button < 1 || button > 3)
9814 if (IS_MM_WALL(element))
9815 element = map_mm_wall_element(element);
9817 de = drawing_elements[button - 1];
9819 *de.new_element = element; // update global drawing element variable
9821 DrawDrawingElementGraphic(element, de.pos);
9822 ModifyDrawingElementButton(element, de.id);
9824 redraw_mask |= REDRAW_DOOR_1;
9827 static void RedrawDrawingElements(void)
9829 PickDrawingElement(1, new_element1);
9830 PickDrawingElement(2, new_element2);
9831 PickDrawingElement(3, new_element3);
9834 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9836 stick_element_properties_window = FALSE;
9838 SetMainBackgroundImage(IMG_UNDEFINED);
9841 UnmapLevelEditorFieldGadgets();
9843 AdjustDrawingAreaGadgets();
9844 AdjustLevelScrollPosition();
9845 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9846 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9848 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9850 MapMainDrawingArea();
9852 if (remap_toolbox_gadgets)
9854 UnmapLevelEditorToolboxCustomGadgets();
9855 MapLevelEditorToolboxDrawingGadgets();
9859 static void DrawDrawingWindow(void)
9861 DrawDrawingWindowExt(TRUE);
9864 static int getTabulatorBarWidth(void)
9866 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9867 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9869 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9872 static int getTabulatorBarHeight(void)
9874 return ED_TAB_BAR_HEIGHT;
9877 static Pixel getTabulatorBarColor(void)
9879 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9880 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9881 int gd_x = gd->x + gd_gi1->border.width / 2;
9882 int gd_y = gd->y + gd_gi1->height - 1;
9884 return GetPixel(gd->bitmap, gd_x, gd_y);
9887 static void DrawLevelConfigTabulatorGadgets(void)
9889 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9890 Pixel tab_color = getTabulatorBarColor();
9891 int id_first = ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL;
9892 int id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR;
9895 // draw additional "engine" tabulator when using native BD engine
9896 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9897 id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE;
9899 for (i = id_first; i <= id_last; i++)
9901 int gadget_id = textbutton_info[i].gadget_id;
9902 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9903 boolean active = (i != edit_mode_levelconfig);
9905 // draw background line below tabulator button
9906 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9908 // draw solid line below inactive tabulator buttons
9909 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9910 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9911 ED_GADGET_TINY_DISTANCE, tab_color);
9913 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9914 MapTextbuttonGadget(i);
9917 // draw little border line below tabulator buttons
9918 if (tab_color != BLACK_PIXEL) // black => transparent
9919 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9920 ED_GADGET_TINY_DISTANCE,
9921 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9924 static void DrawPropertiesTabulatorGadgets(void)
9926 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9927 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9928 int gd_x = gd->x + gd_gi1->border.width / 2;
9929 int gd_y = gd->y + gd_gi1->height - 1;
9930 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9931 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9932 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9935 // draw two config tabulators for player elements
9936 if (IS_PLAYER_ELEMENT(properties_element))
9937 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9939 // draw two config and one "change" tabulator for custom elements
9940 if (IS_CUSTOM_ELEMENT(properties_element))
9941 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9943 for (i = id_first; i <= id_last; i++)
9945 int gadget_id = textbutton_info[i].gadget_id;
9946 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9947 boolean active = (i != edit_mode_properties);
9949 // use "config 1" and "config 2" instead of "config" for players and CEs
9950 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9951 (IS_PLAYER_ELEMENT(properties_element) ||
9952 IS_CUSTOM_ELEMENT(properties_element)))
9955 // draw background line below tabulator button
9956 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9958 // draw solid line below inactive tabulator buttons
9959 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9960 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9961 ED_GADGET_TINY_DISTANCE, tab_color);
9963 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9964 MapTextbuttonGadget(i);
9967 // draw little border line below tabulator buttons
9968 if (tab_color != BLACK_PIXEL) // black => transparent
9969 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9970 ED_GADGET_TINY_DISTANCE,
9971 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9974 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9976 DrawText(SX + xpos, SY + ypos, text, font_nr);
9979 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9982 int font_width = getFontWidth(font_nr);
9983 int font_height = getFontHeight(font_nr);
9984 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9985 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9987 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9988 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9989 TRUE, FALSE, FALSE);
9992 static void DrawLevelConfigLevel(void)
9996 // draw counter gadgets
9997 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9998 MapCounterButtons(i);
10000 // draw checkbutton gadgets
10001 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
10002 MapCheckbuttonGadget(i);
10004 // draw selectbox gadgets
10005 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
10006 MapSelectboxGadget(i);
10008 // draw text input gadgets
10009 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
10010 MapTextInputGadget(i);
10013 static char *getLevelSubdirFromSaveMode(int save_mode)
10015 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
10016 return getNewUserLevelSubdir();
10018 return leveldir_current->subdir;
10021 static void DrawLevelConfigLevelSet_DirectoryInfo(void)
10023 char *directory_text = "Level set directory:";
10024 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
10025 int font1_nr = FONT_TEXT_1;
10026 int font2_nr = FONT_TEXT_2;
10027 int font1_height = getFontHeight(font1_nr);
10028 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
10029 int x = ED_LEVEL_SETTINGS_X(0);
10030 int y = ED_LEVEL_SETTINGS_Y(6);
10032 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
10033 PrintInfoText(directory_name, font2_nr, x, y);
10036 static void DrawLevelConfigLevelSet(void)
10038 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
10039 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
10042 // draw counter gadgets
10043 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
10044 MapCounterButtons(i);
10046 // draw checkbutton gadgets
10047 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
10049 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
10050 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
10051 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
10054 MapCheckbuttonGadget(i);
10057 // draw selectbox gadgets
10058 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
10059 MapSelectboxGadget(i);
10061 // draw text input gadgets
10062 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
10063 MapTextInputGadget(i);
10065 // draw textbutton gadgets
10066 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
10069 DrawLevelConfigLevelSet_DirectoryInfo();
10072 static void DrawLevelConfigEditor(void)
10076 // draw counter gadgets
10077 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
10078 MapCounterButtons(i);
10080 // draw checkbutton gadgets
10081 for (i = ED_CHECKBUTTON_ID_EDITOR_FIRST; i <= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
10082 MapCheckbuttonGadget(i);
10084 // draw radiobutton gadgets
10085 for (i = ED_RADIOBUTTON_ID_EDITOR_FIRST; i <= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
10086 MapRadiobuttonGadget(i);
10088 // draw drawing area
10089 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
10091 // draw textbutton gadgets
10092 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
10095 static void DrawLevelConfigEngine(void)
10099 // draw counter gadgets
10100 if (level.bd_scheduling_type == GD_SCHEDULING_MILLISECONDS)
10102 MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_MS);
10103 MapCounterButtons(ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES);
10107 MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_C64);
10108 MapCounterButtons(ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS);
10111 // draw checkbutton gadgets
10112 for (i = ED_CHECKBUTTON_ID_ENGINE_FIRST; i <= ED_CHECKBUTTON_ID_ENGINE_LAST; i++)
10113 MapCheckbuttonGadget(i);
10115 // draw selectbox gadgets
10116 for (i = ED_SELECTBOX_ID_ENGINE_FIRST; i <= ED_SELECTBOX_ID_ENGINE_LAST; i++)
10117 MapSelectboxGadget(i);
10120 static void DrawLevelConfigWindow(void)
10122 char *text = "Global Settings";
10123 int font_nr = FONT_TITLE_1;
10124 struct MenuPosInfo *pos = &editor.settings.headline;
10125 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
10126 int sy = SY + pos->y;
10128 stick_element_properties_window = FALSE;
10130 SetAutomaticNumberOfGemsNeeded();
10132 UnmapLevelEditorFieldGadgets();
10134 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10137 DrawText(sx, sy, text, font_nr);
10139 DrawLevelConfigTabulatorGadgets();
10141 if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVEL)
10142 DrawLevelConfigLevel();
10143 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVELSET)
10144 DrawLevelConfigLevelSet();
10145 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_EDITOR)
10146 DrawLevelConfigEditor();
10147 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_ENGINE)
10148 DrawLevelConfigEngine();
10151 static void DrawCustomContentArea(void)
10153 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
10154 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10155 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
10156 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
10157 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
10158 int xoffset = ED_GADGET_SPACE_DISTANCE;
10160 // add distance for potential left text (without drawing area border)
10161 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
10163 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10165 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
10168 static void DrawCustomChangeContentArea(void)
10170 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
10171 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10172 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
10173 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
10174 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
10175 int xoffset = ED_GADGET_SPACE_DISTANCE;
10177 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10179 MapDrawingArea(id);
10182 static void RemoveElementContentArea(int id, int font_height)
10184 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10186 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
10187 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
10188 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10189 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
10190 ED_GADGET_TEXT_DISTANCE + font_height);
10193 static void DrawYamYamContentAreas(void)
10195 int font_nr = FONT_TEXT_1;
10196 int font_height = getFontHeight(font_nr);
10197 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10198 int yoffset = (tilesize - font_height) / 2;
10199 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
10200 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
10203 // display counter to choose number of element content areas
10204 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
10206 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10208 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
10210 if (i < level.num_yamyam_contents)
10212 MapDrawingArea(id);
10216 UnmapDrawingArea(id);
10218 // delete content areas in case of reducing number of them
10219 RemoveElementContentArea(id, font_height);
10223 DrawText(x, y + 0 * tilesize, "content", font_nr);
10224 DrawText(x, y + 1 * tilesize, "when", font_nr);
10225 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
10228 static void DrawMagicBallContentAreas(void)
10230 int font_nr = FONT_TEXT_1;
10231 int font_height = getFontHeight(font_nr);
10232 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10233 int yoffset = (tilesize - font_height) / 2;
10234 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
10235 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
10238 // display counter to choose number of element content areas
10239 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
10241 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10243 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
10245 if (i < level.num_ball_contents)
10247 MapDrawingArea(id);
10251 UnmapDrawingArea(id);
10253 // delete content areas in case of reducing number of them
10254 RemoveElementContentArea(id, font_height);
10258 DrawText(x, y + 0 * tilesize, "generated", font_nr);
10259 DrawText(x, y + 1 * tilesize, "when", font_nr);
10260 DrawText(x, y + 2 * tilesize, "active", font_nr);
10263 static void DrawAndroidElementArea(void)
10265 int id = ED_DRAWING_ID_ANDROID_CONTENT;
10266 int num_elements = level.num_android_clone_elements;
10267 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10268 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10269 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10270 int xsize = MAX_ANDROID_ELEMENTS;
10273 // display counter to choose number of element areas
10274 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
10276 if (drawingarea_info[id].text_left != NULL)
10277 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10279 UnmapDrawingArea(id);
10281 ModifyEditorDrawingArea(id, num_elements, 1);
10283 // delete content areas in case of reducing number of them
10284 DrawBackground(sx, sy,
10285 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10286 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10288 MapDrawingArea(id);
10291 static void DrawGroupElementArea(void)
10293 int id = ED_DRAWING_ID_GROUP_CONTENT;
10294 int num_elements = group_element_info.num_elements;
10295 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10296 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10297 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10298 int xsize = MAX_ELEMENTS_IN_GROUP;
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 DrawPlayerInitialInventoryArea(int element)
10318 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
10319 int player_nr = GET_PLAYER_NR(element);
10320 int num_elements = level.initial_inventory_size[player_nr];
10321 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10322 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10323 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10324 int xsize = MAX_INITIAL_INVENTORY_SIZE;
10327 // determine horizontal position to the right of specified gadget
10328 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
10329 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
10330 ED_DRAWINGAREA_TEXT_DISTANCE);
10332 // determine horizontal offset for leading text
10333 if (drawingarea_info[id].text_left != NULL)
10334 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10336 UnmapDrawingArea(id);
10338 ModifyEditorDrawingArea(id, num_elements, 1);
10340 // delete content areas in case of reducing number of them
10341 DrawBackground(sx, sy,
10342 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10343 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10345 MapDrawingArea(id);
10348 static void DrawMMBallContentArea(void)
10350 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
10351 int num_elements = level.num_mm_ball_contents;
10352 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10353 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10354 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10355 int xsize = MAX_MM_BALL_CONTENTS;
10358 if (drawingarea_info[id].text_left != NULL)
10359 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10361 UnmapDrawingArea(id);
10363 ModifyEditorDrawingArea(id, num_elements, 1);
10365 // delete content areas in case of reducing number of them
10366 DrawBackground(sx, sy,
10367 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10368 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10370 MapDrawingArea(id);
10373 static void DrawEnvelopeTextArea(int envelope_nr)
10375 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
10376 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
10380 DrawBackground(gi->x, gi->y,
10381 gi->textarea.crop_width, gi->textarea.crop_height);
10383 if (envelope_nr != -1)
10384 textarea_info[id].value = level.envelope[envelope_nr].text;
10386 ModifyGadget(gi, GDI_AREA_SIZE,
10387 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
10388 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
10391 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
10394 static void DrawPropertiesInfo(void)
10403 // configurable properties
10405 { EP_WALKABLE_OVER, "- player can walk over it" },
10406 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
10407 { EP_WALKABLE_UNDER, "- player can walk under it" },
10408 { EP_PASSABLE_OVER, "- player can pass over it" },
10409 { EP_PASSABLE_INSIDE, "- player can pass through it" },
10410 { EP_PASSABLE_UNDER, "- player can pass under it" },
10411 { EP_PROTECTED, "- player is protected by it" },
10413 { EP_DIGGABLE, "- can be digged away" },
10414 { EP_COLLECTIBLE, "- can be collected" },
10415 { EP_DROPPABLE, "- can be dropped after collecting" },
10416 { EP_THROWABLE, "- can be thrown after collecting" },
10417 { EP_PUSHABLE, "- can be pushed" },
10419 { EP_CAN_FALL, "- can fall" },
10420 { EP_CAN_MOVE, "- can move" },
10422 { EP_CAN_SMASH_PLAYER, "- can smash player" },
10424 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
10426 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
10428 { EP_SLIPPERY, "- slippery for falling elements" },
10429 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
10431 { EP_DONT_RUN_INTO, "- deadly when running into" },
10432 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
10433 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
10434 { EP_DONT_TOUCH, "- deadly when touching" },
10436 { EP_INDESTRUCTIBLE, "- indestructible" },
10438 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
10439 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
10440 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
10442 { EP_CAN_CHANGE, "- can change to other element" },
10444 // pre-defined properties
10445 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
10446 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
10447 { EP_SWITCHABLE, "- can be switched" },
10449 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
10454 char *filename = getElementDescriptionFilename(properties_element);
10455 char *num_elements_text = "In this level: ";
10456 char *num_similar_text = "Similar tiles: ";
10457 char *properties_text = "Standard properties: ";
10458 char *description_text = "Description:";
10459 char *no_description_text = "No description available.";
10460 char *none_text = "None";
10462 int num_elements_in_level = 0;
10463 int num_similar_in_level = 0;
10464 int num_hires_tiles_in_level = 0;
10465 int num_standard_properties = 0;
10466 int font1_nr = FONT_TEXT_1;
10467 int font2_nr = FONT_TEXT_2;
10468 int font1_width = getFontWidth(font1_nr);
10469 int font1_height = getFontHeight(font1_nr);
10470 int font2_height = getFontHeight(font2_nr);
10471 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
10472 int font2_yoffset = (font1_height - font2_height) / 2;
10473 int num_elements_text_len = strlen(num_elements_text) * font1_width;
10474 int num_similar_text_len = strlen(num_similar_text) * font1_width;
10475 int properties_text_len = strlen(properties_text) * font1_width;
10476 int xpos = ED_ELEMENT_SETTINGS_X(0);
10477 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10480 if (setup.editor.show_element_token)
10482 int font3_nr = FONT_TEXT_3;
10483 int font3_height = getFontHeight(font3_nr);
10485 DrawTextF(xpos, ypos, font3_nr,
10486 "[%s]", element_info[properties_element].token_name);
10488 ypos += 2 * font3_height;
10491 // ----- print number of elements / percentage of this element in level
10493 for (y = 0; y < lev_fieldy; y++)
10495 for (x = 0; x < lev_fieldx; x++)
10497 if (Tile[x][y] == properties_element)
10499 num_elements_in_level++;
10501 else if (IS_MM_WALL(Tile[x][y]) &&
10502 map_mm_wall_element(Tile[x][y]) == properties_element)
10504 num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
10509 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10511 DrawTextS(xpos, ypos, font1_nr, num_elements_text);
10513 if (num_hires_tiles_in_level > 0)
10514 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10515 "%d wall tiles", num_hires_tiles_in_level);
10516 else if (num_elements_in_level > 0)
10517 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10518 "%d (%.2f %%)", num_elements_in_level, percentage);
10520 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10523 // ----- print number of similar elements / percentage of them in level
10525 for (y = 0; y < lev_fieldy; y++)
10527 for (x = 0; x < lev_fieldx; x++)
10529 if (strEqual(element_info[Tile[x][y]].class_name,
10530 element_info[properties_element].class_name))
10532 num_similar_in_level++;
10537 if (num_similar_in_level != num_elements_in_level)
10539 ypos += 1 * MAX(font1_height, font2_height);
10541 percentage = num_similar_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10543 DrawTextS(xpos, ypos, font1_nr, num_similar_text);
10545 if (num_similar_in_level > 0)
10546 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10547 "%d (%.2f %%)", num_similar_in_level, percentage);
10549 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10553 ypos += 2 * MAX(font1_height, font2_height);
10555 // ----- print standard properties of this element
10557 DrawTextS(xpos, ypos, font1_nr, properties_text);
10559 ypos += line1_height;
10561 for (i = 0; properties[i].value != -1; i++)
10563 if (!HAS_PROPERTY(properties_element, properties[i].value))
10566 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
10568 ypos += font2_height;
10570 num_standard_properties++;
10573 if (num_standard_properties == 0)
10575 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
10576 font2_nr, none_text);
10578 ypos -= (line1_height - font1_height);
10581 ypos += MAX(font1_height, font2_height);
10583 // ----- print special description of this element
10585 PrintInfoText(description_text, font1_nr, xpos, ypos);
10587 ypos += line1_height;
10589 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
10590 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
10593 #define TEXT_COLLECTING "Score for collecting"
10594 #define TEXT_COLLECTING_EXTRA "Score for extra diamonds"
10595 #define TEXT_SMASHING "Score for smashing"
10596 #define TEXT_SLURPING "Score for slurping robot"
10597 #define TEXT_CRACKING "Score for cracking"
10598 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
10599 #define TEXT_DURATION "Duration when activated"
10600 #define TEXT_DELAY_ON "Delay before activating"
10601 #define TEXT_DELAY_OFF "Delay before deactivating"
10602 #define TEXT_DELAY_CHANGING "Delay before changing"
10603 #define TEXT_DELAY_EXPLODING "Delay before exploding"
10604 #define TEXT_DELAY_MOVING "Delay before moving"
10605 #define TEXT_BALL_DELAY "Element generation delay"
10606 #define TEXT_MOVE_SPEED "Speed of android moving"
10607 #define TEXT_CLONE_SPEED "Speed of android cloning"
10608 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
10609 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
10610 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
10611 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
10612 #define TEXT_TIME_BONUS "Extra time to solve level"
10619 } elements_with_counter[] =
10621 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
10622 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
10623 { EL_BD_DIAMOND, &level.score[SC_DIAMOND_EXTRA], TEXT_COLLECTING_EXTRA },
10624 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
10625 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
10626 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10627 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
10628 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
10629 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
10630 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
10631 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
10632 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10633 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
10634 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10635 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10636 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
10637 { EL_BD_BUTTERFLY_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10638 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
10639 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10640 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10641 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
10642 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10643 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10644 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10645 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10646 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10647 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10648 { EL_BD_FIREFLY_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10649 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10650 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10651 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10652 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10653 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10654 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10655 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10656 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
10657 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
10658 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10659 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
10660 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10661 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10662 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10663 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10664 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10665 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
10666 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10667 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10668 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE], TEXT_COLLECTING },
10669 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10670 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10671 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
10672 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
10673 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
10674 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10675 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10676 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10677 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10678 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10679 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10680 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10681 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10682 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
10683 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
10684 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
10685 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
10686 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
10687 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10688 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
10689 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
10690 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
10691 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10692 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10693 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10694 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10695 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10696 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10697 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10698 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10699 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10700 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10701 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10702 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10703 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10704 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
10705 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10706 { EL_DC_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10707 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
10708 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
10709 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
10710 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
10711 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
10712 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
10713 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
10714 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
10715 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
10716 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
10717 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
10718 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
10719 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
10720 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
10721 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
10722 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
10723 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
10724 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
10725 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
10726 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
10727 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
10728 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
10729 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
10730 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
10731 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
10732 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
10733 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_CHANGING },
10734 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10735 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10740 static boolean checkPropertiesConfig(int element)
10744 // special case: empty space customization only available in R'n'D game engine
10745 if (element == EL_EMPTY_SPACE && level.game_engine_type != GAME_ENGINE_TYPE_RND)
10748 if (IS_GEM(element) ||
10749 IS_CUSTOM_ELEMENT(element) ||
10750 IS_GROUP_ELEMENT(element) ||
10751 IS_EMPTY_ELEMENT(element) ||
10752 IS_BALLOON_ELEMENT(element) ||
10753 IS_ENVELOPE(element) ||
10754 IS_MM_ENVELOPE(element) ||
10755 IS_MM_MCDUFFIN(element) ||
10756 IS_DF_LASER(element) ||
10757 IS_PLAYER_ELEMENT(element) ||
10758 IS_BD_PLAYER_ELEMENT(element) ||
10759 IS_SOKOBAN_OBJECT_OR_FIELD(element) ||
10760 HAS_EDITOR_CONTENT(element) ||
10761 CAN_GROW(element) ||
10762 COULD_MOVE_INTO_ACID(element) ||
10763 MAYBE_DONT_COLLIDE_WITH(element))
10766 for (i = 0; elements_with_counter[i].element != -1; i++)
10767 if (elements_with_counter[i].element == element)
10773 static void SetAutomaticNumberOfGemsNeeded(void)
10777 if (!level.auto_count_gems)
10780 level.gems_needed = 0;
10782 for (x = 0; x < lev_fieldx; x++)
10784 for (y = 0; y < lev_fieldy; y++)
10786 int element = Tile[x][y];
10791 case EL_EMERALD_YELLOW:
10792 case EL_EMERALD_RED:
10793 case EL_EMERALD_PURPLE:
10794 case EL_BD_DIAMOND:
10795 case EL_WALL_EMERALD:
10796 case EL_WALL_EMERALD_YELLOW:
10797 case EL_WALL_EMERALD_RED:
10798 case EL_WALL_EMERALD_PURPLE:
10799 case EL_WALL_BD_DIAMOND:
10801 case EL_SP_INFOTRON:
10804 level.gems_needed++;
10808 case EL_WALL_DIAMOND:
10809 level.gems_needed += 3;
10813 case EL_WALL_PEARL:
10814 level.gems_needed += 5;
10818 case EL_WALL_CRYSTAL:
10819 level.gems_needed += 8;
10828 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10831 static void DrawPropertiesConfig(void)
10833 boolean draw_footer_line = FALSE;
10834 int max_num_element_counters = 4;
10835 int num_element_counters = 0;
10838 if (!checkPropertiesConfig(properties_element))
10840 int xpos = ED_ELEMENT_SETTINGS_X(0);
10841 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10843 PrintInfoText("No configuration options available.",
10844 FONT_TEXT_1, xpos, ypos);
10849 // check if there are elements where a value can be chosen for
10850 for (i = 0; elements_with_counter[i].element != -1; i++)
10852 if (elements_with_counter[i].element == properties_element)
10854 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10856 counterbutton_info[counter_id].y =
10857 ED_ELEMENT_SETTINGS_YPOS(
10858 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10859 (CAN_GROW(properties_element) ? 1 : 0) +
10860 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10861 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10862 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10863 num_element_counters);
10865 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10866 counterbutton_info[counter_id].text_right = elements_with_counter[i].text;
10868 if (properties_element == EL_GAME_OF_LIFE ||
10869 properties_element == EL_BIOMAZE)
10871 counterbutton_info[counter_id].min_value = 0; // min neighbours
10872 counterbutton_info[counter_id].max_value = 8; // max neighbours
10876 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10877 counterbutton_info[counter_id].min_value = MIN_SCORE;
10878 counterbutton_info[counter_id].max_value = MAX_SCORE;
10881 MapCounterButtons(counter_id);
10883 num_element_counters++;
10884 if (num_element_counters >= max_num_element_counters)
10889 if (HAS_EDITOR_CONTENT(properties_element))
10891 // draw stickybutton gadget
10892 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10894 if (IS_AMOEBOID(properties_element))
10895 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10896 else if (properties_element == EL_YAMYAM ||
10897 properties_element == EL_YAMYAM_LEFT ||
10898 properties_element == EL_YAMYAM_RIGHT ||
10899 properties_element == EL_YAMYAM_UP ||
10900 properties_element == EL_YAMYAM_DOWN)
10901 DrawYamYamContentAreas();
10902 else if (properties_element == EL_EMC_MAGIC_BALL)
10904 DrawMagicBallContentAreas();
10906 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10907 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10909 else if (properties_element == EL_EMC_ANDROID)
10910 DrawAndroidElementArea();
10911 else if (properties_element == EL_MM_GRAY_BALL)
10913 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
10914 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
10915 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
10916 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EXPLODE_MM_BALL);
10918 DrawMMBallContentArea();
10922 if (IS_PLAYER_ELEMENT(properties_element))
10924 int player_nr = GET_PLAYER_NR(properties_element);
10926 // these properties can be set for every player individually
10928 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10930 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
10931 &level.start_element[player_nr];
10932 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
10933 &level.artwork_element[player_nr];
10934 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
10935 &level.explosion_element[player_nr];
10937 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10938 &level.use_start_element[player_nr];
10939 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10940 &level.use_artwork_element[player_nr];
10941 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10942 &level.use_explosion_element[player_nr];
10943 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10944 &level.initial_player_gravity[player_nr];
10946 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10947 &level.initial_player_stepsize[player_nr];
10949 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
10950 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
10951 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
10952 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
10953 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
10954 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
10955 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
10956 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
10957 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
10958 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
10959 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
10960 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
10961 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
10962 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
10963 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
10965 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
10966 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
10967 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
10969 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
10971 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10973 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
10974 &level.initial_inventory_content[player_nr][0];
10976 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
10977 &level.initial_inventory_size[player_nr];
10979 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
10980 &level.use_initial_inventory[player_nr];
10982 // draw checkbutton gadgets
10983 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
10984 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
10985 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
10987 // draw counter gadgets
10988 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
10990 // draw drawing area gadgets
10991 DrawPlayerInitialInventoryArea(properties_element);
10995 if (IS_BD_PLAYER_ELEMENT(properties_element))
10996 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS);
10998 // special case: slippery walls option for gems only available in R'n'D game engine
10999 if (IS_GEM(properties_element) && level.game_engine_type == GAME_ENGINE_TYPE_RND)
11001 checkbutton_info[ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS].y =
11002 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_BD_DIAMOND ? 2 : 1);
11004 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
11007 if (properties_element == EL_EM_DYNAMITE)
11008 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
11010 if (COULD_MOVE_INTO_ACID(properties_element) &&
11011 !IS_PLAYER_ELEMENT(properties_element) &&
11012 (!IS_CUSTOM_ELEMENT(properties_element) ||
11013 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
11015 // set position for checkbutton for "can move into acid"
11016 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
11017 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
11018 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
11019 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
11020 IS_BALLOON_ELEMENT(properties_element) ||
11021 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
11023 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
11026 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
11027 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
11029 if (properties_element == EL_SPRING ||
11030 properties_element == EL_SPRING_LEFT ||
11031 properties_element == EL_SPRING_RIGHT)
11032 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
11034 if (properties_element == EL_TIME_ORB_FULL)
11035 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
11037 if (properties_element == EL_GAME_OF_LIFE ||
11038 properties_element == EL_BIOMAZE)
11039 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
11041 if (CAN_GROW(properties_element))
11043 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
11044 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
11046 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
11049 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
11050 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
11052 if (properties_element == EL_SOKOBAN_OBJECT)
11053 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
11055 if (properties_element == EL_SOKOBAN_OBJECT ||
11056 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
11057 properties_element == EL_SOKOBAN_FIELD_FULL)
11059 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
11060 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
11063 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
11066 if (IS_BALLOON_ELEMENT(properties_element))
11067 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
11069 if (IS_ENVELOPE(properties_element) ||
11070 IS_MM_ENVELOPE(properties_element))
11072 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
11073 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
11074 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
11075 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
11076 int envelope_nr = ENVELOPE_NR(properties_element);
11078 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
11079 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
11081 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
11082 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
11084 // display counter to choose size of envelope text area
11085 MapCounterButtons(counter1_id);
11086 MapCounterButtons(counter2_id);
11088 // display checkbuttons to choose auto-wrap and alignment properties
11089 MapCheckbuttonGadget(button1_id);
11090 MapCheckbuttonGadget(button2_id);
11092 DrawEnvelopeTextArea(envelope_nr);
11095 if (IS_MM_MCDUFFIN(properties_element))
11097 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
11098 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
11099 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
11102 if (IS_DF_LASER(properties_element))
11104 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
11105 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
11106 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
11109 if (IS_CUSTOM_ELEMENT(properties_element))
11111 // draw stickybutton gadget
11112 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11114 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
11116 // draw checkbutton gadgets
11117 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
11118 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
11119 MapCheckbuttonGadget(i);
11121 // draw counter gadgets
11122 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
11123 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
11124 MapCounterButtons(i);
11126 // draw selectbox gadgets
11127 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
11128 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
11129 MapSelectboxGadget(i);
11131 // draw textbutton gadgets
11132 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11134 // draw text input gadgets
11135 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11137 // draw drawing area gadgets
11138 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11140 draw_footer_line = TRUE;
11142 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
11144 // draw checkbutton gadgets
11145 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
11146 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
11147 MapCheckbuttonGadget(i);
11149 // draw counter gadgets
11150 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
11151 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
11152 MapCounterButtons(i);
11154 // draw selectbox gadgets
11155 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
11156 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
11157 MapSelectboxGadget(i);
11159 // draw drawing area gadgets
11160 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
11161 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
11162 DrawCustomContentArea();
11165 else if (IS_GROUP_ELEMENT(properties_element))
11167 // draw stickybutton gadget
11168 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11170 // draw checkbutton gadgets
11171 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11172 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11174 // draw counter gadgets
11175 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
11177 // draw selectbox gadgets
11178 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
11180 // draw textbutton gadgets
11181 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11183 // draw drawing area gadgets
11184 DrawGroupElementArea();
11186 // draw text input gadgets
11187 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11189 // draw drawing area gadgets
11190 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11192 draw_footer_line = TRUE;
11194 else if (IS_EMPTY_ELEMENT(properties_element))
11196 // draw stickybutton gadget
11197 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11199 // draw checkbutton gadgets
11200 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11201 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11203 // draw textbutton gadgets
11204 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11206 // draw drawing area gadgets
11207 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11209 draw_footer_line = TRUE;
11212 // draw little footer border line above CE/GE use/save template gadgets
11213 if (draw_footer_line)
11215 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
11216 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
11217 int gd_x = gd->x + gd_gi1->border.width / 2;
11218 int gd_y = gd->y + gd_gi1->height - 1;
11219 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
11221 if (tab_color != BLACK_PIXEL) // black => transparent
11222 FillRectangle(drawto,
11223 SX + ED_ELEMENT_SETTINGS_X(0),
11224 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
11226 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
11230 static void DrawPropertiesChangeDrawingAreas(void)
11232 if (IS_CUSTOM_ELEMENT(properties_element))
11234 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
11235 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
11236 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
11238 DrawCustomChangeContentArea();
11241 redraw_mask |= REDRAW_FIELD;
11244 static void DrawPropertiesChange(void)
11248 // needed to initially set selectbox options for special action options
11249 setSelectboxSpecialActionOptions();
11251 // draw stickybutton gadget
11252 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11254 // draw checkbutton gadgets
11255 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
11256 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
11257 MapCheckbuttonGadget(i);
11259 // draw counter gadgets
11260 for (i = ED_COUNTER_ID_CHANGE_FIRST;
11261 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
11262 MapCounterButtons(i);
11264 // draw selectbox gadgets
11265 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
11266 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
11267 MapSelectboxGadget(i);
11269 // draw textbutton gadgets
11270 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
11271 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
11272 MapTextbuttonGadget(i);
11274 // draw graphicbutton gadgets
11275 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
11276 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
11277 MapGraphicbuttonGadget(i);
11279 // draw drawing area gadgets
11280 DrawPropertiesChangeDrawingAreas();
11283 static void DrawEditorElementAnimation(int x, int y)
11285 int graphic = el2img(properties_element);
11286 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
11287 custom_element.ce_value_fixed_initial :
11288 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
11289 custom_element.collect_score_initial : FrameCounter);
11291 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
11294 static void DrawEditorElementName(int x, int y, int font_nr)
11296 char *element_name = getElementInfoText(properties_element);
11297 int font_width = getFontWidth(font_nr);
11298 int font_height = getFontHeight(font_nr);
11299 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
11300 int max_chars_per_line = max_text_width / font_width;
11302 if (strlen(element_name) <= max_chars_per_line)
11303 DrawTextS(x, y, font_nr, element_name);
11306 char buffer[max_chars_per_line + 1];
11307 int next_pos = max_chars_per_line;
11309 strncpy(buffer, element_name, max_chars_per_line);
11310 buffer[max_chars_per_line] = '\0';
11312 if (element_name[max_chars_per_line] == ' ')
11318 for (i = max_chars_per_line - 1; i >= 0; i--)
11319 if (buffer[i] == ' ')
11322 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
11329 DrawTextS(x, y - font_height / 2, font_nr, buffer);
11331 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
11332 buffer[max_chars_per_line] = '\0';
11334 DrawTextS(x, y + font_height / 2, font_nr, buffer);
11338 static void DrawPropertiesWindow(void)
11340 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
11341 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
11342 int border_size = gd->border_size;
11343 int font_nr = FONT_TEXT_1;
11344 int font_height = getFontHeight(font_nr);
11345 int xoffset = TILEX + element_border + 3 * border_size;
11346 int yoffset = (TILEY - font_height) / 2;
11347 int x1 = editor.settings.element_graphic.x + element_border;
11348 int y1 = editor.settings.element_graphic.y + element_border;
11349 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
11350 editor.settings.element_name.x);
11351 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
11352 editor.settings.element_name.y);
11353 char *text = "Element Settings";
11354 int font2_nr = FONT_TITLE_1;
11355 struct MenuPosInfo *pos = &editor.settings.headline;
11356 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
11357 int sy = SY + pos->y;
11359 stick_element_properties_window = FALSE;
11361 // make sure that previous properties edit mode exists for this element
11362 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
11363 !IS_CUSTOM_ELEMENT(properties_element))
11364 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
11366 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
11367 !IS_PLAYER_ELEMENT(properties_element) &&
11368 !IS_CUSTOM_ELEMENT(properties_element))
11369 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
11371 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
11372 (IS_PLAYER_ELEMENT(properties_element) ||
11373 IS_CUSTOM_ELEMENT(properties_element)))
11374 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
11376 CopyElementPropertiesToEditor(properties_element);
11378 UnmapLevelEditorFieldGadgets();
11379 UnmapLevelEditorToolboxDrawingGadgets();
11380 UnmapLevelEditorToolboxCustomGadgets();
11382 MapLevelEditorToolboxCustomGadgetsIfNeeded();
11384 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11387 DrawText(sx, sy, text, font2_nr);
11389 FrameCounter = 0; // restart animation frame counter
11391 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
11392 DrawEditorElementAnimation(SX + x1, SY + y1);
11393 DrawEditorElementName(x2, y2, font_nr);
11395 DrawPropertiesTabulatorGadgets();
11397 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
11398 DrawPropertiesInfo();
11399 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
11400 DrawPropertiesChange();
11401 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
11402 DrawPropertiesConfig();
11405 static void DrawPaletteWindow(void)
11409 UnmapLevelEditorFieldGadgets();
11411 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11414 // map buttons to select elements
11415 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
11416 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
11417 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
11418 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
11419 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
11422 static void UpdateCustomElementGraphicGadgets(void)
11426 InitElementPropertiesGfxElement();
11428 ModifyEditorElementList();
11429 RedrawDrawingElements();
11431 // force redraw of all mapped drawing area gadgets
11432 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
11434 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
11441 static int getOpenDirectionFromTube(int element)
11445 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
11446 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
11447 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
11448 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
11449 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
11450 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
11451 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
11452 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
11453 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
11454 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
11455 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
11461 static int getTubeFromOpenDirection(int direction)
11465 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
11466 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
11467 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
11468 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
11469 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
11470 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
11471 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
11472 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
11473 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
11474 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
11475 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
11477 // if only one direction, fall back to simple tube with that direction
11478 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
11479 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
11480 case (MV_UP): return EL_TUBE_VERTICAL;
11481 case (MV_DOWN): return EL_TUBE_VERTICAL;
11487 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
11489 int element_new = getTubeFromOpenDirection(direction);
11491 return (element_new != EL_EMPTY ? element_new : element_old);
11494 static int getOpenDirectionFromBelt(int element)
11496 int belt_dir = getBeltDirFromBeltElement(element);
11498 return (belt_dir == MV_LEFT ? MV_RIGHT :
11499 belt_dir == MV_RIGHT ? MV_LEFT :
11500 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
11503 static int getBeltFromNrAndOpenDirection(int nr, int direction)
11505 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
11506 direction == MV_RIGHT ? MV_LEFT :
11507 direction == MV_HORIZONTAL ? MV_NONE : direction);
11509 if (direction == MV_NONE)
11512 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
11515 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
11518 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
11520 return (element_new != EL_EMPTY ? element_new : element_old);
11523 static int getOpenDirectionFromPool(int element)
11527 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
11528 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
11529 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
11530 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
11531 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
11532 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
11538 static int getPoolFromOpenDirection(int direction)
11542 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
11543 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
11544 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
11545 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
11546 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
11547 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
11553 static int getPoolFromOpenDirectionExt(int direction, int help_element)
11555 int element = getPoolFromOpenDirection(direction);
11556 int help_direction = getOpenDirectionFromPool(help_element);
11558 if (element == EL_EMPTY)
11560 int help_direction_vertical = help_direction & MV_VERTICAL;
11562 element = getPoolFromOpenDirection(direction | help_direction_vertical);
11565 if (element == EL_EMPTY)
11567 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
11569 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
11575 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
11577 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
11579 return (element_new != EL_EMPTY ? element_new : element_old);
11582 static int getOpenDirectionFromPillar(int element)
11586 case EL_EMC_WALL_1: return (MV_DOWN);
11587 case EL_EMC_WALL_2: return (MV_VERTICAL);
11588 case EL_EMC_WALL_3: return (MV_UP);
11594 static int getPillarFromOpenDirection(int direction)
11598 case (MV_DOWN): return EL_EMC_WALL_1;
11599 case (MV_VERTICAL): return EL_EMC_WALL_2;
11600 case (MV_UP): return EL_EMC_WALL_3;
11606 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
11608 int element_new = getPillarFromOpenDirection(direction);
11610 return (element_new != EL_EMPTY ? element_new : element_old);
11613 static int getOpenDirectionFromSteel2(int element)
11617 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
11618 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
11619 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
11620 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
11621 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
11622 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
11623 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
11624 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
11630 static int getSteel2FromOpenDirection(int direction)
11634 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
11635 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
11636 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
11637 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
11638 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
11639 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
11640 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
11641 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
11647 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
11649 int element_new = getSteel2FromOpenDirection(direction);
11651 return (element_new != EL_EMPTY ? element_new : element_old);
11654 static int getOpenDirectionFromChip(int element)
11658 case EL_SP_CHIP_SINGLE: return (MV_NONE);
11659 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
11660 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
11661 case EL_SP_CHIP_TOP: return (MV_DOWN);
11662 case EL_SP_CHIP_BOTTOM: return (MV_UP);
11668 static int getChipFromOpenDirection(int direction)
11672 case (MV_NONE): return EL_SP_CHIP_SINGLE;
11673 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
11674 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
11675 case (MV_UP): return EL_SP_CHIP_BOTTOM;
11676 case (MV_DOWN): return EL_SP_CHIP_TOP;
11682 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
11684 int element_new = getChipFromOpenDirection(direction);
11686 return (element_new != EL_EMPTY ? element_new : element_old);
11689 static int getClosedTube(int x, int y)
11691 struct XY *xy = xy_directions;
11692 int element_old = IntelliDrawBuffer[x][y];
11693 int direction_old = getOpenDirectionFromTube(element_old);
11694 int direction_new = MV_NONE;
11697 for (i = 0; i < NUM_DIRECTIONS; i++)
11699 int xx = x + xy[i].x;
11700 int yy = y + xy[i].y;
11701 int dir = MV_DIR_FROM_BIT(i);
11702 int dir_opposite = MV_DIR_OPPOSITE(dir);
11704 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
11705 (direction_old & dir) &&
11706 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11707 direction_new |= dir;
11710 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
11713 static int getClosedBelt(int x, int y)
11715 struct XY *xy = xy_directions;
11716 int element_old = IntelliDrawBuffer[x][y];
11717 int nr = getBeltNrFromBeltElement(element_old);
11718 int direction_old = getOpenDirectionFromBelt(element_old);
11719 int direction_new = MV_NONE;
11722 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11724 int xx = x + xy[i].x;
11725 int yy = y + xy[i].y;
11726 int dir = MV_DIR_FROM_BIT(i);
11727 int dir_opposite = MV_DIR_OPPOSITE(dir);
11729 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
11730 (direction_old & dir) &&
11731 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11732 direction_new |= dir;
11735 return getBeltFromNrAndOpenDirection(nr, direction_new);
11738 static int getClosedPool(int x, int y)
11740 struct XY *xy = xy_directions;
11741 int element_old = IntelliDrawBuffer[x][y];
11742 int direction_old = getOpenDirectionFromPool(element_old);
11743 int direction_new = MV_NONE;
11746 for (i = 0; i < NUM_DIRECTIONS; i++)
11748 int xx = x + xy[i].x;
11749 int yy = y + xy[i].y;
11750 int dir = MV_DIR_FROM_BIT(i);
11751 int dir_opposite = MV_DIR_OPPOSITE(dir);
11753 if (IN_LEV_FIELD(xx, yy) &&
11754 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
11755 (direction_old & dir) &&
11756 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11757 direction_new |= dir;
11760 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
11763 static int getClosedPillar(int x, int y)
11765 struct XY *xy = xy_directions;
11766 int element_old = IntelliDrawBuffer[x][y];
11767 int direction_old = getOpenDirectionFromPillar(element_old);
11768 int direction_new = MV_NONE;
11771 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11773 int xx = x + xy[i].x;
11774 int yy = y + xy[i].y;
11775 int dir = MV_DIR_FROM_BIT(i);
11776 int dir_opposite = MV_DIR_OPPOSITE(dir);
11778 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11779 (direction_old & dir) &&
11780 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11781 direction_new |= dir;
11784 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11787 static int getClosedSteel2(int x, int y)
11789 struct XY *xy = xy_directions;
11790 int element_old = IntelliDrawBuffer[x][y];
11791 int direction_old = getOpenDirectionFromSteel2(element_old);
11792 int direction_new = MV_NONE;
11795 for (i = 0; i < NUM_DIRECTIONS; i++)
11797 int xx = x + xy[i].x;
11798 int yy = y + xy[i].y;
11799 int dir = MV_DIR_FROM_BIT(i);
11800 int dir_opposite = MV_DIR_OPPOSITE(dir);
11802 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11803 (direction_old & dir) &&
11804 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11805 direction_new |= dir;
11808 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11811 static int getClosedChip(int x, int y)
11813 struct XY *xy = xy_directions;
11814 int element_old = IntelliDrawBuffer[x][y];
11815 int direction_old = getOpenDirectionFromChip(element_old);
11816 int direction_new = MV_NONE;
11819 for (i = 0; i < NUM_DIRECTIONS; i++)
11821 int xx = x + xy[i].x;
11822 int yy = y + xy[i].y;
11823 int dir = MV_DIR_FROM_BIT(i);
11824 int dir_opposite = MV_DIR_OPPOSITE(dir);
11826 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11827 (direction_old & dir) &&
11828 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11829 direction_new |= dir;
11832 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11835 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11836 boolean change_level)
11838 int sx = x - level_xpos;
11839 int sy = y - level_ypos;
11840 int old_element = Tile[x][y];
11841 int new_element = element;
11842 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11843 boolean draw_masked = FALSE;
11845 if (IS_MM_WALL_EDITOR(element))
11847 element = map_mm_wall_element_editor(element) | new_bitmask;
11849 if (IS_MM_WALL(old_element))
11850 element |= MM_WALL_BITS(old_element);
11853 draw_masked = TRUE;
11855 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11857 int element_changed = old_element & ~new_bitmask;
11859 if (MM_WALL_BITS(element_changed) != 0)
11860 element = element_changed;
11863 IntelliDrawBuffer[x][y] = element;
11866 Tile[x][y] = element;
11868 if (IN_ED_FIELD(sx, sy))
11870 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11871 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11872 else if (draw_masked)
11873 DrawEditorElementThruMask(sx, sy, element);
11875 DrawEditorElement(sx, sy, element);
11879 static void SetElementSimple(int x, int y, int element, boolean change_level)
11881 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11884 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11885 int x2, int y2, int *element2,
11886 int (*close_function)(int, int),
11887 boolean change_level)
11889 // set neighbour elements to newly determined connections
11890 SetElementSimple(x1, y1, *element1, change_level);
11891 SetElementSimple(x2, y2, *element2, change_level);
11893 // remove all open connections of neighbour elements
11894 *element1 = close_function(x1, y1);
11895 *element2 = close_function(x2, y2);
11897 // set neighbour elements to new, minimized connections
11898 SetElementSimple(x1, y1, *element1, change_level);
11899 SetElementSimple(x2, y2, *element2, change_level);
11902 static void SetElementIntelliDraw(int x, int y, int dx, int dy, int new_element,
11903 boolean change_level, int button)
11905 struct XY *xy = xy_directions;
11906 static int last_x = -1;
11907 static int last_y = -1;
11909 if (new_element == EL_UNDEFINED)
11917 int old_element = IntelliDrawBuffer[x][y];
11919 if (IS_TUBE(new_element))
11921 int last_element_new = EL_UNDEFINED;
11922 int direction = MV_NONE;
11925 // if old element is of same kind, keep all existing directions
11926 if (IS_TUBE(old_element))
11927 direction |= getOpenDirectionFromTube(old_element);
11929 for (i = 0; i < NUM_DIRECTIONS; i++)
11931 int xx = x + xy[i].x;
11932 int yy = y + xy[i].y;
11934 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11935 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11937 int dir = MV_DIR_FROM_BIT(i);
11938 int dir_opposite = MV_DIR_OPPOSITE(dir);
11939 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11940 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11941 int last_direction_new = last_direction_old | dir_opposite;
11943 last_element_new = getTubeFromOpenDirection(last_direction_new);
11949 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
11951 if (last_element_new != EL_UNDEFINED)
11952 MergeAndCloseNeighbourElements(x, y, &new_element,
11953 last_x, last_y, &last_element_new,
11954 getClosedTube, change_level);
11956 else if (IS_BELT(new_element))
11958 int belt_nr = getBeltNrFromBeltElement(new_element);
11959 int last_element_new = EL_UNDEFINED;
11960 int direction = MV_NONE;
11963 // if old element is of same kind, keep all existing directions
11964 if (IS_BELT(old_element))
11965 direction |= getOpenDirectionFromBelt(old_element);
11967 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11969 int xx = x + xy[i].x;
11970 int yy = y + xy[i].y;
11972 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11973 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
11975 int dir = MV_DIR_FROM_BIT(i);
11976 int dir_opposite = MV_DIR_OPPOSITE(dir);
11977 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11978 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
11979 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
11980 int last_direction_new = last_direction_old | dir_opposite;
11982 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11983 last_direction_new);
11988 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
11990 if (last_element_new != EL_UNDEFINED)
11991 MergeAndCloseNeighbourElements(x, y, &new_element,
11992 last_x, last_y, &last_element_new,
11993 getClosedBelt, change_level);
11995 else if (IS_ACID_POOL_OR_ACID(new_element))
11997 int last_element_new = EL_UNDEFINED;
11998 int direction = MV_NONE;
12001 // if old element is of same kind, keep all existing directions
12002 if (IS_ACID_POOL_OR_ACID(old_element))
12003 direction |= getOpenDirectionFromPool(old_element);
12005 for (i = 0; i < NUM_DIRECTIONS; i++)
12007 int xx = x + xy[i].x;
12008 int yy = y + xy[i].y;
12010 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12011 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
12013 int dir = MV_DIR_FROM_BIT(i);
12014 int dir_opposite = MV_DIR_OPPOSITE(dir);
12015 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12016 int last_direction_old = getOpenDirectionFromPool(last_element_old);
12017 int last_direction_new = last_direction_old | dir_opposite;
12019 last_element_new = getPoolFromOpenDirection(last_direction_new);
12025 // special corrections needed for intuitively correct acid pool drawing
12026 if (last_element_new == EL_EMPTY)
12027 last_element_new = new_element;
12028 else if (last_element_new != EL_UNDEFINED)
12029 new_element = last_element_new;
12031 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
12033 if (last_element_new != EL_UNDEFINED)
12034 MergeAndCloseNeighbourElements(x, y, &new_element,
12035 last_x, last_y, &last_element_new,
12036 getClosedPool, change_level);
12038 else if (IS_EMC_PILLAR(new_element))
12040 int last_element_new = EL_UNDEFINED;
12041 int direction = MV_NONE;
12044 // if old element is of same kind, keep all existing directions
12045 if (IS_EMC_PILLAR(old_element))
12046 direction |= getOpenDirectionFromPillar(old_element);
12048 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
12050 int xx = x + xy[i].x;
12051 int yy = y + xy[i].y;
12053 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12054 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
12056 int dir = MV_DIR_FROM_BIT(i);
12057 int dir_opposite = MV_DIR_OPPOSITE(dir);
12058 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12059 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
12060 int last_direction_new = last_direction_old | dir_opposite;
12062 last_element_new = getPillarFromOpenDirection(last_direction_new);
12068 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
12070 if (last_element_new != EL_UNDEFINED)
12071 MergeAndCloseNeighbourElements(x, y, &new_element,
12072 last_x, last_y, &last_element_new,
12073 getClosedPillar, change_level);
12075 else if (IS_DC_STEELWALL_2(new_element))
12077 int last_element_new = EL_UNDEFINED;
12078 int direction = MV_NONE;
12081 // if old element is of same kind, keep all existing directions
12082 if (IS_DC_STEELWALL_2(old_element))
12083 direction |= getOpenDirectionFromSteel2(old_element);
12085 for (i = 0; i < NUM_DIRECTIONS; i++)
12087 int xx = x + xy[i].x;
12088 int yy = y + xy[i].y;
12090 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12091 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
12093 int dir = MV_DIR_FROM_BIT(i);
12094 int dir_opposite = MV_DIR_OPPOSITE(dir);
12095 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12096 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
12097 int last_direction_new = last_direction_old | dir_opposite;
12099 last_element_new = getSteel2FromOpenDirection(last_direction_new);
12105 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
12107 if (last_element_new != EL_UNDEFINED)
12108 MergeAndCloseNeighbourElements(x, y, &new_element,
12109 last_x, last_y, &last_element_new,
12110 getClosedSteel2, change_level);
12112 else if (IS_SP_CHIP(new_element))
12114 int last_element_new = EL_UNDEFINED;
12115 int direction = MV_NONE;
12118 // (do not keep existing directions, regardless of kind of old element)
12120 for (i = 0; i < NUM_DIRECTIONS; i++)
12122 int xx = x + xy[i].x;
12123 int yy = y + xy[i].y;
12125 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12126 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
12128 int dir = MV_DIR_FROM_BIT(i);
12129 int dir_opposite = MV_DIR_OPPOSITE(dir);
12130 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12131 int last_direction_old = getOpenDirectionFromChip(last_element_old);
12132 int last_direction_new = last_direction_old | dir_opposite;
12134 if (last_direction_old == MV_NONE)
12136 last_element_new = getChipFromOpenDirection(last_direction_new);
12139 else if (last_direction_old & (dir | dir_opposite))
12141 direction |= MV_DIR_OPPOSITE(last_direction_old);
12145 direction |= MV_DIR_OPPOSITE(dir);
12150 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
12152 if (last_element_new != EL_UNDEFINED)
12153 MergeAndCloseNeighbourElements(x, y, &new_element,
12154 last_x, last_y, &last_element_new,
12155 getClosedChip, change_level);
12157 else if (IS_SP_HARDWARE_BASE(new_element))
12159 int nr = GetSimpleRandom(6);
12161 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
12162 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
12163 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
12164 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
12165 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
12167 else if (new_element == EL_SP_HARDWARE_GREEN ||
12168 new_element == EL_SP_HARDWARE_BLUE ||
12169 new_element == EL_SP_HARDWARE_RED)
12171 int nr = GetSimpleRandom(3);
12173 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
12174 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
12176 else if (IS_GROUP_ELEMENT(new_element))
12178 boolean connected_drawing = FALSE;
12181 for (i = 0; i < NUM_DIRECTIONS; i++)
12183 int xx = x + xy[i].x;
12184 int yy = y + xy[i].y;
12186 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12187 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
12188 connected_drawing = TRUE;
12191 if (!connected_drawing)
12192 ResolveGroupElement(new_element);
12194 new_element = GetElementFromGroupElement(new_element);
12196 else if (IS_BELT_SWITCH(old_element))
12198 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
12199 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
12201 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
12202 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
12204 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
12208 static int swappable_elements[][2] =
12210 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
12211 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
12212 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
12213 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
12214 { EL_EMERALD, EL_WALL_EMERALD },
12215 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
12216 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
12217 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
12218 { EL_DIAMOND, EL_WALL_DIAMOND },
12219 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
12220 { EL_GATE_1, EL_GATE_1_GRAY },
12221 { EL_GATE_2, EL_GATE_2_GRAY },
12222 { EL_GATE_3, EL_GATE_3_GRAY },
12223 { EL_GATE_4, EL_GATE_4_GRAY },
12224 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
12225 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
12226 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
12227 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
12228 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
12229 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
12230 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
12231 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
12232 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
12233 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
12234 { EL_LAMP, EL_LAMP_ACTIVE },
12235 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
12236 { EL_SP_BASE, EL_SP_BUGGY_BASE },
12237 { EL_PEARL, EL_WALL_PEARL },
12238 { EL_CRYSTAL, EL_WALL_CRYSTAL },
12239 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
12240 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
12241 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
12242 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
12243 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
12244 { EL_LANDMINE, EL_DC_LANDMINE },
12245 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
12246 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
12247 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
12248 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
12249 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
12250 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
12251 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
12252 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
12253 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
12257 static int rotatable_elements_4[][4] =
12267 EL_SPACESHIP_RIGHT,
12272 EL_BD_BUTTERFLY_UP,
12273 EL_BD_BUTTERFLY_RIGHT,
12274 EL_BD_BUTTERFLY_DOWN,
12275 EL_BD_BUTTERFLY_LEFT
12279 EL_BD_FIREFLY_RIGHT,
12280 EL_BD_FIREFLY_DOWN,
12308 EL_SP_GRAVITY_PORT_UP,
12309 EL_SP_GRAVITY_PORT_RIGHT,
12310 EL_SP_GRAVITY_PORT_DOWN,
12311 EL_SP_GRAVITY_PORT_LEFT
12314 EL_SP_GRAVITY_ON_PORT_UP,
12315 EL_SP_GRAVITY_ON_PORT_RIGHT,
12316 EL_SP_GRAVITY_ON_PORT_DOWN,
12317 EL_SP_GRAVITY_ON_PORT_LEFT
12320 EL_SP_GRAVITY_OFF_PORT_UP,
12321 EL_SP_GRAVITY_OFF_PORT_RIGHT,
12322 EL_SP_GRAVITY_OFF_PORT_DOWN,
12323 EL_SP_GRAVITY_OFF_PORT_LEFT
12332 EL_BALLOON_SWITCH_UP,
12333 EL_BALLOON_SWITCH_RIGHT,
12334 EL_BALLOON_SWITCH_DOWN,
12335 EL_BALLOON_SWITCH_LEFT
12339 EL_MM_MCDUFFIN_RIGHT,
12340 EL_MM_MCDUFFIN_DOWN,
12341 EL_MM_MCDUFFIN_LEFT
12344 EL_MM_MIRROR_FIXED_1,
12345 EL_MM_MIRROR_FIXED_4,
12346 EL_MM_MIRROR_FIXED_3,
12347 EL_MM_MIRROR_FIXED_2
12350 EL_MM_STEEL_GRID_FIXED_1,
12351 EL_MM_STEEL_GRID_FIXED_4,
12352 EL_MM_STEEL_GRID_FIXED_2,
12353 EL_MM_STEEL_GRID_FIXED_3
12356 EL_MM_WOODEN_GRID_FIXED_1,
12357 EL_MM_WOODEN_GRID_FIXED_4,
12358 EL_MM_WOODEN_GRID_FIXED_2,
12359 EL_MM_WOODEN_GRID_FIXED_3
12362 EL_MM_POLARIZER_CROSS_1,
12363 EL_MM_POLARIZER_CROSS_4,
12364 EL_MM_POLARIZER_CROSS_3,
12365 EL_MM_POLARIZER_CROSS_2
12369 EL_MM_PACMAN_RIGHT,
12381 EL_DF_RECEIVER_RIGHT,
12382 EL_DF_RECEIVER_DOWN,
12383 EL_DF_RECEIVER_LEFT
12396 static int rotatable_elements_8[][8] =
12399 EL_DF_STEEL_GRID_FIXED_1,
12400 EL_DF_STEEL_GRID_FIXED_8,
12401 EL_DF_STEEL_GRID_FIXED_7,
12402 EL_DF_STEEL_GRID_FIXED_6,
12403 EL_DF_STEEL_GRID_FIXED_5,
12404 EL_DF_STEEL_GRID_FIXED_4,
12405 EL_DF_STEEL_GRID_FIXED_3,
12406 EL_DF_STEEL_GRID_FIXED_2
12409 EL_DF_WOODEN_GRID_FIXED_1,
12410 EL_DF_WOODEN_GRID_FIXED_8,
12411 EL_DF_WOODEN_GRID_FIXED_7,
12412 EL_DF_WOODEN_GRID_FIXED_6,
12413 EL_DF_WOODEN_GRID_FIXED_5,
12414 EL_DF_WOODEN_GRID_FIXED_4,
12415 EL_DF_WOODEN_GRID_FIXED_3,
12416 EL_DF_WOODEN_GRID_FIXED_2
12419 EL_DF_STEEL_GRID_ROTATING_1,
12420 EL_DF_STEEL_GRID_ROTATING_8,
12421 EL_DF_STEEL_GRID_ROTATING_7,
12422 EL_DF_STEEL_GRID_ROTATING_6,
12423 EL_DF_STEEL_GRID_ROTATING_5,
12424 EL_DF_STEEL_GRID_ROTATING_4,
12425 EL_DF_STEEL_GRID_ROTATING_3,
12426 EL_DF_STEEL_GRID_ROTATING_2
12429 EL_DF_WOODEN_GRID_ROTATING_1,
12430 EL_DF_WOODEN_GRID_ROTATING_8,
12431 EL_DF_WOODEN_GRID_ROTATING_7,
12432 EL_DF_WOODEN_GRID_ROTATING_6,
12433 EL_DF_WOODEN_GRID_ROTATING_5,
12434 EL_DF_WOODEN_GRID_ROTATING_4,
12435 EL_DF_WOODEN_GRID_ROTATING_3,
12436 EL_DF_WOODEN_GRID_ROTATING_2
12443 static int rotatable_elements_16[][16] =
12464 EL_MM_TELEPORTER_5,
12465 EL_MM_TELEPORTER_4,
12466 EL_MM_TELEPORTER_3,
12467 EL_MM_TELEPORTER_2,
12468 EL_MM_TELEPORTER_1,
12469 EL_MM_TELEPORTER_16,
12470 EL_MM_TELEPORTER_15,
12471 EL_MM_TELEPORTER_14,
12472 EL_MM_TELEPORTER_13,
12473 EL_MM_TELEPORTER_12,
12474 EL_MM_TELEPORTER_11,
12475 EL_MM_TELEPORTER_10,
12476 EL_MM_TELEPORTER_9,
12477 EL_MM_TELEPORTER_8,
12478 EL_MM_TELEPORTER_7,
12482 EL_MM_TELEPORTER_RED_5,
12483 EL_MM_TELEPORTER_RED_4,
12484 EL_MM_TELEPORTER_RED_3,
12485 EL_MM_TELEPORTER_RED_2,
12486 EL_MM_TELEPORTER_RED_1,
12487 EL_MM_TELEPORTER_RED_16,
12488 EL_MM_TELEPORTER_RED_15,
12489 EL_MM_TELEPORTER_RED_14,
12490 EL_MM_TELEPORTER_RED_13,
12491 EL_MM_TELEPORTER_RED_12,
12492 EL_MM_TELEPORTER_RED_11,
12493 EL_MM_TELEPORTER_RED_10,
12494 EL_MM_TELEPORTER_RED_9,
12495 EL_MM_TELEPORTER_RED_8,
12496 EL_MM_TELEPORTER_RED_7,
12497 EL_MM_TELEPORTER_RED_6
12500 EL_MM_TELEPORTER_YELLOW_5,
12501 EL_MM_TELEPORTER_YELLOW_4,
12502 EL_MM_TELEPORTER_YELLOW_3,
12503 EL_MM_TELEPORTER_YELLOW_2,
12504 EL_MM_TELEPORTER_YELLOW_1,
12505 EL_MM_TELEPORTER_YELLOW_16,
12506 EL_MM_TELEPORTER_YELLOW_15,
12507 EL_MM_TELEPORTER_YELLOW_14,
12508 EL_MM_TELEPORTER_YELLOW_13,
12509 EL_MM_TELEPORTER_YELLOW_12,
12510 EL_MM_TELEPORTER_YELLOW_11,
12511 EL_MM_TELEPORTER_YELLOW_10,
12512 EL_MM_TELEPORTER_YELLOW_9,
12513 EL_MM_TELEPORTER_YELLOW_8,
12514 EL_MM_TELEPORTER_YELLOW_7,
12515 EL_MM_TELEPORTER_YELLOW_6
12518 EL_MM_TELEPORTER_GREEN_5,
12519 EL_MM_TELEPORTER_GREEN_4,
12520 EL_MM_TELEPORTER_GREEN_3,
12521 EL_MM_TELEPORTER_GREEN_2,
12522 EL_MM_TELEPORTER_GREEN_1,
12523 EL_MM_TELEPORTER_GREEN_16,
12524 EL_MM_TELEPORTER_GREEN_15,
12525 EL_MM_TELEPORTER_GREEN_14,
12526 EL_MM_TELEPORTER_GREEN_13,
12527 EL_MM_TELEPORTER_GREEN_12,
12528 EL_MM_TELEPORTER_GREEN_11,
12529 EL_MM_TELEPORTER_GREEN_10,
12530 EL_MM_TELEPORTER_GREEN_9,
12531 EL_MM_TELEPORTER_GREEN_8,
12532 EL_MM_TELEPORTER_GREEN_7,
12533 EL_MM_TELEPORTER_GREEN_6
12536 EL_MM_TELEPORTER_BLUE_5,
12537 EL_MM_TELEPORTER_BLUE_4,
12538 EL_MM_TELEPORTER_BLUE_3,
12539 EL_MM_TELEPORTER_BLUE_2,
12540 EL_MM_TELEPORTER_BLUE_1,
12541 EL_MM_TELEPORTER_BLUE_16,
12542 EL_MM_TELEPORTER_BLUE_15,
12543 EL_MM_TELEPORTER_BLUE_14,
12544 EL_MM_TELEPORTER_BLUE_13,
12545 EL_MM_TELEPORTER_BLUE_12,
12546 EL_MM_TELEPORTER_BLUE_11,
12547 EL_MM_TELEPORTER_BLUE_10,
12548 EL_MM_TELEPORTER_BLUE_9,
12549 EL_MM_TELEPORTER_BLUE_8,
12550 EL_MM_TELEPORTER_BLUE_7,
12551 EL_MM_TELEPORTER_BLUE_6
12555 EL_MM_POLARIZER_16,
12556 EL_MM_POLARIZER_15,
12557 EL_MM_POLARIZER_14,
12558 EL_MM_POLARIZER_13,
12559 EL_MM_POLARIZER_12,
12560 EL_MM_POLARIZER_11,
12561 EL_MM_POLARIZER_10,
12590 EL_DF_MIRROR_ROTATING_1,
12591 EL_DF_MIRROR_ROTATING_16,
12592 EL_DF_MIRROR_ROTATING_15,
12593 EL_DF_MIRROR_ROTATING_14,
12594 EL_DF_MIRROR_ROTATING_13,
12595 EL_DF_MIRROR_ROTATING_12,
12596 EL_DF_MIRROR_ROTATING_11,
12597 EL_DF_MIRROR_ROTATING_10,
12598 EL_DF_MIRROR_ROTATING_9,
12599 EL_DF_MIRROR_ROTATING_8,
12600 EL_DF_MIRROR_ROTATING_7,
12601 EL_DF_MIRROR_ROTATING_6,
12602 EL_DF_MIRROR_ROTATING_5,
12603 EL_DF_MIRROR_ROTATING_4,
12604 EL_DF_MIRROR_ROTATING_3,
12605 EL_DF_MIRROR_ROTATING_2
12608 EL_DF_MIRROR_FIXED_1,
12609 EL_DF_MIRROR_FIXED_16,
12610 EL_DF_MIRROR_FIXED_15,
12611 EL_DF_MIRROR_FIXED_14,
12612 EL_DF_MIRROR_FIXED_13,
12613 EL_DF_MIRROR_FIXED_12,
12614 EL_DF_MIRROR_FIXED_11,
12615 EL_DF_MIRROR_FIXED_10,
12616 EL_DF_MIRROR_FIXED_9,
12617 EL_DF_MIRROR_FIXED_8,
12618 EL_DF_MIRROR_FIXED_7,
12619 EL_DF_MIRROR_FIXED_6,
12620 EL_DF_MIRROR_FIXED_5,
12621 EL_DF_MIRROR_FIXED_4,
12622 EL_DF_MIRROR_FIXED_3,
12623 EL_DF_MIRROR_FIXED_2
12632 for (i = 0; swappable_elements[i][0] != -1; i++)
12634 int element1 = swappable_elements[i][0];
12635 int element2 = swappable_elements[i][1];
12637 if (old_element == element1 || old_element == element2)
12638 new_element = (old_element == element1 ? element2 : element1);
12641 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
12643 for (j = 0; j < 4; j++)
12645 int element = rotatable_elements_4[i][j];
12647 if (old_element == element)
12648 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
12649 button == 2 ? rotatable_elements_4[i][0] :
12650 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
12655 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
12657 for (j = 0; j < 8; j++)
12659 int element = rotatable_elements_8[i][j];
12661 if (old_element == element)
12662 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
12663 button == 2 ? rotatable_elements_8[i][0] :
12664 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
12669 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
12671 for (j = 0; j < 16; j++)
12673 int element = rotatable_elements_16[i][j];
12675 if (old_element == element)
12676 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
12677 button == 2 ? rotatable_elements_16[i][0] :
12678 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
12683 if (old_element != new_element)
12685 int max_infotext_len = getMaxInfoTextLength();
12686 char infotext[MAX_OUTPUT_LINESIZE + 1];
12688 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
12689 infotext[max_infotext_len] = '\0';
12691 ClearEditorGadgetInfoText();
12693 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
12698 if (IS_MM_WALL_EDITOR(new_element))
12699 SetElementSimpleExt(x, y, dx, dy, new_element, change_level);
12701 SetElementSimple(x, y, new_element, change_level);
12707 static void ResetIntelliDraw(void)
12711 for (x = 0; x < lev_fieldx; x++)
12712 for (y = 0; y < lev_fieldy; y++)
12713 IntelliDrawBuffer[x][y] = Tile[x][y];
12715 SetElementIntelliDraw(-1, -1, -1, -1, EL_UNDEFINED, FALSE, -1);
12718 static boolean draw_mode_hires = FALSE;
12720 static boolean isHiresTileElement(int element)
12722 return (IS_MM_WALL(element) || element == EL_EMPTY);
12725 static boolean isHiresDrawElement(int element)
12727 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
12730 static int numHiresTiles(int element)
12732 if (IS_MM_WALL(element))
12733 return get_number_of_bits(MM_WALL_BITS(element));
12738 static void SetDrawModeHiRes(int element)
12741 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12742 isHiresDrawElement(element));
12745 static boolean getDrawModeHiRes(void)
12747 return draw_mode_hires;
12750 static int getLoResScreenPos(int pos)
12752 return (getDrawModeHiRes() ? pos / 2 : pos);
12755 static int getLoResScreenMod(int pos)
12757 return (getDrawModeHiRes() ? pos % 2 : 0);
12760 static void SetElementExt(int x, int y, int dx, int dy, int element,
12761 boolean change_level, int button)
12764 SetElementSimple(x, y, Tile[x][y], change_level);
12765 else if (GetKeyModState() & KMOD_Shift)
12766 SetElementIntelliDraw(x, y, dx, dy, element, change_level, button);
12768 SetElementSimpleExt(x, y, dx, dy, element, change_level);
12771 static void SetElement(int x, int y, int element)
12773 SetElementExt(x, y, 0, 0, element, TRUE, -1);
12776 static void SetElementButton(int x, int y, int dx, int dy, int element,
12779 SetElementExt(x, y, dx, dy, element, TRUE, button);
12782 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
12784 int lx = getLoResScreenPos(sx2) + level_xpos;
12785 int ly = getLoResScreenPos(sy2) + level_ypos;
12786 int dx = getLoResScreenMod(sx2);
12787 int dy = getLoResScreenMod(sy2);
12789 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
12792 static void SetLevelElementHiRes(int lx2, int ly2, int element)
12799 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
12802 static int getLevelElementHiRes(int lx2, int ly2)
12808 int element = Tile[lx][ly];
12809 unsigned int bitmask = (dx + 1) << (dy * 2);
12811 if (IS_MM_WALL(element))
12813 if (element & bitmask)
12814 return map_mm_wall_element(element);
12822 static void DrawLineElement(int x, int y, int element, boolean change_level)
12824 SetElementHiRes(x, y, element, change_level);
12827 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12828 int element, boolean change_level)
12830 int xsize = ABS(to_x - from_x);
12831 int ysize = ABS(to_y - from_y);
12832 int dx = (to_x < from_x ? -1 : +1);
12833 int dy = (to_y < from_y ? -1 : +1);
12836 if (from_y == to_y) // horizontal line
12838 for (i = 0; i <= xsize; i++)
12839 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12841 else if (from_x == to_x) // vertical line
12843 for (i = 0; i <= ysize; i++)
12844 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12846 else // diagonal line
12848 if (ysize < xsize) // a < 1
12850 float a = (float)ysize / (float)xsize;
12852 for (i = 0; i <= xsize; i++)
12855 int y = dy * (int)(a * i + 0.5);
12857 DrawLineElement(from_x + x, from_y + y, element, change_level);
12862 float a = (float)xsize / (float)ysize;
12864 for (i = 0; i <= ysize; i++)
12866 int x = dx * (int)(a * i + 0.5);
12869 DrawLineElement(from_x + x, from_y + y, element, change_level);
12875 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12876 int element, boolean change_level)
12878 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12879 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12880 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12881 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12884 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12885 int element, boolean change_level)
12890 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12892 for (y = from_y; y <= to_y; y++)
12893 DrawLine(from_x, y, to_x, y, element, change_level);
12896 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12897 int element, boolean change_level)
12899 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12900 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12901 int len_x = ABS(to_x - from_x);
12902 int len_y = ABS(to_y - from_y);
12905 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
12907 // not optimal (some points get drawn twice) but simple,
12908 // and fast enough for the few points we are drawing
12910 for (x = 0; x <= radius; x++)
12912 int sx, sy, sx2, sy2, lx, ly;
12914 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
12916 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12917 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12918 sx = getLoResScreenPos(sx2);
12919 sy = getLoResScreenPos(sy2);
12920 lx = sx + level_xpos;
12921 ly = sy + level_ypos;
12923 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12924 DrawLineElement(sx2, sy2, element, change_level);
12927 for (y = 0; y <= radius; y++)
12929 int sx, sy, sx2, sy2, lx, ly;
12931 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
12933 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12934 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12935 sx = getLoResScreenPos(sx2);
12936 sy = getLoResScreenPos(sy2);
12937 lx = sx + level_xpos;
12938 ly = sy + level_ypos;
12940 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12941 DrawLineElement(sx2, sy2, element, change_level);
12945 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
12946 int element, boolean change_level)
12948 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12949 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12951 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12954 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
12956 #if DRAW_CIRCLES_BUTTON_AVAILABLE
12957 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
12958 int element, boolean change_level)
12960 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12961 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12962 int mirror_to_x2 = from_x - (to_x2 - from_x);
12963 int mirror_to_y2 = from_y - (to_y2 - from_y);
12965 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12966 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
12967 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
12968 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element, change_level);
12972 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
12974 int from_sx, from_sy;
12978 swap_numbers(&from_x, &to_x);
12981 swap_numbers(&from_y, &to_y);
12983 from_sx = SX + from_x * ed_tilesize;
12984 from_sy = SY + from_y * ed_tilesize;
12985 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
12986 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
12988 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12989 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12990 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12991 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12993 if (from_x == to_x && from_y == to_y)
12994 MarkTileDirty(from_x/2, from_y/2);
12996 redraw_mask |= REDRAW_FIELD;
12999 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
13000 int element, boolean change_level)
13002 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
13005 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
13006 int element, boolean change_level)
13008 if (element == -1 || change_level)
13009 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
13011 DrawAreaBorder(from_x, from_y, to_x, to_y);
13014 // values for CopyBrushExt()
13015 #define CB_AREA_TO_BRUSH 0
13016 #define CB_BRUSH_TO_CURSOR 1
13017 #define CB_BRUSH_TO_LEVEL 2
13018 #define CB_DELETE_OLD_CURSOR 3
13019 #define CB_DUMP_BRUSH 4
13020 #define CB_DUMP_BRUSH_SMALL 5
13021 #define CB_CLIPBOARD_TO_BRUSH 6
13022 #define CB_BRUSH_TO_CLIPBOARD 7
13023 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
13024 #define CB_UPDATE_BRUSH_POSITION 9
13025 #define CB_FLIP_BRUSH_X 10
13026 #define CB_FLIP_BRUSH_Y 11
13027 #define CB_FLIP_BRUSH_XY 12
13029 #define MAX_CB_PART_SIZE 10
13030 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
13031 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
13032 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
13033 MAX_CB_NUM_LINES * \
13036 static int getFlippedTileExt(int map[], int element)
13040 for (i = 0; map[i] != -1; i++)
13041 if (map[i] == element)
13042 return map[i ^ 1]; // get flipped element by flipping LSB of index
13047 static int getFlippedTileX(int element)
13051 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_RIGHT,
13052 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_RIGHT,
13053 EL_BUG_LEFT, EL_BUG_RIGHT,
13054 EL_SPACESHIP_LEFT, EL_SPACESHIP_RIGHT,
13055 EL_PACMAN_LEFT, EL_PACMAN_RIGHT,
13056 EL_ARROW_LEFT, EL_ARROW_RIGHT,
13057 EL_MOLE_LEFT, EL_MOLE_RIGHT,
13058 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_RIGHT,
13059 EL_YAMYAM_LEFT, EL_YAMYAM_RIGHT,
13060 EL_SP_PORT_LEFT, EL_SP_PORT_RIGHT,
13061 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_RIGHT,
13062 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_RIGHT,
13063 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_RIGHT,
13064 EL_CONVEYOR_BELT_1_LEFT, EL_CONVEYOR_BELT_1_RIGHT,
13065 EL_CONVEYOR_BELT_2_LEFT, EL_CONVEYOR_BELT_2_RIGHT,
13066 EL_CONVEYOR_BELT_3_LEFT, EL_CONVEYOR_BELT_3_RIGHT,
13067 EL_CONVEYOR_BELT_4_LEFT, EL_CONVEYOR_BELT_4_RIGHT,
13068 EL_SPRING_LEFT, EL_SPRING_RIGHT,
13069 EL_SP_CHIP_LEFT, EL_SP_CHIP_RIGHT,
13070 EL_TUBE_VERTICAL_LEFT, EL_TUBE_VERTICAL_RIGHT,
13071 EL_TUBE_LEFT_UP, EL_TUBE_RIGHT_UP,
13072 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_DOWN,
13073 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_RIGHT,
13074 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_TOPRIGHT,
13075 EL_DC_STEELWALL_1_BOTTOMLEFT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13076 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_TOPRIGHT_2,
13077 EL_DC_STEELWALL_1_BOTTOMLEFT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13078 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_RIGHT,
13079 EL_ACID_POOL_TOPLEFT, EL_ACID_POOL_TOPRIGHT,
13080 EL_ACID_POOL_BOTTOMLEFT, EL_ACID_POOL_BOTTOMRIGHT,
13085 return getFlippedTileExt(map, element);
13088 static int getFlippedTileY(int element)
13092 EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY_DOWN,
13093 EL_BD_FIREFLY_UP, EL_BD_FIREFLY_DOWN,
13094 EL_BUG_UP, EL_BUG_DOWN,
13095 EL_SPACESHIP_UP, EL_SPACESHIP_DOWN,
13096 EL_PACMAN_UP, EL_PACMAN_DOWN,
13097 EL_ARROW_UP, EL_ARROW_DOWN,
13098 EL_MOLE_UP, EL_MOLE_DOWN,
13099 EL_BALLOON_SWITCH_UP, EL_BALLOON_SWITCH_DOWN,
13100 EL_YAMYAM_UP, EL_YAMYAM_DOWN,
13101 EL_SP_PORT_UP, EL_SP_PORT_DOWN,
13102 EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN,
13103 EL_SP_GRAVITY_ON_PORT_UP, EL_SP_GRAVITY_ON_PORT_DOWN,
13104 EL_SP_GRAVITY_OFF_PORT_UP, EL_SP_GRAVITY_OFF_PORT_DOWN,
13105 EL_SP_CHIP_TOP, EL_SP_CHIP_BOTTOM,
13106 EL_TUBE_HORIZONTAL_UP, EL_TUBE_HORIZONTAL_DOWN,
13107 EL_TUBE_LEFT_UP, EL_TUBE_LEFT_DOWN,
13108 EL_TUBE_RIGHT_UP, EL_TUBE_RIGHT_DOWN,
13109 EL_DC_STEELWALL_1_TOP, EL_DC_STEELWALL_1_BOTTOM,
13110 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13111 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13112 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13113 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13114 EL_DC_STEELWALL_2_TOP, EL_DC_STEELWALL_2_BOTTOM,
13115 EL_EMC_WALL_1, EL_EMC_WALL_3,
13120 return getFlippedTileExt(map, element);
13123 static int getFlippedTileXY(int element)
13127 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_UP,
13128 EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY_DOWN,
13129 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_UP,
13130 EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY_DOWN,
13131 EL_BUG_LEFT, EL_BUG_UP,
13132 EL_BUG_RIGHT, EL_BUG_DOWN,
13133 EL_SPACESHIP_LEFT, EL_SPACESHIP_UP,
13134 EL_SPACESHIP_RIGHT, EL_SPACESHIP_DOWN,
13135 EL_PACMAN_LEFT, EL_PACMAN_UP,
13136 EL_PACMAN_RIGHT, EL_PACMAN_DOWN,
13137 EL_ARROW_LEFT, EL_ARROW_UP,
13138 EL_ARROW_RIGHT, EL_ARROW_DOWN,
13139 EL_MOLE_LEFT, EL_MOLE_UP,
13140 EL_MOLE_RIGHT, EL_MOLE_DOWN,
13141 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_UP,
13142 EL_BALLOON_SWITCH_RIGHT, EL_BALLOON_SWITCH_DOWN,
13143 EL_YAMYAM_LEFT, EL_YAMYAM_UP,
13144 EL_YAMYAM_RIGHT, EL_YAMYAM_DOWN,
13145 EL_SP_PORT_LEFT, EL_SP_PORT_UP,
13146 EL_SP_PORT_RIGHT, EL_SP_PORT_DOWN,
13147 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_UP,
13148 EL_SP_GRAVITY_PORT_RIGHT, EL_SP_GRAVITY_PORT_DOWN,
13149 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_UP,
13150 EL_SP_GRAVITY_ON_PORT_RIGHT, EL_SP_GRAVITY_ON_PORT_DOWN,
13151 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_UP,
13152 EL_SP_GRAVITY_OFF_PORT_RIGHT, EL_SP_GRAVITY_OFF_PORT_DOWN,
13153 EL_SP_CHIP_LEFT, EL_SP_CHIP_TOP,
13154 EL_SP_CHIP_RIGHT, EL_SP_CHIP_BOTTOM,
13155 EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL,
13156 EL_TUBE_VERTICAL_LEFT, EL_TUBE_HORIZONTAL_UP,
13157 EL_TUBE_VERTICAL_RIGHT, EL_TUBE_HORIZONTAL_DOWN,
13158 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_UP,
13159 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_TOP,
13160 EL_DC_STEELWALL_1_RIGHT, EL_DC_STEELWALL_1_BOTTOM,
13161 EL_DC_STEELWALL_1_HORIZONTAL, EL_DC_STEELWALL_1_VERTICAL,
13162 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13163 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13164 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_TOP,
13165 EL_DC_STEELWALL_2_RIGHT, EL_DC_STEELWALL_2_BOTTOM,
13166 EL_DC_STEELWALL_2_HORIZONTAL, EL_DC_STEELWALL_2_VERTICAL,
13167 EL_EXPANDABLE_WALL_HORIZONTAL, EL_EXPANDABLE_WALL_VERTICAL,
13168 EL_EXPANDABLE_STEELWALL_HORIZONTAL, EL_EXPANDABLE_STEELWALL_VERTICAL,
13173 return getFlippedTileExt(map, element);
13176 static int getFlippedTile(int element, int mode)
13178 if (IS_MM_ELEMENT(element))
13180 // get MM game element
13181 element = map_element_RND_to_MM(element);
13183 // get flipped game element
13184 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX_MM(element) :
13185 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY_MM(element) :
13186 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY_MM(element) :
13189 // get RND game element again
13190 element = map_element_MM_to_RND(element);
13194 // get flipped game element
13195 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX(element) :
13196 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY(element) :
13197 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY(element) :
13204 static void SwapFlippedTiles(short *tile1, short *tile2, int mode)
13207 short tile1_flipped = getFlippedTile(*tile1, mode);
13208 short tile2_flipped = getFlippedTile(*tile2, mode);
13211 *tile1 = tile2_flipped;
13212 *tile2 = tile1_flipped;
13215 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
13217 DrawLineElement(sx, sy, element, change_level);
13220 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
13221 int button, int mode)
13223 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13224 static int brush_width, brush_height;
13225 static int last_cursor_x = -1, last_cursor_y = -1;
13226 static boolean delete_old_brush = FALSE;
13227 int new_element = BUTTON_ELEMENT(button);
13230 if (mode == CB_DUMP_BRUSH ||
13231 mode == CB_DUMP_BRUSH_SMALL ||
13232 mode == CB_BRUSH_TO_CLIPBOARD ||
13233 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13235 if (edit_mode != ED_MODE_DRAWING)
13238 char part[MAX_CB_PART_SIZE + 1] = "";
13239 char text[MAX_CB_TEXT_SIZE + 1] = "";
13240 int width = (draw_with_brush ? brush_width : lev_fieldx);
13241 int height = (draw_with_brush ? brush_height : lev_fieldy);
13242 char *format = "%s%03d";
13244 for (y = 0; y < height; y++)
13245 for (x = 0; x < width; x++)
13246 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
13249 for (y = 0; y < height; y++)
13251 for (x = 0; x < width; x++)
13253 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
13254 char *prefix = (mode == CB_DUMP_BRUSH ||
13255 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
13257 if (element >= NUM_FILE_ELEMENTS)
13258 element = EL_UNKNOWN;
13260 // copy brush to level sketch text buffer for the R'n'D forum:
13261 // - large tiles: `xxx or `xxxx (0x60 ASCII)
13262 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
13263 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
13264 strcat(text, part);
13267 strcat(text, "\n");
13270 if (mode == CB_BRUSH_TO_CLIPBOARD ||
13271 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13272 SDL_SetClipboardText(text);
13274 Print("%s", text); // print brush data to console and log file
13279 if (mode == CB_CLIPBOARD_TO_BRUSH)
13281 if (edit_mode != ED_MODE_DRAWING)
13284 if (!SDL_HasClipboardText())
13286 Request("Clipboard is empty!", REQ_CONFIRM);
13291 boolean copy_to_brush = (draw_with_brush ||
13292 drawing_function == GADGET_ID_GRAB_BRUSH);
13294 // this will delete the old brush, if already drawing with a brush
13296 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
13298 // initialization is required for "odd" (incomplete) clipboard content
13299 for (x = 0; x < MAX_LEV_FIELDX; x++)
13300 for (y = 0; y < MAX_LEV_FIELDY; y++)
13301 brush_buffer[x][y] = EL_EMPTY;
13308 char *clipboard_text = SDL_GetClipboardText();
13309 char *ptr = clipboard_text;
13310 boolean allow_new_row = FALSE;
13311 boolean stop = FALSE;
13313 while (*ptr && !stop)
13315 boolean prefix_found = FALSE;
13316 boolean start_new_row = FALSE;
13318 // level sketch element number prefixes (may be multi-byte characters)
13319 char *prefix_list[] = { "`", "¸" };
13322 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
13324 char *prefix = prefix_list[i];
13326 // check if string is large enough for prefix
13327 if (strlen(ptr) < strlen(prefix))
13334 // check if string starts with prefix
13335 if (strPrefix(ptr, prefix))
13337 ptr += strlen(prefix);
13339 prefix_found = TRUE;
13345 // check if prefix found and followed by (at least) three digits
13346 if (prefix_found &&
13347 strlen(ptr) >= 3 &&
13348 ptr[0] >= '0' && ptr[0] <= '9' &&
13349 ptr[1] >= '0' && ptr[1] <= '9' &&
13350 ptr[2] >= '0' && ptr[2] <= '9')
13352 int element = ((ptr[0] - '0') * 100 +
13353 (ptr[1] - '0') * 10 +
13358 // level sketch element number might consist of four digits
13359 if (ptr[0] >= '0' && ptr[0] <= '9')
13361 element = element * 10 + (ptr[0] - '0');
13365 // remap some (historic, now obsolete) elements
13366 element = getMappedElement(element);
13368 if (element >= NUM_FILE_ELEMENTS)
13369 element = EL_UNKNOWN;
13371 brush_buffer[x][y] = element;
13373 brush_width = MAX(x + 1, brush_width);
13374 brush_height = MAX(y + 1, brush_height);
13378 if (x >= MAX_LEV_FIELDX)
13379 start_new_row = TRUE;
13381 allow_new_row = TRUE;
13385 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
13386 start_new_row = TRUE;
13388 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
13396 if (y >= MAX_LEV_FIELDY)
13399 allow_new_row = FALSE;
13403 SDL_free(clipboard_text);
13405 if (brush_width == 0 || brush_height == 0)
13407 Request("No level sketch found in clipboard!", REQ_CONFIRM);
13414 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
13417 SDL_GetMouseState(&mx, &my);
13419 // if inside drawing area, activate and draw brush at last mouse position
13420 if (mx >= gi->x && mx < gi->x + gi->width &&
13421 my >= gi->y && my < gi->y + gi->height)
13422 CopyBrushToCursor(last_cursor_x, last_cursor_y);
13424 draw_with_brush = TRUE;
13430 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
13431 brush_width, brush_height);
13433 if (!Request(request, REQ_ASK))
13436 for (x = 0; x < MAX_LEV_FIELDX; x++)
13437 for (y = 0; y < MAX_LEV_FIELDY; y++)
13438 Tile[x][y] = brush_buffer[x][y];
13440 lev_fieldx = level.fieldx = brush_width;
13441 lev_fieldy = level.fieldy = brush_height;
13443 boolean use_bd_engine = TRUE;
13444 boolean use_em_engine = TRUE;
13445 boolean use_sp_engine = TRUE;
13446 boolean use_mm_engine = TRUE;
13448 for (x = 0; x < MAX_LEV_FIELDX; x++)
13450 for (y = 0; y < MAX_LEV_FIELDY; y++)
13452 int element = Tile[x][y];
13454 if (!IS_BD_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13455 use_bd_engine = FALSE;
13457 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13458 use_em_engine = FALSE;
13460 if (!IS_SP_ELEMENT(element))
13461 use_sp_engine = FALSE;
13463 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
13464 use_mm_engine = FALSE;
13468 level.game_engine_type = (use_bd_engine ? GAME_ENGINE_TYPE_BD :
13469 use_em_engine ? GAME_ENGINE_TYPE_EM :
13470 use_sp_engine ? GAME_ENGINE_TYPE_SP :
13471 use_mm_engine ? GAME_ENGINE_TYPE_MM :
13472 GAME_ENGINE_TYPE_RND);
13474 // update element selection list
13475 ReinitializeElementList();
13476 ModifyEditorElementList();
13478 SetBorderElement();
13480 DrawEditModeWindow();
13481 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13487 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
13490 if (mode == CB_AREA_TO_BRUSH)
13492 int from_lx, from_ly;
13495 swap_numbers(&from_x, &to_x);
13498 swap_numbers(&from_y, &to_y);
13500 brush_width = to_x - from_x + 1;
13501 brush_height = to_y - from_y + 1;
13503 from_lx = from_x + level_xpos;
13504 from_ly = from_y + level_ypos;
13506 for (y = 0; y < brush_height; y++)
13508 for (x = 0; x < brush_width; x++)
13510 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
13513 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
13518 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13520 delete_old_brush = FALSE;
13522 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
13523 mode == CB_BRUSH_TO_LEVEL)
13525 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
13526 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
13527 int cursor_from_x = cursor_x - brush_width / 2;
13528 int cursor_from_y = cursor_y - brush_height / 2;
13529 int border_from_x = cursor_x, border_from_y = cursor_y;
13530 int border_to_x = cursor_x, border_to_y = cursor_y;
13532 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
13533 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13535 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
13536 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
13538 delete_old_brush = FALSE;
13543 for (y = 0; y < brush_height; y++)
13545 for (x = 0; x < brush_width; x++)
13547 int sx = cursor_from_x + x;
13548 int sy = cursor_from_y + y;
13549 int lx = sx + level_xpos;
13550 int ly = sy + level_ypos;
13551 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
13552 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
13553 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
13554 brush_buffer[x][y] : new_element);
13556 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13558 if (sx < border_from_x)
13559 border_from_x = sx;
13560 else if (sx > border_to_x)
13562 if (sy < border_from_y)
13563 border_from_y = sy;
13564 else if (sy > border_to_y)
13567 DrawBrushElement(sx, sy, element, change_level);
13572 if (mode != CB_DELETE_OLD_CURSOR)
13573 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
13575 last_cursor_x = cursor_x;
13576 last_cursor_y = cursor_y;
13578 delete_old_brush = TRUE;
13580 else if (mode == CB_FLIP_BRUSH_X)
13582 for (y = 0; y < brush_height; y++)
13583 for (x = 0; x < (brush_width + 1) / 2; x++)
13584 SwapFlippedTiles(&brush_buffer[x][y],
13585 &brush_buffer[brush_width - x - 1][y], mode);
13587 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13589 else if (mode == CB_FLIP_BRUSH_Y)
13591 for (y = 0; y < (brush_height + 1) / 2; y++)
13592 for (x = 0; x < brush_width; x++)
13593 SwapFlippedTiles(&brush_buffer[x][y],
13594 &brush_buffer[x][brush_height - y - 1], mode);
13596 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13598 else if (mode == CB_FLIP_BRUSH_XY)
13600 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13602 for (y = 0; y < MAX(brush_width, brush_height); y++)
13603 for (x = 0; x <= y; x++)
13604 SwapFlippedTiles(&brush_buffer[x][y],
13605 &brush_buffer[y][x], mode);
13607 swap_numbers(&brush_width, &brush_height);
13609 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13612 if (mode == CB_UPDATE_BRUSH_POSITION)
13614 last_cursor_x = from_x;
13615 last_cursor_y = from_y;
13619 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
13622 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
13625 static void CopyBrushToLevel(int x, int y, int button)
13627 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
13630 static void CopyBrushToCursor(int x, int y)
13632 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13635 static void UpdateBrushPosition(int x, int y)
13637 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
13640 static void DeleteBrushFromCursor(void)
13642 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13645 static void FlipBrushX(void)
13647 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13650 static void FlipBrushY(void)
13652 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_Y);
13655 static void RotateBrush(void)
13657 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_XY);
13658 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13661 void DumpBrush(void)
13663 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
13666 void DumpBrush_Small(void)
13668 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
13671 void CopyClipboardToBrush(void)
13673 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
13676 void CopyBrushToClipboard(void)
13678 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
13681 void CopyBrushToClipboard_Small(void)
13683 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
13686 void UndoLevelEditorOperation(void)
13688 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
13691 void RedoLevelEditorOperation(void)
13693 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13696 static void FloodFill(int from_x, int from_y, int fill_element)
13698 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
13701 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
13703 int from_x = from_sx2 + 2 * level_xpos;
13704 int from_y = from_sy2 + 2 * level_ypos;
13705 int max_fillx = lev_fieldx * 2;
13706 int max_filly = lev_fieldy * 2;
13707 short Fill[max_fillx][max_filly];
13710 for (x = 0; x < max_fillx; x++)
13711 for (y = 0; y < max_filly; y++)
13712 Fill[x][y] = getLevelElementHiRes(x, y);
13714 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
13715 Fill, max_fillx, max_filly);
13717 for (x = 0; x < max_fillx; x++)
13718 for (y = 0; y < max_filly; y++)
13719 if (Fill[x][y] == fill_element)
13720 SetLevelElementHiRes(x, y, Fill[x][y]);
13723 // values for DrawLevelText() modes
13724 #define TEXT_INIT 0
13725 #define TEXT_SETCURSOR 1
13726 #define TEXT_WRITECHAR 2
13727 #define TEXT_BACKSPACE 3
13728 #define TEXT_NEWLINE 4
13730 #define TEXT_QUERY_TYPING 6
13732 static int DrawLevelText(int sx, int sy, char letter, int mode)
13734 static short delete_buffer[MAX_LEV_FIELDX];
13735 static int start_sx;
13736 static int last_sx, last_sy;
13737 static boolean typing = FALSE;
13738 int letter_element;
13739 int lx = 0, ly = 0;
13741 // map lower case letters to upper case and convert special characters
13742 if (letter >= 'a' && letter <= 'z')
13743 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
13744 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
13745 letter_element = EL_CHAR_AUMLAUT;
13746 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
13747 letter_element = EL_CHAR_OUMLAUT;
13748 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
13749 letter_element = EL_CHAR_UUMLAUT;
13750 else if (letter == '^')
13751 letter_element = EL_CHAR_COPYRIGHT;
13753 letter_element = EL_CHAR_ASCII0 + letter;
13755 if (mode != TEXT_INIT)
13760 if (mode != TEXT_SETCURSOR)
13766 lx = last_sx + level_xpos;
13767 ly = last_sy + level_ypos;
13774 DrawLevelText(0, 0, 0, TEXT_END);
13780 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
13783 case TEXT_SETCURSOR:
13784 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
13785 DrawAreaBorder(sx, sy, sx, sy);
13786 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
13787 ed_tilesize, ed_tilesize);
13792 case TEXT_WRITECHAR:
13793 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
13795 if (new_element1 >= EL_STEEL_CHAR_START &&
13796 new_element1 <= EL_STEEL_CHAR_END)
13797 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
13799 delete_buffer[sx - start_sx] = Tile[lx][ly];
13800 Tile[lx][ly] = letter_element;
13802 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
13803 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
13804 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13805 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13807 DrawLevelText(0, 0, 0, TEXT_END);
13809 level.changed = TRUE;
13813 case TEXT_BACKSPACE:
13816 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
13817 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
13818 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
13823 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13824 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13826 DrawLevelText(0, 0, 0, TEXT_END);
13830 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13831 DrawEditorElement(sx, sy, Tile[lx][ly]);
13836 case TEXT_QUERY_TYPING:
13846 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
13847 int element, boolean change_level)
13849 int lx = sx + level_xpos;
13850 int ly = sy + level_ypos;
13853 DrawEditorElement(sx, sy, Tile[lx][ly]);
13855 DrawAreaBorder(sx, sy, sx, sy);
13858 static void CheckLevelBorderElement(boolean redraw_playfield)
13860 int last_border_element = BorderElement;
13862 SetBorderElement();
13864 if (redraw_playfield && BorderElement != last_border_element)
13865 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13868 static void CopyLevelToUndoBuffer(int mode)
13870 static boolean accumulated_undo = FALSE;
13871 boolean new_undo_buffer_position = TRUE;
13874 if (undo_buffer_steps == 0)
13875 accumulated_undo = FALSE;
13879 case UNDO_IMMEDIATE:
13880 accumulated_undo = FALSE;
13883 case UNDO_ACCUMULATE:
13884 if (accumulated_undo)
13885 new_undo_buffer_position = FALSE;
13886 accumulated_undo = TRUE;
13893 if (new_undo_buffer_position)
13895 // advance position in undo buffer ring
13896 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13898 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
13899 undo_buffer_steps++;
13902 // always reset redo buffer when storing level change into undo buffer
13903 redo_buffer_steps = 0;
13905 for (x = 0; x < lev_fieldx; x++)
13906 for (y = 0; y < lev_fieldy; y++)
13907 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
13909 // check if drawing operation forces change of border style
13910 CheckLevelBorderElement(TRUE);
13912 level.changed = TRUE;
13915 static void RandomPlacement(int new_element)
13917 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13918 int num_free_positions = 0;
13919 int num_percentage, num_elements;
13922 ResetIntelliDraw();
13924 // determine number of free positions for randomly placing the new element
13925 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
13927 free_position[x][y] =
13928 (random_placement_background_restricted ?
13929 Tile[x][y] == random_placement_background_element :
13930 Tile[x][y] != new_element);
13932 if (free_position[x][y])
13933 num_free_positions++;
13936 // determine number of new elements to place there
13937 num_percentage = num_free_positions * random_placement_value / 100;
13938 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
13939 num_percentage : random_placement_value);
13941 // if less free positions than elements to place, fill all these positions
13942 if (num_free_positions < num_elements)
13944 for (x = 0; x < lev_fieldx; x++)
13945 for (y = 0; y < lev_fieldy; y++)
13946 if (free_position[x][y])
13947 SetElement(x, y, new_element);
13951 while (num_elements > 0)
13953 x = GetSimpleRandom(lev_fieldx);
13954 y = GetSimpleRandom(lev_fieldy);
13956 // don't place element at the same position twice
13957 if (free_position[x][y])
13959 free_position[x][y] = FALSE;
13960 SetElement(x, y, new_element);
13966 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13967 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13970 static void WrapLevel(int dx, int dy)
13972 int wrap_dx = lev_fieldx - dx;
13973 int wrap_dy = lev_fieldy - dy;
13976 for (x = 0; x < lev_fieldx; x++)
13977 for (y = 0; y < lev_fieldy; y++)
13978 TileBackup[x][y] = Tile[x][y];
13980 for (x = 0; x < lev_fieldx; x++)
13981 for (y = 0; y < lev_fieldy; y++)
13983 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
13985 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13986 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
13989 static void DrawAreaElementHighlight(boolean highlighted,
13990 boolean highlighted_similar)
13992 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13999 for (x = 0; x < ed_fieldx; x++)
14001 for (y = 0; y < ed_fieldy; y++)
14003 boolean highlight = FALSE;
14004 int lx = x + level_xpos;
14005 int ly = y + level_ypos;
14007 if (!IN_LEV_FIELD(lx, ly))
14010 // check if element is the same
14011 if (Tile[lx][ly] == new_element1)
14014 // check if element is similar
14015 if (highlighted_similar &&
14016 strEqual(element_info[Tile[lx][ly]].class_name,
14017 element_info[new_element1].class_name))
14020 // check if element is matching MM style wall
14021 if (IS_MM_WALL(Tile[lx][ly]) &&
14022 map_mm_wall_element(Tile[lx][ly]) == new_element1)
14028 if (IS_MM_WALL(Tile[lx][ly]) && !highlighted_similar)
14032 for (i = 0; i < 4; i++)
14034 if (!(MM_WALL_BITS(Tile[lx][ly]) & (1 << i)))
14037 int xx = x * 2 + (i % 2);
14038 int yy = y * 2 + (i / 2);
14039 int sx = SX + xx * ed_tilesize / 2;
14040 int sy = SY + yy * ed_tilesize / 2;
14043 int to_sx = sx + ed_tilesize / 2 - 1;
14044 int to_sy = sy + ed_tilesize / 2 - 1;
14046 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
14047 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
14048 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14049 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14054 int sx = SX + x * ed_tilesize;
14055 int sy = SY + y * ed_tilesize;
14058 int to_sx = sx + ed_tilesize - 1;
14059 int to_sy = sy + ed_tilesize - 1;
14061 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
14062 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
14063 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14064 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14070 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
14072 char *template_filename_old = getLocalLevelTemplateFilename();
14073 char *template_filename_new =
14074 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
14076 if (copyFile(template_filename_old, template_filename_new) != 0)
14077 Request("Cannot copy level template!", REQ_CONFIRM);
14079 free(template_filename_new);
14082 static void HandleDrawingAreas(struct GadgetInfo *gi)
14084 static boolean started_inside_drawing_area = FALSE;
14085 static int last_sx = -1;
14086 static int last_sy = -1;
14087 static int last_sx2 = -1;
14088 static int last_sy2 = -1;
14089 int id = gi->custom_id;
14090 int type_id = gi->custom_type_id;
14091 boolean button_press_event;
14092 boolean button_release_event;
14093 boolean inside_drawing_area = !gi->event.off_borders;
14094 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
14095 int actual_drawing_function;
14096 int button = gi->event.button;
14097 int new_element = BUTTON_ELEMENT(button);
14098 int sx = gi->event.x, sy = gi->event.y;
14099 int min_sx = 0, min_sy = 0;
14100 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
14101 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
14102 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
14103 int sx2 = gi->event.mx / mini_item_xsize;
14104 int sy2 = gi->event.my / mini_item_ysize;
14107 int lx = 0, ly = 0;
14110 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
14111 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
14113 // make sure to stay inside drawing area boundaries
14114 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14115 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14119 int min_lx = 0, min_ly = 0;
14120 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14122 // get positions inside level field
14123 lx = sx + level_xpos;
14124 ly = sy + level_ypos;
14126 if (!IN_LEV_FIELD(lx, ly))
14127 inside_drawing_area = FALSE;
14129 // make sure to stay inside level field boundaries
14130 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14131 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14133 // correct drawing area positions accordingly
14134 sx = lx - level_xpos;
14135 sy = ly - level_ypos;
14138 // also correct MM wall-sized (double) drawing area positions accordingly
14139 if (sx2 / 2 < sx || sx2 / 2 > sx)
14141 dx = (sx2 / 2 < sx ? 0 : 1);
14144 if (sy2 / 2 < sy || sy2 / 2 > sy)
14146 dy = (sy2 / 2 < sy ? 0 : 1);
14150 if (!button_press_event && !button_release_event)
14152 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
14153 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
14154 isHiresTileElement(old_element) &&
14155 isHiresDrawElement(new_element));
14157 // prevent handling events for every pixel position when moving mouse
14158 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
14159 (sx2 == last_sx2 && sy2 == last_sy2))
14168 if (button_press_event)
14169 started_inside_drawing_area = inside_drawing_area;
14171 if (!started_inside_drawing_area)
14174 if (!IS_VALID_BUTTON(button))
14177 // handle info callback for each invocation of action callback
14178 gi->callback_info(gi);
14180 // automatically switch to 'single item' drawing mode, if needed
14181 actual_drawing_function =
14182 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
14183 drawing_function : GADGET_ID_SINGLE_ITEMS);
14185 // clicking into drawing area with pressed Control key picks element
14186 if (GetKeyModState() & KMOD_Control)
14188 last_drawing_function = drawing_function;
14189 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14192 if (GetKeyModState() & KMOD_Shift)
14194 if (button_press_event || button_release_event)
14195 ResetIntelliDraw();
14198 SetDrawModeHiRes(-1); // reset to normal draw mode
14200 switch (actual_drawing_function)
14202 case GADGET_ID_SINGLE_ITEMS:
14205 if (button_release_event)
14207 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14209 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
14210 !inside_drawing_area)
14211 DeleteBrushFromCursor();
14216 if (draw_with_brush)
14218 CopyBrushToLevel(sx, sy, button);
14222 SetDrawModeHiRes(new_element);
14224 if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
14226 // remove player at old position
14227 for (y = 0; y < lev_fieldy; y++)
14229 for (x = 0; x < lev_fieldx; x++)
14231 int old_element = Tile[x][y];
14233 if (IS_PLAYER_ELEMENT(old_element) &&
14234 IS_PLAYER_ELEMENT(new_element))
14236 int replaced_with_element =
14237 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
14238 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
14240 old_element == EL_SOKOBAN_FIELD_PLAYER &&
14241 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
14243 new_element == EL_SOKOBAN_FIELD_PLAYER &&
14244 old_element == EL_PLAYER_1 ? EL_EMPTY :
14246 new_element >= EL_PLAYER_1 &&
14247 new_element <= EL_PLAYER_4 &&
14248 new_element == old_element ? EL_EMPTY :
14252 SetElement(x, y, replaced_with_element);
14254 else if (IS_MM_MCDUFFIN(old_element) &&
14255 IS_MM_MCDUFFIN(new_element))
14257 // remove McDuffin at old position
14258 SetElement(x, y, EL_EMPTY);
14264 SetElementButton(lx, ly, dx, dy, new_element, button);
14267 else if (!button_release_event)
14269 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14271 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
14272 DrawMiniGraphicExt(drawto,
14273 gi->x + sx * MINI_TILEX,
14274 gi->y + sy * MINI_TILEY,
14275 el2edimg(new_element));
14277 DrawFixedGraphicExt(drawto,
14278 gi->x + sx * TILEX,
14279 gi->y + sy * TILEY,
14280 el2edimg(new_element), 0);
14282 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14283 new_element = GFX_ELEMENT(new_element);
14285 drawingarea_info[type_id].value[pos] = new_element;
14287 CopyElementPropertiesToGame(properties_element);
14289 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14291 UpdateCustomElementGraphicGadgets();
14293 FrameCounter = 0; // restart animation frame counter
14298 case GADGET_ID_CONNECTED_ITEMS:
14300 static int last_sx = -1;
14301 static int last_sy = -1;
14303 if (button_release_event)
14304 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14306 SetDrawModeHiRes(new_element);
14308 if (getDrawModeHiRes())
14314 if (!button_press_event)
14315 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
14322 case GADGET_ID_LINE:
14323 case GADGET_ID_ARC:
14324 case GADGET_ID_RECTANGLE:
14325 case GADGET_ID_FILLED_BOX:
14326 SetDrawModeHiRes(new_element);
14328 if (getDrawModeHiRes())
14334 case GADGET_ID_GRAB_BRUSH:
14335 case GADGET_ID_TEXT:
14337 static int last_sx = -1;
14338 static int last_sy = -1;
14339 static int start_sx = -1;
14340 static int start_sy = -1;
14341 void (*draw_func)(int, int, int, int, int, boolean);
14343 if (drawing_function == GADGET_ID_LINE)
14344 draw_func = DrawLine;
14345 else if (drawing_function == GADGET_ID_ARC)
14346 draw_func = DrawArc;
14347 else if (drawing_function == GADGET_ID_RECTANGLE)
14348 draw_func = DrawBox;
14349 else if (drawing_function == GADGET_ID_FILLED_BOX)
14350 draw_func = DrawFilledBox;
14351 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
14352 draw_func = SelectArea;
14353 else // (drawing_function == GADGET_ID_TEXT)
14354 draw_func = SetTextCursor;
14356 if (button_press_event)
14358 draw_func(sx, sy, sx, sy, new_element, FALSE);
14359 start_sx = last_sx = sx;
14360 start_sy = last_sy = sy;
14362 if (drawing_function == GADGET_ID_TEXT)
14363 DrawLevelText(0, 0, 0, TEXT_END);
14365 else if (button_release_event)
14367 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
14368 if (drawing_function == GADGET_ID_GRAB_BRUSH)
14370 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
14371 CopyBrushToCursor(sx, sy);
14372 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14374 draw_with_brush = TRUE;
14376 else if (drawing_function == GADGET_ID_TEXT)
14377 DrawLevelText(sx, sy, 0, TEXT_INIT);
14379 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14381 else if (last_sx != sx || last_sy != sy)
14383 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
14384 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
14385 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
14386 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
14393 case GADGET_ID_FLOOD_FILL:
14394 if (button_press_event && Tile[lx][ly] != new_element)
14396 if (IS_MM_WALL_EDITOR(new_element))
14397 FloodFillWall_MM(sx2, sy2, new_element);
14399 FloodFill(lx, ly, new_element);
14401 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14402 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14406 case GADGET_ID_PICK_ELEMENT:
14407 if (button_release_event)
14408 ClickOnGadget(level_editor_gadget[last_drawing_function],
14410 else if (draw_level)
14411 PickDrawingElement(button, Tile[lx][ly]);
14414 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14416 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
14423 // do not mark level as modified for certain non-level-changing gadgets
14424 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
14425 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
14426 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
14427 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14430 level.changed = TRUE;
14433 static void HandleCounterButtons(struct GadgetInfo *gi)
14435 int gadget_id = gi->custom_id;
14436 int counter_id = gi->custom_type_id;
14437 int button = gi->event.button;
14438 int *counter_value = counterbutton_info[counter_id].value;
14439 int step = BUTTON_STEPSIZE(button) *
14440 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
14442 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14444 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
14445 boolean released = (gi->event.type == GD_EVENT_RELEASED);
14446 boolean level_changed = LevelChanged();
14448 if ((level_changed && pressed) || (!level_changed && released))
14451 if (level_changed && !Request("Level has changed! Discard changes?",
14454 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14455 ModifyEditorCounterValue(counter_id, *counter_value);
14461 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14462 *counter_value = gi->textinput.number_value;
14464 ModifyEditorCounterValue(counter_id, *counter_value + step);
14466 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14468 int last_game_engine_type = level.game_engine_type;
14470 LoadLevel(level_nr);
14471 LoadScore(level_nr);
14473 SaveLevelSetup_SeriesInfo();
14478 DrawEditModeWindow();
14480 if (level.game_engine_type != last_game_engine_type)
14482 // update element selection list
14483 ReinitializeElementList();
14484 ModifyEditorElementList();
14490 switch (counter_id)
14492 case ED_COUNTER_ID_YAMYAM_CONTENT:
14493 DrawYamYamContentAreas();
14496 case ED_COUNTER_ID_BALL_CONTENT:
14497 DrawMagicBallContentAreas();
14500 case ED_COUNTER_ID_ANDROID_CONTENT:
14501 DrawAndroidElementArea();
14504 case ED_COUNTER_ID_GROUP_CONTENT:
14505 DrawGroupElementArea();
14506 CopyGroupElementPropertiesToGame(properties_element);
14509 case ED_COUNTER_ID_INVENTORY_SIZE:
14510 DrawPlayerInitialInventoryArea(properties_element);
14513 case ED_COUNTER_ID_MM_BALL_CONTENT:
14514 DrawMMBallContentArea();
14517 case ED_COUNTER_ID_ENVELOPE_XSIZE:
14518 case ED_COUNTER_ID_ENVELOPE_YSIZE:
14519 DrawEnvelopeTextArea(-1);
14522 case ED_COUNTER_ID_LEVEL_XSIZE:
14523 case ED_COUNTER_ID_LEVEL_YSIZE:
14524 lev_fieldx = level.fieldx;
14525 lev_fieldy = level.fieldy;
14527 // check if resizing of level results in change of border border
14528 SetBorderElement();
14536 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
14537 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
14538 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
14539 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
14540 CopyElementPropertiesToGame(properties_element);
14542 // do not mark level as modified for certain non-level-changing gadgets
14543 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
14544 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
14545 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
14546 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
14549 level.changed = TRUE;
14552 static void HandleTextInputGadgets(struct GadgetInfo *gi)
14554 int type_id = gi->custom_type_id;
14556 strcpy(textinput_info[type_id].value, gi->textinput.value);
14558 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
14560 CopyElementPropertiesToGame(properties_element);
14562 ModifyEditorElementList(); // update changed button info text
14565 // do not mark level as modified for certain non-level-changing gadgets
14566 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
14567 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
14570 level.changed = TRUE;
14573 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
14575 int type_id = gi->custom_type_id;
14577 strncpy(textarea_info[type_id].value, gi->textarea.value,
14578 MAX_ENVELOPE_TEXT_LEN);
14579 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
14581 level.changed = TRUE;
14584 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
14586 int type_id = gi->custom_type_id;
14587 int value_old = *selectbox_info[type_id].value;
14588 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
14590 *selectbox_info[type_id].value = value_new;
14592 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
14594 DrawLevelConfigWindow();
14596 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14598 element_info[properties_element].current_change_page = gi->selectbox.index;
14600 DrawPropertiesWindow();
14602 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
14603 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
14604 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
14605 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
14606 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
14608 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
14610 // when changing action type, also check action mode and action arg
14611 if (value_old != value_new)
14612 setSelectboxSpecialActionVariablesIfNeeded();
14614 DrawPropertiesChange();
14617 CopyElementPropertiesToGame(properties_element);
14619 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
14621 // show or hide "engine" tabulator depending on game engine type
14622 DrawLevelConfigWindow();
14624 // update element selection list depending on game engine type
14625 ReinitializeElementList();
14626 ModifyEditorElementList();
14628 else if (type_id == ED_SELECTBOX_ID_BD_SCHEDULING_TYPE)
14630 // update BD cycle delay counter gadgets depending on BD scheduling type
14631 DrawLevelConfigWindow();
14634 // do not mark level as modified for certain non-level-changing gadgets
14635 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
14636 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14639 level.changed = TRUE;
14642 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
14644 int type_id = gi->custom_type_id;
14647 if (type_id >= ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST &&
14648 type_id <= ED_TAB_BUTTON_ID_LEVELCONFIG_LAST)
14650 edit_mode_levelconfig = gi->custom_type_id;
14652 DrawLevelConfigWindow();
14654 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
14655 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
14657 edit_mode_properties = gi->custom_type_id;
14659 DrawPropertiesWindow();
14661 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
14662 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
14664 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
14666 // backup original "level.field" (needed to track playfield changes)
14667 CopyPlayfield(level.field, TileBackup);
14669 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
14670 CopyPlayfield(Tile, level.field);
14672 if (new_template ||
14673 Request("Save this template and kill the old?", REQ_ASK))
14674 SaveLevelTemplate();
14677 Request("Template saved!", REQ_CONFIRM);
14679 // restore original "level.field" (needed to track playfield changes)
14680 CopyPlayfield(TileBackup, level.field);
14682 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
14684 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
14686 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
14687 leveldir_current->readonly)
14689 Request("This level set is read-only!", REQ_CONFIRM);
14694 if (strEqual(levelset_name, ""))
14696 Request("Please enter level set title!", REQ_CONFIRM);
14701 if (strEqual(levelset_author, ""))
14703 Request("Please enter level set author!", REQ_CONFIRM);
14708 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
14710 if (UpdateUserLevelSet(levelset_subdir,
14713 levelset_num_levels))
14715 Request("Level set updated!", REQ_CONFIRM);
14719 Request("Updating level set failed!", REQ_CONFIRM);
14722 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
14724 if (level.changed && !Request("Level has changed! Discard changes?",
14728 if (CreateUserLevelSet(levelset_subdir,
14731 levelset_num_levels,
14732 levelset_use_levelset_artwork))
14734 if (levelset_copy_level_template)
14735 CopyLevelTemplateToUserLevelSet(levelset_subdir);
14737 Request("New level set created!", REQ_CONFIRM);
14739 AddUserLevelSetToLevelInfo(levelset_subdir);
14740 ChangeEditorToLevelSet(levelset_subdir);
14744 Request("Creating new level set failed!", REQ_CONFIRM);
14748 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
14749 custom_element.num_change_pages < MAX_CHANGE_PAGES)
14751 struct ElementInfo *ei = &element_info[properties_element];
14753 // when modifying custom element, ask for copying level template
14754 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14757 setElementChangePages(ei, ei->num_change_pages + 1);
14759 // set new change page to be new current change page
14760 ei->current_change_page = ei->num_change_pages - 1;
14761 ei->change = &ei->change_page[ei->current_change_page];
14763 setElementChangeInfoToDefaults(ei->change);
14765 DrawPropertiesWindow();
14767 level.changed = TRUE;
14769 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
14770 custom_element.num_change_pages > MIN_CHANGE_PAGES)
14772 struct ElementInfo *ei = &element_info[properties_element];
14774 // when modifying custom element, ask for copying level template
14775 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14778 // copy all change pages after change page to be deleted
14779 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
14780 ei->change_page[i] = ei->change_page[i + 1];
14782 setElementChangePages(ei, ei->num_change_pages - 1);
14784 DrawPropertiesWindow();
14786 level.changed = TRUE;
14790 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
14792 int type_id = gi->custom_type_id;
14794 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
14795 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
14797 struct ElementInfo *ei = &element_info[properties_element];
14798 int step = BUTTON_STEPSIZE(gi->event.button);
14800 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
14801 ei->current_change_page += step;
14803 if (ei->current_change_page < 0)
14804 ei->current_change_page = 0;
14805 else if (ei->current_change_page >= ei->num_change_pages)
14806 ei->current_change_page = ei->num_change_pages - 1;
14808 DrawPropertiesWindow();
14810 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
14811 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14813 struct ElementInfo *ei = &element_info[properties_element];
14814 int current_change_page = ei->current_change_page;
14816 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
14818 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
14819 ei->change_page[current_change_page];
14821 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14823 // when modifying custom element, ask for copying level template
14824 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14827 ei->change_page[current_change_page] =
14828 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
14830 level.changed = TRUE;
14833 DrawPropertiesWindow();
14837 static void HandleRadiobuttons(struct GadgetInfo *gi)
14839 int type_id = gi->custom_type_id;
14841 *radiobutton_info[type_id].value =
14842 radiobutton_info[type_id].checked_value;
14844 // do not mark level as modified for certain non-level-changing gadgets
14845 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
14846 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
14849 level.changed = TRUE;
14852 static void HandleCheckbuttons(struct GadgetInfo *gi)
14854 int type_id = gi->custom_type_id;
14856 *checkbutton_info[type_id].value ^= TRUE;
14858 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
14859 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
14860 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
14861 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
14862 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
14863 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
14864 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
14865 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
14867 CopyElementPropertiesToGame(properties_element);
14870 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
14872 UpdateCustomElementGraphicGadgets();
14874 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
14875 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
14877 boolean template_related_changes_found = FALSE;
14880 // check if any custom, group or empty elements have been changed
14881 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
14882 if ((IS_CUSTOM_ELEMENT(i) ||
14883 IS_GROUP_ELEMENT(i) ||
14884 IS_EMPTY_ELEMENT(i)) &&
14885 element_info[i].modified_settings)
14886 template_related_changes_found = TRUE;
14888 if (level.use_custom_template &&
14889 !fileExists(getGlobalLevelTemplateFilename()))
14891 Request("No level template found!", REQ_CONFIRM);
14893 level.use_custom_template = FALSE;
14895 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14900 if (level.use_custom_template &&
14901 template_related_changes_found &&
14902 !Request("Discard changes and use level template?", REQ_ASK))
14904 level.use_custom_template = FALSE;
14906 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14911 if (!level.use_custom_template &&
14912 Request("Copy settings from level template?", REQ_ASK))
14917 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
14919 DrawEditModeWindow();
14921 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
14923 if (setup.editor.use_template_for_new_levels &&
14924 !fileExists(getGlobalLevelTemplateFilename()))
14926 Request("No level template found!", REQ_CONFIRM);
14931 if (setup.editor.use_template_for_new_levels &&
14933 !Request("Discard level and load template?", REQ_ASK))
14938 if (!setup.editor.use_template_for_new_levels &&
14940 !Request("Discard level and use empty level?", REQ_ASK))
14945 LoadLevel(level_nr);
14946 LoadScore(level_nr);
14951 DrawEditModeWindow();
14953 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
14955 SetAutomaticNumberOfGemsNeeded();
14958 // do not mark level as modified for certain non-level-changing gadgets
14959 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
14960 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
14961 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
14962 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
14963 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
14964 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
14967 level.changed = TRUE;
14970 static void HandleControlButtons(struct GadgetInfo *gi)
14972 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
14973 static int last_edit_mode = ED_MODE_DRAWING;
14974 static int last_custom_copy_mode = -1;
14975 static int last_button = 0;
14976 int id = gi->custom_id;
14977 int button = gi->event.button;
14978 int step = BUTTON_STEPSIZE(button);
14979 int new_element = BUTTON_ELEMENT(button);
14980 int last_properties_element = properties_element;
14983 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
14984 DrawLevelText(0, 0, 0, TEXT_END);
14986 if (id < ED_NUM_CTRL1_BUTTONS &&
14987 id != GADGET_ID_SINGLE_ITEMS &&
14988 id != GADGET_ID_PICK_ELEMENT &&
14989 edit_mode != ED_MODE_DRAWING &&
14990 drawing_function != GADGET_ID_PICK_ELEMENT &&
14991 !(GetKeyModState() & KMOD_Control))
14992 ChangeEditModeWindow(ED_MODE_DRAWING);
14994 // element copy mode active, but no element button pressed => deactivate
14995 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
14996 last_custom_copy_mode = -1;
14998 // when showing palette on element buttons, change element of button used
14999 if (editor.palette.show_on_element_buttons &&
15000 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
15002 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
15004 id = GADGET_ID_PALETTE;
15009 case GADGET_ID_SCROLL_LEFT:
15010 if (level_xpos >= 0)
15012 if (lev_fieldx < ed_fieldx - 2)
15015 level_xpos -= step;
15016 if (level_xpos < -1)
15019 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
15021 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15023 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
15024 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
15028 case GADGET_ID_SCROLL_RIGHT:
15029 if (level_xpos <= lev_fieldx - ed_fieldx)
15031 if (lev_fieldx < ed_fieldx - 2)
15034 level_xpos += step;
15035 if (level_xpos > lev_fieldx - ed_fieldx + 1)
15036 level_xpos = lev_fieldx - ed_fieldx + 1;
15038 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
15040 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15042 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
15043 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
15047 case GADGET_ID_SCROLL_UP:
15048 if (level_ypos >= 0)
15050 if (lev_fieldy < ed_fieldy - 2)
15053 level_ypos -= step;
15054 if (level_ypos < -1)
15057 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
15059 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15061 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15062 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15066 case GADGET_ID_SCROLL_DOWN:
15067 if (level_ypos <= lev_fieldy - ed_fieldy)
15069 if (lev_fieldy < ed_fieldy - 2)
15072 level_ypos += step;
15073 if (level_ypos > lev_fieldy - ed_fieldy + 1)
15074 level_ypos = lev_fieldy - ed_fieldy + 1;
15076 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
15078 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15080 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15081 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15085 case GADGET_ID_SCROLL_HORIZONTAL:
15086 level_xpos = gi->event.item_position - 1;
15088 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15093 case GADGET_ID_SCROLL_VERTICAL:
15094 level_ypos = gi->event.item_position - 1;
15096 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15101 case GADGET_ID_SCROLL_LIST_UP:
15102 case GADGET_ID_SCROLL_LIST_DOWN:
15103 case GADGET_ID_SCROLL_LIST_VERTICAL:
15104 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
15105 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
15108 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
15109 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15111 if (element_shift < 0)
15113 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15114 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15116 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15117 GDI_SCROLLBAR_ITEM_POSITION,
15118 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15121 ModifyEditorElementList();
15125 case GADGET_ID_PROPERTIES:
15126 // always switch off element properties when they are already displayed
15127 last_properties_element = new_element;
15128 case GADGET_ID_ELEMENT_LEFT:
15129 case GADGET_ID_ELEMENT_MIDDLE:
15130 case GADGET_ID_ELEMENT_RIGHT:
15131 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
15132 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
15133 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
15136 if (edit_mode != ED_MODE_PROPERTIES)
15138 last_edit_mode = edit_mode;
15140 ChangeEditModeWindow(ED_MODE_PROPERTIES);
15142 last_level_drawing_function = drawing_function;
15143 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
15146 else if (properties_element != last_properties_element)
15148 DrawEditModeWindow();
15152 ChangeEditModeWindow(ED_MODE_DRAWING);
15154 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
15159 case GADGET_ID_PALETTE:
15160 if (edit_mode != ED_MODE_PALETTE)
15162 last_edit_mode = edit_mode;
15164 ChangeEditModeWindow(ED_MODE_PALETTE);
15168 ChangeEditModeWindow(last_edit_mode);
15172 case GADGET_ID_WRAP_LEFT:
15173 WrapLevel(-step, 0);
15176 case GADGET_ID_WRAP_RIGHT:
15177 WrapLevel(step, 0);
15180 case GADGET_ID_WRAP_UP:
15181 WrapLevel(0, -step);
15184 case GADGET_ID_WRAP_DOWN:
15185 WrapLevel(0, step);
15188 case GADGET_ID_SINGLE_ITEMS:
15189 case GADGET_ID_CONNECTED_ITEMS:
15190 case GADGET_ID_LINE:
15191 case GADGET_ID_ARC:
15192 case GADGET_ID_TEXT:
15193 case GADGET_ID_RECTANGLE:
15194 case GADGET_ID_FILLED_BOX:
15195 case GADGET_ID_FLOOD_FILL:
15196 case GADGET_ID_GRAB_BRUSH:
15197 case GADGET_ID_PICK_ELEMENT:
15198 if (drawing_function != GADGET_ID_PICK_ELEMENT)
15199 last_drawing_function = drawing_function;
15200 drawing_function = id;
15201 draw_with_brush = FALSE;
15204 case GADGET_ID_RANDOM_PLACEMENT:
15205 RandomPlacement(new_element);
15208 case GADGET_ID_ZOOM:
15209 // zoom level editor tile size in or out (or reset to default size)
15210 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
15211 button == 2 ? ed_tilesize_default :
15212 button == 3 ? ed_tilesize / 2 : ed_tilesize);
15214 // when using touch device, cycle through all zoom tilesizes
15215 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
15216 ed_tilesize = MICRO_TILESIZE;
15218 // limit zoom level by upper and lower bound
15219 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
15221 InitZoomLevelSettings(ed_tilesize);
15223 if (edit_mode == ED_MODE_DRAWING)
15225 DrawDrawingWindow();
15227 // redraw zoom gadget info text
15228 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15231 // save current editor zoom tilesize
15232 SaveSetup_AutoSetup();
15236 case GADGET_ID_CUSTOM_COPY_FROM:
15237 case GADGET_ID_CUSTOM_COPY_TO:
15238 case GADGET_ID_CUSTOM_EXCHANGE:
15239 last_custom_copy_mode = id;
15240 last_drawing_function = drawing_function;
15243 case GADGET_ID_CUSTOM_COPY:
15244 CopyCustomElement(properties_element, -1, id);
15247 case GADGET_ID_CUSTOM_PASTE:
15248 CopyCustomElement(-1, properties_element, id);
15251 case GADGET_ID_UNDO:
15252 if (button < 0) // keep button value (even if modifier keys are pressed)
15254 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
15257 if (button == 1 && undo_buffer_steps == 0)
15259 Request("Undo buffer empty!", REQ_CONFIRM);
15263 else if (button == 2)
15267 else if (button == 3 && redo_buffer_steps == 0)
15269 Request("Redo buffer empty!", REQ_CONFIRM);
15274 if (edit_mode != ED_MODE_DRAWING)
15275 ChangeEditModeWindow(ED_MODE_DRAWING);
15281 undo_buffer_position =
15282 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
15284 undo_buffer_steps--;
15285 redo_buffer_steps++;
15291 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
15293 undo_buffer_steps++;
15294 redo_buffer_steps--;
15297 for (x = 0; x < lev_fieldx; x++)
15298 for (y = 0; y < lev_fieldy; y++)
15299 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
15301 // check if undo operation forces change of border style
15302 CheckLevelBorderElement(FALSE);
15304 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15308 case GADGET_ID_CONF:
15309 if (edit_mode != ED_MODE_LEVELCONFIG)
15311 last_edit_mode = edit_mode;
15313 ChangeEditModeWindow(ED_MODE_LEVELCONFIG);
15317 ChangeEditModeWindow(ED_MODE_DRAWING);
15321 case GADGET_ID_CLEAR:
15322 if (edit_mode != ED_MODE_DRAWING)
15323 ChangeEditModeWindow(ED_MODE_DRAWING);
15325 for (x = 0; x < MAX_LEV_FIELDX; x++)
15326 for (y = 0; y < MAX_LEV_FIELDY; y++)
15327 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
15329 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
15331 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15334 case GADGET_ID_SAVE:
15336 // saving read-only levels into personal level set modifies global vars
15337 // "leveldir_current" and "level_nr"; restore them after saving level
15338 LevelDirTree *leveldir_former = leveldir_current;
15339 int level_nr_former = level_nr;
15340 char *level_filename;
15343 if (leveldir_current->readonly &&
15344 !PrepareSavingIntoPersonalLevelSet())
15347 level_filename = getDefaultLevelFilename(level_nr);
15348 new_level = !fileExists(level_filename);
15351 Request("Save this level and kill the old?", REQ_ASK))
15353 if (leveldir_former->readonly)
15354 ModifyLevelConfigForSavingIntoPersonalLevelSet(leveldir_former->name);
15356 SetAutomaticNumberOfGemsNeeded();
15358 CopyPlayfield(Tile, level.field);
15359 SaveLevel(level_nr);
15361 level.changed = FALSE;
15365 char level_saved_msg[64];
15367 if (leveldir_former->readonly)
15368 sprintf(level_saved_msg,
15369 "Level saved as level %d into personal level set!",
15372 strcpy(level_saved_msg, "Level saved!");
15374 Request(level_saved_msg, REQ_CONFIRM);
15378 // "cd" back to copied-from levelset (in case of saved read-only level)
15379 leveldir_current = leveldir_former;
15380 level_nr = level_nr_former;
15385 case GADGET_ID_TEST:
15386 if (LevelChanged())
15387 level.game_version = GAME_VERSION_ACTUAL;
15389 CopyPlayfield(level.field, TileBackup);
15390 CopyPlayfield(Tile, level.field);
15392 CopyNativeLevel_RND_to_Native(&level);
15394 UnmapLevelEditorGadgets();
15395 UndrawSpecialEditorDoor();
15397 CloseDoor(DOOR_CLOSE_ALL);
15399 // needed before playing if editor playfield area has different size
15400 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
15402 // redraw_mask = REDRAW_ALL;
15404 level_editor_test_game = TRUE;
15406 StartGameActions(FALSE, setup.autorecord, level.random_seed);
15410 case GADGET_ID_EXIT:
15411 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
15415 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
15416 id <= GADGET_ID_ELEMENTLIST_LAST)
15418 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
15420 new_element = editor_elements[element_position + element_shift];
15422 if (IS_EDITOR_CASCADE(new_element))
15426 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
15428 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
15429 boolean *cascade_value = editor_elements_info[i].setup_cascade_value;
15431 if (*cascade_element == new_element)
15433 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
15434 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
15436 // update element selection list
15437 ReinitializeElementList();
15438 ModifyEditorElementList();
15440 // update cascading gadget info text
15441 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15443 // save current editor cascading state
15444 SaveSetup_EditorCascade();
15453 if (last_custom_copy_mode != -1)
15455 if (CopyCustomElement(properties_element, new_element,
15456 last_custom_copy_mode))
15458 ClickOnGadget(level_editor_gadget[last_drawing_function],
15461 last_custom_copy_mode = -1;
15467 // change element of button used to show palette
15468 if (editor.palette.show_on_element_buttons)
15469 button = last_button;
15471 PickDrawingElement(button, new_element);
15473 if (!stick_element_properties_window &&
15474 drawing_function != GADGET_ID_PICK_ELEMENT &&
15475 !(GetKeyModState() & KMOD_Control))
15477 properties_element = new_element;
15478 if (edit_mode == ED_MODE_PROPERTIES)
15479 DrawPropertiesWindow();
15482 if (drawing_function == GADGET_ID_PICK_ELEMENT)
15483 ClickOnGadget(level_editor_gadget[last_drawing_function],
15486 if (!use_permanent_palette)
15487 ChangeEditModeWindow(last_edit_mode);
15490 else if (gi->event.type == GD_EVENT_PRESSED)
15491 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
15492 else if (gi->event.type == GD_EVENT_RELEASED)
15493 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
15494 else if (gi->event.type == GD_EVENT_MOVING)
15495 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
15497 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
15503 void HandleLevelEditorKeyInput(Key key)
15505 char letter = getCharFromKey(key);
15507 if (drawing_function == GADGET_ID_TEXT &&
15508 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
15511 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
15512 else if (key == KSYM_Delete || key == KSYM_BackSpace)
15513 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
15514 else if (key == KSYM_Return)
15515 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
15516 else if (key == KSYM_Escape)
15517 DrawLevelText(0, 0, 0, TEXT_END);
15522 int id = GADGET_ID_NONE;
15523 int new_element_shift = element_shift;
15524 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
15525 int button = MB_LEFTBUTTON;
15531 id = GADGET_ID_SCROLL_LEFT;
15534 id = GADGET_ID_SCROLL_RIGHT;
15537 id = GADGET_ID_SCROLL_UP;
15540 id = GADGET_ID_SCROLL_DOWN;
15544 case KSYM_Page_Down:
15545 step *= (key == KSYM_Page_Up ? -1 : +1);
15546 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15548 if (element_shift < 0)
15550 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15551 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15553 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15554 GDI_SCROLLBAR_ITEM_POSITION,
15555 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15557 ModifyEditorElementList();
15563 element_shift = (key == KSYM_Home ? 0 :
15564 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
15566 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15567 GDI_SCROLLBAR_ITEM_POSITION,
15568 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15570 ModifyEditorElementList();
15577 // this is needed to prevent interference with running "True X-Mouse"
15578 if (GetKeyModStateFromEvents() & KMOD_Control)
15581 // check for last or next editor cascade block in element list
15582 for (i = 0; i < num_editor_elements; i++)
15584 if ((key == KSYM_Insert && i == element_shift) ||
15585 (key == KSYM_Delete && new_element_shift > element_shift))
15588 // jump to next cascade block (or to start of element list)
15589 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
15590 new_element_shift = i;
15593 if (i < num_editor_elements)
15594 element_shift = new_element_shift;
15596 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15597 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15599 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15600 GDI_SCROLLBAR_ITEM_POSITION,
15601 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15603 ModifyEditorElementList();
15608 if (edit_mode == ED_MODE_DRAWING)
15609 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
15610 else if (edit_mode == ED_MODE_LEVELCONFIG)
15611 HandleControlButtons(level_editor_gadget[GADGET_ID_CONF]);
15612 else if (edit_mode == ED_MODE_PROPERTIES)
15613 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
15614 else if (edit_mode == ED_MODE_PALETTE)
15615 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
15616 else // should never happen
15617 ChangeEditModeWindow(ED_MODE_DRAWING);
15625 if (id != GADGET_ID_NONE)
15626 ClickOnGadget(level_editor_gadget[id], button);
15627 else if (letter == '1' || letter == '?')
15628 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
15629 else if (letter == '2')
15630 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
15631 else if (letter == '3')
15632 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
15633 else if (letter == '.')
15634 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
15635 else if (letter == 'U')
15636 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
15637 else if (letter == '-' || key == KSYM_KP_Subtract)
15638 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
15639 else if (letter == '0' || key == KSYM_KP_0)
15640 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
15641 else if (letter == '+' || key == KSYM_KP_Add ||
15642 letter == '=') // ("Shift-=" is "+" on US keyboards)
15643 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
15644 else if (key == KSYM_Return ||
15645 key == KSYM_space ||
15646 key == setup.shortcut.toggle_pause)
15647 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
15649 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
15650 if (letter && letter == controlbutton_info[i].shortcut)
15651 if (!anyTextGadgetActive())
15652 ClickOnGadget(level_editor_gadget[i], button);
15654 if (draw_with_brush)
15658 else if (letter == 'y')
15660 else if (letter == 'z')
15665 static void HandleLevelEditorIdle_Properties(void)
15667 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
15668 int x = editor.settings.element_graphic.x + element_border;
15669 int y = editor.settings.element_graphic.y + element_border;
15670 static DelayCounter action_delay = { 0 };
15673 action_delay.value = GameFrameDelay;
15675 if (!DelayReached(&action_delay))
15678 for (i = 0; i < ED_NUM_SELECTBOX; i++)
15680 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
15682 if (gi->mapped && gi->active && gi->selectbox.open)
15686 DrawEditorElementAnimation(SX + x, SY + y);
15688 redraw_mask |= REDRAW_FIELD;
15690 FrameCounter++; // increase animation frame counter
15693 static void HandleLevelEditorIdle_Drawing(void)
15695 static boolean last_highlighted = FALSE;
15696 static boolean last_highlighted_similar = FALSE;
15697 boolean highlighted = (GetKeyModState() & KMOD_Alt);
15698 boolean highlighted_similar = (GetKeyModState() & KMOD_Shift);
15700 if (highlighted != last_highlighted ||
15701 (highlighted && highlighted_similar != last_highlighted_similar))
15703 DrawAreaElementHighlight(highlighted, highlighted_similar);
15705 redraw_mask |= REDRAW_FIELD;
15708 last_highlighted = highlighted;
15709 last_highlighted_similar = highlighted_similar;
15712 void HandleLevelEditorIdle(void)
15714 if (edit_mode == ED_MODE_PROPERTIES)
15715 HandleLevelEditorIdle_Properties();
15716 else if (edit_mode == ED_MODE_DRAWING)
15717 HandleLevelEditorIdle_Drawing();
15720 static void ClearEditorGadgetInfoText(void)
15722 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
15725 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
15727 char infotext[MAX_OUTPUT_LINESIZE + 1];
15728 int max_infotext_len = getMaxInfoTextLength();
15730 if (gi == NULL || strlen(gi->info_text) == 0)
15733 strncpy(infotext, gi->info_text, max_infotext_len);
15734 infotext[max_infotext_len] = '\0';
15736 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
15738 int key = controlbutton_info[gi->custom_id].shortcut;
15742 char shortcut[MAX_OUTPUT_LINESIZE + 1];
15744 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
15745 sprintf(shortcut, " ('.' or '%c')", key);
15746 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
15747 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
15748 else if (gi->custom_id == GADGET_ID_TEST)
15749 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
15750 else if (gi->custom_id == GADGET_ID_UNDO)
15751 sprintf(shortcut, " ('%c/Shift-U')", key);
15752 else if (gi->custom_id == GADGET_ID_ZOOM)
15753 sprintf(shortcut, " ('%c', '0', '-')", key);
15755 sprintf(shortcut, " ('%s%c')",
15756 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
15758 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
15759 strcat(infotext, shortcut);
15763 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
15766 void HandleEditorGadgetInfoText(void *ptr)
15768 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
15770 if (game_status != GAME_MODE_EDITOR)
15773 ClearEditorGadgetInfoText();
15775 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
15778 // misuse this function to delete brush cursor, if needed
15779 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
15780 DeleteBrushFromCursor();
15782 PrintEditorGadgetInfoText(gi);
15785 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
15787 int id = gi->custom_id;
15788 int type_id = gi->custom_type_id;
15789 int sx = gi->event.x;
15790 int sy = gi->event.y;
15791 int lx = sx + level_xpos;
15792 int ly = sy + level_ypos;
15793 int min_sx = 0, min_sy = 0;
15794 int max_sx = gi->drawing.area_xsize - 1;
15795 int max_sy = gi->drawing.area_ysize - 1;
15796 int actual_drawing_function = drawing_function;
15797 int max_infotext_len = getMaxInfoTextLength();
15798 char infotext[MAX_OUTPUT_LINESIZE + 1];
15800 infotext[0] = '\0'; // start with empty info text
15802 // pressed Control key: simulate picking element
15803 if (GetKeyModState() & KMOD_Control)
15804 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
15806 ClearEditorGadgetInfoText();
15808 if (gi->event.type == GD_EVENT_INFO_LEAVING)
15811 // make sure to stay inside drawing area boundaries
15812 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
15813 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
15815 if (id == GADGET_ID_DRAWING_LEVEL)
15819 int min_lx = 0, min_ly = 0;
15820 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
15822 // get positions inside level field
15823 lx = sx + level_xpos;
15824 ly = sy + level_ypos;
15826 // make sure to stay inside level field boundaries
15827 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
15828 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
15830 // correct drawing area positions accordingly
15831 sx = lx - level_xpos;
15832 sy = ly - level_ypos;
15835 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15837 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
15839 static int start_lx = 0;
15840 static int start_ly = 0;
15843 if (gi->event.type == GD_EVENT_PRESSED)
15849 switch (actual_drawing_function)
15851 case GADGET_ID_SINGLE_ITEMS:
15852 text = "Drawing single items";
15854 case GADGET_ID_CONNECTED_ITEMS:
15855 text = "Drawing connected items";
15857 case GADGET_ID_LINE:
15858 text = "Drawing line";
15860 case GADGET_ID_ARC:
15861 text = "Drawing arc";
15863 case GADGET_ID_TEXT:
15864 text = "Setting text cursor";
15866 case GADGET_ID_RECTANGLE:
15867 text = "Drawing rectangle";
15869 case GADGET_ID_FILLED_BOX:
15870 text = "Drawing filled box";
15872 case GADGET_ID_FLOOD_FILL:
15873 text = "Flood fill";
15875 case GADGET_ID_GRAB_BRUSH:
15876 text = "Grabbing brush";
15878 case GADGET_ID_PICK_ELEMENT:
15879 text = "Picking element";
15883 text = "Drawing position";
15887 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15888 sprintf(infotext, "%s: %d, %d", text, lx, ly);
15890 sprintf(infotext, "%s: %d, %d", text,
15891 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
15893 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15894 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
15896 sprintf(infotext, "Level position: %d, %d", lx, ly);
15899 // misuse this function to draw brush cursor, if needed
15900 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
15902 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15903 CopyBrushToCursor(sx, sy);
15905 DeleteBrushFromCursor();
15908 if (!draw_with_brush)
15909 UpdateBrushPosition(sx, sy);
15911 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15913 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
15914 int element = drawingarea_info[type_id].value[pos];
15916 strncpy(infotext, getElementInfoText(element), max_infotext_len);
15920 if (id == GADGET_ID_CUSTOM_CONTENT)
15921 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
15922 else if (id == GADGET_ID_GROUP_CONTENT)
15923 sprintf(infotext, "group element position: %d", sx + 1);
15924 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
15925 id <= GADGET_ID_YAMYAM_CONTENT_7)
15926 sprintf(infotext, "content area %d position: %d, %d",
15927 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
15928 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
15929 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
15930 sprintf(infotext, "content area %d position: %d, %d",
15931 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
15932 else if (id == GADGET_ID_ANDROID_CONTENT)
15933 sprintf(infotext, "android element position: %d", sx + 1);
15934 else if (drawingarea_info[type_id].infotext != NULL)
15935 strcpy(infotext, drawingarea_info[type_id].infotext);
15938 infotext[max_infotext_len] = '\0';
15940 if (strlen(infotext) > 0)
15941 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
15944 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
15945 boolean quick_quit)
15947 if (!ask_if_level_has_changed ||
15949 Request("Level has changed! Exit without saving?",
15950 REQ_ASK | REQ_STAY_OPEN))
15952 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
15953 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
15955 // draw normal door
15956 UndrawSpecialEditorDoor();
15958 // use door animation if door 1 viewport is unchanged and contains toolbox
15959 if (useEditorDoorAnimation())
15960 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
15962 // close editor doors if viewport definition is the same as in main menu
15963 if (vp_door_1->x == DX &&
15964 vp_door_1->y == DY &&
15965 vp_door_1->width == DXSIZE &&
15966 vp_door_1->height == DYSIZE &&
15967 vp_door_2->x == VX &&
15968 vp_door_2->y == VY &&
15969 vp_door_2->width == VXSIZE &&
15970 vp_door_2->height == VYSIZE)
15971 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
15973 SetDoorState(DOOR_CLOSE_ALL);
15978 FadeSkipNextFadeIn();
15980 SetGameStatus(GAME_MODE_MAIN);
15986 if (!global.use_envelope_request)
15988 CloseDoor(DOOR_CLOSE_1);
15989 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);