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_ELEMENT_VALUE1_DOWN,
433 GADGET_ID_ELEMENT_VALUE1_TEXT,
434 GADGET_ID_ELEMENT_VALUE1_UP,
435 GADGET_ID_ELEMENT_VALUE2_DOWN,
436 GADGET_ID_ELEMENT_VALUE2_TEXT,
437 GADGET_ID_ELEMENT_VALUE2_UP,
438 GADGET_ID_ELEMENT_VALUE3_DOWN,
439 GADGET_ID_ELEMENT_VALUE3_TEXT,
440 GADGET_ID_ELEMENT_VALUE3_UP,
441 GADGET_ID_ELEMENT_VALUE4_DOWN,
442 GADGET_ID_ELEMENT_VALUE4_TEXT,
443 GADGET_ID_ELEMENT_VALUE4_UP,
444 GADGET_ID_YAMYAM_CONTENT_DOWN,
445 GADGET_ID_YAMYAM_CONTENT_TEXT,
446 GADGET_ID_YAMYAM_CONTENT_UP,
447 GADGET_ID_BALL_CONTENT_DOWN,
448 GADGET_ID_BALL_CONTENT_TEXT,
449 GADGET_ID_BALL_CONTENT_UP,
450 GADGET_ID_ANDROID_CONTENT_DOWN,
451 GADGET_ID_ANDROID_CONTENT_TEXT,
452 GADGET_ID_ANDROID_CONTENT_UP,
453 GADGET_ID_ENVELOPE_XSIZE_DOWN,
454 GADGET_ID_ENVELOPE_XSIZE_TEXT,
455 GADGET_ID_ENVELOPE_XSIZE_UP,
456 GADGET_ID_ENVELOPE_YSIZE_DOWN,
457 GADGET_ID_ENVELOPE_YSIZE_TEXT,
458 GADGET_ID_ENVELOPE_YSIZE_UP,
459 GADGET_ID_INVENTORY_SIZE_DOWN,
460 GADGET_ID_INVENTORY_SIZE_TEXT,
461 GADGET_ID_INVENTORY_SIZE_UP,
462 GADGET_ID_MM_BALL_CONTENT_DOWN,
463 GADGET_ID_MM_BALL_CONTENT_TEXT,
464 GADGET_ID_MM_BALL_CONTENT_UP,
465 GADGET_ID_CUSTOM_SCORE_DOWN,
466 GADGET_ID_CUSTOM_SCORE_TEXT,
467 GADGET_ID_CUSTOM_SCORE_UP,
468 GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
469 GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
470 GADGET_ID_CUSTOM_GEMCOUNT_UP,
471 GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
472 GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
473 GADGET_ID_CUSTOM_VALUE_FIX_UP,
474 GADGET_ID_CUSTOM_VALUE_RND_DOWN,
475 GADGET_ID_CUSTOM_VALUE_RND_TEXT,
476 GADGET_ID_CUSTOM_VALUE_RND_UP,
477 GADGET_ID_PUSH_DELAY_FIX_DOWN,
478 GADGET_ID_PUSH_DELAY_FIX_TEXT,
479 GADGET_ID_PUSH_DELAY_FIX_UP,
480 GADGET_ID_PUSH_DELAY_RND_DOWN,
481 GADGET_ID_PUSH_DELAY_RND_TEXT,
482 GADGET_ID_PUSH_DELAY_RND_UP,
483 GADGET_ID_DROP_DELAY_FIX_DOWN,
484 GADGET_ID_DROP_DELAY_FIX_TEXT,
485 GADGET_ID_DROP_DELAY_FIX_UP,
486 GADGET_ID_DROP_DELAY_RND_DOWN,
487 GADGET_ID_DROP_DELAY_RND_TEXT,
488 GADGET_ID_DROP_DELAY_RND_UP,
489 GADGET_ID_MOVE_DELAY_FIX_DOWN,
490 GADGET_ID_MOVE_DELAY_FIX_TEXT,
491 GADGET_ID_MOVE_DELAY_FIX_UP,
492 GADGET_ID_MOVE_DELAY_RND_DOWN,
493 GADGET_ID_MOVE_DELAY_RND_TEXT,
494 GADGET_ID_MOVE_DELAY_RND_UP,
495 GADGET_ID_STEP_DELAY_FIX_DOWN,
496 GADGET_ID_STEP_DELAY_FIX_TEXT,
497 GADGET_ID_STEP_DELAY_FIX_UP,
498 GADGET_ID_STEP_DELAY_RND_DOWN,
499 GADGET_ID_STEP_DELAY_RND_TEXT,
500 GADGET_ID_STEP_DELAY_RND_UP,
501 GADGET_ID_EXPLOSION_DELAY_DOWN,
502 GADGET_ID_EXPLOSION_DELAY_TEXT,
503 GADGET_ID_EXPLOSION_DELAY_UP,
504 GADGET_ID_IGNITION_DELAY_DOWN,
505 GADGET_ID_IGNITION_DELAY_TEXT,
506 GADGET_ID_IGNITION_DELAY_UP,
507 GADGET_ID_CHANGE_DELAY_FIX_DOWN,
508 GADGET_ID_CHANGE_DELAY_FIX_TEXT,
509 GADGET_ID_CHANGE_DELAY_FIX_UP,
510 GADGET_ID_CHANGE_DELAY_RND_DOWN,
511 GADGET_ID_CHANGE_DELAY_RND_TEXT,
512 GADGET_ID_CHANGE_DELAY_RND_UP,
513 GADGET_ID_CHANGE_CONT_RND_DOWN,
514 GADGET_ID_CHANGE_CONT_RND_TEXT,
515 GADGET_ID_CHANGE_CONT_RND_UP,
516 GADGET_ID_GROUP_CONTENT_DOWN,
517 GADGET_ID_GROUP_CONTENT_TEXT,
518 GADGET_ID_GROUP_CONTENT_UP,
520 // drawing area identifiers
522 GADGET_ID_DRAWING_LEVEL,
523 GADGET_ID_YAMYAM_CONTENT_0,
524 GADGET_ID_YAMYAM_CONTENT_1,
525 GADGET_ID_YAMYAM_CONTENT_2,
526 GADGET_ID_YAMYAM_CONTENT_3,
527 GADGET_ID_YAMYAM_CONTENT_4,
528 GADGET_ID_YAMYAM_CONTENT_5,
529 GADGET_ID_YAMYAM_CONTENT_6,
530 GADGET_ID_YAMYAM_CONTENT_7,
531 GADGET_ID_MAGIC_BALL_CONTENT_0,
532 GADGET_ID_MAGIC_BALL_CONTENT_1,
533 GADGET_ID_MAGIC_BALL_CONTENT_2,
534 GADGET_ID_MAGIC_BALL_CONTENT_3,
535 GADGET_ID_MAGIC_BALL_CONTENT_4,
536 GADGET_ID_MAGIC_BALL_CONTENT_5,
537 GADGET_ID_MAGIC_BALL_CONTENT_6,
538 GADGET_ID_MAGIC_BALL_CONTENT_7,
539 GADGET_ID_ANDROID_CONTENT,
540 GADGET_ID_AMOEBA_CONTENT,
541 GADGET_ID_START_ELEMENT,
542 GADGET_ID_ARTWORK_ELEMENT,
543 GADGET_ID_EXPLOSION_ELEMENT,
544 GADGET_ID_INVENTORY_CONTENT,
545 GADGET_ID_MM_BALL_CONTENT,
546 GADGET_ID_CUSTOM_GRAPHIC,
547 GADGET_ID_CUSTOM_CONTENT,
548 GADGET_ID_CUSTOM_MOVE_ENTER,
549 GADGET_ID_CUSTOM_MOVE_LEAVE,
550 GADGET_ID_CUSTOM_CHANGE_TARGET,
551 GADGET_ID_CUSTOM_CHANGE_CONTENT,
552 GADGET_ID_CUSTOM_CHANGE_TRIGGER,
553 GADGET_ID_CUSTOM_CHANGE_ACTION,
554 GADGET_ID_GROUP_CONTENT,
555 GADGET_ID_RANDOM_BACKGROUND,
557 // text input identifiers
559 GADGET_ID_LEVEL_NAME,
560 GADGET_ID_LEVEL_AUTHOR,
561 GADGET_ID_LEVELSET_NAME,
562 GADGET_ID_LEVELSET_AUTHOR,
563 GADGET_ID_ELEMENT_NAME,
565 // text area identifiers
567 GADGET_ID_ENVELOPE_INFO,
569 // selectbox identifiers
571 GADGET_ID_TIME_OR_STEPS,
572 GADGET_ID_TIME_SCORE_BASE,
573 GADGET_ID_GAME_ENGINE_TYPE,
574 GADGET_ID_LEVELSET_SAVE_MODE,
575 GADGET_ID_WIND_DIRECTION,
576 GADGET_ID_PLAYER_SPEED,
577 GADGET_ID_MM_BALL_CHOICE_MODE,
578 GADGET_ID_CUSTOM_WALK_TO_ACTION,
579 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
580 GADGET_ID_CUSTOM_DEADLINESS,
581 GADGET_ID_CUSTOM_MOVE_PATTERN,
582 GADGET_ID_CUSTOM_MOVE_DIRECTION,
583 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
584 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
585 GADGET_ID_CUSTOM_SMASH_TARGETS,
586 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
587 GADGET_ID_CUSTOM_ACCESS_TYPE,
588 GADGET_ID_CUSTOM_ACCESS_LAYER,
589 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
590 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
591 GADGET_ID_CHANGE_TIME_UNITS,
592 GADGET_ID_CHANGE_DIRECT_ACTION,
593 GADGET_ID_CHANGE_OTHER_ACTION,
594 GADGET_ID_CHANGE_SIDE,
595 GADGET_ID_CHANGE_PLAYER,
596 GADGET_ID_CHANGE_PAGE,
597 GADGET_ID_CHANGE_REPLACE_WHEN,
598 GADGET_ID_ACTION_TYPE,
599 GADGET_ID_ACTION_MODE,
600 GADGET_ID_ACTION_ARG,
601 GADGET_ID_SELECT_CHANGE_PAGE,
602 GADGET_ID_GROUP_CHOICE_MODE,
604 // textbutton identifiers
606 GADGET_ID_LEVELCONFIG_LEVEL,
607 GADGET_ID_LEVELCONFIG_LEVELSET,
608 GADGET_ID_LEVELCONFIG_EDITOR,
609 GADGET_ID_PROPERTIES_INFO,
610 GADGET_ID_PROPERTIES_CONFIG,
611 GADGET_ID_PROPERTIES_CONFIG_1,
612 GADGET_ID_PROPERTIES_CONFIG_2,
613 GADGET_ID_PROPERTIES_CHANGE,
614 GADGET_ID_SAVE_AS_TEMPLATE_1,
615 GADGET_ID_SAVE_AS_TEMPLATE_2,
616 GADGET_ID_SAVE_LEVELSET,
617 GADGET_ID_ADD_CHANGE_PAGE,
618 GADGET_ID_DEL_CHANGE_PAGE,
620 // graphicbutton identifiers
622 GADGET_ID_PREV_CHANGE_PAGE,
623 GADGET_ID_NEXT_CHANGE_PAGE,
624 GADGET_ID_COPY_CHANGE_PAGE,
625 GADGET_ID_PASTE_CHANGE_PAGE,
627 // gadgets for scrolling of drawing area
630 GADGET_ID_SCROLL_DOWN,
631 GADGET_ID_SCROLL_LEFT,
632 GADGET_ID_SCROLL_RIGHT,
633 GADGET_ID_SCROLL_HORIZONTAL,
634 GADGET_ID_SCROLL_VERTICAL,
636 // gadgets for scrolling element list
638 GADGET_ID_SCROLL_LIST_UP,
639 GADGET_ID_SCROLL_LIST_DOWN,
640 GADGET_ID_SCROLL_LIST_VERTICAL,
642 // checkbuttons/radiobuttons for level/element properties
644 GADGET_ID_AUTO_COUNT_GEMS,
645 GADGET_ID_RATE_TIME_OVER_SCORE,
646 GADGET_ID_USE_LEVELSET_ARTWORK,
647 GADGET_ID_COPY_LEVEL_TEMPLATE,
648 GADGET_ID_RANDOM_PERCENTAGE,
649 GADGET_ID_RANDOM_QUANTITY,
650 GADGET_ID_RANDOM_RESTRICTED,
651 GADGET_ID_STICK_ELEMENT,
652 GADGET_ID_EM_SLIPPERY_GEMS,
653 GADGET_ID_EM_EXPLODES_BY_FIRE,
654 GADGET_ID_USE_SPRING_BUG,
655 GADGET_ID_USE_TIME_ORB_BUG,
656 GADGET_ID_USE_LIFE_BUGS,
657 GADGET_ID_RANDOM_BALL_CONTENT,
658 GADGET_ID_INITIAL_BALL_ACTIVE,
659 GADGET_ID_GROW_INTO_DIGGABLE,
660 GADGET_ID_SB_FIELDS_NEEDED,
661 GADGET_ID_SB_OBJECTS_NEEDED,
662 GADGET_ID_AUTO_EXIT_SOKOBAN,
663 GADGET_ID_SOLVED_BY_ONE_PLAYER,
664 GADGET_ID_FINISH_DIG_COLLECT,
665 GADGET_ID_KEEP_WALKABLE_CE,
666 GADGET_ID_CONTINUOUS_SNAPPING,
667 GADGET_ID_BLOCK_SNAP_FIELD,
668 GADGET_ID_BLOCK_LAST_FIELD,
669 GADGET_ID_SP_BLOCK_LAST_FIELD,
670 GADGET_ID_INSTANT_RELOCATION,
671 GADGET_ID_SHIFTED_RELOCATION,
672 GADGET_ID_LAZY_RELOCATION,
673 GADGET_ID_USE_START_ELEMENT,
674 GADGET_ID_USE_ARTWORK_ELEMENT,
675 GADGET_ID_USE_EXPLOSION_ELEMENT,
676 GADGET_ID_INITIAL_GRAVITY,
677 GADGET_ID_USE_INITIAL_INVENTORY,
678 GADGET_ID_CAN_PASS_TO_WALKABLE,
679 GADGET_ID_CAN_FALL_INTO_ACID,
680 GADGET_ID_CAN_MOVE_INTO_ACID,
681 GADGET_ID_DONT_COLLIDE_WITH,
682 GADGET_ID_BD_DIAGONAL_MOVEMENTS,
683 GADGET_ID_ENVELOPE_AUTOWRAP,
684 GADGET_ID_ENVELOPE_CENTERED,
685 GADGET_ID_MM_LASER_RED,
686 GADGET_ID_MM_LASER_GREEN,
687 GADGET_ID_MM_LASER_BLUE,
688 GADGET_ID_DF_LASER_RED,
689 GADGET_ID_DF_LASER_GREEN,
690 GADGET_ID_DF_LASER_BLUE,
691 GADGET_ID_ROTATE_MM_BALL_CONTENT,
692 GADGET_ID_EXPLODE_MM_BALL,
693 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
694 GADGET_ID_CUSTOM_CAN_EXPLODE,
695 GADGET_ID_CUSTOM_EXPLODE_FIRE,
696 GADGET_ID_CUSTOM_EXPLODE_SMASH,
697 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
698 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
699 GADGET_ID_CUSTOM_DEADLY,
700 GADGET_ID_CUSTOM_CAN_MOVE,
701 GADGET_ID_CUSTOM_CAN_FALL,
702 GADGET_ID_CUSTOM_CAN_SMASH,
703 GADGET_ID_CUSTOM_SLIPPERY,
704 GADGET_ID_CUSTOM_ACCESSIBLE,
705 GADGET_ID_CUSTOM_GRAV_REACHABLE,
706 GADGET_ID_CUSTOM_USE_LAST_VALUE,
707 GADGET_ID_CUSTOM_USE_GRAPHIC,
708 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
709 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
710 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
711 GADGET_ID_CUSTOM_CAN_CHANGE,
712 GADGET_ID_CHANGE_USE_CONTENT,
713 GADGET_ID_CHANGE_USE_EXPLOSION,
714 GADGET_ID_CHANGE_ONLY_COMPLETE,
715 GADGET_ID_CHANGE_USE_RANDOM,
716 GADGET_ID_CHANGE_HAS_ACTION,
717 GADGET_ID_CHANGE_DELAY,
718 GADGET_ID_CHANGE_BY_DIRECT_ACT,
719 GADGET_ID_CHANGE_BY_OTHER_ACT,
721 NUM_STATIC_GADGET_IDS
724 // gadgets for buttons in element list (dynamic)
725 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
726 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
727 ED_NUM_ELEMENTLIST_BUTTONS - 1)
729 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
731 // radio button numbers
735 RADIO_NR_DRAWING_TOOLBOX,
736 RADIO_NR_RANDOM_ELEMENTS
739 // values for counter gadgets
742 ED_COUNTER_ID_SELECT_LEVEL,
743 ED_COUNTER_ID_LEVEL_XSIZE,
744 ED_COUNTER_ID_LEVEL_YSIZE,
745 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
746 ED_COUNTER_ID_LEVEL_TIMELIMIT,
747 ED_COUNTER_ID_LEVEL_TIMESCORE,
748 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
749 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
750 ED_COUNTER_ID_LEVEL_RANDOM,
751 ED_COUNTER_ID_ELEMENT_VALUE1,
752 ED_COUNTER_ID_ELEMENT_VALUE2,
753 ED_COUNTER_ID_ELEMENT_VALUE3,
754 ED_COUNTER_ID_ELEMENT_VALUE4,
755 ED_COUNTER_ID_YAMYAM_CONTENT,
756 ED_COUNTER_ID_BALL_CONTENT,
757 ED_COUNTER_ID_ANDROID_CONTENT,
758 ED_COUNTER_ID_ENVELOPE_XSIZE,
759 ED_COUNTER_ID_ENVELOPE_YSIZE,
760 ED_COUNTER_ID_INVENTORY_SIZE,
761 ED_COUNTER_ID_MM_BALL_CONTENT,
762 ED_COUNTER_ID_CUSTOM_SCORE,
763 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
764 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
765 ED_COUNTER_ID_CUSTOM_VALUE_RND,
766 ED_COUNTER_ID_PUSH_DELAY_FIX,
767 ED_COUNTER_ID_PUSH_DELAY_RND,
768 ED_COUNTER_ID_DROP_DELAY_FIX,
769 ED_COUNTER_ID_DROP_DELAY_RND,
770 ED_COUNTER_ID_MOVE_DELAY_FIX,
771 ED_COUNTER_ID_MOVE_DELAY_RND,
772 ED_COUNTER_ID_STEP_DELAY_FIX,
773 ED_COUNTER_ID_STEP_DELAY_RND,
774 ED_COUNTER_ID_EXPLOSION_DELAY,
775 ED_COUNTER_ID_IGNITION_DELAY,
776 ED_COUNTER_ID_GROUP_CONTENT,
777 ED_COUNTER_ID_CHANGE_DELAY_FIX,
778 ED_COUNTER_ID_CHANGE_DELAY_RND,
779 ED_COUNTER_ID_CHANGE_CONT_RND,
781 ED_NUM_COUNTERBUTTONS
784 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
785 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
786 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
787 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
788 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
789 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
791 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
792 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
793 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
794 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
795 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
796 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
798 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
799 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
801 // values for scrollbutton gadgets
804 ED_SCROLLBUTTON_ID_AREA_UP,
805 ED_SCROLLBUTTON_ID_AREA_DOWN,
806 ED_SCROLLBUTTON_ID_AREA_LEFT,
807 ED_SCROLLBUTTON_ID_AREA_RIGHT,
808 ED_SCROLLBUTTON_ID_LIST_UP,
809 ED_SCROLLBUTTON_ID_LIST_DOWN,
814 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
815 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
817 // values for scrollbar gadgets
820 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
821 ED_SCROLLBAR_ID_AREA_VERTICAL,
822 ED_SCROLLBAR_ID_LIST_VERTICAL,
827 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
828 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
830 // values for text input gadgets
833 ED_TEXTINPUT_ID_LEVEL_NAME,
834 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
835 ED_TEXTINPUT_ID_LEVELSET_NAME,
836 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
837 ED_TEXTINPUT_ID_ELEMENT_NAME,
842 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
843 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
845 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
846 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
848 // values for text area gadgets
851 ED_TEXTAREA_ID_ENVELOPE_INFO,
856 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
857 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
859 // values for selectbox gadgets
862 ED_SELECTBOX_ID_TIME_OR_STEPS,
863 ED_SELECTBOX_ID_TIME_SCORE_BASE,
864 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
865 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
866 ED_SELECTBOX_ID_WIND_DIRECTION,
867 ED_SELECTBOX_ID_PLAYER_SPEED,
868 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
869 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
870 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
871 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
872 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
873 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
874 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
875 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
876 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
877 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
878 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
879 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
880 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
881 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
882 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
883 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
884 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
885 ED_SELECTBOX_ID_CHANGE_SIDE,
886 ED_SELECTBOX_ID_CHANGE_PLAYER,
887 ED_SELECTBOX_ID_CHANGE_PAGE,
888 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
889 ED_SELECTBOX_ID_ACTION_TYPE,
890 ED_SELECTBOX_ID_ACTION_MODE,
891 ED_SELECTBOX_ID_ACTION_ARG,
892 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
893 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
898 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
899 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
901 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
902 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
904 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
905 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
906 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
907 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
908 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
909 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
911 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
912 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
914 // values for textbutton gadgets
917 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
918 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
919 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
920 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
921 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
922 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
923 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
924 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
925 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
926 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
927 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
928 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
929 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
934 #define ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
935 #define ED_TAB_BUTTON_ID_LEVELCONFIG_LAST ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
937 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
938 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
940 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
941 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
943 // values for graphicbutton gadgets
946 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
947 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
948 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
949 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
951 ED_NUM_GRAPHICBUTTONS
954 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
955 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
957 // values for checkbutton gadgets
960 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
961 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
962 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
963 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
964 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
965 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
966 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
967 ED_CHECKBUTTON_ID_STICK_ELEMENT,
968 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
969 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
970 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
971 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
972 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
973 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
974 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
975 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
976 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
977 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
978 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
979 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
980 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
981 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
982 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
983 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
984 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
985 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
986 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
987 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
988 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
989 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
990 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
991 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
992 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
993 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
994 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
995 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
996 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
997 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
998 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
999 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
1000 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
1001 ED_CHECKBUTTON_ID_MM_LASER_RED,
1002 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
1003 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1004 ED_CHECKBUTTON_ID_DF_LASER_RED,
1005 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1006 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1007 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
1008 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
1009 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1010 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1011 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1012 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1013 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1014 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1015 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1016 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1017 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1018 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1019 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1020 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1021 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1022 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1023 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1024 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1025 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1026 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1027 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1028 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1029 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1030 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1031 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1032 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1033 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1038 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1039 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1041 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1042 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1044 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1045 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1047 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1048 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1049 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1050 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1051 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1052 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1054 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1055 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1057 // values for radiobutton gadgets
1060 ED_RADIOBUTTON_ID_PERCENTAGE,
1061 ED_RADIOBUTTON_ID_QUANTITY,
1066 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1067 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1069 // values for drawing area gadgets
1072 ED_DRAWING_ID_DRAWING_LEVEL,
1073 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1074 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1075 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1076 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1077 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1078 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1079 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1080 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1081 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1082 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1083 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1084 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1085 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1086 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1087 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1088 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1089 ED_DRAWING_ID_ANDROID_CONTENT,
1090 ED_DRAWING_ID_AMOEBA_CONTENT,
1091 ED_DRAWING_ID_START_ELEMENT,
1092 ED_DRAWING_ID_ARTWORK_ELEMENT,
1093 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1094 ED_DRAWING_ID_INVENTORY_CONTENT,
1095 ED_DRAWING_ID_MM_BALL_CONTENT,
1096 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1097 ED_DRAWING_ID_CUSTOM_CONTENT,
1098 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1099 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1100 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1101 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1102 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1103 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1104 ED_DRAWING_ID_GROUP_CONTENT,
1105 ED_DRAWING_ID_RANDOM_BACKGROUND,
1107 ED_NUM_DRAWING_AREAS
1110 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1111 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1114 // ----------------------------------------------------------------------------
1115 // some internally used definitions
1116 // ----------------------------------------------------------------------------
1118 // values for CopyLevelToUndoBuffer()
1119 #define UNDO_IMMEDIATE 0
1120 #define UNDO_ACCUMULATE 1
1122 // values for scrollbars
1123 #define ED_SCROLL_NO 0
1124 #define ED_SCROLL_LEFT 1
1125 #define ED_SCROLL_RIGHT 2
1126 #define ED_SCROLL_UP 4
1127 #define ED_SCROLL_DOWN 8
1129 // screens in the level editor
1130 #define ED_MODE_DRAWING 0
1131 #define ED_MODE_LEVELCONFIG 1
1132 #define ED_MODE_PROPERTIES 2
1133 #define ED_MODE_PALETTE 3
1135 // sub-screens in the global settings section
1136 #define ED_MODE_LEVELCONFIG_LEVEL ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
1137 #define ED_MODE_LEVELCONFIG_LEVELSET ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET
1138 #define ED_MODE_LEVELCONFIG_EDITOR ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
1140 // sub-screens in the element properties section
1141 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1142 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1143 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1144 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1145 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1147 // how many steps can be cancelled
1148 #define NUM_UNDO_STEPS (64 + 1)
1150 // values for elements with score for certain actions
1152 #define MAX_SCORE 999
1154 // values for elements with count for collecting
1155 #define MIN_COLLECT_COUNT 0
1156 #define MAX_COLLECT_COUNT 999
1158 // values for random placement
1159 #define RANDOM_USE_PERCENTAGE 0
1160 #define RANDOM_USE_QUANTITY 1
1162 // values for level set save mode
1163 #define LEVELSET_SAVE_MODE_UPDATE 0
1164 #define LEVELSET_SAVE_MODE_CREATE 1
1166 // default value for element tile size in drawing area
1167 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1168 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1171 // ----------------------------------------------------------------------------
1172 // some internally used data structure definitions
1173 // ----------------------------------------------------------------------------
1179 struct XYTileSize *pos;
1183 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1185 // note: some additional characters are already reserved for "cheat mode"
1186 // shortcuts (":XYZ" style) -- for details, see "events.c"
1188 // ---------- toolbox control buttons ---------------------------------------
1191 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1192 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1193 "draw single items", 's'
1196 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1197 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1198 "draw connected items", 'd'
1201 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1202 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1206 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1207 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1211 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1212 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1213 "draw outline rectangles", 'r'
1216 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1217 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1218 "draw filled rectangles", 'R'
1221 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1222 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1223 "wrap (rotate) level up", 0
1226 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1227 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1228 "enter text elements", 't'
1231 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1232 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1236 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1237 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1238 "wrap (rotate) level left", 0
1241 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1242 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1243 "zoom level tile size", '+'
1246 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1247 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1248 "wrap (rotate) level right", 0
1251 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1252 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1253 "random element placement", 0
1256 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1257 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1261 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1262 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1263 "wrap (rotate) level down", 0
1266 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1267 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1268 "pick drawing element", ','
1271 // ---------- level control buttons -----------------------------------------
1274 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1275 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1276 "undo/redo last operation", 'u'
1279 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_CONF,
1280 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1281 "level and editor settings", 'I'
1284 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1285 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1289 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1290 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1294 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1295 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1299 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1300 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1301 "exit level editor", 'E'
1304 // ---------- CE and GE control buttons -------------------------------------
1307 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1308 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1309 "copy settings from other element", 0
1312 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1313 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1314 "copy settings to other element", 0
1317 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1318 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1319 "exchange element with other element", 0
1322 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1323 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1324 "copy settings from this element", 0
1327 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1328 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1329 "paste settings to this element", 0
1332 // ---------- palette control buttons ---------------------------------------
1335 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1336 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1337 "properties of drawing element", 'p'
1340 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1341 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1342 "properties of drawing element 1", '1'
1345 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1346 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1347 "properties of drawing element 2", '2'
1350 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1351 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1352 "properties of drawing element 3", '3'
1355 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1356 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1357 "show list of elements", 'e'
1361 static int random_placement_value = 10;
1362 static int random_placement_method = RANDOM_USE_QUANTITY;
1363 static int random_placement_background_element = EL_SAND;
1364 static boolean random_placement_background_restricted = FALSE;
1365 static boolean stick_element_properties_window = FALSE;
1366 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1367 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1368 static struct ElementChangeInfo custom_element_change;
1369 static struct ElementGroupInfo group_element_info;
1370 static struct ElementInfo custom_element;
1372 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1373 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1374 static int levelset_num_levels = 100;
1375 static boolean levelset_use_levelset_artwork = FALSE;
1376 static boolean levelset_copy_level_template = FALSE;
1377 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1383 int min_value, max_value;
1384 int gadget_id_down, gadget_id_up;
1386 int gadget_id_align;
1388 char *text_above, *text_left, *text_right;
1389 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1391 // ---------- current level number ------------------------------------------
1394 ED_COUNTER_ID_SELECT_LEVEL,
1395 -1, -1, // these values are not constant, but can change at runtime
1397 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1398 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1403 // ---------- level and editor settings -------------------------------------
1406 ED_COUNTER_ID_LEVEL_XSIZE,
1407 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1408 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1409 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1410 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1412 "playfield size:", NULL, "width",
1415 ED_COUNTER_ID_LEVEL_YSIZE,
1416 -1, ED_LEVEL_SETTINGS_YPOS(4),
1417 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1418 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1419 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1421 NULL, " ", "height",
1424 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
1425 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1427 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1428 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1430 NULL, "number of gems to collect:", NULL
1433 ED_COUNTER_ID_LEVEL_TIMELIMIT,
1434 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1436 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1437 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1439 "time or step limit to solve level:", NULL, NULL
1442 ED_COUNTER_ID_LEVEL_TIMESCORE,
1443 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1445 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1446 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1447 &level.score[SC_TIME_BONUS],
1448 "score for time or steps left:", NULL, NULL
1451 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
1452 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1454 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1455 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1457 NULL, "random seed:", "(0 => random)"
1460 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
1461 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1463 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1464 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1465 &levelset_num_levels,
1466 "number of levels:", NULL, NULL,
1469 ED_COUNTER_ID_LEVEL_RANDOM,
1470 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1472 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1473 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1474 &random_placement_value,
1475 "random element placement:", NULL, "in"
1478 // ---------- element settings: configure (various elements) ----------------
1481 ED_COUNTER_ID_ELEMENT_VALUE1,
1482 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1483 MIN_SCORE, MAX_SCORE,
1484 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1485 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1486 NULL, // will be set when used
1490 ED_COUNTER_ID_ELEMENT_VALUE2,
1491 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1492 MIN_SCORE, MAX_SCORE,
1493 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1494 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1495 NULL, // will be set when used
1499 ED_COUNTER_ID_ELEMENT_VALUE3,
1500 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1501 MIN_SCORE, MAX_SCORE,
1502 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1503 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1504 NULL, // will be set when used
1508 ED_COUNTER_ID_ELEMENT_VALUE4,
1509 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1510 MIN_SCORE, MAX_SCORE,
1511 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1512 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1513 NULL, // will be set when used
1517 ED_COUNTER_ID_YAMYAM_CONTENT,
1518 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1519 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1520 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1521 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1522 &level.num_yamyam_contents,
1523 NULL, NULL, "number of content areas"
1526 ED_COUNTER_ID_BALL_CONTENT,
1527 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1528 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1529 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1530 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1531 &level.num_ball_contents,
1532 NULL, NULL, "number of content areas"
1535 ED_COUNTER_ID_ANDROID_CONTENT,
1536 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1537 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1538 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1539 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1540 &level.num_android_clone_elements,
1541 NULL, NULL, "number of clonable elements"
1544 ED_COUNTER_ID_ENVELOPE_XSIZE,
1545 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1546 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1547 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1548 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1549 NULL, // will be set when used
1550 NULL, NULL, "width",
1553 ED_COUNTER_ID_ENVELOPE_YSIZE,
1554 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1555 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1556 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1557 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1558 NULL, // will be set when used
1559 NULL, " ", "height",
1562 ED_COUNTER_ID_INVENTORY_SIZE,
1563 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1564 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1565 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1566 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1567 &level.initial_inventory_size[0],
1568 NULL, NULL, "number of inventory elements"
1571 ED_COUNTER_ID_MM_BALL_CONTENT,
1572 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1573 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1574 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1575 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1576 &level.num_mm_ball_contents,
1577 NULL, NULL, "number of content elements"
1580 // ---------- element settings: configure 1 (custom elements) ---------------
1583 ED_COUNTER_ID_CUSTOM_SCORE,
1584 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1585 MIN_SCORE, MAX_SCORE,
1586 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1587 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1588 &custom_element.collect_score_initial,
1589 NULL, "CE score", " "
1592 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
1593 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1594 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1595 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1596 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1597 &custom_element.collect_count_initial,
1598 NULL, "CE count", NULL
1601 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
1602 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1604 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1605 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1606 &custom_element.ce_value_fixed_initial,
1607 NULL, "CE value", NULL
1610 ED_COUNTER_ID_CUSTOM_VALUE_RND,
1611 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1613 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1614 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1615 &custom_element.ce_value_random_initial,
1616 NULL, "+random", NULL
1619 ED_COUNTER_ID_PUSH_DELAY_FIX,
1620 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1622 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1623 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1624 &custom_element.push_delay_fixed,
1625 NULL, "push delay", NULL
1628 ED_COUNTER_ID_PUSH_DELAY_RND,
1629 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1631 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1632 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1633 &custom_element.push_delay_random,
1634 NULL, "+random", NULL
1637 ED_COUNTER_ID_DROP_DELAY_FIX,
1638 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1640 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1641 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1642 &custom_element.drop_delay_fixed,
1643 NULL, "drop delay", NULL
1646 ED_COUNTER_ID_DROP_DELAY_RND,
1647 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1649 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1650 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1651 &custom_element.drop_delay_random,
1652 NULL, "+random", NULL
1655 // ---------- element settings: configure 2 (custom elements) ---------------
1658 ED_COUNTER_ID_MOVE_DELAY_FIX,
1659 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1661 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1662 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1663 &custom_element.move_delay_fixed,
1664 NULL, "move delay", NULL
1667 ED_COUNTER_ID_MOVE_DELAY_RND,
1668 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1670 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1671 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1672 &custom_element.move_delay_random,
1673 NULL, "+random", NULL
1676 ED_COUNTER_ID_STEP_DELAY_FIX,
1677 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1679 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1680 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1681 &custom_element.step_delay_fixed,
1682 NULL, "step delay", NULL
1685 ED_COUNTER_ID_STEP_DELAY_RND,
1686 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1688 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1689 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1690 &custom_element.step_delay_random,
1691 NULL, "+random", NULL
1694 ED_COUNTER_ID_EXPLOSION_DELAY,
1695 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1697 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1698 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1699 &custom_element.explosion_delay,
1700 NULL, "explosion delay", NULL
1703 ED_COUNTER_ID_IGNITION_DELAY,
1704 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1706 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1707 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1708 &custom_element.ignition_delay,
1709 NULL, "ignition delay", "(by fire)"
1712 // ---------- element settings: configure (group elements) ------------------
1715 ED_COUNTER_ID_GROUP_CONTENT,
1716 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1717 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1718 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1719 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1720 &group_element_info.num_elements,
1721 NULL, NULL, "number of elements in group"
1724 // ---------- element settings: advanced (custom elements) ------------------
1727 ED_COUNTER_ID_CHANGE_DELAY_FIX,
1728 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1730 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1731 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1732 &custom_element_change.delay_fixed,
1733 NULL, "CE delay", NULL,
1736 ED_COUNTER_ID_CHANGE_DELAY_RND,
1737 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1739 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1740 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1741 &custom_element_change.delay_random,
1742 NULL, "+random", NULL
1745 ED_COUNTER_ID_CHANGE_CONT_RND,
1746 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1748 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1749 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1750 &custom_element_change.random_percentage,
1751 NULL, "use random replace:", "%"
1762 char *text_above, *infotext;
1763 } textinput_info[ED_NUM_TEXTINPUT] =
1766 ED_TEXTINPUT_ID_LEVEL_NAME,
1767 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1768 GADGET_ID_LEVEL_NAME,
1771 "Title:", "Title for this level"
1774 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
1775 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1776 GADGET_ID_LEVEL_AUTHOR,
1777 MAX_LEVEL_AUTHOR_LEN,
1779 "Author:", "Author for this level"
1782 ED_TEXTINPUT_ID_LEVELSET_NAME,
1783 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1784 GADGET_ID_LEVELSET_NAME,
1787 "Title:", "Title for this or new level set"
1790 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
1791 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1792 GADGET_ID_LEVELSET_AUTHOR,
1793 MAX_LEVEL_AUTHOR_LEN,
1795 "Author:", "Author for this or new level set"
1798 ED_TEXTINPUT_ID_ELEMENT_NAME,
1799 -1, -1, // these values are not constant, but can change at runtime
1800 GADGET_ID_ELEMENT_NAME,
1801 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1802 custom_element.description,
1803 NULL, "Element name"
1814 char *text_above, *text_above_cropped, *infotext;
1815 } textarea_info[ED_NUM_TEXTAREAS] =
1818 ED_TEXTAREA_ID_ENVELOPE_INFO,
1819 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1820 GADGET_ID_ENVELOPE_INFO,
1821 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1823 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1827 static struct ValueTextInfo options_time_or_steps[] =
1835 static struct ValueTextInfo options_time_score_base[] =
1837 { 1, "per second/step" },
1838 { 10, "per 10 seconds/steps" },
1843 static struct ValueTextInfo options_game_engine_type[] =
1845 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1846 { GAME_ENGINE_TYPE_BD, "Boulder Dash" },
1847 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1848 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1849 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1854 static struct ValueTextInfo options_levelset_save_mode[] =
1856 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1857 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1862 static struct ValueTextInfo options_wind_direction[] =
1864 { MV_START_NONE, "none" },
1865 { MV_START_LEFT, "left" },
1866 { MV_START_RIGHT, "right" },
1867 { MV_START_UP, "up" },
1868 { MV_START_DOWN, "down" },
1873 static struct ValueTextInfo options_player_speed[] =
1880 { 16, "very fast" },
1881 { 32, "ultrafast" },
1886 static struct ValueTextInfo options_access_type[] =
1888 { EP_WALKABLE, "walkable" },
1889 { EP_PASSABLE, "passable" },
1894 static struct ValueTextInfo options_access_layer[] =
1896 { EP_ACCESSIBLE_OVER, "over" },
1897 { EP_ACCESSIBLE_INSIDE, "inside" },
1898 { EP_ACCESSIBLE_UNDER, "under" },
1903 static struct ValueTextInfo options_access_protected[] =
1905 { 0, "unprotected" },
1911 static struct ValueTextInfo options_access_direction[] =
1913 { MV_NO_DIRECTION, "no direction" },
1914 { MV_LEFT, "left" },
1915 { MV_RIGHT, "right" },
1917 { MV_DOWN, "down" },
1918 { MV_LEFT | MV_UP, "left + up" },
1919 { MV_LEFT | MV_DOWN, "left + down" },
1920 { MV_RIGHT | MV_UP, "right + up" },
1921 { MV_RIGHT | MV_DOWN, "right + down" },
1922 { MV_HORIZONTAL, "horizontal" },
1923 { MV_VERTICAL, "vertical" },
1924 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1925 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1926 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1927 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1928 { MV_ALL_DIRECTIONS, "all directions" },
1933 static struct ValueTextInfo options_walk_to_action[] =
1935 { EP_DIGGABLE, "diggable" },
1936 { EP_COLLECTIBLE_ONLY, "collectible" },
1937 { EP_DROPPABLE, "collectible & droppable" },
1938 { EP_THROWABLE, "collectible & throwable" },
1939 { EP_PUSHABLE, "pushable" },
1944 static struct ValueTextInfo options_move_pattern[] =
1946 { MV_LEFT, "left" },
1947 { MV_RIGHT, "right" },
1949 { MV_DOWN, "down" },
1950 { MV_HORIZONTAL, "horizontal" },
1951 { MV_VERTICAL, "vertical" },
1952 { MV_ALL_DIRECTIONS, "all directions" },
1953 { MV_WIND_DIRECTION, "wind direction" },
1954 { MV_TOWARDS_PLAYER, "towards player" },
1955 { MV_AWAY_FROM_PLAYER, "away from player" },
1956 { MV_ALONG_LEFT_SIDE, "along left side" },
1957 { MV_ALONG_RIGHT_SIDE, "along right side" },
1958 { MV_TURNING_LEFT, "turning left" },
1959 { MV_TURNING_RIGHT, "turning right" },
1960 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1961 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1962 { MV_TURNING_RANDOM, "turning random" },
1963 { MV_MAZE_RUNNER, "maze runner style" },
1964 { MV_MAZE_HUNTER, "maze hunter style" },
1965 { MV_WHEN_PUSHED, "when pushed" },
1966 { MV_WHEN_DROPPED, "when dropped/thrown" },
1971 static struct ValueTextInfo options_move_direction[] =
1973 { MV_START_AUTOMATIC, "automatic" },
1974 { MV_START_LEFT, "left" },
1975 { MV_START_RIGHT, "right" },
1976 { MV_START_UP, "up" },
1977 { MV_START_DOWN, "down" },
1978 { MV_START_RANDOM, "random" },
1979 { MV_START_PREVIOUS, "previous" },
1984 static struct ValueTextInfo options_move_stepsize[] =
1986 { 0, "not moving" },
1991 { 16, "very fast" },
1992 { 32, "even faster" },
1997 static struct ValueTextInfo options_move_leave_type[] =
1999 { LEAVE_TYPE_UNLIMITED, "leave behind" },
2000 { LEAVE_TYPE_LIMITED, "change it to" },
2005 static struct ValueTextInfo options_smash_targets[] =
2007 { EP_CAN_SMASH_PLAYER, "player" },
2009 { EP_CAN_SMASH_ENEMIES, "enemies" },
2011 { EP_CAN_SMASH_EVERYTHING, "everything" },
2016 static struct ValueTextInfo options_slippery_type[] =
2018 { SLIPPERY_ANY_RANDOM, "random" },
2019 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
2020 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
2021 { SLIPPERY_ONLY_LEFT, "only left" },
2022 { SLIPPERY_ONLY_RIGHT, "only right" },
2027 static struct ValueTextInfo options_deadliness[] =
2029 { EP_DONT_RUN_INTO, "running into" },
2030 { EP_DONT_COLLIDE_WITH, "colliding with" },
2031 { EP_DONT_GET_HIT_BY, "getting hit by" },
2032 { EP_DONT_TOUCH, "touching" },
2037 static struct ValueTextInfo options_explosion_type[] =
2039 { EXPLODES_3X3, "3x3" },
2040 { EXPLODES_CROSS, "3+3" },
2041 { EXPLODES_1X1, "1x1" },
2046 static struct ValueTextInfo options_time_units[] =
2049 { FRAMES_PER_SECOND, "seconds" },
2054 static struct ValueTextInfo options_change_direct_action[] =
2056 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2057 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2058 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2059 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2060 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2061 { CE_ENTERED_BY_PLAYER, "entered by player" },
2062 { CE_LEFT_BY_PLAYER, "left by player" },
2063 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2064 { CE_SWITCHED, "switched" },
2065 { CE_HITTING_SOMETHING, "hitting something" },
2066 { CE_HIT_BY_SOMETHING, "hit by something" },
2068 { CE_BLOCKED, "blocked" },
2070 { CE_IMPACT, "impact (on something)" },
2071 { CE_SMASHED, "smashed (from above)" },
2073 { CE_VALUE_CHANGES, "CE value changes" },
2074 { CE_SCORE_CHANGES, "CE score changes" },
2076 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2077 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2078 { CE_UNDEFINED, " " },
2079 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2080 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2081 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2082 { CE_UNDEFINED, " " },
2083 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2084 { CE_NEXT_TO_PLAYER, "next to player" },
2089 static struct ValueTextInfo options_change_other_action[] =
2091 { CE_PLAYER_TOUCHES_X, "player touches" },
2092 { CE_PLAYER_PRESSES_X, "player presses" },
2093 { CE_PLAYER_SWITCHES_X, "player switches" },
2094 { CE_PLAYER_SNAPS_X, "player snaps" },
2095 { CE_PLAYER_PUSHES_X, "player pushes" },
2096 { CE_PLAYER_ENTERS_X, "player enters" },
2097 { CE_PLAYER_LEAVES_X, "player leaves" },
2098 { CE_PLAYER_DIGS_X, "player digs" },
2099 { CE_PLAYER_COLLECTS_X, "player collects" },
2100 { CE_PLAYER_DROPS_X, "player drops/throws" },
2101 { CE_TOUCHING_X, "touching" },
2102 { CE_HITTING_X, "hitting" },
2103 { CE_DIGGING_X, "digging" },
2104 { CE_HIT_BY_X, "hit by" },
2105 { CE_SWITCH_OF_X, "switch of" },
2106 { CE_CHANGE_OF_X, "change by page of" },
2107 { CE_EXPLOSION_OF_X, "explosion of" },
2108 { CE_MOVE_OF_X, "move of" },
2109 { CE_CREATION_OF_X, "creation of" },
2110 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2111 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2112 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2113 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2114 { CE_UNDEFINED, " " },
2115 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2116 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2117 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2118 { CE_UNDEFINED, " " },
2119 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2120 { CE_PLAYER_NEXT_TO_X, "player next to" },
2121 { CE_NEXT_TO_X, "next to" },
2126 static struct ValueTextInfo options_change_trigger_side[] =
2128 { CH_SIDE_LEFT, "left" },
2129 { CH_SIDE_RIGHT, "right" },
2130 { CH_SIDE_TOP, "top" },
2131 { CH_SIDE_BOTTOM, "bottom" },
2132 { CH_SIDE_LEFT_RIGHT, "left/right" },
2133 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2134 { CH_SIDE_ANY, "any" },
2139 static struct ValueTextInfo options_change_trigger_player[] =
2141 { CH_PLAYER_1, "1" },
2142 { CH_PLAYER_2, "2" },
2143 { CH_PLAYER_3, "3" },
2144 { CH_PLAYER_4, "4" },
2145 { CH_PLAYER_ANY, "any" },
2150 static struct ValueTextInfo options_change_trigger_page[] =
2161 { (1u << 9), "10" },
2162 { (1u << 10), "11" },
2163 { (1u << 11), "12" },
2164 { (1u << 12), "13" },
2165 { (1u << 13), "14" },
2166 { (1u << 14), "15" },
2167 { (1u << 15), "16" },
2168 { (1u << 16), "17" },
2169 { (1u << 17), "18" },
2170 { (1u << 18), "19" },
2171 { (1u << 19), "20" },
2172 { (1u << 20), "21" },
2173 { (1u << 21), "22" },
2174 { (1u << 22), "23" },
2175 { (1u << 23), "24" },
2176 { (1u << 24), "25" },
2177 { (1u << 25), "26" },
2178 { (1u << 26), "27" },
2179 { (1u << 27), "28" },
2180 { (1u << 28), "29" },
2181 { (1u << 29), "30" },
2182 { (1u << 30), "31" },
2183 { (1u << 31), "32" },
2184 { CH_PAGE_ANY, "any" },
2189 static struct ValueTextInfo options_change_replace_when[] =
2191 { CP_WHEN_EMPTY, "empty" },
2192 { CP_WHEN_WALKABLE, "walkable" },
2193 { CP_WHEN_DIGGABLE, "diggable" },
2194 { CP_WHEN_COLLECTIBLE, "collectible" },
2195 { CP_WHEN_REMOVABLE, "removable" },
2196 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2201 static struct ValueTextInfo options_action_type[] =
2203 { CA_NO_ACTION, "no action" },
2204 { CA_UNDEFINED, " " },
2205 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2206 { CA_RESTART_LEVEL, "restart level" },
2207 { CA_SHOW_ENVELOPE, "show envelope" },
2208 { CA_SET_LEVEL_TIME, "set time" },
2209 { CA_SET_LEVEL_SCORE, "set score" },
2210 { CA_SET_LEVEL_GEMS, "set gems" },
2211 { CA_SET_LEVEL_WIND, "set wind dir." },
2212 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2213 { CA_UNDEFINED, " " },
2214 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2215 { CA_MOVE_PLAYER, "move player" },
2216 { CA_MOVE_PLAYER_NEW, "move player new" },
2217 { CA_EXIT_PLAYER, "exit player" },
2218 { CA_KILL_PLAYER, "kill player" },
2219 { CA_SET_PLAYER_KEYS, "set keys" },
2220 { CA_SET_PLAYER_SPEED, "set speed" },
2221 { CA_SET_PLAYER_SHIELD, "set shield" },
2222 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2223 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2224 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2225 { CA_UNDEFINED, " " },
2226 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2227 { CA_SET_CE_VALUE, "set CE value" },
2228 { CA_SET_CE_SCORE, "set CE score" },
2229 { CA_SET_CE_ARTWORK, "set CE artwork" },
2230 { CA_UNDEFINED, " " },
2231 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2232 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2237 static struct ValueTextInfo options_action_mode_none[] =
2239 { CA_MODE_UNDEFINED, " " },
2244 static struct ValueTextInfo options_action_mode_assign[] =
2246 { CA_MODE_SET, "=" },
2251 static struct ValueTextInfo options_action_mode_add_remove[] =
2253 { CA_MODE_ADD, "+" },
2254 { CA_MODE_SUBTRACT, "-" },
2259 static struct ValueTextInfo options_action_mode_calculate[] =
2261 { CA_MODE_SET, "=" },
2262 { CA_MODE_ADD, "+" },
2263 { CA_MODE_SUBTRACT, "-" },
2264 { CA_MODE_MULTIPLY, "*" },
2265 { CA_MODE_DIVIDE, "/" },
2266 { CA_MODE_MODULO, "%" },
2271 static struct ValueTextInfo options_action_arg_none[] =
2273 { CA_ARG_UNDEFINED, " " },
2278 static struct ValueTextInfo options_action_arg_player[] =
2280 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2281 { CA_ARG_PLAYER_1, "1" },
2282 { CA_ARG_PLAYER_2, "2" },
2283 { CA_ARG_PLAYER_3, "3" },
2284 { CA_ARG_PLAYER_4, "4" },
2285 { CA_ARG_PLAYER_ANY, "any" },
2286 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2287 { CA_ARG_PLAYER_ACTION, "action ->" },
2292 static struct ValueTextInfo options_action_arg_number[] =
2294 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2301 { CA_ARG_10, "10" },
2302 { CA_ARG_100, "100" },
2303 { CA_ARG_1000, "1000" },
2304 { CA_ARG_UNDEFINED, " " },
2305 { CA_ARG_NUMBER_MIN, "min" },
2306 { CA_ARG_NUMBER_MAX, "max" },
2307 { CA_ARG_UNDEFINED, " " },
2308 { CA_ARG_NUMBER_RESET, "reset" },
2309 { CA_ARG_UNDEFINED, " " },
2310 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2311 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2312 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2313 { CA_ARG_UNDEFINED, " " },
2314 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2315 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2316 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2317 { CA_ARG_UNDEFINED, " " },
2318 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2319 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2320 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2321 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2322 { CA_ARG_UNDEFINED, " " },
2323 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2324 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2325 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2326 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2331 static struct ValueTextInfo options_action_arg_value[] =
2333 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2340 { CA_ARG_10, "10" },
2341 { CA_ARG_100, "100" },
2342 { CA_ARG_1000, "1000" },
2343 { CA_ARG_UNDEFINED, " " },
2344 { CA_ARG_NUMBER_MIN, "min" },
2345 { CA_ARG_NUMBER_MAX, "max" },
2346 { CA_ARG_UNDEFINED, " " },
2347 { CA_ARG_NUMBER_RESET, "reset" },
2348 { CA_ARG_UNDEFINED, " " },
2349 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2350 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2351 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2352 { CA_ARG_UNDEFINED, " " },
2353 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2354 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2355 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2356 { CA_ARG_UNDEFINED, " " },
2357 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2358 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2359 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2360 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2361 { CA_ARG_UNDEFINED, " " },
2362 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2363 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2364 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2365 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2366 { CA_ARG_UNDEFINED, " " },
2367 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2368 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2369 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2370 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2375 static struct ValueTextInfo options_action_arg_envelope[] =
2377 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2382 { CA_ARG_UNDEFINED, " " },
2383 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2384 { CA_ARG_ELEMENT_TARGET, "target" },
2385 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2386 { CA_ARG_ELEMENT_ACTION, "action ->" },
2391 static struct ValueTextInfo options_action_arg_key[] =
2393 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2402 { CA_ARG_UNDEFINED, " " },
2403 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2404 { CA_ARG_ELEMENT_TARGET, "target" },
2405 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2406 { CA_ARG_ELEMENT_ACTION, "action ->" },
2411 static struct ValueTextInfo options_action_arg_speed[] =
2413 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2414 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2415 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2416 { CA_ARG_SPEED_SLOW, "slow" },
2417 { CA_ARG_SPEED_NORMAL, "normal" },
2418 { CA_ARG_SPEED_FAST, "fast" },
2419 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2420 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2421 { CA_ARG_UNDEFINED, " " },
2422 { CA_ARG_SPEED_SLOWER, "slower" },
2423 { CA_ARG_SPEED_FASTER, "faster" },
2424 { CA_ARG_UNDEFINED, " " },
2425 { CA_ARG_SPEED_RESET, "reset" },
2430 static struct ValueTextInfo options_action_arg_shield[] =
2432 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2433 { CA_ARG_SHIELD_OFF, "off" },
2434 { CA_ARG_SHIELD_NORMAL, "normal" },
2435 { CA_ARG_SHIELD_DEADLY, "deadly" },
2440 static struct ValueTextInfo options_action_arg_artwork[] =
2442 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2443 { CA_ARG_ELEMENT_TARGET, "target" },
2444 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2445 { CA_ARG_ELEMENT_ACTION, "action ->" },
2446 { CA_ARG_UNDEFINED, " " },
2447 { CA_ARG_ELEMENT_RESET, "reset" },
2452 static struct ValueTextInfo options_action_arg_gravity[] =
2454 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2455 { CA_ARG_GRAVITY_ON, "on" },
2456 { CA_ARG_GRAVITY_OFF, "off" },
2457 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2462 static struct ValueTextInfo options_action_arg_direction[] =
2464 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2465 { CA_ARG_DIRECTION_NONE, "none" },
2466 { CA_ARG_DIRECTION_LEFT, "left" },
2467 { CA_ARG_DIRECTION_RIGHT, "right" },
2468 { CA_ARG_DIRECTION_UP, "up" },
2469 { CA_ARG_DIRECTION_DOWN, "down" },
2470 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2471 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2476 static struct ValueTextInfo options_action_arg_scan_mode[] =
2478 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2479 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2480 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2485 static struct ValueTextInfo options_action_arg_inventory[] =
2487 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2488 { CA_ARG_ELEMENT_TARGET, "+ target" },
2489 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2490 { CA_ARG_ELEMENT_ACTION, "+ action" },
2491 { CA_ARG_UNDEFINED, " " },
2492 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2493 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2494 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2495 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2496 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2497 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2498 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2499 { CA_ARG_UNDEFINED, " " },
2500 { CA_ARG_INVENTORY_RESET, "reset" },
2505 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2506 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2511 static struct ValueTextInfo options_group_choice_mode[] =
2513 { ANIM_RANDOM, "random" },
2514 { ANIM_LOOP, "loop" },
2515 { ANIM_LINEAR, "linear" },
2516 { ANIM_PINGPONG, "pingpong" },
2517 { ANIM_PINGPONG2, "pingpong 2" },
2518 { ANIM_LEVEL_NR, "level number" },
2523 static struct ValueTextInfo *action_arg_modes[] =
2525 options_action_mode_none,
2526 options_action_mode_assign,
2527 options_action_mode_add_remove,
2528 options_action_mode_calculate,
2535 struct ValueTextInfo *options;
2537 action_arg_options[] =
2539 { CA_NO_ACTION, 0, options_action_arg_none, },
2540 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2541 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2542 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2543 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2544 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2545 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2546 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2547 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2548 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2549 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2550 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2551 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2552 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2553 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2554 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2555 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2556 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2557 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2558 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2559 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2560 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2570 int gadget_id_align;
2571 int size; // char size of selectbox or '-1' (dynamically determined)
2572 struct ValueTextInfo *options;
2574 char *text_above, *text_left, *text_right, *infotext;
2575 } selectbox_info[ED_NUM_SELECTBOX] =
2577 // ---------- level and editor settings -------------------------------------
2580 ED_SELECTBOX_ID_TIME_OR_STEPS,
2581 -1, ED_LEVEL_SETTINGS_YPOS(8),
2582 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2584 options_time_or_steps,
2585 &level.use_step_counter,
2586 NULL, NULL, "(0 => no limit)", "time or step limit"
2589 ED_SELECTBOX_ID_TIME_SCORE_BASE,
2590 -1, ED_LEVEL_SETTINGS_YPOS(10),
2591 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2593 options_time_score_base,
2594 &level.time_score_base,
2595 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2598 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
2599 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2600 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2602 options_game_engine_type,
2603 &level.game_engine_type,
2604 NULL, "game engine:", NULL, "game engine"
2607 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
2608 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2609 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2611 options_levelset_save_mode,
2612 &levelset_save_mode,
2613 "Action:", NULL, NULL, "action when saving level set"
2616 // ---------- element settings: configure (several elements) ----------------
2619 ED_SELECTBOX_ID_WIND_DIRECTION,
2620 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2621 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2623 options_wind_direction,
2624 &level.wind_direction_initial,
2625 NULL, "initial wind direction:", NULL, "initial wind direction"
2628 ED_SELECTBOX_ID_PLAYER_SPEED,
2629 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2630 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2632 options_player_speed,
2633 &level.initial_player_stepsize[0],
2634 NULL, "initial player speed:", NULL, "initial player speed"
2637 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
2638 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2639 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2641 options_group_choice_mode,
2642 &level.mm_ball_choice_mode,
2643 NULL, "choice type:", NULL, "type of content choice"
2646 // ---------- element settings: configure 1 (custom elements) ---------------
2649 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
2650 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2651 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2653 options_access_type,
2654 &custom_element.access_type,
2655 NULL, NULL, NULL, "type of access to this field"
2658 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
2659 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2660 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2662 options_access_layer,
2663 &custom_element.access_layer,
2664 NULL, NULL, NULL, "layer of access for this field"
2667 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
2668 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2669 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2671 options_access_protected,
2672 &custom_element.access_protected,
2673 NULL, NULL, NULL, "protected access for this field"
2676 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
2677 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2678 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2680 options_access_direction,
2681 &custom_element.access_direction,
2682 NULL, "from", NULL, "access direction for this field"
2685 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
2686 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2687 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2689 options_walk_to_action,
2690 &custom_element.walk_to_action,
2691 NULL, NULL, NULL, "diggable/collectible/pushable"
2694 // ---------- element settings: configure 2 (custom elements) ---------------
2697 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
2698 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2699 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2701 options_move_pattern,
2702 &custom_element.move_pattern,
2703 NULL, "can move", NULL, "element move pattern"
2706 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
2707 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2708 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2710 options_move_direction,
2711 &custom_element.move_direction_initial,
2712 NULL, "starts moving", NULL, "initial element move direction"
2715 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
2716 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2717 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2719 options_move_stepsize,
2720 &custom_element.move_stepsize,
2721 NULL, "move/fall speed", NULL, "speed of element movement"
2724 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
2725 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2726 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2728 options_move_leave_type,
2729 &custom_element.move_leave_type,
2730 // left text with leading spaces to place gadget next to "can dig" gadget
2731 // (needed because drawing area gadgets created after selectbox gadgets)
2732 // NULL, "can dig: can", ":", "leave behind or change element"
2733 NULL, " can", ":", "leave behind or change element"
2736 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
2737 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2738 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2740 options_smash_targets,
2741 &custom_element.smash_targets,
2742 NULL, "can smash", NULL, "elements that can be smashed"
2745 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
2746 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2747 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2749 options_slippery_type,
2750 &custom_element.slippery_type,
2751 NULL, "slippery", NULL, "where other elements fall down"
2754 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
2755 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2756 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2759 &custom_element.deadliness,
2760 NULL, "deadly when", NULL, "deadliness of element"
2763 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
2764 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2765 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2767 options_explosion_type,
2768 &custom_element.explosion_type,
2769 NULL, "can explode", NULL, "explosion type"
2772 // ---------- element settings: advanced (custom elements) ------------------
2775 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
2776 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2777 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2780 &custom_element_change.delay_frames,
2781 NULL, "delay time given in", NULL, "delay time units for change"
2784 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
2785 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2786 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2788 options_change_direct_action,
2789 &custom_element_change.direct_action,
2790 NULL, NULL, NULL, "type of direct action"
2793 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
2794 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2795 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2797 options_change_other_action,
2798 &custom_element_change.other_action,
2799 NULL, NULL, "element:", "type of other element action"
2802 ED_SELECTBOX_ID_CHANGE_SIDE,
2803 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2804 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2806 options_change_trigger_side,
2807 &custom_element_change.trigger_side,
2808 NULL, "at", "side", "element side triggering change"
2811 ED_SELECTBOX_ID_CHANGE_PLAYER,
2812 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2813 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2815 options_change_trigger_player,
2816 &custom_element_change.trigger_player,
2817 NULL, "player:", " ", "player that causes change"
2820 ED_SELECTBOX_ID_CHANGE_PAGE,
2821 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2822 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2824 options_change_trigger_page,
2825 &custom_element_change.trigger_page,
2826 NULL, "page:", NULL, "change page that causes change"
2829 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
2830 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2831 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2833 options_change_replace_when,
2834 &custom_element_change.replace_when,
2835 NULL, "replace when", NULL, "which elements can be replaced"
2838 ED_SELECTBOX_ID_ACTION_TYPE,
2839 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2840 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2842 options_action_type,
2843 &custom_element_change.action_type,
2844 NULL, NULL, NULL, "action on specified condition"
2847 ED_SELECTBOX_ID_ACTION_MODE,
2848 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2849 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2851 options_action_mode_none,
2852 &custom_element_change.action_mode,
2853 NULL, NULL, NULL, "action operator"
2856 ED_SELECTBOX_ID_ACTION_ARG,
2857 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2858 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2860 options_action_arg_none,
2861 &custom_element_change.action_arg,
2862 NULL, NULL, NULL, "action parameter"
2865 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
2866 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2867 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2869 options_change_page,
2870 &custom_element.current_change_page,
2871 NULL, NULL, NULL, "element change page"
2874 // ---------- element settings: configure (group elements) ------------------
2877 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
2878 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2879 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2881 options_group_choice_mode,
2882 &group_element_info.choice_mode,
2883 NULL, "choice type:", NULL, "type of group element choice"
2892 int gadget_id_align;
2895 char *text_above, *text_left, *text_right, *infotext;
2896 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2898 // ---------- level and editor settings (tabs) ------------------------------
2901 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
2902 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2903 GADGET_ID_LEVELCONFIG_LEVEL, GADGET_ID_NONE,
2905 NULL, NULL, NULL, "Configure level settings"
2908 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
2910 GADGET_ID_LEVELCONFIG_LEVELSET, GADGET_ID_LEVELCONFIG_LEVEL,
2912 NULL, NULL, NULL, "Update this or create new level set"
2915 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
2917 GADGET_ID_LEVELCONFIG_EDITOR, GADGET_ID_LEVELCONFIG_LEVELSET,
2919 NULL, NULL, NULL, "Configure editor settings"
2922 // ---------- element settings (tabs) ---------------------------------------
2925 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
2926 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2927 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2929 NULL, NULL, NULL, "Show information about element"
2932 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
2934 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2936 NULL, NULL, NULL, "Configure element properties"
2939 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
2941 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2943 NULL, NULL, NULL, "Configure element properties, part 1"
2946 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
2948 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2950 NULL, NULL, NULL, "Configure element properties, part 2"
2953 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
2955 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2957 NULL, NULL, NULL, "Configure custom element change pages"
2960 // ---------- level and editor settings (buttons) ---------------------------
2963 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
2964 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2965 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
2967 NULL, NULL, NULL, "Update or create level set"
2970 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
2971 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2972 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2974 NULL, NULL, "this level as level template",
2975 "Save current settings as new template"
2978 // ---------- element settings (buttons) ------------------------------------
2981 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
2983 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2985 NULL, " ", "As Template",
2986 "Save current settings as new template"
2989 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
2991 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2993 NULL, NULL, NULL, "Add new change page"
2996 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
2998 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
3000 NULL, NULL, NULL, "Delete current change page"
3010 int gadget_id_align;
3011 char *text_left, *text_right, *infotext;
3012 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
3015 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
3016 IMG_EDITOR_COUNTER_DOWN,
3017 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3018 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
3019 NULL, NULL, "select previous change page"
3022 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
3023 IMG_EDITOR_COUNTER_UP,
3024 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3025 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
3026 NULL, "change page", "select next change page"
3029 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
3030 IMG_GFX_EDITOR_BUTTON_CP_COPY,
3031 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3032 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
3033 " ", NULL, "copy settings from this change page"
3036 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
3037 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
3038 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3039 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
3040 NULL, NULL, "paste settings to this change page"
3047 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
3055 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
3058 ED_SCROLLBUTTON_ID_AREA_UP,
3059 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
3060 GADGET_ID_SCROLL_UP,
3061 "scroll level editing area up"
3064 ED_SCROLLBUTTON_ID_AREA_DOWN,
3065 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
3066 GADGET_ID_SCROLL_DOWN,
3067 "scroll level editing area down"
3070 ED_SCROLLBUTTON_ID_AREA_LEFT,
3071 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
3072 GADGET_ID_SCROLL_LEFT,
3073 "scroll level editing area left"
3076 ED_SCROLLBUTTON_ID_AREA_RIGHT,
3077 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
3078 GADGET_ID_SCROLL_RIGHT,
3079 "scroll level editing area right"
3082 ED_SCROLLBUTTON_ID_LIST_UP,
3083 IMG_EDITOR_PALETTE_SCROLL_UP,
3084 GADGET_ID_SCROLL_LIST_UP,
3085 "scroll element list up ('Page Up')"
3088 ED_SCROLLBUTTON_ID_LIST_DOWN,
3089 IMG_EDITOR_PALETTE_SCROLL_DOWN,
3090 GADGET_ID_SCROLL_LIST_DOWN,
3091 "scroll element list down ('Page Down')"
3099 int wheel_x, wheel_y;
3100 int wheel_width, wheel_height;
3101 } scrollbar_pos[ED_NUM_SCROLLBARS];
3110 } scrollbar_info[ED_NUM_SCROLLBARS] =
3113 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
3114 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3115 GD_TYPE_SCROLLBAR_HORIZONTAL,
3116 GADGET_ID_SCROLL_HORIZONTAL,
3117 "scroll level editing area horizontally"
3120 ED_SCROLLBAR_ID_AREA_VERTICAL,
3121 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3122 GD_TYPE_SCROLLBAR_VERTICAL,
3123 GADGET_ID_SCROLL_VERTICAL,
3124 "scroll level editing area vertically"
3127 ED_SCROLLBAR_ID_LIST_VERTICAL,
3128 IMG_EDITOR_PALETTE_SCROLLBAR,
3129 GD_TYPE_SCROLLBAR_VERTICAL,
3130 GADGET_ID_SCROLL_LIST_VERTICAL,
3131 "scroll element list vertically"
3141 int gadget_id_align;
3142 int radio_button_nr;
3145 char *text_left, *text_right, *infotext;
3146 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3149 ED_RADIOBUTTON_ID_PERCENTAGE,
3150 -1, ED_LEVEL_SETTINGS_YPOS(0),
3151 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3152 RADIO_NR_RANDOM_ELEMENTS,
3153 &random_placement_method, RANDOM_USE_PERCENTAGE,
3154 " ", "percentage", "use percentage for random elements"
3157 ED_RADIOBUTTON_ID_QUANTITY,
3158 -1, ED_LEVEL_SETTINGS_YPOS(0),
3159 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3160 RADIO_NR_RANDOM_ELEMENTS,
3161 &random_placement_method, RANDOM_USE_QUANTITY,
3162 " ", "quantity", "use quantity for random elements"
3171 int gadget_id_align;
3173 char *text_above, *text_left, *text_right, *infotext;
3174 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3176 // ---------- level and editor settings -------------------------------------
3179 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
3180 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3181 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3182 &level.auto_count_gems,
3184 "automatically count gems needed", "set counter to number of gems"
3187 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
3188 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3189 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3190 &level.rate_time_over_score,
3192 "rate time/steps used over score", "sort high scores by playing time/steps"
3195 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
3196 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3197 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3198 &levelset_use_levelset_artwork,
3200 "use current custom artwork", "use custom artwork of this level set"
3203 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
3204 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3205 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3206 &levelset_copy_level_template,
3208 "copy current level template", "copy level template of this level set"
3211 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
3212 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3213 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3214 &random_placement_background_restricted,
3216 "restrict random placement to:", "set random placement restriction"
3219 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
3220 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3221 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3222 &setup.editor.use_template_for_new_levels,
3223 "Template for new levels and CE/GE:", NULL,
3224 "use template for new levels", "use template for level properties"
3227 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
3228 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3229 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3230 &level.use_custom_template,
3232 "use template for custom elements", "use template for custom properties"
3235 // ---------- element settings: configure (various elements) ----------------
3238 ED_CHECKBUTTON_ID_STICK_ELEMENT,
3239 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3240 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3241 &stick_element_properties_window,
3243 "stick this screen to edit content","stick this screen to edit content"
3246 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
3247 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3248 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3249 &level.em_slippery_gems,
3251 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3254 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
3255 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3256 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3257 &level.em_explodes_by_fire,
3259 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3262 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
3263 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3264 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3265 &level.use_spring_bug,
3267 "use spring pushing bug", "use odd spring pushing behaviour"
3270 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
3271 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3272 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3273 &level.use_time_orb_bug,
3275 "use time orb bug", "use odd time orb behaviour"
3278 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
3279 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3280 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3281 &level.use_life_bugs,
3283 "use buggy element behaviour", "use odd (historic) element behaviour"
3286 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
3287 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3288 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3291 "create single random element", "only create one element from content"
3294 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
3295 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3296 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3297 &level.ball_active_initial,
3299 "magic ball initially activated", "activate magic ball after level start"
3302 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
3303 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3304 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3305 &level.grow_into_diggable,
3307 "can grow into anything diggable", "grow into more than just sand"
3310 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
3311 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3312 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3313 &level.sb_fields_needed,
3315 "all fields need to be filled", "require all SB fields to be solved"
3318 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
3319 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3320 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3321 &level.sb_objects_needed,
3323 "all objects need to be placed", "require all SB objects to be solved"
3326 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
3327 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3328 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3329 &level.auto_exit_sokoban,
3331 "exit level if all tasks solved", "automatically finish Sokoban levels"
3334 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
3335 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3336 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3337 &level.solved_by_one_player,
3339 "only one player must enter exit", "level solved by first player in exit"
3342 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
3343 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3344 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3345 &level.finish_dig_collect,
3347 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3350 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
3351 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3352 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3353 &level.keep_walkable_ce,
3355 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3358 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
3359 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3360 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3361 &level.continuous_snapping,
3363 "continuous snapping", "use snapping without releasing key"
3366 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
3367 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3368 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3369 &level.block_snap_field,
3371 "block snapped field when snapping", "use snapping delay to show animation"
3374 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
3375 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3376 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3377 &level.block_last_field,
3379 "block last field when moving", "player blocks last field when moving"
3382 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
3383 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3384 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3385 &level.sp_block_last_field,
3387 "block last field when moving", "player blocks last field when moving"
3390 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
3391 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3392 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3393 &level.instant_relocation,
3395 "no scrolling when relocating", "player gets relocated without delay"
3398 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
3399 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3400 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3401 &level.shifted_relocation,
3403 "no centering when relocating", "level not centered after relocation"
3406 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
3407 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3408 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3409 &level.lazy_relocation,
3411 "only redraw off-screen relocation","no redraw if relocation target visible"
3414 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
3415 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3416 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3417 &level.use_start_element[0],
3419 "use level start element:", "start level at this element's position"
3422 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
3423 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3424 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3425 &level.use_artwork_element[0],
3427 "use artwork from element:", "use player artwork from other element"
3430 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
3431 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3432 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3433 &level.use_explosion_element[0],
3435 "use explosion from element:", "use explosion properties from element"
3438 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
3439 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3440 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3441 &level.initial_player_gravity[0],
3443 "use initial gravity", "set initial player gravity"
3446 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
3447 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3448 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3449 &level.use_initial_inventory[0],
3451 "use initial inventory:", "use collected elements on level start"
3454 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
3455 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3456 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3457 &level.can_pass_to_walkable,
3459 "can pass to walkable element", "player can pass to empty or walkable"
3462 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
3463 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3464 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3465 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3467 "can fall into acid (with gravity)","player can fall into acid pool"
3470 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
3471 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3472 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3473 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3475 "can move into acid", "element can move into acid pool"
3478 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
3479 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3480 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3481 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3483 "deadly when colliding with", "element is deadly when hitting player"
3486 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
3487 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3488 GADGET_ID_BD_DIAGONAL_MOVEMENTS, GADGET_ID_NONE,
3489 &level.bd_diagonal_movements,
3491 "can move diagonally", "player can move diagonally"
3494 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
3495 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3496 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3497 &level.envelope[0].autowrap,
3499 "auto-wrap", "automatically wrap envelope text"
3502 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
3503 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3504 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3505 &level.envelope[0].centered,
3507 "centered", "automatically center envelope text"
3510 ED_CHECKBUTTON_ID_MM_LASER_RED,
3511 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3512 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3513 &level.mm_laser_red,
3514 "choose color components for laser:", NULL,
3515 "red", "use red color components in laser"
3518 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
3519 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3520 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3521 &level.mm_laser_green,
3523 "green", "use green color components in laser"
3526 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
3527 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3528 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3529 &level.mm_laser_blue,
3531 "blue", "use blue color components in laser"
3534 ED_CHECKBUTTON_ID_DF_LASER_RED,
3535 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3536 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3537 &level.df_laser_red,
3538 "choose color components for laser:", NULL,
3539 "red", "use red color components in laser"
3542 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
3543 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3544 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3545 &level.df_laser_green,
3547 "green", "use green color components in laser"
3550 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
3551 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3552 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3553 &level.df_laser_blue,
3555 "blue", "use blue color components in laser"
3558 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
3559 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3560 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3561 &level.rotate_mm_ball_content,
3563 "randomly rotate created content", "randomly rotate newly created content"
3566 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
3567 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3568 GADGET_ID_EXPLODE_MM_BALL, GADGET_ID_NONE,
3569 &level.explode_mm_ball,
3571 "explode ball instead of melting", "use explosion to release ball content"
3574 // ---------- element settings: configure 1 (custom elements) ---------------
3577 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
3578 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3579 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3580 &custom_element.use_gfx_element,
3582 "use graphic of element:", "use existing element graphic"
3585 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
3586 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3587 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3588 &level.use_custom_template,
3590 "use template", "use template for custom properties"
3593 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
3594 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3595 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3596 &custom_element_properties[EP_ACCESSIBLE],
3598 NULL, "player can walk to or pass this field"
3601 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
3602 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3603 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3604 &custom_element_properties[EP_GRAVITY_REACHABLE],
3606 "reachable despite gravity", "player can walk/dig despite gravity"
3609 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
3610 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3611 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3612 &custom_element.use_last_ce_value,
3614 "use last CE value after change", "use last CE value after change"
3617 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
3618 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3619 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3620 &custom_element_properties[EP_WALK_TO_OBJECT],
3622 NULL, "player can dig/collect/push element"
3625 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
3626 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3627 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3628 &custom_element_properties[EP_INDESTRUCTIBLE],
3630 "indestructible", "element is indestructible"
3633 // ---------- element settings: configure 2 (custom elements) ---------------
3636 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
3637 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3638 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3639 &custom_element_properties[EP_CAN_MOVE],
3641 NULL, "element can move with some pattern"
3644 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
3645 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3646 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3647 &custom_element_properties[EP_CAN_FALL],
3649 "can fall", "element can fall down"
3652 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
3653 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3654 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3655 &custom_element_properties[EP_CAN_SMASH],
3657 NULL, "element can smash other elements"
3660 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
3661 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3662 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3663 &custom_element_properties[EP_SLIPPERY],
3665 NULL, "other elements can fall down from it"
3668 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
3669 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3670 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3671 &custom_element_properties[EP_DEADLY],
3673 NULL, "element can kill the player"
3676 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
3677 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3678 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3679 &custom_element_properties[EP_CAN_EXPLODE],
3681 NULL, "element can explode"
3684 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
3685 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3686 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3687 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3689 "by fire", "element can explode by fire/explosion"
3692 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
3693 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3694 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3695 &custom_element_properties[EP_EXPLODES_SMASHED],
3697 "smashed", "element can explode when smashed"
3700 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
3701 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3702 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3703 &custom_element_properties[EP_EXPLODES_IMPACT],
3705 "impact", "element can explode on impact"
3708 // ---------- element settings: advanced (custom elements) ------------------
3711 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
3712 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3713 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3714 &custom_element_change.can_change,
3716 "element changes to:", "change element on specified condition"
3719 ED_CHECKBUTTON_ID_CHANGE_DELAY,
3720 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3721 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3722 &custom_element_change_events[CE_DELAY],
3724 NULL, "element changes after delay"
3727 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
3728 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3729 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3730 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3732 NULL, "element changes by direct action"
3735 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
3736 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3737 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3738 &custom_element_change_events[CE_BY_OTHER_ACTION],
3740 NULL, "element changes by other element"
3743 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
3744 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3745 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3746 &custom_element_change.explode,
3748 "explode instead of change", "element explodes instead of change"
3751 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
3752 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3753 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3754 &custom_element_change.use_target_content,
3756 "use extended change target:", "element changes to more elements"
3759 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
3760 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3761 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3762 &custom_element_change.only_if_complete,
3764 "replace all or nothing", "only replace when all can be changed"
3767 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
3768 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3769 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3770 &custom_element_change.use_random_replace,
3772 NULL, "use percentage for random replace"
3775 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
3776 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3777 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3778 &custom_element_change.has_action,
3780 NULL, "execute action on specified condition"
3788 int xoffset, yoffset;
3790 int gadget_id_align;
3792 int area_xsize, area_ysize;
3793 char *text_left, *text_right, *text_above, *text_below, *infotext;
3794 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3796 // ---------- level playfield content ---------------------------------------
3799 ED_DRAWING_ID_DRAWING_LEVEL,
3802 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3804 -1, -1, // these values are not constant, but can change at runtime
3805 NULL, NULL, NULL, NULL, NULL
3808 // ---------- yam yam content -----------------------------------------------
3811 ED_DRAWING_ID_YAMYAM_CONTENT_0,
3812 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3813 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3814 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3815 &level.yamyam_content[0].e[0][0], 3, 3,
3816 NULL, NULL, NULL, "1", NULL
3819 ED_DRAWING_ID_YAMYAM_CONTENT_1,
3820 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3821 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3822 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3823 &level.yamyam_content[1].e[0][0], 3, 3,
3824 NULL, NULL, NULL, "2", NULL
3827 ED_DRAWING_ID_YAMYAM_CONTENT_2,
3828 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3829 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3830 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3831 &level.yamyam_content[2].e[0][0], 3, 3,
3832 NULL, NULL, NULL, "3", NULL
3835 ED_DRAWING_ID_YAMYAM_CONTENT_3,
3836 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3837 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3838 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3839 &level.yamyam_content[3].e[0][0], 3, 3,
3840 NULL, NULL, NULL, "4", NULL
3843 ED_DRAWING_ID_YAMYAM_CONTENT_4,
3844 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3845 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3846 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3847 &level.yamyam_content[4].e[0][0], 3, 3,
3848 NULL, NULL, NULL, "5", NULL
3851 ED_DRAWING_ID_YAMYAM_CONTENT_5,
3852 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3853 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3854 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3855 &level.yamyam_content[5].e[0][0], 3, 3,
3856 NULL, NULL, NULL, "6", NULL
3859 ED_DRAWING_ID_YAMYAM_CONTENT_6,
3860 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3861 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3862 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3863 &level.yamyam_content[6].e[0][0], 3, 3,
3864 NULL, NULL, NULL, "7", NULL
3867 ED_DRAWING_ID_YAMYAM_CONTENT_7,
3868 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3869 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3870 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3871 &level.yamyam_content[7].e[0][0], 3, 3,
3872 NULL, NULL, NULL, "8", NULL
3875 // ---------- magic ball content --------------------------------------------
3878 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
3879 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3880 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3881 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3882 &level.ball_content[0].e[0][0], 3, 3,
3883 NULL, NULL, NULL, "1", NULL
3886 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
3887 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3888 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3889 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3890 &level.ball_content[1].e[0][0], 3, 3,
3891 NULL, NULL, NULL, "2", NULL
3894 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
3895 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3896 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3897 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3898 &level.ball_content[2].e[0][0], 3, 3,
3899 NULL, NULL, NULL, "3", NULL
3902 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
3903 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3904 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3905 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3906 &level.ball_content[3].e[0][0], 3, 3,
3907 NULL, NULL, NULL, "4", NULL
3910 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
3911 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3912 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3913 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3914 &level.ball_content[4].e[0][0], 3, 3,
3915 NULL, NULL, NULL, "5", NULL
3918 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
3919 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3920 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3921 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3922 &level.ball_content[5].e[0][0], 3, 3,
3923 NULL, NULL, NULL, "6", NULL
3926 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
3927 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3928 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3929 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3930 &level.ball_content[6].e[0][0], 3, 3,
3931 NULL, NULL, NULL, "7", NULL
3934 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
3935 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3936 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3937 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3938 &level.ball_content[7].e[0][0], 3, 3,
3939 NULL, NULL, NULL, "8", NULL
3942 // ---------- android content -----------------------------------------------
3945 ED_DRAWING_ID_ANDROID_CONTENT,
3946 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
3947 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3948 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3949 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3950 NULL, NULL, "elements:", NULL, "elements android can clone"
3953 // ---------- amoeba content ------------------------------------------------
3956 ED_DRAWING_ID_AMOEBA_CONTENT,
3957 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3958 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3959 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3960 &level.amoeba_content, 1, 1,
3961 "content:", NULL, NULL, NULL, "amoeba content"
3964 // ---------- level start element -------------------------------------------
3967 ED_DRAWING_ID_START_ELEMENT,
3968 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3969 0, ED_AREA_1X1_SETTINGS_YOFF,
3970 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3971 &level.start_element[0], 1, 1,
3972 NULL, NULL, NULL, NULL, "level start element"
3975 // ---------- player artwork element ----------------------------------------
3978 ED_DRAWING_ID_ARTWORK_ELEMENT,
3979 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3980 0, ED_AREA_1X1_SETTINGS_YOFF,
3981 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3982 &level.artwork_element[0], 1, 1,
3983 NULL, NULL, NULL, NULL, "element for player artwork"
3986 // ---------- player explosion element --------------------------------------
3989 ED_DRAWING_ID_EXPLOSION_ELEMENT,
3990 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
3991 0, ED_AREA_1X1_SETTINGS_YOFF,
3992 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3993 &level.explosion_element[0], 1, 1,
3994 NULL, NULL, NULL, NULL, "element for player explosion"
3997 // ---------- player initial inventory --------------------------------------
4000 ED_DRAWING_ID_INVENTORY_CONTENT,
4001 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4002 0, ED_AREA_1X1_SETTINGS_YOFF,
4003 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
4004 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
4005 NULL, NULL, NULL, NULL, "content for initial inventory"
4008 // ---------- gray ball content -----------------------------------------
4011 ED_DRAWING_ID_MM_BALL_CONTENT,
4012 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4013 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4014 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
4015 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
4016 "content:", NULL, NULL, NULL, "content for gray ball"
4019 // ---------- element settings: configure 1 (custom elements) ---------------
4021 // ---------- custom graphic ------------------------------------------------
4024 ED_DRAWING_ID_CUSTOM_GRAPHIC,
4025 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4026 0, ED_AREA_1X1_SETTINGS_YOFF,
4027 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
4028 &custom_element.gfx_element_initial, 1, 1,
4029 NULL, NULL, NULL, NULL, "custom graphic element"
4032 // ---------- element settings: configure 2 (custom elements) ---------------
4034 // ---------- custom content (when exploding) -------------------------------
4037 ED_DRAWING_ID_CUSTOM_CONTENT,
4038 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
4039 0, ED_AREA_3X3_SETTINGS_YOFF,
4040 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
4041 &custom_element.content.e[0][0], 3, 3,
4042 "content:", NULL, NULL, NULL, NULL
4045 // ---------- custom enter and leave element (when moving) ------------------
4048 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
4049 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
4050 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4051 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
4052 &custom_element.move_enter_element, 1, 1,
4053 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
4056 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
4057 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
4058 0, ED_AREA_1X1_SETTINGS_YOFF,
4059 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
4060 &custom_element.move_leave_element, 1, 1,
4061 NULL, NULL, NULL, NULL, "element that will be left behind"
4064 // ---------- element settings: advanced (custom elements) ------------------
4066 // ---------- custom change target ------------------------------------------
4069 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
4070 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4071 0, ED_AREA_1X1_SETTINGS_YOFF,
4072 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
4073 &custom_element_change.target_element, 1, 1,
4074 NULL, "after/when:", NULL, NULL, "new target element after change"
4077 // ---------- custom change content (extended change target) ----------------
4080 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
4081 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
4082 0, ED_AREA_3X3_SETTINGS_YOFF,
4083 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
4084 &custom_element_change.target_content.e[0][0], 3, 3,
4085 NULL, NULL, NULL, NULL, "new extended elements after change"
4088 // ---------- custom change trigger (element causing change) ----------------
4091 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
4092 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
4093 0, ED_AREA_1X1_SETTINGS_YOFF,
4094 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
4095 &custom_element_change.initial_trigger_element, 1, 1,
4096 NULL, NULL, NULL, NULL, "other element triggering change"
4099 // ---------- custom change action (element used for action) ----------------
4102 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
4103 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
4104 0, ED_AREA_1X1_SETTINGS_YOFF,
4105 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
4106 &custom_element_change.action_element, 1, 1,
4107 NULL, NULL, NULL, NULL, "element used as action parameter"
4110 // ---------- group element content -----------------------------------------
4113 ED_DRAWING_ID_GROUP_CONTENT,
4114 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4115 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4116 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
4117 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
4118 "content:", NULL, NULL, NULL, NULL
4121 // ---------- random background (for random painting) -----------------------
4124 ED_DRAWING_ID_RANDOM_BACKGROUND,
4125 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
4126 0, ED_AREA_1X1_LSETTINGS_YOFF,
4127 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
4128 &random_placement_background_element, 1, 1,
4129 NULL, NULL, NULL, NULL, "random placement background"
4134 // ----------------------------------------------------------------------------
4135 // some internally used variables
4136 // ----------------------------------------------------------------------------
4138 // maximal size of level editor drawing area
4139 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
4141 // actual size of level editor drawing area
4142 static int ed_fieldx, ed_fieldy;
4144 // actual position of level editor drawing area in level playfield
4145 static int level_xpos = -1, level_ypos = -1;
4147 // actual tile size used to display playfield drawing area
4148 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
4149 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
4151 #define IN_ED_FIELD(x, y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
4153 // drawing elements on the three mouse buttons
4154 static int new_element1 = EL_WALL;
4155 static int new_element2 = EL_EMPTY;
4156 static int new_element3 = EL_SAND;
4158 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
4159 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
4160 (button) == 2 ? new_element2 : \
4161 (button) == 3 ? new_element3 : EL_EMPTY)
4163 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
4165 static int use_permanent_palette = TRUE;
4167 #define PX (use_permanent_palette ? DX : SX)
4168 #define PY (use_permanent_palette ? DY : SY)
4169 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
4170 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
4172 // forward declaration for internal use
4173 static void CopyBrushToCursor(int, int);
4174 static void DeleteBrushFromCursor(void);
4175 static void ModifyEditorCounterValue(int, int);
4176 static void ModifyEditorCounterLimits(int, int, int);
4177 static void ModifyEditorSelectboxValue(int, int);
4178 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
4179 static void ModifyEditorDrawingArea(int, int, int);
4180 static void ModifyEditorElementList(void);
4181 static void AdjustElementListScrollbar(void);
4182 static void RedrawDrawingElements(void);
4183 static void DrawDrawingWindowExt(boolean);
4184 static void DrawDrawingWindow(void);
4185 static void DrawLevelConfigWindow(void);
4186 static void DrawPropertiesWindow(void);
4187 static void DrawPaletteWindow(void);
4188 static void UpdateCustomElementGraphicGadgets(void);
4189 static boolean checkPropertiesConfig(int);
4190 static void SetAutomaticNumberOfGemsNeeded(void);
4191 static void ClearEditorGadgetInfoText(void);
4192 static void CopyLevelToUndoBuffer(int);
4193 static void HandleDrawingAreas(struct GadgetInfo *);
4194 static void HandleCounterButtons(struct GadgetInfo *);
4195 static void HandleTextInputGadgets(struct GadgetInfo *);
4196 static void HandleTextAreaGadgets(struct GadgetInfo *);
4197 static void HandleSelectboxGadgets(struct GadgetInfo *);
4198 static void HandleTextbuttonGadgets(struct GadgetInfo *);
4199 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
4200 static void HandleRadiobuttons(struct GadgetInfo *);
4201 static void HandleCheckbuttons(struct GadgetInfo *);
4202 static void HandleControlButtons(struct GadgetInfo *);
4203 static void HandleDrawingAreaInfo(struct GadgetInfo *);
4204 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
4205 static boolean AskToCopyAndModifyLevelTemplate(void);
4206 static boolean getDrawModeHiRes(void);
4207 static int getTabulatorBarWidth(void);
4208 static int getTabulatorBarHeight(void);
4209 static Pixel getTabulatorBarColor(void);
4210 static int numHiresTiles(int);
4212 static int num_editor_gadgets = 0; // dynamically determined
4214 static struct GadgetInfo **level_editor_gadget = NULL;
4215 static int *right_gadget_border = NULL;
4217 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
4218 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
4219 static boolean draw_with_brush = FALSE;
4220 static int properties_element = 0;
4222 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4223 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4224 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4225 static int undo_buffer_position = 0;
4226 static int undo_buffer_steps = 0;
4227 static int redo_buffer_steps = 0;
4229 static int edit_mode;
4230 static int edit_mode_levelconfig;
4231 static int edit_mode_properties;
4233 static int element_shift = 0;
4235 static int editor_el_players[] =
4242 static int *editor_el_players_ptr = editor_el_players;
4243 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4245 static int editor_hl_boulderdash[] =
4247 EL_INTERNAL_CASCADE_BD_ACTIVE,
4253 static int editor_el_boulderdash[] =
4262 EL_BD_EXPANDABLE_WALL,
4270 EL_BD_BUTTERFLY_LEFT,
4272 EL_BD_BUTTERFLY_RIGHT,
4273 EL_BD_FIREFLY_RIGHT,
4276 EL_BD_BUTTERFLY_DOWN,
4280 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4281 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4282 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4283 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4285 static int editor_hl_boulderdash_native[] =
4287 EL_INTERNAL_CASCADE_BD_NATIVE_ACTIVE,
4293 static int editor_el_boulderdash_native[] =
4310 EL_BD_BUTTERFLY_LEFT,
4312 EL_BD_BUTTERFLY_RIGHT,
4313 EL_BD_FIREFLY_RIGHT,
4316 EL_BD_BUTTERFLY_DOWN,
4321 EL_BD_BUTTERFLY_2_UP,
4325 EL_BD_BUTTERFLY_2_LEFT,
4326 EL_BD_FIREFLY_2_LEFT,
4327 EL_BD_BUTTERFLY_2_RIGHT,
4328 EL_BD_FIREFLY_2_RIGHT,
4331 EL_BD_BUTTERFLY_2_DOWN,
4332 EL_BD_FIREFLY_2_DOWN,
4340 EL_BD_DRAGONFLY_LEFT,
4341 EL_BD_STONEFLY_LEFT,
4342 EL_BD_DRAGONFLY_RIGHT,
4343 EL_BD_STONEFLY_RIGHT,
4346 EL_BD_DRAGONFLY_DOWN,
4347 EL_BD_STONEFLY_DOWN,
4370 EL_BD_SAND_SLOPED_UP_LEFT,
4371 EL_BD_SAND_SLOPED_UP_RIGHT,
4372 EL_BD_WALL_SLOPED_UP_LEFT,
4373 EL_BD_WALL_SLOPED_UP_RIGHT,
4375 EL_BD_SAND_SLOPED_DOWN_LEFT,
4376 EL_BD_SAND_SLOPED_DOWN_RIGHT,
4377 EL_BD_WALL_SLOPED_DOWN_LEFT,
4378 EL_BD_WALL_SLOPED_DOWN_RIGHT,
4380 EL_BD_FLYING_DIAMOND,
4382 EL_BD_STEELWALL_SLOPED_UP_LEFT,
4383 EL_BD_STEELWALL_SLOPED_UP_RIGHT,
4387 EL_BD_STEELWALL_SLOPED_DOWN_LEFT,
4388 EL_BD_STEELWALL_SLOPED_DOWN_RIGHT,
4391 EL_BD_WALL_NON_SLOPED,
4397 EL_BD_INVISIBLE_EXIT_CLOSED,
4398 EL_BD_INVISIBLE_EXIT_OPEN,
4401 EL_BD_STEELWALL_EXPLODABLE,
4402 EL_BD_STEELWALL_DIGGABLE,
4403 EL_BD_WALL_DIGGABLE,
4405 EL_BD_EXPANDABLE_WALL_HORIZONTAL,
4406 EL_BD_EXPANDABLE_WALL_VERTICAL,
4407 EL_BD_EXPANDABLE_WALL_ANY,
4408 EL_BD_CREATURE_SWITCH,
4410 EL_BD_EXPANDABLE_STEELWALL_HORIZONTAL,
4411 EL_BD_EXPANDABLE_STEELWALL_VERTICAL,
4412 EL_BD_EXPANDABLE_STEELWALL_ANY,
4413 EL_BD_EXPANDABLE_WALL_SWITCH_HORIZONTAL,
4415 EL_BD_BITER_SWITCH_1,
4416 EL_BD_REPLICATOR_SWITCH,
4417 EL_BD_CONVEYOR_SWITCH,
4418 EL_BD_CONVEYOR_DIR_SWITCH_RIGHT,
4427 EL_BD_DIAMOND_GLUED,
4430 EL_BD_TRAPPED_DIAMOND,
4450 EL_BD_GRAVITY_SWITCH,
4451 EL_BD_PNEUMATIC_HAMMER,
4458 EL_BD_BLADDER_SPENDER,
4460 EL_BD_CONVEYOR_LEFT,
4461 EL_BD_CONVEYOR_RIGHT,
4476 EL_BD_PLAYER_WITH_BOMB,
4478 EL_BD_PLAYER_STIRRING,
4480 static int *editor_hl_boulderdash_native_ptr = editor_hl_boulderdash_native;
4481 static int *editor_el_boulderdash_native_ptr = editor_el_boulderdash_native;
4482 static int num_editor_hl_boulderdash_native = ARRAY_SIZE(editor_hl_boulderdash_native);
4483 static int num_editor_el_boulderdash_native = ARRAY_SIZE(editor_el_boulderdash_native);
4485 static int editor_hl_emerald_mine[] =
4487 EL_INTERNAL_CASCADE_EM_ACTIVE,
4493 static int editor_el_emerald_mine[] =
4511 EL_EM_DYNAMITE_ACTIVE,
4530 EL_ACID_POOL_TOPLEFT,
4532 EL_ACID_POOL_TOPRIGHT,
4535 EL_ACID_POOL_BOTTOMLEFT,
4536 EL_ACID_POOL_BOTTOM,
4537 EL_ACID_POOL_BOTTOMRIGHT,
4555 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4556 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4557 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4558 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4560 static int editor_hl_emerald_mine_club[] =
4562 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4568 static int editor_el_emerald_mine_club[] =
4595 EL_EMC_WALL_SLIPPERY_1,
4596 EL_EMC_WALL_SLIPPERY_2,
4597 EL_EMC_WALL_SLIPPERY_3,
4598 EL_EMC_WALL_SLIPPERY_4,
4621 EL_EMC_MAGIC_BALL_SWITCH,
4628 EL_EMC_SPRING_BUMPER,
4632 EL_BALLOON_SWITCH_UP,
4633 EL_BALLOON_SWITCH_ANY,
4636 EL_BALLOON_SWITCH_LEFT,
4638 EL_BALLOON_SWITCH_RIGHT,
4642 EL_BALLOON_SWITCH_DOWN,
4643 EL_BALLOON_SWITCH_NONE,
4645 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4646 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4647 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4648 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4650 static int editor_hl_rnd[] =
4652 EL_INTERNAL_CASCADE_RND_ACTIVE,
4658 static int editor_el_rnd[] =
4661 EL_DYNAMITE_ACTIVE, // RND
4695 EL_WALL_EMERALD_YELLOW,
4696 EL_WALL_EMERALD_RED,
4697 EL_WALL_EMERALD_PURPLE,
4715 EL_DYNABOMB_INCREASE_NUMBER,
4716 EL_DYNABOMB_INCREASE_SIZE,
4717 EL_DYNABOMB_INCREASE_POWER,
4737 EL_INVISIBLE_STEELWALL,
4741 EL_EXPANDABLE_WALL_HORIZONTAL,
4742 EL_EXPANDABLE_WALL_VERTICAL,
4743 EL_EXPANDABLE_WALL_ANY,
4745 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4746 static int *editor_el_rnd_ptr = editor_el_rnd;
4747 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4748 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4750 static int editor_hl_sokoban[] =
4752 EL_INTERNAL_CASCADE_SB_ACTIVE,
4758 static int editor_el_sokoban[] =
4761 EL_SOKOBAN_FIELD_EMPTY,
4762 EL_SOKOBAN_FIELD_FULL,
4763 EL_SOKOBAN_FIELD_PLAYER,
4765 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4766 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4767 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4768 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4770 static int editor_hl_supaplex[] =
4772 EL_INTERNAL_CASCADE_SP_ACTIVE,
4778 static int editor_el_supaplex[] =
4796 EL_SP_PORT_HORIZONTAL,
4797 EL_SP_PORT_VERTICAL,
4805 EL_SP_GRAVITY_PORT_LEFT,
4806 EL_SP_GRAVITY_PORT_RIGHT,
4807 EL_SP_GRAVITY_PORT_UP,
4808 EL_SP_GRAVITY_PORT_DOWN,
4810 EL_SP_GRAVITY_ON_PORT_LEFT,
4811 EL_SP_GRAVITY_ON_PORT_RIGHT,
4812 EL_SP_GRAVITY_ON_PORT_UP,
4813 EL_SP_GRAVITY_ON_PORT_DOWN,
4815 EL_SP_GRAVITY_OFF_PORT_LEFT,
4816 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4817 EL_SP_GRAVITY_OFF_PORT_UP,
4818 EL_SP_GRAVITY_OFF_PORT_DOWN,
4820 EL_SP_HARDWARE_GRAY,
4821 EL_SP_HARDWARE_GREEN,
4822 EL_SP_HARDWARE_BLUE,
4825 EL_SP_HARDWARE_BASE_1,
4826 EL_SP_HARDWARE_BASE_2,
4827 EL_SP_HARDWARE_BASE_3,
4828 EL_SP_HARDWARE_BASE_4,
4830 EL_SP_HARDWARE_BASE_5,
4831 EL_SP_HARDWARE_BASE_6,
4832 EL_SP_HARDWARE_YELLOW,
4840 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4841 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4842 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4843 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4845 static int editor_hl_diamond_caves[] =
4847 EL_INTERNAL_CASCADE_DC_ACTIVE,
4853 static int editor_el_diamond_caves[] =
4855 EL_EM_STEEL_EXIT_CLOSED, // DC2
4856 EL_EM_STEEL_EXIT_OPEN, // DC2
4857 EL_WALL_EMERALD, // DC2
4858 EL_WALL_DIAMOND, // DC2
4865 EL_CONVEYOR_BELT_1_LEFT,
4866 EL_CONVEYOR_BELT_1_MIDDLE,
4867 EL_CONVEYOR_BELT_1_RIGHT,
4868 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4870 EL_CONVEYOR_BELT_2_LEFT,
4871 EL_CONVEYOR_BELT_2_MIDDLE,
4872 EL_CONVEYOR_BELT_2_RIGHT,
4873 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4875 EL_CONVEYOR_BELT_3_LEFT,
4876 EL_CONVEYOR_BELT_3_MIDDLE,
4877 EL_CONVEYOR_BELT_3_RIGHT,
4878 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4880 EL_CONVEYOR_BELT_4_LEFT,
4881 EL_CONVEYOR_BELT_4_MIDDLE,
4882 EL_CONVEYOR_BELT_4_RIGHT,
4883 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4885 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4886 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4887 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4888 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4890 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4891 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4892 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4893 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4898 EL_DC_TIMEGATE_SWITCH,
4900 EL_SWITCHGATE_CLOSED,
4902 EL_SWITCHGATE_SWITCH_UP,
4903 EL_SWITCHGATE_SWITCH_DOWN,
4906 EL_LIGHT_SWITCH_ACTIVE,
4907 EL_DC_SWITCHGATE_SWITCH_UP,
4908 EL_DC_SWITCHGATE_SWITCH_DOWN,
4910 EL_STEEL_EXIT_CLOSED,
4912 EL_STEELWALL_SLIPPERY,
4915 EL_QUICKSAND_FAST_EMPTY,
4916 EL_QUICKSAND_FAST_FULL,
4930 EL_SIGN_RADIOACTIVITY,
4936 EL_SIGN_ENTRY_FORBIDDEN,
4937 EL_SIGN_EMERGENCY_EXIT,
4962 EL_DC_STEELWALL_2_SINGLE,
4963 EL_DC_STEELWALL_2_TOP,
4964 EL_SIGN_EXCLAMATION,
4967 EL_DC_STEELWALL_2_LEFT,
4968 EL_DC_STEELWALL_2_MIDDLE,
4969 EL_DC_STEELWALL_2_HORIZONTAL,
4970 EL_DC_STEELWALL_2_RIGHT,
4972 EL_DC_STEELWALL_1_TOPLEFT,
4973 EL_DC_STEELWALL_2_VERTICAL,
4974 EL_DC_STEELWALL_1_TOPRIGHT,
4977 EL_DC_STEELWALL_1_VERTICAL,
4978 EL_DC_STEELWALL_2_BOTTOM,
4980 EL_DC_GATE_WHITE_GRAY,
4982 EL_DC_STEELWALL_1_BOTTOMLEFT,
4983 EL_DC_STEELWALL_1_HORIZONTAL,
4984 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4985 EL_DC_GATE_FAKE_GRAY,
4987 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4988 EL_DC_STEELWALL_1_BOTTOM,
4989 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
4990 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
4992 EL_DC_STEELWALL_1_RIGHT,
4994 EL_DC_STEELWALL_1_LEFT,
4995 EL_EXPANDABLE_STEELWALL_VERTICAL,
4997 EL_DC_STEELWALL_1_TOPRIGHT_2,
4998 EL_DC_STEELWALL_1_TOP,
4999 EL_DC_STEELWALL_1_TOPLEFT_2,
5000 EL_EXPANDABLE_STEELWALL_ANY,
5002 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
5003 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
5004 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
5005 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
5007 static int editor_hl_dx_boulderdash[] =
5009 EL_INTERNAL_CASCADE_DX_ACTIVE,
5015 static int editor_el_dx_boulderdash[] =
5019 EL_TUBE_HORIZONTAL_DOWN,
5023 EL_TUBE_VERTICAL_RIGHT,
5025 EL_TUBE_VERTICAL_LEFT,
5029 EL_TUBE_HORIZONTAL_UP,
5037 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
5038 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
5039 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
5040 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
5042 static int editor_hl_mirror_magic[] =
5044 EL_INTERNAL_CASCADE_MM_ACTIVE,
5050 static int editor_el_mirror_magic[] =
5052 EL_MM_MCDUFFIN_RIGHT,
5054 EL_MM_MCDUFFIN_LEFT,
5055 EL_MM_MCDUFFIN_DOWN,
5058 EL_MM_MIRROR_FIXED_START,
5059 EL_MM_POLARIZER_START,
5060 EL_MM_POLARIZER_CROSS_START,
5062 EL_MM_TELEPORTER_RED_START,
5063 EL_MM_TELEPORTER_YELLOW_START,
5064 EL_MM_TELEPORTER_GREEN_START,
5065 EL_MM_TELEPORTER_BLUE_START,
5078 EL_MM_LIGHTBULB_ACTIVE,
5092 EL_MM_STEEL_GRID_FIXED_1,
5093 EL_MM_STEEL_GRID_FIXED_2,
5094 EL_MM_STEEL_GRID_FIXED_3,
5095 EL_MM_STEEL_GRID_FIXED_4,
5097 EL_MM_WOODEN_GRID_FIXED_1,
5098 EL_MM_WOODEN_GRID_FIXED_2,
5099 EL_MM_WOODEN_GRID_FIXED_3,
5100 EL_MM_WOODEN_GRID_FIXED_4,
5107 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
5108 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
5109 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
5110 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
5112 static int editor_hl_deflektor[] =
5114 EL_INTERNAL_CASCADE_DF_ACTIVE,
5120 static int editor_el_deflektor[] =
5127 EL_DF_RECEIVER_RIGHT,
5129 EL_DF_RECEIVER_LEFT,
5130 EL_DF_RECEIVER_DOWN,
5133 EL_DF_MIRROR_ROTATING_START,
5134 EL_DF_MIRROR_FIXED_START,
5137 EL_DF_FIBRE_OPTIC_RED_1,
5138 EL_DF_FIBRE_OPTIC_YELLOW_1,
5139 EL_DF_FIBRE_OPTIC_GREEN_1,
5140 EL_DF_FIBRE_OPTIC_BLUE_1,
5142 EL_DF_STEEL_GRID_FIXED_START,
5143 EL_DF_STEEL_GRID_ROTATING_START,
5144 EL_DF_WOODEN_GRID_FIXED_START,
5145 EL_DF_WOODEN_GRID_ROTATING_START,
5157 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
5158 static int *editor_el_deflektor_ptr = editor_el_deflektor;
5159 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
5160 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
5162 static int editor_hl_chars[] =
5164 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
5170 static int editor_el_chars[] =
5252 EL_CHAR(CHAR_BYTE_COPYRIGHT),
5253 EL_CHAR(CHAR_BYTE_UMLAUT_A),
5254 EL_CHAR(CHAR_BYTE_UMLAUT_O),
5255 EL_CHAR(CHAR_BYTE_UMLAUT_U),
5257 EL_CHAR(CHAR_BYTE_DEGREE),
5258 EL_CHAR(CHAR_BYTE_REGISTERED),
5259 EL_CHAR(FONT_ASCII_CURSOR),
5260 EL_CHAR(FONT_ASCII_BUTTON),
5262 EL_CHAR(FONT_ASCII_UP),
5263 EL_CHAR(FONT_ASCII_DOWN),
5267 static int *editor_hl_chars_ptr = editor_hl_chars;
5268 static int *editor_el_chars_ptr = editor_el_chars;
5269 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
5270 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
5272 static int editor_hl_steel_chars[] =
5274 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
5280 static int editor_el_steel_chars[] =
5290 EL_STEEL_CHAR('\''),
5357 EL_STEEL_CHAR('\\'),
5362 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
5363 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
5364 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
5365 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
5367 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
5368 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
5369 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
5370 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
5372 EL_STEEL_CHAR(FONT_ASCII_UP),
5373 EL_STEEL_CHAR(FONT_ASCII_DOWN),
5377 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
5378 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
5379 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
5380 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
5382 static int editor_hl_custom[] =
5384 EL_INTERNAL_CASCADE_CE_ACTIVE,
5390 static int editor_el_custom[] =
5392 EL_CUSTOM_START + 0,
5393 EL_CUSTOM_START + 1,
5394 EL_CUSTOM_START + 2,
5395 EL_CUSTOM_START + 3,
5397 EL_CUSTOM_START + 4,
5398 EL_CUSTOM_START + 5,
5399 EL_CUSTOM_START + 6,
5400 EL_CUSTOM_START + 7,
5402 EL_CUSTOM_START + 8,
5403 EL_CUSTOM_START + 9,
5404 EL_CUSTOM_START + 10,
5405 EL_CUSTOM_START + 11,
5407 EL_CUSTOM_START + 12,
5408 EL_CUSTOM_START + 13,
5409 EL_CUSTOM_START + 14,
5410 EL_CUSTOM_START + 15,
5412 EL_CUSTOM_START + 16,
5413 EL_CUSTOM_START + 17,
5414 EL_CUSTOM_START + 18,
5415 EL_CUSTOM_START + 19,
5417 EL_CUSTOM_START + 20,
5418 EL_CUSTOM_START + 21,
5419 EL_CUSTOM_START + 22,
5420 EL_CUSTOM_START + 23,
5422 EL_CUSTOM_START + 24,
5423 EL_CUSTOM_START + 25,
5424 EL_CUSTOM_START + 26,
5425 EL_CUSTOM_START + 27,
5427 EL_CUSTOM_START + 28,
5428 EL_CUSTOM_START + 29,
5429 EL_CUSTOM_START + 30,
5430 EL_CUSTOM_START + 31,
5432 EL_CUSTOM_START + 32,
5433 EL_CUSTOM_START + 33,
5434 EL_CUSTOM_START + 34,
5435 EL_CUSTOM_START + 35,
5437 EL_CUSTOM_START + 36,
5438 EL_CUSTOM_START + 37,
5439 EL_CUSTOM_START + 38,
5440 EL_CUSTOM_START + 39,
5442 EL_CUSTOM_START + 40,
5443 EL_CUSTOM_START + 41,
5444 EL_CUSTOM_START + 42,
5445 EL_CUSTOM_START + 43,
5447 EL_CUSTOM_START + 44,
5448 EL_CUSTOM_START + 45,
5449 EL_CUSTOM_START + 46,
5450 EL_CUSTOM_START + 47,
5452 EL_CUSTOM_START + 48,
5453 EL_CUSTOM_START + 49,
5454 EL_CUSTOM_START + 50,
5455 EL_CUSTOM_START + 51,
5457 EL_CUSTOM_START + 52,
5458 EL_CUSTOM_START + 53,
5459 EL_CUSTOM_START + 54,
5460 EL_CUSTOM_START + 55,
5462 EL_CUSTOM_START + 56,
5463 EL_CUSTOM_START + 57,
5464 EL_CUSTOM_START + 58,
5465 EL_CUSTOM_START + 59,
5467 EL_CUSTOM_START + 60,
5468 EL_CUSTOM_START + 61,
5469 EL_CUSTOM_START + 62,
5470 EL_CUSTOM_START + 63,
5472 EL_CUSTOM_START + 64,
5473 EL_CUSTOM_START + 65,
5474 EL_CUSTOM_START + 66,
5475 EL_CUSTOM_START + 67,
5477 EL_CUSTOM_START + 68,
5478 EL_CUSTOM_START + 69,
5479 EL_CUSTOM_START + 70,
5480 EL_CUSTOM_START + 71,
5482 EL_CUSTOM_START + 72,
5483 EL_CUSTOM_START + 73,
5484 EL_CUSTOM_START + 74,
5485 EL_CUSTOM_START + 75,
5487 EL_CUSTOM_START + 76,
5488 EL_CUSTOM_START + 77,
5489 EL_CUSTOM_START + 78,
5490 EL_CUSTOM_START + 79,
5492 EL_CUSTOM_START + 80,
5493 EL_CUSTOM_START + 81,
5494 EL_CUSTOM_START + 82,
5495 EL_CUSTOM_START + 83,
5497 EL_CUSTOM_START + 84,
5498 EL_CUSTOM_START + 85,
5499 EL_CUSTOM_START + 86,
5500 EL_CUSTOM_START + 87,
5502 EL_CUSTOM_START + 88,
5503 EL_CUSTOM_START + 89,
5504 EL_CUSTOM_START + 90,
5505 EL_CUSTOM_START + 91,
5507 EL_CUSTOM_START + 92,
5508 EL_CUSTOM_START + 93,
5509 EL_CUSTOM_START + 94,
5510 EL_CUSTOM_START + 95,
5512 EL_CUSTOM_START + 96,
5513 EL_CUSTOM_START + 97,
5514 EL_CUSTOM_START + 98,
5515 EL_CUSTOM_START + 99,
5517 EL_CUSTOM_START + 100,
5518 EL_CUSTOM_START + 101,
5519 EL_CUSTOM_START + 102,
5520 EL_CUSTOM_START + 103,
5522 EL_CUSTOM_START + 104,
5523 EL_CUSTOM_START + 105,
5524 EL_CUSTOM_START + 106,
5525 EL_CUSTOM_START + 107,
5527 EL_CUSTOM_START + 108,
5528 EL_CUSTOM_START + 109,
5529 EL_CUSTOM_START + 110,
5530 EL_CUSTOM_START + 111,
5532 EL_CUSTOM_START + 112,
5533 EL_CUSTOM_START + 113,
5534 EL_CUSTOM_START + 114,
5535 EL_CUSTOM_START + 115,
5537 EL_CUSTOM_START + 116,
5538 EL_CUSTOM_START + 117,
5539 EL_CUSTOM_START + 118,
5540 EL_CUSTOM_START + 119,
5542 EL_CUSTOM_START + 120,
5543 EL_CUSTOM_START + 121,
5544 EL_CUSTOM_START + 122,
5545 EL_CUSTOM_START + 123,
5547 EL_CUSTOM_START + 124,
5548 EL_CUSTOM_START + 125,
5549 EL_CUSTOM_START + 126,
5550 EL_CUSTOM_START + 127,
5552 EL_CUSTOM_START + 128,
5553 EL_CUSTOM_START + 129,
5554 EL_CUSTOM_START + 130,
5555 EL_CUSTOM_START + 131,
5557 EL_CUSTOM_START + 132,
5558 EL_CUSTOM_START + 133,
5559 EL_CUSTOM_START + 134,
5560 EL_CUSTOM_START + 135,
5562 EL_CUSTOM_START + 136,
5563 EL_CUSTOM_START + 137,
5564 EL_CUSTOM_START + 138,
5565 EL_CUSTOM_START + 139,
5567 EL_CUSTOM_START + 140,
5568 EL_CUSTOM_START + 141,
5569 EL_CUSTOM_START + 142,
5570 EL_CUSTOM_START + 143,
5572 EL_CUSTOM_START + 144,
5573 EL_CUSTOM_START + 145,
5574 EL_CUSTOM_START + 146,
5575 EL_CUSTOM_START + 147,
5577 EL_CUSTOM_START + 148,
5578 EL_CUSTOM_START + 149,
5579 EL_CUSTOM_START + 150,
5580 EL_CUSTOM_START + 151,
5582 EL_CUSTOM_START + 152,
5583 EL_CUSTOM_START + 153,
5584 EL_CUSTOM_START + 154,
5585 EL_CUSTOM_START + 155,
5587 EL_CUSTOM_START + 156,
5588 EL_CUSTOM_START + 157,
5589 EL_CUSTOM_START + 158,
5590 EL_CUSTOM_START + 159,
5592 EL_CUSTOM_START + 160,
5593 EL_CUSTOM_START + 161,
5594 EL_CUSTOM_START + 162,
5595 EL_CUSTOM_START + 163,
5597 EL_CUSTOM_START + 164,
5598 EL_CUSTOM_START + 165,
5599 EL_CUSTOM_START + 166,
5600 EL_CUSTOM_START + 167,
5602 EL_CUSTOM_START + 168,
5603 EL_CUSTOM_START + 169,
5604 EL_CUSTOM_START + 170,
5605 EL_CUSTOM_START + 171,
5607 EL_CUSTOM_START + 172,
5608 EL_CUSTOM_START + 173,
5609 EL_CUSTOM_START + 174,
5610 EL_CUSTOM_START + 175,
5612 EL_CUSTOM_START + 176,
5613 EL_CUSTOM_START + 177,
5614 EL_CUSTOM_START + 178,
5615 EL_CUSTOM_START + 179,
5617 EL_CUSTOM_START + 180,
5618 EL_CUSTOM_START + 181,
5619 EL_CUSTOM_START + 182,
5620 EL_CUSTOM_START + 183,
5622 EL_CUSTOM_START + 184,
5623 EL_CUSTOM_START + 185,
5624 EL_CUSTOM_START + 186,
5625 EL_CUSTOM_START + 187,
5627 EL_CUSTOM_START + 188,
5628 EL_CUSTOM_START + 189,
5629 EL_CUSTOM_START + 190,
5630 EL_CUSTOM_START + 191,
5632 EL_CUSTOM_START + 192,
5633 EL_CUSTOM_START + 193,
5634 EL_CUSTOM_START + 194,
5635 EL_CUSTOM_START + 195,
5637 EL_CUSTOM_START + 196,
5638 EL_CUSTOM_START + 197,
5639 EL_CUSTOM_START + 198,
5640 EL_CUSTOM_START + 199,
5642 EL_CUSTOM_START + 200,
5643 EL_CUSTOM_START + 201,
5644 EL_CUSTOM_START + 202,
5645 EL_CUSTOM_START + 203,
5647 EL_CUSTOM_START + 204,
5648 EL_CUSTOM_START + 205,
5649 EL_CUSTOM_START + 206,
5650 EL_CUSTOM_START + 207,
5652 EL_CUSTOM_START + 208,
5653 EL_CUSTOM_START + 209,
5654 EL_CUSTOM_START + 210,
5655 EL_CUSTOM_START + 211,
5657 EL_CUSTOM_START + 212,
5658 EL_CUSTOM_START + 213,
5659 EL_CUSTOM_START + 214,
5660 EL_CUSTOM_START + 215,
5662 EL_CUSTOM_START + 216,
5663 EL_CUSTOM_START + 217,
5664 EL_CUSTOM_START + 218,
5665 EL_CUSTOM_START + 219,
5667 EL_CUSTOM_START + 220,
5668 EL_CUSTOM_START + 221,
5669 EL_CUSTOM_START + 222,
5670 EL_CUSTOM_START + 223,
5672 EL_CUSTOM_START + 224,
5673 EL_CUSTOM_START + 225,
5674 EL_CUSTOM_START + 226,
5675 EL_CUSTOM_START + 227,
5677 EL_CUSTOM_START + 228,
5678 EL_CUSTOM_START + 229,
5679 EL_CUSTOM_START + 230,
5680 EL_CUSTOM_START + 231,
5682 EL_CUSTOM_START + 232,
5683 EL_CUSTOM_START + 233,
5684 EL_CUSTOM_START + 234,
5685 EL_CUSTOM_START + 235,
5687 EL_CUSTOM_START + 236,
5688 EL_CUSTOM_START + 237,
5689 EL_CUSTOM_START + 238,
5690 EL_CUSTOM_START + 239,
5692 EL_CUSTOM_START + 240,
5693 EL_CUSTOM_START + 241,
5694 EL_CUSTOM_START + 242,
5695 EL_CUSTOM_START + 243,
5697 EL_CUSTOM_START + 244,
5698 EL_CUSTOM_START + 245,
5699 EL_CUSTOM_START + 246,
5700 EL_CUSTOM_START + 247,
5702 EL_CUSTOM_START + 248,
5703 EL_CUSTOM_START + 249,
5704 EL_CUSTOM_START + 250,
5705 EL_CUSTOM_START + 251,
5707 EL_CUSTOM_START + 252,
5708 EL_CUSTOM_START + 253,
5709 EL_CUSTOM_START + 254,
5710 EL_CUSTOM_START + 255
5712 static int *editor_hl_custom_ptr = editor_hl_custom;
5713 static int *editor_el_custom_ptr = editor_el_custom;
5714 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5715 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5717 static int editor_hl_group[] =
5719 EL_INTERNAL_CASCADE_GE_ACTIVE,
5725 static int editor_el_group[] =
5739 EL_GROUP_START + 10,
5740 EL_GROUP_START + 11,
5742 EL_GROUP_START + 12,
5743 EL_GROUP_START + 13,
5744 EL_GROUP_START + 14,
5745 EL_GROUP_START + 15,
5747 EL_GROUP_START + 16,
5748 EL_GROUP_START + 17,
5749 EL_GROUP_START + 18,
5750 EL_GROUP_START + 19,
5752 EL_GROUP_START + 20,
5753 EL_GROUP_START + 21,
5754 EL_GROUP_START + 22,
5755 EL_GROUP_START + 23,
5757 EL_GROUP_START + 24,
5758 EL_GROUP_START + 25,
5759 EL_GROUP_START + 26,
5760 EL_GROUP_START + 27,
5762 EL_GROUP_START + 28,
5763 EL_GROUP_START + 29,
5764 EL_GROUP_START + 30,
5767 static int *editor_hl_group_ptr = editor_hl_group;
5768 static int *editor_el_group_ptr = editor_el_group;
5769 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5770 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5772 static int editor_hl_empty_space[] =
5774 EL_INTERNAL_CASCADE_ES_ACTIVE,
5780 static int editor_el_empty_space[] =
5802 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
5803 static int *editor_el_empty_space_ptr = editor_el_empty_space;
5804 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
5805 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
5807 static int editor_hl_reference[] =
5809 EL_INTERNAL_CASCADE_REF_ACTIVE,
5815 static int editor_el_reference[] =
5819 EL_TRIGGER_CE_VALUE,
5820 EL_TRIGGER_CE_SCORE,
5824 EL_CURRENT_CE_VALUE,
5825 EL_CURRENT_CE_SCORE,
5847 static int *editor_hl_reference_ptr = editor_hl_reference;
5848 static int *editor_el_reference_ptr = editor_el_reference;
5849 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5850 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5852 static int editor_hl_user_defined[] =
5854 EL_INTERNAL_CASCADE_USER_ACTIVE,
5860 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5861 static int *editor_el_user_defined_ptr = NULL;
5862 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5863 static int num_editor_el_user_defined = 0;
5865 static int editor_hl_dynamic[] =
5867 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5873 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5874 static int *editor_el_dynamic_ptr = NULL;
5875 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5876 static int num_editor_el_dynamic = 0;
5878 static int editor_hl_empty[] = { EL_EMPTY };
5879 static int *editor_el_empty = NULL; // dynamically allocated
5881 static int *editor_hl_empty_ptr = editor_hl_empty;
5882 static int *editor_el_empty_ptr = NULL;
5883 static int num_editor_hl_empty = 0;
5884 static int num_editor_el_empty = 0; // dynamically determined, if needed
5886 static boolean use_el_empty = FALSE;
5888 static int *editor_elements = NULL; // dynamically allocated
5889 static int num_editor_elements = 0; // dynamically determined
5891 static boolean setup_editor_cascade_never = FALSE;
5893 static boolean setup_editor_el_players = TRUE;
5894 static boolean setup_editor_el_boulderdash = TRUE;
5895 static boolean setup_editor_el_boulderdash_native = TRUE;
5896 static boolean setup_editor_el_emerald_mine = TRUE;
5897 static boolean setup_editor_el_emerald_mine_club = TRUE;
5898 static boolean setup_editor_el_more = TRUE;
5899 static boolean setup_editor_el_sokoban = TRUE;
5900 static boolean setup_editor_el_supaplex = TRUE;
5901 static boolean setup_editor_el_diamond_caves = TRUE;
5902 static boolean setup_editor_el_dx_boulderdash = TRUE;
5903 static boolean setup_editor_el_mirror_magic = TRUE;
5904 static boolean setup_editor_el_deflektor = TRUE;
5905 static boolean setup_editor_el_chars = TRUE;
5906 static boolean setup_editor_el_steel_chars = TRUE;
5907 static boolean setup_editor_el_custom = TRUE;
5908 static boolean setup_editor_el_user_defined = TRUE;
5909 static boolean setup_editor_el_dynamic = TRUE;
5911 static int editor_hl_unused[] = { EL_EMPTY };
5912 static int *editor_hl_unused_ptr = editor_hl_unused;
5913 static int num_editor_hl_unused = 0;
5917 boolean *setup_value;
5918 boolean *setup_cascade_value;
5920 int **headline_list;
5921 int *headline_list_size;
5924 int *element_list_size;
5926 boolean last_setup_value;
5928 editor_elements_info[] =
5931 &setup_editor_el_players,
5932 &setup_editor_cascade_never,
5933 &editor_hl_unused_ptr, &num_editor_hl_unused,
5934 &editor_el_players_ptr, &num_editor_el_players
5937 &setup_editor_el_boulderdash,
5938 &setup.editor_cascade.el_bd,
5939 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5940 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5943 &setup_editor_el_boulderdash_native,
5944 &setup.editor_cascade.el_bd_native,
5945 &editor_hl_boulderdash_native_ptr, &num_editor_hl_boulderdash_native,
5946 &editor_el_boulderdash_native_ptr, &num_editor_el_boulderdash_native
5949 &setup_editor_el_emerald_mine,
5950 &setup.editor_cascade.el_em,
5951 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5952 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5955 &setup_editor_el_emerald_mine_club,
5956 &setup.editor_cascade.el_emc,
5957 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5958 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5961 &setup_editor_el_more,
5962 &setup.editor_cascade.el_rnd,
5963 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5964 &editor_el_rnd_ptr, &num_editor_el_rnd
5967 &setup_editor_el_sokoban,
5968 &setup.editor_cascade.el_sb,
5969 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5970 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5973 &setup_editor_el_supaplex,
5974 &setup.editor_cascade.el_sp,
5975 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5976 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5979 &setup_editor_el_diamond_caves,
5980 &setup.editor_cascade.el_dc,
5981 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5982 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5985 &setup_editor_el_dx_boulderdash,
5986 &setup.editor_cascade.el_dx,
5987 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5988 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
5991 &setup_editor_el_mirror_magic,
5992 &setup.editor_cascade.el_mm,
5993 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
5994 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
5997 &setup_editor_el_deflektor,
5998 &setup.editor_cascade.el_df,
5999 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
6000 &editor_el_deflektor_ptr, &num_editor_el_deflektor
6003 &setup_editor_el_chars,
6004 &setup.editor_cascade.el_chars,
6005 &editor_hl_chars_ptr, &num_editor_hl_chars,
6006 &editor_el_chars_ptr, &num_editor_el_chars
6009 &setup_editor_el_steel_chars,
6010 &setup.editor_cascade.el_steel_chars,
6011 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
6012 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
6015 &setup_editor_el_custom,
6016 &setup.editor_cascade.el_ce,
6017 &editor_hl_custom_ptr, &num_editor_hl_custom,
6018 &editor_el_custom_ptr, &num_editor_el_custom
6021 &setup_editor_el_custom,
6022 &setup.editor_cascade.el_ge,
6023 &editor_hl_group_ptr, &num_editor_hl_group,
6024 &editor_el_group_ptr, &num_editor_el_group
6027 &setup_editor_el_custom,
6028 &setup.editor_cascade.el_es,
6029 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
6030 &editor_el_empty_space_ptr, &num_editor_el_empty_space
6033 &setup_editor_el_custom,
6034 &setup.editor_cascade.el_ref,
6035 &editor_hl_reference_ptr, &num_editor_hl_reference,
6036 &editor_el_reference_ptr, &num_editor_el_reference
6039 &setup_editor_el_user_defined,
6040 &setup.editor_cascade.el_user,
6041 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
6042 &editor_el_user_defined_ptr, &num_editor_el_user_defined
6045 &setup_editor_el_dynamic,
6046 &setup.editor_cascade.el_dynamic,
6047 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
6048 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
6053 &editor_hl_empty_ptr, &num_editor_hl_empty,
6054 &editor_el_empty_ptr, &num_editor_el_empty,
6064 static struct XY xy_directions[] =
6073 // ----------------------------------------------------------------------------
6075 // ----------------------------------------------------------------------------
6077 static int getMaxInfoTextLength(void)
6079 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
6082 static int getTextWidthForGadget(char *text)
6087 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
6090 static int getTextWidthForDrawingArea(char *text)
6095 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
6098 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
6100 return (gi->x + gi->width + getTextWidthForGadget(text));
6103 static char *getElementInfoText(int element)
6105 char *info_text = NULL;
6107 if (element < MAX_NUM_ELEMENTS)
6109 if (strlen(element_info[element].description) > 0)
6110 info_text = element_info[element].description;
6111 else if (element_info[element].custom_description != NULL)
6112 info_text = element_info[element].custom_description;
6113 else if (element_info[element].editor_description != NULL)
6114 info_text = element_info[element].editor_description;
6117 if (info_text == NULL)
6118 info_text = INFOTEXT_UNKNOWN_ELEMENT;
6123 static char *getElementDescriptionFilenameExt(char *basename)
6125 char *elements_subdir = ELEMENTS_DIRECTORY;
6126 static char *elements_subdir2 = NULL;
6127 static char *filename = NULL;
6129 if (elements_subdir2 == NULL)
6130 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
6132 checked_free(filename);
6134 // 1st try: look for element description in current level set directory
6135 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
6136 if (fileExists(filename))
6141 // 2nd try: look for element description in the game's base directory
6142 filename = getPath3(options.docs_directory, elements_subdir, basename);
6143 if (fileExists(filename))
6149 static char *getElementDescriptionFilename(int element)
6151 char basename[MAX_FILENAME_LEN];
6154 // 1st try: look for element description file for exactly this element
6155 sprintf(basename, "%s.txt", element_info[element].token_name);
6156 filename = getElementDescriptionFilenameExt(basename);
6157 if (filename != NULL)
6160 // 2nd try: look for element description file for this element's class
6161 sprintf(basename, "%s.txt", element_info[element].class_name);
6162 filename = getElementDescriptionFilenameExt(basename);
6163 if (filename != NULL)
6166 // 3rd try: look for generic fallback text file for any element
6167 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
6168 if (filename != NULL)
6174 static boolean suppressBorderElement(void)
6176 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
6177 lev_fieldx <= MAX_ED_FIELDX &&
6178 lev_fieldy <= MAX_ED_FIELDY);
6181 static void InitDynamicEditorElementList(int **elements, int *num_elements)
6183 boolean element_found[NUM_FILE_ELEMENTS];
6186 // initialize list of used elements to "not used"
6187 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6188 element_found[i] = FALSE;
6190 // find all elements used in current level
6191 for (y = 0; y < lev_fieldy; y++)
6193 for (x = 0; x < lev_fieldx; x++)
6195 if (Tile[x][y] >= NUM_FILE_ELEMENTS) // should never happen
6198 if (IS_MM_WALL(Tile[x][y]))
6199 element_found[map_mm_wall_element(Tile[x][y])] = TRUE;
6201 element_found[Tile[x][y]] = TRUE;
6207 // count number of elements used in current level
6208 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6209 if (element_found[i])
6212 // add space for up to 3 more elements for padding that may be needed
6215 // free memory for old list of elements, if needed
6216 checked_free(*elements);
6218 // allocate memory for new list of elements
6219 *elements = checked_malloc(*num_elements * sizeof(int));
6223 // add all elements used in current level (non-custom/group/empty elements)
6224 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6225 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) ||
6226 IS_GROUP_ELEMENT(i) ||
6227 IS_EMPTY_ELEMENT(i)))
6228 (*elements)[(*num_elements)++] = i;
6230 // add all elements used in current level (custom/group/empty elements)
6231 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6232 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) ||
6233 IS_GROUP_ELEMENT(i) ||
6234 IS_EMPTY_ELEMENT(i)))
6235 (*elements)[(*num_elements)++] = i;
6237 while (*num_elements % 4) // pad with empty elements, if needed
6238 (*elements)[(*num_elements)++] = EL_EMPTY;
6241 static void ReinitializeElementList_EnableSections(void)
6243 // default: enable all element sections
6245 setup_editor_el_players = TRUE;
6246 setup_editor_el_boulderdash = TRUE;
6247 setup_editor_el_boulderdash_native = TRUE;
6248 setup_editor_el_emerald_mine = TRUE;
6249 setup_editor_el_emerald_mine_club = TRUE;
6250 setup_editor_el_more = TRUE;
6251 setup_editor_el_sokoban = TRUE;
6252 setup_editor_el_supaplex = TRUE;
6253 setup_editor_el_diamond_caves = TRUE;
6254 setup_editor_el_dx_boulderdash = TRUE;
6255 setup_editor_el_mirror_magic = TRUE;
6256 setup_editor_el_deflektor = TRUE;
6257 setup_editor_el_chars = TRUE;
6258 setup_editor_el_steel_chars = TRUE;
6260 setup_editor_el_custom = TRUE;
6261 setup_editor_el_user_defined = TRUE;
6262 setup_editor_el_dynamic = TRUE;
6264 // now disable all element sections not to be displayed
6266 if (!setup.editor.el_classic)
6268 setup_editor_el_players = FALSE;
6269 setup_editor_el_boulderdash = FALSE;
6270 setup_editor_el_boulderdash_native = FALSE;
6271 setup_editor_el_emerald_mine = FALSE;
6272 setup_editor_el_emerald_mine_club = FALSE;
6273 setup_editor_el_more = FALSE;
6274 setup_editor_el_sokoban = FALSE;
6275 setup_editor_el_supaplex = FALSE;
6276 setup_editor_el_diamond_caves = FALSE;
6277 setup_editor_el_dx_boulderdash = FALSE;
6278 setup_editor_el_mirror_magic = FALSE;
6279 setup_editor_el_deflektor = FALSE;
6280 setup_editor_el_chars = FALSE;
6281 setup_editor_el_steel_chars = FALSE;
6284 if (!setup.editor.el_custom)
6286 setup_editor_el_custom = FALSE;
6289 if (!setup.editor.el_user_defined)
6291 setup_editor_el_user_defined = FALSE;
6294 if (!setup.editor.el_dynamic)
6296 setup_editor_el_dynamic = FALSE;
6299 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
6301 setup_editor_el_boulderdash_native = FALSE;
6302 setup_editor_el_mirror_magic = FALSE;
6303 setup_editor_el_deflektor = FALSE;
6305 else if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
6307 setup_editor_el_players = FALSE;
6308 setup_editor_el_boulderdash = FALSE;
6309 setup_editor_el_emerald_mine = FALSE;
6310 setup_editor_el_emerald_mine_club = FALSE;
6311 setup_editor_el_more = FALSE;
6312 setup_editor_el_sokoban = FALSE;
6313 setup_editor_el_supaplex = FALSE;
6314 setup_editor_el_diamond_caves = FALSE;
6315 setup_editor_el_dx_boulderdash = FALSE;
6316 setup_editor_el_mirror_magic = FALSE;
6317 setup_editor_el_deflektor = FALSE;
6318 setup_editor_el_chars = FALSE;
6319 setup_editor_el_steel_chars = FALSE;
6321 setup_editor_el_custom = FALSE;
6323 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
6325 setup_editor_el_boulderdash = FALSE;
6326 setup_editor_el_boulderdash_native = FALSE;
6327 setup_editor_el_more = FALSE;
6328 setup_editor_el_sokoban = FALSE;
6329 setup_editor_el_supaplex = FALSE;
6330 setup_editor_el_diamond_caves = FALSE;
6331 setup_editor_el_dx_boulderdash = FALSE;
6332 setup_editor_el_mirror_magic = FALSE;
6333 setup_editor_el_deflektor = FALSE;
6334 setup_editor_el_steel_chars = FALSE;
6336 setup_editor_el_custom = FALSE;
6338 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
6340 setup_editor_el_players = FALSE;
6341 setup_editor_el_boulderdash = FALSE;
6342 setup_editor_el_boulderdash_native = FALSE;
6343 setup_editor_el_emerald_mine = FALSE;
6344 setup_editor_el_emerald_mine_club = FALSE;
6345 setup_editor_el_more = FALSE;
6346 setup_editor_el_sokoban = FALSE;
6347 setup_editor_el_diamond_caves = FALSE;
6348 setup_editor_el_dx_boulderdash = FALSE;
6349 setup_editor_el_mirror_magic = FALSE;
6350 setup_editor_el_deflektor = FALSE;
6351 setup_editor_el_chars = FALSE;
6352 setup_editor_el_steel_chars = FALSE;
6354 setup_editor_el_custom = FALSE;
6356 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
6358 setup_editor_el_players = FALSE;
6359 setup_editor_el_boulderdash = FALSE;
6360 setup_editor_el_boulderdash_native = FALSE;
6361 setup_editor_el_emerald_mine = FALSE;
6362 setup_editor_el_emerald_mine_club = FALSE;
6363 setup_editor_el_more = FALSE;
6364 setup_editor_el_sokoban = FALSE;
6365 setup_editor_el_supaplex = FALSE;
6366 setup_editor_el_diamond_caves = FALSE;
6367 setup_editor_el_dx_boulderdash = FALSE;
6368 setup_editor_el_steel_chars = FALSE;
6370 setup_editor_el_custom = FALSE;
6374 static void ReinitializeElementList(void)
6376 static boolean initialization_needed = TRUE;
6380 ReinitializeElementList_EnableSections();
6382 if (initialization_needed)
6384 LoadSetup_EditorCascade(); // load last editor cascade state
6386 // initialize editor cascade element from saved cascade state
6387 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6389 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
6390 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
6392 if (IS_EDITOR_CASCADE(*cascade_element))
6394 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
6395 EL_CASCADE_INACTIVE(*cascade_element));
6398 initialization_needed = FALSE;
6401 checked_free(editor_elements);
6403 // reload optional user defined element list for each invocation of editor
6404 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
6405 &num_editor_el_user_defined);
6407 // initialize dynamic level element list for each invocation of editor
6408 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
6409 &num_editor_el_dynamic);
6411 // initialize list of empty elements (used for padding, if needed)
6412 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6413 editor_el_empty[i] = EL_EMPTY;
6415 // do some sanity checks for each element from element list
6416 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6418 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6420 int element = (*editor_elements_info[i].element_list)[j];
6422 if (element >= NUM_FILE_ELEMENTS)
6423 Warn("editor element %d is runtime element", element);
6425 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
6426 Warn("no element description text for element %d", element);
6430 num_editor_elements = 0;
6431 use_el_empty = FALSE;
6433 // determine size of element list
6434 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6436 if (*editor_elements_info[i].setup_value)
6438 boolean found_inactive_cascade = FALSE;
6440 if (setup.editor.el_headlines)
6442 // required for correct padding of palette headline buttons
6443 if (*editor_elements_info[i].headline_list_size > 0)
6444 num_editor_elements += ED_ELEMENTLIST_COLS;
6446 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6448 int element = (*editor_elements_info[i].headline_list)[j];
6450 if (IS_EDITOR_CASCADE_INACTIVE(element))
6451 found_inactive_cascade = TRUE;
6455 if (found_inactive_cascade)
6458 // required for correct padding of palette element buttons
6459 int element_list_size = *editor_elements_info[i].element_list_size;
6461 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6462 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6464 num_editor_elements += element_buttons;
6468 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
6470 // offer at least as many elements as element buttons exist
6471 use_el_empty = TRUE;
6472 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
6474 num_editor_elements += num_editor_el_empty;
6478 num_editor_el_empty = 0;
6481 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
6483 // fill element list
6484 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6486 boolean found_inactive_cascade = FALSE;
6488 if (*editor_elements_info[i].setup_value)
6490 if (setup.editor.el_headlines)
6492 // required for correct padding of palette headline buttons
6493 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6494 ED_ELEMENTLIST_COLS : 0);
6496 for (j = 0; j < headline_size; j++)
6498 // use empty elements for padding of palette headline buttons
6499 int element = (j < *editor_elements_info[i].headline_list_size ?
6500 (*editor_elements_info[i].headline_list)[j] :
6501 editor_el_empty[0]);
6503 editor_elements[pos++] = element;
6505 if (IS_EDITOR_CASCADE_INACTIVE(element))
6506 found_inactive_cascade = TRUE;
6510 if (found_inactive_cascade)
6513 // required for correct padding of palette element buttons
6514 int element_list_size = *editor_elements_info[i].element_list_size;
6516 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6517 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6519 // copy all elements from element list
6520 for (j = 0; j < element_list_size; j++)
6521 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6523 // use empty elements for padding of palette element buttons
6524 for (j = 0; j < element_buttons - element_list_size; j++)
6525 editor_elements[pos++] = editor_el_empty[0];
6529 // (this function is also called before editor gadgets are initialized!)
6530 AdjustElementListScrollbar();
6533 void PrintEditorElementList(void)
6535 boolean *stop = &setup_editor_el_user_defined;
6538 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6540 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6542 if (IS_EDITOR_CASCADE(cascade_element))
6544 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6545 char *headline = element_info[cascade_element_show].editor_description;
6547 PrintLineWithPrefix("# ", "-", 77);
6548 Print("# %s\n", headline);
6549 PrintLineWithPrefix("# ", "-", 77);
6552 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6554 int element = (*editor_elements_info[i].headline_list)[j];
6556 if (IS_EDITOR_CASCADE(element))
6557 element = EL_CHAR_MINUS;
6559 Print("# %s\n", element_info[element].token_name);
6565 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6567 int element = (*editor_elements_info[i].element_list)[j];
6569 Print("# %s\n", element_info[element].token_name);
6577 static void ReinitializeElementListButtons(void)
6579 static boolean last_setup_value_headlines = FALSE;
6580 static boolean initialization_needed = TRUE;
6583 if (!initialization_needed) // check if editor element setup has changed
6585 if (last_setup_value_headlines != setup.editor.el_headlines)
6586 initialization_needed = TRUE;
6588 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6589 if (editor_elements_info[i].last_setup_value !=
6590 *editor_elements_info[i].setup_value)
6591 initialization_needed = TRUE;
6594 if (!initialization_needed)
6597 FreeLevelEditorGadgets();
6598 CreateLevelEditorGadgets();
6600 // store current setup values for next invocation of this function
6601 last_setup_value_headlines = setup.editor.el_headlines;
6602 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6603 editor_elements_info[i].last_setup_value =
6604 *editor_elements_info[i].setup_value;
6606 initialization_needed = FALSE;
6609 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6612 int border_graphic =
6613 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6614 struct GraphicInfo *g = &graphic_info[border_graphic];
6615 Bitmap *src_bitmap = g->bitmap;
6616 int src_x = g->src_x;
6617 int src_y = g->src_y;
6618 int border_size = g->border_size;
6619 int border_xpos = g->width - border_size;
6620 int border_ypos = g->height - border_size;
6621 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6624 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6625 border_size, border_size,
6626 dest_x - border_size, dest_y - border_size);
6627 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6628 border_size, border_size,
6629 dest_x + width, dest_y - border_size);
6630 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6631 border_size, border_size,
6632 dest_x - border_size, dest_y + height);
6633 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6634 border_size, border_size,
6635 dest_x + width, dest_y + height);
6637 for (i = 0; i < width / tilesize; i++)
6639 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6640 tilesize, border_size,
6641 dest_x + i * tilesize, dest_y - border_size);
6642 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6643 tilesize, border_size,
6644 dest_x + i * tilesize, dest_y + height);
6647 for (i = 0; i < height / tilesize; i++)
6649 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6650 border_size, tilesize,
6651 dest_x - border_size, dest_y + i * tilesize);
6652 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6653 border_size, tilesize,
6654 dest_x + width, dest_y + i * tilesize);
6657 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6660 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6662 int xsize_tile = MAX(ed_tilesize, xsize);
6663 int ysize_tile = MAX(ed_tilesize, ysize);
6664 int xsize_full = xsize + 1;
6665 int ysize_full = ysize + 1;
6666 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6667 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6668 Pixel line_color = getTabulatorBarColor();
6670 if (line_color == BLACK_PIXEL) // black => transparent
6673 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6674 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6675 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6678 static void DrawEditorLevelBorderLinesIfNeeded(void)
6680 int xsize = lev_fieldx * ed_tilesize;
6681 int ysize = lev_fieldy * ed_tilesize;
6682 int line_size = getTabulatorBarHeight();
6684 if (!suppressBorderElement())
6687 // draw little border line around editable level playfield
6690 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6693 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6695 if (xsize < SXSIZE && ysize < SYSIZE)
6696 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6699 static void DrawEditorElement(int x, int y, int element)
6701 DrawSizedElement(x, y, element, ed_tilesize);
6704 static void DrawEditorElementThruMask(int x, int y, int element)
6706 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6709 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6711 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6714 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6716 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6717 DrawEditorLevelBorderLinesIfNeeded();
6720 static void DrawDrawingArea(int id)
6722 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6725 int *value = drawingarea_info[id].value;
6726 int area_xsize = drawingarea_info[id].area_xsize;
6727 int area_ysize = drawingarea_info[id].area_ysize;
6728 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6730 for (x = 0; x < area_xsize; x++)
6731 for (y = 0; y < area_ysize; y++)
6732 DrawSizedGraphicExt(drawto,
6733 gi->x + x * tilesize,
6734 gi->y + y * tilesize,
6735 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6738 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6741 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6742 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6744 BlitBitmap(drawto, drawto,
6745 SX + (dx == -1 ? ed_tilesize : 0),
6746 SY + (dy == -1 ? ed_tilesize : 0),
6747 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6748 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6749 SX + (dx == +1 ? ed_tilesize : 0),
6750 SY + (dy == +1 ? ed_tilesize : 0));
6754 x = (dx == 1 ? 0 : ed_fieldx - 1);
6755 for (y = 0; y < ed_fieldy; y++)
6756 DrawEditorElementOrWall(x, y, from_x, from_y);
6760 y = (dy == 1 ? 0 : ed_fieldy - 1);
6761 for (x = 0; x < ed_fieldx; x++)
6762 DrawEditorElementOrWall(x, y, from_x, from_y);
6765 redraw_mask |= REDRAW_FIELD;
6769 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6772 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6775 static void CreateControlButtons(void)
6777 struct GadgetInfo *gi;
6780 // create toolbox buttons
6781 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6783 int type_id = controlbutton_info[i].gadget_id; // same as gadget ID here
6784 int id = controlbutton_info[i].gadget_id;
6785 int type = controlbutton_info[i].gadget_type;
6786 int graphic = controlbutton_info[i].graphic;
6787 struct XYTileSize *pos = controlbutton_info[i].pos;
6788 struct GraphicInfo *gd = &graphic_info[graphic];
6789 Bitmap *deco_bitmap = NULL;
6790 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6791 int tile_size = 0, deco_shift = 0;
6792 boolean deco_masked = FALSE;
6793 int gd_x1 = gd->src_x;
6794 int gd_y1 = gd->src_y;
6795 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6796 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6797 int gd_x1a = gd->src_x + gd->active_xoffset;
6798 int gd_y1a = gd->src_y + gd->active_yoffset;
6799 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6800 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6803 unsigned int event_mask;
6804 int radio_button_nr = RADIO_NR_NONE;
6805 boolean checked = FALSE;
6808 Fail("'controlbutton_info' structure corrupted at index %d -- please fix", i);
6810 if (type == GD_TYPE_RADIO_BUTTON)
6812 event_mask = GD_EVENT_PRESSED;
6813 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6815 if (id == drawing_function)
6820 if (id == GADGET_ID_WRAP_LEFT ||
6821 id == GADGET_ID_WRAP_RIGHT ||
6822 id == GADGET_ID_WRAP_UP ||
6823 id == GADGET_ID_WRAP_DOWN)
6824 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6826 event_mask = GD_EVENT_RELEASED;
6829 if (id == GADGET_ID_PROPERTIES ||
6830 id == GADGET_ID_PALETTE)
6835 else if (id == GADGET_ID_ELEMENT_LEFT ||
6836 id == GADGET_ID_ELEMENT_MIDDLE ||
6837 id == GADGET_ID_ELEMENT_RIGHT)
6842 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6843 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6844 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6846 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6847 editor.button.element_left.tile_size :
6848 id == GADGET_ID_ELEMENT_MIDDLE ?
6849 editor.button.element_middle.tile_size :
6850 id == GADGET_ID_ELEMENT_RIGHT ?
6851 editor.button.element_right.tile_size : 0);
6853 // make sure that decoration does not overlap gadget border
6854 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6856 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6858 deco_xpos = (gd->width - tile_size) / 2;
6859 deco_ypos = (gd->height - tile_size) / 2;
6861 deco_masked = gd->draw_masked;
6869 gi = CreateGadget(GDI_CUSTOM_ID, id,
6870 GDI_CUSTOM_TYPE_ID, type_id,
6871 GDI_IMAGE_ID, graphic,
6872 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6875 GDI_WIDTH, gd->width,
6876 GDI_HEIGHT, gd->height,
6878 GDI_STATE, GD_BUTTON_UNPRESSED,
6879 GDI_RADIO_NR, radio_button_nr,
6880 GDI_CHECKED, checked,
6881 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6882 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6883 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6884 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6885 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6886 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6887 GDI_DECORATION_SIZE, tile_size, tile_size,
6888 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6889 GDI_DECORATION_MASKED, deco_masked,
6890 GDI_EVENT_MASK, event_mask,
6891 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6892 GDI_CALLBACK_ACTION, HandleControlButtons,
6896 Fail("cannot create gadget");
6898 level_editor_gadget[id] = gi;
6901 // these values are not constant, but can change at runtime
6902 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6903 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6904 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6905 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6906 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6907 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6908 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6909 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6910 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6911 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6912 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6913 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6915 // create buttons for scrolling of drawing area and element list
6916 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6918 int id = scrollbutton_info[i].gadget_id;
6919 int type_id = scrollbutton_info[i].gadget_type_id;
6920 int graphic = scrollbutton_info[i].graphic;
6921 struct GraphicInfo *gd = &graphic_info[graphic];
6922 Bitmap *gd_bitmap = gd->bitmap;
6923 int gd_x1 = gd->src_x;
6924 int gd_y1 = gd->src_y;
6925 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6926 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6927 int width = gd->width;
6928 int height = gd->height;
6929 int x = scrollbutton_pos[i].x;
6930 int y = scrollbutton_pos[i].y;
6931 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6934 Fail("'scrollbutton_info' structure corrupted at index %d -- please fix", i);
6936 if (id == GADGET_ID_SCROLL_LIST_UP ||
6937 id == GADGET_ID_SCROLL_LIST_DOWN)
6948 gi = CreateGadget(GDI_CUSTOM_ID, id,
6949 GDI_CUSTOM_TYPE_ID, type_id,
6950 GDI_IMAGE_ID, graphic,
6951 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6956 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6957 GDI_STATE, GD_BUTTON_UNPRESSED,
6958 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6959 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6960 GDI_EVENT_MASK, event_mask,
6961 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6962 GDI_CALLBACK_ACTION, HandleControlButtons,
6966 Fail("cannot create gadget");
6968 level_editor_gadget[id] = gi;
6971 // create buttons for element list
6972 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6975 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6976 int graphic = IMG_EDITOR_PALETTE_BUTTON;
6977 struct GraphicInfo *gd = &graphic_info[graphic];
6978 Bitmap *gd_bitmap = gd->bitmap;
6979 Bitmap *deco_bitmap;
6980 int deco_x, deco_y, deco_xpos, deco_ypos;
6981 int gd_x1 = gd->src_x;
6982 int gd_y1 = gd->src_y;
6983 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6984 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6985 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
6986 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
6987 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
6988 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
6989 int element = editor_elements[i];
6990 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
6991 unsigned int event_mask = GD_EVENT_RELEASED;
6993 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
6995 deco_xpos = (gd->width - tile_size) / 2;
6996 deco_ypos = (gd->height - tile_size) / 2;
6998 gi = CreateGadget(GDI_CUSTOM_ID, id,
6999 GDI_CUSTOM_TYPE_ID, type_id,
7000 GDI_IMAGE_ID, graphic,
7001 GDI_INFO_TEXT, getElementInfoText(element),
7004 GDI_WIDTH, gd->width,
7005 GDI_HEIGHT, gd->height,
7006 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7007 GDI_STATE, GD_BUTTON_UNPRESSED,
7008 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7009 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7010 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7011 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7012 GDI_DECORATION_SIZE, tile_size, tile_size,
7013 GDI_DECORATION_SHIFTING, 1, 1,
7014 GDI_EVENT_MASK, event_mask,
7015 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7016 GDI_CALLBACK_ACTION, HandleControlButtons,
7020 Fail("cannot create gadget");
7022 level_editor_gadget[id] = gi;
7026 static void CreateCounterButtons(void)
7028 int max_infotext_len = getMaxInfoTextLength();
7031 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
7033 int type_id = counterbutton_info[i].gadget_type_id;
7034 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
7035 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
7039 Fail("'counterbutton_info' structure corrupted at index %d -- please fix", i);
7041 // determine horizontal position to the right of specified gadget
7042 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7043 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
7044 ED_GADGET_TEXT_DISTANCE);
7046 // determine horizontal offset for leading text
7047 if (counterbutton_info[i].text_left != NULL)
7048 x += getTextWidthForGadget(counterbutton_info[i].text_left);
7050 for (j = 0; j < 2; j++)
7052 struct GadgetInfo *gi;
7054 counterbutton_info[i].gadget_id_down :
7055 counterbutton_info[i].gadget_id_up);
7057 struct GraphicInfo *gd;
7058 int gd_x1, gd_x2, gd_y1, gd_y2;
7059 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7060 char infotext[max_infotext_len + 1];
7062 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7065 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
7066 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
7068 event_mask |= GD_EVENT_RELEASED;
7072 x = DX + editor.button.prev_level.x;
7073 y = DY + editor.button.prev_level.y;
7077 x = DX + editor.button.next_level.x;
7078 y = DY + editor.button.next_level.y;
7084 IMG_EDITOR_COUNTER_DOWN :
7085 IMG_EDITOR_COUNTER_UP);
7088 gd = &graphic_info[graphic];
7092 gd_x2 = gd->src_x + gd->pressed_xoffset;
7093 gd_y2 = gd->src_y + gd->pressed_yoffset;
7095 sprintf(infotext, "%s counter value by 1, 5 or 10",
7096 (j == 0 ? "decrease" : "increase"));
7098 gi = CreateGadget(GDI_CUSTOM_ID, id,
7099 GDI_CUSTOM_TYPE_ID, type_id,
7100 GDI_IMAGE_ID, graphic,
7101 GDI_INFO_TEXT, infotext,
7104 GDI_WIDTH, gd->width,
7105 GDI_HEIGHT, gd->height,
7106 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7107 GDI_STATE, GD_BUTTON_UNPRESSED,
7108 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7109 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7110 GDI_EVENT_MASK, event_mask,
7111 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7112 GDI_CALLBACK_ACTION, HandleCounterButtons,
7116 Fail("cannot create gadget");
7118 level_editor_gadget[id] = gi;
7119 right_gadget_border[id] =
7120 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7122 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
7126 int font_type = FONT_INPUT_1;
7127 int font_type_active = FONT_INPUT_1_ACTIVE;
7129 id = counterbutton_info[i].gadget_id_text;
7131 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7133 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7135 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
7137 font_type = FONT_LEVEL_NUMBER;
7138 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
7140 x = DX + editor.input.level_number.x;
7141 y = DY + editor.input.level_number.y;
7145 graphic = IMG_EDITOR_COUNTER_INPUT;
7148 gd = &graphic_info[graphic];
7152 gd_x2 = gd->src_x + gd->active_xoffset;
7153 gd_y2 = gd->src_y + gd->active_yoffset;
7155 gi = CreateGadget(GDI_CUSTOM_ID, id,
7156 GDI_CUSTOM_TYPE_ID, type_id,
7157 GDI_IMAGE_ID, graphic,
7158 GDI_INFO_TEXT, "enter counter value",
7161 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
7162 GDI_NUMBER_VALUE, 0,
7163 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
7164 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
7165 GDI_TEXT_SIZE, 3, // minimal counter text size
7166 GDI_TEXT_FONT, font_type,
7167 GDI_TEXT_FONT_ACTIVE, font_type_active,
7168 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7169 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7170 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7171 GDI_DESIGN_WIDTH, gd->width,
7172 GDI_EVENT_MASK, event_mask,
7173 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7174 GDI_CALLBACK_ACTION, HandleCounterButtons,
7178 Fail("cannot create gadget");
7180 level_editor_gadget[id] = gi;
7181 right_gadget_border[id] =
7182 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7184 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
7190 static void CreateDrawingAreas(void)
7194 // these values are not constant, but can change at runtime
7195 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
7196 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
7198 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
7200 struct GadgetInfo *gi;
7201 int id = drawingarea_info[i].gadget_id;
7202 int type_id = drawingarea_info[i].gadget_type_id;
7203 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
7204 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
7205 int area_xsize = drawingarea_info[i].area_xsize;
7206 int area_ysize = drawingarea_info[i].area_ysize;
7207 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
7208 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
7209 unsigned int event_mask =
7210 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
7211 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
7214 Fail("'drawingarea_info' structure corrupted at index %d -- please fix", i);
7216 // determine horizontal position to the right of specified gadget
7217 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
7218 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
7219 ED_DRAWINGAREA_TEXT_DISTANCE);
7221 // determine horizontal offset for leading text
7222 if (drawingarea_info[i].text_left != NULL)
7223 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
7225 gi = CreateGadget(GDI_CUSTOM_ID, id,
7226 GDI_CUSTOM_TYPE_ID, type_id,
7229 GDI_TYPE, GD_TYPE_DRAWING_AREA,
7230 GDI_AREA_SIZE, area_xsize, area_ysize,
7231 GDI_ITEM_SIZE, item_size, item_size,
7232 GDI_EVENT_MASK, event_mask,
7233 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
7234 GDI_CALLBACK_ACTION, HandleDrawingAreas,
7238 Fail("cannot create gadget");
7240 level_editor_gadget[id] = gi;
7241 right_gadget_border[id] =
7242 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
7246 static void CreateTextInputGadgets(void)
7248 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
7249 int max_infotext_len = getMaxInfoTextLength();
7252 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
7254 int gd_x1 = gd->src_x;
7255 int gd_y1 = gd->src_y;
7256 int gd_x2 = gd->src_x + gd->active_xoffset;
7257 int gd_y2 = gd->src_y + gd->active_yoffset;
7258 struct GadgetInfo *gi;
7259 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7260 char infotext[MAX_OUTPUT_LINESIZE + 1];
7261 int id = textinput_info[i].gadget_id;
7262 int type_id = textinput_info[i].gadget_type_id;
7266 Fail("'textinput_info' structure corrupted at index %d -- please fix", i);
7268 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
7270 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
7271 int border_size = gd->border_size;
7272 int font_nr = FONT_INPUT_1;
7273 int font_height = getFontHeight(font_nr);
7274 int xoffset = element_border + TILEX + element_border + 3 * border_size;
7275 int yoffset = element_border + (TILEY - font_height) / 2;
7277 x = (editor.settings.element_name.x != -1 ?
7278 editor.settings.element_name.x :
7279 editor.settings.element_graphic.x + xoffset) - border_size;
7280 y = (editor.settings.element_name.y != -1 ?
7281 editor.settings.element_name.y :
7282 editor.settings.element_graphic.y + yoffset) - border_size;
7286 x = ED_SETTINGS_X(textinput_info[i].x);
7287 y = ED_SETTINGS_Y(textinput_info[i].y);
7290 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
7291 infotext[max_infotext_len] = '\0';
7293 gi = CreateGadget(GDI_CUSTOM_ID, id,
7294 GDI_CUSTOM_TYPE_ID, type_id,
7295 GDI_INFO_TEXT, infotext,
7298 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
7299 GDI_TEXT_VALUE, textinput_info[i].value,
7300 GDI_TEXT_SIZE, textinput_info[i].size,
7301 GDI_TEXT_FONT, FONT_INPUT_1,
7302 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7303 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7304 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7305 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7306 GDI_DESIGN_WIDTH, gd->width,
7307 GDI_EVENT_MASK, event_mask,
7308 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7309 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
7313 Fail("cannot create gadget");
7315 level_editor_gadget[id] = gi;
7319 static void CreateTextAreaGadgets(void)
7321 int max_infotext_len = getMaxInfoTextLength();
7324 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
7326 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
7327 int gd_x1 = gd->src_x;
7328 int gd_y1 = gd->src_y;
7329 int gd_x2 = gd->src_x + gd->active_xoffset;
7330 int gd_y2 = gd->src_y + gd->active_yoffset;
7331 struct GadgetInfo *gi;
7332 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
7333 char infotext[MAX_OUTPUT_LINESIZE + 1];
7334 int id = textarea_info[i].gadget_id;
7335 int type_id = textarea_info[i].gadget_type_id;
7336 int area_xsize = textarea_info[i].xsize;
7337 int area_ysize = textarea_info[i].ysize;
7340 Fail("'textarea_info' structure corrupted at index %d -- please fix", i);
7342 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
7343 infotext[max_infotext_len] = '\0';
7345 gi = CreateGadget(GDI_CUSTOM_ID, id,
7346 GDI_CUSTOM_TYPE_ID, type_id,
7347 GDI_INFO_TEXT, infotext,
7348 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
7349 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
7350 GDI_TYPE, GD_TYPE_TEXT_AREA,
7351 GDI_AREA_SIZE, area_xsize, area_ysize,
7352 GDI_TEXT_FONT, FONT_INPUT_1,
7353 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7354 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7355 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7356 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7357 GDI_DESIGN_WIDTH, gd->width,
7358 GDI_EVENT_MASK, event_mask,
7359 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7360 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
7364 Fail("cannot create gadget");
7366 level_editor_gadget[id] = gi;
7370 static void CreateSelectboxGadgets(void)
7372 int max_infotext_len = getMaxInfoTextLength();
7375 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7377 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
7378 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
7379 int gd_x1 = gd->src_x;
7380 int gd_y1 = gd->src_y;
7381 int gd_x2 = gd->src_x + gd->active_xoffset;
7382 int gd_y2 = gd->src_y + gd->active_yoffset;
7383 int selectbox_button_xsize = gd2->width;
7384 struct GadgetInfo *gi;
7385 char infotext[MAX_OUTPUT_LINESIZE + 1];
7386 int id = selectbox_info[i].gadget_id;
7387 int type_id = selectbox_info[i].gadget_type_id;
7388 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
7389 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
7390 unsigned int event_mask =
7391 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7394 Fail("'selectbox_info' structure corrupted at index %d -- please fix", i);
7396 if (selectbox_info[i].size == -1) // dynamically determine size
7398 // (we cannot use -1 for uninitialized values if we directly compare
7399 // with results from strlen(), because the '<' and '>' operation will
7400 // implicitely cast -1 to an unsigned integer value!)
7401 selectbox_info[i].size = 0;
7403 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
7404 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
7405 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
7407 selectbox_info[i].size++; // add one character empty space
7410 // determine horizontal position to the right of specified gadget
7411 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
7412 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
7413 ED_GADGET_TEXT_DISTANCE);
7415 // determine horizontal offset for leading text
7416 if (selectbox_info[i].text_left != NULL)
7417 x += getTextWidthForGadget(selectbox_info[i].text_left);
7419 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
7420 infotext[max_infotext_len] = '\0';
7422 gi = CreateGadget(GDI_CUSTOM_ID, id,
7423 GDI_CUSTOM_TYPE_ID, type_id,
7424 GDI_INFO_TEXT, infotext,
7427 GDI_TYPE, GD_TYPE_SELECTBOX,
7428 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
7429 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
7430 GDI_TEXT_SIZE, selectbox_info[i].size,
7431 GDI_TEXT_FONT, FONT_INPUT_1,
7432 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7433 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
7434 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7435 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7436 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7437 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
7438 GDI_DESIGN_WIDTH, gd->width,
7439 GDI_EVENT_MASK, event_mask,
7440 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7441 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
7445 Fail("cannot create gadget");
7447 level_editor_gadget[id] = gi;
7448 right_gadget_border[id] =
7449 getRightGadgetBorder(gi, selectbox_info[i].text_right);
7453 static void CreateTextbuttonGadgets(void)
7455 int max_infotext_len = getMaxInfoTextLength();
7458 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
7460 int id = textbutton_info[i].gadget_id;
7461 int type_id = textbutton_info[i].gadget_type_id;
7463 ((id >= GADGET_ID_LEVELCONFIG_LEVEL && id <= GADGET_ID_LEVELCONFIG_EDITOR) ||
7464 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
7466 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
7467 int gadget_distance =
7468 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
7469 struct GraphicInfo *gd = &graphic_info[graphic];
7470 int gd_x1 = gd->src_x;
7471 int gd_y1 = gd->src_y;
7472 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7473 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7474 int gd_x1a = gd->src_x + gd->active_xoffset;
7475 int gd_y1a = gd->src_y + gd->active_yoffset;
7476 int border_xsize = gd->border_size + gd->draw_xoffset;
7477 int border_ysize = gd->border_size;
7478 struct GadgetInfo *gi;
7479 unsigned int event_mask = GD_EVENT_RELEASED;
7480 char infotext[MAX_OUTPUT_LINESIZE + 1];
7481 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
7482 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
7485 Fail("'textbutton_info' structure corrupted at index %d -- please fix", i);
7487 if (textbutton_info[i].size == -1) // dynamically determine size
7488 textbutton_info[i].size = strlen(textbutton_info[i].text);
7490 sprintf(infotext, "%s", textbutton_info[i].infotext);
7491 infotext[max_infotext_len] = '\0';
7493 // determine horizontal position to the right of specified gadget
7494 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7496 int gadget_id_align = textbutton_info[i].gadget_id_align;
7498 x = right_gadget_border[gadget_id_align] + gadget_distance;
7500 if (textbutton_info[i].y == -1)
7501 y = level_editor_gadget[gadget_id_align]->y;
7504 // determine horizontal offset for leading text
7505 if (textbutton_info[i].text_left != NULL)
7506 x += getTextWidthForGadget(textbutton_info[i].text_left);
7508 gi = CreateGadget(GDI_CUSTOM_ID, id,
7509 GDI_CUSTOM_TYPE_ID, type_id,
7510 GDI_IMAGE_ID, graphic,
7511 GDI_INFO_TEXT, infotext,
7514 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
7515 GDI_TEXT_VALUE, textbutton_info[i].text,
7516 GDI_TEXT_SIZE, textbutton_info[i].size,
7517 GDI_TEXT_FONT, FONT_INPUT_2,
7518 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
7519 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7520 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7521 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7522 GDI_BORDER_SIZE, border_xsize, border_ysize,
7523 GDI_DESIGN_WIDTH, gd->width,
7524 GDI_DECORATION_SHIFTING, 1, 1,
7525 GDI_EVENT_MASK, event_mask,
7526 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7527 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7531 Fail("cannot create gadget");
7533 level_editor_gadget[id] = gi;
7534 right_gadget_border[id] =
7535 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7539 static void CreateGraphicbuttonGadgets(void)
7541 struct GadgetInfo *gi;
7544 // create buttons for scrolling of drawing area and element list
7545 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7547 int id = graphicbutton_info[i].gadget_id;
7548 int type_id = graphicbutton_info[i].gadget_type_id;
7549 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7550 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7551 int graphic = graphicbutton_info[i].graphic;
7552 struct GraphicInfo *gd = &graphic_info[graphic];
7553 int gd_x1 = gd->src_x;
7554 int gd_y1 = gd->src_y;
7555 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7556 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7557 unsigned int event_mask = GD_EVENT_RELEASED;
7560 Fail("'graphicbutton_info' structure corrupted at index %d -- please fix", i);
7562 // determine horizontal position to the right of specified gadget
7563 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7564 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7565 ED_GADGET_TEXT_DISTANCE);
7567 // determine horizontal offset for leading text
7568 if (graphicbutton_info[i].text_left != NULL)
7569 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7571 gi = CreateGadget(GDI_CUSTOM_ID, id,
7572 GDI_CUSTOM_TYPE_ID, type_id,
7573 GDI_IMAGE_ID, graphic,
7574 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7577 GDI_WIDTH, gd->width,
7578 GDI_HEIGHT, gd->height,
7579 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7580 GDI_STATE, GD_BUTTON_UNPRESSED,
7581 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7582 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7583 GDI_EVENT_MASK, event_mask,
7584 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7585 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7589 Fail("cannot create gadget");
7591 level_editor_gadget[id] = gi;
7592 right_gadget_border[id] =
7593 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7597 static void CreateScrollbarGadgets(void)
7601 // these values are not constant, but can change at runtime
7602 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7603 SX + ED_SCROLL_HORIZONTAL_XPOS;
7604 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7605 SY + ED_SCROLL_HORIZONTAL_YPOS;
7606 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7607 ED_SCROLL_HORIZONTAL_XSIZE;
7608 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7609 ED_SCROLL_HORIZONTAL_YSIZE;
7610 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7611 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7612 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7613 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7615 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7616 SX + ED_SCROLL_VERTICAL_XPOS;
7617 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7618 SY + ED_SCROLL_VERTICAL_YPOS;
7619 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7620 ED_SCROLL_VERTICAL_XSIZE;
7621 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7622 ED_SCROLL_VERTICAL_YSIZE;
7623 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7624 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7625 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7626 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7628 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7629 PX + ED_SCROLL2_VERTICAL_XPOS;
7630 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7631 PY + ED_SCROLL2_VERTICAL_YPOS;
7632 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7633 ED_SCROLL2_VERTICAL_XSIZE;
7634 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7635 ED_SCROLL2_VERTICAL_YSIZE;
7636 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7637 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7638 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7639 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7641 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7643 int id = scrollbar_info[i].gadget_id;
7644 int type_id = scrollbar_info[i].gadget_type_id;
7645 int graphic = scrollbar_info[i].graphic;
7646 struct GraphicInfo *gd = &graphic_info[graphic];
7647 int gd_x1 = gd->src_x;
7648 int gd_y1 = gd->src_y;
7649 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7650 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7651 struct GadgetInfo *gi;
7652 int items_max, items_visible, item_position;
7653 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7656 Fail("'scrollbar_info' structure corrupted at index %d -- please fix", i);
7658 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7660 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7661 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7662 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7664 else // drawing area scrollbars
7666 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7668 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7669 items_visible = ed_fieldx;
7674 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7675 items_visible = ed_fieldy;
7680 gi = CreateGadget(GDI_CUSTOM_ID, id,
7681 GDI_CUSTOM_TYPE_ID, type_id,
7682 GDI_IMAGE_ID, graphic,
7683 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7684 GDI_X, scrollbar_pos[i].x,
7685 GDI_Y, scrollbar_pos[i].y,
7686 GDI_WIDTH, scrollbar_pos[i].width,
7687 GDI_HEIGHT, scrollbar_pos[i].height,
7688 GDI_TYPE, scrollbar_info[i].type,
7689 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7690 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7691 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7692 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7693 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7694 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7695 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7696 GDI_STATE, GD_BUTTON_UNPRESSED,
7697 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7698 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7699 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7700 GDI_EVENT_MASK, event_mask,
7701 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7702 GDI_CALLBACK_ACTION, HandleControlButtons,
7706 Fail("cannot create gadget");
7708 level_editor_gadget[id] = gi;
7712 static void CreateCheckbuttonGadgets(void)
7714 struct GadgetInfo *gi;
7717 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7719 int id = checkbutton_info[i].gadget_id;
7720 int type_id = checkbutton_info[i].gadget_type_id;
7721 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7722 IMG_EDITOR_CHECKBOX);
7723 struct GraphicInfo *gd = &graphic_info[graphic];
7724 int gd_x1 = gd->src_x;
7725 int gd_y1 = gd->src_y;
7726 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7727 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7728 int gd_x1a = gd->src_x + gd->active_xoffset;
7729 int gd_y1a = gd->src_y + gd->active_yoffset;
7730 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7731 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7732 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7733 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7734 unsigned int event_mask = GD_EVENT_PRESSED;
7737 Fail("'checkbutton_info' structure corrupted at index %d -- please fix", i);
7739 // determine horizontal position to the right of specified gadget
7740 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7741 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7742 ED_GADGET_TEXT_DISTANCE);
7744 // determine horizontal offset for leading text
7745 if (checkbutton_info[i].text_left != NULL)
7746 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7748 gi = CreateGadget(GDI_CUSTOM_ID, id,
7749 GDI_CUSTOM_TYPE_ID, type_id,
7750 GDI_IMAGE_ID, graphic,
7751 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7754 GDI_WIDTH, gd->width,
7755 GDI_HEIGHT, gd->height,
7756 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7757 GDI_CHECKED, *checkbutton_info[i].value,
7758 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7759 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7760 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7761 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7762 GDI_EVENT_MASK, event_mask,
7763 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7764 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7768 Fail("cannot create gadget");
7770 level_editor_gadget[id] = gi;
7771 right_gadget_border[id] =
7772 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7776 static void CreateRadiobuttonGadgets(void)
7778 int graphic = IMG_EDITOR_RADIOBUTTON;
7779 struct GraphicInfo *gd = &graphic_info[graphic];
7780 int gd_x1 = gd->src_x;
7781 int gd_y1 = gd->src_y;
7782 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7783 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7784 int gd_x1a = gd->src_x + gd->active_xoffset;
7785 int gd_y1a = gd->src_y + gd->active_yoffset;
7786 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7787 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7788 struct GadgetInfo *gi;
7791 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7793 int id = radiobutton_info[i].gadget_id;
7794 int type_id = radiobutton_info[i].gadget_type_id;
7795 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7796 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7797 unsigned int event_mask = GD_EVENT_PRESSED;
7800 Fail("'radiobutton_info' structure corrupted at index %d -- please fix", i);
7803 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7805 // determine horizontal position to the right of specified gadget
7806 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7807 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7808 ED_GADGET_TEXT_DISTANCE);
7810 // determine horizontal offset for leading text
7811 if (radiobutton_info[i].text_left != NULL)
7812 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7814 gi = CreateGadget(GDI_CUSTOM_ID, id,
7815 GDI_CUSTOM_TYPE_ID, type_id,
7816 GDI_IMAGE_ID, graphic,
7817 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7820 GDI_WIDTH, gd->width,
7821 GDI_HEIGHT, gd->height,
7822 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7823 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7824 GDI_CHECKED, checked,
7825 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7826 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7827 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7828 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7829 GDI_EVENT_MASK, event_mask,
7830 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7831 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7835 Fail("cannot create gadget");
7837 level_editor_gadget[id] = gi;
7838 right_gadget_border[id] =
7839 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7843 void CreateLevelEditorGadgets(void)
7845 // force EDITOR font inside level editor
7846 SetFontStatus(GAME_MODE_EDITOR);
7848 // these values are not constant, but can change at runtime
7849 ed_fieldx = MAX_ED_FIELDX - 1;
7850 ed_fieldy = MAX_ED_FIELDY - 1;
7852 num_editor_gadgets = NUM_EDITOR_GADGETS;
7854 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7856 level_editor_gadget =
7857 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7858 right_gadget_border =
7859 checked_calloc(num_editor_gadgets * sizeof(int));
7861 // set number of empty (padding) element buttons to maximum number of buttons
7862 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7864 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7865 editor_el_empty_ptr = editor_el_empty;
7867 use_permanent_palette = !editor.palette.show_as_separate_screen;
7869 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
7871 ReinitializeElementList();
7873 CreateControlButtons();
7874 CreateScrollbarGadgets();
7876 // order of function calls is important because of cross-references
7877 CreateCheckbuttonGadgets();
7878 CreateCounterButtons();
7879 CreateRadiobuttonGadgets();
7880 CreateTextInputGadgets();
7881 CreateTextAreaGadgets();
7882 CreateSelectboxGadgets();
7883 CreateGraphicbuttonGadgets();
7884 CreateTextbuttonGadgets();
7885 CreateDrawingAreas();
7890 void FreeLevelEditorGadgets(void)
7894 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
7896 for (i = 0; i < num_editor_gadgets; i++)
7898 FreeGadget(level_editor_gadget[i]);
7900 level_editor_gadget[i] = NULL;
7903 checked_free(level_editor_gadget);
7904 checked_free(right_gadget_border);
7906 checked_free(editor_el_empty);
7909 static void MapCounterButtons(int id)
7911 int font_nr = FONT_TEXT_1;
7912 int font_height = getFontHeight(font_nr);
7913 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7914 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7915 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7916 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7917 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7918 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7919 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7920 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7921 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7922 int yoffset = (gi_down->height - font_height) / 2;
7923 int x_left = gi_down->x - xoffset_left;
7924 int x_right; // set after gadget position was modified
7925 int y_above = gi_down->y - yoffset_above;
7927 int y; // set after gadget position was modified
7929 // counter limits must be changed first to prevent value truncation
7930 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7931 counterbutton_info[id].max_value);
7933 // right text position might have changed after setting position above
7934 x_right = gi_up->x + gi_up->width + xoffset_right;
7936 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7938 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
7939 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7940 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7942 ModifyGadget(gi_down, GDI_Y,
7943 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7944 ModifyGadget(gi_text, GDI_Y,
7945 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7946 ModifyGadget(gi_up, GDI_Y,
7947 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7950 // vertical position might have changed after setting position above
7951 y = gi_up->y + yoffset;
7953 if (counterbutton_info[id].text_above)
7954 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
7956 if (counterbutton_info[id].text_left)
7957 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7959 if (counterbutton_info[id].text_right)
7960 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7967 static void MapControlButtons(void)
7972 // map toolbox buttons (excluding special CE toolbox buttons)
7973 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7974 MapGadget(level_editor_gadget[i]);
7976 // map toolbox buttons (element properties buttons)
7977 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
7978 MapGadget(level_editor_gadget[i]);
7980 if (use_permanent_palette)
7982 // map buttons to select elements
7983 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7984 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
7985 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
7986 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
7987 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
7990 // map buttons to select level
7991 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
7992 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
7993 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
7994 MapCounterButtons(counter_id);
7997 static void MapDrawingArea(int id)
7999 int font_nr = FONT_TEXT_1;
8000 int font_height = getFontHeight(font_nr);
8001 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8002 int area_xsize = gi->drawing.area_xsize;
8003 int area_ysize = gi->drawing.area_ysize;
8004 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8005 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
8006 int x_left = gi->x - xoffset_left;
8007 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
8008 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
8009 int x_below = gi->x + (gi->width - xoffset_below) / 2;
8010 int y_side = gi->y + (gi->height - font_height) / 2;
8011 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
8012 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
8014 if (drawingarea_info[id].text_left)
8015 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
8017 if (drawingarea_info[id].text_right)
8018 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
8020 if (drawingarea_info[id].text_above)
8021 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
8023 if (drawingarea_info[id].text_below)
8024 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
8026 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
8028 DrawElementBorder(gi->x, gi->y,
8029 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
8030 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
8032 DrawDrawingArea(id);
8038 static void MapTextInputGadget(int id)
8040 int font_nr = FONT_TEXT_1;
8041 int font_height = getFontHeight(font_nr);
8042 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
8043 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8044 int x_above = ED_SETTINGS_X(textinput_info[id].x);
8045 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
8047 if (textinput_info[id].text_above)
8048 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
8050 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
8055 static void MapTextAreaGadget(int id)
8057 int font_nr = FONT_TEXT_1;
8058 int font_height = getFontHeight(font_nr);
8059 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8060 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8061 int x_above = ED_SETTINGS_X(textarea_info[id].x);
8062 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
8063 char *text_above = textarea_info[id].text_above;
8065 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
8066 text_above = textarea_info[id].text_above_cropped;
8069 DrawTextS(x_above, y_above, font_nr, text_above);
8071 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
8076 static void MapSelectboxGadget(int id)
8078 int font_nr = FONT_TEXT_1;
8079 int font_height = getFontHeight(font_nr);
8080 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
8081 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
8082 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8083 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8084 int yoffset = (gi->height - font_height) / 2;
8085 int x_left = gi->x - xoffset_left;
8086 int x_right = gi->x + gi->width + xoffset_right;
8087 int y_above = gi->y - yoffset_above;
8089 int y = gi->y + yoffset;
8091 if (selectbox_info[id].text_above)
8092 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
8094 if (selectbox_info[id].text_left)
8095 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
8097 if (selectbox_info[id].text_right)
8098 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
8100 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
8105 static void MapTextbuttonGadget(int id)
8107 int font_nr = FONT_TEXT_1;
8108 int font_height = getFontHeight(font_nr);
8109 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
8110 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
8111 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8112 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8113 int yoffset = (gi->height - font_height) / 2;
8114 int x_left = gi->x - xoffset_left;
8115 int x_right = gi->x + gi->width + xoffset_right;
8116 int y_above = gi->y - yoffset_above;
8118 int y = gi->y + yoffset;
8120 // only show button to delete change pages when more than minimum pages
8121 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
8122 custom_element.num_change_pages == MIN_CHANGE_PAGES)
8125 if (textbutton_info[id].text_above)
8126 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
8128 if (textbutton_info[id].text_left)
8129 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
8131 if (textbutton_info[id].text_right)
8132 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
8137 static void MapGraphicbuttonGadget(int id)
8139 int font_nr = FONT_TEXT_1;
8140 int font_height = getFontHeight(font_nr);
8141 struct GadgetInfo *gi = level_editor_gadget[graphicbutton_info[id].gadget_id];
8142 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
8143 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8144 int yoffset = (gi->height - font_height) / 2;
8145 int x_left = gi->x - xoffset_left;
8146 int x_right = gi->x + gi->width + xoffset_right;
8147 int y = gi->y + yoffset;
8149 if (graphicbutton_info[id].text_left)
8150 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
8152 if (graphicbutton_info[id].text_right)
8153 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
8158 static void MapRadiobuttonGadget(int id)
8160 int font_nr = FONT_TEXT_1;
8161 int font_height = getFontHeight(font_nr);
8162 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
8163 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8164 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8165 int yoffset = (gi->height - font_height) / 2;
8166 int x_left = gi->x - xoffset_left;
8167 int x_right = gi->x + gi->width + xoffset_right;
8168 int y = gi->y + yoffset;
8170 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
8172 if (radiobutton_info[id].text_left)
8173 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
8175 if (radiobutton_info[id].text_right)
8176 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
8178 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
8183 static void MapCheckbuttonGadget(int id)
8185 int font_nr = FONT_TEXT_1;
8186 int font_height = getFontHeight(font_nr);
8187 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
8188 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8189 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8190 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8191 int yoffset = (gi->height - font_height) / 2;
8192 int y_above = gi->y - yoffset_above;
8194 int x_left, x_right, y; // set after gadget position was modified
8196 // set position for gadgets with dynamically determined position
8197 if (checkbutton_info[id].x != -1) // do not change dynamic positions
8198 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x), GDI_END);
8199 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
8201 x_left = gi->x - xoffset_left;
8202 x_right = gi->x + gi->width + xoffset_right;
8203 y = gi->y + yoffset;
8205 if (checkbutton_info[id].text_above)
8206 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
8208 if (checkbutton_info[id].text_left)
8209 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
8211 if (checkbutton_info[id].text_right)
8212 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
8214 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
8219 static void MapMainDrawingArea(void)
8221 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
8222 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
8225 if (suppressBorderElement())
8227 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
8228 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
8231 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
8233 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
8234 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
8235 no_horizontal_scrollbar) ||
8236 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
8237 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
8238 no_vertical_scrollbar))
8241 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
8244 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
8246 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
8247 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
8250 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
8253 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
8256 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
8260 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
8262 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
8263 i == GADGET_ID_CUSTOM_COPY_TO ||
8264 i == GADGET_ID_CUSTOM_EXCHANGE ||
8265 i == GADGET_ID_CUSTOM_COPY ||
8266 i == GADGET_ID_CUSTOM_PASTE)
8269 MapGadget(level_editor_gadget[i]);
8271 UnmapGadget(level_editor_gadget[i]);
8276 static void MapLevelEditorToolboxCustomGadgets(void)
8278 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
8281 static void MapLevelEditorToolboxCustomGadgetsIfNeeded(void)
8283 if (IS_CUSTOM_ELEMENT(properties_element) ||
8284 IS_GROUP_ELEMENT(properties_element) ||
8285 IS_EMPTY_ELEMENT(properties_element))
8286 MapLevelEditorToolboxCustomGadgets();
8289 static void UnmapLevelEditorToolboxCustomGadgets(void)
8291 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
8294 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
8298 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
8300 if (i != GADGET_ID_SINGLE_ITEMS &&
8301 i != GADGET_ID_PICK_ELEMENT)
8303 struct GadgetInfo *gi = level_editor_gadget[i];
8311 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
8312 struct GraphicInfo *gd = &graphic_info[graphic];
8316 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
8317 gi->width, gi->height, gi->x, gi->y);
8319 redraw_mask |= REDRAW_DOOR_3;
8325 static void MapLevelEditorToolboxDrawingGadgets(void)
8327 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
8330 static void UnmapLevelEditorToolboxDrawingGadgets(void)
8332 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
8335 static void UnmapDrawingArea(int id)
8337 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
8340 static void UnmapLevelEditorFieldGadgets(void)
8344 for (i = 0; i < num_editor_gadgets; i++)
8345 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
8346 level_editor_gadget[i]->y))
8347 UnmapGadget(level_editor_gadget[i]);
8350 void UnmapLevelEditorGadgets(void)
8354 for (i = 0; i < num_editor_gadgets; i++)
8355 UnmapGadget(level_editor_gadget[i]);
8358 static void ResetUndoBuffer(void)
8360 undo_buffer_position = -1;
8361 undo_buffer_steps = -1;
8362 redo_buffer_steps = 0;
8364 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8366 level.changed = FALSE;
8369 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
8371 if (remap_toolbox_gadgets)
8373 ModifyEditorElementList();
8374 RedrawDrawingElements();
8377 if (edit_mode == ED_MODE_LEVELCONFIG)
8378 DrawLevelConfigWindow();
8379 else if (edit_mode == ED_MODE_PROPERTIES)
8380 DrawPropertiesWindow();
8381 else if (edit_mode == ED_MODE_PALETTE)
8382 DrawPaletteWindow();
8383 else // edit_mode == ED_MODE_DRAWING
8384 DrawDrawingWindowExt(remap_toolbox_gadgets);
8387 static void DrawEditModeWindow(void)
8389 DrawEditModeWindowExt(TRUE);
8392 static void DrawEditModeWindow_PlayfieldOnly(void)
8394 DrawEditModeWindowExt(FALSE);
8397 static void ChangeEditModeWindow(int new_edit_mode)
8399 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
8401 DrawEditModeWindow();
8404 static boolean LevelChanged(void)
8406 boolean field_changed = FALSE;
8409 for (y = 0; y < lev_fieldy; y++)
8410 for (x = 0; x < lev_fieldx; x++)
8411 if (Tile[x][y] != level.field[x][y])
8412 field_changed = TRUE;
8414 return (level.changed || field_changed);
8417 static boolean PrepareSavingIntoPersonalLevelSet(void)
8419 static LevelDirTree *last_copied_leveldir = NULL;
8420 static LevelDirTree *last_written_leveldir = NULL;
8421 static int last_copied_level_nr = -1;
8422 static int last_written_level_nr = -1;
8423 LevelDirTree *leveldir_former = leveldir_current;
8424 int level_nr_former = level_nr;
8427 // remember last mod/save so that for current session, we write
8428 // back to the same personal copy, asking only about overwrite.
8429 if (leveldir_current == last_copied_leveldir &&
8430 level_nr == last_copied_level_nr)
8432 // "cd" to personal level set dir (as used when writing last copy)
8433 leveldir_current = last_written_leveldir;
8434 level_nr = last_written_level_nr;
8439 if (!Request("This level is read-only! "
8440 "Save into personal level set?", REQ_ASK))
8443 // "cd" to personal level set dir (for writing copy the first time)
8445 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
8447 // this may happen if "setup.internal.create_user_levelset" is FALSE
8448 // or if file "levelinfo.conf" is missing in personal user level set
8449 if (leveldir_current == NULL)
8451 Request("Cannot find personal level set?!", REQ_CONFIRM);
8453 leveldir_current = leveldir_former;
8458 // find unused level number
8459 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
8461 static char *level_filename = NULL;
8463 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
8465 if (!fileExists(level_filename))
8469 last_copied_leveldir = leveldir_former;
8470 last_copied_level_nr = level_nr_former;
8472 last_written_leveldir = leveldir_current;
8473 last_written_level_nr = level_nr = new_level_nr;
8478 static void ModifyLevelConfigForSavingIntoPersonalLevelSet(char *former_name)
8480 static char *filename_levelinfo = NULL, *mod_name = NULL;
8483 // annotate this copy-and-mod in personal levelinfo.conf
8484 setString(&filename_levelinfo,
8485 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
8487 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
8489 fprintf(file, "\n");
8490 fprintf(file, "# level %d was modified from:\n", level_nr);
8491 fprintf(file, "# - previous level set name: %s\n",
8493 fprintf(file, "# - level within previous set: %d \"%s\"\n",
8494 level.file_info.nr, level.name);
8495 fprintf(file, "# - previous author: %s\n",
8497 fprintf(file, "# - previous save date: ");
8499 if (level.creation_date.src == DATE_SRC_LEVELFILE)
8501 fprintf(file, "%04d-%02d-%02d\n",
8502 level.creation_date.year,
8503 level.creation_date.month,
8504 level.creation_date.day);
8508 fprintf(file, "not recorded\n");
8514 if (level_nr > leveldir_current->last_level)
8515 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
8517 // else: allow the save even if annotation failed
8519 // now... spray graffiti on the old level vital statistics
8520 // user can change these; just trying to set a good baseline
8522 // don't truncate names for fear of making offensive or silly:
8523 // long-named original author only recorded in levelinfo.conf.
8524 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
8525 if (!strEqual(level.author, leveldir_current->author))
8527 setString(&mod_name, getStringCat3(leveldir_current->author,
8528 " after ", level.author));
8530 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8531 setString(&mod_name,
8532 getStringCat2(leveldir_current->author, " (ed.)"));
8534 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8535 setString(&mod_name, leveldir_current->author);
8537 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
8539 // less worried about truncation here
8540 setString(&mod_name, getStringCat2("Mod: ", level.name));
8541 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
8545 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
8546 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8550 for (x = 0; x < lev_fieldx; x++)
8551 for (y = 0; y < lev_fieldy; y++)
8552 dst[x][y] = src[x][y];
8555 static int setSelectboxValue(int selectbox_id, int new_value)
8557 int new_index_value = 0;
8560 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8561 if (selectbox_info[selectbox_id].options[i].value == new_value)
8562 new_index_value = i;
8564 *selectbox_info[selectbox_id].value =
8565 selectbox_info[selectbox_id].options[new_index_value].value;
8567 return new_index_value;
8570 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8574 // change action mode and arg variables according to action type variable
8575 for (i = 0; action_arg_options[i].value != -1; i++)
8577 if (action_arg_options[i].value == custom_element_change.action_type)
8579 int mode = action_arg_options[i].mode;
8581 // only change if corresponding selectbox has changed
8582 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8583 action_arg_modes[mode])
8584 custom_element_change.action_mode = -1;
8586 // only change if corresponding selectbox has changed
8587 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8588 action_arg_options[i].options)
8589 custom_element_change.action_arg = -1;
8596 static void setSelectboxSpecialActionOptions(void)
8600 // change action mode and arg selectbox according to action type selectbox
8601 for (i = 0; action_arg_options[i].value != -1; i++)
8603 if (action_arg_options[i].value == custom_element_change.action_type)
8605 int mode = action_arg_options[i].mode;
8607 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8608 action_arg_modes[mode]);
8609 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8610 custom_element_change.action_mode);
8612 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8613 action_arg_options[i].options);
8614 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8615 custom_element_change.action_arg);
8621 static void copy_custom_element_settings(int element_from, int element_to)
8623 struct ElementInfo *ei_from = &element_info[element_from];
8624 struct ElementInfo *ei_to = &element_info[element_to];
8626 copyElementInfo(ei_from, ei_to);
8629 static void replace_custom_element_in_settings(int element_from,
8634 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8636 struct ElementInfo *ei = &element_info[i];
8638 for (y = 0; y < 3; y++)
8639 for (x = 0; x < 3; x++)
8640 if (ei->content.e[x][y] == element_from)
8641 ei->content.e[x][y] = element_to;
8643 for (j = 0; j < ei->num_change_pages; j++)
8645 struct ElementChangeInfo *change = &ei->change_page[j];
8647 if (change->target_element == element_from)
8648 change->target_element = element_to;
8650 if (change->initial_trigger_element == element_from)
8651 change->initial_trigger_element = element_to;
8653 if (change->action_element == element_from)
8654 change->action_element = element_to;
8656 for (y = 0; y < 3; y++)
8657 for (x = 0; x < 3; x++)
8658 if (change->target_content.e[x][y] == element_from)
8659 change->target_content.e[x][y] = element_to;
8662 if (ei->group != NULL) // group or internal
8663 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8664 if (ei->group->element[j] == element_from)
8665 ei->group->element[j] = element_to;
8669 static void replace_custom_element_in_playfield(int element_from,
8674 for (x = 0; x < lev_fieldx; x++)
8675 for (y = 0; y < lev_fieldy; y++)
8676 if (Tile[x][y] == element_from)
8677 Tile[x][y] = element_to;
8680 static boolean CopyCustomElement(int element_old, int element_new,
8683 int copy_mode_orig = copy_mode;
8685 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8687 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8688 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8689 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8691 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8693 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8694 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8695 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8697 level.changed = TRUE;
8699 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8701 Request("Please choose custom element!", REQ_CONFIRM);
8705 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8707 Request("Please choose group element!", REQ_CONFIRM);
8711 else if (IS_EMPTY_ELEMENT(element_old) && !IS_EMPTY_ELEMENT(element_new))
8713 Request("Please choose empty element!", REQ_CONFIRM);
8719 level.changed = TRUE;
8722 // when modifying custom/group element, ask for copying level template
8723 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8725 if (!AskToCopyAndModifyLevelTemplate())
8729 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8731 copy_custom_element_settings(element_new, element_old);
8733 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8735 copy_custom_element_settings(element_old, element_new);
8737 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8739 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8740 copy_custom_element_settings(element_new, element_old);
8741 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8743 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8744 replace_custom_element_in_settings(element_new, element_old);
8745 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8747 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8748 replace_custom_element_in_playfield(element_new, element_old);
8749 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8752 UpdateCustomElementGraphicGadgets();
8753 DrawPropertiesWindow();
8758 static void CopyCustomElementPropertiesToEditor(int element)
8761 int current_change_page = element_info[element].current_change_page;
8763 // dynamically (re)build selectbox for selecting change page
8764 for (i = 0; i < element_info[element].num_change_pages; i++)
8766 sprintf(options_change_page_strings[i], "%d", i + 1);
8768 options_change_page[i].value = i;
8769 options_change_page[i].text = options_change_page_strings[i];
8772 options_change_page[i].value = -1;
8773 options_change_page[i].text = NULL;
8775 // needed here to initialize combined element properties
8776 InitElementPropertiesEngine(level.game_version);
8778 element_info[element].change =
8779 &element_info[element].change_page[current_change_page];
8781 custom_element = element_info[element];
8782 custom_element_change = *element_info[element].change;
8784 // needed to initially set selectbox options for special action options
8785 setSelectboxSpecialActionOptions();
8787 // needed to initially set selectbox value variables to reliable defaults
8788 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8789 setSelectboxValue(i, *selectbox_info[i].value);
8791 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8792 custom_element_properties[i] = HAS_PROPERTY(element, i);
8794 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8795 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8797 // ---------- element settings: configure (custom elements) -----------------
8799 // set accessible layer selectbox help value
8800 custom_element.access_type =
8801 (IS_WALKABLE(element) ? EP_WALKABLE :
8802 IS_PASSABLE(element) ? EP_PASSABLE :
8803 custom_element.access_type);
8804 custom_element.access_layer =
8805 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8806 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8807 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8808 custom_element.access_layer);
8809 custom_element.access_protected =
8810 (IS_PROTECTED(element) ? 1 : 0);
8811 custom_element_properties[EP_ACCESSIBLE] =
8812 (IS_ACCESSIBLE_OVER(element) ||
8813 IS_ACCESSIBLE_INSIDE(element) ||
8814 IS_ACCESSIBLE_UNDER(element));
8816 // set walk-to-object action selectbox help value
8817 custom_element.walk_to_action =
8818 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8819 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8820 IS_DROPPABLE(element) ? EP_DROPPABLE :
8821 IS_THROWABLE(element) ? EP_THROWABLE :
8822 IS_PUSHABLE(element) ? EP_PUSHABLE :
8823 custom_element.walk_to_action);
8824 custom_element_properties[EP_WALK_TO_OBJECT] =
8825 (IS_DIGGABLE(element) ||
8826 IS_COLLECTIBLE_ONLY(element) ||
8827 IS_DROPPABLE(element) ||
8828 IS_THROWABLE(element) ||
8829 IS_PUSHABLE(element));
8831 // set smash targets selectbox help value
8832 custom_element.smash_targets =
8833 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8834 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8835 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8836 custom_element.smash_targets);
8837 custom_element_properties[EP_CAN_SMASH] =
8838 (CAN_SMASH_EVERYTHING(element) ||
8839 CAN_SMASH_ENEMIES(element) ||
8840 CAN_SMASH_PLAYER(element));
8842 // set deadliness selectbox help value
8843 custom_element.deadliness =
8844 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8845 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8846 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8847 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8848 custom_element.deadliness);
8849 custom_element_properties[EP_DEADLY] =
8850 (DONT_TOUCH(element) ||
8851 DONT_GET_HIT_BY(element) ||
8852 DONT_COLLIDE_WITH(element) ||
8853 DONT_RUN_INTO(element));
8855 // ---------- element settings: advanced (custom elements) ------------------
8857 // set "change by direct action" selectbox help value
8858 custom_element_change.direct_action =
8859 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
8860 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8861 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8862 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8863 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8864 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8865 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8866 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8867 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8868 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8869 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8870 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8871 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8872 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8873 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8874 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8875 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8876 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8877 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8878 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
8879 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
8880 custom_element_change.direct_action);
8882 // set "change by other element action" selectbox help value
8883 custom_element_change.other_action =
8884 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
8885 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8886 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8887 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8888 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8889 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8890 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8891 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8892 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8893 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8894 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8895 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
8896 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8897 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8898 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8899 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8900 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8901 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8902 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8903 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8904 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8905 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8906 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8907 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8908 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8909 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
8910 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
8911 custom_element_change.other_action);
8914 static void CopyGroupElementPropertiesToEditor(int element)
8916 group_element_info = *element_info[element].group;
8917 custom_element = element_info[element]; // needed for description
8920 static void CopyEmptyElementPropertiesToEditor(int element)
8922 custom_element = element_info[element];
8925 static void CopyClassicElementPropertiesToEditor(int element)
8927 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8928 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
8929 getMoveIntoAcidProperty(&level, element);
8931 if (MAYBE_DONT_COLLIDE_WITH(element))
8932 custom_element_properties[EP_DONT_COLLIDE_WITH] =
8933 getDontCollideWithProperty(&level, element);
8936 static void CopyElementPropertiesToEditor(int element)
8938 if (IS_CUSTOM_ELEMENT(element))
8939 CopyCustomElementPropertiesToEditor(element);
8940 else if (IS_GROUP_ELEMENT(element))
8941 CopyGroupElementPropertiesToEditor(element);
8942 else if (IS_EMPTY_ELEMENT(element))
8943 CopyEmptyElementPropertiesToEditor(element);
8945 CopyClassicElementPropertiesToEditor(element);
8948 static boolean AskToCopyAndModifyLevelTemplate(void)
8950 if (Request("Copy and modify settings from level template?", REQ_ASK))
8952 level.use_custom_template = FALSE;
8954 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
8955 GDI_CHECKED, FALSE, GDI_END);
8956 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
8957 GDI_CHECKED, FALSE, GDI_END);
8963 LoadLevelTemplate(-1); // this resets all element modifications ...
8965 DrawEditModeWindow(); // ... and copies them to 'custom_element'
8971 static void CopyCustomElementPropertiesToGame(int element)
8974 int access_type_and_layer;
8976 // mark that this custom element has been modified
8977 custom_element.modified_settings = TRUE;
8978 level.changed = TRUE;
8980 if (level.use_custom_template)
8981 AskToCopyAndModifyLevelTemplate();
8983 element_info[element] = custom_element;
8984 *element_info[element].change = custom_element_change;
8986 // ---------- element settings: configure (custom elements) -----------------
8988 // set accessible property from checkbox and selectbox
8989 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
8990 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
8991 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
8992 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
8993 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
8994 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
8995 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
8996 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
8997 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
8998 custom_element_properties[access_type_and_layer] =
8999 custom_element_properties[EP_ACCESSIBLE];
9000 custom_element_properties[EP_PROTECTED] =
9001 (custom_element.access_protected != 0 &&
9002 custom_element_properties[EP_ACCESSIBLE]);
9004 // set walk-to-object property from checkbox and selectbox
9005 custom_element_properties[EP_DIGGABLE] = FALSE;
9006 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
9007 custom_element_properties[EP_DROPPABLE] = FALSE;
9008 custom_element_properties[EP_THROWABLE] = FALSE;
9009 custom_element_properties[EP_PUSHABLE] = FALSE;
9010 custom_element_properties[custom_element.walk_to_action] =
9011 custom_element_properties[EP_WALK_TO_OBJECT];
9013 // set smash property from checkbox and selectbox
9014 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
9015 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
9016 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
9017 custom_element_properties[custom_element.smash_targets] =
9018 custom_element_properties[EP_CAN_SMASH];
9020 // set deadliness property from checkbox and selectbox
9021 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
9022 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
9023 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
9024 custom_element_properties[EP_DONT_TOUCH] = FALSE;
9025 custom_element_properties[custom_element.deadliness] =
9026 custom_element_properties[EP_DEADLY];
9028 // ---------- element settings: advanced (custom elements) ------------------
9030 // set player change event from checkbox and selectbox
9031 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
9032 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
9033 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
9034 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
9035 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
9036 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
9037 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
9038 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
9039 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
9040 custom_element_change_events[CE_SWITCHED] = FALSE;
9041 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
9042 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
9043 custom_element_change_events[CE_BLOCKED] = FALSE;
9044 custom_element_change_events[CE_IMPACT] = FALSE;
9045 custom_element_change_events[CE_SMASHED] = FALSE;
9046 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
9047 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
9048 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
9049 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
9050 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
9051 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
9052 custom_element_change_events[custom_element_change.direct_action] =
9053 custom_element_change_events[CE_BY_DIRECT_ACTION];
9055 // set other element action change event from checkbox and selectbox
9056 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
9057 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
9058 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
9059 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
9060 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
9061 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
9062 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
9063 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
9064 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
9065 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
9066 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
9067 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
9068 custom_element_change_events[CE_TOUCHING_X] = FALSE;
9069 custom_element_change_events[CE_HITTING_X] = FALSE;
9070 custom_element_change_events[CE_DIGGING_X] = FALSE;
9071 custom_element_change_events[CE_HIT_BY_X] = FALSE;
9072 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
9073 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
9074 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
9075 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
9076 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
9077 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
9078 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
9079 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
9080 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
9081 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
9082 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
9083 custom_element_change_events[custom_element_change.other_action] =
9084 custom_element_change_events[CE_BY_OTHER_ACTION];
9086 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
9087 SET_PROPERTY(element, i, custom_element_properties[i]);
9089 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
9090 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
9092 // copy change events also to special level editor variable
9093 custom_element = element_info[element];
9094 custom_element_change = *element_info[element].change;
9096 // needed here to restore runtime value "element_info[element].gfx_element"
9097 InitElementPropertiesGfxElement();
9100 static void CopyGroupElementPropertiesToGame(int element)
9102 // mark that this group element has been modified
9103 custom_element.modified_settings = TRUE;
9104 level.changed = TRUE;
9106 if (level.use_custom_template)
9107 AskToCopyAndModifyLevelTemplate();
9109 element_info[element] = custom_element;
9110 *element_info[element].group = group_element_info;
9112 // needed here to restore runtime value "element_info[element].gfx_element"
9113 InitElementPropertiesGfxElement();
9116 static void CopyEmptyElementPropertiesToGame(int element)
9118 // mark that this empty element has been modified
9119 custom_element.modified_settings = TRUE;
9120 level.changed = TRUE;
9122 if (level.use_custom_template)
9123 AskToCopyAndModifyLevelTemplate();
9125 element_info[element] = custom_element;
9127 // needed here to restore runtime value "element_info[element].gfx_element"
9128 InitElementPropertiesGfxElement();
9131 static void CopyClassicElementPropertiesToGame(int element)
9133 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9134 setMoveIntoAcidProperty(&level, element,
9135 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
9137 if (MAYBE_DONT_COLLIDE_WITH(element))
9138 setDontCollideWithProperty(&level, element,
9139 custom_element_properties[EP_DONT_COLLIDE_WITH]);
9142 static void CopyElementPropertiesToGame(int element)
9144 if (IS_CUSTOM_ELEMENT(element))
9145 CopyCustomElementPropertiesToGame(element);
9146 else if (IS_GROUP_ELEMENT(element))
9147 CopyGroupElementPropertiesToGame(element);
9148 else if (IS_EMPTY_ELEMENT(element))
9149 CopyEmptyElementPropertiesToGame(element);
9151 CopyClassicElementPropertiesToGame(element);
9155 static void CheckElementDescriptions(void)
9159 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
9160 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
9161 Warn("no element description file for element '%s'", EL_NAME(i));
9165 static int getMaxEdFieldX(boolean has_scrollbar)
9167 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
9168 int sxsize = SXSIZE - scrollbar_width;
9169 int max_ed_fieldx = sxsize / ed_tilesize;
9171 return max_ed_fieldx;
9174 static int getMaxEdFieldY(boolean has_scrollbar)
9176 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
9177 INFOTEXT_YSIZE_FULL : 0);
9178 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
9179 int sysize = SYSIZE - scrollbar_height - infotext_height;
9180 int max_ed_fieldy = sysize / ed_tilesize;
9182 return max_ed_fieldy;
9185 static void InitZoomLevelSettings(int zoom_tilesize)
9187 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
9189 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
9191 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
9192 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
9194 // make sure that tile size is always a power of 2
9195 ed_tilesize = (1 << log_2(ed_tilesize));
9197 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9199 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
9200 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
9204 last_game_engine_type = level.game_engine_type;
9206 // limit zoom tilesize by upper and lower bound
9207 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
9209 // store zoom tilesize in auto setup file only if it was manually changed
9210 if (zoom_tilesize != -1)
9211 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
9213 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
9214 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
9217 static void InitDrawingElements(void)
9219 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
9221 if (level.game_engine_type == game_engine_type_last)
9224 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9226 new_element1 = EL_BD_WALL;
9227 new_element2 = EL_EMPTY;
9228 new_element3 = EL_BD_SAND;
9230 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
9232 new_element1 = EL_SP_CHIP_SINGLE;
9233 new_element2 = EL_EMPTY;
9234 new_element3 = EL_SP_BASE;
9236 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9238 new_element1 = EL_MM_MIRROR_START;
9239 new_element2 = EL_EMPTY;
9240 new_element3 = EL_MM_WOODEN_WALL;
9244 new_element1 = EL_WALL;
9245 new_element2 = EL_EMPTY;
9246 new_element3 = EL_SAND;
9249 game_engine_type_last = level.game_engine_type;
9252 static void InitLevelSetInfo(void)
9254 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
9255 "%s", leveldir_current->name);
9256 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
9257 "%s", leveldir_current->author);
9259 levelset_num_levels = leveldir_current->levels;
9261 levelset_use_levelset_artwork = FALSE;
9262 levelset_copy_level_template = FALSE;
9264 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
9267 static void ChangeEditorToLevelSet(char *levelset_subdir)
9269 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
9271 // the previous level set might have used custom artwork
9272 ReloadCustomArtwork(0);
9274 LoadLevelSetup_SeriesInfo();
9276 SaveLevelSetup_LastSeries();
9277 SaveLevelSetup_SeriesInfo();
9281 LoadLevel(level_nr);
9282 LoadScore(level_nr);
9287 static boolean useEditorDoorAnimation(void)
9289 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
9290 boolean door_1_viewport_unchanged =
9291 (vp_door_1->x == DX &&
9292 vp_door_1->y == DY &&
9293 vp_door_1->width == DXSIZE &&
9294 vp_door_1->height == DYSIZE);
9295 boolean door_1_contains_toolbox =
9298 EX + EXSIZE <= DX + DXSIZE &&
9299 EY + EYSIZE <= DY + DYSIZE);
9301 return (door_1_viewport_unchanged && door_1_contains_toolbox);
9304 static void DrawEditorDoorBackground(int graphic, int x, int y,
9305 int width, int height)
9307 struct GraphicInfo *g = &graphic_info[graphic];
9309 if (g->bitmap != NULL)
9310 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
9311 MIN(width, g->width), MIN(height, g->height), x, y);
9313 ClearRectangle(drawto, x, y, width, height);
9316 static void DrawEditorDoorContent(void)
9318 // needed for gadgets drawn on background (like palette scrollbar)
9319 SetDoorBackgroundImage(IMG_UNDEFINED);
9321 // copy default editor door content to main double buffer
9322 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
9325 DrawSpecialEditorDoor();
9327 // draw new control window
9328 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
9330 // draw all toolbox gadgets to editor doors
9331 MapControlButtons();
9333 // when returning from test game to properties page, redraw toolbox gadgets
9334 if (edit_mode == ED_MODE_PROPERTIES)
9336 UnmapLevelEditorToolboxDrawingGadgets();
9337 UnmapLevelEditorToolboxCustomGadgets();
9339 MapLevelEditorToolboxCustomGadgetsIfNeeded();
9342 // draw all palette gadgets to editor doors
9343 ModifyEditorElementList();
9344 RedrawDrawingElements();
9346 // copy actual editor door content to door double buffer for OpenDoor()
9347 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
9350 void DrawLevelEd(void)
9352 int fade_mask = REDRAW_FIELD;
9354 FadeSoundsAndMusic();
9357 fade_mask = REDRAW_ALL;
9361 // needed if different viewport properties defined for editor
9362 ChangeViewportPropertiesIfNeeded();
9366 InitZoomLevelSettings(-1);
9367 InitDrawingElements();
9371 CheckElementDescriptions();
9374 if (level_editor_test_game)
9376 CopyPlayfield(level.field, Tile);
9377 CopyPlayfield(TileBackup, level.field);
9379 level_editor_test_game = FALSE;
9383 edit_mode = ED_MODE_DRAWING;
9384 edit_mode_levelconfig = ED_MODE_LEVELCONFIG_LEVEL;
9385 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
9393 // redraw_mask |= REDRAW_ALL;
9395 FreeLevelEditorGadgets();
9396 CreateLevelEditorGadgets();
9398 ReinitializeElementList(); // update dynamic level element list
9399 ReinitializeElementListButtons(); // custom element may look different
9401 InitElementPropertiesGfxElement();
9405 DrawEditModeWindow_PlayfieldOnly();
9407 DrawMaskedBorder(fade_mask);
9409 // use door animation if door 1 viewport is unchanged and contains toolbox
9410 if (useEditorDoorAnimation())
9414 DrawEditorDoorContent();
9416 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
9420 DrawEditorDoorContent();
9425 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
9428 static void AdjustDrawingAreaGadgets(void)
9430 int ed_xsize = lev_fieldx + 2;
9431 int ed_ysize = lev_fieldy + 2;
9432 int max_ed_fieldx = MAX_ED_FIELDX;
9433 int max_ed_fieldy = MAX_ED_FIELDY;
9434 boolean horizontal_scrollbar_needed;
9435 boolean vertical_scrollbar_needed;
9436 int x, y, width, height;
9438 if (suppressBorderElement())
9440 ed_xsize = lev_fieldx;
9441 ed_ysize = lev_fieldy;
9444 // check if we need any scrollbars
9445 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9446 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9448 // check if we have a smaller editor field because of scrollbars
9449 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9450 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9452 // check again if we now need more scrollbars because of less space
9453 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9454 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9456 // check if editor field gets even smaller after adding new scrollbars
9457 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9458 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9460 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
9461 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
9463 x = SX + ed_fieldx * ed_tilesize;
9464 y = SY + ed_fieldy * ed_tilesize;
9466 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
9467 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
9469 // adjust drawing area gadget
9470 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
9471 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
9472 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
9475 // adjust horizontal scrollbar gadgets
9476 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
9479 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
9480 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
9483 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9486 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
9489 // adjust vertical scrollbar gadgets
9490 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
9493 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
9495 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
9497 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9500 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
9504 static void AdjustLevelScrollPosition(void)
9506 if (level_xpos < -1)
9508 if (level_xpos > lev_fieldx - ed_fieldx + 1)
9509 level_xpos = lev_fieldx - ed_fieldx + 1;
9510 if (lev_fieldx < ed_fieldx - 2)
9513 if (level_ypos < -1)
9515 if (level_ypos > lev_fieldy - ed_fieldy + 1)
9516 level_ypos = lev_fieldy - ed_fieldy + 1;
9517 if (lev_fieldy < ed_fieldy - 2)
9520 if (suppressBorderElement())
9527 static void AdjustEditorScrollbar(int id)
9529 struct GadgetInfo *gi = level_editor_gadget[id];
9530 int items_max, items_visible, item_position;
9532 if (id == GADGET_ID_SCROLL_HORIZONTAL)
9534 items_max = MAX(lev_fieldx + 2, ed_fieldx);
9535 items_visible = ed_fieldx;
9536 item_position = level_xpos + 1;
9540 items_max = MAX(lev_fieldy + 2, ed_fieldy);
9541 items_visible = ed_fieldy;
9542 item_position = level_ypos + 1;
9545 if (item_position > items_max - items_visible)
9546 item_position = items_max - items_visible;
9548 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9549 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9552 static void AdjustElementListScrollbar(void)
9554 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
9555 int items_max, items_visible, item_position;
9557 // correct position of element list scrollbar
9558 if (element_shift < 0)
9560 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9561 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9563 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
9564 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
9565 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
9567 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9568 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
9569 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9572 static void ModifyEditorCounterValue(int counter_id, int new_value)
9574 int *counter_value = counterbutton_info[counter_id].value;
9575 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9576 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9578 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9580 if (counter_value != NULL)
9581 *counter_value = gi->textinput.number_value;
9584 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9586 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9587 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9589 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9591 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9592 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9594 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9595 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9597 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9598 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9603 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9605 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9606 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9607 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9609 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9612 static void ModifyEditorSelectboxOptions(int selectbox_id,
9613 struct ValueTextInfo *options)
9615 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9616 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9618 selectbox_info[selectbox_id].options = options;
9620 // set index to zero -- list may be shorter now (correct later, if needed)
9621 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9622 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9625 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9627 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9628 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9630 drawingarea_info[drawingarea_id].area_xsize = xsize;
9631 drawingarea_info[drawingarea_id].area_ysize = ysize;
9633 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9636 static void ModifyEditorElementList(void)
9640 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9643 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9645 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9646 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9647 struct GadgetDesign *gd = &gi->deco.design;
9648 int element = editor_elements[element_shift + i];
9649 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9653 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9655 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9661 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9663 int graphic = el2edimg(element);
9664 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9670 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9673 static void ModifyDrawingElementButton(int element, int id)
9675 struct GadgetInfo *gi = level_editor_gadget[id];
9676 Bitmap *deco_bitmap;
9678 int tile_size = gi->deco.width;
9680 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9682 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9685 static void PickDrawingElement(int button, int element)
9690 struct XYTileSize *pos;
9692 } de, drawing_elements[] =
9694 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9695 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9696 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9699 if (button < 1 || button > 3)
9702 if (IS_MM_WALL(element))
9703 element = map_mm_wall_element(element);
9705 de = drawing_elements[button - 1];
9707 *de.new_element = element; // update global drawing element variable
9709 DrawDrawingElementGraphic(element, de.pos);
9710 ModifyDrawingElementButton(element, de.id);
9712 redraw_mask |= REDRAW_DOOR_1;
9715 static void RedrawDrawingElements(void)
9717 PickDrawingElement(1, new_element1);
9718 PickDrawingElement(2, new_element2);
9719 PickDrawingElement(3, new_element3);
9722 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9724 stick_element_properties_window = FALSE;
9726 SetMainBackgroundImage(IMG_UNDEFINED);
9729 UnmapLevelEditorFieldGadgets();
9731 AdjustDrawingAreaGadgets();
9732 AdjustLevelScrollPosition();
9733 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9734 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9736 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9738 MapMainDrawingArea();
9740 if (remap_toolbox_gadgets)
9742 UnmapLevelEditorToolboxCustomGadgets();
9743 MapLevelEditorToolboxDrawingGadgets();
9747 static void DrawDrawingWindow(void)
9749 DrawDrawingWindowExt(TRUE);
9752 static int getTabulatorBarWidth(void)
9754 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9755 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9757 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9760 static int getTabulatorBarHeight(void)
9762 return ED_TAB_BAR_HEIGHT;
9765 static Pixel getTabulatorBarColor(void)
9767 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9768 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9769 int gd_x = gd->x + gd_gi1->border.width / 2;
9770 int gd_y = gd->y + gd_gi1->height - 1;
9772 return GetPixel(gd->bitmap, gd_x, gd_y);
9775 static void DrawLevelConfigTabulatorGadgets(void)
9777 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9778 Pixel tab_color = getTabulatorBarColor();
9779 int id_first = ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST;
9780 int id_last = ED_TAB_BUTTON_ID_LEVELCONFIG_LAST;
9783 for (i = id_first; i <= id_last; i++)
9785 int gadget_id = textbutton_info[i].gadget_id;
9786 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9787 boolean active = (i != edit_mode_levelconfig);
9789 // draw background line below tabulator button
9790 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9792 // draw solid line below inactive tabulator buttons
9793 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9794 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9795 ED_GADGET_TINY_DISTANCE, tab_color);
9797 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9798 MapTextbuttonGadget(i);
9801 // draw little border line below tabulator buttons
9802 if (tab_color != BLACK_PIXEL) // black => transparent
9803 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9804 ED_GADGET_TINY_DISTANCE,
9805 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9808 static void DrawPropertiesTabulatorGadgets(void)
9810 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9811 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9812 int gd_x = gd->x + gd_gi1->border.width / 2;
9813 int gd_y = gd->y + gd_gi1->height - 1;
9814 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9815 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9816 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9819 // draw two config tabulators for player elements
9820 if (IS_PLAYER_ELEMENT(properties_element))
9821 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9823 // draw two config and one "change" tabulator for custom elements
9824 if (IS_CUSTOM_ELEMENT(properties_element))
9825 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9827 for (i = id_first; i <= id_last; i++)
9829 int gadget_id = textbutton_info[i].gadget_id;
9830 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9831 boolean active = (i != edit_mode_properties);
9833 // use "config 1" and "config 2" instead of "config" for players and CEs
9834 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9835 (IS_PLAYER_ELEMENT(properties_element) ||
9836 IS_CUSTOM_ELEMENT(properties_element)))
9839 // draw background line below tabulator button
9840 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9842 // draw solid line below inactive tabulator buttons
9843 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9844 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9845 ED_GADGET_TINY_DISTANCE, tab_color);
9847 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9848 MapTextbuttonGadget(i);
9851 // draw little border line below tabulator buttons
9852 if (tab_color != BLACK_PIXEL) // black => transparent
9853 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9854 ED_GADGET_TINY_DISTANCE,
9855 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9858 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9860 DrawText(SX + xpos, SY + ypos, text, font_nr);
9863 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9866 int font_width = getFontWidth(font_nr);
9867 int font_height = getFontHeight(font_nr);
9868 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9869 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9871 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9872 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9873 TRUE, FALSE, FALSE);
9876 static void DrawLevelConfigLevel(void)
9880 // draw counter gadgets
9881 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9882 MapCounterButtons(i);
9884 // draw checkbutton gadgets
9885 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9886 MapCheckbuttonGadget(i);
9888 // draw selectbox gadgets
9889 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9890 MapSelectboxGadget(i);
9892 // draw text input gadgets
9893 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9894 MapTextInputGadget(i);
9897 static char *getLevelSubdirFromSaveMode(int save_mode)
9899 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9900 return getNewUserLevelSubdir();
9902 return leveldir_current->subdir;
9905 static void DrawLevelConfigLevelSet_DirectoryInfo(void)
9907 char *directory_text = "Level set directory:";
9908 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9909 int font1_nr = FONT_TEXT_1;
9910 int font2_nr = FONT_TEXT_2;
9911 int font1_height = getFontHeight(font1_nr);
9912 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
9913 int x = ED_LEVEL_SETTINGS_X(0);
9914 int y = ED_LEVEL_SETTINGS_Y(6);
9916 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
9917 PrintInfoText(directory_name, font2_nr, x, y);
9920 static void DrawLevelConfigLevelSet(void)
9922 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
9923 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
9926 // draw counter gadgets
9927 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
9928 MapCounterButtons(i);
9930 // draw checkbutton gadgets
9931 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
9933 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
9934 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
9935 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
9938 MapCheckbuttonGadget(i);
9941 // draw selectbox gadgets
9942 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
9943 MapSelectboxGadget(i);
9945 // draw text input gadgets
9946 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
9947 MapTextInputGadget(i);
9949 // draw textbutton gadgets
9950 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
9953 DrawLevelConfigLevelSet_DirectoryInfo();
9956 static void DrawLevelConfigEditor(void)
9960 // draw counter gadgets
9961 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
9962 MapCounterButtons(i);
9964 // draw checkbutton gadgets
9965 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
9966 MapCheckbuttonGadget(i);
9968 // draw radiobutton gadgets
9969 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
9970 MapRadiobuttonGadget(i);
9972 // draw drawing area
9973 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
9975 // draw textbutton gadgets
9976 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
9979 static void DrawLevelConfigWindow(void)
9981 char *text = "Global Settings";
9982 int font_nr = FONT_TITLE_1;
9983 struct MenuPosInfo *pos = &editor.settings.headline;
9984 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
9985 int sy = SY + pos->y;
9987 stick_element_properties_window = FALSE;
9989 SetAutomaticNumberOfGemsNeeded();
9991 UnmapLevelEditorFieldGadgets();
9993 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9996 DrawText(sx, sy, text, font_nr);
9998 DrawLevelConfigTabulatorGadgets();
10000 if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVEL)
10001 DrawLevelConfigLevel();
10002 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVELSET)
10003 DrawLevelConfigLevelSet();
10004 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_EDITOR)
10005 DrawLevelConfigEditor();
10008 static void DrawCustomContentArea(void)
10010 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
10011 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10012 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
10013 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
10014 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
10015 int xoffset = ED_GADGET_SPACE_DISTANCE;
10017 // add distance for potential left text (without drawing area border)
10018 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
10020 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10022 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
10025 static void DrawCustomChangeContentArea(void)
10027 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
10028 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10029 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
10030 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
10031 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
10032 int xoffset = ED_GADGET_SPACE_DISTANCE;
10034 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10036 MapDrawingArea(id);
10039 static void RemoveElementContentArea(int id, int font_height)
10041 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10043 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
10044 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
10045 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10046 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
10047 ED_GADGET_TEXT_DISTANCE + font_height);
10050 static void DrawYamYamContentAreas(void)
10052 int font_nr = FONT_TEXT_1;
10053 int font_height = getFontHeight(font_nr);
10054 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10055 int yoffset = (tilesize - font_height) / 2;
10056 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
10057 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
10060 // display counter to choose number of element content areas
10061 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
10063 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10065 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
10067 if (i < level.num_yamyam_contents)
10069 MapDrawingArea(id);
10073 UnmapDrawingArea(id);
10075 // delete content areas in case of reducing number of them
10076 RemoveElementContentArea(id, font_height);
10080 DrawText(x, y + 0 * tilesize, "content", font_nr);
10081 DrawText(x, y + 1 * tilesize, "when", font_nr);
10082 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
10085 static void DrawMagicBallContentAreas(void)
10087 int font_nr = FONT_TEXT_1;
10088 int font_height = getFontHeight(font_nr);
10089 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10090 int yoffset = (tilesize - font_height) / 2;
10091 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
10092 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
10095 // display counter to choose number of element content areas
10096 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
10098 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10100 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
10102 if (i < level.num_ball_contents)
10104 MapDrawingArea(id);
10108 UnmapDrawingArea(id);
10110 // delete content areas in case of reducing number of them
10111 RemoveElementContentArea(id, font_height);
10115 DrawText(x, y + 0 * tilesize, "generated", font_nr);
10116 DrawText(x, y + 1 * tilesize, "when", font_nr);
10117 DrawText(x, y + 2 * tilesize, "active", font_nr);
10120 static void DrawAndroidElementArea(void)
10122 int id = ED_DRAWING_ID_ANDROID_CONTENT;
10123 int num_elements = level.num_android_clone_elements;
10124 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10125 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10126 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10127 int xsize = MAX_ANDROID_ELEMENTS;
10130 // display counter to choose number of element areas
10131 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
10133 if (drawingarea_info[id].text_left != NULL)
10134 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10136 UnmapDrawingArea(id);
10138 ModifyEditorDrawingArea(id, num_elements, 1);
10140 // delete content areas in case of reducing number of them
10141 DrawBackground(sx, sy,
10142 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10143 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10145 MapDrawingArea(id);
10148 static void DrawGroupElementArea(void)
10150 int id = ED_DRAWING_ID_GROUP_CONTENT;
10151 int num_elements = group_element_info.num_elements;
10152 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10153 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10154 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10155 int xsize = MAX_ELEMENTS_IN_GROUP;
10158 if (drawingarea_info[id].text_left != NULL)
10159 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10161 UnmapDrawingArea(id);
10163 ModifyEditorDrawingArea(id, num_elements, 1);
10165 // delete content areas in case of reducing number of them
10166 DrawBackground(sx, sy,
10167 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10168 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10170 MapDrawingArea(id);
10173 static void DrawPlayerInitialInventoryArea(int element)
10175 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
10176 int player_nr = GET_PLAYER_NR(element);
10177 int num_elements = level.initial_inventory_size[player_nr];
10178 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10179 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10180 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10181 int xsize = MAX_INITIAL_INVENTORY_SIZE;
10184 // determine horizontal position to the right of specified gadget
10185 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
10186 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
10187 ED_DRAWINGAREA_TEXT_DISTANCE);
10189 // determine horizontal offset for leading text
10190 if (drawingarea_info[id].text_left != NULL)
10191 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10193 UnmapDrawingArea(id);
10195 ModifyEditorDrawingArea(id, num_elements, 1);
10197 // delete content areas in case of reducing number of them
10198 DrawBackground(sx, sy,
10199 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10200 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10202 MapDrawingArea(id);
10205 static void DrawMMBallContentArea(void)
10207 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
10208 int num_elements = level.num_mm_ball_contents;
10209 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10210 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10211 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10212 int xsize = MAX_MM_BALL_CONTENTS;
10215 if (drawingarea_info[id].text_left != NULL)
10216 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10218 UnmapDrawingArea(id);
10220 ModifyEditorDrawingArea(id, num_elements, 1);
10222 // delete content areas in case of reducing number of them
10223 DrawBackground(sx, sy,
10224 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10225 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10227 MapDrawingArea(id);
10230 static void DrawEnvelopeTextArea(int envelope_nr)
10232 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
10233 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
10237 DrawBackground(gi->x, gi->y,
10238 gi->textarea.crop_width, gi->textarea.crop_height);
10240 if (envelope_nr != -1)
10241 textarea_info[id].value = level.envelope[envelope_nr].text;
10243 ModifyGadget(gi, GDI_AREA_SIZE,
10244 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
10245 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
10248 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
10251 static void DrawPropertiesInfo(void)
10260 // configurable properties
10262 { EP_WALKABLE_OVER, "- player can walk over it" },
10263 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
10264 { EP_WALKABLE_UNDER, "- player can walk under it" },
10265 { EP_PASSABLE_OVER, "- player can pass over it" },
10266 { EP_PASSABLE_INSIDE, "- player can pass through it" },
10267 { EP_PASSABLE_UNDER, "- player can pass under it" },
10268 { EP_PROTECTED, "- player is protected by it" },
10270 { EP_DIGGABLE, "- can be digged away" },
10271 { EP_COLLECTIBLE, "- can be collected" },
10272 { EP_DROPPABLE, "- can be dropped after collecting" },
10273 { EP_THROWABLE, "- can be thrown after collecting" },
10274 { EP_PUSHABLE, "- can be pushed" },
10276 { EP_CAN_FALL, "- can fall" },
10277 { EP_CAN_MOVE, "- can move" },
10279 { EP_CAN_SMASH_PLAYER, "- can smash player" },
10281 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
10283 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
10285 { EP_SLIPPERY, "- slippery for falling elements" },
10286 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
10288 { EP_DONT_RUN_INTO, "- deadly when running into" },
10289 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
10290 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
10291 { EP_DONT_TOUCH, "- deadly when touching" },
10293 { EP_INDESTRUCTIBLE, "- indestructible" },
10295 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
10296 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
10297 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
10299 { EP_CAN_CHANGE, "- can change to other element" },
10301 // pre-defined properties
10302 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
10303 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
10304 { EP_SWITCHABLE, "- can be switched" },
10306 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
10311 char *filename = getElementDescriptionFilename(properties_element);
10312 char *num_elements_text = "In this level: ";
10313 char *num_similar_text = "Similar tiles: ";
10314 char *properties_text = "Standard properties: ";
10315 char *description_text = "Description:";
10316 char *no_description_text = "No description available.";
10317 char *none_text = "None";
10319 int num_elements_in_level = 0;
10320 int num_similar_in_level = 0;
10321 int num_hires_tiles_in_level = 0;
10322 int num_standard_properties = 0;
10323 int font1_nr = FONT_TEXT_1;
10324 int font2_nr = FONT_TEXT_2;
10325 int font1_width = getFontWidth(font1_nr);
10326 int font1_height = getFontHeight(font1_nr);
10327 int font2_height = getFontHeight(font2_nr);
10328 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
10329 int font2_yoffset = (font1_height - font2_height) / 2;
10330 int num_elements_text_len = strlen(num_elements_text) * font1_width;
10331 int num_similar_text_len = strlen(num_similar_text) * font1_width;
10332 int properties_text_len = strlen(properties_text) * font1_width;
10333 int xpos = ED_ELEMENT_SETTINGS_X(0);
10334 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10337 if (setup.editor.show_element_token)
10339 int font3_nr = FONT_TEXT_3;
10340 int font3_height = getFontHeight(font3_nr);
10342 DrawTextF(xpos, ypos, font3_nr,
10343 "[%s]", element_info[properties_element].token_name);
10345 ypos += 2 * font3_height;
10348 // ----- print number of elements / percentage of this element in level
10350 for (y = 0; y < lev_fieldy; y++)
10352 for (x = 0; x < lev_fieldx; x++)
10354 if (Tile[x][y] == properties_element)
10356 num_elements_in_level++;
10358 else if (IS_MM_WALL(Tile[x][y]) &&
10359 map_mm_wall_element(Tile[x][y]) == properties_element)
10361 num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
10366 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10368 DrawTextS(xpos, ypos, font1_nr, num_elements_text);
10370 if (num_hires_tiles_in_level > 0)
10371 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10372 "%d wall tiles", num_hires_tiles_in_level);
10373 else if (num_elements_in_level > 0)
10374 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10375 "%d (%.2f %%)", num_elements_in_level, percentage);
10377 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10380 // ----- print number of similar elements / percentage of them in level
10382 for (y = 0; y < lev_fieldy; y++)
10384 for (x = 0; x < lev_fieldx; x++)
10386 if (strEqual(element_info[Tile[x][y]].class_name,
10387 element_info[properties_element].class_name))
10389 num_similar_in_level++;
10394 if (num_similar_in_level != num_elements_in_level)
10396 ypos += 1 * MAX(font1_height, font2_height);
10398 percentage = num_similar_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10400 DrawTextS(xpos, ypos, font1_nr, num_similar_text);
10402 if (num_similar_in_level > 0)
10403 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10404 "%d (%.2f %%)", num_similar_in_level, percentage);
10406 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10410 ypos += 2 * MAX(font1_height, font2_height);
10412 // ----- print standard properties of this element
10414 DrawTextS(xpos, ypos, font1_nr, properties_text);
10416 ypos += line1_height;
10418 for (i = 0; properties[i].value != -1; i++)
10420 if (!HAS_PROPERTY(properties_element, properties[i].value))
10423 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
10425 ypos += font2_height;
10427 num_standard_properties++;
10430 if (num_standard_properties == 0)
10432 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
10433 font2_nr, none_text);
10435 ypos -= (line1_height - font1_height);
10438 ypos += MAX(font1_height, font2_height);
10440 // ----- print special description of this element
10442 PrintInfoText(description_text, font1_nr, xpos, ypos);
10444 ypos += line1_height;
10446 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
10447 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
10450 #define TEXT_COLLECTING "Score for collecting"
10451 #define TEXT_SMASHING "Score for smashing"
10452 #define TEXT_SLURPING "Score for slurping robot"
10453 #define TEXT_CRACKING "Score for cracking"
10454 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
10455 #define TEXT_DURATION "Duration when activated"
10456 #define TEXT_DELAY_ON "Delay before activating"
10457 #define TEXT_DELAY_OFF "Delay before deactivating"
10458 #define TEXT_DELAY_CHANGING "Delay before changing"
10459 #define TEXT_DELAY_EXPLODING "Delay before exploding"
10460 #define TEXT_DELAY_MOVING "Delay before moving"
10461 #define TEXT_BALL_DELAY "Element generation delay"
10462 #define TEXT_MOVE_SPEED "Speed of android moving"
10463 #define TEXT_CLONE_SPEED "Speed of android cloning"
10464 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
10465 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
10466 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
10467 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
10468 #define TEXT_TIME_BONUS "Extra time to solve level"
10475 } elements_with_counter[] =
10477 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
10478 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
10479 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
10480 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
10481 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10482 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
10483 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
10484 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
10485 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
10486 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
10487 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10488 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
10489 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10490 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10491 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
10492 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
10493 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
10494 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10495 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10496 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
10497 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10498 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10499 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10500 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10501 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10502 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10503 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
10504 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10505 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10506 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10507 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10508 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10509 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10510 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10511 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
10512 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
10513 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10514 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
10515 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10516 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10517 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10518 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10519 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10520 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
10521 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10522 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10523 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE], TEXT_COLLECTING },
10524 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10525 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10526 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
10527 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
10528 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
10529 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10530 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10531 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10532 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10533 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10534 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10535 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10536 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10537 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
10538 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
10539 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
10540 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
10541 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
10542 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10543 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
10544 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
10545 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
10546 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10547 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10548 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10549 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10550 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10551 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10552 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10553 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10554 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10555 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10556 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10557 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10558 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10559 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
10561 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10562 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
10563 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
10564 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
10565 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
10566 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
10567 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
10568 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
10569 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
10570 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
10571 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
10572 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
10573 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
10574 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
10575 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
10576 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
10578 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
10579 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
10580 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
10581 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
10582 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
10583 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
10584 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
10585 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
10586 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
10587 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
10588 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
10589 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
10590 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_CHANGING },
10591 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10592 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10597 static boolean checkPropertiesConfig(int element)
10601 if (IS_GEM(element) ||
10602 IS_CUSTOM_ELEMENT(element) ||
10603 IS_GROUP_ELEMENT(element) ||
10604 IS_EMPTY_ELEMENT(element) ||
10605 IS_BALLOON_ELEMENT(element) ||
10606 IS_ENVELOPE(element) ||
10607 IS_MM_ENVELOPE(element) ||
10608 IS_MM_MCDUFFIN(element) ||
10609 IS_DF_LASER(element) ||
10610 IS_PLAYER_ELEMENT(element) ||
10611 HAS_EDITOR_CONTENT(element) ||
10612 CAN_GROW(element) ||
10613 COULD_MOVE_INTO_ACID(element) ||
10614 MAYBE_DONT_COLLIDE_WITH(element) ||
10615 element == EL_BD_PLAYER ||
10616 element == EL_SOKOBAN_OBJECT ||
10617 element == EL_SOKOBAN_FIELD_EMPTY ||
10618 element == EL_SOKOBAN_FIELD_FULL)
10621 for (i = 0; elements_with_counter[i].element != -1; i++)
10622 if (elements_with_counter[i].element == element)
10628 static void SetAutomaticNumberOfGemsNeeded(void)
10632 if (!level.auto_count_gems)
10635 level.gems_needed = 0;
10637 for (x = 0; x < lev_fieldx; x++)
10639 for (y = 0; y < lev_fieldy; y++)
10641 int element = Tile[x][y];
10646 case EL_EMERALD_YELLOW:
10647 case EL_EMERALD_RED:
10648 case EL_EMERALD_PURPLE:
10649 case EL_BD_DIAMOND:
10650 case EL_WALL_EMERALD:
10651 case EL_WALL_EMERALD_YELLOW:
10652 case EL_WALL_EMERALD_RED:
10653 case EL_WALL_EMERALD_PURPLE:
10654 case EL_WALL_BD_DIAMOND:
10656 case EL_SP_INFOTRON:
10659 level.gems_needed++;
10663 case EL_WALL_DIAMOND:
10664 level.gems_needed += 3;
10668 case EL_WALL_PEARL:
10669 level.gems_needed += 5;
10673 case EL_WALL_CRYSTAL:
10674 level.gems_needed += 8;
10683 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10686 static void DrawPropertiesConfig(void)
10688 boolean draw_footer_line = FALSE;
10689 int max_num_element_counters = 4;
10690 int num_element_counters = 0;
10693 if (!checkPropertiesConfig(properties_element))
10695 int xpos = ED_ELEMENT_SETTINGS_X(0);
10696 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10698 PrintInfoText("No configuration options available.",
10699 FONT_TEXT_1, xpos, ypos);
10704 // check if there are elements where a value can be chosen for
10705 for (i = 0; elements_with_counter[i].element != -1; i++)
10707 if (elements_with_counter[i].element == properties_element)
10709 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10711 counterbutton_info[counter_id].y =
10712 ED_ELEMENT_SETTINGS_YPOS(
10713 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10714 (CAN_GROW(properties_element) ? 1 : 0) +
10715 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10716 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10717 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10718 num_element_counters);
10720 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10721 counterbutton_info[counter_id].text_right = elements_with_counter[i].text;
10723 if (properties_element == EL_GAME_OF_LIFE ||
10724 properties_element == EL_BIOMAZE)
10726 counterbutton_info[counter_id].min_value = 0; // min neighbours
10727 counterbutton_info[counter_id].max_value = 8; // max neighbours
10731 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10732 counterbutton_info[counter_id].min_value = MIN_SCORE;
10733 counterbutton_info[counter_id].max_value = MAX_SCORE;
10736 MapCounterButtons(counter_id);
10738 num_element_counters++;
10739 if (num_element_counters >= max_num_element_counters)
10744 if (HAS_EDITOR_CONTENT(properties_element))
10746 // draw stickybutton gadget
10747 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10749 if (IS_AMOEBOID(properties_element))
10750 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10751 else if (properties_element == EL_YAMYAM ||
10752 properties_element == EL_YAMYAM_LEFT ||
10753 properties_element == EL_YAMYAM_RIGHT ||
10754 properties_element == EL_YAMYAM_UP ||
10755 properties_element == EL_YAMYAM_DOWN)
10756 DrawYamYamContentAreas();
10757 else if (properties_element == EL_EMC_MAGIC_BALL)
10759 DrawMagicBallContentAreas();
10761 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10762 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10764 else if (properties_element == EL_EMC_ANDROID)
10765 DrawAndroidElementArea();
10766 else if (properties_element == EL_MM_GRAY_BALL)
10768 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
10769 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
10770 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
10771 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EXPLODE_MM_BALL);
10773 DrawMMBallContentArea();
10777 if (IS_PLAYER_ELEMENT(properties_element))
10779 int player_nr = GET_PLAYER_NR(properties_element);
10781 // these properties can be set for every player individually
10783 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10785 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
10786 &level.start_element[player_nr];
10787 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
10788 &level.artwork_element[player_nr];
10789 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
10790 &level.explosion_element[player_nr];
10792 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10793 &level.use_start_element[player_nr];
10794 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10795 &level.use_artwork_element[player_nr];
10796 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10797 &level.use_explosion_element[player_nr];
10798 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10799 &level.initial_player_gravity[player_nr];
10801 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10802 &level.initial_player_stepsize[player_nr];
10804 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
10805 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
10806 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
10807 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
10808 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
10809 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
10810 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
10811 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
10812 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
10813 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
10814 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
10815 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
10816 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
10817 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
10818 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
10820 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
10821 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
10822 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
10824 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
10826 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10828 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
10829 &level.initial_inventory_content[player_nr][0];
10831 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
10832 &level.initial_inventory_size[player_nr];
10834 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
10835 &level.use_initial_inventory[player_nr];
10837 // draw checkbutton gadgets
10838 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
10839 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
10840 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
10842 // draw counter gadgets
10843 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
10845 // draw drawing area gadgets
10846 DrawPlayerInitialInventoryArea(properties_element);
10850 if (properties_element == EL_BD_PLAYER)
10851 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS);
10853 if (IS_GEM(properties_element))
10854 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
10856 if (properties_element == EL_EM_DYNAMITE)
10857 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
10859 if (COULD_MOVE_INTO_ACID(properties_element) &&
10860 !IS_PLAYER_ELEMENT(properties_element) &&
10861 (!IS_CUSTOM_ELEMENT(properties_element) ||
10862 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
10864 // set position for checkbutton for "can move into acid"
10865 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
10866 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
10867 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
10868 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
10869 IS_BALLOON_ELEMENT(properties_element) ||
10870 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10872 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
10875 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
10876 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
10878 if (properties_element == EL_SPRING ||
10879 properties_element == EL_SPRING_LEFT ||
10880 properties_element == EL_SPRING_RIGHT)
10881 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
10883 if (properties_element == EL_TIME_ORB_FULL)
10884 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
10886 if (properties_element == EL_GAME_OF_LIFE ||
10887 properties_element == EL_BIOMAZE)
10888 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
10890 if (CAN_GROW(properties_element))
10892 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
10893 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10895 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
10898 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
10899 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
10901 if (properties_element == EL_SOKOBAN_OBJECT)
10902 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
10904 if (properties_element == EL_SOKOBAN_OBJECT ||
10905 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
10906 properties_element == EL_SOKOBAN_FIELD_FULL)
10908 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
10909 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
10912 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
10915 if (IS_BALLOON_ELEMENT(properties_element))
10916 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
10918 if (IS_ENVELOPE(properties_element) ||
10919 IS_MM_ENVELOPE(properties_element))
10921 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
10922 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
10923 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
10924 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
10925 int envelope_nr = ENVELOPE_NR(properties_element);
10927 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
10928 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
10930 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
10931 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
10933 // display counter to choose size of envelope text area
10934 MapCounterButtons(counter1_id);
10935 MapCounterButtons(counter2_id);
10937 // display checkbuttons to choose auto-wrap and alignment properties
10938 MapCheckbuttonGadget(button1_id);
10939 MapCheckbuttonGadget(button2_id);
10941 DrawEnvelopeTextArea(envelope_nr);
10944 if (IS_MM_MCDUFFIN(properties_element))
10946 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
10947 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
10948 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
10951 if (IS_DF_LASER(properties_element))
10953 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
10954 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
10955 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
10958 if (IS_CUSTOM_ELEMENT(properties_element))
10960 // draw stickybutton gadget
10961 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10963 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10965 // draw checkbutton gadgets
10966 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
10967 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
10968 MapCheckbuttonGadget(i);
10970 // draw counter gadgets
10971 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
10972 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
10973 MapCounterButtons(i);
10975 // draw selectbox gadgets
10976 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
10977 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
10978 MapSelectboxGadget(i);
10980 // draw textbutton gadgets
10981 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10983 // draw text input gadgets
10984 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10986 // draw drawing area gadgets
10987 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10989 draw_footer_line = TRUE;
10991 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10993 // draw checkbutton gadgets
10994 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
10995 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
10996 MapCheckbuttonGadget(i);
10998 // draw counter gadgets
10999 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
11000 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
11001 MapCounterButtons(i);
11003 // draw selectbox gadgets
11004 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
11005 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
11006 MapSelectboxGadget(i);
11008 // draw drawing area gadgets
11009 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
11010 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
11011 DrawCustomContentArea();
11014 else if (IS_GROUP_ELEMENT(properties_element))
11016 // draw stickybutton gadget
11017 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11019 // draw checkbutton gadgets
11020 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11021 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11023 // draw counter gadgets
11024 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
11026 // draw selectbox gadgets
11027 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
11029 // draw textbutton gadgets
11030 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11032 // draw drawing area gadgets
11033 DrawGroupElementArea();
11035 // draw text input gadgets
11036 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11038 // draw drawing area gadgets
11039 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11041 draw_footer_line = TRUE;
11043 else if (IS_EMPTY_ELEMENT(properties_element))
11045 // draw stickybutton gadget
11046 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11048 // draw checkbutton gadgets
11049 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11050 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11052 // draw textbutton gadgets
11053 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11055 // draw drawing area gadgets
11056 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11058 draw_footer_line = TRUE;
11061 // draw little footer border line above CE/GE use/save template gadgets
11062 if (draw_footer_line)
11064 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
11065 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
11066 int gd_x = gd->x + gd_gi1->border.width / 2;
11067 int gd_y = gd->y + gd_gi1->height - 1;
11068 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
11070 if (tab_color != BLACK_PIXEL) // black => transparent
11071 FillRectangle(drawto,
11072 SX + ED_ELEMENT_SETTINGS_X(0),
11073 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
11075 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
11079 static void DrawPropertiesChangeDrawingAreas(void)
11081 if (IS_CUSTOM_ELEMENT(properties_element))
11083 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
11084 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
11085 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
11087 DrawCustomChangeContentArea();
11090 redraw_mask |= REDRAW_FIELD;
11093 static void DrawPropertiesChange(void)
11097 // needed to initially set selectbox options for special action options
11098 setSelectboxSpecialActionOptions();
11100 // draw stickybutton gadget
11101 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11103 // draw checkbutton gadgets
11104 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
11105 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
11106 MapCheckbuttonGadget(i);
11108 // draw counter gadgets
11109 for (i = ED_COUNTER_ID_CHANGE_FIRST;
11110 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
11111 MapCounterButtons(i);
11113 // draw selectbox gadgets
11114 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
11115 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
11116 MapSelectboxGadget(i);
11118 // draw textbutton gadgets
11119 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
11120 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
11121 MapTextbuttonGadget(i);
11123 // draw graphicbutton gadgets
11124 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
11125 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
11126 MapGraphicbuttonGadget(i);
11128 // draw drawing area gadgets
11129 DrawPropertiesChangeDrawingAreas();
11132 static void DrawEditorElementAnimation(int x, int y)
11134 int graphic = el2img(properties_element);
11135 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
11136 custom_element.ce_value_fixed_initial :
11137 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
11138 custom_element.collect_score_initial : FrameCounter);
11140 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
11143 static void DrawEditorElementName(int x, int y, int font_nr)
11145 char *element_name = getElementInfoText(properties_element);
11146 int font_width = getFontWidth(font_nr);
11147 int font_height = getFontHeight(font_nr);
11148 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
11149 int max_chars_per_line = max_text_width / font_width;
11151 if (strlen(element_name) <= max_chars_per_line)
11152 DrawTextS(x, y, font_nr, element_name);
11155 char buffer[max_chars_per_line + 1];
11156 int next_pos = max_chars_per_line;
11158 strncpy(buffer, element_name, max_chars_per_line);
11159 buffer[max_chars_per_line] = '\0';
11161 if (element_name[max_chars_per_line] == ' ')
11167 for (i = max_chars_per_line - 1; i >= 0; i--)
11168 if (buffer[i] == ' ')
11171 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
11178 DrawTextS(x, y - font_height / 2, font_nr, buffer);
11180 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
11181 buffer[max_chars_per_line] = '\0';
11183 DrawTextS(x, y + font_height / 2, font_nr, buffer);
11187 static void DrawPropertiesWindow(void)
11189 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
11190 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
11191 int border_size = gd->border_size;
11192 int font_nr = FONT_TEXT_1;
11193 int font_height = getFontHeight(font_nr);
11194 int xoffset = TILEX + element_border + 3 * border_size;
11195 int yoffset = (TILEY - font_height) / 2;
11196 int x1 = editor.settings.element_graphic.x + element_border;
11197 int y1 = editor.settings.element_graphic.y + element_border;
11198 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
11199 editor.settings.element_name.x);
11200 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
11201 editor.settings.element_name.y);
11202 char *text = "Element Settings";
11203 int font2_nr = FONT_TITLE_1;
11204 struct MenuPosInfo *pos = &editor.settings.headline;
11205 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
11206 int sy = SY + pos->y;
11208 stick_element_properties_window = FALSE;
11210 // make sure that previous properties edit mode exists for this element
11211 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
11212 !IS_CUSTOM_ELEMENT(properties_element))
11213 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
11215 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
11216 !IS_PLAYER_ELEMENT(properties_element) &&
11217 !IS_CUSTOM_ELEMENT(properties_element))
11218 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
11220 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
11221 (IS_PLAYER_ELEMENT(properties_element) ||
11222 IS_CUSTOM_ELEMENT(properties_element)))
11223 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
11225 CopyElementPropertiesToEditor(properties_element);
11227 UnmapLevelEditorFieldGadgets();
11228 UnmapLevelEditorToolboxDrawingGadgets();
11229 UnmapLevelEditorToolboxCustomGadgets();
11231 MapLevelEditorToolboxCustomGadgetsIfNeeded();
11233 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11236 DrawText(sx, sy, text, font2_nr);
11238 FrameCounter = 0; // restart animation frame counter
11240 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
11241 DrawEditorElementAnimation(SX + x1, SY + y1);
11242 DrawEditorElementName(x2, y2, font_nr);
11244 DrawPropertiesTabulatorGadgets();
11246 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
11247 DrawPropertiesInfo();
11248 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
11249 DrawPropertiesChange();
11250 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
11251 DrawPropertiesConfig();
11254 static void DrawPaletteWindow(void)
11258 UnmapLevelEditorFieldGadgets();
11260 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11263 // map buttons to select elements
11264 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
11265 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
11266 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
11267 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
11268 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
11271 static void UpdateCustomElementGraphicGadgets(void)
11275 InitElementPropertiesGfxElement();
11277 ModifyEditorElementList();
11278 RedrawDrawingElements();
11280 // force redraw of all mapped drawing area gadgets
11281 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
11283 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
11290 static int getOpenDirectionFromTube(int element)
11294 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
11295 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
11296 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
11297 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
11298 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
11299 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
11300 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
11301 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
11302 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
11303 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
11304 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
11310 static int getTubeFromOpenDirection(int direction)
11314 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
11315 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
11316 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
11317 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
11318 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
11319 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
11320 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
11321 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
11322 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
11323 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
11324 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
11326 // if only one direction, fall back to simple tube with that direction
11327 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
11328 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
11329 case (MV_UP): return EL_TUBE_VERTICAL;
11330 case (MV_DOWN): return EL_TUBE_VERTICAL;
11336 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
11338 int element_new = getTubeFromOpenDirection(direction);
11340 return (element_new != EL_EMPTY ? element_new : element_old);
11343 static int getOpenDirectionFromBelt(int element)
11345 int belt_dir = getBeltDirFromBeltElement(element);
11347 return (belt_dir == MV_LEFT ? MV_RIGHT :
11348 belt_dir == MV_RIGHT ? MV_LEFT :
11349 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
11352 static int getBeltFromNrAndOpenDirection(int nr, int direction)
11354 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
11355 direction == MV_RIGHT ? MV_LEFT :
11356 direction == MV_HORIZONTAL ? MV_NONE : direction);
11358 if (direction == MV_NONE)
11361 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
11364 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
11367 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
11369 return (element_new != EL_EMPTY ? element_new : element_old);
11372 static int getOpenDirectionFromPool(int element)
11376 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
11377 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
11378 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
11379 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
11380 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
11381 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
11387 static int getPoolFromOpenDirection(int direction)
11391 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
11392 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
11393 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
11394 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
11395 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
11396 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
11402 static int getPoolFromOpenDirectionExt(int direction, int help_element)
11404 int element = getPoolFromOpenDirection(direction);
11405 int help_direction = getOpenDirectionFromPool(help_element);
11407 if (element == EL_EMPTY)
11409 int help_direction_vertical = help_direction & MV_VERTICAL;
11411 element = getPoolFromOpenDirection(direction | help_direction_vertical);
11414 if (element == EL_EMPTY)
11416 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
11418 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
11424 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
11426 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
11428 return (element_new != EL_EMPTY ? element_new : element_old);
11431 static int getOpenDirectionFromPillar(int element)
11435 case EL_EMC_WALL_1: return (MV_DOWN);
11436 case EL_EMC_WALL_2: return (MV_VERTICAL);
11437 case EL_EMC_WALL_3: return (MV_UP);
11443 static int getPillarFromOpenDirection(int direction)
11447 case (MV_DOWN): return EL_EMC_WALL_1;
11448 case (MV_VERTICAL): return EL_EMC_WALL_2;
11449 case (MV_UP): return EL_EMC_WALL_3;
11455 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
11457 int element_new = getPillarFromOpenDirection(direction);
11459 return (element_new != EL_EMPTY ? element_new : element_old);
11462 static int getOpenDirectionFromSteel2(int element)
11466 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
11467 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
11468 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
11469 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
11470 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
11471 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
11472 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
11473 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
11479 static int getSteel2FromOpenDirection(int direction)
11483 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
11484 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
11485 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
11486 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
11487 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
11488 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
11489 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
11490 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
11496 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
11498 int element_new = getSteel2FromOpenDirection(direction);
11500 return (element_new != EL_EMPTY ? element_new : element_old);
11503 static int getOpenDirectionFromChip(int element)
11507 case EL_SP_CHIP_SINGLE: return (MV_NONE);
11508 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
11509 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
11510 case EL_SP_CHIP_TOP: return (MV_DOWN);
11511 case EL_SP_CHIP_BOTTOM: return (MV_UP);
11517 static int getChipFromOpenDirection(int direction)
11521 case (MV_NONE): return EL_SP_CHIP_SINGLE;
11522 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
11523 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
11524 case (MV_UP): return EL_SP_CHIP_BOTTOM;
11525 case (MV_DOWN): return EL_SP_CHIP_TOP;
11531 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
11533 int element_new = getChipFromOpenDirection(direction);
11535 return (element_new != EL_EMPTY ? element_new : element_old);
11538 static int getClosedTube(int x, int y)
11540 struct XY *xy = xy_directions;
11541 int element_old = IntelliDrawBuffer[x][y];
11542 int direction_old = getOpenDirectionFromTube(element_old);
11543 int direction_new = MV_NONE;
11546 for (i = 0; i < NUM_DIRECTIONS; i++)
11548 int xx = x + xy[i].x;
11549 int yy = y + xy[i].y;
11550 int dir = MV_DIR_FROM_BIT(i);
11551 int dir_opposite = MV_DIR_OPPOSITE(dir);
11553 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
11554 (direction_old & dir) &&
11555 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11556 direction_new |= dir;
11559 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
11562 static int getClosedBelt(int x, int y)
11564 struct XY *xy = xy_directions;
11565 int element_old = IntelliDrawBuffer[x][y];
11566 int nr = getBeltNrFromBeltElement(element_old);
11567 int direction_old = getOpenDirectionFromBelt(element_old);
11568 int direction_new = MV_NONE;
11571 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11573 int xx = x + xy[i].x;
11574 int yy = y + xy[i].y;
11575 int dir = MV_DIR_FROM_BIT(i);
11576 int dir_opposite = MV_DIR_OPPOSITE(dir);
11578 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
11579 (direction_old & dir) &&
11580 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11581 direction_new |= dir;
11584 return getBeltFromNrAndOpenDirection(nr, direction_new);
11587 static int getClosedPool(int x, int y)
11589 struct XY *xy = xy_directions;
11590 int element_old = IntelliDrawBuffer[x][y];
11591 int direction_old = getOpenDirectionFromPool(element_old);
11592 int direction_new = MV_NONE;
11595 for (i = 0; i < NUM_DIRECTIONS; i++)
11597 int xx = x + xy[i].x;
11598 int yy = y + xy[i].y;
11599 int dir = MV_DIR_FROM_BIT(i);
11600 int dir_opposite = MV_DIR_OPPOSITE(dir);
11602 if (IN_LEV_FIELD(xx, yy) &&
11603 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
11604 (direction_old & dir) &&
11605 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11606 direction_new |= dir;
11609 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
11612 static int getClosedPillar(int x, int y)
11614 struct XY *xy = xy_directions;
11615 int element_old = IntelliDrawBuffer[x][y];
11616 int direction_old = getOpenDirectionFromPillar(element_old);
11617 int direction_new = MV_NONE;
11620 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11622 int xx = x + xy[i].x;
11623 int yy = y + xy[i].y;
11624 int dir = MV_DIR_FROM_BIT(i);
11625 int dir_opposite = MV_DIR_OPPOSITE(dir);
11627 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11628 (direction_old & dir) &&
11629 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11630 direction_new |= dir;
11633 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11636 static int getClosedSteel2(int x, int y)
11638 struct XY *xy = xy_directions;
11639 int element_old = IntelliDrawBuffer[x][y];
11640 int direction_old = getOpenDirectionFromSteel2(element_old);
11641 int direction_new = MV_NONE;
11644 for (i = 0; i < NUM_DIRECTIONS; i++)
11646 int xx = x + xy[i].x;
11647 int yy = y + xy[i].y;
11648 int dir = MV_DIR_FROM_BIT(i);
11649 int dir_opposite = MV_DIR_OPPOSITE(dir);
11651 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11652 (direction_old & dir) &&
11653 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11654 direction_new |= dir;
11657 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11660 static int getClosedChip(int x, int y)
11662 struct XY *xy = xy_directions;
11663 int element_old = IntelliDrawBuffer[x][y];
11664 int direction_old = getOpenDirectionFromChip(element_old);
11665 int direction_new = MV_NONE;
11668 for (i = 0; i < NUM_DIRECTIONS; i++)
11670 int xx = x + xy[i].x;
11671 int yy = y + xy[i].y;
11672 int dir = MV_DIR_FROM_BIT(i);
11673 int dir_opposite = MV_DIR_OPPOSITE(dir);
11675 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11676 (direction_old & dir) &&
11677 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11678 direction_new |= dir;
11681 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11684 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11685 boolean change_level)
11687 int sx = x - level_xpos;
11688 int sy = y - level_ypos;
11689 int old_element = Tile[x][y];
11690 int new_element = element;
11691 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11692 boolean draw_masked = FALSE;
11694 if (IS_MM_WALL_EDITOR(element))
11696 element = map_mm_wall_element_editor(element) | new_bitmask;
11698 if (IS_MM_WALL(old_element))
11699 element |= MM_WALL_BITS(old_element);
11702 draw_masked = TRUE;
11704 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11706 int element_changed = old_element & ~new_bitmask;
11708 if (MM_WALL_BITS(element_changed) != 0)
11709 element = element_changed;
11712 IntelliDrawBuffer[x][y] = element;
11715 Tile[x][y] = element;
11717 if (IN_ED_FIELD(sx, sy))
11719 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11720 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11721 else if (draw_masked)
11722 DrawEditorElementThruMask(sx, sy, element);
11724 DrawEditorElement(sx, sy, element);
11728 static void SetElementSimple(int x, int y, int element, boolean change_level)
11730 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11733 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11734 int x2, int y2, int *element2,
11735 int (*close_function)(int, int),
11736 boolean change_level)
11738 // set neighbour elements to newly determined connections
11739 SetElementSimple(x1, y1, *element1, change_level);
11740 SetElementSimple(x2, y2, *element2, change_level);
11742 // remove all open connections of neighbour elements
11743 *element1 = close_function(x1, y1);
11744 *element2 = close_function(x2, y2);
11746 // set neighbour elements to new, minimized connections
11747 SetElementSimple(x1, y1, *element1, change_level);
11748 SetElementSimple(x2, y2, *element2, change_level);
11751 static void SetElementIntelliDraw(int x, int y, int dx, int dy, int new_element,
11752 boolean change_level, int button)
11754 struct XY *xy = xy_directions;
11755 static int last_x = -1;
11756 static int last_y = -1;
11758 if (new_element == EL_UNDEFINED)
11766 int old_element = IntelliDrawBuffer[x][y];
11768 if (IS_TUBE(new_element))
11770 int last_element_new = EL_UNDEFINED;
11771 int direction = MV_NONE;
11774 // if old element is of same kind, keep all existing directions
11775 if (IS_TUBE(old_element))
11776 direction |= getOpenDirectionFromTube(old_element);
11778 for (i = 0; i < NUM_DIRECTIONS; i++)
11780 int xx = x + xy[i].x;
11781 int yy = y + xy[i].y;
11783 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11784 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11786 int dir = MV_DIR_FROM_BIT(i);
11787 int dir_opposite = MV_DIR_OPPOSITE(dir);
11788 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11789 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11790 int last_direction_new = last_direction_old | dir_opposite;
11792 last_element_new = getTubeFromOpenDirection(last_direction_new);
11798 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
11800 if (last_element_new != EL_UNDEFINED)
11801 MergeAndCloseNeighbourElements(x, y, &new_element,
11802 last_x, last_y, &last_element_new,
11803 getClosedTube, change_level);
11805 else if (IS_BELT(new_element))
11807 int belt_nr = getBeltNrFromBeltElement(new_element);
11808 int last_element_new = EL_UNDEFINED;
11809 int direction = MV_NONE;
11812 // if old element is of same kind, keep all existing directions
11813 if (IS_BELT(old_element))
11814 direction |= getOpenDirectionFromBelt(old_element);
11816 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11818 int xx = x + xy[i].x;
11819 int yy = y + xy[i].y;
11821 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11822 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
11824 int dir = MV_DIR_FROM_BIT(i);
11825 int dir_opposite = MV_DIR_OPPOSITE(dir);
11826 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11827 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
11828 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
11829 int last_direction_new = last_direction_old | dir_opposite;
11831 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11832 last_direction_new);
11837 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
11839 if (last_element_new != EL_UNDEFINED)
11840 MergeAndCloseNeighbourElements(x, y, &new_element,
11841 last_x, last_y, &last_element_new,
11842 getClosedBelt, change_level);
11844 else if (IS_ACID_POOL_OR_ACID(new_element))
11846 int last_element_new = EL_UNDEFINED;
11847 int direction = MV_NONE;
11850 // if old element is of same kind, keep all existing directions
11851 if (IS_ACID_POOL_OR_ACID(old_element))
11852 direction |= getOpenDirectionFromPool(old_element);
11854 for (i = 0; i < NUM_DIRECTIONS; i++)
11856 int xx = x + xy[i].x;
11857 int yy = y + xy[i].y;
11859 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11860 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
11862 int dir = MV_DIR_FROM_BIT(i);
11863 int dir_opposite = MV_DIR_OPPOSITE(dir);
11864 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11865 int last_direction_old = getOpenDirectionFromPool(last_element_old);
11866 int last_direction_new = last_direction_old | dir_opposite;
11868 last_element_new = getPoolFromOpenDirection(last_direction_new);
11874 // special corrections needed for intuitively correct acid pool drawing
11875 if (last_element_new == EL_EMPTY)
11876 last_element_new = new_element;
11877 else if (last_element_new != EL_UNDEFINED)
11878 new_element = last_element_new;
11880 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
11882 if (last_element_new != EL_UNDEFINED)
11883 MergeAndCloseNeighbourElements(x, y, &new_element,
11884 last_x, last_y, &last_element_new,
11885 getClosedPool, change_level);
11887 else if (IS_EMC_PILLAR(new_element))
11889 int last_element_new = EL_UNDEFINED;
11890 int direction = MV_NONE;
11893 // if old element is of same kind, keep all existing directions
11894 if (IS_EMC_PILLAR(old_element))
11895 direction |= getOpenDirectionFromPillar(old_element);
11897 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11899 int xx = x + xy[i].x;
11900 int yy = y + xy[i].y;
11902 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11903 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
11905 int dir = MV_DIR_FROM_BIT(i);
11906 int dir_opposite = MV_DIR_OPPOSITE(dir);
11907 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11908 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
11909 int last_direction_new = last_direction_old | dir_opposite;
11911 last_element_new = getPillarFromOpenDirection(last_direction_new);
11917 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
11919 if (last_element_new != EL_UNDEFINED)
11920 MergeAndCloseNeighbourElements(x, y, &new_element,
11921 last_x, last_y, &last_element_new,
11922 getClosedPillar, change_level);
11924 else if (IS_DC_STEELWALL_2(new_element))
11926 int last_element_new = EL_UNDEFINED;
11927 int direction = MV_NONE;
11930 // if old element is of same kind, keep all existing directions
11931 if (IS_DC_STEELWALL_2(old_element))
11932 direction |= getOpenDirectionFromSteel2(old_element);
11934 for (i = 0; i < NUM_DIRECTIONS; i++)
11936 int xx = x + xy[i].x;
11937 int yy = y + xy[i].y;
11939 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11940 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
11942 int dir = MV_DIR_FROM_BIT(i);
11943 int dir_opposite = MV_DIR_OPPOSITE(dir);
11944 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11945 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
11946 int last_direction_new = last_direction_old | dir_opposite;
11948 last_element_new = getSteel2FromOpenDirection(last_direction_new);
11954 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
11956 if (last_element_new != EL_UNDEFINED)
11957 MergeAndCloseNeighbourElements(x, y, &new_element,
11958 last_x, last_y, &last_element_new,
11959 getClosedSteel2, change_level);
11961 else if (IS_SP_CHIP(new_element))
11963 int last_element_new = EL_UNDEFINED;
11964 int direction = MV_NONE;
11967 // (do not keep existing directions, regardless of kind of old element)
11969 for (i = 0; i < NUM_DIRECTIONS; i++)
11971 int xx = x + xy[i].x;
11972 int yy = y + xy[i].y;
11974 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11975 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
11977 int dir = MV_DIR_FROM_BIT(i);
11978 int dir_opposite = MV_DIR_OPPOSITE(dir);
11979 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11980 int last_direction_old = getOpenDirectionFromChip(last_element_old);
11981 int last_direction_new = last_direction_old | dir_opposite;
11983 if (last_direction_old == MV_NONE)
11985 last_element_new = getChipFromOpenDirection(last_direction_new);
11988 else if (last_direction_old & (dir | dir_opposite))
11990 direction |= MV_DIR_OPPOSITE(last_direction_old);
11994 direction |= MV_DIR_OPPOSITE(dir);
11999 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
12001 if (last_element_new != EL_UNDEFINED)
12002 MergeAndCloseNeighbourElements(x, y, &new_element,
12003 last_x, last_y, &last_element_new,
12004 getClosedChip, change_level);
12006 else if (IS_SP_HARDWARE_BASE(new_element))
12008 int nr = GetSimpleRandom(6);
12010 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
12011 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
12012 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
12013 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
12014 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
12016 else if (new_element == EL_SP_HARDWARE_GREEN ||
12017 new_element == EL_SP_HARDWARE_BLUE ||
12018 new_element == EL_SP_HARDWARE_RED)
12020 int nr = GetSimpleRandom(3);
12022 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
12023 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
12025 else if (IS_GROUP_ELEMENT(new_element))
12027 boolean connected_drawing = FALSE;
12030 for (i = 0; i < NUM_DIRECTIONS; i++)
12032 int xx = x + xy[i].x;
12033 int yy = y + xy[i].y;
12035 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12036 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
12037 connected_drawing = TRUE;
12040 if (!connected_drawing)
12041 ResolveGroupElement(new_element);
12043 new_element = GetElementFromGroupElement(new_element);
12045 else if (IS_BELT_SWITCH(old_element))
12047 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
12048 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
12050 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
12051 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
12053 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
12057 static int swappable_elements[][2] =
12059 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
12060 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
12061 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
12062 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
12063 { EL_EMERALD, EL_WALL_EMERALD },
12064 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
12065 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
12066 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
12067 { EL_DIAMOND, EL_WALL_DIAMOND },
12068 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
12069 { EL_GATE_1, EL_GATE_1_GRAY },
12070 { EL_GATE_2, EL_GATE_2_GRAY },
12071 { EL_GATE_3, EL_GATE_3_GRAY },
12072 { EL_GATE_4, EL_GATE_4_GRAY },
12073 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
12074 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
12075 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
12076 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
12077 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
12078 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
12079 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
12080 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
12081 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
12082 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
12083 { EL_LAMP, EL_LAMP_ACTIVE },
12084 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
12085 { EL_SP_BASE, EL_SP_BUGGY_BASE },
12086 { EL_PEARL, EL_WALL_PEARL },
12087 { EL_CRYSTAL, EL_WALL_CRYSTAL },
12088 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
12089 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
12090 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
12091 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
12092 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
12093 { EL_LANDMINE, EL_DC_LANDMINE },
12094 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
12095 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
12096 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
12097 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
12098 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
12099 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
12100 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
12101 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
12102 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
12106 static int rotatable_elements_4[][4] =
12116 EL_SPACESHIP_RIGHT,
12121 EL_BD_BUTTERFLY_UP,
12122 EL_BD_BUTTERFLY_RIGHT,
12123 EL_BD_BUTTERFLY_DOWN,
12124 EL_BD_BUTTERFLY_LEFT
12128 EL_BD_FIREFLY_RIGHT,
12129 EL_BD_FIREFLY_DOWN,
12157 EL_SP_GRAVITY_PORT_UP,
12158 EL_SP_GRAVITY_PORT_RIGHT,
12159 EL_SP_GRAVITY_PORT_DOWN,
12160 EL_SP_GRAVITY_PORT_LEFT
12163 EL_SP_GRAVITY_ON_PORT_UP,
12164 EL_SP_GRAVITY_ON_PORT_RIGHT,
12165 EL_SP_GRAVITY_ON_PORT_DOWN,
12166 EL_SP_GRAVITY_ON_PORT_LEFT
12169 EL_SP_GRAVITY_OFF_PORT_UP,
12170 EL_SP_GRAVITY_OFF_PORT_RIGHT,
12171 EL_SP_GRAVITY_OFF_PORT_DOWN,
12172 EL_SP_GRAVITY_OFF_PORT_LEFT
12181 EL_BALLOON_SWITCH_UP,
12182 EL_BALLOON_SWITCH_RIGHT,
12183 EL_BALLOON_SWITCH_DOWN,
12184 EL_BALLOON_SWITCH_LEFT
12188 EL_MM_MCDUFFIN_RIGHT,
12189 EL_MM_MCDUFFIN_DOWN,
12190 EL_MM_MCDUFFIN_LEFT
12193 EL_MM_MIRROR_FIXED_1,
12194 EL_MM_MIRROR_FIXED_4,
12195 EL_MM_MIRROR_FIXED_3,
12196 EL_MM_MIRROR_FIXED_2
12199 EL_MM_STEEL_GRID_FIXED_1,
12200 EL_MM_STEEL_GRID_FIXED_4,
12201 EL_MM_STEEL_GRID_FIXED_2,
12202 EL_MM_STEEL_GRID_FIXED_3
12205 EL_MM_WOODEN_GRID_FIXED_1,
12206 EL_MM_WOODEN_GRID_FIXED_4,
12207 EL_MM_WOODEN_GRID_FIXED_2,
12208 EL_MM_WOODEN_GRID_FIXED_3
12211 EL_MM_POLARIZER_CROSS_1,
12212 EL_MM_POLARIZER_CROSS_4,
12213 EL_MM_POLARIZER_CROSS_3,
12214 EL_MM_POLARIZER_CROSS_2
12218 EL_MM_PACMAN_RIGHT,
12230 EL_DF_RECEIVER_RIGHT,
12231 EL_DF_RECEIVER_DOWN,
12232 EL_DF_RECEIVER_LEFT
12245 static int rotatable_elements_8[][8] =
12248 EL_DF_STEEL_GRID_FIXED_1,
12249 EL_DF_STEEL_GRID_FIXED_8,
12250 EL_DF_STEEL_GRID_FIXED_7,
12251 EL_DF_STEEL_GRID_FIXED_6,
12252 EL_DF_STEEL_GRID_FIXED_5,
12253 EL_DF_STEEL_GRID_FIXED_4,
12254 EL_DF_STEEL_GRID_FIXED_3,
12255 EL_DF_STEEL_GRID_FIXED_2
12258 EL_DF_WOODEN_GRID_FIXED_1,
12259 EL_DF_WOODEN_GRID_FIXED_8,
12260 EL_DF_WOODEN_GRID_FIXED_7,
12261 EL_DF_WOODEN_GRID_FIXED_6,
12262 EL_DF_WOODEN_GRID_FIXED_5,
12263 EL_DF_WOODEN_GRID_FIXED_4,
12264 EL_DF_WOODEN_GRID_FIXED_3,
12265 EL_DF_WOODEN_GRID_FIXED_2
12268 EL_DF_STEEL_GRID_ROTATING_1,
12269 EL_DF_STEEL_GRID_ROTATING_8,
12270 EL_DF_STEEL_GRID_ROTATING_7,
12271 EL_DF_STEEL_GRID_ROTATING_6,
12272 EL_DF_STEEL_GRID_ROTATING_5,
12273 EL_DF_STEEL_GRID_ROTATING_4,
12274 EL_DF_STEEL_GRID_ROTATING_3,
12275 EL_DF_STEEL_GRID_ROTATING_2
12278 EL_DF_WOODEN_GRID_ROTATING_1,
12279 EL_DF_WOODEN_GRID_ROTATING_8,
12280 EL_DF_WOODEN_GRID_ROTATING_7,
12281 EL_DF_WOODEN_GRID_ROTATING_6,
12282 EL_DF_WOODEN_GRID_ROTATING_5,
12283 EL_DF_WOODEN_GRID_ROTATING_4,
12284 EL_DF_WOODEN_GRID_ROTATING_3,
12285 EL_DF_WOODEN_GRID_ROTATING_2
12292 static int rotatable_elements_16[][16] =
12313 EL_MM_TELEPORTER_5,
12314 EL_MM_TELEPORTER_4,
12315 EL_MM_TELEPORTER_3,
12316 EL_MM_TELEPORTER_2,
12317 EL_MM_TELEPORTER_1,
12318 EL_MM_TELEPORTER_16,
12319 EL_MM_TELEPORTER_15,
12320 EL_MM_TELEPORTER_14,
12321 EL_MM_TELEPORTER_13,
12322 EL_MM_TELEPORTER_12,
12323 EL_MM_TELEPORTER_11,
12324 EL_MM_TELEPORTER_10,
12325 EL_MM_TELEPORTER_9,
12326 EL_MM_TELEPORTER_8,
12327 EL_MM_TELEPORTER_7,
12331 EL_MM_TELEPORTER_RED_5,
12332 EL_MM_TELEPORTER_RED_4,
12333 EL_MM_TELEPORTER_RED_3,
12334 EL_MM_TELEPORTER_RED_2,
12335 EL_MM_TELEPORTER_RED_1,
12336 EL_MM_TELEPORTER_RED_16,
12337 EL_MM_TELEPORTER_RED_15,
12338 EL_MM_TELEPORTER_RED_14,
12339 EL_MM_TELEPORTER_RED_13,
12340 EL_MM_TELEPORTER_RED_12,
12341 EL_MM_TELEPORTER_RED_11,
12342 EL_MM_TELEPORTER_RED_10,
12343 EL_MM_TELEPORTER_RED_9,
12344 EL_MM_TELEPORTER_RED_8,
12345 EL_MM_TELEPORTER_RED_7,
12346 EL_MM_TELEPORTER_RED_6
12349 EL_MM_TELEPORTER_YELLOW_5,
12350 EL_MM_TELEPORTER_YELLOW_4,
12351 EL_MM_TELEPORTER_YELLOW_3,
12352 EL_MM_TELEPORTER_YELLOW_2,
12353 EL_MM_TELEPORTER_YELLOW_1,
12354 EL_MM_TELEPORTER_YELLOW_16,
12355 EL_MM_TELEPORTER_YELLOW_15,
12356 EL_MM_TELEPORTER_YELLOW_14,
12357 EL_MM_TELEPORTER_YELLOW_13,
12358 EL_MM_TELEPORTER_YELLOW_12,
12359 EL_MM_TELEPORTER_YELLOW_11,
12360 EL_MM_TELEPORTER_YELLOW_10,
12361 EL_MM_TELEPORTER_YELLOW_9,
12362 EL_MM_TELEPORTER_YELLOW_8,
12363 EL_MM_TELEPORTER_YELLOW_7,
12364 EL_MM_TELEPORTER_YELLOW_6
12367 EL_MM_TELEPORTER_GREEN_5,
12368 EL_MM_TELEPORTER_GREEN_4,
12369 EL_MM_TELEPORTER_GREEN_3,
12370 EL_MM_TELEPORTER_GREEN_2,
12371 EL_MM_TELEPORTER_GREEN_1,
12372 EL_MM_TELEPORTER_GREEN_16,
12373 EL_MM_TELEPORTER_GREEN_15,
12374 EL_MM_TELEPORTER_GREEN_14,
12375 EL_MM_TELEPORTER_GREEN_13,
12376 EL_MM_TELEPORTER_GREEN_12,
12377 EL_MM_TELEPORTER_GREEN_11,
12378 EL_MM_TELEPORTER_GREEN_10,
12379 EL_MM_TELEPORTER_GREEN_9,
12380 EL_MM_TELEPORTER_GREEN_8,
12381 EL_MM_TELEPORTER_GREEN_7,
12382 EL_MM_TELEPORTER_GREEN_6
12385 EL_MM_TELEPORTER_BLUE_5,
12386 EL_MM_TELEPORTER_BLUE_4,
12387 EL_MM_TELEPORTER_BLUE_3,
12388 EL_MM_TELEPORTER_BLUE_2,
12389 EL_MM_TELEPORTER_BLUE_1,
12390 EL_MM_TELEPORTER_BLUE_16,
12391 EL_MM_TELEPORTER_BLUE_15,
12392 EL_MM_TELEPORTER_BLUE_14,
12393 EL_MM_TELEPORTER_BLUE_13,
12394 EL_MM_TELEPORTER_BLUE_12,
12395 EL_MM_TELEPORTER_BLUE_11,
12396 EL_MM_TELEPORTER_BLUE_10,
12397 EL_MM_TELEPORTER_BLUE_9,
12398 EL_MM_TELEPORTER_BLUE_8,
12399 EL_MM_TELEPORTER_BLUE_7,
12400 EL_MM_TELEPORTER_BLUE_6
12404 EL_MM_POLARIZER_16,
12405 EL_MM_POLARIZER_15,
12406 EL_MM_POLARIZER_14,
12407 EL_MM_POLARIZER_13,
12408 EL_MM_POLARIZER_12,
12409 EL_MM_POLARIZER_11,
12410 EL_MM_POLARIZER_10,
12439 EL_DF_MIRROR_ROTATING_1,
12440 EL_DF_MIRROR_ROTATING_16,
12441 EL_DF_MIRROR_ROTATING_15,
12442 EL_DF_MIRROR_ROTATING_14,
12443 EL_DF_MIRROR_ROTATING_13,
12444 EL_DF_MIRROR_ROTATING_12,
12445 EL_DF_MIRROR_ROTATING_11,
12446 EL_DF_MIRROR_ROTATING_10,
12447 EL_DF_MIRROR_ROTATING_9,
12448 EL_DF_MIRROR_ROTATING_8,
12449 EL_DF_MIRROR_ROTATING_7,
12450 EL_DF_MIRROR_ROTATING_6,
12451 EL_DF_MIRROR_ROTATING_5,
12452 EL_DF_MIRROR_ROTATING_4,
12453 EL_DF_MIRROR_ROTATING_3,
12454 EL_DF_MIRROR_ROTATING_2
12457 EL_DF_MIRROR_FIXED_1,
12458 EL_DF_MIRROR_FIXED_16,
12459 EL_DF_MIRROR_FIXED_15,
12460 EL_DF_MIRROR_FIXED_14,
12461 EL_DF_MIRROR_FIXED_13,
12462 EL_DF_MIRROR_FIXED_12,
12463 EL_DF_MIRROR_FIXED_11,
12464 EL_DF_MIRROR_FIXED_10,
12465 EL_DF_MIRROR_FIXED_9,
12466 EL_DF_MIRROR_FIXED_8,
12467 EL_DF_MIRROR_FIXED_7,
12468 EL_DF_MIRROR_FIXED_6,
12469 EL_DF_MIRROR_FIXED_5,
12470 EL_DF_MIRROR_FIXED_4,
12471 EL_DF_MIRROR_FIXED_3,
12472 EL_DF_MIRROR_FIXED_2
12481 for (i = 0; swappable_elements[i][0] != -1; i++)
12483 int element1 = swappable_elements[i][0];
12484 int element2 = swappable_elements[i][1];
12486 if (old_element == element1 || old_element == element2)
12487 new_element = (old_element == element1 ? element2 : element1);
12490 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
12492 for (j = 0; j < 4; j++)
12494 int element = rotatable_elements_4[i][j];
12496 if (old_element == element)
12497 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
12498 button == 2 ? rotatable_elements_4[i][0] :
12499 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
12504 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
12506 for (j = 0; j < 8; j++)
12508 int element = rotatable_elements_8[i][j];
12510 if (old_element == element)
12511 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
12512 button == 2 ? rotatable_elements_8[i][0] :
12513 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
12518 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
12520 for (j = 0; j < 16; j++)
12522 int element = rotatable_elements_16[i][j];
12524 if (old_element == element)
12525 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
12526 button == 2 ? rotatable_elements_16[i][0] :
12527 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
12532 if (old_element != new_element)
12534 int max_infotext_len = getMaxInfoTextLength();
12535 char infotext[MAX_OUTPUT_LINESIZE + 1];
12537 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
12538 infotext[max_infotext_len] = '\0';
12540 ClearEditorGadgetInfoText();
12542 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
12547 if (IS_MM_WALL_EDITOR(new_element))
12548 SetElementSimpleExt(x, y, dx, dy, new_element, change_level);
12550 SetElementSimple(x, y, new_element, change_level);
12556 static void ResetIntelliDraw(void)
12560 for (x = 0; x < lev_fieldx; x++)
12561 for (y = 0; y < lev_fieldy; y++)
12562 IntelliDrawBuffer[x][y] = Tile[x][y];
12564 SetElementIntelliDraw(-1, -1, -1, -1, EL_UNDEFINED, FALSE, -1);
12567 static boolean draw_mode_hires = FALSE;
12569 static boolean isHiresTileElement(int element)
12571 return (IS_MM_WALL(element) || element == EL_EMPTY);
12574 static boolean isHiresDrawElement(int element)
12576 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
12579 static int numHiresTiles(int element)
12581 if (IS_MM_WALL(element))
12582 return get_number_of_bits(MM_WALL_BITS(element));
12587 static void SetDrawModeHiRes(int element)
12590 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12591 isHiresDrawElement(element));
12594 static boolean getDrawModeHiRes(void)
12596 return draw_mode_hires;
12599 static int getLoResScreenPos(int pos)
12601 return (getDrawModeHiRes() ? pos / 2 : pos);
12604 static int getLoResScreenMod(int pos)
12606 return (getDrawModeHiRes() ? pos % 2 : 0);
12609 static void SetElementExt(int x, int y, int dx, int dy, int element,
12610 boolean change_level, int button)
12613 SetElementSimple(x, y, Tile[x][y], change_level);
12614 else if (GetKeyModState() & KMOD_Shift)
12615 SetElementIntelliDraw(x, y, dx, dy, element, change_level, button);
12617 SetElementSimpleExt(x, y, dx, dy, element, change_level);
12620 static void SetElement(int x, int y, int element)
12622 SetElementExt(x, y, 0, 0, element, TRUE, -1);
12625 static void SetElementButton(int x, int y, int dx, int dy, int element,
12628 SetElementExt(x, y, dx, dy, element, TRUE, button);
12631 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
12633 int lx = getLoResScreenPos(sx2) + level_xpos;
12634 int ly = getLoResScreenPos(sy2) + level_ypos;
12635 int dx = getLoResScreenMod(sx2);
12636 int dy = getLoResScreenMod(sy2);
12638 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
12641 static void SetLevelElementHiRes(int lx2, int ly2, int element)
12648 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
12651 static int getLevelElementHiRes(int lx2, int ly2)
12657 int element = Tile[lx][ly];
12658 unsigned int bitmask = (dx + 1) << (dy * 2);
12660 if (IS_MM_WALL(element))
12662 if (element & bitmask)
12663 return map_mm_wall_element(element);
12671 static void DrawLineElement(int x, int y, int element, boolean change_level)
12673 SetElementHiRes(x, y, element, change_level);
12676 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12677 int element, boolean change_level)
12679 int xsize = ABS(to_x - from_x);
12680 int ysize = ABS(to_y - from_y);
12681 int dx = (to_x < from_x ? -1 : +1);
12682 int dy = (to_y < from_y ? -1 : +1);
12685 if (from_y == to_y) // horizontal line
12687 for (i = 0; i <= xsize; i++)
12688 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12690 else if (from_x == to_x) // vertical line
12692 for (i = 0; i <= ysize; i++)
12693 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12695 else // diagonal line
12697 if (ysize < xsize) // a < 1
12699 float a = (float)ysize / (float)xsize;
12701 for (i = 0; i <= xsize; i++)
12704 int y = dy * (int)(a * i + 0.5);
12706 DrawLineElement(from_x + x, from_y + y, element, change_level);
12711 float a = (float)xsize / (float)ysize;
12713 for (i = 0; i <= ysize; i++)
12715 int x = dx * (int)(a * i + 0.5);
12718 DrawLineElement(from_x + x, from_y + y, element, change_level);
12724 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12725 int element, boolean change_level)
12727 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12728 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12729 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12730 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12733 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12734 int element, boolean change_level)
12739 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12741 for (y = from_y; y <= to_y; y++)
12742 DrawLine(from_x, y, to_x, y, element, change_level);
12745 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12746 int element, boolean change_level)
12748 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12749 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12750 int len_x = ABS(to_x - from_x);
12751 int len_y = ABS(to_y - from_y);
12754 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
12756 // not optimal (some points get drawn twice) but simple,
12757 // and fast enough for the few points we are drawing
12759 for (x = 0; x <= radius; x++)
12761 int sx, sy, sx2, sy2, lx, ly;
12763 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
12765 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12766 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12767 sx = getLoResScreenPos(sx2);
12768 sy = getLoResScreenPos(sy2);
12769 lx = sx + level_xpos;
12770 ly = sy + level_ypos;
12772 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12773 DrawLineElement(sx2, sy2, element, change_level);
12776 for (y = 0; y <= radius; y++)
12778 int sx, sy, sx2, sy2, lx, ly;
12780 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
12782 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12783 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12784 sx = getLoResScreenPos(sx2);
12785 sy = getLoResScreenPos(sy2);
12786 lx = sx + level_xpos;
12787 ly = sy + level_ypos;
12789 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12790 DrawLineElement(sx2, sy2, element, change_level);
12794 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
12795 int element, boolean change_level)
12797 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12798 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12800 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12803 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
12805 #if DRAW_CIRCLES_BUTTON_AVAILABLE
12806 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
12807 int element, boolean change_level)
12809 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12810 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12811 int mirror_to_x2 = from_x - (to_x2 - from_x);
12812 int mirror_to_y2 = from_y - (to_y2 - from_y);
12814 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12815 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
12816 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
12817 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element, change_level);
12821 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
12823 int from_sx, from_sy;
12827 swap_numbers(&from_x, &to_x);
12830 swap_numbers(&from_y, &to_y);
12832 from_sx = SX + from_x * ed_tilesize;
12833 from_sy = SY + from_y * ed_tilesize;
12834 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
12835 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
12837 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12838 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12839 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12840 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12842 if (from_x == to_x && from_y == to_y)
12843 MarkTileDirty(from_x/2, from_y/2);
12845 redraw_mask |= REDRAW_FIELD;
12848 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
12849 int element, boolean change_level)
12851 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
12854 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
12855 int element, boolean change_level)
12857 if (element == -1 || change_level)
12858 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
12860 DrawAreaBorder(from_x, from_y, to_x, to_y);
12863 // values for CopyBrushExt()
12864 #define CB_AREA_TO_BRUSH 0
12865 #define CB_BRUSH_TO_CURSOR 1
12866 #define CB_BRUSH_TO_LEVEL 2
12867 #define CB_DELETE_OLD_CURSOR 3
12868 #define CB_DUMP_BRUSH 4
12869 #define CB_DUMP_BRUSH_SMALL 5
12870 #define CB_CLIPBOARD_TO_BRUSH 6
12871 #define CB_BRUSH_TO_CLIPBOARD 7
12872 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
12873 #define CB_UPDATE_BRUSH_POSITION 9
12874 #define CB_FLIP_BRUSH_X 10
12875 #define CB_FLIP_BRUSH_Y 11
12876 #define CB_FLIP_BRUSH_XY 12
12878 #define MAX_CB_PART_SIZE 10
12879 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
12880 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
12881 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
12882 MAX_CB_NUM_LINES * \
12885 static int getFlippedTileExt(int map[], int element)
12889 for (i = 0; map[i] != -1; i++)
12890 if (map[i] == element)
12891 return map[i ^ 1]; // get flipped element by flipping LSB of index
12896 static int getFlippedTileX(int element)
12900 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_RIGHT,
12901 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_RIGHT,
12902 EL_BUG_LEFT, EL_BUG_RIGHT,
12903 EL_SPACESHIP_LEFT, EL_SPACESHIP_RIGHT,
12904 EL_PACMAN_LEFT, EL_PACMAN_RIGHT,
12905 EL_ARROW_LEFT, EL_ARROW_RIGHT,
12906 EL_MOLE_LEFT, EL_MOLE_RIGHT,
12907 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_RIGHT,
12908 EL_YAMYAM_LEFT, EL_YAMYAM_RIGHT,
12909 EL_SP_PORT_LEFT, EL_SP_PORT_RIGHT,
12910 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_RIGHT,
12911 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_RIGHT,
12912 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_RIGHT,
12913 EL_CONVEYOR_BELT_1_LEFT, EL_CONVEYOR_BELT_1_RIGHT,
12914 EL_CONVEYOR_BELT_2_LEFT, EL_CONVEYOR_BELT_2_RIGHT,
12915 EL_CONVEYOR_BELT_3_LEFT, EL_CONVEYOR_BELT_3_RIGHT,
12916 EL_CONVEYOR_BELT_4_LEFT, EL_CONVEYOR_BELT_4_RIGHT,
12917 EL_SPRING_LEFT, EL_SPRING_RIGHT,
12918 EL_SP_CHIP_LEFT, EL_SP_CHIP_RIGHT,
12919 EL_TUBE_VERTICAL_LEFT, EL_TUBE_VERTICAL_RIGHT,
12920 EL_TUBE_LEFT_UP, EL_TUBE_RIGHT_UP,
12921 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_DOWN,
12922 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_RIGHT,
12923 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_TOPRIGHT,
12924 EL_DC_STEELWALL_1_BOTTOMLEFT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
12925 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_TOPRIGHT_2,
12926 EL_DC_STEELWALL_1_BOTTOMLEFT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
12927 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_RIGHT,
12928 EL_ACID_POOL_TOPLEFT, EL_ACID_POOL_TOPRIGHT,
12929 EL_ACID_POOL_BOTTOMLEFT, EL_ACID_POOL_BOTTOMRIGHT,
12934 return getFlippedTileExt(map, element);
12937 static int getFlippedTileY(int element)
12941 EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY_DOWN,
12942 EL_BD_FIREFLY_UP, EL_BD_FIREFLY_DOWN,
12943 EL_BUG_UP, EL_BUG_DOWN,
12944 EL_SPACESHIP_UP, EL_SPACESHIP_DOWN,
12945 EL_PACMAN_UP, EL_PACMAN_DOWN,
12946 EL_ARROW_UP, EL_ARROW_DOWN,
12947 EL_MOLE_UP, EL_MOLE_DOWN,
12948 EL_BALLOON_SWITCH_UP, EL_BALLOON_SWITCH_DOWN,
12949 EL_YAMYAM_UP, EL_YAMYAM_DOWN,
12950 EL_SP_PORT_UP, EL_SP_PORT_DOWN,
12951 EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN,
12952 EL_SP_GRAVITY_ON_PORT_UP, EL_SP_GRAVITY_ON_PORT_DOWN,
12953 EL_SP_GRAVITY_OFF_PORT_UP, EL_SP_GRAVITY_OFF_PORT_DOWN,
12954 EL_SP_CHIP_TOP, EL_SP_CHIP_BOTTOM,
12955 EL_TUBE_HORIZONTAL_UP, EL_TUBE_HORIZONTAL_DOWN,
12956 EL_TUBE_LEFT_UP, EL_TUBE_LEFT_DOWN,
12957 EL_TUBE_RIGHT_UP, EL_TUBE_RIGHT_DOWN,
12958 EL_DC_STEELWALL_1_TOP, EL_DC_STEELWALL_1_BOTTOM,
12959 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_BOTTOMLEFT,
12960 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
12961 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
12962 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
12963 EL_DC_STEELWALL_2_TOP, EL_DC_STEELWALL_2_BOTTOM,
12964 EL_EMC_WALL_1, EL_EMC_WALL_3,
12969 return getFlippedTileExt(map, element);
12972 static int getFlippedTileXY(int element)
12976 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_UP,
12977 EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY_DOWN,
12978 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_UP,
12979 EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY_DOWN,
12980 EL_BUG_LEFT, EL_BUG_UP,
12981 EL_BUG_RIGHT, EL_BUG_DOWN,
12982 EL_SPACESHIP_LEFT, EL_SPACESHIP_UP,
12983 EL_SPACESHIP_RIGHT, EL_SPACESHIP_DOWN,
12984 EL_PACMAN_LEFT, EL_PACMAN_UP,
12985 EL_PACMAN_RIGHT, EL_PACMAN_DOWN,
12986 EL_ARROW_LEFT, EL_ARROW_UP,
12987 EL_ARROW_RIGHT, EL_ARROW_DOWN,
12988 EL_MOLE_LEFT, EL_MOLE_UP,
12989 EL_MOLE_RIGHT, EL_MOLE_DOWN,
12990 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_UP,
12991 EL_BALLOON_SWITCH_RIGHT, EL_BALLOON_SWITCH_DOWN,
12992 EL_YAMYAM_LEFT, EL_YAMYAM_UP,
12993 EL_YAMYAM_RIGHT, EL_YAMYAM_DOWN,
12994 EL_SP_PORT_LEFT, EL_SP_PORT_UP,
12995 EL_SP_PORT_RIGHT, EL_SP_PORT_DOWN,
12996 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_UP,
12997 EL_SP_GRAVITY_PORT_RIGHT, EL_SP_GRAVITY_PORT_DOWN,
12998 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_UP,
12999 EL_SP_GRAVITY_ON_PORT_RIGHT, EL_SP_GRAVITY_ON_PORT_DOWN,
13000 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_UP,
13001 EL_SP_GRAVITY_OFF_PORT_RIGHT, EL_SP_GRAVITY_OFF_PORT_DOWN,
13002 EL_SP_CHIP_LEFT, EL_SP_CHIP_TOP,
13003 EL_SP_CHIP_RIGHT, EL_SP_CHIP_BOTTOM,
13004 EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL,
13005 EL_TUBE_VERTICAL_LEFT, EL_TUBE_HORIZONTAL_UP,
13006 EL_TUBE_VERTICAL_RIGHT, EL_TUBE_HORIZONTAL_DOWN,
13007 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_UP,
13008 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_TOP,
13009 EL_DC_STEELWALL_1_RIGHT, EL_DC_STEELWALL_1_BOTTOM,
13010 EL_DC_STEELWALL_1_HORIZONTAL, EL_DC_STEELWALL_1_VERTICAL,
13011 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13012 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13013 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_TOP,
13014 EL_DC_STEELWALL_2_RIGHT, EL_DC_STEELWALL_2_BOTTOM,
13015 EL_DC_STEELWALL_2_HORIZONTAL, EL_DC_STEELWALL_2_VERTICAL,
13016 EL_EXPANDABLE_WALL_HORIZONTAL, EL_EXPANDABLE_WALL_VERTICAL,
13017 EL_EXPANDABLE_STEELWALL_HORIZONTAL, EL_EXPANDABLE_STEELWALL_VERTICAL,
13022 return getFlippedTileExt(map, element);
13025 static int getFlippedTile(int element, int mode)
13027 if (IS_MM_ELEMENT(element))
13029 // get MM game element
13030 element = map_element_RND_to_MM(element);
13032 // get flipped game element
13033 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX_MM(element) :
13034 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY_MM(element) :
13035 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY_MM(element) :
13038 // get RND game element again
13039 element = map_element_MM_to_RND(element);
13043 // get flipped game element
13044 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX(element) :
13045 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY(element) :
13046 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY(element) :
13053 static void SwapFlippedTiles(short *tile1, short *tile2, int mode)
13056 short tile1_flipped = getFlippedTile(*tile1, mode);
13057 short tile2_flipped = getFlippedTile(*tile2, mode);
13060 *tile1 = tile2_flipped;
13061 *tile2 = tile1_flipped;
13064 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
13066 DrawLineElement(sx, sy, element, change_level);
13069 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
13070 int button, int mode)
13072 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13073 static int brush_width, brush_height;
13074 static int last_cursor_x = -1, last_cursor_y = -1;
13075 static boolean delete_old_brush = FALSE;
13076 int new_element = BUTTON_ELEMENT(button);
13079 if (mode == CB_DUMP_BRUSH ||
13080 mode == CB_DUMP_BRUSH_SMALL ||
13081 mode == CB_BRUSH_TO_CLIPBOARD ||
13082 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13084 if (edit_mode != ED_MODE_DRAWING)
13087 char part[MAX_CB_PART_SIZE + 1] = "";
13088 char text[MAX_CB_TEXT_SIZE + 1] = "";
13089 int width = (draw_with_brush ? brush_width : lev_fieldx);
13090 int height = (draw_with_brush ? brush_height : lev_fieldy);
13091 char *format = "%s%03d";
13093 for (y = 0; y < height; y++)
13094 for (x = 0; x < width; x++)
13095 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
13098 for (y = 0; y < height; y++)
13100 for (x = 0; x < width; x++)
13102 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
13103 char *prefix = (mode == CB_DUMP_BRUSH ||
13104 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
13106 if (element >= NUM_FILE_ELEMENTS)
13107 element = EL_UNKNOWN;
13109 // copy brush to level sketch text buffer for the R'n'D forum:
13110 // - large tiles: `xxx or `xxxx (0x60 ASCII)
13111 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
13112 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
13113 strcat(text, part);
13116 strcat(text, "\n");
13119 if (mode == CB_BRUSH_TO_CLIPBOARD ||
13120 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13121 SDL_SetClipboardText(text);
13123 Print("%s", text); // print brush data to console and log file
13128 if (mode == CB_CLIPBOARD_TO_BRUSH)
13130 if (edit_mode != ED_MODE_DRAWING)
13133 if (!SDL_HasClipboardText())
13135 Request("Clipboard is empty!", REQ_CONFIRM);
13140 boolean copy_to_brush = (draw_with_brush ||
13141 drawing_function == GADGET_ID_GRAB_BRUSH);
13143 // this will delete the old brush, if already drawing with a brush
13145 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
13147 // initialization is required for "odd" (incomplete) clipboard content
13148 for (x = 0; x < MAX_LEV_FIELDX; x++)
13149 for (y = 0; y < MAX_LEV_FIELDY; y++)
13150 brush_buffer[x][y] = EL_EMPTY;
13157 char *clipboard_text = SDL_GetClipboardText();
13158 char *ptr = clipboard_text;
13159 boolean allow_new_row = FALSE;
13160 boolean stop = FALSE;
13162 while (*ptr && !stop)
13164 boolean prefix_found = FALSE;
13165 boolean start_new_row = FALSE;
13167 // level sketch element number prefixes (may be multi-byte characters)
13168 char *prefix_list[] = { "`", "¸" };
13171 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
13173 char *prefix = prefix_list[i];
13175 // check if string is large enough for prefix
13176 if (strlen(ptr) < strlen(prefix))
13183 // check if string starts with prefix
13184 if (strPrefix(ptr, prefix))
13186 ptr += strlen(prefix);
13188 prefix_found = TRUE;
13194 // check if prefix found and followed by (at least) three digits
13195 if (prefix_found &&
13196 strlen(ptr) >= 3 &&
13197 ptr[0] >= '0' && ptr[0] <= '9' &&
13198 ptr[1] >= '0' && ptr[1] <= '9' &&
13199 ptr[2] >= '0' && ptr[2] <= '9')
13201 int element = ((ptr[0] - '0') * 100 +
13202 (ptr[1] - '0') * 10 +
13207 // level sketch element number might consist of four digits
13208 if (ptr[0] >= '0' && ptr[0] <= '9')
13210 element = element * 10 + (ptr[0] - '0');
13214 // remap some (historic, now obsolete) elements
13215 element = getMappedElement(element);
13217 if (element >= NUM_FILE_ELEMENTS)
13218 element = EL_UNKNOWN;
13220 brush_buffer[x][y] = element;
13222 brush_width = MAX(x + 1, brush_width);
13223 brush_height = MAX(y + 1, brush_height);
13227 if (x >= MAX_LEV_FIELDX)
13228 start_new_row = TRUE;
13230 allow_new_row = TRUE;
13234 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
13235 start_new_row = TRUE;
13237 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
13245 if (y >= MAX_LEV_FIELDY)
13248 allow_new_row = FALSE;
13252 SDL_free(clipboard_text);
13254 if (brush_width == 0 || brush_height == 0)
13256 Request("No level sketch found in clipboard!", REQ_CONFIRM);
13263 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
13266 SDL_GetMouseState(&mx, &my);
13268 // if inside drawing area, activate and draw brush at last mouse position
13269 if (mx >= gi->x && mx < gi->x + gi->width &&
13270 my >= gi->y && my < gi->y + gi->height)
13271 CopyBrushToCursor(last_cursor_x, last_cursor_y);
13273 draw_with_brush = TRUE;
13279 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
13280 brush_width, brush_height);
13282 if (!Request(request, REQ_ASK))
13285 for (x = 0; x < MAX_LEV_FIELDX; x++)
13286 for (y = 0; y < MAX_LEV_FIELDY; y++)
13287 Tile[x][y] = brush_buffer[x][y];
13289 lev_fieldx = level.fieldx = brush_width;
13290 lev_fieldy = level.fieldy = brush_height;
13292 boolean use_bd_engine = TRUE;
13293 boolean use_em_engine = TRUE;
13294 boolean use_sp_engine = TRUE;
13295 boolean use_mm_engine = TRUE;
13297 for (x = 0; x < MAX_LEV_FIELDX; x++)
13299 for (y = 0; y < MAX_LEV_FIELDY; y++)
13301 int element = Tile[x][y];
13303 if (!IS_BD_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13304 use_bd_engine = FALSE;
13306 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13307 use_em_engine = FALSE;
13309 if (!IS_SP_ELEMENT(element))
13310 use_sp_engine = FALSE;
13312 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
13313 use_mm_engine = FALSE;
13317 level.game_engine_type = (use_bd_engine ? GAME_ENGINE_TYPE_BD :
13318 use_em_engine ? GAME_ENGINE_TYPE_EM :
13319 use_sp_engine ? GAME_ENGINE_TYPE_SP :
13320 use_mm_engine ? GAME_ENGINE_TYPE_MM :
13321 GAME_ENGINE_TYPE_RND);
13323 // update element selection list
13324 ReinitializeElementList();
13325 ModifyEditorElementList();
13327 SetBorderElement();
13329 DrawEditModeWindow();
13330 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13336 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
13339 if (mode == CB_AREA_TO_BRUSH)
13341 int from_lx, from_ly;
13344 swap_numbers(&from_x, &to_x);
13347 swap_numbers(&from_y, &to_y);
13349 brush_width = to_x - from_x + 1;
13350 brush_height = to_y - from_y + 1;
13352 from_lx = from_x + level_xpos;
13353 from_ly = from_y + level_ypos;
13355 for (y = 0; y < brush_height; y++)
13357 for (x = 0; x < brush_width; x++)
13359 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
13362 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
13367 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13369 delete_old_brush = FALSE;
13371 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
13372 mode == CB_BRUSH_TO_LEVEL)
13374 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
13375 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
13376 int cursor_from_x = cursor_x - brush_width / 2;
13377 int cursor_from_y = cursor_y - brush_height / 2;
13378 int border_from_x = cursor_x, border_from_y = cursor_y;
13379 int border_to_x = cursor_x, border_to_y = cursor_y;
13381 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
13382 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13384 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
13385 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
13387 delete_old_brush = FALSE;
13392 for (y = 0; y < brush_height; y++)
13394 for (x = 0; x < brush_width; x++)
13396 int sx = cursor_from_x + x;
13397 int sy = cursor_from_y + y;
13398 int lx = sx + level_xpos;
13399 int ly = sy + level_ypos;
13400 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
13401 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
13402 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
13403 brush_buffer[x][y] : new_element);
13405 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13407 if (sx < border_from_x)
13408 border_from_x = sx;
13409 else if (sx > border_to_x)
13411 if (sy < border_from_y)
13412 border_from_y = sy;
13413 else if (sy > border_to_y)
13416 DrawBrushElement(sx, sy, element, change_level);
13421 if (mode != CB_DELETE_OLD_CURSOR)
13422 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
13424 last_cursor_x = cursor_x;
13425 last_cursor_y = cursor_y;
13427 delete_old_brush = TRUE;
13429 else if (mode == CB_FLIP_BRUSH_X)
13431 for (y = 0; y < brush_height; y++)
13432 for (x = 0; x < (brush_width + 1) / 2; x++)
13433 SwapFlippedTiles(&brush_buffer[x][y],
13434 &brush_buffer[brush_width - x - 1][y], mode);
13436 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13438 else if (mode == CB_FLIP_BRUSH_Y)
13440 for (y = 0; y < (brush_height + 1) / 2; y++)
13441 for (x = 0; x < brush_width; x++)
13442 SwapFlippedTiles(&brush_buffer[x][y],
13443 &brush_buffer[x][brush_height - y - 1], mode);
13445 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13447 else if (mode == CB_FLIP_BRUSH_XY)
13449 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13451 for (y = 0; y < MAX(brush_width, brush_height); y++)
13452 for (x = 0; x <= y; x++)
13453 SwapFlippedTiles(&brush_buffer[x][y],
13454 &brush_buffer[y][x], mode);
13456 swap_numbers(&brush_width, &brush_height);
13458 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13461 if (mode == CB_UPDATE_BRUSH_POSITION)
13463 last_cursor_x = from_x;
13464 last_cursor_y = from_y;
13468 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
13471 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
13474 static void CopyBrushToLevel(int x, int y, int button)
13476 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
13479 static void CopyBrushToCursor(int x, int y)
13481 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13484 static void UpdateBrushPosition(int x, int y)
13486 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
13489 static void DeleteBrushFromCursor(void)
13491 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13494 static void FlipBrushX(void)
13496 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13499 static void FlipBrushY(void)
13501 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_Y);
13504 static void RotateBrush(void)
13506 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_XY);
13507 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13510 void DumpBrush(void)
13512 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
13515 void DumpBrush_Small(void)
13517 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
13520 void CopyClipboardToBrush(void)
13522 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
13525 void CopyBrushToClipboard(void)
13527 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
13530 void CopyBrushToClipboard_Small(void)
13532 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
13535 void UndoLevelEditorOperation(void)
13537 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
13540 void RedoLevelEditorOperation(void)
13542 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13545 static void FloodFill(int from_x, int from_y, int fill_element)
13547 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
13550 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
13552 int from_x = from_sx2 + 2 * level_xpos;
13553 int from_y = from_sy2 + 2 * level_ypos;
13554 int max_fillx = lev_fieldx * 2;
13555 int max_filly = lev_fieldy * 2;
13556 short Fill[max_fillx][max_filly];
13559 for (x = 0; x < max_fillx; x++)
13560 for (y = 0; y < max_filly; y++)
13561 Fill[x][y] = getLevelElementHiRes(x, y);
13563 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
13564 Fill, max_fillx, max_filly);
13566 for (x = 0; x < max_fillx; x++)
13567 for (y = 0; y < max_filly; y++)
13568 if (Fill[x][y] == fill_element)
13569 SetLevelElementHiRes(x, y, Fill[x][y]);
13572 // values for DrawLevelText() modes
13573 #define TEXT_INIT 0
13574 #define TEXT_SETCURSOR 1
13575 #define TEXT_WRITECHAR 2
13576 #define TEXT_BACKSPACE 3
13577 #define TEXT_NEWLINE 4
13579 #define TEXT_QUERY_TYPING 6
13581 static int DrawLevelText(int sx, int sy, char letter, int mode)
13583 static short delete_buffer[MAX_LEV_FIELDX];
13584 static int start_sx;
13585 static int last_sx, last_sy;
13586 static boolean typing = FALSE;
13587 int letter_element;
13588 int lx = 0, ly = 0;
13590 // map lower case letters to upper case and convert special characters
13591 if (letter >= 'a' && letter <= 'z')
13592 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
13593 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
13594 letter_element = EL_CHAR_AUMLAUT;
13595 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
13596 letter_element = EL_CHAR_OUMLAUT;
13597 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
13598 letter_element = EL_CHAR_UUMLAUT;
13599 else if (letter == '^')
13600 letter_element = EL_CHAR_COPYRIGHT;
13602 letter_element = EL_CHAR_ASCII0 + letter;
13604 if (mode != TEXT_INIT)
13609 if (mode != TEXT_SETCURSOR)
13615 lx = last_sx + level_xpos;
13616 ly = last_sy + level_ypos;
13623 DrawLevelText(0, 0, 0, TEXT_END);
13629 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
13632 case TEXT_SETCURSOR:
13633 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
13634 DrawAreaBorder(sx, sy, sx, sy);
13635 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
13636 ed_tilesize, ed_tilesize);
13641 case TEXT_WRITECHAR:
13642 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
13644 if (new_element1 >= EL_STEEL_CHAR_START &&
13645 new_element1 <= EL_STEEL_CHAR_END)
13646 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
13648 delete_buffer[sx - start_sx] = Tile[lx][ly];
13649 Tile[lx][ly] = letter_element;
13651 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
13652 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
13653 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13654 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13656 DrawLevelText(0, 0, 0, TEXT_END);
13658 level.changed = TRUE;
13662 case TEXT_BACKSPACE:
13665 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
13666 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
13667 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
13672 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13673 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13675 DrawLevelText(0, 0, 0, TEXT_END);
13679 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13680 DrawEditorElement(sx, sy, Tile[lx][ly]);
13685 case TEXT_QUERY_TYPING:
13695 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
13696 int element, boolean change_level)
13698 int lx = sx + level_xpos;
13699 int ly = sy + level_ypos;
13702 DrawEditorElement(sx, sy, Tile[lx][ly]);
13704 DrawAreaBorder(sx, sy, sx, sy);
13707 static void CheckLevelBorderElement(boolean redraw_playfield)
13709 int last_border_element = BorderElement;
13711 SetBorderElement();
13713 if (redraw_playfield && BorderElement != last_border_element)
13714 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13717 static void CopyLevelToUndoBuffer(int mode)
13719 static boolean accumulated_undo = FALSE;
13720 boolean new_undo_buffer_position = TRUE;
13723 if (undo_buffer_steps == 0)
13724 accumulated_undo = FALSE;
13728 case UNDO_IMMEDIATE:
13729 accumulated_undo = FALSE;
13732 case UNDO_ACCUMULATE:
13733 if (accumulated_undo)
13734 new_undo_buffer_position = FALSE;
13735 accumulated_undo = TRUE;
13742 if (new_undo_buffer_position)
13744 // advance position in undo buffer ring
13745 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13747 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
13748 undo_buffer_steps++;
13751 // always reset redo buffer when storing level change into undo buffer
13752 redo_buffer_steps = 0;
13754 for (x = 0; x < lev_fieldx; x++)
13755 for (y = 0; y < lev_fieldy; y++)
13756 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
13758 // check if drawing operation forces change of border style
13759 CheckLevelBorderElement(TRUE);
13761 level.changed = TRUE;
13764 static void RandomPlacement(int new_element)
13766 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13767 int num_free_positions = 0;
13768 int num_percentage, num_elements;
13771 ResetIntelliDraw();
13773 // determine number of free positions for randomly placing the new element
13774 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
13776 free_position[x][y] =
13777 (random_placement_background_restricted ?
13778 Tile[x][y] == random_placement_background_element :
13779 Tile[x][y] != new_element);
13781 if (free_position[x][y])
13782 num_free_positions++;
13785 // determine number of new elements to place there
13786 num_percentage = num_free_positions * random_placement_value / 100;
13787 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
13788 num_percentage : random_placement_value);
13790 // if less free positions than elements to place, fill all these positions
13791 if (num_free_positions < num_elements)
13793 for (x = 0; x < lev_fieldx; x++)
13794 for (y = 0; y < lev_fieldy; y++)
13795 if (free_position[x][y])
13796 SetElement(x, y, new_element);
13800 while (num_elements > 0)
13802 x = GetSimpleRandom(lev_fieldx);
13803 y = GetSimpleRandom(lev_fieldy);
13805 // don't place element at the same position twice
13806 if (free_position[x][y])
13808 free_position[x][y] = FALSE;
13809 SetElement(x, y, new_element);
13815 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13816 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13819 static void WrapLevel(int dx, int dy)
13821 int wrap_dx = lev_fieldx - dx;
13822 int wrap_dy = lev_fieldy - dy;
13825 for (x = 0; x < lev_fieldx; x++)
13826 for (y = 0; y < lev_fieldy; y++)
13827 TileBackup[x][y] = Tile[x][y];
13829 for (x = 0; x < lev_fieldx; x++)
13830 for (y = 0; y < lev_fieldy; y++)
13832 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
13834 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13835 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
13838 static void DrawAreaElementHighlight(boolean highlighted,
13839 boolean highlighted_similar)
13841 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13848 for (x = 0; x < ed_fieldx; x++)
13850 for (y = 0; y < ed_fieldy; y++)
13852 boolean highlight = FALSE;
13853 int lx = x + level_xpos;
13854 int ly = y + level_ypos;
13856 if (!IN_LEV_FIELD(lx, ly))
13859 // check if element is the same
13860 if (Tile[lx][ly] == new_element1)
13863 // check if element is similar
13864 if (highlighted_similar &&
13865 strEqual(element_info[Tile[lx][ly]].class_name,
13866 element_info[new_element1].class_name))
13869 // check if element is matching MM style wall
13870 if (IS_MM_WALL(Tile[lx][ly]) &&
13871 map_mm_wall_element(Tile[lx][ly]) == new_element1)
13877 if (IS_MM_WALL(Tile[lx][ly]) && !highlighted_similar)
13881 for (i = 0; i < 4; i++)
13883 if (!(MM_WALL_BITS(Tile[lx][ly]) & (1 << i)))
13886 int xx = x * 2 + (i % 2);
13887 int yy = y * 2 + (i / 2);
13888 int sx = SX + xx * ed_tilesize / 2;
13889 int sy = SY + yy * ed_tilesize / 2;
13892 int to_sx = sx + ed_tilesize / 2 - 1;
13893 int to_sy = sy + ed_tilesize / 2 - 1;
13895 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13896 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13897 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13898 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13903 int sx = SX + x * ed_tilesize;
13904 int sy = SY + y * ed_tilesize;
13907 int to_sx = sx + ed_tilesize - 1;
13908 int to_sy = sy + ed_tilesize - 1;
13910 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13911 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13912 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13913 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13919 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
13921 char *template_filename_old = getLocalLevelTemplateFilename();
13922 char *template_filename_new =
13923 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
13925 if (copyFile(template_filename_old, template_filename_new) != 0)
13926 Request("Cannot copy level template!", REQ_CONFIRM);
13928 free(template_filename_new);
13931 static void HandleDrawingAreas(struct GadgetInfo *gi)
13933 static boolean started_inside_drawing_area = FALSE;
13934 static int last_sx = -1;
13935 static int last_sy = -1;
13936 static int last_sx2 = -1;
13937 static int last_sy2 = -1;
13938 int id = gi->custom_id;
13939 int type_id = gi->custom_type_id;
13940 boolean button_press_event;
13941 boolean button_release_event;
13942 boolean inside_drawing_area = !gi->event.off_borders;
13943 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
13944 int actual_drawing_function;
13945 int button = gi->event.button;
13946 int new_element = BUTTON_ELEMENT(button);
13947 int sx = gi->event.x, sy = gi->event.y;
13948 int min_sx = 0, min_sy = 0;
13949 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
13950 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
13951 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
13952 int sx2 = gi->event.mx / mini_item_xsize;
13953 int sy2 = gi->event.my / mini_item_ysize;
13956 int lx = 0, ly = 0;
13959 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
13960 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
13962 // make sure to stay inside drawing area boundaries
13963 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
13964 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
13968 int min_lx = 0, min_ly = 0;
13969 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
13971 // get positions inside level field
13972 lx = sx + level_xpos;
13973 ly = sy + level_ypos;
13975 if (!IN_LEV_FIELD(lx, ly))
13976 inside_drawing_area = FALSE;
13978 // make sure to stay inside level field boundaries
13979 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
13980 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
13982 // correct drawing area positions accordingly
13983 sx = lx - level_xpos;
13984 sy = ly - level_ypos;
13987 // also correct MM wall-sized (double) drawing area positions accordingly
13988 if (sx2 / 2 < sx || sx2 / 2 > sx)
13990 dx = (sx2 / 2 < sx ? 0 : 1);
13993 if (sy2 / 2 < sy || sy2 / 2 > sy)
13995 dy = (sy2 / 2 < sy ? 0 : 1);
13999 if (!button_press_event && !button_release_event)
14001 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
14002 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
14003 isHiresTileElement(old_element) &&
14004 isHiresDrawElement(new_element));
14006 // prevent handling events for every pixel position when moving mouse
14007 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
14008 (sx2 == last_sx2 && sy2 == last_sy2))
14017 if (button_press_event)
14018 started_inside_drawing_area = inside_drawing_area;
14020 if (!started_inside_drawing_area)
14023 if (!IS_VALID_BUTTON(button))
14026 // handle info callback for each invocation of action callback
14027 gi->callback_info(gi);
14029 // automatically switch to 'single item' drawing mode, if needed
14030 actual_drawing_function =
14031 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
14032 drawing_function : GADGET_ID_SINGLE_ITEMS);
14034 // clicking into drawing area with pressed Control key picks element
14035 if (GetKeyModState() & KMOD_Control)
14037 last_drawing_function = drawing_function;
14038 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14041 if (GetKeyModState() & KMOD_Shift)
14043 if (button_press_event || button_release_event)
14044 ResetIntelliDraw();
14047 SetDrawModeHiRes(-1); // reset to normal draw mode
14049 switch (actual_drawing_function)
14051 case GADGET_ID_SINGLE_ITEMS:
14054 if (button_release_event)
14056 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14058 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
14059 !inside_drawing_area)
14060 DeleteBrushFromCursor();
14065 if (draw_with_brush)
14067 CopyBrushToLevel(sx, sy, button);
14071 SetDrawModeHiRes(new_element);
14073 if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
14075 // remove player at old position
14076 for (y = 0; y < lev_fieldy; y++)
14078 for (x = 0; x < lev_fieldx; x++)
14080 int old_element = Tile[x][y];
14082 if (IS_PLAYER_ELEMENT(old_element) &&
14083 IS_PLAYER_ELEMENT(new_element))
14085 int replaced_with_element =
14086 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
14087 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
14089 old_element == EL_SOKOBAN_FIELD_PLAYER &&
14090 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
14092 new_element == EL_SOKOBAN_FIELD_PLAYER &&
14093 old_element == EL_PLAYER_1 ? EL_EMPTY :
14095 new_element >= EL_PLAYER_1 &&
14096 new_element <= EL_PLAYER_4 &&
14097 new_element == old_element ? EL_EMPTY :
14101 SetElement(x, y, replaced_with_element);
14103 else if (IS_MM_MCDUFFIN(old_element) &&
14104 IS_MM_MCDUFFIN(new_element))
14106 // remove McDuffin at old position
14107 SetElement(x, y, EL_EMPTY);
14113 SetElementButton(lx, ly, dx, dy, new_element, button);
14116 else if (!button_release_event)
14118 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14120 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
14121 DrawMiniGraphicExt(drawto,
14122 gi->x + sx * MINI_TILEX,
14123 gi->y + sy * MINI_TILEY,
14124 el2edimg(new_element));
14126 DrawFixedGraphicExt(drawto,
14127 gi->x + sx * TILEX,
14128 gi->y + sy * TILEY,
14129 el2edimg(new_element), 0);
14131 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14132 new_element = GFX_ELEMENT(new_element);
14134 drawingarea_info[type_id].value[pos] = new_element;
14136 CopyElementPropertiesToGame(properties_element);
14138 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14140 UpdateCustomElementGraphicGadgets();
14142 FrameCounter = 0; // restart animation frame counter
14147 case GADGET_ID_CONNECTED_ITEMS:
14149 static int last_sx = -1;
14150 static int last_sy = -1;
14152 if (button_release_event)
14153 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14155 SetDrawModeHiRes(new_element);
14157 if (getDrawModeHiRes())
14163 if (!button_press_event)
14164 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
14171 case GADGET_ID_LINE:
14172 case GADGET_ID_ARC:
14173 case GADGET_ID_RECTANGLE:
14174 case GADGET_ID_FILLED_BOX:
14175 SetDrawModeHiRes(new_element);
14177 if (getDrawModeHiRes())
14183 case GADGET_ID_GRAB_BRUSH:
14184 case GADGET_ID_TEXT:
14186 static int last_sx = -1;
14187 static int last_sy = -1;
14188 static int start_sx = -1;
14189 static int start_sy = -1;
14190 void (*draw_func)(int, int, int, int, int, boolean);
14192 if (drawing_function == GADGET_ID_LINE)
14193 draw_func = DrawLine;
14194 else if (drawing_function == GADGET_ID_ARC)
14195 draw_func = DrawArc;
14196 else if (drawing_function == GADGET_ID_RECTANGLE)
14197 draw_func = DrawBox;
14198 else if (drawing_function == GADGET_ID_FILLED_BOX)
14199 draw_func = DrawFilledBox;
14200 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
14201 draw_func = SelectArea;
14202 else // (drawing_function == GADGET_ID_TEXT)
14203 draw_func = SetTextCursor;
14205 if (button_press_event)
14207 draw_func(sx, sy, sx, sy, new_element, FALSE);
14208 start_sx = last_sx = sx;
14209 start_sy = last_sy = sy;
14211 if (drawing_function == GADGET_ID_TEXT)
14212 DrawLevelText(0, 0, 0, TEXT_END);
14214 else if (button_release_event)
14216 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
14217 if (drawing_function == GADGET_ID_GRAB_BRUSH)
14219 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
14220 CopyBrushToCursor(sx, sy);
14221 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14223 draw_with_brush = TRUE;
14225 else if (drawing_function == GADGET_ID_TEXT)
14226 DrawLevelText(sx, sy, 0, TEXT_INIT);
14228 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14230 else if (last_sx != sx || last_sy != sy)
14232 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
14233 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
14234 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
14235 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
14242 case GADGET_ID_FLOOD_FILL:
14243 if (button_press_event && Tile[lx][ly] != new_element)
14245 if (IS_MM_WALL_EDITOR(new_element))
14246 FloodFillWall_MM(sx2, sy2, new_element);
14248 FloodFill(lx, ly, new_element);
14250 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14251 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14255 case GADGET_ID_PICK_ELEMENT:
14256 if (button_release_event)
14257 ClickOnGadget(level_editor_gadget[last_drawing_function],
14259 else if (draw_level)
14260 PickDrawingElement(button, Tile[lx][ly]);
14263 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14265 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
14272 // do not mark level as modified for certain non-level-changing gadgets
14273 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
14274 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
14275 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
14276 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14279 level.changed = TRUE;
14282 static void HandleCounterButtons(struct GadgetInfo *gi)
14284 int gadget_id = gi->custom_id;
14285 int counter_id = gi->custom_type_id;
14286 int button = gi->event.button;
14287 int *counter_value = counterbutton_info[counter_id].value;
14288 int step = BUTTON_STEPSIZE(button) *
14289 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
14291 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14293 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
14294 boolean released = (gi->event.type == GD_EVENT_RELEASED);
14295 boolean level_changed = LevelChanged();
14297 if ((level_changed && pressed) || (!level_changed && released))
14300 if (level_changed && !Request("Level has changed! Discard changes?",
14303 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14304 ModifyEditorCounterValue(counter_id, *counter_value);
14310 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14311 *counter_value = gi->textinput.number_value;
14313 ModifyEditorCounterValue(counter_id, *counter_value + step);
14315 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14317 int last_game_engine_type = level.game_engine_type;
14319 LoadLevel(level_nr);
14320 LoadScore(level_nr);
14322 SaveLevelSetup_SeriesInfo();
14327 DrawEditModeWindow();
14329 if (level.game_engine_type != last_game_engine_type)
14331 // update element selection list
14332 ReinitializeElementList();
14333 ModifyEditorElementList();
14339 switch (counter_id)
14341 case ED_COUNTER_ID_YAMYAM_CONTENT:
14342 DrawYamYamContentAreas();
14345 case ED_COUNTER_ID_BALL_CONTENT:
14346 DrawMagicBallContentAreas();
14349 case ED_COUNTER_ID_ANDROID_CONTENT:
14350 DrawAndroidElementArea();
14353 case ED_COUNTER_ID_GROUP_CONTENT:
14354 DrawGroupElementArea();
14355 CopyGroupElementPropertiesToGame(properties_element);
14358 case ED_COUNTER_ID_INVENTORY_SIZE:
14359 DrawPlayerInitialInventoryArea(properties_element);
14362 case ED_COUNTER_ID_MM_BALL_CONTENT:
14363 DrawMMBallContentArea();
14366 case ED_COUNTER_ID_ENVELOPE_XSIZE:
14367 case ED_COUNTER_ID_ENVELOPE_YSIZE:
14368 DrawEnvelopeTextArea(-1);
14371 case ED_COUNTER_ID_LEVEL_XSIZE:
14372 case ED_COUNTER_ID_LEVEL_YSIZE:
14373 lev_fieldx = level.fieldx;
14374 lev_fieldy = level.fieldy;
14376 // check if resizing of level results in change of border border
14377 SetBorderElement();
14385 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
14386 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
14387 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
14388 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
14389 CopyElementPropertiesToGame(properties_element);
14391 // do not mark level as modified for certain non-level-changing gadgets
14392 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
14393 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
14394 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
14395 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
14398 level.changed = TRUE;
14401 static void HandleTextInputGadgets(struct GadgetInfo *gi)
14403 int type_id = gi->custom_type_id;
14405 strcpy(textinput_info[type_id].value, gi->textinput.value);
14407 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
14409 CopyElementPropertiesToGame(properties_element);
14411 ModifyEditorElementList(); // update changed button info text
14414 // do not mark level as modified for certain non-level-changing gadgets
14415 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
14416 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
14419 level.changed = TRUE;
14422 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
14424 int type_id = gi->custom_type_id;
14426 strncpy(textarea_info[type_id].value, gi->textarea.value,
14427 MAX_ENVELOPE_TEXT_LEN);
14428 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
14430 level.changed = TRUE;
14433 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
14435 int type_id = gi->custom_type_id;
14436 int value_old = *selectbox_info[type_id].value;
14437 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
14439 *selectbox_info[type_id].value = value_new;
14441 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
14443 DrawLevelConfigWindow();
14445 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14447 element_info[properties_element].current_change_page = gi->selectbox.index;
14449 DrawPropertiesWindow();
14451 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
14452 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
14453 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
14454 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
14455 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
14457 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
14459 // when changing action type, also check action mode and action arg
14460 if (value_old != value_new)
14461 setSelectboxSpecialActionVariablesIfNeeded();
14463 DrawPropertiesChange();
14466 CopyElementPropertiesToGame(properties_element);
14468 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
14470 // update element selection list
14471 ReinitializeElementList();
14472 ModifyEditorElementList();
14475 // do not mark level as modified for certain non-level-changing gadgets
14476 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
14477 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14480 level.changed = TRUE;
14483 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
14485 int type_id = gi->custom_type_id;
14488 if (type_id >= ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST &&
14489 type_id <= ED_TAB_BUTTON_ID_LEVELCONFIG_LAST)
14491 edit_mode_levelconfig = gi->custom_type_id;
14493 DrawLevelConfigWindow();
14495 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
14496 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
14498 edit_mode_properties = gi->custom_type_id;
14500 DrawPropertiesWindow();
14502 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
14503 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
14505 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
14507 // backup original "level.field" (needed to track playfield changes)
14508 CopyPlayfield(level.field, TileBackup);
14510 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
14511 CopyPlayfield(Tile, level.field);
14513 if (new_template ||
14514 Request("Save this template and kill the old?", REQ_ASK))
14515 SaveLevelTemplate();
14518 Request("Template saved!", REQ_CONFIRM);
14520 // restore original "level.field" (needed to track playfield changes)
14521 CopyPlayfield(TileBackup, level.field);
14523 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
14525 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
14527 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
14528 leveldir_current->readonly)
14530 Request("This level set is read-only!", REQ_CONFIRM);
14535 if (strEqual(levelset_name, ""))
14537 Request("Please enter level set title!", REQ_CONFIRM);
14542 if (strEqual(levelset_author, ""))
14544 Request("Please enter level set author!", REQ_CONFIRM);
14549 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
14551 if (UpdateUserLevelSet(levelset_subdir,
14554 levelset_num_levels))
14556 Request("Level set updated!", REQ_CONFIRM);
14560 Request("Updating level set failed!", REQ_CONFIRM);
14563 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
14565 if (level.changed && !Request("Level has changed! Discard changes?",
14569 if (CreateUserLevelSet(levelset_subdir,
14572 levelset_num_levels,
14573 levelset_use_levelset_artwork))
14575 if (levelset_copy_level_template)
14576 CopyLevelTemplateToUserLevelSet(levelset_subdir);
14578 Request("New level set created!", REQ_CONFIRM);
14580 AddUserLevelSetToLevelInfo(levelset_subdir);
14581 ChangeEditorToLevelSet(levelset_subdir);
14585 Request("Creating new level set failed!", REQ_CONFIRM);
14589 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
14590 custom_element.num_change_pages < MAX_CHANGE_PAGES)
14592 struct ElementInfo *ei = &element_info[properties_element];
14594 // when modifying custom element, ask for copying level template
14595 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14598 setElementChangePages(ei, ei->num_change_pages + 1);
14600 // set new change page to be new current change page
14601 ei->current_change_page = ei->num_change_pages - 1;
14602 ei->change = &ei->change_page[ei->current_change_page];
14604 setElementChangeInfoToDefaults(ei->change);
14606 DrawPropertiesWindow();
14608 level.changed = TRUE;
14610 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
14611 custom_element.num_change_pages > MIN_CHANGE_PAGES)
14613 struct ElementInfo *ei = &element_info[properties_element];
14615 // when modifying custom element, ask for copying level template
14616 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14619 // copy all change pages after change page to be deleted
14620 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
14621 ei->change_page[i] = ei->change_page[i + 1];
14623 setElementChangePages(ei, ei->num_change_pages - 1);
14625 DrawPropertiesWindow();
14627 level.changed = TRUE;
14631 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
14633 int type_id = gi->custom_type_id;
14635 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
14636 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
14638 struct ElementInfo *ei = &element_info[properties_element];
14639 int step = BUTTON_STEPSIZE(gi->event.button);
14641 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
14642 ei->current_change_page += step;
14644 if (ei->current_change_page < 0)
14645 ei->current_change_page = 0;
14646 else if (ei->current_change_page >= ei->num_change_pages)
14647 ei->current_change_page = ei->num_change_pages - 1;
14649 DrawPropertiesWindow();
14651 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
14652 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14654 struct ElementInfo *ei = &element_info[properties_element];
14655 int current_change_page = ei->current_change_page;
14657 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
14659 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
14660 ei->change_page[current_change_page];
14662 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14664 // when modifying custom element, ask for copying level template
14665 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14668 ei->change_page[current_change_page] =
14669 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
14671 level.changed = TRUE;
14674 DrawPropertiesWindow();
14678 static void HandleRadiobuttons(struct GadgetInfo *gi)
14680 int type_id = gi->custom_type_id;
14682 *radiobutton_info[type_id].value =
14683 radiobutton_info[type_id].checked_value;
14685 // do not mark level as modified for certain non-level-changing gadgets
14686 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
14687 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
14690 level.changed = TRUE;
14693 static void HandleCheckbuttons(struct GadgetInfo *gi)
14695 int type_id = gi->custom_type_id;
14697 *checkbutton_info[type_id].value ^= TRUE;
14699 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
14700 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
14701 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
14702 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
14703 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
14704 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
14705 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
14706 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
14708 CopyElementPropertiesToGame(properties_element);
14711 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
14713 UpdateCustomElementGraphicGadgets();
14715 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
14716 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
14718 boolean template_related_changes_found = FALSE;
14721 // check if any custom, group or empty elements have been changed
14722 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
14723 if ((IS_CUSTOM_ELEMENT(i) ||
14724 IS_GROUP_ELEMENT(i) ||
14725 IS_EMPTY_ELEMENT(i)) &&
14726 element_info[i].modified_settings)
14727 template_related_changes_found = TRUE;
14729 if (level.use_custom_template &&
14730 !fileExists(getGlobalLevelTemplateFilename()))
14732 Request("No level template found!", REQ_CONFIRM);
14734 level.use_custom_template = FALSE;
14736 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14741 if (level.use_custom_template &&
14742 template_related_changes_found &&
14743 !Request("Discard changes and use level template?", REQ_ASK))
14745 level.use_custom_template = FALSE;
14747 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14752 if (!level.use_custom_template &&
14753 Request("Copy settings from level template?", REQ_ASK))
14758 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
14760 DrawEditModeWindow();
14762 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
14764 if (setup.editor.use_template_for_new_levels &&
14765 !fileExists(getGlobalLevelTemplateFilename()))
14767 Request("No level template found!", REQ_CONFIRM);
14772 if (setup.editor.use_template_for_new_levels &&
14774 !Request("Discard level and load template?", REQ_ASK))
14779 if (!setup.editor.use_template_for_new_levels &&
14781 !Request("Discard level and use empty level?", REQ_ASK))
14786 LoadLevel(level_nr);
14787 LoadScore(level_nr);
14792 DrawEditModeWindow();
14794 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
14796 SetAutomaticNumberOfGemsNeeded();
14799 // do not mark level as modified for certain non-level-changing gadgets
14800 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
14801 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
14802 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
14803 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
14804 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
14805 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
14808 level.changed = TRUE;
14811 static void HandleControlButtons(struct GadgetInfo *gi)
14813 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
14814 static int last_edit_mode = ED_MODE_DRAWING;
14815 static int last_custom_copy_mode = -1;
14816 static int last_button = 0;
14817 int id = gi->custom_id;
14818 int button = gi->event.button;
14819 int step = BUTTON_STEPSIZE(button);
14820 int new_element = BUTTON_ELEMENT(button);
14821 int last_properties_element = properties_element;
14824 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
14825 DrawLevelText(0, 0, 0, TEXT_END);
14827 if (id < ED_NUM_CTRL1_BUTTONS &&
14828 id != GADGET_ID_SINGLE_ITEMS &&
14829 id != GADGET_ID_PICK_ELEMENT &&
14830 edit_mode != ED_MODE_DRAWING &&
14831 drawing_function != GADGET_ID_PICK_ELEMENT &&
14832 !(GetKeyModState() & KMOD_Control))
14833 ChangeEditModeWindow(ED_MODE_DRAWING);
14835 // element copy mode active, but no element button pressed => deactivate
14836 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
14837 last_custom_copy_mode = -1;
14839 // when showing palette on element buttons, change element of button used
14840 if (editor.palette.show_on_element_buttons &&
14841 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
14843 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
14845 id = GADGET_ID_PALETTE;
14850 case GADGET_ID_SCROLL_LEFT:
14851 if (level_xpos >= 0)
14853 if (lev_fieldx < ed_fieldx - 2)
14856 level_xpos -= step;
14857 if (level_xpos < -1)
14860 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
14862 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14864 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14865 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14869 case GADGET_ID_SCROLL_RIGHT:
14870 if (level_xpos <= lev_fieldx - ed_fieldx)
14872 if (lev_fieldx < ed_fieldx - 2)
14875 level_xpos += step;
14876 if (level_xpos > lev_fieldx - ed_fieldx + 1)
14877 level_xpos = lev_fieldx - ed_fieldx + 1;
14879 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
14881 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14883 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14884 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14888 case GADGET_ID_SCROLL_UP:
14889 if (level_ypos >= 0)
14891 if (lev_fieldy < ed_fieldy - 2)
14894 level_ypos -= step;
14895 if (level_ypos < -1)
14898 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
14900 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14902 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
14903 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
14907 case GADGET_ID_SCROLL_DOWN:
14908 if (level_ypos <= lev_fieldy - ed_fieldy)
14910 if (lev_fieldy < ed_fieldy - 2)
14913 level_ypos += step;
14914 if (level_ypos > lev_fieldy - ed_fieldy + 1)
14915 level_ypos = lev_fieldy - ed_fieldy + 1;
14917 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
14919 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14921 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
14922 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
14926 case GADGET_ID_SCROLL_HORIZONTAL:
14927 level_xpos = gi->event.item_position - 1;
14929 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14934 case GADGET_ID_SCROLL_VERTICAL:
14935 level_ypos = gi->event.item_position - 1;
14937 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14942 case GADGET_ID_SCROLL_LIST_UP:
14943 case GADGET_ID_SCROLL_LIST_DOWN:
14944 case GADGET_ID_SCROLL_LIST_VERTICAL:
14945 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
14946 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
14949 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
14950 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
14952 if (element_shift < 0)
14954 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14955 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14957 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14958 GDI_SCROLLBAR_ITEM_POSITION,
14959 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14962 ModifyEditorElementList();
14966 case GADGET_ID_PROPERTIES:
14967 // always switch off element properties when they are already displayed
14968 last_properties_element = new_element;
14969 case GADGET_ID_ELEMENT_LEFT:
14970 case GADGET_ID_ELEMENT_MIDDLE:
14971 case GADGET_ID_ELEMENT_RIGHT:
14972 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
14973 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
14974 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
14977 if (edit_mode != ED_MODE_PROPERTIES)
14979 last_edit_mode = edit_mode;
14981 ChangeEditModeWindow(ED_MODE_PROPERTIES);
14983 last_level_drawing_function = drawing_function;
14984 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14987 else if (properties_element != last_properties_element)
14989 DrawEditModeWindow();
14993 ChangeEditModeWindow(ED_MODE_DRAWING);
14995 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
15000 case GADGET_ID_PALETTE:
15001 if (edit_mode != ED_MODE_PALETTE)
15003 last_edit_mode = edit_mode;
15005 ChangeEditModeWindow(ED_MODE_PALETTE);
15009 ChangeEditModeWindow(last_edit_mode);
15013 case GADGET_ID_WRAP_LEFT:
15014 WrapLevel(-step, 0);
15017 case GADGET_ID_WRAP_RIGHT:
15018 WrapLevel(step, 0);
15021 case GADGET_ID_WRAP_UP:
15022 WrapLevel(0, -step);
15025 case GADGET_ID_WRAP_DOWN:
15026 WrapLevel(0, step);
15029 case GADGET_ID_SINGLE_ITEMS:
15030 case GADGET_ID_CONNECTED_ITEMS:
15031 case GADGET_ID_LINE:
15032 case GADGET_ID_ARC:
15033 case GADGET_ID_TEXT:
15034 case GADGET_ID_RECTANGLE:
15035 case GADGET_ID_FILLED_BOX:
15036 case GADGET_ID_FLOOD_FILL:
15037 case GADGET_ID_GRAB_BRUSH:
15038 case GADGET_ID_PICK_ELEMENT:
15039 if (drawing_function != GADGET_ID_PICK_ELEMENT)
15040 last_drawing_function = drawing_function;
15041 drawing_function = id;
15042 draw_with_brush = FALSE;
15045 case GADGET_ID_RANDOM_PLACEMENT:
15046 RandomPlacement(new_element);
15049 case GADGET_ID_ZOOM:
15050 // zoom level editor tile size in or out (or reset to default size)
15051 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
15052 button == 2 ? ed_tilesize_default :
15053 button == 3 ? ed_tilesize / 2 : ed_tilesize);
15055 // when using touch device, cycle through all zoom tilesizes
15056 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
15057 ed_tilesize = MICRO_TILESIZE;
15059 // limit zoom level by upper and lower bound
15060 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
15062 InitZoomLevelSettings(ed_tilesize);
15064 if (edit_mode == ED_MODE_DRAWING)
15066 DrawDrawingWindow();
15068 // redraw zoom gadget info text
15069 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15072 // save current editor zoom tilesize
15073 SaveSetup_AutoSetup();
15077 case GADGET_ID_CUSTOM_COPY_FROM:
15078 case GADGET_ID_CUSTOM_COPY_TO:
15079 case GADGET_ID_CUSTOM_EXCHANGE:
15080 last_custom_copy_mode = id;
15081 last_drawing_function = drawing_function;
15084 case GADGET_ID_CUSTOM_COPY:
15085 CopyCustomElement(properties_element, -1, id);
15088 case GADGET_ID_CUSTOM_PASTE:
15089 CopyCustomElement(-1, properties_element, id);
15092 case GADGET_ID_UNDO:
15093 if (button < 0) // keep button value (even if modifier keys are pressed)
15095 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
15098 if (button == 1 && undo_buffer_steps == 0)
15100 Request("Undo buffer empty!", REQ_CONFIRM);
15104 else if (button == 2)
15108 else if (button == 3 && redo_buffer_steps == 0)
15110 Request("Redo buffer empty!", REQ_CONFIRM);
15115 if (edit_mode != ED_MODE_DRAWING)
15116 ChangeEditModeWindow(ED_MODE_DRAWING);
15122 undo_buffer_position =
15123 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
15125 undo_buffer_steps--;
15126 redo_buffer_steps++;
15132 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
15134 undo_buffer_steps++;
15135 redo_buffer_steps--;
15138 for (x = 0; x < lev_fieldx; x++)
15139 for (y = 0; y < lev_fieldy; y++)
15140 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
15142 // check if undo operation forces change of border style
15143 CheckLevelBorderElement(FALSE);
15145 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15149 case GADGET_ID_CONF:
15150 if (edit_mode != ED_MODE_LEVELCONFIG)
15152 last_edit_mode = edit_mode;
15154 ChangeEditModeWindow(ED_MODE_LEVELCONFIG);
15158 ChangeEditModeWindow(ED_MODE_DRAWING);
15162 case GADGET_ID_CLEAR:
15163 if (edit_mode != ED_MODE_DRAWING)
15164 ChangeEditModeWindow(ED_MODE_DRAWING);
15166 for (x = 0; x < MAX_LEV_FIELDX; x++)
15167 for (y = 0; y < MAX_LEV_FIELDY; y++)
15168 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
15170 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
15172 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15175 case GADGET_ID_SAVE:
15177 // saving read-only levels into personal level set modifies global vars
15178 // "leveldir_current" and "level_nr"; restore them after saving level
15179 LevelDirTree *leveldir_former = leveldir_current;
15180 int level_nr_former = level_nr;
15181 char *level_filename;
15184 if (leveldir_current->readonly &&
15185 !PrepareSavingIntoPersonalLevelSet())
15188 level_filename = getDefaultLevelFilename(level_nr);
15189 new_level = !fileExists(level_filename);
15192 Request("Save this level and kill the old?", REQ_ASK))
15194 if (leveldir_former->readonly)
15195 ModifyLevelConfigForSavingIntoPersonalLevelSet(leveldir_former->name);
15197 SetAutomaticNumberOfGemsNeeded();
15199 CopyPlayfield(Tile, level.field);
15200 SaveLevel(level_nr);
15202 level.changed = FALSE;
15206 char level_saved_msg[64];
15208 if (leveldir_former->readonly)
15209 sprintf(level_saved_msg,
15210 "Level saved as level %d into personal level set!",
15213 strcpy(level_saved_msg, "Level saved!");
15215 Request(level_saved_msg, REQ_CONFIRM);
15219 // "cd" back to copied-from levelset (in case of saved read-only level)
15220 leveldir_current = leveldir_former;
15221 level_nr = level_nr_former;
15226 case GADGET_ID_TEST:
15227 if (LevelChanged())
15228 level.game_version = GAME_VERSION_ACTUAL;
15230 CopyPlayfield(level.field, TileBackup);
15231 CopyPlayfield(Tile, level.field);
15233 CopyNativeLevel_RND_to_Native(&level);
15235 UnmapLevelEditorGadgets();
15236 UndrawSpecialEditorDoor();
15238 CloseDoor(DOOR_CLOSE_ALL);
15240 // needed before playing if editor playfield area has different size
15241 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
15243 // redraw_mask = REDRAW_ALL;
15245 level_editor_test_game = TRUE;
15247 StartGameActions(FALSE, setup.autorecord, level.random_seed);
15251 case GADGET_ID_EXIT:
15252 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
15256 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
15257 id <= GADGET_ID_ELEMENTLIST_LAST)
15259 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
15261 new_element = editor_elements[element_position + element_shift];
15263 if (IS_EDITOR_CASCADE(new_element))
15267 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
15269 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
15270 boolean *cascade_value = editor_elements_info[i].setup_cascade_value;
15272 if (*cascade_element == new_element)
15274 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
15275 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
15277 // update element selection list
15278 ReinitializeElementList();
15279 ModifyEditorElementList();
15281 // update cascading gadget info text
15282 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15284 // save current editor cascading state
15285 SaveSetup_EditorCascade();
15294 if (last_custom_copy_mode != -1)
15296 if (CopyCustomElement(properties_element, new_element,
15297 last_custom_copy_mode))
15299 ClickOnGadget(level_editor_gadget[last_drawing_function],
15302 last_custom_copy_mode = -1;
15308 // change element of button used to show palette
15309 if (editor.palette.show_on_element_buttons)
15310 button = last_button;
15312 PickDrawingElement(button, new_element);
15314 if (!stick_element_properties_window &&
15315 drawing_function != GADGET_ID_PICK_ELEMENT &&
15316 !(GetKeyModState() & KMOD_Control))
15318 properties_element = new_element;
15319 if (edit_mode == ED_MODE_PROPERTIES)
15320 DrawPropertiesWindow();
15323 if (drawing_function == GADGET_ID_PICK_ELEMENT)
15324 ClickOnGadget(level_editor_gadget[last_drawing_function],
15327 if (!use_permanent_palette)
15328 ChangeEditModeWindow(last_edit_mode);
15331 else if (gi->event.type == GD_EVENT_PRESSED)
15332 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
15333 else if (gi->event.type == GD_EVENT_RELEASED)
15334 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
15335 else if (gi->event.type == GD_EVENT_MOVING)
15336 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
15338 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
15344 void HandleLevelEditorKeyInput(Key key)
15346 char letter = getCharFromKey(key);
15348 if (drawing_function == GADGET_ID_TEXT &&
15349 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
15352 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
15353 else if (key == KSYM_Delete || key == KSYM_BackSpace)
15354 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
15355 else if (key == KSYM_Return)
15356 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
15357 else if (key == KSYM_Escape)
15358 DrawLevelText(0, 0, 0, TEXT_END);
15363 int id = GADGET_ID_NONE;
15364 int new_element_shift = element_shift;
15365 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
15366 int button = MB_LEFTBUTTON;
15372 id = GADGET_ID_SCROLL_LEFT;
15375 id = GADGET_ID_SCROLL_RIGHT;
15378 id = GADGET_ID_SCROLL_UP;
15381 id = GADGET_ID_SCROLL_DOWN;
15385 case KSYM_Page_Down:
15386 step *= (key == KSYM_Page_Up ? -1 : +1);
15387 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15389 if (element_shift < 0)
15391 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15392 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15394 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15395 GDI_SCROLLBAR_ITEM_POSITION,
15396 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15398 ModifyEditorElementList();
15404 element_shift = (key == KSYM_Home ? 0 :
15405 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
15407 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15408 GDI_SCROLLBAR_ITEM_POSITION,
15409 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15411 ModifyEditorElementList();
15418 // this is needed to prevent interference with running "True X-Mouse"
15419 if (GetKeyModStateFromEvents() & KMOD_Control)
15422 // check for last or next editor cascade block in element list
15423 for (i = 0; i < num_editor_elements; i++)
15425 if ((key == KSYM_Insert && i == element_shift) ||
15426 (key == KSYM_Delete && new_element_shift > element_shift))
15429 // jump to next cascade block (or to start of element list)
15430 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
15431 new_element_shift = i;
15434 if (i < num_editor_elements)
15435 element_shift = new_element_shift;
15437 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15438 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15440 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15441 GDI_SCROLLBAR_ITEM_POSITION,
15442 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15444 ModifyEditorElementList();
15449 if (edit_mode == ED_MODE_DRAWING)
15450 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
15451 else if (edit_mode == ED_MODE_LEVELCONFIG)
15452 HandleControlButtons(level_editor_gadget[GADGET_ID_CONF]);
15453 else if (edit_mode == ED_MODE_PROPERTIES)
15454 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
15455 else if (edit_mode == ED_MODE_PALETTE)
15456 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
15457 else // should never happen
15458 ChangeEditModeWindow(ED_MODE_DRAWING);
15466 if (id != GADGET_ID_NONE)
15467 ClickOnGadget(level_editor_gadget[id], button);
15468 else if (letter == '1' || letter == '?')
15469 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
15470 else if (letter == '2')
15471 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
15472 else if (letter == '3')
15473 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
15474 else if (letter == '.')
15475 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
15476 else if (letter == 'U')
15477 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
15478 else if (letter == '-' || key == KSYM_KP_Subtract)
15479 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
15480 else if (letter == '0' || key == KSYM_KP_0)
15481 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
15482 else if (letter == '+' || key == KSYM_KP_Add ||
15483 letter == '=') // ("Shift-=" is "+" on US keyboards)
15484 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
15485 else if (key == KSYM_Return ||
15486 key == KSYM_space ||
15487 key == setup.shortcut.toggle_pause)
15488 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
15490 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
15491 if (letter && letter == controlbutton_info[i].shortcut)
15492 if (!anyTextGadgetActive())
15493 ClickOnGadget(level_editor_gadget[i], button);
15495 if (draw_with_brush)
15499 else if (letter == 'y')
15501 else if (letter == 'z')
15506 static void HandleLevelEditorIdle_Properties(void)
15508 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
15509 int x = editor.settings.element_graphic.x + element_border;
15510 int y = editor.settings.element_graphic.y + element_border;
15511 static DelayCounter action_delay = { 0 };
15514 action_delay.value = GameFrameDelay;
15516 if (!DelayReached(&action_delay))
15519 for (i = 0; i < ED_NUM_SELECTBOX; i++)
15521 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
15523 if (gi->mapped && gi->active && gi->selectbox.open)
15527 DrawEditorElementAnimation(SX + x, SY + y);
15529 redraw_mask |= REDRAW_FIELD;
15531 FrameCounter++; // increase animation frame counter
15534 static void HandleLevelEditorIdle_Drawing(void)
15536 static boolean last_highlighted = FALSE;
15537 static boolean last_highlighted_similar = FALSE;
15538 boolean highlighted = (GetKeyModState() & KMOD_Alt);
15539 boolean highlighted_similar = (GetKeyModState() & KMOD_Shift);
15541 if (highlighted != last_highlighted ||
15542 (highlighted && highlighted_similar != last_highlighted_similar))
15544 DrawAreaElementHighlight(highlighted, highlighted_similar);
15546 redraw_mask |= REDRAW_FIELD;
15549 last_highlighted = highlighted;
15550 last_highlighted_similar = highlighted_similar;
15553 void HandleLevelEditorIdle(void)
15555 if (edit_mode == ED_MODE_PROPERTIES)
15556 HandleLevelEditorIdle_Properties();
15557 else if (edit_mode == ED_MODE_DRAWING)
15558 HandleLevelEditorIdle_Drawing();
15561 static void ClearEditorGadgetInfoText(void)
15563 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
15566 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
15568 char infotext[MAX_OUTPUT_LINESIZE + 1];
15569 int max_infotext_len = getMaxInfoTextLength();
15571 if (gi == NULL || strlen(gi->info_text) == 0)
15574 strncpy(infotext, gi->info_text, max_infotext_len);
15575 infotext[max_infotext_len] = '\0';
15577 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
15579 int key = controlbutton_info[gi->custom_id].shortcut;
15583 char shortcut[MAX_OUTPUT_LINESIZE + 1];
15585 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
15586 sprintf(shortcut, " ('.' or '%c')", key);
15587 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
15588 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
15589 else if (gi->custom_id == GADGET_ID_TEST)
15590 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
15591 else if (gi->custom_id == GADGET_ID_UNDO)
15592 sprintf(shortcut, " ('%c/Shift-U')", key);
15593 else if (gi->custom_id == GADGET_ID_ZOOM)
15594 sprintf(shortcut, " ('%c', '0', '-')", key);
15596 sprintf(shortcut, " ('%s%c')",
15597 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
15599 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
15600 strcat(infotext, shortcut);
15604 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
15607 void HandleEditorGadgetInfoText(void *ptr)
15609 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
15611 if (game_status != GAME_MODE_EDITOR)
15614 ClearEditorGadgetInfoText();
15616 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
15619 // misuse this function to delete brush cursor, if needed
15620 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
15621 DeleteBrushFromCursor();
15623 PrintEditorGadgetInfoText(gi);
15626 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
15628 int id = gi->custom_id;
15629 int type_id = gi->custom_type_id;
15630 int sx = gi->event.x;
15631 int sy = gi->event.y;
15632 int lx = sx + level_xpos;
15633 int ly = sy + level_ypos;
15634 int min_sx = 0, min_sy = 0;
15635 int max_sx = gi->drawing.area_xsize - 1;
15636 int max_sy = gi->drawing.area_ysize - 1;
15637 int actual_drawing_function = drawing_function;
15638 int max_infotext_len = getMaxInfoTextLength();
15639 char infotext[MAX_OUTPUT_LINESIZE + 1];
15641 infotext[0] = '\0'; // start with empty info text
15643 // pressed Control key: simulate picking element
15644 if (GetKeyModState() & KMOD_Control)
15645 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
15647 ClearEditorGadgetInfoText();
15649 if (gi->event.type == GD_EVENT_INFO_LEAVING)
15652 // make sure to stay inside drawing area boundaries
15653 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
15654 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
15656 if (id == GADGET_ID_DRAWING_LEVEL)
15660 int min_lx = 0, min_ly = 0;
15661 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
15663 // get positions inside level field
15664 lx = sx + level_xpos;
15665 ly = sy + level_ypos;
15667 // make sure to stay inside level field boundaries
15668 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
15669 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
15671 // correct drawing area positions accordingly
15672 sx = lx - level_xpos;
15673 sy = ly - level_ypos;
15676 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15678 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
15680 static int start_lx = 0;
15681 static int start_ly = 0;
15684 if (gi->event.type == GD_EVENT_PRESSED)
15690 switch (actual_drawing_function)
15692 case GADGET_ID_SINGLE_ITEMS:
15693 text = "Drawing single items";
15695 case GADGET_ID_CONNECTED_ITEMS:
15696 text = "Drawing connected items";
15698 case GADGET_ID_LINE:
15699 text = "Drawing line";
15701 case GADGET_ID_ARC:
15702 text = "Drawing arc";
15704 case GADGET_ID_TEXT:
15705 text = "Setting text cursor";
15707 case GADGET_ID_RECTANGLE:
15708 text = "Drawing rectangle";
15710 case GADGET_ID_FILLED_BOX:
15711 text = "Drawing filled box";
15713 case GADGET_ID_FLOOD_FILL:
15714 text = "Flood fill";
15716 case GADGET_ID_GRAB_BRUSH:
15717 text = "Grabbing brush";
15719 case GADGET_ID_PICK_ELEMENT:
15720 text = "Picking element";
15724 text = "Drawing position";
15728 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15729 sprintf(infotext, "%s: %d, %d", text, lx, ly);
15731 sprintf(infotext, "%s: %d, %d", text,
15732 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
15734 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15735 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
15737 sprintf(infotext, "Level position: %d, %d", lx, ly);
15740 // misuse this function to draw brush cursor, if needed
15741 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
15743 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15744 CopyBrushToCursor(sx, sy);
15746 DeleteBrushFromCursor();
15749 if (!draw_with_brush)
15750 UpdateBrushPosition(sx, sy);
15752 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15754 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
15755 int element = drawingarea_info[type_id].value[pos];
15757 strncpy(infotext, getElementInfoText(element), max_infotext_len);
15761 if (id == GADGET_ID_CUSTOM_CONTENT)
15762 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
15763 else if (id == GADGET_ID_GROUP_CONTENT)
15764 sprintf(infotext, "group element position: %d", sx + 1);
15765 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
15766 id <= GADGET_ID_YAMYAM_CONTENT_7)
15767 sprintf(infotext, "content area %d position: %d, %d",
15768 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
15769 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
15770 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
15771 sprintf(infotext, "content area %d position: %d, %d",
15772 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
15773 else if (id == GADGET_ID_ANDROID_CONTENT)
15774 sprintf(infotext, "android element position: %d", sx + 1);
15775 else if (drawingarea_info[type_id].infotext != NULL)
15776 strcpy(infotext, drawingarea_info[type_id].infotext);
15779 infotext[max_infotext_len] = '\0';
15781 if (strlen(infotext) > 0)
15782 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
15785 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
15786 boolean quick_quit)
15788 if (!ask_if_level_has_changed ||
15790 Request("Level has changed! Exit without saving?",
15791 REQ_ASK | REQ_STAY_OPEN))
15793 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
15794 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
15796 // draw normal door
15797 UndrawSpecialEditorDoor();
15799 // use door animation if door 1 viewport is unchanged and contains toolbox
15800 if (useEditorDoorAnimation())
15801 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
15803 // close editor doors if viewport definition is the same as in main menu
15804 if (vp_door_1->x == DX &&
15805 vp_door_1->y == DY &&
15806 vp_door_1->width == DXSIZE &&
15807 vp_door_1->height == DYSIZE &&
15808 vp_door_2->x == VX &&
15809 vp_door_2->y == VY &&
15810 vp_door_2->width == VXSIZE &&
15811 vp_door_2->height == VYSIZE)
15812 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
15814 SetDoorState(DOOR_CLOSE_ALL);
15819 FadeSkipNextFadeIn();
15821 SetGameStatus(GAME_MODE_MAIN);
15827 if (!global.use_envelope_request)
15829 CloseDoor(DOOR_CLOSE_1);
15830 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);