1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
14 #include "libgame/libgame.h"
25 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
28 // ----------------------------------------------------------------------------
29 // screen and artwork graphic pixel position definitions
30 // ----------------------------------------------------------------------------
32 // values for the control window
33 #define ED_CTRL1_BUTTONS_HORIZ 4 // toolbox
34 #define ED_CTRL1_BUTTONS_VERT 4
35 #define ED_CTRL2_BUTTONS_HORIZ 3 // level
36 #define ED_CTRL2_BUTTONS_VERT 2
37 #define ED_CTRL3_BUTTONS_HORIZ 3 // CE and GE
38 #define ED_CTRL3_BUTTONS_VERT 1
39 #define ED_CTRL4_BUTTONS_HORIZ 2 // CE and GE
40 #define ED_CTRL4_BUTTONS_VERT 1
41 #define ED_CTRL5_BUTTONS_HORIZ 1 // properties
42 #define ED_CTRL5_BUTTONS_VERT 1
43 #define ED_CTRL6_BUTTONS_HORIZ 3 // properties
44 #define ED_CTRL6_BUTTONS_VERT 1
45 #define ED_CTRL7_BUTTONS_HORIZ 1 // palette
46 #define ED_CTRL7_BUTTONS_VERT 1
48 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
49 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
50 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
51 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
52 #define ED_NUM_CTRL5_BUTTONS (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT)
53 #define ED_NUM_CTRL6_BUTTONS (ED_CTRL6_BUTTONS_HORIZ * ED_CTRL6_BUTTONS_VERT)
54 #define ED_NUM_CTRL7_BUTTONS (ED_CTRL7_BUTTONS_HORIZ * ED_CTRL7_BUTTONS_VERT)
55 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
56 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
57 #define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS)
58 #define ED_NUM_CTRL1_5_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS)
59 #define ED_NUM_CTRL1_6_BUTTONS (ED_NUM_CTRL1_5_BUTTONS + ED_NUM_CTRL6_BUTTONS)
60 #define ED_NUM_CTRL1_7_BUTTONS (ED_NUM_CTRL1_6_BUTTONS + ED_NUM_CTRL7_BUTTONS)
61 #define ED_NUM_CTRL_BUTTONS ED_NUM_CTRL1_7_BUTTONS
63 // values for the element list
64 #define ED_ELEMENTLIST_XPOS (editor.palette.x)
65 #define ED_ELEMENTLIST_YPOS (editor.palette.y)
66 #define ED_ELEMENTLIST_XSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
67 #define ED_ELEMENTLIST_YSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
68 #define ED_ELEMENTLIST_COLS MAX(1, editor.palette.cols)
69 #define ED_ELEMENTLIST_ROWS MAX(1, editor.palette.rows)
70 #define ED_ELEMENTLIST_BUTTONS_HORIZ (ED_ELEMENTLIST_COLS)
71 #define ED_ELEMENTLIST_BUTTONS_VERT (ED_ELEMENTLIST_ROWS)
72 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
73 ED_ELEMENTLIST_BUTTONS_VERT)
76 #define ED_GADGET_NORMAL_DISTANCE (editor.gadget.normal_spacing)
77 #define ED_GADGET_SMALL_DISTANCE (editor.gadget.small_spacing)
78 #define ED_GADGET_TINY_DISTANCE (editor.gadget.tiny_spacing)
79 #define ED_GADGET_LINE_DISTANCE (editor.gadget.line_spacing)
80 #define ED_GADGET_TEXT_DISTANCE (editor.gadget.text_spacing)
81 #define ED_TAB_BAR_HEIGHT (editor.gadget.separator_line.height)
82 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
83 ED_DRAWINGAREA_BORDER_SIZE)
84 #define ED_GADGET_SPACE_DISTANCE (getFontWidth(FONT_TEXT_1))
86 // values for drawingarea gadgets
87 #define IMG_BORDER_1 IMG_EDITOR_ELEMENT_BORDER
88 #define IMG_BORDER_2 IMG_EDITOR_ELEMENT_BORDER_INPUT
89 #define ED_ELEMENT_BORDER (graphic_info[IMG_BORDER_1].border_size)
90 #define ED_DRAWINGAREA_BORDER_SIZE (graphic_info[IMG_BORDER_2].border_size)
91 #define ED_DRAWINGAREA_TILE_SIZE (editor.drawingarea.tile_size)
93 // values for checkbutton gadgets
94 #define ED_CHECKBUTTON_XSIZE (graphic_info[IMG_EDITOR_CHECKBOX].width)
95 #define ED_CHECKBUTTON_YSIZE (graphic_info[IMG_EDITOR_CHECKBOX].height)
97 #define ED_TABBUTTON_XSIZE (graphic_info[IMG_EDITOR_TABBUTTON].width)
98 #define ED_TABBUTTON_YSIZE (graphic_info[IMG_EDITOR_TABBUTTON].height)
100 #define ED_SETTINGS_LEVEL_TABS_X (editor.settings.tabs.x)
101 #define ED_SETTINGS_LEVEL_TABS_Y (editor.settings.tabs.y)
102 #define ED_SETTINGS_ELEMENT_TABS_X (editor.settings.tabs.x)
103 #define ED_SETTINGS_ELEMENT_TABS_Y (editor.settings.tabs.y + \
104 editor.settings.tabs.yoffset2)
106 #define ED_SETTINGS_TABS_XOFFSET (editor.settings.tabs.draw_xoffset)
107 #define ED_SETTINGS_TABS_YOFFSET (editor.settings.tabs.draw_yoffset)
109 #define ED_LEVEL_TABS_XSTART (ED_SETTINGS_LEVEL_TABS_X)
110 #define ED_LEVEL_TABS_YSTART (ED_SETTINGS_LEVEL_TABS_Y)
111 #define ED_LEVEL_SETTINGS_XSTART (ED_SETTINGS_LEVEL_TABS_X + \
112 ED_SETTINGS_TABS_XOFFSET)
113 #define ED_LEVEL_SETTINGS_YSTART (ED_SETTINGS_LEVEL_TABS_Y + \
114 ED_TABBUTTON_YSIZE + \
115 ED_GADGET_TINY_DISTANCE + \
116 ED_TAB_BAR_HEIGHT + \
117 ED_SETTINGS_TABS_YOFFSET + \
118 getFontHeight(FONT_TEXT_1) + \
119 ED_GADGET_TEXT_DISTANCE)
120 #define ED_ELEMENT_TABS_XSTART (ED_SETTINGS_ELEMENT_TABS_X)
121 #define ED_ELEMENT_TABS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y)
122 #define ED_ELEMENT_SETTINGS_XSTART (ED_SETTINGS_ELEMENT_TABS_X + \
123 ED_SETTINGS_TABS_XOFFSET)
124 #define ED_ELEMENT_SETTINGS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y + \
125 ED_TABBUTTON_YSIZE + \
126 ED_GADGET_TINY_DISTANCE + \
127 ED_TAB_BAR_HEIGHT + \
128 ED_SETTINGS_TABS_YOFFSET)
130 #define ED_SETTINGS_XOFFSET (ED_CHECKBUTTON_XSIZE + \
131 ED_GADGET_TEXT_DISTANCE)
132 #define ED_SETTINGS_YOFFSET (ED_CHECKBUTTON_YSIZE + \
133 ED_GADGET_LINE_DISTANCE)
135 #define ED_POS_RANGE (10000)
136 #define ED_POS_LEVEL_TABS_FIRST (1 * ED_POS_RANGE)
137 #define ED_POS_LEVEL_TABS_LAST (2 * ED_POS_RANGE - 1)
138 #define ED_POS_LEVEL_SETTINGS_FIRST (2 * ED_POS_RANGE)
139 #define ED_POS_LEVEL_SETTINGS_LAST (3 * ED_POS_RANGE - 1)
140 #define ED_POS_ELEMENT_TABS_FIRST (3 * ED_POS_RANGE)
141 #define ED_POS_ELEMENT_TABS_LAST (4 * ED_POS_RANGE - 1)
142 #define ED_POS_ELEMENT_SETTINGS_FIRST (4 * ED_POS_RANGE)
143 #define ED_POS_ELEMENT_SETTINGS_LAST (5 * ED_POS_RANGE - 1)
145 #define ED_LEVEL_TABS_XPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
146 #define ED_LEVEL_TABS_YPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
148 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
149 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
151 #define ED_ELEMENT_TABS_XPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
152 #define ED_ELEMENT_TABS_YPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
154 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
155 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
157 #define IS_POS_LEVEL_TABS(n) ((n) >= ED_POS_LEVEL_TABS_FIRST && \
158 (n) <= ED_POS_LEVEL_TABS_LAST)
159 #define IS_POS_LEVEL_SETTINGS(n) ((n) >= ED_POS_LEVEL_SETTINGS_FIRST && \
160 (n) <= ED_POS_LEVEL_SETTINGS_LAST)
161 #define IS_POS_ELEMENT_TABS(n) ((n) >= ED_POS_ELEMENT_TABS_FIRST && \
162 (n) <= ED_POS_ELEMENT_TABS_LAST)
163 #define IS_POS_ELEMENT_SETTINGS(n) ((n) >= ED_POS_ELEMENT_SETTINGS_FIRST && \
164 (n) <= ED_POS_ELEMENT_SETTINGS_LAST)
166 #define ED_LEVEL_TABS_LINE(n) ((n) - ED_POS_LEVEL_TABS_FIRST)
167 #define ED_LEVEL_SETTINGS_LINE(n) ((n) - ED_POS_LEVEL_SETTINGS_FIRST)
168 #define ED_ELEMENT_TABS_LINE(n) ((n) - ED_POS_ELEMENT_TABS_FIRST)
169 #define ED_ELEMENT_SETTINGS_LINE(n) ((n) - ED_POS_ELEMENT_SETTINGS_FIRST)
171 #define ED_LEVEL_TABS_X(n) (ED_LEVEL_TABS_XSTART + \
172 (n) * ED_SETTINGS_TABS_XOFFSET)
173 #define ED_LEVEL_TABS_Y(n) (ED_LEVEL_TABS_YSTART + \
174 (n) * ED_SETTINGS_TABS_YOFFSET)
176 #define ED_LEVEL_SETTINGS_X(n) (ED_LEVEL_SETTINGS_XSTART + \
177 (n) * ED_SETTINGS_XOFFSET)
178 #define ED_LEVEL_SETTINGS_Y(n) (ED_LEVEL_SETTINGS_YSTART + \
179 (n) * ED_SETTINGS_YOFFSET)
181 #define ED_ELEMENT_TABS_X(n) (ED_ELEMENT_TABS_XSTART + \
182 (n) * ED_SETTINGS_TABS_XOFFSET)
183 #define ED_ELEMENT_TABS_Y(n) (ED_ELEMENT_TABS_YSTART + \
184 (n) * ED_SETTINGS_TABS_YOFFSET)
186 #define ED_ELEMENT_SETTINGS_X(n) (ED_ELEMENT_SETTINGS_XSTART + \
187 (n) * ED_SETTINGS_XOFFSET)
188 #define ED_ELEMENT_SETTINGS_Y(n) (ED_ELEMENT_SETTINGS_YSTART + \
189 (n) * ED_SETTINGS_YOFFSET)
191 #define ED_POS_TO_LEVEL_TABS_X(n) \
192 (ED_LEVEL_TABS_X(ED_LEVEL_TABS_LINE(n)))
193 #define ED_POS_TO_LEVEL_TABS_Y(n) \
194 (ED_LEVEL_TABS_Y(ED_LEVEL_TABS_LINE(n)))
196 #define ED_POS_TO_LEVEL_SETTINGS_X(n) \
197 (ED_LEVEL_SETTINGS_X(ED_LEVEL_SETTINGS_LINE(n)))
198 #define ED_POS_TO_LEVEL_SETTINGS_Y(n) \
199 (ED_LEVEL_SETTINGS_Y(ED_LEVEL_SETTINGS_LINE(n)))
201 #define ED_POS_TO_ELEMENT_TABS_X(n) \
202 (ED_ELEMENT_TABS_X(ED_ELEMENT_TABS_LINE(n)))
203 #define ED_POS_TO_ELEMENT_TABS_Y(n) \
204 (ED_ELEMENT_TABS_Y(ED_ELEMENT_TABS_LINE(n)))
206 #define ED_POS_TO_ELEMENT_SETTINGS_X(n) \
207 (ED_ELEMENT_SETTINGS_X(ED_ELEMENT_SETTINGS_LINE(n)))
208 #define ED_POS_TO_ELEMENT_SETTINGS_Y(n) \
209 (ED_ELEMENT_SETTINGS_Y(ED_ELEMENT_SETTINGS_LINE(n)))
211 #define ED_SETTINGS_X(n) (IS_POS_LEVEL_TABS(n) ? \
212 ED_POS_TO_LEVEL_TABS_X(n) : \
213 IS_POS_LEVEL_SETTINGS(n) ? \
214 ED_POS_TO_LEVEL_SETTINGS_X(n) : \
215 IS_POS_ELEMENT_TABS(n) ? \
216 ED_POS_TO_ELEMENT_TABS_X(n) : \
217 IS_POS_ELEMENT_SETTINGS(n) ? \
218 ED_POS_TO_ELEMENT_SETTINGS_X(n) : (n))
219 #define ED_SETTINGS_Y(n) (IS_POS_LEVEL_TABS(n) ? \
220 ED_POS_TO_LEVEL_TABS_Y(n) : \
221 IS_POS_LEVEL_SETTINGS(n) ? \
222 ED_POS_TO_LEVEL_SETTINGS_Y(n) : \
223 IS_POS_ELEMENT_TABS(n) ? \
224 ED_POS_TO_ELEMENT_TABS_Y(n) : \
225 IS_POS_ELEMENT_SETTINGS(n) ? \
226 ED_POS_TO_ELEMENT_SETTINGS_Y(n) : (n))
228 #define ED_SETTINGS_XOFF(n) (5 * ((n) % 4) * \
229 ED_DRAWINGAREA_TILE_SIZE)
230 #define ED_SETTINGS_YOFF(n) (5 * ((n) / 4) * \
231 ED_DRAWINGAREA_TILE_SIZE)
233 #define ED_AREA_XOFFSET_1(n) ((n) != 0 ? \
234 ED_DRAWINGAREA_BORDER_SIZE : 0)
235 #define ED_AREA_YOFFSET_1(n) ((n) != 0 ? \
236 (ED_CHECKBUTTON_YSIZE - \
237 ED_DRAWINGAREA_TILE_SIZE) / 2 : 0)
239 #define ED_AREA_XOFFSET_2(n) (0)
240 #define ED_AREA_YOFFSET_2(n) ((n) == 3 ? \
241 ((n) - 1) * ED_DRAWINGAREA_TILE_SIZE / 2 : 0)
243 #define ED_AREA_SETTINGS_X(i) (ED_SETTINGS_X((i).x) + \
244 ED_SETTINGS_XOFF((i).xoffset) + \
245 ED_AREA_XOFFSET_1((i).x) - \
246 ED_AREA_XOFFSET_2((i).area_xsize))
247 #define ED_AREA_SETTINGS_Y(i) (ED_SETTINGS_Y((i).y) + \
248 ED_SETTINGS_YOFF((i).yoffset) + \
249 ED_AREA_YOFFSET_1((i).y) - \
250 ED_AREA_YOFFSET_2((i).area_ysize))
252 // values for element content drawing areas
253 #define ED_AREA_1X1_LSETTINGS_XPOS(n) ED_LEVEL_SETTINGS_XPOS(n)
254 #define ED_AREA_1X1_LSETTINGS_YPOS(n) ED_LEVEL_SETTINGS_YPOS(n)
255 #define ED_AREA_1X1_LSETTINGS_XOFF (0)
256 #define ED_AREA_1X1_LSETTINGS_YOFF (0)
258 #define ED_AREA_1X1_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
259 #define ED_AREA_1X1_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
260 #define ED_AREA_1X1_SETTINGS_XOFF (0)
261 #define ED_AREA_1X1_SETTINGS_YOFF (0)
263 #define ED_AREA_3X3_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
264 #define ED_AREA_3X3_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
265 #define ED_AREA_3X3_SETTINGS_XOFF (0)
266 #define ED_AREA_3X3_SETTINGS_YOFF (0)
269 #define ED_AREA_ELEMENT_CONTENT_XOFF(n) (n)
270 #define ED_AREA_ELEMENT_CONTENT_YOFF(n) (n)
273 #define ED_XPOS_YAM 0
274 #define ED_YPOS_YAM 5
275 #define ED_AREA_YAMYAM_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_YAM)
276 #define ED_AREA_YAMYAM_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_YAM)
277 #define ED_AREA_YAMYAM_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
278 #define ED_AREA_YAMYAM_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
279 #define ED_AREA_YAMYAM_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_YAM) + \
281 #define ED_AREA_YAMYAM_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_YAM) + \
282 ED_SETTINGS_YOFF(n) + \
283 ED_AREA_YOFFSET_1(ED_YPOS_YAM) - \
284 ED_AREA_YOFFSET_2(3))
286 // magic ball content
287 #define ED_XPOS_BALL 0
288 #define ED_YPOS_BALL 6
289 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_BALL)
290 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_BALL)
291 #define ED_AREA_MAGIC_BALL_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
292 #define ED_AREA_MAGIC_BALL_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
293 #define ED_AREA_MAGIC_BALL_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_BALL) + \
295 #define ED_AREA_MAGIC_BALL_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_BALL) + \
296 ED_SETTINGS_YOFF(n) + \
297 ED_AREA_YOFFSET_1(ED_YPOS_BALL) - \
298 ED_AREA_YOFFSET_2(3))
300 // values for scrolling gadgets for drawing area
301 #define ED_SCROLLBUTTON_XSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].width)
302 #define ED_SCROLLBUTTON_YSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].height)
304 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
305 #define ED_SCROLL_UP_YPOS (0)
306 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
307 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
308 #define ED_SCROLL_LEFT_XPOS (0)
309 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
310 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
311 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
312 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
313 ED_SCROLLBUTTON_XSIZE)
314 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
315 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
316 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
317 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
318 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
319 ED_SCROLLBUTTON_YSIZE)
320 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
321 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
323 // values for scrolling gadgets for element list
324 #define ED_SCROLLBUTTON2_XSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
325 #define ED_SCROLLBUTTON2_YSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
327 #define ED_SCROLL2_UP_XPOS (ED_ELEMENTLIST_XPOS + \
328 ED_ELEMENTLIST_BUTTONS_HORIZ * \
329 ED_ELEMENTLIST_XSIZE)
330 #define ED_SCROLL2_UP_YPOS ED_ELEMENTLIST_YPOS
331 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
332 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
333 ED_ELEMENTLIST_BUTTONS_VERT * \
334 ED_ELEMENTLIST_YSIZE - \
335 ED_SCROLLBUTTON2_YSIZE)
336 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
337 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
338 ED_SCROLLBUTTON2_YSIZE)
339 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
340 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
341 ED_ELEMENTLIST_YSIZE - \
342 2 * ED_SCROLLBUTTON2_YSIZE)
344 // values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText()
345 #define INFOTEXT_FONT FONT_TEXT_2
346 #define INFOTEXT_XSIZE SXSIZE
347 #define INFOTEXT_YSIZE getFontHeight(INFOTEXT_FONT)
348 #define INFOTEXT_YSIZE_FULL (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE)
349 #define INFOTEXT_X (editor.settings.tooltip.x)
350 #define INFOTEXT_Y (editor.settings.tooltip.y)
351 #define INFOTEXT_XY_REDEFINED (INFOTEXT_X != -1 || INFOTEXT_Y != -1)
352 #define INFOTEXT_XPOS SX + (INFOTEXT_XY_REDEFINED ? INFOTEXT_X : 0)
353 #define INFOTEXT_YPOS SY + (INFOTEXT_XY_REDEFINED ? INFOTEXT_Y : \
354 SYSIZE - INFOTEXT_YSIZE)
357 // ----------------------------------------------------------------------------
358 // editor gadget definitions
359 // ----------------------------------------------------------------------------
365 // drawing toolbox buttons
367 GADGET_ID_SINGLE_ITEMS,
368 GADGET_ID_CONNECTED_ITEMS,
372 GADGET_ID_FILLED_BOX,
375 GADGET_ID_FLOOD_FILL,
378 GADGET_ID_WRAP_RIGHT,
379 GADGET_ID_RANDOM_PLACEMENT,
380 GADGET_ID_GRAB_BRUSH,
382 GADGET_ID_PICK_ELEMENT,
391 GADGET_ID_CUSTOM_COPY_FROM,
392 GADGET_ID_CUSTOM_COPY_TO,
393 GADGET_ID_CUSTOM_EXCHANGE,
394 GADGET_ID_CUSTOM_COPY,
395 GADGET_ID_CUSTOM_PASTE,
397 GADGET_ID_PROPERTIES,
398 GADGET_ID_ELEMENT_LEFT,
399 GADGET_ID_ELEMENT_MIDDLE,
400 GADGET_ID_ELEMENT_RIGHT,
403 // counter gadget identifiers
405 GADGET_ID_SELECT_LEVEL_DOWN,
406 GADGET_ID_SELECT_LEVEL_TEXT,
407 GADGET_ID_SELECT_LEVEL_UP,
408 GADGET_ID_LEVEL_XSIZE_DOWN,
409 GADGET_ID_LEVEL_XSIZE_TEXT,
410 GADGET_ID_LEVEL_XSIZE_UP,
411 GADGET_ID_LEVEL_YSIZE_DOWN,
412 GADGET_ID_LEVEL_YSIZE_TEXT,
413 GADGET_ID_LEVEL_YSIZE_UP,
414 GADGET_ID_LEVEL_RANDOM_DOWN,
415 GADGET_ID_LEVEL_RANDOM_TEXT,
416 GADGET_ID_LEVEL_RANDOM_UP,
417 GADGET_ID_LEVEL_GEMSLIMIT_DOWN,
418 GADGET_ID_LEVEL_GEMSLIMIT_TEXT,
419 GADGET_ID_LEVEL_GEMSLIMIT_UP,
420 GADGET_ID_LEVEL_TIMELIMIT_DOWN,
421 GADGET_ID_LEVEL_TIMELIMIT_TEXT,
422 GADGET_ID_LEVEL_TIMELIMIT_UP,
423 GADGET_ID_LEVEL_TIMESCORE_DOWN,
424 GADGET_ID_LEVEL_TIMESCORE_TEXT,
425 GADGET_ID_LEVEL_TIMESCORE_UP,
426 GADGET_ID_LEVEL_RANDOM_SEED_DOWN,
427 GADGET_ID_LEVEL_RANDOM_SEED_TEXT,
428 GADGET_ID_LEVEL_RANDOM_SEED_UP,
429 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN,
430 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT,
431 GADGET_ID_LEVELSET_NUM_LEVELS_UP,
432 GADGET_ID_BD_CYCLE_DELAY_MS_DOWN,
433 GADGET_ID_BD_CYCLE_DELAY_MS_TEXT,
434 GADGET_ID_BD_CYCLE_DELAY_MS_UP,
435 GADGET_ID_BD_CYCLE_DELAY_C64_DOWN,
436 GADGET_ID_BD_CYCLE_DELAY_C64_TEXT,
437 GADGET_ID_BD_CYCLE_DELAY_C64_UP,
438 GADGET_ID_BD_HATCHING_DELAY_CYCLES_DOWN,
439 GADGET_ID_BD_HATCHING_DELAY_CYCLES_TEXT,
440 GADGET_ID_BD_HATCHING_DELAY_CYCLES_UP,
441 GADGET_ID_BD_HATCHING_DELAY_SECONDS_DOWN,
442 GADGET_ID_BD_HATCHING_DELAY_SECONDS_TEXT,
443 GADGET_ID_BD_HATCHING_DELAY_SECONDS_UP,
444 GADGET_ID_BD_PUSHING_PROB_DOWN,
445 GADGET_ID_BD_PUSHING_PROB_TEXT,
446 GADGET_ID_BD_PUSHING_PROB_UP,
447 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_DOWN,
448 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_TEXT,
449 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_UP,
450 GADGET_ID_ELEMENT_VALUE1_DOWN,
451 GADGET_ID_ELEMENT_VALUE1_TEXT,
452 GADGET_ID_ELEMENT_VALUE1_UP,
453 GADGET_ID_ELEMENT_VALUE2_DOWN,
454 GADGET_ID_ELEMENT_VALUE2_TEXT,
455 GADGET_ID_ELEMENT_VALUE2_UP,
456 GADGET_ID_ELEMENT_VALUE3_DOWN,
457 GADGET_ID_ELEMENT_VALUE3_TEXT,
458 GADGET_ID_ELEMENT_VALUE3_UP,
459 GADGET_ID_ELEMENT_VALUE4_DOWN,
460 GADGET_ID_ELEMENT_VALUE4_TEXT,
461 GADGET_ID_ELEMENT_VALUE4_UP,
462 GADGET_ID_YAMYAM_CONTENT_DOWN,
463 GADGET_ID_YAMYAM_CONTENT_TEXT,
464 GADGET_ID_YAMYAM_CONTENT_UP,
465 GADGET_ID_BALL_CONTENT_DOWN,
466 GADGET_ID_BALL_CONTENT_TEXT,
467 GADGET_ID_BALL_CONTENT_UP,
468 GADGET_ID_ANDROID_CONTENT_DOWN,
469 GADGET_ID_ANDROID_CONTENT_TEXT,
470 GADGET_ID_ANDROID_CONTENT_UP,
471 GADGET_ID_ENVELOPE_XSIZE_DOWN,
472 GADGET_ID_ENVELOPE_XSIZE_TEXT,
473 GADGET_ID_ENVELOPE_XSIZE_UP,
474 GADGET_ID_ENVELOPE_YSIZE_DOWN,
475 GADGET_ID_ENVELOPE_YSIZE_TEXT,
476 GADGET_ID_ENVELOPE_YSIZE_UP,
477 GADGET_ID_INVENTORY_SIZE_DOWN,
478 GADGET_ID_INVENTORY_SIZE_TEXT,
479 GADGET_ID_INVENTORY_SIZE_UP,
480 GADGET_ID_MM_BALL_CONTENT_DOWN,
481 GADGET_ID_MM_BALL_CONTENT_TEXT,
482 GADGET_ID_MM_BALL_CONTENT_UP,
483 GADGET_ID_CUSTOM_SCORE_DOWN,
484 GADGET_ID_CUSTOM_SCORE_TEXT,
485 GADGET_ID_CUSTOM_SCORE_UP,
486 GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
487 GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
488 GADGET_ID_CUSTOM_GEMCOUNT_UP,
489 GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
490 GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
491 GADGET_ID_CUSTOM_VALUE_FIX_UP,
492 GADGET_ID_CUSTOM_VALUE_RND_DOWN,
493 GADGET_ID_CUSTOM_VALUE_RND_TEXT,
494 GADGET_ID_CUSTOM_VALUE_RND_UP,
495 GADGET_ID_PUSH_DELAY_FIX_DOWN,
496 GADGET_ID_PUSH_DELAY_FIX_TEXT,
497 GADGET_ID_PUSH_DELAY_FIX_UP,
498 GADGET_ID_PUSH_DELAY_RND_DOWN,
499 GADGET_ID_PUSH_DELAY_RND_TEXT,
500 GADGET_ID_PUSH_DELAY_RND_UP,
501 GADGET_ID_DROP_DELAY_FIX_DOWN,
502 GADGET_ID_DROP_DELAY_FIX_TEXT,
503 GADGET_ID_DROP_DELAY_FIX_UP,
504 GADGET_ID_DROP_DELAY_RND_DOWN,
505 GADGET_ID_DROP_DELAY_RND_TEXT,
506 GADGET_ID_DROP_DELAY_RND_UP,
507 GADGET_ID_MOVE_DELAY_FIX_DOWN,
508 GADGET_ID_MOVE_DELAY_FIX_TEXT,
509 GADGET_ID_MOVE_DELAY_FIX_UP,
510 GADGET_ID_MOVE_DELAY_RND_DOWN,
511 GADGET_ID_MOVE_DELAY_RND_TEXT,
512 GADGET_ID_MOVE_DELAY_RND_UP,
513 GADGET_ID_STEP_DELAY_FIX_DOWN,
514 GADGET_ID_STEP_DELAY_FIX_TEXT,
515 GADGET_ID_STEP_DELAY_FIX_UP,
516 GADGET_ID_STEP_DELAY_RND_DOWN,
517 GADGET_ID_STEP_DELAY_RND_TEXT,
518 GADGET_ID_STEP_DELAY_RND_UP,
519 GADGET_ID_EXPLOSION_DELAY_DOWN,
520 GADGET_ID_EXPLOSION_DELAY_TEXT,
521 GADGET_ID_EXPLOSION_DELAY_UP,
522 GADGET_ID_IGNITION_DELAY_DOWN,
523 GADGET_ID_IGNITION_DELAY_TEXT,
524 GADGET_ID_IGNITION_DELAY_UP,
525 GADGET_ID_CHANGE_DELAY_FIX_DOWN,
526 GADGET_ID_CHANGE_DELAY_FIX_TEXT,
527 GADGET_ID_CHANGE_DELAY_FIX_UP,
528 GADGET_ID_CHANGE_DELAY_RND_DOWN,
529 GADGET_ID_CHANGE_DELAY_RND_TEXT,
530 GADGET_ID_CHANGE_DELAY_RND_UP,
531 GADGET_ID_CHANGE_CONT_RND_DOWN,
532 GADGET_ID_CHANGE_CONT_RND_TEXT,
533 GADGET_ID_CHANGE_CONT_RND_UP,
534 GADGET_ID_GROUP_CONTENT_DOWN,
535 GADGET_ID_GROUP_CONTENT_TEXT,
536 GADGET_ID_GROUP_CONTENT_UP,
538 // drawing area identifiers
540 GADGET_ID_DRAWING_LEVEL,
541 GADGET_ID_YAMYAM_CONTENT_0,
542 GADGET_ID_YAMYAM_CONTENT_1,
543 GADGET_ID_YAMYAM_CONTENT_2,
544 GADGET_ID_YAMYAM_CONTENT_3,
545 GADGET_ID_YAMYAM_CONTENT_4,
546 GADGET_ID_YAMYAM_CONTENT_5,
547 GADGET_ID_YAMYAM_CONTENT_6,
548 GADGET_ID_YAMYAM_CONTENT_7,
549 GADGET_ID_MAGIC_BALL_CONTENT_0,
550 GADGET_ID_MAGIC_BALL_CONTENT_1,
551 GADGET_ID_MAGIC_BALL_CONTENT_2,
552 GADGET_ID_MAGIC_BALL_CONTENT_3,
553 GADGET_ID_MAGIC_BALL_CONTENT_4,
554 GADGET_ID_MAGIC_BALL_CONTENT_5,
555 GADGET_ID_MAGIC_BALL_CONTENT_6,
556 GADGET_ID_MAGIC_BALL_CONTENT_7,
557 GADGET_ID_ANDROID_CONTENT,
558 GADGET_ID_AMOEBA_CONTENT,
559 GADGET_ID_START_ELEMENT,
560 GADGET_ID_ARTWORK_ELEMENT,
561 GADGET_ID_EXPLOSION_ELEMENT,
562 GADGET_ID_INVENTORY_CONTENT,
563 GADGET_ID_MM_BALL_CONTENT,
564 GADGET_ID_CUSTOM_GRAPHIC,
565 GADGET_ID_CUSTOM_CONTENT,
566 GADGET_ID_CUSTOM_MOVE_ENTER,
567 GADGET_ID_CUSTOM_MOVE_LEAVE,
568 GADGET_ID_CUSTOM_CHANGE_TARGET,
569 GADGET_ID_CUSTOM_CHANGE_CONTENT,
570 GADGET_ID_CUSTOM_CHANGE_TRIGGER,
571 GADGET_ID_CUSTOM_CHANGE_ACTION,
572 GADGET_ID_GROUP_CONTENT,
573 GADGET_ID_RANDOM_BACKGROUND,
575 // text input identifiers
577 GADGET_ID_LEVEL_NAME,
578 GADGET_ID_LEVEL_AUTHOR,
579 GADGET_ID_LEVELSET_NAME,
580 GADGET_ID_LEVELSET_AUTHOR,
581 GADGET_ID_ELEMENT_NAME,
583 // text area identifiers
585 GADGET_ID_ENVELOPE_INFO,
587 // selectbox identifiers
589 GADGET_ID_TIME_OR_STEPS,
590 GADGET_ID_TIME_SCORE_BASE,
591 GADGET_ID_GAME_ENGINE_TYPE,
592 GADGET_ID_BD_SCHEDULING_TYPE,
593 GADGET_ID_LEVELSET_SAVE_MODE,
594 GADGET_ID_WIND_DIRECTION,
595 GADGET_ID_PLAYER_SPEED,
596 GADGET_ID_MM_BALL_CHOICE_MODE,
597 GADGET_ID_CUSTOM_WALK_TO_ACTION,
598 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
599 GADGET_ID_CUSTOM_DEADLINESS,
600 GADGET_ID_CUSTOM_MOVE_PATTERN,
601 GADGET_ID_CUSTOM_MOVE_DIRECTION,
602 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
603 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
604 GADGET_ID_CUSTOM_SMASH_TARGETS,
605 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
606 GADGET_ID_CUSTOM_ACCESS_TYPE,
607 GADGET_ID_CUSTOM_ACCESS_LAYER,
608 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
609 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
610 GADGET_ID_CHANGE_TIME_UNITS,
611 GADGET_ID_CHANGE_DIRECT_ACTION,
612 GADGET_ID_CHANGE_OTHER_ACTION,
613 GADGET_ID_CHANGE_SIDE,
614 GADGET_ID_CHANGE_PLAYER,
615 GADGET_ID_CHANGE_PAGE,
616 GADGET_ID_CHANGE_REPLACE_WHEN,
617 GADGET_ID_ACTION_TYPE,
618 GADGET_ID_ACTION_MODE,
619 GADGET_ID_ACTION_ARG,
620 GADGET_ID_SELECT_CHANGE_PAGE,
621 GADGET_ID_GROUP_CHOICE_MODE,
623 // textbutton identifiers
625 GADGET_ID_LEVELCONFIG_LEVEL,
626 GADGET_ID_LEVELCONFIG_LEVELSET,
627 GADGET_ID_LEVELCONFIG_EDITOR,
628 GADGET_ID_LEVELCONFIG_ENGINE,
629 GADGET_ID_PROPERTIES_INFO,
630 GADGET_ID_PROPERTIES_CONFIG,
631 GADGET_ID_PROPERTIES_CONFIG_1,
632 GADGET_ID_PROPERTIES_CONFIG_2,
633 GADGET_ID_PROPERTIES_CHANGE,
634 GADGET_ID_SAVE_AS_TEMPLATE_1,
635 GADGET_ID_SAVE_AS_TEMPLATE_2,
636 GADGET_ID_SAVE_LEVELSET,
637 GADGET_ID_ADD_CHANGE_PAGE,
638 GADGET_ID_DEL_CHANGE_PAGE,
640 // graphicbutton identifiers
642 GADGET_ID_PREV_CHANGE_PAGE,
643 GADGET_ID_NEXT_CHANGE_PAGE,
644 GADGET_ID_COPY_CHANGE_PAGE,
645 GADGET_ID_PASTE_CHANGE_PAGE,
647 // gadgets for scrolling of drawing area
650 GADGET_ID_SCROLL_DOWN,
651 GADGET_ID_SCROLL_LEFT,
652 GADGET_ID_SCROLL_RIGHT,
653 GADGET_ID_SCROLL_HORIZONTAL,
654 GADGET_ID_SCROLL_VERTICAL,
656 // gadgets for scrolling element list
658 GADGET_ID_SCROLL_LIST_UP,
659 GADGET_ID_SCROLL_LIST_DOWN,
660 GADGET_ID_SCROLL_LIST_VERTICAL,
662 // checkbuttons/radiobuttons for level/element properties
664 GADGET_ID_AUTO_COUNT_GEMS,
665 GADGET_ID_RATE_TIME_OVER_SCORE,
666 GADGET_ID_USE_LEVELSET_ARTWORK,
667 GADGET_ID_COPY_LEVEL_TEMPLATE,
668 GADGET_ID_RANDOM_PERCENTAGE,
669 GADGET_ID_RANDOM_QUANTITY,
670 GADGET_ID_RANDOM_RESTRICTED,
671 GADGET_ID_BD_INTERMISSION,
672 GADGET_ID_BD_PAL_TIMING,
673 GADGET_ID_BD_LINE_SHIFTING_BORDERS,
674 GADGET_ID_BD_SCAN_FIRST_AND_LAST_ROW,
675 GADGET_ID_BD_SHORT_EXPLOSIONS,
676 GADGET_ID_BD_GRAVITY_AFFECTS_ALL,
677 GADGET_ID_STICK_ELEMENT,
678 GADGET_ID_EM_SLIPPERY_GEMS,
679 GADGET_ID_EM_EXPLODES_BY_FIRE,
680 GADGET_ID_USE_SPRING_BUG,
681 GADGET_ID_USE_TIME_ORB_BUG,
682 GADGET_ID_USE_LIFE_BUGS,
683 GADGET_ID_RANDOM_BALL_CONTENT,
684 GADGET_ID_INITIAL_BALL_ACTIVE,
685 GADGET_ID_GROW_INTO_DIGGABLE,
686 GADGET_ID_SB_FIELDS_NEEDED,
687 GADGET_ID_SB_OBJECTS_NEEDED,
688 GADGET_ID_AUTO_EXIT_SOKOBAN,
689 GADGET_ID_SOLVED_BY_ONE_PLAYER,
690 GADGET_ID_FINISH_DIG_COLLECT,
691 GADGET_ID_KEEP_WALKABLE_CE,
692 GADGET_ID_CONTINUOUS_SNAPPING,
693 GADGET_ID_BLOCK_SNAP_FIELD,
694 GADGET_ID_BLOCK_LAST_FIELD,
695 GADGET_ID_SP_BLOCK_LAST_FIELD,
696 GADGET_ID_INSTANT_RELOCATION,
697 GADGET_ID_SHIFTED_RELOCATION,
698 GADGET_ID_LAZY_RELOCATION,
699 GADGET_ID_USE_START_ELEMENT,
700 GADGET_ID_USE_ARTWORK_ELEMENT,
701 GADGET_ID_USE_EXPLOSION_ELEMENT,
702 GADGET_ID_INITIAL_GRAVITY,
703 GADGET_ID_USE_INITIAL_INVENTORY,
704 GADGET_ID_CAN_PASS_TO_WALKABLE,
705 GADGET_ID_CAN_FALL_INTO_ACID,
706 GADGET_ID_CAN_MOVE_INTO_ACID,
707 GADGET_ID_DONT_COLLIDE_WITH,
708 GADGET_ID_BD_DIAGONAL_MOVEMENTS,
709 GADGET_ID_BD_TOPMOST_PLAYER_ACTIVE,
710 GADGET_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET,
711 GADGET_ID_BD_MAGIC_WALL_WAIT_HATCHING,
712 GADGET_ID_BD_MAGIC_WALL_STOPS_AMOEBA,
713 GADGET_ID_ENVELOPE_AUTOWRAP,
714 GADGET_ID_ENVELOPE_CENTERED,
715 GADGET_ID_MM_LASER_RED,
716 GADGET_ID_MM_LASER_GREEN,
717 GADGET_ID_MM_LASER_BLUE,
718 GADGET_ID_DF_LASER_RED,
719 GADGET_ID_DF_LASER_GREEN,
720 GADGET_ID_DF_LASER_BLUE,
721 GADGET_ID_ROTATE_MM_BALL_CONTENT,
722 GADGET_ID_EXPLODE_MM_BALL,
723 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
724 GADGET_ID_CUSTOM_CAN_EXPLODE,
725 GADGET_ID_CUSTOM_EXPLODE_FIRE,
726 GADGET_ID_CUSTOM_EXPLODE_SMASH,
727 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
728 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
729 GADGET_ID_CUSTOM_DEADLY,
730 GADGET_ID_CUSTOM_CAN_MOVE,
731 GADGET_ID_CUSTOM_CAN_FALL,
732 GADGET_ID_CUSTOM_CAN_SMASH,
733 GADGET_ID_CUSTOM_SLIPPERY,
734 GADGET_ID_CUSTOM_ACCESSIBLE,
735 GADGET_ID_CUSTOM_GRAV_REACHABLE,
736 GADGET_ID_CUSTOM_USE_LAST_VALUE,
737 GADGET_ID_CUSTOM_USE_GRAPHIC,
738 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
739 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
740 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
741 GADGET_ID_CUSTOM_CAN_CHANGE,
742 GADGET_ID_CHANGE_USE_CONTENT,
743 GADGET_ID_CHANGE_USE_EXPLOSION,
744 GADGET_ID_CHANGE_ONLY_COMPLETE,
745 GADGET_ID_CHANGE_USE_RANDOM,
746 GADGET_ID_CHANGE_HAS_ACTION,
747 GADGET_ID_CHANGE_DELAY,
748 GADGET_ID_CHANGE_BY_DIRECT_ACT,
749 GADGET_ID_CHANGE_BY_OTHER_ACT,
751 NUM_STATIC_GADGET_IDS
754 // gadgets for buttons in element list (dynamic)
755 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
756 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
757 ED_NUM_ELEMENTLIST_BUTTONS - 1)
759 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
761 // radio button numbers
765 RADIO_NR_DRAWING_TOOLBOX,
766 RADIO_NR_RANDOM_ELEMENTS
769 // values for counter gadgets
772 ED_COUNTER_ID_SELECT_LEVEL,
773 ED_COUNTER_ID_LEVEL_XSIZE,
774 ED_COUNTER_ID_LEVEL_YSIZE,
775 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
776 ED_COUNTER_ID_LEVEL_TIMELIMIT,
777 ED_COUNTER_ID_LEVEL_TIMESCORE,
778 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
779 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
780 ED_COUNTER_ID_LEVEL_RANDOM,
781 ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
782 ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
783 ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES,
784 ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS,
785 ED_COUNTER_ID_BD_PUSHING_PROB,
786 ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET,
787 ED_COUNTER_ID_ELEMENT_VALUE1,
788 ED_COUNTER_ID_ELEMENT_VALUE2,
789 ED_COUNTER_ID_ELEMENT_VALUE3,
790 ED_COUNTER_ID_ELEMENT_VALUE4,
791 ED_COUNTER_ID_YAMYAM_CONTENT,
792 ED_COUNTER_ID_BALL_CONTENT,
793 ED_COUNTER_ID_ANDROID_CONTENT,
794 ED_COUNTER_ID_ENVELOPE_XSIZE,
795 ED_COUNTER_ID_ENVELOPE_YSIZE,
796 ED_COUNTER_ID_INVENTORY_SIZE,
797 ED_COUNTER_ID_MM_BALL_CONTENT,
798 ED_COUNTER_ID_CUSTOM_SCORE,
799 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
800 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
801 ED_COUNTER_ID_CUSTOM_VALUE_RND,
802 ED_COUNTER_ID_PUSH_DELAY_FIX,
803 ED_COUNTER_ID_PUSH_DELAY_RND,
804 ED_COUNTER_ID_DROP_DELAY_FIX,
805 ED_COUNTER_ID_DROP_DELAY_RND,
806 ED_COUNTER_ID_MOVE_DELAY_FIX,
807 ED_COUNTER_ID_MOVE_DELAY_RND,
808 ED_COUNTER_ID_STEP_DELAY_FIX,
809 ED_COUNTER_ID_STEP_DELAY_RND,
810 ED_COUNTER_ID_EXPLOSION_DELAY,
811 ED_COUNTER_ID_IGNITION_DELAY,
812 ED_COUNTER_ID_GROUP_CONTENT,
813 ED_COUNTER_ID_CHANGE_DELAY_FIX,
814 ED_COUNTER_ID_CHANGE_DELAY_RND,
815 ED_COUNTER_ID_CHANGE_CONT_RND,
817 ED_NUM_COUNTERBUTTONS
820 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
821 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
822 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
823 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
824 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
825 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
827 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
828 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
829 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
830 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
831 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
832 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
834 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
835 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
837 // values for scrollbutton gadgets
840 ED_SCROLLBUTTON_ID_AREA_UP,
841 ED_SCROLLBUTTON_ID_AREA_DOWN,
842 ED_SCROLLBUTTON_ID_AREA_LEFT,
843 ED_SCROLLBUTTON_ID_AREA_RIGHT,
844 ED_SCROLLBUTTON_ID_LIST_UP,
845 ED_SCROLLBUTTON_ID_LIST_DOWN,
850 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
851 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
853 // values for scrollbar gadgets
856 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
857 ED_SCROLLBAR_ID_AREA_VERTICAL,
858 ED_SCROLLBAR_ID_LIST_VERTICAL,
863 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
864 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
866 // values for text input gadgets
869 ED_TEXTINPUT_ID_LEVEL_NAME,
870 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
871 ED_TEXTINPUT_ID_LEVELSET_NAME,
872 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
873 ED_TEXTINPUT_ID_ELEMENT_NAME,
878 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
879 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
881 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
882 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
884 // values for text area gadgets
887 ED_TEXTAREA_ID_ENVELOPE_INFO,
892 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
893 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
895 // values for selectbox gadgets
898 ED_SELECTBOX_ID_TIME_OR_STEPS,
899 ED_SELECTBOX_ID_TIME_SCORE_BASE,
900 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
901 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
902 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
903 ED_SELECTBOX_ID_WIND_DIRECTION,
904 ED_SELECTBOX_ID_PLAYER_SPEED,
905 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
906 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
907 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
908 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
909 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
910 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
911 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
912 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
913 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
914 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
915 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
916 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
917 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
918 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
919 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
920 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
921 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
922 ED_SELECTBOX_ID_CHANGE_SIDE,
923 ED_SELECTBOX_ID_CHANGE_PLAYER,
924 ED_SELECTBOX_ID_CHANGE_PAGE,
925 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
926 ED_SELECTBOX_ID_ACTION_TYPE,
927 ED_SELECTBOX_ID_ACTION_MODE,
928 ED_SELECTBOX_ID_ACTION_ARG,
929 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
930 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
935 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
936 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
938 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
939 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
941 #define ED_SELECTBOX_ID_ENGINE_FIRST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
942 #define ED_SELECTBOX_ID_ENGINE_LAST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
944 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
945 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
946 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
947 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
948 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
949 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
951 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
952 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
954 // values for textbutton gadgets
957 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
958 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
959 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
960 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
961 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
962 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
963 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
964 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
965 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
966 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
967 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
968 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
969 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
970 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
975 #define ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
976 #define ED_TAB_BUTTON_ID_LEVELCONFIG_LAST ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
978 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
979 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
981 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
982 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
984 // values for graphicbutton gadgets
987 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
988 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
989 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
990 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
992 ED_NUM_GRAPHICBUTTONS
995 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
996 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
998 // values for checkbutton gadgets
1001 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
1002 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
1003 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
1004 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
1005 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
1006 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
1007 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
1008 ED_CHECKBUTTON_ID_BD_INTERMISSION,
1009 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
1010 ED_CHECKBUTTON_ID_BD_LINE_SHIFTING_BORDERS,
1011 ED_CHECKBUTTON_ID_BD_SCAN_FIRST_AND_LAST_ROW,
1012 ED_CHECKBUTTON_ID_BD_SHORT_EXPLOSIONS,
1013 ED_CHECKBUTTON_ID_BD_GRAVITY_AFFECTS_ALL,
1014 ED_CHECKBUTTON_ID_STICK_ELEMENT,
1015 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
1016 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
1017 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
1018 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
1019 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
1020 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
1021 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
1022 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
1023 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
1024 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
1025 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
1026 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
1027 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
1028 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
1029 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
1030 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
1031 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
1032 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
1033 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
1034 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
1035 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
1036 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
1037 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
1038 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
1039 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
1040 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
1041 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
1042 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
1043 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
1044 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
1045 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
1046 ED_CHECKBUTTON_ID_BD_TOPMOST_PLAYER_ACTIVE,
1047 ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET,
1048 ED_CHECKBUTTON_ID_BD_MAGIC_WALL_WAIT_HATCHING,
1049 ED_CHECKBUTTON_ID_BD_MAGIC_WALL_STOPS_AMOEBA,
1050 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
1051 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
1052 ED_CHECKBUTTON_ID_MM_LASER_RED,
1053 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
1054 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1055 ED_CHECKBUTTON_ID_DF_LASER_RED,
1056 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1057 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1058 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
1059 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
1060 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1061 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1062 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1063 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1064 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1065 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1066 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1067 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1068 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1069 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1070 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1071 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1072 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1073 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1074 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1075 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1076 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1077 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1078 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1079 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1080 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1081 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1082 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1083 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1084 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1089 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1090 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1092 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1093 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1095 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1096 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1098 #define ED_CHECKBUTTON_ID_ENGINE_FIRST ED_CHECKBUTTON_ID_BD_INTERMISSION
1099 #define ED_CHECKBUTTON_ID_ENGINE_LAST ED_CHECKBUTTON_ID_BD_GRAVITY_AFFECTS_ALL
1101 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1102 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1103 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1104 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1105 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1106 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1108 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1109 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1111 // values for radiobutton gadgets
1114 ED_RADIOBUTTON_ID_PERCENTAGE,
1115 ED_RADIOBUTTON_ID_QUANTITY,
1120 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1121 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1123 // values for drawing area gadgets
1126 ED_DRAWING_ID_DRAWING_LEVEL,
1127 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1128 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1129 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1130 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1131 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1132 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1133 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1134 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1135 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1136 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1137 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1138 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1139 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1140 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1141 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1142 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1143 ED_DRAWING_ID_ANDROID_CONTENT,
1144 ED_DRAWING_ID_AMOEBA_CONTENT,
1145 ED_DRAWING_ID_START_ELEMENT,
1146 ED_DRAWING_ID_ARTWORK_ELEMENT,
1147 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1148 ED_DRAWING_ID_INVENTORY_CONTENT,
1149 ED_DRAWING_ID_MM_BALL_CONTENT,
1150 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1151 ED_DRAWING_ID_CUSTOM_CONTENT,
1152 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1153 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1154 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1155 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1156 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1157 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1158 ED_DRAWING_ID_GROUP_CONTENT,
1159 ED_DRAWING_ID_RANDOM_BACKGROUND,
1161 ED_NUM_DRAWING_AREAS
1164 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1165 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1168 // ----------------------------------------------------------------------------
1169 // some internally used definitions
1170 // ----------------------------------------------------------------------------
1172 // values for CopyLevelToUndoBuffer()
1173 #define UNDO_IMMEDIATE 0
1174 #define UNDO_ACCUMULATE 1
1176 // values for scrollbars
1177 #define ED_SCROLL_NO 0
1178 #define ED_SCROLL_LEFT 1
1179 #define ED_SCROLL_RIGHT 2
1180 #define ED_SCROLL_UP 4
1181 #define ED_SCROLL_DOWN 8
1183 // screens in the level editor
1184 #define ED_MODE_DRAWING 0
1185 #define ED_MODE_LEVELCONFIG 1
1186 #define ED_MODE_PROPERTIES 2
1187 #define ED_MODE_PALETTE 3
1189 // sub-screens in the global settings section
1190 #define ED_MODE_LEVELCONFIG_LEVEL ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
1191 #define ED_MODE_LEVELCONFIG_LEVELSET ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET
1192 #define ED_MODE_LEVELCONFIG_EDITOR ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
1193 #define ED_MODE_LEVELCONFIG_ENGINE ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
1195 // sub-screens in the element properties section
1196 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1197 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1198 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1199 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1200 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1202 // how many steps can be cancelled
1203 #define NUM_UNDO_STEPS (64 + 1)
1205 // values for elements with score for certain actions
1207 #define MAX_SCORE 999
1209 // values for elements with count for collecting
1210 #define MIN_COLLECT_COUNT 0
1211 #define MAX_COLLECT_COUNT 999
1213 // values for random placement
1214 #define RANDOM_USE_PERCENTAGE 0
1215 #define RANDOM_USE_QUANTITY 1
1217 // values for level set save mode
1218 #define LEVELSET_SAVE_MODE_UPDATE 0
1219 #define LEVELSET_SAVE_MODE_CREATE 1
1221 // default value for element tile size in drawing area
1222 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1223 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1226 // ----------------------------------------------------------------------------
1227 // some internally used data structure definitions
1228 // ----------------------------------------------------------------------------
1234 struct XYTileSize *pos;
1238 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1240 // note: some additional characters are already reserved for "cheat mode"
1241 // shortcuts (":XYZ" style) -- for details, see "events.c"
1243 // ---------- toolbox control buttons ---------------------------------------
1246 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1247 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1248 "draw single items", 's'
1251 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1252 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1253 "draw connected items", 'd'
1256 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1257 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1261 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1262 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1266 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1267 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1268 "draw outline rectangles", 'r'
1271 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1272 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1273 "draw filled rectangles", 'R'
1276 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1277 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1278 "wrap (rotate) level up", 0
1281 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1282 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1283 "enter text elements", 't'
1286 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1287 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1291 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1292 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1293 "wrap (rotate) level left", 0
1296 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1297 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1298 "zoom level tile size", '+'
1301 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1302 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1303 "wrap (rotate) level right", 0
1306 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1307 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1308 "random element placement", 0
1311 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1312 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1316 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1317 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1318 "wrap (rotate) level down", 0
1321 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1322 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1323 "pick drawing element", ','
1326 // ---------- level control buttons -----------------------------------------
1329 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1330 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1331 "undo/redo last operation", 'u'
1334 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_CONF,
1335 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1336 "level and editor settings", 'I'
1339 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1340 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1344 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1345 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1349 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1350 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1354 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1355 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1356 "exit level editor", 'E'
1359 // ---------- CE and GE control buttons -------------------------------------
1362 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1363 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1364 "copy settings from other element", 0
1367 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1368 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1369 "copy settings to other element", 0
1372 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1373 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1374 "exchange element with other element", 0
1377 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1378 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1379 "copy settings from this element", 0
1382 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1383 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1384 "paste settings to this element", 0
1387 // ---------- palette control buttons ---------------------------------------
1390 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1391 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1392 "properties of drawing element", 'p'
1395 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1396 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1397 "properties of drawing element 1", '1'
1400 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1401 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1402 "properties of drawing element 2", '2'
1405 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1406 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1407 "properties of drawing element 3", '3'
1410 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1411 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1412 "show list of elements", 'e'
1416 static int random_placement_value = 10;
1417 static int random_placement_method = RANDOM_USE_QUANTITY;
1418 static int random_placement_background_element = EL_SAND;
1419 static boolean random_placement_background_restricted = FALSE;
1420 static boolean stick_element_properties_window = FALSE;
1421 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1422 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1423 static struct ElementChangeInfo custom_element_change;
1424 static struct ElementGroupInfo group_element_info;
1425 static struct ElementInfo custom_element;
1427 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1428 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1429 static int levelset_num_levels = 100;
1430 static boolean levelset_use_levelset_artwork = FALSE;
1431 static boolean levelset_copy_level_template = FALSE;
1432 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1438 int min_value, max_value;
1439 int gadget_id_down, gadget_id_up;
1441 int gadget_id_align;
1443 char *text_above, *text_left, *text_right;
1444 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1446 // ---------- current level number ------------------------------------------
1449 ED_COUNTER_ID_SELECT_LEVEL,
1450 -1, -1, // these values are not constant, but can change at runtime
1452 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1453 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1458 // ---------- level and editor settings -------------------------------------
1461 ED_COUNTER_ID_LEVEL_XSIZE,
1462 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1463 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1464 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1465 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1467 "playfield size:", NULL, "width",
1470 ED_COUNTER_ID_LEVEL_YSIZE,
1471 -1, ED_LEVEL_SETTINGS_YPOS(4),
1472 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1473 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1474 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1476 NULL, " ", "height",
1479 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
1480 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1482 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1483 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1485 NULL, "number of gems to collect:", NULL
1488 ED_COUNTER_ID_LEVEL_TIMELIMIT,
1489 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1491 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1492 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1494 "time or step limit to solve level:", NULL, NULL
1497 ED_COUNTER_ID_LEVEL_TIMESCORE,
1498 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1500 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1501 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1502 &level.score[SC_TIME_BONUS],
1503 "score for time or steps left:", NULL, NULL
1506 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
1507 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1509 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1510 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1512 NULL, "random seed:", "(0 => random)"
1515 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
1516 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1518 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1519 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1520 &levelset_num_levels,
1521 "number of levels:", NULL, NULL,
1524 ED_COUNTER_ID_LEVEL_RANDOM,
1525 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1527 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1528 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1529 &random_placement_value,
1530 "random element placement:", NULL, "in"
1533 ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
1534 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3),
1536 GADGET_ID_BD_CYCLE_DELAY_MS_DOWN, GADGET_ID_BD_CYCLE_DELAY_MS_UP,
1537 GADGET_ID_BD_CYCLE_DELAY_MS_TEXT, GADGET_ID_NONE,
1538 &level.bd_cycle_delay_ms,
1539 NULL, NULL, "game cycle delay (ms)"
1542 ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
1543 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3),
1545 GADGET_ID_BD_CYCLE_DELAY_C64_DOWN, GADGET_ID_BD_CYCLE_DELAY_C64_UP,
1546 GADGET_ID_BD_CYCLE_DELAY_C64_TEXT, GADGET_ID_NONE,
1547 &level.bd_cycle_delay_c64,
1548 NULL, NULL, "game cycle delay (C64-style)"
1551 ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES,
1552 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1554 GADGET_ID_BD_HATCHING_DELAY_CYCLES_DOWN, GADGET_ID_BD_HATCHING_DELAY_CYCLES_UP,
1555 GADGET_ID_BD_HATCHING_DELAY_CYCLES_TEXT, GADGET_ID_NONE,
1556 &level.bd_hatching_delay_cycles,
1557 NULL, NULL, "hatching delay (cycles)"
1560 ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS,
1561 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1563 GADGET_ID_BD_HATCHING_DELAY_SECONDS_DOWN, GADGET_ID_BD_HATCHING_DELAY_SECONDS_UP,
1564 GADGET_ID_BD_HATCHING_DELAY_SECONDS_TEXT, GADGET_ID_NONE,
1565 &level.bd_hatching_delay_seconds,
1566 NULL, NULL, "hatching delay (seconds)"
1569 // ---------- element settings: configure (various elements) ----------------
1572 ED_COUNTER_ID_BD_PUSHING_PROB,
1573 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1575 GADGET_ID_BD_PUSHING_PROB_DOWN, GADGET_ID_BD_PUSHING_PROB_UP,
1576 GADGET_ID_BD_PUSHING_PROB_TEXT, GADGET_ID_NONE,
1577 &level.bd_pushing_prob,
1578 NULL, NULL, "push probability"
1581 ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET,
1582 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1584 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_DOWN, GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_UP,
1585 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_TEXT, GADGET_ID_NONE,
1586 &level.bd_pushing_prob_with_sweet,
1587 NULL, NULL, "push probability with sweet"
1590 ED_COUNTER_ID_ELEMENT_VALUE1,
1591 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1592 MIN_SCORE, MAX_SCORE,
1593 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1594 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1595 NULL, // will be set when used
1599 ED_COUNTER_ID_ELEMENT_VALUE2,
1600 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1601 MIN_SCORE, MAX_SCORE,
1602 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1603 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1604 NULL, // will be set when used
1608 ED_COUNTER_ID_ELEMENT_VALUE3,
1609 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1610 MIN_SCORE, MAX_SCORE,
1611 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1612 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1613 NULL, // will be set when used
1617 ED_COUNTER_ID_ELEMENT_VALUE4,
1618 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1619 MIN_SCORE, MAX_SCORE,
1620 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1621 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1622 NULL, // will be set when used
1626 ED_COUNTER_ID_YAMYAM_CONTENT,
1627 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1628 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1629 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1630 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1631 &level.num_yamyam_contents,
1632 NULL, NULL, "number of content areas"
1635 ED_COUNTER_ID_BALL_CONTENT,
1636 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1637 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1638 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1639 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1640 &level.num_ball_contents,
1641 NULL, NULL, "number of content areas"
1644 ED_COUNTER_ID_ANDROID_CONTENT,
1645 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1646 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1647 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1648 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1649 &level.num_android_clone_elements,
1650 NULL, NULL, "number of clonable elements"
1653 ED_COUNTER_ID_ENVELOPE_XSIZE,
1654 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1655 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1656 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1657 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1658 NULL, // will be set when used
1659 NULL, NULL, "width",
1662 ED_COUNTER_ID_ENVELOPE_YSIZE,
1663 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1664 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1665 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1666 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1667 NULL, // will be set when used
1668 NULL, " ", "height",
1671 ED_COUNTER_ID_INVENTORY_SIZE,
1672 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1673 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1674 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1675 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1676 &level.initial_inventory_size[0],
1677 NULL, NULL, "number of inventory elements"
1680 ED_COUNTER_ID_MM_BALL_CONTENT,
1681 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1682 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1683 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1684 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1685 &level.num_mm_ball_contents,
1686 NULL, NULL, "number of content elements"
1689 // ---------- element settings: configure 1 (custom elements) ---------------
1692 ED_COUNTER_ID_CUSTOM_SCORE,
1693 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1694 MIN_SCORE, MAX_SCORE,
1695 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1696 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1697 &custom_element.collect_score_initial,
1698 NULL, "CE score", " "
1701 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
1702 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1703 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1704 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1705 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1706 &custom_element.collect_count_initial,
1707 NULL, "CE count", NULL
1710 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
1711 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1713 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1714 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1715 &custom_element.ce_value_fixed_initial,
1716 NULL, "CE value", NULL
1719 ED_COUNTER_ID_CUSTOM_VALUE_RND,
1720 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1722 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1723 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1724 &custom_element.ce_value_random_initial,
1725 NULL, "+random", NULL
1728 ED_COUNTER_ID_PUSH_DELAY_FIX,
1729 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1731 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1732 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1733 &custom_element.push_delay_fixed,
1734 NULL, "push delay", NULL
1737 ED_COUNTER_ID_PUSH_DELAY_RND,
1738 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1740 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1741 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1742 &custom_element.push_delay_random,
1743 NULL, "+random", NULL
1746 ED_COUNTER_ID_DROP_DELAY_FIX,
1747 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1749 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1750 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1751 &custom_element.drop_delay_fixed,
1752 NULL, "drop delay", NULL
1755 ED_COUNTER_ID_DROP_DELAY_RND,
1756 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1758 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1759 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1760 &custom_element.drop_delay_random,
1761 NULL, "+random", NULL
1764 // ---------- element settings: configure 2 (custom elements) ---------------
1767 ED_COUNTER_ID_MOVE_DELAY_FIX,
1768 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1770 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1771 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1772 &custom_element.move_delay_fixed,
1773 NULL, "move delay", NULL
1776 ED_COUNTER_ID_MOVE_DELAY_RND,
1777 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1779 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1780 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1781 &custom_element.move_delay_random,
1782 NULL, "+random", NULL
1785 ED_COUNTER_ID_STEP_DELAY_FIX,
1786 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1788 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1789 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1790 &custom_element.step_delay_fixed,
1791 NULL, "step delay", NULL
1794 ED_COUNTER_ID_STEP_DELAY_RND,
1795 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1797 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1798 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1799 &custom_element.step_delay_random,
1800 NULL, "+random", NULL
1803 ED_COUNTER_ID_EXPLOSION_DELAY,
1804 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1806 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1807 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1808 &custom_element.explosion_delay,
1809 NULL, "explosion delay", NULL
1812 ED_COUNTER_ID_IGNITION_DELAY,
1813 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1815 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1816 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1817 &custom_element.ignition_delay,
1818 NULL, "ignition delay", "(by fire)"
1821 // ---------- element settings: configure (group elements) ------------------
1824 ED_COUNTER_ID_GROUP_CONTENT,
1825 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1826 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1827 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1828 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1829 &group_element_info.num_elements,
1830 NULL, NULL, "number of elements in group"
1833 // ---------- element settings: advanced (custom elements) ------------------
1836 ED_COUNTER_ID_CHANGE_DELAY_FIX,
1837 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1839 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1840 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1841 &custom_element_change.delay_fixed,
1842 NULL, "CE delay", NULL,
1845 ED_COUNTER_ID_CHANGE_DELAY_RND,
1846 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1848 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1849 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1850 &custom_element_change.delay_random,
1851 NULL, "+random", NULL
1854 ED_COUNTER_ID_CHANGE_CONT_RND,
1855 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1857 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1858 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1859 &custom_element_change.random_percentage,
1860 NULL, "use random replace:", "%"
1871 char *text_above, *infotext;
1872 } textinput_info[ED_NUM_TEXTINPUT] =
1875 ED_TEXTINPUT_ID_LEVEL_NAME,
1876 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1877 GADGET_ID_LEVEL_NAME,
1880 "Title:", "Title for this level"
1883 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
1884 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1885 GADGET_ID_LEVEL_AUTHOR,
1886 MAX_LEVEL_AUTHOR_LEN,
1888 "Author:", "Author for this level"
1891 ED_TEXTINPUT_ID_LEVELSET_NAME,
1892 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1893 GADGET_ID_LEVELSET_NAME,
1896 "Title:", "Title for this or new level set"
1899 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
1900 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1901 GADGET_ID_LEVELSET_AUTHOR,
1902 MAX_LEVEL_AUTHOR_LEN,
1904 "Author:", "Author for this or new level set"
1907 ED_TEXTINPUT_ID_ELEMENT_NAME,
1908 -1, -1, // these values are not constant, but can change at runtime
1909 GADGET_ID_ELEMENT_NAME,
1910 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1911 custom_element.description,
1912 NULL, "Element name"
1923 char *text_above, *text_above_cropped, *infotext;
1924 } textarea_info[ED_NUM_TEXTAREAS] =
1927 ED_TEXTAREA_ID_ENVELOPE_INFO,
1928 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1929 GADGET_ID_ENVELOPE_INFO,
1930 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1932 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1936 static struct ValueTextInfo options_time_or_steps[] =
1944 static struct ValueTextInfo options_time_score_base[] =
1946 { 1, "per second/step" },
1947 { 10, "per 10 seconds/steps" },
1952 static struct ValueTextInfo options_game_engine_type[] =
1954 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1955 { GAME_ENGINE_TYPE_BD, "Boulder Dash" },
1956 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1957 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1958 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1963 static struct ValueTextInfo options_levelset_save_mode[] =
1965 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1966 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1971 static struct ValueTextInfo options_wind_direction[] =
1973 { MV_START_NONE, "none" },
1974 { MV_START_LEFT, "left" },
1975 { MV_START_RIGHT, "right" },
1976 { MV_START_UP, "up" },
1977 { MV_START_DOWN, "down" },
1982 static struct ValueTextInfo options_player_speed[] =
1989 { 16, "very fast" },
1990 { 32, "ultrafast" },
1995 static struct ValueTextInfo options_access_type[] =
1997 { EP_WALKABLE, "walkable" },
1998 { EP_PASSABLE, "passable" },
2003 static struct ValueTextInfo options_access_layer[] =
2005 { EP_ACCESSIBLE_OVER, "over" },
2006 { EP_ACCESSIBLE_INSIDE, "inside" },
2007 { EP_ACCESSIBLE_UNDER, "under" },
2012 static struct ValueTextInfo options_access_protected[] =
2014 { 0, "unprotected" },
2020 static struct ValueTextInfo options_access_direction[] =
2022 { MV_NO_DIRECTION, "no direction" },
2023 { MV_LEFT, "left" },
2024 { MV_RIGHT, "right" },
2026 { MV_DOWN, "down" },
2027 { MV_LEFT | MV_UP, "left + up" },
2028 { MV_LEFT | MV_DOWN, "left + down" },
2029 { MV_RIGHT | MV_UP, "right + up" },
2030 { MV_RIGHT | MV_DOWN, "right + down" },
2031 { MV_HORIZONTAL, "horizontal" },
2032 { MV_VERTICAL, "vertical" },
2033 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
2034 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
2035 { MV_VERTICAL | MV_LEFT, "vertical + left" },
2036 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
2037 { MV_ALL_DIRECTIONS, "all directions" },
2042 static struct ValueTextInfo options_walk_to_action[] =
2044 { EP_DIGGABLE, "diggable" },
2045 { EP_COLLECTIBLE_ONLY, "collectible" },
2046 { EP_DROPPABLE, "collectible & droppable" },
2047 { EP_THROWABLE, "collectible & throwable" },
2048 { EP_PUSHABLE, "pushable" },
2053 static struct ValueTextInfo options_move_pattern[] =
2055 { MV_LEFT, "left" },
2056 { MV_RIGHT, "right" },
2058 { MV_DOWN, "down" },
2059 { MV_HORIZONTAL, "horizontal" },
2060 { MV_VERTICAL, "vertical" },
2061 { MV_ALL_DIRECTIONS, "all directions" },
2062 { MV_WIND_DIRECTION, "wind direction" },
2063 { MV_TOWARDS_PLAYER, "towards player" },
2064 { MV_AWAY_FROM_PLAYER, "away from player" },
2065 { MV_ALONG_LEFT_SIDE, "along left side" },
2066 { MV_ALONG_RIGHT_SIDE, "along right side" },
2067 { MV_TURNING_LEFT, "turning left" },
2068 { MV_TURNING_RIGHT, "turning right" },
2069 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
2070 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
2071 { MV_TURNING_RANDOM, "turning random" },
2072 { MV_MAZE_RUNNER, "maze runner style" },
2073 { MV_MAZE_HUNTER, "maze hunter style" },
2074 { MV_WHEN_PUSHED, "when pushed" },
2075 { MV_WHEN_DROPPED, "when dropped/thrown" },
2080 static struct ValueTextInfo options_move_direction[] =
2082 { MV_START_AUTOMATIC, "automatic" },
2083 { MV_START_LEFT, "left" },
2084 { MV_START_RIGHT, "right" },
2085 { MV_START_UP, "up" },
2086 { MV_START_DOWN, "down" },
2087 { MV_START_RANDOM, "random" },
2088 { MV_START_PREVIOUS, "previous" },
2093 static struct ValueTextInfo options_move_stepsize[] =
2095 { 0, "not moving" },
2100 { 16, "very fast" },
2101 { 32, "even faster" },
2106 static struct ValueTextInfo options_move_leave_type[] =
2108 { LEAVE_TYPE_UNLIMITED, "leave behind" },
2109 { LEAVE_TYPE_LIMITED, "change it to" },
2114 static struct ValueTextInfo options_smash_targets[] =
2116 { EP_CAN_SMASH_PLAYER, "player" },
2118 { EP_CAN_SMASH_ENEMIES, "enemies" },
2120 { EP_CAN_SMASH_EVERYTHING, "everything" },
2125 static struct ValueTextInfo options_slippery_type[] =
2127 { SLIPPERY_ANY_RANDOM, "random" },
2128 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
2129 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
2130 { SLIPPERY_ONLY_LEFT, "only left" },
2131 { SLIPPERY_ONLY_RIGHT, "only right" },
2136 static struct ValueTextInfo options_deadliness[] =
2138 { EP_DONT_RUN_INTO, "running into" },
2139 { EP_DONT_COLLIDE_WITH, "colliding with" },
2140 { EP_DONT_GET_HIT_BY, "getting hit by" },
2141 { EP_DONT_TOUCH, "touching" },
2146 static struct ValueTextInfo options_explosion_type[] =
2148 { EXPLODES_3X3, "3x3" },
2149 { EXPLODES_CROSS, "3+3" },
2150 { EXPLODES_1X1, "1x1" },
2155 static struct ValueTextInfo options_time_units[] =
2158 { FRAMES_PER_SECOND, "seconds" },
2163 static struct ValueTextInfo options_change_direct_action[] =
2165 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2166 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2167 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2168 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2169 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2170 { CE_ENTERED_BY_PLAYER, "entered by player" },
2171 { CE_LEFT_BY_PLAYER, "left by player" },
2172 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2173 { CE_SWITCHED, "switched" },
2174 { CE_HITTING_SOMETHING, "hitting something" },
2175 { CE_HIT_BY_SOMETHING, "hit by something" },
2177 { CE_BLOCKED, "blocked" },
2179 { CE_IMPACT, "impact (on something)" },
2180 { CE_SMASHED, "smashed (from above)" },
2182 { CE_VALUE_CHANGES, "CE value changes" },
2183 { CE_SCORE_CHANGES, "CE score changes" },
2185 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2186 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2187 { CE_UNDEFINED, " " },
2188 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2189 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2190 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2191 { CE_UNDEFINED, " " },
2192 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2193 { CE_NEXT_TO_PLAYER, "next to player" },
2198 static struct ValueTextInfo options_change_other_action[] =
2200 { CE_PLAYER_TOUCHES_X, "player touches" },
2201 { CE_PLAYER_PRESSES_X, "player presses" },
2202 { CE_PLAYER_SWITCHES_X, "player switches" },
2203 { CE_PLAYER_SNAPS_X, "player snaps" },
2204 { CE_PLAYER_PUSHES_X, "player pushes" },
2205 { CE_PLAYER_ENTERS_X, "player enters" },
2206 { CE_PLAYER_LEAVES_X, "player leaves" },
2207 { CE_PLAYER_DIGS_X, "player digs" },
2208 { CE_PLAYER_COLLECTS_X, "player collects" },
2209 { CE_PLAYER_DROPS_X, "player drops/throws" },
2210 { CE_TOUCHING_X, "touching" },
2211 { CE_HITTING_X, "hitting" },
2212 { CE_DIGGING_X, "digging" },
2213 { CE_HIT_BY_X, "hit by" },
2214 { CE_SWITCH_OF_X, "switch of" },
2215 { CE_CHANGE_OF_X, "change by page of" },
2216 { CE_EXPLOSION_OF_X, "explosion of" },
2217 { CE_MOVE_OF_X, "move of" },
2218 { CE_CREATION_OF_X, "creation of" },
2219 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2220 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2221 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2222 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2223 { CE_UNDEFINED, " " },
2224 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2225 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2226 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2227 { CE_UNDEFINED, " " },
2228 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2229 { CE_PLAYER_NEXT_TO_X, "player next to" },
2230 { CE_NEXT_TO_X, "next to" },
2235 static struct ValueTextInfo options_change_trigger_side[] =
2237 { CH_SIDE_LEFT, "left" },
2238 { CH_SIDE_RIGHT, "right" },
2239 { CH_SIDE_TOP, "top" },
2240 { CH_SIDE_BOTTOM, "bottom" },
2241 { CH_SIDE_LEFT_RIGHT, "left/right" },
2242 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2243 { CH_SIDE_ANY, "any" },
2248 static struct ValueTextInfo options_change_trigger_player[] =
2250 { CH_PLAYER_1, "1" },
2251 { CH_PLAYER_2, "2" },
2252 { CH_PLAYER_3, "3" },
2253 { CH_PLAYER_4, "4" },
2254 { CH_PLAYER_ANY, "any" },
2259 static struct ValueTextInfo options_change_trigger_page[] =
2270 { (1u << 9), "10" },
2271 { (1u << 10), "11" },
2272 { (1u << 11), "12" },
2273 { (1u << 12), "13" },
2274 { (1u << 13), "14" },
2275 { (1u << 14), "15" },
2276 { (1u << 15), "16" },
2277 { (1u << 16), "17" },
2278 { (1u << 17), "18" },
2279 { (1u << 18), "19" },
2280 { (1u << 19), "20" },
2281 { (1u << 20), "21" },
2282 { (1u << 21), "22" },
2283 { (1u << 22), "23" },
2284 { (1u << 23), "24" },
2285 { (1u << 24), "25" },
2286 { (1u << 25), "26" },
2287 { (1u << 26), "27" },
2288 { (1u << 27), "28" },
2289 { (1u << 28), "29" },
2290 { (1u << 29), "30" },
2291 { (1u << 30), "31" },
2292 { (1u << 31), "32" },
2293 { CH_PAGE_ANY, "any" },
2298 static struct ValueTextInfo options_change_replace_when[] =
2300 { CP_WHEN_EMPTY, "empty" },
2301 { CP_WHEN_WALKABLE, "walkable" },
2302 { CP_WHEN_DIGGABLE, "diggable" },
2303 { CP_WHEN_COLLECTIBLE, "collectible" },
2304 { CP_WHEN_REMOVABLE, "removable" },
2305 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2310 static struct ValueTextInfo options_action_type[] =
2312 { CA_NO_ACTION, "no action" },
2313 { CA_UNDEFINED, " " },
2314 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2315 { CA_RESTART_LEVEL, "restart level" },
2316 { CA_SHOW_ENVELOPE, "show envelope" },
2317 { CA_SET_LEVEL_TIME, "set time" },
2318 { CA_SET_LEVEL_SCORE, "set score" },
2319 { CA_SET_LEVEL_GEMS, "set gems" },
2320 { CA_SET_LEVEL_WIND, "set wind dir." },
2321 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2322 { CA_UNDEFINED, " " },
2323 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2324 { CA_MOVE_PLAYER, "move player" },
2325 { CA_MOVE_PLAYER_NEW, "move player new" },
2326 { CA_EXIT_PLAYER, "exit player" },
2327 { CA_KILL_PLAYER, "kill player" },
2328 { CA_SET_PLAYER_KEYS, "set keys" },
2329 { CA_SET_PLAYER_SPEED, "set speed" },
2330 { CA_SET_PLAYER_SHIELD, "set shield" },
2331 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2332 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2333 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2334 { CA_UNDEFINED, " " },
2335 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2336 { CA_SET_CE_VALUE, "set CE value" },
2337 { CA_SET_CE_SCORE, "set CE score" },
2338 { CA_SET_CE_ARTWORK, "set CE artwork" },
2339 { CA_UNDEFINED, " " },
2340 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2341 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2346 static struct ValueTextInfo options_action_mode_none[] =
2348 { CA_MODE_UNDEFINED, " " },
2353 static struct ValueTextInfo options_action_mode_assign[] =
2355 { CA_MODE_SET, "=" },
2360 static struct ValueTextInfo options_action_mode_add_remove[] =
2362 { CA_MODE_ADD, "+" },
2363 { CA_MODE_SUBTRACT, "-" },
2368 static struct ValueTextInfo options_action_mode_calculate[] =
2370 { CA_MODE_SET, "=" },
2371 { CA_MODE_ADD, "+" },
2372 { CA_MODE_SUBTRACT, "-" },
2373 { CA_MODE_MULTIPLY, "*" },
2374 { CA_MODE_DIVIDE, "/" },
2375 { CA_MODE_MODULO, "%" },
2380 static struct ValueTextInfo options_action_arg_none[] =
2382 { CA_ARG_UNDEFINED, " " },
2387 static struct ValueTextInfo options_action_arg_player[] =
2389 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2390 { CA_ARG_PLAYER_1, "1" },
2391 { CA_ARG_PLAYER_2, "2" },
2392 { CA_ARG_PLAYER_3, "3" },
2393 { CA_ARG_PLAYER_4, "4" },
2394 { CA_ARG_PLAYER_ANY, "any" },
2395 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2396 { CA_ARG_PLAYER_ACTION, "action ->" },
2401 static struct ValueTextInfo options_action_arg_number[] =
2403 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2410 { CA_ARG_10, "10" },
2411 { CA_ARG_100, "100" },
2412 { CA_ARG_1000, "1000" },
2413 { CA_ARG_UNDEFINED, " " },
2414 { CA_ARG_NUMBER_MIN, "min" },
2415 { CA_ARG_NUMBER_MAX, "max" },
2416 { CA_ARG_UNDEFINED, " " },
2417 { CA_ARG_NUMBER_RESET, "reset" },
2418 { CA_ARG_UNDEFINED, " " },
2419 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2420 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2421 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2422 { CA_ARG_UNDEFINED, " " },
2423 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2424 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2425 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2426 { CA_ARG_UNDEFINED, " " },
2427 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2428 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2429 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2430 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2431 { CA_ARG_UNDEFINED, " " },
2432 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2433 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2434 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2435 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2440 static struct ValueTextInfo options_action_arg_value[] =
2442 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2449 { CA_ARG_10, "10" },
2450 { CA_ARG_100, "100" },
2451 { CA_ARG_1000, "1000" },
2452 { CA_ARG_UNDEFINED, " " },
2453 { CA_ARG_NUMBER_MIN, "min" },
2454 { CA_ARG_NUMBER_MAX, "max" },
2455 { CA_ARG_UNDEFINED, " " },
2456 { CA_ARG_NUMBER_RESET, "reset" },
2457 { CA_ARG_UNDEFINED, " " },
2458 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2459 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2460 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2461 { CA_ARG_UNDEFINED, " " },
2462 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2463 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2464 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2465 { CA_ARG_UNDEFINED, " " },
2466 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2467 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2468 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2469 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2470 { CA_ARG_UNDEFINED, " " },
2471 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2472 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2473 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2474 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2475 { CA_ARG_UNDEFINED, " " },
2476 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2477 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2478 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2479 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2484 static struct ValueTextInfo options_action_arg_envelope[] =
2486 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2491 { CA_ARG_UNDEFINED, " " },
2492 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2493 { CA_ARG_ELEMENT_TARGET, "target" },
2494 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2495 { CA_ARG_ELEMENT_ACTION, "action ->" },
2500 static struct ValueTextInfo options_action_arg_key[] =
2502 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2511 { CA_ARG_UNDEFINED, " " },
2512 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2513 { CA_ARG_ELEMENT_TARGET, "target" },
2514 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2515 { CA_ARG_ELEMENT_ACTION, "action ->" },
2520 static struct ValueTextInfo options_action_arg_speed[] =
2522 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2523 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2524 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2525 { CA_ARG_SPEED_SLOW, "slow" },
2526 { CA_ARG_SPEED_NORMAL, "normal" },
2527 { CA_ARG_SPEED_FAST, "fast" },
2528 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2529 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2530 { CA_ARG_UNDEFINED, " " },
2531 { CA_ARG_SPEED_SLOWER, "slower" },
2532 { CA_ARG_SPEED_FASTER, "faster" },
2533 { CA_ARG_UNDEFINED, " " },
2534 { CA_ARG_SPEED_RESET, "reset" },
2539 static struct ValueTextInfo options_action_arg_shield[] =
2541 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2542 { CA_ARG_SHIELD_OFF, "off" },
2543 { CA_ARG_SHIELD_NORMAL, "normal" },
2544 { CA_ARG_SHIELD_DEADLY, "deadly" },
2549 static struct ValueTextInfo options_action_arg_artwork[] =
2551 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2552 { CA_ARG_ELEMENT_TARGET, "target" },
2553 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2554 { CA_ARG_ELEMENT_ACTION, "action ->" },
2555 { CA_ARG_UNDEFINED, " " },
2556 { CA_ARG_ELEMENT_RESET, "reset" },
2561 static struct ValueTextInfo options_action_arg_gravity[] =
2563 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2564 { CA_ARG_GRAVITY_ON, "on" },
2565 { CA_ARG_GRAVITY_OFF, "off" },
2566 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2571 static struct ValueTextInfo options_action_arg_direction[] =
2573 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2574 { CA_ARG_DIRECTION_NONE, "none" },
2575 { CA_ARG_DIRECTION_LEFT, "left" },
2576 { CA_ARG_DIRECTION_RIGHT, "right" },
2577 { CA_ARG_DIRECTION_UP, "up" },
2578 { CA_ARG_DIRECTION_DOWN, "down" },
2579 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2580 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2585 static struct ValueTextInfo options_action_arg_scan_mode[] =
2587 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2588 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2589 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2594 static struct ValueTextInfo options_action_arg_inventory[] =
2596 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2597 { CA_ARG_ELEMENT_TARGET, "+ target" },
2598 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2599 { CA_ARG_ELEMENT_ACTION, "+ action" },
2600 { CA_ARG_UNDEFINED, " " },
2601 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2602 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2603 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2604 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2605 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2606 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2607 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2608 { CA_ARG_UNDEFINED, " " },
2609 { CA_ARG_INVENTORY_RESET, "reset" },
2614 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2615 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2620 static struct ValueTextInfo options_group_choice_mode[] =
2622 { ANIM_RANDOM, "random" },
2623 { ANIM_LOOP, "loop" },
2624 { ANIM_LINEAR, "linear" },
2625 { ANIM_PINGPONG, "pingpong" },
2626 { ANIM_PINGPONG2, "pingpong 2" },
2627 { ANIM_LEVEL_NR, "level number" },
2632 static struct ValueTextInfo options_bd_scheduling_type[] =
2634 { GD_SCHEDULING_MILLISECONDS, "Milliseconds" },
2635 { GD_SCHEDULING_BD1, "BD1" },
2636 { GD_SCHEDULING_BD2, "BD2" },
2637 { GD_SCHEDULING_PLCK, "Construction Kit" },
2638 { GD_SCHEDULING_CRDR, "Crazy Dream 7" },
2639 { GD_SCHEDULING_BD1_ATARI, "Atari BD1" },
2640 { GD_SCHEDULING_BD2_PLCK_ATARI, "Atari BD2 / PLCK" },
2645 static struct ValueTextInfo *action_arg_modes[] =
2647 options_action_mode_none,
2648 options_action_mode_assign,
2649 options_action_mode_add_remove,
2650 options_action_mode_calculate,
2657 struct ValueTextInfo *options;
2659 action_arg_options[] =
2661 { CA_NO_ACTION, 0, options_action_arg_none, },
2662 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2663 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2664 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2665 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2666 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2667 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2668 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2669 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2670 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2671 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2672 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2673 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2674 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2675 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2676 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2677 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2678 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2679 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2680 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2681 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2682 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2692 int gadget_id_align;
2693 int size; // char size of selectbox or '-1' (dynamically determined)
2694 struct ValueTextInfo *options;
2696 char *text_above, *text_left, *text_right, *infotext;
2697 } selectbox_info[ED_NUM_SELECTBOX] =
2699 // ---------- level and editor settings -------------------------------------
2702 ED_SELECTBOX_ID_TIME_OR_STEPS,
2703 -1, ED_LEVEL_SETTINGS_YPOS(8),
2704 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2706 options_time_or_steps,
2707 &level.use_step_counter,
2708 NULL, NULL, "(0 => no limit)", "time or step limit"
2711 ED_SELECTBOX_ID_TIME_SCORE_BASE,
2712 -1, ED_LEVEL_SETTINGS_YPOS(10),
2713 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2715 options_time_score_base,
2716 &level.time_score_base,
2717 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2720 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
2721 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2722 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2724 options_game_engine_type,
2725 &level.game_engine_type,
2726 NULL, "game engine:", NULL, "game engine"
2729 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
2730 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2731 GADGET_ID_BD_SCHEDULING_TYPE, GADGET_ID_NONE,
2733 options_bd_scheduling_type,
2734 &level.bd_scheduling_type,
2735 NULL, "scheduling type:", NULL, "level timing"
2738 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
2739 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2740 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2742 options_levelset_save_mode,
2743 &levelset_save_mode,
2744 "Action:", NULL, NULL, "action when saving level set"
2747 // ---------- element settings: configure (several elements) ----------------
2750 ED_SELECTBOX_ID_WIND_DIRECTION,
2751 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2752 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2754 options_wind_direction,
2755 &level.wind_direction_initial,
2756 NULL, "initial wind direction:", NULL, "initial wind direction"
2759 ED_SELECTBOX_ID_PLAYER_SPEED,
2760 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2761 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2763 options_player_speed,
2764 &level.initial_player_stepsize[0],
2765 NULL, "initial player speed:", NULL, "initial player speed"
2768 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
2769 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2770 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2772 options_group_choice_mode,
2773 &level.mm_ball_choice_mode,
2774 NULL, "choice type:", NULL, "type of content choice"
2777 // ---------- element settings: configure 1 (custom elements) ---------------
2780 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
2781 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2782 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2784 options_access_type,
2785 &custom_element.access_type,
2786 NULL, NULL, NULL, "type of access to this field"
2789 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
2790 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2791 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2793 options_access_layer,
2794 &custom_element.access_layer,
2795 NULL, NULL, NULL, "layer of access for this field"
2798 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
2799 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2800 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2802 options_access_protected,
2803 &custom_element.access_protected,
2804 NULL, NULL, NULL, "protected access for this field"
2807 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
2808 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2809 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2811 options_access_direction,
2812 &custom_element.access_direction,
2813 NULL, "from", NULL, "access direction for this field"
2816 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
2817 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2818 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2820 options_walk_to_action,
2821 &custom_element.walk_to_action,
2822 NULL, NULL, NULL, "diggable/collectible/pushable"
2825 // ---------- element settings: configure 2 (custom elements) ---------------
2828 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
2829 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2830 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2832 options_move_pattern,
2833 &custom_element.move_pattern,
2834 NULL, "can move", NULL, "element move pattern"
2837 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
2838 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2839 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2841 options_move_direction,
2842 &custom_element.move_direction_initial,
2843 NULL, "starts moving", NULL, "initial element move direction"
2846 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
2847 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2848 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2850 options_move_stepsize,
2851 &custom_element.move_stepsize,
2852 NULL, "move/fall speed", NULL, "speed of element movement"
2855 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
2856 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2857 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2859 options_move_leave_type,
2860 &custom_element.move_leave_type,
2861 // left text with leading spaces to place gadget next to "can dig" gadget
2862 // (needed because drawing area gadgets created after selectbox gadgets)
2863 // NULL, "can dig: can", ":", "leave behind or change element"
2864 NULL, " can", ":", "leave behind or change element"
2867 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
2868 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2869 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2871 options_smash_targets,
2872 &custom_element.smash_targets,
2873 NULL, "can smash", NULL, "elements that can be smashed"
2876 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
2877 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2878 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2880 options_slippery_type,
2881 &custom_element.slippery_type,
2882 NULL, "slippery", NULL, "where other elements fall down"
2885 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
2886 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2887 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2890 &custom_element.deadliness,
2891 NULL, "deadly when", NULL, "deadliness of element"
2894 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
2895 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2896 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2898 options_explosion_type,
2899 &custom_element.explosion_type,
2900 NULL, "can explode", NULL, "explosion type"
2903 // ---------- element settings: advanced (custom elements) ------------------
2906 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
2907 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2908 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2911 &custom_element_change.delay_frames,
2912 NULL, "delay time given in", NULL, "delay time units for change"
2915 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
2916 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2917 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2919 options_change_direct_action,
2920 &custom_element_change.direct_action,
2921 NULL, NULL, NULL, "type of direct action"
2924 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
2925 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2926 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2928 options_change_other_action,
2929 &custom_element_change.other_action,
2930 NULL, NULL, "element:", "type of other element action"
2933 ED_SELECTBOX_ID_CHANGE_SIDE,
2934 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2935 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2937 options_change_trigger_side,
2938 &custom_element_change.trigger_side,
2939 NULL, "at", "side", "element side triggering change"
2942 ED_SELECTBOX_ID_CHANGE_PLAYER,
2943 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2944 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2946 options_change_trigger_player,
2947 &custom_element_change.trigger_player,
2948 NULL, "player:", " ", "player that causes change"
2951 ED_SELECTBOX_ID_CHANGE_PAGE,
2952 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2953 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2955 options_change_trigger_page,
2956 &custom_element_change.trigger_page,
2957 NULL, "page:", NULL, "change page that causes change"
2960 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
2961 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2962 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2964 options_change_replace_when,
2965 &custom_element_change.replace_when,
2966 NULL, "replace when", NULL, "which elements can be replaced"
2969 ED_SELECTBOX_ID_ACTION_TYPE,
2970 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2971 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2973 options_action_type,
2974 &custom_element_change.action_type,
2975 NULL, NULL, NULL, "action on specified condition"
2978 ED_SELECTBOX_ID_ACTION_MODE,
2979 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2980 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2982 options_action_mode_none,
2983 &custom_element_change.action_mode,
2984 NULL, NULL, NULL, "action operator"
2987 ED_SELECTBOX_ID_ACTION_ARG,
2988 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2989 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2991 options_action_arg_none,
2992 &custom_element_change.action_arg,
2993 NULL, NULL, NULL, "action parameter"
2996 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
2997 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2998 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
3000 options_change_page,
3001 &custom_element.current_change_page,
3002 NULL, NULL, NULL, "element change page"
3005 // ---------- element settings: configure (group elements) ------------------
3008 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
3009 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3010 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
3012 options_group_choice_mode,
3013 &group_element_info.choice_mode,
3014 NULL, "choice type:", NULL, "type of group element choice"
3023 int gadget_id_align;
3026 char *text_above, *text_left, *text_right, *infotext;
3027 } textbutton_info[ED_NUM_TEXTBUTTONS] =
3029 // ---------- level and editor settings (tabs) ------------------------------
3032 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
3033 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
3034 GADGET_ID_LEVELCONFIG_LEVEL, GADGET_ID_NONE,
3036 NULL, NULL, NULL, "Configure level settings"
3039 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
3041 GADGET_ID_LEVELCONFIG_LEVELSET, GADGET_ID_LEVELCONFIG_LEVEL,
3043 NULL, NULL, NULL, "Update this or create new level set"
3046 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
3048 GADGET_ID_LEVELCONFIG_EDITOR, GADGET_ID_LEVELCONFIG_LEVELSET,
3050 NULL, NULL, NULL, "Configure editor settings"
3053 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
3055 GADGET_ID_LEVELCONFIG_ENGINE, GADGET_ID_LEVELCONFIG_EDITOR,
3057 NULL, NULL, NULL, "Configure engine settings"
3060 // ---------- element settings (tabs) ---------------------------------------
3063 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
3064 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
3065 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
3067 NULL, NULL, NULL, "Show information about element"
3070 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
3072 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
3074 NULL, NULL, NULL, "Configure element properties"
3077 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
3079 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
3081 NULL, NULL, NULL, "Configure element properties, part 1"
3084 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
3086 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
3088 NULL, NULL, NULL, "Configure element properties, part 2"
3091 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
3093 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
3095 NULL, NULL, NULL, "Configure custom element change pages"
3098 // ---------- level and editor settings (buttons) ---------------------------
3101 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
3102 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
3103 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
3105 NULL, NULL, NULL, "Update or create level set"
3108 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
3109 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3110 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
3112 NULL, NULL, "this level as level template",
3113 "Save current settings as new template"
3116 // ---------- element settings (buttons) ------------------------------------
3119 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
3121 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
3123 NULL, " ", "As Template",
3124 "Save current settings as new template"
3127 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
3129 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
3131 NULL, NULL, NULL, "Add new change page"
3134 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
3136 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
3138 NULL, NULL, NULL, "Delete current change page"
3148 int gadget_id_align;
3149 char *text_left, *text_right, *infotext;
3150 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
3153 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
3154 IMG_EDITOR_COUNTER_DOWN,
3155 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3156 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
3157 NULL, NULL, "select previous change page"
3160 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
3161 IMG_EDITOR_COUNTER_UP,
3162 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3163 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
3164 NULL, "change page", "select next change page"
3167 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
3168 IMG_GFX_EDITOR_BUTTON_CP_COPY,
3169 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3170 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
3171 " ", NULL, "copy settings from this change page"
3174 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
3175 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
3176 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3177 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
3178 NULL, NULL, "paste settings to this change page"
3185 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
3193 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
3196 ED_SCROLLBUTTON_ID_AREA_UP,
3197 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
3198 GADGET_ID_SCROLL_UP,
3199 "scroll level editing area up"
3202 ED_SCROLLBUTTON_ID_AREA_DOWN,
3203 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
3204 GADGET_ID_SCROLL_DOWN,
3205 "scroll level editing area down"
3208 ED_SCROLLBUTTON_ID_AREA_LEFT,
3209 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
3210 GADGET_ID_SCROLL_LEFT,
3211 "scroll level editing area left"
3214 ED_SCROLLBUTTON_ID_AREA_RIGHT,
3215 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
3216 GADGET_ID_SCROLL_RIGHT,
3217 "scroll level editing area right"
3220 ED_SCROLLBUTTON_ID_LIST_UP,
3221 IMG_EDITOR_PALETTE_SCROLL_UP,
3222 GADGET_ID_SCROLL_LIST_UP,
3223 "scroll element list up ('Page Up')"
3226 ED_SCROLLBUTTON_ID_LIST_DOWN,
3227 IMG_EDITOR_PALETTE_SCROLL_DOWN,
3228 GADGET_ID_SCROLL_LIST_DOWN,
3229 "scroll element list down ('Page Down')"
3237 int wheel_x, wheel_y;
3238 int wheel_width, wheel_height;
3239 } scrollbar_pos[ED_NUM_SCROLLBARS];
3248 } scrollbar_info[ED_NUM_SCROLLBARS] =
3251 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
3252 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3253 GD_TYPE_SCROLLBAR_HORIZONTAL,
3254 GADGET_ID_SCROLL_HORIZONTAL,
3255 "scroll level editing area horizontally"
3258 ED_SCROLLBAR_ID_AREA_VERTICAL,
3259 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3260 GD_TYPE_SCROLLBAR_VERTICAL,
3261 GADGET_ID_SCROLL_VERTICAL,
3262 "scroll level editing area vertically"
3265 ED_SCROLLBAR_ID_LIST_VERTICAL,
3266 IMG_EDITOR_PALETTE_SCROLLBAR,
3267 GD_TYPE_SCROLLBAR_VERTICAL,
3268 GADGET_ID_SCROLL_LIST_VERTICAL,
3269 "scroll element list vertically"
3279 int gadget_id_align;
3280 int radio_button_nr;
3283 char *text_left, *text_right, *infotext;
3284 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3287 ED_RADIOBUTTON_ID_PERCENTAGE,
3288 -1, ED_LEVEL_SETTINGS_YPOS(0),
3289 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3290 RADIO_NR_RANDOM_ELEMENTS,
3291 &random_placement_method, RANDOM_USE_PERCENTAGE,
3292 " ", "percentage", "use percentage for random elements"
3295 ED_RADIOBUTTON_ID_QUANTITY,
3296 -1, ED_LEVEL_SETTINGS_YPOS(0),
3297 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3298 RADIO_NR_RANDOM_ELEMENTS,
3299 &random_placement_method, RANDOM_USE_QUANTITY,
3300 " ", "quantity", "use quantity for random elements"
3309 int gadget_id_align;
3311 char *text_above, *text_left, *text_right, *infotext;
3312 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3314 // ---------- level and editor settings -------------------------------------
3317 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
3318 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3319 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3320 &level.auto_count_gems,
3322 "automatically count gems needed", "set counter to number of gems"
3325 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
3326 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3327 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3328 &level.rate_time_over_score,
3330 "rate time/steps used over score", "sort high scores by playing time/steps"
3333 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
3334 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3335 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3336 &levelset_use_levelset_artwork,
3338 "use current custom artwork", "use custom artwork of this level set"
3341 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
3342 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3343 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3344 &levelset_copy_level_template,
3346 "copy current level template", "copy level template of this level set"
3349 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
3350 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3351 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3352 &random_placement_background_restricted,
3354 "restrict random placement to:", "set random placement restriction"
3357 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
3358 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3359 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3360 &setup.editor.use_template_for_new_levels,
3361 "Template for new levels and CE/GE:", NULL,
3362 "use template for new levels", "use template for level properties"
3365 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
3366 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3367 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3368 &level.use_custom_template,
3370 "use template for custom elements", "use template for custom properties"
3373 ED_CHECKBUTTON_ID_BD_INTERMISSION,
3374 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
3375 GADGET_ID_BD_INTERMISSION, GADGET_ID_NONE,
3376 &level.bd_intermission,
3377 "Boulder Dash game engine settings:", NULL,
3378 "intermission", "level is an intermission level"
3381 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
3382 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
3383 GADGET_ID_BD_PAL_TIMING, GADGET_ID_NONE,
3384 &level.bd_pal_timing,
3386 "PAL timing", "use slower timer (like PAL C64)"
3389 ED_CHECKBUTTON_ID_BD_LINE_SHIFTING_BORDERS,
3390 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3391 GADGET_ID_BD_LINE_SHIFTING_BORDERS, GADGET_ID_NONE,
3392 &level.bd_line_shifting_borders,
3393 "Compatibility settings:", NULL,
3394 "line-shifting borders", "use line-shifting wrap-around"
3397 ED_CHECKBUTTON_ID_BD_SCAN_FIRST_AND_LAST_ROW,
3398 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3399 GADGET_ID_BD_SCAN_FIRST_AND_LAST_ROW, GADGET_ID_NONE,
3400 &level.bd_scan_first_and_last_row,
3402 "scan first and last row", "also process top/bottom border rows"
3405 ED_CHECKBUTTON_ID_BD_SHORT_EXPLOSIONS,
3406 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3407 GADGET_ID_BD_SHORT_EXPLOSIONS, GADGET_ID_NONE,
3408 &level.bd_short_explosions,
3410 "short explosions", "use four game cycles for explosions"
3413 ED_CHECKBUTTON_ID_BD_GRAVITY_AFFECTS_ALL,
3414 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(9),
3415 GADGET_ID_BD_GRAVITY_AFFECTS_ALL, GADGET_ID_NONE,
3416 &level.bd_gravity_affects_all,
3418 "gravity change affects everything", "gravity affects all falling objects"
3421 // ---------- element settings: configure (various elements) ----------------
3424 ED_CHECKBUTTON_ID_STICK_ELEMENT,
3425 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3426 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3427 &stick_element_properties_window,
3429 "stick this screen to edit content","stick this screen to edit content"
3432 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
3433 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3434 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3435 &level.em_slippery_gems,
3437 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3440 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
3441 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3442 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3443 &level.em_explodes_by_fire,
3445 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3448 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
3449 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3450 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3451 &level.use_spring_bug,
3453 "use spring pushing bug", "use odd spring pushing behaviour"
3456 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
3457 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3458 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3459 &level.use_time_orb_bug,
3461 "use time orb bug", "use odd time orb behaviour"
3464 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
3465 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3466 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3467 &level.use_life_bugs,
3469 "use buggy element behaviour", "use odd (historic) element behaviour"
3472 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
3473 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3474 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3477 "create single random element", "only create one element from content"
3480 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
3481 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3482 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3483 &level.ball_active_initial,
3485 "magic ball initially activated", "activate magic ball after level start"
3488 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
3489 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3490 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3491 &level.grow_into_diggable,
3493 "can grow into anything diggable", "grow into more than just sand"
3496 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
3497 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3498 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3499 &level.sb_fields_needed,
3501 "all fields need to be filled", "require all SB fields to be solved"
3504 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
3505 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3506 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3507 &level.sb_objects_needed,
3509 "all objects need to be placed", "require all SB objects to be solved"
3512 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
3513 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3514 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3515 &level.auto_exit_sokoban,
3517 "exit level if all tasks solved", "automatically finish Sokoban levels"
3520 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
3521 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3522 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3523 &level.solved_by_one_player,
3525 "only one player must enter exit", "level solved by first player in exit"
3528 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
3529 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3530 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3531 &level.finish_dig_collect,
3533 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3536 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
3537 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3538 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3539 &level.keep_walkable_ce,
3541 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3544 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
3545 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3546 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3547 &level.continuous_snapping,
3549 "continuous snapping", "use snapping without releasing key"
3552 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
3553 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3554 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3555 &level.block_snap_field,
3557 "block snapped field when snapping", "use snapping delay to show animation"
3560 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
3561 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3562 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3563 &level.block_last_field,
3565 "block last field when moving", "player blocks last field when moving"
3568 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
3569 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3570 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3571 &level.sp_block_last_field,
3573 "block last field when moving", "player blocks last field when moving"
3576 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
3577 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3578 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3579 &level.instant_relocation,
3581 "no scrolling when relocating", "player gets relocated without delay"
3584 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
3585 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3586 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3587 &level.shifted_relocation,
3589 "no centering when relocating", "level not centered after relocation"
3592 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
3593 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3594 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3595 &level.lazy_relocation,
3597 "only redraw off-screen relocation","no redraw if relocation target visible"
3600 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
3601 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3602 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3603 &level.use_start_element[0],
3605 "use level start element:", "start level at this element's position"
3608 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
3609 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3610 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3611 &level.use_artwork_element[0],
3613 "use artwork from element:", "use player artwork from other element"
3616 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
3617 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3618 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3619 &level.use_explosion_element[0],
3621 "use explosion from element:", "use explosion properties from element"
3624 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
3625 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3626 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3627 &level.initial_player_gravity[0],
3629 "use initial gravity", "set initial player gravity"
3632 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
3633 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3634 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3635 &level.use_initial_inventory[0],
3637 "use initial inventory:", "use collected elements on level start"
3640 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
3641 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3642 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3643 &level.can_pass_to_walkable,
3645 "can pass to walkable element", "player can pass to empty or walkable"
3648 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
3649 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3650 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3651 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3653 "can fall into acid (with gravity)","player can fall into acid pool"
3656 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
3657 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3658 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3659 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3661 "can move into acid", "element can move into acid pool"
3664 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
3665 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3666 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3667 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3669 "deadly when colliding with", "element is deadly when hitting player"
3672 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
3673 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3674 GADGET_ID_BD_DIAGONAL_MOVEMENTS, GADGET_ID_NONE,
3675 &level.bd_diagonal_movements,
3677 "can move diagonally", "player can move diagonally"
3680 ED_CHECKBUTTON_ID_BD_TOPMOST_PLAYER_ACTIVE,
3681 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3682 GADGET_ID_BD_TOPMOST_PLAYER_ACTIVE, GADGET_ID_NONE,
3683 &level.bd_topmost_player_active,
3685 "topmost player is active", "use first player found on playfield"
3688 ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET,
3689 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3690 GADGET_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET, GADGET_ID_NONE,
3691 &level.bd_push_mega_rock_with_sweet,
3693 "mega rocks pushable with sweet", "push mega rocks after eating sweet"
3696 ED_CHECKBUTTON_ID_BD_MAGIC_WALL_WAIT_HATCHING,
3697 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3698 GADGET_ID_BD_MAGIC_WALL_WAIT_HATCHING, GADGET_ID_NONE,
3699 &level.bd_magic_wall_wait_hatching,
3701 "wait for player's birth", "timer start waits for player's birth"
3704 ED_CHECKBUTTON_ID_BD_MAGIC_WALL_STOPS_AMOEBA,
3705 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3706 GADGET_ID_BD_MAGIC_WALL_STOPS_AMOEBA, GADGET_ID_NONE,
3707 &level.bd_magic_wall_stops_amoeba,
3709 "turn amoeba to diamonds", "activation changes amoeba to diamonds"
3712 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
3713 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3714 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3715 &level.envelope[0].autowrap,
3717 "auto-wrap", "automatically wrap envelope text"
3720 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
3721 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3722 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3723 &level.envelope[0].centered,
3725 "centered", "automatically center envelope text"
3728 ED_CHECKBUTTON_ID_MM_LASER_RED,
3729 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3730 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3731 &level.mm_laser_red,
3732 "choose color components for laser:", NULL,
3733 "red", "use red color components in laser"
3736 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
3737 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3738 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3739 &level.mm_laser_green,
3741 "green", "use green color components in laser"
3744 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
3745 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3746 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3747 &level.mm_laser_blue,
3749 "blue", "use blue color components in laser"
3752 ED_CHECKBUTTON_ID_DF_LASER_RED,
3753 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3754 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3755 &level.df_laser_red,
3756 "choose color components for laser:", NULL,
3757 "red", "use red color components in laser"
3760 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
3761 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3762 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3763 &level.df_laser_green,
3765 "green", "use green color components in laser"
3768 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
3769 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3770 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3771 &level.df_laser_blue,
3773 "blue", "use blue color components in laser"
3776 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
3777 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3778 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3779 &level.rotate_mm_ball_content,
3781 "randomly rotate created content", "randomly rotate newly created content"
3784 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
3785 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3786 GADGET_ID_EXPLODE_MM_BALL, GADGET_ID_NONE,
3787 &level.explode_mm_ball,
3789 "explode ball instead of melting", "use explosion to release ball content"
3792 // ---------- element settings: configure 1 (custom elements) ---------------
3795 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
3796 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3797 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3798 &custom_element.use_gfx_element,
3800 "use graphic of element:", "use existing element graphic"
3803 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
3804 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3805 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3806 &level.use_custom_template,
3808 "use template", "use template for custom properties"
3811 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
3812 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3813 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3814 &custom_element_properties[EP_ACCESSIBLE],
3816 NULL, "player can walk to or pass this field"
3819 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
3820 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3821 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3822 &custom_element_properties[EP_GRAVITY_REACHABLE],
3824 "reachable despite gravity", "player can walk/dig despite gravity"
3827 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
3828 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3829 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3830 &custom_element.use_last_ce_value,
3832 "use last CE value after change", "use last CE value after change"
3835 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
3836 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3837 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3838 &custom_element_properties[EP_WALK_TO_OBJECT],
3840 NULL, "player can dig/collect/push element"
3843 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
3844 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3845 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3846 &custom_element_properties[EP_INDESTRUCTIBLE],
3848 "indestructible", "element is indestructible"
3851 // ---------- element settings: configure 2 (custom elements) ---------------
3854 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
3855 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3856 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3857 &custom_element_properties[EP_CAN_MOVE],
3859 NULL, "element can move with some pattern"
3862 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
3863 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3864 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3865 &custom_element_properties[EP_CAN_FALL],
3867 "can fall", "element can fall down"
3870 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
3871 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3872 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3873 &custom_element_properties[EP_CAN_SMASH],
3875 NULL, "element can smash other elements"
3878 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
3879 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3880 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3881 &custom_element_properties[EP_SLIPPERY],
3883 NULL, "other elements can fall down from it"
3886 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
3887 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3888 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3889 &custom_element_properties[EP_DEADLY],
3891 NULL, "element can kill the player"
3894 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
3895 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3896 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3897 &custom_element_properties[EP_CAN_EXPLODE],
3899 NULL, "element can explode"
3902 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
3903 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3904 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3905 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3907 "by fire", "element can explode by fire/explosion"
3910 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
3911 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3912 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3913 &custom_element_properties[EP_EXPLODES_SMASHED],
3915 "smashed", "element can explode when smashed"
3918 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
3919 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3920 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3921 &custom_element_properties[EP_EXPLODES_IMPACT],
3923 "impact", "element can explode on impact"
3926 // ---------- element settings: advanced (custom elements) ------------------
3929 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
3930 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3931 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3932 &custom_element_change.can_change,
3934 "element changes to:", "change element on specified condition"
3937 ED_CHECKBUTTON_ID_CHANGE_DELAY,
3938 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3939 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3940 &custom_element_change_events[CE_DELAY],
3942 NULL, "element changes after delay"
3945 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
3946 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3947 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3948 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3950 NULL, "element changes by direct action"
3953 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
3954 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3955 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3956 &custom_element_change_events[CE_BY_OTHER_ACTION],
3958 NULL, "element changes by other element"
3961 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
3962 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3963 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3964 &custom_element_change.explode,
3966 "explode instead of change", "element explodes instead of change"
3969 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
3970 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3971 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3972 &custom_element_change.use_target_content,
3974 "use extended change target:", "element changes to more elements"
3977 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
3978 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3979 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3980 &custom_element_change.only_if_complete,
3982 "replace all or nothing", "only replace when all can be changed"
3985 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
3986 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3987 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3988 &custom_element_change.use_random_replace,
3990 NULL, "use percentage for random replace"
3993 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
3994 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3995 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3996 &custom_element_change.has_action,
3998 NULL, "execute action on specified condition"
4006 int xoffset, yoffset;
4008 int gadget_id_align;
4010 int area_xsize, area_ysize;
4011 char *text_left, *text_right, *text_above, *text_below, *infotext;
4012 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
4014 // ---------- level playfield content ---------------------------------------
4017 ED_DRAWING_ID_DRAWING_LEVEL,
4020 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
4022 -1, -1, // these values are not constant, but can change at runtime
4023 NULL, NULL, NULL, NULL, NULL
4026 // ---------- yam yam content -----------------------------------------------
4029 ED_DRAWING_ID_YAMYAM_CONTENT_0,
4030 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4031 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
4032 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
4033 &level.yamyam_content[0].e[0][0], 3, 3,
4034 NULL, NULL, NULL, "1", NULL
4037 ED_DRAWING_ID_YAMYAM_CONTENT_1,
4038 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4039 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
4040 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
4041 &level.yamyam_content[1].e[0][0], 3, 3,
4042 NULL, NULL, NULL, "2", NULL
4045 ED_DRAWING_ID_YAMYAM_CONTENT_2,
4046 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4047 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
4048 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
4049 &level.yamyam_content[2].e[0][0], 3, 3,
4050 NULL, NULL, NULL, "3", NULL
4053 ED_DRAWING_ID_YAMYAM_CONTENT_3,
4054 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4055 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
4056 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
4057 &level.yamyam_content[3].e[0][0], 3, 3,
4058 NULL, NULL, NULL, "4", NULL
4061 ED_DRAWING_ID_YAMYAM_CONTENT_4,
4062 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4063 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
4064 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
4065 &level.yamyam_content[4].e[0][0], 3, 3,
4066 NULL, NULL, NULL, "5", NULL
4069 ED_DRAWING_ID_YAMYAM_CONTENT_5,
4070 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4071 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
4072 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
4073 &level.yamyam_content[5].e[0][0], 3, 3,
4074 NULL, NULL, NULL, "6", NULL
4077 ED_DRAWING_ID_YAMYAM_CONTENT_6,
4078 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4079 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
4080 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
4081 &level.yamyam_content[6].e[0][0], 3, 3,
4082 NULL, NULL, NULL, "7", NULL
4085 ED_DRAWING_ID_YAMYAM_CONTENT_7,
4086 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4087 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
4088 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
4089 &level.yamyam_content[7].e[0][0], 3, 3,
4090 NULL, NULL, NULL, "8", NULL
4093 // ---------- magic ball content --------------------------------------------
4096 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
4097 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4098 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
4099 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
4100 &level.ball_content[0].e[0][0], 3, 3,
4101 NULL, NULL, NULL, "1", NULL
4104 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
4105 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4106 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
4107 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
4108 &level.ball_content[1].e[0][0], 3, 3,
4109 NULL, NULL, NULL, "2", NULL
4112 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
4113 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4114 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
4115 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
4116 &level.ball_content[2].e[0][0], 3, 3,
4117 NULL, NULL, NULL, "3", NULL
4120 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
4121 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4122 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
4123 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
4124 &level.ball_content[3].e[0][0], 3, 3,
4125 NULL, NULL, NULL, "4", NULL
4128 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
4129 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4130 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
4131 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
4132 &level.ball_content[4].e[0][0], 3, 3,
4133 NULL, NULL, NULL, "5", NULL
4136 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
4137 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4138 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
4139 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
4140 &level.ball_content[5].e[0][0], 3, 3,
4141 NULL, NULL, NULL, "6", NULL
4144 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
4145 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4146 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
4147 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
4148 &level.ball_content[6].e[0][0], 3, 3,
4149 NULL, NULL, NULL, "7", NULL
4152 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
4153 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4154 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
4155 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
4156 &level.ball_content[7].e[0][0], 3, 3,
4157 NULL, NULL, NULL, "8", NULL
4160 // ---------- android content -----------------------------------------------
4163 ED_DRAWING_ID_ANDROID_CONTENT,
4164 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
4165 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4166 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
4167 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
4168 NULL, NULL, "elements:", NULL, "elements android can clone"
4171 // ---------- amoeba content ------------------------------------------------
4174 ED_DRAWING_ID_AMOEBA_CONTENT,
4175 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
4176 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4177 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
4178 &level.amoeba_content, 1, 1,
4179 "content:", NULL, NULL, NULL, "amoeba content"
4182 // ---------- level start element -------------------------------------------
4185 ED_DRAWING_ID_START_ELEMENT,
4186 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
4187 0, ED_AREA_1X1_SETTINGS_YOFF,
4188 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
4189 &level.start_element[0], 1, 1,
4190 NULL, NULL, NULL, NULL, "level start element"
4193 // ---------- player artwork element ----------------------------------------
4196 ED_DRAWING_ID_ARTWORK_ELEMENT,
4197 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
4198 0, ED_AREA_1X1_SETTINGS_YOFF,
4199 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
4200 &level.artwork_element[0], 1, 1,
4201 NULL, NULL, NULL, NULL, "element for player artwork"
4204 // ---------- player explosion element --------------------------------------
4207 ED_DRAWING_ID_EXPLOSION_ELEMENT,
4208 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
4209 0, ED_AREA_1X1_SETTINGS_YOFF,
4210 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
4211 &level.explosion_element[0], 1, 1,
4212 NULL, NULL, NULL, NULL, "element for player explosion"
4215 // ---------- player initial inventory --------------------------------------
4218 ED_DRAWING_ID_INVENTORY_CONTENT,
4219 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4220 0, ED_AREA_1X1_SETTINGS_YOFF,
4221 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
4222 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
4223 NULL, NULL, NULL, NULL, "content for initial inventory"
4226 // ---------- gray ball content -----------------------------------------
4229 ED_DRAWING_ID_MM_BALL_CONTENT,
4230 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4231 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4232 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
4233 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
4234 "content:", NULL, NULL, NULL, "content for gray ball"
4237 // ---------- element settings: configure 1 (custom elements) ---------------
4239 // ---------- custom graphic ------------------------------------------------
4242 ED_DRAWING_ID_CUSTOM_GRAPHIC,
4243 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4244 0, ED_AREA_1X1_SETTINGS_YOFF,
4245 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
4246 &custom_element.gfx_element_initial, 1, 1,
4247 NULL, NULL, NULL, NULL, "custom graphic element"
4250 // ---------- element settings: configure 2 (custom elements) ---------------
4252 // ---------- custom content (when exploding) -------------------------------
4255 ED_DRAWING_ID_CUSTOM_CONTENT,
4256 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
4257 0, ED_AREA_3X3_SETTINGS_YOFF,
4258 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
4259 &custom_element.content.e[0][0], 3, 3,
4260 "content:", NULL, NULL, NULL, NULL
4263 // ---------- custom enter and leave element (when moving) ------------------
4266 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
4267 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
4268 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4269 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
4270 &custom_element.move_enter_element, 1, 1,
4271 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
4274 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
4275 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
4276 0, ED_AREA_1X1_SETTINGS_YOFF,
4277 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
4278 &custom_element.move_leave_element, 1, 1,
4279 NULL, NULL, NULL, NULL, "element that will be left behind"
4282 // ---------- element settings: advanced (custom elements) ------------------
4284 // ---------- custom change target ------------------------------------------
4287 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
4288 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4289 0, ED_AREA_1X1_SETTINGS_YOFF,
4290 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
4291 &custom_element_change.target_element, 1, 1,
4292 NULL, "after/when:", NULL, NULL, "new target element after change"
4295 // ---------- custom change content (extended change target) ----------------
4298 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
4299 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
4300 0, ED_AREA_3X3_SETTINGS_YOFF,
4301 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
4302 &custom_element_change.target_content.e[0][0], 3, 3,
4303 NULL, NULL, NULL, NULL, "new extended elements after change"
4306 // ---------- custom change trigger (element causing change) ----------------
4309 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
4310 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
4311 0, ED_AREA_1X1_SETTINGS_YOFF,
4312 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
4313 &custom_element_change.initial_trigger_element, 1, 1,
4314 NULL, NULL, NULL, NULL, "other element triggering change"
4317 // ---------- custom change action (element used for action) ----------------
4320 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
4321 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
4322 0, ED_AREA_1X1_SETTINGS_YOFF,
4323 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
4324 &custom_element_change.action_element, 1, 1,
4325 NULL, NULL, NULL, NULL, "element used as action parameter"
4328 // ---------- group element content -----------------------------------------
4331 ED_DRAWING_ID_GROUP_CONTENT,
4332 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4333 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4334 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
4335 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
4336 "content:", NULL, NULL, NULL, NULL
4339 // ---------- random background (for random painting) -----------------------
4342 ED_DRAWING_ID_RANDOM_BACKGROUND,
4343 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
4344 0, ED_AREA_1X1_LSETTINGS_YOFF,
4345 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
4346 &random_placement_background_element, 1, 1,
4347 NULL, NULL, NULL, NULL, "random placement background"
4352 // ----------------------------------------------------------------------------
4353 // some internally used variables
4354 // ----------------------------------------------------------------------------
4356 // maximal size of level editor drawing area
4357 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
4359 // actual size of level editor drawing area
4360 static int ed_fieldx, ed_fieldy;
4362 // actual position of level editor drawing area in level playfield
4363 static int level_xpos = -1, level_ypos = -1;
4365 // actual tile size used to display playfield drawing area
4366 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
4367 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
4369 #define IN_ED_FIELD(x, y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
4371 // drawing elements on the three mouse buttons
4372 static int new_element1 = EL_WALL;
4373 static int new_element2 = EL_EMPTY;
4374 static int new_element3 = EL_SAND;
4376 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
4377 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
4378 (button) == 2 ? new_element2 : \
4379 (button) == 3 ? new_element3 : EL_EMPTY)
4381 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
4383 static int use_permanent_palette = TRUE;
4385 #define PX (use_permanent_palette ? DX : SX)
4386 #define PY (use_permanent_palette ? DY : SY)
4387 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
4388 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
4390 // forward declaration for internal use
4391 static void CopyBrushToCursor(int, int);
4392 static void DeleteBrushFromCursor(void);
4393 static void ModifyEditorCounterValue(int, int);
4394 static void ModifyEditorCounterLimits(int, int, int);
4395 static void ModifyEditorSelectboxValue(int, int);
4396 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
4397 static void ModifyEditorDrawingArea(int, int, int);
4398 static void ModifyEditorElementList(void);
4399 static void AdjustElementListScrollbar(void);
4400 static void RedrawDrawingElements(void);
4401 static void DrawDrawingWindowExt(boolean);
4402 static void DrawDrawingWindow(void);
4403 static void DrawLevelConfigWindow(void);
4404 static void DrawPropertiesWindow(void);
4405 static void DrawPaletteWindow(void);
4406 static void UpdateCustomElementGraphicGadgets(void);
4407 static boolean checkPropertiesConfig(int);
4408 static void SetAutomaticNumberOfGemsNeeded(void);
4409 static void ClearEditorGadgetInfoText(void);
4410 static void CopyLevelToUndoBuffer(int);
4411 static void HandleDrawingAreas(struct GadgetInfo *);
4412 static void HandleCounterButtons(struct GadgetInfo *);
4413 static void HandleTextInputGadgets(struct GadgetInfo *);
4414 static void HandleTextAreaGadgets(struct GadgetInfo *);
4415 static void HandleSelectboxGadgets(struct GadgetInfo *);
4416 static void HandleTextbuttonGadgets(struct GadgetInfo *);
4417 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
4418 static void HandleRadiobuttons(struct GadgetInfo *);
4419 static void HandleCheckbuttons(struct GadgetInfo *);
4420 static void HandleControlButtons(struct GadgetInfo *);
4421 static void HandleDrawingAreaInfo(struct GadgetInfo *);
4422 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
4423 static boolean AskToCopyAndModifyLevelTemplate(void);
4424 static boolean getDrawModeHiRes(void);
4425 static int getTabulatorBarWidth(void);
4426 static int getTabulatorBarHeight(void);
4427 static Pixel getTabulatorBarColor(void);
4428 static int numHiresTiles(int);
4430 static int num_editor_gadgets = 0; // dynamically determined
4432 static struct GadgetInfo **level_editor_gadget = NULL;
4433 static int *right_gadget_border = NULL;
4435 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
4436 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
4437 static boolean draw_with_brush = FALSE;
4438 static int properties_element = 0;
4440 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4441 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4442 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4443 static int undo_buffer_position = 0;
4444 static int undo_buffer_steps = 0;
4445 static int redo_buffer_steps = 0;
4447 static int edit_mode;
4448 static int edit_mode_levelconfig;
4449 static int edit_mode_properties;
4451 static int element_shift = 0;
4453 static int editor_el_players[] =
4460 static int *editor_el_players_ptr = editor_el_players;
4461 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4463 static int editor_hl_boulderdash[] =
4465 EL_INTERNAL_CASCADE_BD_ACTIVE,
4471 static int editor_el_boulderdash[] =
4480 EL_BD_EXPANDABLE_WALL,
4488 EL_BD_BUTTERFLY_LEFT,
4490 EL_BD_BUTTERFLY_RIGHT,
4491 EL_BD_FIREFLY_RIGHT,
4494 EL_BD_BUTTERFLY_DOWN,
4498 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4499 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4500 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4501 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4503 static int editor_hl_boulderdash_native[] =
4505 EL_INTERNAL_CASCADE_BD_NATIVE_ACTIVE,
4511 static int editor_el_boulderdash_native[] =
4528 EL_BD_BUTTERFLY_LEFT,
4530 EL_BD_BUTTERFLY_RIGHT,
4531 EL_BD_FIREFLY_RIGHT,
4534 EL_BD_BUTTERFLY_DOWN,
4539 EL_BD_BUTTERFLY_2_UP,
4543 EL_BD_BUTTERFLY_2_LEFT,
4544 EL_BD_FIREFLY_2_LEFT,
4545 EL_BD_BUTTERFLY_2_RIGHT,
4546 EL_BD_FIREFLY_2_RIGHT,
4549 EL_BD_BUTTERFLY_2_DOWN,
4550 EL_BD_FIREFLY_2_DOWN,
4558 EL_BD_DRAGONFLY_LEFT,
4559 EL_BD_STONEFLY_LEFT,
4560 EL_BD_DRAGONFLY_RIGHT,
4561 EL_BD_STONEFLY_RIGHT,
4564 EL_BD_DRAGONFLY_DOWN,
4565 EL_BD_STONEFLY_DOWN,
4588 EL_BD_SAND_SLOPED_UP_LEFT,
4589 EL_BD_SAND_SLOPED_UP_RIGHT,
4590 EL_BD_WALL_SLOPED_UP_LEFT,
4591 EL_BD_WALL_SLOPED_UP_RIGHT,
4593 EL_BD_SAND_SLOPED_DOWN_LEFT,
4594 EL_BD_SAND_SLOPED_DOWN_RIGHT,
4595 EL_BD_WALL_SLOPED_DOWN_LEFT,
4596 EL_BD_WALL_SLOPED_DOWN_RIGHT,
4598 EL_BD_FLYING_DIAMOND,
4600 EL_BD_STEELWALL_SLOPED_UP_LEFT,
4601 EL_BD_STEELWALL_SLOPED_UP_RIGHT,
4605 EL_BD_STEELWALL_SLOPED_DOWN_LEFT,
4606 EL_BD_STEELWALL_SLOPED_DOWN_RIGHT,
4609 EL_BD_WALL_NON_SLOPED,
4615 EL_BD_INVISIBLE_EXIT_CLOSED,
4616 EL_BD_INVISIBLE_EXIT_OPEN,
4619 EL_BD_STEELWALL_EXPLODABLE,
4620 EL_BD_STEELWALL_DIGGABLE,
4621 EL_BD_WALL_DIGGABLE,
4623 EL_BD_EXPANDABLE_WALL_HORIZONTAL,
4624 EL_BD_EXPANDABLE_WALL_VERTICAL,
4625 EL_BD_EXPANDABLE_WALL_ANY,
4626 EL_BD_CREATURE_SWITCH,
4628 EL_BD_EXPANDABLE_STEELWALL_HORIZONTAL,
4629 EL_BD_EXPANDABLE_STEELWALL_VERTICAL,
4630 EL_BD_EXPANDABLE_STEELWALL_ANY,
4631 EL_BD_EXPANDABLE_WALL_SWITCH_HORIZONTAL,
4633 EL_BD_BITER_SWITCH_1,
4634 EL_BD_REPLICATOR_SWITCH,
4635 EL_BD_CONVEYOR_SWITCH,
4636 EL_BD_CONVEYOR_DIR_SWITCH_RIGHT,
4645 EL_BD_DIAMOND_GLUED,
4648 EL_BD_TRAPPED_DIAMOND,
4668 EL_BD_GRAVITY_SWITCH,
4669 EL_BD_PNEUMATIC_HAMMER,
4676 EL_BD_BLADDER_SPENDER,
4678 EL_BD_CONVEYOR_LEFT,
4679 EL_BD_CONVEYOR_RIGHT,
4694 EL_BD_PLAYER_WITH_BOMB,
4696 EL_BD_PLAYER_STIRRING,
4698 static int *editor_hl_boulderdash_native_ptr = editor_hl_boulderdash_native;
4699 static int *editor_el_boulderdash_native_ptr = editor_el_boulderdash_native;
4700 static int num_editor_hl_boulderdash_native = ARRAY_SIZE(editor_hl_boulderdash_native);
4701 static int num_editor_el_boulderdash_native = ARRAY_SIZE(editor_el_boulderdash_native);
4703 static int editor_hl_emerald_mine[] =
4705 EL_INTERNAL_CASCADE_EM_ACTIVE,
4711 static int editor_el_emerald_mine[] =
4729 EL_EM_DYNAMITE_ACTIVE,
4748 EL_ACID_POOL_TOPLEFT,
4750 EL_ACID_POOL_TOPRIGHT,
4753 EL_ACID_POOL_BOTTOMLEFT,
4754 EL_ACID_POOL_BOTTOM,
4755 EL_ACID_POOL_BOTTOMRIGHT,
4773 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4774 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4775 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4776 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4778 static int editor_hl_emerald_mine_club[] =
4780 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4786 static int editor_el_emerald_mine_club[] =
4813 EL_EMC_WALL_SLIPPERY_1,
4814 EL_EMC_WALL_SLIPPERY_2,
4815 EL_EMC_WALL_SLIPPERY_3,
4816 EL_EMC_WALL_SLIPPERY_4,
4839 EL_EMC_MAGIC_BALL_SWITCH,
4846 EL_EMC_SPRING_BUMPER,
4850 EL_BALLOON_SWITCH_UP,
4851 EL_BALLOON_SWITCH_ANY,
4854 EL_BALLOON_SWITCH_LEFT,
4856 EL_BALLOON_SWITCH_RIGHT,
4860 EL_BALLOON_SWITCH_DOWN,
4861 EL_BALLOON_SWITCH_NONE,
4863 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4864 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4865 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4866 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4868 static int editor_hl_rnd[] =
4870 EL_INTERNAL_CASCADE_RND_ACTIVE,
4876 static int editor_el_rnd[] =
4879 EL_DYNAMITE_ACTIVE, // RND
4913 EL_WALL_EMERALD_YELLOW,
4914 EL_WALL_EMERALD_RED,
4915 EL_WALL_EMERALD_PURPLE,
4933 EL_DYNABOMB_INCREASE_NUMBER,
4934 EL_DYNABOMB_INCREASE_SIZE,
4935 EL_DYNABOMB_INCREASE_POWER,
4955 EL_INVISIBLE_STEELWALL,
4959 EL_EXPANDABLE_WALL_HORIZONTAL,
4960 EL_EXPANDABLE_WALL_VERTICAL,
4961 EL_EXPANDABLE_WALL_ANY,
4963 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4964 static int *editor_el_rnd_ptr = editor_el_rnd;
4965 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4966 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4968 static int editor_hl_sokoban[] =
4970 EL_INTERNAL_CASCADE_SB_ACTIVE,
4976 static int editor_el_sokoban[] =
4979 EL_SOKOBAN_FIELD_EMPTY,
4980 EL_SOKOBAN_FIELD_FULL,
4981 EL_SOKOBAN_FIELD_PLAYER,
4983 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4984 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4985 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4986 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4988 static int editor_hl_supaplex[] =
4990 EL_INTERNAL_CASCADE_SP_ACTIVE,
4996 static int editor_el_supaplex[] =
5014 EL_SP_PORT_HORIZONTAL,
5015 EL_SP_PORT_VERTICAL,
5023 EL_SP_GRAVITY_PORT_LEFT,
5024 EL_SP_GRAVITY_PORT_RIGHT,
5025 EL_SP_GRAVITY_PORT_UP,
5026 EL_SP_GRAVITY_PORT_DOWN,
5028 EL_SP_GRAVITY_ON_PORT_LEFT,
5029 EL_SP_GRAVITY_ON_PORT_RIGHT,
5030 EL_SP_GRAVITY_ON_PORT_UP,
5031 EL_SP_GRAVITY_ON_PORT_DOWN,
5033 EL_SP_GRAVITY_OFF_PORT_LEFT,
5034 EL_SP_GRAVITY_OFF_PORT_RIGHT,
5035 EL_SP_GRAVITY_OFF_PORT_UP,
5036 EL_SP_GRAVITY_OFF_PORT_DOWN,
5038 EL_SP_HARDWARE_GRAY,
5039 EL_SP_HARDWARE_GREEN,
5040 EL_SP_HARDWARE_BLUE,
5043 EL_SP_HARDWARE_BASE_1,
5044 EL_SP_HARDWARE_BASE_2,
5045 EL_SP_HARDWARE_BASE_3,
5046 EL_SP_HARDWARE_BASE_4,
5048 EL_SP_HARDWARE_BASE_5,
5049 EL_SP_HARDWARE_BASE_6,
5050 EL_SP_HARDWARE_YELLOW,
5058 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
5059 static int *editor_el_supaplex_ptr = editor_el_supaplex;
5060 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
5061 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
5063 static int editor_hl_diamond_caves[] =
5065 EL_INTERNAL_CASCADE_DC_ACTIVE,
5071 static int editor_el_diamond_caves[] =
5073 EL_EM_STEEL_EXIT_CLOSED, // DC2
5074 EL_EM_STEEL_EXIT_OPEN, // DC2
5075 EL_WALL_EMERALD, // DC2
5076 EL_WALL_DIAMOND, // DC2
5083 EL_CONVEYOR_BELT_1_LEFT,
5084 EL_CONVEYOR_BELT_1_MIDDLE,
5085 EL_CONVEYOR_BELT_1_RIGHT,
5086 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
5088 EL_CONVEYOR_BELT_2_LEFT,
5089 EL_CONVEYOR_BELT_2_MIDDLE,
5090 EL_CONVEYOR_BELT_2_RIGHT,
5091 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
5093 EL_CONVEYOR_BELT_3_LEFT,
5094 EL_CONVEYOR_BELT_3_MIDDLE,
5095 EL_CONVEYOR_BELT_3_RIGHT,
5096 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
5098 EL_CONVEYOR_BELT_4_LEFT,
5099 EL_CONVEYOR_BELT_4_MIDDLE,
5100 EL_CONVEYOR_BELT_4_RIGHT,
5101 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
5103 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
5104 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
5105 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
5106 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
5108 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
5109 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
5110 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
5111 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
5116 EL_DC_TIMEGATE_SWITCH,
5118 EL_SWITCHGATE_CLOSED,
5120 EL_SWITCHGATE_SWITCH_UP,
5121 EL_SWITCHGATE_SWITCH_DOWN,
5124 EL_LIGHT_SWITCH_ACTIVE,
5125 EL_DC_SWITCHGATE_SWITCH_UP,
5126 EL_DC_SWITCHGATE_SWITCH_DOWN,
5128 EL_STEEL_EXIT_CLOSED,
5130 EL_STEELWALL_SLIPPERY,
5133 EL_QUICKSAND_FAST_EMPTY,
5134 EL_QUICKSAND_FAST_FULL,
5148 EL_SIGN_RADIOACTIVITY,
5154 EL_SIGN_ENTRY_FORBIDDEN,
5155 EL_SIGN_EMERGENCY_EXIT,
5180 EL_DC_STEELWALL_2_SINGLE,
5181 EL_DC_STEELWALL_2_TOP,
5182 EL_SIGN_EXCLAMATION,
5185 EL_DC_STEELWALL_2_LEFT,
5186 EL_DC_STEELWALL_2_MIDDLE,
5187 EL_DC_STEELWALL_2_HORIZONTAL,
5188 EL_DC_STEELWALL_2_RIGHT,
5190 EL_DC_STEELWALL_1_TOPLEFT,
5191 EL_DC_STEELWALL_2_VERTICAL,
5192 EL_DC_STEELWALL_1_TOPRIGHT,
5195 EL_DC_STEELWALL_1_VERTICAL,
5196 EL_DC_STEELWALL_2_BOTTOM,
5198 EL_DC_GATE_WHITE_GRAY,
5200 EL_DC_STEELWALL_1_BOTTOMLEFT,
5201 EL_DC_STEELWALL_1_HORIZONTAL,
5202 EL_DC_STEELWALL_1_BOTTOMRIGHT,
5203 EL_DC_GATE_FAKE_GRAY,
5205 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
5206 EL_DC_STEELWALL_1_BOTTOM,
5207 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
5208 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
5210 EL_DC_STEELWALL_1_RIGHT,
5212 EL_DC_STEELWALL_1_LEFT,
5213 EL_EXPANDABLE_STEELWALL_VERTICAL,
5215 EL_DC_STEELWALL_1_TOPRIGHT_2,
5216 EL_DC_STEELWALL_1_TOP,
5217 EL_DC_STEELWALL_1_TOPLEFT_2,
5218 EL_EXPANDABLE_STEELWALL_ANY,
5220 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
5221 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
5222 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
5223 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
5225 static int editor_hl_dx_boulderdash[] =
5227 EL_INTERNAL_CASCADE_DX_ACTIVE,
5233 static int editor_el_dx_boulderdash[] =
5237 EL_TUBE_HORIZONTAL_DOWN,
5241 EL_TUBE_VERTICAL_RIGHT,
5243 EL_TUBE_VERTICAL_LEFT,
5247 EL_TUBE_HORIZONTAL_UP,
5255 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
5256 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
5257 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
5258 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
5260 static int editor_hl_mirror_magic[] =
5262 EL_INTERNAL_CASCADE_MM_ACTIVE,
5268 static int editor_el_mirror_magic[] =
5270 EL_MM_MCDUFFIN_RIGHT,
5272 EL_MM_MCDUFFIN_LEFT,
5273 EL_MM_MCDUFFIN_DOWN,
5276 EL_MM_MIRROR_FIXED_START,
5277 EL_MM_POLARIZER_START,
5278 EL_MM_POLARIZER_CROSS_START,
5280 EL_MM_TELEPORTER_RED_START,
5281 EL_MM_TELEPORTER_YELLOW_START,
5282 EL_MM_TELEPORTER_GREEN_START,
5283 EL_MM_TELEPORTER_BLUE_START,
5296 EL_MM_LIGHTBULB_ACTIVE,
5310 EL_MM_STEEL_GRID_FIXED_1,
5311 EL_MM_STEEL_GRID_FIXED_2,
5312 EL_MM_STEEL_GRID_FIXED_3,
5313 EL_MM_STEEL_GRID_FIXED_4,
5315 EL_MM_WOODEN_GRID_FIXED_1,
5316 EL_MM_WOODEN_GRID_FIXED_2,
5317 EL_MM_WOODEN_GRID_FIXED_3,
5318 EL_MM_WOODEN_GRID_FIXED_4,
5325 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
5326 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
5327 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
5328 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
5330 static int editor_hl_deflektor[] =
5332 EL_INTERNAL_CASCADE_DF_ACTIVE,
5338 static int editor_el_deflektor[] =
5345 EL_DF_RECEIVER_RIGHT,
5347 EL_DF_RECEIVER_LEFT,
5348 EL_DF_RECEIVER_DOWN,
5351 EL_DF_MIRROR_ROTATING_START,
5352 EL_DF_MIRROR_FIXED_START,
5355 EL_DF_FIBRE_OPTIC_RED_1,
5356 EL_DF_FIBRE_OPTIC_YELLOW_1,
5357 EL_DF_FIBRE_OPTIC_GREEN_1,
5358 EL_DF_FIBRE_OPTIC_BLUE_1,
5360 EL_DF_STEEL_GRID_FIXED_START,
5361 EL_DF_STEEL_GRID_ROTATING_START,
5362 EL_DF_WOODEN_GRID_FIXED_START,
5363 EL_DF_WOODEN_GRID_ROTATING_START,
5375 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
5376 static int *editor_el_deflektor_ptr = editor_el_deflektor;
5377 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
5378 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
5380 static int editor_hl_chars[] =
5382 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
5388 static int editor_el_chars[] =
5470 EL_CHAR(CHAR_BYTE_COPYRIGHT),
5471 EL_CHAR(CHAR_BYTE_UMLAUT_A),
5472 EL_CHAR(CHAR_BYTE_UMLAUT_O),
5473 EL_CHAR(CHAR_BYTE_UMLAUT_U),
5475 EL_CHAR(CHAR_BYTE_DEGREE),
5476 EL_CHAR(CHAR_BYTE_REGISTERED),
5477 EL_CHAR(FONT_ASCII_CURSOR),
5478 EL_CHAR(FONT_ASCII_BUTTON),
5480 EL_CHAR(FONT_ASCII_UP),
5481 EL_CHAR(FONT_ASCII_DOWN),
5485 static int *editor_hl_chars_ptr = editor_hl_chars;
5486 static int *editor_el_chars_ptr = editor_el_chars;
5487 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
5488 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
5490 static int editor_hl_steel_chars[] =
5492 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
5498 static int editor_el_steel_chars[] =
5508 EL_STEEL_CHAR('\''),
5575 EL_STEEL_CHAR('\\'),
5580 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
5581 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
5582 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
5583 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
5585 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
5586 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
5587 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
5588 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
5590 EL_STEEL_CHAR(FONT_ASCII_UP),
5591 EL_STEEL_CHAR(FONT_ASCII_DOWN),
5595 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
5596 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
5597 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
5598 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
5600 static int editor_hl_custom[] =
5602 EL_INTERNAL_CASCADE_CE_ACTIVE,
5608 static int editor_el_custom[] =
5610 EL_CUSTOM_START + 0,
5611 EL_CUSTOM_START + 1,
5612 EL_CUSTOM_START + 2,
5613 EL_CUSTOM_START + 3,
5615 EL_CUSTOM_START + 4,
5616 EL_CUSTOM_START + 5,
5617 EL_CUSTOM_START + 6,
5618 EL_CUSTOM_START + 7,
5620 EL_CUSTOM_START + 8,
5621 EL_CUSTOM_START + 9,
5622 EL_CUSTOM_START + 10,
5623 EL_CUSTOM_START + 11,
5625 EL_CUSTOM_START + 12,
5626 EL_CUSTOM_START + 13,
5627 EL_CUSTOM_START + 14,
5628 EL_CUSTOM_START + 15,
5630 EL_CUSTOM_START + 16,
5631 EL_CUSTOM_START + 17,
5632 EL_CUSTOM_START + 18,
5633 EL_CUSTOM_START + 19,
5635 EL_CUSTOM_START + 20,
5636 EL_CUSTOM_START + 21,
5637 EL_CUSTOM_START + 22,
5638 EL_CUSTOM_START + 23,
5640 EL_CUSTOM_START + 24,
5641 EL_CUSTOM_START + 25,
5642 EL_CUSTOM_START + 26,
5643 EL_CUSTOM_START + 27,
5645 EL_CUSTOM_START + 28,
5646 EL_CUSTOM_START + 29,
5647 EL_CUSTOM_START + 30,
5648 EL_CUSTOM_START + 31,
5650 EL_CUSTOM_START + 32,
5651 EL_CUSTOM_START + 33,
5652 EL_CUSTOM_START + 34,
5653 EL_CUSTOM_START + 35,
5655 EL_CUSTOM_START + 36,
5656 EL_CUSTOM_START + 37,
5657 EL_CUSTOM_START + 38,
5658 EL_CUSTOM_START + 39,
5660 EL_CUSTOM_START + 40,
5661 EL_CUSTOM_START + 41,
5662 EL_CUSTOM_START + 42,
5663 EL_CUSTOM_START + 43,
5665 EL_CUSTOM_START + 44,
5666 EL_CUSTOM_START + 45,
5667 EL_CUSTOM_START + 46,
5668 EL_CUSTOM_START + 47,
5670 EL_CUSTOM_START + 48,
5671 EL_CUSTOM_START + 49,
5672 EL_CUSTOM_START + 50,
5673 EL_CUSTOM_START + 51,
5675 EL_CUSTOM_START + 52,
5676 EL_CUSTOM_START + 53,
5677 EL_CUSTOM_START + 54,
5678 EL_CUSTOM_START + 55,
5680 EL_CUSTOM_START + 56,
5681 EL_CUSTOM_START + 57,
5682 EL_CUSTOM_START + 58,
5683 EL_CUSTOM_START + 59,
5685 EL_CUSTOM_START + 60,
5686 EL_CUSTOM_START + 61,
5687 EL_CUSTOM_START + 62,
5688 EL_CUSTOM_START + 63,
5690 EL_CUSTOM_START + 64,
5691 EL_CUSTOM_START + 65,
5692 EL_CUSTOM_START + 66,
5693 EL_CUSTOM_START + 67,
5695 EL_CUSTOM_START + 68,
5696 EL_CUSTOM_START + 69,
5697 EL_CUSTOM_START + 70,
5698 EL_CUSTOM_START + 71,
5700 EL_CUSTOM_START + 72,
5701 EL_CUSTOM_START + 73,
5702 EL_CUSTOM_START + 74,
5703 EL_CUSTOM_START + 75,
5705 EL_CUSTOM_START + 76,
5706 EL_CUSTOM_START + 77,
5707 EL_CUSTOM_START + 78,
5708 EL_CUSTOM_START + 79,
5710 EL_CUSTOM_START + 80,
5711 EL_CUSTOM_START + 81,
5712 EL_CUSTOM_START + 82,
5713 EL_CUSTOM_START + 83,
5715 EL_CUSTOM_START + 84,
5716 EL_CUSTOM_START + 85,
5717 EL_CUSTOM_START + 86,
5718 EL_CUSTOM_START + 87,
5720 EL_CUSTOM_START + 88,
5721 EL_CUSTOM_START + 89,
5722 EL_CUSTOM_START + 90,
5723 EL_CUSTOM_START + 91,
5725 EL_CUSTOM_START + 92,
5726 EL_CUSTOM_START + 93,
5727 EL_CUSTOM_START + 94,
5728 EL_CUSTOM_START + 95,
5730 EL_CUSTOM_START + 96,
5731 EL_CUSTOM_START + 97,
5732 EL_CUSTOM_START + 98,
5733 EL_CUSTOM_START + 99,
5735 EL_CUSTOM_START + 100,
5736 EL_CUSTOM_START + 101,
5737 EL_CUSTOM_START + 102,
5738 EL_CUSTOM_START + 103,
5740 EL_CUSTOM_START + 104,
5741 EL_CUSTOM_START + 105,
5742 EL_CUSTOM_START + 106,
5743 EL_CUSTOM_START + 107,
5745 EL_CUSTOM_START + 108,
5746 EL_CUSTOM_START + 109,
5747 EL_CUSTOM_START + 110,
5748 EL_CUSTOM_START + 111,
5750 EL_CUSTOM_START + 112,
5751 EL_CUSTOM_START + 113,
5752 EL_CUSTOM_START + 114,
5753 EL_CUSTOM_START + 115,
5755 EL_CUSTOM_START + 116,
5756 EL_CUSTOM_START + 117,
5757 EL_CUSTOM_START + 118,
5758 EL_CUSTOM_START + 119,
5760 EL_CUSTOM_START + 120,
5761 EL_CUSTOM_START + 121,
5762 EL_CUSTOM_START + 122,
5763 EL_CUSTOM_START + 123,
5765 EL_CUSTOM_START + 124,
5766 EL_CUSTOM_START + 125,
5767 EL_CUSTOM_START + 126,
5768 EL_CUSTOM_START + 127,
5770 EL_CUSTOM_START + 128,
5771 EL_CUSTOM_START + 129,
5772 EL_CUSTOM_START + 130,
5773 EL_CUSTOM_START + 131,
5775 EL_CUSTOM_START + 132,
5776 EL_CUSTOM_START + 133,
5777 EL_CUSTOM_START + 134,
5778 EL_CUSTOM_START + 135,
5780 EL_CUSTOM_START + 136,
5781 EL_CUSTOM_START + 137,
5782 EL_CUSTOM_START + 138,
5783 EL_CUSTOM_START + 139,
5785 EL_CUSTOM_START + 140,
5786 EL_CUSTOM_START + 141,
5787 EL_CUSTOM_START + 142,
5788 EL_CUSTOM_START + 143,
5790 EL_CUSTOM_START + 144,
5791 EL_CUSTOM_START + 145,
5792 EL_CUSTOM_START + 146,
5793 EL_CUSTOM_START + 147,
5795 EL_CUSTOM_START + 148,
5796 EL_CUSTOM_START + 149,
5797 EL_CUSTOM_START + 150,
5798 EL_CUSTOM_START + 151,
5800 EL_CUSTOM_START + 152,
5801 EL_CUSTOM_START + 153,
5802 EL_CUSTOM_START + 154,
5803 EL_CUSTOM_START + 155,
5805 EL_CUSTOM_START + 156,
5806 EL_CUSTOM_START + 157,
5807 EL_CUSTOM_START + 158,
5808 EL_CUSTOM_START + 159,
5810 EL_CUSTOM_START + 160,
5811 EL_CUSTOM_START + 161,
5812 EL_CUSTOM_START + 162,
5813 EL_CUSTOM_START + 163,
5815 EL_CUSTOM_START + 164,
5816 EL_CUSTOM_START + 165,
5817 EL_CUSTOM_START + 166,
5818 EL_CUSTOM_START + 167,
5820 EL_CUSTOM_START + 168,
5821 EL_CUSTOM_START + 169,
5822 EL_CUSTOM_START + 170,
5823 EL_CUSTOM_START + 171,
5825 EL_CUSTOM_START + 172,
5826 EL_CUSTOM_START + 173,
5827 EL_CUSTOM_START + 174,
5828 EL_CUSTOM_START + 175,
5830 EL_CUSTOM_START + 176,
5831 EL_CUSTOM_START + 177,
5832 EL_CUSTOM_START + 178,
5833 EL_CUSTOM_START + 179,
5835 EL_CUSTOM_START + 180,
5836 EL_CUSTOM_START + 181,
5837 EL_CUSTOM_START + 182,
5838 EL_CUSTOM_START + 183,
5840 EL_CUSTOM_START + 184,
5841 EL_CUSTOM_START + 185,
5842 EL_CUSTOM_START + 186,
5843 EL_CUSTOM_START + 187,
5845 EL_CUSTOM_START + 188,
5846 EL_CUSTOM_START + 189,
5847 EL_CUSTOM_START + 190,
5848 EL_CUSTOM_START + 191,
5850 EL_CUSTOM_START + 192,
5851 EL_CUSTOM_START + 193,
5852 EL_CUSTOM_START + 194,
5853 EL_CUSTOM_START + 195,
5855 EL_CUSTOM_START + 196,
5856 EL_CUSTOM_START + 197,
5857 EL_CUSTOM_START + 198,
5858 EL_CUSTOM_START + 199,
5860 EL_CUSTOM_START + 200,
5861 EL_CUSTOM_START + 201,
5862 EL_CUSTOM_START + 202,
5863 EL_CUSTOM_START + 203,
5865 EL_CUSTOM_START + 204,
5866 EL_CUSTOM_START + 205,
5867 EL_CUSTOM_START + 206,
5868 EL_CUSTOM_START + 207,
5870 EL_CUSTOM_START + 208,
5871 EL_CUSTOM_START + 209,
5872 EL_CUSTOM_START + 210,
5873 EL_CUSTOM_START + 211,
5875 EL_CUSTOM_START + 212,
5876 EL_CUSTOM_START + 213,
5877 EL_CUSTOM_START + 214,
5878 EL_CUSTOM_START + 215,
5880 EL_CUSTOM_START + 216,
5881 EL_CUSTOM_START + 217,
5882 EL_CUSTOM_START + 218,
5883 EL_CUSTOM_START + 219,
5885 EL_CUSTOM_START + 220,
5886 EL_CUSTOM_START + 221,
5887 EL_CUSTOM_START + 222,
5888 EL_CUSTOM_START + 223,
5890 EL_CUSTOM_START + 224,
5891 EL_CUSTOM_START + 225,
5892 EL_CUSTOM_START + 226,
5893 EL_CUSTOM_START + 227,
5895 EL_CUSTOM_START + 228,
5896 EL_CUSTOM_START + 229,
5897 EL_CUSTOM_START + 230,
5898 EL_CUSTOM_START + 231,
5900 EL_CUSTOM_START + 232,
5901 EL_CUSTOM_START + 233,
5902 EL_CUSTOM_START + 234,
5903 EL_CUSTOM_START + 235,
5905 EL_CUSTOM_START + 236,
5906 EL_CUSTOM_START + 237,
5907 EL_CUSTOM_START + 238,
5908 EL_CUSTOM_START + 239,
5910 EL_CUSTOM_START + 240,
5911 EL_CUSTOM_START + 241,
5912 EL_CUSTOM_START + 242,
5913 EL_CUSTOM_START + 243,
5915 EL_CUSTOM_START + 244,
5916 EL_CUSTOM_START + 245,
5917 EL_CUSTOM_START + 246,
5918 EL_CUSTOM_START + 247,
5920 EL_CUSTOM_START + 248,
5921 EL_CUSTOM_START + 249,
5922 EL_CUSTOM_START + 250,
5923 EL_CUSTOM_START + 251,
5925 EL_CUSTOM_START + 252,
5926 EL_CUSTOM_START + 253,
5927 EL_CUSTOM_START + 254,
5928 EL_CUSTOM_START + 255
5930 static int *editor_hl_custom_ptr = editor_hl_custom;
5931 static int *editor_el_custom_ptr = editor_el_custom;
5932 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5933 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5935 static int editor_hl_group[] =
5937 EL_INTERNAL_CASCADE_GE_ACTIVE,
5943 static int editor_el_group[] =
5957 EL_GROUP_START + 10,
5958 EL_GROUP_START + 11,
5960 EL_GROUP_START + 12,
5961 EL_GROUP_START + 13,
5962 EL_GROUP_START + 14,
5963 EL_GROUP_START + 15,
5965 EL_GROUP_START + 16,
5966 EL_GROUP_START + 17,
5967 EL_GROUP_START + 18,
5968 EL_GROUP_START + 19,
5970 EL_GROUP_START + 20,
5971 EL_GROUP_START + 21,
5972 EL_GROUP_START + 22,
5973 EL_GROUP_START + 23,
5975 EL_GROUP_START + 24,
5976 EL_GROUP_START + 25,
5977 EL_GROUP_START + 26,
5978 EL_GROUP_START + 27,
5980 EL_GROUP_START + 28,
5981 EL_GROUP_START + 29,
5982 EL_GROUP_START + 30,
5985 static int *editor_hl_group_ptr = editor_hl_group;
5986 static int *editor_el_group_ptr = editor_el_group;
5987 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5988 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5990 static int editor_hl_empty_space[] =
5992 EL_INTERNAL_CASCADE_ES_ACTIVE,
5998 static int editor_el_empty_space[] =
6020 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
6021 static int *editor_el_empty_space_ptr = editor_el_empty_space;
6022 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
6023 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
6025 static int editor_hl_reference[] =
6027 EL_INTERNAL_CASCADE_REF_ACTIVE,
6033 static int editor_el_reference[] =
6037 EL_TRIGGER_CE_VALUE,
6038 EL_TRIGGER_CE_SCORE,
6042 EL_CURRENT_CE_VALUE,
6043 EL_CURRENT_CE_SCORE,
6065 static int *editor_hl_reference_ptr = editor_hl_reference;
6066 static int *editor_el_reference_ptr = editor_el_reference;
6067 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
6068 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
6070 static int editor_hl_user_defined[] =
6072 EL_INTERNAL_CASCADE_USER_ACTIVE,
6078 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
6079 static int *editor_el_user_defined_ptr = NULL;
6080 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
6081 static int num_editor_el_user_defined = 0;
6083 static int editor_hl_dynamic[] =
6085 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
6091 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
6092 static int *editor_el_dynamic_ptr = NULL;
6093 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
6094 static int num_editor_el_dynamic = 0;
6096 static int editor_hl_empty[] = { EL_EMPTY };
6097 static int *editor_el_empty = NULL; // dynamically allocated
6099 static int *editor_hl_empty_ptr = editor_hl_empty;
6100 static int *editor_el_empty_ptr = NULL;
6101 static int num_editor_hl_empty = 0;
6102 static int num_editor_el_empty = 0; // dynamically determined, if needed
6104 static boolean use_el_empty = FALSE;
6106 static int *editor_elements = NULL; // dynamically allocated
6107 static int num_editor_elements = 0; // dynamically determined
6109 static boolean setup_editor_cascade_never = FALSE;
6111 static boolean setup_editor_el_players = TRUE;
6112 static boolean setup_editor_el_boulderdash = TRUE;
6113 static boolean setup_editor_el_boulderdash_native = TRUE;
6114 static boolean setup_editor_el_emerald_mine = TRUE;
6115 static boolean setup_editor_el_emerald_mine_club = TRUE;
6116 static boolean setup_editor_el_more = TRUE;
6117 static boolean setup_editor_el_sokoban = TRUE;
6118 static boolean setup_editor_el_supaplex = TRUE;
6119 static boolean setup_editor_el_diamond_caves = TRUE;
6120 static boolean setup_editor_el_dx_boulderdash = TRUE;
6121 static boolean setup_editor_el_mirror_magic = TRUE;
6122 static boolean setup_editor_el_deflektor = TRUE;
6123 static boolean setup_editor_el_chars = TRUE;
6124 static boolean setup_editor_el_steel_chars = TRUE;
6125 static boolean setup_editor_el_custom = TRUE;
6126 static boolean setup_editor_el_user_defined = TRUE;
6127 static boolean setup_editor_el_dynamic = TRUE;
6129 static int editor_hl_unused[] = { EL_EMPTY };
6130 static int *editor_hl_unused_ptr = editor_hl_unused;
6131 static int num_editor_hl_unused = 0;
6135 boolean *setup_value;
6136 boolean *setup_cascade_value;
6138 int **headline_list;
6139 int *headline_list_size;
6142 int *element_list_size;
6144 boolean last_setup_value;
6146 editor_elements_info[] =
6149 &setup_editor_el_players,
6150 &setup_editor_cascade_never,
6151 &editor_hl_unused_ptr, &num_editor_hl_unused,
6152 &editor_el_players_ptr, &num_editor_el_players
6155 &setup_editor_el_boulderdash,
6156 &setup.editor_cascade.el_bd,
6157 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
6158 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
6161 &setup_editor_el_boulderdash_native,
6162 &setup.editor_cascade.el_bd_native,
6163 &editor_hl_boulderdash_native_ptr, &num_editor_hl_boulderdash_native,
6164 &editor_el_boulderdash_native_ptr, &num_editor_el_boulderdash_native
6167 &setup_editor_el_emerald_mine,
6168 &setup.editor_cascade.el_em,
6169 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
6170 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
6173 &setup_editor_el_emerald_mine_club,
6174 &setup.editor_cascade.el_emc,
6175 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
6176 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
6179 &setup_editor_el_more,
6180 &setup.editor_cascade.el_rnd,
6181 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
6182 &editor_el_rnd_ptr, &num_editor_el_rnd
6185 &setup_editor_el_sokoban,
6186 &setup.editor_cascade.el_sb,
6187 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
6188 &editor_el_sokoban_ptr, &num_editor_el_sokoban
6191 &setup_editor_el_supaplex,
6192 &setup.editor_cascade.el_sp,
6193 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
6194 &editor_el_supaplex_ptr, &num_editor_el_supaplex
6197 &setup_editor_el_diamond_caves,
6198 &setup.editor_cascade.el_dc,
6199 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
6200 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
6203 &setup_editor_el_dx_boulderdash,
6204 &setup.editor_cascade.el_dx,
6205 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
6206 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
6209 &setup_editor_el_mirror_magic,
6210 &setup.editor_cascade.el_mm,
6211 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
6212 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
6215 &setup_editor_el_deflektor,
6216 &setup.editor_cascade.el_df,
6217 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
6218 &editor_el_deflektor_ptr, &num_editor_el_deflektor
6221 &setup_editor_el_chars,
6222 &setup.editor_cascade.el_chars,
6223 &editor_hl_chars_ptr, &num_editor_hl_chars,
6224 &editor_el_chars_ptr, &num_editor_el_chars
6227 &setup_editor_el_steel_chars,
6228 &setup.editor_cascade.el_steel_chars,
6229 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
6230 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
6233 &setup_editor_el_custom,
6234 &setup.editor_cascade.el_ce,
6235 &editor_hl_custom_ptr, &num_editor_hl_custom,
6236 &editor_el_custom_ptr, &num_editor_el_custom
6239 &setup_editor_el_custom,
6240 &setup.editor_cascade.el_ge,
6241 &editor_hl_group_ptr, &num_editor_hl_group,
6242 &editor_el_group_ptr, &num_editor_el_group
6245 &setup_editor_el_custom,
6246 &setup.editor_cascade.el_es,
6247 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
6248 &editor_el_empty_space_ptr, &num_editor_el_empty_space
6251 &setup_editor_el_custom,
6252 &setup.editor_cascade.el_ref,
6253 &editor_hl_reference_ptr, &num_editor_hl_reference,
6254 &editor_el_reference_ptr, &num_editor_el_reference
6257 &setup_editor_el_user_defined,
6258 &setup.editor_cascade.el_user,
6259 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
6260 &editor_el_user_defined_ptr, &num_editor_el_user_defined
6263 &setup_editor_el_dynamic,
6264 &setup.editor_cascade.el_dynamic,
6265 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
6266 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
6271 &editor_hl_empty_ptr, &num_editor_hl_empty,
6272 &editor_el_empty_ptr, &num_editor_el_empty,
6282 static struct XY xy_directions[] =
6291 // ----------------------------------------------------------------------------
6293 // ----------------------------------------------------------------------------
6295 static int getMaxInfoTextLength(void)
6297 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
6300 static int getTextWidthForGadget(char *text)
6305 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
6308 static int getTextWidthForDrawingArea(char *text)
6313 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
6316 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
6318 return (gi->x + gi->width + getTextWidthForGadget(text));
6321 static char *getElementInfoText(int element)
6323 char *info_text = NULL;
6325 if (element < MAX_NUM_ELEMENTS)
6327 if (strlen(element_info[element].description) > 0)
6328 info_text = element_info[element].description;
6329 else if (element_info[element].custom_description != NULL)
6330 info_text = element_info[element].custom_description;
6331 else if (element_info[element].editor_description != NULL)
6332 info_text = element_info[element].editor_description;
6335 if (info_text == NULL)
6336 info_text = INFOTEXT_UNKNOWN_ELEMENT;
6341 static char *getElementDescriptionFilenameExt(char *basename)
6343 char *elements_subdir = ELEMENTS_DIRECTORY;
6344 static char *elements_subdir2 = NULL;
6345 static char *filename = NULL;
6347 if (elements_subdir2 == NULL)
6348 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
6350 checked_free(filename);
6352 // 1st try: look for element description in current level set directory
6353 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
6354 if (fileExists(filename))
6359 // 2nd try: look for element description in the game's base directory
6360 filename = getPath3(options.docs_directory, elements_subdir, basename);
6361 if (fileExists(filename))
6367 static char *getElementDescriptionFilename(int element)
6369 char basename[MAX_FILENAME_LEN];
6372 // 1st try: look for element description file for exactly this element
6373 sprintf(basename, "%s.txt", element_info[element].token_name);
6374 filename = getElementDescriptionFilenameExt(basename);
6375 if (filename != NULL)
6378 // 2nd try: look for element description file for this element's class
6379 sprintf(basename, "%s.txt", element_info[element].class_name);
6380 filename = getElementDescriptionFilenameExt(basename);
6381 if (filename != NULL)
6384 // 3rd try: look for generic fallback text file for any element
6385 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
6386 if (filename != NULL)
6392 static boolean suppressBorderElement(void)
6394 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
6395 lev_fieldx <= MAX_ED_FIELDX &&
6396 lev_fieldy <= MAX_ED_FIELDY);
6399 static void InitDynamicEditorElementList(int **elements, int *num_elements)
6401 boolean element_found[NUM_FILE_ELEMENTS];
6404 // initialize list of used elements to "not used"
6405 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6406 element_found[i] = FALSE;
6408 // find all elements used in current level
6409 for (y = 0; y < lev_fieldy; y++)
6411 for (x = 0; x < lev_fieldx; x++)
6413 if (Tile[x][y] >= NUM_FILE_ELEMENTS) // should never happen
6416 if (IS_MM_WALL(Tile[x][y]))
6417 element_found[map_mm_wall_element(Tile[x][y])] = TRUE;
6419 element_found[Tile[x][y]] = TRUE;
6425 // count number of elements used in current level
6426 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6427 if (element_found[i])
6430 // add space for up to 3 more elements for padding that may be needed
6433 // free memory for old list of elements, if needed
6434 checked_free(*elements);
6436 // allocate memory for new list of elements
6437 *elements = checked_malloc(*num_elements * sizeof(int));
6441 // add all elements used in current level (non-custom/group/empty elements)
6442 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6443 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) ||
6444 IS_GROUP_ELEMENT(i) ||
6445 IS_EMPTY_ELEMENT(i)))
6446 (*elements)[(*num_elements)++] = i;
6448 // add all elements used in current level (custom/group/empty elements)
6449 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6450 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) ||
6451 IS_GROUP_ELEMENT(i) ||
6452 IS_EMPTY_ELEMENT(i)))
6453 (*elements)[(*num_elements)++] = i;
6455 while (*num_elements % 4) // pad with empty elements, if needed
6456 (*elements)[(*num_elements)++] = EL_EMPTY;
6459 static void ReinitializeElementList_EnableSections(void)
6461 // default: enable all element sections
6463 setup_editor_el_players = TRUE;
6464 setup_editor_el_boulderdash = TRUE;
6465 setup_editor_el_boulderdash_native = TRUE;
6466 setup_editor_el_emerald_mine = TRUE;
6467 setup_editor_el_emerald_mine_club = TRUE;
6468 setup_editor_el_more = TRUE;
6469 setup_editor_el_sokoban = TRUE;
6470 setup_editor_el_supaplex = TRUE;
6471 setup_editor_el_diamond_caves = TRUE;
6472 setup_editor_el_dx_boulderdash = TRUE;
6473 setup_editor_el_mirror_magic = TRUE;
6474 setup_editor_el_deflektor = TRUE;
6475 setup_editor_el_chars = TRUE;
6476 setup_editor_el_steel_chars = TRUE;
6478 setup_editor_el_custom = TRUE;
6479 setup_editor_el_user_defined = TRUE;
6480 setup_editor_el_dynamic = TRUE;
6482 // now disable all element sections not to be displayed
6484 if (!setup.editor.el_classic)
6486 setup_editor_el_players = FALSE;
6487 setup_editor_el_boulderdash = FALSE;
6488 setup_editor_el_boulderdash_native = FALSE;
6489 setup_editor_el_emerald_mine = FALSE;
6490 setup_editor_el_emerald_mine_club = FALSE;
6491 setup_editor_el_more = FALSE;
6492 setup_editor_el_sokoban = FALSE;
6493 setup_editor_el_supaplex = FALSE;
6494 setup_editor_el_diamond_caves = FALSE;
6495 setup_editor_el_dx_boulderdash = FALSE;
6496 setup_editor_el_mirror_magic = FALSE;
6497 setup_editor_el_deflektor = FALSE;
6498 setup_editor_el_chars = FALSE;
6499 setup_editor_el_steel_chars = FALSE;
6502 if (!setup.editor.el_custom)
6504 setup_editor_el_custom = FALSE;
6507 if (!setup.editor.el_user_defined)
6509 setup_editor_el_user_defined = FALSE;
6512 if (!setup.editor.el_dynamic)
6514 setup_editor_el_dynamic = FALSE;
6517 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
6519 setup_editor_el_boulderdash_native = FALSE;
6520 setup_editor_el_mirror_magic = FALSE;
6521 setup_editor_el_deflektor = FALSE;
6523 else if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
6525 setup_editor_el_players = FALSE;
6526 setup_editor_el_boulderdash = FALSE;
6527 setup_editor_el_emerald_mine = FALSE;
6528 setup_editor_el_emerald_mine_club = FALSE;
6529 setup_editor_el_more = FALSE;
6530 setup_editor_el_sokoban = FALSE;
6531 setup_editor_el_supaplex = FALSE;
6532 setup_editor_el_diamond_caves = FALSE;
6533 setup_editor_el_dx_boulderdash = FALSE;
6534 setup_editor_el_mirror_magic = FALSE;
6535 setup_editor_el_deflektor = FALSE;
6536 setup_editor_el_chars = FALSE;
6537 setup_editor_el_steel_chars = FALSE;
6539 setup_editor_el_custom = FALSE;
6541 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
6543 setup_editor_el_boulderdash = FALSE;
6544 setup_editor_el_boulderdash_native = FALSE;
6545 setup_editor_el_more = FALSE;
6546 setup_editor_el_sokoban = FALSE;
6547 setup_editor_el_supaplex = FALSE;
6548 setup_editor_el_diamond_caves = FALSE;
6549 setup_editor_el_dx_boulderdash = FALSE;
6550 setup_editor_el_mirror_magic = FALSE;
6551 setup_editor_el_deflektor = FALSE;
6552 setup_editor_el_steel_chars = FALSE;
6554 setup_editor_el_custom = FALSE;
6556 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
6558 setup_editor_el_players = FALSE;
6559 setup_editor_el_boulderdash = FALSE;
6560 setup_editor_el_boulderdash_native = FALSE;
6561 setup_editor_el_emerald_mine = FALSE;
6562 setup_editor_el_emerald_mine_club = FALSE;
6563 setup_editor_el_more = FALSE;
6564 setup_editor_el_sokoban = FALSE;
6565 setup_editor_el_diamond_caves = FALSE;
6566 setup_editor_el_dx_boulderdash = FALSE;
6567 setup_editor_el_mirror_magic = FALSE;
6568 setup_editor_el_deflektor = FALSE;
6569 setup_editor_el_chars = FALSE;
6570 setup_editor_el_steel_chars = FALSE;
6572 setup_editor_el_custom = FALSE;
6574 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
6576 setup_editor_el_players = FALSE;
6577 setup_editor_el_boulderdash = FALSE;
6578 setup_editor_el_boulderdash_native = FALSE;
6579 setup_editor_el_emerald_mine = FALSE;
6580 setup_editor_el_emerald_mine_club = FALSE;
6581 setup_editor_el_more = FALSE;
6582 setup_editor_el_sokoban = FALSE;
6583 setup_editor_el_supaplex = FALSE;
6584 setup_editor_el_diamond_caves = FALSE;
6585 setup_editor_el_dx_boulderdash = FALSE;
6586 setup_editor_el_steel_chars = FALSE;
6588 setup_editor_el_custom = FALSE;
6592 static void ReinitializeElementList(void)
6594 static boolean initialization_needed = TRUE;
6598 ReinitializeElementList_EnableSections();
6600 if (initialization_needed)
6602 LoadSetup_EditorCascade(); // load last editor cascade state
6604 // initialize editor cascade element from saved cascade state
6605 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6607 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
6608 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
6610 if (IS_EDITOR_CASCADE(*cascade_element))
6612 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
6613 EL_CASCADE_INACTIVE(*cascade_element));
6616 initialization_needed = FALSE;
6619 checked_free(editor_elements);
6621 // reload optional user defined element list for each invocation of editor
6622 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
6623 &num_editor_el_user_defined);
6625 // initialize dynamic level element list for each invocation of editor
6626 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
6627 &num_editor_el_dynamic);
6629 // initialize list of empty elements (used for padding, if needed)
6630 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6631 editor_el_empty[i] = EL_EMPTY;
6633 // do some sanity checks for each element from element list
6634 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6636 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6638 int element = (*editor_elements_info[i].element_list)[j];
6640 if (element >= NUM_FILE_ELEMENTS)
6641 Warn("editor element %d is runtime element", element);
6643 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
6644 Warn("no element description text for element %d", element);
6648 num_editor_elements = 0;
6649 use_el_empty = FALSE;
6651 // determine size of element list
6652 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6654 if (*editor_elements_info[i].setup_value)
6656 boolean found_inactive_cascade = FALSE;
6658 if (setup.editor.el_headlines)
6660 // required for correct padding of palette headline buttons
6661 if (*editor_elements_info[i].headline_list_size > 0)
6662 num_editor_elements += ED_ELEMENTLIST_COLS;
6664 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6666 int element = (*editor_elements_info[i].headline_list)[j];
6668 if (IS_EDITOR_CASCADE_INACTIVE(element))
6669 found_inactive_cascade = TRUE;
6673 if (found_inactive_cascade)
6676 // required for correct padding of palette element buttons
6677 int element_list_size = *editor_elements_info[i].element_list_size;
6679 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6680 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6682 num_editor_elements += element_buttons;
6686 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
6688 // offer at least as many elements as element buttons exist
6689 use_el_empty = TRUE;
6690 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
6692 num_editor_elements += num_editor_el_empty;
6696 num_editor_el_empty = 0;
6699 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
6701 // fill element list
6702 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6704 boolean found_inactive_cascade = FALSE;
6706 if (*editor_elements_info[i].setup_value)
6708 if (setup.editor.el_headlines)
6710 // required for correct padding of palette headline buttons
6711 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6712 ED_ELEMENTLIST_COLS : 0);
6714 for (j = 0; j < headline_size; j++)
6716 // use empty elements for padding of palette headline buttons
6717 int element = (j < *editor_elements_info[i].headline_list_size ?
6718 (*editor_elements_info[i].headline_list)[j] :
6719 editor_el_empty[0]);
6721 editor_elements[pos++] = element;
6723 if (IS_EDITOR_CASCADE_INACTIVE(element))
6724 found_inactive_cascade = TRUE;
6728 if (found_inactive_cascade)
6731 // required for correct padding of palette element buttons
6732 int element_list_size = *editor_elements_info[i].element_list_size;
6734 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6735 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6737 // copy all elements from element list
6738 for (j = 0; j < element_list_size; j++)
6739 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6741 // use empty elements for padding of palette element buttons
6742 for (j = 0; j < element_buttons - element_list_size; j++)
6743 editor_elements[pos++] = editor_el_empty[0];
6747 // (this function is also called before editor gadgets are initialized!)
6748 AdjustElementListScrollbar();
6751 void PrintEditorElementList(void)
6753 boolean *stop = &setup_editor_el_user_defined;
6756 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6758 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6760 if (IS_EDITOR_CASCADE(cascade_element))
6762 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6763 char *headline = element_info[cascade_element_show].editor_description;
6765 PrintLineWithPrefix("# ", "-", 77);
6766 Print("# %s\n", headline);
6767 PrintLineWithPrefix("# ", "-", 77);
6770 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6772 int element = (*editor_elements_info[i].headline_list)[j];
6774 if (IS_EDITOR_CASCADE(element))
6775 element = EL_CHAR_MINUS;
6777 Print("# %s\n", element_info[element].token_name);
6783 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6785 int element = (*editor_elements_info[i].element_list)[j];
6787 Print("# %s\n", element_info[element].token_name);
6795 static void ReinitializeElementListButtons(void)
6797 static boolean last_setup_value_headlines = FALSE;
6798 static boolean initialization_needed = TRUE;
6801 if (!initialization_needed) // check if editor element setup has changed
6803 if (last_setup_value_headlines != setup.editor.el_headlines)
6804 initialization_needed = TRUE;
6806 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6807 if (editor_elements_info[i].last_setup_value !=
6808 *editor_elements_info[i].setup_value)
6809 initialization_needed = TRUE;
6812 if (!initialization_needed)
6815 FreeLevelEditorGadgets();
6816 CreateLevelEditorGadgets();
6818 // store current setup values for next invocation of this function
6819 last_setup_value_headlines = setup.editor.el_headlines;
6820 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6821 editor_elements_info[i].last_setup_value =
6822 *editor_elements_info[i].setup_value;
6824 initialization_needed = FALSE;
6827 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6830 int border_graphic =
6831 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6832 struct GraphicInfo *g = &graphic_info[border_graphic];
6833 Bitmap *src_bitmap = g->bitmap;
6834 int src_x = g->src_x;
6835 int src_y = g->src_y;
6836 int border_size = g->border_size;
6837 int border_xpos = g->width - border_size;
6838 int border_ypos = g->height - border_size;
6839 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6842 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6843 border_size, border_size,
6844 dest_x - border_size, dest_y - border_size);
6845 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6846 border_size, border_size,
6847 dest_x + width, dest_y - border_size);
6848 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6849 border_size, border_size,
6850 dest_x - border_size, dest_y + height);
6851 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6852 border_size, border_size,
6853 dest_x + width, dest_y + height);
6855 for (i = 0; i < width / tilesize; i++)
6857 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6858 tilesize, border_size,
6859 dest_x + i * tilesize, dest_y - border_size);
6860 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6861 tilesize, border_size,
6862 dest_x + i * tilesize, dest_y + height);
6865 for (i = 0; i < height / tilesize; i++)
6867 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6868 border_size, tilesize,
6869 dest_x - border_size, dest_y + i * tilesize);
6870 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6871 border_size, tilesize,
6872 dest_x + width, dest_y + i * tilesize);
6875 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6878 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6880 int xsize_tile = MAX(ed_tilesize, xsize);
6881 int ysize_tile = MAX(ed_tilesize, ysize);
6882 int xsize_full = xsize + 1;
6883 int ysize_full = ysize + 1;
6884 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6885 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6886 Pixel line_color = getTabulatorBarColor();
6888 if (line_color == BLACK_PIXEL) // black => transparent
6891 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6892 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6893 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6896 static void DrawEditorLevelBorderLinesIfNeeded(void)
6898 int xsize = lev_fieldx * ed_tilesize;
6899 int ysize = lev_fieldy * ed_tilesize;
6900 int line_size = getTabulatorBarHeight();
6902 if (!suppressBorderElement())
6905 // draw little border line around editable level playfield
6908 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6911 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6913 if (xsize < SXSIZE && ysize < SYSIZE)
6914 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6917 static void DrawEditorElement(int x, int y, int element)
6919 DrawSizedElement(x, y, element, ed_tilesize);
6922 static void DrawEditorElementThruMask(int x, int y, int element)
6924 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6927 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6929 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6932 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6934 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6935 DrawEditorLevelBorderLinesIfNeeded();
6938 static void DrawDrawingArea(int id)
6940 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6943 int *value = drawingarea_info[id].value;
6944 int area_xsize = drawingarea_info[id].area_xsize;
6945 int area_ysize = drawingarea_info[id].area_ysize;
6946 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6948 for (x = 0; x < area_xsize; x++)
6949 for (y = 0; y < area_ysize; y++)
6950 DrawSizedGraphicExt(drawto,
6951 gi->x + x * tilesize,
6952 gi->y + y * tilesize,
6953 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6956 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6959 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6960 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6962 BlitBitmap(drawto, drawto,
6963 SX + (dx == -1 ? ed_tilesize : 0),
6964 SY + (dy == -1 ? ed_tilesize : 0),
6965 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6966 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6967 SX + (dx == +1 ? ed_tilesize : 0),
6968 SY + (dy == +1 ? ed_tilesize : 0));
6972 x = (dx == 1 ? 0 : ed_fieldx - 1);
6973 for (y = 0; y < ed_fieldy; y++)
6974 DrawEditorElementOrWall(x, y, from_x, from_y);
6978 y = (dy == 1 ? 0 : ed_fieldy - 1);
6979 for (x = 0; x < ed_fieldx; x++)
6980 DrawEditorElementOrWall(x, y, from_x, from_y);
6983 redraw_mask |= REDRAW_FIELD;
6987 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6990 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6993 static void CreateControlButtons(void)
6995 struct GadgetInfo *gi;
6998 // create toolbox buttons
6999 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
7001 int type_id = controlbutton_info[i].gadget_id; // same as gadget ID here
7002 int id = controlbutton_info[i].gadget_id;
7003 int type = controlbutton_info[i].gadget_type;
7004 int graphic = controlbutton_info[i].graphic;
7005 struct XYTileSize *pos = controlbutton_info[i].pos;
7006 struct GraphicInfo *gd = &graphic_info[graphic];
7007 Bitmap *deco_bitmap = NULL;
7008 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
7009 int tile_size = 0, deco_shift = 0;
7010 boolean deco_masked = FALSE;
7011 int gd_x1 = gd->src_x;
7012 int gd_y1 = gd->src_y;
7013 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7014 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7015 int gd_x1a = gd->src_x + gd->active_xoffset;
7016 int gd_y1a = gd->src_y + gd->active_yoffset;
7017 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7018 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7021 unsigned int event_mask;
7022 int radio_button_nr = RADIO_NR_NONE;
7023 boolean checked = FALSE;
7026 Fail("'controlbutton_info' structure corrupted at index %d -- please fix", i);
7028 if (type == GD_TYPE_RADIO_BUTTON)
7030 event_mask = GD_EVENT_PRESSED;
7031 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
7033 if (id == drawing_function)
7038 if (id == GADGET_ID_WRAP_LEFT ||
7039 id == GADGET_ID_WRAP_RIGHT ||
7040 id == GADGET_ID_WRAP_UP ||
7041 id == GADGET_ID_WRAP_DOWN)
7042 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7044 event_mask = GD_EVENT_RELEASED;
7047 if (id == GADGET_ID_PROPERTIES ||
7048 id == GADGET_ID_PALETTE)
7053 else if (id == GADGET_ID_ELEMENT_LEFT ||
7054 id == GADGET_ID_ELEMENT_MIDDLE ||
7055 id == GADGET_ID_ELEMENT_RIGHT)
7060 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
7061 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
7062 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
7064 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
7065 editor.button.element_left.tile_size :
7066 id == GADGET_ID_ELEMENT_MIDDLE ?
7067 editor.button.element_middle.tile_size :
7068 id == GADGET_ID_ELEMENT_RIGHT ?
7069 editor.button.element_right.tile_size : 0);
7071 // make sure that decoration does not overlap gadget border
7072 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
7074 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
7076 deco_xpos = (gd->width - tile_size) / 2;
7077 deco_ypos = (gd->height - tile_size) / 2;
7079 deco_masked = gd->draw_masked;
7087 gi = CreateGadget(GDI_CUSTOM_ID, id,
7088 GDI_CUSTOM_TYPE_ID, type_id,
7089 GDI_IMAGE_ID, graphic,
7090 GDI_INFO_TEXT, controlbutton_info[i].infotext,
7093 GDI_WIDTH, gd->width,
7094 GDI_HEIGHT, gd->height,
7096 GDI_STATE, GD_BUTTON_UNPRESSED,
7097 GDI_RADIO_NR, radio_button_nr,
7098 GDI_CHECKED, checked,
7099 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7100 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7101 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7102 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7103 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7104 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7105 GDI_DECORATION_SIZE, tile_size, tile_size,
7106 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
7107 GDI_DECORATION_MASKED, deco_masked,
7108 GDI_EVENT_MASK, event_mask,
7109 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7110 GDI_CALLBACK_ACTION, HandleControlButtons,
7114 Fail("cannot create gadget");
7116 level_editor_gadget[id] = gi;
7119 // these values are not constant, but can change at runtime
7120 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
7121 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
7122 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
7123 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
7124 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
7125 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
7126 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
7127 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
7128 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
7129 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
7130 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
7131 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
7133 // create buttons for scrolling of drawing area and element list
7134 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
7136 int id = scrollbutton_info[i].gadget_id;
7137 int type_id = scrollbutton_info[i].gadget_type_id;
7138 int graphic = scrollbutton_info[i].graphic;
7139 struct GraphicInfo *gd = &graphic_info[graphic];
7140 Bitmap *gd_bitmap = gd->bitmap;
7141 int gd_x1 = gd->src_x;
7142 int gd_y1 = gd->src_y;
7143 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7144 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7145 int width = gd->width;
7146 int height = gd->height;
7147 int x = scrollbutton_pos[i].x;
7148 int y = scrollbutton_pos[i].y;
7149 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7152 Fail("'scrollbutton_info' structure corrupted at index %d -- please fix", i);
7154 if (id == GADGET_ID_SCROLL_LIST_UP ||
7155 id == GADGET_ID_SCROLL_LIST_DOWN)
7166 gi = CreateGadget(GDI_CUSTOM_ID, id,
7167 GDI_CUSTOM_TYPE_ID, type_id,
7168 GDI_IMAGE_ID, graphic,
7169 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
7174 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7175 GDI_STATE, GD_BUTTON_UNPRESSED,
7176 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7177 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7178 GDI_EVENT_MASK, event_mask,
7179 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7180 GDI_CALLBACK_ACTION, HandleControlButtons,
7184 Fail("cannot create gadget");
7186 level_editor_gadget[id] = gi;
7189 // create buttons for element list
7190 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7193 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
7194 int graphic = IMG_EDITOR_PALETTE_BUTTON;
7195 struct GraphicInfo *gd = &graphic_info[graphic];
7196 Bitmap *gd_bitmap = gd->bitmap;
7197 Bitmap *deco_bitmap;
7198 int deco_x, deco_y, deco_xpos, deco_ypos;
7199 int gd_x1 = gd->src_x;
7200 int gd_y1 = gd->src_y;
7201 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7202 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7203 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
7204 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
7205 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
7206 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
7207 int element = editor_elements[i];
7208 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
7209 unsigned int event_mask = GD_EVENT_RELEASED;
7211 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
7213 deco_xpos = (gd->width - tile_size) / 2;
7214 deco_ypos = (gd->height - tile_size) / 2;
7216 gi = CreateGadget(GDI_CUSTOM_ID, id,
7217 GDI_CUSTOM_TYPE_ID, type_id,
7218 GDI_IMAGE_ID, graphic,
7219 GDI_INFO_TEXT, getElementInfoText(element),
7222 GDI_WIDTH, gd->width,
7223 GDI_HEIGHT, gd->height,
7224 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7225 GDI_STATE, GD_BUTTON_UNPRESSED,
7226 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7227 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7228 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7229 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7230 GDI_DECORATION_SIZE, tile_size, tile_size,
7231 GDI_DECORATION_SHIFTING, 1, 1,
7232 GDI_EVENT_MASK, event_mask,
7233 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7234 GDI_CALLBACK_ACTION, HandleControlButtons,
7238 Fail("cannot create gadget");
7240 level_editor_gadget[id] = gi;
7244 static void CreateCounterButtons(void)
7246 int max_infotext_len = getMaxInfoTextLength();
7249 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
7251 int type_id = counterbutton_info[i].gadget_type_id;
7252 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
7253 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
7257 Fail("'counterbutton_info' structure corrupted at index %d -- please fix", i);
7259 // determine horizontal position to the right of specified gadget
7260 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7261 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
7262 ED_GADGET_TEXT_DISTANCE);
7264 // determine horizontal offset for leading text
7265 if (counterbutton_info[i].text_left != NULL)
7266 x += getTextWidthForGadget(counterbutton_info[i].text_left);
7268 for (j = 0; j < 2; j++)
7270 struct GadgetInfo *gi;
7272 counterbutton_info[i].gadget_id_down :
7273 counterbutton_info[i].gadget_id_up);
7275 struct GraphicInfo *gd;
7276 int gd_x1, gd_x2, gd_y1, gd_y2;
7277 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7278 char infotext[max_infotext_len + 1];
7280 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7283 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
7284 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
7286 event_mask |= GD_EVENT_RELEASED;
7290 x = DX + editor.button.prev_level.x;
7291 y = DY + editor.button.prev_level.y;
7295 x = DX + editor.button.next_level.x;
7296 y = DY + editor.button.next_level.y;
7302 IMG_EDITOR_COUNTER_DOWN :
7303 IMG_EDITOR_COUNTER_UP);
7306 gd = &graphic_info[graphic];
7310 gd_x2 = gd->src_x + gd->pressed_xoffset;
7311 gd_y2 = gd->src_y + gd->pressed_yoffset;
7313 sprintf(infotext, "%s counter value by 1, 5 or 10",
7314 (j == 0 ? "decrease" : "increase"));
7316 gi = CreateGadget(GDI_CUSTOM_ID, id,
7317 GDI_CUSTOM_TYPE_ID, type_id,
7318 GDI_IMAGE_ID, graphic,
7319 GDI_INFO_TEXT, infotext,
7322 GDI_WIDTH, gd->width,
7323 GDI_HEIGHT, gd->height,
7324 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7325 GDI_STATE, GD_BUTTON_UNPRESSED,
7326 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7327 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7328 GDI_EVENT_MASK, event_mask,
7329 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7330 GDI_CALLBACK_ACTION, HandleCounterButtons,
7334 Fail("cannot create gadget");
7336 level_editor_gadget[id] = gi;
7337 right_gadget_border[id] =
7338 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7340 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
7344 int font_type = FONT_INPUT_1;
7345 int font_type_active = FONT_INPUT_1_ACTIVE;
7347 id = counterbutton_info[i].gadget_id_text;
7349 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7351 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7353 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
7355 font_type = FONT_LEVEL_NUMBER;
7356 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
7358 x = DX + editor.input.level_number.x;
7359 y = DY + editor.input.level_number.y;
7363 graphic = IMG_EDITOR_COUNTER_INPUT;
7366 gd = &graphic_info[graphic];
7370 gd_x2 = gd->src_x + gd->active_xoffset;
7371 gd_y2 = gd->src_y + gd->active_yoffset;
7373 gi = CreateGadget(GDI_CUSTOM_ID, id,
7374 GDI_CUSTOM_TYPE_ID, type_id,
7375 GDI_IMAGE_ID, graphic,
7376 GDI_INFO_TEXT, "enter counter value",
7379 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
7380 GDI_NUMBER_VALUE, 0,
7381 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
7382 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
7383 GDI_TEXT_SIZE, 3, // minimal counter text size
7384 GDI_TEXT_FONT, font_type,
7385 GDI_TEXT_FONT_ACTIVE, font_type_active,
7386 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7387 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7388 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7389 GDI_DESIGN_WIDTH, gd->width,
7390 GDI_EVENT_MASK, event_mask,
7391 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7392 GDI_CALLBACK_ACTION, HandleCounterButtons,
7396 Fail("cannot create gadget");
7398 level_editor_gadget[id] = gi;
7399 right_gadget_border[id] =
7400 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7402 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
7408 static void CreateDrawingAreas(void)
7412 // these values are not constant, but can change at runtime
7413 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
7414 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
7416 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
7418 struct GadgetInfo *gi;
7419 int id = drawingarea_info[i].gadget_id;
7420 int type_id = drawingarea_info[i].gadget_type_id;
7421 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
7422 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
7423 int area_xsize = drawingarea_info[i].area_xsize;
7424 int area_ysize = drawingarea_info[i].area_ysize;
7425 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
7426 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
7427 unsigned int event_mask =
7428 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
7429 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
7432 Fail("'drawingarea_info' structure corrupted at index %d -- please fix", i);
7434 // determine horizontal position to the right of specified gadget
7435 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
7436 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
7437 ED_DRAWINGAREA_TEXT_DISTANCE);
7439 // determine horizontal offset for leading text
7440 if (drawingarea_info[i].text_left != NULL)
7441 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
7443 gi = CreateGadget(GDI_CUSTOM_ID, id,
7444 GDI_CUSTOM_TYPE_ID, type_id,
7447 GDI_TYPE, GD_TYPE_DRAWING_AREA,
7448 GDI_AREA_SIZE, area_xsize, area_ysize,
7449 GDI_ITEM_SIZE, item_size, item_size,
7450 GDI_EVENT_MASK, event_mask,
7451 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
7452 GDI_CALLBACK_ACTION, HandleDrawingAreas,
7456 Fail("cannot create gadget");
7458 level_editor_gadget[id] = gi;
7459 right_gadget_border[id] =
7460 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
7464 static void CreateTextInputGadgets(void)
7466 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
7467 int max_infotext_len = getMaxInfoTextLength();
7470 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
7472 int gd_x1 = gd->src_x;
7473 int gd_y1 = gd->src_y;
7474 int gd_x2 = gd->src_x + gd->active_xoffset;
7475 int gd_y2 = gd->src_y + gd->active_yoffset;
7476 struct GadgetInfo *gi;
7477 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7478 char infotext[MAX_OUTPUT_LINESIZE + 1];
7479 int id = textinput_info[i].gadget_id;
7480 int type_id = textinput_info[i].gadget_type_id;
7484 Fail("'textinput_info' structure corrupted at index %d -- please fix", i);
7486 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
7488 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
7489 int border_size = gd->border_size;
7490 int font_nr = FONT_INPUT_1;
7491 int font_height = getFontHeight(font_nr);
7492 int xoffset = element_border + TILEX + element_border + 3 * border_size;
7493 int yoffset = element_border + (TILEY - font_height) / 2;
7495 x = (editor.settings.element_name.x != -1 ?
7496 editor.settings.element_name.x :
7497 editor.settings.element_graphic.x + xoffset) - border_size;
7498 y = (editor.settings.element_name.y != -1 ?
7499 editor.settings.element_name.y :
7500 editor.settings.element_graphic.y + yoffset) - border_size;
7504 x = ED_SETTINGS_X(textinput_info[i].x);
7505 y = ED_SETTINGS_Y(textinput_info[i].y);
7508 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
7509 infotext[max_infotext_len] = '\0';
7511 gi = CreateGadget(GDI_CUSTOM_ID, id,
7512 GDI_CUSTOM_TYPE_ID, type_id,
7513 GDI_INFO_TEXT, infotext,
7516 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
7517 GDI_TEXT_VALUE, textinput_info[i].value,
7518 GDI_TEXT_SIZE, textinput_info[i].size,
7519 GDI_TEXT_FONT, FONT_INPUT_1,
7520 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7521 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7522 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7523 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7524 GDI_DESIGN_WIDTH, gd->width,
7525 GDI_EVENT_MASK, event_mask,
7526 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7527 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
7531 Fail("cannot create gadget");
7533 level_editor_gadget[id] = gi;
7537 static void CreateTextAreaGadgets(void)
7539 int max_infotext_len = getMaxInfoTextLength();
7542 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
7544 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
7545 int gd_x1 = gd->src_x;
7546 int gd_y1 = gd->src_y;
7547 int gd_x2 = gd->src_x + gd->active_xoffset;
7548 int gd_y2 = gd->src_y + gd->active_yoffset;
7549 struct GadgetInfo *gi;
7550 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
7551 char infotext[MAX_OUTPUT_LINESIZE + 1];
7552 int id = textarea_info[i].gadget_id;
7553 int type_id = textarea_info[i].gadget_type_id;
7554 int area_xsize = textarea_info[i].xsize;
7555 int area_ysize = textarea_info[i].ysize;
7558 Fail("'textarea_info' structure corrupted at index %d -- please fix", i);
7560 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
7561 infotext[max_infotext_len] = '\0';
7563 gi = CreateGadget(GDI_CUSTOM_ID, id,
7564 GDI_CUSTOM_TYPE_ID, type_id,
7565 GDI_INFO_TEXT, infotext,
7566 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
7567 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
7568 GDI_TYPE, GD_TYPE_TEXT_AREA,
7569 GDI_AREA_SIZE, area_xsize, area_ysize,
7570 GDI_TEXT_FONT, FONT_INPUT_1,
7571 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7572 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7573 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7574 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7575 GDI_DESIGN_WIDTH, gd->width,
7576 GDI_EVENT_MASK, event_mask,
7577 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7578 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
7582 Fail("cannot create gadget");
7584 level_editor_gadget[id] = gi;
7588 static void CreateSelectboxGadgets(void)
7590 int max_infotext_len = getMaxInfoTextLength();
7593 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7595 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
7596 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
7597 int gd_x1 = gd->src_x;
7598 int gd_y1 = gd->src_y;
7599 int gd_x2 = gd->src_x + gd->active_xoffset;
7600 int gd_y2 = gd->src_y + gd->active_yoffset;
7601 int selectbox_button_xsize = gd2->width;
7602 struct GadgetInfo *gi;
7603 char infotext[MAX_OUTPUT_LINESIZE + 1];
7604 int id = selectbox_info[i].gadget_id;
7605 int type_id = selectbox_info[i].gadget_type_id;
7606 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
7607 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
7608 unsigned int event_mask =
7609 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7612 Fail("'selectbox_info' structure corrupted at index %d -- please fix", i);
7614 if (selectbox_info[i].size == -1) // dynamically determine size
7616 // (we cannot use -1 for uninitialized values if we directly compare
7617 // with results from strlen(), because the '<' and '>' operation will
7618 // implicitely cast -1 to an unsigned integer value!)
7619 selectbox_info[i].size = 0;
7621 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
7622 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
7623 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
7625 selectbox_info[i].size++; // add one character empty space
7628 // determine horizontal position to the right of specified gadget
7629 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
7630 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
7631 ED_GADGET_TEXT_DISTANCE);
7633 // determine horizontal offset for leading text
7634 if (selectbox_info[i].text_left != NULL)
7635 x += getTextWidthForGadget(selectbox_info[i].text_left);
7637 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
7638 infotext[max_infotext_len] = '\0';
7640 gi = CreateGadget(GDI_CUSTOM_ID, id,
7641 GDI_CUSTOM_TYPE_ID, type_id,
7642 GDI_INFO_TEXT, infotext,
7645 GDI_TYPE, GD_TYPE_SELECTBOX,
7646 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
7647 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
7648 GDI_TEXT_SIZE, selectbox_info[i].size,
7649 GDI_TEXT_FONT, FONT_INPUT_1,
7650 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7651 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
7652 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7653 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7654 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7655 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
7656 GDI_DESIGN_WIDTH, gd->width,
7657 GDI_EVENT_MASK, event_mask,
7658 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7659 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
7663 Fail("cannot create gadget");
7665 level_editor_gadget[id] = gi;
7666 right_gadget_border[id] =
7667 getRightGadgetBorder(gi, selectbox_info[i].text_right);
7671 static void CreateTextbuttonGadgets(void)
7673 int max_infotext_len = getMaxInfoTextLength();
7676 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
7678 int id = textbutton_info[i].gadget_id;
7679 int type_id = textbutton_info[i].gadget_type_id;
7681 ((id >= GADGET_ID_LEVELCONFIG_LEVEL && id <= GADGET_ID_LEVELCONFIG_ENGINE) ||
7682 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
7684 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
7685 int gadget_distance =
7686 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
7687 struct GraphicInfo *gd = &graphic_info[graphic];
7688 int gd_x1 = gd->src_x;
7689 int gd_y1 = gd->src_y;
7690 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7691 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7692 int gd_x1a = gd->src_x + gd->active_xoffset;
7693 int gd_y1a = gd->src_y + gd->active_yoffset;
7694 int border_xsize = gd->border_size + gd->draw_xoffset;
7695 int border_ysize = gd->border_size;
7696 struct GadgetInfo *gi;
7697 unsigned int event_mask = GD_EVENT_RELEASED;
7698 char infotext[MAX_OUTPUT_LINESIZE + 1];
7699 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
7700 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
7703 Fail("'textbutton_info' structure corrupted at index %d -- please fix", i);
7705 if (textbutton_info[i].size == -1) // dynamically determine size
7706 textbutton_info[i].size = strlen(textbutton_info[i].text);
7708 sprintf(infotext, "%s", textbutton_info[i].infotext);
7709 infotext[max_infotext_len] = '\0';
7711 // determine horizontal position to the right of specified gadget
7712 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7714 int gadget_id_align = textbutton_info[i].gadget_id_align;
7716 x = right_gadget_border[gadget_id_align] + gadget_distance;
7718 if (textbutton_info[i].y == -1)
7719 y = level_editor_gadget[gadget_id_align]->y;
7722 // determine horizontal offset for leading text
7723 if (textbutton_info[i].text_left != NULL)
7724 x += getTextWidthForGadget(textbutton_info[i].text_left);
7726 gi = CreateGadget(GDI_CUSTOM_ID, id,
7727 GDI_CUSTOM_TYPE_ID, type_id,
7728 GDI_IMAGE_ID, graphic,
7729 GDI_INFO_TEXT, infotext,
7732 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
7733 GDI_TEXT_VALUE, textbutton_info[i].text,
7734 GDI_TEXT_SIZE, textbutton_info[i].size,
7735 GDI_TEXT_FONT, FONT_INPUT_2,
7736 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
7737 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7738 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7739 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7740 GDI_BORDER_SIZE, border_xsize, border_ysize,
7741 GDI_DESIGN_WIDTH, gd->width,
7742 GDI_DECORATION_SHIFTING, 1, 1,
7743 GDI_EVENT_MASK, event_mask,
7744 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7745 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7749 Fail("cannot create gadget");
7751 level_editor_gadget[id] = gi;
7752 right_gadget_border[id] =
7753 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7757 static void CreateGraphicbuttonGadgets(void)
7759 struct GadgetInfo *gi;
7762 // create buttons for scrolling of drawing area and element list
7763 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7765 int id = graphicbutton_info[i].gadget_id;
7766 int type_id = graphicbutton_info[i].gadget_type_id;
7767 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7768 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7769 int graphic = graphicbutton_info[i].graphic;
7770 struct GraphicInfo *gd = &graphic_info[graphic];
7771 int gd_x1 = gd->src_x;
7772 int gd_y1 = gd->src_y;
7773 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7774 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7775 unsigned int event_mask = GD_EVENT_RELEASED;
7778 Fail("'graphicbutton_info' structure corrupted at index %d -- please fix", i);
7780 // determine horizontal position to the right of specified gadget
7781 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7782 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7783 ED_GADGET_TEXT_DISTANCE);
7785 // determine horizontal offset for leading text
7786 if (graphicbutton_info[i].text_left != NULL)
7787 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7789 gi = CreateGadget(GDI_CUSTOM_ID, id,
7790 GDI_CUSTOM_TYPE_ID, type_id,
7791 GDI_IMAGE_ID, graphic,
7792 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7795 GDI_WIDTH, gd->width,
7796 GDI_HEIGHT, gd->height,
7797 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7798 GDI_STATE, GD_BUTTON_UNPRESSED,
7799 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7800 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7801 GDI_EVENT_MASK, event_mask,
7802 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7803 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7807 Fail("cannot create gadget");
7809 level_editor_gadget[id] = gi;
7810 right_gadget_border[id] =
7811 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7815 static void CreateScrollbarGadgets(void)
7819 // these values are not constant, but can change at runtime
7820 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7821 SX + ED_SCROLL_HORIZONTAL_XPOS;
7822 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7823 SY + ED_SCROLL_HORIZONTAL_YPOS;
7824 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7825 ED_SCROLL_HORIZONTAL_XSIZE;
7826 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7827 ED_SCROLL_HORIZONTAL_YSIZE;
7828 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7829 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7830 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7831 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7833 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7834 SX + ED_SCROLL_VERTICAL_XPOS;
7835 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7836 SY + ED_SCROLL_VERTICAL_YPOS;
7837 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7838 ED_SCROLL_VERTICAL_XSIZE;
7839 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7840 ED_SCROLL_VERTICAL_YSIZE;
7841 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7842 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7843 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7844 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7846 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7847 PX + ED_SCROLL2_VERTICAL_XPOS;
7848 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7849 PY + ED_SCROLL2_VERTICAL_YPOS;
7850 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7851 ED_SCROLL2_VERTICAL_XSIZE;
7852 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7853 ED_SCROLL2_VERTICAL_YSIZE;
7854 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7855 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7856 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7857 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7859 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7861 int id = scrollbar_info[i].gadget_id;
7862 int type_id = scrollbar_info[i].gadget_type_id;
7863 int graphic = scrollbar_info[i].graphic;
7864 struct GraphicInfo *gd = &graphic_info[graphic];
7865 int gd_x1 = gd->src_x;
7866 int gd_y1 = gd->src_y;
7867 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7868 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7869 struct GadgetInfo *gi;
7870 int items_max, items_visible, item_position;
7871 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7874 Fail("'scrollbar_info' structure corrupted at index %d -- please fix", i);
7876 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7878 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7879 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7880 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7882 else // drawing area scrollbars
7884 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7886 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7887 items_visible = ed_fieldx;
7892 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7893 items_visible = ed_fieldy;
7898 gi = CreateGadget(GDI_CUSTOM_ID, id,
7899 GDI_CUSTOM_TYPE_ID, type_id,
7900 GDI_IMAGE_ID, graphic,
7901 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7902 GDI_X, scrollbar_pos[i].x,
7903 GDI_Y, scrollbar_pos[i].y,
7904 GDI_WIDTH, scrollbar_pos[i].width,
7905 GDI_HEIGHT, scrollbar_pos[i].height,
7906 GDI_TYPE, scrollbar_info[i].type,
7907 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7908 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7909 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7910 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7911 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7912 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7913 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7914 GDI_STATE, GD_BUTTON_UNPRESSED,
7915 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7916 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7917 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7918 GDI_EVENT_MASK, event_mask,
7919 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7920 GDI_CALLBACK_ACTION, HandleControlButtons,
7924 Fail("cannot create gadget");
7926 level_editor_gadget[id] = gi;
7930 static void CreateCheckbuttonGadgets(void)
7932 struct GadgetInfo *gi;
7935 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7937 int id = checkbutton_info[i].gadget_id;
7938 int type_id = checkbutton_info[i].gadget_type_id;
7939 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7940 IMG_EDITOR_CHECKBOX);
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 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7951 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7952 unsigned int event_mask = GD_EVENT_PRESSED;
7955 Fail("'checkbutton_info' structure corrupted at index %d -- please fix", i);
7957 // determine horizontal position to the right of specified gadget
7958 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7959 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7960 ED_GADGET_TEXT_DISTANCE);
7962 // determine horizontal offset for leading text
7963 if (checkbutton_info[i].text_left != NULL)
7964 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7966 gi = CreateGadget(GDI_CUSTOM_ID, id,
7967 GDI_CUSTOM_TYPE_ID, type_id,
7968 GDI_IMAGE_ID, graphic,
7969 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7972 GDI_WIDTH, gd->width,
7973 GDI_HEIGHT, gd->height,
7974 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7975 GDI_CHECKED, *checkbutton_info[i].value,
7976 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7977 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7978 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7979 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7980 GDI_EVENT_MASK, event_mask,
7981 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7982 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7986 Fail("cannot create gadget");
7988 level_editor_gadget[id] = gi;
7989 right_gadget_border[id] =
7990 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7994 static void CreateRadiobuttonGadgets(void)
7996 int graphic = IMG_EDITOR_RADIOBUTTON;
7997 struct GraphicInfo *gd = &graphic_info[graphic];
7998 int gd_x1 = gd->src_x;
7999 int gd_y1 = gd->src_y;
8000 int gd_x2 = gd->src_x + gd->pressed_xoffset;
8001 int gd_y2 = gd->src_y + gd->pressed_yoffset;
8002 int gd_x1a = gd->src_x + gd->active_xoffset;
8003 int gd_y1a = gd->src_y + gd->active_yoffset;
8004 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
8005 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
8006 struct GadgetInfo *gi;
8009 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
8011 int id = radiobutton_info[i].gadget_id;
8012 int type_id = radiobutton_info[i].gadget_type_id;
8013 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
8014 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
8015 unsigned int event_mask = GD_EVENT_PRESSED;
8018 Fail("'radiobutton_info' structure corrupted at index %d -- please fix", i);
8021 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
8023 // determine horizontal position to the right of specified gadget
8024 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
8025 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
8026 ED_GADGET_TEXT_DISTANCE);
8028 // determine horizontal offset for leading text
8029 if (radiobutton_info[i].text_left != NULL)
8030 x += getTextWidthForGadget(radiobutton_info[i].text_left);
8032 gi = CreateGadget(GDI_CUSTOM_ID, id,
8033 GDI_CUSTOM_TYPE_ID, type_id,
8034 GDI_IMAGE_ID, graphic,
8035 GDI_INFO_TEXT, radiobutton_info[i].infotext,
8038 GDI_WIDTH, gd->width,
8039 GDI_HEIGHT, gd->height,
8040 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
8041 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
8042 GDI_CHECKED, checked,
8043 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
8044 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
8045 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
8046 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
8047 GDI_EVENT_MASK, event_mask,
8048 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
8049 GDI_CALLBACK_ACTION, HandleRadiobuttons,
8053 Fail("cannot create gadget");
8055 level_editor_gadget[id] = gi;
8056 right_gadget_border[id] =
8057 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
8061 void CreateLevelEditorGadgets(void)
8063 // force EDITOR font inside level editor
8064 SetFontStatus(GAME_MODE_EDITOR);
8066 // these values are not constant, but can change at runtime
8067 ed_fieldx = MAX_ED_FIELDX - 1;
8068 ed_fieldy = MAX_ED_FIELDY - 1;
8070 num_editor_gadgets = NUM_EDITOR_GADGETS;
8072 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
8074 level_editor_gadget =
8075 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
8076 right_gadget_border =
8077 checked_calloc(num_editor_gadgets * sizeof(int));
8079 // set number of empty (padding) element buttons to maximum number of buttons
8080 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
8082 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
8083 editor_el_empty_ptr = editor_el_empty;
8085 use_permanent_palette = !editor.palette.show_as_separate_screen;
8087 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
8089 ReinitializeElementList();
8091 CreateControlButtons();
8092 CreateScrollbarGadgets();
8094 // order of function calls is important because of cross-references
8095 CreateCheckbuttonGadgets();
8096 CreateCounterButtons();
8097 CreateRadiobuttonGadgets();
8098 CreateTextInputGadgets();
8099 CreateTextAreaGadgets();
8100 CreateSelectboxGadgets();
8101 CreateGraphicbuttonGadgets();
8102 CreateTextbuttonGadgets();
8103 CreateDrawingAreas();
8108 void FreeLevelEditorGadgets(void)
8112 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
8114 for (i = 0; i < num_editor_gadgets; i++)
8116 FreeGadget(level_editor_gadget[i]);
8118 level_editor_gadget[i] = NULL;
8121 checked_free(level_editor_gadget);
8122 checked_free(right_gadget_border);
8124 checked_free(editor_el_empty);
8127 static void MapCounterButtons(int id)
8129 int font_nr = FONT_TEXT_1;
8130 int font_height = getFontHeight(font_nr);
8131 int gadget_id_down = counterbutton_info[id].gadget_id_down;
8132 int gadget_id_text = counterbutton_info[id].gadget_id_text;
8133 int gadget_id_up = counterbutton_info[id].gadget_id_up;
8134 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
8135 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
8136 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8137 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
8138 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8139 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8140 int yoffset = (gi_down->height - font_height) / 2;
8141 int x_left = gi_down->x - xoffset_left;
8142 int x_right; // set after gadget position was modified
8143 int y_above = gi_down->y - yoffset_above;
8145 int y; // set after gadget position was modified
8147 // counter limits must be changed first to prevent value truncation
8148 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
8149 counterbutton_info[id].max_value);
8151 // right text position might have changed after setting position above
8152 x_right = gi_up->x + gi_up->width + xoffset_right;
8154 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
8156 // set position for counter gadgets with dynamically determined position
8157 ModifyGadget(gi_down, GDI_Y, SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8158 ModifyGadget(gi_text, GDI_Y, SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8159 ModifyGadget(gi_up, GDI_Y, SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8161 // vertical position might have changed after setting position above
8162 y = gi_up->y + yoffset;
8164 if (counterbutton_info[id].text_above)
8165 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
8167 if (counterbutton_info[id].text_left)
8168 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
8170 if (counterbutton_info[id].text_right)
8171 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
8178 static void MapControlButtons(void)
8183 // map toolbox buttons (excluding special CE toolbox buttons)
8184 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
8185 MapGadget(level_editor_gadget[i]);
8187 // map toolbox buttons (element properties buttons)
8188 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
8189 MapGadget(level_editor_gadget[i]);
8191 if (use_permanent_palette)
8193 // map buttons to select elements
8194 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8195 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
8196 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
8197 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
8198 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
8201 // map buttons to select level
8202 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
8203 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
8204 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
8205 MapCounterButtons(counter_id);
8208 static void MapDrawingArea(int id)
8210 int font_nr = FONT_TEXT_1;
8211 int font_height = getFontHeight(font_nr);
8212 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8213 int area_xsize = gi->drawing.area_xsize;
8214 int area_ysize = gi->drawing.area_ysize;
8215 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8216 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
8217 int x_left = gi->x - xoffset_left;
8218 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
8219 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
8220 int x_below = gi->x + (gi->width - xoffset_below) / 2;
8221 int y_side = gi->y + (gi->height - font_height) / 2;
8222 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
8223 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
8225 if (drawingarea_info[id].text_left)
8226 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
8228 if (drawingarea_info[id].text_right)
8229 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
8231 if (drawingarea_info[id].text_above)
8232 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
8234 if (drawingarea_info[id].text_below)
8235 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
8237 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
8239 DrawElementBorder(gi->x, gi->y,
8240 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
8241 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
8243 DrawDrawingArea(id);
8249 static void MapTextInputGadget(int id)
8251 int font_nr = FONT_TEXT_1;
8252 int font_height = getFontHeight(font_nr);
8253 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
8254 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8255 int x_above = ED_SETTINGS_X(textinput_info[id].x);
8256 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
8258 if (textinput_info[id].text_above)
8259 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
8261 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
8266 static void MapTextAreaGadget(int id)
8268 int font_nr = FONT_TEXT_1;
8269 int font_height = getFontHeight(font_nr);
8270 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8271 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8272 int x_above = ED_SETTINGS_X(textarea_info[id].x);
8273 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
8274 char *text_above = textarea_info[id].text_above;
8276 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
8277 text_above = textarea_info[id].text_above_cropped;
8280 DrawTextS(x_above, y_above, font_nr, text_above);
8282 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
8287 static void MapSelectboxGadget(int id)
8289 int font_nr = FONT_TEXT_1;
8290 int font_height = getFontHeight(font_nr);
8291 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
8292 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
8293 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8294 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8295 int yoffset = (gi->height - font_height) / 2;
8296 int x_left = gi->x - xoffset_left;
8297 int x_right = gi->x + gi->width + xoffset_right;
8298 int y_above = gi->y - yoffset_above;
8300 int y = gi->y + yoffset;
8302 if (selectbox_info[id].text_above)
8303 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
8305 if (selectbox_info[id].text_left)
8306 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
8308 if (selectbox_info[id].text_right)
8309 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
8311 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
8316 static void MapTextbuttonGadget(int id)
8318 int font_nr = FONT_TEXT_1;
8319 int font_height = getFontHeight(font_nr);
8320 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
8321 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
8322 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8323 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8324 int yoffset = (gi->height - font_height) / 2;
8325 int x_left = gi->x - xoffset_left;
8326 int x_right = gi->x + gi->width + xoffset_right;
8327 int y_above = gi->y - yoffset_above;
8329 int y = gi->y + yoffset;
8331 // only show button to delete change pages when more than minimum pages
8332 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
8333 custom_element.num_change_pages == MIN_CHANGE_PAGES)
8336 if (textbutton_info[id].text_above)
8337 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
8339 if (textbutton_info[id].text_left)
8340 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
8342 if (textbutton_info[id].text_right)
8343 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
8348 static void MapGraphicbuttonGadget(int id)
8350 int font_nr = FONT_TEXT_1;
8351 int font_height = getFontHeight(font_nr);
8352 struct GadgetInfo *gi = level_editor_gadget[graphicbutton_info[id].gadget_id];
8353 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
8354 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8355 int yoffset = (gi->height - font_height) / 2;
8356 int x_left = gi->x - xoffset_left;
8357 int x_right = gi->x + gi->width + xoffset_right;
8358 int y = gi->y + yoffset;
8360 if (graphicbutton_info[id].text_left)
8361 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
8363 if (graphicbutton_info[id].text_right)
8364 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
8369 static void MapRadiobuttonGadget(int id)
8371 int font_nr = FONT_TEXT_1;
8372 int font_height = getFontHeight(font_nr);
8373 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
8374 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8375 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8376 int yoffset = (gi->height - font_height) / 2;
8377 int x_left = gi->x - xoffset_left;
8378 int x_right = gi->x + gi->width + xoffset_right;
8379 int y = gi->y + yoffset;
8381 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
8383 if (radiobutton_info[id].text_left)
8384 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
8386 if (radiobutton_info[id].text_right)
8387 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
8389 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
8394 static void MapCheckbuttonGadget(int id)
8396 int font_nr = FONT_TEXT_1;
8397 int font_height = getFontHeight(font_nr);
8398 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
8399 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8400 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8401 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8402 int yoffset = (gi->height - font_height) / 2;
8403 int y_above = gi->y - yoffset_above;
8405 int x_left, x_right, y; // set after gadget position was modified
8407 // set position for gadgets with dynamically determined position
8408 if (checkbutton_info[id].x != -1) // do not change dynamic positions
8409 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x), GDI_END);
8410 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
8412 x_left = gi->x - xoffset_left;
8413 x_right = gi->x + gi->width + xoffset_right;
8414 y = gi->y + yoffset;
8416 if (checkbutton_info[id].text_above)
8417 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
8419 if (checkbutton_info[id].text_left)
8420 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
8422 if (checkbutton_info[id].text_right)
8423 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
8425 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
8430 static void MapMainDrawingArea(void)
8432 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
8433 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
8436 if (suppressBorderElement())
8438 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
8439 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
8442 for (i = ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
8444 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
8445 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
8446 no_horizontal_scrollbar) ||
8447 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
8448 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
8449 no_vertical_scrollbar))
8452 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
8455 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
8457 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
8458 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
8461 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
8464 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
8467 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
8471 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
8473 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
8474 i == GADGET_ID_CUSTOM_COPY_TO ||
8475 i == GADGET_ID_CUSTOM_EXCHANGE ||
8476 i == GADGET_ID_CUSTOM_COPY ||
8477 i == GADGET_ID_CUSTOM_PASTE)
8480 MapGadget(level_editor_gadget[i]);
8482 UnmapGadget(level_editor_gadget[i]);
8487 static void MapLevelEditorToolboxCustomGadgets(void)
8489 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
8492 static void MapLevelEditorToolboxCustomGadgetsIfNeeded(void)
8494 if (IS_CUSTOM_ELEMENT(properties_element) ||
8495 IS_GROUP_ELEMENT(properties_element) ||
8496 IS_EMPTY_ELEMENT(properties_element))
8497 MapLevelEditorToolboxCustomGadgets();
8500 static void UnmapLevelEditorToolboxCustomGadgets(void)
8502 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
8505 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
8509 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
8511 if (i != GADGET_ID_SINGLE_ITEMS &&
8512 i != GADGET_ID_PICK_ELEMENT)
8514 struct GadgetInfo *gi = level_editor_gadget[i];
8522 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
8523 struct GraphicInfo *gd = &graphic_info[graphic];
8527 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
8528 gi->width, gi->height, gi->x, gi->y);
8530 redraw_mask |= REDRAW_DOOR_3;
8536 static void MapLevelEditorToolboxDrawingGadgets(void)
8538 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
8541 static void UnmapLevelEditorToolboxDrawingGadgets(void)
8543 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
8546 static void UnmapDrawingArea(int id)
8548 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
8551 static void UnmapLevelEditorFieldGadgets(void)
8555 for (i = 0; i < num_editor_gadgets; i++)
8556 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
8557 level_editor_gadget[i]->y))
8558 UnmapGadget(level_editor_gadget[i]);
8561 void UnmapLevelEditorGadgets(void)
8565 for (i = 0; i < num_editor_gadgets; i++)
8566 UnmapGadget(level_editor_gadget[i]);
8569 static void ResetUndoBuffer(void)
8571 undo_buffer_position = -1;
8572 undo_buffer_steps = -1;
8573 redo_buffer_steps = 0;
8575 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8577 level.changed = FALSE;
8580 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
8582 if (remap_toolbox_gadgets)
8584 ModifyEditorElementList();
8585 RedrawDrawingElements();
8588 if (edit_mode == ED_MODE_LEVELCONFIG)
8589 DrawLevelConfigWindow();
8590 else if (edit_mode == ED_MODE_PROPERTIES)
8591 DrawPropertiesWindow();
8592 else if (edit_mode == ED_MODE_PALETTE)
8593 DrawPaletteWindow();
8594 else // edit_mode == ED_MODE_DRAWING
8595 DrawDrawingWindowExt(remap_toolbox_gadgets);
8598 static void DrawEditModeWindow(void)
8600 DrawEditModeWindowExt(TRUE);
8603 static void DrawEditModeWindow_PlayfieldOnly(void)
8605 DrawEditModeWindowExt(FALSE);
8608 static void ChangeEditModeWindow(int new_edit_mode)
8610 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
8612 DrawEditModeWindow();
8615 static boolean LevelChanged(void)
8617 boolean field_changed = FALSE;
8620 for (y = 0; y < lev_fieldy; y++)
8621 for (x = 0; x < lev_fieldx; x++)
8622 if (Tile[x][y] != level.field[x][y])
8623 field_changed = TRUE;
8625 return (level.changed || field_changed);
8628 static boolean PrepareSavingIntoPersonalLevelSet(void)
8630 static LevelDirTree *last_copied_leveldir = NULL;
8631 static LevelDirTree *last_written_leveldir = NULL;
8632 static int last_copied_level_nr = -1;
8633 static int last_written_level_nr = -1;
8634 LevelDirTree *leveldir_former = leveldir_current;
8635 int level_nr_former = level_nr;
8638 // remember last mod/save so that for current session, we write
8639 // back to the same personal copy, asking only about overwrite.
8640 if (leveldir_current == last_copied_leveldir &&
8641 level_nr == last_copied_level_nr)
8643 // "cd" to personal level set dir (as used when writing last copy)
8644 leveldir_current = last_written_leveldir;
8645 level_nr = last_written_level_nr;
8650 if (!Request("This level is read-only! "
8651 "Save into personal level set?", REQ_ASK))
8654 // "cd" to personal level set dir (for writing copy the first time)
8656 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
8658 // this may happen if "setup.internal.create_user_levelset" is FALSE
8659 // or if file "levelinfo.conf" is missing in personal user level set
8660 if (leveldir_current == NULL)
8662 Request("Cannot find personal level set?!", REQ_CONFIRM);
8664 leveldir_current = leveldir_former;
8669 // find unused level number
8670 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
8672 static char *level_filename = NULL;
8674 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
8676 if (!fileExists(level_filename))
8680 last_copied_leveldir = leveldir_former;
8681 last_copied_level_nr = level_nr_former;
8683 last_written_leveldir = leveldir_current;
8684 last_written_level_nr = level_nr = new_level_nr;
8689 static void ModifyLevelConfigForSavingIntoPersonalLevelSet(char *former_name)
8691 static char *filename_levelinfo = NULL, *mod_name = NULL;
8694 // annotate this copy-and-mod in personal levelinfo.conf
8695 setString(&filename_levelinfo,
8696 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
8698 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
8700 fprintf(file, "\n");
8701 fprintf(file, "# level %d was modified from:\n", level_nr);
8702 fprintf(file, "# - previous level set name: %s\n",
8704 fprintf(file, "# - level within previous set: %d \"%s\"\n",
8705 level.file_info.nr, level.name);
8706 fprintf(file, "# - previous author: %s\n",
8708 fprintf(file, "# - previous save date: ");
8710 if (level.creation_date.src == DATE_SRC_LEVELFILE)
8712 fprintf(file, "%04d-%02d-%02d\n",
8713 level.creation_date.year,
8714 level.creation_date.month,
8715 level.creation_date.day);
8719 fprintf(file, "not recorded\n");
8725 if (level_nr > leveldir_current->last_level)
8726 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
8728 // else: allow the save even if annotation failed
8730 // now... spray graffiti on the old level vital statistics
8731 // user can change these; just trying to set a good baseline
8733 // don't truncate names for fear of making offensive or silly:
8734 // long-named original author only recorded in levelinfo.conf.
8735 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
8736 if (!strEqual(level.author, leveldir_current->author))
8738 setString(&mod_name, getStringCat3(leveldir_current->author,
8739 " after ", level.author));
8741 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8742 setString(&mod_name,
8743 getStringCat2(leveldir_current->author, " (ed.)"));
8745 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8746 setString(&mod_name, leveldir_current->author);
8748 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
8750 // less worried about truncation here
8751 setString(&mod_name, getStringCat2("Mod: ", level.name));
8752 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
8756 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
8757 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8761 for (x = 0; x < lev_fieldx; x++)
8762 for (y = 0; y < lev_fieldy; y++)
8763 dst[x][y] = src[x][y];
8766 static int setSelectboxValue(int selectbox_id, int new_value)
8768 int new_index_value = 0;
8771 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8772 if (selectbox_info[selectbox_id].options[i].value == new_value)
8773 new_index_value = i;
8775 *selectbox_info[selectbox_id].value =
8776 selectbox_info[selectbox_id].options[new_index_value].value;
8778 return new_index_value;
8781 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8785 // change action mode and arg variables according to action type variable
8786 for (i = 0; action_arg_options[i].value != -1; i++)
8788 if (action_arg_options[i].value == custom_element_change.action_type)
8790 int mode = action_arg_options[i].mode;
8792 // only change if corresponding selectbox has changed
8793 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8794 action_arg_modes[mode])
8795 custom_element_change.action_mode = -1;
8797 // only change if corresponding selectbox has changed
8798 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8799 action_arg_options[i].options)
8800 custom_element_change.action_arg = -1;
8807 static void setSelectboxSpecialActionOptions(void)
8811 // change action mode and arg selectbox according to action type selectbox
8812 for (i = 0; action_arg_options[i].value != -1; i++)
8814 if (action_arg_options[i].value == custom_element_change.action_type)
8816 int mode = action_arg_options[i].mode;
8818 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8819 action_arg_modes[mode]);
8820 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8821 custom_element_change.action_mode);
8823 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8824 action_arg_options[i].options);
8825 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8826 custom_element_change.action_arg);
8832 static void copy_custom_element_settings(int element_from, int element_to)
8834 struct ElementInfo *ei_from = &element_info[element_from];
8835 struct ElementInfo *ei_to = &element_info[element_to];
8837 copyElementInfo(ei_from, ei_to);
8840 static void replace_custom_element_in_settings(int element_from,
8845 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8847 struct ElementInfo *ei = &element_info[i];
8849 for (y = 0; y < 3; y++)
8850 for (x = 0; x < 3; x++)
8851 if (ei->content.e[x][y] == element_from)
8852 ei->content.e[x][y] = element_to;
8854 for (j = 0; j < ei->num_change_pages; j++)
8856 struct ElementChangeInfo *change = &ei->change_page[j];
8858 if (change->target_element == element_from)
8859 change->target_element = element_to;
8861 if (change->initial_trigger_element == element_from)
8862 change->initial_trigger_element = element_to;
8864 if (change->action_element == element_from)
8865 change->action_element = element_to;
8867 for (y = 0; y < 3; y++)
8868 for (x = 0; x < 3; x++)
8869 if (change->target_content.e[x][y] == element_from)
8870 change->target_content.e[x][y] = element_to;
8873 if (ei->group != NULL) // group or internal
8874 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8875 if (ei->group->element[j] == element_from)
8876 ei->group->element[j] = element_to;
8880 static void replace_custom_element_in_playfield(int element_from,
8885 for (x = 0; x < lev_fieldx; x++)
8886 for (y = 0; y < lev_fieldy; y++)
8887 if (Tile[x][y] == element_from)
8888 Tile[x][y] = element_to;
8891 static boolean CopyCustomElement(int element_old, int element_new,
8894 int copy_mode_orig = copy_mode;
8896 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8898 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8899 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8900 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8902 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8904 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8905 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8906 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8908 level.changed = TRUE;
8910 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8912 Request("Please choose custom element!", REQ_CONFIRM);
8916 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8918 Request("Please choose group element!", REQ_CONFIRM);
8922 else if (IS_EMPTY_ELEMENT(element_old) && !IS_EMPTY_ELEMENT(element_new))
8924 Request("Please choose empty element!", REQ_CONFIRM);
8930 level.changed = TRUE;
8933 // when modifying custom/group element, ask for copying level template
8934 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8936 if (!AskToCopyAndModifyLevelTemplate())
8940 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8942 copy_custom_element_settings(element_new, element_old);
8944 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8946 copy_custom_element_settings(element_old, element_new);
8948 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8950 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8951 copy_custom_element_settings(element_new, element_old);
8952 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8954 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8955 replace_custom_element_in_settings(element_new, element_old);
8956 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8958 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8959 replace_custom_element_in_playfield(element_new, element_old);
8960 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8963 UpdateCustomElementGraphicGadgets();
8964 DrawPropertiesWindow();
8969 static void CopyCustomElementPropertiesToEditor(int element)
8972 int current_change_page = element_info[element].current_change_page;
8974 // dynamically (re)build selectbox for selecting change page
8975 for (i = 0; i < element_info[element].num_change_pages; i++)
8977 sprintf(options_change_page_strings[i], "%d", i + 1);
8979 options_change_page[i].value = i;
8980 options_change_page[i].text = options_change_page_strings[i];
8983 options_change_page[i].value = -1;
8984 options_change_page[i].text = NULL;
8986 // needed here to initialize combined element properties
8987 InitElementPropertiesEngine(level.game_version);
8989 element_info[element].change =
8990 &element_info[element].change_page[current_change_page];
8992 custom_element = element_info[element];
8993 custom_element_change = *element_info[element].change;
8995 // needed to initially set selectbox options for special action options
8996 setSelectboxSpecialActionOptions();
8998 // needed to initially set selectbox value variables to reliable defaults
8999 for (i = 0; i < ED_NUM_SELECTBOX; i++)
9000 setSelectboxValue(i, *selectbox_info[i].value);
9002 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
9003 custom_element_properties[i] = HAS_PROPERTY(element, i);
9005 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
9006 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
9008 // ---------- element settings: configure (custom elements) -----------------
9010 // set accessible layer selectbox help value
9011 custom_element.access_type =
9012 (IS_WALKABLE(element) ? EP_WALKABLE :
9013 IS_PASSABLE(element) ? EP_PASSABLE :
9014 custom_element.access_type);
9015 custom_element.access_layer =
9016 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
9017 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
9018 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
9019 custom_element.access_layer);
9020 custom_element.access_protected =
9021 (IS_PROTECTED(element) ? 1 : 0);
9022 custom_element_properties[EP_ACCESSIBLE] =
9023 (IS_ACCESSIBLE_OVER(element) ||
9024 IS_ACCESSIBLE_INSIDE(element) ||
9025 IS_ACCESSIBLE_UNDER(element));
9027 // set walk-to-object action selectbox help value
9028 custom_element.walk_to_action =
9029 (IS_DIGGABLE(element) ? EP_DIGGABLE :
9030 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
9031 IS_DROPPABLE(element) ? EP_DROPPABLE :
9032 IS_THROWABLE(element) ? EP_THROWABLE :
9033 IS_PUSHABLE(element) ? EP_PUSHABLE :
9034 custom_element.walk_to_action);
9035 custom_element_properties[EP_WALK_TO_OBJECT] =
9036 (IS_DIGGABLE(element) ||
9037 IS_COLLECTIBLE_ONLY(element) ||
9038 IS_DROPPABLE(element) ||
9039 IS_THROWABLE(element) ||
9040 IS_PUSHABLE(element));
9042 // set smash targets selectbox help value
9043 custom_element.smash_targets =
9044 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
9045 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
9046 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
9047 custom_element.smash_targets);
9048 custom_element_properties[EP_CAN_SMASH] =
9049 (CAN_SMASH_EVERYTHING(element) ||
9050 CAN_SMASH_ENEMIES(element) ||
9051 CAN_SMASH_PLAYER(element));
9053 // set deadliness selectbox help value
9054 custom_element.deadliness =
9055 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
9056 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
9057 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
9058 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
9059 custom_element.deadliness);
9060 custom_element_properties[EP_DEADLY] =
9061 (DONT_TOUCH(element) ||
9062 DONT_GET_HIT_BY(element) ||
9063 DONT_COLLIDE_WITH(element) ||
9064 DONT_RUN_INTO(element));
9066 // ---------- element settings: advanced (custom elements) ------------------
9068 // set "change by direct action" selectbox help value
9069 custom_element_change.direct_action =
9070 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
9071 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
9072 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
9073 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
9074 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
9075 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
9076 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
9077 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
9078 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
9079 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
9080 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
9081 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
9082 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
9083 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
9084 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
9085 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
9086 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
9087 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
9088 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
9089 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
9090 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
9091 custom_element_change.direct_action);
9093 // set "change by other element action" selectbox help value
9094 custom_element_change.other_action =
9095 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
9096 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
9097 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
9098 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
9099 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
9100 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
9101 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
9102 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
9103 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
9104 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
9105 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
9106 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
9107 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
9108 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
9109 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
9110 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
9111 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
9112 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
9113 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
9114 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
9115 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
9116 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
9117 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
9118 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
9119 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
9120 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
9121 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
9122 custom_element_change.other_action);
9125 static void CopyGroupElementPropertiesToEditor(int element)
9127 group_element_info = *element_info[element].group;
9128 custom_element = element_info[element]; // needed for description
9131 static void CopyEmptyElementPropertiesToEditor(int element)
9133 custom_element = element_info[element];
9136 static void CopyClassicElementPropertiesToEditor(int element)
9138 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9139 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
9140 getMoveIntoAcidProperty(&level, element);
9142 if (MAYBE_DONT_COLLIDE_WITH(element))
9143 custom_element_properties[EP_DONT_COLLIDE_WITH] =
9144 getDontCollideWithProperty(&level, element);
9147 static void CopyElementPropertiesToEditor(int element)
9149 if (IS_CUSTOM_ELEMENT(element))
9150 CopyCustomElementPropertiesToEditor(element);
9151 else if (IS_GROUP_ELEMENT(element))
9152 CopyGroupElementPropertiesToEditor(element);
9153 else if (IS_EMPTY_ELEMENT(element))
9154 CopyEmptyElementPropertiesToEditor(element);
9156 CopyClassicElementPropertiesToEditor(element);
9159 static boolean AskToCopyAndModifyLevelTemplate(void)
9161 if (Request("Copy and modify settings from level template?", REQ_ASK))
9163 level.use_custom_template = FALSE;
9165 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
9166 GDI_CHECKED, FALSE, GDI_END);
9167 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
9168 GDI_CHECKED, FALSE, GDI_END);
9174 LoadLevelTemplate(-1); // this resets all element modifications ...
9176 DrawEditModeWindow(); // ... and copies them to 'custom_element'
9182 static void CopyCustomElementPropertiesToGame(int element)
9185 int access_type_and_layer;
9187 // mark that this custom element has been modified
9188 custom_element.modified_settings = TRUE;
9189 level.changed = TRUE;
9191 if (level.use_custom_template)
9192 AskToCopyAndModifyLevelTemplate();
9194 element_info[element] = custom_element;
9195 *element_info[element].change = custom_element_change;
9197 // ---------- element settings: configure (custom elements) -----------------
9199 // set accessible property from checkbox and selectbox
9200 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
9201 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
9202 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
9203 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
9204 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
9205 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
9206 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
9207 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
9208 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
9209 custom_element_properties[access_type_and_layer] =
9210 custom_element_properties[EP_ACCESSIBLE];
9211 custom_element_properties[EP_PROTECTED] =
9212 (custom_element.access_protected != 0 &&
9213 custom_element_properties[EP_ACCESSIBLE]);
9215 // set walk-to-object property from checkbox and selectbox
9216 custom_element_properties[EP_DIGGABLE] = FALSE;
9217 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
9218 custom_element_properties[EP_DROPPABLE] = FALSE;
9219 custom_element_properties[EP_THROWABLE] = FALSE;
9220 custom_element_properties[EP_PUSHABLE] = FALSE;
9221 custom_element_properties[custom_element.walk_to_action] =
9222 custom_element_properties[EP_WALK_TO_OBJECT];
9224 // set smash property from checkbox and selectbox
9225 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
9226 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
9227 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
9228 custom_element_properties[custom_element.smash_targets] =
9229 custom_element_properties[EP_CAN_SMASH];
9231 // set deadliness property from checkbox and selectbox
9232 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
9233 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
9234 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
9235 custom_element_properties[EP_DONT_TOUCH] = FALSE;
9236 custom_element_properties[custom_element.deadliness] =
9237 custom_element_properties[EP_DEADLY];
9239 // ---------- element settings: advanced (custom elements) ------------------
9241 // set player change event from checkbox and selectbox
9242 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
9243 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
9244 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
9245 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
9246 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
9247 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
9248 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
9249 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
9250 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
9251 custom_element_change_events[CE_SWITCHED] = FALSE;
9252 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
9253 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
9254 custom_element_change_events[CE_BLOCKED] = FALSE;
9255 custom_element_change_events[CE_IMPACT] = FALSE;
9256 custom_element_change_events[CE_SMASHED] = FALSE;
9257 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
9258 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
9259 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
9260 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
9261 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
9262 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
9263 custom_element_change_events[custom_element_change.direct_action] =
9264 custom_element_change_events[CE_BY_DIRECT_ACTION];
9266 // set other element action change event from checkbox and selectbox
9267 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
9268 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
9269 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
9270 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
9271 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
9272 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
9273 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
9274 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
9275 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
9276 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
9277 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
9278 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
9279 custom_element_change_events[CE_TOUCHING_X] = FALSE;
9280 custom_element_change_events[CE_HITTING_X] = FALSE;
9281 custom_element_change_events[CE_DIGGING_X] = FALSE;
9282 custom_element_change_events[CE_HIT_BY_X] = FALSE;
9283 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
9284 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
9285 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
9286 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
9287 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
9288 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
9289 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
9290 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
9291 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
9292 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
9293 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
9294 custom_element_change_events[custom_element_change.other_action] =
9295 custom_element_change_events[CE_BY_OTHER_ACTION];
9297 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
9298 SET_PROPERTY(element, i, custom_element_properties[i]);
9300 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
9301 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
9303 // copy change events also to special level editor variable
9304 custom_element = element_info[element];
9305 custom_element_change = *element_info[element].change;
9307 // needed here to restore runtime value "element_info[element].gfx_element"
9308 InitElementPropertiesGfxElement();
9311 static void CopyGroupElementPropertiesToGame(int element)
9313 // mark that this group element has been modified
9314 custom_element.modified_settings = TRUE;
9315 level.changed = TRUE;
9317 if (level.use_custom_template)
9318 AskToCopyAndModifyLevelTemplate();
9320 element_info[element] = custom_element;
9321 *element_info[element].group = group_element_info;
9323 // needed here to restore runtime value "element_info[element].gfx_element"
9324 InitElementPropertiesGfxElement();
9327 static void CopyEmptyElementPropertiesToGame(int element)
9329 // mark that this empty element has been modified
9330 custom_element.modified_settings = TRUE;
9331 level.changed = TRUE;
9333 if (level.use_custom_template)
9334 AskToCopyAndModifyLevelTemplate();
9336 element_info[element] = custom_element;
9338 // needed here to restore runtime value "element_info[element].gfx_element"
9339 InitElementPropertiesGfxElement();
9342 static void CopyClassicElementPropertiesToGame(int element)
9344 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9345 setMoveIntoAcidProperty(&level, element,
9346 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
9348 if (MAYBE_DONT_COLLIDE_WITH(element))
9349 setDontCollideWithProperty(&level, element,
9350 custom_element_properties[EP_DONT_COLLIDE_WITH]);
9353 static void CopyElementPropertiesToGame(int element)
9355 if (IS_CUSTOM_ELEMENT(element))
9356 CopyCustomElementPropertiesToGame(element);
9357 else if (IS_GROUP_ELEMENT(element))
9358 CopyGroupElementPropertiesToGame(element);
9359 else if (IS_EMPTY_ELEMENT(element))
9360 CopyEmptyElementPropertiesToGame(element);
9362 CopyClassicElementPropertiesToGame(element);
9366 static void CheckElementDescriptions(void)
9370 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
9371 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
9372 Warn("no element description file for element '%s'", EL_NAME(i));
9376 static int getMaxEdFieldX(boolean has_scrollbar)
9378 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
9379 int sxsize = SXSIZE - scrollbar_width;
9380 int max_ed_fieldx = sxsize / ed_tilesize;
9382 return max_ed_fieldx;
9385 static int getMaxEdFieldY(boolean has_scrollbar)
9387 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
9388 INFOTEXT_YSIZE_FULL : 0);
9389 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
9390 int sysize = SYSIZE - scrollbar_height - infotext_height;
9391 int max_ed_fieldy = sysize / ed_tilesize;
9393 return max_ed_fieldy;
9396 static void InitZoomLevelSettings(int zoom_tilesize)
9398 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
9400 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
9402 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
9403 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
9405 // make sure that tile size is always a power of 2
9406 ed_tilesize = (1 << log_2(ed_tilesize));
9408 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9410 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
9411 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
9415 last_game_engine_type = level.game_engine_type;
9417 // limit zoom tilesize by upper and lower bound
9418 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
9420 // store zoom tilesize in auto setup file only if it was manually changed
9421 if (zoom_tilesize != -1)
9422 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
9424 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
9425 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
9428 static void InitDrawingElements(void)
9430 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
9432 if (level.game_engine_type == game_engine_type_last)
9435 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9437 new_element1 = EL_BD_WALL;
9438 new_element2 = EL_EMPTY;
9439 new_element3 = EL_BD_SAND;
9441 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
9443 new_element1 = EL_SP_CHIP_SINGLE;
9444 new_element2 = EL_EMPTY;
9445 new_element3 = EL_SP_BASE;
9447 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9449 new_element1 = EL_MM_MIRROR_START;
9450 new_element2 = EL_EMPTY;
9451 new_element3 = EL_MM_WOODEN_WALL;
9455 new_element1 = EL_WALL;
9456 new_element2 = EL_EMPTY;
9457 new_element3 = EL_SAND;
9460 game_engine_type_last = level.game_engine_type;
9463 static void InitLevelSetInfo(void)
9465 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
9466 "%s", leveldir_current->name);
9467 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
9468 "%s", leveldir_current->author);
9470 levelset_num_levels = leveldir_current->levels;
9472 levelset_use_levelset_artwork = FALSE;
9473 levelset_copy_level_template = FALSE;
9475 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
9478 static void ChangeEditorToLevelSet(char *levelset_subdir)
9480 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
9482 // the previous level set might have used custom artwork
9483 ReloadCustomArtwork(0);
9485 LoadLevelSetup_SeriesInfo();
9487 SaveLevelSetup_LastSeries();
9488 SaveLevelSetup_SeriesInfo();
9492 LoadLevel(level_nr);
9493 LoadScore(level_nr);
9498 static boolean useEditorDoorAnimation(void)
9500 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
9501 boolean door_1_viewport_unchanged =
9502 (vp_door_1->x == DX &&
9503 vp_door_1->y == DY &&
9504 vp_door_1->width == DXSIZE &&
9505 vp_door_1->height == DYSIZE);
9506 boolean door_1_contains_toolbox =
9509 EX + EXSIZE <= DX + DXSIZE &&
9510 EY + EYSIZE <= DY + DYSIZE);
9512 return (door_1_viewport_unchanged && door_1_contains_toolbox);
9515 static void DrawEditorDoorBackground(int graphic, int x, int y,
9516 int width, int height)
9518 struct GraphicInfo *g = &graphic_info[graphic];
9520 if (g->bitmap != NULL)
9521 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
9522 MIN(width, g->width), MIN(height, g->height), x, y);
9524 ClearRectangle(drawto, x, y, width, height);
9527 static void DrawEditorDoorContent(void)
9529 // needed for gadgets drawn on background (like palette scrollbar)
9530 SetDoorBackgroundImage(IMG_UNDEFINED);
9532 // copy default editor door content to main double buffer
9533 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
9536 DrawSpecialEditorDoor();
9538 // draw new control window
9539 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
9541 // draw all toolbox gadgets to editor doors
9542 MapControlButtons();
9544 // when returning from test game to properties page, redraw toolbox gadgets
9545 if (edit_mode == ED_MODE_PROPERTIES)
9547 UnmapLevelEditorToolboxDrawingGadgets();
9548 UnmapLevelEditorToolboxCustomGadgets();
9550 MapLevelEditorToolboxCustomGadgetsIfNeeded();
9553 // draw all palette gadgets to editor doors
9554 ModifyEditorElementList();
9555 RedrawDrawingElements();
9557 // copy actual editor door content to door double buffer for OpenDoor()
9558 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
9561 void DrawLevelEd(void)
9563 int fade_mask = REDRAW_FIELD;
9565 FadeSoundsAndMusic();
9568 fade_mask = REDRAW_ALL;
9572 // needed if different viewport properties defined for editor
9573 ChangeViewportPropertiesIfNeeded();
9577 InitZoomLevelSettings(-1);
9578 InitDrawingElements();
9582 CheckElementDescriptions();
9585 if (level_editor_test_game)
9587 CopyPlayfield(level.field, Tile);
9588 CopyPlayfield(TileBackup, level.field);
9590 level_editor_test_game = FALSE;
9594 edit_mode = ED_MODE_DRAWING;
9595 edit_mode_levelconfig = ED_MODE_LEVELCONFIG_LEVEL;
9596 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
9604 // redraw_mask |= REDRAW_ALL;
9606 FreeLevelEditorGadgets();
9607 CreateLevelEditorGadgets();
9609 ReinitializeElementList(); // update dynamic level element list
9610 ReinitializeElementListButtons(); // custom element may look different
9612 InitElementPropertiesGfxElement();
9616 DrawEditModeWindow_PlayfieldOnly();
9618 DrawMaskedBorder(fade_mask);
9620 // use door animation if door 1 viewport is unchanged and contains toolbox
9621 if (useEditorDoorAnimation())
9625 DrawEditorDoorContent();
9627 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
9631 DrawEditorDoorContent();
9636 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
9639 static void AdjustDrawingAreaGadgets(void)
9641 int ed_xsize = lev_fieldx + 2;
9642 int ed_ysize = lev_fieldy + 2;
9643 int max_ed_fieldx = MAX_ED_FIELDX;
9644 int max_ed_fieldy = MAX_ED_FIELDY;
9645 boolean horizontal_scrollbar_needed;
9646 boolean vertical_scrollbar_needed;
9647 int x, y, width, height;
9649 if (suppressBorderElement())
9651 ed_xsize = lev_fieldx;
9652 ed_ysize = lev_fieldy;
9655 // check if we need any scrollbars
9656 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9657 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9659 // check if we have a smaller editor field because of scrollbars
9660 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9661 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9663 // check again if we now need more scrollbars because of less space
9664 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9665 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9667 // check if editor field gets even smaller after adding new scrollbars
9668 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9669 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9671 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
9672 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
9674 x = SX + ed_fieldx * ed_tilesize;
9675 y = SY + ed_fieldy * ed_tilesize;
9677 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
9678 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
9680 // adjust drawing area gadget
9681 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
9682 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
9683 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
9686 // adjust horizontal scrollbar gadgets
9687 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
9690 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
9691 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
9694 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9697 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
9700 // adjust vertical scrollbar gadgets
9701 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
9704 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
9706 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
9708 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9711 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
9715 static void AdjustLevelScrollPosition(void)
9717 if (level_xpos < -1)
9719 if (level_xpos > lev_fieldx - ed_fieldx + 1)
9720 level_xpos = lev_fieldx - ed_fieldx + 1;
9721 if (lev_fieldx < ed_fieldx - 2)
9724 if (level_ypos < -1)
9726 if (level_ypos > lev_fieldy - ed_fieldy + 1)
9727 level_ypos = lev_fieldy - ed_fieldy + 1;
9728 if (lev_fieldy < ed_fieldy - 2)
9731 if (suppressBorderElement())
9738 static void AdjustEditorScrollbar(int id)
9740 struct GadgetInfo *gi = level_editor_gadget[id];
9741 int items_max, items_visible, item_position;
9743 if (id == GADGET_ID_SCROLL_HORIZONTAL)
9745 items_max = MAX(lev_fieldx + 2, ed_fieldx);
9746 items_visible = ed_fieldx;
9747 item_position = level_xpos + 1;
9751 items_max = MAX(lev_fieldy + 2, ed_fieldy);
9752 items_visible = ed_fieldy;
9753 item_position = level_ypos + 1;
9756 if (item_position > items_max - items_visible)
9757 item_position = items_max - items_visible;
9759 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9760 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9763 static void AdjustElementListScrollbar(void)
9765 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
9766 int items_max, items_visible, item_position;
9768 // correct position of element list scrollbar
9769 if (element_shift < 0)
9771 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9772 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9774 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
9775 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
9776 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
9778 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9779 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
9780 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9783 static void ModifyEditorCounterValue(int counter_id, int new_value)
9785 int *counter_value = counterbutton_info[counter_id].value;
9786 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9787 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9789 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9791 if (counter_value != NULL)
9792 *counter_value = gi->textinput.number_value;
9795 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9797 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9798 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9800 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9802 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9803 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9805 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9806 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9808 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9809 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9814 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9816 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9817 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9818 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9820 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9823 static void ModifyEditorSelectboxOptions(int selectbox_id,
9824 struct ValueTextInfo *options)
9826 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9827 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9829 selectbox_info[selectbox_id].options = options;
9831 // set index to zero -- list may be shorter now (correct later, if needed)
9832 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9833 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9836 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9838 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9839 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9841 drawingarea_info[drawingarea_id].area_xsize = xsize;
9842 drawingarea_info[drawingarea_id].area_ysize = ysize;
9844 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9847 static void ModifyEditorElementList(void)
9851 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9854 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9856 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9857 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9858 struct GadgetDesign *gd = &gi->deco.design;
9859 int element = editor_elements[element_shift + i];
9860 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9864 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9866 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9872 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9874 int graphic = el2edimg(element);
9875 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9881 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9884 static void ModifyDrawingElementButton(int element, int id)
9886 struct GadgetInfo *gi = level_editor_gadget[id];
9887 Bitmap *deco_bitmap;
9889 int tile_size = gi->deco.width;
9891 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9893 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9896 static void PickDrawingElement(int button, int element)
9901 struct XYTileSize *pos;
9903 } de, drawing_elements[] =
9905 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9906 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9907 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9910 if (button < 1 || button > 3)
9913 if (IS_MM_WALL(element))
9914 element = map_mm_wall_element(element);
9916 de = drawing_elements[button - 1];
9918 *de.new_element = element; // update global drawing element variable
9920 DrawDrawingElementGraphic(element, de.pos);
9921 ModifyDrawingElementButton(element, de.id);
9923 redraw_mask |= REDRAW_DOOR_1;
9926 static void RedrawDrawingElements(void)
9928 PickDrawingElement(1, new_element1);
9929 PickDrawingElement(2, new_element2);
9930 PickDrawingElement(3, new_element3);
9933 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9935 stick_element_properties_window = FALSE;
9937 SetMainBackgroundImage(IMG_UNDEFINED);
9940 UnmapLevelEditorFieldGadgets();
9942 AdjustDrawingAreaGadgets();
9943 AdjustLevelScrollPosition();
9944 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9945 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9947 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9949 MapMainDrawingArea();
9951 if (remap_toolbox_gadgets)
9953 UnmapLevelEditorToolboxCustomGadgets();
9954 MapLevelEditorToolboxDrawingGadgets();
9958 static void DrawDrawingWindow(void)
9960 DrawDrawingWindowExt(TRUE);
9963 static int getTabulatorBarWidth(void)
9965 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9966 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9968 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9971 static int getTabulatorBarHeight(void)
9973 return ED_TAB_BAR_HEIGHT;
9976 static Pixel getTabulatorBarColor(void)
9978 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9979 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9980 int gd_x = gd->x + gd_gi1->border.width / 2;
9981 int gd_y = gd->y + gd_gi1->height - 1;
9983 return GetPixel(gd->bitmap, gd_x, gd_y);
9986 static void DrawLevelConfigTabulatorGadgets(void)
9988 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9989 Pixel tab_color = getTabulatorBarColor();
9990 int id_first = ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL;
9991 int id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR;
9994 // draw additional "engine" tabulator when using native BD engine
9995 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9996 id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE;
9998 for (i = id_first; i <= id_last; i++)
10000 int gadget_id = textbutton_info[i].gadget_id;
10001 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
10002 boolean active = (i != edit_mode_levelconfig);
10004 // draw background line below tabulator button
10005 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
10007 // draw solid line below inactive tabulator buttons
10008 if (!active && tab_color != BLACK_PIXEL) // black => transparent
10009 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
10010 ED_GADGET_TINY_DISTANCE, tab_color);
10012 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
10013 MapTextbuttonGadget(i);
10016 // draw little border line below tabulator buttons
10017 if (tab_color != BLACK_PIXEL) // black => transparent
10018 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
10019 ED_GADGET_TINY_DISTANCE,
10020 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10023 static void DrawPropertiesTabulatorGadgets(void)
10025 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
10026 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
10027 int gd_x = gd->x + gd_gi1->border.width / 2;
10028 int gd_y = gd->y + gd_gi1->height - 1;
10029 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
10030 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
10031 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
10034 // draw two config tabulators for player elements
10035 if (IS_PLAYER_ELEMENT(properties_element))
10036 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
10038 // draw two config and one "change" tabulator for custom elements
10039 if (IS_CUSTOM_ELEMENT(properties_element))
10040 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
10042 for (i = id_first; i <= id_last; i++)
10044 int gadget_id = textbutton_info[i].gadget_id;
10045 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
10046 boolean active = (i != edit_mode_properties);
10048 // use "config 1" and "config 2" instead of "config" for players and CEs
10049 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
10050 (IS_PLAYER_ELEMENT(properties_element) ||
10051 IS_CUSTOM_ELEMENT(properties_element)))
10054 // draw background line below tabulator button
10055 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
10057 // draw solid line below inactive tabulator buttons
10058 if (!active && tab_color != BLACK_PIXEL) // black => transparent
10059 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
10060 ED_GADGET_TINY_DISTANCE, tab_color);
10062 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
10063 MapTextbuttonGadget(i);
10066 // draw little border line below tabulator buttons
10067 if (tab_color != BLACK_PIXEL) // black => transparent
10068 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
10069 ED_GADGET_TINY_DISTANCE,
10070 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10073 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
10075 DrawText(SX + xpos, SY + ypos, text, font_nr);
10078 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
10079 int xpos, int ypos)
10081 int font_width = getFontWidth(font_nr);
10082 int font_height = getFontHeight(font_nr);
10083 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
10084 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
10086 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
10087 max_chars_per_line, -1, max_lines_drawable, 0, -1,
10088 TRUE, FALSE, FALSE);
10091 static void DrawLevelConfigLevel(void)
10095 // draw counter gadgets
10096 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
10097 MapCounterButtons(i);
10099 // draw checkbutton gadgets
10100 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
10101 MapCheckbuttonGadget(i);
10103 // draw selectbox gadgets
10104 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
10105 MapSelectboxGadget(i);
10107 // draw text input gadgets
10108 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
10109 MapTextInputGadget(i);
10112 static char *getLevelSubdirFromSaveMode(int save_mode)
10114 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
10115 return getNewUserLevelSubdir();
10117 return leveldir_current->subdir;
10120 static void DrawLevelConfigLevelSet_DirectoryInfo(void)
10122 char *directory_text = "Level set directory:";
10123 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
10124 int font1_nr = FONT_TEXT_1;
10125 int font2_nr = FONT_TEXT_2;
10126 int font1_height = getFontHeight(font1_nr);
10127 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
10128 int x = ED_LEVEL_SETTINGS_X(0);
10129 int y = ED_LEVEL_SETTINGS_Y(6);
10131 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
10132 PrintInfoText(directory_name, font2_nr, x, y);
10135 static void DrawLevelConfigLevelSet(void)
10137 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
10138 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
10141 // draw counter gadgets
10142 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
10143 MapCounterButtons(i);
10145 // draw checkbutton gadgets
10146 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
10148 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
10149 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
10150 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
10153 MapCheckbuttonGadget(i);
10156 // draw selectbox gadgets
10157 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
10158 MapSelectboxGadget(i);
10160 // draw text input gadgets
10161 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
10162 MapTextInputGadget(i);
10164 // draw textbutton gadgets
10165 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
10168 DrawLevelConfigLevelSet_DirectoryInfo();
10171 static void DrawLevelConfigEditor(void)
10175 // draw counter gadgets
10176 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
10177 MapCounterButtons(i);
10179 // draw checkbutton gadgets
10180 for (i = ED_CHECKBUTTON_ID_EDITOR_FIRST; i <= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
10181 MapCheckbuttonGadget(i);
10183 // draw radiobutton gadgets
10184 for (i = ED_RADIOBUTTON_ID_EDITOR_FIRST; i <= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
10185 MapRadiobuttonGadget(i);
10187 // draw drawing area
10188 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
10190 // draw textbutton gadgets
10191 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
10194 static void DrawLevelConfigEngine(void)
10198 // draw counter gadgets
10199 if (level.bd_scheduling_type == GD_SCHEDULING_MILLISECONDS)
10201 MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_MS);
10202 MapCounterButtons(ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES);
10206 MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_C64);
10207 MapCounterButtons(ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS);
10210 // draw checkbutton gadgets
10211 for (i = ED_CHECKBUTTON_ID_ENGINE_FIRST; i <= ED_CHECKBUTTON_ID_ENGINE_LAST; i++)
10212 MapCheckbuttonGadget(i);
10214 // draw selectbox gadgets
10215 for (i = ED_SELECTBOX_ID_ENGINE_FIRST; i <= ED_SELECTBOX_ID_ENGINE_LAST; i++)
10216 MapSelectboxGadget(i);
10219 static void DrawLevelConfigWindow(void)
10221 char *text = "Global Settings";
10222 int font_nr = FONT_TITLE_1;
10223 struct MenuPosInfo *pos = &editor.settings.headline;
10224 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
10225 int sy = SY + pos->y;
10227 stick_element_properties_window = FALSE;
10229 SetAutomaticNumberOfGemsNeeded();
10231 UnmapLevelEditorFieldGadgets();
10233 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10236 DrawText(sx, sy, text, font_nr);
10238 DrawLevelConfigTabulatorGadgets();
10240 if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVEL)
10241 DrawLevelConfigLevel();
10242 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVELSET)
10243 DrawLevelConfigLevelSet();
10244 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_EDITOR)
10245 DrawLevelConfigEditor();
10246 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_ENGINE)
10247 DrawLevelConfigEngine();
10250 static void DrawCustomContentArea(void)
10252 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
10253 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10254 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
10255 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
10256 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
10257 int xoffset = ED_GADGET_SPACE_DISTANCE;
10259 // add distance for potential left text (without drawing area border)
10260 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
10262 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10264 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
10267 static void DrawCustomChangeContentArea(void)
10269 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
10270 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10271 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
10272 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
10273 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
10274 int xoffset = ED_GADGET_SPACE_DISTANCE;
10276 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10278 MapDrawingArea(id);
10281 static void RemoveElementContentArea(int id, int font_height)
10283 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10285 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
10286 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
10287 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10288 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
10289 ED_GADGET_TEXT_DISTANCE + font_height);
10292 static void DrawYamYamContentAreas(void)
10294 int font_nr = FONT_TEXT_1;
10295 int font_height = getFontHeight(font_nr);
10296 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10297 int yoffset = (tilesize - font_height) / 2;
10298 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
10299 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
10302 // display counter to choose number of element content areas
10303 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
10305 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10307 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
10309 if (i < level.num_yamyam_contents)
10311 MapDrawingArea(id);
10315 UnmapDrawingArea(id);
10317 // delete content areas in case of reducing number of them
10318 RemoveElementContentArea(id, font_height);
10322 DrawText(x, y + 0 * tilesize, "content", font_nr);
10323 DrawText(x, y + 1 * tilesize, "when", font_nr);
10324 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
10327 static void DrawMagicBallContentAreas(void)
10329 int font_nr = FONT_TEXT_1;
10330 int font_height = getFontHeight(font_nr);
10331 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10332 int yoffset = (tilesize - font_height) / 2;
10333 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
10334 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
10337 // display counter to choose number of element content areas
10338 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
10340 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10342 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
10344 if (i < level.num_ball_contents)
10346 MapDrawingArea(id);
10350 UnmapDrawingArea(id);
10352 // delete content areas in case of reducing number of them
10353 RemoveElementContentArea(id, font_height);
10357 DrawText(x, y + 0 * tilesize, "generated", font_nr);
10358 DrawText(x, y + 1 * tilesize, "when", font_nr);
10359 DrawText(x, y + 2 * tilesize, "active", font_nr);
10362 static void DrawAndroidElementArea(void)
10364 int id = ED_DRAWING_ID_ANDROID_CONTENT;
10365 int num_elements = level.num_android_clone_elements;
10366 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10367 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10368 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10369 int xsize = MAX_ANDROID_ELEMENTS;
10372 // display counter to choose number of element areas
10373 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
10375 if (drawingarea_info[id].text_left != NULL)
10376 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10378 UnmapDrawingArea(id);
10380 ModifyEditorDrawingArea(id, num_elements, 1);
10382 // delete content areas in case of reducing number of them
10383 DrawBackground(sx, sy,
10384 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10385 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10387 MapDrawingArea(id);
10390 static void DrawGroupElementArea(void)
10392 int id = ED_DRAWING_ID_GROUP_CONTENT;
10393 int num_elements = group_element_info.num_elements;
10394 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10395 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10396 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10397 int xsize = MAX_ELEMENTS_IN_GROUP;
10400 if (drawingarea_info[id].text_left != NULL)
10401 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10403 UnmapDrawingArea(id);
10405 ModifyEditorDrawingArea(id, num_elements, 1);
10407 // delete content areas in case of reducing number of them
10408 DrawBackground(sx, sy,
10409 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10410 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10412 MapDrawingArea(id);
10415 static void DrawPlayerInitialInventoryArea(int element)
10417 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
10418 int player_nr = GET_PLAYER_NR(element);
10419 int num_elements = level.initial_inventory_size[player_nr];
10420 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10421 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10422 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10423 int xsize = MAX_INITIAL_INVENTORY_SIZE;
10426 // determine horizontal position to the right of specified gadget
10427 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
10428 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
10429 ED_DRAWINGAREA_TEXT_DISTANCE);
10431 // determine horizontal offset for leading text
10432 if (drawingarea_info[id].text_left != NULL)
10433 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10435 UnmapDrawingArea(id);
10437 ModifyEditorDrawingArea(id, num_elements, 1);
10439 // delete content areas in case of reducing number of them
10440 DrawBackground(sx, sy,
10441 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10442 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10444 MapDrawingArea(id);
10447 static void DrawMMBallContentArea(void)
10449 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
10450 int num_elements = level.num_mm_ball_contents;
10451 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10452 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10453 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10454 int xsize = MAX_MM_BALL_CONTENTS;
10457 if (drawingarea_info[id].text_left != NULL)
10458 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10460 UnmapDrawingArea(id);
10462 ModifyEditorDrawingArea(id, num_elements, 1);
10464 // delete content areas in case of reducing number of them
10465 DrawBackground(sx, sy,
10466 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10467 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10469 MapDrawingArea(id);
10472 static void DrawEnvelopeTextArea(int envelope_nr)
10474 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
10475 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
10479 DrawBackground(gi->x, gi->y,
10480 gi->textarea.crop_width, gi->textarea.crop_height);
10482 if (envelope_nr != -1)
10483 textarea_info[id].value = level.envelope[envelope_nr].text;
10485 ModifyGadget(gi, GDI_AREA_SIZE,
10486 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
10487 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
10490 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
10493 static void DrawPropertiesInfo(void)
10502 // configurable properties
10504 { EP_WALKABLE_OVER, "- player can walk over it" },
10505 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
10506 { EP_WALKABLE_UNDER, "- player can walk under it" },
10507 { EP_PASSABLE_OVER, "- player can pass over it" },
10508 { EP_PASSABLE_INSIDE, "- player can pass through it" },
10509 { EP_PASSABLE_UNDER, "- player can pass under it" },
10510 { EP_PROTECTED, "- player is protected by it" },
10512 { EP_DIGGABLE, "- can be digged away" },
10513 { EP_COLLECTIBLE, "- can be collected" },
10514 { EP_DROPPABLE, "- can be dropped after collecting" },
10515 { EP_THROWABLE, "- can be thrown after collecting" },
10516 { EP_PUSHABLE, "- can be pushed" },
10518 { EP_CAN_FALL, "- can fall" },
10519 { EP_CAN_MOVE, "- can move" },
10521 { EP_CAN_SMASH_PLAYER, "- can smash player" },
10523 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
10525 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
10527 { EP_SLIPPERY, "- slippery for falling elements" },
10528 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
10530 { EP_DONT_RUN_INTO, "- deadly when running into" },
10531 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
10532 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
10533 { EP_DONT_TOUCH, "- deadly when touching" },
10535 { EP_INDESTRUCTIBLE, "- indestructible" },
10537 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
10538 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
10539 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
10541 { EP_CAN_CHANGE, "- can change to other element" },
10543 // pre-defined properties
10544 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
10545 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
10546 { EP_SWITCHABLE, "- can be switched" },
10548 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
10553 char *filename = getElementDescriptionFilename(properties_element);
10554 char *num_elements_text = "In this level: ";
10555 char *num_similar_text = "Similar tiles: ";
10556 char *properties_text = "Standard properties: ";
10557 char *description_text = "Description:";
10558 char *no_description_text = "No description available.";
10559 char *none_text = "None";
10561 int num_elements_in_level = 0;
10562 int num_similar_in_level = 0;
10563 int num_hires_tiles_in_level = 0;
10564 int num_standard_properties = 0;
10565 int font1_nr = FONT_TEXT_1;
10566 int font2_nr = FONT_TEXT_2;
10567 int font1_width = getFontWidth(font1_nr);
10568 int font1_height = getFontHeight(font1_nr);
10569 int font2_height = getFontHeight(font2_nr);
10570 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
10571 int font2_yoffset = (font1_height - font2_height) / 2;
10572 int num_elements_text_len = strlen(num_elements_text) * font1_width;
10573 int num_similar_text_len = strlen(num_similar_text) * font1_width;
10574 int properties_text_len = strlen(properties_text) * font1_width;
10575 int xpos = ED_ELEMENT_SETTINGS_X(0);
10576 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10579 if (setup.editor.show_element_token)
10581 int font3_nr = FONT_TEXT_3;
10582 int font3_height = getFontHeight(font3_nr);
10584 DrawTextF(xpos, ypos, font3_nr,
10585 "[%s]", element_info[properties_element].token_name);
10587 ypos += 2 * font3_height;
10590 // ----- print number of elements / percentage of this element in level
10592 for (y = 0; y < lev_fieldy; y++)
10594 for (x = 0; x < lev_fieldx; x++)
10596 if (Tile[x][y] == properties_element)
10598 num_elements_in_level++;
10600 else if (IS_MM_WALL(Tile[x][y]) &&
10601 map_mm_wall_element(Tile[x][y]) == properties_element)
10603 num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
10608 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10610 DrawTextS(xpos, ypos, font1_nr, num_elements_text);
10612 if (num_hires_tiles_in_level > 0)
10613 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10614 "%d wall tiles", num_hires_tiles_in_level);
10615 else if (num_elements_in_level > 0)
10616 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10617 "%d (%.2f %%)", num_elements_in_level, percentage);
10619 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10622 // ----- print number of similar elements / percentage of them in level
10624 for (y = 0; y < lev_fieldy; y++)
10626 for (x = 0; x < lev_fieldx; x++)
10628 if (strEqual(element_info[Tile[x][y]].class_name,
10629 element_info[properties_element].class_name))
10631 num_similar_in_level++;
10636 if (num_similar_in_level != num_elements_in_level)
10638 ypos += 1 * MAX(font1_height, font2_height);
10640 percentage = num_similar_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10642 DrawTextS(xpos, ypos, font1_nr, num_similar_text);
10644 if (num_similar_in_level > 0)
10645 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10646 "%d (%.2f %%)", num_similar_in_level, percentage);
10648 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10652 ypos += 2 * MAX(font1_height, font2_height);
10654 // ----- print standard properties of this element
10656 DrawTextS(xpos, ypos, font1_nr, properties_text);
10658 ypos += line1_height;
10660 for (i = 0; properties[i].value != -1; i++)
10662 if (!HAS_PROPERTY(properties_element, properties[i].value))
10665 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
10667 ypos += font2_height;
10669 num_standard_properties++;
10672 if (num_standard_properties == 0)
10674 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
10675 font2_nr, none_text);
10677 ypos -= (line1_height - font1_height);
10680 ypos += MAX(font1_height, font2_height);
10682 // ----- print special description of this element
10684 PrintInfoText(description_text, font1_nr, xpos, ypos);
10686 ypos += line1_height;
10688 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
10689 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
10692 #define TEXT_COLLECTING "Score for collecting"
10693 #define TEXT_COLLECTING_EXTRA "Score for extra diamonds"
10694 #define TEXT_SMASHING "Score for smashing"
10695 #define TEXT_SLURPING "Score for slurping robot"
10696 #define TEXT_CRACKING "Score for cracking"
10697 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
10698 #define TEXT_DURATION "Duration when activated"
10699 #define TEXT_DELAY_ON "Delay before activating"
10700 #define TEXT_DELAY_OFF "Delay before deactivating"
10701 #define TEXT_DELAY_CHANGING "Delay before changing"
10702 #define TEXT_DELAY_EXPLODING "Delay before exploding"
10703 #define TEXT_DELAY_MOVING "Delay before moving"
10704 #define TEXT_BALL_DELAY "Element generation delay"
10705 #define TEXT_MOVE_SPEED "Speed of android moving"
10706 #define TEXT_CLONE_SPEED "Speed of android cloning"
10707 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
10708 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
10709 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
10710 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
10711 #define TEXT_TIME_BONUS "Extra time to solve level"
10718 } elements_with_counter[] =
10720 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
10721 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
10722 { EL_BD_DIAMOND, &level.score[SC_DIAMOND_EXTRA], TEXT_COLLECTING_EXTRA },
10723 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
10724 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
10725 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10726 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
10727 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
10728 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
10729 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
10730 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
10731 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10732 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
10733 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10734 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10735 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
10736 { EL_BD_BUTTERFLY_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10737 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
10738 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10739 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10740 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
10741 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10742 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10743 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10744 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10745 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10746 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10747 { EL_BD_FIREFLY_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10748 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10749 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10750 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10751 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10752 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10753 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10754 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10755 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
10756 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
10757 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10758 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
10759 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10760 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10761 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10762 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10763 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10764 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
10765 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10766 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10767 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE], TEXT_COLLECTING },
10768 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10769 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10770 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
10771 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
10772 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
10773 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10774 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10775 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10776 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10777 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10778 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10779 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10780 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10781 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
10782 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
10783 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
10784 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
10785 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
10786 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10787 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
10788 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
10789 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
10790 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10791 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10792 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10793 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10794 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10795 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10796 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10797 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10798 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10799 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10800 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10801 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10802 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10803 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
10804 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10805 { EL_DC_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10806 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
10807 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
10808 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
10809 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
10810 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
10811 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
10812 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
10813 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
10814 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
10815 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
10816 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
10817 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
10818 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
10819 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
10820 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
10821 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
10822 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
10823 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
10824 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
10825 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
10826 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
10827 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
10828 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
10829 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
10830 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
10831 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
10832 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_CHANGING },
10833 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10834 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10839 static boolean checkPropertiesConfig(int element)
10843 // special case: empty space customization only available in R'n'D game engine
10844 if (element == EL_EMPTY_SPACE && level.game_engine_type != GAME_ENGINE_TYPE_RND)
10847 // special case: BD style rock customization only available in BD game engine
10848 if (element == EL_BD_ROCK && level.game_engine_type != GAME_ENGINE_TYPE_BD)
10851 if (IS_GEM(element) ||
10852 IS_CUSTOM_ELEMENT(element) ||
10853 IS_GROUP_ELEMENT(element) ||
10854 IS_EMPTY_ELEMENT(element) ||
10855 IS_BALLOON_ELEMENT(element) ||
10856 IS_ENVELOPE(element) ||
10857 IS_MM_ENVELOPE(element) ||
10858 IS_MM_MCDUFFIN(element) ||
10859 IS_DF_LASER(element) ||
10860 IS_PLAYER_ELEMENT(element) ||
10861 IS_BD_PLAYER_ELEMENT(element) ||
10862 IS_SOKOBAN_OBJECT_OR_FIELD(element) ||
10863 HAS_EDITOR_CONTENT(element) ||
10864 CAN_GROW(element) ||
10865 COULD_MOVE_INTO_ACID(element) ||
10866 MAYBE_DONT_COLLIDE_WITH(element) ||
10867 element == EL_BD_ROCK ||
10868 element == EL_BD_MEGA_ROCK ||
10869 element == EL_BD_SWEET)
10875 for (i = 0; elements_with_counter[i].element != -1; i++)
10876 if (elements_with_counter[i].element == element)
10883 static void SetAutomaticNumberOfGemsNeeded(void)
10887 if (!level.auto_count_gems)
10890 level.gems_needed = 0;
10892 for (x = 0; x < lev_fieldx; x++)
10894 for (y = 0; y < lev_fieldy; y++)
10896 int element = Tile[x][y];
10901 case EL_EMERALD_YELLOW:
10902 case EL_EMERALD_RED:
10903 case EL_EMERALD_PURPLE:
10904 case EL_BD_DIAMOND:
10905 case EL_WALL_EMERALD:
10906 case EL_WALL_EMERALD_YELLOW:
10907 case EL_WALL_EMERALD_RED:
10908 case EL_WALL_EMERALD_PURPLE:
10909 case EL_WALL_BD_DIAMOND:
10911 case EL_SP_INFOTRON:
10914 level.gems_needed++;
10918 case EL_WALL_DIAMOND:
10919 level.gems_needed += 3;
10923 case EL_WALL_PEARL:
10924 level.gems_needed += 5;
10928 case EL_WALL_CRYSTAL:
10929 level.gems_needed += 8;
10938 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10941 static void DrawPropertiesConfig(void)
10943 boolean draw_footer_line = FALSE;
10944 int max_num_element_counters = 4;
10945 int num_element_counters = 0;
10948 if (!checkPropertiesConfig(properties_element))
10950 int xpos = ED_ELEMENT_SETTINGS_X(0);
10951 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10953 PrintInfoText("No configuration options available.",
10954 FONT_TEXT_1, xpos, ypos);
10959 // check if there are elements where a value can be chosen for
10960 for (i = 0; elements_with_counter[i].element != -1; i++)
10962 if (elements_with_counter[i].element == properties_element)
10964 // special case: score for extra diamonds only available in BD game engine
10965 if (elements_with_counter[i].element == EL_BD_DIAMOND &&
10966 elements_with_counter[i].value == &level.score[SC_DIAMOND_EXTRA] &&
10967 level.game_engine_type != GAME_ENGINE_TYPE_BD)
10970 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10972 counterbutton_info[counter_id].y =
10973 ED_ELEMENT_SETTINGS_YPOS(
10974 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10975 (CAN_GROW(properties_element) ? 1 : 0) +
10976 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10977 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10978 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10979 num_element_counters);
10981 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10982 counterbutton_info[counter_id].text_right = elements_with_counter[i].text;
10984 if (properties_element == EL_GAME_OF_LIFE ||
10985 properties_element == EL_BIOMAZE)
10987 counterbutton_info[counter_id].min_value = 0; // min neighbours
10988 counterbutton_info[counter_id].max_value = 8; // max neighbours
10992 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10993 counterbutton_info[counter_id].min_value = MIN_SCORE;
10994 counterbutton_info[counter_id].max_value = MAX_SCORE;
10997 MapCounterButtons(counter_id);
10999 num_element_counters++;
11000 if (num_element_counters >= max_num_element_counters)
11005 if (HAS_EDITOR_CONTENT(properties_element))
11007 // draw stickybutton gadget
11008 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11010 if (IS_AMOEBOID(properties_element))
11011 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
11012 else if (properties_element == EL_YAMYAM ||
11013 properties_element == EL_YAMYAM_LEFT ||
11014 properties_element == EL_YAMYAM_RIGHT ||
11015 properties_element == EL_YAMYAM_UP ||
11016 properties_element == EL_YAMYAM_DOWN)
11017 DrawYamYamContentAreas();
11018 else if (properties_element == EL_EMC_MAGIC_BALL)
11020 DrawMagicBallContentAreas();
11022 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
11023 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
11025 else if (properties_element == EL_EMC_ANDROID)
11026 DrawAndroidElementArea();
11027 else if (properties_element == EL_MM_GRAY_BALL)
11029 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
11030 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
11031 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
11032 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EXPLODE_MM_BALL);
11034 DrawMMBallContentArea();
11038 if (IS_PLAYER_ELEMENT(properties_element))
11040 int player_nr = GET_PLAYER_NR(properties_element);
11042 // these properties can be set for every player individually
11044 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
11046 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
11047 &level.start_element[player_nr];
11048 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
11049 &level.artwork_element[player_nr];
11050 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
11051 &level.explosion_element[player_nr];
11053 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
11054 &level.use_start_element[player_nr];
11055 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
11056 &level.use_artwork_element[player_nr];
11057 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
11058 &level.use_explosion_element[player_nr];
11059 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
11060 &level.initial_player_gravity[player_nr];
11062 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
11063 &level.initial_player_stepsize[player_nr];
11065 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
11066 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
11067 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
11068 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
11069 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
11070 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
11071 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
11072 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
11073 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
11074 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
11075 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
11076 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
11077 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
11078 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
11079 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
11081 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
11082 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
11083 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
11085 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
11087 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
11089 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
11090 &level.initial_inventory_content[player_nr][0];
11092 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
11093 &level.initial_inventory_size[player_nr];
11095 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
11096 &level.use_initial_inventory[player_nr];
11098 // draw checkbutton gadgets
11099 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
11100 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
11101 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
11103 // draw counter gadgets
11104 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
11106 // draw drawing area gadgets
11107 DrawPlayerInitialInventoryArea(properties_element);
11111 if (IS_BD_PLAYER_ELEMENT(properties_element))
11113 counterbutton_info[ED_COUNTER_ID_BD_PUSHING_PROB].y =
11114 ED_ELEMENT_SETTINGS_YPOS(2);
11115 counterbutton_info[ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET].y =
11116 ED_ELEMENT_SETTINGS_YPOS(3);
11117 checkbutton_info[ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET].y =
11118 ED_ELEMENT_SETTINGS_YPOS(4);
11120 // draw checkbutton gadgets
11121 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS);
11122 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_TOPMOST_PLAYER_ACTIVE);
11123 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET);
11125 // draw counter gadgets
11126 MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB);
11127 MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET);
11130 if (properties_element == EL_BD_ROCK && level.game_engine_type == GAME_ENGINE_TYPE_BD)
11132 counterbutton_info[ED_COUNTER_ID_BD_PUSHING_PROB].y =
11133 ED_ELEMENT_SETTINGS_YPOS(0);
11134 counterbutton_info[ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET].y =
11135 ED_ELEMENT_SETTINGS_YPOS(1);
11137 MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB);
11138 MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET);
11141 if (properties_element == EL_BD_MEGA_ROCK ||
11142 properties_element == EL_BD_SWEET)
11144 counterbutton_info[ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET].y =
11145 ED_ELEMENT_SETTINGS_YPOS(0);
11146 checkbutton_info[ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET].y =
11147 ED_ELEMENT_SETTINGS_YPOS(1);
11149 MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET);
11150 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET);
11153 if (properties_element == EL_BD_MAGIC_WALL)
11155 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_MAGIC_WALL_WAIT_HATCHING);
11156 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_MAGIC_WALL_STOPS_AMOEBA);
11159 // special case: slippery walls option for gems only available in R'n'D game engine
11160 if (IS_GEM(properties_element) && level.game_engine_type == GAME_ENGINE_TYPE_RND)
11161 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
11163 if (properties_element == EL_EM_DYNAMITE)
11164 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
11166 if (COULD_MOVE_INTO_ACID(properties_element) &&
11167 !IS_PLAYER_ELEMENT(properties_element) &&
11168 (!IS_CUSTOM_ELEMENT(properties_element) ||
11169 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
11171 // set position for checkbutton for "can move into acid"
11172 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
11173 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
11174 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
11175 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
11176 IS_BALLOON_ELEMENT(properties_element) ||
11177 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
11179 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
11182 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
11183 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
11185 if (properties_element == EL_SPRING ||
11186 properties_element == EL_SPRING_LEFT ||
11187 properties_element == EL_SPRING_RIGHT)
11188 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
11190 if (properties_element == EL_TIME_ORB_FULL)
11191 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
11193 if (properties_element == EL_GAME_OF_LIFE ||
11194 properties_element == EL_BIOMAZE)
11195 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
11197 if (CAN_GROW(properties_element))
11199 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
11200 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
11202 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
11205 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
11206 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
11208 if (properties_element == EL_SOKOBAN_OBJECT)
11209 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
11211 if (properties_element == EL_SOKOBAN_OBJECT ||
11212 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
11213 properties_element == EL_SOKOBAN_FIELD_FULL)
11215 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
11216 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
11219 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
11222 if (IS_BALLOON_ELEMENT(properties_element))
11223 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
11225 if (IS_ENVELOPE(properties_element) ||
11226 IS_MM_ENVELOPE(properties_element))
11228 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
11229 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
11230 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
11231 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
11232 int envelope_nr = ENVELOPE_NR(properties_element);
11234 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
11235 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
11237 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
11238 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
11240 // display counter to choose size of envelope text area
11241 MapCounterButtons(counter1_id);
11242 MapCounterButtons(counter2_id);
11244 // display checkbuttons to choose auto-wrap and alignment properties
11245 MapCheckbuttonGadget(button1_id);
11246 MapCheckbuttonGadget(button2_id);
11248 DrawEnvelopeTextArea(envelope_nr);
11251 if (IS_MM_MCDUFFIN(properties_element))
11253 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
11254 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
11255 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
11258 if (IS_DF_LASER(properties_element))
11260 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
11261 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
11262 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
11265 if (IS_CUSTOM_ELEMENT(properties_element))
11267 // draw stickybutton gadget
11268 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11270 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
11272 // draw checkbutton gadgets
11273 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
11274 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
11275 MapCheckbuttonGadget(i);
11277 // draw counter gadgets
11278 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
11279 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
11280 MapCounterButtons(i);
11282 // draw selectbox gadgets
11283 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
11284 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
11285 MapSelectboxGadget(i);
11287 // draw textbutton gadgets
11288 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11290 // draw text input gadgets
11291 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11293 // draw drawing area gadgets
11294 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11296 draw_footer_line = TRUE;
11298 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
11300 // draw checkbutton gadgets
11301 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
11302 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
11303 MapCheckbuttonGadget(i);
11305 // draw counter gadgets
11306 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
11307 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
11308 MapCounterButtons(i);
11310 // draw selectbox gadgets
11311 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
11312 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
11313 MapSelectboxGadget(i);
11315 // draw drawing area gadgets
11316 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
11317 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
11318 DrawCustomContentArea();
11321 else if (IS_GROUP_ELEMENT(properties_element))
11323 // draw stickybutton gadget
11324 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11326 // draw checkbutton gadgets
11327 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11328 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11330 // draw counter gadgets
11331 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
11333 // draw selectbox gadgets
11334 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
11336 // draw textbutton gadgets
11337 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11339 // draw drawing area gadgets
11340 DrawGroupElementArea();
11342 // draw text input gadgets
11343 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11345 // draw drawing area gadgets
11346 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11348 draw_footer_line = TRUE;
11350 else if (IS_EMPTY_ELEMENT(properties_element))
11352 // draw stickybutton gadget
11353 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11355 // draw checkbutton gadgets
11356 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11357 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11359 // draw textbutton gadgets
11360 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11362 // draw drawing area gadgets
11363 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11365 draw_footer_line = TRUE;
11368 // draw little footer border line above CE/GE use/save template gadgets
11369 if (draw_footer_line)
11371 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
11372 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
11373 int gd_x = gd->x + gd_gi1->border.width / 2;
11374 int gd_y = gd->y + gd_gi1->height - 1;
11375 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
11377 if (tab_color != BLACK_PIXEL) // black => transparent
11378 FillRectangle(drawto,
11379 SX + ED_ELEMENT_SETTINGS_X(0),
11380 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
11382 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
11386 static void DrawPropertiesChangeDrawingAreas(void)
11388 if (IS_CUSTOM_ELEMENT(properties_element))
11390 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
11391 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
11392 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
11394 DrawCustomChangeContentArea();
11397 redraw_mask |= REDRAW_FIELD;
11400 static void DrawPropertiesChange(void)
11404 // needed to initially set selectbox options for special action options
11405 setSelectboxSpecialActionOptions();
11407 // draw stickybutton gadget
11408 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11410 // draw checkbutton gadgets
11411 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
11412 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
11413 MapCheckbuttonGadget(i);
11415 // draw counter gadgets
11416 for (i = ED_COUNTER_ID_CHANGE_FIRST;
11417 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
11418 MapCounterButtons(i);
11420 // draw selectbox gadgets
11421 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
11422 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
11423 MapSelectboxGadget(i);
11425 // draw textbutton gadgets
11426 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
11427 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
11428 MapTextbuttonGadget(i);
11430 // draw graphicbutton gadgets
11431 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
11432 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
11433 MapGraphicbuttonGadget(i);
11435 // draw drawing area gadgets
11436 DrawPropertiesChangeDrawingAreas();
11439 static void DrawEditorElementAnimation(int x, int y)
11441 int graphic = el2img(properties_element);
11442 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
11443 custom_element.ce_value_fixed_initial :
11444 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
11445 custom_element.collect_score_initial : FrameCounter);
11447 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
11450 static void DrawEditorElementName(int x, int y, int font_nr)
11452 char *element_name = getElementInfoText(properties_element);
11453 int font_width = getFontWidth(font_nr);
11454 int font_height = getFontHeight(font_nr);
11455 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
11456 int max_chars_per_line = max_text_width / font_width;
11458 if (strlen(element_name) <= max_chars_per_line)
11459 DrawTextS(x, y, font_nr, element_name);
11462 char buffer[max_chars_per_line + 1];
11463 int next_pos = max_chars_per_line;
11465 strncpy(buffer, element_name, max_chars_per_line);
11466 buffer[max_chars_per_line] = '\0';
11468 if (element_name[max_chars_per_line] == ' ')
11474 for (i = max_chars_per_line - 1; i >= 0; i--)
11475 if (buffer[i] == ' ')
11478 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
11485 DrawTextS(x, y - font_height / 2, font_nr, buffer);
11487 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
11488 buffer[max_chars_per_line] = '\0';
11490 DrawTextS(x, y + font_height / 2, font_nr, buffer);
11494 static void DrawPropertiesWindow(void)
11496 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
11497 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
11498 int border_size = gd->border_size;
11499 int font_nr = FONT_TEXT_1;
11500 int font_height = getFontHeight(font_nr);
11501 int xoffset = TILEX + element_border + 3 * border_size;
11502 int yoffset = (TILEY - font_height) / 2;
11503 int x1 = editor.settings.element_graphic.x + element_border;
11504 int y1 = editor.settings.element_graphic.y + element_border;
11505 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
11506 editor.settings.element_name.x);
11507 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
11508 editor.settings.element_name.y);
11509 char *text = "Element Settings";
11510 int font2_nr = FONT_TITLE_1;
11511 struct MenuPosInfo *pos = &editor.settings.headline;
11512 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
11513 int sy = SY + pos->y;
11515 stick_element_properties_window = FALSE;
11517 // make sure that previous properties edit mode exists for this element
11518 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
11519 !IS_CUSTOM_ELEMENT(properties_element))
11520 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
11522 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
11523 !IS_PLAYER_ELEMENT(properties_element) &&
11524 !IS_CUSTOM_ELEMENT(properties_element))
11525 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
11527 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
11528 (IS_PLAYER_ELEMENT(properties_element) ||
11529 IS_CUSTOM_ELEMENT(properties_element)))
11530 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
11532 CopyElementPropertiesToEditor(properties_element);
11534 UnmapLevelEditorFieldGadgets();
11535 UnmapLevelEditorToolboxDrawingGadgets();
11536 UnmapLevelEditorToolboxCustomGadgets();
11538 MapLevelEditorToolboxCustomGadgetsIfNeeded();
11540 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11543 DrawText(sx, sy, text, font2_nr);
11545 FrameCounter = 0; // restart animation frame counter
11547 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
11548 DrawEditorElementAnimation(SX + x1, SY + y1);
11549 DrawEditorElementName(x2, y2, font_nr);
11551 DrawPropertiesTabulatorGadgets();
11553 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
11554 DrawPropertiesInfo();
11555 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
11556 DrawPropertiesChange();
11557 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
11558 DrawPropertiesConfig();
11561 static void DrawPaletteWindow(void)
11565 UnmapLevelEditorFieldGadgets();
11567 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11570 // map buttons to select elements
11571 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
11572 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
11573 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
11574 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
11575 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
11578 static void UpdateCustomElementGraphicGadgets(void)
11582 InitElementPropertiesGfxElement();
11584 ModifyEditorElementList();
11585 RedrawDrawingElements();
11587 // force redraw of all mapped drawing area gadgets
11588 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
11590 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
11597 static int getOpenDirectionFromTube(int element)
11601 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
11602 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
11603 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
11604 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
11605 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
11606 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
11607 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
11608 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
11609 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
11610 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
11611 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
11617 static int getTubeFromOpenDirection(int direction)
11621 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
11622 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
11623 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
11624 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
11625 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
11626 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
11627 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
11628 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
11629 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
11630 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
11631 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
11633 // if only one direction, fall back to simple tube with that direction
11634 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
11635 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
11636 case (MV_UP): return EL_TUBE_VERTICAL;
11637 case (MV_DOWN): return EL_TUBE_VERTICAL;
11643 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
11645 int element_new = getTubeFromOpenDirection(direction);
11647 return (element_new != EL_EMPTY ? element_new : element_old);
11650 static int getOpenDirectionFromBelt(int element)
11652 int belt_dir = getBeltDirFromBeltElement(element);
11654 return (belt_dir == MV_LEFT ? MV_RIGHT :
11655 belt_dir == MV_RIGHT ? MV_LEFT :
11656 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
11659 static int getBeltFromNrAndOpenDirection(int nr, int direction)
11661 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
11662 direction == MV_RIGHT ? MV_LEFT :
11663 direction == MV_HORIZONTAL ? MV_NONE : direction);
11665 if (direction == MV_NONE)
11668 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
11671 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
11674 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
11676 return (element_new != EL_EMPTY ? element_new : element_old);
11679 static int getOpenDirectionFromPool(int element)
11683 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
11684 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
11685 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
11686 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
11687 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
11688 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
11694 static int getPoolFromOpenDirection(int direction)
11698 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
11699 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
11700 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
11701 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
11702 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
11703 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
11709 static int getPoolFromOpenDirectionExt(int direction, int help_element)
11711 int element = getPoolFromOpenDirection(direction);
11712 int help_direction = getOpenDirectionFromPool(help_element);
11714 if (element == EL_EMPTY)
11716 int help_direction_vertical = help_direction & MV_VERTICAL;
11718 element = getPoolFromOpenDirection(direction | help_direction_vertical);
11721 if (element == EL_EMPTY)
11723 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
11725 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
11731 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
11733 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
11735 return (element_new != EL_EMPTY ? element_new : element_old);
11738 static int getOpenDirectionFromPillar(int element)
11742 case EL_EMC_WALL_1: return (MV_DOWN);
11743 case EL_EMC_WALL_2: return (MV_VERTICAL);
11744 case EL_EMC_WALL_3: return (MV_UP);
11750 static int getPillarFromOpenDirection(int direction)
11754 case (MV_DOWN): return EL_EMC_WALL_1;
11755 case (MV_VERTICAL): return EL_EMC_WALL_2;
11756 case (MV_UP): return EL_EMC_WALL_3;
11762 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
11764 int element_new = getPillarFromOpenDirection(direction);
11766 return (element_new != EL_EMPTY ? element_new : element_old);
11769 static int getOpenDirectionFromSteel2(int element)
11773 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
11774 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
11775 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
11776 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
11777 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
11778 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
11779 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
11780 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
11786 static int getSteel2FromOpenDirection(int direction)
11790 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
11791 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
11792 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
11793 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
11794 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
11795 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
11796 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
11797 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
11803 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
11805 int element_new = getSteel2FromOpenDirection(direction);
11807 return (element_new != EL_EMPTY ? element_new : element_old);
11810 static int getOpenDirectionFromChip(int element)
11814 case EL_SP_CHIP_SINGLE: return (MV_NONE);
11815 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
11816 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
11817 case EL_SP_CHIP_TOP: return (MV_DOWN);
11818 case EL_SP_CHIP_BOTTOM: return (MV_UP);
11824 static int getChipFromOpenDirection(int direction)
11828 case (MV_NONE): return EL_SP_CHIP_SINGLE;
11829 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
11830 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
11831 case (MV_UP): return EL_SP_CHIP_BOTTOM;
11832 case (MV_DOWN): return EL_SP_CHIP_TOP;
11838 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
11840 int element_new = getChipFromOpenDirection(direction);
11842 return (element_new != EL_EMPTY ? element_new : element_old);
11845 static int getClosedTube(int x, int y)
11847 struct XY *xy = xy_directions;
11848 int element_old = IntelliDrawBuffer[x][y];
11849 int direction_old = getOpenDirectionFromTube(element_old);
11850 int direction_new = MV_NONE;
11853 for (i = 0; i < NUM_DIRECTIONS; i++)
11855 int xx = x + xy[i].x;
11856 int yy = y + xy[i].y;
11857 int dir = MV_DIR_FROM_BIT(i);
11858 int dir_opposite = MV_DIR_OPPOSITE(dir);
11860 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
11861 (direction_old & dir) &&
11862 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11863 direction_new |= dir;
11866 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
11869 static int getClosedBelt(int x, int y)
11871 struct XY *xy = xy_directions;
11872 int element_old = IntelliDrawBuffer[x][y];
11873 int nr = getBeltNrFromBeltElement(element_old);
11874 int direction_old = getOpenDirectionFromBelt(element_old);
11875 int direction_new = MV_NONE;
11878 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11880 int xx = x + xy[i].x;
11881 int yy = y + xy[i].y;
11882 int dir = MV_DIR_FROM_BIT(i);
11883 int dir_opposite = MV_DIR_OPPOSITE(dir);
11885 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
11886 (direction_old & dir) &&
11887 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11888 direction_new |= dir;
11891 return getBeltFromNrAndOpenDirection(nr, direction_new);
11894 static int getClosedPool(int x, int y)
11896 struct XY *xy = xy_directions;
11897 int element_old = IntelliDrawBuffer[x][y];
11898 int direction_old = getOpenDirectionFromPool(element_old);
11899 int direction_new = MV_NONE;
11902 for (i = 0; i < NUM_DIRECTIONS; i++)
11904 int xx = x + xy[i].x;
11905 int yy = y + xy[i].y;
11906 int dir = MV_DIR_FROM_BIT(i);
11907 int dir_opposite = MV_DIR_OPPOSITE(dir);
11909 if (IN_LEV_FIELD(xx, yy) &&
11910 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
11911 (direction_old & dir) &&
11912 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11913 direction_new |= dir;
11916 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
11919 static int getClosedPillar(int x, int y)
11921 struct XY *xy = xy_directions;
11922 int element_old = IntelliDrawBuffer[x][y];
11923 int direction_old = getOpenDirectionFromPillar(element_old);
11924 int direction_new = MV_NONE;
11927 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11929 int xx = x + xy[i].x;
11930 int yy = y + xy[i].y;
11931 int dir = MV_DIR_FROM_BIT(i);
11932 int dir_opposite = MV_DIR_OPPOSITE(dir);
11934 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11935 (direction_old & dir) &&
11936 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11937 direction_new |= dir;
11940 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11943 static int getClosedSteel2(int x, int y)
11945 struct XY *xy = xy_directions;
11946 int element_old = IntelliDrawBuffer[x][y];
11947 int direction_old = getOpenDirectionFromSteel2(element_old);
11948 int direction_new = MV_NONE;
11951 for (i = 0; i < NUM_DIRECTIONS; i++)
11953 int xx = x + xy[i].x;
11954 int yy = y + xy[i].y;
11955 int dir = MV_DIR_FROM_BIT(i);
11956 int dir_opposite = MV_DIR_OPPOSITE(dir);
11958 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11959 (direction_old & dir) &&
11960 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11961 direction_new |= dir;
11964 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11967 static int getClosedChip(int x, int y)
11969 struct XY *xy = xy_directions;
11970 int element_old = IntelliDrawBuffer[x][y];
11971 int direction_old = getOpenDirectionFromChip(element_old);
11972 int direction_new = MV_NONE;
11975 for (i = 0; i < NUM_DIRECTIONS; i++)
11977 int xx = x + xy[i].x;
11978 int yy = y + xy[i].y;
11979 int dir = MV_DIR_FROM_BIT(i);
11980 int dir_opposite = MV_DIR_OPPOSITE(dir);
11982 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11983 (direction_old & dir) &&
11984 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11985 direction_new |= dir;
11988 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11991 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11992 boolean change_level)
11994 int sx = x - level_xpos;
11995 int sy = y - level_ypos;
11996 int old_element = Tile[x][y];
11997 int new_element = element;
11998 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11999 boolean draw_masked = FALSE;
12001 if (IS_MM_WALL_EDITOR(element))
12003 element = map_mm_wall_element_editor(element) | new_bitmask;
12005 if (IS_MM_WALL(old_element))
12006 element |= MM_WALL_BITS(old_element);
12009 draw_masked = TRUE;
12011 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
12013 int element_changed = old_element & ~new_bitmask;
12015 if (MM_WALL_BITS(element_changed) != 0)
12016 element = element_changed;
12019 IntelliDrawBuffer[x][y] = element;
12022 Tile[x][y] = element;
12024 if (IN_ED_FIELD(sx, sy))
12026 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
12027 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
12028 else if (draw_masked)
12029 DrawEditorElementThruMask(sx, sy, element);
12031 DrawEditorElement(sx, sy, element);
12035 static void SetElementSimple(int x, int y, int element, boolean change_level)
12037 SetElementSimpleExt(x, y, 0, 0, element, change_level);
12040 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
12041 int x2, int y2, int *element2,
12042 int (*close_function)(int, int),
12043 boolean change_level)
12045 // set neighbour elements to newly determined connections
12046 SetElementSimple(x1, y1, *element1, change_level);
12047 SetElementSimple(x2, y2, *element2, change_level);
12049 // remove all open connections of neighbour elements
12050 *element1 = close_function(x1, y1);
12051 *element2 = close_function(x2, y2);
12053 // set neighbour elements to new, minimized connections
12054 SetElementSimple(x1, y1, *element1, change_level);
12055 SetElementSimple(x2, y2, *element2, change_level);
12058 static void SetElementIntelliDraw(int x, int y, int dx, int dy, int new_element,
12059 boolean change_level, int button)
12061 struct XY *xy = xy_directions;
12062 static int last_x = -1;
12063 static int last_y = -1;
12065 if (new_element == EL_UNDEFINED)
12073 int old_element = IntelliDrawBuffer[x][y];
12075 if (IS_TUBE(new_element))
12077 int last_element_new = EL_UNDEFINED;
12078 int direction = MV_NONE;
12081 // if old element is of same kind, keep all existing directions
12082 if (IS_TUBE(old_element))
12083 direction |= getOpenDirectionFromTube(old_element);
12085 for (i = 0; i < NUM_DIRECTIONS; i++)
12087 int xx = x + xy[i].x;
12088 int yy = y + xy[i].y;
12090 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12091 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
12093 int dir = MV_DIR_FROM_BIT(i);
12094 int dir_opposite = MV_DIR_OPPOSITE(dir);
12095 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12096 int last_direction_old = getOpenDirectionFromTube(last_element_old);
12097 int last_direction_new = last_direction_old | dir_opposite;
12099 last_element_new = getTubeFromOpenDirection(last_direction_new);
12105 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
12107 if (last_element_new != EL_UNDEFINED)
12108 MergeAndCloseNeighbourElements(x, y, &new_element,
12109 last_x, last_y, &last_element_new,
12110 getClosedTube, change_level);
12112 else if (IS_BELT(new_element))
12114 int belt_nr = getBeltNrFromBeltElement(new_element);
12115 int last_element_new = EL_UNDEFINED;
12116 int direction = MV_NONE;
12119 // if old element is of same kind, keep all existing directions
12120 if (IS_BELT(old_element))
12121 direction |= getOpenDirectionFromBelt(old_element);
12123 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
12125 int xx = x + xy[i].x;
12126 int yy = y + xy[i].y;
12128 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12129 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
12131 int dir = MV_DIR_FROM_BIT(i);
12132 int dir_opposite = MV_DIR_OPPOSITE(dir);
12133 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12134 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
12135 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
12136 int last_direction_new = last_direction_old | dir_opposite;
12138 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
12139 last_direction_new);
12144 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
12146 if (last_element_new != EL_UNDEFINED)
12147 MergeAndCloseNeighbourElements(x, y, &new_element,
12148 last_x, last_y, &last_element_new,
12149 getClosedBelt, change_level);
12151 else if (IS_ACID_POOL_OR_ACID(new_element))
12153 int last_element_new = EL_UNDEFINED;
12154 int direction = MV_NONE;
12157 // if old element is of same kind, keep all existing directions
12158 if (IS_ACID_POOL_OR_ACID(old_element))
12159 direction |= getOpenDirectionFromPool(old_element);
12161 for (i = 0; i < NUM_DIRECTIONS; i++)
12163 int xx = x + xy[i].x;
12164 int yy = y + xy[i].y;
12166 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12167 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
12169 int dir = MV_DIR_FROM_BIT(i);
12170 int dir_opposite = MV_DIR_OPPOSITE(dir);
12171 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12172 int last_direction_old = getOpenDirectionFromPool(last_element_old);
12173 int last_direction_new = last_direction_old | dir_opposite;
12175 last_element_new = getPoolFromOpenDirection(last_direction_new);
12181 // special corrections needed for intuitively correct acid pool drawing
12182 if (last_element_new == EL_EMPTY)
12183 last_element_new = new_element;
12184 else if (last_element_new != EL_UNDEFINED)
12185 new_element = last_element_new;
12187 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
12189 if (last_element_new != EL_UNDEFINED)
12190 MergeAndCloseNeighbourElements(x, y, &new_element,
12191 last_x, last_y, &last_element_new,
12192 getClosedPool, change_level);
12194 else if (IS_EMC_PILLAR(new_element))
12196 int last_element_new = EL_UNDEFINED;
12197 int direction = MV_NONE;
12200 // if old element is of same kind, keep all existing directions
12201 if (IS_EMC_PILLAR(old_element))
12202 direction |= getOpenDirectionFromPillar(old_element);
12204 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
12206 int xx = x + xy[i].x;
12207 int yy = y + xy[i].y;
12209 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12210 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
12212 int dir = MV_DIR_FROM_BIT(i);
12213 int dir_opposite = MV_DIR_OPPOSITE(dir);
12214 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12215 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
12216 int last_direction_new = last_direction_old | dir_opposite;
12218 last_element_new = getPillarFromOpenDirection(last_direction_new);
12224 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
12226 if (last_element_new != EL_UNDEFINED)
12227 MergeAndCloseNeighbourElements(x, y, &new_element,
12228 last_x, last_y, &last_element_new,
12229 getClosedPillar, change_level);
12231 else if (IS_DC_STEELWALL_2(new_element))
12233 int last_element_new = EL_UNDEFINED;
12234 int direction = MV_NONE;
12237 // if old element is of same kind, keep all existing directions
12238 if (IS_DC_STEELWALL_2(old_element))
12239 direction |= getOpenDirectionFromSteel2(old_element);
12241 for (i = 0; i < NUM_DIRECTIONS; i++)
12243 int xx = x + xy[i].x;
12244 int yy = y + xy[i].y;
12246 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12247 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
12249 int dir = MV_DIR_FROM_BIT(i);
12250 int dir_opposite = MV_DIR_OPPOSITE(dir);
12251 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12252 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
12253 int last_direction_new = last_direction_old | dir_opposite;
12255 last_element_new = getSteel2FromOpenDirection(last_direction_new);
12261 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
12263 if (last_element_new != EL_UNDEFINED)
12264 MergeAndCloseNeighbourElements(x, y, &new_element,
12265 last_x, last_y, &last_element_new,
12266 getClosedSteel2, change_level);
12268 else if (IS_SP_CHIP(new_element))
12270 int last_element_new = EL_UNDEFINED;
12271 int direction = MV_NONE;
12274 // (do not keep existing directions, regardless of kind of old element)
12276 for (i = 0; i < NUM_DIRECTIONS; i++)
12278 int xx = x + xy[i].x;
12279 int yy = y + xy[i].y;
12281 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12282 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
12284 int dir = MV_DIR_FROM_BIT(i);
12285 int dir_opposite = MV_DIR_OPPOSITE(dir);
12286 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12287 int last_direction_old = getOpenDirectionFromChip(last_element_old);
12288 int last_direction_new = last_direction_old | dir_opposite;
12290 if (last_direction_old == MV_NONE)
12292 last_element_new = getChipFromOpenDirection(last_direction_new);
12295 else if (last_direction_old & (dir | dir_opposite))
12297 direction |= MV_DIR_OPPOSITE(last_direction_old);
12301 direction |= MV_DIR_OPPOSITE(dir);
12306 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
12308 if (last_element_new != EL_UNDEFINED)
12309 MergeAndCloseNeighbourElements(x, y, &new_element,
12310 last_x, last_y, &last_element_new,
12311 getClosedChip, change_level);
12313 else if (IS_SP_HARDWARE_BASE(new_element))
12315 int nr = GetSimpleRandom(6);
12317 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
12318 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
12319 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
12320 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
12321 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
12323 else if (new_element == EL_SP_HARDWARE_GREEN ||
12324 new_element == EL_SP_HARDWARE_BLUE ||
12325 new_element == EL_SP_HARDWARE_RED)
12327 int nr = GetSimpleRandom(3);
12329 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
12330 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
12332 else if (IS_GROUP_ELEMENT(new_element))
12334 boolean connected_drawing = FALSE;
12337 for (i = 0; i < NUM_DIRECTIONS; i++)
12339 int xx = x + xy[i].x;
12340 int yy = y + xy[i].y;
12342 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12343 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
12344 connected_drawing = TRUE;
12347 if (!connected_drawing)
12348 ResolveGroupElement(new_element);
12350 new_element = GetElementFromGroupElement(new_element);
12352 else if (IS_BELT_SWITCH(old_element))
12354 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
12355 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
12357 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
12358 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
12360 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
12364 static int swappable_elements[][2] =
12366 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
12367 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
12368 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
12369 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
12370 { EL_EMERALD, EL_WALL_EMERALD },
12371 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
12372 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
12373 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
12374 { EL_DIAMOND, EL_WALL_DIAMOND },
12375 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
12376 { EL_GATE_1, EL_GATE_1_GRAY },
12377 { EL_GATE_2, EL_GATE_2_GRAY },
12378 { EL_GATE_3, EL_GATE_3_GRAY },
12379 { EL_GATE_4, EL_GATE_4_GRAY },
12380 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
12381 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
12382 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
12383 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
12384 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
12385 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
12386 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
12387 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
12388 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
12389 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
12390 { EL_LAMP, EL_LAMP_ACTIVE },
12391 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
12392 { EL_SP_BASE, EL_SP_BUGGY_BASE },
12393 { EL_PEARL, EL_WALL_PEARL },
12394 { EL_CRYSTAL, EL_WALL_CRYSTAL },
12395 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
12396 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
12397 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
12398 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
12399 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
12400 { EL_LANDMINE, EL_DC_LANDMINE },
12401 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
12402 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
12403 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
12404 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
12405 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
12406 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
12407 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
12408 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
12409 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
12413 static int rotatable_elements_4[][4] =
12423 EL_SPACESHIP_RIGHT,
12428 EL_BD_BUTTERFLY_UP,
12429 EL_BD_BUTTERFLY_RIGHT,
12430 EL_BD_BUTTERFLY_DOWN,
12431 EL_BD_BUTTERFLY_LEFT
12435 EL_BD_FIREFLY_RIGHT,
12436 EL_BD_FIREFLY_DOWN,
12464 EL_SP_GRAVITY_PORT_UP,
12465 EL_SP_GRAVITY_PORT_RIGHT,
12466 EL_SP_GRAVITY_PORT_DOWN,
12467 EL_SP_GRAVITY_PORT_LEFT
12470 EL_SP_GRAVITY_ON_PORT_UP,
12471 EL_SP_GRAVITY_ON_PORT_RIGHT,
12472 EL_SP_GRAVITY_ON_PORT_DOWN,
12473 EL_SP_GRAVITY_ON_PORT_LEFT
12476 EL_SP_GRAVITY_OFF_PORT_UP,
12477 EL_SP_GRAVITY_OFF_PORT_RIGHT,
12478 EL_SP_GRAVITY_OFF_PORT_DOWN,
12479 EL_SP_GRAVITY_OFF_PORT_LEFT
12488 EL_BALLOON_SWITCH_UP,
12489 EL_BALLOON_SWITCH_RIGHT,
12490 EL_BALLOON_SWITCH_DOWN,
12491 EL_BALLOON_SWITCH_LEFT
12495 EL_MM_MCDUFFIN_RIGHT,
12496 EL_MM_MCDUFFIN_DOWN,
12497 EL_MM_MCDUFFIN_LEFT
12500 EL_MM_MIRROR_FIXED_1,
12501 EL_MM_MIRROR_FIXED_4,
12502 EL_MM_MIRROR_FIXED_3,
12503 EL_MM_MIRROR_FIXED_2
12506 EL_MM_STEEL_GRID_FIXED_1,
12507 EL_MM_STEEL_GRID_FIXED_4,
12508 EL_MM_STEEL_GRID_FIXED_2,
12509 EL_MM_STEEL_GRID_FIXED_3
12512 EL_MM_WOODEN_GRID_FIXED_1,
12513 EL_MM_WOODEN_GRID_FIXED_4,
12514 EL_MM_WOODEN_GRID_FIXED_2,
12515 EL_MM_WOODEN_GRID_FIXED_3
12518 EL_MM_POLARIZER_CROSS_1,
12519 EL_MM_POLARIZER_CROSS_4,
12520 EL_MM_POLARIZER_CROSS_3,
12521 EL_MM_POLARIZER_CROSS_2
12525 EL_MM_PACMAN_RIGHT,
12537 EL_DF_RECEIVER_RIGHT,
12538 EL_DF_RECEIVER_DOWN,
12539 EL_DF_RECEIVER_LEFT
12552 static int rotatable_elements_8[][8] =
12555 EL_DF_STEEL_GRID_FIXED_1,
12556 EL_DF_STEEL_GRID_FIXED_8,
12557 EL_DF_STEEL_GRID_FIXED_7,
12558 EL_DF_STEEL_GRID_FIXED_6,
12559 EL_DF_STEEL_GRID_FIXED_5,
12560 EL_DF_STEEL_GRID_FIXED_4,
12561 EL_DF_STEEL_GRID_FIXED_3,
12562 EL_DF_STEEL_GRID_FIXED_2
12565 EL_DF_WOODEN_GRID_FIXED_1,
12566 EL_DF_WOODEN_GRID_FIXED_8,
12567 EL_DF_WOODEN_GRID_FIXED_7,
12568 EL_DF_WOODEN_GRID_FIXED_6,
12569 EL_DF_WOODEN_GRID_FIXED_5,
12570 EL_DF_WOODEN_GRID_FIXED_4,
12571 EL_DF_WOODEN_GRID_FIXED_3,
12572 EL_DF_WOODEN_GRID_FIXED_2
12575 EL_DF_STEEL_GRID_ROTATING_1,
12576 EL_DF_STEEL_GRID_ROTATING_8,
12577 EL_DF_STEEL_GRID_ROTATING_7,
12578 EL_DF_STEEL_GRID_ROTATING_6,
12579 EL_DF_STEEL_GRID_ROTATING_5,
12580 EL_DF_STEEL_GRID_ROTATING_4,
12581 EL_DF_STEEL_GRID_ROTATING_3,
12582 EL_DF_STEEL_GRID_ROTATING_2
12585 EL_DF_WOODEN_GRID_ROTATING_1,
12586 EL_DF_WOODEN_GRID_ROTATING_8,
12587 EL_DF_WOODEN_GRID_ROTATING_7,
12588 EL_DF_WOODEN_GRID_ROTATING_6,
12589 EL_DF_WOODEN_GRID_ROTATING_5,
12590 EL_DF_WOODEN_GRID_ROTATING_4,
12591 EL_DF_WOODEN_GRID_ROTATING_3,
12592 EL_DF_WOODEN_GRID_ROTATING_2
12599 static int rotatable_elements_16[][16] =
12620 EL_MM_TELEPORTER_5,
12621 EL_MM_TELEPORTER_4,
12622 EL_MM_TELEPORTER_3,
12623 EL_MM_TELEPORTER_2,
12624 EL_MM_TELEPORTER_1,
12625 EL_MM_TELEPORTER_16,
12626 EL_MM_TELEPORTER_15,
12627 EL_MM_TELEPORTER_14,
12628 EL_MM_TELEPORTER_13,
12629 EL_MM_TELEPORTER_12,
12630 EL_MM_TELEPORTER_11,
12631 EL_MM_TELEPORTER_10,
12632 EL_MM_TELEPORTER_9,
12633 EL_MM_TELEPORTER_8,
12634 EL_MM_TELEPORTER_7,
12638 EL_MM_TELEPORTER_RED_5,
12639 EL_MM_TELEPORTER_RED_4,
12640 EL_MM_TELEPORTER_RED_3,
12641 EL_MM_TELEPORTER_RED_2,
12642 EL_MM_TELEPORTER_RED_1,
12643 EL_MM_TELEPORTER_RED_16,
12644 EL_MM_TELEPORTER_RED_15,
12645 EL_MM_TELEPORTER_RED_14,
12646 EL_MM_TELEPORTER_RED_13,
12647 EL_MM_TELEPORTER_RED_12,
12648 EL_MM_TELEPORTER_RED_11,
12649 EL_MM_TELEPORTER_RED_10,
12650 EL_MM_TELEPORTER_RED_9,
12651 EL_MM_TELEPORTER_RED_8,
12652 EL_MM_TELEPORTER_RED_7,
12653 EL_MM_TELEPORTER_RED_6
12656 EL_MM_TELEPORTER_YELLOW_5,
12657 EL_MM_TELEPORTER_YELLOW_4,
12658 EL_MM_TELEPORTER_YELLOW_3,
12659 EL_MM_TELEPORTER_YELLOW_2,
12660 EL_MM_TELEPORTER_YELLOW_1,
12661 EL_MM_TELEPORTER_YELLOW_16,
12662 EL_MM_TELEPORTER_YELLOW_15,
12663 EL_MM_TELEPORTER_YELLOW_14,
12664 EL_MM_TELEPORTER_YELLOW_13,
12665 EL_MM_TELEPORTER_YELLOW_12,
12666 EL_MM_TELEPORTER_YELLOW_11,
12667 EL_MM_TELEPORTER_YELLOW_10,
12668 EL_MM_TELEPORTER_YELLOW_9,
12669 EL_MM_TELEPORTER_YELLOW_8,
12670 EL_MM_TELEPORTER_YELLOW_7,
12671 EL_MM_TELEPORTER_YELLOW_6
12674 EL_MM_TELEPORTER_GREEN_5,
12675 EL_MM_TELEPORTER_GREEN_4,
12676 EL_MM_TELEPORTER_GREEN_3,
12677 EL_MM_TELEPORTER_GREEN_2,
12678 EL_MM_TELEPORTER_GREEN_1,
12679 EL_MM_TELEPORTER_GREEN_16,
12680 EL_MM_TELEPORTER_GREEN_15,
12681 EL_MM_TELEPORTER_GREEN_14,
12682 EL_MM_TELEPORTER_GREEN_13,
12683 EL_MM_TELEPORTER_GREEN_12,
12684 EL_MM_TELEPORTER_GREEN_11,
12685 EL_MM_TELEPORTER_GREEN_10,
12686 EL_MM_TELEPORTER_GREEN_9,
12687 EL_MM_TELEPORTER_GREEN_8,
12688 EL_MM_TELEPORTER_GREEN_7,
12689 EL_MM_TELEPORTER_GREEN_6
12692 EL_MM_TELEPORTER_BLUE_5,
12693 EL_MM_TELEPORTER_BLUE_4,
12694 EL_MM_TELEPORTER_BLUE_3,
12695 EL_MM_TELEPORTER_BLUE_2,
12696 EL_MM_TELEPORTER_BLUE_1,
12697 EL_MM_TELEPORTER_BLUE_16,
12698 EL_MM_TELEPORTER_BLUE_15,
12699 EL_MM_TELEPORTER_BLUE_14,
12700 EL_MM_TELEPORTER_BLUE_13,
12701 EL_MM_TELEPORTER_BLUE_12,
12702 EL_MM_TELEPORTER_BLUE_11,
12703 EL_MM_TELEPORTER_BLUE_10,
12704 EL_MM_TELEPORTER_BLUE_9,
12705 EL_MM_TELEPORTER_BLUE_8,
12706 EL_MM_TELEPORTER_BLUE_7,
12707 EL_MM_TELEPORTER_BLUE_6
12711 EL_MM_POLARIZER_16,
12712 EL_MM_POLARIZER_15,
12713 EL_MM_POLARIZER_14,
12714 EL_MM_POLARIZER_13,
12715 EL_MM_POLARIZER_12,
12716 EL_MM_POLARIZER_11,
12717 EL_MM_POLARIZER_10,
12746 EL_DF_MIRROR_ROTATING_1,
12747 EL_DF_MIRROR_ROTATING_16,
12748 EL_DF_MIRROR_ROTATING_15,
12749 EL_DF_MIRROR_ROTATING_14,
12750 EL_DF_MIRROR_ROTATING_13,
12751 EL_DF_MIRROR_ROTATING_12,
12752 EL_DF_MIRROR_ROTATING_11,
12753 EL_DF_MIRROR_ROTATING_10,
12754 EL_DF_MIRROR_ROTATING_9,
12755 EL_DF_MIRROR_ROTATING_8,
12756 EL_DF_MIRROR_ROTATING_7,
12757 EL_DF_MIRROR_ROTATING_6,
12758 EL_DF_MIRROR_ROTATING_5,
12759 EL_DF_MIRROR_ROTATING_4,
12760 EL_DF_MIRROR_ROTATING_3,
12761 EL_DF_MIRROR_ROTATING_2
12764 EL_DF_MIRROR_FIXED_1,
12765 EL_DF_MIRROR_FIXED_16,
12766 EL_DF_MIRROR_FIXED_15,
12767 EL_DF_MIRROR_FIXED_14,
12768 EL_DF_MIRROR_FIXED_13,
12769 EL_DF_MIRROR_FIXED_12,
12770 EL_DF_MIRROR_FIXED_11,
12771 EL_DF_MIRROR_FIXED_10,
12772 EL_DF_MIRROR_FIXED_9,
12773 EL_DF_MIRROR_FIXED_8,
12774 EL_DF_MIRROR_FIXED_7,
12775 EL_DF_MIRROR_FIXED_6,
12776 EL_DF_MIRROR_FIXED_5,
12777 EL_DF_MIRROR_FIXED_4,
12778 EL_DF_MIRROR_FIXED_3,
12779 EL_DF_MIRROR_FIXED_2
12788 for (i = 0; swappable_elements[i][0] != -1; i++)
12790 int element1 = swappable_elements[i][0];
12791 int element2 = swappable_elements[i][1];
12793 if (old_element == element1 || old_element == element2)
12794 new_element = (old_element == element1 ? element2 : element1);
12797 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
12799 for (j = 0; j < 4; j++)
12801 int element = rotatable_elements_4[i][j];
12803 if (old_element == element)
12804 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
12805 button == 2 ? rotatable_elements_4[i][0] :
12806 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
12811 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
12813 for (j = 0; j < 8; j++)
12815 int element = rotatable_elements_8[i][j];
12817 if (old_element == element)
12818 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
12819 button == 2 ? rotatable_elements_8[i][0] :
12820 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
12825 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
12827 for (j = 0; j < 16; j++)
12829 int element = rotatable_elements_16[i][j];
12831 if (old_element == element)
12832 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
12833 button == 2 ? rotatable_elements_16[i][0] :
12834 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
12839 if (old_element != new_element)
12841 int max_infotext_len = getMaxInfoTextLength();
12842 char infotext[MAX_OUTPUT_LINESIZE + 1];
12844 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
12845 infotext[max_infotext_len] = '\0';
12847 ClearEditorGadgetInfoText();
12849 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
12854 if (IS_MM_WALL_EDITOR(new_element))
12855 SetElementSimpleExt(x, y, dx, dy, new_element, change_level);
12857 SetElementSimple(x, y, new_element, change_level);
12863 static void ResetIntelliDraw(void)
12867 for (x = 0; x < lev_fieldx; x++)
12868 for (y = 0; y < lev_fieldy; y++)
12869 IntelliDrawBuffer[x][y] = Tile[x][y];
12871 SetElementIntelliDraw(-1, -1, -1, -1, EL_UNDEFINED, FALSE, -1);
12874 static boolean draw_mode_hires = FALSE;
12876 static boolean isHiresTileElement(int element)
12878 return (IS_MM_WALL(element) || element == EL_EMPTY);
12881 static boolean isHiresDrawElement(int element)
12883 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
12886 static int numHiresTiles(int element)
12888 if (IS_MM_WALL(element))
12889 return get_number_of_bits(MM_WALL_BITS(element));
12894 static void SetDrawModeHiRes(int element)
12897 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12898 isHiresDrawElement(element));
12901 static boolean getDrawModeHiRes(void)
12903 return draw_mode_hires;
12906 static int getLoResScreenPos(int pos)
12908 return (getDrawModeHiRes() ? pos / 2 : pos);
12911 static int getLoResScreenMod(int pos)
12913 return (getDrawModeHiRes() ? pos % 2 : 0);
12916 static void SetElementExt(int x, int y, int dx, int dy, int element,
12917 boolean change_level, int button)
12920 SetElementSimple(x, y, Tile[x][y], change_level);
12921 else if (GetKeyModState() & KMOD_Shift)
12922 SetElementIntelliDraw(x, y, dx, dy, element, change_level, button);
12924 SetElementSimpleExt(x, y, dx, dy, element, change_level);
12927 static void SetElement(int x, int y, int element)
12929 SetElementExt(x, y, 0, 0, element, TRUE, -1);
12932 static void SetElementButton(int x, int y, int dx, int dy, int element,
12935 SetElementExt(x, y, dx, dy, element, TRUE, button);
12938 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
12940 int lx = getLoResScreenPos(sx2) + level_xpos;
12941 int ly = getLoResScreenPos(sy2) + level_ypos;
12942 int dx = getLoResScreenMod(sx2);
12943 int dy = getLoResScreenMod(sy2);
12945 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
12948 static void SetLevelElementHiRes(int lx2, int ly2, int element)
12955 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
12958 static int getLevelElementHiRes(int lx2, int ly2)
12964 int element = Tile[lx][ly];
12965 unsigned int bitmask = (dx + 1) << (dy * 2);
12967 if (IS_MM_WALL(element))
12969 if (element & bitmask)
12970 return map_mm_wall_element(element);
12978 static void DrawLineElement(int x, int y, int element, boolean change_level)
12980 SetElementHiRes(x, y, element, change_level);
12983 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12984 int element, boolean change_level)
12986 int xsize = ABS(to_x - from_x);
12987 int ysize = ABS(to_y - from_y);
12988 int dx = (to_x < from_x ? -1 : +1);
12989 int dy = (to_y < from_y ? -1 : +1);
12992 if (from_y == to_y) // horizontal line
12994 for (i = 0; i <= xsize; i++)
12995 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12997 else if (from_x == to_x) // vertical line
12999 for (i = 0; i <= ysize; i++)
13000 DrawLineElement(from_x, from_y + i * dy, element, change_level);
13002 else // diagonal line
13004 if (ysize < xsize) // a < 1
13006 float a = (float)ysize / (float)xsize;
13008 for (i = 0; i <= xsize; i++)
13011 int y = dy * (int)(a * i + 0.5);
13013 DrawLineElement(from_x + x, from_y + y, element, change_level);
13018 float a = (float)xsize / (float)ysize;
13020 for (i = 0; i <= ysize; i++)
13022 int x = dx * (int)(a * i + 0.5);
13025 DrawLineElement(from_x + x, from_y + y, element, change_level);
13031 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
13032 int element, boolean change_level)
13034 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
13035 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
13036 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
13037 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
13040 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
13041 int element, boolean change_level)
13046 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
13048 for (y = from_y; y <= to_y; y++)
13049 DrawLine(from_x, y, to_x, y, element, change_level);
13052 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
13053 int element, boolean change_level)
13055 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
13056 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
13057 int len_x = ABS(to_x - from_x);
13058 int len_y = ABS(to_y - from_y);
13061 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
13063 // not optimal (some points get drawn twice) but simple,
13064 // and fast enough for the few points we are drawing
13066 for (x = 0; x <= radius; x++)
13068 int sx, sy, sx2, sy2, lx, ly;
13070 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
13072 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
13073 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
13074 sx = getLoResScreenPos(sx2);
13075 sy = getLoResScreenPos(sy2);
13076 lx = sx + level_xpos;
13077 ly = sy + level_ypos;
13079 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13080 DrawLineElement(sx2, sy2, element, change_level);
13083 for (y = 0; y <= radius; y++)
13085 int sx, sy, sx2, sy2, lx, ly;
13087 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
13089 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
13090 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
13091 sx = getLoResScreenPos(sx2);
13092 sy = getLoResScreenPos(sy2);
13093 lx = sx + level_xpos;
13094 ly = sy + level_ypos;
13096 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13097 DrawLineElement(sx2, sy2, element, change_level);
13101 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
13102 int element, boolean change_level)
13104 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
13105 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
13107 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
13110 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
13112 #if DRAW_CIRCLES_BUTTON_AVAILABLE
13113 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
13114 int element, boolean change_level)
13116 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
13117 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
13118 int mirror_to_x2 = from_x - (to_x2 - from_x);
13119 int mirror_to_y2 = from_y - (to_y2 - from_y);
13121 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
13122 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
13123 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
13124 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element, change_level);
13128 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
13130 int from_sx, from_sy;
13134 swap_numbers(&from_x, &to_x);
13137 swap_numbers(&from_y, &to_y);
13139 from_sx = SX + from_x * ed_tilesize;
13140 from_sy = SY + from_y * ed_tilesize;
13141 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
13142 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
13144 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13145 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13146 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13147 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13149 if (from_x == to_x && from_y == to_y)
13150 MarkTileDirty(from_x/2, from_y/2);
13152 redraw_mask |= REDRAW_FIELD;
13155 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
13156 int element, boolean change_level)
13158 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
13161 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
13162 int element, boolean change_level)
13164 if (element == -1 || change_level)
13165 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
13167 DrawAreaBorder(from_x, from_y, to_x, to_y);
13170 // values for CopyBrushExt()
13171 #define CB_AREA_TO_BRUSH 0
13172 #define CB_BRUSH_TO_CURSOR 1
13173 #define CB_BRUSH_TO_LEVEL 2
13174 #define CB_DELETE_OLD_CURSOR 3
13175 #define CB_DUMP_BRUSH 4
13176 #define CB_DUMP_BRUSH_SMALL 5
13177 #define CB_CLIPBOARD_TO_BRUSH 6
13178 #define CB_BRUSH_TO_CLIPBOARD 7
13179 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
13180 #define CB_UPDATE_BRUSH_POSITION 9
13181 #define CB_FLIP_BRUSH_X 10
13182 #define CB_FLIP_BRUSH_Y 11
13183 #define CB_FLIP_BRUSH_XY 12
13185 #define MAX_CB_PART_SIZE 10
13186 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
13187 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
13188 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
13189 MAX_CB_NUM_LINES * \
13192 static int getFlippedTileExt(int map[], int element)
13196 for (i = 0; map[i] != -1; i++)
13197 if (map[i] == element)
13198 return map[i ^ 1]; // get flipped element by flipping LSB of index
13203 static int getFlippedTileX(int element)
13207 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_RIGHT,
13208 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_RIGHT,
13209 EL_BUG_LEFT, EL_BUG_RIGHT,
13210 EL_SPACESHIP_LEFT, EL_SPACESHIP_RIGHT,
13211 EL_PACMAN_LEFT, EL_PACMAN_RIGHT,
13212 EL_ARROW_LEFT, EL_ARROW_RIGHT,
13213 EL_MOLE_LEFT, EL_MOLE_RIGHT,
13214 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_RIGHT,
13215 EL_YAMYAM_LEFT, EL_YAMYAM_RIGHT,
13216 EL_SP_PORT_LEFT, EL_SP_PORT_RIGHT,
13217 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_RIGHT,
13218 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_RIGHT,
13219 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_RIGHT,
13220 EL_CONVEYOR_BELT_1_LEFT, EL_CONVEYOR_BELT_1_RIGHT,
13221 EL_CONVEYOR_BELT_2_LEFT, EL_CONVEYOR_BELT_2_RIGHT,
13222 EL_CONVEYOR_BELT_3_LEFT, EL_CONVEYOR_BELT_3_RIGHT,
13223 EL_CONVEYOR_BELT_4_LEFT, EL_CONVEYOR_BELT_4_RIGHT,
13224 EL_SPRING_LEFT, EL_SPRING_RIGHT,
13225 EL_SP_CHIP_LEFT, EL_SP_CHIP_RIGHT,
13226 EL_TUBE_VERTICAL_LEFT, EL_TUBE_VERTICAL_RIGHT,
13227 EL_TUBE_LEFT_UP, EL_TUBE_RIGHT_UP,
13228 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_DOWN,
13229 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_RIGHT,
13230 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_TOPRIGHT,
13231 EL_DC_STEELWALL_1_BOTTOMLEFT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13232 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_TOPRIGHT_2,
13233 EL_DC_STEELWALL_1_BOTTOMLEFT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13234 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_RIGHT,
13235 EL_ACID_POOL_TOPLEFT, EL_ACID_POOL_TOPRIGHT,
13236 EL_ACID_POOL_BOTTOMLEFT, EL_ACID_POOL_BOTTOMRIGHT,
13241 return getFlippedTileExt(map, element);
13244 static int getFlippedTileY(int element)
13248 EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY_DOWN,
13249 EL_BD_FIREFLY_UP, EL_BD_FIREFLY_DOWN,
13250 EL_BUG_UP, EL_BUG_DOWN,
13251 EL_SPACESHIP_UP, EL_SPACESHIP_DOWN,
13252 EL_PACMAN_UP, EL_PACMAN_DOWN,
13253 EL_ARROW_UP, EL_ARROW_DOWN,
13254 EL_MOLE_UP, EL_MOLE_DOWN,
13255 EL_BALLOON_SWITCH_UP, EL_BALLOON_SWITCH_DOWN,
13256 EL_YAMYAM_UP, EL_YAMYAM_DOWN,
13257 EL_SP_PORT_UP, EL_SP_PORT_DOWN,
13258 EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN,
13259 EL_SP_GRAVITY_ON_PORT_UP, EL_SP_GRAVITY_ON_PORT_DOWN,
13260 EL_SP_GRAVITY_OFF_PORT_UP, EL_SP_GRAVITY_OFF_PORT_DOWN,
13261 EL_SP_CHIP_TOP, EL_SP_CHIP_BOTTOM,
13262 EL_TUBE_HORIZONTAL_UP, EL_TUBE_HORIZONTAL_DOWN,
13263 EL_TUBE_LEFT_UP, EL_TUBE_LEFT_DOWN,
13264 EL_TUBE_RIGHT_UP, EL_TUBE_RIGHT_DOWN,
13265 EL_DC_STEELWALL_1_TOP, EL_DC_STEELWALL_1_BOTTOM,
13266 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13267 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13268 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13269 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13270 EL_DC_STEELWALL_2_TOP, EL_DC_STEELWALL_2_BOTTOM,
13271 EL_EMC_WALL_1, EL_EMC_WALL_3,
13276 return getFlippedTileExt(map, element);
13279 static int getFlippedTileXY(int element)
13283 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_UP,
13284 EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY_DOWN,
13285 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_UP,
13286 EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY_DOWN,
13287 EL_BUG_LEFT, EL_BUG_UP,
13288 EL_BUG_RIGHT, EL_BUG_DOWN,
13289 EL_SPACESHIP_LEFT, EL_SPACESHIP_UP,
13290 EL_SPACESHIP_RIGHT, EL_SPACESHIP_DOWN,
13291 EL_PACMAN_LEFT, EL_PACMAN_UP,
13292 EL_PACMAN_RIGHT, EL_PACMAN_DOWN,
13293 EL_ARROW_LEFT, EL_ARROW_UP,
13294 EL_ARROW_RIGHT, EL_ARROW_DOWN,
13295 EL_MOLE_LEFT, EL_MOLE_UP,
13296 EL_MOLE_RIGHT, EL_MOLE_DOWN,
13297 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_UP,
13298 EL_BALLOON_SWITCH_RIGHT, EL_BALLOON_SWITCH_DOWN,
13299 EL_YAMYAM_LEFT, EL_YAMYAM_UP,
13300 EL_YAMYAM_RIGHT, EL_YAMYAM_DOWN,
13301 EL_SP_PORT_LEFT, EL_SP_PORT_UP,
13302 EL_SP_PORT_RIGHT, EL_SP_PORT_DOWN,
13303 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_UP,
13304 EL_SP_GRAVITY_PORT_RIGHT, EL_SP_GRAVITY_PORT_DOWN,
13305 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_UP,
13306 EL_SP_GRAVITY_ON_PORT_RIGHT, EL_SP_GRAVITY_ON_PORT_DOWN,
13307 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_UP,
13308 EL_SP_GRAVITY_OFF_PORT_RIGHT, EL_SP_GRAVITY_OFF_PORT_DOWN,
13309 EL_SP_CHIP_LEFT, EL_SP_CHIP_TOP,
13310 EL_SP_CHIP_RIGHT, EL_SP_CHIP_BOTTOM,
13311 EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL,
13312 EL_TUBE_VERTICAL_LEFT, EL_TUBE_HORIZONTAL_UP,
13313 EL_TUBE_VERTICAL_RIGHT, EL_TUBE_HORIZONTAL_DOWN,
13314 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_UP,
13315 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_TOP,
13316 EL_DC_STEELWALL_1_RIGHT, EL_DC_STEELWALL_1_BOTTOM,
13317 EL_DC_STEELWALL_1_HORIZONTAL, EL_DC_STEELWALL_1_VERTICAL,
13318 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13319 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13320 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_TOP,
13321 EL_DC_STEELWALL_2_RIGHT, EL_DC_STEELWALL_2_BOTTOM,
13322 EL_DC_STEELWALL_2_HORIZONTAL, EL_DC_STEELWALL_2_VERTICAL,
13323 EL_EXPANDABLE_WALL_HORIZONTAL, EL_EXPANDABLE_WALL_VERTICAL,
13324 EL_EXPANDABLE_STEELWALL_HORIZONTAL, EL_EXPANDABLE_STEELWALL_VERTICAL,
13329 return getFlippedTileExt(map, element);
13332 static int getFlippedTile(int element, int mode)
13334 if (IS_MM_ELEMENT(element))
13336 // get MM game element
13337 element = map_element_RND_to_MM(element);
13339 // get flipped game element
13340 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX_MM(element) :
13341 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY_MM(element) :
13342 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY_MM(element) :
13345 // get RND game element again
13346 element = map_element_MM_to_RND(element);
13350 // get flipped game element
13351 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX(element) :
13352 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY(element) :
13353 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY(element) :
13360 static void SwapFlippedTiles(short *tile1, short *tile2, int mode)
13363 short tile1_flipped = getFlippedTile(*tile1, mode);
13364 short tile2_flipped = getFlippedTile(*tile2, mode);
13367 *tile1 = tile2_flipped;
13368 *tile2 = tile1_flipped;
13371 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
13373 DrawLineElement(sx, sy, element, change_level);
13376 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
13377 int button, int mode)
13379 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13380 static int brush_width, brush_height;
13381 static int last_cursor_x = -1, last_cursor_y = -1;
13382 static boolean delete_old_brush = FALSE;
13383 int new_element = BUTTON_ELEMENT(button);
13386 if (mode == CB_DUMP_BRUSH ||
13387 mode == CB_DUMP_BRUSH_SMALL ||
13388 mode == CB_BRUSH_TO_CLIPBOARD ||
13389 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13391 if (edit_mode != ED_MODE_DRAWING)
13394 char part[MAX_CB_PART_SIZE + 1] = "";
13395 char text[MAX_CB_TEXT_SIZE + 1] = "";
13396 int width = (draw_with_brush ? brush_width : lev_fieldx);
13397 int height = (draw_with_brush ? brush_height : lev_fieldy);
13398 char *format = "%s%03d";
13400 for (y = 0; y < height; y++)
13401 for (x = 0; x < width; x++)
13402 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
13405 for (y = 0; y < height; y++)
13407 for (x = 0; x < width; x++)
13409 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
13410 char *prefix = (mode == CB_DUMP_BRUSH ||
13411 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
13413 if (element >= NUM_FILE_ELEMENTS)
13414 element = EL_UNKNOWN;
13416 // copy brush to level sketch text buffer for the R'n'D forum:
13417 // - large tiles: `xxx or `xxxx (0x60 ASCII)
13418 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
13419 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
13420 strcat(text, part);
13423 strcat(text, "\n");
13426 if (mode == CB_BRUSH_TO_CLIPBOARD ||
13427 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13428 SDL_SetClipboardText(text);
13430 Print("%s", text); // print brush data to console and log file
13435 if (mode == CB_CLIPBOARD_TO_BRUSH)
13437 if (edit_mode != ED_MODE_DRAWING)
13440 if (!SDL_HasClipboardText())
13442 Request("Clipboard is empty!", REQ_CONFIRM);
13447 boolean copy_to_brush = (draw_with_brush ||
13448 drawing_function == GADGET_ID_GRAB_BRUSH);
13450 // this will delete the old brush, if already drawing with a brush
13452 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
13454 // initialization is required for "odd" (incomplete) clipboard content
13455 for (x = 0; x < MAX_LEV_FIELDX; x++)
13456 for (y = 0; y < MAX_LEV_FIELDY; y++)
13457 brush_buffer[x][y] = EL_EMPTY;
13464 char *clipboard_text = SDL_GetClipboardText();
13465 char *ptr = clipboard_text;
13466 boolean allow_new_row = FALSE;
13467 boolean stop = FALSE;
13469 while (*ptr && !stop)
13471 boolean prefix_found = FALSE;
13472 boolean start_new_row = FALSE;
13474 // level sketch element number prefixes (may be multi-byte characters)
13475 char *prefix_list[] = { "`", "¸" };
13478 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
13480 char *prefix = prefix_list[i];
13482 // check if string is large enough for prefix
13483 if (strlen(ptr) < strlen(prefix))
13490 // check if string starts with prefix
13491 if (strPrefix(ptr, prefix))
13493 ptr += strlen(prefix);
13495 prefix_found = TRUE;
13501 // check if prefix found and followed by (at least) three digits
13502 if (prefix_found &&
13503 strlen(ptr) >= 3 &&
13504 ptr[0] >= '0' && ptr[0] <= '9' &&
13505 ptr[1] >= '0' && ptr[1] <= '9' &&
13506 ptr[2] >= '0' && ptr[2] <= '9')
13508 int element = ((ptr[0] - '0') * 100 +
13509 (ptr[1] - '0') * 10 +
13514 // level sketch element number might consist of four digits
13515 if (ptr[0] >= '0' && ptr[0] <= '9')
13517 element = element * 10 + (ptr[0] - '0');
13521 // remap some (historic, now obsolete) elements
13522 element = getMappedElement(element);
13524 if (element >= NUM_FILE_ELEMENTS)
13525 element = EL_UNKNOWN;
13527 brush_buffer[x][y] = element;
13529 brush_width = MAX(x + 1, brush_width);
13530 brush_height = MAX(y + 1, brush_height);
13534 if (x >= MAX_LEV_FIELDX)
13535 start_new_row = TRUE;
13537 allow_new_row = TRUE;
13541 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
13542 start_new_row = TRUE;
13544 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
13552 if (y >= MAX_LEV_FIELDY)
13555 allow_new_row = FALSE;
13559 SDL_free(clipboard_text);
13561 if (brush_width == 0 || brush_height == 0)
13563 Request("No level sketch found in clipboard!", REQ_CONFIRM);
13570 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
13573 SDL_GetMouseState(&mx, &my);
13575 // if inside drawing area, activate and draw brush at last mouse position
13576 if (mx >= gi->x && mx < gi->x + gi->width &&
13577 my >= gi->y && my < gi->y + gi->height)
13578 CopyBrushToCursor(last_cursor_x, last_cursor_y);
13580 draw_with_brush = TRUE;
13586 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
13587 brush_width, brush_height);
13589 if (!Request(request, REQ_ASK))
13592 for (x = 0; x < MAX_LEV_FIELDX; x++)
13593 for (y = 0; y < MAX_LEV_FIELDY; y++)
13594 Tile[x][y] = brush_buffer[x][y];
13596 lev_fieldx = level.fieldx = brush_width;
13597 lev_fieldy = level.fieldy = brush_height;
13599 boolean use_bd_engine = TRUE;
13600 boolean use_em_engine = TRUE;
13601 boolean use_sp_engine = TRUE;
13602 boolean use_mm_engine = TRUE;
13604 for (x = 0; x < MAX_LEV_FIELDX; x++)
13606 for (y = 0; y < MAX_LEV_FIELDY; y++)
13608 int element = Tile[x][y];
13610 if (!IS_BD_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13611 use_bd_engine = FALSE;
13613 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13614 use_em_engine = FALSE;
13616 if (!IS_SP_ELEMENT(element))
13617 use_sp_engine = FALSE;
13619 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
13620 use_mm_engine = FALSE;
13624 level.game_engine_type = (use_bd_engine ? GAME_ENGINE_TYPE_BD :
13625 use_em_engine ? GAME_ENGINE_TYPE_EM :
13626 use_sp_engine ? GAME_ENGINE_TYPE_SP :
13627 use_mm_engine ? GAME_ENGINE_TYPE_MM :
13628 GAME_ENGINE_TYPE_RND);
13630 // update element selection list
13631 ReinitializeElementList();
13632 ModifyEditorElementList();
13634 SetBorderElement();
13636 DrawEditModeWindow();
13637 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13643 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
13646 if (mode == CB_AREA_TO_BRUSH)
13648 int from_lx, from_ly;
13651 swap_numbers(&from_x, &to_x);
13654 swap_numbers(&from_y, &to_y);
13656 brush_width = to_x - from_x + 1;
13657 brush_height = to_y - from_y + 1;
13659 from_lx = from_x + level_xpos;
13660 from_ly = from_y + level_ypos;
13662 for (y = 0; y < brush_height; y++)
13664 for (x = 0; x < brush_width; x++)
13666 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
13669 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
13674 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13676 delete_old_brush = FALSE;
13678 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
13679 mode == CB_BRUSH_TO_LEVEL)
13681 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
13682 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
13683 int cursor_from_x = cursor_x - brush_width / 2;
13684 int cursor_from_y = cursor_y - brush_height / 2;
13685 int border_from_x = cursor_x, border_from_y = cursor_y;
13686 int border_to_x = cursor_x, border_to_y = cursor_y;
13688 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
13689 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13691 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
13692 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
13694 delete_old_brush = FALSE;
13699 for (y = 0; y < brush_height; y++)
13701 for (x = 0; x < brush_width; x++)
13703 int sx = cursor_from_x + x;
13704 int sy = cursor_from_y + y;
13705 int lx = sx + level_xpos;
13706 int ly = sy + level_ypos;
13707 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
13708 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
13709 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
13710 brush_buffer[x][y] : new_element);
13712 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13714 if (sx < border_from_x)
13715 border_from_x = sx;
13716 else if (sx > border_to_x)
13718 if (sy < border_from_y)
13719 border_from_y = sy;
13720 else if (sy > border_to_y)
13723 DrawBrushElement(sx, sy, element, change_level);
13728 if (mode != CB_DELETE_OLD_CURSOR)
13729 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
13731 last_cursor_x = cursor_x;
13732 last_cursor_y = cursor_y;
13734 delete_old_brush = TRUE;
13736 else if (mode == CB_FLIP_BRUSH_X)
13738 for (y = 0; y < brush_height; y++)
13739 for (x = 0; x < (brush_width + 1) / 2; x++)
13740 SwapFlippedTiles(&brush_buffer[x][y],
13741 &brush_buffer[brush_width - x - 1][y], mode);
13743 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13745 else if (mode == CB_FLIP_BRUSH_Y)
13747 for (y = 0; y < (brush_height + 1) / 2; y++)
13748 for (x = 0; x < brush_width; x++)
13749 SwapFlippedTiles(&brush_buffer[x][y],
13750 &brush_buffer[x][brush_height - y - 1], mode);
13752 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13754 else if (mode == CB_FLIP_BRUSH_XY)
13756 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13758 for (y = 0; y < MAX(brush_width, brush_height); y++)
13759 for (x = 0; x <= y; x++)
13760 SwapFlippedTiles(&brush_buffer[x][y],
13761 &brush_buffer[y][x], mode);
13763 swap_numbers(&brush_width, &brush_height);
13765 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13768 if (mode == CB_UPDATE_BRUSH_POSITION)
13770 last_cursor_x = from_x;
13771 last_cursor_y = from_y;
13775 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
13778 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
13781 static void CopyBrushToLevel(int x, int y, int button)
13783 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
13786 static void CopyBrushToCursor(int x, int y)
13788 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13791 static void UpdateBrushPosition(int x, int y)
13793 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
13796 static void DeleteBrushFromCursor(void)
13798 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13801 static void FlipBrushX(void)
13803 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13806 static void FlipBrushY(void)
13808 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_Y);
13811 static void RotateBrush(void)
13813 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_XY);
13814 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13817 void DumpBrush(void)
13819 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
13822 void DumpBrush_Small(void)
13824 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
13827 void CopyClipboardToBrush(void)
13829 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
13832 void CopyBrushToClipboard(void)
13834 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
13837 void CopyBrushToClipboard_Small(void)
13839 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
13842 void UndoLevelEditorOperation(void)
13844 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
13847 void RedoLevelEditorOperation(void)
13849 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13852 static void FloodFill(int from_x, int from_y, int fill_element)
13854 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
13857 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
13859 int from_x = from_sx2 + 2 * level_xpos;
13860 int from_y = from_sy2 + 2 * level_ypos;
13861 int max_fillx = lev_fieldx * 2;
13862 int max_filly = lev_fieldy * 2;
13863 short Fill[max_fillx][max_filly];
13866 for (x = 0; x < max_fillx; x++)
13867 for (y = 0; y < max_filly; y++)
13868 Fill[x][y] = getLevelElementHiRes(x, y);
13870 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
13871 Fill, max_fillx, max_filly);
13873 for (x = 0; x < max_fillx; x++)
13874 for (y = 0; y < max_filly; y++)
13875 if (Fill[x][y] == fill_element)
13876 SetLevelElementHiRes(x, y, Fill[x][y]);
13879 // values for DrawLevelText() modes
13880 #define TEXT_INIT 0
13881 #define TEXT_SETCURSOR 1
13882 #define TEXT_WRITECHAR 2
13883 #define TEXT_BACKSPACE 3
13884 #define TEXT_NEWLINE 4
13886 #define TEXT_QUERY_TYPING 6
13888 static int DrawLevelText(int sx, int sy, char letter, int mode)
13890 static short delete_buffer[MAX_LEV_FIELDX];
13891 static int start_sx;
13892 static int last_sx, last_sy;
13893 static boolean typing = FALSE;
13894 int letter_element;
13895 int lx = 0, ly = 0;
13897 // map lower case letters to upper case and convert special characters
13898 if (letter >= 'a' && letter <= 'z')
13899 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
13900 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
13901 letter_element = EL_CHAR_AUMLAUT;
13902 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
13903 letter_element = EL_CHAR_OUMLAUT;
13904 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
13905 letter_element = EL_CHAR_UUMLAUT;
13906 else if (letter == '^')
13907 letter_element = EL_CHAR_COPYRIGHT;
13909 letter_element = EL_CHAR_ASCII0 + letter;
13911 if (mode != TEXT_INIT)
13916 if (mode != TEXT_SETCURSOR)
13922 lx = last_sx + level_xpos;
13923 ly = last_sy + level_ypos;
13930 DrawLevelText(0, 0, 0, TEXT_END);
13936 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
13939 case TEXT_SETCURSOR:
13940 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
13941 DrawAreaBorder(sx, sy, sx, sy);
13942 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
13943 ed_tilesize, ed_tilesize);
13948 case TEXT_WRITECHAR:
13949 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
13951 if (new_element1 >= EL_STEEL_CHAR_START &&
13952 new_element1 <= EL_STEEL_CHAR_END)
13953 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
13955 delete_buffer[sx - start_sx] = Tile[lx][ly];
13956 Tile[lx][ly] = letter_element;
13958 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
13959 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
13960 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13961 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13963 DrawLevelText(0, 0, 0, TEXT_END);
13965 level.changed = TRUE;
13969 case TEXT_BACKSPACE:
13972 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
13973 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
13974 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
13979 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13980 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13982 DrawLevelText(0, 0, 0, TEXT_END);
13986 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13987 DrawEditorElement(sx, sy, Tile[lx][ly]);
13992 case TEXT_QUERY_TYPING:
14002 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
14003 int element, boolean change_level)
14005 int lx = sx + level_xpos;
14006 int ly = sy + level_ypos;
14009 DrawEditorElement(sx, sy, Tile[lx][ly]);
14011 DrawAreaBorder(sx, sy, sx, sy);
14014 static void CheckLevelBorderElement(boolean redraw_playfield)
14016 int last_border_element = BorderElement;
14018 SetBorderElement();
14020 if (redraw_playfield && BorderElement != last_border_element)
14021 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14024 static void CopyLevelToUndoBuffer(int mode)
14026 static boolean accumulated_undo = FALSE;
14027 boolean new_undo_buffer_position = TRUE;
14030 if (undo_buffer_steps == 0)
14031 accumulated_undo = FALSE;
14035 case UNDO_IMMEDIATE:
14036 accumulated_undo = FALSE;
14039 case UNDO_ACCUMULATE:
14040 if (accumulated_undo)
14041 new_undo_buffer_position = FALSE;
14042 accumulated_undo = TRUE;
14049 if (new_undo_buffer_position)
14051 // advance position in undo buffer ring
14052 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
14054 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
14055 undo_buffer_steps++;
14058 // always reset redo buffer when storing level change into undo buffer
14059 redo_buffer_steps = 0;
14061 for (x = 0; x < lev_fieldx; x++)
14062 for (y = 0; y < lev_fieldy; y++)
14063 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
14065 // check if drawing operation forces change of border style
14066 CheckLevelBorderElement(TRUE);
14068 level.changed = TRUE;
14071 static void RandomPlacement(int new_element)
14073 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
14074 int num_free_positions = 0;
14075 int num_percentage, num_elements;
14078 ResetIntelliDraw();
14080 // determine number of free positions for randomly placing the new element
14081 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
14083 free_position[x][y] =
14084 (random_placement_background_restricted ?
14085 Tile[x][y] == random_placement_background_element :
14086 Tile[x][y] != new_element);
14088 if (free_position[x][y])
14089 num_free_positions++;
14092 // determine number of new elements to place there
14093 num_percentage = num_free_positions * random_placement_value / 100;
14094 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
14095 num_percentage : random_placement_value);
14097 // if less free positions than elements to place, fill all these positions
14098 if (num_free_positions < num_elements)
14100 for (x = 0; x < lev_fieldx; x++)
14101 for (y = 0; y < lev_fieldy; y++)
14102 if (free_position[x][y])
14103 SetElement(x, y, new_element);
14107 while (num_elements > 0)
14109 x = GetSimpleRandom(lev_fieldx);
14110 y = GetSimpleRandom(lev_fieldy);
14112 // don't place element at the same position twice
14113 if (free_position[x][y])
14115 free_position[x][y] = FALSE;
14116 SetElement(x, y, new_element);
14122 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14123 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14126 static void WrapLevel(int dx, int dy)
14128 int wrap_dx = lev_fieldx - dx;
14129 int wrap_dy = lev_fieldy - dy;
14132 for (x = 0; x < lev_fieldx; x++)
14133 for (y = 0; y < lev_fieldy; y++)
14134 TileBackup[x][y] = Tile[x][y];
14136 for (x = 0; x < lev_fieldx; x++)
14137 for (y = 0; y < lev_fieldy; y++)
14139 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
14141 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14142 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
14145 static void DrawAreaElementHighlight(boolean highlighted,
14146 boolean highlighted_similar)
14148 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14155 for (x = 0; x < ed_fieldx; x++)
14157 for (y = 0; y < ed_fieldy; y++)
14159 boolean highlight = FALSE;
14160 int lx = x + level_xpos;
14161 int ly = y + level_ypos;
14163 if (!IN_LEV_FIELD(lx, ly))
14166 // check if element is the same
14167 if (Tile[lx][ly] == new_element1)
14170 // check if element is similar
14171 if (highlighted_similar &&
14172 strEqual(element_info[Tile[lx][ly]].class_name,
14173 element_info[new_element1].class_name))
14176 // check if element is matching MM style wall
14177 if (IS_MM_WALL(Tile[lx][ly]) &&
14178 map_mm_wall_element(Tile[lx][ly]) == new_element1)
14184 if (IS_MM_WALL(Tile[lx][ly]) && !highlighted_similar)
14188 for (i = 0; i < 4; i++)
14190 if (!(MM_WALL_BITS(Tile[lx][ly]) & (1 << i)))
14193 int xx = x * 2 + (i % 2);
14194 int yy = y * 2 + (i / 2);
14195 int sx = SX + xx * ed_tilesize / 2;
14196 int sy = SY + yy * ed_tilesize / 2;
14199 int to_sx = sx + ed_tilesize / 2 - 1;
14200 int to_sy = sy + ed_tilesize / 2 - 1;
14202 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
14203 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
14204 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14205 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14210 int sx = SX + x * ed_tilesize;
14211 int sy = SY + y * ed_tilesize;
14214 int to_sx = sx + ed_tilesize - 1;
14215 int to_sy = sy + ed_tilesize - 1;
14217 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
14218 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
14219 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14220 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14226 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
14228 char *template_filename_old = getLocalLevelTemplateFilename();
14229 char *template_filename_new =
14230 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
14232 if (copyFile(template_filename_old, template_filename_new) != 0)
14233 Request("Cannot copy level template!", REQ_CONFIRM);
14235 free(template_filename_new);
14238 static void HandleDrawingAreas(struct GadgetInfo *gi)
14240 static boolean started_inside_drawing_area = FALSE;
14241 static int last_sx = -1;
14242 static int last_sy = -1;
14243 static int last_sx2 = -1;
14244 static int last_sy2 = -1;
14245 int id = gi->custom_id;
14246 int type_id = gi->custom_type_id;
14247 boolean button_press_event;
14248 boolean button_release_event;
14249 boolean inside_drawing_area = !gi->event.off_borders;
14250 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
14251 int actual_drawing_function;
14252 int button = gi->event.button;
14253 int new_element = BUTTON_ELEMENT(button);
14254 int sx = gi->event.x, sy = gi->event.y;
14255 int min_sx = 0, min_sy = 0;
14256 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
14257 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
14258 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
14259 int sx2 = gi->event.mx / mini_item_xsize;
14260 int sy2 = gi->event.my / mini_item_ysize;
14263 int lx = 0, ly = 0;
14266 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
14267 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
14269 // make sure to stay inside drawing area boundaries
14270 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14271 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14275 int min_lx = 0, min_ly = 0;
14276 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14278 // get positions inside level field
14279 lx = sx + level_xpos;
14280 ly = sy + level_ypos;
14282 if (!IN_LEV_FIELD(lx, ly))
14283 inside_drawing_area = FALSE;
14285 // make sure to stay inside level field boundaries
14286 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14287 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14289 // correct drawing area positions accordingly
14290 sx = lx - level_xpos;
14291 sy = ly - level_ypos;
14294 // also correct MM wall-sized (double) drawing area positions accordingly
14295 if (sx2 / 2 < sx || sx2 / 2 > sx)
14297 dx = (sx2 / 2 < sx ? 0 : 1);
14300 if (sy2 / 2 < sy || sy2 / 2 > sy)
14302 dy = (sy2 / 2 < sy ? 0 : 1);
14306 if (!button_press_event && !button_release_event)
14308 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
14309 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
14310 isHiresTileElement(old_element) &&
14311 isHiresDrawElement(new_element));
14313 // prevent handling events for every pixel position when moving mouse
14314 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
14315 (sx2 == last_sx2 && sy2 == last_sy2))
14324 if (button_press_event)
14325 started_inside_drawing_area = inside_drawing_area;
14327 if (!started_inside_drawing_area)
14330 if (!IS_VALID_BUTTON(button))
14333 // handle info callback for each invocation of action callback
14334 gi->callback_info(gi);
14336 // automatically switch to 'single item' drawing mode, if needed
14337 actual_drawing_function =
14338 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
14339 drawing_function : GADGET_ID_SINGLE_ITEMS);
14341 // clicking into drawing area with pressed Control key picks element
14342 if (GetKeyModState() & KMOD_Control)
14344 last_drawing_function = drawing_function;
14345 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14348 if (GetKeyModState() & KMOD_Shift)
14350 if (button_press_event || button_release_event)
14351 ResetIntelliDraw();
14354 SetDrawModeHiRes(-1); // reset to normal draw mode
14356 switch (actual_drawing_function)
14358 case GADGET_ID_SINGLE_ITEMS:
14361 if (button_release_event)
14363 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14365 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
14366 !inside_drawing_area)
14367 DeleteBrushFromCursor();
14372 if (draw_with_brush)
14374 CopyBrushToLevel(sx, sy, button);
14378 SetDrawModeHiRes(new_element);
14380 if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
14382 // remove player at old position
14383 for (y = 0; y < lev_fieldy; y++)
14385 for (x = 0; x < lev_fieldx; x++)
14387 int old_element = Tile[x][y];
14389 if (IS_PLAYER_ELEMENT(old_element) &&
14390 IS_PLAYER_ELEMENT(new_element))
14392 int replaced_with_element =
14393 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
14394 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
14396 old_element == EL_SOKOBAN_FIELD_PLAYER &&
14397 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
14399 new_element == EL_SOKOBAN_FIELD_PLAYER &&
14400 old_element == EL_PLAYER_1 ? EL_EMPTY :
14402 new_element >= EL_PLAYER_1 &&
14403 new_element <= EL_PLAYER_4 &&
14404 new_element == old_element ? EL_EMPTY :
14408 SetElement(x, y, replaced_with_element);
14410 else if (IS_MM_MCDUFFIN(old_element) &&
14411 IS_MM_MCDUFFIN(new_element))
14413 // remove McDuffin at old position
14414 SetElement(x, y, EL_EMPTY);
14420 SetElementButton(lx, ly, dx, dy, new_element, button);
14423 else if (!button_release_event)
14425 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14427 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
14428 DrawMiniGraphicExt(drawto,
14429 gi->x + sx * MINI_TILEX,
14430 gi->y + sy * MINI_TILEY,
14431 el2edimg(new_element));
14433 DrawFixedGraphicExt(drawto,
14434 gi->x + sx * TILEX,
14435 gi->y + sy * TILEY,
14436 el2edimg(new_element), 0);
14438 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14439 new_element = GFX_ELEMENT(new_element);
14441 drawingarea_info[type_id].value[pos] = new_element;
14443 CopyElementPropertiesToGame(properties_element);
14445 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14447 UpdateCustomElementGraphicGadgets();
14449 FrameCounter = 0; // restart animation frame counter
14454 case GADGET_ID_CONNECTED_ITEMS:
14456 static int last_sx = -1;
14457 static int last_sy = -1;
14459 if (button_release_event)
14460 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14462 SetDrawModeHiRes(new_element);
14464 if (getDrawModeHiRes())
14470 if (!button_press_event)
14471 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
14478 case GADGET_ID_LINE:
14479 case GADGET_ID_ARC:
14480 case GADGET_ID_RECTANGLE:
14481 case GADGET_ID_FILLED_BOX:
14482 SetDrawModeHiRes(new_element);
14484 if (getDrawModeHiRes())
14490 case GADGET_ID_GRAB_BRUSH:
14491 case GADGET_ID_TEXT:
14493 static int last_sx = -1;
14494 static int last_sy = -1;
14495 static int start_sx = -1;
14496 static int start_sy = -1;
14497 void (*draw_func)(int, int, int, int, int, boolean);
14499 if (drawing_function == GADGET_ID_LINE)
14500 draw_func = DrawLine;
14501 else if (drawing_function == GADGET_ID_ARC)
14502 draw_func = DrawArc;
14503 else if (drawing_function == GADGET_ID_RECTANGLE)
14504 draw_func = DrawBox;
14505 else if (drawing_function == GADGET_ID_FILLED_BOX)
14506 draw_func = DrawFilledBox;
14507 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
14508 draw_func = SelectArea;
14509 else // (drawing_function == GADGET_ID_TEXT)
14510 draw_func = SetTextCursor;
14512 if (button_press_event)
14514 draw_func(sx, sy, sx, sy, new_element, FALSE);
14515 start_sx = last_sx = sx;
14516 start_sy = last_sy = sy;
14518 if (drawing_function == GADGET_ID_TEXT)
14519 DrawLevelText(0, 0, 0, TEXT_END);
14521 else if (button_release_event)
14523 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
14524 if (drawing_function == GADGET_ID_GRAB_BRUSH)
14526 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
14527 CopyBrushToCursor(sx, sy);
14528 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14530 draw_with_brush = TRUE;
14532 else if (drawing_function == GADGET_ID_TEXT)
14533 DrawLevelText(sx, sy, 0, TEXT_INIT);
14535 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14537 else if (last_sx != sx || last_sy != sy)
14539 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
14540 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
14541 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
14542 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
14549 case GADGET_ID_FLOOD_FILL:
14550 if (button_press_event && Tile[lx][ly] != new_element)
14552 if (IS_MM_WALL_EDITOR(new_element))
14553 FloodFillWall_MM(sx2, sy2, new_element);
14555 FloodFill(lx, ly, new_element);
14557 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14558 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14562 case GADGET_ID_PICK_ELEMENT:
14563 if (button_release_event)
14564 ClickOnGadget(level_editor_gadget[last_drawing_function],
14566 else if (draw_level)
14567 PickDrawingElement(button, Tile[lx][ly]);
14570 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14572 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
14579 // do not mark level as modified for certain non-level-changing gadgets
14580 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
14581 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
14582 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
14583 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14586 level.changed = TRUE;
14589 static void HandleCounterButtons(struct GadgetInfo *gi)
14591 int gadget_id = gi->custom_id;
14592 int counter_id = gi->custom_type_id;
14593 int button = gi->event.button;
14594 int *counter_value = counterbutton_info[counter_id].value;
14595 int step = BUTTON_STEPSIZE(button) *
14596 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
14598 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14600 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
14601 boolean released = (gi->event.type == GD_EVENT_RELEASED);
14602 boolean level_changed = LevelChanged();
14604 if ((level_changed && pressed) || (!level_changed && released))
14607 if (level_changed && !Request("Level has changed! Discard changes?",
14610 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14611 ModifyEditorCounterValue(counter_id, *counter_value);
14617 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14618 *counter_value = gi->textinput.number_value;
14620 ModifyEditorCounterValue(counter_id, *counter_value + step);
14622 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14624 int last_game_engine_type = level.game_engine_type;
14626 LoadLevel(level_nr);
14627 LoadScore(level_nr);
14629 SaveLevelSetup_SeriesInfo();
14634 DrawEditModeWindow();
14636 if (level.game_engine_type != last_game_engine_type)
14638 // update element selection list
14639 ReinitializeElementList();
14640 ModifyEditorElementList();
14646 switch (counter_id)
14648 case ED_COUNTER_ID_YAMYAM_CONTENT:
14649 DrawYamYamContentAreas();
14652 case ED_COUNTER_ID_BALL_CONTENT:
14653 DrawMagicBallContentAreas();
14656 case ED_COUNTER_ID_ANDROID_CONTENT:
14657 DrawAndroidElementArea();
14660 case ED_COUNTER_ID_GROUP_CONTENT:
14661 DrawGroupElementArea();
14662 CopyGroupElementPropertiesToGame(properties_element);
14665 case ED_COUNTER_ID_INVENTORY_SIZE:
14666 DrawPlayerInitialInventoryArea(properties_element);
14669 case ED_COUNTER_ID_MM_BALL_CONTENT:
14670 DrawMMBallContentArea();
14673 case ED_COUNTER_ID_ENVELOPE_XSIZE:
14674 case ED_COUNTER_ID_ENVELOPE_YSIZE:
14675 DrawEnvelopeTextArea(-1);
14678 case ED_COUNTER_ID_LEVEL_XSIZE:
14679 case ED_COUNTER_ID_LEVEL_YSIZE:
14680 lev_fieldx = level.fieldx;
14681 lev_fieldy = level.fieldy;
14683 // check if resizing of level results in change of border border
14684 SetBorderElement();
14692 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
14693 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
14694 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
14695 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
14696 CopyElementPropertiesToGame(properties_element);
14698 // do not mark level as modified for certain non-level-changing gadgets
14699 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
14700 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
14701 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
14702 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
14705 level.changed = TRUE;
14708 static void HandleTextInputGadgets(struct GadgetInfo *gi)
14710 int type_id = gi->custom_type_id;
14712 strcpy(textinput_info[type_id].value, gi->textinput.value);
14714 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
14716 CopyElementPropertiesToGame(properties_element);
14718 ModifyEditorElementList(); // update changed button info text
14721 // do not mark level as modified for certain non-level-changing gadgets
14722 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
14723 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
14726 level.changed = TRUE;
14729 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
14731 int type_id = gi->custom_type_id;
14733 strncpy(textarea_info[type_id].value, gi->textarea.value,
14734 MAX_ENVELOPE_TEXT_LEN);
14735 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
14737 level.changed = TRUE;
14740 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
14742 int type_id = gi->custom_type_id;
14743 int value_old = *selectbox_info[type_id].value;
14744 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
14746 *selectbox_info[type_id].value = value_new;
14748 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
14750 DrawLevelConfigWindow();
14752 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14754 element_info[properties_element].current_change_page = gi->selectbox.index;
14756 DrawPropertiesWindow();
14758 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
14759 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
14760 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
14761 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
14762 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
14764 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
14766 // when changing action type, also check action mode and action arg
14767 if (value_old != value_new)
14768 setSelectboxSpecialActionVariablesIfNeeded();
14770 DrawPropertiesChange();
14773 CopyElementPropertiesToGame(properties_element);
14775 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
14777 // show or hide "engine" tabulator depending on game engine type
14778 DrawLevelConfigWindow();
14780 // update element selection list depending on game engine type
14781 ReinitializeElementList();
14782 ModifyEditorElementList();
14784 else if (type_id == ED_SELECTBOX_ID_BD_SCHEDULING_TYPE)
14786 // update BD cycle delay counter gadgets depending on BD scheduling type
14787 DrawLevelConfigWindow();
14790 // do not mark level as modified for certain non-level-changing gadgets
14791 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
14792 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14795 level.changed = TRUE;
14798 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
14800 int type_id = gi->custom_type_id;
14803 if (type_id >= ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST &&
14804 type_id <= ED_TAB_BUTTON_ID_LEVELCONFIG_LAST)
14806 edit_mode_levelconfig = gi->custom_type_id;
14808 DrawLevelConfigWindow();
14810 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
14811 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
14813 edit_mode_properties = gi->custom_type_id;
14815 DrawPropertiesWindow();
14817 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
14818 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
14820 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
14822 // backup original "level.field" (needed to track playfield changes)
14823 CopyPlayfield(level.field, TileBackup);
14825 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
14826 CopyPlayfield(Tile, level.field);
14828 if (new_template ||
14829 Request("Save this template and kill the old?", REQ_ASK))
14830 SaveLevelTemplate();
14833 Request("Template saved!", REQ_CONFIRM);
14835 // restore original "level.field" (needed to track playfield changes)
14836 CopyPlayfield(TileBackup, level.field);
14838 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
14840 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
14842 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
14843 leveldir_current->readonly)
14845 Request("This level set is read-only!", REQ_CONFIRM);
14850 if (strEqual(levelset_name, ""))
14852 Request("Please enter level set title!", REQ_CONFIRM);
14857 if (strEqual(levelset_author, ""))
14859 Request("Please enter level set author!", REQ_CONFIRM);
14864 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
14866 if (UpdateUserLevelSet(levelset_subdir,
14869 levelset_num_levels))
14871 Request("Level set updated!", REQ_CONFIRM);
14875 Request("Updating level set failed!", REQ_CONFIRM);
14878 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
14880 if (level.changed && !Request("Level has changed! Discard changes?",
14884 if (CreateUserLevelSet(levelset_subdir,
14887 levelset_num_levels,
14888 levelset_use_levelset_artwork))
14890 if (levelset_copy_level_template)
14891 CopyLevelTemplateToUserLevelSet(levelset_subdir);
14893 Request("New level set created!", REQ_CONFIRM);
14895 AddUserLevelSetToLevelInfo(levelset_subdir);
14896 ChangeEditorToLevelSet(levelset_subdir);
14900 Request("Creating new level set failed!", REQ_CONFIRM);
14904 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
14905 custom_element.num_change_pages < MAX_CHANGE_PAGES)
14907 struct ElementInfo *ei = &element_info[properties_element];
14909 // when modifying custom element, ask for copying level template
14910 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14913 setElementChangePages(ei, ei->num_change_pages + 1);
14915 // set new change page to be new current change page
14916 ei->current_change_page = ei->num_change_pages - 1;
14917 ei->change = &ei->change_page[ei->current_change_page];
14919 setElementChangeInfoToDefaults(ei->change);
14921 DrawPropertiesWindow();
14923 level.changed = TRUE;
14925 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
14926 custom_element.num_change_pages > MIN_CHANGE_PAGES)
14928 struct ElementInfo *ei = &element_info[properties_element];
14930 // when modifying custom element, ask for copying level template
14931 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14934 // copy all change pages after change page to be deleted
14935 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
14936 ei->change_page[i] = ei->change_page[i + 1];
14938 setElementChangePages(ei, ei->num_change_pages - 1);
14940 DrawPropertiesWindow();
14942 level.changed = TRUE;
14946 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
14948 int type_id = gi->custom_type_id;
14950 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
14951 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
14953 struct ElementInfo *ei = &element_info[properties_element];
14954 int step = BUTTON_STEPSIZE(gi->event.button);
14956 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
14957 ei->current_change_page += step;
14959 if (ei->current_change_page < 0)
14960 ei->current_change_page = 0;
14961 else if (ei->current_change_page >= ei->num_change_pages)
14962 ei->current_change_page = ei->num_change_pages - 1;
14964 DrawPropertiesWindow();
14966 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
14967 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14969 struct ElementInfo *ei = &element_info[properties_element];
14970 int current_change_page = ei->current_change_page;
14972 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
14974 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
14975 ei->change_page[current_change_page];
14977 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14979 // when modifying custom element, ask for copying level template
14980 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14983 ei->change_page[current_change_page] =
14984 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
14986 level.changed = TRUE;
14989 DrawPropertiesWindow();
14993 static void HandleRadiobuttons(struct GadgetInfo *gi)
14995 int type_id = gi->custom_type_id;
14997 *radiobutton_info[type_id].value =
14998 radiobutton_info[type_id].checked_value;
15000 // do not mark level as modified for certain non-level-changing gadgets
15001 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
15002 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
15005 level.changed = TRUE;
15008 static void HandleCheckbuttons(struct GadgetInfo *gi)
15010 int type_id = gi->custom_type_id;
15012 *checkbutton_info[type_id].value ^= TRUE;
15014 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
15015 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
15016 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
15017 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
15018 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
15019 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
15020 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
15021 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
15023 CopyElementPropertiesToGame(properties_element);
15026 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
15028 UpdateCustomElementGraphicGadgets();
15030 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
15031 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
15033 boolean template_related_changes_found = FALSE;
15036 // check if any custom, group or empty elements have been changed
15037 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
15038 if ((IS_CUSTOM_ELEMENT(i) ||
15039 IS_GROUP_ELEMENT(i) ||
15040 IS_EMPTY_ELEMENT(i)) &&
15041 element_info[i].modified_settings)
15042 template_related_changes_found = TRUE;
15044 if (level.use_custom_template &&
15045 !fileExists(getGlobalLevelTemplateFilename()))
15047 Request("No level template found!", REQ_CONFIRM);
15049 level.use_custom_template = FALSE;
15051 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
15056 if (level.use_custom_template &&
15057 template_related_changes_found &&
15058 !Request("Discard changes and use level template?", REQ_ASK))
15060 level.use_custom_template = FALSE;
15062 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
15067 if (!level.use_custom_template &&
15068 Request("Copy settings from level template?", REQ_ASK))
15073 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
15075 DrawEditModeWindow();
15077 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
15079 if (setup.editor.use_template_for_new_levels &&
15080 !fileExists(getGlobalLevelTemplateFilename()))
15082 Request("No level template found!", REQ_CONFIRM);
15087 if (setup.editor.use_template_for_new_levels &&
15089 !Request("Discard level and load template?", REQ_ASK))
15094 if (!setup.editor.use_template_for_new_levels &&
15096 !Request("Discard level and use empty level?", REQ_ASK))
15101 LoadLevel(level_nr);
15102 LoadScore(level_nr);
15107 DrawEditModeWindow();
15109 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
15111 SetAutomaticNumberOfGemsNeeded();
15114 // do not mark level as modified for certain non-level-changing gadgets
15115 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
15116 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
15117 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
15118 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
15119 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
15120 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
15123 level.changed = TRUE;
15126 static void HandleControlButtons(struct GadgetInfo *gi)
15128 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
15129 static int last_edit_mode = ED_MODE_DRAWING;
15130 static int last_custom_copy_mode = -1;
15131 static int last_button = 0;
15132 int id = gi->custom_id;
15133 int button = gi->event.button;
15134 int step = BUTTON_STEPSIZE(button);
15135 int new_element = BUTTON_ELEMENT(button);
15136 int last_properties_element = properties_element;
15139 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
15140 DrawLevelText(0, 0, 0, TEXT_END);
15142 if (id < ED_NUM_CTRL1_BUTTONS &&
15143 id != GADGET_ID_SINGLE_ITEMS &&
15144 id != GADGET_ID_PICK_ELEMENT &&
15145 edit_mode != ED_MODE_DRAWING &&
15146 drawing_function != GADGET_ID_PICK_ELEMENT &&
15147 !(GetKeyModState() & KMOD_Control))
15148 ChangeEditModeWindow(ED_MODE_DRAWING);
15150 // element copy mode active, but no element button pressed => deactivate
15151 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
15152 last_custom_copy_mode = -1;
15154 // when showing palette on element buttons, change element of button used
15155 if (editor.palette.show_on_element_buttons &&
15156 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
15158 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
15160 id = GADGET_ID_PALETTE;
15165 case GADGET_ID_SCROLL_LEFT:
15166 if (level_xpos >= 0)
15168 if (lev_fieldx < ed_fieldx - 2)
15171 level_xpos -= step;
15172 if (level_xpos < -1)
15175 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
15177 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15179 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
15180 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
15184 case GADGET_ID_SCROLL_RIGHT:
15185 if (level_xpos <= lev_fieldx - ed_fieldx)
15187 if (lev_fieldx < ed_fieldx - 2)
15190 level_xpos += step;
15191 if (level_xpos > lev_fieldx - ed_fieldx + 1)
15192 level_xpos = lev_fieldx - ed_fieldx + 1;
15194 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
15196 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15198 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
15199 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
15203 case GADGET_ID_SCROLL_UP:
15204 if (level_ypos >= 0)
15206 if (lev_fieldy < ed_fieldy - 2)
15209 level_ypos -= step;
15210 if (level_ypos < -1)
15213 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
15215 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15217 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15218 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15222 case GADGET_ID_SCROLL_DOWN:
15223 if (level_ypos <= lev_fieldy - ed_fieldy)
15225 if (lev_fieldy < ed_fieldy - 2)
15228 level_ypos += step;
15229 if (level_ypos > lev_fieldy - ed_fieldy + 1)
15230 level_ypos = lev_fieldy - ed_fieldy + 1;
15232 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
15234 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15236 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15237 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15241 case GADGET_ID_SCROLL_HORIZONTAL:
15242 level_xpos = gi->event.item_position - 1;
15244 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15249 case GADGET_ID_SCROLL_VERTICAL:
15250 level_ypos = gi->event.item_position - 1;
15252 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15257 case GADGET_ID_SCROLL_LIST_UP:
15258 case GADGET_ID_SCROLL_LIST_DOWN:
15259 case GADGET_ID_SCROLL_LIST_VERTICAL:
15260 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
15261 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
15264 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
15265 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15267 if (element_shift < 0)
15269 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15270 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15272 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15273 GDI_SCROLLBAR_ITEM_POSITION,
15274 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15277 ModifyEditorElementList();
15281 case GADGET_ID_PROPERTIES:
15282 // always switch off element properties when they are already displayed
15283 last_properties_element = new_element;
15284 case GADGET_ID_ELEMENT_LEFT:
15285 case GADGET_ID_ELEMENT_MIDDLE:
15286 case GADGET_ID_ELEMENT_RIGHT:
15287 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
15288 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
15289 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
15292 if (edit_mode != ED_MODE_PROPERTIES)
15294 last_edit_mode = edit_mode;
15296 ChangeEditModeWindow(ED_MODE_PROPERTIES);
15298 last_level_drawing_function = drawing_function;
15299 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
15302 else if (properties_element != last_properties_element)
15304 DrawEditModeWindow();
15308 ChangeEditModeWindow(ED_MODE_DRAWING);
15310 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
15315 case GADGET_ID_PALETTE:
15316 if (edit_mode != ED_MODE_PALETTE)
15318 last_edit_mode = edit_mode;
15320 ChangeEditModeWindow(ED_MODE_PALETTE);
15324 ChangeEditModeWindow(last_edit_mode);
15328 case GADGET_ID_WRAP_LEFT:
15329 WrapLevel(-step, 0);
15332 case GADGET_ID_WRAP_RIGHT:
15333 WrapLevel(step, 0);
15336 case GADGET_ID_WRAP_UP:
15337 WrapLevel(0, -step);
15340 case GADGET_ID_WRAP_DOWN:
15341 WrapLevel(0, step);
15344 case GADGET_ID_SINGLE_ITEMS:
15345 case GADGET_ID_CONNECTED_ITEMS:
15346 case GADGET_ID_LINE:
15347 case GADGET_ID_ARC:
15348 case GADGET_ID_TEXT:
15349 case GADGET_ID_RECTANGLE:
15350 case GADGET_ID_FILLED_BOX:
15351 case GADGET_ID_FLOOD_FILL:
15352 case GADGET_ID_GRAB_BRUSH:
15353 case GADGET_ID_PICK_ELEMENT:
15354 if (drawing_function != GADGET_ID_PICK_ELEMENT)
15355 last_drawing_function = drawing_function;
15356 drawing_function = id;
15357 draw_with_brush = FALSE;
15360 case GADGET_ID_RANDOM_PLACEMENT:
15361 RandomPlacement(new_element);
15364 case GADGET_ID_ZOOM:
15365 // zoom level editor tile size in or out (or reset to default size)
15366 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
15367 button == 2 ? ed_tilesize_default :
15368 button == 3 ? ed_tilesize / 2 : ed_tilesize);
15370 // when using touch device, cycle through all zoom tilesizes
15371 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
15372 ed_tilesize = MICRO_TILESIZE;
15374 // limit zoom level by upper and lower bound
15375 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
15377 InitZoomLevelSettings(ed_tilesize);
15379 if (edit_mode == ED_MODE_DRAWING)
15381 DrawDrawingWindow();
15383 // redraw zoom gadget info text
15384 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15387 // save current editor zoom tilesize
15388 SaveSetup_AutoSetup();
15392 case GADGET_ID_CUSTOM_COPY_FROM:
15393 case GADGET_ID_CUSTOM_COPY_TO:
15394 case GADGET_ID_CUSTOM_EXCHANGE:
15395 last_custom_copy_mode = id;
15396 last_drawing_function = drawing_function;
15399 case GADGET_ID_CUSTOM_COPY:
15400 CopyCustomElement(properties_element, -1, id);
15403 case GADGET_ID_CUSTOM_PASTE:
15404 CopyCustomElement(-1, properties_element, id);
15407 case GADGET_ID_UNDO:
15408 if (button < 0) // keep button value (even if modifier keys are pressed)
15410 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
15413 if (button == 1 && undo_buffer_steps == 0)
15415 Request("Undo buffer empty!", REQ_CONFIRM);
15419 else if (button == 2)
15423 else if (button == 3 && redo_buffer_steps == 0)
15425 Request("Redo buffer empty!", REQ_CONFIRM);
15430 if (edit_mode != ED_MODE_DRAWING)
15431 ChangeEditModeWindow(ED_MODE_DRAWING);
15437 undo_buffer_position =
15438 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
15440 undo_buffer_steps--;
15441 redo_buffer_steps++;
15447 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
15449 undo_buffer_steps++;
15450 redo_buffer_steps--;
15453 for (x = 0; x < lev_fieldx; x++)
15454 for (y = 0; y < lev_fieldy; y++)
15455 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
15457 // check if undo operation forces change of border style
15458 CheckLevelBorderElement(FALSE);
15460 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15464 case GADGET_ID_CONF:
15465 if (edit_mode != ED_MODE_LEVELCONFIG)
15467 last_edit_mode = edit_mode;
15469 ChangeEditModeWindow(ED_MODE_LEVELCONFIG);
15473 ChangeEditModeWindow(ED_MODE_DRAWING);
15477 case GADGET_ID_CLEAR:
15478 if (edit_mode != ED_MODE_DRAWING)
15479 ChangeEditModeWindow(ED_MODE_DRAWING);
15481 for (x = 0; x < MAX_LEV_FIELDX; x++)
15482 for (y = 0; y < MAX_LEV_FIELDY; y++)
15483 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
15485 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
15487 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15490 case GADGET_ID_SAVE:
15492 // saving read-only levels into personal level set modifies global vars
15493 // "leveldir_current" and "level_nr"; restore them after saving level
15494 LevelDirTree *leveldir_former = leveldir_current;
15495 int level_nr_former = level_nr;
15496 char *level_filename;
15499 if (leveldir_current->readonly &&
15500 !PrepareSavingIntoPersonalLevelSet())
15503 level_filename = getDefaultLevelFilename(level_nr);
15504 new_level = !fileExists(level_filename);
15507 Request("Save this level and kill the old?", REQ_ASK))
15509 if (leveldir_former->readonly)
15510 ModifyLevelConfigForSavingIntoPersonalLevelSet(leveldir_former->name);
15512 SetAutomaticNumberOfGemsNeeded();
15514 CopyPlayfield(Tile, level.field);
15515 SaveLevel(level_nr);
15517 level.changed = FALSE;
15521 char level_saved_msg[64];
15523 if (leveldir_former->readonly)
15524 sprintf(level_saved_msg,
15525 "Level saved as level %d into personal level set!",
15528 strcpy(level_saved_msg, "Level saved!");
15530 Request(level_saved_msg, REQ_CONFIRM);
15534 // "cd" back to copied-from levelset (in case of saved read-only level)
15535 leveldir_current = leveldir_former;
15536 level_nr = level_nr_former;
15541 case GADGET_ID_TEST:
15542 if (LevelChanged())
15543 level.game_version = GAME_VERSION_ACTUAL;
15545 CopyPlayfield(level.field, TileBackup);
15546 CopyPlayfield(Tile, level.field);
15548 CopyNativeLevel_RND_to_Native(&level);
15550 UnmapLevelEditorGadgets();
15551 UndrawSpecialEditorDoor();
15553 CloseDoor(DOOR_CLOSE_ALL);
15555 // needed before playing if editor playfield area has different size
15556 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
15558 // redraw_mask = REDRAW_ALL;
15560 level_editor_test_game = TRUE;
15562 StartGameActions(FALSE, setup.autorecord, level.random_seed);
15566 case GADGET_ID_EXIT:
15567 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
15571 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
15572 id <= GADGET_ID_ELEMENTLIST_LAST)
15574 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
15576 new_element = editor_elements[element_position + element_shift];
15578 if (IS_EDITOR_CASCADE(new_element))
15582 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
15584 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
15585 boolean *cascade_value = editor_elements_info[i].setup_cascade_value;
15587 if (*cascade_element == new_element)
15589 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
15590 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
15592 // update element selection list
15593 ReinitializeElementList();
15594 ModifyEditorElementList();
15596 // update cascading gadget info text
15597 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15599 // save current editor cascading state
15600 SaveSetup_EditorCascade();
15609 if (last_custom_copy_mode != -1)
15611 if (CopyCustomElement(properties_element, new_element,
15612 last_custom_copy_mode))
15614 ClickOnGadget(level_editor_gadget[last_drawing_function],
15617 last_custom_copy_mode = -1;
15623 // change element of button used to show palette
15624 if (editor.palette.show_on_element_buttons)
15625 button = last_button;
15627 PickDrawingElement(button, new_element);
15629 if (!stick_element_properties_window &&
15630 drawing_function != GADGET_ID_PICK_ELEMENT &&
15631 !(GetKeyModState() & KMOD_Control))
15633 properties_element = new_element;
15634 if (edit_mode == ED_MODE_PROPERTIES)
15635 DrawPropertiesWindow();
15638 if (drawing_function == GADGET_ID_PICK_ELEMENT)
15639 ClickOnGadget(level_editor_gadget[last_drawing_function],
15642 if (!use_permanent_palette)
15643 ChangeEditModeWindow(last_edit_mode);
15646 else if (gi->event.type == GD_EVENT_PRESSED)
15647 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
15648 else if (gi->event.type == GD_EVENT_RELEASED)
15649 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
15650 else if (gi->event.type == GD_EVENT_MOVING)
15651 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
15653 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
15659 void HandleLevelEditorKeyInput(Key key)
15661 char letter = getCharFromKey(key);
15663 if (drawing_function == GADGET_ID_TEXT &&
15664 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
15667 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
15668 else if (key == KSYM_Delete || key == KSYM_BackSpace)
15669 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
15670 else if (key == KSYM_Return)
15671 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
15672 else if (key == KSYM_Escape)
15673 DrawLevelText(0, 0, 0, TEXT_END);
15678 int id = GADGET_ID_NONE;
15679 int new_element_shift = element_shift;
15680 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
15681 int button = MB_LEFTBUTTON;
15687 id = GADGET_ID_SCROLL_LEFT;
15690 id = GADGET_ID_SCROLL_RIGHT;
15693 id = GADGET_ID_SCROLL_UP;
15696 id = GADGET_ID_SCROLL_DOWN;
15700 case KSYM_Page_Down:
15701 step *= (key == KSYM_Page_Up ? -1 : +1);
15702 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15704 if (element_shift < 0)
15706 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15707 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15709 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15710 GDI_SCROLLBAR_ITEM_POSITION,
15711 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15713 ModifyEditorElementList();
15719 element_shift = (key == KSYM_Home ? 0 :
15720 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
15722 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15723 GDI_SCROLLBAR_ITEM_POSITION,
15724 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15726 ModifyEditorElementList();
15733 // this is needed to prevent interference with running "True X-Mouse"
15734 if (GetKeyModStateFromEvents() & KMOD_Control)
15737 // check for last or next editor cascade block in element list
15738 for (i = 0; i < num_editor_elements; i++)
15740 if ((key == KSYM_Insert && i == element_shift) ||
15741 (key == KSYM_Delete && new_element_shift > element_shift))
15744 // jump to next cascade block (or to start of element list)
15745 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
15746 new_element_shift = i;
15749 if (i < num_editor_elements)
15750 element_shift = new_element_shift;
15752 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15753 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15755 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15756 GDI_SCROLLBAR_ITEM_POSITION,
15757 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15759 ModifyEditorElementList();
15764 if (edit_mode == ED_MODE_DRAWING)
15765 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
15766 else if (edit_mode == ED_MODE_LEVELCONFIG)
15767 HandleControlButtons(level_editor_gadget[GADGET_ID_CONF]);
15768 else if (edit_mode == ED_MODE_PROPERTIES)
15769 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
15770 else if (edit_mode == ED_MODE_PALETTE)
15771 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
15772 else // should never happen
15773 ChangeEditModeWindow(ED_MODE_DRAWING);
15781 if (id != GADGET_ID_NONE)
15782 ClickOnGadget(level_editor_gadget[id], button);
15783 else if (letter == '1' || letter == '?')
15784 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
15785 else if (letter == '2')
15786 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
15787 else if (letter == '3')
15788 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
15789 else if (letter == '.')
15790 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
15791 else if (letter == 'U')
15792 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
15793 else if (letter == '-' || key == KSYM_KP_Subtract)
15794 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
15795 else if (letter == '0' || key == KSYM_KP_0)
15796 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
15797 else if (letter == '+' || key == KSYM_KP_Add ||
15798 letter == '=') // ("Shift-=" is "+" on US keyboards)
15799 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
15800 else if (key == KSYM_Return ||
15801 key == KSYM_space ||
15802 key == setup.shortcut.toggle_pause)
15803 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
15805 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
15806 if (letter && letter == controlbutton_info[i].shortcut)
15807 if (!anyTextGadgetActive())
15808 ClickOnGadget(level_editor_gadget[i], button);
15810 if (draw_with_brush)
15814 else if (letter == 'y')
15816 else if (letter == 'z')
15821 static void HandleLevelEditorIdle_Properties(void)
15823 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
15824 int x = editor.settings.element_graphic.x + element_border;
15825 int y = editor.settings.element_graphic.y + element_border;
15826 static DelayCounter action_delay = { 0 };
15829 action_delay.value = GameFrameDelay;
15831 if (!DelayReached(&action_delay))
15834 for (i = 0; i < ED_NUM_SELECTBOX; i++)
15836 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
15838 if (gi->mapped && gi->active && gi->selectbox.open)
15842 DrawEditorElementAnimation(SX + x, SY + y);
15844 redraw_mask |= REDRAW_FIELD;
15846 FrameCounter++; // increase animation frame counter
15849 static void HandleLevelEditorIdle_Drawing(void)
15851 static boolean last_highlighted = FALSE;
15852 static boolean last_highlighted_similar = FALSE;
15853 boolean highlighted = (GetKeyModState() & KMOD_Alt);
15854 boolean highlighted_similar = (GetKeyModState() & KMOD_Shift);
15856 if (highlighted != last_highlighted ||
15857 (highlighted && highlighted_similar != last_highlighted_similar))
15859 DrawAreaElementHighlight(highlighted, highlighted_similar);
15861 redraw_mask |= REDRAW_FIELD;
15864 last_highlighted = highlighted;
15865 last_highlighted_similar = highlighted_similar;
15868 void HandleLevelEditorIdle(void)
15870 if (edit_mode == ED_MODE_PROPERTIES)
15871 HandleLevelEditorIdle_Properties();
15872 else if (edit_mode == ED_MODE_DRAWING)
15873 HandleLevelEditorIdle_Drawing();
15876 static void ClearEditorGadgetInfoText(void)
15878 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
15881 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
15883 char infotext[MAX_OUTPUT_LINESIZE + 1];
15884 int max_infotext_len = getMaxInfoTextLength();
15886 if (gi == NULL || strlen(gi->info_text) == 0)
15889 strncpy(infotext, gi->info_text, max_infotext_len);
15890 infotext[max_infotext_len] = '\0';
15892 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
15894 int key = controlbutton_info[gi->custom_id].shortcut;
15898 char shortcut[MAX_OUTPUT_LINESIZE + 1];
15900 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
15901 sprintf(shortcut, " ('.' or '%c')", key);
15902 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
15903 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
15904 else if (gi->custom_id == GADGET_ID_TEST)
15905 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
15906 else if (gi->custom_id == GADGET_ID_UNDO)
15907 sprintf(shortcut, " ('%c/Shift-U')", key);
15908 else if (gi->custom_id == GADGET_ID_ZOOM)
15909 sprintf(shortcut, " ('%c', '0', '-')", key);
15911 sprintf(shortcut, " ('%s%c')",
15912 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
15914 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
15915 strcat(infotext, shortcut);
15919 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
15922 void HandleEditorGadgetInfoText(void *ptr)
15924 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
15926 if (game_status != GAME_MODE_EDITOR)
15929 ClearEditorGadgetInfoText();
15931 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
15934 // misuse this function to delete brush cursor, if needed
15935 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
15936 DeleteBrushFromCursor();
15938 PrintEditorGadgetInfoText(gi);
15941 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
15943 int id = gi->custom_id;
15944 int type_id = gi->custom_type_id;
15945 int sx = gi->event.x;
15946 int sy = gi->event.y;
15947 int lx = sx + level_xpos;
15948 int ly = sy + level_ypos;
15949 int min_sx = 0, min_sy = 0;
15950 int max_sx = gi->drawing.area_xsize - 1;
15951 int max_sy = gi->drawing.area_ysize - 1;
15952 int actual_drawing_function = drawing_function;
15953 int max_infotext_len = getMaxInfoTextLength();
15954 char infotext[MAX_OUTPUT_LINESIZE + 1];
15956 infotext[0] = '\0'; // start with empty info text
15958 // pressed Control key: simulate picking element
15959 if (GetKeyModState() & KMOD_Control)
15960 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
15962 ClearEditorGadgetInfoText();
15964 if (gi->event.type == GD_EVENT_INFO_LEAVING)
15967 // make sure to stay inside drawing area boundaries
15968 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
15969 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
15971 if (id == GADGET_ID_DRAWING_LEVEL)
15975 int min_lx = 0, min_ly = 0;
15976 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
15978 // get positions inside level field
15979 lx = sx + level_xpos;
15980 ly = sy + level_ypos;
15982 // make sure to stay inside level field boundaries
15983 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
15984 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
15986 // correct drawing area positions accordingly
15987 sx = lx - level_xpos;
15988 sy = ly - level_ypos;
15991 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15993 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
15995 static int start_lx = 0;
15996 static int start_ly = 0;
15999 if (gi->event.type == GD_EVENT_PRESSED)
16005 switch (actual_drawing_function)
16007 case GADGET_ID_SINGLE_ITEMS:
16008 text = "Drawing single items";
16010 case GADGET_ID_CONNECTED_ITEMS:
16011 text = "Drawing connected items";
16013 case GADGET_ID_LINE:
16014 text = "Drawing line";
16016 case GADGET_ID_ARC:
16017 text = "Drawing arc";
16019 case GADGET_ID_TEXT:
16020 text = "Setting text cursor";
16022 case GADGET_ID_RECTANGLE:
16023 text = "Drawing rectangle";
16025 case GADGET_ID_FILLED_BOX:
16026 text = "Drawing filled box";
16028 case GADGET_ID_FLOOD_FILL:
16029 text = "Flood fill";
16031 case GADGET_ID_GRAB_BRUSH:
16032 text = "Grabbing brush";
16034 case GADGET_ID_PICK_ELEMENT:
16035 text = "Picking element";
16039 text = "Drawing position";
16043 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
16044 sprintf(infotext, "%s: %d, %d", text, lx, ly);
16046 sprintf(infotext, "%s: %d, %d", text,
16047 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
16049 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
16050 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
16052 sprintf(infotext, "Level position: %d, %d", lx, ly);
16055 // misuse this function to draw brush cursor, if needed
16056 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
16058 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
16059 CopyBrushToCursor(sx, sy);
16061 DeleteBrushFromCursor();
16064 if (!draw_with_brush)
16065 UpdateBrushPosition(sx, sy);
16067 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
16069 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
16070 int element = drawingarea_info[type_id].value[pos];
16072 strncpy(infotext, getElementInfoText(element), max_infotext_len);
16076 if (id == GADGET_ID_CUSTOM_CONTENT)
16077 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
16078 else if (id == GADGET_ID_GROUP_CONTENT)
16079 sprintf(infotext, "group element position: %d", sx + 1);
16080 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
16081 id <= GADGET_ID_YAMYAM_CONTENT_7)
16082 sprintf(infotext, "content area %d position: %d, %d",
16083 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
16084 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
16085 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
16086 sprintf(infotext, "content area %d position: %d, %d",
16087 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
16088 else if (id == GADGET_ID_ANDROID_CONTENT)
16089 sprintf(infotext, "android element position: %d", sx + 1);
16090 else if (drawingarea_info[type_id].infotext != NULL)
16091 strcpy(infotext, drawingarea_info[type_id].infotext);
16094 infotext[max_infotext_len] = '\0';
16096 if (strlen(infotext) > 0)
16097 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
16100 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
16101 boolean quick_quit)
16103 if (!ask_if_level_has_changed ||
16105 Request("Level has changed! Exit without saving?",
16106 REQ_ASK | REQ_STAY_OPEN))
16108 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
16109 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
16111 // draw normal door
16112 UndrawSpecialEditorDoor();
16114 // use door animation if door 1 viewport is unchanged and contains toolbox
16115 if (useEditorDoorAnimation())
16116 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
16118 // close editor doors if viewport definition is the same as in main menu
16119 if (vp_door_1->x == DX &&
16120 vp_door_1->y == DY &&
16121 vp_door_1->width == DXSIZE &&
16122 vp_door_1->height == DYSIZE &&
16123 vp_door_2->x == VX &&
16124 vp_door_2->y == VY &&
16125 vp_door_2->width == VXSIZE &&
16126 vp_door_2->height == VYSIZE)
16127 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
16129 SetDoorState(DOOR_CLOSE_ALL);
16134 FadeSkipNextFadeIn();
16136 SetGameStatus(GAME_MODE_MAIN);
16142 if (!global.use_envelope_request)
16144 CloseDoor(DOOR_CLOSE_1);
16145 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);