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_BD_SCAN_FIRST_AND_LAST_ROW,
669 GADGET_ID_BD_SHORT_EXPLOSIONS,
670 GADGET_ID_BD_GRAVITY_AFFECTS_ALL,
671 GADGET_ID_STICK_ELEMENT,
672 GADGET_ID_EM_SLIPPERY_GEMS,
673 GADGET_ID_EM_EXPLODES_BY_FIRE,
674 GADGET_ID_USE_SPRING_BUG,
675 GADGET_ID_USE_TIME_ORB_BUG,
676 GADGET_ID_USE_LIFE_BUGS,
677 GADGET_ID_RANDOM_BALL_CONTENT,
678 GADGET_ID_INITIAL_BALL_ACTIVE,
679 GADGET_ID_GROW_INTO_DIGGABLE,
680 GADGET_ID_SB_FIELDS_NEEDED,
681 GADGET_ID_SB_OBJECTS_NEEDED,
682 GADGET_ID_AUTO_EXIT_SOKOBAN,
683 GADGET_ID_SOLVED_BY_ONE_PLAYER,
684 GADGET_ID_FINISH_DIG_COLLECT,
685 GADGET_ID_KEEP_WALKABLE_CE,
686 GADGET_ID_CONTINUOUS_SNAPPING,
687 GADGET_ID_BLOCK_SNAP_FIELD,
688 GADGET_ID_BLOCK_LAST_FIELD,
689 GADGET_ID_SP_BLOCK_LAST_FIELD,
690 GADGET_ID_INSTANT_RELOCATION,
691 GADGET_ID_SHIFTED_RELOCATION,
692 GADGET_ID_LAZY_RELOCATION,
693 GADGET_ID_USE_START_ELEMENT,
694 GADGET_ID_USE_ARTWORK_ELEMENT,
695 GADGET_ID_USE_EXPLOSION_ELEMENT,
696 GADGET_ID_INITIAL_GRAVITY,
697 GADGET_ID_USE_INITIAL_INVENTORY,
698 GADGET_ID_CAN_PASS_TO_WALKABLE,
699 GADGET_ID_CAN_FALL_INTO_ACID,
700 GADGET_ID_CAN_MOVE_INTO_ACID,
701 GADGET_ID_DONT_COLLIDE_WITH,
702 GADGET_ID_BD_DIAGONAL_MOVEMENTS,
703 GADGET_ID_BD_TOPMOST_PLAYER_ACTIVE,
704 GADGET_ID_ENVELOPE_AUTOWRAP,
705 GADGET_ID_ENVELOPE_CENTERED,
706 GADGET_ID_MM_LASER_RED,
707 GADGET_ID_MM_LASER_GREEN,
708 GADGET_ID_MM_LASER_BLUE,
709 GADGET_ID_DF_LASER_RED,
710 GADGET_ID_DF_LASER_GREEN,
711 GADGET_ID_DF_LASER_BLUE,
712 GADGET_ID_ROTATE_MM_BALL_CONTENT,
713 GADGET_ID_EXPLODE_MM_BALL,
714 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
715 GADGET_ID_CUSTOM_CAN_EXPLODE,
716 GADGET_ID_CUSTOM_EXPLODE_FIRE,
717 GADGET_ID_CUSTOM_EXPLODE_SMASH,
718 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
719 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
720 GADGET_ID_CUSTOM_DEADLY,
721 GADGET_ID_CUSTOM_CAN_MOVE,
722 GADGET_ID_CUSTOM_CAN_FALL,
723 GADGET_ID_CUSTOM_CAN_SMASH,
724 GADGET_ID_CUSTOM_SLIPPERY,
725 GADGET_ID_CUSTOM_ACCESSIBLE,
726 GADGET_ID_CUSTOM_GRAV_REACHABLE,
727 GADGET_ID_CUSTOM_USE_LAST_VALUE,
728 GADGET_ID_CUSTOM_USE_GRAPHIC,
729 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
730 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
731 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
732 GADGET_ID_CUSTOM_CAN_CHANGE,
733 GADGET_ID_CHANGE_USE_CONTENT,
734 GADGET_ID_CHANGE_USE_EXPLOSION,
735 GADGET_ID_CHANGE_ONLY_COMPLETE,
736 GADGET_ID_CHANGE_USE_RANDOM,
737 GADGET_ID_CHANGE_HAS_ACTION,
738 GADGET_ID_CHANGE_DELAY,
739 GADGET_ID_CHANGE_BY_DIRECT_ACT,
740 GADGET_ID_CHANGE_BY_OTHER_ACT,
742 NUM_STATIC_GADGET_IDS
745 // gadgets for buttons in element list (dynamic)
746 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
747 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
748 ED_NUM_ELEMENTLIST_BUTTONS - 1)
750 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
752 // radio button numbers
756 RADIO_NR_DRAWING_TOOLBOX,
757 RADIO_NR_RANDOM_ELEMENTS
760 // values for counter gadgets
763 ED_COUNTER_ID_SELECT_LEVEL,
764 ED_COUNTER_ID_LEVEL_XSIZE,
765 ED_COUNTER_ID_LEVEL_YSIZE,
766 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
767 ED_COUNTER_ID_LEVEL_TIMELIMIT,
768 ED_COUNTER_ID_LEVEL_TIMESCORE,
769 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
770 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
771 ED_COUNTER_ID_LEVEL_RANDOM,
772 ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
773 ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
774 ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES,
775 ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS,
776 ED_COUNTER_ID_ELEMENT_VALUE1,
777 ED_COUNTER_ID_ELEMENT_VALUE2,
778 ED_COUNTER_ID_ELEMENT_VALUE3,
779 ED_COUNTER_ID_ELEMENT_VALUE4,
780 ED_COUNTER_ID_YAMYAM_CONTENT,
781 ED_COUNTER_ID_BALL_CONTENT,
782 ED_COUNTER_ID_ANDROID_CONTENT,
783 ED_COUNTER_ID_ENVELOPE_XSIZE,
784 ED_COUNTER_ID_ENVELOPE_YSIZE,
785 ED_COUNTER_ID_INVENTORY_SIZE,
786 ED_COUNTER_ID_MM_BALL_CONTENT,
787 ED_COUNTER_ID_CUSTOM_SCORE,
788 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
789 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
790 ED_COUNTER_ID_CUSTOM_VALUE_RND,
791 ED_COUNTER_ID_PUSH_DELAY_FIX,
792 ED_COUNTER_ID_PUSH_DELAY_RND,
793 ED_COUNTER_ID_DROP_DELAY_FIX,
794 ED_COUNTER_ID_DROP_DELAY_RND,
795 ED_COUNTER_ID_MOVE_DELAY_FIX,
796 ED_COUNTER_ID_MOVE_DELAY_RND,
797 ED_COUNTER_ID_STEP_DELAY_FIX,
798 ED_COUNTER_ID_STEP_DELAY_RND,
799 ED_COUNTER_ID_EXPLOSION_DELAY,
800 ED_COUNTER_ID_IGNITION_DELAY,
801 ED_COUNTER_ID_GROUP_CONTENT,
802 ED_COUNTER_ID_CHANGE_DELAY_FIX,
803 ED_COUNTER_ID_CHANGE_DELAY_RND,
804 ED_COUNTER_ID_CHANGE_CONT_RND,
806 ED_NUM_COUNTERBUTTONS
809 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
810 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
811 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
812 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
813 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
814 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
816 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
817 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
818 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
819 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
820 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
821 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
823 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
824 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
826 // values for scrollbutton gadgets
829 ED_SCROLLBUTTON_ID_AREA_UP,
830 ED_SCROLLBUTTON_ID_AREA_DOWN,
831 ED_SCROLLBUTTON_ID_AREA_LEFT,
832 ED_SCROLLBUTTON_ID_AREA_RIGHT,
833 ED_SCROLLBUTTON_ID_LIST_UP,
834 ED_SCROLLBUTTON_ID_LIST_DOWN,
839 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
840 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
842 // values for scrollbar gadgets
845 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
846 ED_SCROLLBAR_ID_AREA_VERTICAL,
847 ED_SCROLLBAR_ID_LIST_VERTICAL,
852 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
853 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
855 // values for text input gadgets
858 ED_TEXTINPUT_ID_LEVEL_NAME,
859 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
860 ED_TEXTINPUT_ID_LEVELSET_NAME,
861 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
862 ED_TEXTINPUT_ID_ELEMENT_NAME,
867 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
868 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
870 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
871 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
873 // values for text area gadgets
876 ED_TEXTAREA_ID_ENVELOPE_INFO,
881 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
882 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
884 // values for selectbox gadgets
887 ED_SELECTBOX_ID_TIME_OR_STEPS,
888 ED_SELECTBOX_ID_TIME_SCORE_BASE,
889 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
890 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
891 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
892 ED_SELECTBOX_ID_WIND_DIRECTION,
893 ED_SELECTBOX_ID_PLAYER_SPEED,
894 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
895 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
896 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
897 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
898 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
899 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
900 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
901 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
902 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
903 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
904 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
905 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
906 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
907 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
908 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
909 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
910 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
911 ED_SELECTBOX_ID_CHANGE_SIDE,
912 ED_SELECTBOX_ID_CHANGE_PLAYER,
913 ED_SELECTBOX_ID_CHANGE_PAGE,
914 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
915 ED_SELECTBOX_ID_ACTION_TYPE,
916 ED_SELECTBOX_ID_ACTION_MODE,
917 ED_SELECTBOX_ID_ACTION_ARG,
918 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
919 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
924 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
925 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
927 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
928 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
930 #define ED_SELECTBOX_ID_ENGINE_FIRST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
931 #define ED_SELECTBOX_ID_ENGINE_LAST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
933 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
934 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
935 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
936 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
937 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
938 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
940 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
941 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
943 // values for textbutton gadgets
946 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
947 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
948 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
949 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
950 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
951 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
952 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
953 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
954 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
955 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
956 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
957 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
958 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
959 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
964 #define ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
965 #define ED_TAB_BUTTON_ID_LEVELCONFIG_LAST ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
967 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
968 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
970 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
971 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
973 // values for graphicbutton gadgets
976 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
977 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
978 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
979 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
981 ED_NUM_GRAPHICBUTTONS
984 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
985 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
987 // values for checkbutton gadgets
990 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
991 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
992 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
993 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
994 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
995 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
996 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
997 ED_CHECKBUTTON_ID_BD_INTERMISSION,
998 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
999 ED_CHECKBUTTON_ID_BD_LINE_SHIFTING_BORDERS,
1000 ED_CHECKBUTTON_ID_BD_SCAN_FIRST_AND_LAST_ROW,
1001 ED_CHECKBUTTON_ID_BD_SHORT_EXPLOSIONS,
1002 ED_CHECKBUTTON_ID_BD_GRAVITY_AFFECTS_ALL,
1003 ED_CHECKBUTTON_ID_STICK_ELEMENT,
1004 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
1005 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
1006 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
1007 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
1008 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
1009 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
1010 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
1011 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
1012 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
1013 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
1014 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
1015 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
1016 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
1017 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
1018 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
1019 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
1020 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
1021 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
1022 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
1023 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
1024 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
1025 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
1026 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
1027 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
1028 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
1029 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
1030 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
1031 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
1032 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
1033 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
1034 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
1035 ED_CHECKBUTTON_ID_BD_TOPMOST_PLAYER_ACTIVE,
1036 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
1037 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
1038 ED_CHECKBUTTON_ID_MM_LASER_RED,
1039 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
1040 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1041 ED_CHECKBUTTON_ID_DF_LASER_RED,
1042 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1043 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1044 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
1045 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
1046 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1047 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1048 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1049 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1050 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1051 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1052 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1053 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1054 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1055 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1056 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1057 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1058 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1059 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1060 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1061 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1062 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1063 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1064 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1065 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1066 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1067 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1068 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1069 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1070 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1075 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1076 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1078 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1079 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1081 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1082 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1084 #define ED_CHECKBUTTON_ID_ENGINE_FIRST ED_CHECKBUTTON_ID_BD_INTERMISSION
1085 #define ED_CHECKBUTTON_ID_ENGINE_LAST ED_CHECKBUTTON_ID_BD_GRAVITY_AFFECTS_ALL
1087 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1088 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1089 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1090 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1091 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1092 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1094 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1095 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1097 // values for radiobutton gadgets
1100 ED_RADIOBUTTON_ID_PERCENTAGE,
1101 ED_RADIOBUTTON_ID_QUANTITY,
1106 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1107 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1109 // values for drawing area gadgets
1112 ED_DRAWING_ID_DRAWING_LEVEL,
1113 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1114 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1115 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1116 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1117 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1118 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1119 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1120 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1121 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1122 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1123 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1124 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1125 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1126 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1127 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1128 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1129 ED_DRAWING_ID_ANDROID_CONTENT,
1130 ED_DRAWING_ID_AMOEBA_CONTENT,
1131 ED_DRAWING_ID_START_ELEMENT,
1132 ED_DRAWING_ID_ARTWORK_ELEMENT,
1133 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1134 ED_DRAWING_ID_INVENTORY_CONTENT,
1135 ED_DRAWING_ID_MM_BALL_CONTENT,
1136 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1137 ED_DRAWING_ID_CUSTOM_CONTENT,
1138 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1139 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1140 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1141 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1142 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1143 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1144 ED_DRAWING_ID_GROUP_CONTENT,
1145 ED_DRAWING_ID_RANDOM_BACKGROUND,
1147 ED_NUM_DRAWING_AREAS
1150 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1151 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1154 // ----------------------------------------------------------------------------
1155 // some internally used definitions
1156 // ----------------------------------------------------------------------------
1158 // values for CopyLevelToUndoBuffer()
1159 #define UNDO_IMMEDIATE 0
1160 #define UNDO_ACCUMULATE 1
1162 // values for scrollbars
1163 #define ED_SCROLL_NO 0
1164 #define ED_SCROLL_LEFT 1
1165 #define ED_SCROLL_RIGHT 2
1166 #define ED_SCROLL_UP 4
1167 #define ED_SCROLL_DOWN 8
1169 // screens in the level editor
1170 #define ED_MODE_DRAWING 0
1171 #define ED_MODE_LEVELCONFIG 1
1172 #define ED_MODE_PROPERTIES 2
1173 #define ED_MODE_PALETTE 3
1175 // sub-screens in the global settings section
1176 #define ED_MODE_LEVELCONFIG_LEVEL ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
1177 #define ED_MODE_LEVELCONFIG_LEVELSET ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET
1178 #define ED_MODE_LEVELCONFIG_EDITOR ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
1179 #define ED_MODE_LEVELCONFIG_ENGINE ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
1181 // sub-screens in the element properties section
1182 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1183 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1184 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1185 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1186 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1188 // how many steps can be cancelled
1189 #define NUM_UNDO_STEPS (64 + 1)
1191 // values for elements with score for certain actions
1193 #define MAX_SCORE 999
1195 // values for elements with count for collecting
1196 #define MIN_COLLECT_COUNT 0
1197 #define MAX_COLLECT_COUNT 999
1199 // values for random placement
1200 #define RANDOM_USE_PERCENTAGE 0
1201 #define RANDOM_USE_QUANTITY 1
1203 // values for level set save mode
1204 #define LEVELSET_SAVE_MODE_UPDATE 0
1205 #define LEVELSET_SAVE_MODE_CREATE 1
1207 // default value for element tile size in drawing area
1208 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1209 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1212 // ----------------------------------------------------------------------------
1213 // some internally used data structure definitions
1214 // ----------------------------------------------------------------------------
1220 struct XYTileSize *pos;
1224 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1226 // note: some additional characters are already reserved for "cheat mode"
1227 // shortcuts (":XYZ" style) -- for details, see "events.c"
1229 // ---------- toolbox control buttons ---------------------------------------
1232 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1233 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1234 "draw single items", 's'
1237 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1238 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1239 "draw connected items", 'd'
1242 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1243 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1247 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1248 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1252 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1253 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1254 "draw outline rectangles", 'r'
1257 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1258 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1259 "draw filled rectangles", 'R'
1262 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1263 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1264 "wrap (rotate) level up", 0
1267 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1268 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1269 "enter text elements", 't'
1272 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1273 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1277 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1278 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1279 "wrap (rotate) level left", 0
1282 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1283 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1284 "zoom level tile size", '+'
1287 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1288 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1289 "wrap (rotate) level right", 0
1292 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1293 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1294 "random element placement", 0
1297 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1298 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1302 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1303 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1304 "wrap (rotate) level down", 0
1307 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1308 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1309 "pick drawing element", ','
1312 // ---------- level control buttons -----------------------------------------
1315 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1316 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1317 "undo/redo last operation", 'u'
1320 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_CONF,
1321 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1322 "level and editor settings", 'I'
1325 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1326 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1330 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1331 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1335 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1336 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1340 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1341 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1342 "exit level editor", 'E'
1345 // ---------- CE and GE control buttons -------------------------------------
1348 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1349 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1350 "copy settings from other element", 0
1353 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1354 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1355 "copy settings to other element", 0
1358 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1359 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1360 "exchange element with other element", 0
1363 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1364 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1365 "copy settings from this element", 0
1368 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1369 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1370 "paste settings to this element", 0
1373 // ---------- palette control buttons ---------------------------------------
1376 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1377 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1378 "properties of drawing element", 'p'
1381 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1382 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1383 "properties of drawing element 1", '1'
1386 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1387 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1388 "properties of drawing element 2", '2'
1391 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1392 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1393 "properties of drawing element 3", '3'
1396 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1397 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1398 "show list of elements", 'e'
1402 static int random_placement_value = 10;
1403 static int random_placement_method = RANDOM_USE_QUANTITY;
1404 static int random_placement_background_element = EL_SAND;
1405 static boolean random_placement_background_restricted = FALSE;
1406 static boolean stick_element_properties_window = FALSE;
1407 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1408 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1409 static struct ElementChangeInfo custom_element_change;
1410 static struct ElementGroupInfo group_element_info;
1411 static struct ElementInfo custom_element;
1413 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1414 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1415 static int levelset_num_levels = 100;
1416 static boolean levelset_use_levelset_artwork = FALSE;
1417 static boolean levelset_copy_level_template = FALSE;
1418 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1424 int min_value, max_value;
1425 int gadget_id_down, gadget_id_up;
1427 int gadget_id_align;
1429 char *text_above, *text_left, *text_right;
1430 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1432 // ---------- current level number ------------------------------------------
1435 ED_COUNTER_ID_SELECT_LEVEL,
1436 -1, -1, // these values are not constant, but can change at runtime
1438 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1439 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1444 // ---------- level and editor settings -------------------------------------
1447 ED_COUNTER_ID_LEVEL_XSIZE,
1448 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1449 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1450 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1451 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1453 "playfield size:", NULL, "width",
1456 ED_COUNTER_ID_LEVEL_YSIZE,
1457 -1, ED_LEVEL_SETTINGS_YPOS(4),
1458 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1459 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1460 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1462 NULL, " ", "height",
1465 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
1466 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1468 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1469 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1471 NULL, "number of gems to collect:", NULL
1474 ED_COUNTER_ID_LEVEL_TIMELIMIT,
1475 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1477 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1478 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1480 "time or step limit to solve level:", NULL, NULL
1483 ED_COUNTER_ID_LEVEL_TIMESCORE,
1484 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1486 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1487 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1488 &level.score[SC_TIME_BONUS],
1489 "score for time or steps left:", NULL, NULL
1492 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
1493 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1495 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1496 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1498 NULL, "random seed:", "(0 => random)"
1501 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
1502 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1504 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1505 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1506 &levelset_num_levels,
1507 "number of levels:", NULL, NULL,
1510 ED_COUNTER_ID_LEVEL_RANDOM,
1511 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1513 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1514 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1515 &random_placement_value,
1516 "random element placement:", NULL, "in"
1519 ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
1520 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3),
1522 GADGET_ID_BD_CYCLE_DELAY_MS_DOWN, GADGET_ID_BD_CYCLE_DELAY_MS_UP,
1523 GADGET_ID_BD_CYCLE_DELAY_MS_TEXT, GADGET_ID_NONE,
1524 &level.bd_cycle_delay_ms,
1525 NULL, NULL, "game cycle delay (ms)"
1528 ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
1529 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3),
1531 GADGET_ID_BD_CYCLE_DELAY_C64_DOWN, GADGET_ID_BD_CYCLE_DELAY_C64_UP,
1532 GADGET_ID_BD_CYCLE_DELAY_C64_TEXT, GADGET_ID_NONE,
1533 &level.bd_cycle_delay_c64,
1534 NULL, NULL, "game cycle delay (C64-style)"
1537 ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES,
1538 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1540 GADGET_ID_BD_HATCHING_DELAY_CYCLES_DOWN, GADGET_ID_BD_HATCHING_DELAY_CYCLES_UP,
1541 GADGET_ID_BD_HATCHING_DELAY_CYCLES_TEXT, GADGET_ID_NONE,
1542 &level.bd_hatching_delay_cycles,
1543 NULL, NULL, "hatching delay (cycles)"
1546 ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS,
1547 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1549 GADGET_ID_BD_HATCHING_DELAY_SECONDS_DOWN, GADGET_ID_BD_HATCHING_DELAY_SECONDS_UP,
1550 GADGET_ID_BD_HATCHING_DELAY_SECONDS_TEXT, GADGET_ID_NONE,
1551 &level.bd_hatching_delay_seconds,
1552 NULL, NULL, "hatching delay (seconds)"
1555 // ---------- element settings: configure (various elements) ----------------
1558 ED_COUNTER_ID_ELEMENT_VALUE1,
1559 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1560 MIN_SCORE, MAX_SCORE,
1561 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1562 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1563 NULL, // will be set when used
1567 ED_COUNTER_ID_ELEMENT_VALUE2,
1568 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1569 MIN_SCORE, MAX_SCORE,
1570 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1571 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1572 NULL, // will be set when used
1576 ED_COUNTER_ID_ELEMENT_VALUE3,
1577 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1578 MIN_SCORE, MAX_SCORE,
1579 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1580 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1581 NULL, // will be set when used
1585 ED_COUNTER_ID_ELEMENT_VALUE4,
1586 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1587 MIN_SCORE, MAX_SCORE,
1588 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1589 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1590 NULL, // will be set when used
1594 ED_COUNTER_ID_YAMYAM_CONTENT,
1595 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1596 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1597 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1598 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1599 &level.num_yamyam_contents,
1600 NULL, NULL, "number of content areas"
1603 ED_COUNTER_ID_BALL_CONTENT,
1604 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1605 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1606 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1607 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1608 &level.num_ball_contents,
1609 NULL, NULL, "number of content areas"
1612 ED_COUNTER_ID_ANDROID_CONTENT,
1613 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1614 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1615 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1616 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1617 &level.num_android_clone_elements,
1618 NULL, NULL, "number of clonable elements"
1621 ED_COUNTER_ID_ENVELOPE_XSIZE,
1622 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1623 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1624 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1625 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1626 NULL, // will be set when used
1627 NULL, NULL, "width",
1630 ED_COUNTER_ID_ENVELOPE_YSIZE,
1631 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1632 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1633 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1634 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1635 NULL, // will be set when used
1636 NULL, " ", "height",
1639 ED_COUNTER_ID_INVENTORY_SIZE,
1640 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1641 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1642 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1643 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1644 &level.initial_inventory_size[0],
1645 NULL, NULL, "number of inventory elements"
1648 ED_COUNTER_ID_MM_BALL_CONTENT,
1649 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1650 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1651 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1652 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1653 &level.num_mm_ball_contents,
1654 NULL, NULL, "number of content elements"
1657 // ---------- element settings: configure 1 (custom elements) ---------------
1660 ED_COUNTER_ID_CUSTOM_SCORE,
1661 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1662 MIN_SCORE, MAX_SCORE,
1663 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1664 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1665 &custom_element.collect_score_initial,
1666 NULL, "CE score", " "
1669 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
1670 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1671 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1672 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1673 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1674 &custom_element.collect_count_initial,
1675 NULL, "CE count", NULL
1678 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
1679 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1681 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1682 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1683 &custom_element.ce_value_fixed_initial,
1684 NULL, "CE value", NULL
1687 ED_COUNTER_ID_CUSTOM_VALUE_RND,
1688 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1690 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1691 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1692 &custom_element.ce_value_random_initial,
1693 NULL, "+random", NULL
1696 ED_COUNTER_ID_PUSH_DELAY_FIX,
1697 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1699 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1700 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1701 &custom_element.push_delay_fixed,
1702 NULL, "push delay", NULL
1705 ED_COUNTER_ID_PUSH_DELAY_RND,
1706 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1708 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1709 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1710 &custom_element.push_delay_random,
1711 NULL, "+random", NULL
1714 ED_COUNTER_ID_DROP_DELAY_FIX,
1715 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1717 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1718 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1719 &custom_element.drop_delay_fixed,
1720 NULL, "drop delay", NULL
1723 ED_COUNTER_ID_DROP_DELAY_RND,
1724 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1726 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1727 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1728 &custom_element.drop_delay_random,
1729 NULL, "+random", NULL
1732 // ---------- element settings: configure 2 (custom elements) ---------------
1735 ED_COUNTER_ID_MOVE_DELAY_FIX,
1736 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1738 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1739 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1740 &custom_element.move_delay_fixed,
1741 NULL, "move delay", NULL
1744 ED_COUNTER_ID_MOVE_DELAY_RND,
1745 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1747 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1748 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1749 &custom_element.move_delay_random,
1750 NULL, "+random", NULL
1753 ED_COUNTER_ID_STEP_DELAY_FIX,
1754 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1756 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1757 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1758 &custom_element.step_delay_fixed,
1759 NULL, "step delay", NULL
1762 ED_COUNTER_ID_STEP_DELAY_RND,
1763 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1765 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1766 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1767 &custom_element.step_delay_random,
1768 NULL, "+random", NULL
1771 ED_COUNTER_ID_EXPLOSION_DELAY,
1772 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1774 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1775 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1776 &custom_element.explosion_delay,
1777 NULL, "explosion delay", NULL
1780 ED_COUNTER_ID_IGNITION_DELAY,
1781 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1783 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1784 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1785 &custom_element.ignition_delay,
1786 NULL, "ignition delay", "(by fire)"
1789 // ---------- element settings: configure (group elements) ------------------
1792 ED_COUNTER_ID_GROUP_CONTENT,
1793 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1794 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1795 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1796 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1797 &group_element_info.num_elements,
1798 NULL, NULL, "number of elements in group"
1801 // ---------- element settings: advanced (custom elements) ------------------
1804 ED_COUNTER_ID_CHANGE_DELAY_FIX,
1805 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1807 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1808 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1809 &custom_element_change.delay_fixed,
1810 NULL, "CE delay", NULL,
1813 ED_COUNTER_ID_CHANGE_DELAY_RND,
1814 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1816 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1817 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1818 &custom_element_change.delay_random,
1819 NULL, "+random", NULL
1822 ED_COUNTER_ID_CHANGE_CONT_RND,
1823 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1825 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1826 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1827 &custom_element_change.random_percentage,
1828 NULL, "use random replace:", "%"
1839 char *text_above, *infotext;
1840 } textinput_info[ED_NUM_TEXTINPUT] =
1843 ED_TEXTINPUT_ID_LEVEL_NAME,
1844 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1845 GADGET_ID_LEVEL_NAME,
1848 "Title:", "Title for this level"
1851 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
1852 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1853 GADGET_ID_LEVEL_AUTHOR,
1854 MAX_LEVEL_AUTHOR_LEN,
1856 "Author:", "Author for this level"
1859 ED_TEXTINPUT_ID_LEVELSET_NAME,
1860 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1861 GADGET_ID_LEVELSET_NAME,
1864 "Title:", "Title for this or new level set"
1867 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
1868 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1869 GADGET_ID_LEVELSET_AUTHOR,
1870 MAX_LEVEL_AUTHOR_LEN,
1872 "Author:", "Author for this or new level set"
1875 ED_TEXTINPUT_ID_ELEMENT_NAME,
1876 -1, -1, // these values are not constant, but can change at runtime
1877 GADGET_ID_ELEMENT_NAME,
1878 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1879 custom_element.description,
1880 NULL, "Element name"
1891 char *text_above, *text_above_cropped, *infotext;
1892 } textarea_info[ED_NUM_TEXTAREAS] =
1895 ED_TEXTAREA_ID_ENVELOPE_INFO,
1896 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1897 GADGET_ID_ENVELOPE_INFO,
1898 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1900 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1904 static struct ValueTextInfo options_time_or_steps[] =
1912 static struct ValueTextInfo options_time_score_base[] =
1914 { 1, "per second/step" },
1915 { 10, "per 10 seconds/steps" },
1920 static struct ValueTextInfo options_game_engine_type[] =
1922 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1923 { GAME_ENGINE_TYPE_BD, "Boulder Dash" },
1924 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1925 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1926 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1931 static struct ValueTextInfo options_levelset_save_mode[] =
1933 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1934 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1939 static struct ValueTextInfo options_wind_direction[] =
1941 { MV_START_NONE, "none" },
1942 { MV_START_LEFT, "left" },
1943 { MV_START_RIGHT, "right" },
1944 { MV_START_UP, "up" },
1945 { MV_START_DOWN, "down" },
1950 static struct ValueTextInfo options_player_speed[] =
1957 { 16, "very fast" },
1958 { 32, "ultrafast" },
1963 static struct ValueTextInfo options_access_type[] =
1965 { EP_WALKABLE, "walkable" },
1966 { EP_PASSABLE, "passable" },
1971 static struct ValueTextInfo options_access_layer[] =
1973 { EP_ACCESSIBLE_OVER, "over" },
1974 { EP_ACCESSIBLE_INSIDE, "inside" },
1975 { EP_ACCESSIBLE_UNDER, "under" },
1980 static struct ValueTextInfo options_access_protected[] =
1982 { 0, "unprotected" },
1988 static struct ValueTextInfo options_access_direction[] =
1990 { MV_NO_DIRECTION, "no direction" },
1991 { MV_LEFT, "left" },
1992 { MV_RIGHT, "right" },
1994 { MV_DOWN, "down" },
1995 { MV_LEFT | MV_UP, "left + up" },
1996 { MV_LEFT | MV_DOWN, "left + down" },
1997 { MV_RIGHT | MV_UP, "right + up" },
1998 { MV_RIGHT | MV_DOWN, "right + down" },
1999 { MV_HORIZONTAL, "horizontal" },
2000 { MV_VERTICAL, "vertical" },
2001 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
2002 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
2003 { MV_VERTICAL | MV_LEFT, "vertical + left" },
2004 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
2005 { MV_ALL_DIRECTIONS, "all directions" },
2010 static struct ValueTextInfo options_walk_to_action[] =
2012 { EP_DIGGABLE, "diggable" },
2013 { EP_COLLECTIBLE_ONLY, "collectible" },
2014 { EP_DROPPABLE, "collectible & droppable" },
2015 { EP_THROWABLE, "collectible & throwable" },
2016 { EP_PUSHABLE, "pushable" },
2021 static struct ValueTextInfo options_move_pattern[] =
2023 { MV_LEFT, "left" },
2024 { MV_RIGHT, "right" },
2026 { MV_DOWN, "down" },
2027 { MV_HORIZONTAL, "horizontal" },
2028 { MV_VERTICAL, "vertical" },
2029 { MV_ALL_DIRECTIONS, "all directions" },
2030 { MV_WIND_DIRECTION, "wind direction" },
2031 { MV_TOWARDS_PLAYER, "towards player" },
2032 { MV_AWAY_FROM_PLAYER, "away from player" },
2033 { MV_ALONG_LEFT_SIDE, "along left side" },
2034 { MV_ALONG_RIGHT_SIDE, "along right side" },
2035 { MV_TURNING_LEFT, "turning left" },
2036 { MV_TURNING_RIGHT, "turning right" },
2037 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
2038 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
2039 { MV_TURNING_RANDOM, "turning random" },
2040 { MV_MAZE_RUNNER, "maze runner style" },
2041 { MV_MAZE_HUNTER, "maze hunter style" },
2042 { MV_WHEN_PUSHED, "when pushed" },
2043 { MV_WHEN_DROPPED, "when dropped/thrown" },
2048 static struct ValueTextInfo options_move_direction[] =
2050 { MV_START_AUTOMATIC, "automatic" },
2051 { MV_START_LEFT, "left" },
2052 { MV_START_RIGHT, "right" },
2053 { MV_START_UP, "up" },
2054 { MV_START_DOWN, "down" },
2055 { MV_START_RANDOM, "random" },
2056 { MV_START_PREVIOUS, "previous" },
2061 static struct ValueTextInfo options_move_stepsize[] =
2063 { 0, "not moving" },
2068 { 16, "very fast" },
2069 { 32, "even faster" },
2074 static struct ValueTextInfo options_move_leave_type[] =
2076 { LEAVE_TYPE_UNLIMITED, "leave behind" },
2077 { LEAVE_TYPE_LIMITED, "change it to" },
2082 static struct ValueTextInfo options_smash_targets[] =
2084 { EP_CAN_SMASH_PLAYER, "player" },
2086 { EP_CAN_SMASH_ENEMIES, "enemies" },
2088 { EP_CAN_SMASH_EVERYTHING, "everything" },
2093 static struct ValueTextInfo options_slippery_type[] =
2095 { SLIPPERY_ANY_RANDOM, "random" },
2096 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
2097 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
2098 { SLIPPERY_ONLY_LEFT, "only left" },
2099 { SLIPPERY_ONLY_RIGHT, "only right" },
2104 static struct ValueTextInfo options_deadliness[] =
2106 { EP_DONT_RUN_INTO, "running into" },
2107 { EP_DONT_COLLIDE_WITH, "colliding with" },
2108 { EP_DONT_GET_HIT_BY, "getting hit by" },
2109 { EP_DONT_TOUCH, "touching" },
2114 static struct ValueTextInfo options_explosion_type[] =
2116 { EXPLODES_3X3, "3x3" },
2117 { EXPLODES_CROSS, "3+3" },
2118 { EXPLODES_1X1, "1x1" },
2123 static struct ValueTextInfo options_time_units[] =
2126 { FRAMES_PER_SECOND, "seconds" },
2131 static struct ValueTextInfo options_change_direct_action[] =
2133 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2134 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2135 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2136 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2137 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2138 { CE_ENTERED_BY_PLAYER, "entered by player" },
2139 { CE_LEFT_BY_PLAYER, "left by player" },
2140 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2141 { CE_SWITCHED, "switched" },
2142 { CE_HITTING_SOMETHING, "hitting something" },
2143 { CE_HIT_BY_SOMETHING, "hit by something" },
2145 { CE_BLOCKED, "blocked" },
2147 { CE_IMPACT, "impact (on something)" },
2148 { CE_SMASHED, "smashed (from above)" },
2150 { CE_VALUE_CHANGES, "CE value changes" },
2151 { CE_SCORE_CHANGES, "CE score changes" },
2153 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2154 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2155 { CE_UNDEFINED, " " },
2156 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2157 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2158 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2159 { CE_UNDEFINED, " " },
2160 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2161 { CE_NEXT_TO_PLAYER, "next to player" },
2166 static struct ValueTextInfo options_change_other_action[] =
2168 { CE_PLAYER_TOUCHES_X, "player touches" },
2169 { CE_PLAYER_PRESSES_X, "player presses" },
2170 { CE_PLAYER_SWITCHES_X, "player switches" },
2171 { CE_PLAYER_SNAPS_X, "player snaps" },
2172 { CE_PLAYER_PUSHES_X, "player pushes" },
2173 { CE_PLAYER_ENTERS_X, "player enters" },
2174 { CE_PLAYER_LEAVES_X, "player leaves" },
2175 { CE_PLAYER_DIGS_X, "player digs" },
2176 { CE_PLAYER_COLLECTS_X, "player collects" },
2177 { CE_PLAYER_DROPS_X, "player drops/throws" },
2178 { CE_TOUCHING_X, "touching" },
2179 { CE_HITTING_X, "hitting" },
2180 { CE_DIGGING_X, "digging" },
2181 { CE_HIT_BY_X, "hit by" },
2182 { CE_SWITCH_OF_X, "switch of" },
2183 { CE_CHANGE_OF_X, "change by page of" },
2184 { CE_EXPLOSION_OF_X, "explosion of" },
2185 { CE_MOVE_OF_X, "move of" },
2186 { CE_CREATION_OF_X, "creation of" },
2187 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2188 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2189 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2190 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2191 { CE_UNDEFINED, " " },
2192 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2193 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2194 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2195 { CE_UNDEFINED, " " },
2196 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2197 { CE_PLAYER_NEXT_TO_X, "player next to" },
2198 { CE_NEXT_TO_X, "next to" },
2203 static struct ValueTextInfo options_change_trigger_side[] =
2205 { CH_SIDE_LEFT, "left" },
2206 { CH_SIDE_RIGHT, "right" },
2207 { CH_SIDE_TOP, "top" },
2208 { CH_SIDE_BOTTOM, "bottom" },
2209 { CH_SIDE_LEFT_RIGHT, "left/right" },
2210 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2211 { CH_SIDE_ANY, "any" },
2216 static struct ValueTextInfo options_change_trigger_player[] =
2218 { CH_PLAYER_1, "1" },
2219 { CH_PLAYER_2, "2" },
2220 { CH_PLAYER_3, "3" },
2221 { CH_PLAYER_4, "4" },
2222 { CH_PLAYER_ANY, "any" },
2227 static struct ValueTextInfo options_change_trigger_page[] =
2238 { (1u << 9), "10" },
2239 { (1u << 10), "11" },
2240 { (1u << 11), "12" },
2241 { (1u << 12), "13" },
2242 { (1u << 13), "14" },
2243 { (1u << 14), "15" },
2244 { (1u << 15), "16" },
2245 { (1u << 16), "17" },
2246 { (1u << 17), "18" },
2247 { (1u << 18), "19" },
2248 { (1u << 19), "20" },
2249 { (1u << 20), "21" },
2250 { (1u << 21), "22" },
2251 { (1u << 22), "23" },
2252 { (1u << 23), "24" },
2253 { (1u << 24), "25" },
2254 { (1u << 25), "26" },
2255 { (1u << 26), "27" },
2256 { (1u << 27), "28" },
2257 { (1u << 28), "29" },
2258 { (1u << 29), "30" },
2259 { (1u << 30), "31" },
2260 { (1u << 31), "32" },
2261 { CH_PAGE_ANY, "any" },
2266 static struct ValueTextInfo options_change_replace_when[] =
2268 { CP_WHEN_EMPTY, "empty" },
2269 { CP_WHEN_WALKABLE, "walkable" },
2270 { CP_WHEN_DIGGABLE, "diggable" },
2271 { CP_WHEN_COLLECTIBLE, "collectible" },
2272 { CP_WHEN_REMOVABLE, "removable" },
2273 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2278 static struct ValueTextInfo options_action_type[] =
2280 { CA_NO_ACTION, "no action" },
2281 { CA_UNDEFINED, " " },
2282 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2283 { CA_RESTART_LEVEL, "restart level" },
2284 { CA_SHOW_ENVELOPE, "show envelope" },
2285 { CA_SET_LEVEL_TIME, "set time" },
2286 { CA_SET_LEVEL_SCORE, "set score" },
2287 { CA_SET_LEVEL_GEMS, "set gems" },
2288 { CA_SET_LEVEL_WIND, "set wind dir." },
2289 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2290 { CA_UNDEFINED, " " },
2291 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2292 { CA_MOVE_PLAYER, "move player" },
2293 { CA_MOVE_PLAYER_NEW, "move player new" },
2294 { CA_EXIT_PLAYER, "exit player" },
2295 { CA_KILL_PLAYER, "kill player" },
2296 { CA_SET_PLAYER_KEYS, "set keys" },
2297 { CA_SET_PLAYER_SPEED, "set speed" },
2298 { CA_SET_PLAYER_SHIELD, "set shield" },
2299 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2300 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2301 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2302 { CA_UNDEFINED, " " },
2303 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2304 { CA_SET_CE_VALUE, "set CE value" },
2305 { CA_SET_CE_SCORE, "set CE score" },
2306 { CA_SET_CE_ARTWORK, "set CE artwork" },
2307 { CA_UNDEFINED, " " },
2308 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2309 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2314 static struct ValueTextInfo options_action_mode_none[] =
2316 { CA_MODE_UNDEFINED, " " },
2321 static struct ValueTextInfo options_action_mode_assign[] =
2323 { CA_MODE_SET, "=" },
2328 static struct ValueTextInfo options_action_mode_add_remove[] =
2330 { CA_MODE_ADD, "+" },
2331 { CA_MODE_SUBTRACT, "-" },
2336 static struct ValueTextInfo options_action_mode_calculate[] =
2338 { CA_MODE_SET, "=" },
2339 { CA_MODE_ADD, "+" },
2340 { CA_MODE_SUBTRACT, "-" },
2341 { CA_MODE_MULTIPLY, "*" },
2342 { CA_MODE_DIVIDE, "/" },
2343 { CA_MODE_MODULO, "%" },
2348 static struct ValueTextInfo options_action_arg_none[] =
2350 { CA_ARG_UNDEFINED, " " },
2355 static struct ValueTextInfo options_action_arg_player[] =
2357 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2358 { CA_ARG_PLAYER_1, "1" },
2359 { CA_ARG_PLAYER_2, "2" },
2360 { CA_ARG_PLAYER_3, "3" },
2361 { CA_ARG_PLAYER_4, "4" },
2362 { CA_ARG_PLAYER_ANY, "any" },
2363 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2364 { CA_ARG_PLAYER_ACTION, "action ->" },
2369 static struct ValueTextInfo options_action_arg_number[] =
2371 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2378 { CA_ARG_10, "10" },
2379 { CA_ARG_100, "100" },
2380 { CA_ARG_1000, "1000" },
2381 { CA_ARG_UNDEFINED, " " },
2382 { CA_ARG_NUMBER_MIN, "min" },
2383 { CA_ARG_NUMBER_MAX, "max" },
2384 { CA_ARG_UNDEFINED, " " },
2385 { CA_ARG_NUMBER_RESET, "reset" },
2386 { CA_ARG_UNDEFINED, " " },
2387 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2388 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2389 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2390 { CA_ARG_UNDEFINED, " " },
2391 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2392 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2393 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2394 { CA_ARG_UNDEFINED, " " },
2395 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2396 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2397 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2398 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2399 { CA_ARG_UNDEFINED, " " },
2400 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2401 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2402 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2403 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2408 static struct ValueTextInfo options_action_arg_value[] =
2410 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2417 { CA_ARG_10, "10" },
2418 { CA_ARG_100, "100" },
2419 { CA_ARG_1000, "1000" },
2420 { CA_ARG_UNDEFINED, " " },
2421 { CA_ARG_NUMBER_MIN, "min" },
2422 { CA_ARG_NUMBER_MAX, "max" },
2423 { CA_ARG_UNDEFINED, " " },
2424 { CA_ARG_NUMBER_RESET, "reset" },
2425 { CA_ARG_UNDEFINED, " " },
2426 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2427 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2428 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2429 { CA_ARG_UNDEFINED, " " },
2430 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2431 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2432 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2433 { CA_ARG_UNDEFINED, " " },
2434 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2435 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2436 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2437 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2438 { CA_ARG_UNDEFINED, " " },
2439 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2440 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2441 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2442 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2443 { CA_ARG_UNDEFINED, " " },
2444 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2445 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2446 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2447 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2452 static struct ValueTextInfo options_action_arg_envelope[] =
2454 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2459 { CA_ARG_UNDEFINED, " " },
2460 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2461 { CA_ARG_ELEMENT_TARGET, "target" },
2462 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2463 { CA_ARG_ELEMENT_ACTION, "action ->" },
2468 static struct ValueTextInfo options_action_arg_key[] =
2470 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2479 { CA_ARG_UNDEFINED, " " },
2480 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2481 { CA_ARG_ELEMENT_TARGET, "target" },
2482 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2483 { CA_ARG_ELEMENT_ACTION, "action ->" },
2488 static struct ValueTextInfo options_action_arg_speed[] =
2490 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2491 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2492 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2493 { CA_ARG_SPEED_SLOW, "slow" },
2494 { CA_ARG_SPEED_NORMAL, "normal" },
2495 { CA_ARG_SPEED_FAST, "fast" },
2496 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2497 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2498 { CA_ARG_UNDEFINED, " " },
2499 { CA_ARG_SPEED_SLOWER, "slower" },
2500 { CA_ARG_SPEED_FASTER, "faster" },
2501 { CA_ARG_UNDEFINED, " " },
2502 { CA_ARG_SPEED_RESET, "reset" },
2507 static struct ValueTextInfo options_action_arg_shield[] =
2509 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2510 { CA_ARG_SHIELD_OFF, "off" },
2511 { CA_ARG_SHIELD_NORMAL, "normal" },
2512 { CA_ARG_SHIELD_DEADLY, "deadly" },
2517 static struct ValueTextInfo options_action_arg_artwork[] =
2519 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2520 { CA_ARG_ELEMENT_TARGET, "target" },
2521 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2522 { CA_ARG_ELEMENT_ACTION, "action ->" },
2523 { CA_ARG_UNDEFINED, " " },
2524 { CA_ARG_ELEMENT_RESET, "reset" },
2529 static struct ValueTextInfo options_action_arg_gravity[] =
2531 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2532 { CA_ARG_GRAVITY_ON, "on" },
2533 { CA_ARG_GRAVITY_OFF, "off" },
2534 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2539 static struct ValueTextInfo options_action_arg_direction[] =
2541 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2542 { CA_ARG_DIRECTION_NONE, "none" },
2543 { CA_ARG_DIRECTION_LEFT, "left" },
2544 { CA_ARG_DIRECTION_RIGHT, "right" },
2545 { CA_ARG_DIRECTION_UP, "up" },
2546 { CA_ARG_DIRECTION_DOWN, "down" },
2547 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2548 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2553 static struct ValueTextInfo options_action_arg_scan_mode[] =
2555 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2556 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2557 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2562 static struct ValueTextInfo options_action_arg_inventory[] =
2564 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2565 { CA_ARG_ELEMENT_TARGET, "+ target" },
2566 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2567 { CA_ARG_ELEMENT_ACTION, "+ action" },
2568 { CA_ARG_UNDEFINED, " " },
2569 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2570 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2571 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2572 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2573 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2574 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2575 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2576 { CA_ARG_UNDEFINED, " " },
2577 { CA_ARG_INVENTORY_RESET, "reset" },
2582 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2583 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2588 static struct ValueTextInfo options_group_choice_mode[] =
2590 { ANIM_RANDOM, "random" },
2591 { ANIM_LOOP, "loop" },
2592 { ANIM_LINEAR, "linear" },
2593 { ANIM_PINGPONG, "pingpong" },
2594 { ANIM_PINGPONG2, "pingpong 2" },
2595 { ANIM_LEVEL_NR, "level number" },
2600 static struct ValueTextInfo options_bd_scheduling_type[] =
2602 { GD_SCHEDULING_MILLISECONDS, "Milliseconds" },
2603 { GD_SCHEDULING_BD1, "BD1" },
2604 { GD_SCHEDULING_BD2, "BD2" },
2605 { GD_SCHEDULING_PLCK, "Construction Kit" },
2606 { GD_SCHEDULING_CRDR, "Crazy Dream 7" },
2607 { GD_SCHEDULING_BD1_ATARI, "Atari BD1" },
2608 { GD_SCHEDULING_BD2_PLCK_ATARI, "Atari BD2 / PLCK" },
2613 static struct ValueTextInfo *action_arg_modes[] =
2615 options_action_mode_none,
2616 options_action_mode_assign,
2617 options_action_mode_add_remove,
2618 options_action_mode_calculate,
2625 struct ValueTextInfo *options;
2627 action_arg_options[] =
2629 { CA_NO_ACTION, 0, options_action_arg_none, },
2630 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2631 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2632 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2633 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2634 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2635 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2636 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2637 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2638 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2639 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2640 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2641 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2642 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2643 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2644 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2645 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2646 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2647 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2648 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2649 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2650 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2660 int gadget_id_align;
2661 int size; // char size of selectbox or '-1' (dynamically determined)
2662 struct ValueTextInfo *options;
2664 char *text_above, *text_left, *text_right, *infotext;
2665 } selectbox_info[ED_NUM_SELECTBOX] =
2667 // ---------- level and editor settings -------------------------------------
2670 ED_SELECTBOX_ID_TIME_OR_STEPS,
2671 -1, ED_LEVEL_SETTINGS_YPOS(8),
2672 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2674 options_time_or_steps,
2675 &level.use_step_counter,
2676 NULL, NULL, "(0 => no limit)", "time or step limit"
2679 ED_SELECTBOX_ID_TIME_SCORE_BASE,
2680 -1, ED_LEVEL_SETTINGS_YPOS(10),
2681 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2683 options_time_score_base,
2684 &level.time_score_base,
2685 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2688 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
2689 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2690 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2692 options_game_engine_type,
2693 &level.game_engine_type,
2694 NULL, "game engine:", NULL, "game engine"
2697 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
2698 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2699 GADGET_ID_BD_SCHEDULING_TYPE, GADGET_ID_NONE,
2701 options_bd_scheduling_type,
2702 &level.bd_scheduling_type,
2703 NULL, "scheduling type:", NULL, "level timing"
2706 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
2707 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2708 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2710 options_levelset_save_mode,
2711 &levelset_save_mode,
2712 "Action:", NULL, NULL, "action when saving level set"
2715 // ---------- element settings: configure (several elements) ----------------
2718 ED_SELECTBOX_ID_WIND_DIRECTION,
2719 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2720 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2722 options_wind_direction,
2723 &level.wind_direction_initial,
2724 NULL, "initial wind direction:", NULL, "initial wind direction"
2727 ED_SELECTBOX_ID_PLAYER_SPEED,
2728 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2729 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2731 options_player_speed,
2732 &level.initial_player_stepsize[0],
2733 NULL, "initial player speed:", NULL, "initial player speed"
2736 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
2737 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2738 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2740 options_group_choice_mode,
2741 &level.mm_ball_choice_mode,
2742 NULL, "choice type:", NULL, "type of content choice"
2745 // ---------- element settings: configure 1 (custom elements) ---------------
2748 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
2749 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2750 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2752 options_access_type,
2753 &custom_element.access_type,
2754 NULL, NULL, NULL, "type of access to this field"
2757 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
2758 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2759 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2761 options_access_layer,
2762 &custom_element.access_layer,
2763 NULL, NULL, NULL, "layer of access for this field"
2766 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
2767 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2768 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2770 options_access_protected,
2771 &custom_element.access_protected,
2772 NULL, NULL, NULL, "protected access for this field"
2775 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
2776 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2777 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2779 options_access_direction,
2780 &custom_element.access_direction,
2781 NULL, "from", NULL, "access direction for this field"
2784 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
2785 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2786 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2788 options_walk_to_action,
2789 &custom_element.walk_to_action,
2790 NULL, NULL, NULL, "diggable/collectible/pushable"
2793 // ---------- element settings: configure 2 (custom elements) ---------------
2796 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
2797 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2798 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2800 options_move_pattern,
2801 &custom_element.move_pattern,
2802 NULL, "can move", NULL, "element move pattern"
2805 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
2806 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2807 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2809 options_move_direction,
2810 &custom_element.move_direction_initial,
2811 NULL, "starts moving", NULL, "initial element move direction"
2814 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
2815 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2816 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2818 options_move_stepsize,
2819 &custom_element.move_stepsize,
2820 NULL, "move/fall speed", NULL, "speed of element movement"
2823 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
2824 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2825 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2827 options_move_leave_type,
2828 &custom_element.move_leave_type,
2829 // left text with leading spaces to place gadget next to "can dig" gadget
2830 // (needed because drawing area gadgets created after selectbox gadgets)
2831 // NULL, "can dig: can", ":", "leave behind or change element"
2832 NULL, " can", ":", "leave behind or change element"
2835 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
2836 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2837 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2839 options_smash_targets,
2840 &custom_element.smash_targets,
2841 NULL, "can smash", NULL, "elements that can be smashed"
2844 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
2845 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2846 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2848 options_slippery_type,
2849 &custom_element.slippery_type,
2850 NULL, "slippery", NULL, "where other elements fall down"
2853 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
2854 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2855 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2858 &custom_element.deadliness,
2859 NULL, "deadly when", NULL, "deadliness of element"
2862 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
2863 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2864 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2866 options_explosion_type,
2867 &custom_element.explosion_type,
2868 NULL, "can explode", NULL, "explosion type"
2871 // ---------- element settings: advanced (custom elements) ------------------
2874 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
2875 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2876 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2879 &custom_element_change.delay_frames,
2880 NULL, "delay time given in", NULL, "delay time units for change"
2883 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
2884 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2885 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2887 options_change_direct_action,
2888 &custom_element_change.direct_action,
2889 NULL, NULL, NULL, "type of direct action"
2892 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
2893 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2894 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2896 options_change_other_action,
2897 &custom_element_change.other_action,
2898 NULL, NULL, "element:", "type of other element action"
2901 ED_SELECTBOX_ID_CHANGE_SIDE,
2902 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2903 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2905 options_change_trigger_side,
2906 &custom_element_change.trigger_side,
2907 NULL, "at", "side", "element side triggering change"
2910 ED_SELECTBOX_ID_CHANGE_PLAYER,
2911 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2912 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2914 options_change_trigger_player,
2915 &custom_element_change.trigger_player,
2916 NULL, "player:", " ", "player that causes change"
2919 ED_SELECTBOX_ID_CHANGE_PAGE,
2920 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2921 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2923 options_change_trigger_page,
2924 &custom_element_change.trigger_page,
2925 NULL, "page:", NULL, "change page that causes change"
2928 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
2929 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2930 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2932 options_change_replace_when,
2933 &custom_element_change.replace_when,
2934 NULL, "replace when", NULL, "which elements can be replaced"
2937 ED_SELECTBOX_ID_ACTION_TYPE,
2938 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2939 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2941 options_action_type,
2942 &custom_element_change.action_type,
2943 NULL, NULL, NULL, "action on specified condition"
2946 ED_SELECTBOX_ID_ACTION_MODE,
2947 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2948 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2950 options_action_mode_none,
2951 &custom_element_change.action_mode,
2952 NULL, NULL, NULL, "action operator"
2955 ED_SELECTBOX_ID_ACTION_ARG,
2956 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2957 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2959 options_action_arg_none,
2960 &custom_element_change.action_arg,
2961 NULL, NULL, NULL, "action parameter"
2964 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
2965 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2966 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2968 options_change_page,
2969 &custom_element.current_change_page,
2970 NULL, NULL, NULL, "element change page"
2973 // ---------- element settings: configure (group elements) ------------------
2976 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
2977 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2978 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2980 options_group_choice_mode,
2981 &group_element_info.choice_mode,
2982 NULL, "choice type:", NULL, "type of group element choice"
2991 int gadget_id_align;
2994 char *text_above, *text_left, *text_right, *infotext;
2995 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2997 // ---------- level and editor settings (tabs) ------------------------------
3000 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
3001 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
3002 GADGET_ID_LEVELCONFIG_LEVEL, GADGET_ID_NONE,
3004 NULL, NULL, NULL, "Configure level settings"
3007 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
3009 GADGET_ID_LEVELCONFIG_LEVELSET, GADGET_ID_LEVELCONFIG_LEVEL,
3011 NULL, NULL, NULL, "Update this or create new level set"
3014 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
3016 GADGET_ID_LEVELCONFIG_EDITOR, GADGET_ID_LEVELCONFIG_LEVELSET,
3018 NULL, NULL, NULL, "Configure editor settings"
3021 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
3023 GADGET_ID_LEVELCONFIG_ENGINE, GADGET_ID_LEVELCONFIG_EDITOR,
3025 NULL, NULL, NULL, "Configure engine settings"
3028 // ---------- element settings (tabs) ---------------------------------------
3031 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
3032 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
3033 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
3035 NULL, NULL, NULL, "Show information about element"
3038 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
3040 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
3042 NULL, NULL, NULL, "Configure element properties"
3045 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
3047 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
3049 NULL, NULL, NULL, "Configure element properties, part 1"
3052 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
3054 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
3056 NULL, NULL, NULL, "Configure element properties, part 2"
3059 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
3061 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
3063 NULL, NULL, NULL, "Configure custom element change pages"
3066 // ---------- level and editor settings (buttons) ---------------------------
3069 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
3070 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
3071 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
3073 NULL, NULL, NULL, "Update or create level set"
3076 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
3077 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3078 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
3080 NULL, NULL, "this level as level template",
3081 "Save current settings as new template"
3084 // ---------- element settings (buttons) ------------------------------------
3087 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
3089 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
3091 NULL, " ", "As Template",
3092 "Save current settings as new template"
3095 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
3097 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
3099 NULL, NULL, NULL, "Add new change page"
3102 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
3104 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
3106 NULL, NULL, NULL, "Delete current change page"
3116 int gadget_id_align;
3117 char *text_left, *text_right, *infotext;
3118 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
3121 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
3122 IMG_EDITOR_COUNTER_DOWN,
3123 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3124 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
3125 NULL, NULL, "select previous change page"
3128 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
3129 IMG_EDITOR_COUNTER_UP,
3130 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3131 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
3132 NULL, "change page", "select next change page"
3135 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
3136 IMG_GFX_EDITOR_BUTTON_CP_COPY,
3137 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3138 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
3139 " ", NULL, "copy settings from this change page"
3142 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
3143 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
3144 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3145 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
3146 NULL, NULL, "paste settings to this change page"
3153 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
3161 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
3164 ED_SCROLLBUTTON_ID_AREA_UP,
3165 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
3166 GADGET_ID_SCROLL_UP,
3167 "scroll level editing area up"
3170 ED_SCROLLBUTTON_ID_AREA_DOWN,
3171 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
3172 GADGET_ID_SCROLL_DOWN,
3173 "scroll level editing area down"
3176 ED_SCROLLBUTTON_ID_AREA_LEFT,
3177 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
3178 GADGET_ID_SCROLL_LEFT,
3179 "scroll level editing area left"
3182 ED_SCROLLBUTTON_ID_AREA_RIGHT,
3183 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
3184 GADGET_ID_SCROLL_RIGHT,
3185 "scroll level editing area right"
3188 ED_SCROLLBUTTON_ID_LIST_UP,
3189 IMG_EDITOR_PALETTE_SCROLL_UP,
3190 GADGET_ID_SCROLL_LIST_UP,
3191 "scroll element list up ('Page Up')"
3194 ED_SCROLLBUTTON_ID_LIST_DOWN,
3195 IMG_EDITOR_PALETTE_SCROLL_DOWN,
3196 GADGET_ID_SCROLL_LIST_DOWN,
3197 "scroll element list down ('Page Down')"
3205 int wheel_x, wheel_y;
3206 int wheel_width, wheel_height;
3207 } scrollbar_pos[ED_NUM_SCROLLBARS];
3216 } scrollbar_info[ED_NUM_SCROLLBARS] =
3219 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
3220 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3221 GD_TYPE_SCROLLBAR_HORIZONTAL,
3222 GADGET_ID_SCROLL_HORIZONTAL,
3223 "scroll level editing area horizontally"
3226 ED_SCROLLBAR_ID_AREA_VERTICAL,
3227 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3228 GD_TYPE_SCROLLBAR_VERTICAL,
3229 GADGET_ID_SCROLL_VERTICAL,
3230 "scroll level editing area vertically"
3233 ED_SCROLLBAR_ID_LIST_VERTICAL,
3234 IMG_EDITOR_PALETTE_SCROLLBAR,
3235 GD_TYPE_SCROLLBAR_VERTICAL,
3236 GADGET_ID_SCROLL_LIST_VERTICAL,
3237 "scroll element list vertically"
3247 int gadget_id_align;
3248 int radio_button_nr;
3251 char *text_left, *text_right, *infotext;
3252 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3255 ED_RADIOBUTTON_ID_PERCENTAGE,
3256 -1, ED_LEVEL_SETTINGS_YPOS(0),
3257 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3258 RADIO_NR_RANDOM_ELEMENTS,
3259 &random_placement_method, RANDOM_USE_PERCENTAGE,
3260 " ", "percentage", "use percentage for random elements"
3263 ED_RADIOBUTTON_ID_QUANTITY,
3264 -1, ED_LEVEL_SETTINGS_YPOS(0),
3265 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3266 RADIO_NR_RANDOM_ELEMENTS,
3267 &random_placement_method, RANDOM_USE_QUANTITY,
3268 " ", "quantity", "use quantity for random elements"
3277 int gadget_id_align;
3279 char *text_above, *text_left, *text_right, *infotext;
3280 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3282 // ---------- level and editor settings -------------------------------------
3285 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
3286 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3287 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3288 &level.auto_count_gems,
3290 "automatically count gems needed", "set counter to number of gems"
3293 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
3294 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3295 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3296 &level.rate_time_over_score,
3298 "rate time/steps used over score", "sort high scores by playing time/steps"
3301 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
3302 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3303 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3304 &levelset_use_levelset_artwork,
3306 "use current custom artwork", "use custom artwork of this level set"
3309 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
3310 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3311 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3312 &levelset_copy_level_template,
3314 "copy current level template", "copy level template of this level set"
3317 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
3318 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3319 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3320 &random_placement_background_restricted,
3322 "restrict random placement to:", "set random placement restriction"
3325 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
3326 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3327 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3328 &setup.editor.use_template_for_new_levels,
3329 "Template for new levels and CE/GE:", NULL,
3330 "use template for new levels", "use template for level properties"
3333 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
3334 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3335 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3336 &level.use_custom_template,
3338 "use template for custom elements", "use template for custom properties"
3341 ED_CHECKBUTTON_ID_BD_INTERMISSION,
3342 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
3343 GADGET_ID_BD_INTERMISSION, GADGET_ID_NONE,
3344 &level.bd_intermission,
3345 "Boulder Dash game engine settings:", NULL,
3346 "intermission", "level is an intermission level"
3349 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
3350 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
3351 GADGET_ID_BD_PAL_TIMING, GADGET_ID_NONE,
3352 &level.bd_pal_timing,
3354 "PAL timing", "use slower timer (like PAL C64)"
3357 ED_CHECKBUTTON_ID_BD_LINE_SHIFTING_BORDERS,
3358 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3359 GADGET_ID_BD_LINE_SHIFTING_BORDERS, GADGET_ID_NONE,
3360 &level.bd_line_shifting_borders,
3361 "Compatibility settings:", NULL,
3362 "line-shifting borders", "use line-shifting wrap-around"
3365 ED_CHECKBUTTON_ID_BD_SCAN_FIRST_AND_LAST_ROW,
3366 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3367 GADGET_ID_BD_SCAN_FIRST_AND_LAST_ROW, GADGET_ID_NONE,
3368 &level.bd_scan_first_and_last_row,
3370 "scan first and last row", "also process top/bottom border rows"
3373 ED_CHECKBUTTON_ID_BD_SHORT_EXPLOSIONS,
3374 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3375 GADGET_ID_BD_SHORT_EXPLOSIONS, GADGET_ID_NONE,
3376 &level.bd_short_explosions,
3378 "short explosions", "use four game cycles for explosions"
3381 ED_CHECKBUTTON_ID_BD_GRAVITY_AFFECTS_ALL,
3382 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(9),
3383 GADGET_ID_BD_GRAVITY_AFFECTS_ALL, GADGET_ID_NONE,
3384 &level.bd_gravity_affects_all,
3386 "gravity change affects everything", "gravity affects all falling objects"
3389 // ---------- element settings: configure (various elements) ----------------
3392 ED_CHECKBUTTON_ID_STICK_ELEMENT,
3393 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3394 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3395 &stick_element_properties_window,
3397 "stick this screen to edit content","stick this screen to edit content"
3400 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
3401 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3402 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3403 &level.em_slippery_gems,
3405 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3408 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
3409 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3410 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3411 &level.em_explodes_by_fire,
3413 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3416 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
3417 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3418 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3419 &level.use_spring_bug,
3421 "use spring pushing bug", "use odd spring pushing behaviour"
3424 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
3425 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3426 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3427 &level.use_time_orb_bug,
3429 "use time orb bug", "use odd time orb behaviour"
3432 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
3433 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3434 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3435 &level.use_life_bugs,
3437 "use buggy element behaviour", "use odd (historic) element behaviour"
3440 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
3441 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3442 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3445 "create single random element", "only create one element from content"
3448 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
3449 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3450 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3451 &level.ball_active_initial,
3453 "magic ball initially activated", "activate magic ball after level start"
3456 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
3457 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3458 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3459 &level.grow_into_diggable,
3461 "can grow into anything diggable", "grow into more than just sand"
3464 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
3465 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3466 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3467 &level.sb_fields_needed,
3469 "all fields need to be filled", "require all SB fields to be solved"
3472 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
3473 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3474 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3475 &level.sb_objects_needed,
3477 "all objects need to be placed", "require all SB objects to be solved"
3480 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
3481 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3482 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3483 &level.auto_exit_sokoban,
3485 "exit level if all tasks solved", "automatically finish Sokoban levels"
3488 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
3489 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3490 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3491 &level.solved_by_one_player,
3493 "only one player must enter exit", "level solved by first player in exit"
3496 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
3497 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3498 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3499 &level.finish_dig_collect,
3501 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3504 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
3505 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3506 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3507 &level.keep_walkable_ce,
3509 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3512 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
3513 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3514 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3515 &level.continuous_snapping,
3517 "continuous snapping", "use snapping without releasing key"
3520 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
3521 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3522 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3523 &level.block_snap_field,
3525 "block snapped field when snapping", "use snapping delay to show animation"
3528 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
3529 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3530 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3531 &level.block_last_field,
3533 "block last field when moving", "player blocks last field when moving"
3536 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
3537 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3538 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3539 &level.sp_block_last_field,
3541 "block last field when moving", "player blocks last field when moving"
3544 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
3545 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3546 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3547 &level.instant_relocation,
3549 "no scrolling when relocating", "player gets relocated without delay"
3552 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
3553 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3554 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3555 &level.shifted_relocation,
3557 "no centering when relocating", "level not centered after relocation"
3560 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
3561 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3562 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3563 &level.lazy_relocation,
3565 "only redraw off-screen relocation","no redraw if relocation target visible"
3568 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
3569 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3570 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3571 &level.use_start_element[0],
3573 "use level start element:", "start level at this element's position"
3576 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
3577 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3578 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3579 &level.use_artwork_element[0],
3581 "use artwork from element:", "use player artwork from other element"
3584 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
3585 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3586 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3587 &level.use_explosion_element[0],
3589 "use explosion from element:", "use explosion properties from element"
3592 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
3593 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3594 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3595 &level.initial_player_gravity[0],
3597 "use initial gravity", "set initial player gravity"
3600 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
3601 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3602 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3603 &level.use_initial_inventory[0],
3605 "use initial inventory:", "use collected elements on level start"
3608 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
3609 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3610 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3611 &level.can_pass_to_walkable,
3613 "can pass to walkable element", "player can pass to empty or walkable"
3616 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
3617 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3618 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3619 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3621 "can fall into acid (with gravity)","player can fall into acid pool"
3624 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
3625 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3626 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3627 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3629 "can move into acid", "element can move into acid pool"
3632 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
3633 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3634 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3635 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3637 "deadly when colliding with", "element is deadly when hitting player"
3640 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
3641 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3642 GADGET_ID_BD_DIAGONAL_MOVEMENTS, GADGET_ID_NONE,
3643 &level.bd_diagonal_movements,
3645 "can move diagonally", "player can move diagonally"
3648 ED_CHECKBUTTON_ID_BD_TOPMOST_PLAYER_ACTIVE,
3649 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3650 GADGET_ID_BD_TOPMOST_PLAYER_ACTIVE, GADGET_ID_NONE,
3651 &level.bd_topmost_player_active,
3653 "topmost player is active", "use first player found on playfield"
3656 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
3657 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3658 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3659 &level.envelope[0].autowrap,
3661 "auto-wrap", "automatically wrap envelope text"
3664 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
3665 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3666 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3667 &level.envelope[0].centered,
3669 "centered", "automatically center envelope text"
3672 ED_CHECKBUTTON_ID_MM_LASER_RED,
3673 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3674 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3675 &level.mm_laser_red,
3676 "choose color components for laser:", NULL,
3677 "red", "use red color components in laser"
3680 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
3681 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3682 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3683 &level.mm_laser_green,
3685 "green", "use green color components in laser"
3688 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
3689 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3690 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3691 &level.mm_laser_blue,
3693 "blue", "use blue color components in laser"
3696 ED_CHECKBUTTON_ID_DF_LASER_RED,
3697 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3698 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3699 &level.df_laser_red,
3700 "choose color components for laser:", NULL,
3701 "red", "use red color components in laser"
3704 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
3705 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3706 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3707 &level.df_laser_green,
3709 "green", "use green color components in laser"
3712 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
3713 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3714 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3715 &level.df_laser_blue,
3717 "blue", "use blue color components in laser"
3720 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
3721 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3722 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3723 &level.rotate_mm_ball_content,
3725 "randomly rotate created content", "randomly rotate newly created content"
3728 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
3729 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3730 GADGET_ID_EXPLODE_MM_BALL, GADGET_ID_NONE,
3731 &level.explode_mm_ball,
3733 "explode ball instead of melting", "use explosion to release ball content"
3736 // ---------- element settings: configure 1 (custom elements) ---------------
3739 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
3740 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3741 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3742 &custom_element.use_gfx_element,
3744 "use graphic of element:", "use existing element graphic"
3747 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
3748 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3749 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3750 &level.use_custom_template,
3752 "use template", "use template for custom properties"
3755 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
3756 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3757 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3758 &custom_element_properties[EP_ACCESSIBLE],
3760 NULL, "player can walk to or pass this field"
3763 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
3764 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3765 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3766 &custom_element_properties[EP_GRAVITY_REACHABLE],
3768 "reachable despite gravity", "player can walk/dig despite gravity"
3771 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
3772 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3773 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3774 &custom_element.use_last_ce_value,
3776 "use last CE value after change", "use last CE value after change"
3779 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
3780 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3781 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3782 &custom_element_properties[EP_WALK_TO_OBJECT],
3784 NULL, "player can dig/collect/push element"
3787 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
3788 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3789 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3790 &custom_element_properties[EP_INDESTRUCTIBLE],
3792 "indestructible", "element is indestructible"
3795 // ---------- element settings: configure 2 (custom elements) ---------------
3798 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
3799 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3800 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3801 &custom_element_properties[EP_CAN_MOVE],
3803 NULL, "element can move with some pattern"
3806 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
3807 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3808 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3809 &custom_element_properties[EP_CAN_FALL],
3811 "can fall", "element can fall down"
3814 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
3815 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3816 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3817 &custom_element_properties[EP_CAN_SMASH],
3819 NULL, "element can smash other elements"
3822 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
3823 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3824 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3825 &custom_element_properties[EP_SLIPPERY],
3827 NULL, "other elements can fall down from it"
3830 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
3831 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3832 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3833 &custom_element_properties[EP_DEADLY],
3835 NULL, "element can kill the player"
3838 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
3839 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3840 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3841 &custom_element_properties[EP_CAN_EXPLODE],
3843 NULL, "element can explode"
3846 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
3847 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3848 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3849 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3851 "by fire", "element can explode by fire/explosion"
3854 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
3855 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3856 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3857 &custom_element_properties[EP_EXPLODES_SMASHED],
3859 "smashed", "element can explode when smashed"
3862 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
3863 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3864 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3865 &custom_element_properties[EP_EXPLODES_IMPACT],
3867 "impact", "element can explode on impact"
3870 // ---------- element settings: advanced (custom elements) ------------------
3873 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
3874 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3875 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3876 &custom_element_change.can_change,
3878 "element changes to:", "change element on specified condition"
3881 ED_CHECKBUTTON_ID_CHANGE_DELAY,
3882 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3883 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3884 &custom_element_change_events[CE_DELAY],
3886 NULL, "element changes after delay"
3889 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
3890 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3891 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3892 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3894 NULL, "element changes by direct action"
3897 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
3898 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3899 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3900 &custom_element_change_events[CE_BY_OTHER_ACTION],
3902 NULL, "element changes by other element"
3905 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
3906 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3907 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3908 &custom_element_change.explode,
3910 "explode instead of change", "element explodes instead of change"
3913 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
3914 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3915 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3916 &custom_element_change.use_target_content,
3918 "use extended change target:", "element changes to more elements"
3921 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
3922 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3923 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3924 &custom_element_change.only_if_complete,
3926 "replace all or nothing", "only replace when all can be changed"
3929 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
3930 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3931 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3932 &custom_element_change.use_random_replace,
3934 NULL, "use percentage for random replace"
3937 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
3938 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3939 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3940 &custom_element_change.has_action,
3942 NULL, "execute action on specified condition"
3950 int xoffset, yoffset;
3952 int gadget_id_align;
3954 int area_xsize, area_ysize;
3955 char *text_left, *text_right, *text_above, *text_below, *infotext;
3956 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3958 // ---------- level playfield content ---------------------------------------
3961 ED_DRAWING_ID_DRAWING_LEVEL,
3964 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3966 -1, -1, // these values are not constant, but can change at runtime
3967 NULL, NULL, NULL, NULL, NULL
3970 // ---------- yam yam content -----------------------------------------------
3973 ED_DRAWING_ID_YAMYAM_CONTENT_0,
3974 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3975 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3976 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3977 &level.yamyam_content[0].e[0][0], 3, 3,
3978 NULL, NULL, NULL, "1", NULL
3981 ED_DRAWING_ID_YAMYAM_CONTENT_1,
3982 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3983 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3984 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3985 &level.yamyam_content[1].e[0][0], 3, 3,
3986 NULL, NULL, NULL, "2", NULL
3989 ED_DRAWING_ID_YAMYAM_CONTENT_2,
3990 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3991 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3992 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3993 &level.yamyam_content[2].e[0][0], 3, 3,
3994 NULL, NULL, NULL, "3", NULL
3997 ED_DRAWING_ID_YAMYAM_CONTENT_3,
3998 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3999 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
4000 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
4001 &level.yamyam_content[3].e[0][0], 3, 3,
4002 NULL, NULL, NULL, "4", NULL
4005 ED_DRAWING_ID_YAMYAM_CONTENT_4,
4006 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4007 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
4008 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
4009 &level.yamyam_content[4].e[0][0], 3, 3,
4010 NULL, NULL, NULL, "5", NULL
4013 ED_DRAWING_ID_YAMYAM_CONTENT_5,
4014 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4015 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
4016 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
4017 &level.yamyam_content[5].e[0][0], 3, 3,
4018 NULL, NULL, NULL, "6", NULL
4021 ED_DRAWING_ID_YAMYAM_CONTENT_6,
4022 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4023 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
4024 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
4025 &level.yamyam_content[6].e[0][0], 3, 3,
4026 NULL, NULL, NULL, "7", NULL
4029 ED_DRAWING_ID_YAMYAM_CONTENT_7,
4030 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4031 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
4032 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
4033 &level.yamyam_content[7].e[0][0], 3, 3,
4034 NULL, NULL, NULL, "8", NULL
4037 // ---------- magic ball content --------------------------------------------
4040 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
4041 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4042 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
4043 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
4044 &level.ball_content[0].e[0][0], 3, 3,
4045 NULL, NULL, NULL, "1", NULL
4048 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
4049 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4050 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
4051 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
4052 &level.ball_content[1].e[0][0], 3, 3,
4053 NULL, NULL, NULL, "2", NULL
4056 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
4057 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4058 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
4059 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
4060 &level.ball_content[2].e[0][0], 3, 3,
4061 NULL, NULL, NULL, "3", NULL
4064 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
4065 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4066 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
4067 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
4068 &level.ball_content[3].e[0][0], 3, 3,
4069 NULL, NULL, NULL, "4", NULL
4072 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
4073 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4074 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
4075 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
4076 &level.ball_content[4].e[0][0], 3, 3,
4077 NULL, NULL, NULL, "5", NULL
4080 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
4081 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4082 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
4083 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
4084 &level.ball_content[5].e[0][0], 3, 3,
4085 NULL, NULL, NULL, "6", NULL
4088 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
4089 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4090 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
4091 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
4092 &level.ball_content[6].e[0][0], 3, 3,
4093 NULL, NULL, NULL, "7", NULL
4096 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
4097 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4098 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
4099 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
4100 &level.ball_content[7].e[0][0], 3, 3,
4101 NULL, NULL, NULL, "8", NULL
4104 // ---------- android content -----------------------------------------------
4107 ED_DRAWING_ID_ANDROID_CONTENT,
4108 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
4109 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4110 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
4111 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
4112 NULL, NULL, "elements:", NULL, "elements android can clone"
4115 // ---------- amoeba content ------------------------------------------------
4118 ED_DRAWING_ID_AMOEBA_CONTENT,
4119 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
4120 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4121 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
4122 &level.amoeba_content, 1, 1,
4123 "content:", NULL, NULL, NULL, "amoeba content"
4126 // ---------- level start element -------------------------------------------
4129 ED_DRAWING_ID_START_ELEMENT,
4130 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
4131 0, ED_AREA_1X1_SETTINGS_YOFF,
4132 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
4133 &level.start_element[0], 1, 1,
4134 NULL, NULL, NULL, NULL, "level start element"
4137 // ---------- player artwork element ----------------------------------------
4140 ED_DRAWING_ID_ARTWORK_ELEMENT,
4141 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
4142 0, ED_AREA_1X1_SETTINGS_YOFF,
4143 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
4144 &level.artwork_element[0], 1, 1,
4145 NULL, NULL, NULL, NULL, "element for player artwork"
4148 // ---------- player explosion element --------------------------------------
4151 ED_DRAWING_ID_EXPLOSION_ELEMENT,
4152 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
4153 0, ED_AREA_1X1_SETTINGS_YOFF,
4154 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
4155 &level.explosion_element[0], 1, 1,
4156 NULL, NULL, NULL, NULL, "element for player explosion"
4159 // ---------- player initial inventory --------------------------------------
4162 ED_DRAWING_ID_INVENTORY_CONTENT,
4163 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4164 0, ED_AREA_1X1_SETTINGS_YOFF,
4165 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
4166 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
4167 NULL, NULL, NULL, NULL, "content for initial inventory"
4170 // ---------- gray ball content -----------------------------------------
4173 ED_DRAWING_ID_MM_BALL_CONTENT,
4174 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4175 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4176 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
4177 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
4178 "content:", NULL, NULL, NULL, "content for gray ball"
4181 // ---------- element settings: configure 1 (custom elements) ---------------
4183 // ---------- custom graphic ------------------------------------------------
4186 ED_DRAWING_ID_CUSTOM_GRAPHIC,
4187 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4188 0, ED_AREA_1X1_SETTINGS_YOFF,
4189 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
4190 &custom_element.gfx_element_initial, 1, 1,
4191 NULL, NULL, NULL, NULL, "custom graphic element"
4194 // ---------- element settings: configure 2 (custom elements) ---------------
4196 // ---------- custom content (when exploding) -------------------------------
4199 ED_DRAWING_ID_CUSTOM_CONTENT,
4200 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
4201 0, ED_AREA_3X3_SETTINGS_YOFF,
4202 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
4203 &custom_element.content.e[0][0], 3, 3,
4204 "content:", NULL, NULL, NULL, NULL
4207 // ---------- custom enter and leave element (when moving) ------------------
4210 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
4211 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
4212 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4213 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
4214 &custom_element.move_enter_element, 1, 1,
4215 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
4218 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
4219 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
4220 0, ED_AREA_1X1_SETTINGS_YOFF,
4221 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
4222 &custom_element.move_leave_element, 1, 1,
4223 NULL, NULL, NULL, NULL, "element that will be left behind"
4226 // ---------- element settings: advanced (custom elements) ------------------
4228 // ---------- custom change target ------------------------------------------
4231 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
4232 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4233 0, ED_AREA_1X1_SETTINGS_YOFF,
4234 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
4235 &custom_element_change.target_element, 1, 1,
4236 NULL, "after/when:", NULL, NULL, "new target element after change"
4239 // ---------- custom change content (extended change target) ----------------
4242 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
4243 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
4244 0, ED_AREA_3X3_SETTINGS_YOFF,
4245 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
4246 &custom_element_change.target_content.e[0][0], 3, 3,
4247 NULL, NULL, NULL, NULL, "new extended elements after change"
4250 // ---------- custom change trigger (element causing change) ----------------
4253 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
4254 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
4255 0, ED_AREA_1X1_SETTINGS_YOFF,
4256 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
4257 &custom_element_change.initial_trigger_element, 1, 1,
4258 NULL, NULL, NULL, NULL, "other element triggering change"
4261 // ---------- custom change action (element used for action) ----------------
4264 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
4265 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
4266 0, ED_AREA_1X1_SETTINGS_YOFF,
4267 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
4268 &custom_element_change.action_element, 1, 1,
4269 NULL, NULL, NULL, NULL, "element used as action parameter"
4272 // ---------- group element content -----------------------------------------
4275 ED_DRAWING_ID_GROUP_CONTENT,
4276 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4277 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4278 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
4279 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
4280 "content:", NULL, NULL, NULL, NULL
4283 // ---------- random background (for random painting) -----------------------
4286 ED_DRAWING_ID_RANDOM_BACKGROUND,
4287 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
4288 0, ED_AREA_1X1_LSETTINGS_YOFF,
4289 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
4290 &random_placement_background_element, 1, 1,
4291 NULL, NULL, NULL, NULL, "random placement background"
4296 // ----------------------------------------------------------------------------
4297 // some internally used variables
4298 // ----------------------------------------------------------------------------
4300 // maximal size of level editor drawing area
4301 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
4303 // actual size of level editor drawing area
4304 static int ed_fieldx, ed_fieldy;
4306 // actual position of level editor drawing area in level playfield
4307 static int level_xpos = -1, level_ypos = -1;
4309 // actual tile size used to display playfield drawing area
4310 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
4311 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
4313 #define IN_ED_FIELD(x, y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
4315 // drawing elements on the three mouse buttons
4316 static int new_element1 = EL_WALL;
4317 static int new_element2 = EL_EMPTY;
4318 static int new_element3 = EL_SAND;
4320 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
4321 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
4322 (button) == 2 ? new_element2 : \
4323 (button) == 3 ? new_element3 : EL_EMPTY)
4325 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
4327 static int use_permanent_palette = TRUE;
4329 #define PX (use_permanent_palette ? DX : SX)
4330 #define PY (use_permanent_palette ? DY : SY)
4331 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
4332 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
4334 // forward declaration for internal use
4335 static void CopyBrushToCursor(int, int);
4336 static void DeleteBrushFromCursor(void);
4337 static void ModifyEditorCounterValue(int, int);
4338 static void ModifyEditorCounterLimits(int, int, int);
4339 static void ModifyEditorSelectboxValue(int, int);
4340 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
4341 static void ModifyEditorDrawingArea(int, int, int);
4342 static void ModifyEditorElementList(void);
4343 static void AdjustElementListScrollbar(void);
4344 static void RedrawDrawingElements(void);
4345 static void DrawDrawingWindowExt(boolean);
4346 static void DrawDrawingWindow(void);
4347 static void DrawLevelConfigWindow(void);
4348 static void DrawPropertiesWindow(void);
4349 static void DrawPaletteWindow(void);
4350 static void UpdateCustomElementGraphicGadgets(void);
4351 static boolean checkPropertiesConfig(int);
4352 static void SetAutomaticNumberOfGemsNeeded(void);
4353 static void ClearEditorGadgetInfoText(void);
4354 static void CopyLevelToUndoBuffer(int);
4355 static void HandleDrawingAreas(struct GadgetInfo *);
4356 static void HandleCounterButtons(struct GadgetInfo *);
4357 static void HandleTextInputGadgets(struct GadgetInfo *);
4358 static void HandleTextAreaGadgets(struct GadgetInfo *);
4359 static void HandleSelectboxGadgets(struct GadgetInfo *);
4360 static void HandleTextbuttonGadgets(struct GadgetInfo *);
4361 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
4362 static void HandleRadiobuttons(struct GadgetInfo *);
4363 static void HandleCheckbuttons(struct GadgetInfo *);
4364 static void HandleControlButtons(struct GadgetInfo *);
4365 static void HandleDrawingAreaInfo(struct GadgetInfo *);
4366 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
4367 static boolean AskToCopyAndModifyLevelTemplate(void);
4368 static boolean getDrawModeHiRes(void);
4369 static int getTabulatorBarWidth(void);
4370 static int getTabulatorBarHeight(void);
4371 static Pixel getTabulatorBarColor(void);
4372 static int numHiresTiles(int);
4374 static int num_editor_gadgets = 0; // dynamically determined
4376 static struct GadgetInfo **level_editor_gadget = NULL;
4377 static int *right_gadget_border = NULL;
4379 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
4380 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
4381 static boolean draw_with_brush = FALSE;
4382 static int properties_element = 0;
4384 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4385 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4386 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4387 static int undo_buffer_position = 0;
4388 static int undo_buffer_steps = 0;
4389 static int redo_buffer_steps = 0;
4391 static int edit_mode;
4392 static int edit_mode_levelconfig;
4393 static int edit_mode_properties;
4395 static int element_shift = 0;
4397 static int editor_el_players[] =
4404 static int *editor_el_players_ptr = editor_el_players;
4405 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4407 static int editor_hl_boulderdash[] =
4409 EL_INTERNAL_CASCADE_BD_ACTIVE,
4415 static int editor_el_boulderdash[] =
4424 EL_BD_EXPANDABLE_WALL,
4432 EL_BD_BUTTERFLY_LEFT,
4434 EL_BD_BUTTERFLY_RIGHT,
4435 EL_BD_FIREFLY_RIGHT,
4438 EL_BD_BUTTERFLY_DOWN,
4442 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4443 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4444 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4445 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4447 static int editor_hl_boulderdash_native[] =
4449 EL_INTERNAL_CASCADE_BD_NATIVE_ACTIVE,
4455 static int editor_el_boulderdash_native[] =
4472 EL_BD_BUTTERFLY_LEFT,
4474 EL_BD_BUTTERFLY_RIGHT,
4475 EL_BD_FIREFLY_RIGHT,
4478 EL_BD_BUTTERFLY_DOWN,
4483 EL_BD_BUTTERFLY_2_UP,
4487 EL_BD_BUTTERFLY_2_LEFT,
4488 EL_BD_FIREFLY_2_LEFT,
4489 EL_BD_BUTTERFLY_2_RIGHT,
4490 EL_BD_FIREFLY_2_RIGHT,
4493 EL_BD_BUTTERFLY_2_DOWN,
4494 EL_BD_FIREFLY_2_DOWN,
4502 EL_BD_DRAGONFLY_LEFT,
4503 EL_BD_STONEFLY_LEFT,
4504 EL_BD_DRAGONFLY_RIGHT,
4505 EL_BD_STONEFLY_RIGHT,
4508 EL_BD_DRAGONFLY_DOWN,
4509 EL_BD_STONEFLY_DOWN,
4532 EL_BD_SAND_SLOPED_UP_LEFT,
4533 EL_BD_SAND_SLOPED_UP_RIGHT,
4534 EL_BD_WALL_SLOPED_UP_LEFT,
4535 EL_BD_WALL_SLOPED_UP_RIGHT,
4537 EL_BD_SAND_SLOPED_DOWN_LEFT,
4538 EL_BD_SAND_SLOPED_DOWN_RIGHT,
4539 EL_BD_WALL_SLOPED_DOWN_LEFT,
4540 EL_BD_WALL_SLOPED_DOWN_RIGHT,
4542 EL_BD_FLYING_DIAMOND,
4544 EL_BD_STEELWALL_SLOPED_UP_LEFT,
4545 EL_BD_STEELWALL_SLOPED_UP_RIGHT,
4549 EL_BD_STEELWALL_SLOPED_DOWN_LEFT,
4550 EL_BD_STEELWALL_SLOPED_DOWN_RIGHT,
4553 EL_BD_WALL_NON_SLOPED,
4559 EL_BD_INVISIBLE_EXIT_CLOSED,
4560 EL_BD_INVISIBLE_EXIT_OPEN,
4563 EL_BD_STEELWALL_EXPLODABLE,
4564 EL_BD_STEELWALL_DIGGABLE,
4565 EL_BD_WALL_DIGGABLE,
4567 EL_BD_EXPANDABLE_WALL_HORIZONTAL,
4568 EL_BD_EXPANDABLE_WALL_VERTICAL,
4569 EL_BD_EXPANDABLE_WALL_ANY,
4570 EL_BD_CREATURE_SWITCH,
4572 EL_BD_EXPANDABLE_STEELWALL_HORIZONTAL,
4573 EL_BD_EXPANDABLE_STEELWALL_VERTICAL,
4574 EL_BD_EXPANDABLE_STEELWALL_ANY,
4575 EL_BD_EXPANDABLE_WALL_SWITCH_HORIZONTAL,
4577 EL_BD_BITER_SWITCH_1,
4578 EL_BD_REPLICATOR_SWITCH,
4579 EL_BD_CONVEYOR_SWITCH,
4580 EL_BD_CONVEYOR_DIR_SWITCH_RIGHT,
4589 EL_BD_DIAMOND_GLUED,
4592 EL_BD_TRAPPED_DIAMOND,
4612 EL_BD_GRAVITY_SWITCH,
4613 EL_BD_PNEUMATIC_HAMMER,
4620 EL_BD_BLADDER_SPENDER,
4622 EL_BD_CONVEYOR_LEFT,
4623 EL_BD_CONVEYOR_RIGHT,
4638 EL_BD_PLAYER_WITH_BOMB,
4640 EL_BD_PLAYER_STIRRING,
4642 static int *editor_hl_boulderdash_native_ptr = editor_hl_boulderdash_native;
4643 static int *editor_el_boulderdash_native_ptr = editor_el_boulderdash_native;
4644 static int num_editor_hl_boulderdash_native = ARRAY_SIZE(editor_hl_boulderdash_native);
4645 static int num_editor_el_boulderdash_native = ARRAY_SIZE(editor_el_boulderdash_native);
4647 static int editor_hl_emerald_mine[] =
4649 EL_INTERNAL_CASCADE_EM_ACTIVE,
4655 static int editor_el_emerald_mine[] =
4673 EL_EM_DYNAMITE_ACTIVE,
4692 EL_ACID_POOL_TOPLEFT,
4694 EL_ACID_POOL_TOPRIGHT,
4697 EL_ACID_POOL_BOTTOMLEFT,
4698 EL_ACID_POOL_BOTTOM,
4699 EL_ACID_POOL_BOTTOMRIGHT,
4717 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4718 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4719 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4720 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4722 static int editor_hl_emerald_mine_club[] =
4724 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4730 static int editor_el_emerald_mine_club[] =
4757 EL_EMC_WALL_SLIPPERY_1,
4758 EL_EMC_WALL_SLIPPERY_2,
4759 EL_EMC_WALL_SLIPPERY_3,
4760 EL_EMC_WALL_SLIPPERY_4,
4783 EL_EMC_MAGIC_BALL_SWITCH,
4790 EL_EMC_SPRING_BUMPER,
4794 EL_BALLOON_SWITCH_UP,
4795 EL_BALLOON_SWITCH_ANY,
4798 EL_BALLOON_SWITCH_LEFT,
4800 EL_BALLOON_SWITCH_RIGHT,
4804 EL_BALLOON_SWITCH_DOWN,
4805 EL_BALLOON_SWITCH_NONE,
4807 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4808 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4809 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4810 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4812 static int editor_hl_rnd[] =
4814 EL_INTERNAL_CASCADE_RND_ACTIVE,
4820 static int editor_el_rnd[] =
4823 EL_DYNAMITE_ACTIVE, // RND
4857 EL_WALL_EMERALD_YELLOW,
4858 EL_WALL_EMERALD_RED,
4859 EL_WALL_EMERALD_PURPLE,
4877 EL_DYNABOMB_INCREASE_NUMBER,
4878 EL_DYNABOMB_INCREASE_SIZE,
4879 EL_DYNABOMB_INCREASE_POWER,
4899 EL_INVISIBLE_STEELWALL,
4903 EL_EXPANDABLE_WALL_HORIZONTAL,
4904 EL_EXPANDABLE_WALL_VERTICAL,
4905 EL_EXPANDABLE_WALL_ANY,
4907 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4908 static int *editor_el_rnd_ptr = editor_el_rnd;
4909 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4910 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4912 static int editor_hl_sokoban[] =
4914 EL_INTERNAL_CASCADE_SB_ACTIVE,
4920 static int editor_el_sokoban[] =
4923 EL_SOKOBAN_FIELD_EMPTY,
4924 EL_SOKOBAN_FIELD_FULL,
4925 EL_SOKOBAN_FIELD_PLAYER,
4927 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4928 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4929 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4930 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4932 static int editor_hl_supaplex[] =
4934 EL_INTERNAL_CASCADE_SP_ACTIVE,
4940 static int editor_el_supaplex[] =
4958 EL_SP_PORT_HORIZONTAL,
4959 EL_SP_PORT_VERTICAL,
4967 EL_SP_GRAVITY_PORT_LEFT,
4968 EL_SP_GRAVITY_PORT_RIGHT,
4969 EL_SP_GRAVITY_PORT_UP,
4970 EL_SP_GRAVITY_PORT_DOWN,
4972 EL_SP_GRAVITY_ON_PORT_LEFT,
4973 EL_SP_GRAVITY_ON_PORT_RIGHT,
4974 EL_SP_GRAVITY_ON_PORT_UP,
4975 EL_SP_GRAVITY_ON_PORT_DOWN,
4977 EL_SP_GRAVITY_OFF_PORT_LEFT,
4978 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4979 EL_SP_GRAVITY_OFF_PORT_UP,
4980 EL_SP_GRAVITY_OFF_PORT_DOWN,
4982 EL_SP_HARDWARE_GRAY,
4983 EL_SP_HARDWARE_GREEN,
4984 EL_SP_HARDWARE_BLUE,
4987 EL_SP_HARDWARE_BASE_1,
4988 EL_SP_HARDWARE_BASE_2,
4989 EL_SP_HARDWARE_BASE_3,
4990 EL_SP_HARDWARE_BASE_4,
4992 EL_SP_HARDWARE_BASE_5,
4993 EL_SP_HARDWARE_BASE_6,
4994 EL_SP_HARDWARE_YELLOW,
5002 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
5003 static int *editor_el_supaplex_ptr = editor_el_supaplex;
5004 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
5005 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
5007 static int editor_hl_diamond_caves[] =
5009 EL_INTERNAL_CASCADE_DC_ACTIVE,
5015 static int editor_el_diamond_caves[] =
5017 EL_EM_STEEL_EXIT_CLOSED, // DC2
5018 EL_EM_STEEL_EXIT_OPEN, // DC2
5019 EL_WALL_EMERALD, // DC2
5020 EL_WALL_DIAMOND, // DC2
5027 EL_CONVEYOR_BELT_1_LEFT,
5028 EL_CONVEYOR_BELT_1_MIDDLE,
5029 EL_CONVEYOR_BELT_1_RIGHT,
5030 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
5032 EL_CONVEYOR_BELT_2_LEFT,
5033 EL_CONVEYOR_BELT_2_MIDDLE,
5034 EL_CONVEYOR_BELT_2_RIGHT,
5035 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
5037 EL_CONVEYOR_BELT_3_LEFT,
5038 EL_CONVEYOR_BELT_3_MIDDLE,
5039 EL_CONVEYOR_BELT_3_RIGHT,
5040 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
5042 EL_CONVEYOR_BELT_4_LEFT,
5043 EL_CONVEYOR_BELT_4_MIDDLE,
5044 EL_CONVEYOR_BELT_4_RIGHT,
5045 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
5047 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
5048 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
5049 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
5050 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
5052 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
5053 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
5054 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
5055 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
5060 EL_DC_TIMEGATE_SWITCH,
5062 EL_SWITCHGATE_CLOSED,
5064 EL_SWITCHGATE_SWITCH_UP,
5065 EL_SWITCHGATE_SWITCH_DOWN,
5068 EL_LIGHT_SWITCH_ACTIVE,
5069 EL_DC_SWITCHGATE_SWITCH_UP,
5070 EL_DC_SWITCHGATE_SWITCH_DOWN,
5072 EL_STEEL_EXIT_CLOSED,
5074 EL_STEELWALL_SLIPPERY,
5077 EL_QUICKSAND_FAST_EMPTY,
5078 EL_QUICKSAND_FAST_FULL,
5092 EL_SIGN_RADIOACTIVITY,
5098 EL_SIGN_ENTRY_FORBIDDEN,
5099 EL_SIGN_EMERGENCY_EXIT,
5124 EL_DC_STEELWALL_2_SINGLE,
5125 EL_DC_STEELWALL_2_TOP,
5126 EL_SIGN_EXCLAMATION,
5129 EL_DC_STEELWALL_2_LEFT,
5130 EL_DC_STEELWALL_2_MIDDLE,
5131 EL_DC_STEELWALL_2_HORIZONTAL,
5132 EL_DC_STEELWALL_2_RIGHT,
5134 EL_DC_STEELWALL_1_TOPLEFT,
5135 EL_DC_STEELWALL_2_VERTICAL,
5136 EL_DC_STEELWALL_1_TOPRIGHT,
5139 EL_DC_STEELWALL_1_VERTICAL,
5140 EL_DC_STEELWALL_2_BOTTOM,
5142 EL_DC_GATE_WHITE_GRAY,
5144 EL_DC_STEELWALL_1_BOTTOMLEFT,
5145 EL_DC_STEELWALL_1_HORIZONTAL,
5146 EL_DC_STEELWALL_1_BOTTOMRIGHT,
5147 EL_DC_GATE_FAKE_GRAY,
5149 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
5150 EL_DC_STEELWALL_1_BOTTOM,
5151 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
5152 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
5154 EL_DC_STEELWALL_1_RIGHT,
5156 EL_DC_STEELWALL_1_LEFT,
5157 EL_EXPANDABLE_STEELWALL_VERTICAL,
5159 EL_DC_STEELWALL_1_TOPRIGHT_2,
5160 EL_DC_STEELWALL_1_TOP,
5161 EL_DC_STEELWALL_1_TOPLEFT_2,
5162 EL_EXPANDABLE_STEELWALL_ANY,
5164 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
5165 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
5166 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
5167 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
5169 static int editor_hl_dx_boulderdash[] =
5171 EL_INTERNAL_CASCADE_DX_ACTIVE,
5177 static int editor_el_dx_boulderdash[] =
5181 EL_TUBE_HORIZONTAL_DOWN,
5185 EL_TUBE_VERTICAL_RIGHT,
5187 EL_TUBE_VERTICAL_LEFT,
5191 EL_TUBE_HORIZONTAL_UP,
5199 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
5200 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
5201 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
5202 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
5204 static int editor_hl_mirror_magic[] =
5206 EL_INTERNAL_CASCADE_MM_ACTIVE,
5212 static int editor_el_mirror_magic[] =
5214 EL_MM_MCDUFFIN_RIGHT,
5216 EL_MM_MCDUFFIN_LEFT,
5217 EL_MM_MCDUFFIN_DOWN,
5220 EL_MM_MIRROR_FIXED_START,
5221 EL_MM_POLARIZER_START,
5222 EL_MM_POLARIZER_CROSS_START,
5224 EL_MM_TELEPORTER_RED_START,
5225 EL_MM_TELEPORTER_YELLOW_START,
5226 EL_MM_TELEPORTER_GREEN_START,
5227 EL_MM_TELEPORTER_BLUE_START,
5240 EL_MM_LIGHTBULB_ACTIVE,
5254 EL_MM_STEEL_GRID_FIXED_1,
5255 EL_MM_STEEL_GRID_FIXED_2,
5256 EL_MM_STEEL_GRID_FIXED_3,
5257 EL_MM_STEEL_GRID_FIXED_4,
5259 EL_MM_WOODEN_GRID_FIXED_1,
5260 EL_MM_WOODEN_GRID_FIXED_2,
5261 EL_MM_WOODEN_GRID_FIXED_3,
5262 EL_MM_WOODEN_GRID_FIXED_4,
5269 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
5270 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
5271 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
5272 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
5274 static int editor_hl_deflektor[] =
5276 EL_INTERNAL_CASCADE_DF_ACTIVE,
5282 static int editor_el_deflektor[] =
5289 EL_DF_RECEIVER_RIGHT,
5291 EL_DF_RECEIVER_LEFT,
5292 EL_DF_RECEIVER_DOWN,
5295 EL_DF_MIRROR_ROTATING_START,
5296 EL_DF_MIRROR_FIXED_START,
5299 EL_DF_FIBRE_OPTIC_RED_1,
5300 EL_DF_FIBRE_OPTIC_YELLOW_1,
5301 EL_DF_FIBRE_OPTIC_GREEN_1,
5302 EL_DF_FIBRE_OPTIC_BLUE_1,
5304 EL_DF_STEEL_GRID_FIXED_START,
5305 EL_DF_STEEL_GRID_ROTATING_START,
5306 EL_DF_WOODEN_GRID_FIXED_START,
5307 EL_DF_WOODEN_GRID_ROTATING_START,
5319 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
5320 static int *editor_el_deflektor_ptr = editor_el_deflektor;
5321 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
5322 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
5324 static int editor_hl_chars[] =
5326 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
5332 static int editor_el_chars[] =
5414 EL_CHAR(CHAR_BYTE_COPYRIGHT),
5415 EL_CHAR(CHAR_BYTE_UMLAUT_A),
5416 EL_CHAR(CHAR_BYTE_UMLAUT_O),
5417 EL_CHAR(CHAR_BYTE_UMLAUT_U),
5419 EL_CHAR(CHAR_BYTE_DEGREE),
5420 EL_CHAR(CHAR_BYTE_REGISTERED),
5421 EL_CHAR(FONT_ASCII_CURSOR),
5422 EL_CHAR(FONT_ASCII_BUTTON),
5424 EL_CHAR(FONT_ASCII_UP),
5425 EL_CHAR(FONT_ASCII_DOWN),
5429 static int *editor_hl_chars_ptr = editor_hl_chars;
5430 static int *editor_el_chars_ptr = editor_el_chars;
5431 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
5432 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
5434 static int editor_hl_steel_chars[] =
5436 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
5442 static int editor_el_steel_chars[] =
5452 EL_STEEL_CHAR('\''),
5519 EL_STEEL_CHAR('\\'),
5524 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
5525 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
5526 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
5527 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
5529 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
5530 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
5531 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
5532 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
5534 EL_STEEL_CHAR(FONT_ASCII_UP),
5535 EL_STEEL_CHAR(FONT_ASCII_DOWN),
5539 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
5540 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
5541 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
5542 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
5544 static int editor_hl_custom[] =
5546 EL_INTERNAL_CASCADE_CE_ACTIVE,
5552 static int editor_el_custom[] =
5554 EL_CUSTOM_START + 0,
5555 EL_CUSTOM_START + 1,
5556 EL_CUSTOM_START + 2,
5557 EL_CUSTOM_START + 3,
5559 EL_CUSTOM_START + 4,
5560 EL_CUSTOM_START + 5,
5561 EL_CUSTOM_START + 6,
5562 EL_CUSTOM_START + 7,
5564 EL_CUSTOM_START + 8,
5565 EL_CUSTOM_START + 9,
5566 EL_CUSTOM_START + 10,
5567 EL_CUSTOM_START + 11,
5569 EL_CUSTOM_START + 12,
5570 EL_CUSTOM_START + 13,
5571 EL_CUSTOM_START + 14,
5572 EL_CUSTOM_START + 15,
5574 EL_CUSTOM_START + 16,
5575 EL_CUSTOM_START + 17,
5576 EL_CUSTOM_START + 18,
5577 EL_CUSTOM_START + 19,
5579 EL_CUSTOM_START + 20,
5580 EL_CUSTOM_START + 21,
5581 EL_CUSTOM_START + 22,
5582 EL_CUSTOM_START + 23,
5584 EL_CUSTOM_START + 24,
5585 EL_CUSTOM_START + 25,
5586 EL_CUSTOM_START + 26,
5587 EL_CUSTOM_START + 27,
5589 EL_CUSTOM_START + 28,
5590 EL_CUSTOM_START + 29,
5591 EL_CUSTOM_START + 30,
5592 EL_CUSTOM_START + 31,
5594 EL_CUSTOM_START + 32,
5595 EL_CUSTOM_START + 33,
5596 EL_CUSTOM_START + 34,
5597 EL_CUSTOM_START + 35,
5599 EL_CUSTOM_START + 36,
5600 EL_CUSTOM_START + 37,
5601 EL_CUSTOM_START + 38,
5602 EL_CUSTOM_START + 39,
5604 EL_CUSTOM_START + 40,
5605 EL_CUSTOM_START + 41,
5606 EL_CUSTOM_START + 42,
5607 EL_CUSTOM_START + 43,
5609 EL_CUSTOM_START + 44,
5610 EL_CUSTOM_START + 45,
5611 EL_CUSTOM_START + 46,
5612 EL_CUSTOM_START + 47,
5614 EL_CUSTOM_START + 48,
5615 EL_CUSTOM_START + 49,
5616 EL_CUSTOM_START + 50,
5617 EL_CUSTOM_START + 51,
5619 EL_CUSTOM_START + 52,
5620 EL_CUSTOM_START + 53,
5621 EL_CUSTOM_START + 54,
5622 EL_CUSTOM_START + 55,
5624 EL_CUSTOM_START + 56,
5625 EL_CUSTOM_START + 57,
5626 EL_CUSTOM_START + 58,
5627 EL_CUSTOM_START + 59,
5629 EL_CUSTOM_START + 60,
5630 EL_CUSTOM_START + 61,
5631 EL_CUSTOM_START + 62,
5632 EL_CUSTOM_START + 63,
5634 EL_CUSTOM_START + 64,
5635 EL_CUSTOM_START + 65,
5636 EL_CUSTOM_START + 66,
5637 EL_CUSTOM_START + 67,
5639 EL_CUSTOM_START + 68,
5640 EL_CUSTOM_START + 69,
5641 EL_CUSTOM_START + 70,
5642 EL_CUSTOM_START + 71,
5644 EL_CUSTOM_START + 72,
5645 EL_CUSTOM_START + 73,
5646 EL_CUSTOM_START + 74,
5647 EL_CUSTOM_START + 75,
5649 EL_CUSTOM_START + 76,
5650 EL_CUSTOM_START + 77,
5651 EL_CUSTOM_START + 78,
5652 EL_CUSTOM_START + 79,
5654 EL_CUSTOM_START + 80,
5655 EL_CUSTOM_START + 81,
5656 EL_CUSTOM_START + 82,
5657 EL_CUSTOM_START + 83,
5659 EL_CUSTOM_START + 84,
5660 EL_CUSTOM_START + 85,
5661 EL_CUSTOM_START + 86,
5662 EL_CUSTOM_START + 87,
5664 EL_CUSTOM_START + 88,
5665 EL_CUSTOM_START + 89,
5666 EL_CUSTOM_START + 90,
5667 EL_CUSTOM_START + 91,
5669 EL_CUSTOM_START + 92,
5670 EL_CUSTOM_START + 93,
5671 EL_CUSTOM_START + 94,
5672 EL_CUSTOM_START + 95,
5674 EL_CUSTOM_START + 96,
5675 EL_CUSTOM_START + 97,
5676 EL_CUSTOM_START + 98,
5677 EL_CUSTOM_START + 99,
5679 EL_CUSTOM_START + 100,
5680 EL_CUSTOM_START + 101,
5681 EL_CUSTOM_START + 102,
5682 EL_CUSTOM_START + 103,
5684 EL_CUSTOM_START + 104,
5685 EL_CUSTOM_START + 105,
5686 EL_CUSTOM_START + 106,
5687 EL_CUSTOM_START + 107,
5689 EL_CUSTOM_START + 108,
5690 EL_CUSTOM_START + 109,
5691 EL_CUSTOM_START + 110,
5692 EL_CUSTOM_START + 111,
5694 EL_CUSTOM_START + 112,
5695 EL_CUSTOM_START + 113,
5696 EL_CUSTOM_START + 114,
5697 EL_CUSTOM_START + 115,
5699 EL_CUSTOM_START + 116,
5700 EL_CUSTOM_START + 117,
5701 EL_CUSTOM_START + 118,
5702 EL_CUSTOM_START + 119,
5704 EL_CUSTOM_START + 120,
5705 EL_CUSTOM_START + 121,
5706 EL_CUSTOM_START + 122,
5707 EL_CUSTOM_START + 123,
5709 EL_CUSTOM_START + 124,
5710 EL_CUSTOM_START + 125,
5711 EL_CUSTOM_START + 126,
5712 EL_CUSTOM_START + 127,
5714 EL_CUSTOM_START + 128,
5715 EL_CUSTOM_START + 129,
5716 EL_CUSTOM_START + 130,
5717 EL_CUSTOM_START + 131,
5719 EL_CUSTOM_START + 132,
5720 EL_CUSTOM_START + 133,
5721 EL_CUSTOM_START + 134,
5722 EL_CUSTOM_START + 135,
5724 EL_CUSTOM_START + 136,
5725 EL_CUSTOM_START + 137,
5726 EL_CUSTOM_START + 138,
5727 EL_CUSTOM_START + 139,
5729 EL_CUSTOM_START + 140,
5730 EL_CUSTOM_START + 141,
5731 EL_CUSTOM_START + 142,
5732 EL_CUSTOM_START + 143,
5734 EL_CUSTOM_START + 144,
5735 EL_CUSTOM_START + 145,
5736 EL_CUSTOM_START + 146,
5737 EL_CUSTOM_START + 147,
5739 EL_CUSTOM_START + 148,
5740 EL_CUSTOM_START + 149,
5741 EL_CUSTOM_START + 150,
5742 EL_CUSTOM_START + 151,
5744 EL_CUSTOM_START + 152,
5745 EL_CUSTOM_START + 153,
5746 EL_CUSTOM_START + 154,
5747 EL_CUSTOM_START + 155,
5749 EL_CUSTOM_START + 156,
5750 EL_CUSTOM_START + 157,
5751 EL_CUSTOM_START + 158,
5752 EL_CUSTOM_START + 159,
5754 EL_CUSTOM_START + 160,
5755 EL_CUSTOM_START + 161,
5756 EL_CUSTOM_START + 162,
5757 EL_CUSTOM_START + 163,
5759 EL_CUSTOM_START + 164,
5760 EL_CUSTOM_START + 165,
5761 EL_CUSTOM_START + 166,
5762 EL_CUSTOM_START + 167,
5764 EL_CUSTOM_START + 168,
5765 EL_CUSTOM_START + 169,
5766 EL_CUSTOM_START + 170,
5767 EL_CUSTOM_START + 171,
5769 EL_CUSTOM_START + 172,
5770 EL_CUSTOM_START + 173,
5771 EL_CUSTOM_START + 174,
5772 EL_CUSTOM_START + 175,
5774 EL_CUSTOM_START + 176,
5775 EL_CUSTOM_START + 177,
5776 EL_CUSTOM_START + 178,
5777 EL_CUSTOM_START + 179,
5779 EL_CUSTOM_START + 180,
5780 EL_CUSTOM_START + 181,
5781 EL_CUSTOM_START + 182,
5782 EL_CUSTOM_START + 183,
5784 EL_CUSTOM_START + 184,
5785 EL_CUSTOM_START + 185,
5786 EL_CUSTOM_START + 186,
5787 EL_CUSTOM_START + 187,
5789 EL_CUSTOM_START + 188,
5790 EL_CUSTOM_START + 189,
5791 EL_CUSTOM_START + 190,
5792 EL_CUSTOM_START + 191,
5794 EL_CUSTOM_START + 192,
5795 EL_CUSTOM_START + 193,
5796 EL_CUSTOM_START + 194,
5797 EL_CUSTOM_START + 195,
5799 EL_CUSTOM_START + 196,
5800 EL_CUSTOM_START + 197,
5801 EL_CUSTOM_START + 198,
5802 EL_CUSTOM_START + 199,
5804 EL_CUSTOM_START + 200,
5805 EL_CUSTOM_START + 201,
5806 EL_CUSTOM_START + 202,
5807 EL_CUSTOM_START + 203,
5809 EL_CUSTOM_START + 204,
5810 EL_CUSTOM_START + 205,
5811 EL_CUSTOM_START + 206,
5812 EL_CUSTOM_START + 207,
5814 EL_CUSTOM_START + 208,
5815 EL_CUSTOM_START + 209,
5816 EL_CUSTOM_START + 210,
5817 EL_CUSTOM_START + 211,
5819 EL_CUSTOM_START + 212,
5820 EL_CUSTOM_START + 213,
5821 EL_CUSTOM_START + 214,
5822 EL_CUSTOM_START + 215,
5824 EL_CUSTOM_START + 216,
5825 EL_CUSTOM_START + 217,
5826 EL_CUSTOM_START + 218,
5827 EL_CUSTOM_START + 219,
5829 EL_CUSTOM_START + 220,
5830 EL_CUSTOM_START + 221,
5831 EL_CUSTOM_START + 222,
5832 EL_CUSTOM_START + 223,
5834 EL_CUSTOM_START + 224,
5835 EL_CUSTOM_START + 225,
5836 EL_CUSTOM_START + 226,
5837 EL_CUSTOM_START + 227,
5839 EL_CUSTOM_START + 228,
5840 EL_CUSTOM_START + 229,
5841 EL_CUSTOM_START + 230,
5842 EL_CUSTOM_START + 231,
5844 EL_CUSTOM_START + 232,
5845 EL_CUSTOM_START + 233,
5846 EL_CUSTOM_START + 234,
5847 EL_CUSTOM_START + 235,
5849 EL_CUSTOM_START + 236,
5850 EL_CUSTOM_START + 237,
5851 EL_CUSTOM_START + 238,
5852 EL_CUSTOM_START + 239,
5854 EL_CUSTOM_START + 240,
5855 EL_CUSTOM_START + 241,
5856 EL_CUSTOM_START + 242,
5857 EL_CUSTOM_START + 243,
5859 EL_CUSTOM_START + 244,
5860 EL_CUSTOM_START + 245,
5861 EL_CUSTOM_START + 246,
5862 EL_CUSTOM_START + 247,
5864 EL_CUSTOM_START + 248,
5865 EL_CUSTOM_START + 249,
5866 EL_CUSTOM_START + 250,
5867 EL_CUSTOM_START + 251,
5869 EL_CUSTOM_START + 252,
5870 EL_CUSTOM_START + 253,
5871 EL_CUSTOM_START + 254,
5872 EL_CUSTOM_START + 255
5874 static int *editor_hl_custom_ptr = editor_hl_custom;
5875 static int *editor_el_custom_ptr = editor_el_custom;
5876 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5877 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5879 static int editor_hl_group[] =
5881 EL_INTERNAL_CASCADE_GE_ACTIVE,
5887 static int editor_el_group[] =
5901 EL_GROUP_START + 10,
5902 EL_GROUP_START + 11,
5904 EL_GROUP_START + 12,
5905 EL_GROUP_START + 13,
5906 EL_GROUP_START + 14,
5907 EL_GROUP_START + 15,
5909 EL_GROUP_START + 16,
5910 EL_GROUP_START + 17,
5911 EL_GROUP_START + 18,
5912 EL_GROUP_START + 19,
5914 EL_GROUP_START + 20,
5915 EL_GROUP_START + 21,
5916 EL_GROUP_START + 22,
5917 EL_GROUP_START + 23,
5919 EL_GROUP_START + 24,
5920 EL_GROUP_START + 25,
5921 EL_GROUP_START + 26,
5922 EL_GROUP_START + 27,
5924 EL_GROUP_START + 28,
5925 EL_GROUP_START + 29,
5926 EL_GROUP_START + 30,
5929 static int *editor_hl_group_ptr = editor_hl_group;
5930 static int *editor_el_group_ptr = editor_el_group;
5931 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5932 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5934 static int editor_hl_empty_space[] =
5936 EL_INTERNAL_CASCADE_ES_ACTIVE,
5942 static int editor_el_empty_space[] =
5964 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
5965 static int *editor_el_empty_space_ptr = editor_el_empty_space;
5966 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
5967 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
5969 static int editor_hl_reference[] =
5971 EL_INTERNAL_CASCADE_REF_ACTIVE,
5977 static int editor_el_reference[] =
5981 EL_TRIGGER_CE_VALUE,
5982 EL_TRIGGER_CE_SCORE,
5986 EL_CURRENT_CE_VALUE,
5987 EL_CURRENT_CE_SCORE,
6009 static int *editor_hl_reference_ptr = editor_hl_reference;
6010 static int *editor_el_reference_ptr = editor_el_reference;
6011 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
6012 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
6014 static int editor_hl_user_defined[] =
6016 EL_INTERNAL_CASCADE_USER_ACTIVE,
6022 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
6023 static int *editor_el_user_defined_ptr = NULL;
6024 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
6025 static int num_editor_el_user_defined = 0;
6027 static int editor_hl_dynamic[] =
6029 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
6035 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
6036 static int *editor_el_dynamic_ptr = NULL;
6037 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
6038 static int num_editor_el_dynamic = 0;
6040 static int editor_hl_empty[] = { EL_EMPTY };
6041 static int *editor_el_empty = NULL; // dynamically allocated
6043 static int *editor_hl_empty_ptr = editor_hl_empty;
6044 static int *editor_el_empty_ptr = NULL;
6045 static int num_editor_hl_empty = 0;
6046 static int num_editor_el_empty = 0; // dynamically determined, if needed
6048 static boolean use_el_empty = FALSE;
6050 static int *editor_elements = NULL; // dynamically allocated
6051 static int num_editor_elements = 0; // dynamically determined
6053 static boolean setup_editor_cascade_never = FALSE;
6055 static boolean setup_editor_el_players = TRUE;
6056 static boolean setup_editor_el_boulderdash = TRUE;
6057 static boolean setup_editor_el_boulderdash_native = TRUE;
6058 static boolean setup_editor_el_emerald_mine = TRUE;
6059 static boolean setup_editor_el_emerald_mine_club = TRUE;
6060 static boolean setup_editor_el_more = TRUE;
6061 static boolean setup_editor_el_sokoban = TRUE;
6062 static boolean setup_editor_el_supaplex = TRUE;
6063 static boolean setup_editor_el_diamond_caves = TRUE;
6064 static boolean setup_editor_el_dx_boulderdash = TRUE;
6065 static boolean setup_editor_el_mirror_magic = TRUE;
6066 static boolean setup_editor_el_deflektor = TRUE;
6067 static boolean setup_editor_el_chars = TRUE;
6068 static boolean setup_editor_el_steel_chars = TRUE;
6069 static boolean setup_editor_el_custom = TRUE;
6070 static boolean setup_editor_el_user_defined = TRUE;
6071 static boolean setup_editor_el_dynamic = TRUE;
6073 static int editor_hl_unused[] = { EL_EMPTY };
6074 static int *editor_hl_unused_ptr = editor_hl_unused;
6075 static int num_editor_hl_unused = 0;
6079 boolean *setup_value;
6080 boolean *setup_cascade_value;
6082 int **headline_list;
6083 int *headline_list_size;
6086 int *element_list_size;
6088 boolean last_setup_value;
6090 editor_elements_info[] =
6093 &setup_editor_el_players,
6094 &setup_editor_cascade_never,
6095 &editor_hl_unused_ptr, &num_editor_hl_unused,
6096 &editor_el_players_ptr, &num_editor_el_players
6099 &setup_editor_el_boulderdash,
6100 &setup.editor_cascade.el_bd,
6101 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
6102 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
6105 &setup_editor_el_boulderdash_native,
6106 &setup.editor_cascade.el_bd_native,
6107 &editor_hl_boulderdash_native_ptr, &num_editor_hl_boulderdash_native,
6108 &editor_el_boulderdash_native_ptr, &num_editor_el_boulderdash_native
6111 &setup_editor_el_emerald_mine,
6112 &setup.editor_cascade.el_em,
6113 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
6114 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
6117 &setup_editor_el_emerald_mine_club,
6118 &setup.editor_cascade.el_emc,
6119 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
6120 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
6123 &setup_editor_el_more,
6124 &setup.editor_cascade.el_rnd,
6125 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
6126 &editor_el_rnd_ptr, &num_editor_el_rnd
6129 &setup_editor_el_sokoban,
6130 &setup.editor_cascade.el_sb,
6131 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
6132 &editor_el_sokoban_ptr, &num_editor_el_sokoban
6135 &setup_editor_el_supaplex,
6136 &setup.editor_cascade.el_sp,
6137 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
6138 &editor_el_supaplex_ptr, &num_editor_el_supaplex
6141 &setup_editor_el_diamond_caves,
6142 &setup.editor_cascade.el_dc,
6143 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
6144 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
6147 &setup_editor_el_dx_boulderdash,
6148 &setup.editor_cascade.el_dx,
6149 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
6150 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
6153 &setup_editor_el_mirror_magic,
6154 &setup.editor_cascade.el_mm,
6155 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
6156 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
6159 &setup_editor_el_deflektor,
6160 &setup.editor_cascade.el_df,
6161 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
6162 &editor_el_deflektor_ptr, &num_editor_el_deflektor
6165 &setup_editor_el_chars,
6166 &setup.editor_cascade.el_chars,
6167 &editor_hl_chars_ptr, &num_editor_hl_chars,
6168 &editor_el_chars_ptr, &num_editor_el_chars
6171 &setup_editor_el_steel_chars,
6172 &setup.editor_cascade.el_steel_chars,
6173 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
6174 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
6177 &setup_editor_el_custom,
6178 &setup.editor_cascade.el_ce,
6179 &editor_hl_custom_ptr, &num_editor_hl_custom,
6180 &editor_el_custom_ptr, &num_editor_el_custom
6183 &setup_editor_el_custom,
6184 &setup.editor_cascade.el_ge,
6185 &editor_hl_group_ptr, &num_editor_hl_group,
6186 &editor_el_group_ptr, &num_editor_el_group
6189 &setup_editor_el_custom,
6190 &setup.editor_cascade.el_es,
6191 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
6192 &editor_el_empty_space_ptr, &num_editor_el_empty_space
6195 &setup_editor_el_custom,
6196 &setup.editor_cascade.el_ref,
6197 &editor_hl_reference_ptr, &num_editor_hl_reference,
6198 &editor_el_reference_ptr, &num_editor_el_reference
6201 &setup_editor_el_user_defined,
6202 &setup.editor_cascade.el_user,
6203 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
6204 &editor_el_user_defined_ptr, &num_editor_el_user_defined
6207 &setup_editor_el_dynamic,
6208 &setup.editor_cascade.el_dynamic,
6209 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
6210 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
6215 &editor_hl_empty_ptr, &num_editor_hl_empty,
6216 &editor_el_empty_ptr, &num_editor_el_empty,
6226 static struct XY xy_directions[] =
6235 // ----------------------------------------------------------------------------
6237 // ----------------------------------------------------------------------------
6239 static int getMaxInfoTextLength(void)
6241 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
6244 static int getTextWidthForGadget(char *text)
6249 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
6252 static int getTextWidthForDrawingArea(char *text)
6257 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
6260 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
6262 return (gi->x + gi->width + getTextWidthForGadget(text));
6265 static char *getElementInfoText(int element)
6267 char *info_text = NULL;
6269 if (element < MAX_NUM_ELEMENTS)
6271 if (strlen(element_info[element].description) > 0)
6272 info_text = element_info[element].description;
6273 else if (element_info[element].custom_description != NULL)
6274 info_text = element_info[element].custom_description;
6275 else if (element_info[element].editor_description != NULL)
6276 info_text = element_info[element].editor_description;
6279 if (info_text == NULL)
6280 info_text = INFOTEXT_UNKNOWN_ELEMENT;
6285 static char *getElementDescriptionFilenameExt(char *basename)
6287 char *elements_subdir = ELEMENTS_DIRECTORY;
6288 static char *elements_subdir2 = NULL;
6289 static char *filename = NULL;
6291 if (elements_subdir2 == NULL)
6292 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
6294 checked_free(filename);
6296 // 1st try: look for element description in current level set directory
6297 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
6298 if (fileExists(filename))
6303 // 2nd try: look for element description in the game's base directory
6304 filename = getPath3(options.docs_directory, elements_subdir, basename);
6305 if (fileExists(filename))
6311 static char *getElementDescriptionFilename(int element)
6313 char basename[MAX_FILENAME_LEN];
6316 // 1st try: look for element description file for exactly this element
6317 sprintf(basename, "%s.txt", element_info[element].token_name);
6318 filename = getElementDescriptionFilenameExt(basename);
6319 if (filename != NULL)
6322 // 2nd try: look for element description file for this element's class
6323 sprintf(basename, "%s.txt", element_info[element].class_name);
6324 filename = getElementDescriptionFilenameExt(basename);
6325 if (filename != NULL)
6328 // 3rd try: look for generic fallback text file for any element
6329 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
6330 if (filename != NULL)
6336 static boolean suppressBorderElement(void)
6338 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
6339 lev_fieldx <= MAX_ED_FIELDX &&
6340 lev_fieldy <= MAX_ED_FIELDY);
6343 static void InitDynamicEditorElementList(int **elements, int *num_elements)
6345 boolean element_found[NUM_FILE_ELEMENTS];
6348 // initialize list of used elements to "not used"
6349 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6350 element_found[i] = FALSE;
6352 // find all elements used in current level
6353 for (y = 0; y < lev_fieldy; y++)
6355 for (x = 0; x < lev_fieldx; x++)
6357 if (Tile[x][y] >= NUM_FILE_ELEMENTS) // should never happen
6360 if (IS_MM_WALL(Tile[x][y]))
6361 element_found[map_mm_wall_element(Tile[x][y])] = TRUE;
6363 element_found[Tile[x][y]] = TRUE;
6369 // count number of elements used in current level
6370 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6371 if (element_found[i])
6374 // add space for up to 3 more elements for padding that may be needed
6377 // free memory for old list of elements, if needed
6378 checked_free(*elements);
6380 // allocate memory for new list of elements
6381 *elements = checked_malloc(*num_elements * sizeof(int));
6385 // add all elements used in current level (non-custom/group/empty elements)
6386 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6387 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) ||
6388 IS_GROUP_ELEMENT(i) ||
6389 IS_EMPTY_ELEMENT(i)))
6390 (*elements)[(*num_elements)++] = i;
6392 // add all elements used in current level (custom/group/empty elements)
6393 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6394 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) ||
6395 IS_GROUP_ELEMENT(i) ||
6396 IS_EMPTY_ELEMENT(i)))
6397 (*elements)[(*num_elements)++] = i;
6399 while (*num_elements % 4) // pad with empty elements, if needed
6400 (*elements)[(*num_elements)++] = EL_EMPTY;
6403 static void ReinitializeElementList_EnableSections(void)
6405 // default: enable all element sections
6407 setup_editor_el_players = TRUE;
6408 setup_editor_el_boulderdash = TRUE;
6409 setup_editor_el_boulderdash_native = TRUE;
6410 setup_editor_el_emerald_mine = TRUE;
6411 setup_editor_el_emerald_mine_club = TRUE;
6412 setup_editor_el_more = TRUE;
6413 setup_editor_el_sokoban = TRUE;
6414 setup_editor_el_supaplex = TRUE;
6415 setup_editor_el_diamond_caves = TRUE;
6416 setup_editor_el_dx_boulderdash = TRUE;
6417 setup_editor_el_mirror_magic = TRUE;
6418 setup_editor_el_deflektor = TRUE;
6419 setup_editor_el_chars = TRUE;
6420 setup_editor_el_steel_chars = TRUE;
6422 setup_editor_el_custom = TRUE;
6423 setup_editor_el_user_defined = TRUE;
6424 setup_editor_el_dynamic = TRUE;
6426 // now disable all element sections not to be displayed
6428 if (!setup.editor.el_classic)
6430 setup_editor_el_players = FALSE;
6431 setup_editor_el_boulderdash = FALSE;
6432 setup_editor_el_boulderdash_native = FALSE;
6433 setup_editor_el_emerald_mine = FALSE;
6434 setup_editor_el_emerald_mine_club = FALSE;
6435 setup_editor_el_more = FALSE;
6436 setup_editor_el_sokoban = FALSE;
6437 setup_editor_el_supaplex = FALSE;
6438 setup_editor_el_diamond_caves = FALSE;
6439 setup_editor_el_dx_boulderdash = FALSE;
6440 setup_editor_el_mirror_magic = FALSE;
6441 setup_editor_el_deflektor = FALSE;
6442 setup_editor_el_chars = FALSE;
6443 setup_editor_el_steel_chars = FALSE;
6446 if (!setup.editor.el_custom)
6448 setup_editor_el_custom = FALSE;
6451 if (!setup.editor.el_user_defined)
6453 setup_editor_el_user_defined = FALSE;
6456 if (!setup.editor.el_dynamic)
6458 setup_editor_el_dynamic = FALSE;
6461 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
6463 setup_editor_el_boulderdash_native = FALSE;
6464 setup_editor_el_mirror_magic = FALSE;
6465 setup_editor_el_deflektor = FALSE;
6467 else if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
6469 setup_editor_el_players = FALSE;
6470 setup_editor_el_boulderdash = FALSE;
6471 setup_editor_el_emerald_mine = FALSE;
6472 setup_editor_el_emerald_mine_club = FALSE;
6473 setup_editor_el_more = FALSE;
6474 setup_editor_el_sokoban = FALSE;
6475 setup_editor_el_supaplex = FALSE;
6476 setup_editor_el_diamond_caves = FALSE;
6477 setup_editor_el_dx_boulderdash = FALSE;
6478 setup_editor_el_mirror_magic = FALSE;
6479 setup_editor_el_deflektor = FALSE;
6480 setup_editor_el_chars = FALSE;
6481 setup_editor_el_steel_chars = FALSE;
6483 setup_editor_el_custom = FALSE;
6485 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
6487 setup_editor_el_boulderdash = FALSE;
6488 setup_editor_el_boulderdash_native = FALSE;
6489 setup_editor_el_more = FALSE;
6490 setup_editor_el_sokoban = FALSE;
6491 setup_editor_el_supaplex = FALSE;
6492 setup_editor_el_diamond_caves = FALSE;
6493 setup_editor_el_dx_boulderdash = FALSE;
6494 setup_editor_el_mirror_magic = FALSE;
6495 setup_editor_el_deflektor = FALSE;
6496 setup_editor_el_steel_chars = FALSE;
6498 setup_editor_el_custom = FALSE;
6500 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
6502 setup_editor_el_players = FALSE;
6503 setup_editor_el_boulderdash = FALSE;
6504 setup_editor_el_boulderdash_native = FALSE;
6505 setup_editor_el_emerald_mine = FALSE;
6506 setup_editor_el_emerald_mine_club = FALSE;
6507 setup_editor_el_more = FALSE;
6508 setup_editor_el_sokoban = FALSE;
6509 setup_editor_el_diamond_caves = FALSE;
6510 setup_editor_el_dx_boulderdash = FALSE;
6511 setup_editor_el_mirror_magic = FALSE;
6512 setup_editor_el_deflektor = FALSE;
6513 setup_editor_el_chars = FALSE;
6514 setup_editor_el_steel_chars = FALSE;
6516 setup_editor_el_custom = FALSE;
6518 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
6520 setup_editor_el_players = FALSE;
6521 setup_editor_el_boulderdash = FALSE;
6522 setup_editor_el_boulderdash_native = FALSE;
6523 setup_editor_el_emerald_mine = FALSE;
6524 setup_editor_el_emerald_mine_club = FALSE;
6525 setup_editor_el_more = FALSE;
6526 setup_editor_el_sokoban = FALSE;
6527 setup_editor_el_supaplex = FALSE;
6528 setup_editor_el_diamond_caves = FALSE;
6529 setup_editor_el_dx_boulderdash = FALSE;
6530 setup_editor_el_steel_chars = FALSE;
6532 setup_editor_el_custom = FALSE;
6536 static void ReinitializeElementList(void)
6538 static boolean initialization_needed = TRUE;
6542 ReinitializeElementList_EnableSections();
6544 if (initialization_needed)
6546 LoadSetup_EditorCascade(); // load last editor cascade state
6548 // initialize editor cascade element from saved cascade state
6549 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6551 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
6552 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
6554 if (IS_EDITOR_CASCADE(*cascade_element))
6556 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
6557 EL_CASCADE_INACTIVE(*cascade_element));
6560 initialization_needed = FALSE;
6563 checked_free(editor_elements);
6565 // reload optional user defined element list for each invocation of editor
6566 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
6567 &num_editor_el_user_defined);
6569 // initialize dynamic level element list for each invocation of editor
6570 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
6571 &num_editor_el_dynamic);
6573 // initialize list of empty elements (used for padding, if needed)
6574 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6575 editor_el_empty[i] = EL_EMPTY;
6577 // do some sanity checks for each element from element list
6578 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6580 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6582 int element = (*editor_elements_info[i].element_list)[j];
6584 if (element >= NUM_FILE_ELEMENTS)
6585 Warn("editor element %d is runtime element", element);
6587 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
6588 Warn("no element description text for element %d", element);
6592 num_editor_elements = 0;
6593 use_el_empty = FALSE;
6595 // determine size of element list
6596 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6598 if (*editor_elements_info[i].setup_value)
6600 boolean found_inactive_cascade = FALSE;
6602 if (setup.editor.el_headlines)
6604 // required for correct padding of palette headline buttons
6605 if (*editor_elements_info[i].headline_list_size > 0)
6606 num_editor_elements += ED_ELEMENTLIST_COLS;
6608 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6610 int element = (*editor_elements_info[i].headline_list)[j];
6612 if (IS_EDITOR_CASCADE_INACTIVE(element))
6613 found_inactive_cascade = TRUE;
6617 if (found_inactive_cascade)
6620 // required for correct padding of palette element buttons
6621 int element_list_size = *editor_elements_info[i].element_list_size;
6623 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6624 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6626 num_editor_elements += element_buttons;
6630 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
6632 // offer at least as many elements as element buttons exist
6633 use_el_empty = TRUE;
6634 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
6636 num_editor_elements += num_editor_el_empty;
6640 num_editor_el_empty = 0;
6643 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
6645 // fill element list
6646 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6648 boolean found_inactive_cascade = FALSE;
6650 if (*editor_elements_info[i].setup_value)
6652 if (setup.editor.el_headlines)
6654 // required for correct padding of palette headline buttons
6655 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6656 ED_ELEMENTLIST_COLS : 0);
6658 for (j = 0; j < headline_size; j++)
6660 // use empty elements for padding of palette headline buttons
6661 int element = (j < *editor_elements_info[i].headline_list_size ?
6662 (*editor_elements_info[i].headline_list)[j] :
6663 editor_el_empty[0]);
6665 editor_elements[pos++] = element;
6667 if (IS_EDITOR_CASCADE_INACTIVE(element))
6668 found_inactive_cascade = TRUE;
6672 if (found_inactive_cascade)
6675 // required for correct padding of palette element buttons
6676 int element_list_size = *editor_elements_info[i].element_list_size;
6678 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6679 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6681 // copy all elements from element list
6682 for (j = 0; j < element_list_size; j++)
6683 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6685 // use empty elements for padding of palette element buttons
6686 for (j = 0; j < element_buttons - element_list_size; j++)
6687 editor_elements[pos++] = editor_el_empty[0];
6691 // (this function is also called before editor gadgets are initialized!)
6692 AdjustElementListScrollbar();
6695 void PrintEditorElementList(void)
6697 boolean *stop = &setup_editor_el_user_defined;
6700 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6702 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6704 if (IS_EDITOR_CASCADE(cascade_element))
6706 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6707 char *headline = element_info[cascade_element_show].editor_description;
6709 PrintLineWithPrefix("# ", "-", 77);
6710 Print("# %s\n", headline);
6711 PrintLineWithPrefix("# ", "-", 77);
6714 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6716 int element = (*editor_elements_info[i].headline_list)[j];
6718 if (IS_EDITOR_CASCADE(element))
6719 element = EL_CHAR_MINUS;
6721 Print("# %s\n", element_info[element].token_name);
6727 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6729 int element = (*editor_elements_info[i].element_list)[j];
6731 Print("# %s\n", element_info[element].token_name);
6739 static void ReinitializeElementListButtons(void)
6741 static boolean last_setup_value_headlines = FALSE;
6742 static boolean initialization_needed = TRUE;
6745 if (!initialization_needed) // check if editor element setup has changed
6747 if (last_setup_value_headlines != setup.editor.el_headlines)
6748 initialization_needed = TRUE;
6750 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6751 if (editor_elements_info[i].last_setup_value !=
6752 *editor_elements_info[i].setup_value)
6753 initialization_needed = TRUE;
6756 if (!initialization_needed)
6759 FreeLevelEditorGadgets();
6760 CreateLevelEditorGadgets();
6762 // store current setup values for next invocation of this function
6763 last_setup_value_headlines = setup.editor.el_headlines;
6764 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6765 editor_elements_info[i].last_setup_value =
6766 *editor_elements_info[i].setup_value;
6768 initialization_needed = FALSE;
6771 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6774 int border_graphic =
6775 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6776 struct GraphicInfo *g = &graphic_info[border_graphic];
6777 Bitmap *src_bitmap = g->bitmap;
6778 int src_x = g->src_x;
6779 int src_y = g->src_y;
6780 int border_size = g->border_size;
6781 int border_xpos = g->width - border_size;
6782 int border_ypos = g->height - border_size;
6783 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6786 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6787 border_size, border_size,
6788 dest_x - border_size, dest_y - border_size);
6789 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6790 border_size, border_size,
6791 dest_x + width, dest_y - border_size);
6792 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6793 border_size, border_size,
6794 dest_x - border_size, dest_y + height);
6795 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6796 border_size, border_size,
6797 dest_x + width, dest_y + height);
6799 for (i = 0; i < width / tilesize; i++)
6801 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6802 tilesize, border_size,
6803 dest_x + i * tilesize, dest_y - border_size);
6804 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6805 tilesize, border_size,
6806 dest_x + i * tilesize, dest_y + height);
6809 for (i = 0; i < height / tilesize; i++)
6811 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6812 border_size, tilesize,
6813 dest_x - border_size, dest_y + i * tilesize);
6814 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6815 border_size, tilesize,
6816 dest_x + width, dest_y + i * tilesize);
6819 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6822 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6824 int xsize_tile = MAX(ed_tilesize, xsize);
6825 int ysize_tile = MAX(ed_tilesize, ysize);
6826 int xsize_full = xsize + 1;
6827 int ysize_full = ysize + 1;
6828 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6829 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6830 Pixel line_color = getTabulatorBarColor();
6832 if (line_color == BLACK_PIXEL) // black => transparent
6835 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6836 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6837 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6840 static void DrawEditorLevelBorderLinesIfNeeded(void)
6842 int xsize = lev_fieldx * ed_tilesize;
6843 int ysize = lev_fieldy * ed_tilesize;
6844 int line_size = getTabulatorBarHeight();
6846 if (!suppressBorderElement())
6849 // draw little border line around editable level playfield
6852 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6855 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6857 if (xsize < SXSIZE && ysize < SYSIZE)
6858 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6861 static void DrawEditorElement(int x, int y, int element)
6863 DrawSizedElement(x, y, element, ed_tilesize);
6866 static void DrawEditorElementThruMask(int x, int y, int element)
6868 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6871 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6873 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6876 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6878 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6879 DrawEditorLevelBorderLinesIfNeeded();
6882 static void DrawDrawingArea(int id)
6884 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6887 int *value = drawingarea_info[id].value;
6888 int area_xsize = drawingarea_info[id].area_xsize;
6889 int area_ysize = drawingarea_info[id].area_ysize;
6890 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6892 for (x = 0; x < area_xsize; x++)
6893 for (y = 0; y < area_ysize; y++)
6894 DrawSizedGraphicExt(drawto,
6895 gi->x + x * tilesize,
6896 gi->y + y * tilesize,
6897 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6900 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6903 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6904 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6906 BlitBitmap(drawto, drawto,
6907 SX + (dx == -1 ? ed_tilesize : 0),
6908 SY + (dy == -1 ? ed_tilesize : 0),
6909 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6910 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6911 SX + (dx == +1 ? ed_tilesize : 0),
6912 SY + (dy == +1 ? ed_tilesize : 0));
6916 x = (dx == 1 ? 0 : ed_fieldx - 1);
6917 for (y = 0; y < ed_fieldy; y++)
6918 DrawEditorElementOrWall(x, y, from_x, from_y);
6922 y = (dy == 1 ? 0 : ed_fieldy - 1);
6923 for (x = 0; x < ed_fieldx; x++)
6924 DrawEditorElementOrWall(x, y, from_x, from_y);
6927 redraw_mask |= REDRAW_FIELD;
6931 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6934 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6937 static void CreateControlButtons(void)
6939 struct GadgetInfo *gi;
6942 // create toolbox buttons
6943 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6945 int type_id = controlbutton_info[i].gadget_id; // same as gadget ID here
6946 int id = controlbutton_info[i].gadget_id;
6947 int type = controlbutton_info[i].gadget_type;
6948 int graphic = controlbutton_info[i].graphic;
6949 struct XYTileSize *pos = controlbutton_info[i].pos;
6950 struct GraphicInfo *gd = &graphic_info[graphic];
6951 Bitmap *deco_bitmap = NULL;
6952 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6953 int tile_size = 0, deco_shift = 0;
6954 boolean deco_masked = FALSE;
6955 int gd_x1 = gd->src_x;
6956 int gd_y1 = gd->src_y;
6957 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6958 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6959 int gd_x1a = gd->src_x + gd->active_xoffset;
6960 int gd_y1a = gd->src_y + gd->active_yoffset;
6961 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6962 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6965 unsigned int event_mask;
6966 int radio_button_nr = RADIO_NR_NONE;
6967 boolean checked = FALSE;
6970 Fail("'controlbutton_info' structure corrupted at index %d -- please fix", i);
6972 if (type == GD_TYPE_RADIO_BUTTON)
6974 event_mask = GD_EVENT_PRESSED;
6975 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6977 if (id == drawing_function)
6982 if (id == GADGET_ID_WRAP_LEFT ||
6983 id == GADGET_ID_WRAP_RIGHT ||
6984 id == GADGET_ID_WRAP_UP ||
6985 id == GADGET_ID_WRAP_DOWN)
6986 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6988 event_mask = GD_EVENT_RELEASED;
6991 if (id == GADGET_ID_PROPERTIES ||
6992 id == GADGET_ID_PALETTE)
6997 else if (id == GADGET_ID_ELEMENT_LEFT ||
6998 id == GADGET_ID_ELEMENT_MIDDLE ||
6999 id == GADGET_ID_ELEMENT_RIGHT)
7004 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
7005 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
7006 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
7008 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
7009 editor.button.element_left.tile_size :
7010 id == GADGET_ID_ELEMENT_MIDDLE ?
7011 editor.button.element_middle.tile_size :
7012 id == GADGET_ID_ELEMENT_RIGHT ?
7013 editor.button.element_right.tile_size : 0);
7015 // make sure that decoration does not overlap gadget border
7016 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
7018 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
7020 deco_xpos = (gd->width - tile_size) / 2;
7021 deco_ypos = (gd->height - tile_size) / 2;
7023 deco_masked = gd->draw_masked;
7031 gi = CreateGadget(GDI_CUSTOM_ID, id,
7032 GDI_CUSTOM_TYPE_ID, type_id,
7033 GDI_IMAGE_ID, graphic,
7034 GDI_INFO_TEXT, controlbutton_info[i].infotext,
7037 GDI_WIDTH, gd->width,
7038 GDI_HEIGHT, gd->height,
7040 GDI_STATE, GD_BUTTON_UNPRESSED,
7041 GDI_RADIO_NR, radio_button_nr,
7042 GDI_CHECKED, checked,
7043 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7044 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7045 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7046 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7047 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7048 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7049 GDI_DECORATION_SIZE, tile_size, tile_size,
7050 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
7051 GDI_DECORATION_MASKED, deco_masked,
7052 GDI_EVENT_MASK, event_mask,
7053 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7054 GDI_CALLBACK_ACTION, HandleControlButtons,
7058 Fail("cannot create gadget");
7060 level_editor_gadget[id] = gi;
7063 // these values are not constant, but can change at runtime
7064 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
7065 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
7066 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
7067 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
7068 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
7069 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
7070 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
7071 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
7072 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
7073 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
7074 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
7075 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
7077 // create buttons for scrolling of drawing area and element list
7078 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
7080 int id = scrollbutton_info[i].gadget_id;
7081 int type_id = scrollbutton_info[i].gadget_type_id;
7082 int graphic = scrollbutton_info[i].graphic;
7083 struct GraphicInfo *gd = &graphic_info[graphic];
7084 Bitmap *gd_bitmap = gd->bitmap;
7085 int gd_x1 = gd->src_x;
7086 int gd_y1 = gd->src_y;
7087 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7088 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7089 int width = gd->width;
7090 int height = gd->height;
7091 int x = scrollbutton_pos[i].x;
7092 int y = scrollbutton_pos[i].y;
7093 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7096 Fail("'scrollbutton_info' structure corrupted at index %d -- please fix", i);
7098 if (id == GADGET_ID_SCROLL_LIST_UP ||
7099 id == GADGET_ID_SCROLL_LIST_DOWN)
7110 gi = CreateGadget(GDI_CUSTOM_ID, id,
7111 GDI_CUSTOM_TYPE_ID, type_id,
7112 GDI_IMAGE_ID, graphic,
7113 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
7118 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7119 GDI_STATE, GD_BUTTON_UNPRESSED,
7120 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7121 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7122 GDI_EVENT_MASK, event_mask,
7123 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7124 GDI_CALLBACK_ACTION, HandleControlButtons,
7128 Fail("cannot create gadget");
7130 level_editor_gadget[id] = gi;
7133 // create buttons for element list
7134 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7137 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
7138 int graphic = IMG_EDITOR_PALETTE_BUTTON;
7139 struct GraphicInfo *gd = &graphic_info[graphic];
7140 Bitmap *gd_bitmap = gd->bitmap;
7141 Bitmap *deco_bitmap;
7142 int deco_x, deco_y, deco_xpos, deco_ypos;
7143 int gd_x1 = gd->src_x;
7144 int gd_y1 = gd->src_y;
7145 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7146 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7147 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
7148 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
7149 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
7150 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
7151 int element = editor_elements[i];
7152 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
7153 unsigned int event_mask = GD_EVENT_RELEASED;
7155 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
7157 deco_xpos = (gd->width - tile_size) / 2;
7158 deco_ypos = (gd->height - tile_size) / 2;
7160 gi = CreateGadget(GDI_CUSTOM_ID, id,
7161 GDI_CUSTOM_TYPE_ID, type_id,
7162 GDI_IMAGE_ID, graphic,
7163 GDI_INFO_TEXT, getElementInfoText(element),
7166 GDI_WIDTH, gd->width,
7167 GDI_HEIGHT, gd->height,
7168 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7169 GDI_STATE, GD_BUTTON_UNPRESSED,
7170 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7171 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7172 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7173 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7174 GDI_DECORATION_SIZE, tile_size, tile_size,
7175 GDI_DECORATION_SHIFTING, 1, 1,
7176 GDI_EVENT_MASK, event_mask,
7177 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7178 GDI_CALLBACK_ACTION, HandleControlButtons,
7182 Fail("cannot create gadget");
7184 level_editor_gadget[id] = gi;
7188 static void CreateCounterButtons(void)
7190 int max_infotext_len = getMaxInfoTextLength();
7193 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
7195 int type_id = counterbutton_info[i].gadget_type_id;
7196 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
7197 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
7201 Fail("'counterbutton_info' structure corrupted at index %d -- please fix", i);
7203 // determine horizontal position to the right of specified gadget
7204 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7205 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
7206 ED_GADGET_TEXT_DISTANCE);
7208 // determine horizontal offset for leading text
7209 if (counterbutton_info[i].text_left != NULL)
7210 x += getTextWidthForGadget(counterbutton_info[i].text_left);
7212 for (j = 0; j < 2; j++)
7214 struct GadgetInfo *gi;
7216 counterbutton_info[i].gadget_id_down :
7217 counterbutton_info[i].gadget_id_up);
7219 struct GraphicInfo *gd;
7220 int gd_x1, gd_x2, gd_y1, gd_y2;
7221 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7222 char infotext[max_infotext_len + 1];
7224 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7227 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
7228 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
7230 event_mask |= GD_EVENT_RELEASED;
7234 x = DX + editor.button.prev_level.x;
7235 y = DY + editor.button.prev_level.y;
7239 x = DX + editor.button.next_level.x;
7240 y = DY + editor.button.next_level.y;
7246 IMG_EDITOR_COUNTER_DOWN :
7247 IMG_EDITOR_COUNTER_UP);
7250 gd = &graphic_info[graphic];
7254 gd_x2 = gd->src_x + gd->pressed_xoffset;
7255 gd_y2 = gd->src_y + gd->pressed_yoffset;
7257 sprintf(infotext, "%s counter value by 1, 5 or 10",
7258 (j == 0 ? "decrease" : "increase"));
7260 gi = CreateGadget(GDI_CUSTOM_ID, id,
7261 GDI_CUSTOM_TYPE_ID, type_id,
7262 GDI_IMAGE_ID, graphic,
7263 GDI_INFO_TEXT, infotext,
7266 GDI_WIDTH, gd->width,
7267 GDI_HEIGHT, gd->height,
7268 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7269 GDI_STATE, GD_BUTTON_UNPRESSED,
7270 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7271 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7272 GDI_EVENT_MASK, event_mask,
7273 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7274 GDI_CALLBACK_ACTION, HandleCounterButtons,
7278 Fail("cannot create gadget");
7280 level_editor_gadget[id] = gi;
7281 right_gadget_border[id] =
7282 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7284 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
7288 int font_type = FONT_INPUT_1;
7289 int font_type_active = FONT_INPUT_1_ACTIVE;
7291 id = counterbutton_info[i].gadget_id_text;
7293 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7295 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7297 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
7299 font_type = FONT_LEVEL_NUMBER;
7300 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
7302 x = DX + editor.input.level_number.x;
7303 y = DY + editor.input.level_number.y;
7307 graphic = IMG_EDITOR_COUNTER_INPUT;
7310 gd = &graphic_info[graphic];
7314 gd_x2 = gd->src_x + gd->active_xoffset;
7315 gd_y2 = gd->src_y + gd->active_yoffset;
7317 gi = CreateGadget(GDI_CUSTOM_ID, id,
7318 GDI_CUSTOM_TYPE_ID, type_id,
7319 GDI_IMAGE_ID, graphic,
7320 GDI_INFO_TEXT, "enter counter value",
7323 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
7324 GDI_NUMBER_VALUE, 0,
7325 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
7326 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
7327 GDI_TEXT_SIZE, 3, // minimal counter text size
7328 GDI_TEXT_FONT, font_type,
7329 GDI_TEXT_FONT_ACTIVE, font_type_active,
7330 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7331 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7332 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7333 GDI_DESIGN_WIDTH, gd->width,
7334 GDI_EVENT_MASK, event_mask,
7335 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7336 GDI_CALLBACK_ACTION, HandleCounterButtons,
7340 Fail("cannot create gadget");
7342 level_editor_gadget[id] = gi;
7343 right_gadget_border[id] =
7344 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7346 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
7352 static void CreateDrawingAreas(void)
7356 // these values are not constant, but can change at runtime
7357 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
7358 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
7360 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
7362 struct GadgetInfo *gi;
7363 int id = drawingarea_info[i].gadget_id;
7364 int type_id = drawingarea_info[i].gadget_type_id;
7365 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
7366 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
7367 int area_xsize = drawingarea_info[i].area_xsize;
7368 int area_ysize = drawingarea_info[i].area_ysize;
7369 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
7370 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
7371 unsigned int event_mask =
7372 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
7373 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
7376 Fail("'drawingarea_info' structure corrupted at index %d -- please fix", i);
7378 // determine horizontal position to the right of specified gadget
7379 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
7380 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
7381 ED_DRAWINGAREA_TEXT_DISTANCE);
7383 // determine horizontal offset for leading text
7384 if (drawingarea_info[i].text_left != NULL)
7385 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
7387 gi = CreateGadget(GDI_CUSTOM_ID, id,
7388 GDI_CUSTOM_TYPE_ID, type_id,
7391 GDI_TYPE, GD_TYPE_DRAWING_AREA,
7392 GDI_AREA_SIZE, area_xsize, area_ysize,
7393 GDI_ITEM_SIZE, item_size, item_size,
7394 GDI_EVENT_MASK, event_mask,
7395 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
7396 GDI_CALLBACK_ACTION, HandleDrawingAreas,
7400 Fail("cannot create gadget");
7402 level_editor_gadget[id] = gi;
7403 right_gadget_border[id] =
7404 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
7408 static void CreateTextInputGadgets(void)
7410 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
7411 int max_infotext_len = getMaxInfoTextLength();
7414 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
7416 int gd_x1 = gd->src_x;
7417 int gd_y1 = gd->src_y;
7418 int gd_x2 = gd->src_x + gd->active_xoffset;
7419 int gd_y2 = gd->src_y + gd->active_yoffset;
7420 struct GadgetInfo *gi;
7421 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7422 char infotext[MAX_OUTPUT_LINESIZE + 1];
7423 int id = textinput_info[i].gadget_id;
7424 int type_id = textinput_info[i].gadget_type_id;
7428 Fail("'textinput_info' structure corrupted at index %d -- please fix", i);
7430 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
7432 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
7433 int border_size = gd->border_size;
7434 int font_nr = FONT_INPUT_1;
7435 int font_height = getFontHeight(font_nr);
7436 int xoffset = element_border + TILEX + element_border + 3 * border_size;
7437 int yoffset = element_border + (TILEY - font_height) / 2;
7439 x = (editor.settings.element_name.x != -1 ?
7440 editor.settings.element_name.x :
7441 editor.settings.element_graphic.x + xoffset) - border_size;
7442 y = (editor.settings.element_name.y != -1 ?
7443 editor.settings.element_name.y :
7444 editor.settings.element_graphic.y + yoffset) - border_size;
7448 x = ED_SETTINGS_X(textinput_info[i].x);
7449 y = ED_SETTINGS_Y(textinput_info[i].y);
7452 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
7453 infotext[max_infotext_len] = '\0';
7455 gi = CreateGadget(GDI_CUSTOM_ID, id,
7456 GDI_CUSTOM_TYPE_ID, type_id,
7457 GDI_INFO_TEXT, infotext,
7460 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
7461 GDI_TEXT_VALUE, textinput_info[i].value,
7462 GDI_TEXT_SIZE, textinput_info[i].size,
7463 GDI_TEXT_FONT, FONT_INPUT_1,
7464 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7465 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7466 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7467 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7468 GDI_DESIGN_WIDTH, gd->width,
7469 GDI_EVENT_MASK, event_mask,
7470 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7471 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
7475 Fail("cannot create gadget");
7477 level_editor_gadget[id] = gi;
7481 static void CreateTextAreaGadgets(void)
7483 int max_infotext_len = getMaxInfoTextLength();
7486 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
7488 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
7489 int gd_x1 = gd->src_x;
7490 int gd_y1 = gd->src_y;
7491 int gd_x2 = gd->src_x + gd->active_xoffset;
7492 int gd_y2 = gd->src_y + gd->active_yoffset;
7493 struct GadgetInfo *gi;
7494 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
7495 char infotext[MAX_OUTPUT_LINESIZE + 1];
7496 int id = textarea_info[i].gadget_id;
7497 int type_id = textarea_info[i].gadget_type_id;
7498 int area_xsize = textarea_info[i].xsize;
7499 int area_ysize = textarea_info[i].ysize;
7502 Fail("'textarea_info' structure corrupted at index %d -- please fix", i);
7504 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
7505 infotext[max_infotext_len] = '\0';
7507 gi = CreateGadget(GDI_CUSTOM_ID, id,
7508 GDI_CUSTOM_TYPE_ID, type_id,
7509 GDI_INFO_TEXT, infotext,
7510 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
7511 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
7512 GDI_TYPE, GD_TYPE_TEXT_AREA,
7513 GDI_AREA_SIZE, area_xsize, area_ysize,
7514 GDI_TEXT_FONT, FONT_INPUT_1,
7515 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7516 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7517 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7518 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7519 GDI_DESIGN_WIDTH, gd->width,
7520 GDI_EVENT_MASK, event_mask,
7521 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7522 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
7526 Fail("cannot create gadget");
7528 level_editor_gadget[id] = gi;
7532 static void CreateSelectboxGadgets(void)
7534 int max_infotext_len = getMaxInfoTextLength();
7537 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7539 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
7540 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
7541 int gd_x1 = gd->src_x;
7542 int gd_y1 = gd->src_y;
7543 int gd_x2 = gd->src_x + gd->active_xoffset;
7544 int gd_y2 = gd->src_y + gd->active_yoffset;
7545 int selectbox_button_xsize = gd2->width;
7546 struct GadgetInfo *gi;
7547 char infotext[MAX_OUTPUT_LINESIZE + 1];
7548 int id = selectbox_info[i].gadget_id;
7549 int type_id = selectbox_info[i].gadget_type_id;
7550 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
7551 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
7552 unsigned int event_mask =
7553 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7556 Fail("'selectbox_info' structure corrupted at index %d -- please fix", i);
7558 if (selectbox_info[i].size == -1) // dynamically determine size
7560 // (we cannot use -1 for uninitialized values if we directly compare
7561 // with results from strlen(), because the '<' and '>' operation will
7562 // implicitely cast -1 to an unsigned integer value!)
7563 selectbox_info[i].size = 0;
7565 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
7566 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
7567 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
7569 selectbox_info[i].size++; // add one character empty space
7572 // determine horizontal position to the right of specified gadget
7573 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
7574 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
7575 ED_GADGET_TEXT_DISTANCE);
7577 // determine horizontal offset for leading text
7578 if (selectbox_info[i].text_left != NULL)
7579 x += getTextWidthForGadget(selectbox_info[i].text_left);
7581 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
7582 infotext[max_infotext_len] = '\0';
7584 gi = CreateGadget(GDI_CUSTOM_ID, id,
7585 GDI_CUSTOM_TYPE_ID, type_id,
7586 GDI_INFO_TEXT, infotext,
7589 GDI_TYPE, GD_TYPE_SELECTBOX,
7590 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
7591 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
7592 GDI_TEXT_SIZE, selectbox_info[i].size,
7593 GDI_TEXT_FONT, FONT_INPUT_1,
7594 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7595 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
7596 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7597 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7598 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7599 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
7600 GDI_DESIGN_WIDTH, gd->width,
7601 GDI_EVENT_MASK, event_mask,
7602 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7603 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
7607 Fail("cannot create gadget");
7609 level_editor_gadget[id] = gi;
7610 right_gadget_border[id] =
7611 getRightGadgetBorder(gi, selectbox_info[i].text_right);
7615 static void CreateTextbuttonGadgets(void)
7617 int max_infotext_len = getMaxInfoTextLength();
7620 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
7622 int id = textbutton_info[i].gadget_id;
7623 int type_id = textbutton_info[i].gadget_type_id;
7625 ((id >= GADGET_ID_LEVELCONFIG_LEVEL && id <= GADGET_ID_LEVELCONFIG_ENGINE) ||
7626 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
7628 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
7629 int gadget_distance =
7630 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
7631 struct GraphicInfo *gd = &graphic_info[graphic];
7632 int gd_x1 = gd->src_x;
7633 int gd_y1 = gd->src_y;
7634 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7635 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7636 int gd_x1a = gd->src_x + gd->active_xoffset;
7637 int gd_y1a = gd->src_y + gd->active_yoffset;
7638 int border_xsize = gd->border_size + gd->draw_xoffset;
7639 int border_ysize = gd->border_size;
7640 struct GadgetInfo *gi;
7641 unsigned int event_mask = GD_EVENT_RELEASED;
7642 char infotext[MAX_OUTPUT_LINESIZE + 1];
7643 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
7644 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
7647 Fail("'textbutton_info' structure corrupted at index %d -- please fix", i);
7649 if (textbutton_info[i].size == -1) // dynamically determine size
7650 textbutton_info[i].size = strlen(textbutton_info[i].text);
7652 sprintf(infotext, "%s", textbutton_info[i].infotext);
7653 infotext[max_infotext_len] = '\0';
7655 // determine horizontal position to the right of specified gadget
7656 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7658 int gadget_id_align = textbutton_info[i].gadget_id_align;
7660 x = right_gadget_border[gadget_id_align] + gadget_distance;
7662 if (textbutton_info[i].y == -1)
7663 y = level_editor_gadget[gadget_id_align]->y;
7666 // determine horizontal offset for leading text
7667 if (textbutton_info[i].text_left != NULL)
7668 x += getTextWidthForGadget(textbutton_info[i].text_left);
7670 gi = CreateGadget(GDI_CUSTOM_ID, id,
7671 GDI_CUSTOM_TYPE_ID, type_id,
7672 GDI_IMAGE_ID, graphic,
7673 GDI_INFO_TEXT, infotext,
7676 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
7677 GDI_TEXT_VALUE, textbutton_info[i].text,
7678 GDI_TEXT_SIZE, textbutton_info[i].size,
7679 GDI_TEXT_FONT, FONT_INPUT_2,
7680 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
7681 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7682 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7683 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7684 GDI_BORDER_SIZE, border_xsize, border_ysize,
7685 GDI_DESIGN_WIDTH, gd->width,
7686 GDI_DECORATION_SHIFTING, 1, 1,
7687 GDI_EVENT_MASK, event_mask,
7688 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7689 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7693 Fail("cannot create gadget");
7695 level_editor_gadget[id] = gi;
7696 right_gadget_border[id] =
7697 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7701 static void CreateGraphicbuttonGadgets(void)
7703 struct GadgetInfo *gi;
7706 // create buttons for scrolling of drawing area and element list
7707 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7709 int id = graphicbutton_info[i].gadget_id;
7710 int type_id = graphicbutton_info[i].gadget_type_id;
7711 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7712 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7713 int graphic = graphicbutton_info[i].graphic;
7714 struct GraphicInfo *gd = &graphic_info[graphic];
7715 int gd_x1 = gd->src_x;
7716 int gd_y1 = gd->src_y;
7717 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7718 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7719 unsigned int event_mask = GD_EVENT_RELEASED;
7722 Fail("'graphicbutton_info' structure corrupted at index %d -- please fix", i);
7724 // determine horizontal position to the right of specified gadget
7725 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7726 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7727 ED_GADGET_TEXT_DISTANCE);
7729 // determine horizontal offset for leading text
7730 if (graphicbutton_info[i].text_left != NULL)
7731 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7733 gi = CreateGadget(GDI_CUSTOM_ID, id,
7734 GDI_CUSTOM_TYPE_ID, type_id,
7735 GDI_IMAGE_ID, graphic,
7736 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7739 GDI_WIDTH, gd->width,
7740 GDI_HEIGHT, gd->height,
7741 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7742 GDI_STATE, GD_BUTTON_UNPRESSED,
7743 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7744 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7745 GDI_EVENT_MASK, event_mask,
7746 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7747 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7751 Fail("cannot create gadget");
7753 level_editor_gadget[id] = gi;
7754 right_gadget_border[id] =
7755 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7759 static void CreateScrollbarGadgets(void)
7763 // these values are not constant, but can change at runtime
7764 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7765 SX + ED_SCROLL_HORIZONTAL_XPOS;
7766 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7767 SY + ED_SCROLL_HORIZONTAL_YPOS;
7768 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7769 ED_SCROLL_HORIZONTAL_XSIZE;
7770 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7771 ED_SCROLL_HORIZONTAL_YSIZE;
7772 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7773 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7774 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7775 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7777 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7778 SX + ED_SCROLL_VERTICAL_XPOS;
7779 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7780 SY + ED_SCROLL_VERTICAL_YPOS;
7781 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7782 ED_SCROLL_VERTICAL_XSIZE;
7783 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7784 ED_SCROLL_VERTICAL_YSIZE;
7785 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7786 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7787 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7788 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7790 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7791 PX + ED_SCROLL2_VERTICAL_XPOS;
7792 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7793 PY + ED_SCROLL2_VERTICAL_YPOS;
7794 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7795 ED_SCROLL2_VERTICAL_XSIZE;
7796 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7797 ED_SCROLL2_VERTICAL_YSIZE;
7798 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7799 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7800 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7801 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7803 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7805 int id = scrollbar_info[i].gadget_id;
7806 int type_id = scrollbar_info[i].gadget_type_id;
7807 int graphic = scrollbar_info[i].graphic;
7808 struct GraphicInfo *gd = &graphic_info[graphic];
7809 int gd_x1 = gd->src_x;
7810 int gd_y1 = gd->src_y;
7811 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7812 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7813 struct GadgetInfo *gi;
7814 int items_max, items_visible, item_position;
7815 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7818 Fail("'scrollbar_info' structure corrupted at index %d -- please fix", i);
7820 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7822 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7823 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7824 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7826 else // drawing area scrollbars
7828 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7830 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7831 items_visible = ed_fieldx;
7836 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7837 items_visible = ed_fieldy;
7842 gi = CreateGadget(GDI_CUSTOM_ID, id,
7843 GDI_CUSTOM_TYPE_ID, type_id,
7844 GDI_IMAGE_ID, graphic,
7845 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7846 GDI_X, scrollbar_pos[i].x,
7847 GDI_Y, scrollbar_pos[i].y,
7848 GDI_WIDTH, scrollbar_pos[i].width,
7849 GDI_HEIGHT, scrollbar_pos[i].height,
7850 GDI_TYPE, scrollbar_info[i].type,
7851 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7852 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7853 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7854 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7855 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7856 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7857 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7858 GDI_STATE, GD_BUTTON_UNPRESSED,
7859 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7860 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7861 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7862 GDI_EVENT_MASK, event_mask,
7863 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7864 GDI_CALLBACK_ACTION, HandleControlButtons,
7868 Fail("cannot create gadget");
7870 level_editor_gadget[id] = gi;
7874 static void CreateCheckbuttonGadgets(void)
7876 struct GadgetInfo *gi;
7879 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7881 int id = checkbutton_info[i].gadget_id;
7882 int type_id = checkbutton_info[i].gadget_type_id;
7883 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7884 IMG_EDITOR_CHECKBOX);
7885 struct GraphicInfo *gd = &graphic_info[graphic];
7886 int gd_x1 = gd->src_x;
7887 int gd_y1 = gd->src_y;
7888 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7889 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7890 int gd_x1a = gd->src_x + gd->active_xoffset;
7891 int gd_y1a = gd->src_y + gd->active_yoffset;
7892 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7893 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7894 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7895 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7896 unsigned int event_mask = GD_EVENT_PRESSED;
7899 Fail("'checkbutton_info' structure corrupted at index %d -- please fix", i);
7901 // determine horizontal position to the right of specified gadget
7902 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7903 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7904 ED_GADGET_TEXT_DISTANCE);
7906 // determine horizontal offset for leading text
7907 if (checkbutton_info[i].text_left != NULL)
7908 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7910 gi = CreateGadget(GDI_CUSTOM_ID, id,
7911 GDI_CUSTOM_TYPE_ID, type_id,
7912 GDI_IMAGE_ID, graphic,
7913 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7916 GDI_WIDTH, gd->width,
7917 GDI_HEIGHT, gd->height,
7918 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7919 GDI_CHECKED, *checkbutton_info[i].value,
7920 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7921 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7922 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7923 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7924 GDI_EVENT_MASK, event_mask,
7925 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7926 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7930 Fail("cannot create gadget");
7932 level_editor_gadget[id] = gi;
7933 right_gadget_border[id] =
7934 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7938 static void CreateRadiobuttonGadgets(void)
7940 int graphic = IMG_EDITOR_RADIOBUTTON;
7941 struct GraphicInfo *gd = &graphic_info[graphic];
7942 int gd_x1 = gd->src_x;
7943 int gd_y1 = gd->src_y;
7944 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7945 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7946 int gd_x1a = gd->src_x + gd->active_xoffset;
7947 int gd_y1a = gd->src_y + gd->active_yoffset;
7948 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7949 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7950 struct GadgetInfo *gi;
7953 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7955 int id = radiobutton_info[i].gadget_id;
7956 int type_id = radiobutton_info[i].gadget_type_id;
7957 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7958 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7959 unsigned int event_mask = GD_EVENT_PRESSED;
7962 Fail("'radiobutton_info' structure corrupted at index %d -- please fix", i);
7965 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7967 // determine horizontal position to the right of specified gadget
7968 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7969 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7970 ED_GADGET_TEXT_DISTANCE);
7972 // determine horizontal offset for leading text
7973 if (radiobutton_info[i].text_left != NULL)
7974 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7976 gi = CreateGadget(GDI_CUSTOM_ID, id,
7977 GDI_CUSTOM_TYPE_ID, type_id,
7978 GDI_IMAGE_ID, graphic,
7979 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7982 GDI_WIDTH, gd->width,
7983 GDI_HEIGHT, gd->height,
7984 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7985 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7986 GDI_CHECKED, checked,
7987 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7988 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7989 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7990 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7991 GDI_EVENT_MASK, event_mask,
7992 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7993 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7997 Fail("cannot create gadget");
7999 level_editor_gadget[id] = gi;
8000 right_gadget_border[id] =
8001 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
8005 void CreateLevelEditorGadgets(void)
8007 // force EDITOR font inside level editor
8008 SetFontStatus(GAME_MODE_EDITOR);
8010 // these values are not constant, but can change at runtime
8011 ed_fieldx = MAX_ED_FIELDX - 1;
8012 ed_fieldy = MAX_ED_FIELDY - 1;
8014 num_editor_gadgets = NUM_EDITOR_GADGETS;
8016 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
8018 level_editor_gadget =
8019 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
8020 right_gadget_border =
8021 checked_calloc(num_editor_gadgets * sizeof(int));
8023 // set number of empty (padding) element buttons to maximum number of buttons
8024 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
8026 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
8027 editor_el_empty_ptr = editor_el_empty;
8029 use_permanent_palette = !editor.palette.show_as_separate_screen;
8031 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
8033 ReinitializeElementList();
8035 CreateControlButtons();
8036 CreateScrollbarGadgets();
8038 // order of function calls is important because of cross-references
8039 CreateCheckbuttonGadgets();
8040 CreateCounterButtons();
8041 CreateRadiobuttonGadgets();
8042 CreateTextInputGadgets();
8043 CreateTextAreaGadgets();
8044 CreateSelectboxGadgets();
8045 CreateGraphicbuttonGadgets();
8046 CreateTextbuttonGadgets();
8047 CreateDrawingAreas();
8052 void FreeLevelEditorGadgets(void)
8056 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
8058 for (i = 0; i < num_editor_gadgets; i++)
8060 FreeGadget(level_editor_gadget[i]);
8062 level_editor_gadget[i] = NULL;
8065 checked_free(level_editor_gadget);
8066 checked_free(right_gadget_border);
8068 checked_free(editor_el_empty);
8071 static void MapCounterButtons(int id)
8073 int font_nr = FONT_TEXT_1;
8074 int font_height = getFontHeight(font_nr);
8075 int gadget_id_down = counterbutton_info[id].gadget_id_down;
8076 int gadget_id_text = counterbutton_info[id].gadget_id_text;
8077 int gadget_id_up = counterbutton_info[id].gadget_id_up;
8078 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
8079 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
8080 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8081 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
8082 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8083 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8084 int yoffset = (gi_down->height - font_height) / 2;
8085 int x_left = gi_down->x - xoffset_left;
8086 int x_right; // set after gadget position was modified
8087 int y_above = gi_down->y - yoffset_above;
8089 int y; // set after gadget position was modified
8091 // counter limits must be changed first to prevent value truncation
8092 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
8093 counterbutton_info[id].max_value);
8095 // right text position might have changed after setting position above
8096 x_right = gi_up->x + gi_up->width + xoffset_right;
8098 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
8100 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
8101 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
8102 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
8104 ModifyGadget(gi_down, GDI_Y,
8105 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8106 ModifyGadget(gi_text, GDI_Y,
8107 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8108 ModifyGadget(gi_up, GDI_Y,
8109 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8112 // vertical position might have changed after setting position above
8113 y = gi_up->y + yoffset;
8115 if (counterbutton_info[id].text_above)
8116 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
8118 if (counterbutton_info[id].text_left)
8119 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
8121 if (counterbutton_info[id].text_right)
8122 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
8129 static void MapControlButtons(void)
8134 // map toolbox buttons (excluding special CE toolbox buttons)
8135 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
8136 MapGadget(level_editor_gadget[i]);
8138 // map toolbox buttons (element properties buttons)
8139 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
8140 MapGadget(level_editor_gadget[i]);
8142 if (use_permanent_palette)
8144 // map buttons to select elements
8145 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8146 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
8147 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
8148 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
8149 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
8152 // map buttons to select level
8153 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
8154 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
8155 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
8156 MapCounterButtons(counter_id);
8159 static void MapDrawingArea(int id)
8161 int font_nr = FONT_TEXT_1;
8162 int font_height = getFontHeight(font_nr);
8163 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8164 int area_xsize = gi->drawing.area_xsize;
8165 int area_ysize = gi->drawing.area_ysize;
8166 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8167 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
8168 int x_left = gi->x - xoffset_left;
8169 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
8170 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
8171 int x_below = gi->x + (gi->width - xoffset_below) / 2;
8172 int y_side = gi->y + (gi->height - font_height) / 2;
8173 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
8174 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
8176 if (drawingarea_info[id].text_left)
8177 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
8179 if (drawingarea_info[id].text_right)
8180 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
8182 if (drawingarea_info[id].text_above)
8183 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
8185 if (drawingarea_info[id].text_below)
8186 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
8188 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
8190 DrawElementBorder(gi->x, gi->y,
8191 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
8192 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
8194 DrawDrawingArea(id);
8200 static void MapTextInputGadget(int id)
8202 int font_nr = FONT_TEXT_1;
8203 int font_height = getFontHeight(font_nr);
8204 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
8205 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8206 int x_above = ED_SETTINGS_X(textinput_info[id].x);
8207 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
8209 if (textinput_info[id].text_above)
8210 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
8212 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
8217 static void MapTextAreaGadget(int id)
8219 int font_nr = FONT_TEXT_1;
8220 int font_height = getFontHeight(font_nr);
8221 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8222 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8223 int x_above = ED_SETTINGS_X(textarea_info[id].x);
8224 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
8225 char *text_above = textarea_info[id].text_above;
8227 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
8228 text_above = textarea_info[id].text_above_cropped;
8231 DrawTextS(x_above, y_above, font_nr, text_above);
8233 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
8238 static void MapSelectboxGadget(int id)
8240 int font_nr = FONT_TEXT_1;
8241 int font_height = getFontHeight(font_nr);
8242 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
8243 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
8244 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8245 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8246 int yoffset = (gi->height - font_height) / 2;
8247 int x_left = gi->x - xoffset_left;
8248 int x_right = gi->x + gi->width + xoffset_right;
8249 int y_above = gi->y - yoffset_above;
8251 int y = gi->y + yoffset;
8253 if (selectbox_info[id].text_above)
8254 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
8256 if (selectbox_info[id].text_left)
8257 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
8259 if (selectbox_info[id].text_right)
8260 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
8262 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
8267 static void MapTextbuttonGadget(int id)
8269 int font_nr = FONT_TEXT_1;
8270 int font_height = getFontHeight(font_nr);
8271 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
8272 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
8273 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8274 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8275 int yoffset = (gi->height - font_height) / 2;
8276 int x_left = gi->x - xoffset_left;
8277 int x_right = gi->x + gi->width + xoffset_right;
8278 int y_above = gi->y - yoffset_above;
8280 int y = gi->y + yoffset;
8282 // only show button to delete change pages when more than minimum pages
8283 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
8284 custom_element.num_change_pages == MIN_CHANGE_PAGES)
8287 if (textbutton_info[id].text_above)
8288 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
8290 if (textbutton_info[id].text_left)
8291 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
8293 if (textbutton_info[id].text_right)
8294 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
8299 static void MapGraphicbuttonGadget(int id)
8301 int font_nr = FONT_TEXT_1;
8302 int font_height = getFontHeight(font_nr);
8303 struct GadgetInfo *gi = level_editor_gadget[graphicbutton_info[id].gadget_id];
8304 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
8305 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8306 int yoffset = (gi->height - font_height) / 2;
8307 int x_left = gi->x - xoffset_left;
8308 int x_right = gi->x + gi->width + xoffset_right;
8309 int y = gi->y + yoffset;
8311 if (graphicbutton_info[id].text_left)
8312 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
8314 if (graphicbutton_info[id].text_right)
8315 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
8320 static void MapRadiobuttonGadget(int id)
8322 int font_nr = FONT_TEXT_1;
8323 int font_height = getFontHeight(font_nr);
8324 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
8325 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8326 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8327 int yoffset = (gi->height - font_height) / 2;
8328 int x_left = gi->x - xoffset_left;
8329 int x_right = gi->x + gi->width + xoffset_right;
8330 int y = gi->y + yoffset;
8332 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
8334 if (radiobutton_info[id].text_left)
8335 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
8337 if (radiobutton_info[id].text_right)
8338 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
8340 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
8345 static void MapCheckbuttonGadget(int id)
8347 int font_nr = FONT_TEXT_1;
8348 int font_height = getFontHeight(font_nr);
8349 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
8350 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8351 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8352 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8353 int yoffset = (gi->height - font_height) / 2;
8354 int y_above = gi->y - yoffset_above;
8356 int x_left, x_right, y; // set after gadget position was modified
8358 // set position for gadgets with dynamically determined position
8359 if (checkbutton_info[id].x != -1) // do not change dynamic positions
8360 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x), GDI_END);
8361 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
8363 x_left = gi->x - xoffset_left;
8364 x_right = gi->x + gi->width + xoffset_right;
8365 y = gi->y + yoffset;
8367 if (checkbutton_info[id].text_above)
8368 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
8370 if (checkbutton_info[id].text_left)
8371 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
8373 if (checkbutton_info[id].text_right)
8374 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
8376 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
8381 static void MapMainDrawingArea(void)
8383 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
8384 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
8387 if (suppressBorderElement())
8389 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
8390 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
8393 for (i = ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
8395 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
8396 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
8397 no_horizontal_scrollbar) ||
8398 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
8399 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
8400 no_vertical_scrollbar))
8403 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
8406 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
8408 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
8409 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
8412 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
8415 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
8418 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
8422 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
8424 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
8425 i == GADGET_ID_CUSTOM_COPY_TO ||
8426 i == GADGET_ID_CUSTOM_EXCHANGE ||
8427 i == GADGET_ID_CUSTOM_COPY ||
8428 i == GADGET_ID_CUSTOM_PASTE)
8431 MapGadget(level_editor_gadget[i]);
8433 UnmapGadget(level_editor_gadget[i]);
8438 static void MapLevelEditorToolboxCustomGadgets(void)
8440 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
8443 static void MapLevelEditorToolboxCustomGadgetsIfNeeded(void)
8445 if (IS_CUSTOM_ELEMENT(properties_element) ||
8446 IS_GROUP_ELEMENT(properties_element) ||
8447 IS_EMPTY_ELEMENT(properties_element))
8448 MapLevelEditorToolboxCustomGadgets();
8451 static void UnmapLevelEditorToolboxCustomGadgets(void)
8453 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
8456 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
8460 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
8462 if (i != GADGET_ID_SINGLE_ITEMS &&
8463 i != GADGET_ID_PICK_ELEMENT)
8465 struct GadgetInfo *gi = level_editor_gadget[i];
8473 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
8474 struct GraphicInfo *gd = &graphic_info[graphic];
8478 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
8479 gi->width, gi->height, gi->x, gi->y);
8481 redraw_mask |= REDRAW_DOOR_3;
8487 static void MapLevelEditorToolboxDrawingGadgets(void)
8489 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
8492 static void UnmapLevelEditorToolboxDrawingGadgets(void)
8494 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
8497 static void UnmapDrawingArea(int id)
8499 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
8502 static void UnmapLevelEditorFieldGadgets(void)
8506 for (i = 0; i < num_editor_gadgets; i++)
8507 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
8508 level_editor_gadget[i]->y))
8509 UnmapGadget(level_editor_gadget[i]);
8512 void UnmapLevelEditorGadgets(void)
8516 for (i = 0; i < num_editor_gadgets; i++)
8517 UnmapGadget(level_editor_gadget[i]);
8520 static void ResetUndoBuffer(void)
8522 undo_buffer_position = -1;
8523 undo_buffer_steps = -1;
8524 redo_buffer_steps = 0;
8526 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8528 level.changed = FALSE;
8531 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
8533 if (remap_toolbox_gadgets)
8535 ModifyEditorElementList();
8536 RedrawDrawingElements();
8539 if (edit_mode == ED_MODE_LEVELCONFIG)
8540 DrawLevelConfigWindow();
8541 else if (edit_mode == ED_MODE_PROPERTIES)
8542 DrawPropertiesWindow();
8543 else if (edit_mode == ED_MODE_PALETTE)
8544 DrawPaletteWindow();
8545 else // edit_mode == ED_MODE_DRAWING
8546 DrawDrawingWindowExt(remap_toolbox_gadgets);
8549 static void DrawEditModeWindow(void)
8551 DrawEditModeWindowExt(TRUE);
8554 static void DrawEditModeWindow_PlayfieldOnly(void)
8556 DrawEditModeWindowExt(FALSE);
8559 static void ChangeEditModeWindow(int new_edit_mode)
8561 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
8563 DrawEditModeWindow();
8566 static boolean LevelChanged(void)
8568 boolean field_changed = FALSE;
8571 for (y = 0; y < lev_fieldy; y++)
8572 for (x = 0; x < lev_fieldx; x++)
8573 if (Tile[x][y] != level.field[x][y])
8574 field_changed = TRUE;
8576 return (level.changed || field_changed);
8579 static boolean PrepareSavingIntoPersonalLevelSet(void)
8581 static LevelDirTree *last_copied_leveldir = NULL;
8582 static LevelDirTree *last_written_leveldir = NULL;
8583 static int last_copied_level_nr = -1;
8584 static int last_written_level_nr = -1;
8585 LevelDirTree *leveldir_former = leveldir_current;
8586 int level_nr_former = level_nr;
8589 // remember last mod/save so that for current session, we write
8590 // back to the same personal copy, asking only about overwrite.
8591 if (leveldir_current == last_copied_leveldir &&
8592 level_nr == last_copied_level_nr)
8594 // "cd" to personal level set dir (as used when writing last copy)
8595 leveldir_current = last_written_leveldir;
8596 level_nr = last_written_level_nr;
8601 if (!Request("This level is read-only! "
8602 "Save into personal level set?", REQ_ASK))
8605 // "cd" to personal level set dir (for writing copy the first time)
8607 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
8609 // this may happen if "setup.internal.create_user_levelset" is FALSE
8610 // or if file "levelinfo.conf" is missing in personal user level set
8611 if (leveldir_current == NULL)
8613 Request("Cannot find personal level set?!", REQ_CONFIRM);
8615 leveldir_current = leveldir_former;
8620 // find unused level number
8621 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
8623 static char *level_filename = NULL;
8625 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
8627 if (!fileExists(level_filename))
8631 last_copied_leveldir = leveldir_former;
8632 last_copied_level_nr = level_nr_former;
8634 last_written_leveldir = leveldir_current;
8635 last_written_level_nr = level_nr = new_level_nr;
8640 static void ModifyLevelConfigForSavingIntoPersonalLevelSet(char *former_name)
8642 static char *filename_levelinfo = NULL, *mod_name = NULL;
8645 // annotate this copy-and-mod in personal levelinfo.conf
8646 setString(&filename_levelinfo,
8647 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
8649 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
8651 fprintf(file, "\n");
8652 fprintf(file, "# level %d was modified from:\n", level_nr);
8653 fprintf(file, "# - previous level set name: %s\n",
8655 fprintf(file, "# - level within previous set: %d \"%s\"\n",
8656 level.file_info.nr, level.name);
8657 fprintf(file, "# - previous author: %s\n",
8659 fprintf(file, "# - previous save date: ");
8661 if (level.creation_date.src == DATE_SRC_LEVELFILE)
8663 fprintf(file, "%04d-%02d-%02d\n",
8664 level.creation_date.year,
8665 level.creation_date.month,
8666 level.creation_date.day);
8670 fprintf(file, "not recorded\n");
8676 if (level_nr > leveldir_current->last_level)
8677 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
8679 // else: allow the save even if annotation failed
8681 // now... spray graffiti on the old level vital statistics
8682 // user can change these; just trying to set a good baseline
8684 // don't truncate names for fear of making offensive or silly:
8685 // long-named original author only recorded in levelinfo.conf.
8686 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
8687 if (!strEqual(level.author, leveldir_current->author))
8689 setString(&mod_name, getStringCat3(leveldir_current->author,
8690 " after ", level.author));
8692 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8693 setString(&mod_name,
8694 getStringCat2(leveldir_current->author, " (ed.)"));
8696 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8697 setString(&mod_name, leveldir_current->author);
8699 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
8701 // less worried about truncation here
8702 setString(&mod_name, getStringCat2("Mod: ", level.name));
8703 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
8707 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
8708 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8712 for (x = 0; x < lev_fieldx; x++)
8713 for (y = 0; y < lev_fieldy; y++)
8714 dst[x][y] = src[x][y];
8717 static int setSelectboxValue(int selectbox_id, int new_value)
8719 int new_index_value = 0;
8722 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8723 if (selectbox_info[selectbox_id].options[i].value == new_value)
8724 new_index_value = i;
8726 *selectbox_info[selectbox_id].value =
8727 selectbox_info[selectbox_id].options[new_index_value].value;
8729 return new_index_value;
8732 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8736 // change action mode and arg variables according to action type variable
8737 for (i = 0; action_arg_options[i].value != -1; i++)
8739 if (action_arg_options[i].value == custom_element_change.action_type)
8741 int mode = action_arg_options[i].mode;
8743 // only change if corresponding selectbox has changed
8744 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8745 action_arg_modes[mode])
8746 custom_element_change.action_mode = -1;
8748 // only change if corresponding selectbox has changed
8749 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8750 action_arg_options[i].options)
8751 custom_element_change.action_arg = -1;
8758 static void setSelectboxSpecialActionOptions(void)
8762 // change action mode and arg selectbox according to action type selectbox
8763 for (i = 0; action_arg_options[i].value != -1; i++)
8765 if (action_arg_options[i].value == custom_element_change.action_type)
8767 int mode = action_arg_options[i].mode;
8769 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8770 action_arg_modes[mode]);
8771 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8772 custom_element_change.action_mode);
8774 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8775 action_arg_options[i].options);
8776 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8777 custom_element_change.action_arg);
8783 static void copy_custom_element_settings(int element_from, int element_to)
8785 struct ElementInfo *ei_from = &element_info[element_from];
8786 struct ElementInfo *ei_to = &element_info[element_to];
8788 copyElementInfo(ei_from, ei_to);
8791 static void replace_custom_element_in_settings(int element_from,
8796 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8798 struct ElementInfo *ei = &element_info[i];
8800 for (y = 0; y < 3; y++)
8801 for (x = 0; x < 3; x++)
8802 if (ei->content.e[x][y] == element_from)
8803 ei->content.e[x][y] = element_to;
8805 for (j = 0; j < ei->num_change_pages; j++)
8807 struct ElementChangeInfo *change = &ei->change_page[j];
8809 if (change->target_element == element_from)
8810 change->target_element = element_to;
8812 if (change->initial_trigger_element == element_from)
8813 change->initial_trigger_element = element_to;
8815 if (change->action_element == element_from)
8816 change->action_element = element_to;
8818 for (y = 0; y < 3; y++)
8819 for (x = 0; x < 3; x++)
8820 if (change->target_content.e[x][y] == element_from)
8821 change->target_content.e[x][y] = element_to;
8824 if (ei->group != NULL) // group or internal
8825 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8826 if (ei->group->element[j] == element_from)
8827 ei->group->element[j] = element_to;
8831 static void replace_custom_element_in_playfield(int element_from,
8836 for (x = 0; x < lev_fieldx; x++)
8837 for (y = 0; y < lev_fieldy; y++)
8838 if (Tile[x][y] == element_from)
8839 Tile[x][y] = element_to;
8842 static boolean CopyCustomElement(int element_old, int element_new,
8845 int copy_mode_orig = copy_mode;
8847 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8849 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8850 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8851 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8853 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8855 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8856 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8857 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8859 level.changed = TRUE;
8861 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8863 Request("Please choose custom element!", REQ_CONFIRM);
8867 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8869 Request("Please choose group element!", REQ_CONFIRM);
8873 else if (IS_EMPTY_ELEMENT(element_old) && !IS_EMPTY_ELEMENT(element_new))
8875 Request("Please choose empty element!", REQ_CONFIRM);
8881 level.changed = TRUE;
8884 // when modifying custom/group element, ask for copying level template
8885 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8887 if (!AskToCopyAndModifyLevelTemplate())
8891 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8893 copy_custom_element_settings(element_new, element_old);
8895 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8897 copy_custom_element_settings(element_old, element_new);
8899 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8901 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8902 copy_custom_element_settings(element_new, element_old);
8903 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8905 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8906 replace_custom_element_in_settings(element_new, element_old);
8907 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8909 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8910 replace_custom_element_in_playfield(element_new, element_old);
8911 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8914 UpdateCustomElementGraphicGadgets();
8915 DrawPropertiesWindow();
8920 static void CopyCustomElementPropertiesToEditor(int element)
8923 int current_change_page = element_info[element].current_change_page;
8925 // dynamically (re)build selectbox for selecting change page
8926 for (i = 0; i < element_info[element].num_change_pages; i++)
8928 sprintf(options_change_page_strings[i], "%d", i + 1);
8930 options_change_page[i].value = i;
8931 options_change_page[i].text = options_change_page_strings[i];
8934 options_change_page[i].value = -1;
8935 options_change_page[i].text = NULL;
8937 // needed here to initialize combined element properties
8938 InitElementPropertiesEngine(level.game_version);
8940 element_info[element].change =
8941 &element_info[element].change_page[current_change_page];
8943 custom_element = element_info[element];
8944 custom_element_change = *element_info[element].change;
8946 // needed to initially set selectbox options for special action options
8947 setSelectboxSpecialActionOptions();
8949 // needed to initially set selectbox value variables to reliable defaults
8950 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8951 setSelectboxValue(i, *selectbox_info[i].value);
8953 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8954 custom_element_properties[i] = HAS_PROPERTY(element, i);
8956 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8957 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8959 // ---------- element settings: configure (custom elements) -----------------
8961 // set accessible layer selectbox help value
8962 custom_element.access_type =
8963 (IS_WALKABLE(element) ? EP_WALKABLE :
8964 IS_PASSABLE(element) ? EP_PASSABLE :
8965 custom_element.access_type);
8966 custom_element.access_layer =
8967 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8968 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8969 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8970 custom_element.access_layer);
8971 custom_element.access_protected =
8972 (IS_PROTECTED(element) ? 1 : 0);
8973 custom_element_properties[EP_ACCESSIBLE] =
8974 (IS_ACCESSIBLE_OVER(element) ||
8975 IS_ACCESSIBLE_INSIDE(element) ||
8976 IS_ACCESSIBLE_UNDER(element));
8978 // set walk-to-object action selectbox help value
8979 custom_element.walk_to_action =
8980 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8981 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8982 IS_DROPPABLE(element) ? EP_DROPPABLE :
8983 IS_THROWABLE(element) ? EP_THROWABLE :
8984 IS_PUSHABLE(element) ? EP_PUSHABLE :
8985 custom_element.walk_to_action);
8986 custom_element_properties[EP_WALK_TO_OBJECT] =
8987 (IS_DIGGABLE(element) ||
8988 IS_COLLECTIBLE_ONLY(element) ||
8989 IS_DROPPABLE(element) ||
8990 IS_THROWABLE(element) ||
8991 IS_PUSHABLE(element));
8993 // set smash targets selectbox help value
8994 custom_element.smash_targets =
8995 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8996 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8997 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8998 custom_element.smash_targets);
8999 custom_element_properties[EP_CAN_SMASH] =
9000 (CAN_SMASH_EVERYTHING(element) ||
9001 CAN_SMASH_ENEMIES(element) ||
9002 CAN_SMASH_PLAYER(element));
9004 // set deadliness selectbox help value
9005 custom_element.deadliness =
9006 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
9007 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
9008 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
9009 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
9010 custom_element.deadliness);
9011 custom_element_properties[EP_DEADLY] =
9012 (DONT_TOUCH(element) ||
9013 DONT_GET_HIT_BY(element) ||
9014 DONT_COLLIDE_WITH(element) ||
9015 DONT_RUN_INTO(element));
9017 // ---------- element settings: advanced (custom elements) ------------------
9019 // set "change by direct action" selectbox help value
9020 custom_element_change.direct_action =
9021 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
9022 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
9023 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
9024 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
9025 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
9026 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
9027 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
9028 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
9029 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
9030 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
9031 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
9032 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
9033 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
9034 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
9035 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
9036 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
9037 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
9038 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
9039 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
9040 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
9041 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
9042 custom_element_change.direct_action);
9044 // set "change by other element action" selectbox help value
9045 custom_element_change.other_action =
9046 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
9047 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
9048 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
9049 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
9050 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
9051 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
9052 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
9053 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
9054 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
9055 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
9056 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
9057 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
9058 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
9059 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
9060 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
9061 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
9062 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
9063 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
9064 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
9065 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
9066 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
9067 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
9068 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
9069 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
9070 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
9071 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
9072 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
9073 custom_element_change.other_action);
9076 static void CopyGroupElementPropertiesToEditor(int element)
9078 group_element_info = *element_info[element].group;
9079 custom_element = element_info[element]; // needed for description
9082 static void CopyEmptyElementPropertiesToEditor(int element)
9084 custom_element = element_info[element];
9087 static void CopyClassicElementPropertiesToEditor(int element)
9089 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9090 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
9091 getMoveIntoAcidProperty(&level, element);
9093 if (MAYBE_DONT_COLLIDE_WITH(element))
9094 custom_element_properties[EP_DONT_COLLIDE_WITH] =
9095 getDontCollideWithProperty(&level, element);
9098 static void CopyElementPropertiesToEditor(int element)
9100 if (IS_CUSTOM_ELEMENT(element))
9101 CopyCustomElementPropertiesToEditor(element);
9102 else if (IS_GROUP_ELEMENT(element))
9103 CopyGroupElementPropertiesToEditor(element);
9104 else if (IS_EMPTY_ELEMENT(element))
9105 CopyEmptyElementPropertiesToEditor(element);
9107 CopyClassicElementPropertiesToEditor(element);
9110 static boolean AskToCopyAndModifyLevelTemplate(void)
9112 if (Request("Copy and modify settings from level template?", REQ_ASK))
9114 level.use_custom_template = FALSE;
9116 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
9117 GDI_CHECKED, FALSE, GDI_END);
9118 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
9119 GDI_CHECKED, FALSE, GDI_END);
9125 LoadLevelTemplate(-1); // this resets all element modifications ...
9127 DrawEditModeWindow(); // ... and copies them to 'custom_element'
9133 static void CopyCustomElementPropertiesToGame(int element)
9136 int access_type_and_layer;
9138 // mark that this custom element has been modified
9139 custom_element.modified_settings = TRUE;
9140 level.changed = TRUE;
9142 if (level.use_custom_template)
9143 AskToCopyAndModifyLevelTemplate();
9145 element_info[element] = custom_element;
9146 *element_info[element].change = custom_element_change;
9148 // ---------- element settings: configure (custom elements) -----------------
9150 // set accessible property from checkbox and selectbox
9151 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
9152 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
9153 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
9154 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
9155 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
9156 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
9157 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
9158 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
9159 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
9160 custom_element_properties[access_type_and_layer] =
9161 custom_element_properties[EP_ACCESSIBLE];
9162 custom_element_properties[EP_PROTECTED] =
9163 (custom_element.access_protected != 0 &&
9164 custom_element_properties[EP_ACCESSIBLE]);
9166 // set walk-to-object property from checkbox and selectbox
9167 custom_element_properties[EP_DIGGABLE] = FALSE;
9168 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
9169 custom_element_properties[EP_DROPPABLE] = FALSE;
9170 custom_element_properties[EP_THROWABLE] = FALSE;
9171 custom_element_properties[EP_PUSHABLE] = FALSE;
9172 custom_element_properties[custom_element.walk_to_action] =
9173 custom_element_properties[EP_WALK_TO_OBJECT];
9175 // set smash property from checkbox and selectbox
9176 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
9177 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
9178 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
9179 custom_element_properties[custom_element.smash_targets] =
9180 custom_element_properties[EP_CAN_SMASH];
9182 // set deadliness property from checkbox and selectbox
9183 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
9184 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
9185 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
9186 custom_element_properties[EP_DONT_TOUCH] = FALSE;
9187 custom_element_properties[custom_element.deadliness] =
9188 custom_element_properties[EP_DEADLY];
9190 // ---------- element settings: advanced (custom elements) ------------------
9192 // set player change event from checkbox and selectbox
9193 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
9194 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
9195 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
9196 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
9197 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
9198 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
9199 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
9200 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
9201 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
9202 custom_element_change_events[CE_SWITCHED] = FALSE;
9203 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
9204 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
9205 custom_element_change_events[CE_BLOCKED] = FALSE;
9206 custom_element_change_events[CE_IMPACT] = FALSE;
9207 custom_element_change_events[CE_SMASHED] = FALSE;
9208 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
9209 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
9210 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
9211 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
9212 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
9213 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
9214 custom_element_change_events[custom_element_change.direct_action] =
9215 custom_element_change_events[CE_BY_DIRECT_ACTION];
9217 // set other element action change event from checkbox and selectbox
9218 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
9219 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
9220 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
9221 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
9222 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
9223 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
9224 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
9225 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
9226 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
9227 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
9228 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
9229 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
9230 custom_element_change_events[CE_TOUCHING_X] = FALSE;
9231 custom_element_change_events[CE_HITTING_X] = FALSE;
9232 custom_element_change_events[CE_DIGGING_X] = FALSE;
9233 custom_element_change_events[CE_HIT_BY_X] = FALSE;
9234 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
9235 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
9236 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
9237 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
9238 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
9239 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
9240 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
9241 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
9242 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
9243 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
9244 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
9245 custom_element_change_events[custom_element_change.other_action] =
9246 custom_element_change_events[CE_BY_OTHER_ACTION];
9248 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
9249 SET_PROPERTY(element, i, custom_element_properties[i]);
9251 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
9252 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
9254 // copy change events also to special level editor variable
9255 custom_element = element_info[element];
9256 custom_element_change = *element_info[element].change;
9258 // needed here to restore runtime value "element_info[element].gfx_element"
9259 InitElementPropertiesGfxElement();
9262 static void CopyGroupElementPropertiesToGame(int element)
9264 // mark that this group element has been modified
9265 custom_element.modified_settings = TRUE;
9266 level.changed = TRUE;
9268 if (level.use_custom_template)
9269 AskToCopyAndModifyLevelTemplate();
9271 element_info[element] = custom_element;
9272 *element_info[element].group = group_element_info;
9274 // needed here to restore runtime value "element_info[element].gfx_element"
9275 InitElementPropertiesGfxElement();
9278 static void CopyEmptyElementPropertiesToGame(int element)
9280 // mark that this empty element has been modified
9281 custom_element.modified_settings = TRUE;
9282 level.changed = TRUE;
9284 if (level.use_custom_template)
9285 AskToCopyAndModifyLevelTemplate();
9287 element_info[element] = custom_element;
9289 // needed here to restore runtime value "element_info[element].gfx_element"
9290 InitElementPropertiesGfxElement();
9293 static void CopyClassicElementPropertiesToGame(int element)
9295 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9296 setMoveIntoAcidProperty(&level, element,
9297 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
9299 if (MAYBE_DONT_COLLIDE_WITH(element))
9300 setDontCollideWithProperty(&level, element,
9301 custom_element_properties[EP_DONT_COLLIDE_WITH]);
9304 static void CopyElementPropertiesToGame(int element)
9306 if (IS_CUSTOM_ELEMENT(element))
9307 CopyCustomElementPropertiesToGame(element);
9308 else if (IS_GROUP_ELEMENT(element))
9309 CopyGroupElementPropertiesToGame(element);
9310 else if (IS_EMPTY_ELEMENT(element))
9311 CopyEmptyElementPropertiesToGame(element);
9313 CopyClassicElementPropertiesToGame(element);
9317 static void CheckElementDescriptions(void)
9321 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
9322 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
9323 Warn("no element description file for element '%s'", EL_NAME(i));
9327 static int getMaxEdFieldX(boolean has_scrollbar)
9329 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
9330 int sxsize = SXSIZE - scrollbar_width;
9331 int max_ed_fieldx = sxsize / ed_tilesize;
9333 return max_ed_fieldx;
9336 static int getMaxEdFieldY(boolean has_scrollbar)
9338 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
9339 INFOTEXT_YSIZE_FULL : 0);
9340 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
9341 int sysize = SYSIZE - scrollbar_height - infotext_height;
9342 int max_ed_fieldy = sysize / ed_tilesize;
9344 return max_ed_fieldy;
9347 static void InitZoomLevelSettings(int zoom_tilesize)
9349 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
9351 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
9353 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
9354 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
9356 // make sure that tile size is always a power of 2
9357 ed_tilesize = (1 << log_2(ed_tilesize));
9359 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9361 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
9362 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
9366 last_game_engine_type = level.game_engine_type;
9368 // limit zoom tilesize by upper and lower bound
9369 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
9371 // store zoom tilesize in auto setup file only if it was manually changed
9372 if (zoom_tilesize != -1)
9373 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
9375 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
9376 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
9379 static void InitDrawingElements(void)
9381 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
9383 if (level.game_engine_type == game_engine_type_last)
9386 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9388 new_element1 = EL_BD_WALL;
9389 new_element2 = EL_EMPTY;
9390 new_element3 = EL_BD_SAND;
9392 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
9394 new_element1 = EL_SP_CHIP_SINGLE;
9395 new_element2 = EL_EMPTY;
9396 new_element3 = EL_SP_BASE;
9398 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9400 new_element1 = EL_MM_MIRROR_START;
9401 new_element2 = EL_EMPTY;
9402 new_element3 = EL_MM_WOODEN_WALL;
9406 new_element1 = EL_WALL;
9407 new_element2 = EL_EMPTY;
9408 new_element3 = EL_SAND;
9411 game_engine_type_last = level.game_engine_type;
9414 static void InitLevelSetInfo(void)
9416 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
9417 "%s", leveldir_current->name);
9418 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
9419 "%s", leveldir_current->author);
9421 levelset_num_levels = leveldir_current->levels;
9423 levelset_use_levelset_artwork = FALSE;
9424 levelset_copy_level_template = FALSE;
9426 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
9429 static void ChangeEditorToLevelSet(char *levelset_subdir)
9431 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
9433 // the previous level set might have used custom artwork
9434 ReloadCustomArtwork(0);
9436 LoadLevelSetup_SeriesInfo();
9438 SaveLevelSetup_LastSeries();
9439 SaveLevelSetup_SeriesInfo();
9443 LoadLevel(level_nr);
9444 LoadScore(level_nr);
9449 static boolean useEditorDoorAnimation(void)
9451 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
9452 boolean door_1_viewport_unchanged =
9453 (vp_door_1->x == DX &&
9454 vp_door_1->y == DY &&
9455 vp_door_1->width == DXSIZE &&
9456 vp_door_1->height == DYSIZE);
9457 boolean door_1_contains_toolbox =
9460 EX + EXSIZE <= DX + DXSIZE &&
9461 EY + EYSIZE <= DY + DYSIZE);
9463 return (door_1_viewport_unchanged && door_1_contains_toolbox);
9466 static void DrawEditorDoorBackground(int graphic, int x, int y,
9467 int width, int height)
9469 struct GraphicInfo *g = &graphic_info[graphic];
9471 if (g->bitmap != NULL)
9472 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
9473 MIN(width, g->width), MIN(height, g->height), x, y);
9475 ClearRectangle(drawto, x, y, width, height);
9478 static void DrawEditorDoorContent(void)
9480 // needed for gadgets drawn on background (like palette scrollbar)
9481 SetDoorBackgroundImage(IMG_UNDEFINED);
9483 // copy default editor door content to main double buffer
9484 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
9487 DrawSpecialEditorDoor();
9489 // draw new control window
9490 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
9492 // draw all toolbox gadgets to editor doors
9493 MapControlButtons();
9495 // when returning from test game to properties page, redraw toolbox gadgets
9496 if (edit_mode == ED_MODE_PROPERTIES)
9498 UnmapLevelEditorToolboxDrawingGadgets();
9499 UnmapLevelEditorToolboxCustomGadgets();
9501 MapLevelEditorToolboxCustomGadgetsIfNeeded();
9504 // draw all palette gadgets to editor doors
9505 ModifyEditorElementList();
9506 RedrawDrawingElements();
9508 // copy actual editor door content to door double buffer for OpenDoor()
9509 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
9512 void DrawLevelEd(void)
9514 int fade_mask = REDRAW_FIELD;
9516 FadeSoundsAndMusic();
9519 fade_mask = REDRAW_ALL;
9523 // needed if different viewport properties defined for editor
9524 ChangeViewportPropertiesIfNeeded();
9528 InitZoomLevelSettings(-1);
9529 InitDrawingElements();
9533 CheckElementDescriptions();
9536 if (level_editor_test_game)
9538 CopyPlayfield(level.field, Tile);
9539 CopyPlayfield(TileBackup, level.field);
9541 level_editor_test_game = FALSE;
9545 edit_mode = ED_MODE_DRAWING;
9546 edit_mode_levelconfig = ED_MODE_LEVELCONFIG_LEVEL;
9547 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
9555 // redraw_mask |= REDRAW_ALL;
9557 FreeLevelEditorGadgets();
9558 CreateLevelEditorGadgets();
9560 ReinitializeElementList(); // update dynamic level element list
9561 ReinitializeElementListButtons(); // custom element may look different
9563 InitElementPropertiesGfxElement();
9567 DrawEditModeWindow_PlayfieldOnly();
9569 DrawMaskedBorder(fade_mask);
9571 // use door animation if door 1 viewport is unchanged and contains toolbox
9572 if (useEditorDoorAnimation())
9576 DrawEditorDoorContent();
9578 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
9582 DrawEditorDoorContent();
9587 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
9590 static void AdjustDrawingAreaGadgets(void)
9592 int ed_xsize = lev_fieldx + 2;
9593 int ed_ysize = lev_fieldy + 2;
9594 int max_ed_fieldx = MAX_ED_FIELDX;
9595 int max_ed_fieldy = MAX_ED_FIELDY;
9596 boolean horizontal_scrollbar_needed;
9597 boolean vertical_scrollbar_needed;
9598 int x, y, width, height;
9600 if (suppressBorderElement())
9602 ed_xsize = lev_fieldx;
9603 ed_ysize = lev_fieldy;
9606 // check if we need any scrollbars
9607 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9608 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9610 // check if we have a smaller editor field because of scrollbars
9611 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9612 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9614 // check again if we now need more scrollbars because of less space
9615 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9616 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9618 // check if editor field gets even smaller after adding new scrollbars
9619 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9620 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9622 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
9623 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
9625 x = SX + ed_fieldx * ed_tilesize;
9626 y = SY + ed_fieldy * ed_tilesize;
9628 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
9629 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
9631 // adjust drawing area gadget
9632 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
9633 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
9634 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
9637 // adjust horizontal scrollbar gadgets
9638 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
9641 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
9642 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
9645 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9648 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
9651 // adjust vertical scrollbar gadgets
9652 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
9655 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
9657 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
9659 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9662 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
9666 static void AdjustLevelScrollPosition(void)
9668 if (level_xpos < -1)
9670 if (level_xpos > lev_fieldx - ed_fieldx + 1)
9671 level_xpos = lev_fieldx - ed_fieldx + 1;
9672 if (lev_fieldx < ed_fieldx - 2)
9675 if (level_ypos < -1)
9677 if (level_ypos > lev_fieldy - ed_fieldy + 1)
9678 level_ypos = lev_fieldy - ed_fieldy + 1;
9679 if (lev_fieldy < ed_fieldy - 2)
9682 if (suppressBorderElement())
9689 static void AdjustEditorScrollbar(int id)
9691 struct GadgetInfo *gi = level_editor_gadget[id];
9692 int items_max, items_visible, item_position;
9694 if (id == GADGET_ID_SCROLL_HORIZONTAL)
9696 items_max = MAX(lev_fieldx + 2, ed_fieldx);
9697 items_visible = ed_fieldx;
9698 item_position = level_xpos + 1;
9702 items_max = MAX(lev_fieldy + 2, ed_fieldy);
9703 items_visible = ed_fieldy;
9704 item_position = level_ypos + 1;
9707 if (item_position > items_max - items_visible)
9708 item_position = items_max - items_visible;
9710 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9711 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9714 static void AdjustElementListScrollbar(void)
9716 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
9717 int items_max, items_visible, item_position;
9719 // correct position of element list scrollbar
9720 if (element_shift < 0)
9722 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9723 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9725 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
9726 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
9727 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
9729 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9730 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
9731 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9734 static void ModifyEditorCounterValue(int counter_id, int new_value)
9736 int *counter_value = counterbutton_info[counter_id].value;
9737 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9738 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9740 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9742 if (counter_value != NULL)
9743 *counter_value = gi->textinput.number_value;
9746 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9748 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9749 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9751 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9753 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9754 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9756 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9757 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9759 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9760 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9765 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9767 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9768 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9769 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9771 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9774 static void ModifyEditorSelectboxOptions(int selectbox_id,
9775 struct ValueTextInfo *options)
9777 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9778 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9780 selectbox_info[selectbox_id].options = options;
9782 // set index to zero -- list may be shorter now (correct later, if needed)
9783 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9784 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9787 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9789 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9790 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9792 drawingarea_info[drawingarea_id].area_xsize = xsize;
9793 drawingarea_info[drawingarea_id].area_ysize = ysize;
9795 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9798 static void ModifyEditorElementList(void)
9802 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9805 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9807 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9808 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9809 struct GadgetDesign *gd = &gi->deco.design;
9810 int element = editor_elements[element_shift + i];
9811 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9815 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9817 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9823 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9825 int graphic = el2edimg(element);
9826 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9832 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9835 static void ModifyDrawingElementButton(int element, int id)
9837 struct GadgetInfo *gi = level_editor_gadget[id];
9838 Bitmap *deco_bitmap;
9840 int tile_size = gi->deco.width;
9842 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9844 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9847 static void PickDrawingElement(int button, int element)
9852 struct XYTileSize *pos;
9854 } de, drawing_elements[] =
9856 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9857 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9858 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9861 if (button < 1 || button > 3)
9864 if (IS_MM_WALL(element))
9865 element = map_mm_wall_element(element);
9867 de = drawing_elements[button - 1];
9869 *de.new_element = element; // update global drawing element variable
9871 DrawDrawingElementGraphic(element, de.pos);
9872 ModifyDrawingElementButton(element, de.id);
9874 redraw_mask |= REDRAW_DOOR_1;
9877 static void RedrawDrawingElements(void)
9879 PickDrawingElement(1, new_element1);
9880 PickDrawingElement(2, new_element2);
9881 PickDrawingElement(3, new_element3);
9884 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9886 stick_element_properties_window = FALSE;
9888 SetMainBackgroundImage(IMG_UNDEFINED);
9891 UnmapLevelEditorFieldGadgets();
9893 AdjustDrawingAreaGadgets();
9894 AdjustLevelScrollPosition();
9895 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9896 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9898 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9900 MapMainDrawingArea();
9902 if (remap_toolbox_gadgets)
9904 UnmapLevelEditorToolboxCustomGadgets();
9905 MapLevelEditorToolboxDrawingGadgets();
9909 static void DrawDrawingWindow(void)
9911 DrawDrawingWindowExt(TRUE);
9914 static int getTabulatorBarWidth(void)
9916 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9917 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9919 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9922 static int getTabulatorBarHeight(void)
9924 return ED_TAB_BAR_HEIGHT;
9927 static Pixel getTabulatorBarColor(void)
9929 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9930 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9931 int gd_x = gd->x + gd_gi1->border.width / 2;
9932 int gd_y = gd->y + gd_gi1->height - 1;
9934 return GetPixel(gd->bitmap, gd_x, gd_y);
9937 static void DrawLevelConfigTabulatorGadgets(void)
9939 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9940 Pixel tab_color = getTabulatorBarColor();
9941 int id_first = ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL;
9942 int id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR;
9945 // draw additional "engine" tabulator when using native BD engine
9946 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9947 id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE;
9949 for (i = id_first; i <= id_last; i++)
9951 int gadget_id = textbutton_info[i].gadget_id;
9952 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9953 boolean active = (i != edit_mode_levelconfig);
9955 // draw background line below tabulator button
9956 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9958 // draw solid line below inactive tabulator buttons
9959 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9960 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9961 ED_GADGET_TINY_DISTANCE, tab_color);
9963 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9964 MapTextbuttonGadget(i);
9967 // draw little border line below tabulator buttons
9968 if (tab_color != BLACK_PIXEL) // black => transparent
9969 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9970 ED_GADGET_TINY_DISTANCE,
9971 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9974 static void DrawPropertiesTabulatorGadgets(void)
9976 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9977 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9978 int gd_x = gd->x + gd_gi1->border.width / 2;
9979 int gd_y = gd->y + gd_gi1->height - 1;
9980 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9981 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9982 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9985 // draw two config tabulators for player elements
9986 if (IS_PLAYER_ELEMENT(properties_element))
9987 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9989 // draw two config and one "change" tabulator for custom elements
9990 if (IS_CUSTOM_ELEMENT(properties_element))
9991 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9993 for (i = id_first; i <= id_last; i++)
9995 int gadget_id = textbutton_info[i].gadget_id;
9996 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9997 boolean active = (i != edit_mode_properties);
9999 // use "config 1" and "config 2" instead of "config" for players and CEs
10000 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
10001 (IS_PLAYER_ELEMENT(properties_element) ||
10002 IS_CUSTOM_ELEMENT(properties_element)))
10005 // draw background line below tabulator button
10006 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
10008 // draw solid line below inactive tabulator buttons
10009 if (!active && tab_color != BLACK_PIXEL) // black => transparent
10010 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
10011 ED_GADGET_TINY_DISTANCE, tab_color);
10013 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
10014 MapTextbuttonGadget(i);
10017 // draw little border line below tabulator buttons
10018 if (tab_color != BLACK_PIXEL) // black => transparent
10019 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
10020 ED_GADGET_TINY_DISTANCE,
10021 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10024 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
10026 DrawText(SX + xpos, SY + ypos, text, font_nr);
10029 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
10030 int xpos, int ypos)
10032 int font_width = getFontWidth(font_nr);
10033 int font_height = getFontHeight(font_nr);
10034 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
10035 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
10037 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
10038 max_chars_per_line, -1, max_lines_drawable, 0, -1,
10039 TRUE, FALSE, FALSE);
10042 static void DrawLevelConfigLevel(void)
10046 // draw counter gadgets
10047 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
10048 MapCounterButtons(i);
10050 // draw checkbutton gadgets
10051 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
10052 MapCheckbuttonGadget(i);
10054 // draw selectbox gadgets
10055 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
10056 MapSelectboxGadget(i);
10058 // draw text input gadgets
10059 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
10060 MapTextInputGadget(i);
10063 static char *getLevelSubdirFromSaveMode(int save_mode)
10065 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
10066 return getNewUserLevelSubdir();
10068 return leveldir_current->subdir;
10071 static void DrawLevelConfigLevelSet_DirectoryInfo(void)
10073 char *directory_text = "Level set directory:";
10074 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
10075 int font1_nr = FONT_TEXT_1;
10076 int font2_nr = FONT_TEXT_2;
10077 int font1_height = getFontHeight(font1_nr);
10078 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
10079 int x = ED_LEVEL_SETTINGS_X(0);
10080 int y = ED_LEVEL_SETTINGS_Y(6);
10082 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
10083 PrintInfoText(directory_name, font2_nr, x, y);
10086 static void DrawLevelConfigLevelSet(void)
10088 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
10089 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
10092 // draw counter gadgets
10093 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
10094 MapCounterButtons(i);
10096 // draw checkbutton gadgets
10097 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
10099 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
10100 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
10101 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
10104 MapCheckbuttonGadget(i);
10107 // draw selectbox gadgets
10108 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
10109 MapSelectboxGadget(i);
10111 // draw text input gadgets
10112 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
10113 MapTextInputGadget(i);
10115 // draw textbutton gadgets
10116 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
10119 DrawLevelConfigLevelSet_DirectoryInfo();
10122 static void DrawLevelConfigEditor(void)
10126 // draw counter gadgets
10127 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
10128 MapCounterButtons(i);
10130 // draw checkbutton gadgets
10131 for (i = ED_CHECKBUTTON_ID_EDITOR_FIRST; i <= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
10132 MapCheckbuttonGadget(i);
10134 // draw radiobutton gadgets
10135 for (i = ED_RADIOBUTTON_ID_EDITOR_FIRST; i <= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
10136 MapRadiobuttonGadget(i);
10138 // draw drawing area
10139 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
10141 // draw textbutton gadgets
10142 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
10145 static void DrawLevelConfigEngine(void)
10149 // draw counter gadgets
10150 if (level.bd_scheduling_type == GD_SCHEDULING_MILLISECONDS)
10152 MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_MS);
10153 MapCounterButtons(ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES);
10157 MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_C64);
10158 MapCounterButtons(ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS);
10161 // draw checkbutton gadgets
10162 for (i = ED_CHECKBUTTON_ID_ENGINE_FIRST; i <= ED_CHECKBUTTON_ID_ENGINE_LAST; i++)
10163 MapCheckbuttonGadget(i);
10165 // draw selectbox gadgets
10166 for (i = ED_SELECTBOX_ID_ENGINE_FIRST; i <= ED_SELECTBOX_ID_ENGINE_LAST; i++)
10167 MapSelectboxGadget(i);
10170 static void DrawLevelConfigWindow(void)
10172 char *text = "Global Settings";
10173 int font_nr = FONT_TITLE_1;
10174 struct MenuPosInfo *pos = &editor.settings.headline;
10175 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
10176 int sy = SY + pos->y;
10178 stick_element_properties_window = FALSE;
10180 SetAutomaticNumberOfGemsNeeded();
10182 UnmapLevelEditorFieldGadgets();
10184 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10187 DrawText(sx, sy, text, font_nr);
10189 DrawLevelConfigTabulatorGadgets();
10191 if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVEL)
10192 DrawLevelConfigLevel();
10193 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVELSET)
10194 DrawLevelConfigLevelSet();
10195 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_EDITOR)
10196 DrawLevelConfigEditor();
10197 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_ENGINE)
10198 DrawLevelConfigEngine();
10201 static void DrawCustomContentArea(void)
10203 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
10204 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10205 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
10206 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
10207 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
10208 int xoffset = ED_GADGET_SPACE_DISTANCE;
10210 // add distance for potential left text (without drawing area border)
10211 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
10213 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10215 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
10218 static void DrawCustomChangeContentArea(void)
10220 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
10221 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10222 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
10223 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
10224 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
10225 int xoffset = ED_GADGET_SPACE_DISTANCE;
10227 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10229 MapDrawingArea(id);
10232 static void RemoveElementContentArea(int id, int font_height)
10234 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10236 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
10237 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
10238 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10239 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
10240 ED_GADGET_TEXT_DISTANCE + font_height);
10243 static void DrawYamYamContentAreas(void)
10245 int font_nr = FONT_TEXT_1;
10246 int font_height = getFontHeight(font_nr);
10247 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10248 int yoffset = (tilesize - font_height) / 2;
10249 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
10250 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
10253 // display counter to choose number of element content areas
10254 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
10256 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10258 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
10260 if (i < level.num_yamyam_contents)
10262 MapDrawingArea(id);
10266 UnmapDrawingArea(id);
10268 // delete content areas in case of reducing number of them
10269 RemoveElementContentArea(id, font_height);
10273 DrawText(x, y + 0 * tilesize, "content", font_nr);
10274 DrawText(x, y + 1 * tilesize, "when", font_nr);
10275 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
10278 static void DrawMagicBallContentAreas(void)
10280 int font_nr = FONT_TEXT_1;
10281 int font_height = getFontHeight(font_nr);
10282 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10283 int yoffset = (tilesize - font_height) / 2;
10284 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
10285 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
10288 // display counter to choose number of element content areas
10289 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
10291 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10293 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
10295 if (i < level.num_ball_contents)
10297 MapDrawingArea(id);
10301 UnmapDrawingArea(id);
10303 // delete content areas in case of reducing number of them
10304 RemoveElementContentArea(id, font_height);
10308 DrawText(x, y + 0 * tilesize, "generated", font_nr);
10309 DrawText(x, y + 1 * tilesize, "when", font_nr);
10310 DrawText(x, y + 2 * tilesize, "active", font_nr);
10313 static void DrawAndroidElementArea(void)
10315 int id = ED_DRAWING_ID_ANDROID_CONTENT;
10316 int num_elements = level.num_android_clone_elements;
10317 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10318 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10319 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10320 int xsize = MAX_ANDROID_ELEMENTS;
10323 // display counter to choose number of element areas
10324 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
10326 if (drawingarea_info[id].text_left != NULL)
10327 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10329 UnmapDrawingArea(id);
10331 ModifyEditorDrawingArea(id, num_elements, 1);
10333 // delete content areas in case of reducing number of them
10334 DrawBackground(sx, sy,
10335 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10336 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10338 MapDrawingArea(id);
10341 static void DrawGroupElementArea(void)
10343 int id = ED_DRAWING_ID_GROUP_CONTENT;
10344 int num_elements = group_element_info.num_elements;
10345 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10346 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10347 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10348 int xsize = MAX_ELEMENTS_IN_GROUP;
10351 if (drawingarea_info[id].text_left != NULL)
10352 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10354 UnmapDrawingArea(id);
10356 ModifyEditorDrawingArea(id, num_elements, 1);
10358 // delete content areas in case of reducing number of them
10359 DrawBackground(sx, sy,
10360 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10361 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10363 MapDrawingArea(id);
10366 static void DrawPlayerInitialInventoryArea(int element)
10368 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
10369 int player_nr = GET_PLAYER_NR(element);
10370 int num_elements = level.initial_inventory_size[player_nr];
10371 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10372 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10373 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10374 int xsize = MAX_INITIAL_INVENTORY_SIZE;
10377 // determine horizontal position to the right of specified gadget
10378 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
10379 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
10380 ED_DRAWINGAREA_TEXT_DISTANCE);
10382 // determine horizontal offset for leading text
10383 if (drawingarea_info[id].text_left != NULL)
10384 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10386 UnmapDrawingArea(id);
10388 ModifyEditorDrawingArea(id, num_elements, 1);
10390 // delete content areas in case of reducing number of them
10391 DrawBackground(sx, sy,
10392 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10393 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10395 MapDrawingArea(id);
10398 static void DrawMMBallContentArea(void)
10400 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
10401 int num_elements = level.num_mm_ball_contents;
10402 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10403 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10404 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10405 int xsize = MAX_MM_BALL_CONTENTS;
10408 if (drawingarea_info[id].text_left != NULL)
10409 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10411 UnmapDrawingArea(id);
10413 ModifyEditorDrawingArea(id, num_elements, 1);
10415 // delete content areas in case of reducing number of them
10416 DrawBackground(sx, sy,
10417 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10418 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10420 MapDrawingArea(id);
10423 static void DrawEnvelopeTextArea(int envelope_nr)
10425 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
10426 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
10430 DrawBackground(gi->x, gi->y,
10431 gi->textarea.crop_width, gi->textarea.crop_height);
10433 if (envelope_nr != -1)
10434 textarea_info[id].value = level.envelope[envelope_nr].text;
10436 ModifyGadget(gi, GDI_AREA_SIZE,
10437 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
10438 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
10441 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
10444 static void DrawPropertiesInfo(void)
10453 // configurable properties
10455 { EP_WALKABLE_OVER, "- player can walk over it" },
10456 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
10457 { EP_WALKABLE_UNDER, "- player can walk under it" },
10458 { EP_PASSABLE_OVER, "- player can pass over it" },
10459 { EP_PASSABLE_INSIDE, "- player can pass through it" },
10460 { EP_PASSABLE_UNDER, "- player can pass under it" },
10461 { EP_PROTECTED, "- player is protected by it" },
10463 { EP_DIGGABLE, "- can be digged away" },
10464 { EP_COLLECTIBLE, "- can be collected" },
10465 { EP_DROPPABLE, "- can be dropped after collecting" },
10466 { EP_THROWABLE, "- can be thrown after collecting" },
10467 { EP_PUSHABLE, "- can be pushed" },
10469 { EP_CAN_FALL, "- can fall" },
10470 { EP_CAN_MOVE, "- can move" },
10472 { EP_CAN_SMASH_PLAYER, "- can smash player" },
10474 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
10476 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
10478 { EP_SLIPPERY, "- slippery for falling elements" },
10479 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
10481 { EP_DONT_RUN_INTO, "- deadly when running into" },
10482 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
10483 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
10484 { EP_DONT_TOUCH, "- deadly when touching" },
10486 { EP_INDESTRUCTIBLE, "- indestructible" },
10488 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
10489 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
10490 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
10492 { EP_CAN_CHANGE, "- can change to other element" },
10494 // pre-defined properties
10495 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
10496 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
10497 { EP_SWITCHABLE, "- can be switched" },
10499 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
10504 char *filename = getElementDescriptionFilename(properties_element);
10505 char *num_elements_text = "In this level: ";
10506 char *num_similar_text = "Similar tiles: ";
10507 char *properties_text = "Standard properties: ";
10508 char *description_text = "Description:";
10509 char *no_description_text = "No description available.";
10510 char *none_text = "None";
10512 int num_elements_in_level = 0;
10513 int num_similar_in_level = 0;
10514 int num_hires_tiles_in_level = 0;
10515 int num_standard_properties = 0;
10516 int font1_nr = FONT_TEXT_1;
10517 int font2_nr = FONT_TEXT_2;
10518 int font1_width = getFontWidth(font1_nr);
10519 int font1_height = getFontHeight(font1_nr);
10520 int font2_height = getFontHeight(font2_nr);
10521 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
10522 int font2_yoffset = (font1_height - font2_height) / 2;
10523 int num_elements_text_len = strlen(num_elements_text) * font1_width;
10524 int num_similar_text_len = strlen(num_similar_text) * font1_width;
10525 int properties_text_len = strlen(properties_text) * font1_width;
10526 int xpos = ED_ELEMENT_SETTINGS_X(0);
10527 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10530 if (setup.editor.show_element_token)
10532 int font3_nr = FONT_TEXT_3;
10533 int font3_height = getFontHeight(font3_nr);
10535 DrawTextF(xpos, ypos, font3_nr,
10536 "[%s]", element_info[properties_element].token_name);
10538 ypos += 2 * font3_height;
10541 // ----- print number of elements / percentage of this element in level
10543 for (y = 0; y < lev_fieldy; y++)
10545 for (x = 0; x < lev_fieldx; x++)
10547 if (Tile[x][y] == properties_element)
10549 num_elements_in_level++;
10551 else if (IS_MM_WALL(Tile[x][y]) &&
10552 map_mm_wall_element(Tile[x][y]) == properties_element)
10554 num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
10559 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10561 DrawTextS(xpos, ypos, font1_nr, num_elements_text);
10563 if (num_hires_tiles_in_level > 0)
10564 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10565 "%d wall tiles", num_hires_tiles_in_level);
10566 else if (num_elements_in_level > 0)
10567 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10568 "%d (%.2f %%)", num_elements_in_level, percentage);
10570 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10573 // ----- print number of similar elements / percentage of them in level
10575 for (y = 0; y < lev_fieldy; y++)
10577 for (x = 0; x < lev_fieldx; x++)
10579 if (strEqual(element_info[Tile[x][y]].class_name,
10580 element_info[properties_element].class_name))
10582 num_similar_in_level++;
10587 if (num_similar_in_level != num_elements_in_level)
10589 ypos += 1 * MAX(font1_height, font2_height);
10591 percentage = num_similar_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10593 DrawTextS(xpos, ypos, font1_nr, num_similar_text);
10595 if (num_similar_in_level > 0)
10596 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10597 "%d (%.2f %%)", num_similar_in_level, percentage);
10599 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10603 ypos += 2 * MAX(font1_height, font2_height);
10605 // ----- print standard properties of this element
10607 DrawTextS(xpos, ypos, font1_nr, properties_text);
10609 ypos += line1_height;
10611 for (i = 0; properties[i].value != -1; i++)
10613 if (!HAS_PROPERTY(properties_element, properties[i].value))
10616 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
10618 ypos += font2_height;
10620 num_standard_properties++;
10623 if (num_standard_properties == 0)
10625 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
10626 font2_nr, none_text);
10628 ypos -= (line1_height - font1_height);
10631 ypos += MAX(font1_height, font2_height);
10633 // ----- print special description of this element
10635 PrintInfoText(description_text, font1_nr, xpos, ypos);
10637 ypos += line1_height;
10639 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
10640 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
10643 #define TEXT_COLLECTING "Score for collecting"
10644 #define TEXT_COLLECTING_EXTRA "Score for extra diamonds"
10645 #define TEXT_SMASHING "Score for smashing"
10646 #define TEXT_SLURPING "Score for slurping robot"
10647 #define TEXT_CRACKING "Score for cracking"
10648 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
10649 #define TEXT_DURATION "Duration when activated"
10650 #define TEXT_DELAY_ON "Delay before activating"
10651 #define TEXT_DELAY_OFF "Delay before deactivating"
10652 #define TEXT_DELAY_CHANGING "Delay before changing"
10653 #define TEXT_DELAY_EXPLODING "Delay before exploding"
10654 #define TEXT_DELAY_MOVING "Delay before moving"
10655 #define TEXT_BALL_DELAY "Element generation delay"
10656 #define TEXT_MOVE_SPEED "Speed of android moving"
10657 #define TEXT_CLONE_SPEED "Speed of android cloning"
10658 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
10659 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
10660 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
10661 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
10662 #define TEXT_TIME_BONUS "Extra time to solve level"
10669 } elements_with_counter[] =
10671 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
10672 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
10673 { EL_BD_DIAMOND, &level.score[SC_DIAMOND_EXTRA], TEXT_COLLECTING_EXTRA },
10674 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
10675 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
10676 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10677 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
10678 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
10679 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
10680 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
10681 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
10682 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10683 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
10684 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10685 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10686 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
10687 { EL_BD_BUTTERFLY_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10688 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
10689 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10690 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10691 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
10692 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10693 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10694 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10695 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10696 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10697 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10698 { EL_BD_FIREFLY_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10699 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10700 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10701 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10702 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10703 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10704 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10705 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10706 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
10707 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
10708 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10709 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
10710 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10711 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10712 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10713 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10714 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10715 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
10716 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10717 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10718 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE], TEXT_COLLECTING },
10719 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10720 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10721 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
10722 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
10723 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
10724 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10725 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10726 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10727 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10728 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10729 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10730 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10731 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10732 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
10733 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
10734 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
10735 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
10736 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
10737 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10738 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
10739 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
10740 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
10741 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10742 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10743 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10744 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10745 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10746 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10747 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10748 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10749 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10750 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10751 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10752 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10753 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10754 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
10755 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10756 { EL_DC_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10757 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
10758 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
10759 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
10760 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
10761 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
10762 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
10763 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
10764 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
10765 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
10766 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
10767 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
10768 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
10769 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
10770 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
10771 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
10772 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
10773 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
10774 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
10775 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
10776 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
10777 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
10778 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
10779 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
10780 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
10781 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
10782 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
10783 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_CHANGING },
10784 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10785 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10790 static boolean checkPropertiesConfig(int element)
10794 // special case: empty space customization only available in R'n'D game engine
10795 if (element == EL_EMPTY_SPACE && level.game_engine_type != GAME_ENGINE_TYPE_RND)
10798 if (IS_GEM(element) ||
10799 IS_CUSTOM_ELEMENT(element) ||
10800 IS_GROUP_ELEMENT(element) ||
10801 IS_EMPTY_ELEMENT(element) ||
10802 IS_BALLOON_ELEMENT(element) ||
10803 IS_ENVELOPE(element) ||
10804 IS_MM_ENVELOPE(element) ||
10805 IS_MM_MCDUFFIN(element) ||
10806 IS_DF_LASER(element) ||
10807 IS_PLAYER_ELEMENT(element) ||
10808 IS_BD_PLAYER_ELEMENT(element) ||
10809 IS_SOKOBAN_OBJECT_OR_FIELD(element) ||
10810 HAS_EDITOR_CONTENT(element) ||
10811 CAN_GROW(element) ||
10812 COULD_MOVE_INTO_ACID(element) ||
10813 MAYBE_DONT_COLLIDE_WITH(element))
10816 for (i = 0; elements_with_counter[i].element != -1; i++)
10817 if (elements_with_counter[i].element == element)
10823 static void SetAutomaticNumberOfGemsNeeded(void)
10827 if (!level.auto_count_gems)
10830 level.gems_needed = 0;
10832 for (x = 0; x < lev_fieldx; x++)
10834 for (y = 0; y < lev_fieldy; y++)
10836 int element = Tile[x][y];
10841 case EL_EMERALD_YELLOW:
10842 case EL_EMERALD_RED:
10843 case EL_EMERALD_PURPLE:
10844 case EL_BD_DIAMOND:
10845 case EL_WALL_EMERALD:
10846 case EL_WALL_EMERALD_YELLOW:
10847 case EL_WALL_EMERALD_RED:
10848 case EL_WALL_EMERALD_PURPLE:
10849 case EL_WALL_BD_DIAMOND:
10851 case EL_SP_INFOTRON:
10854 level.gems_needed++;
10858 case EL_WALL_DIAMOND:
10859 level.gems_needed += 3;
10863 case EL_WALL_PEARL:
10864 level.gems_needed += 5;
10868 case EL_WALL_CRYSTAL:
10869 level.gems_needed += 8;
10878 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10881 static void DrawPropertiesConfig(void)
10883 boolean draw_footer_line = FALSE;
10884 int max_num_element_counters = 4;
10885 int num_element_counters = 0;
10888 if (!checkPropertiesConfig(properties_element))
10890 int xpos = ED_ELEMENT_SETTINGS_X(0);
10891 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10893 PrintInfoText("No configuration options available.",
10894 FONT_TEXT_1, xpos, ypos);
10899 // check if there are elements where a value can be chosen for
10900 for (i = 0; elements_with_counter[i].element != -1; i++)
10902 if (elements_with_counter[i].element == properties_element)
10904 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10906 counterbutton_info[counter_id].y =
10907 ED_ELEMENT_SETTINGS_YPOS(
10908 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10909 (CAN_GROW(properties_element) ? 1 : 0) +
10910 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10911 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10912 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10913 num_element_counters);
10915 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10916 counterbutton_info[counter_id].text_right = elements_with_counter[i].text;
10918 if (properties_element == EL_GAME_OF_LIFE ||
10919 properties_element == EL_BIOMAZE)
10921 counterbutton_info[counter_id].min_value = 0; // min neighbours
10922 counterbutton_info[counter_id].max_value = 8; // max neighbours
10926 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10927 counterbutton_info[counter_id].min_value = MIN_SCORE;
10928 counterbutton_info[counter_id].max_value = MAX_SCORE;
10931 MapCounterButtons(counter_id);
10933 num_element_counters++;
10934 if (num_element_counters >= max_num_element_counters)
10939 if (HAS_EDITOR_CONTENT(properties_element))
10941 // draw stickybutton gadget
10942 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10944 if (IS_AMOEBOID(properties_element))
10945 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10946 else if (properties_element == EL_YAMYAM ||
10947 properties_element == EL_YAMYAM_LEFT ||
10948 properties_element == EL_YAMYAM_RIGHT ||
10949 properties_element == EL_YAMYAM_UP ||
10950 properties_element == EL_YAMYAM_DOWN)
10951 DrawYamYamContentAreas();
10952 else if (properties_element == EL_EMC_MAGIC_BALL)
10954 DrawMagicBallContentAreas();
10956 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10957 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10959 else if (properties_element == EL_EMC_ANDROID)
10960 DrawAndroidElementArea();
10961 else if (properties_element == EL_MM_GRAY_BALL)
10963 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
10964 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
10965 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
10966 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EXPLODE_MM_BALL);
10968 DrawMMBallContentArea();
10972 if (IS_PLAYER_ELEMENT(properties_element))
10974 int player_nr = GET_PLAYER_NR(properties_element);
10976 // these properties can be set for every player individually
10978 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10980 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
10981 &level.start_element[player_nr];
10982 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
10983 &level.artwork_element[player_nr];
10984 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
10985 &level.explosion_element[player_nr];
10987 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10988 &level.use_start_element[player_nr];
10989 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10990 &level.use_artwork_element[player_nr];
10991 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10992 &level.use_explosion_element[player_nr];
10993 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10994 &level.initial_player_gravity[player_nr];
10996 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10997 &level.initial_player_stepsize[player_nr];
10999 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
11000 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
11001 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
11002 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
11003 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
11004 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
11005 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
11006 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
11007 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
11008 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
11009 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
11010 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
11011 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
11012 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
11013 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
11015 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
11016 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
11017 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
11019 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
11021 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
11023 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
11024 &level.initial_inventory_content[player_nr][0];
11026 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
11027 &level.initial_inventory_size[player_nr];
11029 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
11030 &level.use_initial_inventory[player_nr];
11032 // draw checkbutton gadgets
11033 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
11034 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
11035 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
11037 // draw counter gadgets
11038 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
11040 // draw drawing area gadgets
11041 DrawPlayerInitialInventoryArea(properties_element);
11045 if (IS_BD_PLAYER_ELEMENT(properties_element))
11047 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS);
11048 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_TOPMOST_PLAYER_ACTIVE);
11051 // special case: slippery walls option for gems only available in R'n'D game engine
11052 if (IS_GEM(properties_element) && level.game_engine_type == GAME_ENGINE_TYPE_RND)
11054 checkbutton_info[ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS].y =
11055 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_BD_DIAMOND ? 2 : 1);
11057 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
11060 if (properties_element == EL_EM_DYNAMITE)
11061 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
11063 if (COULD_MOVE_INTO_ACID(properties_element) &&
11064 !IS_PLAYER_ELEMENT(properties_element) &&
11065 (!IS_CUSTOM_ELEMENT(properties_element) ||
11066 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
11068 // set position for checkbutton for "can move into acid"
11069 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
11070 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
11071 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
11072 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
11073 IS_BALLOON_ELEMENT(properties_element) ||
11074 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
11076 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
11079 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
11080 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
11082 if (properties_element == EL_SPRING ||
11083 properties_element == EL_SPRING_LEFT ||
11084 properties_element == EL_SPRING_RIGHT)
11085 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
11087 if (properties_element == EL_TIME_ORB_FULL)
11088 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
11090 if (properties_element == EL_GAME_OF_LIFE ||
11091 properties_element == EL_BIOMAZE)
11092 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
11094 if (CAN_GROW(properties_element))
11096 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
11097 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
11099 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
11102 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
11103 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
11105 if (properties_element == EL_SOKOBAN_OBJECT)
11106 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
11108 if (properties_element == EL_SOKOBAN_OBJECT ||
11109 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
11110 properties_element == EL_SOKOBAN_FIELD_FULL)
11112 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
11113 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
11116 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
11119 if (IS_BALLOON_ELEMENT(properties_element))
11120 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
11122 if (IS_ENVELOPE(properties_element) ||
11123 IS_MM_ENVELOPE(properties_element))
11125 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
11126 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
11127 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
11128 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
11129 int envelope_nr = ENVELOPE_NR(properties_element);
11131 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
11132 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
11134 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
11135 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
11137 // display counter to choose size of envelope text area
11138 MapCounterButtons(counter1_id);
11139 MapCounterButtons(counter2_id);
11141 // display checkbuttons to choose auto-wrap and alignment properties
11142 MapCheckbuttonGadget(button1_id);
11143 MapCheckbuttonGadget(button2_id);
11145 DrawEnvelopeTextArea(envelope_nr);
11148 if (IS_MM_MCDUFFIN(properties_element))
11150 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
11151 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
11152 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
11155 if (IS_DF_LASER(properties_element))
11157 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
11158 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
11159 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
11162 if (IS_CUSTOM_ELEMENT(properties_element))
11164 // draw stickybutton gadget
11165 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11167 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
11169 // draw checkbutton gadgets
11170 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
11171 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
11172 MapCheckbuttonGadget(i);
11174 // draw counter gadgets
11175 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
11176 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
11177 MapCounterButtons(i);
11179 // draw selectbox gadgets
11180 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
11181 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
11182 MapSelectboxGadget(i);
11184 // draw textbutton gadgets
11185 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11187 // draw text input gadgets
11188 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11190 // draw drawing area gadgets
11191 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11193 draw_footer_line = TRUE;
11195 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
11197 // draw checkbutton gadgets
11198 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
11199 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
11200 MapCheckbuttonGadget(i);
11202 // draw counter gadgets
11203 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
11204 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
11205 MapCounterButtons(i);
11207 // draw selectbox gadgets
11208 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
11209 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
11210 MapSelectboxGadget(i);
11212 // draw drawing area gadgets
11213 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
11214 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
11215 DrawCustomContentArea();
11218 else if (IS_GROUP_ELEMENT(properties_element))
11220 // draw stickybutton gadget
11221 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11223 // draw checkbutton gadgets
11224 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11225 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11227 // draw counter gadgets
11228 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
11230 // draw selectbox gadgets
11231 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
11233 // draw textbutton gadgets
11234 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11236 // draw drawing area gadgets
11237 DrawGroupElementArea();
11239 // draw text input gadgets
11240 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11242 // draw drawing area gadgets
11243 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11245 draw_footer_line = TRUE;
11247 else if (IS_EMPTY_ELEMENT(properties_element))
11249 // draw stickybutton gadget
11250 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11252 // draw checkbutton gadgets
11253 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11254 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11256 // draw textbutton gadgets
11257 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11259 // draw drawing area gadgets
11260 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11262 draw_footer_line = TRUE;
11265 // draw little footer border line above CE/GE use/save template gadgets
11266 if (draw_footer_line)
11268 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
11269 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
11270 int gd_x = gd->x + gd_gi1->border.width / 2;
11271 int gd_y = gd->y + gd_gi1->height - 1;
11272 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
11274 if (tab_color != BLACK_PIXEL) // black => transparent
11275 FillRectangle(drawto,
11276 SX + ED_ELEMENT_SETTINGS_X(0),
11277 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
11279 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
11283 static void DrawPropertiesChangeDrawingAreas(void)
11285 if (IS_CUSTOM_ELEMENT(properties_element))
11287 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
11288 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
11289 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
11291 DrawCustomChangeContentArea();
11294 redraw_mask |= REDRAW_FIELD;
11297 static void DrawPropertiesChange(void)
11301 // needed to initially set selectbox options for special action options
11302 setSelectboxSpecialActionOptions();
11304 // draw stickybutton gadget
11305 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11307 // draw checkbutton gadgets
11308 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
11309 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
11310 MapCheckbuttonGadget(i);
11312 // draw counter gadgets
11313 for (i = ED_COUNTER_ID_CHANGE_FIRST;
11314 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
11315 MapCounterButtons(i);
11317 // draw selectbox gadgets
11318 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
11319 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
11320 MapSelectboxGadget(i);
11322 // draw textbutton gadgets
11323 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
11324 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
11325 MapTextbuttonGadget(i);
11327 // draw graphicbutton gadgets
11328 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
11329 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
11330 MapGraphicbuttonGadget(i);
11332 // draw drawing area gadgets
11333 DrawPropertiesChangeDrawingAreas();
11336 static void DrawEditorElementAnimation(int x, int y)
11338 int graphic = el2img(properties_element);
11339 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
11340 custom_element.ce_value_fixed_initial :
11341 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
11342 custom_element.collect_score_initial : FrameCounter);
11344 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
11347 static void DrawEditorElementName(int x, int y, int font_nr)
11349 char *element_name = getElementInfoText(properties_element);
11350 int font_width = getFontWidth(font_nr);
11351 int font_height = getFontHeight(font_nr);
11352 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
11353 int max_chars_per_line = max_text_width / font_width;
11355 if (strlen(element_name) <= max_chars_per_line)
11356 DrawTextS(x, y, font_nr, element_name);
11359 char buffer[max_chars_per_line + 1];
11360 int next_pos = max_chars_per_line;
11362 strncpy(buffer, element_name, max_chars_per_line);
11363 buffer[max_chars_per_line] = '\0';
11365 if (element_name[max_chars_per_line] == ' ')
11371 for (i = max_chars_per_line - 1; i >= 0; i--)
11372 if (buffer[i] == ' ')
11375 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
11382 DrawTextS(x, y - font_height / 2, font_nr, buffer);
11384 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
11385 buffer[max_chars_per_line] = '\0';
11387 DrawTextS(x, y + font_height / 2, font_nr, buffer);
11391 static void DrawPropertiesWindow(void)
11393 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
11394 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
11395 int border_size = gd->border_size;
11396 int font_nr = FONT_TEXT_1;
11397 int font_height = getFontHeight(font_nr);
11398 int xoffset = TILEX + element_border + 3 * border_size;
11399 int yoffset = (TILEY - font_height) / 2;
11400 int x1 = editor.settings.element_graphic.x + element_border;
11401 int y1 = editor.settings.element_graphic.y + element_border;
11402 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
11403 editor.settings.element_name.x);
11404 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
11405 editor.settings.element_name.y);
11406 char *text = "Element Settings";
11407 int font2_nr = FONT_TITLE_1;
11408 struct MenuPosInfo *pos = &editor.settings.headline;
11409 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
11410 int sy = SY + pos->y;
11412 stick_element_properties_window = FALSE;
11414 // make sure that previous properties edit mode exists for this element
11415 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
11416 !IS_CUSTOM_ELEMENT(properties_element))
11417 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
11419 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
11420 !IS_PLAYER_ELEMENT(properties_element) &&
11421 !IS_CUSTOM_ELEMENT(properties_element))
11422 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
11424 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
11425 (IS_PLAYER_ELEMENT(properties_element) ||
11426 IS_CUSTOM_ELEMENT(properties_element)))
11427 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
11429 CopyElementPropertiesToEditor(properties_element);
11431 UnmapLevelEditorFieldGadgets();
11432 UnmapLevelEditorToolboxDrawingGadgets();
11433 UnmapLevelEditorToolboxCustomGadgets();
11435 MapLevelEditorToolboxCustomGadgetsIfNeeded();
11437 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11440 DrawText(sx, sy, text, font2_nr);
11442 FrameCounter = 0; // restart animation frame counter
11444 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
11445 DrawEditorElementAnimation(SX + x1, SY + y1);
11446 DrawEditorElementName(x2, y2, font_nr);
11448 DrawPropertiesTabulatorGadgets();
11450 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
11451 DrawPropertiesInfo();
11452 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
11453 DrawPropertiesChange();
11454 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
11455 DrawPropertiesConfig();
11458 static void DrawPaletteWindow(void)
11462 UnmapLevelEditorFieldGadgets();
11464 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11467 // map buttons to select elements
11468 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
11469 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
11470 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
11471 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
11472 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
11475 static void UpdateCustomElementGraphicGadgets(void)
11479 InitElementPropertiesGfxElement();
11481 ModifyEditorElementList();
11482 RedrawDrawingElements();
11484 // force redraw of all mapped drawing area gadgets
11485 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
11487 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
11494 static int getOpenDirectionFromTube(int element)
11498 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
11499 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
11500 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
11501 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
11502 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
11503 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
11504 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
11505 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
11506 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
11507 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
11508 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
11514 static int getTubeFromOpenDirection(int direction)
11518 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
11519 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
11520 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
11521 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
11522 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
11523 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
11524 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
11525 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
11526 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
11527 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
11528 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
11530 // if only one direction, fall back to simple tube with that direction
11531 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
11532 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
11533 case (MV_UP): return EL_TUBE_VERTICAL;
11534 case (MV_DOWN): return EL_TUBE_VERTICAL;
11540 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
11542 int element_new = getTubeFromOpenDirection(direction);
11544 return (element_new != EL_EMPTY ? element_new : element_old);
11547 static int getOpenDirectionFromBelt(int element)
11549 int belt_dir = getBeltDirFromBeltElement(element);
11551 return (belt_dir == MV_LEFT ? MV_RIGHT :
11552 belt_dir == MV_RIGHT ? MV_LEFT :
11553 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
11556 static int getBeltFromNrAndOpenDirection(int nr, int direction)
11558 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
11559 direction == MV_RIGHT ? MV_LEFT :
11560 direction == MV_HORIZONTAL ? MV_NONE : direction);
11562 if (direction == MV_NONE)
11565 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
11568 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
11571 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
11573 return (element_new != EL_EMPTY ? element_new : element_old);
11576 static int getOpenDirectionFromPool(int element)
11580 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
11581 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
11582 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
11583 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
11584 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
11585 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
11591 static int getPoolFromOpenDirection(int direction)
11595 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
11596 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
11597 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
11598 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
11599 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
11600 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
11606 static int getPoolFromOpenDirectionExt(int direction, int help_element)
11608 int element = getPoolFromOpenDirection(direction);
11609 int help_direction = getOpenDirectionFromPool(help_element);
11611 if (element == EL_EMPTY)
11613 int help_direction_vertical = help_direction & MV_VERTICAL;
11615 element = getPoolFromOpenDirection(direction | help_direction_vertical);
11618 if (element == EL_EMPTY)
11620 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
11622 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
11628 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
11630 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
11632 return (element_new != EL_EMPTY ? element_new : element_old);
11635 static int getOpenDirectionFromPillar(int element)
11639 case EL_EMC_WALL_1: return (MV_DOWN);
11640 case EL_EMC_WALL_2: return (MV_VERTICAL);
11641 case EL_EMC_WALL_3: return (MV_UP);
11647 static int getPillarFromOpenDirection(int direction)
11651 case (MV_DOWN): return EL_EMC_WALL_1;
11652 case (MV_VERTICAL): return EL_EMC_WALL_2;
11653 case (MV_UP): return EL_EMC_WALL_3;
11659 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
11661 int element_new = getPillarFromOpenDirection(direction);
11663 return (element_new != EL_EMPTY ? element_new : element_old);
11666 static int getOpenDirectionFromSteel2(int element)
11670 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
11671 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
11672 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
11673 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
11674 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
11675 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
11676 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
11677 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
11683 static int getSteel2FromOpenDirection(int direction)
11687 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
11688 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
11689 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
11690 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
11691 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
11692 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
11693 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
11694 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
11700 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
11702 int element_new = getSteel2FromOpenDirection(direction);
11704 return (element_new != EL_EMPTY ? element_new : element_old);
11707 static int getOpenDirectionFromChip(int element)
11711 case EL_SP_CHIP_SINGLE: return (MV_NONE);
11712 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
11713 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
11714 case EL_SP_CHIP_TOP: return (MV_DOWN);
11715 case EL_SP_CHIP_BOTTOM: return (MV_UP);
11721 static int getChipFromOpenDirection(int direction)
11725 case (MV_NONE): return EL_SP_CHIP_SINGLE;
11726 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
11727 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
11728 case (MV_UP): return EL_SP_CHIP_BOTTOM;
11729 case (MV_DOWN): return EL_SP_CHIP_TOP;
11735 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
11737 int element_new = getChipFromOpenDirection(direction);
11739 return (element_new != EL_EMPTY ? element_new : element_old);
11742 static int getClosedTube(int x, int y)
11744 struct XY *xy = xy_directions;
11745 int element_old = IntelliDrawBuffer[x][y];
11746 int direction_old = getOpenDirectionFromTube(element_old);
11747 int direction_new = MV_NONE;
11750 for (i = 0; i < NUM_DIRECTIONS; i++)
11752 int xx = x + xy[i].x;
11753 int yy = y + xy[i].y;
11754 int dir = MV_DIR_FROM_BIT(i);
11755 int dir_opposite = MV_DIR_OPPOSITE(dir);
11757 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
11758 (direction_old & dir) &&
11759 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11760 direction_new |= dir;
11763 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
11766 static int getClosedBelt(int x, int y)
11768 struct XY *xy = xy_directions;
11769 int element_old = IntelliDrawBuffer[x][y];
11770 int nr = getBeltNrFromBeltElement(element_old);
11771 int direction_old = getOpenDirectionFromBelt(element_old);
11772 int direction_new = MV_NONE;
11775 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11777 int xx = x + xy[i].x;
11778 int yy = y + xy[i].y;
11779 int dir = MV_DIR_FROM_BIT(i);
11780 int dir_opposite = MV_DIR_OPPOSITE(dir);
11782 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
11783 (direction_old & dir) &&
11784 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11785 direction_new |= dir;
11788 return getBeltFromNrAndOpenDirection(nr, direction_new);
11791 static int getClosedPool(int x, int y)
11793 struct XY *xy = xy_directions;
11794 int element_old = IntelliDrawBuffer[x][y];
11795 int direction_old = getOpenDirectionFromPool(element_old);
11796 int direction_new = MV_NONE;
11799 for (i = 0; i < NUM_DIRECTIONS; i++)
11801 int xx = x + xy[i].x;
11802 int yy = y + xy[i].y;
11803 int dir = MV_DIR_FROM_BIT(i);
11804 int dir_opposite = MV_DIR_OPPOSITE(dir);
11806 if (IN_LEV_FIELD(xx, yy) &&
11807 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
11808 (direction_old & dir) &&
11809 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11810 direction_new |= dir;
11813 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
11816 static int getClosedPillar(int x, int y)
11818 struct XY *xy = xy_directions;
11819 int element_old = IntelliDrawBuffer[x][y];
11820 int direction_old = getOpenDirectionFromPillar(element_old);
11821 int direction_new = MV_NONE;
11824 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11826 int xx = x + xy[i].x;
11827 int yy = y + xy[i].y;
11828 int dir = MV_DIR_FROM_BIT(i);
11829 int dir_opposite = MV_DIR_OPPOSITE(dir);
11831 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11832 (direction_old & dir) &&
11833 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11834 direction_new |= dir;
11837 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11840 static int getClosedSteel2(int x, int y)
11842 struct XY *xy = xy_directions;
11843 int element_old = IntelliDrawBuffer[x][y];
11844 int direction_old = getOpenDirectionFromSteel2(element_old);
11845 int direction_new = MV_NONE;
11848 for (i = 0; i < NUM_DIRECTIONS; i++)
11850 int xx = x + xy[i].x;
11851 int yy = y + xy[i].y;
11852 int dir = MV_DIR_FROM_BIT(i);
11853 int dir_opposite = MV_DIR_OPPOSITE(dir);
11855 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11856 (direction_old & dir) &&
11857 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11858 direction_new |= dir;
11861 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11864 static int getClosedChip(int x, int y)
11866 struct XY *xy = xy_directions;
11867 int element_old = IntelliDrawBuffer[x][y];
11868 int direction_old = getOpenDirectionFromChip(element_old);
11869 int direction_new = MV_NONE;
11872 for (i = 0; i < NUM_DIRECTIONS; i++)
11874 int xx = x + xy[i].x;
11875 int yy = y + xy[i].y;
11876 int dir = MV_DIR_FROM_BIT(i);
11877 int dir_opposite = MV_DIR_OPPOSITE(dir);
11879 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11880 (direction_old & dir) &&
11881 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11882 direction_new |= dir;
11885 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11888 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11889 boolean change_level)
11891 int sx = x - level_xpos;
11892 int sy = y - level_ypos;
11893 int old_element = Tile[x][y];
11894 int new_element = element;
11895 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11896 boolean draw_masked = FALSE;
11898 if (IS_MM_WALL_EDITOR(element))
11900 element = map_mm_wall_element_editor(element) | new_bitmask;
11902 if (IS_MM_WALL(old_element))
11903 element |= MM_WALL_BITS(old_element);
11906 draw_masked = TRUE;
11908 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11910 int element_changed = old_element & ~new_bitmask;
11912 if (MM_WALL_BITS(element_changed) != 0)
11913 element = element_changed;
11916 IntelliDrawBuffer[x][y] = element;
11919 Tile[x][y] = element;
11921 if (IN_ED_FIELD(sx, sy))
11923 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11924 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11925 else if (draw_masked)
11926 DrawEditorElementThruMask(sx, sy, element);
11928 DrawEditorElement(sx, sy, element);
11932 static void SetElementSimple(int x, int y, int element, boolean change_level)
11934 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11937 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11938 int x2, int y2, int *element2,
11939 int (*close_function)(int, int),
11940 boolean change_level)
11942 // set neighbour elements to newly determined connections
11943 SetElementSimple(x1, y1, *element1, change_level);
11944 SetElementSimple(x2, y2, *element2, change_level);
11946 // remove all open connections of neighbour elements
11947 *element1 = close_function(x1, y1);
11948 *element2 = close_function(x2, y2);
11950 // set neighbour elements to new, minimized connections
11951 SetElementSimple(x1, y1, *element1, change_level);
11952 SetElementSimple(x2, y2, *element2, change_level);
11955 static void SetElementIntelliDraw(int x, int y, int dx, int dy, int new_element,
11956 boolean change_level, int button)
11958 struct XY *xy = xy_directions;
11959 static int last_x = -1;
11960 static int last_y = -1;
11962 if (new_element == EL_UNDEFINED)
11970 int old_element = IntelliDrawBuffer[x][y];
11972 if (IS_TUBE(new_element))
11974 int last_element_new = EL_UNDEFINED;
11975 int direction = MV_NONE;
11978 // if old element is of same kind, keep all existing directions
11979 if (IS_TUBE(old_element))
11980 direction |= getOpenDirectionFromTube(old_element);
11982 for (i = 0; i < NUM_DIRECTIONS; i++)
11984 int xx = x + xy[i].x;
11985 int yy = y + xy[i].y;
11987 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11988 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11990 int dir = MV_DIR_FROM_BIT(i);
11991 int dir_opposite = MV_DIR_OPPOSITE(dir);
11992 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11993 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11994 int last_direction_new = last_direction_old | dir_opposite;
11996 last_element_new = getTubeFromOpenDirection(last_direction_new);
12002 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
12004 if (last_element_new != EL_UNDEFINED)
12005 MergeAndCloseNeighbourElements(x, y, &new_element,
12006 last_x, last_y, &last_element_new,
12007 getClosedTube, change_level);
12009 else if (IS_BELT(new_element))
12011 int belt_nr = getBeltNrFromBeltElement(new_element);
12012 int last_element_new = EL_UNDEFINED;
12013 int direction = MV_NONE;
12016 // if old element is of same kind, keep all existing directions
12017 if (IS_BELT(old_element))
12018 direction |= getOpenDirectionFromBelt(old_element);
12020 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
12022 int xx = x + xy[i].x;
12023 int yy = y + xy[i].y;
12025 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12026 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
12028 int dir = MV_DIR_FROM_BIT(i);
12029 int dir_opposite = MV_DIR_OPPOSITE(dir);
12030 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12031 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
12032 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
12033 int last_direction_new = last_direction_old | dir_opposite;
12035 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
12036 last_direction_new);
12041 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
12043 if (last_element_new != EL_UNDEFINED)
12044 MergeAndCloseNeighbourElements(x, y, &new_element,
12045 last_x, last_y, &last_element_new,
12046 getClosedBelt, change_level);
12048 else if (IS_ACID_POOL_OR_ACID(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_ACID_POOL_OR_ACID(old_element))
12056 direction |= getOpenDirectionFromPool(old_element);
12058 for (i = 0; i < NUM_DIRECTIONS; 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_ACID_POOL_OR_ACID(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 = getOpenDirectionFromPool(last_element_old);
12070 int last_direction_new = last_direction_old | dir_opposite;
12072 last_element_new = getPoolFromOpenDirection(last_direction_new);
12078 // special corrections needed for intuitively correct acid pool drawing
12079 if (last_element_new == EL_EMPTY)
12080 last_element_new = new_element;
12081 else if (last_element_new != EL_UNDEFINED)
12082 new_element = last_element_new;
12084 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
12086 if (last_element_new != EL_UNDEFINED)
12087 MergeAndCloseNeighbourElements(x, y, &new_element,
12088 last_x, last_y, &last_element_new,
12089 getClosedPool, change_level);
12091 else if (IS_EMC_PILLAR(new_element))
12093 int last_element_new = EL_UNDEFINED;
12094 int direction = MV_NONE;
12097 // if old element is of same kind, keep all existing directions
12098 if (IS_EMC_PILLAR(old_element))
12099 direction |= getOpenDirectionFromPillar(old_element);
12101 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
12103 int xx = x + xy[i].x;
12104 int yy = y + xy[i].y;
12106 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12107 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
12109 int dir = MV_DIR_FROM_BIT(i);
12110 int dir_opposite = MV_DIR_OPPOSITE(dir);
12111 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12112 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
12113 int last_direction_new = last_direction_old | dir_opposite;
12115 last_element_new = getPillarFromOpenDirection(last_direction_new);
12121 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
12123 if (last_element_new != EL_UNDEFINED)
12124 MergeAndCloseNeighbourElements(x, y, &new_element,
12125 last_x, last_y, &last_element_new,
12126 getClosedPillar, change_level);
12128 else if (IS_DC_STEELWALL_2(new_element))
12130 int last_element_new = EL_UNDEFINED;
12131 int direction = MV_NONE;
12134 // if old element is of same kind, keep all existing directions
12135 if (IS_DC_STEELWALL_2(old_element))
12136 direction |= getOpenDirectionFromSteel2(old_element);
12138 for (i = 0; i < NUM_DIRECTIONS; i++)
12140 int xx = x + xy[i].x;
12141 int yy = y + xy[i].y;
12143 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12144 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
12146 int dir = MV_DIR_FROM_BIT(i);
12147 int dir_opposite = MV_DIR_OPPOSITE(dir);
12148 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12149 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
12150 int last_direction_new = last_direction_old | dir_opposite;
12152 last_element_new = getSteel2FromOpenDirection(last_direction_new);
12158 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
12160 if (last_element_new != EL_UNDEFINED)
12161 MergeAndCloseNeighbourElements(x, y, &new_element,
12162 last_x, last_y, &last_element_new,
12163 getClosedSteel2, change_level);
12165 else if (IS_SP_CHIP(new_element))
12167 int last_element_new = EL_UNDEFINED;
12168 int direction = MV_NONE;
12171 // (do not keep existing directions, regardless of kind of old element)
12173 for (i = 0; i < NUM_DIRECTIONS; i++)
12175 int xx = x + xy[i].x;
12176 int yy = y + xy[i].y;
12178 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12179 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
12181 int dir = MV_DIR_FROM_BIT(i);
12182 int dir_opposite = MV_DIR_OPPOSITE(dir);
12183 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12184 int last_direction_old = getOpenDirectionFromChip(last_element_old);
12185 int last_direction_new = last_direction_old | dir_opposite;
12187 if (last_direction_old == MV_NONE)
12189 last_element_new = getChipFromOpenDirection(last_direction_new);
12192 else if (last_direction_old & (dir | dir_opposite))
12194 direction |= MV_DIR_OPPOSITE(last_direction_old);
12198 direction |= MV_DIR_OPPOSITE(dir);
12203 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
12205 if (last_element_new != EL_UNDEFINED)
12206 MergeAndCloseNeighbourElements(x, y, &new_element,
12207 last_x, last_y, &last_element_new,
12208 getClosedChip, change_level);
12210 else if (IS_SP_HARDWARE_BASE(new_element))
12212 int nr = GetSimpleRandom(6);
12214 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
12215 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
12216 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
12217 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
12218 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
12220 else if (new_element == EL_SP_HARDWARE_GREEN ||
12221 new_element == EL_SP_HARDWARE_BLUE ||
12222 new_element == EL_SP_HARDWARE_RED)
12224 int nr = GetSimpleRandom(3);
12226 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
12227 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
12229 else if (IS_GROUP_ELEMENT(new_element))
12231 boolean connected_drawing = FALSE;
12234 for (i = 0; i < NUM_DIRECTIONS; i++)
12236 int xx = x + xy[i].x;
12237 int yy = y + xy[i].y;
12239 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12240 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
12241 connected_drawing = TRUE;
12244 if (!connected_drawing)
12245 ResolveGroupElement(new_element);
12247 new_element = GetElementFromGroupElement(new_element);
12249 else if (IS_BELT_SWITCH(old_element))
12251 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
12252 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
12254 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
12255 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
12257 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
12261 static int swappable_elements[][2] =
12263 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
12264 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
12265 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
12266 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
12267 { EL_EMERALD, EL_WALL_EMERALD },
12268 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
12269 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
12270 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
12271 { EL_DIAMOND, EL_WALL_DIAMOND },
12272 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
12273 { EL_GATE_1, EL_GATE_1_GRAY },
12274 { EL_GATE_2, EL_GATE_2_GRAY },
12275 { EL_GATE_3, EL_GATE_3_GRAY },
12276 { EL_GATE_4, EL_GATE_4_GRAY },
12277 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
12278 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
12279 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
12280 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
12281 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
12282 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
12283 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
12284 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
12285 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
12286 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
12287 { EL_LAMP, EL_LAMP_ACTIVE },
12288 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
12289 { EL_SP_BASE, EL_SP_BUGGY_BASE },
12290 { EL_PEARL, EL_WALL_PEARL },
12291 { EL_CRYSTAL, EL_WALL_CRYSTAL },
12292 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
12293 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
12294 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
12295 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
12296 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
12297 { EL_LANDMINE, EL_DC_LANDMINE },
12298 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
12299 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
12300 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
12301 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
12302 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
12303 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
12304 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
12305 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
12306 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
12310 static int rotatable_elements_4[][4] =
12320 EL_SPACESHIP_RIGHT,
12325 EL_BD_BUTTERFLY_UP,
12326 EL_BD_BUTTERFLY_RIGHT,
12327 EL_BD_BUTTERFLY_DOWN,
12328 EL_BD_BUTTERFLY_LEFT
12332 EL_BD_FIREFLY_RIGHT,
12333 EL_BD_FIREFLY_DOWN,
12361 EL_SP_GRAVITY_PORT_UP,
12362 EL_SP_GRAVITY_PORT_RIGHT,
12363 EL_SP_GRAVITY_PORT_DOWN,
12364 EL_SP_GRAVITY_PORT_LEFT
12367 EL_SP_GRAVITY_ON_PORT_UP,
12368 EL_SP_GRAVITY_ON_PORT_RIGHT,
12369 EL_SP_GRAVITY_ON_PORT_DOWN,
12370 EL_SP_GRAVITY_ON_PORT_LEFT
12373 EL_SP_GRAVITY_OFF_PORT_UP,
12374 EL_SP_GRAVITY_OFF_PORT_RIGHT,
12375 EL_SP_GRAVITY_OFF_PORT_DOWN,
12376 EL_SP_GRAVITY_OFF_PORT_LEFT
12385 EL_BALLOON_SWITCH_UP,
12386 EL_BALLOON_SWITCH_RIGHT,
12387 EL_BALLOON_SWITCH_DOWN,
12388 EL_BALLOON_SWITCH_LEFT
12392 EL_MM_MCDUFFIN_RIGHT,
12393 EL_MM_MCDUFFIN_DOWN,
12394 EL_MM_MCDUFFIN_LEFT
12397 EL_MM_MIRROR_FIXED_1,
12398 EL_MM_MIRROR_FIXED_4,
12399 EL_MM_MIRROR_FIXED_3,
12400 EL_MM_MIRROR_FIXED_2
12403 EL_MM_STEEL_GRID_FIXED_1,
12404 EL_MM_STEEL_GRID_FIXED_4,
12405 EL_MM_STEEL_GRID_FIXED_2,
12406 EL_MM_STEEL_GRID_FIXED_3
12409 EL_MM_WOODEN_GRID_FIXED_1,
12410 EL_MM_WOODEN_GRID_FIXED_4,
12411 EL_MM_WOODEN_GRID_FIXED_2,
12412 EL_MM_WOODEN_GRID_FIXED_3
12415 EL_MM_POLARIZER_CROSS_1,
12416 EL_MM_POLARIZER_CROSS_4,
12417 EL_MM_POLARIZER_CROSS_3,
12418 EL_MM_POLARIZER_CROSS_2
12422 EL_MM_PACMAN_RIGHT,
12434 EL_DF_RECEIVER_RIGHT,
12435 EL_DF_RECEIVER_DOWN,
12436 EL_DF_RECEIVER_LEFT
12449 static int rotatable_elements_8[][8] =
12452 EL_DF_STEEL_GRID_FIXED_1,
12453 EL_DF_STEEL_GRID_FIXED_8,
12454 EL_DF_STEEL_GRID_FIXED_7,
12455 EL_DF_STEEL_GRID_FIXED_6,
12456 EL_DF_STEEL_GRID_FIXED_5,
12457 EL_DF_STEEL_GRID_FIXED_4,
12458 EL_DF_STEEL_GRID_FIXED_3,
12459 EL_DF_STEEL_GRID_FIXED_2
12462 EL_DF_WOODEN_GRID_FIXED_1,
12463 EL_DF_WOODEN_GRID_FIXED_8,
12464 EL_DF_WOODEN_GRID_FIXED_7,
12465 EL_DF_WOODEN_GRID_FIXED_6,
12466 EL_DF_WOODEN_GRID_FIXED_5,
12467 EL_DF_WOODEN_GRID_FIXED_4,
12468 EL_DF_WOODEN_GRID_FIXED_3,
12469 EL_DF_WOODEN_GRID_FIXED_2
12472 EL_DF_STEEL_GRID_ROTATING_1,
12473 EL_DF_STEEL_GRID_ROTATING_8,
12474 EL_DF_STEEL_GRID_ROTATING_7,
12475 EL_DF_STEEL_GRID_ROTATING_6,
12476 EL_DF_STEEL_GRID_ROTATING_5,
12477 EL_DF_STEEL_GRID_ROTATING_4,
12478 EL_DF_STEEL_GRID_ROTATING_3,
12479 EL_DF_STEEL_GRID_ROTATING_2
12482 EL_DF_WOODEN_GRID_ROTATING_1,
12483 EL_DF_WOODEN_GRID_ROTATING_8,
12484 EL_DF_WOODEN_GRID_ROTATING_7,
12485 EL_DF_WOODEN_GRID_ROTATING_6,
12486 EL_DF_WOODEN_GRID_ROTATING_5,
12487 EL_DF_WOODEN_GRID_ROTATING_4,
12488 EL_DF_WOODEN_GRID_ROTATING_3,
12489 EL_DF_WOODEN_GRID_ROTATING_2
12496 static int rotatable_elements_16[][16] =
12517 EL_MM_TELEPORTER_5,
12518 EL_MM_TELEPORTER_4,
12519 EL_MM_TELEPORTER_3,
12520 EL_MM_TELEPORTER_2,
12521 EL_MM_TELEPORTER_1,
12522 EL_MM_TELEPORTER_16,
12523 EL_MM_TELEPORTER_15,
12524 EL_MM_TELEPORTER_14,
12525 EL_MM_TELEPORTER_13,
12526 EL_MM_TELEPORTER_12,
12527 EL_MM_TELEPORTER_11,
12528 EL_MM_TELEPORTER_10,
12529 EL_MM_TELEPORTER_9,
12530 EL_MM_TELEPORTER_8,
12531 EL_MM_TELEPORTER_7,
12535 EL_MM_TELEPORTER_RED_5,
12536 EL_MM_TELEPORTER_RED_4,
12537 EL_MM_TELEPORTER_RED_3,
12538 EL_MM_TELEPORTER_RED_2,
12539 EL_MM_TELEPORTER_RED_1,
12540 EL_MM_TELEPORTER_RED_16,
12541 EL_MM_TELEPORTER_RED_15,
12542 EL_MM_TELEPORTER_RED_14,
12543 EL_MM_TELEPORTER_RED_13,
12544 EL_MM_TELEPORTER_RED_12,
12545 EL_MM_TELEPORTER_RED_11,
12546 EL_MM_TELEPORTER_RED_10,
12547 EL_MM_TELEPORTER_RED_9,
12548 EL_MM_TELEPORTER_RED_8,
12549 EL_MM_TELEPORTER_RED_7,
12550 EL_MM_TELEPORTER_RED_6
12553 EL_MM_TELEPORTER_YELLOW_5,
12554 EL_MM_TELEPORTER_YELLOW_4,
12555 EL_MM_TELEPORTER_YELLOW_3,
12556 EL_MM_TELEPORTER_YELLOW_2,
12557 EL_MM_TELEPORTER_YELLOW_1,
12558 EL_MM_TELEPORTER_YELLOW_16,
12559 EL_MM_TELEPORTER_YELLOW_15,
12560 EL_MM_TELEPORTER_YELLOW_14,
12561 EL_MM_TELEPORTER_YELLOW_13,
12562 EL_MM_TELEPORTER_YELLOW_12,
12563 EL_MM_TELEPORTER_YELLOW_11,
12564 EL_MM_TELEPORTER_YELLOW_10,
12565 EL_MM_TELEPORTER_YELLOW_9,
12566 EL_MM_TELEPORTER_YELLOW_8,
12567 EL_MM_TELEPORTER_YELLOW_7,
12568 EL_MM_TELEPORTER_YELLOW_6
12571 EL_MM_TELEPORTER_GREEN_5,
12572 EL_MM_TELEPORTER_GREEN_4,
12573 EL_MM_TELEPORTER_GREEN_3,
12574 EL_MM_TELEPORTER_GREEN_2,
12575 EL_MM_TELEPORTER_GREEN_1,
12576 EL_MM_TELEPORTER_GREEN_16,
12577 EL_MM_TELEPORTER_GREEN_15,
12578 EL_MM_TELEPORTER_GREEN_14,
12579 EL_MM_TELEPORTER_GREEN_13,
12580 EL_MM_TELEPORTER_GREEN_12,
12581 EL_MM_TELEPORTER_GREEN_11,
12582 EL_MM_TELEPORTER_GREEN_10,
12583 EL_MM_TELEPORTER_GREEN_9,
12584 EL_MM_TELEPORTER_GREEN_8,
12585 EL_MM_TELEPORTER_GREEN_7,
12586 EL_MM_TELEPORTER_GREEN_6
12589 EL_MM_TELEPORTER_BLUE_5,
12590 EL_MM_TELEPORTER_BLUE_4,
12591 EL_MM_TELEPORTER_BLUE_3,
12592 EL_MM_TELEPORTER_BLUE_2,
12593 EL_MM_TELEPORTER_BLUE_1,
12594 EL_MM_TELEPORTER_BLUE_16,
12595 EL_MM_TELEPORTER_BLUE_15,
12596 EL_MM_TELEPORTER_BLUE_14,
12597 EL_MM_TELEPORTER_BLUE_13,
12598 EL_MM_TELEPORTER_BLUE_12,
12599 EL_MM_TELEPORTER_BLUE_11,
12600 EL_MM_TELEPORTER_BLUE_10,
12601 EL_MM_TELEPORTER_BLUE_9,
12602 EL_MM_TELEPORTER_BLUE_8,
12603 EL_MM_TELEPORTER_BLUE_7,
12604 EL_MM_TELEPORTER_BLUE_6
12608 EL_MM_POLARIZER_16,
12609 EL_MM_POLARIZER_15,
12610 EL_MM_POLARIZER_14,
12611 EL_MM_POLARIZER_13,
12612 EL_MM_POLARIZER_12,
12613 EL_MM_POLARIZER_11,
12614 EL_MM_POLARIZER_10,
12643 EL_DF_MIRROR_ROTATING_1,
12644 EL_DF_MIRROR_ROTATING_16,
12645 EL_DF_MIRROR_ROTATING_15,
12646 EL_DF_MIRROR_ROTATING_14,
12647 EL_DF_MIRROR_ROTATING_13,
12648 EL_DF_MIRROR_ROTATING_12,
12649 EL_DF_MIRROR_ROTATING_11,
12650 EL_DF_MIRROR_ROTATING_10,
12651 EL_DF_MIRROR_ROTATING_9,
12652 EL_DF_MIRROR_ROTATING_8,
12653 EL_DF_MIRROR_ROTATING_7,
12654 EL_DF_MIRROR_ROTATING_6,
12655 EL_DF_MIRROR_ROTATING_5,
12656 EL_DF_MIRROR_ROTATING_4,
12657 EL_DF_MIRROR_ROTATING_3,
12658 EL_DF_MIRROR_ROTATING_2
12661 EL_DF_MIRROR_FIXED_1,
12662 EL_DF_MIRROR_FIXED_16,
12663 EL_DF_MIRROR_FIXED_15,
12664 EL_DF_MIRROR_FIXED_14,
12665 EL_DF_MIRROR_FIXED_13,
12666 EL_DF_MIRROR_FIXED_12,
12667 EL_DF_MIRROR_FIXED_11,
12668 EL_DF_MIRROR_FIXED_10,
12669 EL_DF_MIRROR_FIXED_9,
12670 EL_DF_MIRROR_FIXED_8,
12671 EL_DF_MIRROR_FIXED_7,
12672 EL_DF_MIRROR_FIXED_6,
12673 EL_DF_MIRROR_FIXED_5,
12674 EL_DF_MIRROR_FIXED_4,
12675 EL_DF_MIRROR_FIXED_3,
12676 EL_DF_MIRROR_FIXED_2
12685 for (i = 0; swappable_elements[i][0] != -1; i++)
12687 int element1 = swappable_elements[i][0];
12688 int element2 = swappable_elements[i][1];
12690 if (old_element == element1 || old_element == element2)
12691 new_element = (old_element == element1 ? element2 : element1);
12694 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
12696 for (j = 0; j < 4; j++)
12698 int element = rotatable_elements_4[i][j];
12700 if (old_element == element)
12701 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
12702 button == 2 ? rotatable_elements_4[i][0] :
12703 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
12708 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
12710 for (j = 0; j < 8; j++)
12712 int element = rotatable_elements_8[i][j];
12714 if (old_element == element)
12715 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
12716 button == 2 ? rotatable_elements_8[i][0] :
12717 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
12722 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
12724 for (j = 0; j < 16; j++)
12726 int element = rotatable_elements_16[i][j];
12728 if (old_element == element)
12729 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
12730 button == 2 ? rotatable_elements_16[i][0] :
12731 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
12736 if (old_element != new_element)
12738 int max_infotext_len = getMaxInfoTextLength();
12739 char infotext[MAX_OUTPUT_LINESIZE + 1];
12741 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
12742 infotext[max_infotext_len] = '\0';
12744 ClearEditorGadgetInfoText();
12746 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
12751 if (IS_MM_WALL_EDITOR(new_element))
12752 SetElementSimpleExt(x, y, dx, dy, new_element, change_level);
12754 SetElementSimple(x, y, new_element, change_level);
12760 static void ResetIntelliDraw(void)
12764 for (x = 0; x < lev_fieldx; x++)
12765 for (y = 0; y < lev_fieldy; y++)
12766 IntelliDrawBuffer[x][y] = Tile[x][y];
12768 SetElementIntelliDraw(-1, -1, -1, -1, EL_UNDEFINED, FALSE, -1);
12771 static boolean draw_mode_hires = FALSE;
12773 static boolean isHiresTileElement(int element)
12775 return (IS_MM_WALL(element) || element == EL_EMPTY);
12778 static boolean isHiresDrawElement(int element)
12780 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
12783 static int numHiresTiles(int element)
12785 if (IS_MM_WALL(element))
12786 return get_number_of_bits(MM_WALL_BITS(element));
12791 static void SetDrawModeHiRes(int element)
12794 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12795 isHiresDrawElement(element));
12798 static boolean getDrawModeHiRes(void)
12800 return draw_mode_hires;
12803 static int getLoResScreenPos(int pos)
12805 return (getDrawModeHiRes() ? pos / 2 : pos);
12808 static int getLoResScreenMod(int pos)
12810 return (getDrawModeHiRes() ? pos % 2 : 0);
12813 static void SetElementExt(int x, int y, int dx, int dy, int element,
12814 boolean change_level, int button)
12817 SetElementSimple(x, y, Tile[x][y], change_level);
12818 else if (GetKeyModState() & KMOD_Shift)
12819 SetElementIntelliDraw(x, y, dx, dy, element, change_level, button);
12821 SetElementSimpleExt(x, y, dx, dy, element, change_level);
12824 static void SetElement(int x, int y, int element)
12826 SetElementExt(x, y, 0, 0, element, TRUE, -1);
12829 static void SetElementButton(int x, int y, int dx, int dy, int element,
12832 SetElementExt(x, y, dx, dy, element, TRUE, button);
12835 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
12837 int lx = getLoResScreenPos(sx2) + level_xpos;
12838 int ly = getLoResScreenPos(sy2) + level_ypos;
12839 int dx = getLoResScreenMod(sx2);
12840 int dy = getLoResScreenMod(sy2);
12842 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
12845 static void SetLevelElementHiRes(int lx2, int ly2, int element)
12852 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
12855 static int getLevelElementHiRes(int lx2, int ly2)
12861 int element = Tile[lx][ly];
12862 unsigned int bitmask = (dx + 1) << (dy * 2);
12864 if (IS_MM_WALL(element))
12866 if (element & bitmask)
12867 return map_mm_wall_element(element);
12875 static void DrawLineElement(int x, int y, int element, boolean change_level)
12877 SetElementHiRes(x, y, element, change_level);
12880 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12881 int element, boolean change_level)
12883 int xsize = ABS(to_x - from_x);
12884 int ysize = ABS(to_y - from_y);
12885 int dx = (to_x < from_x ? -1 : +1);
12886 int dy = (to_y < from_y ? -1 : +1);
12889 if (from_y == to_y) // horizontal line
12891 for (i = 0; i <= xsize; i++)
12892 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12894 else if (from_x == to_x) // vertical line
12896 for (i = 0; i <= ysize; i++)
12897 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12899 else // diagonal line
12901 if (ysize < xsize) // a < 1
12903 float a = (float)ysize / (float)xsize;
12905 for (i = 0; i <= xsize; i++)
12908 int y = dy * (int)(a * i + 0.5);
12910 DrawLineElement(from_x + x, from_y + y, element, change_level);
12915 float a = (float)xsize / (float)ysize;
12917 for (i = 0; i <= ysize; i++)
12919 int x = dx * (int)(a * i + 0.5);
12922 DrawLineElement(from_x + x, from_y + y, element, change_level);
12928 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12929 int element, boolean change_level)
12931 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12932 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12933 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12934 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12937 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12938 int element, boolean change_level)
12943 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12945 for (y = from_y; y <= to_y; y++)
12946 DrawLine(from_x, y, to_x, y, element, change_level);
12949 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12950 int element, boolean change_level)
12952 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12953 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12954 int len_x = ABS(to_x - from_x);
12955 int len_y = ABS(to_y - from_y);
12958 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
12960 // not optimal (some points get drawn twice) but simple,
12961 // and fast enough for the few points we are drawing
12963 for (x = 0; x <= radius; x++)
12965 int sx, sy, sx2, sy2, lx, ly;
12967 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
12969 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12970 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12971 sx = getLoResScreenPos(sx2);
12972 sy = getLoResScreenPos(sy2);
12973 lx = sx + level_xpos;
12974 ly = sy + level_ypos;
12976 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12977 DrawLineElement(sx2, sy2, element, change_level);
12980 for (y = 0; y <= radius; y++)
12982 int sx, sy, sx2, sy2, lx, ly;
12984 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
12986 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12987 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12988 sx = getLoResScreenPos(sx2);
12989 sy = getLoResScreenPos(sy2);
12990 lx = sx + level_xpos;
12991 ly = sy + level_ypos;
12993 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12994 DrawLineElement(sx2, sy2, element, change_level);
12998 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
12999 int element, boolean change_level)
13001 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
13002 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
13004 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
13007 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
13009 #if DRAW_CIRCLES_BUTTON_AVAILABLE
13010 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
13011 int element, boolean change_level)
13013 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
13014 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
13015 int mirror_to_x2 = from_x - (to_x2 - from_x);
13016 int mirror_to_y2 = from_y - (to_y2 - from_y);
13018 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
13019 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
13020 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
13021 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element, change_level);
13025 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
13027 int from_sx, from_sy;
13031 swap_numbers(&from_x, &to_x);
13034 swap_numbers(&from_y, &to_y);
13036 from_sx = SX + from_x * ed_tilesize;
13037 from_sy = SY + from_y * ed_tilesize;
13038 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
13039 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
13041 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13042 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13043 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13044 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13046 if (from_x == to_x && from_y == to_y)
13047 MarkTileDirty(from_x/2, from_y/2);
13049 redraw_mask |= REDRAW_FIELD;
13052 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
13053 int element, boolean change_level)
13055 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
13058 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
13059 int element, boolean change_level)
13061 if (element == -1 || change_level)
13062 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
13064 DrawAreaBorder(from_x, from_y, to_x, to_y);
13067 // values for CopyBrushExt()
13068 #define CB_AREA_TO_BRUSH 0
13069 #define CB_BRUSH_TO_CURSOR 1
13070 #define CB_BRUSH_TO_LEVEL 2
13071 #define CB_DELETE_OLD_CURSOR 3
13072 #define CB_DUMP_BRUSH 4
13073 #define CB_DUMP_BRUSH_SMALL 5
13074 #define CB_CLIPBOARD_TO_BRUSH 6
13075 #define CB_BRUSH_TO_CLIPBOARD 7
13076 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
13077 #define CB_UPDATE_BRUSH_POSITION 9
13078 #define CB_FLIP_BRUSH_X 10
13079 #define CB_FLIP_BRUSH_Y 11
13080 #define CB_FLIP_BRUSH_XY 12
13082 #define MAX_CB_PART_SIZE 10
13083 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
13084 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
13085 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
13086 MAX_CB_NUM_LINES * \
13089 static int getFlippedTileExt(int map[], int element)
13093 for (i = 0; map[i] != -1; i++)
13094 if (map[i] == element)
13095 return map[i ^ 1]; // get flipped element by flipping LSB of index
13100 static int getFlippedTileX(int element)
13104 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_RIGHT,
13105 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_RIGHT,
13106 EL_BUG_LEFT, EL_BUG_RIGHT,
13107 EL_SPACESHIP_LEFT, EL_SPACESHIP_RIGHT,
13108 EL_PACMAN_LEFT, EL_PACMAN_RIGHT,
13109 EL_ARROW_LEFT, EL_ARROW_RIGHT,
13110 EL_MOLE_LEFT, EL_MOLE_RIGHT,
13111 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_RIGHT,
13112 EL_YAMYAM_LEFT, EL_YAMYAM_RIGHT,
13113 EL_SP_PORT_LEFT, EL_SP_PORT_RIGHT,
13114 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_RIGHT,
13115 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_RIGHT,
13116 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_RIGHT,
13117 EL_CONVEYOR_BELT_1_LEFT, EL_CONVEYOR_BELT_1_RIGHT,
13118 EL_CONVEYOR_BELT_2_LEFT, EL_CONVEYOR_BELT_2_RIGHT,
13119 EL_CONVEYOR_BELT_3_LEFT, EL_CONVEYOR_BELT_3_RIGHT,
13120 EL_CONVEYOR_BELT_4_LEFT, EL_CONVEYOR_BELT_4_RIGHT,
13121 EL_SPRING_LEFT, EL_SPRING_RIGHT,
13122 EL_SP_CHIP_LEFT, EL_SP_CHIP_RIGHT,
13123 EL_TUBE_VERTICAL_LEFT, EL_TUBE_VERTICAL_RIGHT,
13124 EL_TUBE_LEFT_UP, EL_TUBE_RIGHT_UP,
13125 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_DOWN,
13126 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_RIGHT,
13127 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_TOPRIGHT,
13128 EL_DC_STEELWALL_1_BOTTOMLEFT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13129 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_TOPRIGHT_2,
13130 EL_DC_STEELWALL_1_BOTTOMLEFT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13131 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_RIGHT,
13132 EL_ACID_POOL_TOPLEFT, EL_ACID_POOL_TOPRIGHT,
13133 EL_ACID_POOL_BOTTOMLEFT, EL_ACID_POOL_BOTTOMRIGHT,
13138 return getFlippedTileExt(map, element);
13141 static int getFlippedTileY(int element)
13145 EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY_DOWN,
13146 EL_BD_FIREFLY_UP, EL_BD_FIREFLY_DOWN,
13147 EL_BUG_UP, EL_BUG_DOWN,
13148 EL_SPACESHIP_UP, EL_SPACESHIP_DOWN,
13149 EL_PACMAN_UP, EL_PACMAN_DOWN,
13150 EL_ARROW_UP, EL_ARROW_DOWN,
13151 EL_MOLE_UP, EL_MOLE_DOWN,
13152 EL_BALLOON_SWITCH_UP, EL_BALLOON_SWITCH_DOWN,
13153 EL_YAMYAM_UP, EL_YAMYAM_DOWN,
13154 EL_SP_PORT_UP, EL_SP_PORT_DOWN,
13155 EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN,
13156 EL_SP_GRAVITY_ON_PORT_UP, EL_SP_GRAVITY_ON_PORT_DOWN,
13157 EL_SP_GRAVITY_OFF_PORT_UP, EL_SP_GRAVITY_OFF_PORT_DOWN,
13158 EL_SP_CHIP_TOP, EL_SP_CHIP_BOTTOM,
13159 EL_TUBE_HORIZONTAL_UP, EL_TUBE_HORIZONTAL_DOWN,
13160 EL_TUBE_LEFT_UP, EL_TUBE_LEFT_DOWN,
13161 EL_TUBE_RIGHT_UP, EL_TUBE_RIGHT_DOWN,
13162 EL_DC_STEELWALL_1_TOP, EL_DC_STEELWALL_1_BOTTOM,
13163 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13164 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13165 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13166 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13167 EL_DC_STEELWALL_2_TOP, EL_DC_STEELWALL_2_BOTTOM,
13168 EL_EMC_WALL_1, EL_EMC_WALL_3,
13173 return getFlippedTileExt(map, element);
13176 static int getFlippedTileXY(int element)
13180 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_UP,
13181 EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY_DOWN,
13182 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_UP,
13183 EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY_DOWN,
13184 EL_BUG_LEFT, EL_BUG_UP,
13185 EL_BUG_RIGHT, EL_BUG_DOWN,
13186 EL_SPACESHIP_LEFT, EL_SPACESHIP_UP,
13187 EL_SPACESHIP_RIGHT, EL_SPACESHIP_DOWN,
13188 EL_PACMAN_LEFT, EL_PACMAN_UP,
13189 EL_PACMAN_RIGHT, EL_PACMAN_DOWN,
13190 EL_ARROW_LEFT, EL_ARROW_UP,
13191 EL_ARROW_RIGHT, EL_ARROW_DOWN,
13192 EL_MOLE_LEFT, EL_MOLE_UP,
13193 EL_MOLE_RIGHT, EL_MOLE_DOWN,
13194 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_UP,
13195 EL_BALLOON_SWITCH_RIGHT, EL_BALLOON_SWITCH_DOWN,
13196 EL_YAMYAM_LEFT, EL_YAMYAM_UP,
13197 EL_YAMYAM_RIGHT, EL_YAMYAM_DOWN,
13198 EL_SP_PORT_LEFT, EL_SP_PORT_UP,
13199 EL_SP_PORT_RIGHT, EL_SP_PORT_DOWN,
13200 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_UP,
13201 EL_SP_GRAVITY_PORT_RIGHT, EL_SP_GRAVITY_PORT_DOWN,
13202 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_UP,
13203 EL_SP_GRAVITY_ON_PORT_RIGHT, EL_SP_GRAVITY_ON_PORT_DOWN,
13204 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_UP,
13205 EL_SP_GRAVITY_OFF_PORT_RIGHT, EL_SP_GRAVITY_OFF_PORT_DOWN,
13206 EL_SP_CHIP_LEFT, EL_SP_CHIP_TOP,
13207 EL_SP_CHIP_RIGHT, EL_SP_CHIP_BOTTOM,
13208 EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL,
13209 EL_TUBE_VERTICAL_LEFT, EL_TUBE_HORIZONTAL_UP,
13210 EL_TUBE_VERTICAL_RIGHT, EL_TUBE_HORIZONTAL_DOWN,
13211 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_UP,
13212 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_TOP,
13213 EL_DC_STEELWALL_1_RIGHT, EL_DC_STEELWALL_1_BOTTOM,
13214 EL_DC_STEELWALL_1_HORIZONTAL, EL_DC_STEELWALL_1_VERTICAL,
13215 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13216 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13217 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_TOP,
13218 EL_DC_STEELWALL_2_RIGHT, EL_DC_STEELWALL_2_BOTTOM,
13219 EL_DC_STEELWALL_2_HORIZONTAL, EL_DC_STEELWALL_2_VERTICAL,
13220 EL_EXPANDABLE_WALL_HORIZONTAL, EL_EXPANDABLE_WALL_VERTICAL,
13221 EL_EXPANDABLE_STEELWALL_HORIZONTAL, EL_EXPANDABLE_STEELWALL_VERTICAL,
13226 return getFlippedTileExt(map, element);
13229 static int getFlippedTile(int element, int mode)
13231 if (IS_MM_ELEMENT(element))
13233 // get MM game element
13234 element = map_element_RND_to_MM(element);
13236 // get flipped game element
13237 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX_MM(element) :
13238 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY_MM(element) :
13239 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY_MM(element) :
13242 // get RND game element again
13243 element = map_element_MM_to_RND(element);
13247 // get flipped game element
13248 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX(element) :
13249 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY(element) :
13250 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY(element) :
13257 static void SwapFlippedTiles(short *tile1, short *tile2, int mode)
13260 short tile1_flipped = getFlippedTile(*tile1, mode);
13261 short tile2_flipped = getFlippedTile(*tile2, mode);
13264 *tile1 = tile2_flipped;
13265 *tile2 = tile1_flipped;
13268 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
13270 DrawLineElement(sx, sy, element, change_level);
13273 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
13274 int button, int mode)
13276 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13277 static int brush_width, brush_height;
13278 static int last_cursor_x = -1, last_cursor_y = -1;
13279 static boolean delete_old_brush = FALSE;
13280 int new_element = BUTTON_ELEMENT(button);
13283 if (mode == CB_DUMP_BRUSH ||
13284 mode == CB_DUMP_BRUSH_SMALL ||
13285 mode == CB_BRUSH_TO_CLIPBOARD ||
13286 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13288 if (edit_mode != ED_MODE_DRAWING)
13291 char part[MAX_CB_PART_SIZE + 1] = "";
13292 char text[MAX_CB_TEXT_SIZE + 1] = "";
13293 int width = (draw_with_brush ? brush_width : lev_fieldx);
13294 int height = (draw_with_brush ? brush_height : lev_fieldy);
13295 char *format = "%s%03d";
13297 for (y = 0; y < height; y++)
13298 for (x = 0; x < width; x++)
13299 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
13302 for (y = 0; y < height; y++)
13304 for (x = 0; x < width; x++)
13306 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
13307 char *prefix = (mode == CB_DUMP_BRUSH ||
13308 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
13310 if (element >= NUM_FILE_ELEMENTS)
13311 element = EL_UNKNOWN;
13313 // copy brush to level sketch text buffer for the R'n'D forum:
13314 // - large tiles: `xxx or `xxxx (0x60 ASCII)
13315 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
13316 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
13317 strcat(text, part);
13320 strcat(text, "\n");
13323 if (mode == CB_BRUSH_TO_CLIPBOARD ||
13324 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13325 SDL_SetClipboardText(text);
13327 Print("%s", text); // print brush data to console and log file
13332 if (mode == CB_CLIPBOARD_TO_BRUSH)
13334 if (edit_mode != ED_MODE_DRAWING)
13337 if (!SDL_HasClipboardText())
13339 Request("Clipboard is empty!", REQ_CONFIRM);
13344 boolean copy_to_brush = (draw_with_brush ||
13345 drawing_function == GADGET_ID_GRAB_BRUSH);
13347 // this will delete the old brush, if already drawing with a brush
13349 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
13351 // initialization is required for "odd" (incomplete) clipboard content
13352 for (x = 0; x < MAX_LEV_FIELDX; x++)
13353 for (y = 0; y < MAX_LEV_FIELDY; y++)
13354 brush_buffer[x][y] = EL_EMPTY;
13361 char *clipboard_text = SDL_GetClipboardText();
13362 char *ptr = clipboard_text;
13363 boolean allow_new_row = FALSE;
13364 boolean stop = FALSE;
13366 while (*ptr && !stop)
13368 boolean prefix_found = FALSE;
13369 boolean start_new_row = FALSE;
13371 // level sketch element number prefixes (may be multi-byte characters)
13372 char *prefix_list[] = { "`", "¸" };
13375 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
13377 char *prefix = prefix_list[i];
13379 // check if string is large enough for prefix
13380 if (strlen(ptr) < strlen(prefix))
13387 // check if string starts with prefix
13388 if (strPrefix(ptr, prefix))
13390 ptr += strlen(prefix);
13392 prefix_found = TRUE;
13398 // check if prefix found and followed by (at least) three digits
13399 if (prefix_found &&
13400 strlen(ptr) >= 3 &&
13401 ptr[0] >= '0' && ptr[0] <= '9' &&
13402 ptr[1] >= '0' && ptr[1] <= '9' &&
13403 ptr[2] >= '0' && ptr[2] <= '9')
13405 int element = ((ptr[0] - '0') * 100 +
13406 (ptr[1] - '0') * 10 +
13411 // level sketch element number might consist of four digits
13412 if (ptr[0] >= '0' && ptr[0] <= '9')
13414 element = element * 10 + (ptr[0] - '0');
13418 // remap some (historic, now obsolete) elements
13419 element = getMappedElement(element);
13421 if (element >= NUM_FILE_ELEMENTS)
13422 element = EL_UNKNOWN;
13424 brush_buffer[x][y] = element;
13426 brush_width = MAX(x + 1, brush_width);
13427 brush_height = MAX(y + 1, brush_height);
13431 if (x >= MAX_LEV_FIELDX)
13432 start_new_row = TRUE;
13434 allow_new_row = TRUE;
13438 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
13439 start_new_row = TRUE;
13441 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
13449 if (y >= MAX_LEV_FIELDY)
13452 allow_new_row = FALSE;
13456 SDL_free(clipboard_text);
13458 if (brush_width == 0 || brush_height == 0)
13460 Request("No level sketch found in clipboard!", REQ_CONFIRM);
13467 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
13470 SDL_GetMouseState(&mx, &my);
13472 // if inside drawing area, activate and draw brush at last mouse position
13473 if (mx >= gi->x && mx < gi->x + gi->width &&
13474 my >= gi->y && my < gi->y + gi->height)
13475 CopyBrushToCursor(last_cursor_x, last_cursor_y);
13477 draw_with_brush = TRUE;
13483 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
13484 brush_width, brush_height);
13486 if (!Request(request, REQ_ASK))
13489 for (x = 0; x < MAX_LEV_FIELDX; x++)
13490 for (y = 0; y < MAX_LEV_FIELDY; y++)
13491 Tile[x][y] = brush_buffer[x][y];
13493 lev_fieldx = level.fieldx = brush_width;
13494 lev_fieldy = level.fieldy = brush_height;
13496 boolean use_bd_engine = TRUE;
13497 boolean use_em_engine = TRUE;
13498 boolean use_sp_engine = TRUE;
13499 boolean use_mm_engine = TRUE;
13501 for (x = 0; x < MAX_LEV_FIELDX; x++)
13503 for (y = 0; y < MAX_LEV_FIELDY; y++)
13505 int element = Tile[x][y];
13507 if (!IS_BD_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13508 use_bd_engine = FALSE;
13510 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13511 use_em_engine = FALSE;
13513 if (!IS_SP_ELEMENT(element))
13514 use_sp_engine = FALSE;
13516 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
13517 use_mm_engine = FALSE;
13521 level.game_engine_type = (use_bd_engine ? GAME_ENGINE_TYPE_BD :
13522 use_em_engine ? GAME_ENGINE_TYPE_EM :
13523 use_sp_engine ? GAME_ENGINE_TYPE_SP :
13524 use_mm_engine ? GAME_ENGINE_TYPE_MM :
13525 GAME_ENGINE_TYPE_RND);
13527 // update element selection list
13528 ReinitializeElementList();
13529 ModifyEditorElementList();
13531 SetBorderElement();
13533 DrawEditModeWindow();
13534 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13540 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
13543 if (mode == CB_AREA_TO_BRUSH)
13545 int from_lx, from_ly;
13548 swap_numbers(&from_x, &to_x);
13551 swap_numbers(&from_y, &to_y);
13553 brush_width = to_x - from_x + 1;
13554 brush_height = to_y - from_y + 1;
13556 from_lx = from_x + level_xpos;
13557 from_ly = from_y + level_ypos;
13559 for (y = 0; y < brush_height; y++)
13561 for (x = 0; x < brush_width; x++)
13563 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
13566 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
13571 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13573 delete_old_brush = FALSE;
13575 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
13576 mode == CB_BRUSH_TO_LEVEL)
13578 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
13579 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
13580 int cursor_from_x = cursor_x - brush_width / 2;
13581 int cursor_from_y = cursor_y - brush_height / 2;
13582 int border_from_x = cursor_x, border_from_y = cursor_y;
13583 int border_to_x = cursor_x, border_to_y = cursor_y;
13585 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
13586 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13588 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
13589 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
13591 delete_old_brush = FALSE;
13596 for (y = 0; y < brush_height; y++)
13598 for (x = 0; x < brush_width; x++)
13600 int sx = cursor_from_x + x;
13601 int sy = cursor_from_y + y;
13602 int lx = sx + level_xpos;
13603 int ly = sy + level_ypos;
13604 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
13605 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
13606 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
13607 brush_buffer[x][y] : new_element);
13609 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13611 if (sx < border_from_x)
13612 border_from_x = sx;
13613 else if (sx > border_to_x)
13615 if (sy < border_from_y)
13616 border_from_y = sy;
13617 else if (sy > border_to_y)
13620 DrawBrushElement(sx, sy, element, change_level);
13625 if (mode != CB_DELETE_OLD_CURSOR)
13626 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
13628 last_cursor_x = cursor_x;
13629 last_cursor_y = cursor_y;
13631 delete_old_brush = TRUE;
13633 else if (mode == CB_FLIP_BRUSH_X)
13635 for (y = 0; y < brush_height; y++)
13636 for (x = 0; x < (brush_width + 1) / 2; x++)
13637 SwapFlippedTiles(&brush_buffer[x][y],
13638 &brush_buffer[brush_width - x - 1][y], mode);
13640 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13642 else if (mode == CB_FLIP_BRUSH_Y)
13644 for (y = 0; y < (brush_height + 1) / 2; y++)
13645 for (x = 0; x < brush_width; x++)
13646 SwapFlippedTiles(&brush_buffer[x][y],
13647 &brush_buffer[x][brush_height - y - 1], mode);
13649 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13651 else if (mode == CB_FLIP_BRUSH_XY)
13653 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13655 for (y = 0; y < MAX(brush_width, brush_height); y++)
13656 for (x = 0; x <= y; x++)
13657 SwapFlippedTiles(&brush_buffer[x][y],
13658 &brush_buffer[y][x], mode);
13660 swap_numbers(&brush_width, &brush_height);
13662 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13665 if (mode == CB_UPDATE_BRUSH_POSITION)
13667 last_cursor_x = from_x;
13668 last_cursor_y = from_y;
13672 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
13675 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
13678 static void CopyBrushToLevel(int x, int y, int button)
13680 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
13683 static void CopyBrushToCursor(int x, int y)
13685 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13688 static void UpdateBrushPosition(int x, int y)
13690 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
13693 static void DeleteBrushFromCursor(void)
13695 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13698 static void FlipBrushX(void)
13700 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13703 static void FlipBrushY(void)
13705 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_Y);
13708 static void RotateBrush(void)
13710 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_XY);
13711 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13714 void DumpBrush(void)
13716 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
13719 void DumpBrush_Small(void)
13721 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
13724 void CopyClipboardToBrush(void)
13726 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
13729 void CopyBrushToClipboard(void)
13731 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
13734 void CopyBrushToClipboard_Small(void)
13736 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
13739 void UndoLevelEditorOperation(void)
13741 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
13744 void RedoLevelEditorOperation(void)
13746 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13749 static void FloodFill(int from_x, int from_y, int fill_element)
13751 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
13754 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
13756 int from_x = from_sx2 + 2 * level_xpos;
13757 int from_y = from_sy2 + 2 * level_ypos;
13758 int max_fillx = lev_fieldx * 2;
13759 int max_filly = lev_fieldy * 2;
13760 short Fill[max_fillx][max_filly];
13763 for (x = 0; x < max_fillx; x++)
13764 for (y = 0; y < max_filly; y++)
13765 Fill[x][y] = getLevelElementHiRes(x, y);
13767 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
13768 Fill, max_fillx, max_filly);
13770 for (x = 0; x < max_fillx; x++)
13771 for (y = 0; y < max_filly; y++)
13772 if (Fill[x][y] == fill_element)
13773 SetLevelElementHiRes(x, y, Fill[x][y]);
13776 // values for DrawLevelText() modes
13777 #define TEXT_INIT 0
13778 #define TEXT_SETCURSOR 1
13779 #define TEXT_WRITECHAR 2
13780 #define TEXT_BACKSPACE 3
13781 #define TEXT_NEWLINE 4
13783 #define TEXT_QUERY_TYPING 6
13785 static int DrawLevelText(int sx, int sy, char letter, int mode)
13787 static short delete_buffer[MAX_LEV_FIELDX];
13788 static int start_sx;
13789 static int last_sx, last_sy;
13790 static boolean typing = FALSE;
13791 int letter_element;
13792 int lx = 0, ly = 0;
13794 // map lower case letters to upper case and convert special characters
13795 if (letter >= 'a' && letter <= 'z')
13796 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
13797 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
13798 letter_element = EL_CHAR_AUMLAUT;
13799 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
13800 letter_element = EL_CHAR_OUMLAUT;
13801 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
13802 letter_element = EL_CHAR_UUMLAUT;
13803 else if (letter == '^')
13804 letter_element = EL_CHAR_COPYRIGHT;
13806 letter_element = EL_CHAR_ASCII0 + letter;
13808 if (mode != TEXT_INIT)
13813 if (mode != TEXT_SETCURSOR)
13819 lx = last_sx + level_xpos;
13820 ly = last_sy + level_ypos;
13827 DrawLevelText(0, 0, 0, TEXT_END);
13833 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
13836 case TEXT_SETCURSOR:
13837 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
13838 DrawAreaBorder(sx, sy, sx, sy);
13839 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
13840 ed_tilesize, ed_tilesize);
13845 case TEXT_WRITECHAR:
13846 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
13848 if (new_element1 >= EL_STEEL_CHAR_START &&
13849 new_element1 <= EL_STEEL_CHAR_END)
13850 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
13852 delete_buffer[sx - start_sx] = Tile[lx][ly];
13853 Tile[lx][ly] = letter_element;
13855 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
13856 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
13857 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13858 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13860 DrawLevelText(0, 0, 0, TEXT_END);
13862 level.changed = TRUE;
13866 case TEXT_BACKSPACE:
13869 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
13870 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
13871 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
13876 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13877 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13879 DrawLevelText(0, 0, 0, TEXT_END);
13883 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13884 DrawEditorElement(sx, sy, Tile[lx][ly]);
13889 case TEXT_QUERY_TYPING:
13899 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
13900 int element, boolean change_level)
13902 int lx = sx + level_xpos;
13903 int ly = sy + level_ypos;
13906 DrawEditorElement(sx, sy, Tile[lx][ly]);
13908 DrawAreaBorder(sx, sy, sx, sy);
13911 static void CheckLevelBorderElement(boolean redraw_playfield)
13913 int last_border_element = BorderElement;
13915 SetBorderElement();
13917 if (redraw_playfield && BorderElement != last_border_element)
13918 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13921 static void CopyLevelToUndoBuffer(int mode)
13923 static boolean accumulated_undo = FALSE;
13924 boolean new_undo_buffer_position = TRUE;
13927 if (undo_buffer_steps == 0)
13928 accumulated_undo = FALSE;
13932 case UNDO_IMMEDIATE:
13933 accumulated_undo = FALSE;
13936 case UNDO_ACCUMULATE:
13937 if (accumulated_undo)
13938 new_undo_buffer_position = FALSE;
13939 accumulated_undo = TRUE;
13946 if (new_undo_buffer_position)
13948 // advance position in undo buffer ring
13949 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13951 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
13952 undo_buffer_steps++;
13955 // always reset redo buffer when storing level change into undo buffer
13956 redo_buffer_steps = 0;
13958 for (x = 0; x < lev_fieldx; x++)
13959 for (y = 0; y < lev_fieldy; y++)
13960 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
13962 // check if drawing operation forces change of border style
13963 CheckLevelBorderElement(TRUE);
13965 level.changed = TRUE;
13968 static void RandomPlacement(int new_element)
13970 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13971 int num_free_positions = 0;
13972 int num_percentage, num_elements;
13975 ResetIntelliDraw();
13977 // determine number of free positions for randomly placing the new element
13978 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
13980 free_position[x][y] =
13981 (random_placement_background_restricted ?
13982 Tile[x][y] == random_placement_background_element :
13983 Tile[x][y] != new_element);
13985 if (free_position[x][y])
13986 num_free_positions++;
13989 // determine number of new elements to place there
13990 num_percentage = num_free_positions * random_placement_value / 100;
13991 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
13992 num_percentage : random_placement_value);
13994 // if less free positions than elements to place, fill all these positions
13995 if (num_free_positions < num_elements)
13997 for (x = 0; x < lev_fieldx; x++)
13998 for (y = 0; y < lev_fieldy; y++)
13999 if (free_position[x][y])
14000 SetElement(x, y, new_element);
14004 while (num_elements > 0)
14006 x = GetSimpleRandom(lev_fieldx);
14007 y = GetSimpleRandom(lev_fieldy);
14009 // don't place element at the same position twice
14010 if (free_position[x][y])
14012 free_position[x][y] = FALSE;
14013 SetElement(x, y, new_element);
14019 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14020 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14023 static void WrapLevel(int dx, int dy)
14025 int wrap_dx = lev_fieldx - dx;
14026 int wrap_dy = lev_fieldy - dy;
14029 for (x = 0; x < lev_fieldx; x++)
14030 for (y = 0; y < lev_fieldy; y++)
14031 TileBackup[x][y] = Tile[x][y];
14033 for (x = 0; x < lev_fieldx; x++)
14034 for (y = 0; y < lev_fieldy; y++)
14036 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
14038 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14039 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
14042 static void DrawAreaElementHighlight(boolean highlighted,
14043 boolean highlighted_similar)
14045 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14052 for (x = 0; x < ed_fieldx; x++)
14054 for (y = 0; y < ed_fieldy; y++)
14056 boolean highlight = FALSE;
14057 int lx = x + level_xpos;
14058 int ly = y + level_ypos;
14060 if (!IN_LEV_FIELD(lx, ly))
14063 // check if element is the same
14064 if (Tile[lx][ly] == new_element1)
14067 // check if element is similar
14068 if (highlighted_similar &&
14069 strEqual(element_info[Tile[lx][ly]].class_name,
14070 element_info[new_element1].class_name))
14073 // check if element is matching MM style wall
14074 if (IS_MM_WALL(Tile[lx][ly]) &&
14075 map_mm_wall_element(Tile[lx][ly]) == new_element1)
14081 if (IS_MM_WALL(Tile[lx][ly]) && !highlighted_similar)
14085 for (i = 0; i < 4; i++)
14087 if (!(MM_WALL_BITS(Tile[lx][ly]) & (1 << i)))
14090 int xx = x * 2 + (i % 2);
14091 int yy = y * 2 + (i / 2);
14092 int sx = SX + xx * ed_tilesize / 2;
14093 int sy = SY + yy * ed_tilesize / 2;
14096 int to_sx = sx + ed_tilesize / 2 - 1;
14097 int to_sy = sy + ed_tilesize / 2 - 1;
14099 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
14100 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
14101 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14102 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14107 int sx = SX + x * ed_tilesize;
14108 int sy = SY + y * ed_tilesize;
14111 int to_sx = sx + ed_tilesize - 1;
14112 int to_sy = sy + ed_tilesize - 1;
14114 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
14115 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
14116 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14117 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14123 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
14125 char *template_filename_old = getLocalLevelTemplateFilename();
14126 char *template_filename_new =
14127 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
14129 if (copyFile(template_filename_old, template_filename_new) != 0)
14130 Request("Cannot copy level template!", REQ_CONFIRM);
14132 free(template_filename_new);
14135 static void HandleDrawingAreas(struct GadgetInfo *gi)
14137 static boolean started_inside_drawing_area = FALSE;
14138 static int last_sx = -1;
14139 static int last_sy = -1;
14140 static int last_sx2 = -1;
14141 static int last_sy2 = -1;
14142 int id = gi->custom_id;
14143 int type_id = gi->custom_type_id;
14144 boolean button_press_event;
14145 boolean button_release_event;
14146 boolean inside_drawing_area = !gi->event.off_borders;
14147 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
14148 int actual_drawing_function;
14149 int button = gi->event.button;
14150 int new_element = BUTTON_ELEMENT(button);
14151 int sx = gi->event.x, sy = gi->event.y;
14152 int min_sx = 0, min_sy = 0;
14153 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
14154 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
14155 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
14156 int sx2 = gi->event.mx / mini_item_xsize;
14157 int sy2 = gi->event.my / mini_item_ysize;
14160 int lx = 0, ly = 0;
14163 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
14164 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
14166 // make sure to stay inside drawing area boundaries
14167 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14168 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14172 int min_lx = 0, min_ly = 0;
14173 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14175 // get positions inside level field
14176 lx = sx + level_xpos;
14177 ly = sy + level_ypos;
14179 if (!IN_LEV_FIELD(lx, ly))
14180 inside_drawing_area = FALSE;
14182 // make sure to stay inside level field boundaries
14183 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14184 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14186 // correct drawing area positions accordingly
14187 sx = lx - level_xpos;
14188 sy = ly - level_ypos;
14191 // also correct MM wall-sized (double) drawing area positions accordingly
14192 if (sx2 / 2 < sx || sx2 / 2 > sx)
14194 dx = (sx2 / 2 < sx ? 0 : 1);
14197 if (sy2 / 2 < sy || sy2 / 2 > sy)
14199 dy = (sy2 / 2 < sy ? 0 : 1);
14203 if (!button_press_event && !button_release_event)
14205 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
14206 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
14207 isHiresTileElement(old_element) &&
14208 isHiresDrawElement(new_element));
14210 // prevent handling events for every pixel position when moving mouse
14211 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
14212 (sx2 == last_sx2 && sy2 == last_sy2))
14221 if (button_press_event)
14222 started_inside_drawing_area = inside_drawing_area;
14224 if (!started_inside_drawing_area)
14227 if (!IS_VALID_BUTTON(button))
14230 // handle info callback for each invocation of action callback
14231 gi->callback_info(gi);
14233 // automatically switch to 'single item' drawing mode, if needed
14234 actual_drawing_function =
14235 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
14236 drawing_function : GADGET_ID_SINGLE_ITEMS);
14238 // clicking into drawing area with pressed Control key picks element
14239 if (GetKeyModState() & KMOD_Control)
14241 last_drawing_function = drawing_function;
14242 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14245 if (GetKeyModState() & KMOD_Shift)
14247 if (button_press_event || button_release_event)
14248 ResetIntelliDraw();
14251 SetDrawModeHiRes(-1); // reset to normal draw mode
14253 switch (actual_drawing_function)
14255 case GADGET_ID_SINGLE_ITEMS:
14258 if (button_release_event)
14260 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14262 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
14263 !inside_drawing_area)
14264 DeleteBrushFromCursor();
14269 if (draw_with_brush)
14271 CopyBrushToLevel(sx, sy, button);
14275 SetDrawModeHiRes(new_element);
14277 if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
14279 // remove player at old position
14280 for (y = 0; y < lev_fieldy; y++)
14282 for (x = 0; x < lev_fieldx; x++)
14284 int old_element = Tile[x][y];
14286 if (IS_PLAYER_ELEMENT(old_element) &&
14287 IS_PLAYER_ELEMENT(new_element))
14289 int replaced_with_element =
14290 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
14291 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
14293 old_element == EL_SOKOBAN_FIELD_PLAYER &&
14294 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
14296 new_element == EL_SOKOBAN_FIELD_PLAYER &&
14297 old_element == EL_PLAYER_1 ? EL_EMPTY :
14299 new_element >= EL_PLAYER_1 &&
14300 new_element <= EL_PLAYER_4 &&
14301 new_element == old_element ? EL_EMPTY :
14305 SetElement(x, y, replaced_with_element);
14307 else if (IS_MM_MCDUFFIN(old_element) &&
14308 IS_MM_MCDUFFIN(new_element))
14310 // remove McDuffin at old position
14311 SetElement(x, y, EL_EMPTY);
14317 SetElementButton(lx, ly, dx, dy, new_element, button);
14320 else if (!button_release_event)
14322 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14324 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
14325 DrawMiniGraphicExt(drawto,
14326 gi->x + sx * MINI_TILEX,
14327 gi->y + sy * MINI_TILEY,
14328 el2edimg(new_element));
14330 DrawFixedGraphicExt(drawto,
14331 gi->x + sx * TILEX,
14332 gi->y + sy * TILEY,
14333 el2edimg(new_element), 0);
14335 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14336 new_element = GFX_ELEMENT(new_element);
14338 drawingarea_info[type_id].value[pos] = new_element;
14340 CopyElementPropertiesToGame(properties_element);
14342 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14344 UpdateCustomElementGraphicGadgets();
14346 FrameCounter = 0; // restart animation frame counter
14351 case GADGET_ID_CONNECTED_ITEMS:
14353 static int last_sx = -1;
14354 static int last_sy = -1;
14356 if (button_release_event)
14357 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14359 SetDrawModeHiRes(new_element);
14361 if (getDrawModeHiRes())
14367 if (!button_press_event)
14368 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
14375 case GADGET_ID_LINE:
14376 case GADGET_ID_ARC:
14377 case GADGET_ID_RECTANGLE:
14378 case GADGET_ID_FILLED_BOX:
14379 SetDrawModeHiRes(new_element);
14381 if (getDrawModeHiRes())
14387 case GADGET_ID_GRAB_BRUSH:
14388 case GADGET_ID_TEXT:
14390 static int last_sx = -1;
14391 static int last_sy = -1;
14392 static int start_sx = -1;
14393 static int start_sy = -1;
14394 void (*draw_func)(int, int, int, int, int, boolean);
14396 if (drawing_function == GADGET_ID_LINE)
14397 draw_func = DrawLine;
14398 else if (drawing_function == GADGET_ID_ARC)
14399 draw_func = DrawArc;
14400 else if (drawing_function == GADGET_ID_RECTANGLE)
14401 draw_func = DrawBox;
14402 else if (drawing_function == GADGET_ID_FILLED_BOX)
14403 draw_func = DrawFilledBox;
14404 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
14405 draw_func = SelectArea;
14406 else // (drawing_function == GADGET_ID_TEXT)
14407 draw_func = SetTextCursor;
14409 if (button_press_event)
14411 draw_func(sx, sy, sx, sy, new_element, FALSE);
14412 start_sx = last_sx = sx;
14413 start_sy = last_sy = sy;
14415 if (drawing_function == GADGET_ID_TEXT)
14416 DrawLevelText(0, 0, 0, TEXT_END);
14418 else if (button_release_event)
14420 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
14421 if (drawing_function == GADGET_ID_GRAB_BRUSH)
14423 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
14424 CopyBrushToCursor(sx, sy);
14425 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14427 draw_with_brush = TRUE;
14429 else if (drawing_function == GADGET_ID_TEXT)
14430 DrawLevelText(sx, sy, 0, TEXT_INIT);
14432 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14434 else if (last_sx != sx || last_sy != sy)
14436 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
14437 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
14438 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
14439 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
14446 case GADGET_ID_FLOOD_FILL:
14447 if (button_press_event && Tile[lx][ly] != new_element)
14449 if (IS_MM_WALL_EDITOR(new_element))
14450 FloodFillWall_MM(sx2, sy2, new_element);
14452 FloodFill(lx, ly, new_element);
14454 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14455 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14459 case GADGET_ID_PICK_ELEMENT:
14460 if (button_release_event)
14461 ClickOnGadget(level_editor_gadget[last_drawing_function],
14463 else if (draw_level)
14464 PickDrawingElement(button, Tile[lx][ly]);
14467 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14469 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
14476 // do not mark level as modified for certain non-level-changing gadgets
14477 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
14478 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
14479 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
14480 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14483 level.changed = TRUE;
14486 static void HandleCounterButtons(struct GadgetInfo *gi)
14488 int gadget_id = gi->custom_id;
14489 int counter_id = gi->custom_type_id;
14490 int button = gi->event.button;
14491 int *counter_value = counterbutton_info[counter_id].value;
14492 int step = BUTTON_STEPSIZE(button) *
14493 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
14495 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14497 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
14498 boolean released = (gi->event.type == GD_EVENT_RELEASED);
14499 boolean level_changed = LevelChanged();
14501 if ((level_changed && pressed) || (!level_changed && released))
14504 if (level_changed && !Request("Level has changed! Discard changes?",
14507 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14508 ModifyEditorCounterValue(counter_id, *counter_value);
14514 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14515 *counter_value = gi->textinput.number_value;
14517 ModifyEditorCounterValue(counter_id, *counter_value + step);
14519 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14521 int last_game_engine_type = level.game_engine_type;
14523 LoadLevel(level_nr);
14524 LoadScore(level_nr);
14526 SaveLevelSetup_SeriesInfo();
14531 DrawEditModeWindow();
14533 if (level.game_engine_type != last_game_engine_type)
14535 // update element selection list
14536 ReinitializeElementList();
14537 ModifyEditorElementList();
14543 switch (counter_id)
14545 case ED_COUNTER_ID_YAMYAM_CONTENT:
14546 DrawYamYamContentAreas();
14549 case ED_COUNTER_ID_BALL_CONTENT:
14550 DrawMagicBallContentAreas();
14553 case ED_COUNTER_ID_ANDROID_CONTENT:
14554 DrawAndroidElementArea();
14557 case ED_COUNTER_ID_GROUP_CONTENT:
14558 DrawGroupElementArea();
14559 CopyGroupElementPropertiesToGame(properties_element);
14562 case ED_COUNTER_ID_INVENTORY_SIZE:
14563 DrawPlayerInitialInventoryArea(properties_element);
14566 case ED_COUNTER_ID_MM_BALL_CONTENT:
14567 DrawMMBallContentArea();
14570 case ED_COUNTER_ID_ENVELOPE_XSIZE:
14571 case ED_COUNTER_ID_ENVELOPE_YSIZE:
14572 DrawEnvelopeTextArea(-1);
14575 case ED_COUNTER_ID_LEVEL_XSIZE:
14576 case ED_COUNTER_ID_LEVEL_YSIZE:
14577 lev_fieldx = level.fieldx;
14578 lev_fieldy = level.fieldy;
14580 // check if resizing of level results in change of border border
14581 SetBorderElement();
14589 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
14590 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
14591 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
14592 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
14593 CopyElementPropertiesToGame(properties_element);
14595 // do not mark level as modified for certain non-level-changing gadgets
14596 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
14597 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
14598 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
14599 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
14602 level.changed = TRUE;
14605 static void HandleTextInputGadgets(struct GadgetInfo *gi)
14607 int type_id = gi->custom_type_id;
14609 strcpy(textinput_info[type_id].value, gi->textinput.value);
14611 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
14613 CopyElementPropertiesToGame(properties_element);
14615 ModifyEditorElementList(); // update changed button info text
14618 // do not mark level as modified for certain non-level-changing gadgets
14619 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
14620 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
14623 level.changed = TRUE;
14626 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
14628 int type_id = gi->custom_type_id;
14630 strncpy(textarea_info[type_id].value, gi->textarea.value,
14631 MAX_ENVELOPE_TEXT_LEN);
14632 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
14634 level.changed = TRUE;
14637 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
14639 int type_id = gi->custom_type_id;
14640 int value_old = *selectbox_info[type_id].value;
14641 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
14643 *selectbox_info[type_id].value = value_new;
14645 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
14647 DrawLevelConfigWindow();
14649 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14651 element_info[properties_element].current_change_page = gi->selectbox.index;
14653 DrawPropertiesWindow();
14655 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
14656 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
14657 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
14658 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
14659 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
14661 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
14663 // when changing action type, also check action mode and action arg
14664 if (value_old != value_new)
14665 setSelectboxSpecialActionVariablesIfNeeded();
14667 DrawPropertiesChange();
14670 CopyElementPropertiesToGame(properties_element);
14672 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
14674 // show or hide "engine" tabulator depending on game engine type
14675 DrawLevelConfigWindow();
14677 // update element selection list depending on game engine type
14678 ReinitializeElementList();
14679 ModifyEditorElementList();
14681 else if (type_id == ED_SELECTBOX_ID_BD_SCHEDULING_TYPE)
14683 // update BD cycle delay counter gadgets depending on BD scheduling type
14684 DrawLevelConfigWindow();
14687 // do not mark level as modified for certain non-level-changing gadgets
14688 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
14689 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14692 level.changed = TRUE;
14695 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
14697 int type_id = gi->custom_type_id;
14700 if (type_id >= ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST &&
14701 type_id <= ED_TAB_BUTTON_ID_LEVELCONFIG_LAST)
14703 edit_mode_levelconfig = gi->custom_type_id;
14705 DrawLevelConfigWindow();
14707 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
14708 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
14710 edit_mode_properties = gi->custom_type_id;
14712 DrawPropertiesWindow();
14714 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
14715 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
14717 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
14719 // backup original "level.field" (needed to track playfield changes)
14720 CopyPlayfield(level.field, TileBackup);
14722 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
14723 CopyPlayfield(Tile, level.field);
14725 if (new_template ||
14726 Request("Save this template and kill the old?", REQ_ASK))
14727 SaveLevelTemplate();
14730 Request("Template saved!", REQ_CONFIRM);
14732 // restore original "level.field" (needed to track playfield changes)
14733 CopyPlayfield(TileBackup, level.field);
14735 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
14737 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
14739 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
14740 leveldir_current->readonly)
14742 Request("This level set is read-only!", REQ_CONFIRM);
14747 if (strEqual(levelset_name, ""))
14749 Request("Please enter level set title!", REQ_CONFIRM);
14754 if (strEqual(levelset_author, ""))
14756 Request("Please enter level set author!", REQ_CONFIRM);
14761 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
14763 if (UpdateUserLevelSet(levelset_subdir,
14766 levelset_num_levels))
14768 Request("Level set updated!", REQ_CONFIRM);
14772 Request("Updating level set failed!", REQ_CONFIRM);
14775 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
14777 if (level.changed && !Request("Level has changed! Discard changes?",
14781 if (CreateUserLevelSet(levelset_subdir,
14784 levelset_num_levels,
14785 levelset_use_levelset_artwork))
14787 if (levelset_copy_level_template)
14788 CopyLevelTemplateToUserLevelSet(levelset_subdir);
14790 Request("New level set created!", REQ_CONFIRM);
14792 AddUserLevelSetToLevelInfo(levelset_subdir);
14793 ChangeEditorToLevelSet(levelset_subdir);
14797 Request("Creating new level set failed!", REQ_CONFIRM);
14801 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
14802 custom_element.num_change_pages < MAX_CHANGE_PAGES)
14804 struct ElementInfo *ei = &element_info[properties_element];
14806 // when modifying custom element, ask for copying level template
14807 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14810 setElementChangePages(ei, ei->num_change_pages + 1);
14812 // set new change page to be new current change page
14813 ei->current_change_page = ei->num_change_pages - 1;
14814 ei->change = &ei->change_page[ei->current_change_page];
14816 setElementChangeInfoToDefaults(ei->change);
14818 DrawPropertiesWindow();
14820 level.changed = TRUE;
14822 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
14823 custom_element.num_change_pages > MIN_CHANGE_PAGES)
14825 struct ElementInfo *ei = &element_info[properties_element];
14827 // when modifying custom element, ask for copying level template
14828 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14831 // copy all change pages after change page to be deleted
14832 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
14833 ei->change_page[i] = ei->change_page[i + 1];
14835 setElementChangePages(ei, ei->num_change_pages - 1);
14837 DrawPropertiesWindow();
14839 level.changed = TRUE;
14843 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
14845 int type_id = gi->custom_type_id;
14847 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
14848 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
14850 struct ElementInfo *ei = &element_info[properties_element];
14851 int step = BUTTON_STEPSIZE(gi->event.button);
14853 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
14854 ei->current_change_page += step;
14856 if (ei->current_change_page < 0)
14857 ei->current_change_page = 0;
14858 else if (ei->current_change_page >= ei->num_change_pages)
14859 ei->current_change_page = ei->num_change_pages - 1;
14861 DrawPropertiesWindow();
14863 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
14864 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14866 struct ElementInfo *ei = &element_info[properties_element];
14867 int current_change_page = ei->current_change_page;
14869 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
14871 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
14872 ei->change_page[current_change_page];
14874 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14876 // when modifying custom element, ask for copying level template
14877 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14880 ei->change_page[current_change_page] =
14881 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
14883 level.changed = TRUE;
14886 DrawPropertiesWindow();
14890 static void HandleRadiobuttons(struct GadgetInfo *gi)
14892 int type_id = gi->custom_type_id;
14894 *radiobutton_info[type_id].value =
14895 radiobutton_info[type_id].checked_value;
14897 // do not mark level as modified for certain non-level-changing gadgets
14898 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
14899 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
14902 level.changed = TRUE;
14905 static void HandleCheckbuttons(struct GadgetInfo *gi)
14907 int type_id = gi->custom_type_id;
14909 *checkbutton_info[type_id].value ^= TRUE;
14911 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
14912 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
14913 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
14914 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
14915 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
14916 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
14917 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
14918 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
14920 CopyElementPropertiesToGame(properties_element);
14923 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
14925 UpdateCustomElementGraphicGadgets();
14927 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
14928 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
14930 boolean template_related_changes_found = FALSE;
14933 // check if any custom, group or empty elements have been changed
14934 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
14935 if ((IS_CUSTOM_ELEMENT(i) ||
14936 IS_GROUP_ELEMENT(i) ||
14937 IS_EMPTY_ELEMENT(i)) &&
14938 element_info[i].modified_settings)
14939 template_related_changes_found = TRUE;
14941 if (level.use_custom_template &&
14942 !fileExists(getGlobalLevelTemplateFilename()))
14944 Request("No level template found!", REQ_CONFIRM);
14946 level.use_custom_template = FALSE;
14948 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14953 if (level.use_custom_template &&
14954 template_related_changes_found &&
14955 !Request("Discard changes and use level template?", REQ_ASK))
14957 level.use_custom_template = FALSE;
14959 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14964 if (!level.use_custom_template &&
14965 Request("Copy settings from level template?", REQ_ASK))
14970 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
14972 DrawEditModeWindow();
14974 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
14976 if (setup.editor.use_template_for_new_levels &&
14977 !fileExists(getGlobalLevelTemplateFilename()))
14979 Request("No level template found!", REQ_CONFIRM);
14984 if (setup.editor.use_template_for_new_levels &&
14986 !Request("Discard level and load template?", REQ_ASK))
14991 if (!setup.editor.use_template_for_new_levels &&
14993 !Request("Discard level and use empty level?", REQ_ASK))
14998 LoadLevel(level_nr);
14999 LoadScore(level_nr);
15004 DrawEditModeWindow();
15006 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
15008 SetAutomaticNumberOfGemsNeeded();
15011 // do not mark level as modified for certain non-level-changing gadgets
15012 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
15013 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
15014 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
15015 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
15016 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
15017 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
15020 level.changed = TRUE;
15023 static void HandleControlButtons(struct GadgetInfo *gi)
15025 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
15026 static int last_edit_mode = ED_MODE_DRAWING;
15027 static int last_custom_copy_mode = -1;
15028 static int last_button = 0;
15029 int id = gi->custom_id;
15030 int button = gi->event.button;
15031 int step = BUTTON_STEPSIZE(button);
15032 int new_element = BUTTON_ELEMENT(button);
15033 int last_properties_element = properties_element;
15036 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
15037 DrawLevelText(0, 0, 0, TEXT_END);
15039 if (id < ED_NUM_CTRL1_BUTTONS &&
15040 id != GADGET_ID_SINGLE_ITEMS &&
15041 id != GADGET_ID_PICK_ELEMENT &&
15042 edit_mode != ED_MODE_DRAWING &&
15043 drawing_function != GADGET_ID_PICK_ELEMENT &&
15044 !(GetKeyModState() & KMOD_Control))
15045 ChangeEditModeWindow(ED_MODE_DRAWING);
15047 // element copy mode active, but no element button pressed => deactivate
15048 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
15049 last_custom_copy_mode = -1;
15051 // when showing palette on element buttons, change element of button used
15052 if (editor.palette.show_on_element_buttons &&
15053 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
15055 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
15057 id = GADGET_ID_PALETTE;
15062 case GADGET_ID_SCROLL_LEFT:
15063 if (level_xpos >= 0)
15065 if (lev_fieldx < ed_fieldx - 2)
15068 level_xpos -= step;
15069 if (level_xpos < -1)
15072 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
15074 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15076 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
15077 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
15081 case GADGET_ID_SCROLL_RIGHT:
15082 if (level_xpos <= lev_fieldx - ed_fieldx)
15084 if (lev_fieldx < ed_fieldx - 2)
15087 level_xpos += step;
15088 if (level_xpos > lev_fieldx - ed_fieldx + 1)
15089 level_xpos = lev_fieldx - ed_fieldx + 1;
15091 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
15093 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15095 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
15096 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
15100 case GADGET_ID_SCROLL_UP:
15101 if (level_ypos >= 0)
15103 if (lev_fieldy < ed_fieldy - 2)
15106 level_ypos -= step;
15107 if (level_ypos < -1)
15110 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
15112 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15114 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15115 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15119 case GADGET_ID_SCROLL_DOWN:
15120 if (level_ypos <= lev_fieldy - ed_fieldy)
15122 if (lev_fieldy < ed_fieldy - 2)
15125 level_ypos += step;
15126 if (level_ypos > lev_fieldy - ed_fieldy + 1)
15127 level_ypos = lev_fieldy - ed_fieldy + 1;
15129 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
15131 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15133 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15134 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15138 case GADGET_ID_SCROLL_HORIZONTAL:
15139 level_xpos = gi->event.item_position - 1;
15141 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15146 case GADGET_ID_SCROLL_VERTICAL:
15147 level_ypos = gi->event.item_position - 1;
15149 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15154 case GADGET_ID_SCROLL_LIST_UP:
15155 case GADGET_ID_SCROLL_LIST_DOWN:
15156 case GADGET_ID_SCROLL_LIST_VERTICAL:
15157 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
15158 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
15161 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
15162 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15164 if (element_shift < 0)
15166 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15167 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15169 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15170 GDI_SCROLLBAR_ITEM_POSITION,
15171 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15174 ModifyEditorElementList();
15178 case GADGET_ID_PROPERTIES:
15179 // always switch off element properties when they are already displayed
15180 last_properties_element = new_element;
15181 case GADGET_ID_ELEMENT_LEFT:
15182 case GADGET_ID_ELEMENT_MIDDLE:
15183 case GADGET_ID_ELEMENT_RIGHT:
15184 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
15185 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
15186 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
15189 if (edit_mode != ED_MODE_PROPERTIES)
15191 last_edit_mode = edit_mode;
15193 ChangeEditModeWindow(ED_MODE_PROPERTIES);
15195 last_level_drawing_function = drawing_function;
15196 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
15199 else if (properties_element != last_properties_element)
15201 DrawEditModeWindow();
15205 ChangeEditModeWindow(ED_MODE_DRAWING);
15207 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
15212 case GADGET_ID_PALETTE:
15213 if (edit_mode != ED_MODE_PALETTE)
15215 last_edit_mode = edit_mode;
15217 ChangeEditModeWindow(ED_MODE_PALETTE);
15221 ChangeEditModeWindow(last_edit_mode);
15225 case GADGET_ID_WRAP_LEFT:
15226 WrapLevel(-step, 0);
15229 case GADGET_ID_WRAP_RIGHT:
15230 WrapLevel(step, 0);
15233 case GADGET_ID_WRAP_UP:
15234 WrapLevel(0, -step);
15237 case GADGET_ID_WRAP_DOWN:
15238 WrapLevel(0, step);
15241 case GADGET_ID_SINGLE_ITEMS:
15242 case GADGET_ID_CONNECTED_ITEMS:
15243 case GADGET_ID_LINE:
15244 case GADGET_ID_ARC:
15245 case GADGET_ID_TEXT:
15246 case GADGET_ID_RECTANGLE:
15247 case GADGET_ID_FILLED_BOX:
15248 case GADGET_ID_FLOOD_FILL:
15249 case GADGET_ID_GRAB_BRUSH:
15250 case GADGET_ID_PICK_ELEMENT:
15251 if (drawing_function != GADGET_ID_PICK_ELEMENT)
15252 last_drawing_function = drawing_function;
15253 drawing_function = id;
15254 draw_with_brush = FALSE;
15257 case GADGET_ID_RANDOM_PLACEMENT:
15258 RandomPlacement(new_element);
15261 case GADGET_ID_ZOOM:
15262 // zoom level editor tile size in or out (or reset to default size)
15263 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
15264 button == 2 ? ed_tilesize_default :
15265 button == 3 ? ed_tilesize / 2 : ed_tilesize);
15267 // when using touch device, cycle through all zoom tilesizes
15268 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
15269 ed_tilesize = MICRO_TILESIZE;
15271 // limit zoom level by upper and lower bound
15272 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
15274 InitZoomLevelSettings(ed_tilesize);
15276 if (edit_mode == ED_MODE_DRAWING)
15278 DrawDrawingWindow();
15280 // redraw zoom gadget info text
15281 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15284 // save current editor zoom tilesize
15285 SaveSetup_AutoSetup();
15289 case GADGET_ID_CUSTOM_COPY_FROM:
15290 case GADGET_ID_CUSTOM_COPY_TO:
15291 case GADGET_ID_CUSTOM_EXCHANGE:
15292 last_custom_copy_mode = id;
15293 last_drawing_function = drawing_function;
15296 case GADGET_ID_CUSTOM_COPY:
15297 CopyCustomElement(properties_element, -1, id);
15300 case GADGET_ID_CUSTOM_PASTE:
15301 CopyCustomElement(-1, properties_element, id);
15304 case GADGET_ID_UNDO:
15305 if (button < 0) // keep button value (even if modifier keys are pressed)
15307 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
15310 if (button == 1 && undo_buffer_steps == 0)
15312 Request("Undo buffer empty!", REQ_CONFIRM);
15316 else if (button == 2)
15320 else if (button == 3 && redo_buffer_steps == 0)
15322 Request("Redo buffer empty!", REQ_CONFIRM);
15327 if (edit_mode != ED_MODE_DRAWING)
15328 ChangeEditModeWindow(ED_MODE_DRAWING);
15334 undo_buffer_position =
15335 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
15337 undo_buffer_steps--;
15338 redo_buffer_steps++;
15344 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
15346 undo_buffer_steps++;
15347 redo_buffer_steps--;
15350 for (x = 0; x < lev_fieldx; x++)
15351 for (y = 0; y < lev_fieldy; y++)
15352 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
15354 // check if undo operation forces change of border style
15355 CheckLevelBorderElement(FALSE);
15357 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15361 case GADGET_ID_CONF:
15362 if (edit_mode != ED_MODE_LEVELCONFIG)
15364 last_edit_mode = edit_mode;
15366 ChangeEditModeWindow(ED_MODE_LEVELCONFIG);
15370 ChangeEditModeWindow(ED_MODE_DRAWING);
15374 case GADGET_ID_CLEAR:
15375 if (edit_mode != ED_MODE_DRAWING)
15376 ChangeEditModeWindow(ED_MODE_DRAWING);
15378 for (x = 0; x < MAX_LEV_FIELDX; x++)
15379 for (y = 0; y < MAX_LEV_FIELDY; y++)
15380 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
15382 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
15384 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15387 case GADGET_ID_SAVE:
15389 // saving read-only levels into personal level set modifies global vars
15390 // "leveldir_current" and "level_nr"; restore them after saving level
15391 LevelDirTree *leveldir_former = leveldir_current;
15392 int level_nr_former = level_nr;
15393 char *level_filename;
15396 if (leveldir_current->readonly &&
15397 !PrepareSavingIntoPersonalLevelSet())
15400 level_filename = getDefaultLevelFilename(level_nr);
15401 new_level = !fileExists(level_filename);
15404 Request("Save this level and kill the old?", REQ_ASK))
15406 if (leveldir_former->readonly)
15407 ModifyLevelConfigForSavingIntoPersonalLevelSet(leveldir_former->name);
15409 SetAutomaticNumberOfGemsNeeded();
15411 CopyPlayfield(Tile, level.field);
15412 SaveLevel(level_nr);
15414 level.changed = FALSE;
15418 char level_saved_msg[64];
15420 if (leveldir_former->readonly)
15421 sprintf(level_saved_msg,
15422 "Level saved as level %d into personal level set!",
15425 strcpy(level_saved_msg, "Level saved!");
15427 Request(level_saved_msg, REQ_CONFIRM);
15431 // "cd" back to copied-from levelset (in case of saved read-only level)
15432 leveldir_current = leveldir_former;
15433 level_nr = level_nr_former;
15438 case GADGET_ID_TEST:
15439 if (LevelChanged())
15440 level.game_version = GAME_VERSION_ACTUAL;
15442 CopyPlayfield(level.field, TileBackup);
15443 CopyPlayfield(Tile, level.field);
15445 CopyNativeLevel_RND_to_Native(&level);
15447 UnmapLevelEditorGadgets();
15448 UndrawSpecialEditorDoor();
15450 CloseDoor(DOOR_CLOSE_ALL);
15452 // needed before playing if editor playfield area has different size
15453 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
15455 // redraw_mask = REDRAW_ALL;
15457 level_editor_test_game = TRUE;
15459 StartGameActions(FALSE, setup.autorecord, level.random_seed);
15463 case GADGET_ID_EXIT:
15464 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
15468 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
15469 id <= GADGET_ID_ELEMENTLIST_LAST)
15471 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
15473 new_element = editor_elements[element_position + element_shift];
15475 if (IS_EDITOR_CASCADE(new_element))
15479 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
15481 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
15482 boolean *cascade_value = editor_elements_info[i].setup_cascade_value;
15484 if (*cascade_element == new_element)
15486 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
15487 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
15489 // update element selection list
15490 ReinitializeElementList();
15491 ModifyEditorElementList();
15493 // update cascading gadget info text
15494 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15496 // save current editor cascading state
15497 SaveSetup_EditorCascade();
15506 if (last_custom_copy_mode != -1)
15508 if (CopyCustomElement(properties_element, new_element,
15509 last_custom_copy_mode))
15511 ClickOnGadget(level_editor_gadget[last_drawing_function],
15514 last_custom_copy_mode = -1;
15520 // change element of button used to show palette
15521 if (editor.palette.show_on_element_buttons)
15522 button = last_button;
15524 PickDrawingElement(button, new_element);
15526 if (!stick_element_properties_window &&
15527 drawing_function != GADGET_ID_PICK_ELEMENT &&
15528 !(GetKeyModState() & KMOD_Control))
15530 properties_element = new_element;
15531 if (edit_mode == ED_MODE_PROPERTIES)
15532 DrawPropertiesWindow();
15535 if (drawing_function == GADGET_ID_PICK_ELEMENT)
15536 ClickOnGadget(level_editor_gadget[last_drawing_function],
15539 if (!use_permanent_palette)
15540 ChangeEditModeWindow(last_edit_mode);
15543 else if (gi->event.type == GD_EVENT_PRESSED)
15544 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
15545 else if (gi->event.type == GD_EVENT_RELEASED)
15546 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
15547 else if (gi->event.type == GD_EVENT_MOVING)
15548 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
15550 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
15556 void HandleLevelEditorKeyInput(Key key)
15558 char letter = getCharFromKey(key);
15560 if (drawing_function == GADGET_ID_TEXT &&
15561 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
15564 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
15565 else if (key == KSYM_Delete || key == KSYM_BackSpace)
15566 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
15567 else if (key == KSYM_Return)
15568 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
15569 else if (key == KSYM_Escape)
15570 DrawLevelText(0, 0, 0, TEXT_END);
15575 int id = GADGET_ID_NONE;
15576 int new_element_shift = element_shift;
15577 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
15578 int button = MB_LEFTBUTTON;
15584 id = GADGET_ID_SCROLL_LEFT;
15587 id = GADGET_ID_SCROLL_RIGHT;
15590 id = GADGET_ID_SCROLL_UP;
15593 id = GADGET_ID_SCROLL_DOWN;
15597 case KSYM_Page_Down:
15598 step *= (key == KSYM_Page_Up ? -1 : +1);
15599 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15601 if (element_shift < 0)
15603 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15604 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15606 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15607 GDI_SCROLLBAR_ITEM_POSITION,
15608 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15610 ModifyEditorElementList();
15616 element_shift = (key == KSYM_Home ? 0 :
15617 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
15619 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15620 GDI_SCROLLBAR_ITEM_POSITION,
15621 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15623 ModifyEditorElementList();
15630 // this is needed to prevent interference with running "True X-Mouse"
15631 if (GetKeyModStateFromEvents() & KMOD_Control)
15634 // check for last or next editor cascade block in element list
15635 for (i = 0; i < num_editor_elements; i++)
15637 if ((key == KSYM_Insert && i == element_shift) ||
15638 (key == KSYM_Delete && new_element_shift > element_shift))
15641 // jump to next cascade block (or to start of element list)
15642 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
15643 new_element_shift = i;
15646 if (i < num_editor_elements)
15647 element_shift = new_element_shift;
15649 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15650 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15652 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15653 GDI_SCROLLBAR_ITEM_POSITION,
15654 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15656 ModifyEditorElementList();
15661 if (edit_mode == ED_MODE_DRAWING)
15662 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
15663 else if (edit_mode == ED_MODE_LEVELCONFIG)
15664 HandleControlButtons(level_editor_gadget[GADGET_ID_CONF]);
15665 else if (edit_mode == ED_MODE_PROPERTIES)
15666 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
15667 else if (edit_mode == ED_MODE_PALETTE)
15668 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
15669 else // should never happen
15670 ChangeEditModeWindow(ED_MODE_DRAWING);
15678 if (id != GADGET_ID_NONE)
15679 ClickOnGadget(level_editor_gadget[id], button);
15680 else if (letter == '1' || letter == '?')
15681 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
15682 else if (letter == '2')
15683 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
15684 else if (letter == '3')
15685 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
15686 else if (letter == '.')
15687 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
15688 else if (letter == 'U')
15689 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
15690 else if (letter == '-' || key == KSYM_KP_Subtract)
15691 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
15692 else if (letter == '0' || key == KSYM_KP_0)
15693 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
15694 else if (letter == '+' || key == KSYM_KP_Add ||
15695 letter == '=') // ("Shift-=" is "+" on US keyboards)
15696 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
15697 else if (key == KSYM_Return ||
15698 key == KSYM_space ||
15699 key == setup.shortcut.toggle_pause)
15700 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
15702 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
15703 if (letter && letter == controlbutton_info[i].shortcut)
15704 if (!anyTextGadgetActive())
15705 ClickOnGadget(level_editor_gadget[i], button);
15707 if (draw_with_brush)
15711 else if (letter == 'y')
15713 else if (letter == 'z')
15718 static void HandleLevelEditorIdle_Properties(void)
15720 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
15721 int x = editor.settings.element_graphic.x + element_border;
15722 int y = editor.settings.element_graphic.y + element_border;
15723 static DelayCounter action_delay = { 0 };
15726 action_delay.value = GameFrameDelay;
15728 if (!DelayReached(&action_delay))
15731 for (i = 0; i < ED_NUM_SELECTBOX; i++)
15733 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
15735 if (gi->mapped && gi->active && gi->selectbox.open)
15739 DrawEditorElementAnimation(SX + x, SY + y);
15741 redraw_mask |= REDRAW_FIELD;
15743 FrameCounter++; // increase animation frame counter
15746 static void HandleLevelEditorIdle_Drawing(void)
15748 static boolean last_highlighted = FALSE;
15749 static boolean last_highlighted_similar = FALSE;
15750 boolean highlighted = (GetKeyModState() & KMOD_Alt);
15751 boolean highlighted_similar = (GetKeyModState() & KMOD_Shift);
15753 if (highlighted != last_highlighted ||
15754 (highlighted && highlighted_similar != last_highlighted_similar))
15756 DrawAreaElementHighlight(highlighted, highlighted_similar);
15758 redraw_mask |= REDRAW_FIELD;
15761 last_highlighted = highlighted;
15762 last_highlighted_similar = highlighted_similar;
15765 void HandleLevelEditorIdle(void)
15767 if (edit_mode == ED_MODE_PROPERTIES)
15768 HandleLevelEditorIdle_Properties();
15769 else if (edit_mode == ED_MODE_DRAWING)
15770 HandleLevelEditorIdle_Drawing();
15773 static void ClearEditorGadgetInfoText(void)
15775 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
15778 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
15780 char infotext[MAX_OUTPUT_LINESIZE + 1];
15781 int max_infotext_len = getMaxInfoTextLength();
15783 if (gi == NULL || strlen(gi->info_text) == 0)
15786 strncpy(infotext, gi->info_text, max_infotext_len);
15787 infotext[max_infotext_len] = '\0';
15789 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
15791 int key = controlbutton_info[gi->custom_id].shortcut;
15795 char shortcut[MAX_OUTPUT_LINESIZE + 1];
15797 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
15798 sprintf(shortcut, " ('.' or '%c')", key);
15799 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
15800 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
15801 else if (gi->custom_id == GADGET_ID_TEST)
15802 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
15803 else if (gi->custom_id == GADGET_ID_UNDO)
15804 sprintf(shortcut, " ('%c/Shift-U')", key);
15805 else if (gi->custom_id == GADGET_ID_ZOOM)
15806 sprintf(shortcut, " ('%c', '0', '-')", key);
15808 sprintf(shortcut, " ('%s%c')",
15809 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
15811 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
15812 strcat(infotext, shortcut);
15816 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
15819 void HandleEditorGadgetInfoText(void *ptr)
15821 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
15823 if (game_status != GAME_MODE_EDITOR)
15826 ClearEditorGadgetInfoText();
15828 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
15831 // misuse this function to delete brush cursor, if needed
15832 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
15833 DeleteBrushFromCursor();
15835 PrintEditorGadgetInfoText(gi);
15838 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
15840 int id = gi->custom_id;
15841 int type_id = gi->custom_type_id;
15842 int sx = gi->event.x;
15843 int sy = gi->event.y;
15844 int lx = sx + level_xpos;
15845 int ly = sy + level_ypos;
15846 int min_sx = 0, min_sy = 0;
15847 int max_sx = gi->drawing.area_xsize - 1;
15848 int max_sy = gi->drawing.area_ysize - 1;
15849 int actual_drawing_function = drawing_function;
15850 int max_infotext_len = getMaxInfoTextLength();
15851 char infotext[MAX_OUTPUT_LINESIZE + 1];
15853 infotext[0] = '\0'; // start with empty info text
15855 // pressed Control key: simulate picking element
15856 if (GetKeyModState() & KMOD_Control)
15857 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
15859 ClearEditorGadgetInfoText();
15861 if (gi->event.type == GD_EVENT_INFO_LEAVING)
15864 // make sure to stay inside drawing area boundaries
15865 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
15866 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
15868 if (id == GADGET_ID_DRAWING_LEVEL)
15872 int min_lx = 0, min_ly = 0;
15873 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
15875 // get positions inside level field
15876 lx = sx + level_xpos;
15877 ly = sy + level_ypos;
15879 // make sure to stay inside level field boundaries
15880 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
15881 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
15883 // correct drawing area positions accordingly
15884 sx = lx - level_xpos;
15885 sy = ly - level_ypos;
15888 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15890 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
15892 static int start_lx = 0;
15893 static int start_ly = 0;
15896 if (gi->event.type == GD_EVENT_PRESSED)
15902 switch (actual_drawing_function)
15904 case GADGET_ID_SINGLE_ITEMS:
15905 text = "Drawing single items";
15907 case GADGET_ID_CONNECTED_ITEMS:
15908 text = "Drawing connected items";
15910 case GADGET_ID_LINE:
15911 text = "Drawing line";
15913 case GADGET_ID_ARC:
15914 text = "Drawing arc";
15916 case GADGET_ID_TEXT:
15917 text = "Setting text cursor";
15919 case GADGET_ID_RECTANGLE:
15920 text = "Drawing rectangle";
15922 case GADGET_ID_FILLED_BOX:
15923 text = "Drawing filled box";
15925 case GADGET_ID_FLOOD_FILL:
15926 text = "Flood fill";
15928 case GADGET_ID_GRAB_BRUSH:
15929 text = "Grabbing brush";
15931 case GADGET_ID_PICK_ELEMENT:
15932 text = "Picking element";
15936 text = "Drawing position";
15940 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15941 sprintf(infotext, "%s: %d, %d", text, lx, ly);
15943 sprintf(infotext, "%s: %d, %d", text,
15944 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
15946 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15947 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
15949 sprintf(infotext, "Level position: %d, %d", lx, ly);
15952 // misuse this function to draw brush cursor, if needed
15953 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
15955 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15956 CopyBrushToCursor(sx, sy);
15958 DeleteBrushFromCursor();
15961 if (!draw_with_brush)
15962 UpdateBrushPosition(sx, sy);
15964 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15966 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
15967 int element = drawingarea_info[type_id].value[pos];
15969 strncpy(infotext, getElementInfoText(element), max_infotext_len);
15973 if (id == GADGET_ID_CUSTOM_CONTENT)
15974 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
15975 else if (id == GADGET_ID_GROUP_CONTENT)
15976 sprintf(infotext, "group element position: %d", sx + 1);
15977 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
15978 id <= GADGET_ID_YAMYAM_CONTENT_7)
15979 sprintf(infotext, "content area %d position: %d, %d",
15980 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
15981 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
15982 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
15983 sprintf(infotext, "content area %d position: %d, %d",
15984 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
15985 else if (id == GADGET_ID_ANDROID_CONTENT)
15986 sprintf(infotext, "android element position: %d", sx + 1);
15987 else if (drawingarea_info[type_id].infotext != NULL)
15988 strcpy(infotext, drawingarea_info[type_id].infotext);
15991 infotext[max_infotext_len] = '\0';
15993 if (strlen(infotext) > 0)
15994 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
15997 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
15998 boolean quick_quit)
16000 if (!ask_if_level_has_changed ||
16002 Request("Level has changed! Exit without saving?",
16003 REQ_ASK | REQ_STAY_OPEN))
16005 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
16006 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
16008 // draw normal door
16009 UndrawSpecialEditorDoor();
16011 // use door animation if door 1 viewport is unchanged and contains toolbox
16012 if (useEditorDoorAnimation())
16013 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
16015 // close editor doors if viewport definition is the same as in main menu
16016 if (vp_door_1->x == DX &&
16017 vp_door_1->y == DY &&
16018 vp_door_1->width == DXSIZE &&
16019 vp_door_1->height == DYSIZE &&
16020 vp_door_2->x == VX &&
16021 vp_door_2->y == VY &&
16022 vp_door_2->width == VXSIZE &&
16023 vp_door_2->height == VYSIZE)
16024 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
16026 SetDoorState(DOOR_CLOSE_ALL);
16031 FadeSkipNextFadeIn();
16033 SetGameStatus(GAME_MODE_MAIN);
16039 if (!global.use_envelope_request)
16041 CloseDoor(DOOR_CLOSE_1);
16042 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);