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_BD_LINE_SHIFTING_BORDERS,
668 GADGET_ID_STICK_ELEMENT,
669 GADGET_ID_EM_SLIPPERY_GEMS,
670 GADGET_ID_EM_EXPLODES_BY_FIRE,
671 GADGET_ID_USE_SPRING_BUG,
672 GADGET_ID_USE_TIME_ORB_BUG,
673 GADGET_ID_USE_LIFE_BUGS,
674 GADGET_ID_RANDOM_BALL_CONTENT,
675 GADGET_ID_INITIAL_BALL_ACTIVE,
676 GADGET_ID_GROW_INTO_DIGGABLE,
677 GADGET_ID_SB_FIELDS_NEEDED,
678 GADGET_ID_SB_OBJECTS_NEEDED,
679 GADGET_ID_AUTO_EXIT_SOKOBAN,
680 GADGET_ID_SOLVED_BY_ONE_PLAYER,
681 GADGET_ID_FINISH_DIG_COLLECT,
682 GADGET_ID_KEEP_WALKABLE_CE,
683 GADGET_ID_CONTINUOUS_SNAPPING,
684 GADGET_ID_BLOCK_SNAP_FIELD,
685 GADGET_ID_BLOCK_LAST_FIELD,
686 GADGET_ID_SP_BLOCK_LAST_FIELD,
687 GADGET_ID_INSTANT_RELOCATION,
688 GADGET_ID_SHIFTED_RELOCATION,
689 GADGET_ID_LAZY_RELOCATION,
690 GADGET_ID_USE_START_ELEMENT,
691 GADGET_ID_USE_ARTWORK_ELEMENT,
692 GADGET_ID_USE_EXPLOSION_ELEMENT,
693 GADGET_ID_INITIAL_GRAVITY,
694 GADGET_ID_USE_INITIAL_INVENTORY,
695 GADGET_ID_CAN_PASS_TO_WALKABLE,
696 GADGET_ID_CAN_FALL_INTO_ACID,
697 GADGET_ID_CAN_MOVE_INTO_ACID,
698 GADGET_ID_DONT_COLLIDE_WITH,
699 GADGET_ID_BD_DIAGONAL_MOVEMENTS,
700 GADGET_ID_ENVELOPE_AUTOWRAP,
701 GADGET_ID_ENVELOPE_CENTERED,
702 GADGET_ID_MM_LASER_RED,
703 GADGET_ID_MM_LASER_GREEN,
704 GADGET_ID_MM_LASER_BLUE,
705 GADGET_ID_DF_LASER_RED,
706 GADGET_ID_DF_LASER_GREEN,
707 GADGET_ID_DF_LASER_BLUE,
708 GADGET_ID_ROTATE_MM_BALL_CONTENT,
709 GADGET_ID_EXPLODE_MM_BALL,
710 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
711 GADGET_ID_CUSTOM_CAN_EXPLODE,
712 GADGET_ID_CUSTOM_EXPLODE_FIRE,
713 GADGET_ID_CUSTOM_EXPLODE_SMASH,
714 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
715 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
716 GADGET_ID_CUSTOM_DEADLY,
717 GADGET_ID_CUSTOM_CAN_MOVE,
718 GADGET_ID_CUSTOM_CAN_FALL,
719 GADGET_ID_CUSTOM_CAN_SMASH,
720 GADGET_ID_CUSTOM_SLIPPERY,
721 GADGET_ID_CUSTOM_ACCESSIBLE,
722 GADGET_ID_CUSTOM_GRAV_REACHABLE,
723 GADGET_ID_CUSTOM_USE_LAST_VALUE,
724 GADGET_ID_CUSTOM_USE_GRAPHIC,
725 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
726 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
727 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
728 GADGET_ID_CUSTOM_CAN_CHANGE,
729 GADGET_ID_CHANGE_USE_CONTENT,
730 GADGET_ID_CHANGE_USE_EXPLOSION,
731 GADGET_ID_CHANGE_ONLY_COMPLETE,
732 GADGET_ID_CHANGE_USE_RANDOM,
733 GADGET_ID_CHANGE_HAS_ACTION,
734 GADGET_ID_CHANGE_DELAY,
735 GADGET_ID_CHANGE_BY_DIRECT_ACT,
736 GADGET_ID_CHANGE_BY_OTHER_ACT,
738 NUM_STATIC_GADGET_IDS
741 // gadgets for buttons in element list (dynamic)
742 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
743 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
744 ED_NUM_ELEMENTLIST_BUTTONS - 1)
746 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
748 // radio button numbers
752 RADIO_NR_DRAWING_TOOLBOX,
753 RADIO_NR_RANDOM_ELEMENTS
756 // values for counter gadgets
759 ED_COUNTER_ID_SELECT_LEVEL,
760 ED_COUNTER_ID_LEVEL_XSIZE,
761 ED_COUNTER_ID_LEVEL_YSIZE,
762 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
763 ED_COUNTER_ID_LEVEL_TIMELIMIT,
764 ED_COUNTER_ID_LEVEL_TIMESCORE,
765 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
766 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
767 ED_COUNTER_ID_LEVEL_RANDOM,
768 ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
769 ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
770 ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES,
771 ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS,
772 ED_COUNTER_ID_ELEMENT_VALUE1,
773 ED_COUNTER_ID_ELEMENT_VALUE2,
774 ED_COUNTER_ID_ELEMENT_VALUE3,
775 ED_COUNTER_ID_ELEMENT_VALUE4,
776 ED_COUNTER_ID_YAMYAM_CONTENT,
777 ED_COUNTER_ID_BALL_CONTENT,
778 ED_COUNTER_ID_ANDROID_CONTENT,
779 ED_COUNTER_ID_ENVELOPE_XSIZE,
780 ED_COUNTER_ID_ENVELOPE_YSIZE,
781 ED_COUNTER_ID_INVENTORY_SIZE,
782 ED_COUNTER_ID_MM_BALL_CONTENT,
783 ED_COUNTER_ID_CUSTOM_SCORE,
784 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
785 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
786 ED_COUNTER_ID_CUSTOM_VALUE_RND,
787 ED_COUNTER_ID_PUSH_DELAY_FIX,
788 ED_COUNTER_ID_PUSH_DELAY_RND,
789 ED_COUNTER_ID_DROP_DELAY_FIX,
790 ED_COUNTER_ID_DROP_DELAY_RND,
791 ED_COUNTER_ID_MOVE_DELAY_FIX,
792 ED_COUNTER_ID_MOVE_DELAY_RND,
793 ED_COUNTER_ID_STEP_DELAY_FIX,
794 ED_COUNTER_ID_STEP_DELAY_RND,
795 ED_COUNTER_ID_EXPLOSION_DELAY,
796 ED_COUNTER_ID_IGNITION_DELAY,
797 ED_COUNTER_ID_GROUP_CONTENT,
798 ED_COUNTER_ID_CHANGE_DELAY_FIX,
799 ED_COUNTER_ID_CHANGE_DELAY_RND,
800 ED_COUNTER_ID_CHANGE_CONT_RND,
802 ED_NUM_COUNTERBUTTONS
805 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
806 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
807 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
808 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
809 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
810 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
812 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
813 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
814 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
815 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
816 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
817 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
819 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
820 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
822 // values for scrollbutton gadgets
825 ED_SCROLLBUTTON_ID_AREA_UP,
826 ED_SCROLLBUTTON_ID_AREA_DOWN,
827 ED_SCROLLBUTTON_ID_AREA_LEFT,
828 ED_SCROLLBUTTON_ID_AREA_RIGHT,
829 ED_SCROLLBUTTON_ID_LIST_UP,
830 ED_SCROLLBUTTON_ID_LIST_DOWN,
835 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
836 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
838 // values for scrollbar gadgets
841 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
842 ED_SCROLLBAR_ID_AREA_VERTICAL,
843 ED_SCROLLBAR_ID_LIST_VERTICAL,
848 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
849 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
851 // values for text input gadgets
854 ED_TEXTINPUT_ID_LEVEL_NAME,
855 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
856 ED_TEXTINPUT_ID_LEVELSET_NAME,
857 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
858 ED_TEXTINPUT_ID_ELEMENT_NAME,
863 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
864 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
866 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
867 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
869 // values for text area gadgets
872 ED_TEXTAREA_ID_ENVELOPE_INFO,
877 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
878 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
880 // values for selectbox gadgets
883 ED_SELECTBOX_ID_TIME_OR_STEPS,
884 ED_SELECTBOX_ID_TIME_SCORE_BASE,
885 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
886 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
887 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
888 ED_SELECTBOX_ID_WIND_DIRECTION,
889 ED_SELECTBOX_ID_PLAYER_SPEED,
890 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
891 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
892 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
893 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
894 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
895 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
896 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
897 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
898 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
899 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
900 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
901 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
902 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
903 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
904 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
905 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
906 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
907 ED_SELECTBOX_ID_CHANGE_SIDE,
908 ED_SELECTBOX_ID_CHANGE_PLAYER,
909 ED_SELECTBOX_ID_CHANGE_PAGE,
910 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
911 ED_SELECTBOX_ID_ACTION_TYPE,
912 ED_SELECTBOX_ID_ACTION_MODE,
913 ED_SELECTBOX_ID_ACTION_ARG,
914 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
915 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
920 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
921 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
923 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
924 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
926 #define ED_SELECTBOX_ID_ENGINE_FIRST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
927 #define ED_SELECTBOX_ID_ENGINE_LAST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
929 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
930 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
931 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
932 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
933 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
934 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
936 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
937 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
939 // values for textbutton gadgets
942 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
943 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
944 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
945 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
946 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
947 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
948 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
949 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
950 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
951 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
952 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
953 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
954 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
955 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
960 #define ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
961 #define ED_TAB_BUTTON_ID_LEVELCONFIG_LAST ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
963 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
964 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
966 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
967 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
969 // values for graphicbutton gadgets
972 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
973 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
974 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
975 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
977 ED_NUM_GRAPHICBUTTONS
980 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
981 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
983 // values for checkbutton gadgets
986 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
987 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
988 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
989 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
990 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
991 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
992 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
993 ED_CHECKBUTTON_ID_BD_INTERMISSION,
994 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
995 ED_CHECKBUTTON_ID_BD_LINE_SHIFTING_BORDERS,
996 ED_CHECKBUTTON_ID_STICK_ELEMENT,
997 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
998 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
999 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
1000 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
1001 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
1002 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
1003 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
1004 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
1005 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
1006 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
1007 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
1008 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
1009 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
1010 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
1011 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
1012 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
1013 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
1014 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
1015 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
1016 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
1017 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
1018 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
1019 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
1020 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
1021 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
1022 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
1023 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
1024 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
1025 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
1026 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
1027 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
1028 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
1029 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
1030 ED_CHECKBUTTON_ID_MM_LASER_RED,
1031 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
1032 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1033 ED_CHECKBUTTON_ID_DF_LASER_RED,
1034 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1035 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1036 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
1037 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
1038 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1039 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1040 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1041 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1042 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1043 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1044 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1045 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1046 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1047 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1048 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1049 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1050 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1051 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1052 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1053 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1054 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1055 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1056 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1057 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1058 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1059 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1060 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1061 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1062 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1067 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1068 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1070 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1071 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1073 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1074 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1076 #define ED_CHECKBUTTON_ID_ENGINE_FIRST ED_CHECKBUTTON_ID_BD_INTERMISSION
1077 #define ED_CHECKBUTTON_ID_ENGINE_LAST ED_CHECKBUTTON_ID_BD_LINE_SHIFTING_BORDERS
1079 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1080 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1081 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1082 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1083 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1084 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1086 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1087 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1089 // values for radiobutton gadgets
1092 ED_RADIOBUTTON_ID_PERCENTAGE,
1093 ED_RADIOBUTTON_ID_QUANTITY,
1098 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1099 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1101 // values for drawing area gadgets
1104 ED_DRAWING_ID_DRAWING_LEVEL,
1105 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1106 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1107 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1108 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1109 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1110 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1111 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1112 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1113 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1114 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1115 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1116 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1117 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1118 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1119 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1120 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1121 ED_DRAWING_ID_ANDROID_CONTENT,
1122 ED_DRAWING_ID_AMOEBA_CONTENT,
1123 ED_DRAWING_ID_START_ELEMENT,
1124 ED_DRAWING_ID_ARTWORK_ELEMENT,
1125 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1126 ED_DRAWING_ID_INVENTORY_CONTENT,
1127 ED_DRAWING_ID_MM_BALL_CONTENT,
1128 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1129 ED_DRAWING_ID_CUSTOM_CONTENT,
1130 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1131 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1132 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1133 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1134 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1135 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1136 ED_DRAWING_ID_GROUP_CONTENT,
1137 ED_DRAWING_ID_RANDOM_BACKGROUND,
1139 ED_NUM_DRAWING_AREAS
1142 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1143 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1146 // ----------------------------------------------------------------------------
1147 // some internally used definitions
1148 // ----------------------------------------------------------------------------
1150 // values for CopyLevelToUndoBuffer()
1151 #define UNDO_IMMEDIATE 0
1152 #define UNDO_ACCUMULATE 1
1154 // values for scrollbars
1155 #define ED_SCROLL_NO 0
1156 #define ED_SCROLL_LEFT 1
1157 #define ED_SCROLL_RIGHT 2
1158 #define ED_SCROLL_UP 4
1159 #define ED_SCROLL_DOWN 8
1161 // screens in the level editor
1162 #define ED_MODE_DRAWING 0
1163 #define ED_MODE_LEVELCONFIG 1
1164 #define ED_MODE_PROPERTIES 2
1165 #define ED_MODE_PALETTE 3
1167 // sub-screens in the global settings section
1168 #define ED_MODE_LEVELCONFIG_LEVEL ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
1169 #define ED_MODE_LEVELCONFIG_LEVELSET ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET
1170 #define ED_MODE_LEVELCONFIG_EDITOR ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
1171 #define ED_MODE_LEVELCONFIG_ENGINE ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
1173 // sub-screens in the element properties section
1174 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1175 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1176 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1177 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1178 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1180 // how many steps can be cancelled
1181 #define NUM_UNDO_STEPS (64 + 1)
1183 // values for elements with score for certain actions
1185 #define MAX_SCORE 999
1187 // values for elements with count for collecting
1188 #define MIN_COLLECT_COUNT 0
1189 #define MAX_COLLECT_COUNT 999
1191 // values for random placement
1192 #define RANDOM_USE_PERCENTAGE 0
1193 #define RANDOM_USE_QUANTITY 1
1195 // values for level set save mode
1196 #define LEVELSET_SAVE_MODE_UPDATE 0
1197 #define LEVELSET_SAVE_MODE_CREATE 1
1199 // default value for element tile size in drawing area
1200 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1201 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1204 // ----------------------------------------------------------------------------
1205 // some internally used data structure definitions
1206 // ----------------------------------------------------------------------------
1212 struct XYTileSize *pos;
1216 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1218 // note: some additional characters are already reserved for "cheat mode"
1219 // shortcuts (":XYZ" style) -- for details, see "events.c"
1221 // ---------- toolbox control buttons ---------------------------------------
1224 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1225 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1226 "draw single items", 's'
1229 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1230 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1231 "draw connected items", 'd'
1234 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1235 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1239 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1240 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1244 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1245 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1246 "draw outline rectangles", 'r'
1249 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1250 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1251 "draw filled rectangles", 'R'
1254 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1255 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1256 "wrap (rotate) level up", 0
1259 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1260 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1261 "enter text elements", 't'
1264 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1265 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1269 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1270 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1271 "wrap (rotate) level left", 0
1274 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1275 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1276 "zoom level tile size", '+'
1279 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1280 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1281 "wrap (rotate) level right", 0
1284 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1285 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1286 "random element placement", 0
1289 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1290 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1294 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1295 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1296 "wrap (rotate) level down", 0
1299 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1300 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1301 "pick drawing element", ','
1304 // ---------- level control buttons -----------------------------------------
1307 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1308 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1309 "undo/redo last operation", 'u'
1312 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_CONF,
1313 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1314 "level and editor settings", 'I'
1317 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1318 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1322 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1323 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1327 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1328 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1332 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1333 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1334 "exit level editor", 'E'
1337 // ---------- CE and GE control buttons -------------------------------------
1340 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1341 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1342 "copy settings from other element", 0
1345 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1346 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1347 "copy settings to other element", 0
1350 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1351 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1352 "exchange element with other element", 0
1355 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1356 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1357 "copy settings from this element", 0
1360 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1361 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1362 "paste settings to this element", 0
1365 // ---------- palette control buttons ---------------------------------------
1368 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1369 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1370 "properties of drawing element", 'p'
1373 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1374 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1375 "properties of drawing element 1", '1'
1378 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1379 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1380 "properties of drawing element 2", '2'
1383 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1384 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1385 "properties of drawing element 3", '3'
1388 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1389 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1390 "show list of elements", 'e'
1394 static int random_placement_value = 10;
1395 static int random_placement_method = RANDOM_USE_QUANTITY;
1396 static int random_placement_background_element = EL_SAND;
1397 static boolean random_placement_background_restricted = FALSE;
1398 static boolean stick_element_properties_window = FALSE;
1399 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1400 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1401 static struct ElementChangeInfo custom_element_change;
1402 static struct ElementGroupInfo group_element_info;
1403 static struct ElementInfo custom_element;
1405 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1406 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1407 static int levelset_num_levels = 100;
1408 static boolean levelset_use_levelset_artwork = FALSE;
1409 static boolean levelset_copy_level_template = FALSE;
1410 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1416 int min_value, max_value;
1417 int gadget_id_down, gadget_id_up;
1419 int gadget_id_align;
1421 char *text_above, *text_left, *text_right;
1422 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1424 // ---------- current level number ------------------------------------------
1427 ED_COUNTER_ID_SELECT_LEVEL,
1428 -1, -1, // these values are not constant, but can change at runtime
1430 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1431 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1436 // ---------- level and editor settings -------------------------------------
1439 ED_COUNTER_ID_LEVEL_XSIZE,
1440 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1441 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1442 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1443 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1445 "playfield size:", NULL, "width",
1448 ED_COUNTER_ID_LEVEL_YSIZE,
1449 -1, ED_LEVEL_SETTINGS_YPOS(4),
1450 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1451 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1452 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1454 NULL, " ", "height",
1457 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
1458 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1460 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1461 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1463 NULL, "number of gems to collect:", NULL
1466 ED_COUNTER_ID_LEVEL_TIMELIMIT,
1467 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1469 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1470 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1472 "time or step limit to solve level:", NULL, NULL
1475 ED_COUNTER_ID_LEVEL_TIMESCORE,
1476 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1478 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1479 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1480 &level.score[SC_TIME_BONUS],
1481 "score for time or steps left:", NULL, NULL
1484 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
1485 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1487 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1488 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1490 NULL, "random seed:", "(0 => random)"
1493 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
1494 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1496 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1497 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1498 &levelset_num_levels,
1499 "number of levels:", NULL, NULL,
1502 ED_COUNTER_ID_LEVEL_RANDOM,
1503 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1505 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1506 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1507 &random_placement_value,
1508 "random element placement:", NULL, "in"
1511 ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
1512 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3),
1514 GADGET_ID_BD_CYCLE_DELAY_MS_DOWN, GADGET_ID_BD_CYCLE_DELAY_MS_UP,
1515 GADGET_ID_BD_CYCLE_DELAY_MS_TEXT, GADGET_ID_NONE,
1516 &level.bd_cycle_delay_ms,
1517 NULL, NULL, "game cycle delay (ms)"
1520 ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
1521 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3),
1523 GADGET_ID_BD_CYCLE_DELAY_C64_DOWN, GADGET_ID_BD_CYCLE_DELAY_C64_UP,
1524 GADGET_ID_BD_CYCLE_DELAY_C64_TEXT, GADGET_ID_NONE,
1525 &level.bd_cycle_delay_c64,
1526 NULL, NULL, "game cycle delay (C64-style)"
1529 ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES,
1530 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1532 GADGET_ID_BD_HATCHING_DELAY_CYCLES_DOWN, GADGET_ID_BD_HATCHING_DELAY_CYCLES_UP,
1533 GADGET_ID_BD_HATCHING_DELAY_CYCLES_TEXT, GADGET_ID_NONE,
1534 &level.bd_hatching_delay_cycles,
1535 NULL, NULL, "hatching delay (cycles)"
1538 ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS,
1539 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1541 GADGET_ID_BD_HATCHING_DELAY_SECONDS_DOWN, GADGET_ID_BD_HATCHING_DELAY_SECONDS_UP,
1542 GADGET_ID_BD_HATCHING_DELAY_SECONDS_TEXT, GADGET_ID_NONE,
1543 &level.bd_hatching_delay_seconds,
1544 NULL, NULL, "hatching delay (seconds)"
1547 // ---------- element settings: configure (various elements) ----------------
1550 ED_COUNTER_ID_ELEMENT_VALUE1,
1551 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1552 MIN_SCORE, MAX_SCORE,
1553 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1554 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1555 NULL, // will be set when used
1559 ED_COUNTER_ID_ELEMENT_VALUE2,
1560 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1561 MIN_SCORE, MAX_SCORE,
1562 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1563 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1564 NULL, // will be set when used
1568 ED_COUNTER_ID_ELEMENT_VALUE3,
1569 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1570 MIN_SCORE, MAX_SCORE,
1571 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1572 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1573 NULL, // will be set when used
1577 ED_COUNTER_ID_ELEMENT_VALUE4,
1578 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1579 MIN_SCORE, MAX_SCORE,
1580 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1581 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1582 NULL, // will be set when used
1586 ED_COUNTER_ID_YAMYAM_CONTENT,
1587 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1588 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1589 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1590 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1591 &level.num_yamyam_contents,
1592 NULL, NULL, "number of content areas"
1595 ED_COUNTER_ID_BALL_CONTENT,
1596 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1597 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1598 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1599 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1600 &level.num_ball_contents,
1601 NULL, NULL, "number of content areas"
1604 ED_COUNTER_ID_ANDROID_CONTENT,
1605 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1606 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1607 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1608 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1609 &level.num_android_clone_elements,
1610 NULL, NULL, "number of clonable elements"
1613 ED_COUNTER_ID_ENVELOPE_XSIZE,
1614 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1615 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1616 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1617 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1618 NULL, // will be set when used
1619 NULL, NULL, "width",
1622 ED_COUNTER_ID_ENVELOPE_YSIZE,
1623 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1624 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1625 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1626 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1627 NULL, // will be set when used
1628 NULL, " ", "height",
1631 ED_COUNTER_ID_INVENTORY_SIZE,
1632 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1633 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1634 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1635 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1636 &level.initial_inventory_size[0],
1637 NULL, NULL, "number of inventory elements"
1640 ED_COUNTER_ID_MM_BALL_CONTENT,
1641 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1642 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1643 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1644 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1645 &level.num_mm_ball_contents,
1646 NULL, NULL, "number of content elements"
1649 // ---------- element settings: configure 1 (custom elements) ---------------
1652 ED_COUNTER_ID_CUSTOM_SCORE,
1653 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1654 MIN_SCORE, MAX_SCORE,
1655 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1656 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1657 &custom_element.collect_score_initial,
1658 NULL, "CE score", " "
1661 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
1662 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1663 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1664 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1665 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1666 &custom_element.collect_count_initial,
1667 NULL, "CE count", NULL
1670 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
1671 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1673 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1674 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1675 &custom_element.ce_value_fixed_initial,
1676 NULL, "CE value", NULL
1679 ED_COUNTER_ID_CUSTOM_VALUE_RND,
1680 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1682 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1683 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1684 &custom_element.ce_value_random_initial,
1685 NULL, "+random", NULL
1688 ED_COUNTER_ID_PUSH_DELAY_FIX,
1689 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1691 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1692 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1693 &custom_element.push_delay_fixed,
1694 NULL, "push delay", NULL
1697 ED_COUNTER_ID_PUSH_DELAY_RND,
1698 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1700 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1701 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1702 &custom_element.push_delay_random,
1703 NULL, "+random", NULL
1706 ED_COUNTER_ID_DROP_DELAY_FIX,
1707 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1709 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1710 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1711 &custom_element.drop_delay_fixed,
1712 NULL, "drop delay", NULL
1715 ED_COUNTER_ID_DROP_DELAY_RND,
1716 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1718 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1719 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1720 &custom_element.drop_delay_random,
1721 NULL, "+random", NULL
1724 // ---------- element settings: configure 2 (custom elements) ---------------
1727 ED_COUNTER_ID_MOVE_DELAY_FIX,
1728 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1730 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1731 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1732 &custom_element.move_delay_fixed,
1733 NULL, "move delay", NULL
1736 ED_COUNTER_ID_MOVE_DELAY_RND,
1737 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1739 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1740 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1741 &custom_element.move_delay_random,
1742 NULL, "+random", NULL
1745 ED_COUNTER_ID_STEP_DELAY_FIX,
1746 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1748 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1749 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1750 &custom_element.step_delay_fixed,
1751 NULL, "step delay", NULL
1754 ED_COUNTER_ID_STEP_DELAY_RND,
1755 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1757 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1758 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1759 &custom_element.step_delay_random,
1760 NULL, "+random", NULL
1763 ED_COUNTER_ID_EXPLOSION_DELAY,
1764 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1766 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1767 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1768 &custom_element.explosion_delay,
1769 NULL, "explosion delay", NULL
1772 ED_COUNTER_ID_IGNITION_DELAY,
1773 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1775 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1776 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1777 &custom_element.ignition_delay,
1778 NULL, "ignition delay", "(by fire)"
1781 // ---------- element settings: configure (group elements) ------------------
1784 ED_COUNTER_ID_GROUP_CONTENT,
1785 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1786 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1787 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1788 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1789 &group_element_info.num_elements,
1790 NULL, NULL, "number of elements in group"
1793 // ---------- element settings: advanced (custom elements) ------------------
1796 ED_COUNTER_ID_CHANGE_DELAY_FIX,
1797 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1799 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1800 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1801 &custom_element_change.delay_fixed,
1802 NULL, "CE delay", NULL,
1805 ED_COUNTER_ID_CHANGE_DELAY_RND,
1806 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1808 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1809 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1810 &custom_element_change.delay_random,
1811 NULL, "+random", NULL
1814 ED_COUNTER_ID_CHANGE_CONT_RND,
1815 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1817 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1818 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1819 &custom_element_change.random_percentage,
1820 NULL, "use random replace:", "%"
1831 char *text_above, *infotext;
1832 } textinput_info[ED_NUM_TEXTINPUT] =
1835 ED_TEXTINPUT_ID_LEVEL_NAME,
1836 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1837 GADGET_ID_LEVEL_NAME,
1840 "Title:", "Title for this level"
1843 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
1844 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1845 GADGET_ID_LEVEL_AUTHOR,
1846 MAX_LEVEL_AUTHOR_LEN,
1848 "Author:", "Author for this level"
1851 ED_TEXTINPUT_ID_LEVELSET_NAME,
1852 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1853 GADGET_ID_LEVELSET_NAME,
1856 "Title:", "Title for this or new level set"
1859 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
1860 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1861 GADGET_ID_LEVELSET_AUTHOR,
1862 MAX_LEVEL_AUTHOR_LEN,
1864 "Author:", "Author for this or new level set"
1867 ED_TEXTINPUT_ID_ELEMENT_NAME,
1868 -1, -1, // these values are not constant, but can change at runtime
1869 GADGET_ID_ELEMENT_NAME,
1870 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1871 custom_element.description,
1872 NULL, "Element name"
1883 char *text_above, *text_above_cropped, *infotext;
1884 } textarea_info[ED_NUM_TEXTAREAS] =
1887 ED_TEXTAREA_ID_ENVELOPE_INFO,
1888 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1889 GADGET_ID_ENVELOPE_INFO,
1890 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1892 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1896 static struct ValueTextInfo options_time_or_steps[] =
1904 static struct ValueTextInfo options_time_score_base[] =
1906 { 1, "per second/step" },
1907 { 10, "per 10 seconds/steps" },
1912 static struct ValueTextInfo options_game_engine_type[] =
1914 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1915 { GAME_ENGINE_TYPE_BD, "Boulder Dash" },
1916 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1917 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1918 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1923 static struct ValueTextInfo options_levelset_save_mode[] =
1925 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1926 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1931 static struct ValueTextInfo options_wind_direction[] =
1933 { MV_START_NONE, "none" },
1934 { MV_START_LEFT, "left" },
1935 { MV_START_RIGHT, "right" },
1936 { MV_START_UP, "up" },
1937 { MV_START_DOWN, "down" },
1942 static struct ValueTextInfo options_player_speed[] =
1949 { 16, "very fast" },
1950 { 32, "ultrafast" },
1955 static struct ValueTextInfo options_access_type[] =
1957 { EP_WALKABLE, "walkable" },
1958 { EP_PASSABLE, "passable" },
1963 static struct ValueTextInfo options_access_layer[] =
1965 { EP_ACCESSIBLE_OVER, "over" },
1966 { EP_ACCESSIBLE_INSIDE, "inside" },
1967 { EP_ACCESSIBLE_UNDER, "under" },
1972 static struct ValueTextInfo options_access_protected[] =
1974 { 0, "unprotected" },
1980 static struct ValueTextInfo options_access_direction[] =
1982 { MV_NO_DIRECTION, "no direction" },
1983 { MV_LEFT, "left" },
1984 { MV_RIGHT, "right" },
1986 { MV_DOWN, "down" },
1987 { MV_LEFT | MV_UP, "left + up" },
1988 { MV_LEFT | MV_DOWN, "left + down" },
1989 { MV_RIGHT | MV_UP, "right + up" },
1990 { MV_RIGHT | MV_DOWN, "right + down" },
1991 { MV_HORIZONTAL, "horizontal" },
1992 { MV_VERTICAL, "vertical" },
1993 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1994 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1995 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1996 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1997 { MV_ALL_DIRECTIONS, "all directions" },
2002 static struct ValueTextInfo options_walk_to_action[] =
2004 { EP_DIGGABLE, "diggable" },
2005 { EP_COLLECTIBLE_ONLY, "collectible" },
2006 { EP_DROPPABLE, "collectible & droppable" },
2007 { EP_THROWABLE, "collectible & throwable" },
2008 { EP_PUSHABLE, "pushable" },
2013 static struct ValueTextInfo options_move_pattern[] =
2015 { MV_LEFT, "left" },
2016 { MV_RIGHT, "right" },
2018 { MV_DOWN, "down" },
2019 { MV_HORIZONTAL, "horizontal" },
2020 { MV_VERTICAL, "vertical" },
2021 { MV_ALL_DIRECTIONS, "all directions" },
2022 { MV_WIND_DIRECTION, "wind direction" },
2023 { MV_TOWARDS_PLAYER, "towards player" },
2024 { MV_AWAY_FROM_PLAYER, "away from player" },
2025 { MV_ALONG_LEFT_SIDE, "along left side" },
2026 { MV_ALONG_RIGHT_SIDE, "along right side" },
2027 { MV_TURNING_LEFT, "turning left" },
2028 { MV_TURNING_RIGHT, "turning right" },
2029 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
2030 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
2031 { MV_TURNING_RANDOM, "turning random" },
2032 { MV_MAZE_RUNNER, "maze runner style" },
2033 { MV_MAZE_HUNTER, "maze hunter style" },
2034 { MV_WHEN_PUSHED, "when pushed" },
2035 { MV_WHEN_DROPPED, "when dropped/thrown" },
2040 static struct ValueTextInfo options_move_direction[] =
2042 { MV_START_AUTOMATIC, "automatic" },
2043 { MV_START_LEFT, "left" },
2044 { MV_START_RIGHT, "right" },
2045 { MV_START_UP, "up" },
2046 { MV_START_DOWN, "down" },
2047 { MV_START_RANDOM, "random" },
2048 { MV_START_PREVIOUS, "previous" },
2053 static struct ValueTextInfo options_move_stepsize[] =
2055 { 0, "not moving" },
2060 { 16, "very fast" },
2061 { 32, "even faster" },
2066 static struct ValueTextInfo options_move_leave_type[] =
2068 { LEAVE_TYPE_UNLIMITED, "leave behind" },
2069 { LEAVE_TYPE_LIMITED, "change it to" },
2074 static struct ValueTextInfo options_smash_targets[] =
2076 { EP_CAN_SMASH_PLAYER, "player" },
2078 { EP_CAN_SMASH_ENEMIES, "enemies" },
2080 { EP_CAN_SMASH_EVERYTHING, "everything" },
2085 static struct ValueTextInfo options_slippery_type[] =
2087 { SLIPPERY_ANY_RANDOM, "random" },
2088 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
2089 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
2090 { SLIPPERY_ONLY_LEFT, "only left" },
2091 { SLIPPERY_ONLY_RIGHT, "only right" },
2096 static struct ValueTextInfo options_deadliness[] =
2098 { EP_DONT_RUN_INTO, "running into" },
2099 { EP_DONT_COLLIDE_WITH, "colliding with" },
2100 { EP_DONT_GET_HIT_BY, "getting hit by" },
2101 { EP_DONT_TOUCH, "touching" },
2106 static struct ValueTextInfo options_explosion_type[] =
2108 { EXPLODES_3X3, "3x3" },
2109 { EXPLODES_CROSS, "3+3" },
2110 { EXPLODES_1X1, "1x1" },
2115 static struct ValueTextInfo options_time_units[] =
2118 { FRAMES_PER_SECOND, "seconds" },
2123 static struct ValueTextInfo options_change_direct_action[] =
2125 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2126 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2127 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2128 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2129 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2130 { CE_ENTERED_BY_PLAYER, "entered by player" },
2131 { CE_LEFT_BY_PLAYER, "left by player" },
2132 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2133 { CE_SWITCHED, "switched" },
2134 { CE_HITTING_SOMETHING, "hitting something" },
2135 { CE_HIT_BY_SOMETHING, "hit by something" },
2137 { CE_BLOCKED, "blocked" },
2139 { CE_IMPACT, "impact (on something)" },
2140 { CE_SMASHED, "smashed (from above)" },
2142 { CE_VALUE_CHANGES, "CE value changes" },
2143 { CE_SCORE_CHANGES, "CE score changes" },
2145 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2146 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2147 { CE_UNDEFINED, " " },
2148 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2149 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2150 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2151 { CE_UNDEFINED, " " },
2152 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2153 { CE_NEXT_TO_PLAYER, "next to player" },
2158 static struct ValueTextInfo options_change_other_action[] =
2160 { CE_PLAYER_TOUCHES_X, "player touches" },
2161 { CE_PLAYER_PRESSES_X, "player presses" },
2162 { CE_PLAYER_SWITCHES_X, "player switches" },
2163 { CE_PLAYER_SNAPS_X, "player snaps" },
2164 { CE_PLAYER_PUSHES_X, "player pushes" },
2165 { CE_PLAYER_ENTERS_X, "player enters" },
2166 { CE_PLAYER_LEAVES_X, "player leaves" },
2167 { CE_PLAYER_DIGS_X, "player digs" },
2168 { CE_PLAYER_COLLECTS_X, "player collects" },
2169 { CE_PLAYER_DROPS_X, "player drops/throws" },
2170 { CE_TOUCHING_X, "touching" },
2171 { CE_HITTING_X, "hitting" },
2172 { CE_DIGGING_X, "digging" },
2173 { CE_HIT_BY_X, "hit by" },
2174 { CE_SWITCH_OF_X, "switch of" },
2175 { CE_CHANGE_OF_X, "change by page of" },
2176 { CE_EXPLOSION_OF_X, "explosion of" },
2177 { CE_MOVE_OF_X, "move of" },
2178 { CE_CREATION_OF_X, "creation of" },
2179 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2180 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2181 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2182 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2183 { CE_UNDEFINED, " " },
2184 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2185 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2186 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2187 { CE_UNDEFINED, " " },
2188 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2189 { CE_PLAYER_NEXT_TO_X, "player next to" },
2190 { CE_NEXT_TO_X, "next to" },
2195 static struct ValueTextInfo options_change_trigger_side[] =
2197 { CH_SIDE_LEFT, "left" },
2198 { CH_SIDE_RIGHT, "right" },
2199 { CH_SIDE_TOP, "top" },
2200 { CH_SIDE_BOTTOM, "bottom" },
2201 { CH_SIDE_LEFT_RIGHT, "left/right" },
2202 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2203 { CH_SIDE_ANY, "any" },
2208 static struct ValueTextInfo options_change_trigger_player[] =
2210 { CH_PLAYER_1, "1" },
2211 { CH_PLAYER_2, "2" },
2212 { CH_PLAYER_3, "3" },
2213 { CH_PLAYER_4, "4" },
2214 { CH_PLAYER_ANY, "any" },
2219 static struct ValueTextInfo options_change_trigger_page[] =
2230 { (1u << 9), "10" },
2231 { (1u << 10), "11" },
2232 { (1u << 11), "12" },
2233 { (1u << 12), "13" },
2234 { (1u << 13), "14" },
2235 { (1u << 14), "15" },
2236 { (1u << 15), "16" },
2237 { (1u << 16), "17" },
2238 { (1u << 17), "18" },
2239 { (1u << 18), "19" },
2240 { (1u << 19), "20" },
2241 { (1u << 20), "21" },
2242 { (1u << 21), "22" },
2243 { (1u << 22), "23" },
2244 { (1u << 23), "24" },
2245 { (1u << 24), "25" },
2246 { (1u << 25), "26" },
2247 { (1u << 26), "27" },
2248 { (1u << 27), "28" },
2249 { (1u << 28), "29" },
2250 { (1u << 29), "30" },
2251 { (1u << 30), "31" },
2252 { (1u << 31), "32" },
2253 { CH_PAGE_ANY, "any" },
2258 static struct ValueTextInfo options_change_replace_when[] =
2260 { CP_WHEN_EMPTY, "empty" },
2261 { CP_WHEN_WALKABLE, "walkable" },
2262 { CP_WHEN_DIGGABLE, "diggable" },
2263 { CP_WHEN_COLLECTIBLE, "collectible" },
2264 { CP_WHEN_REMOVABLE, "removable" },
2265 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2270 static struct ValueTextInfo options_action_type[] =
2272 { CA_NO_ACTION, "no action" },
2273 { CA_UNDEFINED, " " },
2274 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2275 { CA_RESTART_LEVEL, "restart level" },
2276 { CA_SHOW_ENVELOPE, "show envelope" },
2277 { CA_SET_LEVEL_TIME, "set time" },
2278 { CA_SET_LEVEL_SCORE, "set score" },
2279 { CA_SET_LEVEL_GEMS, "set gems" },
2280 { CA_SET_LEVEL_WIND, "set wind dir." },
2281 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2282 { CA_UNDEFINED, " " },
2283 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2284 { CA_MOVE_PLAYER, "move player" },
2285 { CA_MOVE_PLAYER_NEW, "move player new" },
2286 { CA_EXIT_PLAYER, "exit player" },
2287 { CA_KILL_PLAYER, "kill player" },
2288 { CA_SET_PLAYER_KEYS, "set keys" },
2289 { CA_SET_PLAYER_SPEED, "set speed" },
2290 { CA_SET_PLAYER_SHIELD, "set shield" },
2291 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2292 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2293 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2294 { CA_UNDEFINED, " " },
2295 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2296 { CA_SET_CE_VALUE, "set CE value" },
2297 { CA_SET_CE_SCORE, "set CE score" },
2298 { CA_SET_CE_ARTWORK, "set CE artwork" },
2299 { CA_UNDEFINED, " " },
2300 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2301 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2306 static struct ValueTextInfo options_action_mode_none[] =
2308 { CA_MODE_UNDEFINED, " " },
2313 static struct ValueTextInfo options_action_mode_assign[] =
2315 { CA_MODE_SET, "=" },
2320 static struct ValueTextInfo options_action_mode_add_remove[] =
2322 { CA_MODE_ADD, "+" },
2323 { CA_MODE_SUBTRACT, "-" },
2328 static struct ValueTextInfo options_action_mode_calculate[] =
2330 { CA_MODE_SET, "=" },
2331 { CA_MODE_ADD, "+" },
2332 { CA_MODE_SUBTRACT, "-" },
2333 { CA_MODE_MULTIPLY, "*" },
2334 { CA_MODE_DIVIDE, "/" },
2335 { CA_MODE_MODULO, "%" },
2340 static struct ValueTextInfo options_action_arg_none[] =
2342 { CA_ARG_UNDEFINED, " " },
2347 static struct ValueTextInfo options_action_arg_player[] =
2349 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2350 { CA_ARG_PLAYER_1, "1" },
2351 { CA_ARG_PLAYER_2, "2" },
2352 { CA_ARG_PLAYER_3, "3" },
2353 { CA_ARG_PLAYER_4, "4" },
2354 { CA_ARG_PLAYER_ANY, "any" },
2355 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2356 { CA_ARG_PLAYER_ACTION, "action ->" },
2361 static struct ValueTextInfo options_action_arg_number[] =
2363 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2370 { CA_ARG_10, "10" },
2371 { CA_ARG_100, "100" },
2372 { CA_ARG_1000, "1000" },
2373 { CA_ARG_UNDEFINED, " " },
2374 { CA_ARG_NUMBER_MIN, "min" },
2375 { CA_ARG_NUMBER_MAX, "max" },
2376 { CA_ARG_UNDEFINED, " " },
2377 { CA_ARG_NUMBER_RESET, "reset" },
2378 { CA_ARG_UNDEFINED, " " },
2379 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2380 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2381 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2382 { CA_ARG_UNDEFINED, " " },
2383 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2384 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2385 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2386 { CA_ARG_UNDEFINED, " " },
2387 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2388 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2389 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2390 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2391 { CA_ARG_UNDEFINED, " " },
2392 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2393 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2394 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2395 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2400 static struct ValueTextInfo options_action_arg_value[] =
2402 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2409 { CA_ARG_10, "10" },
2410 { CA_ARG_100, "100" },
2411 { CA_ARG_1000, "1000" },
2412 { CA_ARG_UNDEFINED, " " },
2413 { CA_ARG_NUMBER_MIN, "min" },
2414 { CA_ARG_NUMBER_MAX, "max" },
2415 { CA_ARG_UNDEFINED, " " },
2416 { CA_ARG_NUMBER_RESET, "reset" },
2417 { CA_ARG_UNDEFINED, " " },
2418 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2419 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2420 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2421 { CA_ARG_UNDEFINED, " " },
2422 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2423 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2424 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2425 { CA_ARG_UNDEFINED, " " },
2426 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2427 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2428 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2429 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2430 { CA_ARG_UNDEFINED, " " },
2431 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2432 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2433 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2434 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2435 { CA_ARG_UNDEFINED, " " },
2436 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2437 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2438 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2439 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2444 static struct ValueTextInfo options_action_arg_envelope[] =
2446 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2451 { CA_ARG_UNDEFINED, " " },
2452 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2453 { CA_ARG_ELEMENT_TARGET, "target" },
2454 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2455 { CA_ARG_ELEMENT_ACTION, "action ->" },
2460 static struct ValueTextInfo options_action_arg_key[] =
2462 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2471 { CA_ARG_UNDEFINED, " " },
2472 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2473 { CA_ARG_ELEMENT_TARGET, "target" },
2474 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2475 { CA_ARG_ELEMENT_ACTION, "action ->" },
2480 static struct ValueTextInfo options_action_arg_speed[] =
2482 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2483 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2484 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2485 { CA_ARG_SPEED_SLOW, "slow" },
2486 { CA_ARG_SPEED_NORMAL, "normal" },
2487 { CA_ARG_SPEED_FAST, "fast" },
2488 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2489 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2490 { CA_ARG_UNDEFINED, " " },
2491 { CA_ARG_SPEED_SLOWER, "slower" },
2492 { CA_ARG_SPEED_FASTER, "faster" },
2493 { CA_ARG_UNDEFINED, " " },
2494 { CA_ARG_SPEED_RESET, "reset" },
2499 static struct ValueTextInfo options_action_arg_shield[] =
2501 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2502 { CA_ARG_SHIELD_OFF, "off" },
2503 { CA_ARG_SHIELD_NORMAL, "normal" },
2504 { CA_ARG_SHIELD_DEADLY, "deadly" },
2509 static struct ValueTextInfo options_action_arg_artwork[] =
2511 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2512 { CA_ARG_ELEMENT_TARGET, "target" },
2513 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2514 { CA_ARG_ELEMENT_ACTION, "action ->" },
2515 { CA_ARG_UNDEFINED, " " },
2516 { CA_ARG_ELEMENT_RESET, "reset" },
2521 static struct ValueTextInfo options_action_arg_gravity[] =
2523 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2524 { CA_ARG_GRAVITY_ON, "on" },
2525 { CA_ARG_GRAVITY_OFF, "off" },
2526 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2531 static struct ValueTextInfo options_action_arg_direction[] =
2533 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2534 { CA_ARG_DIRECTION_NONE, "none" },
2535 { CA_ARG_DIRECTION_LEFT, "left" },
2536 { CA_ARG_DIRECTION_RIGHT, "right" },
2537 { CA_ARG_DIRECTION_UP, "up" },
2538 { CA_ARG_DIRECTION_DOWN, "down" },
2539 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2540 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2545 static struct ValueTextInfo options_action_arg_scan_mode[] =
2547 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2548 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2549 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2554 static struct ValueTextInfo options_action_arg_inventory[] =
2556 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2557 { CA_ARG_ELEMENT_TARGET, "+ target" },
2558 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2559 { CA_ARG_ELEMENT_ACTION, "+ action" },
2560 { CA_ARG_UNDEFINED, " " },
2561 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2562 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2563 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2564 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2565 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2566 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2567 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2568 { CA_ARG_UNDEFINED, " " },
2569 { CA_ARG_INVENTORY_RESET, "reset" },
2574 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2575 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2580 static struct ValueTextInfo options_group_choice_mode[] =
2582 { ANIM_RANDOM, "random" },
2583 { ANIM_LOOP, "loop" },
2584 { ANIM_LINEAR, "linear" },
2585 { ANIM_PINGPONG, "pingpong" },
2586 { ANIM_PINGPONG2, "pingpong 2" },
2587 { ANIM_LEVEL_NR, "level number" },
2592 static struct ValueTextInfo options_bd_scheduling_type[] =
2594 { GD_SCHEDULING_MILLISECONDS, "Milliseconds" },
2595 { GD_SCHEDULING_BD1, "BD1" },
2596 { GD_SCHEDULING_BD2, "BD2" },
2597 { GD_SCHEDULING_PLCK, "Construction Kit" },
2598 { GD_SCHEDULING_CRDR, "Crazy Dream 7" },
2599 { GD_SCHEDULING_BD1_ATARI, "Atari BD1" },
2600 { GD_SCHEDULING_BD2_PLCK_ATARI, "Atari BD2 / PLCK" },
2605 static struct ValueTextInfo *action_arg_modes[] =
2607 options_action_mode_none,
2608 options_action_mode_assign,
2609 options_action_mode_add_remove,
2610 options_action_mode_calculate,
2617 struct ValueTextInfo *options;
2619 action_arg_options[] =
2621 { CA_NO_ACTION, 0, options_action_arg_none, },
2622 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2623 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2624 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2625 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2626 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2627 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2628 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2629 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2630 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2631 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2632 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2633 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2634 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2635 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2636 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2637 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2638 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2639 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2640 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2641 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2642 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2652 int gadget_id_align;
2653 int size; // char size of selectbox or '-1' (dynamically determined)
2654 struct ValueTextInfo *options;
2656 char *text_above, *text_left, *text_right, *infotext;
2657 } selectbox_info[ED_NUM_SELECTBOX] =
2659 // ---------- level and editor settings -------------------------------------
2662 ED_SELECTBOX_ID_TIME_OR_STEPS,
2663 -1, ED_LEVEL_SETTINGS_YPOS(8),
2664 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2666 options_time_or_steps,
2667 &level.use_step_counter,
2668 NULL, NULL, "(0 => no limit)", "time or step limit"
2671 ED_SELECTBOX_ID_TIME_SCORE_BASE,
2672 -1, ED_LEVEL_SETTINGS_YPOS(10),
2673 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2675 options_time_score_base,
2676 &level.time_score_base,
2677 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2680 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
2681 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2682 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2684 options_game_engine_type,
2685 &level.game_engine_type,
2686 NULL, "game engine:", NULL, "game engine"
2689 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
2690 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2691 GADGET_ID_BD_SCHEDULING_TYPE, GADGET_ID_NONE,
2693 options_bd_scheduling_type,
2694 &level.bd_scheduling_type,
2695 NULL, "scheduling type:", NULL, "level timing"
2698 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
2699 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2700 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2702 options_levelset_save_mode,
2703 &levelset_save_mode,
2704 "Action:", NULL, NULL, "action when saving level set"
2707 // ---------- element settings: configure (several elements) ----------------
2710 ED_SELECTBOX_ID_WIND_DIRECTION,
2711 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2712 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2714 options_wind_direction,
2715 &level.wind_direction_initial,
2716 NULL, "initial wind direction:", NULL, "initial wind direction"
2719 ED_SELECTBOX_ID_PLAYER_SPEED,
2720 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2721 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2723 options_player_speed,
2724 &level.initial_player_stepsize[0],
2725 NULL, "initial player speed:", NULL, "initial player speed"
2728 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
2729 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2730 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2732 options_group_choice_mode,
2733 &level.mm_ball_choice_mode,
2734 NULL, "choice type:", NULL, "type of content choice"
2737 // ---------- element settings: configure 1 (custom elements) ---------------
2740 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
2741 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2742 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2744 options_access_type,
2745 &custom_element.access_type,
2746 NULL, NULL, NULL, "type of access to this field"
2749 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
2750 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2751 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2753 options_access_layer,
2754 &custom_element.access_layer,
2755 NULL, NULL, NULL, "layer of access for this field"
2758 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
2759 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2760 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2762 options_access_protected,
2763 &custom_element.access_protected,
2764 NULL, NULL, NULL, "protected access for this field"
2767 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
2768 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2769 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2771 options_access_direction,
2772 &custom_element.access_direction,
2773 NULL, "from", NULL, "access direction for this field"
2776 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
2777 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2778 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2780 options_walk_to_action,
2781 &custom_element.walk_to_action,
2782 NULL, NULL, NULL, "diggable/collectible/pushable"
2785 // ---------- element settings: configure 2 (custom elements) ---------------
2788 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
2789 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2790 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2792 options_move_pattern,
2793 &custom_element.move_pattern,
2794 NULL, "can move", NULL, "element move pattern"
2797 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
2798 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2799 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2801 options_move_direction,
2802 &custom_element.move_direction_initial,
2803 NULL, "starts moving", NULL, "initial element move direction"
2806 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
2807 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2808 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2810 options_move_stepsize,
2811 &custom_element.move_stepsize,
2812 NULL, "move/fall speed", NULL, "speed of element movement"
2815 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
2816 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2817 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2819 options_move_leave_type,
2820 &custom_element.move_leave_type,
2821 // left text with leading spaces to place gadget next to "can dig" gadget
2822 // (needed because drawing area gadgets created after selectbox gadgets)
2823 // NULL, "can dig: can", ":", "leave behind or change element"
2824 NULL, " can", ":", "leave behind or change element"
2827 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
2828 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2829 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2831 options_smash_targets,
2832 &custom_element.smash_targets,
2833 NULL, "can smash", NULL, "elements that can be smashed"
2836 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
2837 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2838 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2840 options_slippery_type,
2841 &custom_element.slippery_type,
2842 NULL, "slippery", NULL, "where other elements fall down"
2845 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
2846 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2847 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2850 &custom_element.deadliness,
2851 NULL, "deadly when", NULL, "deadliness of element"
2854 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
2855 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2856 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2858 options_explosion_type,
2859 &custom_element.explosion_type,
2860 NULL, "can explode", NULL, "explosion type"
2863 // ---------- element settings: advanced (custom elements) ------------------
2866 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
2867 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2868 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2871 &custom_element_change.delay_frames,
2872 NULL, "delay time given in", NULL, "delay time units for change"
2875 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
2876 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2877 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2879 options_change_direct_action,
2880 &custom_element_change.direct_action,
2881 NULL, NULL, NULL, "type of direct action"
2884 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
2885 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2886 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2888 options_change_other_action,
2889 &custom_element_change.other_action,
2890 NULL, NULL, "element:", "type of other element action"
2893 ED_SELECTBOX_ID_CHANGE_SIDE,
2894 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2895 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2897 options_change_trigger_side,
2898 &custom_element_change.trigger_side,
2899 NULL, "at", "side", "element side triggering change"
2902 ED_SELECTBOX_ID_CHANGE_PLAYER,
2903 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2904 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2906 options_change_trigger_player,
2907 &custom_element_change.trigger_player,
2908 NULL, "player:", " ", "player that causes change"
2911 ED_SELECTBOX_ID_CHANGE_PAGE,
2912 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2913 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2915 options_change_trigger_page,
2916 &custom_element_change.trigger_page,
2917 NULL, "page:", NULL, "change page that causes change"
2920 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
2921 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2922 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2924 options_change_replace_when,
2925 &custom_element_change.replace_when,
2926 NULL, "replace when", NULL, "which elements can be replaced"
2929 ED_SELECTBOX_ID_ACTION_TYPE,
2930 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2931 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2933 options_action_type,
2934 &custom_element_change.action_type,
2935 NULL, NULL, NULL, "action on specified condition"
2938 ED_SELECTBOX_ID_ACTION_MODE,
2939 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2940 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2942 options_action_mode_none,
2943 &custom_element_change.action_mode,
2944 NULL, NULL, NULL, "action operator"
2947 ED_SELECTBOX_ID_ACTION_ARG,
2948 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2949 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2951 options_action_arg_none,
2952 &custom_element_change.action_arg,
2953 NULL, NULL, NULL, "action parameter"
2956 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
2957 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2958 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2960 options_change_page,
2961 &custom_element.current_change_page,
2962 NULL, NULL, NULL, "element change page"
2965 // ---------- element settings: configure (group elements) ------------------
2968 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
2969 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2970 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2972 options_group_choice_mode,
2973 &group_element_info.choice_mode,
2974 NULL, "choice type:", NULL, "type of group element choice"
2983 int gadget_id_align;
2986 char *text_above, *text_left, *text_right, *infotext;
2987 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2989 // ---------- level and editor settings (tabs) ------------------------------
2992 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
2993 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2994 GADGET_ID_LEVELCONFIG_LEVEL, GADGET_ID_NONE,
2996 NULL, NULL, NULL, "Configure level settings"
2999 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
3001 GADGET_ID_LEVELCONFIG_LEVELSET, GADGET_ID_LEVELCONFIG_LEVEL,
3003 NULL, NULL, NULL, "Update this or create new level set"
3006 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
3008 GADGET_ID_LEVELCONFIG_EDITOR, GADGET_ID_LEVELCONFIG_LEVELSET,
3010 NULL, NULL, NULL, "Configure editor settings"
3013 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
3015 GADGET_ID_LEVELCONFIG_ENGINE, GADGET_ID_LEVELCONFIG_EDITOR,
3017 NULL, NULL, NULL, "Configure engine settings"
3020 // ---------- element settings (tabs) ---------------------------------------
3023 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
3024 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
3025 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
3027 NULL, NULL, NULL, "Show information about element"
3030 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
3032 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
3034 NULL, NULL, NULL, "Configure element properties"
3037 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
3039 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
3041 NULL, NULL, NULL, "Configure element properties, part 1"
3044 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
3046 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
3048 NULL, NULL, NULL, "Configure element properties, part 2"
3051 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
3053 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
3055 NULL, NULL, NULL, "Configure custom element change pages"
3058 // ---------- level and editor settings (buttons) ---------------------------
3061 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
3062 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
3063 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
3065 NULL, NULL, NULL, "Update or create level set"
3068 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
3069 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3070 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
3072 NULL, NULL, "this level as level template",
3073 "Save current settings as new template"
3076 // ---------- element settings (buttons) ------------------------------------
3079 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
3081 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
3083 NULL, " ", "As Template",
3084 "Save current settings as new template"
3087 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
3089 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
3091 NULL, NULL, NULL, "Add new change page"
3094 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
3096 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
3098 NULL, NULL, NULL, "Delete current change page"
3108 int gadget_id_align;
3109 char *text_left, *text_right, *infotext;
3110 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
3113 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
3114 IMG_EDITOR_COUNTER_DOWN,
3115 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3116 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
3117 NULL, NULL, "select previous change page"
3120 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
3121 IMG_EDITOR_COUNTER_UP,
3122 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3123 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
3124 NULL, "change page", "select next change page"
3127 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
3128 IMG_GFX_EDITOR_BUTTON_CP_COPY,
3129 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3130 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
3131 " ", NULL, "copy settings from this change page"
3134 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
3135 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
3136 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3137 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
3138 NULL, NULL, "paste settings to this change page"
3145 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
3153 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
3156 ED_SCROLLBUTTON_ID_AREA_UP,
3157 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
3158 GADGET_ID_SCROLL_UP,
3159 "scroll level editing area up"
3162 ED_SCROLLBUTTON_ID_AREA_DOWN,
3163 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
3164 GADGET_ID_SCROLL_DOWN,
3165 "scroll level editing area down"
3168 ED_SCROLLBUTTON_ID_AREA_LEFT,
3169 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
3170 GADGET_ID_SCROLL_LEFT,
3171 "scroll level editing area left"
3174 ED_SCROLLBUTTON_ID_AREA_RIGHT,
3175 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
3176 GADGET_ID_SCROLL_RIGHT,
3177 "scroll level editing area right"
3180 ED_SCROLLBUTTON_ID_LIST_UP,
3181 IMG_EDITOR_PALETTE_SCROLL_UP,
3182 GADGET_ID_SCROLL_LIST_UP,
3183 "scroll element list up ('Page Up')"
3186 ED_SCROLLBUTTON_ID_LIST_DOWN,
3187 IMG_EDITOR_PALETTE_SCROLL_DOWN,
3188 GADGET_ID_SCROLL_LIST_DOWN,
3189 "scroll element list down ('Page Down')"
3197 int wheel_x, wheel_y;
3198 int wheel_width, wheel_height;
3199 } scrollbar_pos[ED_NUM_SCROLLBARS];
3208 } scrollbar_info[ED_NUM_SCROLLBARS] =
3211 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
3212 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3213 GD_TYPE_SCROLLBAR_HORIZONTAL,
3214 GADGET_ID_SCROLL_HORIZONTAL,
3215 "scroll level editing area horizontally"
3218 ED_SCROLLBAR_ID_AREA_VERTICAL,
3219 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3220 GD_TYPE_SCROLLBAR_VERTICAL,
3221 GADGET_ID_SCROLL_VERTICAL,
3222 "scroll level editing area vertically"
3225 ED_SCROLLBAR_ID_LIST_VERTICAL,
3226 IMG_EDITOR_PALETTE_SCROLLBAR,
3227 GD_TYPE_SCROLLBAR_VERTICAL,
3228 GADGET_ID_SCROLL_LIST_VERTICAL,
3229 "scroll element list vertically"
3239 int gadget_id_align;
3240 int radio_button_nr;
3243 char *text_left, *text_right, *infotext;
3244 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3247 ED_RADIOBUTTON_ID_PERCENTAGE,
3248 -1, ED_LEVEL_SETTINGS_YPOS(0),
3249 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3250 RADIO_NR_RANDOM_ELEMENTS,
3251 &random_placement_method, RANDOM_USE_PERCENTAGE,
3252 " ", "percentage", "use percentage for random elements"
3255 ED_RADIOBUTTON_ID_QUANTITY,
3256 -1, ED_LEVEL_SETTINGS_YPOS(0),
3257 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3258 RADIO_NR_RANDOM_ELEMENTS,
3259 &random_placement_method, RANDOM_USE_QUANTITY,
3260 " ", "quantity", "use quantity for random elements"
3269 int gadget_id_align;
3271 char *text_above, *text_left, *text_right, *infotext;
3272 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3274 // ---------- level and editor settings -------------------------------------
3277 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
3278 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3279 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3280 &level.auto_count_gems,
3282 "automatically count gems needed", "set counter to number of gems"
3285 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
3286 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3287 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3288 &level.rate_time_over_score,
3290 "rate time/steps used over score", "sort high scores by playing time/steps"
3293 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
3294 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3295 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3296 &levelset_use_levelset_artwork,
3298 "use current custom artwork", "use custom artwork of this level set"
3301 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
3302 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3303 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3304 &levelset_copy_level_template,
3306 "copy current level template", "copy level template of this level set"
3309 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
3310 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3311 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3312 &random_placement_background_restricted,
3314 "restrict random placement to:", "set random placement restriction"
3317 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
3318 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3319 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3320 &setup.editor.use_template_for_new_levels,
3321 "Template for new levels and CE/GE:", NULL,
3322 "use template for new levels", "use template for level properties"
3325 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
3326 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3327 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3328 &level.use_custom_template,
3330 "use template for custom elements", "use template for custom properties"
3333 ED_CHECKBUTTON_ID_BD_INTERMISSION,
3334 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
3335 GADGET_ID_BD_INTERMISSION, GADGET_ID_NONE,
3336 &level.bd_intermission,
3337 "Boulder Dash game engine settings:", NULL,
3338 "intermission", "level is an intermission level"
3341 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
3342 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
3343 GADGET_ID_BD_PAL_TIMING, GADGET_ID_NONE,
3344 &level.bd_pal_timing,
3346 "PAL timing", "use slower timer (like PAL C64)"
3349 ED_CHECKBUTTON_ID_BD_LINE_SHIFTING_BORDERS,
3350 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3351 GADGET_ID_BD_LINE_SHIFTING_BORDERS, GADGET_ID_NONE,
3352 &level.bd_line_shifting_borders,
3353 "Compatibility settings:", NULL,
3354 "line-shifting borders", "use line-shifting wrap-around"
3357 // ---------- element settings: configure (various elements) ----------------
3360 ED_CHECKBUTTON_ID_STICK_ELEMENT,
3361 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3362 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3363 &stick_element_properties_window,
3365 "stick this screen to edit content","stick this screen to edit content"
3368 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
3369 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3370 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3371 &level.em_slippery_gems,
3373 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3376 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
3377 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3378 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3379 &level.em_explodes_by_fire,
3381 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3384 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
3385 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3386 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3387 &level.use_spring_bug,
3389 "use spring pushing bug", "use odd spring pushing behaviour"
3392 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
3393 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3394 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3395 &level.use_time_orb_bug,
3397 "use time orb bug", "use odd time orb behaviour"
3400 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
3401 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3402 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3403 &level.use_life_bugs,
3405 "use buggy element behaviour", "use odd (historic) element behaviour"
3408 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
3409 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3410 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3413 "create single random element", "only create one element from content"
3416 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
3417 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3418 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3419 &level.ball_active_initial,
3421 "magic ball initially activated", "activate magic ball after level start"
3424 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
3425 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3426 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3427 &level.grow_into_diggable,
3429 "can grow into anything diggable", "grow into more than just sand"
3432 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
3433 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3434 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3435 &level.sb_fields_needed,
3437 "all fields need to be filled", "require all SB fields to be solved"
3440 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
3441 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3442 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3443 &level.sb_objects_needed,
3445 "all objects need to be placed", "require all SB objects to be solved"
3448 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
3449 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3450 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3451 &level.auto_exit_sokoban,
3453 "exit level if all tasks solved", "automatically finish Sokoban levels"
3456 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
3457 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3458 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3459 &level.solved_by_one_player,
3461 "only one player must enter exit", "level solved by first player in exit"
3464 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
3465 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3466 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3467 &level.finish_dig_collect,
3469 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3472 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
3473 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3474 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3475 &level.keep_walkable_ce,
3477 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3480 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
3481 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3482 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3483 &level.continuous_snapping,
3485 "continuous snapping", "use snapping without releasing key"
3488 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
3489 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3490 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3491 &level.block_snap_field,
3493 "block snapped field when snapping", "use snapping delay to show animation"
3496 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
3497 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3498 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3499 &level.block_last_field,
3501 "block last field when moving", "player blocks last field when moving"
3504 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
3505 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3506 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3507 &level.sp_block_last_field,
3509 "block last field when moving", "player blocks last field when moving"
3512 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
3513 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3514 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3515 &level.instant_relocation,
3517 "no scrolling when relocating", "player gets relocated without delay"
3520 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
3521 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3522 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3523 &level.shifted_relocation,
3525 "no centering when relocating", "level not centered after relocation"
3528 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
3529 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3530 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3531 &level.lazy_relocation,
3533 "only redraw off-screen relocation","no redraw if relocation target visible"
3536 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
3537 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3538 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3539 &level.use_start_element[0],
3541 "use level start element:", "start level at this element's position"
3544 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
3545 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3546 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3547 &level.use_artwork_element[0],
3549 "use artwork from element:", "use player artwork from other element"
3552 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
3553 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3554 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3555 &level.use_explosion_element[0],
3557 "use explosion from element:", "use explosion properties from element"
3560 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
3561 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3562 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3563 &level.initial_player_gravity[0],
3565 "use initial gravity", "set initial player gravity"
3568 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
3569 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3570 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3571 &level.use_initial_inventory[0],
3573 "use initial inventory:", "use collected elements on level start"
3576 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
3577 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3578 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3579 &level.can_pass_to_walkable,
3581 "can pass to walkable element", "player can pass to empty or walkable"
3584 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
3585 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3586 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3587 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3589 "can fall into acid (with gravity)","player can fall into acid pool"
3592 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
3593 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3594 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3595 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3597 "can move into acid", "element can move into acid pool"
3600 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
3601 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3602 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3603 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3605 "deadly when colliding with", "element is deadly when hitting player"
3608 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
3609 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3610 GADGET_ID_BD_DIAGONAL_MOVEMENTS, GADGET_ID_NONE,
3611 &level.bd_diagonal_movements,
3613 "can move diagonally", "player can move diagonally"
3616 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
3617 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3618 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3619 &level.envelope[0].autowrap,
3621 "auto-wrap", "automatically wrap envelope text"
3624 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
3625 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3626 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3627 &level.envelope[0].centered,
3629 "centered", "automatically center envelope text"
3632 ED_CHECKBUTTON_ID_MM_LASER_RED,
3633 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3634 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3635 &level.mm_laser_red,
3636 "choose color components for laser:", NULL,
3637 "red", "use red color components in laser"
3640 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
3641 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3642 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3643 &level.mm_laser_green,
3645 "green", "use green color components in laser"
3648 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
3649 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3650 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3651 &level.mm_laser_blue,
3653 "blue", "use blue color components in laser"
3656 ED_CHECKBUTTON_ID_DF_LASER_RED,
3657 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3658 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3659 &level.df_laser_red,
3660 "choose color components for laser:", NULL,
3661 "red", "use red color components in laser"
3664 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
3665 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3666 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3667 &level.df_laser_green,
3669 "green", "use green color components in laser"
3672 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
3673 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3674 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3675 &level.df_laser_blue,
3677 "blue", "use blue color components in laser"
3680 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
3681 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3682 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3683 &level.rotate_mm_ball_content,
3685 "randomly rotate created content", "randomly rotate newly created content"
3688 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
3689 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3690 GADGET_ID_EXPLODE_MM_BALL, GADGET_ID_NONE,
3691 &level.explode_mm_ball,
3693 "explode ball instead of melting", "use explosion to release ball content"
3696 // ---------- element settings: configure 1 (custom elements) ---------------
3699 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
3700 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3701 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3702 &custom_element.use_gfx_element,
3704 "use graphic of element:", "use existing element graphic"
3707 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
3708 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3709 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3710 &level.use_custom_template,
3712 "use template", "use template for custom properties"
3715 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
3716 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3717 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3718 &custom_element_properties[EP_ACCESSIBLE],
3720 NULL, "player can walk to or pass this field"
3723 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
3724 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3725 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3726 &custom_element_properties[EP_GRAVITY_REACHABLE],
3728 "reachable despite gravity", "player can walk/dig despite gravity"
3731 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
3732 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3733 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3734 &custom_element.use_last_ce_value,
3736 "use last CE value after change", "use last CE value after change"
3739 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
3740 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3741 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3742 &custom_element_properties[EP_WALK_TO_OBJECT],
3744 NULL, "player can dig/collect/push element"
3747 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
3748 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3749 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3750 &custom_element_properties[EP_INDESTRUCTIBLE],
3752 "indestructible", "element is indestructible"
3755 // ---------- element settings: configure 2 (custom elements) ---------------
3758 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
3759 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3760 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3761 &custom_element_properties[EP_CAN_MOVE],
3763 NULL, "element can move with some pattern"
3766 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
3767 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3768 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3769 &custom_element_properties[EP_CAN_FALL],
3771 "can fall", "element can fall down"
3774 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
3775 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3776 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3777 &custom_element_properties[EP_CAN_SMASH],
3779 NULL, "element can smash other elements"
3782 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
3783 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3784 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3785 &custom_element_properties[EP_SLIPPERY],
3787 NULL, "other elements can fall down from it"
3790 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
3791 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3792 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3793 &custom_element_properties[EP_DEADLY],
3795 NULL, "element can kill the player"
3798 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
3799 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3800 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3801 &custom_element_properties[EP_CAN_EXPLODE],
3803 NULL, "element can explode"
3806 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
3807 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3808 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3809 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3811 "by fire", "element can explode by fire/explosion"
3814 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
3815 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3816 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3817 &custom_element_properties[EP_EXPLODES_SMASHED],
3819 "smashed", "element can explode when smashed"
3822 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
3823 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3824 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3825 &custom_element_properties[EP_EXPLODES_IMPACT],
3827 "impact", "element can explode on impact"
3830 // ---------- element settings: advanced (custom elements) ------------------
3833 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
3834 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3835 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3836 &custom_element_change.can_change,
3838 "element changes to:", "change element on specified condition"
3841 ED_CHECKBUTTON_ID_CHANGE_DELAY,
3842 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3843 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3844 &custom_element_change_events[CE_DELAY],
3846 NULL, "element changes after delay"
3849 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
3850 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3851 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3852 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3854 NULL, "element changes by direct action"
3857 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
3858 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3859 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3860 &custom_element_change_events[CE_BY_OTHER_ACTION],
3862 NULL, "element changes by other element"
3865 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
3866 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3867 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3868 &custom_element_change.explode,
3870 "explode instead of change", "element explodes instead of change"
3873 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
3874 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3875 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3876 &custom_element_change.use_target_content,
3878 "use extended change target:", "element changes to more elements"
3881 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
3882 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3883 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3884 &custom_element_change.only_if_complete,
3886 "replace all or nothing", "only replace when all can be changed"
3889 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
3890 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3891 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3892 &custom_element_change.use_random_replace,
3894 NULL, "use percentage for random replace"
3897 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
3898 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3899 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3900 &custom_element_change.has_action,
3902 NULL, "execute action on specified condition"
3910 int xoffset, yoffset;
3912 int gadget_id_align;
3914 int area_xsize, area_ysize;
3915 char *text_left, *text_right, *text_above, *text_below, *infotext;
3916 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3918 // ---------- level playfield content ---------------------------------------
3921 ED_DRAWING_ID_DRAWING_LEVEL,
3924 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3926 -1, -1, // these values are not constant, but can change at runtime
3927 NULL, NULL, NULL, NULL, NULL
3930 // ---------- yam yam content -----------------------------------------------
3933 ED_DRAWING_ID_YAMYAM_CONTENT_0,
3934 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3935 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3936 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3937 &level.yamyam_content[0].e[0][0], 3, 3,
3938 NULL, NULL, NULL, "1", NULL
3941 ED_DRAWING_ID_YAMYAM_CONTENT_1,
3942 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3943 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3944 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3945 &level.yamyam_content[1].e[0][0], 3, 3,
3946 NULL, NULL, NULL, "2", NULL
3949 ED_DRAWING_ID_YAMYAM_CONTENT_2,
3950 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3951 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3952 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3953 &level.yamyam_content[2].e[0][0], 3, 3,
3954 NULL, NULL, NULL, "3", NULL
3957 ED_DRAWING_ID_YAMYAM_CONTENT_3,
3958 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3959 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3960 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3961 &level.yamyam_content[3].e[0][0], 3, 3,
3962 NULL, NULL, NULL, "4", NULL
3965 ED_DRAWING_ID_YAMYAM_CONTENT_4,
3966 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3967 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3968 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3969 &level.yamyam_content[4].e[0][0], 3, 3,
3970 NULL, NULL, NULL, "5", NULL
3973 ED_DRAWING_ID_YAMYAM_CONTENT_5,
3974 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3975 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3976 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3977 &level.yamyam_content[5].e[0][0], 3, 3,
3978 NULL, NULL, NULL, "6", NULL
3981 ED_DRAWING_ID_YAMYAM_CONTENT_6,
3982 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3983 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3984 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3985 &level.yamyam_content[6].e[0][0], 3, 3,
3986 NULL, NULL, NULL, "7", NULL
3989 ED_DRAWING_ID_YAMYAM_CONTENT_7,
3990 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3991 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3992 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3993 &level.yamyam_content[7].e[0][0], 3, 3,
3994 NULL, NULL, NULL, "8", NULL
3997 // ---------- magic ball content --------------------------------------------
4000 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
4001 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4002 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
4003 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
4004 &level.ball_content[0].e[0][0], 3, 3,
4005 NULL, NULL, NULL, "1", NULL
4008 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
4009 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4010 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
4011 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
4012 &level.ball_content[1].e[0][0], 3, 3,
4013 NULL, NULL, NULL, "2", NULL
4016 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
4017 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4018 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
4019 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
4020 &level.ball_content[2].e[0][0], 3, 3,
4021 NULL, NULL, NULL, "3", NULL
4024 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
4025 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4026 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
4027 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
4028 &level.ball_content[3].e[0][0], 3, 3,
4029 NULL, NULL, NULL, "4", NULL
4032 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
4033 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4034 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
4035 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
4036 &level.ball_content[4].e[0][0], 3, 3,
4037 NULL, NULL, NULL, "5", NULL
4040 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
4041 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4042 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
4043 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
4044 &level.ball_content[5].e[0][0], 3, 3,
4045 NULL, NULL, NULL, "6", NULL
4048 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
4049 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4050 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
4051 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
4052 &level.ball_content[6].e[0][0], 3, 3,
4053 NULL, NULL, NULL, "7", NULL
4056 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
4057 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4058 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
4059 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
4060 &level.ball_content[7].e[0][0], 3, 3,
4061 NULL, NULL, NULL, "8", NULL
4064 // ---------- android content -----------------------------------------------
4067 ED_DRAWING_ID_ANDROID_CONTENT,
4068 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
4069 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4070 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
4071 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
4072 NULL, NULL, "elements:", NULL, "elements android can clone"
4075 // ---------- amoeba content ------------------------------------------------
4078 ED_DRAWING_ID_AMOEBA_CONTENT,
4079 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
4080 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4081 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
4082 &level.amoeba_content, 1, 1,
4083 "content:", NULL, NULL, NULL, "amoeba content"
4086 // ---------- level start element -------------------------------------------
4089 ED_DRAWING_ID_START_ELEMENT,
4090 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
4091 0, ED_AREA_1X1_SETTINGS_YOFF,
4092 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
4093 &level.start_element[0], 1, 1,
4094 NULL, NULL, NULL, NULL, "level start element"
4097 // ---------- player artwork element ----------------------------------------
4100 ED_DRAWING_ID_ARTWORK_ELEMENT,
4101 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
4102 0, ED_AREA_1X1_SETTINGS_YOFF,
4103 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
4104 &level.artwork_element[0], 1, 1,
4105 NULL, NULL, NULL, NULL, "element for player artwork"
4108 // ---------- player explosion element --------------------------------------
4111 ED_DRAWING_ID_EXPLOSION_ELEMENT,
4112 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
4113 0, ED_AREA_1X1_SETTINGS_YOFF,
4114 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
4115 &level.explosion_element[0], 1, 1,
4116 NULL, NULL, NULL, NULL, "element for player explosion"
4119 // ---------- player initial inventory --------------------------------------
4122 ED_DRAWING_ID_INVENTORY_CONTENT,
4123 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4124 0, ED_AREA_1X1_SETTINGS_YOFF,
4125 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
4126 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
4127 NULL, NULL, NULL, NULL, "content for initial inventory"
4130 // ---------- gray ball content -----------------------------------------
4133 ED_DRAWING_ID_MM_BALL_CONTENT,
4134 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4135 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4136 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
4137 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
4138 "content:", NULL, NULL, NULL, "content for gray ball"
4141 // ---------- element settings: configure 1 (custom elements) ---------------
4143 // ---------- custom graphic ------------------------------------------------
4146 ED_DRAWING_ID_CUSTOM_GRAPHIC,
4147 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4148 0, ED_AREA_1X1_SETTINGS_YOFF,
4149 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
4150 &custom_element.gfx_element_initial, 1, 1,
4151 NULL, NULL, NULL, NULL, "custom graphic element"
4154 // ---------- element settings: configure 2 (custom elements) ---------------
4156 // ---------- custom content (when exploding) -------------------------------
4159 ED_DRAWING_ID_CUSTOM_CONTENT,
4160 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
4161 0, ED_AREA_3X3_SETTINGS_YOFF,
4162 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
4163 &custom_element.content.e[0][0], 3, 3,
4164 "content:", NULL, NULL, NULL, NULL
4167 // ---------- custom enter and leave element (when moving) ------------------
4170 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
4171 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
4172 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4173 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
4174 &custom_element.move_enter_element, 1, 1,
4175 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
4178 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
4179 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
4180 0, ED_AREA_1X1_SETTINGS_YOFF,
4181 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
4182 &custom_element.move_leave_element, 1, 1,
4183 NULL, NULL, NULL, NULL, "element that will be left behind"
4186 // ---------- element settings: advanced (custom elements) ------------------
4188 // ---------- custom change target ------------------------------------------
4191 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
4192 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4193 0, ED_AREA_1X1_SETTINGS_YOFF,
4194 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
4195 &custom_element_change.target_element, 1, 1,
4196 NULL, "after/when:", NULL, NULL, "new target element after change"
4199 // ---------- custom change content (extended change target) ----------------
4202 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
4203 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
4204 0, ED_AREA_3X3_SETTINGS_YOFF,
4205 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
4206 &custom_element_change.target_content.e[0][0], 3, 3,
4207 NULL, NULL, NULL, NULL, "new extended elements after change"
4210 // ---------- custom change trigger (element causing change) ----------------
4213 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
4214 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
4215 0, ED_AREA_1X1_SETTINGS_YOFF,
4216 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
4217 &custom_element_change.initial_trigger_element, 1, 1,
4218 NULL, NULL, NULL, NULL, "other element triggering change"
4221 // ---------- custom change action (element used for action) ----------------
4224 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
4225 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
4226 0, ED_AREA_1X1_SETTINGS_YOFF,
4227 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
4228 &custom_element_change.action_element, 1, 1,
4229 NULL, NULL, NULL, NULL, "element used as action parameter"
4232 // ---------- group element content -----------------------------------------
4235 ED_DRAWING_ID_GROUP_CONTENT,
4236 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4237 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4238 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
4239 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
4240 "content:", NULL, NULL, NULL, NULL
4243 // ---------- random background (for random painting) -----------------------
4246 ED_DRAWING_ID_RANDOM_BACKGROUND,
4247 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
4248 0, ED_AREA_1X1_LSETTINGS_YOFF,
4249 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
4250 &random_placement_background_element, 1, 1,
4251 NULL, NULL, NULL, NULL, "random placement background"
4256 // ----------------------------------------------------------------------------
4257 // some internally used variables
4258 // ----------------------------------------------------------------------------
4260 // maximal size of level editor drawing area
4261 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
4263 // actual size of level editor drawing area
4264 static int ed_fieldx, ed_fieldy;
4266 // actual position of level editor drawing area in level playfield
4267 static int level_xpos = -1, level_ypos = -1;
4269 // actual tile size used to display playfield drawing area
4270 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
4271 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
4273 #define IN_ED_FIELD(x, y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
4275 // drawing elements on the three mouse buttons
4276 static int new_element1 = EL_WALL;
4277 static int new_element2 = EL_EMPTY;
4278 static int new_element3 = EL_SAND;
4280 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
4281 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
4282 (button) == 2 ? new_element2 : \
4283 (button) == 3 ? new_element3 : EL_EMPTY)
4285 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
4287 static int use_permanent_palette = TRUE;
4289 #define PX (use_permanent_palette ? DX : SX)
4290 #define PY (use_permanent_palette ? DY : SY)
4291 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
4292 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
4294 // forward declaration for internal use
4295 static void CopyBrushToCursor(int, int);
4296 static void DeleteBrushFromCursor(void);
4297 static void ModifyEditorCounterValue(int, int);
4298 static void ModifyEditorCounterLimits(int, int, int);
4299 static void ModifyEditorSelectboxValue(int, int);
4300 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
4301 static void ModifyEditorDrawingArea(int, int, int);
4302 static void ModifyEditorElementList(void);
4303 static void AdjustElementListScrollbar(void);
4304 static void RedrawDrawingElements(void);
4305 static void DrawDrawingWindowExt(boolean);
4306 static void DrawDrawingWindow(void);
4307 static void DrawLevelConfigWindow(void);
4308 static void DrawPropertiesWindow(void);
4309 static void DrawPaletteWindow(void);
4310 static void UpdateCustomElementGraphicGadgets(void);
4311 static boolean checkPropertiesConfig(int);
4312 static void SetAutomaticNumberOfGemsNeeded(void);
4313 static void ClearEditorGadgetInfoText(void);
4314 static void CopyLevelToUndoBuffer(int);
4315 static void HandleDrawingAreas(struct GadgetInfo *);
4316 static void HandleCounterButtons(struct GadgetInfo *);
4317 static void HandleTextInputGadgets(struct GadgetInfo *);
4318 static void HandleTextAreaGadgets(struct GadgetInfo *);
4319 static void HandleSelectboxGadgets(struct GadgetInfo *);
4320 static void HandleTextbuttonGadgets(struct GadgetInfo *);
4321 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
4322 static void HandleRadiobuttons(struct GadgetInfo *);
4323 static void HandleCheckbuttons(struct GadgetInfo *);
4324 static void HandleControlButtons(struct GadgetInfo *);
4325 static void HandleDrawingAreaInfo(struct GadgetInfo *);
4326 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
4327 static boolean AskToCopyAndModifyLevelTemplate(void);
4328 static boolean getDrawModeHiRes(void);
4329 static int getTabulatorBarWidth(void);
4330 static int getTabulatorBarHeight(void);
4331 static Pixel getTabulatorBarColor(void);
4332 static int numHiresTiles(int);
4334 static int num_editor_gadgets = 0; // dynamically determined
4336 static struct GadgetInfo **level_editor_gadget = NULL;
4337 static int *right_gadget_border = NULL;
4339 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
4340 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
4341 static boolean draw_with_brush = FALSE;
4342 static int properties_element = 0;
4344 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4345 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4346 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4347 static int undo_buffer_position = 0;
4348 static int undo_buffer_steps = 0;
4349 static int redo_buffer_steps = 0;
4351 static int edit_mode;
4352 static int edit_mode_levelconfig;
4353 static int edit_mode_properties;
4355 static int element_shift = 0;
4357 static int editor_el_players[] =
4364 static int *editor_el_players_ptr = editor_el_players;
4365 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4367 static int editor_hl_boulderdash[] =
4369 EL_INTERNAL_CASCADE_BD_ACTIVE,
4375 static int editor_el_boulderdash[] =
4384 EL_BD_EXPANDABLE_WALL,
4392 EL_BD_BUTTERFLY_LEFT,
4394 EL_BD_BUTTERFLY_RIGHT,
4395 EL_BD_FIREFLY_RIGHT,
4398 EL_BD_BUTTERFLY_DOWN,
4402 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4403 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4404 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4405 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4407 static int editor_hl_boulderdash_native[] =
4409 EL_INTERNAL_CASCADE_BD_NATIVE_ACTIVE,
4415 static int editor_el_boulderdash_native[] =
4432 EL_BD_BUTTERFLY_LEFT,
4434 EL_BD_BUTTERFLY_RIGHT,
4435 EL_BD_FIREFLY_RIGHT,
4438 EL_BD_BUTTERFLY_DOWN,
4443 EL_BD_BUTTERFLY_2_UP,
4447 EL_BD_BUTTERFLY_2_LEFT,
4448 EL_BD_FIREFLY_2_LEFT,
4449 EL_BD_BUTTERFLY_2_RIGHT,
4450 EL_BD_FIREFLY_2_RIGHT,
4453 EL_BD_BUTTERFLY_2_DOWN,
4454 EL_BD_FIREFLY_2_DOWN,
4462 EL_BD_DRAGONFLY_LEFT,
4463 EL_BD_STONEFLY_LEFT,
4464 EL_BD_DRAGONFLY_RIGHT,
4465 EL_BD_STONEFLY_RIGHT,
4468 EL_BD_DRAGONFLY_DOWN,
4469 EL_BD_STONEFLY_DOWN,
4492 EL_BD_SAND_SLOPED_UP_LEFT,
4493 EL_BD_SAND_SLOPED_UP_RIGHT,
4494 EL_BD_WALL_SLOPED_UP_LEFT,
4495 EL_BD_WALL_SLOPED_UP_RIGHT,
4497 EL_BD_SAND_SLOPED_DOWN_LEFT,
4498 EL_BD_SAND_SLOPED_DOWN_RIGHT,
4499 EL_BD_WALL_SLOPED_DOWN_LEFT,
4500 EL_BD_WALL_SLOPED_DOWN_RIGHT,
4502 EL_BD_FLYING_DIAMOND,
4504 EL_BD_STEELWALL_SLOPED_UP_LEFT,
4505 EL_BD_STEELWALL_SLOPED_UP_RIGHT,
4509 EL_BD_STEELWALL_SLOPED_DOWN_LEFT,
4510 EL_BD_STEELWALL_SLOPED_DOWN_RIGHT,
4513 EL_BD_WALL_NON_SLOPED,
4519 EL_BD_INVISIBLE_EXIT_CLOSED,
4520 EL_BD_INVISIBLE_EXIT_OPEN,
4523 EL_BD_STEELWALL_EXPLODABLE,
4524 EL_BD_STEELWALL_DIGGABLE,
4525 EL_BD_WALL_DIGGABLE,
4527 EL_BD_EXPANDABLE_WALL_HORIZONTAL,
4528 EL_BD_EXPANDABLE_WALL_VERTICAL,
4529 EL_BD_EXPANDABLE_WALL_ANY,
4530 EL_BD_CREATURE_SWITCH,
4532 EL_BD_EXPANDABLE_STEELWALL_HORIZONTAL,
4533 EL_BD_EXPANDABLE_STEELWALL_VERTICAL,
4534 EL_BD_EXPANDABLE_STEELWALL_ANY,
4535 EL_BD_EXPANDABLE_WALL_SWITCH_HORIZONTAL,
4537 EL_BD_BITER_SWITCH_1,
4538 EL_BD_REPLICATOR_SWITCH,
4539 EL_BD_CONVEYOR_SWITCH,
4540 EL_BD_CONVEYOR_DIR_SWITCH_RIGHT,
4549 EL_BD_DIAMOND_GLUED,
4552 EL_BD_TRAPPED_DIAMOND,
4572 EL_BD_GRAVITY_SWITCH,
4573 EL_BD_PNEUMATIC_HAMMER,
4580 EL_BD_BLADDER_SPENDER,
4582 EL_BD_CONVEYOR_LEFT,
4583 EL_BD_CONVEYOR_RIGHT,
4598 EL_BD_PLAYER_WITH_BOMB,
4600 EL_BD_PLAYER_STIRRING,
4602 static int *editor_hl_boulderdash_native_ptr = editor_hl_boulderdash_native;
4603 static int *editor_el_boulderdash_native_ptr = editor_el_boulderdash_native;
4604 static int num_editor_hl_boulderdash_native = ARRAY_SIZE(editor_hl_boulderdash_native);
4605 static int num_editor_el_boulderdash_native = ARRAY_SIZE(editor_el_boulderdash_native);
4607 static int editor_hl_emerald_mine[] =
4609 EL_INTERNAL_CASCADE_EM_ACTIVE,
4615 static int editor_el_emerald_mine[] =
4633 EL_EM_DYNAMITE_ACTIVE,
4652 EL_ACID_POOL_TOPLEFT,
4654 EL_ACID_POOL_TOPRIGHT,
4657 EL_ACID_POOL_BOTTOMLEFT,
4658 EL_ACID_POOL_BOTTOM,
4659 EL_ACID_POOL_BOTTOMRIGHT,
4677 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4678 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4679 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4680 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4682 static int editor_hl_emerald_mine_club[] =
4684 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4690 static int editor_el_emerald_mine_club[] =
4717 EL_EMC_WALL_SLIPPERY_1,
4718 EL_EMC_WALL_SLIPPERY_2,
4719 EL_EMC_WALL_SLIPPERY_3,
4720 EL_EMC_WALL_SLIPPERY_4,
4743 EL_EMC_MAGIC_BALL_SWITCH,
4750 EL_EMC_SPRING_BUMPER,
4754 EL_BALLOON_SWITCH_UP,
4755 EL_BALLOON_SWITCH_ANY,
4758 EL_BALLOON_SWITCH_LEFT,
4760 EL_BALLOON_SWITCH_RIGHT,
4764 EL_BALLOON_SWITCH_DOWN,
4765 EL_BALLOON_SWITCH_NONE,
4767 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4768 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4769 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4770 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4772 static int editor_hl_rnd[] =
4774 EL_INTERNAL_CASCADE_RND_ACTIVE,
4780 static int editor_el_rnd[] =
4783 EL_DYNAMITE_ACTIVE, // RND
4817 EL_WALL_EMERALD_YELLOW,
4818 EL_WALL_EMERALD_RED,
4819 EL_WALL_EMERALD_PURPLE,
4837 EL_DYNABOMB_INCREASE_NUMBER,
4838 EL_DYNABOMB_INCREASE_SIZE,
4839 EL_DYNABOMB_INCREASE_POWER,
4859 EL_INVISIBLE_STEELWALL,
4863 EL_EXPANDABLE_WALL_HORIZONTAL,
4864 EL_EXPANDABLE_WALL_VERTICAL,
4865 EL_EXPANDABLE_WALL_ANY,
4867 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4868 static int *editor_el_rnd_ptr = editor_el_rnd;
4869 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4870 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4872 static int editor_hl_sokoban[] =
4874 EL_INTERNAL_CASCADE_SB_ACTIVE,
4880 static int editor_el_sokoban[] =
4883 EL_SOKOBAN_FIELD_EMPTY,
4884 EL_SOKOBAN_FIELD_FULL,
4885 EL_SOKOBAN_FIELD_PLAYER,
4887 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4888 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4889 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4890 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4892 static int editor_hl_supaplex[] =
4894 EL_INTERNAL_CASCADE_SP_ACTIVE,
4900 static int editor_el_supaplex[] =
4918 EL_SP_PORT_HORIZONTAL,
4919 EL_SP_PORT_VERTICAL,
4927 EL_SP_GRAVITY_PORT_LEFT,
4928 EL_SP_GRAVITY_PORT_RIGHT,
4929 EL_SP_GRAVITY_PORT_UP,
4930 EL_SP_GRAVITY_PORT_DOWN,
4932 EL_SP_GRAVITY_ON_PORT_LEFT,
4933 EL_SP_GRAVITY_ON_PORT_RIGHT,
4934 EL_SP_GRAVITY_ON_PORT_UP,
4935 EL_SP_GRAVITY_ON_PORT_DOWN,
4937 EL_SP_GRAVITY_OFF_PORT_LEFT,
4938 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4939 EL_SP_GRAVITY_OFF_PORT_UP,
4940 EL_SP_GRAVITY_OFF_PORT_DOWN,
4942 EL_SP_HARDWARE_GRAY,
4943 EL_SP_HARDWARE_GREEN,
4944 EL_SP_HARDWARE_BLUE,
4947 EL_SP_HARDWARE_BASE_1,
4948 EL_SP_HARDWARE_BASE_2,
4949 EL_SP_HARDWARE_BASE_3,
4950 EL_SP_HARDWARE_BASE_4,
4952 EL_SP_HARDWARE_BASE_5,
4953 EL_SP_HARDWARE_BASE_6,
4954 EL_SP_HARDWARE_YELLOW,
4962 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4963 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4964 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4965 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4967 static int editor_hl_diamond_caves[] =
4969 EL_INTERNAL_CASCADE_DC_ACTIVE,
4975 static int editor_el_diamond_caves[] =
4977 EL_EM_STEEL_EXIT_CLOSED, // DC2
4978 EL_EM_STEEL_EXIT_OPEN, // DC2
4979 EL_WALL_EMERALD, // DC2
4980 EL_WALL_DIAMOND, // DC2
4987 EL_CONVEYOR_BELT_1_LEFT,
4988 EL_CONVEYOR_BELT_1_MIDDLE,
4989 EL_CONVEYOR_BELT_1_RIGHT,
4990 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4992 EL_CONVEYOR_BELT_2_LEFT,
4993 EL_CONVEYOR_BELT_2_MIDDLE,
4994 EL_CONVEYOR_BELT_2_RIGHT,
4995 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4997 EL_CONVEYOR_BELT_3_LEFT,
4998 EL_CONVEYOR_BELT_3_MIDDLE,
4999 EL_CONVEYOR_BELT_3_RIGHT,
5000 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
5002 EL_CONVEYOR_BELT_4_LEFT,
5003 EL_CONVEYOR_BELT_4_MIDDLE,
5004 EL_CONVEYOR_BELT_4_RIGHT,
5005 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
5007 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
5008 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
5009 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
5010 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
5012 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
5013 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
5014 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
5015 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
5020 EL_DC_TIMEGATE_SWITCH,
5022 EL_SWITCHGATE_CLOSED,
5024 EL_SWITCHGATE_SWITCH_UP,
5025 EL_SWITCHGATE_SWITCH_DOWN,
5028 EL_LIGHT_SWITCH_ACTIVE,
5029 EL_DC_SWITCHGATE_SWITCH_UP,
5030 EL_DC_SWITCHGATE_SWITCH_DOWN,
5032 EL_STEEL_EXIT_CLOSED,
5034 EL_STEELWALL_SLIPPERY,
5037 EL_QUICKSAND_FAST_EMPTY,
5038 EL_QUICKSAND_FAST_FULL,
5052 EL_SIGN_RADIOACTIVITY,
5058 EL_SIGN_ENTRY_FORBIDDEN,
5059 EL_SIGN_EMERGENCY_EXIT,
5084 EL_DC_STEELWALL_2_SINGLE,
5085 EL_DC_STEELWALL_2_TOP,
5086 EL_SIGN_EXCLAMATION,
5089 EL_DC_STEELWALL_2_LEFT,
5090 EL_DC_STEELWALL_2_MIDDLE,
5091 EL_DC_STEELWALL_2_HORIZONTAL,
5092 EL_DC_STEELWALL_2_RIGHT,
5094 EL_DC_STEELWALL_1_TOPLEFT,
5095 EL_DC_STEELWALL_2_VERTICAL,
5096 EL_DC_STEELWALL_1_TOPRIGHT,
5099 EL_DC_STEELWALL_1_VERTICAL,
5100 EL_DC_STEELWALL_2_BOTTOM,
5102 EL_DC_GATE_WHITE_GRAY,
5104 EL_DC_STEELWALL_1_BOTTOMLEFT,
5105 EL_DC_STEELWALL_1_HORIZONTAL,
5106 EL_DC_STEELWALL_1_BOTTOMRIGHT,
5107 EL_DC_GATE_FAKE_GRAY,
5109 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
5110 EL_DC_STEELWALL_1_BOTTOM,
5111 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
5112 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
5114 EL_DC_STEELWALL_1_RIGHT,
5116 EL_DC_STEELWALL_1_LEFT,
5117 EL_EXPANDABLE_STEELWALL_VERTICAL,
5119 EL_DC_STEELWALL_1_TOPRIGHT_2,
5120 EL_DC_STEELWALL_1_TOP,
5121 EL_DC_STEELWALL_1_TOPLEFT_2,
5122 EL_EXPANDABLE_STEELWALL_ANY,
5124 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
5125 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
5126 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
5127 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
5129 static int editor_hl_dx_boulderdash[] =
5131 EL_INTERNAL_CASCADE_DX_ACTIVE,
5137 static int editor_el_dx_boulderdash[] =
5141 EL_TUBE_HORIZONTAL_DOWN,
5145 EL_TUBE_VERTICAL_RIGHT,
5147 EL_TUBE_VERTICAL_LEFT,
5151 EL_TUBE_HORIZONTAL_UP,
5159 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
5160 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
5161 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
5162 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
5164 static int editor_hl_mirror_magic[] =
5166 EL_INTERNAL_CASCADE_MM_ACTIVE,
5172 static int editor_el_mirror_magic[] =
5174 EL_MM_MCDUFFIN_RIGHT,
5176 EL_MM_MCDUFFIN_LEFT,
5177 EL_MM_MCDUFFIN_DOWN,
5180 EL_MM_MIRROR_FIXED_START,
5181 EL_MM_POLARIZER_START,
5182 EL_MM_POLARIZER_CROSS_START,
5184 EL_MM_TELEPORTER_RED_START,
5185 EL_MM_TELEPORTER_YELLOW_START,
5186 EL_MM_TELEPORTER_GREEN_START,
5187 EL_MM_TELEPORTER_BLUE_START,
5200 EL_MM_LIGHTBULB_ACTIVE,
5214 EL_MM_STEEL_GRID_FIXED_1,
5215 EL_MM_STEEL_GRID_FIXED_2,
5216 EL_MM_STEEL_GRID_FIXED_3,
5217 EL_MM_STEEL_GRID_FIXED_4,
5219 EL_MM_WOODEN_GRID_FIXED_1,
5220 EL_MM_WOODEN_GRID_FIXED_2,
5221 EL_MM_WOODEN_GRID_FIXED_3,
5222 EL_MM_WOODEN_GRID_FIXED_4,
5229 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
5230 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
5231 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
5232 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
5234 static int editor_hl_deflektor[] =
5236 EL_INTERNAL_CASCADE_DF_ACTIVE,
5242 static int editor_el_deflektor[] =
5249 EL_DF_RECEIVER_RIGHT,
5251 EL_DF_RECEIVER_LEFT,
5252 EL_DF_RECEIVER_DOWN,
5255 EL_DF_MIRROR_ROTATING_START,
5256 EL_DF_MIRROR_FIXED_START,
5259 EL_DF_FIBRE_OPTIC_RED_1,
5260 EL_DF_FIBRE_OPTIC_YELLOW_1,
5261 EL_DF_FIBRE_OPTIC_GREEN_1,
5262 EL_DF_FIBRE_OPTIC_BLUE_1,
5264 EL_DF_STEEL_GRID_FIXED_START,
5265 EL_DF_STEEL_GRID_ROTATING_START,
5266 EL_DF_WOODEN_GRID_FIXED_START,
5267 EL_DF_WOODEN_GRID_ROTATING_START,
5279 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
5280 static int *editor_el_deflektor_ptr = editor_el_deflektor;
5281 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
5282 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
5284 static int editor_hl_chars[] =
5286 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
5292 static int editor_el_chars[] =
5374 EL_CHAR(CHAR_BYTE_COPYRIGHT),
5375 EL_CHAR(CHAR_BYTE_UMLAUT_A),
5376 EL_CHAR(CHAR_BYTE_UMLAUT_O),
5377 EL_CHAR(CHAR_BYTE_UMLAUT_U),
5379 EL_CHAR(CHAR_BYTE_DEGREE),
5380 EL_CHAR(CHAR_BYTE_REGISTERED),
5381 EL_CHAR(FONT_ASCII_CURSOR),
5382 EL_CHAR(FONT_ASCII_BUTTON),
5384 EL_CHAR(FONT_ASCII_UP),
5385 EL_CHAR(FONT_ASCII_DOWN),
5389 static int *editor_hl_chars_ptr = editor_hl_chars;
5390 static int *editor_el_chars_ptr = editor_el_chars;
5391 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
5392 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
5394 static int editor_hl_steel_chars[] =
5396 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
5402 static int editor_el_steel_chars[] =
5412 EL_STEEL_CHAR('\''),
5479 EL_STEEL_CHAR('\\'),
5484 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
5485 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
5486 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
5487 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
5489 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
5490 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
5491 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
5492 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
5494 EL_STEEL_CHAR(FONT_ASCII_UP),
5495 EL_STEEL_CHAR(FONT_ASCII_DOWN),
5499 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
5500 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
5501 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
5502 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
5504 static int editor_hl_custom[] =
5506 EL_INTERNAL_CASCADE_CE_ACTIVE,
5512 static int editor_el_custom[] =
5514 EL_CUSTOM_START + 0,
5515 EL_CUSTOM_START + 1,
5516 EL_CUSTOM_START + 2,
5517 EL_CUSTOM_START + 3,
5519 EL_CUSTOM_START + 4,
5520 EL_CUSTOM_START + 5,
5521 EL_CUSTOM_START + 6,
5522 EL_CUSTOM_START + 7,
5524 EL_CUSTOM_START + 8,
5525 EL_CUSTOM_START + 9,
5526 EL_CUSTOM_START + 10,
5527 EL_CUSTOM_START + 11,
5529 EL_CUSTOM_START + 12,
5530 EL_CUSTOM_START + 13,
5531 EL_CUSTOM_START + 14,
5532 EL_CUSTOM_START + 15,
5534 EL_CUSTOM_START + 16,
5535 EL_CUSTOM_START + 17,
5536 EL_CUSTOM_START + 18,
5537 EL_CUSTOM_START + 19,
5539 EL_CUSTOM_START + 20,
5540 EL_CUSTOM_START + 21,
5541 EL_CUSTOM_START + 22,
5542 EL_CUSTOM_START + 23,
5544 EL_CUSTOM_START + 24,
5545 EL_CUSTOM_START + 25,
5546 EL_CUSTOM_START + 26,
5547 EL_CUSTOM_START + 27,
5549 EL_CUSTOM_START + 28,
5550 EL_CUSTOM_START + 29,
5551 EL_CUSTOM_START + 30,
5552 EL_CUSTOM_START + 31,
5554 EL_CUSTOM_START + 32,
5555 EL_CUSTOM_START + 33,
5556 EL_CUSTOM_START + 34,
5557 EL_CUSTOM_START + 35,
5559 EL_CUSTOM_START + 36,
5560 EL_CUSTOM_START + 37,
5561 EL_CUSTOM_START + 38,
5562 EL_CUSTOM_START + 39,
5564 EL_CUSTOM_START + 40,
5565 EL_CUSTOM_START + 41,
5566 EL_CUSTOM_START + 42,
5567 EL_CUSTOM_START + 43,
5569 EL_CUSTOM_START + 44,
5570 EL_CUSTOM_START + 45,
5571 EL_CUSTOM_START + 46,
5572 EL_CUSTOM_START + 47,
5574 EL_CUSTOM_START + 48,
5575 EL_CUSTOM_START + 49,
5576 EL_CUSTOM_START + 50,
5577 EL_CUSTOM_START + 51,
5579 EL_CUSTOM_START + 52,
5580 EL_CUSTOM_START + 53,
5581 EL_CUSTOM_START + 54,
5582 EL_CUSTOM_START + 55,
5584 EL_CUSTOM_START + 56,
5585 EL_CUSTOM_START + 57,
5586 EL_CUSTOM_START + 58,
5587 EL_CUSTOM_START + 59,
5589 EL_CUSTOM_START + 60,
5590 EL_CUSTOM_START + 61,
5591 EL_CUSTOM_START + 62,
5592 EL_CUSTOM_START + 63,
5594 EL_CUSTOM_START + 64,
5595 EL_CUSTOM_START + 65,
5596 EL_CUSTOM_START + 66,
5597 EL_CUSTOM_START + 67,
5599 EL_CUSTOM_START + 68,
5600 EL_CUSTOM_START + 69,
5601 EL_CUSTOM_START + 70,
5602 EL_CUSTOM_START + 71,
5604 EL_CUSTOM_START + 72,
5605 EL_CUSTOM_START + 73,
5606 EL_CUSTOM_START + 74,
5607 EL_CUSTOM_START + 75,
5609 EL_CUSTOM_START + 76,
5610 EL_CUSTOM_START + 77,
5611 EL_CUSTOM_START + 78,
5612 EL_CUSTOM_START + 79,
5614 EL_CUSTOM_START + 80,
5615 EL_CUSTOM_START + 81,
5616 EL_CUSTOM_START + 82,
5617 EL_CUSTOM_START + 83,
5619 EL_CUSTOM_START + 84,
5620 EL_CUSTOM_START + 85,
5621 EL_CUSTOM_START + 86,
5622 EL_CUSTOM_START + 87,
5624 EL_CUSTOM_START + 88,
5625 EL_CUSTOM_START + 89,
5626 EL_CUSTOM_START + 90,
5627 EL_CUSTOM_START + 91,
5629 EL_CUSTOM_START + 92,
5630 EL_CUSTOM_START + 93,
5631 EL_CUSTOM_START + 94,
5632 EL_CUSTOM_START + 95,
5634 EL_CUSTOM_START + 96,
5635 EL_CUSTOM_START + 97,
5636 EL_CUSTOM_START + 98,
5637 EL_CUSTOM_START + 99,
5639 EL_CUSTOM_START + 100,
5640 EL_CUSTOM_START + 101,
5641 EL_CUSTOM_START + 102,
5642 EL_CUSTOM_START + 103,
5644 EL_CUSTOM_START + 104,
5645 EL_CUSTOM_START + 105,
5646 EL_CUSTOM_START + 106,
5647 EL_CUSTOM_START + 107,
5649 EL_CUSTOM_START + 108,
5650 EL_CUSTOM_START + 109,
5651 EL_CUSTOM_START + 110,
5652 EL_CUSTOM_START + 111,
5654 EL_CUSTOM_START + 112,
5655 EL_CUSTOM_START + 113,
5656 EL_CUSTOM_START + 114,
5657 EL_CUSTOM_START + 115,
5659 EL_CUSTOM_START + 116,
5660 EL_CUSTOM_START + 117,
5661 EL_CUSTOM_START + 118,
5662 EL_CUSTOM_START + 119,
5664 EL_CUSTOM_START + 120,
5665 EL_CUSTOM_START + 121,
5666 EL_CUSTOM_START + 122,
5667 EL_CUSTOM_START + 123,
5669 EL_CUSTOM_START + 124,
5670 EL_CUSTOM_START + 125,
5671 EL_CUSTOM_START + 126,
5672 EL_CUSTOM_START + 127,
5674 EL_CUSTOM_START + 128,
5675 EL_CUSTOM_START + 129,
5676 EL_CUSTOM_START + 130,
5677 EL_CUSTOM_START + 131,
5679 EL_CUSTOM_START + 132,
5680 EL_CUSTOM_START + 133,
5681 EL_CUSTOM_START + 134,
5682 EL_CUSTOM_START + 135,
5684 EL_CUSTOM_START + 136,
5685 EL_CUSTOM_START + 137,
5686 EL_CUSTOM_START + 138,
5687 EL_CUSTOM_START + 139,
5689 EL_CUSTOM_START + 140,
5690 EL_CUSTOM_START + 141,
5691 EL_CUSTOM_START + 142,
5692 EL_CUSTOM_START + 143,
5694 EL_CUSTOM_START + 144,
5695 EL_CUSTOM_START + 145,
5696 EL_CUSTOM_START + 146,
5697 EL_CUSTOM_START + 147,
5699 EL_CUSTOM_START + 148,
5700 EL_CUSTOM_START + 149,
5701 EL_CUSTOM_START + 150,
5702 EL_CUSTOM_START + 151,
5704 EL_CUSTOM_START + 152,
5705 EL_CUSTOM_START + 153,
5706 EL_CUSTOM_START + 154,
5707 EL_CUSTOM_START + 155,
5709 EL_CUSTOM_START + 156,
5710 EL_CUSTOM_START + 157,
5711 EL_CUSTOM_START + 158,
5712 EL_CUSTOM_START + 159,
5714 EL_CUSTOM_START + 160,
5715 EL_CUSTOM_START + 161,
5716 EL_CUSTOM_START + 162,
5717 EL_CUSTOM_START + 163,
5719 EL_CUSTOM_START + 164,
5720 EL_CUSTOM_START + 165,
5721 EL_CUSTOM_START + 166,
5722 EL_CUSTOM_START + 167,
5724 EL_CUSTOM_START + 168,
5725 EL_CUSTOM_START + 169,
5726 EL_CUSTOM_START + 170,
5727 EL_CUSTOM_START + 171,
5729 EL_CUSTOM_START + 172,
5730 EL_CUSTOM_START + 173,
5731 EL_CUSTOM_START + 174,
5732 EL_CUSTOM_START + 175,
5734 EL_CUSTOM_START + 176,
5735 EL_CUSTOM_START + 177,
5736 EL_CUSTOM_START + 178,
5737 EL_CUSTOM_START + 179,
5739 EL_CUSTOM_START + 180,
5740 EL_CUSTOM_START + 181,
5741 EL_CUSTOM_START + 182,
5742 EL_CUSTOM_START + 183,
5744 EL_CUSTOM_START + 184,
5745 EL_CUSTOM_START + 185,
5746 EL_CUSTOM_START + 186,
5747 EL_CUSTOM_START + 187,
5749 EL_CUSTOM_START + 188,
5750 EL_CUSTOM_START + 189,
5751 EL_CUSTOM_START + 190,
5752 EL_CUSTOM_START + 191,
5754 EL_CUSTOM_START + 192,
5755 EL_CUSTOM_START + 193,
5756 EL_CUSTOM_START + 194,
5757 EL_CUSTOM_START + 195,
5759 EL_CUSTOM_START + 196,
5760 EL_CUSTOM_START + 197,
5761 EL_CUSTOM_START + 198,
5762 EL_CUSTOM_START + 199,
5764 EL_CUSTOM_START + 200,
5765 EL_CUSTOM_START + 201,
5766 EL_CUSTOM_START + 202,
5767 EL_CUSTOM_START + 203,
5769 EL_CUSTOM_START + 204,
5770 EL_CUSTOM_START + 205,
5771 EL_CUSTOM_START + 206,
5772 EL_CUSTOM_START + 207,
5774 EL_CUSTOM_START + 208,
5775 EL_CUSTOM_START + 209,
5776 EL_CUSTOM_START + 210,
5777 EL_CUSTOM_START + 211,
5779 EL_CUSTOM_START + 212,
5780 EL_CUSTOM_START + 213,
5781 EL_CUSTOM_START + 214,
5782 EL_CUSTOM_START + 215,
5784 EL_CUSTOM_START + 216,
5785 EL_CUSTOM_START + 217,
5786 EL_CUSTOM_START + 218,
5787 EL_CUSTOM_START + 219,
5789 EL_CUSTOM_START + 220,
5790 EL_CUSTOM_START + 221,
5791 EL_CUSTOM_START + 222,
5792 EL_CUSTOM_START + 223,
5794 EL_CUSTOM_START + 224,
5795 EL_CUSTOM_START + 225,
5796 EL_CUSTOM_START + 226,
5797 EL_CUSTOM_START + 227,
5799 EL_CUSTOM_START + 228,
5800 EL_CUSTOM_START + 229,
5801 EL_CUSTOM_START + 230,
5802 EL_CUSTOM_START + 231,
5804 EL_CUSTOM_START + 232,
5805 EL_CUSTOM_START + 233,
5806 EL_CUSTOM_START + 234,
5807 EL_CUSTOM_START + 235,
5809 EL_CUSTOM_START + 236,
5810 EL_CUSTOM_START + 237,
5811 EL_CUSTOM_START + 238,
5812 EL_CUSTOM_START + 239,
5814 EL_CUSTOM_START + 240,
5815 EL_CUSTOM_START + 241,
5816 EL_CUSTOM_START + 242,
5817 EL_CUSTOM_START + 243,
5819 EL_CUSTOM_START + 244,
5820 EL_CUSTOM_START + 245,
5821 EL_CUSTOM_START + 246,
5822 EL_CUSTOM_START + 247,
5824 EL_CUSTOM_START + 248,
5825 EL_CUSTOM_START + 249,
5826 EL_CUSTOM_START + 250,
5827 EL_CUSTOM_START + 251,
5829 EL_CUSTOM_START + 252,
5830 EL_CUSTOM_START + 253,
5831 EL_CUSTOM_START + 254,
5832 EL_CUSTOM_START + 255
5834 static int *editor_hl_custom_ptr = editor_hl_custom;
5835 static int *editor_el_custom_ptr = editor_el_custom;
5836 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5837 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5839 static int editor_hl_group[] =
5841 EL_INTERNAL_CASCADE_GE_ACTIVE,
5847 static int editor_el_group[] =
5861 EL_GROUP_START + 10,
5862 EL_GROUP_START + 11,
5864 EL_GROUP_START + 12,
5865 EL_GROUP_START + 13,
5866 EL_GROUP_START + 14,
5867 EL_GROUP_START + 15,
5869 EL_GROUP_START + 16,
5870 EL_GROUP_START + 17,
5871 EL_GROUP_START + 18,
5872 EL_GROUP_START + 19,
5874 EL_GROUP_START + 20,
5875 EL_GROUP_START + 21,
5876 EL_GROUP_START + 22,
5877 EL_GROUP_START + 23,
5879 EL_GROUP_START + 24,
5880 EL_GROUP_START + 25,
5881 EL_GROUP_START + 26,
5882 EL_GROUP_START + 27,
5884 EL_GROUP_START + 28,
5885 EL_GROUP_START + 29,
5886 EL_GROUP_START + 30,
5889 static int *editor_hl_group_ptr = editor_hl_group;
5890 static int *editor_el_group_ptr = editor_el_group;
5891 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5892 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5894 static int editor_hl_empty_space[] =
5896 EL_INTERNAL_CASCADE_ES_ACTIVE,
5902 static int editor_el_empty_space[] =
5924 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
5925 static int *editor_el_empty_space_ptr = editor_el_empty_space;
5926 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
5927 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
5929 static int editor_hl_reference[] =
5931 EL_INTERNAL_CASCADE_REF_ACTIVE,
5937 static int editor_el_reference[] =
5941 EL_TRIGGER_CE_VALUE,
5942 EL_TRIGGER_CE_SCORE,
5946 EL_CURRENT_CE_VALUE,
5947 EL_CURRENT_CE_SCORE,
5969 static int *editor_hl_reference_ptr = editor_hl_reference;
5970 static int *editor_el_reference_ptr = editor_el_reference;
5971 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5972 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5974 static int editor_hl_user_defined[] =
5976 EL_INTERNAL_CASCADE_USER_ACTIVE,
5982 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5983 static int *editor_el_user_defined_ptr = NULL;
5984 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5985 static int num_editor_el_user_defined = 0;
5987 static int editor_hl_dynamic[] =
5989 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5995 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5996 static int *editor_el_dynamic_ptr = NULL;
5997 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5998 static int num_editor_el_dynamic = 0;
6000 static int editor_hl_empty[] = { EL_EMPTY };
6001 static int *editor_el_empty = NULL; // dynamically allocated
6003 static int *editor_hl_empty_ptr = editor_hl_empty;
6004 static int *editor_el_empty_ptr = NULL;
6005 static int num_editor_hl_empty = 0;
6006 static int num_editor_el_empty = 0; // dynamically determined, if needed
6008 static boolean use_el_empty = FALSE;
6010 static int *editor_elements = NULL; // dynamically allocated
6011 static int num_editor_elements = 0; // dynamically determined
6013 static boolean setup_editor_cascade_never = FALSE;
6015 static boolean setup_editor_el_players = TRUE;
6016 static boolean setup_editor_el_boulderdash = TRUE;
6017 static boolean setup_editor_el_boulderdash_native = TRUE;
6018 static boolean setup_editor_el_emerald_mine = TRUE;
6019 static boolean setup_editor_el_emerald_mine_club = TRUE;
6020 static boolean setup_editor_el_more = TRUE;
6021 static boolean setup_editor_el_sokoban = TRUE;
6022 static boolean setup_editor_el_supaplex = TRUE;
6023 static boolean setup_editor_el_diamond_caves = TRUE;
6024 static boolean setup_editor_el_dx_boulderdash = TRUE;
6025 static boolean setup_editor_el_mirror_magic = TRUE;
6026 static boolean setup_editor_el_deflektor = TRUE;
6027 static boolean setup_editor_el_chars = TRUE;
6028 static boolean setup_editor_el_steel_chars = TRUE;
6029 static boolean setup_editor_el_custom = TRUE;
6030 static boolean setup_editor_el_user_defined = TRUE;
6031 static boolean setup_editor_el_dynamic = TRUE;
6033 static int editor_hl_unused[] = { EL_EMPTY };
6034 static int *editor_hl_unused_ptr = editor_hl_unused;
6035 static int num_editor_hl_unused = 0;
6039 boolean *setup_value;
6040 boolean *setup_cascade_value;
6042 int **headline_list;
6043 int *headline_list_size;
6046 int *element_list_size;
6048 boolean last_setup_value;
6050 editor_elements_info[] =
6053 &setup_editor_el_players,
6054 &setup_editor_cascade_never,
6055 &editor_hl_unused_ptr, &num_editor_hl_unused,
6056 &editor_el_players_ptr, &num_editor_el_players
6059 &setup_editor_el_boulderdash,
6060 &setup.editor_cascade.el_bd,
6061 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
6062 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
6065 &setup_editor_el_boulderdash_native,
6066 &setup.editor_cascade.el_bd_native,
6067 &editor_hl_boulderdash_native_ptr, &num_editor_hl_boulderdash_native,
6068 &editor_el_boulderdash_native_ptr, &num_editor_el_boulderdash_native
6071 &setup_editor_el_emerald_mine,
6072 &setup.editor_cascade.el_em,
6073 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
6074 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
6077 &setup_editor_el_emerald_mine_club,
6078 &setup.editor_cascade.el_emc,
6079 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
6080 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
6083 &setup_editor_el_more,
6084 &setup.editor_cascade.el_rnd,
6085 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
6086 &editor_el_rnd_ptr, &num_editor_el_rnd
6089 &setup_editor_el_sokoban,
6090 &setup.editor_cascade.el_sb,
6091 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
6092 &editor_el_sokoban_ptr, &num_editor_el_sokoban
6095 &setup_editor_el_supaplex,
6096 &setup.editor_cascade.el_sp,
6097 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
6098 &editor_el_supaplex_ptr, &num_editor_el_supaplex
6101 &setup_editor_el_diamond_caves,
6102 &setup.editor_cascade.el_dc,
6103 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
6104 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
6107 &setup_editor_el_dx_boulderdash,
6108 &setup.editor_cascade.el_dx,
6109 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
6110 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
6113 &setup_editor_el_mirror_magic,
6114 &setup.editor_cascade.el_mm,
6115 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
6116 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
6119 &setup_editor_el_deflektor,
6120 &setup.editor_cascade.el_df,
6121 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
6122 &editor_el_deflektor_ptr, &num_editor_el_deflektor
6125 &setup_editor_el_chars,
6126 &setup.editor_cascade.el_chars,
6127 &editor_hl_chars_ptr, &num_editor_hl_chars,
6128 &editor_el_chars_ptr, &num_editor_el_chars
6131 &setup_editor_el_steel_chars,
6132 &setup.editor_cascade.el_steel_chars,
6133 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
6134 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
6137 &setup_editor_el_custom,
6138 &setup.editor_cascade.el_ce,
6139 &editor_hl_custom_ptr, &num_editor_hl_custom,
6140 &editor_el_custom_ptr, &num_editor_el_custom
6143 &setup_editor_el_custom,
6144 &setup.editor_cascade.el_ge,
6145 &editor_hl_group_ptr, &num_editor_hl_group,
6146 &editor_el_group_ptr, &num_editor_el_group
6149 &setup_editor_el_custom,
6150 &setup.editor_cascade.el_es,
6151 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
6152 &editor_el_empty_space_ptr, &num_editor_el_empty_space
6155 &setup_editor_el_custom,
6156 &setup.editor_cascade.el_ref,
6157 &editor_hl_reference_ptr, &num_editor_hl_reference,
6158 &editor_el_reference_ptr, &num_editor_el_reference
6161 &setup_editor_el_user_defined,
6162 &setup.editor_cascade.el_user,
6163 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
6164 &editor_el_user_defined_ptr, &num_editor_el_user_defined
6167 &setup_editor_el_dynamic,
6168 &setup.editor_cascade.el_dynamic,
6169 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
6170 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
6175 &editor_hl_empty_ptr, &num_editor_hl_empty,
6176 &editor_el_empty_ptr, &num_editor_el_empty,
6186 static struct XY xy_directions[] =
6195 // ----------------------------------------------------------------------------
6197 // ----------------------------------------------------------------------------
6199 static int getMaxInfoTextLength(void)
6201 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
6204 static int getTextWidthForGadget(char *text)
6209 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
6212 static int getTextWidthForDrawingArea(char *text)
6217 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
6220 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
6222 return (gi->x + gi->width + getTextWidthForGadget(text));
6225 static char *getElementInfoText(int element)
6227 char *info_text = NULL;
6229 if (element < MAX_NUM_ELEMENTS)
6231 if (strlen(element_info[element].description) > 0)
6232 info_text = element_info[element].description;
6233 else if (element_info[element].custom_description != NULL)
6234 info_text = element_info[element].custom_description;
6235 else if (element_info[element].editor_description != NULL)
6236 info_text = element_info[element].editor_description;
6239 if (info_text == NULL)
6240 info_text = INFOTEXT_UNKNOWN_ELEMENT;
6245 static char *getElementDescriptionFilenameExt(char *basename)
6247 char *elements_subdir = ELEMENTS_DIRECTORY;
6248 static char *elements_subdir2 = NULL;
6249 static char *filename = NULL;
6251 if (elements_subdir2 == NULL)
6252 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
6254 checked_free(filename);
6256 // 1st try: look for element description in current level set directory
6257 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
6258 if (fileExists(filename))
6263 // 2nd try: look for element description in the game's base directory
6264 filename = getPath3(options.docs_directory, elements_subdir, basename);
6265 if (fileExists(filename))
6271 static char *getElementDescriptionFilename(int element)
6273 char basename[MAX_FILENAME_LEN];
6276 // 1st try: look for element description file for exactly this element
6277 sprintf(basename, "%s.txt", element_info[element].token_name);
6278 filename = getElementDescriptionFilenameExt(basename);
6279 if (filename != NULL)
6282 // 2nd try: look for element description file for this element's class
6283 sprintf(basename, "%s.txt", element_info[element].class_name);
6284 filename = getElementDescriptionFilenameExt(basename);
6285 if (filename != NULL)
6288 // 3rd try: look for generic fallback text file for any element
6289 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
6290 if (filename != NULL)
6296 static boolean suppressBorderElement(void)
6298 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
6299 lev_fieldx <= MAX_ED_FIELDX &&
6300 lev_fieldy <= MAX_ED_FIELDY);
6303 static void InitDynamicEditorElementList(int **elements, int *num_elements)
6305 boolean element_found[NUM_FILE_ELEMENTS];
6308 // initialize list of used elements to "not used"
6309 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6310 element_found[i] = FALSE;
6312 // find all elements used in current level
6313 for (y = 0; y < lev_fieldy; y++)
6315 for (x = 0; x < lev_fieldx; x++)
6317 if (Tile[x][y] >= NUM_FILE_ELEMENTS) // should never happen
6320 if (IS_MM_WALL(Tile[x][y]))
6321 element_found[map_mm_wall_element(Tile[x][y])] = TRUE;
6323 element_found[Tile[x][y]] = TRUE;
6329 // count number of elements used in current level
6330 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6331 if (element_found[i])
6334 // add space for up to 3 more elements for padding that may be needed
6337 // free memory for old list of elements, if needed
6338 checked_free(*elements);
6340 // allocate memory for new list of elements
6341 *elements = checked_malloc(*num_elements * sizeof(int));
6345 // add all elements used in current level (non-custom/group/empty elements)
6346 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6347 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) ||
6348 IS_GROUP_ELEMENT(i) ||
6349 IS_EMPTY_ELEMENT(i)))
6350 (*elements)[(*num_elements)++] = i;
6352 // add all elements used in current level (custom/group/empty elements)
6353 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6354 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) ||
6355 IS_GROUP_ELEMENT(i) ||
6356 IS_EMPTY_ELEMENT(i)))
6357 (*elements)[(*num_elements)++] = i;
6359 while (*num_elements % 4) // pad with empty elements, if needed
6360 (*elements)[(*num_elements)++] = EL_EMPTY;
6363 static void ReinitializeElementList_EnableSections(void)
6365 // default: enable all element sections
6367 setup_editor_el_players = TRUE;
6368 setup_editor_el_boulderdash = TRUE;
6369 setup_editor_el_boulderdash_native = TRUE;
6370 setup_editor_el_emerald_mine = TRUE;
6371 setup_editor_el_emerald_mine_club = TRUE;
6372 setup_editor_el_more = TRUE;
6373 setup_editor_el_sokoban = TRUE;
6374 setup_editor_el_supaplex = TRUE;
6375 setup_editor_el_diamond_caves = TRUE;
6376 setup_editor_el_dx_boulderdash = TRUE;
6377 setup_editor_el_mirror_magic = TRUE;
6378 setup_editor_el_deflektor = TRUE;
6379 setup_editor_el_chars = TRUE;
6380 setup_editor_el_steel_chars = TRUE;
6382 setup_editor_el_custom = TRUE;
6383 setup_editor_el_user_defined = TRUE;
6384 setup_editor_el_dynamic = TRUE;
6386 // now disable all element sections not to be displayed
6388 if (!setup.editor.el_classic)
6390 setup_editor_el_players = FALSE;
6391 setup_editor_el_boulderdash = FALSE;
6392 setup_editor_el_boulderdash_native = FALSE;
6393 setup_editor_el_emerald_mine = FALSE;
6394 setup_editor_el_emerald_mine_club = FALSE;
6395 setup_editor_el_more = FALSE;
6396 setup_editor_el_sokoban = FALSE;
6397 setup_editor_el_supaplex = FALSE;
6398 setup_editor_el_diamond_caves = FALSE;
6399 setup_editor_el_dx_boulderdash = FALSE;
6400 setup_editor_el_mirror_magic = FALSE;
6401 setup_editor_el_deflektor = FALSE;
6402 setup_editor_el_chars = FALSE;
6403 setup_editor_el_steel_chars = FALSE;
6406 if (!setup.editor.el_custom)
6408 setup_editor_el_custom = FALSE;
6411 if (!setup.editor.el_user_defined)
6413 setup_editor_el_user_defined = FALSE;
6416 if (!setup.editor.el_dynamic)
6418 setup_editor_el_dynamic = FALSE;
6421 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
6423 setup_editor_el_boulderdash_native = FALSE;
6424 setup_editor_el_mirror_magic = FALSE;
6425 setup_editor_el_deflektor = FALSE;
6427 else if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
6429 setup_editor_el_players = FALSE;
6430 setup_editor_el_boulderdash = FALSE;
6431 setup_editor_el_emerald_mine = FALSE;
6432 setup_editor_el_emerald_mine_club = FALSE;
6433 setup_editor_el_more = FALSE;
6434 setup_editor_el_sokoban = FALSE;
6435 setup_editor_el_supaplex = FALSE;
6436 setup_editor_el_diamond_caves = FALSE;
6437 setup_editor_el_dx_boulderdash = FALSE;
6438 setup_editor_el_mirror_magic = FALSE;
6439 setup_editor_el_deflektor = FALSE;
6440 setup_editor_el_chars = FALSE;
6441 setup_editor_el_steel_chars = FALSE;
6443 setup_editor_el_custom = FALSE;
6445 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
6447 setup_editor_el_boulderdash = FALSE;
6448 setup_editor_el_boulderdash_native = FALSE;
6449 setup_editor_el_more = FALSE;
6450 setup_editor_el_sokoban = FALSE;
6451 setup_editor_el_supaplex = FALSE;
6452 setup_editor_el_diamond_caves = FALSE;
6453 setup_editor_el_dx_boulderdash = FALSE;
6454 setup_editor_el_mirror_magic = FALSE;
6455 setup_editor_el_deflektor = FALSE;
6456 setup_editor_el_steel_chars = FALSE;
6458 setup_editor_el_custom = FALSE;
6460 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
6462 setup_editor_el_players = FALSE;
6463 setup_editor_el_boulderdash = FALSE;
6464 setup_editor_el_boulderdash_native = FALSE;
6465 setup_editor_el_emerald_mine = FALSE;
6466 setup_editor_el_emerald_mine_club = FALSE;
6467 setup_editor_el_more = FALSE;
6468 setup_editor_el_sokoban = FALSE;
6469 setup_editor_el_diamond_caves = FALSE;
6470 setup_editor_el_dx_boulderdash = FALSE;
6471 setup_editor_el_mirror_magic = FALSE;
6472 setup_editor_el_deflektor = FALSE;
6473 setup_editor_el_chars = FALSE;
6474 setup_editor_el_steel_chars = FALSE;
6476 setup_editor_el_custom = FALSE;
6478 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
6480 setup_editor_el_players = FALSE;
6481 setup_editor_el_boulderdash = FALSE;
6482 setup_editor_el_boulderdash_native = FALSE;
6483 setup_editor_el_emerald_mine = FALSE;
6484 setup_editor_el_emerald_mine_club = FALSE;
6485 setup_editor_el_more = FALSE;
6486 setup_editor_el_sokoban = FALSE;
6487 setup_editor_el_supaplex = FALSE;
6488 setup_editor_el_diamond_caves = FALSE;
6489 setup_editor_el_dx_boulderdash = FALSE;
6490 setup_editor_el_steel_chars = FALSE;
6492 setup_editor_el_custom = FALSE;
6496 static void ReinitializeElementList(void)
6498 static boolean initialization_needed = TRUE;
6502 ReinitializeElementList_EnableSections();
6504 if (initialization_needed)
6506 LoadSetup_EditorCascade(); // load last editor cascade state
6508 // initialize editor cascade element from saved cascade state
6509 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6511 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
6512 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
6514 if (IS_EDITOR_CASCADE(*cascade_element))
6516 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
6517 EL_CASCADE_INACTIVE(*cascade_element));
6520 initialization_needed = FALSE;
6523 checked_free(editor_elements);
6525 // reload optional user defined element list for each invocation of editor
6526 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
6527 &num_editor_el_user_defined);
6529 // initialize dynamic level element list for each invocation of editor
6530 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
6531 &num_editor_el_dynamic);
6533 // initialize list of empty elements (used for padding, if needed)
6534 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6535 editor_el_empty[i] = EL_EMPTY;
6537 // do some sanity checks for each element from element list
6538 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6540 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6542 int element = (*editor_elements_info[i].element_list)[j];
6544 if (element >= NUM_FILE_ELEMENTS)
6545 Warn("editor element %d is runtime element", element);
6547 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
6548 Warn("no element description text for element %d", element);
6552 num_editor_elements = 0;
6553 use_el_empty = FALSE;
6555 // determine size of element list
6556 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6558 if (*editor_elements_info[i].setup_value)
6560 boolean found_inactive_cascade = FALSE;
6562 if (setup.editor.el_headlines)
6564 // required for correct padding of palette headline buttons
6565 if (*editor_elements_info[i].headline_list_size > 0)
6566 num_editor_elements += ED_ELEMENTLIST_COLS;
6568 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6570 int element = (*editor_elements_info[i].headline_list)[j];
6572 if (IS_EDITOR_CASCADE_INACTIVE(element))
6573 found_inactive_cascade = TRUE;
6577 if (found_inactive_cascade)
6580 // required for correct padding of palette element buttons
6581 int element_list_size = *editor_elements_info[i].element_list_size;
6583 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6584 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6586 num_editor_elements += element_buttons;
6590 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
6592 // offer at least as many elements as element buttons exist
6593 use_el_empty = TRUE;
6594 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
6596 num_editor_elements += num_editor_el_empty;
6600 num_editor_el_empty = 0;
6603 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
6605 // fill element list
6606 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6608 boolean found_inactive_cascade = FALSE;
6610 if (*editor_elements_info[i].setup_value)
6612 if (setup.editor.el_headlines)
6614 // required for correct padding of palette headline buttons
6615 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6616 ED_ELEMENTLIST_COLS : 0);
6618 for (j = 0; j < headline_size; j++)
6620 // use empty elements for padding of palette headline buttons
6621 int element = (j < *editor_elements_info[i].headline_list_size ?
6622 (*editor_elements_info[i].headline_list)[j] :
6623 editor_el_empty[0]);
6625 editor_elements[pos++] = element;
6627 if (IS_EDITOR_CASCADE_INACTIVE(element))
6628 found_inactive_cascade = TRUE;
6632 if (found_inactive_cascade)
6635 // required for correct padding of palette element buttons
6636 int element_list_size = *editor_elements_info[i].element_list_size;
6638 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6639 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6641 // copy all elements from element list
6642 for (j = 0; j < element_list_size; j++)
6643 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6645 // use empty elements for padding of palette element buttons
6646 for (j = 0; j < element_buttons - element_list_size; j++)
6647 editor_elements[pos++] = editor_el_empty[0];
6651 // (this function is also called before editor gadgets are initialized!)
6652 AdjustElementListScrollbar();
6655 void PrintEditorElementList(void)
6657 boolean *stop = &setup_editor_el_user_defined;
6660 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6662 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6664 if (IS_EDITOR_CASCADE(cascade_element))
6666 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6667 char *headline = element_info[cascade_element_show].editor_description;
6669 PrintLineWithPrefix("# ", "-", 77);
6670 Print("# %s\n", headline);
6671 PrintLineWithPrefix("# ", "-", 77);
6674 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6676 int element = (*editor_elements_info[i].headline_list)[j];
6678 if (IS_EDITOR_CASCADE(element))
6679 element = EL_CHAR_MINUS;
6681 Print("# %s\n", element_info[element].token_name);
6687 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6689 int element = (*editor_elements_info[i].element_list)[j];
6691 Print("# %s\n", element_info[element].token_name);
6699 static void ReinitializeElementListButtons(void)
6701 static boolean last_setup_value_headlines = FALSE;
6702 static boolean initialization_needed = TRUE;
6705 if (!initialization_needed) // check if editor element setup has changed
6707 if (last_setup_value_headlines != setup.editor.el_headlines)
6708 initialization_needed = TRUE;
6710 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6711 if (editor_elements_info[i].last_setup_value !=
6712 *editor_elements_info[i].setup_value)
6713 initialization_needed = TRUE;
6716 if (!initialization_needed)
6719 FreeLevelEditorGadgets();
6720 CreateLevelEditorGadgets();
6722 // store current setup values for next invocation of this function
6723 last_setup_value_headlines = setup.editor.el_headlines;
6724 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6725 editor_elements_info[i].last_setup_value =
6726 *editor_elements_info[i].setup_value;
6728 initialization_needed = FALSE;
6731 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6734 int border_graphic =
6735 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6736 struct GraphicInfo *g = &graphic_info[border_graphic];
6737 Bitmap *src_bitmap = g->bitmap;
6738 int src_x = g->src_x;
6739 int src_y = g->src_y;
6740 int border_size = g->border_size;
6741 int border_xpos = g->width - border_size;
6742 int border_ypos = g->height - border_size;
6743 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6746 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6747 border_size, border_size,
6748 dest_x - border_size, dest_y - border_size);
6749 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6750 border_size, border_size,
6751 dest_x + width, dest_y - border_size);
6752 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6753 border_size, border_size,
6754 dest_x - border_size, dest_y + height);
6755 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6756 border_size, border_size,
6757 dest_x + width, dest_y + height);
6759 for (i = 0; i < width / tilesize; i++)
6761 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6762 tilesize, border_size,
6763 dest_x + i * tilesize, dest_y - border_size);
6764 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6765 tilesize, border_size,
6766 dest_x + i * tilesize, dest_y + height);
6769 for (i = 0; i < height / tilesize; i++)
6771 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6772 border_size, tilesize,
6773 dest_x - border_size, dest_y + i * tilesize);
6774 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6775 border_size, tilesize,
6776 dest_x + width, dest_y + i * tilesize);
6779 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6782 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6784 int xsize_tile = MAX(ed_tilesize, xsize);
6785 int ysize_tile = MAX(ed_tilesize, ysize);
6786 int xsize_full = xsize + 1;
6787 int ysize_full = ysize + 1;
6788 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6789 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6790 Pixel line_color = getTabulatorBarColor();
6792 if (line_color == BLACK_PIXEL) // black => transparent
6795 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6796 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6797 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6800 static void DrawEditorLevelBorderLinesIfNeeded(void)
6802 int xsize = lev_fieldx * ed_tilesize;
6803 int ysize = lev_fieldy * ed_tilesize;
6804 int line_size = getTabulatorBarHeight();
6806 if (!suppressBorderElement())
6809 // draw little border line around editable level playfield
6812 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6815 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6817 if (xsize < SXSIZE && ysize < SYSIZE)
6818 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6821 static void DrawEditorElement(int x, int y, int element)
6823 DrawSizedElement(x, y, element, ed_tilesize);
6826 static void DrawEditorElementThruMask(int x, int y, int element)
6828 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6831 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6833 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6836 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6838 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6839 DrawEditorLevelBorderLinesIfNeeded();
6842 static void DrawDrawingArea(int id)
6844 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6847 int *value = drawingarea_info[id].value;
6848 int area_xsize = drawingarea_info[id].area_xsize;
6849 int area_ysize = drawingarea_info[id].area_ysize;
6850 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6852 for (x = 0; x < area_xsize; x++)
6853 for (y = 0; y < area_ysize; y++)
6854 DrawSizedGraphicExt(drawto,
6855 gi->x + x * tilesize,
6856 gi->y + y * tilesize,
6857 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6860 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6863 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6864 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6866 BlitBitmap(drawto, drawto,
6867 SX + (dx == -1 ? ed_tilesize : 0),
6868 SY + (dy == -1 ? ed_tilesize : 0),
6869 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6870 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6871 SX + (dx == +1 ? ed_tilesize : 0),
6872 SY + (dy == +1 ? ed_tilesize : 0));
6876 x = (dx == 1 ? 0 : ed_fieldx - 1);
6877 for (y = 0; y < ed_fieldy; y++)
6878 DrawEditorElementOrWall(x, y, from_x, from_y);
6882 y = (dy == 1 ? 0 : ed_fieldy - 1);
6883 for (x = 0; x < ed_fieldx; x++)
6884 DrawEditorElementOrWall(x, y, from_x, from_y);
6887 redraw_mask |= REDRAW_FIELD;
6891 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6894 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6897 static void CreateControlButtons(void)
6899 struct GadgetInfo *gi;
6902 // create toolbox buttons
6903 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6905 int type_id = controlbutton_info[i].gadget_id; // same as gadget ID here
6906 int id = controlbutton_info[i].gadget_id;
6907 int type = controlbutton_info[i].gadget_type;
6908 int graphic = controlbutton_info[i].graphic;
6909 struct XYTileSize *pos = controlbutton_info[i].pos;
6910 struct GraphicInfo *gd = &graphic_info[graphic];
6911 Bitmap *deco_bitmap = NULL;
6912 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6913 int tile_size = 0, deco_shift = 0;
6914 boolean deco_masked = FALSE;
6915 int gd_x1 = gd->src_x;
6916 int gd_y1 = gd->src_y;
6917 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6918 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6919 int gd_x1a = gd->src_x + gd->active_xoffset;
6920 int gd_y1a = gd->src_y + gd->active_yoffset;
6921 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6922 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6925 unsigned int event_mask;
6926 int radio_button_nr = RADIO_NR_NONE;
6927 boolean checked = FALSE;
6930 Fail("'controlbutton_info' structure corrupted at index %d -- please fix", i);
6932 if (type == GD_TYPE_RADIO_BUTTON)
6934 event_mask = GD_EVENT_PRESSED;
6935 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6937 if (id == drawing_function)
6942 if (id == GADGET_ID_WRAP_LEFT ||
6943 id == GADGET_ID_WRAP_RIGHT ||
6944 id == GADGET_ID_WRAP_UP ||
6945 id == GADGET_ID_WRAP_DOWN)
6946 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6948 event_mask = GD_EVENT_RELEASED;
6951 if (id == GADGET_ID_PROPERTIES ||
6952 id == GADGET_ID_PALETTE)
6957 else if (id == GADGET_ID_ELEMENT_LEFT ||
6958 id == GADGET_ID_ELEMENT_MIDDLE ||
6959 id == GADGET_ID_ELEMENT_RIGHT)
6964 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6965 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6966 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6968 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6969 editor.button.element_left.tile_size :
6970 id == GADGET_ID_ELEMENT_MIDDLE ?
6971 editor.button.element_middle.tile_size :
6972 id == GADGET_ID_ELEMENT_RIGHT ?
6973 editor.button.element_right.tile_size : 0);
6975 // make sure that decoration does not overlap gadget border
6976 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6978 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6980 deco_xpos = (gd->width - tile_size) / 2;
6981 deco_ypos = (gd->height - tile_size) / 2;
6983 deco_masked = gd->draw_masked;
6991 gi = CreateGadget(GDI_CUSTOM_ID, id,
6992 GDI_CUSTOM_TYPE_ID, type_id,
6993 GDI_IMAGE_ID, graphic,
6994 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6997 GDI_WIDTH, gd->width,
6998 GDI_HEIGHT, gd->height,
7000 GDI_STATE, GD_BUTTON_UNPRESSED,
7001 GDI_RADIO_NR, radio_button_nr,
7002 GDI_CHECKED, checked,
7003 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7004 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7005 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7006 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7007 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7008 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7009 GDI_DECORATION_SIZE, tile_size, tile_size,
7010 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
7011 GDI_DECORATION_MASKED, deco_masked,
7012 GDI_EVENT_MASK, event_mask,
7013 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7014 GDI_CALLBACK_ACTION, HandleControlButtons,
7018 Fail("cannot create gadget");
7020 level_editor_gadget[id] = gi;
7023 // these values are not constant, but can change at runtime
7024 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
7025 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
7026 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
7027 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
7028 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
7029 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
7030 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
7031 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
7032 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
7033 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
7034 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
7035 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
7037 // create buttons for scrolling of drawing area and element list
7038 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
7040 int id = scrollbutton_info[i].gadget_id;
7041 int type_id = scrollbutton_info[i].gadget_type_id;
7042 int graphic = scrollbutton_info[i].graphic;
7043 struct GraphicInfo *gd = &graphic_info[graphic];
7044 Bitmap *gd_bitmap = gd->bitmap;
7045 int gd_x1 = gd->src_x;
7046 int gd_y1 = gd->src_y;
7047 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7048 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7049 int width = gd->width;
7050 int height = gd->height;
7051 int x = scrollbutton_pos[i].x;
7052 int y = scrollbutton_pos[i].y;
7053 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7056 Fail("'scrollbutton_info' structure corrupted at index %d -- please fix", i);
7058 if (id == GADGET_ID_SCROLL_LIST_UP ||
7059 id == GADGET_ID_SCROLL_LIST_DOWN)
7070 gi = CreateGadget(GDI_CUSTOM_ID, id,
7071 GDI_CUSTOM_TYPE_ID, type_id,
7072 GDI_IMAGE_ID, graphic,
7073 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
7078 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7079 GDI_STATE, GD_BUTTON_UNPRESSED,
7080 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7081 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7082 GDI_EVENT_MASK, event_mask,
7083 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7084 GDI_CALLBACK_ACTION, HandleControlButtons,
7088 Fail("cannot create gadget");
7090 level_editor_gadget[id] = gi;
7093 // create buttons for element list
7094 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7097 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
7098 int graphic = IMG_EDITOR_PALETTE_BUTTON;
7099 struct GraphicInfo *gd = &graphic_info[graphic];
7100 Bitmap *gd_bitmap = gd->bitmap;
7101 Bitmap *deco_bitmap;
7102 int deco_x, deco_y, deco_xpos, deco_ypos;
7103 int gd_x1 = gd->src_x;
7104 int gd_y1 = gd->src_y;
7105 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7106 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7107 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
7108 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
7109 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
7110 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
7111 int element = editor_elements[i];
7112 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
7113 unsigned int event_mask = GD_EVENT_RELEASED;
7115 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
7117 deco_xpos = (gd->width - tile_size) / 2;
7118 deco_ypos = (gd->height - tile_size) / 2;
7120 gi = CreateGadget(GDI_CUSTOM_ID, id,
7121 GDI_CUSTOM_TYPE_ID, type_id,
7122 GDI_IMAGE_ID, graphic,
7123 GDI_INFO_TEXT, getElementInfoText(element),
7126 GDI_WIDTH, gd->width,
7127 GDI_HEIGHT, gd->height,
7128 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7129 GDI_STATE, GD_BUTTON_UNPRESSED,
7130 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7131 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7132 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7133 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7134 GDI_DECORATION_SIZE, tile_size, tile_size,
7135 GDI_DECORATION_SHIFTING, 1, 1,
7136 GDI_EVENT_MASK, event_mask,
7137 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7138 GDI_CALLBACK_ACTION, HandleControlButtons,
7142 Fail("cannot create gadget");
7144 level_editor_gadget[id] = gi;
7148 static void CreateCounterButtons(void)
7150 int max_infotext_len = getMaxInfoTextLength();
7153 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
7155 int type_id = counterbutton_info[i].gadget_type_id;
7156 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
7157 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
7161 Fail("'counterbutton_info' structure corrupted at index %d -- please fix", i);
7163 // determine horizontal position to the right of specified gadget
7164 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7165 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
7166 ED_GADGET_TEXT_DISTANCE);
7168 // determine horizontal offset for leading text
7169 if (counterbutton_info[i].text_left != NULL)
7170 x += getTextWidthForGadget(counterbutton_info[i].text_left);
7172 for (j = 0; j < 2; j++)
7174 struct GadgetInfo *gi;
7176 counterbutton_info[i].gadget_id_down :
7177 counterbutton_info[i].gadget_id_up);
7179 struct GraphicInfo *gd;
7180 int gd_x1, gd_x2, gd_y1, gd_y2;
7181 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7182 char infotext[max_infotext_len + 1];
7184 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7187 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
7188 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
7190 event_mask |= GD_EVENT_RELEASED;
7194 x = DX + editor.button.prev_level.x;
7195 y = DY + editor.button.prev_level.y;
7199 x = DX + editor.button.next_level.x;
7200 y = DY + editor.button.next_level.y;
7206 IMG_EDITOR_COUNTER_DOWN :
7207 IMG_EDITOR_COUNTER_UP);
7210 gd = &graphic_info[graphic];
7214 gd_x2 = gd->src_x + gd->pressed_xoffset;
7215 gd_y2 = gd->src_y + gd->pressed_yoffset;
7217 sprintf(infotext, "%s counter value by 1, 5 or 10",
7218 (j == 0 ? "decrease" : "increase"));
7220 gi = CreateGadget(GDI_CUSTOM_ID, id,
7221 GDI_CUSTOM_TYPE_ID, type_id,
7222 GDI_IMAGE_ID, graphic,
7223 GDI_INFO_TEXT, infotext,
7226 GDI_WIDTH, gd->width,
7227 GDI_HEIGHT, gd->height,
7228 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7229 GDI_STATE, GD_BUTTON_UNPRESSED,
7230 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7231 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7232 GDI_EVENT_MASK, event_mask,
7233 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7234 GDI_CALLBACK_ACTION, HandleCounterButtons,
7238 Fail("cannot create gadget");
7240 level_editor_gadget[id] = gi;
7241 right_gadget_border[id] =
7242 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7244 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
7248 int font_type = FONT_INPUT_1;
7249 int font_type_active = FONT_INPUT_1_ACTIVE;
7251 id = counterbutton_info[i].gadget_id_text;
7253 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7255 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7257 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
7259 font_type = FONT_LEVEL_NUMBER;
7260 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
7262 x = DX + editor.input.level_number.x;
7263 y = DY + editor.input.level_number.y;
7267 graphic = IMG_EDITOR_COUNTER_INPUT;
7270 gd = &graphic_info[graphic];
7274 gd_x2 = gd->src_x + gd->active_xoffset;
7275 gd_y2 = gd->src_y + gd->active_yoffset;
7277 gi = CreateGadget(GDI_CUSTOM_ID, id,
7278 GDI_CUSTOM_TYPE_ID, type_id,
7279 GDI_IMAGE_ID, graphic,
7280 GDI_INFO_TEXT, "enter counter value",
7283 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
7284 GDI_NUMBER_VALUE, 0,
7285 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
7286 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
7287 GDI_TEXT_SIZE, 3, // minimal counter text size
7288 GDI_TEXT_FONT, font_type,
7289 GDI_TEXT_FONT_ACTIVE, font_type_active,
7290 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7291 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7292 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7293 GDI_DESIGN_WIDTH, gd->width,
7294 GDI_EVENT_MASK, event_mask,
7295 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7296 GDI_CALLBACK_ACTION, HandleCounterButtons,
7300 Fail("cannot create gadget");
7302 level_editor_gadget[id] = gi;
7303 right_gadget_border[id] =
7304 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7306 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
7312 static void CreateDrawingAreas(void)
7316 // these values are not constant, but can change at runtime
7317 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
7318 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
7320 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
7322 struct GadgetInfo *gi;
7323 int id = drawingarea_info[i].gadget_id;
7324 int type_id = drawingarea_info[i].gadget_type_id;
7325 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
7326 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
7327 int area_xsize = drawingarea_info[i].area_xsize;
7328 int area_ysize = drawingarea_info[i].area_ysize;
7329 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
7330 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
7331 unsigned int event_mask =
7332 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
7333 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
7336 Fail("'drawingarea_info' structure corrupted at index %d -- please fix", i);
7338 // determine horizontal position to the right of specified gadget
7339 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
7340 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
7341 ED_DRAWINGAREA_TEXT_DISTANCE);
7343 // determine horizontal offset for leading text
7344 if (drawingarea_info[i].text_left != NULL)
7345 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
7347 gi = CreateGadget(GDI_CUSTOM_ID, id,
7348 GDI_CUSTOM_TYPE_ID, type_id,
7351 GDI_TYPE, GD_TYPE_DRAWING_AREA,
7352 GDI_AREA_SIZE, area_xsize, area_ysize,
7353 GDI_ITEM_SIZE, item_size, item_size,
7354 GDI_EVENT_MASK, event_mask,
7355 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
7356 GDI_CALLBACK_ACTION, HandleDrawingAreas,
7360 Fail("cannot create gadget");
7362 level_editor_gadget[id] = gi;
7363 right_gadget_border[id] =
7364 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
7368 static void CreateTextInputGadgets(void)
7370 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
7371 int max_infotext_len = getMaxInfoTextLength();
7374 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
7376 int gd_x1 = gd->src_x;
7377 int gd_y1 = gd->src_y;
7378 int gd_x2 = gd->src_x + gd->active_xoffset;
7379 int gd_y2 = gd->src_y + gd->active_yoffset;
7380 struct GadgetInfo *gi;
7381 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7382 char infotext[MAX_OUTPUT_LINESIZE + 1];
7383 int id = textinput_info[i].gadget_id;
7384 int type_id = textinput_info[i].gadget_type_id;
7388 Fail("'textinput_info' structure corrupted at index %d -- please fix", i);
7390 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
7392 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
7393 int border_size = gd->border_size;
7394 int font_nr = FONT_INPUT_1;
7395 int font_height = getFontHeight(font_nr);
7396 int xoffset = element_border + TILEX + element_border + 3 * border_size;
7397 int yoffset = element_border + (TILEY - font_height) / 2;
7399 x = (editor.settings.element_name.x != -1 ?
7400 editor.settings.element_name.x :
7401 editor.settings.element_graphic.x + xoffset) - border_size;
7402 y = (editor.settings.element_name.y != -1 ?
7403 editor.settings.element_name.y :
7404 editor.settings.element_graphic.y + yoffset) - border_size;
7408 x = ED_SETTINGS_X(textinput_info[i].x);
7409 y = ED_SETTINGS_Y(textinput_info[i].y);
7412 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
7413 infotext[max_infotext_len] = '\0';
7415 gi = CreateGadget(GDI_CUSTOM_ID, id,
7416 GDI_CUSTOM_TYPE_ID, type_id,
7417 GDI_INFO_TEXT, infotext,
7420 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
7421 GDI_TEXT_VALUE, textinput_info[i].value,
7422 GDI_TEXT_SIZE, textinput_info[i].size,
7423 GDI_TEXT_FONT, FONT_INPUT_1,
7424 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7425 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7426 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7427 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7428 GDI_DESIGN_WIDTH, gd->width,
7429 GDI_EVENT_MASK, event_mask,
7430 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7431 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
7435 Fail("cannot create gadget");
7437 level_editor_gadget[id] = gi;
7441 static void CreateTextAreaGadgets(void)
7443 int max_infotext_len = getMaxInfoTextLength();
7446 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
7448 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
7449 int gd_x1 = gd->src_x;
7450 int gd_y1 = gd->src_y;
7451 int gd_x2 = gd->src_x + gd->active_xoffset;
7452 int gd_y2 = gd->src_y + gd->active_yoffset;
7453 struct GadgetInfo *gi;
7454 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
7455 char infotext[MAX_OUTPUT_LINESIZE + 1];
7456 int id = textarea_info[i].gadget_id;
7457 int type_id = textarea_info[i].gadget_type_id;
7458 int area_xsize = textarea_info[i].xsize;
7459 int area_ysize = textarea_info[i].ysize;
7462 Fail("'textarea_info' structure corrupted at index %d -- please fix", i);
7464 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
7465 infotext[max_infotext_len] = '\0';
7467 gi = CreateGadget(GDI_CUSTOM_ID, id,
7468 GDI_CUSTOM_TYPE_ID, type_id,
7469 GDI_INFO_TEXT, infotext,
7470 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
7471 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
7472 GDI_TYPE, GD_TYPE_TEXT_AREA,
7473 GDI_AREA_SIZE, area_xsize, area_ysize,
7474 GDI_TEXT_FONT, FONT_INPUT_1,
7475 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7476 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7477 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7478 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7479 GDI_DESIGN_WIDTH, gd->width,
7480 GDI_EVENT_MASK, event_mask,
7481 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7482 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
7486 Fail("cannot create gadget");
7488 level_editor_gadget[id] = gi;
7492 static void CreateSelectboxGadgets(void)
7494 int max_infotext_len = getMaxInfoTextLength();
7497 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7499 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
7500 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
7501 int gd_x1 = gd->src_x;
7502 int gd_y1 = gd->src_y;
7503 int gd_x2 = gd->src_x + gd->active_xoffset;
7504 int gd_y2 = gd->src_y + gd->active_yoffset;
7505 int selectbox_button_xsize = gd2->width;
7506 struct GadgetInfo *gi;
7507 char infotext[MAX_OUTPUT_LINESIZE + 1];
7508 int id = selectbox_info[i].gadget_id;
7509 int type_id = selectbox_info[i].gadget_type_id;
7510 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
7511 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
7512 unsigned int event_mask =
7513 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7516 Fail("'selectbox_info' structure corrupted at index %d -- please fix", i);
7518 if (selectbox_info[i].size == -1) // dynamically determine size
7520 // (we cannot use -1 for uninitialized values if we directly compare
7521 // with results from strlen(), because the '<' and '>' operation will
7522 // implicitely cast -1 to an unsigned integer value!)
7523 selectbox_info[i].size = 0;
7525 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
7526 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
7527 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
7529 selectbox_info[i].size++; // add one character empty space
7532 // determine horizontal position to the right of specified gadget
7533 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
7534 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
7535 ED_GADGET_TEXT_DISTANCE);
7537 // determine horizontal offset for leading text
7538 if (selectbox_info[i].text_left != NULL)
7539 x += getTextWidthForGadget(selectbox_info[i].text_left);
7541 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
7542 infotext[max_infotext_len] = '\0';
7544 gi = CreateGadget(GDI_CUSTOM_ID, id,
7545 GDI_CUSTOM_TYPE_ID, type_id,
7546 GDI_INFO_TEXT, infotext,
7549 GDI_TYPE, GD_TYPE_SELECTBOX,
7550 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
7551 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
7552 GDI_TEXT_SIZE, selectbox_info[i].size,
7553 GDI_TEXT_FONT, FONT_INPUT_1,
7554 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7555 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
7556 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7557 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7558 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7559 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
7560 GDI_DESIGN_WIDTH, gd->width,
7561 GDI_EVENT_MASK, event_mask,
7562 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7563 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
7567 Fail("cannot create gadget");
7569 level_editor_gadget[id] = gi;
7570 right_gadget_border[id] =
7571 getRightGadgetBorder(gi, selectbox_info[i].text_right);
7575 static void CreateTextbuttonGadgets(void)
7577 int max_infotext_len = getMaxInfoTextLength();
7580 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
7582 int id = textbutton_info[i].gadget_id;
7583 int type_id = textbutton_info[i].gadget_type_id;
7585 ((id >= GADGET_ID_LEVELCONFIG_LEVEL && id <= GADGET_ID_LEVELCONFIG_ENGINE) ||
7586 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
7588 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
7589 int gadget_distance =
7590 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
7591 struct GraphicInfo *gd = &graphic_info[graphic];
7592 int gd_x1 = gd->src_x;
7593 int gd_y1 = gd->src_y;
7594 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7595 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7596 int gd_x1a = gd->src_x + gd->active_xoffset;
7597 int gd_y1a = gd->src_y + gd->active_yoffset;
7598 int border_xsize = gd->border_size + gd->draw_xoffset;
7599 int border_ysize = gd->border_size;
7600 struct GadgetInfo *gi;
7601 unsigned int event_mask = GD_EVENT_RELEASED;
7602 char infotext[MAX_OUTPUT_LINESIZE + 1];
7603 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
7604 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
7607 Fail("'textbutton_info' structure corrupted at index %d -- please fix", i);
7609 if (textbutton_info[i].size == -1) // dynamically determine size
7610 textbutton_info[i].size = strlen(textbutton_info[i].text);
7612 sprintf(infotext, "%s", textbutton_info[i].infotext);
7613 infotext[max_infotext_len] = '\0';
7615 // determine horizontal position to the right of specified gadget
7616 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7618 int gadget_id_align = textbutton_info[i].gadget_id_align;
7620 x = right_gadget_border[gadget_id_align] + gadget_distance;
7622 if (textbutton_info[i].y == -1)
7623 y = level_editor_gadget[gadget_id_align]->y;
7626 // determine horizontal offset for leading text
7627 if (textbutton_info[i].text_left != NULL)
7628 x += getTextWidthForGadget(textbutton_info[i].text_left);
7630 gi = CreateGadget(GDI_CUSTOM_ID, id,
7631 GDI_CUSTOM_TYPE_ID, type_id,
7632 GDI_IMAGE_ID, graphic,
7633 GDI_INFO_TEXT, infotext,
7636 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
7637 GDI_TEXT_VALUE, textbutton_info[i].text,
7638 GDI_TEXT_SIZE, textbutton_info[i].size,
7639 GDI_TEXT_FONT, FONT_INPUT_2,
7640 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
7641 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7642 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7643 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7644 GDI_BORDER_SIZE, border_xsize, border_ysize,
7645 GDI_DESIGN_WIDTH, gd->width,
7646 GDI_DECORATION_SHIFTING, 1, 1,
7647 GDI_EVENT_MASK, event_mask,
7648 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7649 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7653 Fail("cannot create gadget");
7655 level_editor_gadget[id] = gi;
7656 right_gadget_border[id] =
7657 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7661 static void CreateGraphicbuttonGadgets(void)
7663 struct GadgetInfo *gi;
7666 // create buttons for scrolling of drawing area and element list
7667 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7669 int id = graphicbutton_info[i].gadget_id;
7670 int type_id = graphicbutton_info[i].gadget_type_id;
7671 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7672 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7673 int graphic = graphicbutton_info[i].graphic;
7674 struct GraphicInfo *gd = &graphic_info[graphic];
7675 int gd_x1 = gd->src_x;
7676 int gd_y1 = gd->src_y;
7677 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7678 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7679 unsigned int event_mask = GD_EVENT_RELEASED;
7682 Fail("'graphicbutton_info' structure corrupted at index %d -- please fix", i);
7684 // determine horizontal position to the right of specified gadget
7685 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7686 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7687 ED_GADGET_TEXT_DISTANCE);
7689 // determine horizontal offset for leading text
7690 if (graphicbutton_info[i].text_left != NULL)
7691 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7693 gi = CreateGadget(GDI_CUSTOM_ID, id,
7694 GDI_CUSTOM_TYPE_ID, type_id,
7695 GDI_IMAGE_ID, graphic,
7696 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7699 GDI_WIDTH, gd->width,
7700 GDI_HEIGHT, gd->height,
7701 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7702 GDI_STATE, GD_BUTTON_UNPRESSED,
7703 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7704 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7705 GDI_EVENT_MASK, event_mask,
7706 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7707 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7711 Fail("cannot create gadget");
7713 level_editor_gadget[id] = gi;
7714 right_gadget_border[id] =
7715 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7719 static void CreateScrollbarGadgets(void)
7723 // these values are not constant, but can change at runtime
7724 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7725 SX + ED_SCROLL_HORIZONTAL_XPOS;
7726 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7727 SY + ED_SCROLL_HORIZONTAL_YPOS;
7728 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7729 ED_SCROLL_HORIZONTAL_XSIZE;
7730 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7731 ED_SCROLL_HORIZONTAL_YSIZE;
7732 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7733 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7734 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7735 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7737 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7738 SX + ED_SCROLL_VERTICAL_XPOS;
7739 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7740 SY + ED_SCROLL_VERTICAL_YPOS;
7741 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7742 ED_SCROLL_VERTICAL_XSIZE;
7743 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7744 ED_SCROLL_VERTICAL_YSIZE;
7745 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7746 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7747 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7748 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7750 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7751 PX + ED_SCROLL2_VERTICAL_XPOS;
7752 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7753 PY + ED_SCROLL2_VERTICAL_YPOS;
7754 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7755 ED_SCROLL2_VERTICAL_XSIZE;
7756 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7757 ED_SCROLL2_VERTICAL_YSIZE;
7758 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7759 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7760 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7761 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7763 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7765 int id = scrollbar_info[i].gadget_id;
7766 int type_id = scrollbar_info[i].gadget_type_id;
7767 int graphic = scrollbar_info[i].graphic;
7768 struct GraphicInfo *gd = &graphic_info[graphic];
7769 int gd_x1 = gd->src_x;
7770 int gd_y1 = gd->src_y;
7771 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7772 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7773 struct GadgetInfo *gi;
7774 int items_max, items_visible, item_position;
7775 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7778 Fail("'scrollbar_info' structure corrupted at index %d -- please fix", i);
7780 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7782 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7783 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7784 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7786 else // drawing area scrollbars
7788 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7790 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7791 items_visible = ed_fieldx;
7796 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7797 items_visible = ed_fieldy;
7802 gi = CreateGadget(GDI_CUSTOM_ID, id,
7803 GDI_CUSTOM_TYPE_ID, type_id,
7804 GDI_IMAGE_ID, graphic,
7805 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7806 GDI_X, scrollbar_pos[i].x,
7807 GDI_Y, scrollbar_pos[i].y,
7808 GDI_WIDTH, scrollbar_pos[i].width,
7809 GDI_HEIGHT, scrollbar_pos[i].height,
7810 GDI_TYPE, scrollbar_info[i].type,
7811 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7812 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7813 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7814 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7815 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7816 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7817 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7818 GDI_STATE, GD_BUTTON_UNPRESSED,
7819 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7820 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7821 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7822 GDI_EVENT_MASK, event_mask,
7823 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7824 GDI_CALLBACK_ACTION, HandleControlButtons,
7828 Fail("cannot create gadget");
7830 level_editor_gadget[id] = gi;
7834 static void CreateCheckbuttonGadgets(void)
7836 struct GadgetInfo *gi;
7839 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7841 int id = checkbutton_info[i].gadget_id;
7842 int type_id = checkbutton_info[i].gadget_type_id;
7843 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7844 IMG_EDITOR_CHECKBOX);
7845 struct GraphicInfo *gd = &graphic_info[graphic];
7846 int gd_x1 = gd->src_x;
7847 int gd_y1 = gd->src_y;
7848 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7849 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7850 int gd_x1a = gd->src_x + gd->active_xoffset;
7851 int gd_y1a = gd->src_y + gd->active_yoffset;
7852 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7853 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7854 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7855 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7856 unsigned int event_mask = GD_EVENT_PRESSED;
7859 Fail("'checkbutton_info' structure corrupted at index %d -- please fix", i);
7861 // determine horizontal position to the right of specified gadget
7862 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7863 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7864 ED_GADGET_TEXT_DISTANCE);
7866 // determine horizontal offset for leading text
7867 if (checkbutton_info[i].text_left != NULL)
7868 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7870 gi = CreateGadget(GDI_CUSTOM_ID, id,
7871 GDI_CUSTOM_TYPE_ID, type_id,
7872 GDI_IMAGE_ID, graphic,
7873 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7876 GDI_WIDTH, gd->width,
7877 GDI_HEIGHT, gd->height,
7878 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7879 GDI_CHECKED, *checkbutton_info[i].value,
7880 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7881 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7882 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7883 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7884 GDI_EVENT_MASK, event_mask,
7885 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7886 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7890 Fail("cannot create gadget");
7892 level_editor_gadget[id] = gi;
7893 right_gadget_border[id] =
7894 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7898 static void CreateRadiobuttonGadgets(void)
7900 int graphic = IMG_EDITOR_RADIOBUTTON;
7901 struct GraphicInfo *gd = &graphic_info[graphic];
7902 int gd_x1 = gd->src_x;
7903 int gd_y1 = gd->src_y;
7904 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7905 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7906 int gd_x1a = gd->src_x + gd->active_xoffset;
7907 int gd_y1a = gd->src_y + gd->active_yoffset;
7908 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7909 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7910 struct GadgetInfo *gi;
7913 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7915 int id = radiobutton_info[i].gadget_id;
7916 int type_id = radiobutton_info[i].gadget_type_id;
7917 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7918 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7919 unsigned int event_mask = GD_EVENT_PRESSED;
7922 Fail("'radiobutton_info' structure corrupted at index %d -- please fix", i);
7925 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7927 // determine horizontal position to the right of specified gadget
7928 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7929 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7930 ED_GADGET_TEXT_DISTANCE);
7932 // determine horizontal offset for leading text
7933 if (radiobutton_info[i].text_left != NULL)
7934 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7936 gi = CreateGadget(GDI_CUSTOM_ID, id,
7937 GDI_CUSTOM_TYPE_ID, type_id,
7938 GDI_IMAGE_ID, graphic,
7939 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7942 GDI_WIDTH, gd->width,
7943 GDI_HEIGHT, gd->height,
7944 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7945 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7946 GDI_CHECKED, checked,
7947 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7948 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7949 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7950 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7951 GDI_EVENT_MASK, event_mask,
7952 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7953 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7957 Fail("cannot create gadget");
7959 level_editor_gadget[id] = gi;
7960 right_gadget_border[id] =
7961 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7965 void CreateLevelEditorGadgets(void)
7967 // force EDITOR font inside level editor
7968 SetFontStatus(GAME_MODE_EDITOR);
7970 // these values are not constant, but can change at runtime
7971 ed_fieldx = MAX_ED_FIELDX - 1;
7972 ed_fieldy = MAX_ED_FIELDY - 1;
7974 num_editor_gadgets = NUM_EDITOR_GADGETS;
7976 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7978 level_editor_gadget =
7979 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7980 right_gadget_border =
7981 checked_calloc(num_editor_gadgets * sizeof(int));
7983 // set number of empty (padding) element buttons to maximum number of buttons
7984 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7986 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7987 editor_el_empty_ptr = editor_el_empty;
7989 use_permanent_palette = !editor.palette.show_as_separate_screen;
7991 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
7993 ReinitializeElementList();
7995 CreateControlButtons();
7996 CreateScrollbarGadgets();
7998 // order of function calls is important because of cross-references
7999 CreateCheckbuttonGadgets();
8000 CreateCounterButtons();
8001 CreateRadiobuttonGadgets();
8002 CreateTextInputGadgets();
8003 CreateTextAreaGadgets();
8004 CreateSelectboxGadgets();
8005 CreateGraphicbuttonGadgets();
8006 CreateTextbuttonGadgets();
8007 CreateDrawingAreas();
8012 void FreeLevelEditorGadgets(void)
8016 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
8018 for (i = 0; i < num_editor_gadgets; i++)
8020 FreeGadget(level_editor_gadget[i]);
8022 level_editor_gadget[i] = NULL;
8025 checked_free(level_editor_gadget);
8026 checked_free(right_gadget_border);
8028 checked_free(editor_el_empty);
8031 static void MapCounterButtons(int id)
8033 int font_nr = FONT_TEXT_1;
8034 int font_height = getFontHeight(font_nr);
8035 int gadget_id_down = counterbutton_info[id].gadget_id_down;
8036 int gadget_id_text = counterbutton_info[id].gadget_id_text;
8037 int gadget_id_up = counterbutton_info[id].gadget_id_up;
8038 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
8039 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
8040 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8041 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
8042 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8043 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8044 int yoffset = (gi_down->height - font_height) / 2;
8045 int x_left = gi_down->x - xoffset_left;
8046 int x_right; // set after gadget position was modified
8047 int y_above = gi_down->y - yoffset_above;
8049 int y; // set after gadget position was modified
8051 // counter limits must be changed first to prevent value truncation
8052 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
8053 counterbutton_info[id].max_value);
8055 // right text position might have changed after setting position above
8056 x_right = gi_up->x + gi_up->width + xoffset_right;
8058 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
8060 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
8061 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
8062 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
8064 ModifyGadget(gi_down, GDI_Y,
8065 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8066 ModifyGadget(gi_text, GDI_Y,
8067 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8068 ModifyGadget(gi_up, GDI_Y,
8069 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8072 // vertical position might have changed after setting position above
8073 y = gi_up->y + yoffset;
8075 if (counterbutton_info[id].text_above)
8076 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
8078 if (counterbutton_info[id].text_left)
8079 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
8081 if (counterbutton_info[id].text_right)
8082 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
8089 static void MapControlButtons(void)
8094 // map toolbox buttons (excluding special CE toolbox buttons)
8095 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
8096 MapGadget(level_editor_gadget[i]);
8098 // map toolbox buttons (element properties buttons)
8099 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
8100 MapGadget(level_editor_gadget[i]);
8102 if (use_permanent_palette)
8104 // map buttons to select elements
8105 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8106 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
8107 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
8108 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
8109 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
8112 // map buttons to select level
8113 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
8114 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
8115 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
8116 MapCounterButtons(counter_id);
8119 static void MapDrawingArea(int id)
8121 int font_nr = FONT_TEXT_1;
8122 int font_height = getFontHeight(font_nr);
8123 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8124 int area_xsize = gi->drawing.area_xsize;
8125 int area_ysize = gi->drawing.area_ysize;
8126 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8127 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
8128 int x_left = gi->x - xoffset_left;
8129 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
8130 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
8131 int x_below = gi->x + (gi->width - xoffset_below) / 2;
8132 int y_side = gi->y + (gi->height - font_height) / 2;
8133 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
8134 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
8136 if (drawingarea_info[id].text_left)
8137 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
8139 if (drawingarea_info[id].text_right)
8140 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
8142 if (drawingarea_info[id].text_above)
8143 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
8145 if (drawingarea_info[id].text_below)
8146 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
8148 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
8150 DrawElementBorder(gi->x, gi->y,
8151 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
8152 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
8154 DrawDrawingArea(id);
8160 static void MapTextInputGadget(int id)
8162 int font_nr = FONT_TEXT_1;
8163 int font_height = getFontHeight(font_nr);
8164 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
8165 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8166 int x_above = ED_SETTINGS_X(textinput_info[id].x);
8167 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
8169 if (textinput_info[id].text_above)
8170 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
8172 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
8177 static void MapTextAreaGadget(int id)
8179 int font_nr = FONT_TEXT_1;
8180 int font_height = getFontHeight(font_nr);
8181 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8182 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8183 int x_above = ED_SETTINGS_X(textarea_info[id].x);
8184 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
8185 char *text_above = textarea_info[id].text_above;
8187 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
8188 text_above = textarea_info[id].text_above_cropped;
8191 DrawTextS(x_above, y_above, font_nr, text_above);
8193 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
8198 static void MapSelectboxGadget(int id)
8200 int font_nr = FONT_TEXT_1;
8201 int font_height = getFontHeight(font_nr);
8202 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
8203 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
8204 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8205 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8206 int yoffset = (gi->height - font_height) / 2;
8207 int x_left = gi->x - xoffset_left;
8208 int x_right = gi->x + gi->width + xoffset_right;
8209 int y_above = gi->y - yoffset_above;
8211 int y = gi->y + yoffset;
8213 if (selectbox_info[id].text_above)
8214 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
8216 if (selectbox_info[id].text_left)
8217 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
8219 if (selectbox_info[id].text_right)
8220 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
8222 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
8227 static void MapTextbuttonGadget(int id)
8229 int font_nr = FONT_TEXT_1;
8230 int font_height = getFontHeight(font_nr);
8231 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
8232 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
8233 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8234 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8235 int yoffset = (gi->height - font_height) / 2;
8236 int x_left = gi->x - xoffset_left;
8237 int x_right = gi->x + gi->width + xoffset_right;
8238 int y_above = gi->y - yoffset_above;
8240 int y = gi->y + yoffset;
8242 // only show button to delete change pages when more than minimum pages
8243 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
8244 custom_element.num_change_pages == MIN_CHANGE_PAGES)
8247 if (textbutton_info[id].text_above)
8248 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
8250 if (textbutton_info[id].text_left)
8251 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
8253 if (textbutton_info[id].text_right)
8254 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
8259 static void MapGraphicbuttonGadget(int id)
8261 int font_nr = FONT_TEXT_1;
8262 int font_height = getFontHeight(font_nr);
8263 struct GadgetInfo *gi = level_editor_gadget[graphicbutton_info[id].gadget_id];
8264 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
8265 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8266 int yoffset = (gi->height - font_height) / 2;
8267 int x_left = gi->x - xoffset_left;
8268 int x_right = gi->x + gi->width + xoffset_right;
8269 int y = gi->y + yoffset;
8271 if (graphicbutton_info[id].text_left)
8272 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
8274 if (graphicbutton_info[id].text_right)
8275 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
8280 static void MapRadiobuttonGadget(int id)
8282 int font_nr = FONT_TEXT_1;
8283 int font_height = getFontHeight(font_nr);
8284 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
8285 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8286 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8287 int yoffset = (gi->height - font_height) / 2;
8288 int x_left = gi->x - xoffset_left;
8289 int x_right = gi->x + gi->width + xoffset_right;
8290 int y = gi->y + yoffset;
8292 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
8294 if (radiobutton_info[id].text_left)
8295 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
8297 if (radiobutton_info[id].text_right)
8298 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
8300 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
8305 static void MapCheckbuttonGadget(int id)
8307 int font_nr = FONT_TEXT_1;
8308 int font_height = getFontHeight(font_nr);
8309 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
8310 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8311 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8312 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8313 int yoffset = (gi->height - font_height) / 2;
8314 int y_above = gi->y - yoffset_above;
8316 int x_left, x_right, y; // set after gadget position was modified
8318 // set position for gadgets with dynamically determined position
8319 if (checkbutton_info[id].x != -1) // do not change dynamic positions
8320 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x), GDI_END);
8321 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
8323 x_left = gi->x - xoffset_left;
8324 x_right = gi->x + gi->width + xoffset_right;
8325 y = gi->y + yoffset;
8327 if (checkbutton_info[id].text_above)
8328 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
8330 if (checkbutton_info[id].text_left)
8331 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
8333 if (checkbutton_info[id].text_right)
8334 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
8336 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
8341 static void MapMainDrawingArea(void)
8343 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
8344 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
8347 if (suppressBorderElement())
8349 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
8350 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
8353 for (i = ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
8355 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
8356 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
8357 no_horizontal_scrollbar) ||
8358 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
8359 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
8360 no_vertical_scrollbar))
8363 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
8366 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
8368 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
8369 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
8372 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
8375 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
8378 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
8382 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
8384 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
8385 i == GADGET_ID_CUSTOM_COPY_TO ||
8386 i == GADGET_ID_CUSTOM_EXCHANGE ||
8387 i == GADGET_ID_CUSTOM_COPY ||
8388 i == GADGET_ID_CUSTOM_PASTE)
8391 MapGadget(level_editor_gadget[i]);
8393 UnmapGadget(level_editor_gadget[i]);
8398 static void MapLevelEditorToolboxCustomGadgets(void)
8400 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
8403 static void MapLevelEditorToolboxCustomGadgetsIfNeeded(void)
8405 if (IS_CUSTOM_ELEMENT(properties_element) ||
8406 IS_GROUP_ELEMENT(properties_element) ||
8407 IS_EMPTY_ELEMENT(properties_element))
8408 MapLevelEditorToolboxCustomGadgets();
8411 static void UnmapLevelEditorToolboxCustomGadgets(void)
8413 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
8416 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
8420 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
8422 if (i != GADGET_ID_SINGLE_ITEMS &&
8423 i != GADGET_ID_PICK_ELEMENT)
8425 struct GadgetInfo *gi = level_editor_gadget[i];
8433 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
8434 struct GraphicInfo *gd = &graphic_info[graphic];
8438 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
8439 gi->width, gi->height, gi->x, gi->y);
8441 redraw_mask |= REDRAW_DOOR_3;
8447 static void MapLevelEditorToolboxDrawingGadgets(void)
8449 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
8452 static void UnmapLevelEditorToolboxDrawingGadgets(void)
8454 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
8457 static void UnmapDrawingArea(int id)
8459 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
8462 static void UnmapLevelEditorFieldGadgets(void)
8466 for (i = 0; i < num_editor_gadgets; i++)
8467 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
8468 level_editor_gadget[i]->y))
8469 UnmapGadget(level_editor_gadget[i]);
8472 void UnmapLevelEditorGadgets(void)
8476 for (i = 0; i < num_editor_gadgets; i++)
8477 UnmapGadget(level_editor_gadget[i]);
8480 static void ResetUndoBuffer(void)
8482 undo_buffer_position = -1;
8483 undo_buffer_steps = -1;
8484 redo_buffer_steps = 0;
8486 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8488 level.changed = FALSE;
8491 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
8493 if (remap_toolbox_gadgets)
8495 ModifyEditorElementList();
8496 RedrawDrawingElements();
8499 if (edit_mode == ED_MODE_LEVELCONFIG)
8500 DrawLevelConfigWindow();
8501 else if (edit_mode == ED_MODE_PROPERTIES)
8502 DrawPropertiesWindow();
8503 else if (edit_mode == ED_MODE_PALETTE)
8504 DrawPaletteWindow();
8505 else // edit_mode == ED_MODE_DRAWING
8506 DrawDrawingWindowExt(remap_toolbox_gadgets);
8509 static void DrawEditModeWindow(void)
8511 DrawEditModeWindowExt(TRUE);
8514 static void DrawEditModeWindow_PlayfieldOnly(void)
8516 DrawEditModeWindowExt(FALSE);
8519 static void ChangeEditModeWindow(int new_edit_mode)
8521 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
8523 DrawEditModeWindow();
8526 static boolean LevelChanged(void)
8528 boolean field_changed = FALSE;
8531 for (y = 0; y < lev_fieldy; y++)
8532 for (x = 0; x < lev_fieldx; x++)
8533 if (Tile[x][y] != level.field[x][y])
8534 field_changed = TRUE;
8536 return (level.changed || field_changed);
8539 static boolean PrepareSavingIntoPersonalLevelSet(void)
8541 static LevelDirTree *last_copied_leveldir = NULL;
8542 static LevelDirTree *last_written_leveldir = NULL;
8543 static int last_copied_level_nr = -1;
8544 static int last_written_level_nr = -1;
8545 LevelDirTree *leveldir_former = leveldir_current;
8546 int level_nr_former = level_nr;
8549 // remember last mod/save so that for current session, we write
8550 // back to the same personal copy, asking only about overwrite.
8551 if (leveldir_current == last_copied_leveldir &&
8552 level_nr == last_copied_level_nr)
8554 // "cd" to personal level set dir (as used when writing last copy)
8555 leveldir_current = last_written_leveldir;
8556 level_nr = last_written_level_nr;
8561 if (!Request("This level is read-only! "
8562 "Save into personal level set?", REQ_ASK))
8565 // "cd" to personal level set dir (for writing copy the first time)
8567 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
8569 // this may happen if "setup.internal.create_user_levelset" is FALSE
8570 // or if file "levelinfo.conf" is missing in personal user level set
8571 if (leveldir_current == NULL)
8573 Request("Cannot find personal level set?!", REQ_CONFIRM);
8575 leveldir_current = leveldir_former;
8580 // find unused level number
8581 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
8583 static char *level_filename = NULL;
8585 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
8587 if (!fileExists(level_filename))
8591 last_copied_leveldir = leveldir_former;
8592 last_copied_level_nr = level_nr_former;
8594 last_written_leveldir = leveldir_current;
8595 last_written_level_nr = level_nr = new_level_nr;
8600 static void ModifyLevelConfigForSavingIntoPersonalLevelSet(char *former_name)
8602 static char *filename_levelinfo = NULL, *mod_name = NULL;
8605 // annotate this copy-and-mod in personal levelinfo.conf
8606 setString(&filename_levelinfo,
8607 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
8609 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
8611 fprintf(file, "\n");
8612 fprintf(file, "# level %d was modified from:\n", level_nr);
8613 fprintf(file, "# - previous level set name: %s\n",
8615 fprintf(file, "# - level within previous set: %d \"%s\"\n",
8616 level.file_info.nr, level.name);
8617 fprintf(file, "# - previous author: %s\n",
8619 fprintf(file, "# - previous save date: ");
8621 if (level.creation_date.src == DATE_SRC_LEVELFILE)
8623 fprintf(file, "%04d-%02d-%02d\n",
8624 level.creation_date.year,
8625 level.creation_date.month,
8626 level.creation_date.day);
8630 fprintf(file, "not recorded\n");
8636 if (level_nr > leveldir_current->last_level)
8637 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
8639 // else: allow the save even if annotation failed
8641 // now... spray graffiti on the old level vital statistics
8642 // user can change these; just trying to set a good baseline
8644 // don't truncate names for fear of making offensive or silly:
8645 // long-named original author only recorded in levelinfo.conf.
8646 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
8647 if (!strEqual(level.author, leveldir_current->author))
8649 setString(&mod_name, getStringCat3(leveldir_current->author,
8650 " after ", level.author));
8652 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8653 setString(&mod_name,
8654 getStringCat2(leveldir_current->author, " (ed.)"));
8656 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8657 setString(&mod_name, leveldir_current->author);
8659 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
8661 // less worried about truncation here
8662 setString(&mod_name, getStringCat2("Mod: ", level.name));
8663 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
8667 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
8668 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8672 for (x = 0; x < lev_fieldx; x++)
8673 for (y = 0; y < lev_fieldy; y++)
8674 dst[x][y] = src[x][y];
8677 static int setSelectboxValue(int selectbox_id, int new_value)
8679 int new_index_value = 0;
8682 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8683 if (selectbox_info[selectbox_id].options[i].value == new_value)
8684 new_index_value = i;
8686 *selectbox_info[selectbox_id].value =
8687 selectbox_info[selectbox_id].options[new_index_value].value;
8689 return new_index_value;
8692 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8696 // change action mode and arg variables according to action type variable
8697 for (i = 0; action_arg_options[i].value != -1; i++)
8699 if (action_arg_options[i].value == custom_element_change.action_type)
8701 int mode = action_arg_options[i].mode;
8703 // only change if corresponding selectbox has changed
8704 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8705 action_arg_modes[mode])
8706 custom_element_change.action_mode = -1;
8708 // only change if corresponding selectbox has changed
8709 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8710 action_arg_options[i].options)
8711 custom_element_change.action_arg = -1;
8718 static void setSelectboxSpecialActionOptions(void)
8722 // change action mode and arg selectbox according to action type selectbox
8723 for (i = 0; action_arg_options[i].value != -1; i++)
8725 if (action_arg_options[i].value == custom_element_change.action_type)
8727 int mode = action_arg_options[i].mode;
8729 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8730 action_arg_modes[mode]);
8731 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8732 custom_element_change.action_mode);
8734 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8735 action_arg_options[i].options);
8736 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8737 custom_element_change.action_arg);
8743 static void copy_custom_element_settings(int element_from, int element_to)
8745 struct ElementInfo *ei_from = &element_info[element_from];
8746 struct ElementInfo *ei_to = &element_info[element_to];
8748 copyElementInfo(ei_from, ei_to);
8751 static void replace_custom_element_in_settings(int element_from,
8756 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8758 struct ElementInfo *ei = &element_info[i];
8760 for (y = 0; y < 3; y++)
8761 for (x = 0; x < 3; x++)
8762 if (ei->content.e[x][y] == element_from)
8763 ei->content.e[x][y] = element_to;
8765 for (j = 0; j < ei->num_change_pages; j++)
8767 struct ElementChangeInfo *change = &ei->change_page[j];
8769 if (change->target_element == element_from)
8770 change->target_element = element_to;
8772 if (change->initial_trigger_element == element_from)
8773 change->initial_trigger_element = element_to;
8775 if (change->action_element == element_from)
8776 change->action_element = element_to;
8778 for (y = 0; y < 3; y++)
8779 for (x = 0; x < 3; x++)
8780 if (change->target_content.e[x][y] == element_from)
8781 change->target_content.e[x][y] = element_to;
8784 if (ei->group != NULL) // group or internal
8785 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8786 if (ei->group->element[j] == element_from)
8787 ei->group->element[j] = element_to;
8791 static void replace_custom_element_in_playfield(int element_from,
8796 for (x = 0; x < lev_fieldx; x++)
8797 for (y = 0; y < lev_fieldy; y++)
8798 if (Tile[x][y] == element_from)
8799 Tile[x][y] = element_to;
8802 static boolean CopyCustomElement(int element_old, int element_new,
8805 int copy_mode_orig = copy_mode;
8807 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8809 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8810 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8811 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8813 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8815 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8816 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8817 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8819 level.changed = TRUE;
8821 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8823 Request("Please choose custom element!", REQ_CONFIRM);
8827 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8829 Request("Please choose group element!", REQ_CONFIRM);
8833 else if (IS_EMPTY_ELEMENT(element_old) && !IS_EMPTY_ELEMENT(element_new))
8835 Request("Please choose empty element!", REQ_CONFIRM);
8841 level.changed = TRUE;
8844 // when modifying custom/group element, ask for copying level template
8845 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8847 if (!AskToCopyAndModifyLevelTemplate())
8851 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8853 copy_custom_element_settings(element_new, element_old);
8855 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8857 copy_custom_element_settings(element_old, element_new);
8859 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8861 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8862 copy_custom_element_settings(element_new, element_old);
8863 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8865 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8866 replace_custom_element_in_settings(element_new, element_old);
8867 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8869 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8870 replace_custom_element_in_playfield(element_new, element_old);
8871 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8874 UpdateCustomElementGraphicGadgets();
8875 DrawPropertiesWindow();
8880 static void CopyCustomElementPropertiesToEditor(int element)
8883 int current_change_page = element_info[element].current_change_page;
8885 // dynamically (re)build selectbox for selecting change page
8886 for (i = 0; i < element_info[element].num_change_pages; i++)
8888 sprintf(options_change_page_strings[i], "%d", i + 1);
8890 options_change_page[i].value = i;
8891 options_change_page[i].text = options_change_page_strings[i];
8894 options_change_page[i].value = -1;
8895 options_change_page[i].text = NULL;
8897 // needed here to initialize combined element properties
8898 InitElementPropertiesEngine(level.game_version);
8900 element_info[element].change =
8901 &element_info[element].change_page[current_change_page];
8903 custom_element = element_info[element];
8904 custom_element_change = *element_info[element].change;
8906 // needed to initially set selectbox options for special action options
8907 setSelectboxSpecialActionOptions();
8909 // needed to initially set selectbox value variables to reliable defaults
8910 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8911 setSelectboxValue(i, *selectbox_info[i].value);
8913 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8914 custom_element_properties[i] = HAS_PROPERTY(element, i);
8916 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8917 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8919 // ---------- element settings: configure (custom elements) -----------------
8921 // set accessible layer selectbox help value
8922 custom_element.access_type =
8923 (IS_WALKABLE(element) ? EP_WALKABLE :
8924 IS_PASSABLE(element) ? EP_PASSABLE :
8925 custom_element.access_type);
8926 custom_element.access_layer =
8927 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8928 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8929 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8930 custom_element.access_layer);
8931 custom_element.access_protected =
8932 (IS_PROTECTED(element) ? 1 : 0);
8933 custom_element_properties[EP_ACCESSIBLE] =
8934 (IS_ACCESSIBLE_OVER(element) ||
8935 IS_ACCESSIBLE_INSIDE(element) ||
8936 IS_ACCESSIBLE_UNDER(element));
8938 // set walk-to-object action selectbox help value
8939 custom_element.walk_to_action =
8940 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8941 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8942 IS_DROPPABLE(element) ? EP_DROPPABLE :
8943 IS_THROWABLE(element) ? EP_THROWABLE :
8944 IS_PUSHABLE(element) ? EP_PUSHABLE :
8945 custom_element.walk_to_action);
8946 custom_element_properties[EP_WALK_TO_OBJECT] =
8947 (IS_DIGGABLE(element) ||
8948 IS_COLLECTIBLE_ONLY(element) ||
8949 IS_DROPPABLE(element) ||
8950 IS_THROWABLE(element) ||
8951 IS_PUSHABLE(element));
8953 // set smash targets selectbox help value
8954 custom_element.smash_targets =
8955 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8956 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8957 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8958 custom_element.smash_targets);
8959 custom_element_properties[EP_CAN_SMASH] =
8960 (CAN_SMASH_EVERYTHING(element) ||
8961 CAN_SMASH_ENEMIES(element) ||
8962 CAN_SMASH_PLAYER(element));
8964 // set deadliness selectbox help value
8965 custom_element.deadliness =
8966 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8967 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8968 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8969 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8970 custom_element.deadliness);
8971 custom_element_properties[EP_DEADLY] =
8972 (DONT_TOUCH(element) ||
8973 DONT_GET_HIT_BY(element) ||
8974 DONT_COLLIDE_WITH(element) ||
8975 DONT_RUN_INTO(element));
8977 // ---------- element settings: advanced (custom elements) ------------------
8979 // set "change by direct action" selectbox help value
8980 custom_element_change.direct_action =
8981 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
8982 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8983 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8984 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8985 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8986 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8987 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8988 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8989 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8990 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8991 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8992 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8993 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8994 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8995 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8996 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8997 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8998 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8999 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
9000 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
9001 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
9002 custom_element_change.direct_action);
9004 // set "change by other element action" selectbox help value
9005 custom_element_change.other_action =
9006 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
9007 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
9008 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
9009 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
9010 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
9011 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
9012 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
9013 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
9014 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
9015 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
9016 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
9017 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
9018 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
9019 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
9020 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
9021 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
9022 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
9023 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
9024 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
9025 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
9026 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
9027 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
9028 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
9029 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
9030 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
9031 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
9032 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
9033 custom_element_change.other_action);
9036 static void CopyGroupElementPropertiesToEditor(int element)
9038 group_element_info = *element_info[element].group;
9039 custom_element = element_info[element]; // needed for description
9042 static void CopyEmptyElementPropertiesToEditor(int element)
9044 custom_element = element_info[element];
9047 static void CopyClassicElementPropertiesToEditor(int element)
9049 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9050 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
9051 getMoveIntoAcidProperty(&level, element);
9053 if (MAYBE_DONT_COLLIDE_WITH(element))
9054 custom_element_properties[EP_DONT_COLLIDE_WITH] =
9055 getDontCollideWithProperty(&level, element);
9058 static void CopyElementPropertiesToEditor(int element)
9060 if (IS_CUSTOM_ELEMENT(element))
9061 CopyCustomElementPropertiesToEditor(element);
9062 else if (IS_GROUP_ELEMENT(element))
9063 CopyGroupElementPropertiesToEditor(element);
9064 else if (IS_EMPTY_ELEMENT(element))
9065 CopyEmptyElementPropertiesToEditor(element);
9067 CopyClassicElementPropertiesToEditor(element);
9070 static boolean AskToCopyAndModifyLevelTemplate(void)
9072 if (Request("Copy and modify settings from level template?", REQ_ASK))
9074 level.use_custom_template = FALSE;
9076 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
9077 GDI_CHECKED, FALSE, GDI_END);
9078 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
9079 GDI_CHECKED, FALSE, GDI_END);
9085 LoadLevelTemplate(-1); // this resets all element modifications ...
9087 DrawEditModeWindow(); // ... and copies them to 'custom_element'
9093 static void CopyCustomElementPropertiesToGame(int element)
9096 int access_type_and_layer;
9098 // mark that this custom element has been modified
9099 custom_element.modified_settings = TRUE;
9100 level.changed = TRUE;
9102 if (level.use_custom_template)
9103 AskToCopyAndModifyLevelTemplate();
9105 element_info[element] = custom_element;
9106 *element_info[element].change = custom_element_change;
9108 // ---------- element settings: configure (custom elements) -----------------
9110 // set accessible property from checkbox and selectbox
9111 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
9112 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
9113 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
9114 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
9115 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
9116 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
9117 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
9118 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
9119 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
9120 custom_element_properties[access_type_and_layer] =
9121 custom_element_properties[EP_ACCESSIBLE];
9122 custom_element_properties[EP_PROTECTED] =
9123 (custom_element.access_protected != 0 &&
9124 custom_element_properties[EP_ACCESSIBLE]);
9126 // set walk-to-object property from checkbox and selectbox
9127 custom_element_properties[EP_DIGGABLE] = FALSE;
9128 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
9129 custom_element_properties[EP_DROPPABLE] = FALSE;
9130 custom_element_properties[EP_THROWABLE] = FALSE;
9131 custom_element_properties[EP_PUSHABLE] = FALSE;
9132 custom_element_properties[custom_element.walk_to_action] =
9133 custom_element_properties[EP_WALK_TO_OBJECT];
9135 // set smash property from checkbox and selectbox
9136 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
9137 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
9138 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
9139 custom_element_properties[custom_element.smash_targets] =
9140 custom_element_properties[EP_CAN_SMASH];
9142 // set deadliness property from checkbox and selectbox
9143 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
9144 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
9145 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
9146 custom_element_properties[EP_DONT_TOUCH] = FALSE;
9147 custom_element_properties[custom_element.deadliness] =
9148 custom_element_properties[EP_DEADLY];
9150 // ---------- element settings: advanced (custom elements) ------------------
9152 // set player change event from checkbox and selectbox
9153 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
9154 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
9155 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
9156 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
9157 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
9158 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
9159 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
9160 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
9161 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
9162 custom_element_change_events[CE_SWITCHED] = FALSE;
9163 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
9164 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
9165 custom_element_change_events[CE_BLOCKED] = FALSE;
9166 custom_element_change_events[CE_IMPACT] = FALSE;
9167 custom_element_change_events[CE_SMASHED] = FALSE;
9168 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
9169 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
9170 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
9171 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
9172 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
9173 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
9174 custom_element_change_events[custom_element_change.direct_action] =
9175 custom_element_change_events[CE_BY_DIRECT_ACTION];
9177 // set other element action change event from checkbox and selectbox
9178 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
9179 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
9180 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
9181 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
9182 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
9183 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
9184 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
9185 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
9186 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
9187 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
9188 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
9189 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
9190 custom_element_change_events[CE_TOUCHING_X] = FALSE;
9191 custom_element_change_events[CE_HITTING_X] = FALSE;
9192 custom_element_change_events[CE_DIGGING_X] = FALSE;
9193 custom_element_change_events[CE_HIT_BY_X] = FALSE;
9194 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
9195 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
9196 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
9197 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
9198 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
9199 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
9200 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
9201 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
9202 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
9203 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
9204 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
9205 custom_element_change_events[custom_element_change.other_action] =
9206 custom_element_change_events[CE_BY_OTHER_ACTION];
9208 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
9209 SET_PROPERTY(element, i, custom_element_properties[i]);
9211 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
9212 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
9214 // copy change events also to special level editor variable
9215 custom_element = element_info[element];
9216 custom_element_change = *element_info[element].change;
9218 // needed here to restore runtime value "element_info[element].gfx_element"
9219 InitElementPropertiesGfxElement();
9222 static void CopyGroupElementPropertiesToGame(int element)
9224 // mark that this group element has been modified
9225 custom_element.modified_settings = TRUE;
9226 level.changed = TRUE;
9228 if (level.use_custom_template)
9229 AskToCopyAndModifyLevelTemplate();
9231 element_info[element] = custom_element;
9232 *element_info[element].group = group_element_info;
9234 // needed here to restore runtime value "element_info[element].gfx_element"
9235 InitElementPropertiesGfxElement();
9238 static void CopyEmptyElementPropertiesToGame(int element)
9240 // mark that this empty element has been modified
9241 custom_element.modified_settings = TRUE;
9242 level.changed = TRUE;
9244 if (level.use_custom_template)
9245 AskToCopyAndModifyLevelTemplate();
9247 element_info[element] = custom_element;
9249 // needed here to restore runtime value "element_info[element].gfx_element"
9250 InitElementPropertiesGfxElement();
9253 static void CopyClassicElementPropertiesToGame(int element)
9255 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9256 setMoveIntoAcidProperty(&level, element,
9257 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
9259 if (MAYBE_DONT_COLLIDE_WITH(element))
9260 setDontCollideWithProperty(&level, element,
9261 custom_element_properties[EP_DONT_COLLIDE_WITH]);
9264 static void CopyElementPropertiesToGame(int element)
9266 if (IS_CUSTOM_ELEMENT(element))
9267 CopyCustomElementPropertiesToGame(element);
9268 else if (IS_GROUP_ELEMENT(element))
9269 CopyGroupElementPropertiesToGame(element);
9270 else if (IS_EMPTY_ELEMENT(element))
9271 CopyEmptyElementPropertiesToGame(element);
9273 CopyClassicElementPropertiesToGame(element);
9277 static void CheckElementDescriptions(void)
9281 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
9282 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
9283 Warn("no element description file for element '%s'", EL_NAME(i));
9287 static int getMaxEdFieldX(boolean has_scrollbar)
9289 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
9290 int sxsize = SXSIZE - scrollbar_width;
9291 int max_ed_fieldx = sxsize / ed_tilesize;
9293 return max_ed_fieldx;
9296 static int getMaxEdFieldY(boolean has_scrollbar)
9298 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
9299 INFOTEXT_YSIZE_FULL : 0);
9300 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
9301 int sysize = SYSIZE - scrollbar_height - infotext_height;
9302 int max_ed_fieldy = sysize / ed_tilesize;
9304 return max_ed_fieldy;
9307 static void InitZoomLevelSettings(int zoom_tilesize)
9309 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
9311 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
9313 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
9314 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
9316 // make sure that tile size is always a power of 2
9317 ed_tilesize = (1 << log_2(ed_tilesize));
9319 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9321 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
9322 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
9326 last_game_engine_type = level.game_engine_type;
9328 // limit zoom tilesize by upper and lower bound
9329 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
9331 // store zoom tilesize in auto setup file only if it was manually changed
9332 if (zoom_tilesize != -1)
9333 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
9335 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
9336 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
9339 static void InitDrawingElements(void)
9341 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
9343 if (level.game_engine_type == game_engine_type_last)
9346 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9348 new_element1 = EL_BD_WALL;
9349 new_element2 = EL_EMPTY;
9350 new_element3 = EL_BD_SAND;
9352 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
9354 new_element1 = EL_SP_CHIP_SINGLE;
9355 new_element2 = EL_EMPTY;
9356 new_element3 = EL_SP_BASE;
9358 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9360 new_element1 = EL_MM_MIRROR_START;
9361 new_element2 = EL_EMPTY;
9362 new_element3 = EL_MM_WOODEN_WALL;
9366 new_element1 = EL_WALL;
9367 new_element2 = EL_EMPTY;
9368 new_element3 = EL_SAND;
9371 game_engine_type_last = level.game_engine_type;
9374 static void InitLevelSetInfo(void)
9376 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
9377 "%s", leveldir_current->name);
9378 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
9379 "%s", leveldir_current->author);
9381 levelset_num_levels = leveldir_current->levels;
9383 levelset_use_levelset_artwork = FALSE;
9384 levelset_copy_level_template = FALSE;
9386 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
9389 static void ChangeEditorToLevelSet(char *levelset_subdir)
9391 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
9393 // the previous level set might have used custom artwork
9394 ReloadCustomArtwork(0);
9396 LoadLevelSetup_SeriesInfo();
9398 SaveLevelSetup_LastSeries();
9399 SaveLevelSetup_SeriesInfo();
9403 LoadLevel(level_nr);
9404 LoadScore(level_nr);
9409 static boolean useEditorDoorAnimation(void)
9411 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
9412 boolean door_1_viewport_unchanged =
9413 (vp_door_1->x == DX &&
9414 vp_door_1->y == DY &&
9415 vp_door_1->width == DXSIZE &&
9416 vp_door_1->height == DYSIZE);
9417 boolean door_1_contains_toolbox =
9420 EX + EXSIZE <= DX + DXSIZE &&
9421 EY + EYSIZE <= DY + DYSIZE);
9423 return (door_1_viewport_unchanged && door_1_contains_toolbox);
9426 static void DrawEditorDoorBackground(int graphic, int x, int y,
9427 int width, int height)
9429 struct GraphicInfo *g = &graphic_info[graphic];
9431 if (g->bitmap != NULL)
9432 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
9433 MIN(width, g->width), MIN(height, g->height), x, y);
9435 ClearRectangle(drawto, x, y, width, height);
9438 static void DrawEditorDoorContent(void)
9440 // needed for gadgets drawn on background (like palette scrollbar)
9441 SetDoorBackgroundImage(IMG_UNDEFINED);
9443 // copy default editor door content to main double buffer
9444 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
9447 DrawSpecialEditorDoor();
9449 // draw new control window
9450 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
9452 // draw all toolbox gadgets to editor doors
9453 MapControlButtons();
9455 // when returning from test game to properties page, redraw toolbox gadgets
9456 if (edit_mode == ED_MODE_PROPERTIES)
9458 UnmapLevelEditorToolboxDrawingGadgets();
9459 UnmapLevelEditorToolboxCustomGadgets();
9461 MapLevelEditorToolboxCustomGadgetsIfNeeded();
9464 // draw all palette gadgets to editor doors
9465 ModifyEditorElementList();
9466 RedrawDrawingElements();
9468 // copy actual editor door content to door double buffer for OpenDoor()
9469 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
9472 void DrawLevelEd(void)
9474 int fade_mask = REDRAW_FIELD;
9476 FadeSoundsAndMusic();
9479 fade_mask = REDRAW_ALL;
9483 // needed if different viewport properties defined for editor
9484 ChangeViewportPropertiesIfNeeded();
9488 InitZoomLevelSettings(-1);
9489 InitDrawingElements();
9493 CheckElementDescriptions();
9496 if (level_editor_test_game)
9498 CopyPlayfield(level.field, Tile);
9499 CopyPlayfield(TileBackup, level.field);
9501 level_editor_test_game = FALSE;
9505 edit_mode = ED_MODE_DRAWING;
9506 edit_mode_levelconfig = ED_MODE_LEVELCONFIG_LEVEL;
9507 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
9515 // redraw_mask |= REDRAW_ALL;
9517 FreeLevelEditorGadgets();
9518 CreateLevelEditorGadgets();
9520 ReinitializeElementList(); // update dynamic level element list
9521 ReinitializeElementListButtons(); // custom element may look different
9523 InitElementPropertiesGfxElement();
9527 DrawEditModeWindow_PlayfieldOnly();
9529 DrawMaskedBorder(fade_mask);
9531 // use door animation if door 1 viewport is unchanged and contains toolbox
9532 if (useEditorDoorAnimation())
9536 DrawEditorDoorContent();
9538 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
9542 DrawEditorDoorContent();
9547 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
9550 static void AdjustDrawingAreaGadgets(void)
9552 int ed_xsize = lev_fieldx + 2;
9553 int ed_ysize = lev_fieldy + 2;
9554 int max_ed_fieldx = MAX_ED_FIELDX;
9555 int max_ed_fieldy = MAX_ED_FIELDY;
9556 boolean horizontal_scrollbar_needed;
9557 boolean vertical_scrollbar_needed;
9558 int x, y, width, height;
9560 if (suppressBorderElement())
9562 ed_xsize = lev_fieldx;
9563 ed_ysize = lev_fieldy;
9566 // check if we need any scrollbars
9567 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9568 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9570 // check if we have a smaller editor field because of scrollbars
9571 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9572 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9574 // check again if we now need more scrollbars because of less space
9575 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9576 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9578 // check if editor field gets even smaller after adding new scrollbars
9579 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9580 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9582 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
9583 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
9585 x = SX + ed_fieldx * ed_tilesize;
9586 y = SY + ed_fieldy * ed_tilesize;
9588 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
9589 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
9591 // adjust drawing area gadget
9592 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
9593 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
9594 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
9597 // adjust horizontal scrollbar gadgets
9598 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
9601 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
9602 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
9605 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9608 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
9611 // adjust vertical scrollbar gadgets
9612 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
9615 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
9617 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
9619 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9622 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
9626 static void AdjustLevelScrollPosition(void)
9628 if (level_xpos < -1)
9630 if (level_xpos > lev_fieldx - ed_fieldx + 1)
9631 level_xpos = lev_fieldx - ed_fieldx + 1;
9632 if (lev_fieldx < ed_fieldx - 2)
9635 if (level_ypos < -1)
9637 if (level_ypos > lev_fieldy - ed_fieldy + 1)
9638 level_ypos = lev_fieldy - ed_fieldy + 1;
9639 if (lev_fieldy < ed_fieldy - 2)
9642 if (suppressBorderElement())
9649 static void AdjustEditorScrollbar(int id)
9651 struct GadgetInfo *gi = level_editor_gadget[id];
9652 int items_max, items_visible, item_position;
9654 if (id == GADGET_ID_SCROLL_HORIZONTAL)
9656 items_max = MAX(lev_fieldx + 2, ed_fieldx);
9657 items_visible = ed_fieldx;
9658 item_position = level_xpos + 1;
9662 items_max = MAX(lev_fieldy + 2, ed_fieldy);
9663 items_visible = ed_fieldy;
9664 item_position = level_ypos + 1;
9667 if (item_position > items_max - items_visible)
9668 item_position = items_max - items_visible;
9670 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9671 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9674 static void AdjustElementListScrollbar(void)
9676 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
9677 int items_max, items_visible, item_position;
9679 // correct position of element list scrollbar
9680 if (element_shift < 0)
9682 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9683 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9685 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
9686 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
9687 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
9689 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9690 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
9691 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9694 static void ModifyEditorCounterValue(int counter_id, int new_value)
9696 int *counter_value = counterbutton_info[counter_id].value;
9697 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9698 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9700 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9702 if (counter_value != NULL)
9703 *counter_value = gi->textinput.number_value;
9706 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9708 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9709 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9711 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9713 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9714 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9716 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9717 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9719 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9720 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9725 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9727 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9728 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9729 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9731 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9734 static void ModifyEditorSelectboxOptions(int selectbox_id,
9735 struct ValueTextInfo *options)
9737 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9738 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9740 selectbox_info[selectbox_id].options = options;
9742 // set index to zero -- list may be shorter now (correct later, if needed)
9743 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9744 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9747 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9749 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9750 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9752 drawingarea_info[drawingarea_id].area_xsize = xsize;
9753 drawingarea_info[drawingarea_id].area_ysize = ysize;
9755 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9758 static void ModifyEditorElementList(void)
9762 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9765 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9767 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9768 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9769 struct GadgetDesign *gd = &gi->deco.design;
9770 int element = editor_elements[element_shift + i];
9771 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9775 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9777 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9783 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9785 int graphic = el2edimg(element);
9786 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9792 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9795 static void ModifyDrawingElementButton(int element, int id)
9797 struct GadgetInfo *gi = level_editor_gadget[id];
9798 Bitmap *deco_bitmap;
9800 int tile_size = gi->deco.width;
9802 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9804 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9807 static void PickDrawingElement(int button, int element)
9812 struct XYTileSize *pos;
9814 } de, drawing_elements[] =
9816 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9817 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9818 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9821 if (button < 1 || button > 3)
9824 if (IS_MM_WALL(element))
9825 element = map_mm_wall_element(element);
9827 de = drawing_elements[button - 1];
9829 *de.new_element = element; // update global drawing element variable
9831 DrawDrawingElementGraphic(element, de.pos);
9832 ModifyDrawingElementButton(element, de.id);
9834 redraw_mask |= REDRAW_DOOR_1;
9837 static void RedrawDrawingElements(void)
9839 PickDrawingElement(1, new_element1);
9840 PickDrawingElement(2, new_element2);
9841 PickDrawingElement(3, new_element3);
9844 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9846 stick_element_properties_window = FALSE;
9848 SetMainBackgroundImage(IMG_UNDEFINED);
9851 UnmapLevelEditorFieldGadgets();
9853 AdjustDrawingAreaGadgets();
9854 AdjustLevelScrollPosition();
9855 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9856 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9858 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9860 MapMainDrawingArea();
9862 if (remap_toolbox_gadgets)
9864 UnmapLevelEditorToolboxCustomGadgets();
9865 MapLevelEditorToolboxDrawingGadgets();
9869 static void DrawDrawingWindow(void)
9871 DrawDrawingWindowExt(TRUE);
9874 static int getTabulatorBarWidth(void)
9876 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9877 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9879 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9882 static int getTabulatorBarHeight(void)
9884 return ED_TAB_BAR_HEIGHT;
9887 static Pixel getTabulatorBarColor(void)
9889 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9890 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9891 int gd_x = gd->x + gd_gi1->border.width / 2;
9892 int gd_y = gd->y + gd_gi1->height - 1;
9894 return GetPixel(gd->bitmap, gd_x, gd_y);
9897 static void DrawLevelConfigTabulatorGadgets(void)
9899 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9900 Pixel tab_color = getTabulatorBarColor();
9901 int id_first = ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL;
9902 int id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR;
9905 // draw additional "engine" tabulator when using native BD engine
9906 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9907 id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE;
9909 for (i = id_first; i <= id_last; i++)
9911 int gadget_id = textbutton_info[i].gadget_id;
9912 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9913 boolean active = (i != edit_mode_levelconfig);
9915 // draw background line below tabulator button
9916 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9918 // draw solid line below inactive tabulator buttons
9919 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9920 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9921 ED_GADGET_TINY_DISTANCE, tab_color);
9923 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9924 MapTextbuttonGadget(i);
9927 // draw little border line below tabulator buttons
9928 if (tab_color != BLACK_PIXEL) // black => transparent
9929 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9930 ED_GADGET_TINY_DISTANCE,
9931 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9934 static void DrawPropertiesTabulatorGadgets(void)
9936 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9937 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9938 int gd_x = gd->x + gd_gi1->border.width / 2;
9939 int gd_y = gd->y + gd_gi1->height - 1;
9940 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9941 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9942 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9945 // draw two config tabulators for player elements
9946 if (IS_PLAYER_ELEMENT(properties_element))
9947 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9949 // draw two config and one "change" tabulator for custom elements
9950 if (IS_CUSTOM_ELEMENT(properties_element))
9951 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9953 for (i = id_first; i <= id_last; i++)
9955 int gadget_id = textbutton_info[i].gadget_id;
9956 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9957 boolean active = (i != edit_mode_properties);
9959 // use "config 1" and "config 2" instead of "config" for players and CEs
9960 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9961 (IS_PLAYER_ELEMENT(properties_element) ||
9962 IS_CUSTOM_ELEMENT(properties_element)))
9965 // draw background line below tabulator button
9966 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9968 // draw solid line below inactive tabulator buttons
9969 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9970 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9971 ED_GADGET_TINY_DISTANCE, tab_color);
9973 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9974 MapTextbuttonGadget(i);
9977 // draw little border line below tabulator buttons
9978 if (tab_color != BLACK_PIXEL) // black => transparent
9979 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9980 ED_GADGET_TINY_DISTANCE,
9981 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9984 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9986 DrawText(SX + xpos, SY + ypos, text, font_nr);
9989 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9992 int font_width = getFontWidth(font_nr);
9993 int font_height = getFontHeight(font_nr);
9994 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9995 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9997 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9998 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9999 TRUE, FALSE, FALSE);
10002 static void DrawLevelConfigLevel(void)
10006 // draw counter gadgets
10007 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
10008 MapCounterButtons(i);
10010 // draw checkbutton gadgets
10011 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
10012 MapCheckbuttonGadget(i);
10014 // draw selectbox gadgets
10015 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
10016 MapSelectboxGadget(i);
10018 // draw text input gadgets
10019 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
10020 MapTextInputGadget(i);
10023 static char *getLevelSubdirFromSaveMode(int save_mode)
10025 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
10026 return getNewUserLevelSubdir();
10028 return leveldir_current->subdir;
10031 static void DrawLevelConfigLevelSet_DirectoryInfo(void)
10033 char *directory_text = "Level set directory:";
10034 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
10035 int font1_nr = FONT_TEXT_1;
10036 int font2_nr = FONT_TEXT_2;
10037 int font1_height = getFontHeight(font1_nr);
10038 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
10039 int x = ED_LEVEL_SETTINGS_X(0);
10040 int y = ED_LEVEL_SETTINGS_Y(6);
10042 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
10043 PrintInfoText(directory_name, font2_nr, x, y);
10046 static void DrawLevelConfigLevelSet(void)
10048 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
10049 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
10052 // draw counter gadgets
10053 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
10054 MapCounterButtons(i);
10056 // draw checkbutton gadgets
10057 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
10059 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
10060 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
10061 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
10064 MapCheckbuttonGadget(i);
10067 // draw selectbox gadgets
10068 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
10069 MapSelectboxGadget(i);
10071 // draw text input gadgets
10072 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
10073 MapTextInputGadget(i);
10075 // draw textbutton gadgets
10076 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
10079 DrawLevelConfigLevelSet_DirectoryInfo();
10082 static void DrawLevelConfigEditor(void)
10086 // draw counter gadgets
10087 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
10088 MapCounterButtons(i);
10090 // draw checkbutton gadgets
10091 for (i = ED_CHECKBUTTON_ID_EDITOR_FIRST; i <= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
10092 MapCheckbuttonGadget(i);
10094 // draw radiobutton gadgets
10095 for (i = ED_RADIOBUTTON_ID_EDITOR_FIRST; i <= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
10096 MapRadiobuttonGadget(i);
10098 // draw drawing area
10099 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
10101 // draw textbutton gadgets
10102 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
10105 static void DrawLevelConfigEngine(void)
10109 // draw counter gadgets
10110 if (level.bd_scheduling_type == GD_SCHEDULING_MILLISECONDS)
10112 MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_MS);
10113 MapCounterButtons(ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES);
10117 MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_C64);
10118 MapCounterButtons(ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS);
10121 // draw checkbutton gadgets
10122 for (i = ED_CHECKBUTTON_ID_ENGINE_FIRST; i <= ED_CHECKBUTTON_ID_ENGINE_LAST; i++)
10123 MapCheckbuttonGadget(i);
10125 // draw selectbox gadgets
10126 for (i = ED_SELECTBOX_ID_ENGINE_FIRST; i <= ED_SELECTBOX_ID_ENGINE_LAST; i++)
10127 MapSelectboxGadget(i);
10130 static void DrawLevelConfigWindow(void)
10132 char *text = "Global Settings";
10133 int font_nr = FONT_TITLE_1;
10134 struct MenuPosInfo *pos = &editor.settings.headline;
10135 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
10136 int sy = SY + pos->y;
10138 stick_element_properties_window = FALSE;
10140 SetAutomaticNumberOfGemsNeeded();
10142 UnmapLevelEditorFieldGadgets();
10144 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10147 DrawText(sx, sy, text, font_nr);
10149 DrawLevelConfigTabulatorGadgets();
10151 if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVEL)
10152 DrawLevelConfigLevel();
10153 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVELSET)
10154 DrawLevelConfigLevelSet();
10155 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_EDITOR)
10156 DrawLevelConfigEditor();
10157 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_ENGINE)
10158 DrawLevelConfigEngine();
10161 static void DrawCustomContentArea(void)
10163 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
10164 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10165 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
10166 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
10167 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
10168 int xoffset = ED_GADGET_SPACE_DISTANCE;
10170 // add distance for potential left text (without drawing area border)
10171 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
10173 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10175 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
10178 static void DrawCustomChangeContentArea(void)
10180 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
10181 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10182 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
10183 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
10184 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
10185 int xoffset = ED_GADGET_SPACE_DISTANCE;
10187 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10189 MapDrawingArea(id);
10192 static void RemoveElementContentArea(int id, int font_height)
10194 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10196 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
10197 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
10198 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10199 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
10200 ED_GADGET_TEXT_DISTANCE + font_height);
10203 static void DrawYamYamContentAreas(void)
10205 int font_nr = FONT_TEXT_1;
10206 int font_height = getFontHeight(font_nr);
10207 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10208 int yoffset = (tilesize - font_height) / 2;
10209 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
10210 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
10213 // display counter to choose number of element content areas
10214 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
10216 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10218 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
10220 if (i < level.num_yamyam_contents)
10222 MapDrawingArea(id);
10226 UnmapDrawingArea(id);
10228 // delete content areas in case of reducing number of them
10229 RemoveElementContentArea(id, font_height);
10233 DrawText(x, y + 0 * tilesize, "content", font_nr);
10234 DrawText(x, y + 1 * tilesize, "when", font_nr);
10235 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
10238 static void DrawMagicBallContentAreas(void)
10240 int font_nr = FONT_TEXT_1;
10241 int font_height = getFontHeight(font_nr);
10242 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10243 int yoffset = (tilesize - font_height) / 2;
10244 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
10245 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
10248 // display counter to choose number of element content areas
10249 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
10251 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10253 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
10255 if (i < level.num_ball_contents)
10257 MapDrawingArea(id);
10261 UnmapDrawingArea(id);
10263 // delete content areas in case of reducing number of them
10264 RemoveElementContentArea(id, font_height);
10268 DrawText(x, y + 0 * tilesize, "generated", font_nr);
10269 DrawText(x, y + 1 * tilesize, "when", font_nr);
10270 DrawText(x, y + 2 * tilesize, "active", font_nr);
10273 static void DrawAndroidElementArea(void)
10275 int id = ED_DRAWING_ID_ANDROID_CONTENT;
10276 int num_elements = level.num_android_clone_elements;
10277 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10278 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10279 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10280 int xsize = MAX_ANDROID_ELEMENTS;
10283 // display counter to choose number of element areas
10284 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
10286 if (drawingarea_info[id].text_left != NULL)
10287 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10289 UnmapDrawingArea(id);
10291 ModifyEditorDrawingArea(id, num_elements, 1);
10293 // delete content areas in case of reducing number of them
10294 DrawBackground(sx, sy,
10295 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10296 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10298 MapDrawingArea(id);
10301 static void DrawGroupElementArea(void)
10303 int id = ED_DRAWING_ID_GROUP_CONTENT;
10304 int num_elements = group_element_info.num_elements;
10305 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10306 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10307 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10308 int xsize = MAX_ELEMENTS_IN_GROUP;
10311 if (drawingarea_info[id].text_left != NULL)
10312 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10314 UnmapDrawingArea(id);
10316 ModifyEditorDrawingArea(id, num_elements, 1);
10318 // delete content areas in case of reducing number of them
10319 DrawBackground(sx, sy,
10320 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10321 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10323 MapDrawingArea(id);
10326 static void DrawPlayerInitialInventoryArea(int element)
10328 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
10329 int player_nr = GET_PLAYER_NR(element);
10330 int num_elements = level.initial_inventory_size[player_nr];
10331 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10332 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10333 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10334 int xsize = MAX_INITIAL_INVENTORY_SIZE;
10337 // determine horizontal position to the right of specified gadget
10338 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
10339 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
10340 ED_DRAWINGAREA_TEXT_DISTANCE);
10342 // determine horizontal offset for leading text
10343 if (drawingarea_info[id].text_left != NULL)
10344 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10346 UnmapDrawingArea(id);
10348 ModifyEditorDrawingArea(id, num_elements, 1);
10350 // delete content areas in case of reducing number of them
10351 DrawBackground(sx, sy,
10352 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10353 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10355 MapDrawingArea(id);
10358 static void DrawMMBallContentArea(void)
10360 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
10361 int num_elements = level.num_mm_ball_contents;
10362 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10363 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10364 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10365 int xsize = MAX_MM_BALL_CONTENTS;
10368 if (drawingarea_info[id].text_left != NULL)
10369 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10371 UnmapDrawingArea(id);
10373 ModifyEditorDrawingArea(id, num_elements, 1);
10375 // delete content areas in case of reducing number of them
10376 DrawBackground(sx, sy,
10377 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10378 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10380 MapDrawingArea(id);
10383 static void DrawEnvelopeTextArea(int envelope_nr)
10385 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
10386 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
10390 DrawBackground(gi->x, gi->y,
10391 gi->textarea.crop_width, gi->textarea.crop_height);
10393 if (envelope_nr != -1)
10394 textarea_info[id].value = level.envelope[envelope_nr].text;
10396 ModifyGadget(gi, GDI_AREA_SIZE,
10397 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
10398 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
10401 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
10404 static void DrawPropertiesInfo(void)
10413 // configurable properties
10415 { EP_WALKABLE_OVER, "- player can walk over it" },
10416 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
10417 { EP_WALKABLE_UNDER, "- player can walk under it" },
10418 { EP_PASSABLE_OVER, "- player can pass over it" },
10419 { EP_PASSABLE_INSIDE, "- player can pass through it" },
10420 { EP_PASSABLE_UNDER, "- player can pass under it" },
10421 { EP_PROTECTED, "- player is protected by it" },
10423 { EP_DIGGABLE, "- can be digged away" },
10424 { EP_COLLECTIBLE, "- can be collected" },
10425 { EP_DROPPABLE, "- can be dropped after collecting" },
10426 { EP_THROWABLE, "- can be thrown after collecting" },
10427 { EP_PUSHABLE, "- can be pushed" },
10429 { EP_CAN_FALL, "- can fall" },
10430 { EP_CAN_MOVE, "- can move" },
10432 { EP_CAN_SMASH_PLAYER, "- can smash player" },
10434 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
10436 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
10438 { EP_SLIPPERY, "- slippery for falling elements" },
10439 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
10441 { EP_DONT_RUN_INTO, "- deadly when running into" },
10442 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
10443 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
10444 { EP_DONT_TOUCH, "- deadly when touching" },
10446 { EP_INDESTRUCTIBLE, "- indestructible" },
10448 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
10449 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
10450 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
10452 { EP_CAN_CHANGE, "- can change to other element" },
10454 // pre-defined properties
10455 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
10456 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
10457 { EP_SWITCHABLE, "- can be switched" },
10459 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
10464 char *filename = getElementDescriptionFilename(properties_element);
10465 char *num_elements_text = "In this level: ";
10466 char *num_similar_text = "Similar tiles: ";
10467 char *properties_text = "Standard properties: ";
10468 char *description_text = "Description:";
10469 char *no_description_text = "No description available.";
10470 char *none_text = "None";
10472 int num_elements_in_level = 0;
10473 int num_similar_in_level = 0;
10474 int num_hires_tiles_in_level = 0;
10475 int num_standard_properties = 0;
10476 int font1_nr = FONT_TEXT_1;
10477 int font2_nr = FONT_TEXT_2;
10478 int font1_width = getFontWidth(font1_nr);
10479 int font1_height = getFontHeight(font1_nr);
10480 int font2_height = getFontHeight(font2_nr);
10481 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
10482 int font2_yoffset = (font1_height - font2_height) / 2;
10483 int num_elements_text_len = strlen(num_elements_text) * font1_width;
10484 int num_similar_text_len = strlen(num_similar_text) * font1_width;
10485 int properties_text_len = strlen(properties_text) * font1_width;
10486 int xpos = ED_ELEMENT_SETTINGS_X(0);
10487 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10490 if (setup.editor.show_element_token)
10492 int font3_nr = FONT_TEXT_3;
10493 int font3_height = getFontHeight(font3_nr);
10495 DrawTextF(xpos, ypos, font3_nr,
10496 "[%s]", element_info[properties_element].token_name);
10498 ypos += 2 * font3_height;
10501 // ----- print number of elements / percentage of this element in level
10503 for (y = 0; y < lev_fieldy; y++)
10505 for (x = 0; x < lev_fieldx; x++)
10507 if (Tile[x][y] == properties_element)
10509 num_elements_in_level++;
10511 else if (IS_MM_WALL(Tile[x][y]) &&
10512 map_mm_wall_element(Tile[x][y]) == properties_element)
10514 num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
10519 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10521 DrawTextS(xpos, ypos, font1_nr, num_elements_text);
10523 if (num_hires_tiles_in_level > 0)
10524 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10525 "%d wall tiles", num_hires_tiles_in_level);
10526 else if (num_elements_in_level > 0)
10527 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10528 "%d (%.2f %%)", num_elements_in_level, percentage);
10530 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10533 // ----- print number of similar elements / percentage of them in level
10535 for (y = 0; y < lev_fieldy; y++)
10537 for (x = 0; x < lev_fieldx; x++)
10539 if (strEqual(element_info[Tile[x][y]].class_name,
10540 element_info[properties_element].class_name))
10542 num_similar_in_level++;
10547 if (num_similar_in_level != num_elements_in_level)
10549 ypos += 1 * MAX(font1_height, font2_height);
10551 percentage = num_similar_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10553 DrawTextS(xpos, ypos, font1_nr, num_similar_text);
10555 if (num_similar_in_level > 0)
10556 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10557 "%d (%.2f %%)", num_similar_in_level, percentage);
10559 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10563 ypos += 2 * MAX(font1_height, font2_height);
10565 // ----- print standard properties of this element
10567 DrawTextS(xpos, ypos, font1_nr, properties_text);
10569 ypos += line1_height;
10571 for (i = 0; properties[i].value != -1; i++)
10573 if (!HAS_PROPERTY(properties_element, properties[i].value))
10576 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
10578 ypos += font2_height;
10580 num_standard_properties++;
10583 if (num_standard_properties == 0)
10585 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
10586 font2_nr, none_text);
10588 ypos -= (line1_height - font1_height);
10591 ypos += MAX(font1_height, font2_height);
10593 // ----- print special description of this element
10595 PrintInfoText(description_text, font1_nr, xpos, ypos);
10597 ypos += line1_height;
10599 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
10600 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
10603 #define TEXT_COLLECTING "Score for collecting"
10604 #define TEXT_COLLECTING_EXTRA "Score for extra diamonds"
10605 #define TEXT_SMASHING "Score for smashing"
10606 #define TEXT_SLURPING "Score for slurping robot"
10607 #define TEXT_CRACKING "Score for cracking"
10608 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
10609 #define TEXT_DURATION "Duration when activated"
10610 #define TEXT_DELAY_ON "Delay before activating"
10611 #define TEXT_DELAY_OFF "Delay before deactivating"
10612 #define TEXT_DELAY_CHANGING "Delay before changing"
10613 #define TEXT_DELAY_EXPLODING "Delay before exploding"
10614 #define TEXT_DELAY_MOVING "Delay before moving"
10615 #define TEXT_BALL_DELAY "Element generation delay"
10616 #define TEXT_MOVE_SPEED "Speed of android moving"
10617 #define TEXT_CLONE_SPEED "Speed of android cloning"
10618 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
10619 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
10620 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
10621 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
10622 #define TEXT_TIME_BONUS "Extra time to solve level"
10629 } elements_with_counter[] =
10631 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
10632 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
10633 { EL_BD_DIAMOND, &level.score[SC_DIAMOND_EXTRA], TEXT_COLLECTING_EXTRA },
10634 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
10635 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
10636 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10637 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
10638 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
10639 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
10640 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
10641 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
10642 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10643 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
10644 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10645 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10646 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
10647 { EL_BD_BUTTERFLY_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10648 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
10649 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10650 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10651 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
10652 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10653 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10654 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10655 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10656 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10657 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10658 { EL_BD_FIREFLY_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10659 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10660 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10661 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10662 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10663 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10664 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10665 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10666 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
10667 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
10668 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10669 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
10670 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10671 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10672 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10673 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10674 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10675 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
10676 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10677 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10678 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE], TEXT_COLLECTING },
10679 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10680 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10681 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
10682 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
10683 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
10684 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10685 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10686 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10687 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10688 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10689 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10690 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10691 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10692 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
10693 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
10694 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
10695 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
10696 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
10697 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10698 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
10699 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
10700 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
10701 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10702 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10703 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10704 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10705 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10706 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10707 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10708 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10709 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10710 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10711 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10712 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10713 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10714 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
10715 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10716 { EL_DC_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10717 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
10718 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
10719 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
10720 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
10721 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
10722 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
10723 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
10724 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
10725 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
10726 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
10727 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
10728 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
10729 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
10730 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
10731 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
10732 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
10733 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
10734 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
10735 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
10736 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
10737 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
10738 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
10739 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
10740 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
10741 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
10742 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
10743 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_CHANGING },
10744 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10745 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10750 static boolean checkPropertiesConfig(int element)
10754 // special case: empty space customization only available in R'n'D game engine
10755 if (element == EL_EMPTY_SPACE && level.game_engine_type != GAME_ENGINE_TYPE_RND)
10758 if (IS_GEM(element) ||
10759 IS_CUSTOM_ELEMENT(element) ||
10760 IS_GROUP_ELEMENT(element) ||
10761 IS_EMPTY_ELEMENT(element) ||
10762 IS_BALLOON_ELEMENT(element) ||
10763 IS_ENVELOPE(element) ||
10764 IS_MM_ENVELOPE(element) ||
10765 IS_MM_MCDUFFIN(element) ||
10766 IS_DF_LASER(element) ||
10767 IS_PLAYER_ELEMENT(element) ||
10768 IS_BD_PLAYER_ELEMENT(element) ||
10769 IS_SOKOBAN_OBJECT_OR_FIELD(element) ||
10770 HAS_EDITOR_CONTENT(element) ||
10771 CAN_GROW(element) ||
10772 COULD_MOVE_INTO_ACID(element) ||
10773 MAYBE_DONT_COLLIDE_WITH(element))
10776 for (i = 0; elements_with_counter[i].element != -1; i++)
10777 if (elements_with_counter[i].element == element)
10783 static void SetAutomaticNumberOfGemsNeeded(void)
10787 if (!level.auto_count_gems)
10790 level.gems_needed = 0;
10792 for (x = 0; x < lev_fieldx; x++)
10794 for (y = 0; y < lev_fieldy; y++)
10796 int element = Tile[x][y];
10801 case EL_EMERALD_YELLOW:
10802 case EL_EMERALD_RED:
10803 case EL_EMERALD_PURPLE:
10804 case EL_BD_DIAMOND:
10805 case EL_WALL_EMERALD:
10806 case EL_WALL_EMERALD_YELLOW:
10807 case EL_WALL_EMERALD_RED:
10808 case EL_WALL_EMERALD_PURPLE:
10809 case EL_WALL_BD_DIAMOND:
10811 case EL_SP_INFOTRON:
10814 level.gems_needed++;
10818 case EL_WALL_DIAMOND:
10819 level.gems_needed += 3;
10823 case EL_WALL_PEARL:
10824 level.gems_needed += 5;
10828 case EL_WALL_CRYSTAL:
10829 level.gems_needed += 8;
10838 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10841 static void DrawPropertiesConfig(void)
10843 boolean draw_footer_line = FALSE;
10844 int max_num_element_counters = 4;
10845 int num_element_counters = 0;
10848 if (!checkPropertiesConfig(properties_element))
10850 int xpos = ED_ELEMENT_SETTINGS_X(0);
10851 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10853 PrintInfoText("No configuration options available.",
10854 FONT_TEXT_1, xpos, ypos);
10859 // check if there are elements where a value can be chosen for
10860 for (i = 0; elements_with_counter[i].element != -1; i++)
10862 if (elements_with_counter[i].element == properties_element)
10864 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10866 counterbutton_info[counter_id].y =
10867 ED_ELEMENT_SETTINGS_YPOS(
10868 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10869 (CAN_GROW(properties_element) ? 1 : 0) +
10870 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10871 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10872 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10873 num_element_counters);
10875 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10876 counterbutton_info[counter_id].text_right = elements_with_counter[i].text;
10878 if (properties_element == EL_GAME_OF_LIFE ||
10879 properties_element == EL_BIOMAZE)
10881 counterbutton_info[counter_id].min_value = 0; // min neighbours
10882 counterbutton_info[counter_id].max_value = 8; // max neighbours
10886 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10887 counterbutton_info[counter_id].min_value = MIN_SCORE;
10888 counterbutton_info[counter_id].max_value = MAX_SCORE;
10891 MapCounterButtons(counter_id);
10893 num_element_counters++;
10894 if (num_element_counters >= max_num_element_counters)
10899 if (HAS_EDITOR_CONTENT(properties_element))
10901 // draw stickybutton gadget
10902 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10904 if (IS_AMOEBOID(properties_element))
10905 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10906 else if (properties_element == EL_YAMYAM ||
10907 properties_element == EL_YAMYAM_LEFT ||
10908 properties_element == EL_YAMYAM_RIGHT ||
10909 properties_element == EL_YAMYAM_UP ||
10910 properties_element == EL_YAMYAM_DOWN)
10911 DrawYamYamContentAreas();
10912 else if (properties_element == EL_EMC_MAGIC_BALL)
10914 DrawMagicBallContentAreas();
10916 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10917 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10919 else if (properties_element == EL_EMC_ANDROID)
10920 DrawAndroidElementArea();
10921 else if (properties_element == EL_MM_GRAY_BALL)
10923 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
10924 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
10925 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
10926 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EXPLODE_MM_BALL);
10928 DrawMMBallContentArea();
10932 if (IS_PLAYER_ELEMENT(properties_element))
10934 int player_nr = GET_PLAYER_NR(properties_element);
10936 // these properties can be set for every player individually
10938 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10940 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
10941 &level.start_element[player_nr];
10942 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
10943 &level.artwork_element[player_nr];
10944 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
10945 &level.explosion_element[player_nr];
10947 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10948 &level.use_start_element[player_nr];
10949 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10950 &level.use_artwork_element[player_nr];
10951 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10952 &level.use_explosion_element[player_nr];
10953 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10954 &level.initial_player_gravity[player_nr];
10956 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10957 &level.initial_player_stepsize[player_nr];
10959 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
10960 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
10961 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
10962 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
10963 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
10964 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
10965 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
10966 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
10967 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
10968 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
10969 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
10970 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
10971 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
10972 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
10973 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
10975 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
10976 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
10977 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
10979 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
10981 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10983 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
10984 &level.initial_inventory_content[player_nr][0];
10986 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
10987 &level.initial_inventory_size[player_nr];
10989 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
10990 &level.use_initial_inventory[player_nr];
10992 // draw checkbutton gadgets
10993 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
10994 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
10995 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
10997 // draw counter gadgets
10998 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
11000 // draw drawing area gadgets
11001 DrawPlayerInitialInventoryArea(properties_element);
11005 if (IS_BD_PLAYER_ELEMENT(properties_element))
11006 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS);
11008 // special case: slippery walls option for gems only available in R'n'D game engine
11009 if (IS_GEM(properties_element) && level.game_engine_type == GAME_ENGINE_TYPE_RND)
11011 checkbutton_info[ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS].y =
11012 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_BD_DIAMOND ? 2 : 1);
11014 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
11017 if (properties_element == EL_EM_DYNAMITE)
11018 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
11020 if (COULD_MOVE_INTO_ACID(properties_element) &&
11021 !IS_PLAYER_ELEMENT(properties_element) &&
11022 (!IS_CUSTOM_ELEMENT(properties_element) ||
11023 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
11025 // set position for checkbutton for "can move into acid"
11026 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
11027 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
11028 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
11029 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
11030 IS_BALLOON_ELEMENT(properties_element) ||
11031 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
11033 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
11036 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
11037 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
11039 if (properties_element == EL_SPRING ||
11040 properties_element == EL_SPRING_LEFT ||
11041 properties_element == EL_SPRING_RIGHT)
11042 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
11044 if (properties_element == EL_TIME_ORB_FULL)
11045 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
11047 if (properties_element == EL_GAME_OF_LIFE ||
11048 properties_element == EL_BIOMAZE)
11049 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
11051 if (CAN_GROW(properties_element))
11053 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
11054 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
11056 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
11059 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
11060 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
11062 if (properties_element == EL_SOKOBAN_OBJECT)
11063 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
11065 if (properties_element == EL_SOKOBAN_OBJECT ||
11066 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
11067 properties_element == EL_SOKOBAN_FIELD_FULL)
11069 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
11070 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
11073 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
11076 if (IS_BALLOON_ELEMENT(properties_element))
11077 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
11079 if (IS_ENVELOPE(properties_element) ||
11080 IS_MM_ENVELOPE(properties_element))
11082 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
11083 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
11084 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
11085 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
11086 int envelope_nr = ENVELOPE_NR(properties_element);
11088 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
11089 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
11091 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
11092 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
11094 // display counter to choose size of envelope text area
11095 MapCounterButtons(counter1_id);
11096 MapCounterButtons(counter2_id);
11098 // display checkbuttons to choose auto-wrap and alignment properties
11099 MapCheckbuttonGadget(button1_id);
11100 MapCheckbuttonGadget(button2_id);
11102 DrawEnvelopeTextArea(envelope_nr);
11105 if (IS_MM_MCDUFFIN(properties_element))
11107 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
11108 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
11109 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
11112 if (IS_DF_LASER(properties_element))
11114 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
11115 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
11116 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
11119 if (IS_CUSTOM_ELEMENT(properties_element))
11121 // draw stickybutton gadget
11122 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11124 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
11126 // draw checkbutton gadgets
11127 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
11128 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
11129 MapCheckbuttonGadget(i);
11131 // draw counter gadgets
11132 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
11133 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
11134 MapCounterButtons(i);
11136 // draw selectbox gadgets
11137 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
11138 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
11139 MapSelectboxGadget(i);
11141 // draw textbutton gadgets
11142 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11144 // draw text input gadgets
11145 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11147 // draw drawing area gadgets
11148 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11150 draw_footer_line = TRUE;
11152 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
11154 // draw checkbutton gadgets
11155 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
11156 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
11157 MapCheckbuttonGadget(i);
11159 // draw counter gadgets
11160 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
11161 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
11162 MapCounterButtons(i);
11164 // draw selectbox gadgets
11165 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
11166 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
11167 MapSelectboxGadget(i);
11169 // draw drawing area gadgets
11170 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
11171 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
11172 DrawCustomContentArea();
11175 else if (IS_GROUP_ELEMENT(properties_element))
11177 // draw stickybutton gadget
11178 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11180 // draw checkbutton gadgets
11181 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11182 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11184 // draw counter gadgets
11185 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
11187 // draw selectbox gadgets
11188 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
11190 // draw textbutton gadgets
11191 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11193 // draw drawing area gadgets
11194 DrawGroupElementArea();
11196 // draw text input gadgets
11197 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11199 // draw drawing area gadgets
11200 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11202 draw_footer_line = TRUE;
11204 else if (IS_EMPTY_ELEMENT(properties_element))
11206 // draw stickybutton gadget
11207 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11209 // draw checkbutton gadgets
11210 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11211 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11213 // draw textbutton gadgets
11214 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11216 // draw drawing area gadgets
11217 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11219 draw_footer_line = TRUE;
11222 // draw little footer border line above CE/GE use/save template gadgets
11223 if (draw_footer_line)
11225 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
11226 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
11227 int gd_x = gd->x + gd_gi1->border.width / 2;
11228 int gd_y = gd->y + gd_gi1->height - 1;
11229 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
11231 if (tab_color != BLACK_PIXEL) // black => transparent
11232 FillRectangle(drawto,
11233 SX + ED_ELEMENT_SETTINGS_X(0),
11234 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
11236 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
11240 static void DrawPropertiesChangeDrawingAreas(void)
11242 if (IS_CUSTOM_ELEMENT(properties_element))
11244 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
11245 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
11246 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
11248 DrawCustomChangeContentArea();
11251 redraw_mask |= REDRAW_FIELD;
11254 static void DrawPropertiesChange(void)
11258 // needed to initially set selectbox options for special action options
11259 setSelectboxSpecialActionOptions();
11261 // draw stickybutton gadget
11262 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11264 // draw checkbutton gadgets
11265 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
11266 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
11267 MapCheckbuttonGadget(i);
11269 // draw counter gadgets
11270 for (i = ED_COUNTER_ID_CHANGE_FIRST;
11271 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
11272 MapCounterButtons(i);
11274 // draw selectbox gadgets
11275 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
11276 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
11277 MapSelectboxGadget(i);
11279 // draw textbutton gadgets
11280 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
11281 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
11282 MapTextbuttonGadget(i);
11284 // draw graphicbutton gadgets
11285 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
11286 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
11287 MapGraphicbuttonGadget(i);
11289 // draw drawing area gadgets
11290 DrawPropertiesChangeDrawingAreas();
11293 static void DrawEditorElementAnimation(int x, int y)
11295 int graphic = el2img(properties_element);
11296 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
11297 custom_element.ce_value_fixed_initial :
11298 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
11299 custom_element.collect_score_initial : FrameCounter);
11301 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
11304 static void DrawEditorElementName(int x, int y, int font_nr)
11306 char *element_name = getElementInfoText(properties_element);
11307 int font_width = getFontWidth(font_nr);
11308 int font_height = getFontHeight(font_nr);
11309 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
11310 int max_chars_per_line = max_text_width / font_width;
11312 if (strlen(element_name) <= max_chars_per_line)
11313 DrawTextS(x, y, font_nr, element_name);
11316 char buffer[max_chars_per_line + 1];
11317 int next_pos = max_chars_per_line;
11319 strncpy(buffer, element_name, max_chars_per_line);
11320 buffer[max_chars_per_line] = '\0';
11322 if (element_name[max_chars_per_line] == ' ')
11328 for (i = max_chars_per_line - 1; i >= 0; i--)
11329 if (buffer[i] == ' ')
11332 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
11339 DrawTextS(x, y - font_height / 2, font_nr, buffer);
11341 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
11342 buffer[max_chars_per_line] = '\0';
11344 DrawTextS(x, y + font_height / 2, font_nr, buffer);
11348 static void DrawPropertiesWindow(void)
11350 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
11351 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
11352 int border_size = gd->border_size;
11353 int font_nr = FONT_TEXT_1;
11354 int font_height = getFontHeight(font_nr);
11355 int xoffset = TILEX + element_border + 3 * border_size;
11356 int yoffset = (TILEY - font_height) / 2;
11357 int x1 = editor.settings.element_graphic.x + element_border;
11358 int y1 = editor.settings.element_graphic.y + element_border;
11359 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
11360 editor.settings.element_name.x);
11361 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
11362 editor.settings.element_name.y);
11363 char *text = "Element Settings";
11364 int font2_nr = FONT_TITLE_1;
11365 struct MenuPosInfo *pos = &editor.settings.headline;
11366 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
11367 int sy = SY + pos->y;
11369 stick_element_properties_window = FALSE;
11371 // make sure that previous properties edit mode exists for this element
11372 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
11373 !IS_CUSTOM_ELEMENT(properties_element))
11374 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
11376 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
11377 !IS_PLAYER_ELEMENT(properties_element) &&
11378 !IS_CUSTOM_ELEMENT(properties_element))
11379 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
11381 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
11382 (IS_PLAYER_ELEMENT(properties_element) ||
11383 IS_CUSTOM_ELEMENT(properties_element)))
11384 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
11386 CopyElementPropertiesToEditor(properties_element);
11388 UnmapLevelEditorFieldGadgets();
11389 UnmapLevelEditorToolboxDrawingGadgets();
11390 UnmapLevelEditorToolboxCustomGadgets();
11392 MapLevelEditorToolboxCustomGadgetsIfNeeded();
11394 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11397 DrawText(sx, sy, text, font2_nr);
11399 FrameCounter = 0; // restart animation frame counter
11401 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
11402 DrawEditorElementAnimation(SX + x1, SY + y1);
11403 DrawEditorElementName(x2, y2, font_nr);
11405 DrawPropertiesTabulatorGadgets();
11407 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
11408 DrawPropertiesInfo();
11409 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
11410 DrawPropertiesChange();
11411 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
11412 DrawPropertiesConfig();
11415 static void DrawPaletteWindow(void)
11419 UnmapLevelEditorFieldGadgets();
11421 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11424 // map buttons to select elements
11425 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
11426 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
11427 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
11428 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
11429 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
11432 static void UpdateCustomElementGraphicGadgets(void)
11436 InitElementPropertiesGfxElement();
11438 ModifyEditorElementList();
11439 RedrawDrawingElements();
11441 // force redraw of all mapped drawing area gadgets
11442 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
11444 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
11451 static int getOpenDirectionFromTube(int element)
11455 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
11456 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
11457 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
11458 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
11459 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
11460 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
11461 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
11462 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
11463 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
11464 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
11465 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
11471 static int getTubeFromOpenDirection(int direction)
11475 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
11476 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
11477 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
11478 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
11479 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
11480 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
11481 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
11482 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
11483 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
11484 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
11485 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
11487 // if only one direction, fall back to simple tube with that direction
11488 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
11489 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
11490 case (MV_UP): return EL_TUBE_VERTICAL;
11491 case (MV_DOWN): return EL_TUBE_VERTICAL;
11497 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
11499 int element_new = getTubeFromOpenDirection(direction);
11501 return (element_new != EL_EMPTY ? element_new : element_old);
11504 static int getOpenDirectionFromBelt(int element)
11506 int belt_dir = getBeltDirFromBeltElement(element);
11508 return (belt_dir == MV_LEFT ? MV_RIGHT :
11509 belt_dir == MV_RIGHT ? MV_LEFT :
11510 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
11513 static int getBeltFromNrAndOpenDirection(int nr, int direction)
11515 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
11516 direction == MV_RIGHT ? MV_LEFT :
11517 direction == MV_HORIZONTAL ? MV_NONE : direction);
11519 if (direction == MV_NONE)
11522 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
11525 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
11528 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
11530 return (element_new != EL_EMPTY ? element_new : element_old);
11533 static int getOpenDirectionFromPool(int element)
11537 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
11538 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
11539 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
11540 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
11541 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
11542 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
11548 static int getPoolFromOpenDirection(int direction)
11552 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
11553 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
11554 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
11555 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
11556 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
11557 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
11563 static int getPoolFromOpenDirectionExt(int direction, int help_element)
11565 int element = getPoolFromOpenDirection(direction);
11566 int help_direction = getOpenDirectionFromPool(help_element);
11568 if (element == EL_EMPTY)
11570 int help_direction_vertical = help_direction & MV_VERTICAL;
11572 element = getPoolFromOpenDirection(direction | help_direction_vertical);
11575 if (element == EL_EMPTY)
11577 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
11579 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
11585 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
11587 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
11589 return (element_new != EL_EMPTY ? element_new : element_old);
11592 static int getOpenDirectionFromPillar(int element)
11596 case EL_EMC_WALL_1: return (MV_DOWN);
11597 case EL_EMC_WALL_2: return (MV_VERTICAL);
11598 case EL_EMC_WALL_3: return (MV_UP);
11604 static int getPillarFromOpenDirection(int direction)
11608 case (MV_DOWN): return EL_EMC_WALL_1;
11609 case (MV_VERTICAL): return EL_EMC_WALL_2;
11610 case (MV_UP): return EL_EMC_WALL_3;
11616 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
11618 int element_new = getPillarFromOpenDirection(direction);
11620 return (element_new != EL_EMPTY ? element_new : element_old);
11623 static int getOpenDirectionFromSteel2(int element)
11627 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
11628 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
11629 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
11630 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
11631 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
11632 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
11633 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
11634 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
11640 static int getSteel2FromOpenDirection(int direction)
11644 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
11645 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
11646 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
11647 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
11648 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
11649 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
11650 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
11651 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
11657 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
11659 int element_new = getSteel2FromOpenDirection(direction);
11661 return (element_new != EL_EMPTY ? element_new : element_old);
11664 static int getOpenDirectionFromChip(int element)
11668 case EL_SP_CHIP_SINGLE: return (MV_NONE);
11669 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
11670 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
11671 case EL_SP_CHIP_TOP: return (MV_DOWN);
11672 case EL_SP_CHIP_BOTTOM: return (MV_UP);
11678 static int getChipFromOpenDirection(int direction)
11682 case (MV_NONE): return EL_SP_CHIP_SINGLE;
11683 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
11684 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
11685 case (MV_UP): return EL_SP_CHIP_BOTTOM;
11686 case (MV_DOWN): return EL_SP_CHIP_TOP;
11692 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
11694 int element_new = getChipFromOpenDirection(direction);
11696 return (element_new != EL_EMPTY ? element_new : element_old);
11699 static int getClosedTube(int x, int y)
11701 struct XY *xy = xy_directions;
11702 int element_old = IntelliDrawBuffer[x][y];
11703 int direction_old = getOpenDirectionFromTube(element_old);
11704 int direction_new = MV_NONE;
11707 for (i = 0; i < NUM_DIRECTIONS; i++)
11709 int xx = x + xy[i].x;
11710 int yy = y + xy[i].y;
11711 int dir = MV_DIR_FROM_BIT(i);
11712 int dir_opposite = MV_DIR_OPPOSITE(dir);
11714 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
11715 (direction_old & dir) &&
11716 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11717 direction_new |= dir;
11720 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
11723 static int getClosedBelt(int x, int y)
11725 struct XY *xy = xy_directions;
11726 int element_old = IntelliDrawBuffer[x][y];
11727 int nr = getBeltNrFromBeltElement(element_old);
11728 int direction_old = getOpenDirectionFromBelt(element_old);
11729 int direction_new = MV_NONE;
11732 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11734 int xx = x + xy[i].x;
11735 int yy = y + xy[i].y;
11736 int dir = MV_DIR_FROM_BIT(i);
11737 int dir_opposite = MV_DIR_OPPOSITE(dir);
11739 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
11740 (direction_old & dir) &&
11741 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11742 direction_new |= dir;
11745 return getBeltFromNrAndOpenDirection(nr, direction_new);
11748 static int getClosedPool(int x, int y)
11750 struct XY *xy = xy_directions;
11751 int element_old = IntelliDrawBuffer[x][y];
11752 int direction_old = getOpenDirectionFromPool(element_old);
11753 int direction_new = MV_NONE;
11756 for (i = 0; i < NUM_DIRECTIONS; i++)
11758 int xx = x + xy[i].x;
11759 int yy = y + xy[i].y;
11760 int dir = MV_DIR_FROM_BIT(i);
11761 int dir_opposite = MV_DIR_OPPOSITE(dir);
11763 if (IN_LEV_FIELD(xx, yy) &&
11764 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
11765 (direction_old & dir) &&
11766 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11767 direction_new |= dir;
11770 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
11773 static int getClosedPillar(int x, int y)
11775 struct XY *xy = xy_directions;
11776 int element_old = IntelliDrawBuffer[x][y];
11777 int direction_old = getOpenDirectionFromPillar(element_old);
11778 int direction_new = MV_NONE;
11781 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11783 int xx = x + xy[i].x;
11784 int yy = y + xy[i].y;
11785 int dir = MV_DIR_FROM_BIT(i);
11786 int dir_opposite = MV_DIR_OPPOSITE(dir);
11788 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11789 (direction_old & dir) &&
11790 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11791 direction_new |= dir;
11794 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11797 static int getClosedSteel2(int x, int y)
11799 struct XY *xy = xy_directions;
11800 int element_old = IntelliDrawBuffer[x][y];
11801 int direction_old = getOpenDirectionFromSteel2(element_old);
11802 int direction_new = MV_NONE;
11805 for (i = 0; i < NUM_DIRECTIONS; i++)
11807 int xx = x + xy[i].x;
11808 int yy = y + xy[i].y;
11809 int dir = MV_DIR_FROM_BIT(i);
11810 int dir_opposite = MV_DIR_OPPOSITE(dir);
11812 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11813 (direction_old & dir) &&
11814 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11815 direction_new |= dir;
11818 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11821 static int getClosedChip(int x, int y)
11823 struct XY *xy = xy_directions;
11824 int element_old = IntelliDrawBuffer[x][y];
11825 int direction_old = getOpenDirectionFromChip(element_old);
11826 int direction_new = MV_NONE;
11829 for (i = 0; i < NUM_DIRECTIONS; i++)
11831 int xx = x + xy[i].x;
11832 int yy = y + xy[i].y;
11833 int dir = MV_DIR_FROM_BIT(i);
11834 int dir_opposite = MV_DIR_OPPOSITE(dir);
11836 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11837 (direction_old & dir) &&
11838 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11839 direction_new |= dir;
11842 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11845 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11846 boolean change_level)
11848 int sx = x - level_xpos;
11849 int sy = y - level_ypos;
11850 int old_element = Tile[x][y];
11851 int new_element = element;
11852 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11853 boolean draw_masked = FALSE;
11855 if (IS_MM_WALL_EDITOR(element))
11857 element = map_mm_wall_element_editor(element) | new_bitmask;
11859 if (IS_MM_WALL(old_element))
11860 element |= MM_WALL_BITS(old_element);
11863 draw_masked = TRUE;
11865 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11867 int element_changed = old_element & ~new_bitmask;
11869 if (MM_WALL_BITS(element_changed) != 0)
11870 element = element_changed;
11873 IntelliDrawBuffer[x][y] = element;
11876 Tile[x][y] = element;
11878 if (IN_ED_FIELD(sx, sy))
11880 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11881 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11882 else if (draw_masked)
11883 DrawEditorElementThruMask(sx, sy, element);
11885 DrawEditorElement(sx, sy, element);
11889 static void SetElementSimple(int x, int y, int element, boolean change_level)
11891 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11894 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11895 int x2, int y2, int *element2,
11896 int (*close_function)(int, int),
11897 boolean change_level)
11899 // set neighbour elements to newly determined connections
11900 SetElementSimple(x1, y1, *element1, change_level);
11901 SetElementSimple(x2, y2, *element2, change_level);
11903 // remove all open connections of neighbour elements
11904 *element1 = close_function(x1, y1);
11905 *element2 = close_function(x2, y2);
11907 // set neighbour elements to new, minimized connections
11908 SetElementSimple(x1, y1, *element1, change_level);
11909 SetElementSimple(x2, y2, *element2, change_level);
11912 static void SetElementIntelliDraw(int x, int y, int dx, int dy, int new_element,
11913 boolean change_level, int button)
11915 struct XY *xy = xy_directions;
11916 static int last_x = -1;
11917 static int last_y = -1;
11919 if (new_element == EL_UNDEFINED)
11927 int old_element = IntelliDrawBuffer[x][y];
11929 if (IS_TUBE(new_element))
11931 int last_element_new = EL_UNDEFINED;
11932 int direction = MV_NONE;
11935 // if old element is of same kind, keep all existing directions
11936 if (IS_TUBE(old_element))
11937 direction |= getOpenDirectionFromTube(old_element);
11939 for (i = 0; i < NUM_DIRECTIONS; i++)
11941 int xx = x + xy[i].x;
11942 int yy = y + xy[i].y;
11944 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11945 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11947 int dir = MV_DIR_FROM_BIT(i);
11948 int dir_opposite = MV_DIR_OPPOSITE(dir);
11949 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11950 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11951 int last_direction_new = last_direction_old | dir_opposite;
11953 last_element_new = getTubeFromOpenDirection(last_direction_new);
11959 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
11961 if (last_element_new != EL_UNDEFINED)
11962 MergeAndCloseNeighbourElements(x, y, &new_element,
11963 last_x, last_y, &last_element_new,
11964 getClosedTube, change_level);
11966 else if (IS_BELT(new_element))
11968 int belt_nr = getBeltNrFromBeltElement(new_element);
11969 int last_element_new = EL_UNDEFINED;
11970 int direction = MV_NONE;
11973 // if old element is of same kind, keep all existing directions
11974 if (IS_BELT(old_element))
11975 direction |= getOpenDirectionFromBelt(old_element);
11977 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11979 int xx = x + xy[i].x;
11980 int yy = y + xy[i].y;
11982 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11983 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
11985 int dir = MV_DIR_FROM_BIT(i);
11986 int dir_opposite = MV_DIR_OPPOSITE(dir);
11987 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11988 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
11989 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
11990 int last_direction_new = last_direction_old | dir_opposite;
11992 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11993 last_direction_new);
11998 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
12000 if (last_element_new != EL_UNDEFINED)
12001 MergeAndCloseNeighbourElements(x, y, &new_element,
12002 last_x, last_y, &last_element_new,
12003 getClosedBelt, change_level);
12005 else if (IS_ACID_POOL_OR_ACID(new_element))
12007 int last_element_new = EL_UNDEFINED;
12008 int direction = MV_NONE;
12011 // if old element is of same kind, keep all existing directions
12012 if (IS_ACID_POOL_OR_ACID(old_element))
12013 direction |= getOpenDirectionFromPool(old_element);
12015 for (i = 0; i < NUM_DIRECTIONS; i++)
12017 int xx = x + xy[i].x;
12018 int yy = y + xy[i].y;
12020 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12021 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
12023 int dir = MV_DIR_FROM_BIT(i);
12024 int dir_opposite = MV_DIR_OPPOSITE(dir);
12025 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12026 int last_direction_old = getOpenDirectionFromPool(last_element_old);
12027 int last_direction_new = last_direction_old | dir_opposite;
12029 last_element_new = getPoolFromOpenDirection(last_direction_new);
12035 // special corrections needed for intuitively correct acid pool drawing
12036 if (last_element_new == EL_EMPTY)
12037 last_element_new = new_element;
12038 else if (last_element_new != EL_UNDEFINED)
12039 new_element = last_element_new;
12041 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
12043 if (last_element_new != EL_UNDEFINED)
12044 MergeAndCloseNeighbourElements(x, y, &new_element,
12045 last_x, last_y, &last_element_new,
12046 getClosedPool, change_level);
12048 else if (IS_EMC_PILLAR(new_element))
12050 int last_element_new = EL_UNDEFINED;
12051 int direction = MV_NONE;
12054 // if old element is of same kind, keep all existing directions
12055 if (IS_EMC_PILLAR(old_element))
12056 direction |= getOpenDirectionFromPillar(old_element);
12058 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
12060 int xx = x + xy[i].x;
12061 int yy = y + xy[i].y;
12063 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12064 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
12066 int dir = MV_DIR_FROM_BIT(i);
12067 int dir_opposite = MV_DIR_OPPOSITE(dir);
12068 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12069 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
12070 int last_direction_new = last_direction_old | dir_opposite;
12072 last_element_new = getPillarFromOpenDirection(last_direction_new);
12078 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
12080 if (last_element_new != EL_UNDEFINED)
12081 MergeAndCloseNeighbourElements(x, y, &new_element,
12082 last_x, last_y, &last_element_new,
12083 getClosedPillar, change_level);
12085 else if (IS_DC_STEELWALL_2(new_element))
12087 int last_element_new = EL_UNDEFINED;
12088 int direction = MV_NONE;
12091 // if old element is of same kind, keep all existing directions
12092 if (IS_DC_STEELWALL_2(old_element))
12093 direction |= getOpenDirectionFromSteel2(old_element);
12095 for (i = 0; i < NUM_DIRECTIONS; i++)
12097 int xx = x + xy[i].x;
12098 int yy = y + xy[i].y;
12100 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12101 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
12103 int dir = MV_DIR_FROM_BIT(i);
12104 int dir_opposite = MV_DIR_OPPOSITE(dir);
12105 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12106 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
12107 int last_direction_new = last_direction_old | dir_opposite;
12109 last_element_new = getSteel2FromOpenDirection(last_direction_new);
12115 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
12117 if (last_element_new != EL_UNDEFINED)
12118 MergeAndCloseNeighbourElements(x, y, &new_element,
12119 last_x, last_y, &last_element_new,
12120 getClosedSteel2, change_level);
12122 else if (IS_SP_CHIP(new_element))
12124 int last_element_new = EL_UNDEFINED;
12125 int direction = MV_NONE;
12128 // (do not keep existing directions, regardless of kind of old element)
12130 for (i = 0; i < NUM_DIRECTIONS; i++)
12132 int xx = x + xy[i].x;
12133 int yy = y + xy[i].y;
12135 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12136 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
12138 int dir = MV_DIR_FROM_BIT(i);
12139 int dir_opposite = MV_DIR_OPPOSITE(dir);
12140 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12141 int last_direction_old = getOpenDirectionFromChip(last_element_old);
12142 int last_direction_new = last_direction_old | dir_opposite;
12144 if (last_direction_old == MV_NONE)
12146 last_element_new = getChipFromOpenDirection(last_direction_new);
12149 else if (last_direction_old & (dir | dir_opposite))
12151 direction |= MV_DIR_OPPOSITE(last_direction_old);
12155 direction |= MV_DIR_OPPOSITE(dir);
12160 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
12162 if (last_element_new != EL_UNDEFINED)
12163 MergeAndCloseNeighbourElements(x, y, &new_element,
12164 last_x, last_y, &last_element_new,
12165 getClosedChip, change_level);
12167 else if (IS_SP_HARDWARE_BASE(new_element))
12169 int nr = GetSimpleRandom(6);
12171 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
12172 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
12173 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
12174 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
12175 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
12177 else if (new_element == EL_SP_HARDWARE_GREEN ||
12178 new_element == EL_SP_HARDWARE_BLUE ||
12179 new_element == EL_SP_HARDWARE_RED)
12181 int nr = GetSimpleRandom(3);
12183 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
12184 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
12186 else if (IS_GROUP_ELEMENT(new_element))
12188 boolean connected_drawing = FALSE;
12191 for (i = 0; i < NUM_DIRECTIONS; i++)
12193 int xx = x + xy[i].x;
12194 int yy = y + xy[i].y;
12196 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12197 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
12198 connected_drawing = TRUE;
12201 if (!connected_drawing)
12202 ResolveGroupElement(new_element);
12204 new_element = GetElementFromGroupElement(new_element);
12206 else if (IS_BELT_SWITCH(old_element))
12208 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
12209 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
12211 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
12212 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
12214 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
12218 static int swappable_elements[][2] =
12220 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
12221 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
12222 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
12223 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
12224 { EL_EMERALD, EL_WALL_EMERALD },
12225 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
12226 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
12227 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
12228 { EL_DIAMOND, EL_WALL_DIAMOND },
12229 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
12230 { EL_GATE_1, EL_GATE_1_GRAY },
12231 { EL_GATE_2, EL_GATE_2_GRAY },
12232 { EL_GATE_3, EL_GATE_3_GRAY },
12233 { EL_GATE_4, EL_GATE_4_GRAY },
12234 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
12235 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
12236 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
12237 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
12238 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
12239 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
12240 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
12241 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
12242 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
12243 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
12244 { EL_LAMP, EL_LAMP_ACTIVE },
12245 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
12246 { EL_SP_BASE, EL_SP_BUGGY_BASE },
12247 { EL_PEARL, EL_WALL_PEARL },
12248 { EL_CRYSTAL, EL_WALL_CRYSTAL },
12249 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
12250 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
12251 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
12252 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
12253 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
12254 { EL_LANDMINE, EL_DC_LANDMINE },
12255 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
12256 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
12257 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
12258 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
12259 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
12260 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
12261 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
12262 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
12263 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
12267 static int rotatable_elements_4[][4] =
12277 EL_SPACESHIP_RIGHT,
12282 EL_BD_BUTTERFLY_UP,
12283 EL_BD_BUTTERFLY_RIGHT,
12284 EL_BD_BUTTERFLY_DOWN,
12285 EL_BD_BUTTERFLY_LEFT
12289 EL_BD_FIREFLY_RIGHT,
12290 EL_BD_FIREFLY_DOWN,
12318 EL_SP_GRAVITY_PORT_UP,
12319 EL_SP_GRAVITY_PORT_RIGHT,
12320 EL_SP_GRAVITY_PORT_DOWN,
12321 EL_SP_GRAVITY_PORT_LEFT
12324 EL_SP_GRAVITY_ON_PORT_UP,
12325 EL_SP_GRAVITY_ON_PORT_RIGHT,
12326 EL_SP_GRAVITY_ON_PORT_DOWN,
12327 EL_SP_GRAVITY_ON_PORT_LEFT
12330 EL_SP_GRAVITY_OFF_PORT_UP,
12331 EL_SP_GRAVITY_OFF_PORT_RIGHT,
12332 EL_SP_GRAVITY_OFF_PORT_DOWN,
12333 EL_SP_GRAVITY_OFF_PORT_LEFT
12342 EL_BALLOON_SWITCH_UP,
12343 EL_BALLOON_SWITCH_RIGHT,
12344 EL_BALLOON_SWITCH_DOWN,
12345 EL_BALLOON_SWITCH_LEFT
12349 EL_MM_MCDUFFIN_RIGHT,
12350 EL_MM_MCDUFFIN_DOWN,
12351 EL_MM_MCDUFFIN_LEFT
12354 EL_MM_MIRROR_FIXED_1,
12355 EL_MM_MIRROR_FIXED_4,
12356 EL_MM_MIRROR_FIXED_3,
12357 EL_MM_MIRROR_FIXED_2
12360 EL_MM_STEEL_GRID_FIXED_1,
12361 EL_MM_STEEL_GRID_FIXED_4,
12362 EL_MM_STEEL_GRID_FIXED_2,
12363 EL_MM_STEEL_GRID_FIXED_3
12366 EL_MM_WOODEN_GRID_FIXED_1,
12367 EL_MM_WOODEN_GRID_FIXED_4,
12368 EL_MM_WOODEN_GRID_FIXED_2,
12369 EL_MM_WOODEN_GRID_FIXED_3
12372 EL_MM_POLARIZER_CROSS_1,
12373 EL_MM_POLARIZER_CROSS_4,
12374 EL_MM_POLARIZER_CROSS_3,
12375 EL_MM_POLARIZER_CROSS_2
12379 EL_MM_PACMAN_RIGHT,
12391 EL_DF_RECEIVER_RIGHT,
12392 EL_DF_RECEIVER_DOWN,
12393 EL_DF_RECEIVER_LEFT
12406 static int rotatable_elements_8[][8] =
12409 EL_DF_STEEL_GRID_FIXED_1,
12410 EL_DF_STEEL_GRID_FIXED_8,
12411 EL_DF_STEEL_GRID_FIXED_7,
12412 EL_DF_STEEL_GRID_FIXED_6,
12413 EL_DF_STEEL_GRID_FIXED_5,
12414 EL_DF_STEEL_GRID_FIXED_4,
12415 EL_DF_STEEL_GRID_FIXED_3,
12416 EL_DF_STEEL_GRID_FIXED_2
12419 EL_DF_WOODEN_GRID_FIXED_1,
12420 EL_DF_WOODEN_GRID_FIXED_8,
12421 EL_DF_WOODEN_GRID_FIXED_7,
12422 EL_DF_WOODEN_GRID_FIXED_6,
12423 EL_DF_WOODEN_GRID_FIXED_5,
12424 EL_DF_WOODEN_GRID_FIXED_4,
12425 EL_DF_WOODEN_GRID_FIXED_3,
12426 EL_DF_WOODEN_GRID_FIXED_2
12429 EL_DF_STEEL_GRID_ROTATING_1,
12430 EL_DF_STEEL_GRID_ROTATING_8,
12431 EL_DF_STEEL_GRID_ROTATING_7,
12432 EL_DF_STEEL_GRID_ROTATING_6,
12433 EL_DF_STEEL_GRID_ROTATING_5,
12434 EL_DF_STEEL_GRID_ROTATING_4,
12435 EL_DF_STEEL_GRID_ROTATING_3,
12436 EL_DF_STEEL_GRID_ROTATING_2
12439 EL_DF_WOODEN_GRID_ROTATING_1,
12440 EL_DF_WOODEN_GRID_ROTATING_8,
12441 EL_DF_WOODEN_GRID_ROTATING_7,
12442 EL_DF_WOODEN_GRID_ROTATING_6,
12443 EL_DF_WOODEN_GRID_ROTATING_5,
12444 EL_DF_WOODEN_GRID_ROTATING_4,
12445 EL_DF_WOODEN_GRID_ROTATING_3,
12446 EL_DF_WOODEN_GRID_ROTATING_2
12453 static int rotatable_elements_16[][16] =
12474 EL_MM_TELEPORTER_5,
12475 EL_MM_TELEPORTER_4,
12476 EL_MM_TELEPORTER_3,
12477 EL_MM_TELEPORTER_2,
12478 EL_MM_TELEPORTER_1,
12479 EL_MM_TELEPORTER_16,
12480 EL_MM_TELEPORTER_15,
12481 EL_MM_TELEPORTER_14,
12482 EL_MM_TELEPORTER_13,
12483 EL_MM_TELEPORTER_12,
12484 EL_MM_TELEPORTER_11,
12485 EL_MM_TELEPORTER_10,
12486 EL_MM_TELEPORTER_9,
12487 EL_MM_TELEPORTER_8,
12488 EL_MM_TELEPORTER_7,
12492 EL_MM_TELEPORTER_RED_5,
12493 EL_MM_TELEPORTER_RED_4,
12494 EL_MM_TELEPORTER_RED_3,
12495 EL_MM_TELEPORTER_RED_2,
12496 EL_MM_TELEPORTER_RED_1,
12497 EL_MM_TELEPORTER_RED_16,
12498 EL_MM_TELEPORTER_RED_15,
12499 EL_MM_TELEPORTER_RED_14,
12500 EL_MM_TELEPORTER_RED_13,
12501 EL_MM_TELEPORTER_RED_12,
12502 EL_MM_TELEPORTER_RED_11,
12503 EL_MM_TELEPORTER_RED_10,
12504 EL_MM_TELEPORTER_RED_9,
12505 EL_MM_TELEPORTER_RED_8,
12506 EL_MM_TELEPORTER_RED_7,
12507 EL_MM_TELEPORTER_RED_6
12510 EL_MM_TELEPORTER_YELLOW_5,
12511 EL_MM_TELEPORTER_YELLOW_4,
12512 EL_MM_TELEPORTER_YELLOW_3,
12513 EL_MM_TELEPORTER_YELLOW_2,
12514 EL_MM_TELEPORTER_YELLOW_1,
12515 EL_MM_TELEPORTER_YELLOW_16,
12516 EL_MM_TELEPORTER_YELLOW_15,
12517 EL_MM_TELEPORTER_YELLOW_14,
12518 EL_MM_TELEPORTER_YELLOW_13,
12519 EL_MM_TELEPORTER_YELLOW_12,
12520 EL_MM_TELEPORTER_YELLOW_11,
12521 EL_MM_TELEPORTER_YELLOW_10,
12522 EL_MM_TELEPORTER_YELLOW_9,
12523 EL_MM_TELEPORTER_YELLOW_8,
12524 EL_MM_TELEPORTER_YELLOW_7,
12525 EL_MM_TELEPORTER_YELLOW_6
12528 EL_MM_TELEPORTER_GREEN_5,
12529 EL_MM_TELEPORTER_GREEN_4,
12530 EL_MM_TELEPORTER_GREEN_3,
12531 EL_MM_TELEPORTER_GREEN_2,
12532 EL_MM_TELEPORTER_GREEN_1,
12533 EL_MM_TELEPORTER_GREEN_16,
12534 EL_MM_TELEPORTER_GREEN_15,
12535 EL_MM_TELEPORTER_GREEN_14,
12536 EL_MM_TELEPORTER_GREEN_13,
12537 EL_MM_TELEPORTER_GREEN_12,
12538 EL_MM_TELEPORTER_GREEN_11,
12539 EL_MM_TELEPORTER_GREEN_10,
12540 EL_MM_TELEPORTER_GREEN_9,
12541 EL_MM_TELEPORTER_GREEN_8,
12542 EL_MM_TELEPORTER_GREEN_7,
12543 EL_MM_TELEPORTER_GREEN_6
12546 EL_MM_TELEPORTER_BLUE_5,
12547 EL_MM_TELEPORTER_BLUE_4,
12548 EL_MM_TELEPORTER_BLUE_3,
12549 EL_MM_TELEPORTER_BLUE_2,
12550 EL_MM_TELEPORTER_BLUE_1,
12551 EL_MM_TELEPORTER_BLUE_16,
12552 EL_MM_TELEPORTER_BLUE_15,
12553 EL_MM_TELEPORTER_BLUE_14,
12554 EL_MM_TELEPORTER_BLUE_13,
12555 EL_MM_TELEPORTER_BLUE_12,
12556 EL_MM_TELEPORTER_BLUE_11,
12557 EL_MM_TELEPORTER_BLUE_10,
12558 EL_MM_TELEPORTER_BLUE_9,
12559 EL_MM_TELEPORTER_BLUE_8,
12560 EL_MM_TELEPORTER_BLUE_7,
12561 EL_MM_TELEPORTER_BLUE_6
12565 EL_MM_POLARIZER_16,
12566 EL_MM_POLARIZER_15,
12567 EL_MM_POLARIZER_14,
12568 EL_MM_POLARIZER_13,
12569 EL_MM_POLARIZER_12,
12570 EL_MM_POLARIZER_11,
12571 EL_MM_POLARIZER_10,
12600 EL_DF_MIRROR_ROTATING_1,
12601 EL_DF_MIRROR_ROTATING_16,
12602 EL_DF_MIRROR_ROTATING_15,
12603 EL_DF_MIRROR_ROTATING_14,
12604 EL_DF_MIRROR_ROTATING_13,
12605 EL_DF_MIRROR_ROTATING_12,
12606 EL_DF_MIRROR_ROTATING_11,
12607 EL_DF_MIRROR_ROTATING_10,
12608 EL_DF_MIRROR_ROTATING_9,
12609 EL_DF_MIRROR_ROTATING_8,
12610 EL_DF_MIRROR_ROTATING_7,
12611 EL_DF_MIRROR_ROTATING_6,
12612 EL_DF_MIRROR_ROTATING_5,
12613 EL_DF_MIRROR_ROTATING_4,
12614 EL_DF_MIRROR_ROTATING_3,
12615 EL_DF_MIRROR_ROTATING_2
12618 EL_DF_MIRROR_FIXED_1,
12619 EL_DF_MIRROR_FIXED_16,
12620 EL_DF_MIRROR_FIXED_15,
12621 EL_DF_MIRROR_FIXED_14,
12622 EL_DF_MIRROR_FIXED_13,
12623 EL_DF_MIRROR_FIXED_12,
12624 EL_DF_MIRROR_FIXED_11,
12625 EL_DF_MIRROR_FIXED_10,
12626 EL_DF_MIRROR_FIXED_9,
12627 EL_DF_MIRROR_FIXED_8,
12628 EL_DF_MIRROR_FIXED_7,
12629 EL_DF_MIRROR_FIXED_6,
12630 EL_DF_MIRROR_FIXED_5,
12631 EL_DF_MIRROR_FIXED_4,
12632 EL_DF_MIRROR_FIXED_3,
12633 EL_DF_MIRROR_FIXED_2
12642 for (i = 0; swappable_elements[i][0] != -1; i++)
12644 int element1 = swappable_elements[i][0];
12645 int element2 = swappable_elements[i][1];
12647 if (old_element == element1 || old_element == element2)
12648 new_element = (old_element == element1 ? element2 : element1);
12651 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
12653 for (j = 0; j < 4; j++)
12655 int element = rotatable_elements_4[i][j];
12657 if (old_element == element)
12658 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
12659 button == 2 ? rotatable_elements_4[i][0] :
12660 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
12665 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
12667 for (j = 0; j < 8; j++)
12669 int element = rotatable_elements_8[i][j];
12671 if (old_element == element)
12672 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
12673 button == 2 ? rotatable_elements_8[i][0] :
12674 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
12679 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
12681 for (j = 0; j < 16; j++)
12683 int element = rotatable_elements_16[i][j];
12685 if (old_element == element)
12686 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
12687 button == 2 ? rotatable_elements_16[i][0] :
12688 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
12693 if (old_element != new_element)
12695 int max_infotext_len = getMaxInfoTextLength();
12696 char infotext[MAX_OUTPUT_LINESIZE + 1];
12698 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
12699 infotext[max_infotext_len] = '\0';
12701 ClearEditorGadgetInfoText();
12703 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
12708 if (IS_MM_WALL_EDITOR(new_element))
12709 SetElementSimpleExt(x, y, dx, dy, new_element, change_level);
12711 SetElementSimple(x, y, new_element, change_level);
12717 static void ResetIntelliDraw(void)
12721 for (x = 0; x < lev_fieldx; x++)
12722 for (y = 0; y < lev_fieldy; y++)
12723 IntelliDrawBuffer[x][y] = Tile[x][y];
12725 SetElementIntelliDraw(-1, -1, -1, -1, EL_UNDEFINED, FALSE, -1);
12728 static boolean draw_mode_hires = FALSE;
12730 static boolean isHiresTileElement(int element)
12732 return (IS_MM_WALL(element) || element == EL_EMPTY);
12735 static boolean isHiresDrawElement(int element)
12737 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
12740 static int numHiresTiles(int element)
12742 if (IS_MM_WALL(element))
12743 return get_number_of_bits(MM_WALL_BITS(element));
12748 static void SetDrawModeHiRes(int element)
12751 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12752 isHiresDrawElement(element));
12755 static boolean getDrawModeHiRes(void)
12757 return draw_mode_hires;
12760 static int getLoResScreenPos(int pos)
12762 return (getDrawModeHiRes() ? pos / 2 : pos);
12765 static int getLoResScreenMod(int pos)
12767 return (getDrawModeHiRes() ? pos % 2 : 0);
12770 static void SetElementExt(int x, int y, int dx, int dy, int element,
12771 boolean change_level, int button)
12774 SetElementSimple(x, y, Tile[x][y], change_level);
12775 else if (GetKeyModState() & KMOD_Shift)
12776 SetElementIntelliDraw(x, y, dx, dy, element, change_level, button);
12778 SetElementSimpleExt(x, y, dx, dy, element, change_level);
12781 static void SetElement(int x, int y, int element)
12783 SetElementExt(x, y, 0, 0, element, TRUE, -1);
12786 static void SetElementButton(int x, int y, int dx, int dy, int element,
12789 SetElementExt(x, y, dx, dy, element, TRUE, button);
12792 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
12794 int lx = getLoResScreenPos(sx2) + level_xpos;
12795 int ly = getLoResScreenPos(sy2) + level_ypos;
12796 int dx = getLoResScreenMod(sx2);
12797 int dy = getLoResScreenMod(sy2);
12799 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
12802 static void SetLevelElementHiRes(int lx2, int ly2, int element)
12809 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
12812 static int getLevelElementHiRes(int lx2, int ly2)
12818 int element = Tile[lx][ly];
12819 unsigned int bitmask = (dx + 1) << (dy * 2);
12821 if (IS_MM_WALL(element))
12823 if (element & bitmask)
12824 return map_mm_wall_element(element);
12832 static void DrawLineElement(int x, int y, int element, boolean change_level)
12834 SetElementHiRes(x, y, element, change_level);
12837 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12838 int element, boolean change_level)
12840 int xsize = ABS(to_x - from_x);
12841 int ysize = ABS(to_y - from_y);
12842 int dx = (to_x < from_x ? -1 : +1);
12843 int dy = (to_y < from_y ? -1 : +1);
12846 if (from_y == to_y) // horizontal line
12848 for (i = 0; i <= xsize; i++)
12849 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12851 else if (from_x == to_x) // vertical line
12853 for (i = 0; i <= ysize; i++)
12854 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12856 else // diagonal line
12858 if (ysize < xsize) // a < 1
12860 float a = (float)ysize / (float)xsize;
12862 for (i = 0; i <= xsize; i++)
12865 int y = dy * (int)(a * i + 0.5);
12867 DrawLineElement(from_x + x, from_y + y, element, change_level);
12872 float a = (float)xsize / (float)ysize;
12874 for (i = 0; i <= ysize; i++)
12876 int x = dx * (int)(a * i + 0.5);
12879 DrawLineElement(from_x + x, from_y + y, element, change_level);
12885 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12886 int element, boolean change_level)
12888 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12889 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12890 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12891 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12894 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12895 int element, boolean change_level)
12900 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12902 for (y = from_y; y <= to_y; y++)
12903 DrawLine(from_x, y, to_x, y, element, change_level);
12906 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12907 int element, boolean change_level)
12909 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12910 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12911 int len_x = ABS(to_x - from_x);
12912 int len_y = ABS(to_y - from_y);
12915 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
12917 // not optimal (some points get drawn twice) but simple,
12918 // and fast enough for the few points we are drawing
12920 for (x = 0; x <= radius; x++)
12922 int sx, sy, sx2, sy2, lx, ly;
12924 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
12926 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12927 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12928 sx = getLoResScreenPos(sx2);
12929 sy = getLoResScreenPos(sy2);
12930 lx = sx + level_xpos;
12931 ly = sy + level_ypos;
12933 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12934 DrawLineElement(sx2, sy2, element, change_level);
12937 for (y = 0; y <= radius; y++)
12939 int sx, sy, sx2, sy2, lx, ly;
12941 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
12943 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12944 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12945 sx = getLoResScreenPos(sx2);
12946 sy = getLoResScreenPos(sy2);
12947 lx = sx + level_xpos;
12948 ly = sy + level_ypos;
12950 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12951 DrawLineElement(sx2, sy2, element, change_level);
12955 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
12956 int element, boolean change_level)
12958 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12959 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12961 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12964 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
12966 #if DRAW_CIRCLES_BUTTON_AVAILABLE
12967 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
12968 int element, boolean change_level)
12970 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12971 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12972 int mirror_to_x2 = from_x - (to_x2 - from_x);
12973 int mirror_to_y2 = from_y - (to_y2 - from_y);
12975 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12976 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
12977 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
12978 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element, change_level);
12982 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
12984 int from_sx, from_sy;
12988 swap_numbers(&from_x, &to_x);
12991 swap_numbers(&from_y, &to_y);
12993 from_sx = SX + from_x * ed_tilesize;
12994 from_sy = SY + from_y * ed_tilesize;
12995 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
12996 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
12998 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12999 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13000 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13001 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13003 if (from_x == to_x && from_y == to_y)
13004 MarkTileDirty(from_x/2, from_y/2);
13006 redraw_mask |= REDRAW_FIELD;
13009 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
13010 int element, boolean change_level)
13012 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
13015 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
13016 int element, boolean change_level)
13018 if (element == -1 || change_level)
13019 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
13021 DrawAreaBorder(from_x, from_y, to_x, to_y);
13024 // values for CopyBrushExt()
13025 #define CB_AREA_TO_BRUSH 0
13026 #define CB_BRUSH_TO_CURSOR 1
13027 #define CB_BRUSH_TO_LEVEL 2
13028 #define CB_DELETE_OLD_CURSOR 3
13029 #define CB_DUMP_BRUSH 4
13030 #define CB_DUMP_BRUSH_SMALL 5
13031 #define CB_CLIPBOARD_TO_BRUSH 6
13032 #define CB_BRUSH_TO_CLIPBOARD 7
13033 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
13034 #define CB_UPDATE_BRUSH_POSITION 9
13035 #define CB_FLIP_BRUSH_X 10
13036 #define CB_FLIP_BRUSH_Y 11
13037 #define CB_FLIP_BRUSH_XY 12
13039 #define MAX_CB_PART_SIZE 10
13040 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
13041 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
13042 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
13043 MAX_CB_NUM_LINES * \
13046 static int getFlippedTileExt(int map[], int element)
13050 for (i = 0; map[i] != -1; i++)
13051 if (map[i] == element)
13052 return map[i ^ 1]; // get flipped element by flipping LSB of index
13057 static int getFlippedTileX(int element)
13061 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_RIGHT,
13062 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_RIGHT,
13063 EL_BUG_LEFT, EL_BUG_RIGHT,
13064 EL_SPACESHIP_LEFT, EL_SPACESHIP_RIGHT,
13065 EL_PACMAN_LEFT, EL_PACMAN_RIGHT,
13066 EL_ARROW_LEFT, EL_ARROW_RIGHT,
13067 EL_MOLE_LEFT, EL_MOLE_RIGHT,
13068 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_RIGHT,
13069 EL_YAMYAM_LEFT, EL_YAMYAM_RIGHT,
13070 EL_SP_PORT_LEFT, EL_SP_PORT_RIGHT,
13071 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_RIGHT,
13072 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_RIGHT,
13073 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_RIGHT,
13074 EL_CONVEYOR_BELT_1_LEFT, EL_CONVEYOR_BELT_1_RIGHT,
13075 EL_CONVEYOR_BELT_2_LEFT, EL_CONVEYOR_BELT_2_RIGHT,
13076 EL_CONVEYOR_BELT_3_LEFT, EL_CONVEYOR_BELT_3_RIGHT,
13077 EL_CONVEYOR_BELT_4_LEFT, EL_CONVEYOR_BELT_4_RIGHT,
13078 EL_SPRING_LEFT, EL_SPRING_RIGHT,
13079 EL_SP_CHIP_LEFT, EL_SP_CHIP_RIGHT,
13080 EL_TUBE_VERTICAL_LEFT, EL_TUBE_VERTICAL_RIGHT,
13081 EL_TUBE_LEFT_UP, EL_TUBE_RIGHT_UP,
13082 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_DOWN,
13083 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_RIGHT,
13084 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_TOPRIGHT,
13085 EL_DC_STEELWALL_1_BOTTOMLEFT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13086 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_TOPRIGHT_2,
13087 EL_DC_STEELWALL_1_BOTTOMLEFT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13088 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_RIGHT,
13089 EL_ACID_POOL_TOPLEFT, EL_ACID_POOL_TOPRIGHT,
13090 EL_ACID_POOL_BOTTOMLEFT, EL_ACID_POOL_BOTTOMRIGHT,
13095 return getFlippedTileExt(map, element);
13098 static int getFlippedTileY(int element)
13102 EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY_DOWN,
13103 EL_BD_FIREFLY_UP, EL_BD_FIREFLY_DOWN,
13104 EL_BUG_UP, EL_BUG_DOWN,
13105 EL_SPACESHIP_UP, EL_SPACESHIP_DOWN,
13106 EL_PACMAN_UP, EL_PACMAN_DOWN,
13107 EL_ARROW_UP, EL_ARROW_DOWN,
13108 EL_MOLE_UP, EL_MOLE_DOWN,
13109 EL_BALLOON_SWITCH_UP, EL_BALLOON_SWITCH_DOWN,
13110 EL_YAMYAM_UP, EL_YAMYAM_DOWN,
13111 EL_SP_PORT_UP, EL_SP_PORT_DOWN,
13112 EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN,
13113 EL_SP_GRAVITY_ON_PORT_UP, EL_SP_GRAVITY_ON_PORT_DOWN,
13114 EL_SP_GRAVITY_OFF_PORT_UP, EL_SP_GRAVITY_OFF_PORT_DOWN,
13115 EL_SP_CHIP_TOP, EL_SP_CHIP_BOTTOM,
13116 EL_TUBE_HORIZONTAL_UP, EL_TUBE_HORIZONTAL_DOWN,
13117 EL_TUBE_LEFT_UP, EL_TUBE_LEFT_DOWN,
13118 EL_TUBE_RIGHT_UP, EL_TUBE_RIGHT_DOWN,
13119 EL_DC_STEELWALL_1_TOP, EL_DC_STEELWALL_1_BOTTOM,
13120 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13121 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13122 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13123 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13124 EL_DC_STEELWALL_2_TOP, EL_DC_STEELWALL_2_BOTTOM,
13125 EL_EMC_WALL_1, EL_EMC_WALL_3,
13130 return getFlippedTileExt(map, element);
13133 static int getFlippedTileXY(int element)
13137 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_UP,
13138 EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY_DOWN,
13139 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_UP,
13140 EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY_DOWN,
13141 EL_BUG_LEFT, EL_BUG_UP,
13142 EL_BUG_RIGHT, EL_BUG_DOWN,
13143 EL_SPACESHIP_LEFT, EL_SPACESHIP_UP,
13144 EL_SPACESHIP_RIGHT, EL_SPACESHIP_DOWN,
13145 EL_PACMAN_LEFT, EL_PACMAN_UP,
13146 EL_PACMAN_RIGHT, EL_PACMAN_DOWN,
13147 EL_ARROW_LEFT, EL_ARROW_UP,
13148 EL_ARROW_RIGHT, EL_ARROW_DOWN,
13149 EL_MOLE_LEFT, EL_MOLE_UP,
13150 EL_MOLE_RIGHT, EL_MOLE_DOWN,
13151 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_UP,
13152 EL_BALLOON_SWITCH_RIGHT, EL_BALLOON_SWITCH_DOWN,
13153 EL_YAMYAM_LEFT, EL_YAMYAM_UP,
13154 EL_YAMYAM_RIGHT, EL_YAMYAM_DOWN,
13155 EL_SP_PORT_LEFT, EL_SP_PORT_UP,
13156 EL_SP_PORT_RIGHT, EL_SP_PORT_DOWN,
13157 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_UP,
13158 EL_SP_GRAVITY_PORT_RIGHT, EL_SP_GRAVITY_PORT_DOWN,
13159 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_UP,
13160 EL_SP_GRAVITY_ON_PORT_RIGHT, EL_SP_GRAVITY_ON_PORT_DOWN,
13161 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_UP,
13162 EL_SP_GRAVITY_OFF_PORT_RIGHT, EL_SP_GRAVITY_OFF_PORT_DOWN,
13163 EL_SP_CHIP_LEFT, EL_SP_CHIP_TOP,
13164 EL_SP_CHIP_RIGHT, EL_SP_CHIP_BOTTOM,
13165 EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL,
13166 EL_TUBE_VERTICAL_LEFT, EL_TUBE_HORIZONTAL_UP,
13167 EL_TUBE_VERTICAL_RIGHT, EL_TUBE_HORIZONTAL_DOWN,
13168 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_UP,
13169 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_TOP,
13170 EL_DC_STEELWALL_1_RIGHT, EL_DC_STEELWALL_1_BOTTOM,
13171 EL_DC_STEELWALL_1_HORIZONTAL, EL_DC_STEELWALL_1_VERTICAL,
13172 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13173 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13174 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_TOP,
13175 EL_DC_STEELWALL_2_RIGHT, EL_DC_STEELWALL_2_BOTTOM,
13176 EL_DC_STEELWALL_2_HORIZONTAL, EL_DC_STEELWALL_2_VERTICAL,
13177 EL_EXPANDABLE_WALL_HORIZONTAL, EL_EXPANDABLE_WALL_VERTICAL,
13178 EL_EXPANDABLE_STEELWALL_HORIZONTAL, EL_EXPANDABLE_STEELWALL_VERTICAL,
13183 return getFlippedTileExt(map, element);
13186 static int getFlippedTile(int element, int mode)
13188 if (IS_MM_ELEMENT(element))
13190 // get MM game element
13191 element = map_element_RND_to_MM(element);
13193 // get flipped game element
13194 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX_MM(element) :
13195 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY_MM(element) :
13196 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY_MM(element) :
13199 // get RND game element again
13200 element = map_element_MM_to_RND(element);
13204 // get flipped game element
13205 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX(element) :
13206 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY(element) :
13207 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY(element) :
13214 static void SwapFlippedTiles(short *tile1, short *tile2, int mode)
13217 short tile1_flipped = getFlippedTile(*tile1, mode);
13218 short tile2_flipped = getFlippedTile(*tile2, mode);
13221 *tile1 = tile2_flipped;
13222 *tile2 = tile1_flipped;
13225 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
13227 DrawLineElement(sx, sy, element, change_level);
13230 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
13231 int button, int mode)
13233 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13234 static int brush_width, brush_height;
13235 static int last_cursor_x = -1, last_cursor_y = -1;
13236 static boolean delete_old_brush = FALSE;
13237 int new_element = BUTTON_ELEMENT(button);
13240 if (mode == CB_DUMP_BRUSH ||
13241 mode == CB_DUMP_BRUSH_SMALL ||
13242 mode == CB_BRUSH_TO_CLIPBOARD ||
13243 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13245 if (edit_mode != ED_MODE_DRAWING)
13248 char part[MAX_CB_PART_SIZE + 1] = "";
13249 char text[MAX_CB_TEXT_SIZE + 1] = "";
13250 int width = (draw_with_brush ? brush_width : lev_fieldx);
13251 int height = (draw_with_brush ? brush_height : lev_fieldy);
13252 char *format = "%s%03d";
13254 for (y = 0; y < height; y++)
13255 for (x = 0; x < width; x++)
13256 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
13259 for (y = 0; y < height; y++)
13261 for (x = 0; x < width; x++)
13263 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
13264 char *prefix = (mode == CB_DUMP_BRUSH ||
13265 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
13267 if (element >= NUM_FILE_ELEMENTS)
13268 element = EL_UNKNOWN;
13270 // copy brush to level sketch text buffer for the R'n'D forum:
13271 // - large tiles: `xxx or `xxxx (0x60 ASCII)
13272 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
13273 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
13274 strcat(text, part);
13277 strcat(text, "\n");
13280 if (mode == CB_BRUSH_TO_CLIPBOARD ||
13281 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13282 SDL_SetClipboardText(text);
13284 Print("%s", text); // print brush data to console and log file
13289 if (mode == CB_CLIPBOARD_TO_BRUSH)
13291 if (edit_mode != ED_MODE_DRAWING)
13294 if (!SDL_HasClipboardText())
13296 Request("Clipboard is empty!", REQ_CONFIRM);
13301 boolean copy_to_brush = (draw_with_brush ||
13302 drawing_function == GADGET_ID_GRAB_BRUSH);
13304 // this will delete the old brush, if already drawing with a brush
13306 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
13308 // initialization is required for "odd" (incomplete) clipboard content
13309 for (x = 0; x < MAX_LEV_FIELDX; x++)
13310 for (y = 0; y < MAX_LEV_FIELDY; y++)
13311 brush_buffer[x][y] = EL_EMPTY;
13318 char *clipboard_text = SDL_GetClipboardText();
13319 char *ptr = clipboard_text;
13320 boolean allow_new_row = FALSE;
13321 boolean stop = FALSE;
13323 while (*ptr && !stop)
13325 boolean prefix_found = FALSE;
13326 boolean start_new_row = FALSE;
13328 // level sketch element number prefixes (may be multi-byte characters)
13329 char *prefix_list[] = { "`", "¸" };
13332 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
13334 char *prefix = prefix_list[i];
13336 // check if string is large enough for prefix
13337 if (strlen(ptr) < strlen(prefix))
13344 // check if string starts with prefix
13345 if (strPrefix(ptr, prefix))
13347 ptr += strlen(prefix);
13349 prefix_found = TRUE;
13355 // check if prefix found and followed by (at least) three digits
13356 if (prefix_found &&
13357 strlen(ptr) >= 3 &&
13358 ptr[0] >= '0' && ptr[0] <= '9' &&
13359 ptr[1] >= '0' && ptr[1] <= '9' &&
13360 ptr[2] >= '0' && ptr[2] <= '9')
13362 int element = ((ptr[0] - '0') * 100 +
13363 (ptr[1] - '0') * 10 +
13368 // level sketch element number might consist of four digits
13369 if (ptr[0] >= '0' && ptr[0] <= '9')
13371 element = element * 10 + (ptr[0] - '0');
13375 // remap some (historic, now obsolete) elements
13376 element = getMappedElement(element);
13378 if (element >= NUM_FILE_ELEMENTS)
13379 element = EL_UNKNOWN;
13381 brush_buffer[x][y] = element;
13383 brush_width = MAX(x + 1, brush_width);
13384 brush_height = MAX(y + 1, brush_height);
13388 if (x >= MAX_LEV_FIELDX)
13389 start_new_row = TRUE;
13391 allow_new_row = TRUE;
13395 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
13396 start_new_row = TRUE;
13398 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
13406 if (y >= MAX_LEV_FIELDY)
13409 allow_new_row = FALSE;
13413 SDL_free(clipboard_text);
13415 if (brush_width == 0 || brush_height == 0)
13417 Request("No level sketch found in clipboard!", REQ_CONFIRM);
13424 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
13427 SDL_GetMouseState(&mx, &my);
13429 // if inside drawing area, activate and draw brush at last mouse position
13430 if (mx >= gi->x && mx < gi->x + gi->width &&
13431 my >= gi->y && my < gi->y + gi->height)
13432 CopyBrushToCursor(last_cursor_x, last_cursor_y);
13434 draw_with_brush = TRUE;
13440 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
13441 brush_width, brush_height);
13443 if (!Request(request, REQ_ASK))
13446 for (x = 0; x < MAX_LEV_FIELDX; x++)
13447 for (y = 0; y < MAX_LEV_FIELDY; y++)
13448 Tile[x][y] = brush_buffer[x][y];
13450 lev_fieldx = level.fieldx = brush_width;
13451 lev_fieldy = level.fieldy = brush_height;
13453 boolean use_bd_engine = TRUE;
13454 boolean use_em_engine = TRUE;
13455 boolean use_sp_engine = TRUE;
13456 boolean use_mm_engine = TRUE;
13458 for (x = 0; x < MAX_LEV_FIELDX; x++)
13460 for (y = 0; y < MAX_LEV_FIELDY; y++)
13462 int element = Tile[x][y];
13464 if (!IS_BD_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13465 use_bd_engine = FALSE;
13467 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13468 use_em_engine = FALSE;
13470 if (!IS_SP_ELEMENT(element))
13471 use_sp_engine = FALSE;
13473 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
13474 use_mm_engine = FALSE;
13478 level.game_engine_type = (use_bd_engine ? GAME_ENGINE_TYPE_BD :
13479 use_em_engine ? GAME_ENGINE_TYPE_EM :
13480 use_sp_engine ? GAME_ENGINE_TYPE_SP :
13481 use_mm_engine ? GAME_ENGINE_TYPE_MM :
13482 GAME_ENGINE_TYPE_RND);
13484 // update element selection list
13485 ReinitializeElementList();
13486 ModifyEditorElementList();
13488 SetBorderElement();
13490 DrawEditModeWindow();
13491 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13497 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
13500 if (mode == CB_AREA_TO_BRUSH)
13502 int from_lx, from_ly;
13505 swap_numbers(&from_x, &to_x);
13508 swap_numbers(&from_y, &to_y);
13510 brush_width = to_x - from_x + 1;
13511 brush_height = to_y - from_y + 1;
13513 from_lx = from_x + level_xpos;
13514 from_ly = from_y + level_ypos;
13516 for (y = 0; y < brush_height; y++)
13518 for (x = 0; x < brush_width; x++)
13520 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
13523 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
13528 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13530 delete_old_brush = FALSE;
13532 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
13533 mode == CB_BRUSH_TO_LEVEL)
13535 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
13536 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
13537 int cursor_from_x = cursor_x - brush_width / 2;
13538 int cursor_from_y = cursor_y - brush_height / 2;
13539 int border_from_x = cursor_x, border_from_y = cursor_y;
13540 int border_to_x = cursor_x, border_to_y = cursor_y;
13542 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
13543 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13545 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
13546 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
13548 delete_old_brush = FALSE;
13553 for (y = 0; y < brush_height; y++)
13555 for (x = 0; x < brush_width; x++)
13557 int sx = cursor_from_x + x;
13558 int sy = cursor_from_y + y;
13559 int lx = sx + level_xpos;
13560 int ly = sy + level_ypos;
13561 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
13562 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
13563 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
13564 brush_buffer[x][y] : new_element);
13566 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13568 if (sx < border_from_x)
13569 border_from_x = sx;
13570 else if (sx > border_to_x)
13572 if (sy < border_from_y)
13573 border_from_y = sy;
13574 else if (sy > border_to_y)
13577 DrawBrushElement(sx, sy, element, change_level);
13582 if (mode != CB_DELETE_OLD_CURSOR)
13583 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
13585 last_cursor_x = cursor_x;
13586 last_cursor_y = cursor_y;
13588 delete_old_brush = TRUE;
13590 else if (mode == CB_FLIP_BRUSH_X)
13592 for (y = 0; y < brush_height; y++)
13593 for (x = 0; x < (brush_width + 1) / 2; x++)
13594 SwapFlippedTiles(&brush_buffer[x][y],
13595 &brush_buffer[brush_width - x - 1][y], mode);
13597 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13599 else if (mode == CB_FLIP_BRUSH_Y)
13601 for (y = 0; y < (brush_height + 1) / 2; y++)
13602 for (x = 0; x < brush_width; x++)
13603 SwapFlippedTiles(&brush_buffer[x][y],
13604 &brush_buffer[x][brush_height - y - 1], mode);
13606 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13608 else if (mode == CB_FLIP_BRUSH_XY)
13610 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13612 for (y = 0; y < MAX(brush_width, brush_height); y++)
13613 for (x = 0; x <= y; x++)
13614 SwapFlippedTiles(&brush_buffer[x][y],
13615 &brush_buffer[y][x], mode);
13617 swap_numbers(&brush_width, &brush_height);
13619 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13622 if (mode == CB_UPDATE_BRUSH_POSITION)
13624 last_cursor_x = from_x;
13625 last_cursor_y = from_y;
13629 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
13632 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
13635 static void CopyBrushToLevel(int x, int y, int button)
13637 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
13640 static void CopyBrushToCursor(int x, int y)
13642 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13645 static void UpdateBrushPosition(int x, int y)
13647 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
13650 static void DeleteBrushFromCursor(void)
13652 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13655 static void FlipBrushX(void)
13657 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13660 static void FlipBrushY(void)
13662 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_Y);
13665 static void RotateBrush(void)
13667 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_XY);
13668 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13671 void DumpBrush(void)
13673 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
13676 void DumpBrush_Small(void)
13678 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
13681 void CopyClipboardToBrush(void)
13683 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
13686 void CopyBrushToClipboard(void)
13688 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
13691 void CopyBrushToClipboard_Small(void)
13693 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
13696 void UndoLevelEditorOperation(void)
13698 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
13701 void RedoLevelEditorOperation(void)
13703 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13706 static void FloodFill(int from_x, int from_y, int fill_element)
13708 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
13711 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
13713 int from_x = from_sx2 + 2 * level_xpos;
13714 int from_y = from_sy2 + 2 * level_ypos;
13715 int max_fillx = lev_fieldx * 2;
13716 int max_filly = lev_fieldy * 2;
13717 short Fill[max_fillx][max_filly];
13720 for (x = 0; x < max_fillx; x++)
13721 for (y = 0; y < max_filly; y++)
13722 Fill[x][y] = getLevelElementHiRes(x, y);
13724 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
13725 Fill, max_fillx, max_filly);
13727 for (x = 0; x < max_fillx; x++)
13728 for (y = 0; y < max_filly; y++)
13729 if (Fill[x][y] == fill_element)
13730 SetLevelElementHiRes(x, y, Fill[x][y]);
13733 // values for DrawLevelText() modes
13734 #define TEXT_INIT 0
13735 #define TEXT_SETCURSOR 1
13736 #define TEXT_WRITECHAR 2
13737 #define TEXT_BACKSPACE 3
13738 #define TEXT_NEWLINE 4
13740 #define TEXT_QUERY_TYPING 6
13742 static int DrawLevelText(int sx, int sy, char letter, int mode)
13744 static short delete_buffer[MAX_LEV_FIELDX];
13745 static int start_sx;
13746 static int last_sx, last_sy;
13747 static boolean typing = FALSE;
13748 int letter_element;
13749 int lx = 0, ly = 0;
13751 // map lower case letters to upper case and convert special characters
13752 if (letter >= 'a' && letter <= 'z')
13753 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
13754 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
13755 letter_element = EL_CHAR_AUMLAUT;
13756 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
13757 letter_element = EL_CHAR_OUMLAUT;
13758 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
13759 letter_element = EL_CHAR_UUMLAUT;
13760 else if (letter == '^')
13761 letter_element = EL_CHAR_COPYRIGHT;
13763 letter_element = EL_CHAR_ASCII0 + letter;
13765 if (mode != TEXT_INIT)
13770 if (mode != TEXT_SETCURSOR)
13776 lx = last_sx + level_xpos;
13777 ly = last_sy + level_ypos;
13784 DrawLevelText(0, 0, 0, TEXT_END);
13790 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
13793 case TEXT_SETCURSOR:
13794 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
13795 DrawAreaBorder(sx, sy, sx, sy);
13796 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
13797 ed_tilesize, ed_tilesize);
13802 case TEXT_WRITECHAR:
13803 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
13805 if (new_element1 >= EL_STEEL_CHAR_START &&
13806 new_element1 <= EL_STEEL_CHAR_END)
13807 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
13809 delete_buffer[sx - start_sx] = Tile[lx][ly];
13810 Tile[lx][ly] = letter_element;
13812 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
13813 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
13814 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13815 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13817 DrawLevelText(0, 0, 0, TEXT_END);
13819 level.changed = TRUE;
13823 case TEXT_BACKSPACE:
13826 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
13827 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
13828 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
13833 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13834 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13836 DrawLevelText(0, 0, 0, TEXT_END);
13840 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13841 DrawEditorElement(sx, sy, Tile[lx][ly]);
13846 case TEXT_QUERY_TYPING:
13856 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
13857 int element, boolean change_level)
13859 int lx = sx + level_xpos;
13860 int ly = sy + level_ypos;
13863 DrawEditorElement(sx, sy, Tile[lx][ly]);
13865 DrawAreaBorder(sx, sy, sx, sy);
13868 static void CheckLevelBorderElement(boolean redraw_playfield)
13870 int last_border_element = BorderElement;
13872 SetBorderElement();
13874 if (redraw_playfield && BorderElement != last_border_element)
13875 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13878 static void CopyLevelToUndoBuffer(int mode)
13880 static boolean accumulated_undo = FALSE;
13881 boolean new_undo_buffer_position = TRUE;
13884 if (undo_buffer_steps == 0)
13885 accumulated_undo = FALSE;
13889 case UNDO_IMMEDIATE:
13890 accumulated_undo = FALSE;
13893 case UNDO_ACCUMULATE:
13894 if (accumulated_undo)
13895 new_undo_buffer_position = FALSE;
13896 accumulated_undo = TRUE;
13903 if (new_undo_buffer_position)
13905 // advance position in undo buffer ring
13906 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13908 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
13909 undo_buffer_steps++;
13912 // always reset redo buffer when storing level change into undo buffer
13913 redo_buffer_steps = 0;
13915 for (x = 0; x < lev_fieldx; x++)
13916 for (y = 0; y < lev_fieldy; y++)
13917 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
13919 // check if drawing operation forces change of border style
13920 CheckLevelBorderElement(TRUE);
13922 level.changed = TRUE;
13925 static void RandomPlacement(int new_element)
13927 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13928 int num_free_positions = 0;
13929 int num_percentage, num_elements;
13932 ResetIntelliDraw();
13934 // determine number of free positions for randomly placing the new element
13935 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
13937 free_position[x][y] =
13938 (random_placement_background_restricted ?
13939 Tile[x][y] == random_placement_background_element :
13940 Tile[x][y] != new_element);
13942 if (free_position[x][y])
13943 num_free_positions++;
13946 // determine number of new elements to place there
13947 num_percentage = num_free_positions * random_placement_value / 100;
13948 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
13949 num_percentage : random_placement_value);
13951 // if less free positions than elements to place, fill all these positions
13952 if (num_free_positions < num_elements)
13954 for (x = 0; x < lev_fieldx; x++)
13955 for (y = 0; y < lev_fieldy; y++)
13956 if (free_position[x][y])
13957 SetElement(x, y, new_element);
13961 while (num_elements > 0)
13963 x = GetSimpleRandom(lev_fieldx);
13964 y = GetSimpleRandom(lev_fieldy);
13966 // don't place element at the same position twice
13967 if (free_position[x][y])
13969 free_position[x][y] = FALSE;
13970 SetElement(x, y, new_element);
13976 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13977 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13980 static void WrapLevel(int dx, int dy)
13982 int wrap_dx = lev_fieldx - dx;
13983 int wrap_dy = lev_fieldy - dy;
13986 for (x = 0; x < lev_fieldx; x++)
13987 for (y = 0; y < lev_fieldy; y++)
13988 TileBackup[x][y] = Tile[x][y];
13990 for (x = 0; x < lev_fieldx; x++)
13991 for (y = 0; y < lev_fieldy; y++)
13993 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
13995 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13996 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
13999 static void DrawAreaElementHighlight(boolean highlighted,
14000 boolean highlighted_similar)
14002 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14009 for (x = 0; x < ed_fieldx; x++)
14011 for (y = 0; y < ed_fieldy; y++)
14013 boolean highlight = FALSE;
14014 int lx = x + level_xpos;
14015 int ly = y + level_ypos;
14017 if (!IN_LEV_FIELD(lx, ly))
14020 // check if element is the same
14021 if (Tile[lx][ly] == new_element1)
14024 // check if element is similar
14025 if (highlighted_similar &&
14026 strEqual(element_info[Tile[lx][ly]].class_name,
14027 element_info[new_element1].class_name))
14030 // check if element is matching MM style wall
14031 if (IS_MM_WALL(Tile[lx][ly]) &&
14032 map_mm_wall_element(Tile[lx][ly]) == new_element1)
14038 if (IS_MM_WALL(Tile[lx][ly]) && !highlighted_similar)
14042 for (i = 0; i < 4; i++)
14044 if (!(MM_WALL_BITS(Tile[lx][ly]) & (1 << i)))
14047 int xx = x * 2 + (i % 2);
14048 int yy = y * 2 + (i / 2);
14049 int sx = SX + xx * ed_tilesize / 2;
14050 int sy = SY + yy * ed_tilesize / 2;
14053 int to_sx = sx + ed_tilesize / 2 - 1;
14054 int to_sy = sy + ed_tilesize / 2 - 1;
14056 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
14057 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
14058 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14059 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14064 int sx = SX + x * ed_tilesize;
14065 int sy = SY + y * ed_tilesize;
14068 int to_sx = sx + ed_tilesize - 1;
14069 int to_sy = sy + ed_tilesize - 1;
14071 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
14072 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
14073 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14074 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14080 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
14082 char *template_filename_old = getLocalLevelTemplateFilename();
14083 char *template_filename_new =
14084 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
14086 if (copyFile(template_filename_old, template_filename_new) != 0)
14087 Request("Cannot copy level template!", REQ_CONFIRM);
14089 free(template_filename_new);
14092 static void HandleDrawingAreas(struct GadgetInfo *gi)
14094 static boolean started_inside_drawing_area = FALSE;
14095 static int last_sx = -1;
14096 static int last_sy = -1;
14097 static int last_sx2 = -1;
14098 static int last_sy2 = -1;
14099 int id = gi->custom_id;
14100 int type_id = gi->custom_type_id;
14101 boolean button_press_event;
14102 boolean button_release_event;
14103 boolean inside_drawing_area = !gi->event.off_borders;
14104 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
14105 int actual_drawing_function;
14106 int button = gi->event.button;
14107 int new_element = BUTTON_ELEMENT(button);
14108 int sx = gi->event.x, sy = gi->event.y;
14109 int min_sx = 0, min_sy = 0;
14110 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
14111 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
14112 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
14113 int sx2 = gi->event.mx / mini_item_xsize;
14114 int sy2 = gi->event.my / mini_item_ysize;
14117 int lx = 0, ly = 0;
14120 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
14121 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
14123 // make sure to stay inside drawing area boundaries
14124 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14125 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14129 int min_lx = 0, min_ly = 0;
14130 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14132 // get positions inside level field
14133 lx = sx + level_xpos;
14134 ly = sy + level_ypos;
14136 if (!IN_LEV_FIELD(lx, ly))
14137 inside_drawing_area = FALSE;
14139 // make sure to stay inside level field boundaries
14140 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14141 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14143 // correct drawing area positions accordingly
14144 sx = lx - level_xpos;
14145 sy = ly - level_ypos;
14148 // also correct MM wall-sized (double) drawing area positions accordingly
14149 if (sx2 / 2 < sx || sx2 / 2 > sx)
14151 dx = (sx2 / 2 < sx ? 0 : 1);
14154 if (sy2 / 2 < sy || sy2 / 2 > sy)
14156 dy = (sy2 / 2 < sy ? 0 : 1);
14160 if (!button_press_event && !button_release_event)
14162 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
14163 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
14164 isHiresTileElement(old_element) &&
14165 isHiresDrawElement(new_element));
14167 // prevent handling events for every pixel position when moving mouse
14168 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
14169 (sx2 == last_sx2 && sy2 == last_sy2))
14178 if (button_press_event)
14179 started_inside_drawing_area = inside_drawing_area;
14181 if (!started_inside_drawing_area)
14184 if (!IS_VALID_BUTTON(button))
14187 // handle info callback for each invocation of action callback
14188 gi->callback_info(gi);
14190 // automatically switch to 'single item' drawing mode, if needed
14191 actual_drawing_function =
14192 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
14193 drawing_function : GADGET_ID_SINGLE_ITEMS);
14195 // clicking into drawing area with pressed Control key picks element
14196 if (GetKeyModState() & KMOD_Control)
14198 last_drawing_function = drawing_function;
14199 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14202 if (GetKeyModState() & KMOD_Shift)
14204 if (button_press_event || button_release_event)
14205 ResetIntelliDraw();
14208 SetDrawModeHiRes(-1); // reset to normal draw mode
14210 switch (actual_drawing_function)
14212 case GADGET_ID_SINGLE_ITEMS:
14215 if (button_release_event)
14217 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14219 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
14220 !inside_drawing_area)
14221 DeleteBrushFromCursor();
14226 if (draw_with_brush)
14228 CopyBrushToLevel(sx, sy, button);
14232 SetDrawModeHiRes(new_element);
14234 if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
14236 // remove player at old position
14237 for (y = 0; y < lev_fieldy; y++)
14239 for (x = 0; x < lev_fieldx; x++)
14241 int old_element = Tile[x][y];
14243 if (IS_PLAYER_ELEMENT(old_element) &&
14244 IS_PLAYER_ELEMENT(new_element))
14246 int replaced_with_element =
14247 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
14248 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
14250 old_element == EL_SOKOBAN_FIELD_PLAYER &&
14251 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
14253 new_element == EL_SOKOBAN_FIELD_PLAYER &&
14254 old_element == EL_PLAYER_1 ? EL_EMPTY :
14256 new_element >= EL_PLAYER_1 &&
14257 new_element <= EL_PLAYER_4 &&
14258 new_element == old_element ? EL_EMPTY :
14262 SetElement(x, y, replaced_with_element);
14264 else if (IS_MM_MCDUFFIN(old_element) &&
14265 IS_MM_MCDUFFIN(new_element))
14267 // remove McDuffin at old position
14268 SetElement(x, y, EL_EMPTY);
14274 SetElementButton(lx, ly, dx, dy, new_element, button);
14277 else if (!button_release_event)
14279 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14281 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
14282 DrawMiniGraphicExt(drawto,
14283 gi->x + sx * MINI_TILEX,
14284 gi->y + sy * MINI_TILEY,
14285 el2edimg(new_element));
14287 DrawFixedGraphicExt(drawto,
14288 gi->x + sx * TILEX,
14289 gi->y + sy * TILEY,
14290 el2edimg(new_element), 0);
14292 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14293 new_element = GFX_ELEMENT(new_element);
14295 drawingarea_info[type_id].value[pos] = new_element;
14297 CopyElementPropertiesToGame(properties_element);
14299 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14301 UpdateCustomElementGraphicGadgets();
14303 FrameCounter = 0; // restart animation frame counter
14308 case GADGET_ID_CONNECTED_ITEMS:
14310 static int last_sx = -1;
14311 static int last_sy = -1;
14313 if (button_release_event)
14314 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14316 SetDrawModeHiRes(new_element);
14318 if (getDrawModeHiRes())
14324 if (!button_press_event)
14325 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
14332 case GADGET_ID_LINE:
14333 case GADGET_ID_ARC:
14334 case GADGET_ID_RECTANGLE:
14335 case GADGET_ID_FILLED_BOX:
14336 SetDrawModeHiRes(new_element);
14338 if (getDrawModeHiRes())
14344 case GADGET_ID_GRAB_BRUSH:
14345 case GADGET_ID_TEXT:
14347 static int last_sx = -1;
14348 static int last_sy = -1;
14349 static int start_sx = -1;
14350 static int start_sy = -1;
14351 void (*draw_func)(int, int, int, int, int, boolean);
14353 if (drawing_function == GADGET_ID_LINE)
14354 draw_func = DrawLine;
14355 else if (drawing_function == GADGET_ID_ARC)
14356 draw_func = DrawArc;
14357 else if (drawing_function == GADGET_ID_RECTANGLE)
14358 draw_func = DrawBox;
14359 else if (drawing_function == GADGET_ID_FILLED_BOX)
14360 draw_func = DrawFilledBox;
14361 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
14362 draw_func = SelectArea;
14363 else // (drawing_function == GADGET_ID_TEXT)
14364 draw_func = SetTextCursor;
14366 if (button_press_event)
14368 draw_func(sx, sy, sx, sy, new_element, FALSE);
14369 start_sx = last_sx = sx;
14370 start_sy = last_sy = sy;
14372 if (drawing_function == GADGET_ID_TEXT)
14373 DrawLevelText(0, 0, 0, TEXT_END);
14375 else if (button_release_event)
14377 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
14378 if (drawing_function == GADGET_ID_GRAB_BRUSH)
14380 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
14381 CopyBrushToCursor(sx, sy);
14382 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14384 draw_with_brush = TRUE;
14386 else if (drawing_function == GADGET_ID_TEXT)
14387 DrawLevelText(sx, sy, 0, TEXT_INIT);
14389 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14391 else if (last_sx != sx || last_sy != sy)
14393 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
14394 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
14395 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
14396 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
14403 case GADGET_ID_FLOOD_FILL:
14404 if (button_press_event && Tile[lx][ly] != new_element)
14406 if (IS_MM_WALL_EDITOR(new_element))
14407 FloodFillWall_MM(sx2, sy2, new_element);
14409 FloodFill(lx, ly, new_element);
14411 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14412 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14416 case GADGET_ID_PICK_ELEMENT:
14417 if (button_release_event)
14418 ClickOnGadget(level_editor_gadget[last_drawing_function],
14420 else if (draw_level)
14421 PickDrawingElement(button, Tile[lx][ly]);
14424 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14426 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
14433 // do not mark level as modified for certain non-level-changing gadgets
14434 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
14435 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
14436 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
14437 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14440 level.changed = TRUE;
14443 static void HandleCounterButtons(struct GadgetInfo *gi)
14445 int gadget_id = gi->custom_id;
14446 int counter_id = gi->custom_type_id;
14447 int button = gi->event.button;
14448 int *counter_value = counterbutton_info[counter_id].value;
14449 int step = BUTTON_STEPSIZE(button) *
14450 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
14452 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14454 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
14455 boolean released = (gi->event.type == GD_EVENT_RELEASED);
14456 boolean level_changed = LevelChanged();
14458 if ((level_changed && pressed) || (!level_changed && released))
14461 if (level_changed && !Request("Level has changed! Discard changes?",
14464 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14465 ModifyEditorCounterValue(counter_id, *counter_value);
14471 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14472 *counter_value = gi->textinput.number_value;
14474 ModifyEditorCounterValue(counter_id, *counter_value + step);
14476 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14478 int last_game_engine_type = level.game_engine_type;
14480 LoadLevel(level_nr);
14481 LoadScore(level_nr);
14483 SaveLevelSetup_SeriesInfo();
14488 DrawEditModeWindow();
14490 if (level.game_engine_type != last_game_engine_type)
14492 // update element selection list
14493 ReinitializeElementList();
14494 ModifyEditorElementList();
14500 switch (counter_id)
14502 case ED_COUNTER_ID_YAMYAM_CONTENT:
14503 DrawYamYamContentAreas();
14506 case ED_COUNTER_ID_BALL_CONTENT:
14507 DrawMagicBallContentAreas();
14510 case ED_COUNTER_ID_ANDROID_CONTENT:
14511 DrawAndroidElementArea();
14514 case ED_COUNTER_ID_GROUP_CONTENT:
14515 DrawGroupElementArea();
14516 CopyGroupElementPropertiesToGame(properties_element);
14519 case ED_COUNTER_ID_INVENTORY_SIZE:
14520 DrawPlayerInitialInventoryArea(properties_element);
14523 case ED_COUNTER_ID_MM_BALL_CONTENT:
14524 DrawMMBallContentArea();
14527 case ED_COUNTER_ID_ENVELOPE_XSIZE:
14528 case ED_COUNTER_ID_ENVELOPE_YSIZE:
14529 DrawEnvelopeTextArea(-1);
14532 case ED_COUNTER_ID_LEVEL_XSIZE:
14533 case ED_COUNTER_ID_LEVEL_YSIZE:
14534 lev_fieldx = level.fieldx;
14535 lev_fieldy = level.fieldy;
14537 // check if resizing of level results in change of border border
14538 SetBorderElement();
14546 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
14547 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
14548 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
14549 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
14550 CopyElementPropertiesToGame(properties_element);
14552 // do not mark level as modified for certain non-level-changing gadgets
14553 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
14554 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
14555 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
14556 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
14559 level.changed = TRUE;
14562 static void HandleTextInputGadgets(struct GadgetInfo *gi)
14564 int type_id = gi->custom_type_id;
14566 strcpy(textinput_info[type_id].value, gi->textinput.value);
14568 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
14570 CopyElementPropertiesToGame(properties_element);
14572 ModifyEditorElementList(); // update changed button info text
14575 // do not mark level as modified for certain non-level-changing gadgets
14576 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
14577 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
14580 level.changed = TRUE;
14583 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
14585 int type_id = gi->custom_type_id;
14587 strncpy(textarea_info[type_id].value, gi->textarea.value,
14588 MAX_ENVELOPE_TEXT_LEN);
14589 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
14591 level.changed = TRUE;
14594 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
14596 int type_id = gi->custom_type_id;
14597 int value_old = *selectbox_info[type_id].value;
14598 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
14600 *selectbox_info[type_id].value = value_new;
14602 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
14604 DrawLevelConfigWindow();
14606 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14608 element_info[properties_element].current_change_page = gi->selectbox.index;
14610 DrawPropertiesWindow();
14612 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
14613 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
14614 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
14615 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
14616 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
14618 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
14620 // when changing action type, also check action mode and action arg
14621 if (value_old != value_new)
14622 setSelectboxSpecialActionVariablesIfNeeded();
14624 DrawPropertiesChange();
14627 CopyElementPropertiesToGame(properties_element);
14629 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
14631 // show or hide "engine" tabulator depending on game engine type
14632 DrawLevelConfigWindow();
14634 // update element selection list depending on game engine type
14635 ReinitializeElementList();
14636 ModifyEditorElementList();
14638 else if (type_id == ED_SELECTBOX_ID_BD_SCHEDULING_TYPE)
14640 // update BD cycle delay counter gadgets depending on BD scheduling type
14641 DrawLevelConfigWindow();
14644 // do not mark level as modified for certain non-level-changing gadgets
14645 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
14646 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14649 level.changed = TRUE;
14652 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
14654 int type_id = gi->custom_type_id;
14657 if (type_id >= ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST &&
14658 type_id <= ED_TAB_BUTTON_ID_LEVELCONFIG_LAST)
14660 edit_mode_levelconfig = gi->custom_type_id;
14662 DrawLevelConfigWindow();
14664 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
14665 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
14667 edit_mode_properties = gi->custom_type_id;
14669 DrawPropertiesWindow();
14671 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
14672 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
14674 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
14676 // backup original "level.field" (needed to track playfield changes)
14677 CopyPlayfield(level.field, TileBackup);
14679 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
14680 CopyPlayfield(Tile, level.field);
14682 if (new_template ||
14683 Request("Save this template and kill the old?", REQ_ASK))
14684 SaveLevelTemplate();
14687 Request("Template saved!", REQ_CONFIRM);
14689 // restore original "level.field" (needed to track playfield changes)
14690 CopyPlayfield(TileBackup, level.field);
14692 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
14694 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
14696 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
14697 leveldir_current->readonly)
14699 Request("This level set is read-only!", REQ_CONFIRM);
14704 if (strEqual(levelset_name, ""))
14706 Request("Please enter level set title!", REQ_CONFIRM);
14711 if (strEqual(levelset_author, ""))
14713 Request("Please enter level set author!", REQ_CONFIRM);
14718 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
14720 if (UpdateUserLevelSet(levelset_subdir,
14723 levelset_num_levels))
14725 Request("Level set updated!", REQ_CONFIRM);
14729 Request("Updating level set failed!", REQ_CONFIRM);
14732 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
14734 if (level.changed && !Request("Level has changed! Discard changes?",
14738 if (CreateUserLevelSet(levelset_subdir,
14741 levelset_num_levels,
14742 levelset_use_levelset_artwork))
14744 if (levelset_copy_level_template)
14745 CopyLevelTemplateToUserLevelSet(levelset_subdir);
14747 Request("New level set created!", REQ_CONFIRM);
14749 AddUserLevelSetToLevelInfo(levelset_subdir);
14750 ChangeEditorToLevelSet(levelset_subdir);
14754 Request("Creating new level set failed!", REQ_CONFIRM);
14758 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
14759 custom_element.num_change_pages < MAX_CHANGE_PAGES)
14761 struct ElementInfo *ei = &element_info[properties_element];
14763 // when modifying custom element, ask for copying level template
14764 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14767 setElementChangePages(ei, ei->num_change_pages + 1);
14769 // set new change page to be new current change page
14770 ei->current_change_page = ei->num_change_pages - 1;
14771 ei->change = &ei->change_page[ei->current_change_page];
14773 setElementChangeInfoToDefaults(ei->change);
14775 DrawPropertiesWindow();
14777 level.changed = TRUE;
14779 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
14780 custom_element.num_change_pages > MIN_CHANGE_PAGES)
14782 struct ElementInfo *ei = &element_info[properties_element];
14784 // when modifying custom element, ask for copying level template
14785 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14788 // copy all change pages after change page to be deleted
14789 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
14790 ei->change_page[i] = ei->change_page[i + 1];
14792 setElementChangePages(ei, ei->num_change_pages - 1);
14794 DrawPropertiesWindow();
14796 level.changed = TRUE;
14800 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
14802 int type_id = gi->custom_type_id;
14804 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
14805 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
14807 struct ElementInfo *ei = &element_info[properties_element];
14808 int step = BUTTON_STEPSIZE(gi->event.button);
14810 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
14811 ei->current_change_page += step;
14813 if (ei->current_change_page < 0)
14814 ei->current_change_page = 0;
14815 else if (ei->current_change_page >= ei->num_change_pages)
14816 ei->current_change_page = ei->num_change_pages - 1;
14818 DrawPropertiesWindow();
14820 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
14821 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14823 struct ElementInfo *ei = &element_info[properties_element];
14824 int current_change_page = ei->current_change_page;
14826 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
14828 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
14829 ei->change_page[current_change_page];
14831 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14833 // when modifying custom element, ask for copying level template
14834 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14837 ei->change_page[current_change_page] =
14838 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
14840 level.changed = TRUE;
14843 DrawPropertiesWindow();
14847 static void HandleRadiobuttons(struct GadgetInfo *gi)
14849 int type_id = gi->custom_type_id;
14851 *radiobutton_info[type_id].value =
14852 radiobutton_info[type_id].checked_value;
14854 // do not mark level as modified for certain non-level-changing gadgets
14855 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
14856 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
14859 level.changed = TRUE;
14862 static void HandleCheckbuttons(struct GadgetInfo *gi)
14864 int type_id = gi->custom_type_id;
14866 *checkbutton_info[type_id].value ^= TRUE;
14868 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
14869 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
14870 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
14871 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
14872 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
14873 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
14874 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
14875 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
14877 CopyElementPropertiesToGame(properties_element);
14880 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
14882 UpdateCustomElementGraphicGadgets();
14884 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
14885 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
14887 boolean template_related_changes_found = FALSE;
14890 // check if any custom, group or empty elements have been changed
14891 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
14892 if ((IS_CUSTOM_ELEMENT(i) ||
14893 IS_GROUP_ELEMENT(i) ||
14894 IS_EMPTY_ELEMENT(i)) &&
14895 element_info[i].modified_settings)
14896 template_related_changes_found = TRUE;
14898 if (level.use_custom_template &&
14899 !fileExists(getGlobalLevelTemplateFilename()))
14901 Request("No level template found!", REQ_CONFIRM);
14903 level.use_custom_template = FALSE;
14905 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14910 if (level.use_custom_template &&
14911 template_related_changes_found &&
14912 !Request("Discard changes and use level template?", REQ_ASK))
14914 level.use_custom_template = FALSE;
14916 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14921 if (!level.use_custom_template &&
14922 Request("Copy settings from level template?", REQ_ASK))
14927 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
14929 DrawEditModeWindow();
14931 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
14933 if (setup.editor.use_template_for_new_levels &&
14934 !fileExists(getGlobalLevelTemplateFilename()))
14936 Request("No level template found!", REQ_CONFIRM);
14941 if (setup.editor.use_template_for_new_levels &&
14943 !Request("Discard level and load template?", REQ_ASK))
14948 if (!setup.editor.use_template_for_new_levels &&
14950 !Request("Discard level and use empty level?", REQ_ASK))
14955 LoadLevel(level_nr);
14956 LoadScore(level_nr);
14961 DrawEditModeWindow();
14963 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
14965 SetAutomaticNumberOfGemsNeeded();
14968 // do not mark level as modified for certain non-level-changing gadgets
14969 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
14970 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
14971 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
14972 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
14973 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
14974 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
14977 level.changed = TRUE;
14980 static void HandleControlButtons(struct GadgetInfo *gi)
14982 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
14983 static int last_edit_mode = ED_MODE_DRAWING;
14984 static int last_custom_copy_mode = -1;
14985 static int last_button = 0;
14986 int id = gi->custom_id;
14987 int button = gi->event.button;
14988 int step = BUTTON_STEPSIZE(button);
14989 int new_element = BUTTON_ELEMENT(button);
14990 int last_properties_element = properties_element;
14993 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
14994 DrawLevelText(0, 0, 0, TEXT_END);
14996 if (id < ED_NUM_CTRL1_BUTTONS &&
14997 id != GADGET_ID_SINGLE_ITEMS &&
14998 id != GADGET_ID_PICK_ELEMENT &&
14999 edit_mode != ED_MODE_DRAWING &&
15000 drawing_function != GADGET_ID_PICK_ELEMENT &&
15001 !(GetKeyModState() & KMOD_Control))
15002 ChangeEditModeWindow(ED_MODE_DRAWING);
15004 // element copy mode active, but no element button pressed => deactivate
15005 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
15006 last_custom_copy_mode = -1;
15008 // when showing palette on element buttons, change element of button used
15009 if (editor.palette.show_on_element_buttons &&
15010 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
15012 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
15014 id = GADGET_ID_PALETTE;
15019 case GADGET_ID_SCROLL_LEFT:
15020 if (level_xpos >= 0)
15022 if (lev_fieldx < ed_fieldx - 2)
15025 level_xpos -= step;
15026 if (level_xpos < -1)
15029 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
15031 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15033 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
15034 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
15038 case GADGET_ID_SCROLL_RIGHT:
15039 if (level_xpos <= lev_fieldx - ed_fieldx)
15041 if (lev_fieldx < ed_fieldx - 2)
15044 level_xpos += step;
15045 if (level_xpos > lev_fieldx - ed_fieldx + 1)
15046 level_xpos = lev_fieldx - ed_fieldx + 1;
15048 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
15050 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15052 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
15053 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
15057 case GADGET_ID_SCROLL_UP:
15058 if (level_ypos >= 0)
15060 if (lev_fieldy < ed_fieldy - 2)
15063 level_ypos -= step;
15064 if (level_ypos < -1)
15067 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
15069 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15071 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15072 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15076 case GADGET_ID_SCROLL_DOWN:
15077 if (level_ypos <= lev_fieldy - ed_fieldy)
15079 if (lev_fieldy < ed_fieldy - 2)
15082 level_ypos += step;
15083 if (level_ypos > lev_fieldy - ed_fieldy + 1)
15084 level_ypos = lev_fieldy - ed_fieldy + 1;
15086 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
15088 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15090 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15091 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15095 case GADGET_ID_SCROLL_HORIZONTAL:
15096 level_xpos = gi->event.item_position - 1;
15098 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15103 case GADGET_ID_SCROLL_VERTICAL:
15104 level_ypos = gi->event.item_position - 1;
15106 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15111 case GADGET_ID_SCROLL_LIST_UP:
15112 case GADGET_ID_SCROLL_LIST_DOWN:
15113 case GADGET_ID_SCROLL_LIST_VERTICAL:
15114 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
15115 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
15118 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
15119 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15121 if (element_shift < 0)
15123 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15124 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15126 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15127 GDI_SCROLLBAR_ITEM_POSITION,
15128 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15131 ModifyEditorElementList();
15135 case GADGET_ID_PROPERTIES:
15136 // always switch off element properties when they are already displayed
15137 last_properties_element = new_element;
15138 case GADGET_ID_ELEMENT_LEFT:
15139 case GADGET_ID_ELEMENT_MIDDLE:
15140 case GADGET_ID_ELEMENT_RIGHT:
15141 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
15142 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
15143 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
15146 if (edit_mode != ED_MODE_PROPERTIES)
15148 last_edit_mode = edit_mode;
15150 ChangeEditModeWindow(ED_MODE_PROPERTIES);
15152 last_level_drawing_function = drawing_function;
15153 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
15156 else if (properties_element != last_properties_element)
15158 DrawEditModeWindow();
15162 ChangeEditModeWindow(ED_MODE_DRAWING);
15164 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
15169 case GADGET_ID_PALETTE:
15170 if (edit_mode != ED_MODE_PALETTE)
15172 last_edit_mode = edit_mode;
15174 ChangeEditModeWindow(ED_MODE_PALETTE);
15178 ChangeEditModeWindow(last_edit_mode);
15182 case GADGET_ID_WRAP_LEFT:
15183 WrapLevel(-step, 0);
15186 case GADGET_ID_WRAP_RIGHT:
15187 WrapLevel(step, 0);
15190 case GADGET_ID_WRAP_UP:
15191 WrapLevel(0, -step);
15194 case GADGET_ID_WRAP_DOWN:
15195 WrapLevel(0, step);
15198 case GADGET_ID_SINGLE_ITEMS:
15199 case GADGET_ID_CONNECTED_ITEMS:
15200 case GADGET_ID_LINE:
15201 case GADGET_ID_ARC:
15202 case GADGET_ID_TEXT:
15203 case GADGET_ID_RECTANGLE:
15204 case GADGET_ID_FILLED_BOX:
15205 case GADGET_ID_FLOOD_FILL:
15206 case GADGET_ID_GRAB_BRUSH:
15207 case GADGET_ID_PICK_ELEMENT:
15208 if (drawing_function != GADGET_ID_PICK_ELEMENT)
15209 last_drawing_function = drawing_function;
15210 drawing_function = id;
15211 draw_with_brush = FALSE;
15214 case GADGET_ID_RANDOM_PLACEMENT:
15215 RandomPlacement(new_element);
15218 case GADGET_ID_ZOOM:
15219 // zoom level editor tile size in or out (or reset to default size)
15220 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
15221 button == 2 ? ed_tilesize_default :
15222 button == 3 ? ed_tilesize / 2 : ed_tilesize);
15224 // when using touch device, cycle through all zoom tilesizes
15225 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
15226 ed_tilesize = MICRO_TILESIZE;
15228 // limit zoom level by upper and lower bound
15229 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
15231 InitZoomLevelSettings(ed_tilesize);
15233 if (edit_mode == ED_MODE_DRAWING)
15235 DrawDrawingWindow();
15237 // redraw zoom gadget info text
15238 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15241 // save current editor zoom tilesize
15242 SaveSetup_AutoSetup();
15246 case GADGET_ID_CUSTOM_COPY_FROM:
15247 case GADGET_ID_CUSTOM_COPY_TO:
15248 case GADGET_ID_CUSTOM_EXCHANGE:
15249 last_custom_copy_mode = id;
15250 last_drawing_function = drawing_function;
15253 case GADGET_ID_CUSTOM_COPY:
15254 CopyCustomElement(properties_element, -1, id);
15257 case GADGET_ID_CUSTOM_PASTE:
15258 CopyCustomElement(-1, properties_element, id);
15261 case GADGET_ID_UNDO:
15262 if (button < 0) // keep button value (even if modifier keys are pressed)
15264 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
15267 if (button == 1 && undo_buffer_steps == 0)
15269 Request("Undo buffer empty!", REQ_CONFIRM);
15273 else if (button == 2)
15277 else if (button == 3 && redo_buffer_steps == 0)
15279 Request("Redo buffer empty!", REQ_CONFIRM);
15284 if (edit_mode != ED_MODE_DRAWING)
15285 ChangeEditModeWindow(ED_MODE_DRAWING);
15291 undo_buffer_position =
15292 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
15294 undo_buffer_steps--;
15295 redo_buffer_steps++;
15301 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
15303 undo_buffer_steps++;
15304 redo_buffer_steps--;
15307 for (x = 0; x < lev_fieldx; x++)
15308 for (y = 0; y < lev_fieldy; y++)
15309 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
15311 // check if undo operation forces change of border style
15312 CheckLevelBorderElement(FALSE);
15314 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15318 case GADGET_ID_CONF:
15319 if (edit_mode != ED_MODE_LEVELCONFIG)
15321 last_edit_mode = edit_mode;
15323 ChangeEditModeWindow(ED_MODE_LEVELCONFIG);
15327 ChangeEditModeWindow(ED_MODE_DRAWING);
15331 case GADGET_ID_CLEAR:
15332 if (edit_mode != ED_MODE_DRAWING)
15333 ChangeEditModeWindow(ED_MODE_DRAWING);
15335 for (x = 0; x < MAX_LEV_FIELDX; x++)
15336 for (y = 0; y < MAX_LEV_FIELDY; y++)
15337 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
15339 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
15341 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15344 case GADGET_ID_SAVE:
15346 // saving read-only levels into personal level set modifies global vars
15347 // "leveldir_current" and "level_nr"; restore them after saving level
15348 LevelDirTree *leveldir_former = leveldir_current;
15349 int level_nr_former = level_nr;
15350 char *level_filename;
15353 if (leveldir_current->readonly &&
15354 !PrepareSavingIntoPersonalLevelSet())
15357 level_filename = getDefaultLevelFilename(level_nr);
15358 new_level = !fileExists(level_filename);
15361 Request("Save this level and kill the old?", REQ_ASK))
15363 if (leveldir_former->readonly)
15364 ModifyLevelConfigForSavingIntoPersonalLevelSet(leveldir_former->name);
15366 SetAutomaticNumberOfGemsNeeded();
15368 CopyPlayfield(Tile, level.field);
15369 SaveLevel(level_nr);
15371 level.changed = FALSE;
15375 char level_saved_msg[64];
15377 if (leveldir_former->readonly)
15378 sprintf(level_saved_msg,
15379 "Level saved as level %d into personal level set!",
15382 strcpy(level_saved_msg, "Level saved!");
15384 Request(level_saved_msg, REQ_CONFIRM);
15388 // "cd" back to copied-from levelset (in case of saved read-only level)
15389 leveldir_current = leveldir_former;
15390 level_nr = level_nr_former;
15395 case GADGET_ID_TEST:
15396 if (LevelChanged())
15397 level.game_version = GAME_VERSION_ACTUAL;
15399 CopyPlayfield(level.field, TileBackup);
15400 CopyPlayfield(Tile, level.field);
15402 CopyNativeLevel_RND_to_Native(&level);
15404 UnmapLevelEditorGadgets();
15405 UndrawSpecialEditorDoor();
15407 CloseDoor(DOOR_CLOSE_ALL);
15409 // needed before playing if editor playfield area has different size
15410 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
15412 // redraw_mask = REDRAW_ALL;
15414 level_editor_test_game = TRUE;
15416 StartGameActions(FALSE, setup.autorecord, level.random_seed);
15420 case GADGET_ID_EXIT:
15421 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
15425 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
15426 id <= GADGET_ID_ELEMENTLIST_LAST)
15428 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
15430 new_element = editor_elements[element_position + element_shift];
15432 if (IS_EDITOR_CASCADE(new_element))
15436 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
15438 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
15439 boolean *cascade_value = editor_elements_info[i].setup_cascade_value;
15441 if (*cascade_element == new_element)
15443 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
15444 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
15446 // update element selection list
15447 ReinitializeElementList();
15448 ModifyEditorElementList();
15450 // update cascading gadget info text
15451 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15453 // save current editor cascading state
15454 SaveSetup_EditorCascade();
15463 if (last_custom_copy_mode != -1)
15465 if (CopyCustomElement(properties_element, new_element,
15466 last_custom_copy_mode))
15468 ClickOnGadget(level_editor_gadget[last_drawing_function],
15471 last_custom_copy_mode = -1;
15477 // change element of button used to show palette
15478 if (editor.palette.show_on_element_buttons)
15479 button = last_button;
15481 PickDrawingElement(button, new_element);
15483 if (!stick_element_properties_window &&
15484 drawing_function != GADGET_ID_PICK_ELEMENT &&
15485 !(GetKeyModState() & KMOD_Control))
15487 properties_element = new_element;
15488 if (edit_mode == ED_MODE_PROPERTIES)
15489 DrawPropertiesWindow();
15492 if (drawing_function == GADGET_ID_PICK_ELEMENT)
15493 ClickOnGadget(level_editor_gadget[last_drawing_function],
15496 if (!use_permanent_palette)
15497 ChangeEditModeWindow(last_edit_mode);
15500 else if (gi->event.type == GD_EVENT_PRESSED)
15501 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
15502 else if (gi->event.type == GD_EVENT_RELEASED)
15503 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
15504 else if (gi->event.type == GD_EVENT_MOVING)
15505 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
15507 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
15513 void HandleLevelEditorKeyInput(Key key)
15515 char letter = getCharFromKey(key);
15517 if (drawing_function == GADGET_ID_TEXT &&
15518 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
15521 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
15522 else if (key == KSYM_Delete || key == KSYM_BackSpace)
15523 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
15524 else if (key == KSYM_Return)
15525 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
15526 else if (key == KSYM_Escape)
15527 DrawLevelText(0, 0, 0, TEXT_END);
15532 int id = GADGET_ID_NONE;
15533 int new_element_shift = element_shift;
15534 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
15535 int button = MB_LEFTBUTTON;
15541 id = GADGET_ID_SCROLL_LEFT;
15544 id = GADGET_ID_SCROLL_RIGHT;
15547 id = GADGET_ID_SCROLL_UP;
15550 id = GADGET_ID_SCROLL_DOWN;
15554 case KSYM_Page_Down:
15555 step *= (key == KSYM_Page_Up ? -1 : +1);
15556 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15558 if (element_shift < 0)
15560 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15561 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15563 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15564 GDI_SCROLLBAR_ITEM_POSITION,
15565 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15567 ModifyEditorElementList();
15573 element_shift = (key == KSYM_Home ? 0 :
15574 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
15576 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15577 GDI_SCROLLBAR_ITEM_POSITION,
15578 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15580 ModifyEditorElementList();
15587 // this is needed to prevent interference with running "True X-Mouse"
15588 if (GetKeyModStateFromEvents() & KMOD_Control)
15591 // check for last or next editor cascade block in element list
15592 for (i = 0; i < num_editor_elements; i++)
15594 if ((key == KSYM_Insert && i == element_shift) ||
15595 (key == KSYM_Delete && new_element_shift > element_shift))
15598 // jump to next cascade block (or to start of element list)
15599 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
15600 new_element_shift = i;
15603 if (i < num_editor_elements)
15604 element_shift = new_element_shift;
15606 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15607 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15609 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15610 GDI_SCROLLBAR_ITEM_POSITION,
15611 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15613 ModifyEditorElementList();
15618 if (edit_mode == ED_MODE_DRAWING)
15619 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
15620 else if (edit_mode == ED_MODE_LEVELCONFIG)
15621 HandleControlButtons(level_editor_gadget[GADGET_ID_CONF]);
15622 else if (edit_mode == ED_MODE_PROPERTIES)
15623 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
15624 else if (edit_mode == ED_MODE_PALETTE)
15625 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
15626 else // should never happen
15627 ChangeEditModeWindow(ED_MODE_DRAWING);
15635 if (id != GADGET_ID_NONE)
15636 ClickOnGadget(level_editor_gadget[id], button);
15637 else if (letter == '1' || letter == '?')
15638 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
15639 else if (letter == '2')
15640 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
15641 else if (letter == '3')
15642 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
15643 else if (letter == '.')
15644 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
15645 else if (letter == 'U')
15646 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
15647 else if (letter == '-' || key == KSYM_KP_Subtract)
15648 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
15649 else if (letter == '0' || key == KSYM_KP_0)
15650 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
15651 else if (letter == '+' || key == KSYM_KP_Add ||
15652 letter == '=') // ("Shift-=" is "+" on US keyboards)
15653 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
15654 else if (key == KSYM_Return ||
15655 key == KSYM_space ||
15656 key == setup.shortcut.toggle_pause)
15657 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
15659 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
15660 if (letter && letter == controlbutton_info[i].shortcut)
15661 if (!anyTextGadgetActive())
15662 ClickOnGadget(level_editor_gadget[i], button);
15664 if (draw_with_brush)
15668 else if (letter == 'y')
15670 else if (letter == 'z')
15675 static void HandleLevelEditorIdle_Properties(void)
15677 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
15678 int x = editor.settings.element_graphic.x + element_border;
15679 int y = editor.settings.element_graphic.y + element_border;
15680 static DelayCounter action_delay = { 0 };
15683 action_delay.value = GameFrameDelay;
15685 if (!DelayReached(&action_delay))
15688 for (i = 0; i < ED_NUM_SELECTBOX; i++)
15690 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
15692 if (gi->mapped && gi->active && gi->selectbox.open)
15696 DrawEditorElementAnimation(SX + x, SY + y);
15698 redraw_mask |= REDRAW_FIELD;
15700 FrameCounter++; // increase animation frame counter
15703 static void HandleLevelEditorIdle_Drawing(void)
15705 static boolean last_highlighted = FALSE;
15706 static boolean last_highlighted_similar = FALSE;
15707 boolean highlighted = (GetKeyModState() & KMOD_Alt);
15708 boolean highlighted_similar = (GetKeyModState() & KMOD_Shift);
15710 if (highlighted != last_highlighted ||
15711 (highlighted && highlighted_similar != last_highlighted_similar))
15713 DrawAreaElementHighlight(highlighted, highlighted_similar);
15715 redraw_mask |= REDRAW_FIELD;
15718 last_highlighted = highlighted;
15719 last_highlighted_similar = highlighted_similar;
15722 void HandleLevelEditorIdle(void)
15724 if (edit_mode == ED_MODE_PROPERTIES)
15725 HandleLevelEditorIdle_Properties();
15726 else if (edit_mode == ED_MODE_DRAWING)
15727 HandleLevelEditorIdle_Drawing();
15730 static void ClearEditorGadgetInfoText(void)
15732 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
15735 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
15737 char infotext[MAX_OUTPUT_LINESIZE + 1];
15738 int max_infotext_len = getMaxInfoTextLength();
15740 if (gi == NULL || strlen(gi->info_text) == 0)
15743 strncpy(infotext, gi->info_text, max_infotext_len);
15744 infotext[max_infotext_len] = '\0';
15746 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
15748 int key = controlbutton_info[gi->custom_id].shortcut;
15752 char shortcut[MAX_OUTPUT_LINESIZE + 1];
15754 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
15755 sprintf(shortcut, " ('.' or '%c')", key);
15756 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
15757 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
15758 else if (gi->custom_id == GADGET_ID_TEST)
15759 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
15760 else if (gi->custom_id == GADGET_ID_UNDO)
15761 sprintf(shortcut, " ('%c/Shift-U')", key);
15762 else if (gi->custom_id == GADGET_ID_ZOOM)
15763 sprintf(shortcut, " ('%c', '0', '-')", key);
15765 sprintf(shortcut, " ('%s%c')",
15766 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
15768 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
15769 strcat(infotext, shortcut);
15773 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
15776 void HandleEditorGadgetInfoText(void *ptr)
15778 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
15780 if (game_status != GAME_MODE_EDITOR)
15783 ClearEditorGadgetInfoText();
15785 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
15788 // misuse this function to delete brush cursor, if needed
15789 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
15790 DeleteBrushFromCursor();
15792 PrintEditorGadgetInfoText(gi);
15795 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
15797 int id = gi->custom_id;
15798 int type_id = gi->custom_type_id;
15799 int sx = gi->event.x;
15800 int sy = gi->event.y;
15801 int lx = sx + level_xpos;
15802 int ly = sy + level_ypos;
15803 int min_sx = 0, min_sy = 0;
15804 int max_sx = gi->drawing.area_xsize - 1;
15805 int max_sy = gi->drawing.area_ysize - 1;
15806 int actual_drawing_function = drawing_function;
15807 int max_infotext_len = getMaxInfoTextLength();
15808 char infotext[MAX_OUTPUT_LINESIZE + 1];
15810 infotext[0] = '\0'; // start with empty info text
15812 // pressed Control key: simulate picking element
15813 if (GetKeyModState() & KMOD_Control)
15814 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
15816 ClearEditorGadgetInfoText();
15818 if (gi->event.type == GD_EVENT_INFO_LEAVING)
15821 // make sure to stay inside drawing area boundaries
15822 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
15823 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
15825 if (id == GADGET_ID_DRAWING_LEVEL)
15829 int min_lx = 0, min_ly = 0;
15830 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
15832 // get positions inside level field
15833 lx = sx + level_xpos;
15834 ly = sy + level_ypos;
15836 // make sure to stay inside level field boundaries
15837 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
15838 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
15840 // correct drawing area positions accordingly
15841 sx = lx - level_xpos;
15842 sy = ly - level_ypos;
15845 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15847 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
15849 static int start_lx = 0;
15850 static int start_ly = 0;
15853 if (gi->event.type == GD_EVENT_PRESSED)
15859 switch (actual_drawing_function)
15861 case GADGET_ID_SINGLE_ITEMS:
15862 text = "Drawing single items";
15864 case GADGET_ID_CONNECTED_ITEMS:
15865 text = "Drawing connected items";
15867 case GADGET_ID_LINE:
15868 text = "Drawing line";
15870 case GADGET_ID_ARC:
15871 text = "Drawing arc";
15873 case GADGET_ID_TEXT:
15874 text = "Setting text cursor";
15876 case GADGET_ID_RECTANGLE:
15877 text = "Drawing rectangle";
15879 case GADGET_ID_FILLED_BOX:
15880 text = "Drawing filled box";
15882 case GADGET_ID_FLOOD_FILL:
15883 text = "Flood fill";
15885 case GADGET_ID_GRAB_BRUSH:
15886 text = "Grabbing brush";
15888 case GADGET_ID_PICK_ELEMENT:
15889 text = "Picking element";
15893 text = "Drawing position";
15897 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15898 sprintf(infotext, "%s: %d, %d", text, lx, ly);
15900 sprintf(infotext, "%s: %d, %d", text,
15901 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
15903 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15904 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
15906 sprintf(infotext, "Level position: %d, %d", lx, ly);
15909 // misuse this function to draw brush cursor, if needed
15910 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
15912 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15913 CopyBrushToCursor(sx, sy);
15915 DeleteBrushFromCursor();
15918 if (!draw_with_brush)
15919 UpdateBrushPosition(sx, sy);
15921 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15923 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
15924 int element = drawingarea_info[type_id].value[pos];
15926 strncpy(infotext, getElementInfoText(element), max_infotext_len);
15930 if (id == GADGET_ID_CUSTOM_CONTENT)
15931 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
15932 else if (id == GADGET_ID_GROUP_CONTENT)
15933 sprintf(infotext, "group element position: %d", sx + 1);
15934 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
15935 id <= GADGET_ID_YAMYAM_CONTENT_7)
15936 sprintf(infotext, "content area %d position: %d, %d",
15937 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
15938 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
15939 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
15940 sprintf(infotext, "content area %d position: %d, %d",
15941 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
15942 else if (id == GADGET_ID_ANDROID_CONTENT)
15943 sprintf(infotext, "android element position: %d", sx + 1);
15944 else if (drawingarea_info[type_id].infotext != NULL)
15945 strcpy(infotext, drawingarea_info[type_id].infotext);
15948 infotext[max_infotext_len] = '\0';
15950 if (strlen(infotext) > 0)
15951 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
15954 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
15955 boolean quick_quit)
15957 if (!ask_if_level_has_changed ||
15959 Request("Level has changed! Exit without saving?",
15960 REQ_ASK | REQ_STAY_OPEN))
15962 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
15963 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
15965 // draw normal door
15966 UndrawSpecialEditorDoor();
15968 // use door animation if door 1 viewport is unchanged and contains toolbox
15969 if (useEditorDoorAnimation())
15970 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
15972 // close editor doors if viewport definition is the same as in main menu
15973 if (vp_door_1->x == DX &&
15974 vp_door_1->y == DY &&
15975 vp_door_1->width == DXSIZE &&
15976 vp_door_1->height == DYSIZE &&
15977 vp_door_2->x == VX &&
15978 vp_door_2->y == VY &&
15979 vp_door_2->width == VXSIZE &&
15980 vp_door_2->height == VYSIZE)
15981 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
15983 SetDoorState(DOOR_CLOSE_ALL);
15988 FadeSkipNextFadeIn();
15990 SetGameStatus(GAME_MODE_MAIN);
15996 if (!global.use_envelope_request)
15998 CloseDoor(DOOR_CLOSE_1);
15999 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);