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_BD_SCHEDULING_TYPE,
575 GADGET_ID_LEVELSET_SAVE_MODE,
576 GADGET_ID_WIND_DIRECTION,
577 GADGET_ID_PLAYER_SPEED,
578 GADGET_ID_MM_BALL_CHOICE_MODE,
579 GADGET_ID_CUSTOM_WALK_TO_ACTION,
580 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
581 GADGET_ID_CUSTOM_DEADLINESS,
582 GADGET_ID_CUSTOM_MOVE_PATTERN,
583 GADGET_ID_CUSTOM_MOVE_DIRECTION,
584 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
585 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
586 GADGET_ID_CUSTOM_SMASH_TARGETS,
587 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
588 GADGET_ID_CUSTOM_ACCESS_TYPE,
589 GADGET_ID_CUSTOM_ACCESS_LAYER,
590 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
591 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
592 GADGET_ID_CHANGE_TIME_UNITS,
593 GADGET_ID_CHANGE_DIRECT_ACTION,
594 GADGET_ID_CHANGE_OTHER_ACTION,
595 GADGET_ID_CHANGE_SIDE,
596 GADGET_ID_CHANGE_PLAYER,
597 GADGET_ID_CHANGE_PAGE,
598 GADGET_ID_CHANGE_REPLACE_WHEN,
599 GADGET_ID_ACTION_TYPE,
600 GADGET_ID_ACTION_MODE,
601 GADGET_ID_ACTION_ARG,
602 GADGET_ID_SELECT_CHANGE_PAGE,
603 GADGET_ID_GROUP_CHOICE_MODE,
605 // textbutton identifiers
607 GADGET_ID_LEVELCONFIG_LEVEL,
608 GADGET_ID_LEVELCONFIG_LEVELSET,
609 GADGET_ID_LEVELCONFIG_EDITOR,
610 GADGET_ID_LEVELCONFIG_ENGINE,
611 GADGET_ID_PROPERTIES_INFO,
612 GADGET_ID_PROPERTIES_CONFIG,
613 GADGET_ID_PROPERTIES_CONFIG_1,
614 GADGET_ID_PROPERTIES_CONFIG_2,
615 GADGET_ID_PROPERTIES_CHANGE,
616 GADGET_ID_SAVE_AS_TEMPLATE_1,
617 GADGET_ID_SAVE_AS_TEMPLATE_2,
618 GADGET_ID_SAVE_LEVELSET,
619 GADGET_ID_ADD_CHANGE_PAGE,
620 GADGET_ID_DEL_CHANGE_PAGE,
622 // graphicbutton identifiers
624 GADGET_ID_PREV_CHANGE_PAGE,
625 GADGET_ID_NEXT_CHANGE_PAGE,
626 GADGET_ID_COPY_CHANGE_PAGE,
627 GADGET_ID_PASTE_CHANGE_PAGE,
629 // gadgets for scrolling of drawing area
632 GADGET_ID_SCROLL_DOWN,
633 GADGET_ID_SCROLL_LEFT,
634 GADGET_ID_SCROLL_RIGHT,
635 GADGET_ID_SCROLL_HORIZONTAL,
636 GADGET_ID_SCROLL_VERTICAL,
638 // gadgets for scrolling element list
640 GADGET_ID_SCROLL_LIST_UP,
641 GADGET_ID_SCROLL_LIST_DOWN,
642 GADGET_ID_SCROLL_LIST_VERTICAL,
644 // checkbuttons/radiobuttons for level/element properties
646 GADGET_ID_AUTO_COUNT_GEMS,
647 GADGET_ID_RATE_TIME_OVER_SCORE,
648 GADGET_ID_USE_LEVELSET_ARTWORK,
649 GADGET_ID_COPY_LEVEL_TEMPLATE,
650 GADGET_ID_RANDOM_PERCENTAGE,
651 GADGET_ID_RANDOM_QUANTITY,
652 GADGET_ID_RANDOM_RESTRICTED,
653 GADGET_ID_BD_INTERMISSION,
654 GADGET_ID_BD_PAL_TIMING,
655 GADGET_ID_STICK_ELEMENT,
656 GADGET_ID_EM_SLIPPERY_GEMS,
657 GADGET_ID_EM_EXPLODES_BY_FIRE,
658 GADGET_ID_USE_SPRING_BUG,
659 GADGET_ID_USE_TIME_ORB_BUG,
660 GADGET_ID_USE_LIFE_BUGS,
661 GADGET_ID_RANDOM_BALL_CONTENT,
662 GADGET_ID_INITIAL_BALL_ACTIVE,
663 GADGET_ID_GROW_INTO_DIGGABLE,
664 GADGET_ID_SB_FIELDS_NEEDED,
665 GADGET_ID_SB_OBJECTS_NEEDED,
666 GADGET_ID_AUTO_EXIT_SOKOBAN,
667 GADGET_ID_SOLVED_BY_ONE_PLAYER,
668 GADGET_ID_FINISH_DIG_COLLECT,
669 GADGET_ID_KEEP_WALKABLE_CE,
670 GADGET_ID_CONTINUOUS_SNAPPING,
671 GADGET_ID_BLOCK_SNAP_FIELD,
672 GADGET_ID_BLOCK_LAST_FIELD,
673 GADGET_ID_SP_BLOCK_LAST_FIELD,
674 GADGET_ID_INSTANT_RELOCATION,
675 GADGET_ID_SHIFTED_RELOCATION,
676 GADGET_ID_LAZY_RELOCATION,
677 GADGET_ID_USE_START_ELEMENT,
678 GADGET_ID_USE_ARTWORK_ELEMENT,
679 GADGET_ID_USE_EXPLOSION_ELEMENT,
680 GADGET_ID_INITIAL_GRAVITY,
681 GADGET_ID_USE_INITIAL_INVENTORY,
682 GADGET_ID_CAN_PASS_TO_WALKABLE,
683 GADGET_ID_CAN_FALL_INTO_ACID,
684 GADGET_ID_CAN_MOVE_INTO_ACID,
685 GADGET_ID_DONT_COLLIDE_WITH,
686 GADGET_ID_BD_DIAGONAL_MOVEMENTS,
687 GADGET_ID_ENVELOPE_AUTOWRAP,
688 GADGET_ID_ENVELOPE_CENTERED,
689 GADGET_ID_MM_LASER_RED,
690 GADGET_ID_MM_LASER_GREEN,
691 GADGET_ID_MM_LASER_BLUE,
692 GADGET_ID_DF_LASER_RED,
693 GADGET_ID_DF_LASER_GREEN,
694 GADGET_ID_DF_LASER_BLUE,
695 GADGET_ID_ROTATE_MM_BALL_CONTENT,
696 GADGET_ID_EXPLODE_MM_BALL,
697 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
698 GADGET_ID_CUSTOM_CAN_EXPLODE,
699 GADGET_ID_CUSTOM_EXPLODE_FIRE,
700 GADGET_ID_CUSTOM_EXPLODE_SMASH,
701 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
702 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
703 GADGET_ID_CUSTOM_DEADLY,
704 GADGET_ID_CUSTOM_CAN_MOVE,
705 GADGET_ID_CUSTOM_CAN_FALL,
706 GADGET_ID_CUSTOM_CAN_SMASH,
707 GADGET_ID_CUSTOM_SLIPPERY,
708 GADGET_ID_CUSTOM_ACCESSIBLE,
709 GADGET_ID_CUSTOM_GRAV_REACHABLE,
710 GADGET_ID_CUSTOM_USE_LAST_VALUE,
711 GADGET_ID_CUSTOM_USE_GRAPHIC,
712 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
713 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
714 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
715 GADGET_ID_CUSTOM_CAN_CHANGE,
716 GADGET_ID_CHANGE_USE_CONTENT,
717 GADGET_ID_CHANGE_USE_EXPLOSION,
718 GADGET_ID_CHANGE_ONLY_COMPLETE,
719 GADGET_ID_CHANGE_USE_RANDOM,
720 GADGET_ID_CHANGE_HAS_ACTION,
721 GADGET_ID_CHANGE_DELAY,
722 GADGET_ID_CHANGE_BY_DIRECT_ACT,
723 GADGET_ID_CHANGE_BY_OTHER_ACT,
725 NUM_STATIC_GADGET_IDS
728 // gadgets for buttons in element list (dynamic)
729 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
730 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
731 ED_NUM_ELEMENTLIST_BUTTONS - 1)
733 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
735 // radio button numbers
739 RADIO_NR_DRAWING_TOOLBOX,
740 RADIO_NR_RANDOM_ELEMENTS
743 // values for counter gadgets
746 ED_COUNTER_ID_SELECT_LEVEL,
747 ED_COUNTER_ID_LEVEL_XSIZE,
748 ED_COUNTER_ID_LEVEL_YSIZE,
749 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
750 ED_COUNTER_ID_LEVEL_TIMELIMIT,
751 ED_COUNTER_ID_LEVEL_TIMESCORE,
752 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
753 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
754 ED_COUNTER_ID_LEVEL_RANDOM,
755 ED_COUNTER_ID_ELEMENT_VALUE1,
756 ED_COUNTER_ID_ELEMENT_VALUE2,
757 ED_COUNTER_ID_ELEMENT_VALUE3,
758 ED_COUNTER_ID_ELEMENT_VALUE4,
759 ED_COUNTER_ID_YAMYAM_CONTENT,
760 ED_COUNTER_ID_BALL_CONTENT,
761 ED_COUNTER_ID_ANDROID_CONTENT,
762 ED_COUNTER_ID_ENVELOPE_XSIZE,
763 ED_COUNTER_ID_ENVELOPE_YSIZE,
764 ED_COUNTER_ID_INVENTORY_SIZE,
765 ED_COUNTER_ID_MM_BALL_CONTENT,
766 ED_COUNTER_ID_CUSTOM_SCORE,
767 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
768 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
769 ED_COUNTER_ID_CUSTOM_VALUE_RND,
770 ED_COUNTER_ID_PUSH_DELAY_FIX,
771 ED_COUNTER_ID_PUSH_DELAY_RND,
772 ED_COUNTER_ID_DROP_DELAY_FIX,
773 ED_COUNTER_ID_DROP_DELAY_RND,
774 ED_COUNTER_ID_MOVE_DELAY_FIX,
775 ED_COUNTER_ID_MOVE_DELAY_RND,
776 ED_COUNTER_ID_STEP_DELAY_FIX,
777 ED_COUNTER_ID_STEP_DELAY_RND,
778 ED_COUNTER_ID_EXPLOSION_DELAY,
779 ED_COUNTER_ID_IGNITION_DELAY,
780 ED_COUNTER_ID_GROUP_CONTENT,
781 ED_COUNTER_ID_CHANGE_DELAY_FIX,
782 ED_COUNTER_ID_CHANGE_DELAY_RND,
783 ED_COUNTER_ID_CHANGE_CONT_RND,
785 ED_NUM_COUNTERBUTTONS
788 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
789 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
790 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
791 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
792 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
793 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
795 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
796 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
797 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
798 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
799 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
800 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
802 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
803 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
805 // values for scrollbutton gadgets
808 ED_SCROLLBUTTON_ID_AREA_UP,
809 ED_SCROLLBUTTON_ID_AREA_DOWN,
810 ED_SCROLLBUTTON_ID_AREA_LEFT,
811 ED_SCROLLBUTTON_ID_AREA_RIGHT,
812 ED_SCROLLBUTTON_ID_LIST_UP,
813 ED_SCROLLBUTTON_ID_LIST_DOWN,
818 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
819 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
821 // values for scrollbar gadgets
824 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
825 ED_SCROLLBAR_ID_AREA_VERTICAL,
826 ED_SCROLLBAR_ID_LIST_VERTICAL,
831 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
832 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
834 // values for text input gadgets
837 ED_TEXTINPUT_ID_LEVEL_NAME,
838 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
839 ED_TEXTINPUT_ID_LEVELSET_NAME,
840 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
841 ED_TEXTINPUT_ID_ELEMENT_NAME,
846 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
847 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
849 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
850 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
852 // values for text area gadgets
855 ED_TEXTAREA_ID_ENVELOPE_INFO,
860 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
861 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
863 // values for selectbox gadgets
866 ED_SELECTBOX_ID_TIME_OR_STEPS,
867 ED_SELECTBOX_ID_TIME_SCORE_BASE,
868 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
869 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
870 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
871 ED_SELECTBOX_ID_WIND_DIRECTION,
872 ED_SELECTBOX_ID_PLAYER_SPEED,
873 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
874 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
875 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
876 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
877 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
878 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
879 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
880 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
881 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
882 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
883 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
884 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
885 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
886 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
887 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
888 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
889 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
890 ED_SELECTBOX_ID_CHANGE_SIDE,
891 ED_SELECTBOX_ID_CHANGE_PLAYER,
892 ED_SELECTBOX_ID_CHANGE_PAGE,
893 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
894 ED_SELECTBOX_ID_ACTION_TYPE,
895 ED_SELECTBOX_ID_ACTION_MODE,
896 ED_SELECTBOX_ID_ACTION_ARG,
897 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
898 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
903 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
904 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
906 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
907 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
909 #define ED_SELECTBOX_ID_ENGINE_FIRST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
910 #define ED_SELECTBOX_ID_ENGINE_LAST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
912 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
913 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
914 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
915 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
916 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
917 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
919 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
920 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
922 // values for textbutton gadgets
925 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
926 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
927 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
928 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
929 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
930 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
931 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
932 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
933 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
934 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
935 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
936 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
937 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
938 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
943 #define ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
944 #define ED_TAB_BUTTON_ID_LEVELCONFIG_LAST ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
946 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
947 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
949 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
950 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
952 // values for graphicbutton gadgets
955 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
956 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
957 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
958 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
960 ED_NUM_GRAPHICBUTTONS
963 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
964 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
966 // values for checkbutton gadgets
969 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
970 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
971 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
972 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
973 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
974 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
975 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
976 ED_CHECKBUTTON_ID_BD_INTERMISSION,
977 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
978 ED_CHECKBUTTON_ID_STICK_ELEMENT,
979 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
980 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
981 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
982 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
983 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
984 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
985 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
986 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
987 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
988 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
989 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
990 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
991 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
992 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
993 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
994 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
995 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
996 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
997 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
998 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
999 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
1000 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
1001 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
1002 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
1003 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
1004 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
1005 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
1006 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
1007 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
1008 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
1009 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
1010 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
1011 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
1012 ED_CHECKBUTTON_ID_MM_LASER_RED,
1013 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
1014 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1015 ED_CHECKBUTTON_ID_DF_LASER_RED,
1016 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1017 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1018 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
1019 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
1020 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1021 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1022 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1023 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1024 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1025 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1026 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1027 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1028 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1029 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1030 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1031 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1032 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1033 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1034 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1035 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1036 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1037 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1038 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1039 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1040 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1041 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1042 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1043 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1044 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1049 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1050 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1052 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1053 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1055 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1056 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1058 #define ED_CHECKBUTTON_ID_ENGINE_FIRST ED_CHECKBUTTON_ID_BD_INTERMISSION
1059 #define ED_CHECKBUTTON_ID_ENGINE_LAST ED_CHECKBUTTON_ID_BD_PAL_TIMING
1061 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1062 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1063 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1064 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1065 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1066 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1068 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1069 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1071 // values for radiobutton gadgets
1074 ED_RADIOBUTTON_ID_PERCENTAGE,
1075 ED_RADIOBUTTON_ID_QUANTITY,
1080 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1081 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1083 // values for drawing area gadgets
1086 ED_DRAWING_ID_DRAWING_LEVEL,
1087 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1088 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1089 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1090 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1091 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1092 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1093 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1094 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1095 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1096 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1097 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1098 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1099 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1100 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1101 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1102 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1103 ED_DRAWING_ID_ANDROID_CONTENT,
1104 ED_DRAWING_ID_AMOEBA_CONTENT,
1105 ED_DRAWING_ID_START_ELEMENT,
1106 ED_DRAWING_ID_ARTWORK_ELEMENT,
1107 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1108 ED_DRAWING_ID_INVENTORY_CONTENT,
1109 ED_DRAWING_ID_MM_BALL_CONTENT,
1110 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1111 ED_DRAWING_ID_CUSTOM_CONTENT,
1112 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1113 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1114 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1115 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1116 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1117 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1118 ED_DRAWING_ID_GROUP_CONTENT,
1119 ED_DRAWING_ID_RANDOM_BACKGROUND,
1121 ED_NUM_DRAWING_AREAS
1124 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1125 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1128 // ----------------------------------------------------------------------------
1129 // some internally used definitions
1130 // ----------------------------------------------------------------------------
1132 // values for CopyLevelToUndoBuffer()
1133 #define UNDO_IMMEDIATE 0
1134 #define UNDO_ACCUMULATE 1
1136 // values for scrollbars
1137 #define ED_SCROLL_NO 0
1138 #define ED_SCROLL_LEFT 1
1139 #define ED_SCROLL_RIGHT 2
1140 #define ED_SCROLL_UP 4
1141 #define ED_SCROLL_DOWN 8
1143 // screens in the level editor
1144 #define ED_MODE_DRAWING 0
1145 #define ED_MODE_LEVELCONFIG 1
1146 #define ED_MODE_PROPERTIES 2
1147 #define ED_MODE_PALETTE 3
1149 // sub-screens in the global settings section
1150 #define ED_MODE_LEVELCONFIG_LEVEL ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
1151 #define ED_MODE_LEVELCONFIG_LEVELSET ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET
1152 #define ED_MODE_LEVELCONFIG_EDITOR ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
1153 #define ED_MODE_LEVELCONFIG_ENGINE ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
1155 // sub-screens in the element properties section
1156 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1157 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1158 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1159 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1160 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1162 // how many steps can be cancelled
1163 #define NUM_UNDO_STEPS (64 + 1)
1165 // values for elements with score for certain actions
1167 #define MAX_SCORE 999
1169 // values for elements with count for collecting
1170 #define MIN_COLLECT_COUNT 0
1171 #define MAX_COLLECT_COUNT 999
1173 // values for random placement
1174 #define RANDOM_USE_PERCENTAGE 0
1175 #define RANDOM_USE_QUANTITY 1
1177 // values for level set save mode
1178 #define LEVELSET_SAVE_MODE_UPDATE 0
1179 #define LEVELSET_SAVE_MODE_CREATE 1
1181 // default value for element tile size in drawing area
1182 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1183 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1186 // ----------------------------------------------------------------------------
1187 // some internally used data structure definitions
1188 // ----------------------------------------------------------------------------
1194 struct XYTileSize *pos;
1198 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1200 // note: some additional characters are already reserved for "cheat mode"
1201 // shortcuts (":XYZ" style) -- for details, see "events.c"
1203 // ---------- toolbox control buttons ---------------------------------------
1206 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1207 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1208 "draw single items", 's'
1211 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1212 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1213 "draw connected items", 'd'
1216 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1217 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1221 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1222 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1226 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1227 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1228 "draw outline rectangles", 'r'
1231 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1232 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1233 "draw filled rectangles", 'R'
1236 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1237 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1238 "wrap (rotate) level up", 0
1241 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1242 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1243 "enter text elements", 't'
1246 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1247 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1251 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1252 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1253 "wrap (rotate) level left", 0
1256 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1257 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1258 "zoom level tile size", '+'
1261 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1262 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1263 "wrap (rotate) level right", 0
1266 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1267 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1268 "random element placement", 0
1271 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1272 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1276 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1277 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1278 "wrap (rotate) level down", 0
1281 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1282 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1283 "pick drawing element", ','
1286 // ---------- level control buttons -----------------------------------------
1289 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1290 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1291 "undo/redo last operation", 'u'
1294 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_CONF,
1295 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1296 "level and editor settings", 'I'
1299 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1300 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1304 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1305 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1309 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1310 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1314 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1315 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1316 "exit level editor", 'E'
1319 // ---------- CE and GE control buttons -------------------------------------
1322 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1323 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1324 "copy settings from other element", 0
1327 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1328 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1329 "copy settings to other element", 0
1332 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1333 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1334 "exchange element with other element", 0
1337 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1338 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1339 "copy settings from this element", 0
1342 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1343 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1344 "paste settings to this element", 0
1347 // ---------- palette control buttons ---------------------------------------
1350 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1351 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1352 "properties of drawing element", 'p'
1355 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1356 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1357 "properties of drawing element 1", '1'
1360 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1361 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1362 "properties of drawing element 2", '2'
1365 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1366 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1367 "properties of drawing element 3", '3'
1370 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1371 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1372 "show list of elements", 'e'
1376 static int random_placement_value = 10;
1377 static int random_placement_method = RANDOM_USE_QUANTITY;
1378 static int random_placement_background_element = EL_SAND;
1379 static boolean random_placement_background_restricted = FALSE;
1380 static boolean stick_element_properties_window = FALSE;
1381 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1382 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1383 static struct ElementChangeInfo custom_element_change;
1384 static struct ElementGroupInfo group_element_info;
1385 static struct ElementInfo custom_element;
1387 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1388 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1389 static int levelset_num_levels = 100;
1390 static boolean levelset_use_levelset_artwork = FALSE;
1391 static boolean levelset_copy_level_template = FALSE;
1392 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1398 int min_value, max_value;
1399 int gadget_id_down, gadget_id_up;
1401 int gadget_id_align;
1403 char *text_above, *text_left, *text_right;
1404 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1406 // ---------- current level number ------------------------------------------
1409 ED_COUNTER_ID_SELECT_LEVEL,
1410 -1, -1, // these values are not constant, but can change at runtime
1412 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1413 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1418 // ---------- level and editor settings -------------------------------------
1421 ED_COUNTER_ID_LEVEL_XSIZE,
1422 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1423 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1424 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1425 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1427 "playfield size:", NULL, "width",
1430 ED_COUNTER_ID_LEVEL_YSIZE,
1431 -1, ED_LEVEL_SETTINGS_YPOS(4),
1432 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1433 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1434 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1436 NULL, " ", "height",
1439 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
1440 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1442 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1443 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1445 NULL, "number of gems to collect:", NULL
1448 ED_COUNTER_ID_LEVEL_TIMELIMIT,
1449 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1451 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1452 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1454 "time or step limit to solve level:", NULL, NULL
1457 ED_COUNTER_ID_LEVEL_TIMESCORE,
1458 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1460 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1461 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1462 &level.score[SC_TIME_BONUS],
1463 "score for time or steps left:", NULL, NULL
1466 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
1467 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1469 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1470 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1472 NULL, "random seed:", "(0 => random)"
1475 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
1476 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1478 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1479 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1480 &levelset_num_levels,
1481 "number of levels:", NULL, NULL,
1484 ED_COUNTER_ID_LEVEL_RANDOM,
1485 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1487 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1488 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1489 &random_placement_value,
1490 "random element placement:", NULL, "in"
1493 // ---------- element settings: configure (various elements) ----------------
1496 ED_COUNTER_ID_ELEMENT_VALUE1,
1497 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1498 MIN_SCORE, MAX_SCORE,
1499 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1500 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1501 NULL, // will be set when used
1505 ED_COUNTER_ID_ELEMENT_VALUE2,
1506 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1507 MIN_SCORE, MAX_SCORE,
1508 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1509 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1510 NULL, // will be set when used
1514 ED_COUNTER_ID_ELEMENT_VALUE3,
1515 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1516 MIN_SCORE, MAX_SCORE,
1517 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1518 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1519 NULL, // will be set when used
1523 ED_COUNTER_ID_ELEMENT_VALUE4,
1524 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1525 MIN_SCORE, MAX_SCORE,
1526 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1527 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1528 NULL, // will be set when used
1532 ED_COUNTER_ID_YAMYAM_CONTENT,
1533 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1534 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1535 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1536 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1537 &level.num_yamyam_contents,
1538 NULL, NULL, "number of content areas"
1541 ED_COUNTER_ID_BALL_CONTENT,
1542 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1543 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1544 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1545 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1546 &level.num_ball_contents,
1547 NULL, NULL, "number of content areas"
1550 ED_COUNTER_ID_ANDROID_CONTENT,
1551 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1552 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1553 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1554 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1555 &level.num_android_clone_elements,
1556 NULL, NULL, "number of clonable elements"
1559 ED_COUNTER_ID_ENVELOPE_XSIZE,
1560 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1561 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1562 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1563 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1564 NULL, // will be set when used
1565 NULL, NULL, "width",
1568 ED_COUNTER_ID_ENVELOPE_YSIZE,
1569 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1570 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1571 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1572 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1573 NULL, // will be set when used
1574 NULL, " ", "height",
1577 ED_COUNTER_ID_INVENTORY_SIZE,
1578 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1579 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1580 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1581 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1582 &level.initial_inventory_size[0],
1583 NULL, NULL, "number of inventory elements"
1586 ED_COUNTER_ID_MM_BALL_CONTENT,
1587 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1588 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1589 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1590 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1591 &level.num_mm_ball_contents,
1592 NULL, NULL, "number of content elements"
1595 // ---------- element settings: configure 1 (custom elements) ---------------
1598 ED_COUNTER_ID_CUSTOM_SCORE,
1599 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1600 MIN_SCORE, MAX_SCORE,
1601 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1602 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1603 &custom_element.collect_score_initial,
1604 NULL, "CE score", " "
1607 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
1608 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1609 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1610 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1611 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1612 &custom_element.collect_count_initial,
1613 NULL, "CE count", NULL
1616 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
1617 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1619 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1620 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1621 &custom_element.ce_value_fixed_initial,
1622 NULL, "CE value", NULL
1625 ED_COUNTER_ID_CUSTOM_VALUE_RND,
1626 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1628 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1629 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1630 &custom_element.ce_value_random_initial,
1631 NULL, "+random", NULL
1634 ED_COUNTER_ID_PUSH_DELAY_FIX,
1635 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1637 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1638 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1639 &custom_element.push_delay_fixed,
1640 NULL, "push delay", NULL
1643 ED_COUNTER_ID_PUSH_DELAY_RND,
1644 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1646 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1647 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1648 &custom_element.push_delay_random,
1649 NULL, "+random", NULL
1652 ED_COUNTER_ID_DROP_DELAY_FIX,
1653 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1655 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1656 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1657 &custom_element.drop_delay_fixed,
1658 NULL, "drop delay", NULL
1661 ED_COUNTER_ID_DROP_DELAY_RND,
1662 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1664 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1665 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1666 &custom_element.drop_delay_random,
1667 NULL, "+random", NULL
1670 // ---------- element settings: configure 2 (custom elements) ---------------
1673 ED_COUNTER_ID_MOVE_DELAY_FIX,
1674 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1676 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1677 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1678 &custom_element.move_delay_fixed,
1679 NULL, "move delay", NULL
1682 ED_COUNTER_ID_MOVE_DELAY_RND,
1683 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1685 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1686 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1687 &custom_element.move_delay_random,
1688 NULL, "+random", NULL
1691 ED_COUNTER_ID_STEP_DELAY_FIX,
1692 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1694 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1695 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1696 &custom_element.step_delay_fixed,
1697 NULL, "step delay", NULL
1700 ED_COUNTER_ID_STEP_DELAY_RND,
1701 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1703 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1704 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1705 &custom_element.step_delay_random,
1706 NULL, "+random", NULL
1709 ED_COUNTER_ID_EXPLOSION_DELAY,
1710 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1712 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1713 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1714 &custom_element.explosion_delay,
1715 NULL, "explosion delay", NULL
1718 ED_COUNTER_ID_IGNITION_DELAY,
1719 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1721 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1722 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1723 &custom_element.ignition_delay,
1724 NULL, "ignition delay", "(by fire)"
1727 // ---------- element settings: configure (group elements) ------------------
1730 ED_COUNTER_ID_GROUP_CONTENT,
1731 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1732 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1733 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1734 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1735 &group_element_info.num_elements,
1736 NULL, NULL, "number of elements in group"
1739 // ---------- element settings: advanced (custom elements) ------------------
1742 ED_COUNTER_ID_CHANGE_DELAY_FIX,
1743 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1745 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1746 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1747 &custom_element_change.delay_fixed,
1748 NULL, "CE delay", NULL,
1751 ED_COUNTER_ID_CHANGE_DELAY_RND,
1752 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1754 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1755 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1756 &custom_element_change.delay_random,
1757 NULL, "+random", NULL
1760 ED_COUNTER_ID_CHANGE_CONT_RND,
1761 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1763 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1764 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1765 &custom_element_change.random_percentage,
1766 NULL, "use random replace:", "%"
1777 char *text_above, *infotext;
1778 } textinput_info[ED_NUM_TEXTINPUT] =
1781 ED_TEXTINPUT_ID_LEVEL_NAME,
1782 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1783 GADGET_ID_LEVEL_NAME,
1786 "Title:", "Title for this level"
1789 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
1790 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1791 GADGET_ID_LEVEL_AUTHOR,
1792 MAX_LEVEL_AUTHOR_LEN,
1794 "Author:", "Author for this level"
1797 ED_TEXTINPUT_ID_LEVELSET_NAME,
1798 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1799 GADGET_ID_LEVELSET_NAME,
1802 "Title:", "Title for this or new level set"
1805 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
1806 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1807 GADGET_ID_LEVELSET_AUTHOR,
1808 MAX_LEVEL_AUTHOR_LEN,
1810 "Author:", "Author for this or new level set"
1813 ED_TEXTINPUT_ID_ELEMENT_NAME,
1814 -1, -1, // these values are not constant, but can change at runtime
1815 GADGET_ID_ELEMENT_NAME,
1816 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1817 custom_element.description,
1818 NULL, "Element name"
1829 char *text_above, *text_above_cropped, *infotext;
1830 } textarea_info[ED_NUM_TEXTAREAS] =
1833 ED_TEXTAREA_ID_ENVELOPE_INFO,
1834 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1835 GADGET_ID_ENVELOPE_INFO,
1836 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1838 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1842 static struct ValueTextInfo options_time_or_steps[] =
1850 static struct ValueTextInfo options_time_score_base[] =
1852 { 1, "per second/step" },
1853 { 10, "per 10 seconds/steps" },
1858 static struct ValueTextInfo options_game_engine_type[] =
1860 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1861 { GAME_ENGINE_TYPE_BD, "Boulder Dash" },
1862 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1863 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1864 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1869 static struct ValueTextInfo options_levelset_save_mode[] =
1871 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1872 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1877 static struct ValueTextInfo options_wind_direction[] =
1879 { MV_START_NONE, "none" },
1880 { MV_START_LEFT, "left" },
1881 { MV_START_RIGHT, "right" },
1882 { MV_START_UP, "up" },
1883 { MV_START_DOWN, "down" },
1888 static struct ValueTextInfo options_player_speed[] =
1895 { 16, "very fast" },
1896 { 32, "ultrafast" },
1901 static struct ValueTextInfo options_access_type[] =
1903 { EP_WALKABLE, "walkable" },
1904 { EP_PASSABLE, "passable" },
1909 static struct ValueTextInfo options_access_layer[] =
1911 { EP_ACCESSIBLE_OVER, "over" },
1912 { EP_ACCESSIBLE_INSIDE, "inside" },
1913 { EP_ACCESSIBLE_UNDER, "under" },
1918 static struct ValueTextInfo options_access_protected[] =
1920 { 0, "unprotected" },
1926 static struct ValueTextInfo options_access_direction[] =
1928 { MV_NO_DIRECTION, "no direction" },
1929 { MV_LEFT, "left" },
1930 { MV_RIGHT, "right" },
1932 { MV_DOWN, "down" },
1933 { MV_LEFT | MV_UP, "left + up" },
1934 { MV_LEFT | MV_DOWN, "left + down" },
1935 { MV_RIGHT | MV_UP, "right + up" },
1936 { MV_RIGHT | MV_DOWN, "right + down" },
1937 { MV_HORIZONTAL, "horizontal" },
1938 { MV_VERTICAL, "vertical" },
1939 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1940 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1941 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1942 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1943 { MV_ALL_DIRECTIONS, "all directions" },
1948 static struct ValueTextInfo options_walk_to_action[] =
1950 { EP_DIGGABLE, "diggable" },
1951 { EP_COLLECTIBLE_ONLY, "collectible" },
1952 { EP_DROPPABLE, "collectible & droppable" },
1953 { EP_THROWABLE, "collectible & throwable" },
1954 { EP_PUSHABLE, "pushable" },
1959 static struct ValueTextInfo options_move_pattern[] =
1961 { MV_LEFT, "left" },
1962 { MV_RIGHT, "right" },
1964 { MV_DOWN, "down" },
1965 { MV_HORIZONTAL, "horizontal" },
1966 { MV_VERTICAL, "vertical" },
1967 { MV_ALL_DIRECTIONS, "all directions" },
1968 { MV_WIND_DIRECTION, "wind direction" },
1969 { MV_TOWARDS_PLAYER, "towards player" },
1970 { MV_AWAY_FROM_PLAYER, "away from player" },
1971 { MV_ALONG_LEFT_SIDE, "along left side" },
1972 { MV_ALONG_RIGHT_SIDE, "along right side" },
1973 { MV_TURNING_LEFT, "turning left" },
1974 { MV_TURNING_RIGHT, "turning right" },
1975 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1976 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1977 { MV_TURNING_RANDOM, "turning random" },
1978 { MV_MAZE_RUNNER, "maze runner style" },
1979 { MV_MAZE_HUNTER, "maze hunter style" },
1980 { MV_WHEN_PUSHED, "when pushed" },
1981 { MV_WHEN_DROPPED, "when dropped/thrown" },
1986 static struct ValueTextInfo options_move_direction[] =
1988 { MV_START_AUTOMATIC, "automatic" },
1989 { MV_START_LEFT, "left" },
1990 { MV_START_RIGHT, "right" },
1991 { MV_START_UP, "up" },
1992 { MV_START_DOWN, "down" },
1993 { MV_START_RANDOM, "random" },
1994 { MV_START_PREVIOUS, "previous" },
1999 static struct ValueTextInfo options_move_stepsize[] =
2001 { 0, "not moving" },
2006 { 16, "very fast" },
2007 { 32, "even faster" },
2012 static struct ValueTextInfo options_move_leave_type[] =
2014 { LEAVE_TYPE_UNLIMITED, "leave behind" },
2015 { LEAVE_TYPE_LIMITED, "change it to" },
2020 static struct ValueTextInfo options_smash_targets[] =
2022 { EP_CAN_SMASH_PLAYER, "player" },
2024 { EP_CAN_SMASH_ENEMIES, "enemies" },
2026 { EP_CAN_SMASH_EVERYTHING, "everything" },
2031 static struct ValueTextInfo options_slippery_type[] =
2033 { SLIPPERY_ANY_RANDOM, "random" },
2034 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
2035 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
2036 { SLIPPERY_ONLY_LEFT, "only left" },
2037 { SLIPPERY_ONLY_RIGHT, "only right" },
2042 static struct ValueTextInfo options_deadliness[] =
2044 { EP_DONT_RUN_INTO, "running into" },
2045 { EP_DONT_COLLIDE_WITH, "colliding with" },
2046 { EP_DONT_GET_HIT_BY, "getting hit by" },
2047 { EP_DONT_TOUCH, "touching" },
2052 static struct ValueTextInfo options_explosion_type[] =
2054 { EXPLODES_3X3, "3x3" },
2055 { EXPLODES_CROSS, "3+3" },
2056 { EXPLODES_1X1, "1x1" },
2061 static struct ValueTextInfo options_time_units[] =
2064 { FRAMES_PER_SECOND, "seconds" },
2069 static struct ValueTextInfo options_change_direct_action[] =
2071 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2072 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2073 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2074 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2075 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2076 { CE_ENTERED_BY_PLAYER, "entered by player" },
2077 { CE_LEFT_BY_PLAYER, "left by player" },
2078 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2079 { CE_SWITCHED, "switched" },
2080 { CE_HITTING_SOMETHING, "hitting something" },
2081 { CE_HIT_BY_SOMETHING, "hit by something" },
2083 { CE_BLOCKED, "blocked" },
2085 { CE_IMPACT, "impact (on something)" },
2086 { CE_SMASHED, "smashed (from above)" },
2088 { CE_VALUE_CHANGES, "CE value changes" },
2089 { CE_SCORE_CHANGES, "CE score changes" },
2091 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2092 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2093 { CE_UNDEFINED, " " },
2094 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2095 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2096 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2097 { CE_UNDEFINED, " " },
2098 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2099 { CE_NEXT_TO_PLAYER, "next to player" },
2104 static struct ValueTextInfo options_change_other_action[] =
2106 { CE_PLAYER_TOUCHES_X, "player touches" },
2107 { CE_PLAYER_PRESSES_X, "player presses" },
2108 { CE_PLAYER_SWITCHES_X, "player switches" },
2109 { CE_PLAYER_SNAPS_X, "player snaps" },
2110 { CE_PLAYER_PUSHES_X, "player pushes" },
2111 { CE_PLAYER_ENTERS_X, "player enters" },
2112 { CE_PLAYER_LEAVES_X, "player leaves" },
2113 { CE_PLAYER_DIGS_X, "player digs" },
2114 { CE_PLAYER_COLLECTS_X, "player collects" },
2115 { CE_PLAYER_DROPS_X, "player drops/throws" },
2116 { CE_TOUCHING_X, "touching" },
2117 { CE_HITTING_X, "hitting" },
2118 { CE_DIGGING_X, "digging" },
2119 { CE_HIT_BY_X, "hit by" },
2120 { CE_SWITCH_OF_X, "switch of" },
2121 { CE_CHANGE_OF_X, "change by page of" },
2122 { CE_EXPLOSION_OF_X, "explosion of" },
2123 { CE_MOVE_OF_X, "move of" },
2124 { CE_CREATION_OF_X, "creation of" },
2125 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2126 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2127 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2128 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2129 { CE_UNDEFINED, " " },
2130 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2131 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2132 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2133 { CE_UNDEFINED, " " },
2134 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2135 { CE_PLAYER_NEXT_TO_X, "player next to" },
2136 { CE_NEXT_TO_X, "next to" },
2141 static struct ValueTextInfo options_change_trigger_side[] =
2143 { CH_SIDE_LEFT, "left" },
2144 { CH_SIDE_RIGHT, "right" },
2145 { CH_SIDE_TOP, "top" },
2146 { CH_SIDE_BOTTOM, "bottom" },
2147 { CH_SIDE_LEFT_RIGHT, "left/right" },
2148 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2149 { CH_SIDE_ANY, "any" },
2154 static struct ValueTextInfo options_change_trigger_player[] =
2156 { CH_PLAYER_1, "1" },
2157 { CH_PLAYER_2, "2" },
2158 { CH_PLAYER_3, "3" },
2159 { CH_PLAYER_4, "4" },
2160 { CH_PLAYER_ANY, "any" },
2165 static struct ValueTextInfo options_change_trigger_page[] =
2176 { (1u << 9), "10" },
2177 { (1u << 10), "11" },
2178 { (1u << 11), "12" },
2179 { (1u << 12), "13" },
2180 { (1u << 13), "14" },
2181 { (1u << 14), "15" },
2182 { (1u << 15), "16" },
2183 { (1u << 16), "17" },
2184 { (1u << 17), "18" },
2185 { (1u << 18), "19" },
2186 { (1u << 19), "20" },
2187 { (1u << 20), "21" },
2188 { (1u << 21), "22" },
2189 { (1u << 22), "23" },
2190 { (1u << 23), "24" },
2191 { (1u << 24), "25" },
2192 { (1u << 25), "26" },
2193 { (1u << 26), "27" },
2194 { (1u << 27), "28" },
2195 { (1u << 28), "29" },
2196 { (1u << 29), "30" },
2197 { (1u << 30), "31" },
2198 { (1u << 31), "32" },
2199 { CH_PAGE_ANY, "any" },
2204 static struct ValueTextInfo options_change_replace_when[] =
2206 { CP_WHEN_EMPTY, "empty" },
2207 { CP_WHEN_WALKABLE, "walkable" },
2208 { CP_WHEN_DIGGABLE, "diggable" },
2209 { CP_WHEN_COLLECTIBLE, "collectible" },
2210 { CP_WHEN_REMOVABLE, "removable" },
2211 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2216 static struct ValueTextInfo options_action_type[] =
2218 { CA_NO_ACTION, "no action" },
2219 { CA_UNDEFINED, " " },
2220 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2221 { CA_RESTART_LEVEL, "restart level" },
2222 { CA_SHOW_ENVELOPE, "show envelope" },
2223 { CA_SET_LEVEL_TIME, "set time" },
2224 { CA_SET_LEVEL_SCORE, "set score" },
2225 { CA_SET_LEVEL_GEMS, "set gems" },
2226 { CA_SET_LEVEL_WIND, "set wind dir." },
2227 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2228 { CA_UNDEFINED, " " },
2229 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2230 { CA_MOVE_PLAYER, "move player" },
2231 { CA_MOVE_PLAYER_NEW, "move player new" },
2232 { CA_EXIT_PLAYER, "exit player" },
2233 { CA_KILL_PLAYER, "kill player" },
2234 { CA_SET_PLAYER_KEYS, "set keys" },
2235 { CA_SET_PLAYER_SPEED, "set speed" },
2236 { CA_SET_PLAYER_SHIELD, "set shield" },
2237 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2238 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2239 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2240 { CA_UNDEFINED, " " },
2241 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2242 { CA_SET_CE_VALUE, "set CE value" },
2243 { CA_SET_CE_SCORE, "set CE score" },
2244 { CA_SET_CE_ARTWORK, "set CE artwork" },
2245 { CA_UNDEFINED, " " },
2246 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2247 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2252 static struct ValueTextInfo options_action_mode_none[] =
2254 { CA_MODE_UNDEFINED, " " },
2259 static struct ValueTextInfo options_action_mode_assign[] =
2261 { CA_MODE_SET, "=" },
2266 static struct ValueTextInfo options_action_mode_add_remove[] =
2268 { CA_MODE_ADD, "+" },
2269 { CA_MODE_SUBTRACT, "-" },
2274 static struct ValueTextInfo options_action_mode_calculate[] =
2276 { CA_MODE_SET, "=" },
2277 { CA_MODE_ADD, "+" },
2278 { CA_MODE_SUBTRACT, "-" },
2279 { CA_MODE_MULTIPLY, "*" },
2280 { CA_MODE_DIVIDE, "/" },
2281 { CA_MODE_MODULO, "%" },
2286 static struct ValueTextInfo options_action_arg_none[] =
2288 { CA_ARG_UNDEFINED, " " },
2293 static struct ValueTextInfo options_action_arg_player[] =
2295 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2296 { CA_ARG_PLAYER_1, "1" },
2297 { CA_ARG_PLAYER_2, "2" },
2298 { CA_ARG_PLAYER_3, "3" },
2299 { CA_ARG_PLAYER_4, "4" },
2300 { CA_ARG_PLAYER_ANY, "any" },
2301 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2302 { CA_ARG_PLAYER_ACTION, "action ->" },
2307 static struct ValueTextInfo options_action_arg_number[] =
2309 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2316 { CA_ARG_10, "10" },
2317 { CA_ARG_100, "100" },
2318 { CA_ARG_1000, "1000" },
2319 { CA_ARG_UNDEFINED, " " },
2320 { CA_ARG_NUMBER_MIN, "min" },
2321 { CA_ARG_NUMBER_MAX, "max" },
2322 { CA_ARG_UNDEFINED, " " },
2323 { CA_ARG_NUMBER_RESET, "reset" },
2324 { CA_ARG_UNDEFINED, " " },
2325 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2326 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2327 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2328 { CA_ARG_UNDEFINED, " " },
2329 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2330 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2331 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2332 { CA_ARG_UNDEFINED, " " },
2333 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2334 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2335 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2336 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2337 { CA_ARG_UNDEFINED, " " },
2338 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2339 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2340 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2341 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2346 static struct ValueTextInfo options_action_arg_value[] =
2348 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2355 { CA_ARG_10, "10" },
2356 { CA_ARG_100, "100" },
2357 { CA_ARG_1000, "1000" },
2358 { CA_ARG_UNDEFINED, " " },
2359 { CA_ARG_NUMBER_MIN, "min" },
2360 { CA_ARG_NUMBER_MAX, "max" },
2361 { CA_ARG_UNDEFINED, " " },
2362 { CA_ARG_NUMBER_RESET, "reset" },
2363 { CA_ARG_UNDEFINED, " " },
2364 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2365 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2366 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2367 { CA_ARG_UNDEFINED, " " },
2368 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2369 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2370 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2371 { CA_ARG_UNDEFINED, " " },
2372 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2373 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2374 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2375 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2376 { CA_ARG_UNDEFINED, " " },
2377 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2378 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2379 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2380 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2381 { CA_ARG_UNDEFINED, " " },
2382 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2383 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2384 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2385 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2390 static struct ValueTextInfo options_action_arg_envelope[] =
2392 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2397 { CA_ARG_UNDEFINED, " " },
2398 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2399 { CA_ARG_ELEMENT_TARGET, "target" },
2400 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2401 { CA_ARG_ELEMENT_ACTION, "action ->" },
2406 static struct ValueTextInfo options_action_arg_key[] =
2408 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2417 { CA_ARG_UNDEFINED, " " },
2418 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2419 { CA_ARG_ELEMENT_TARGET, "target" },
2420 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2421 { CA_ARG_ELEMENT_ACTION, "action ->" },
2426 static struct ValueTextInfo options_action_arg_speed[] =
2428 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2429 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2430 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2431 { CA_ARG_SPEED_SLOW, "slow" },
2432 { CA_ARG_SPEED_NORMAL, "normal" },
2433 { CA_ARG_SPEED_FAST, "fast" },
2434 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2435 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2436 { CA_ARG_UNDEFINED, " " },
2437 { CA_ARG_SPEED_SLOWER, "slower" },
2438 { CA_ARG_SPEED_FASTER, "faster" },
2439 { CA_ARG_UNDEFINED, " " },
2440 { CA_ARG_SPEED_RESET, "reset" },
2445 static struct ValueTextInfo options_action_arg_shield[] =
2447 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2448 { CA_ARG_SHIELD_OFF, "off" },
2449 { CA_ARG_SHIELD_NORMAL, "normal" },
2450 { CA_ARG_SHIELD_DEADLY, "deadly" },
2455 static struct ValueTextInfo options_action_arg_artwork[] =
2457 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2458 { CA_ARG_ELEMENT_TARGET, "target" },
2459 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2460 { CA_ARG_ELEMENT_ACTION, "action ->" },
2461 { CA_ARG_UNDEFINED, " " },
2462 { CA_ARG_ELEMENT_RESET, "reset" },
2467 static struct ValueTextInfo options_action_arg_gravity[] =
2469 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2470 { CA_ARG_GRAVITY_ON, "on" },
2471 { CA_ARG_GRAVITY_OFF, "off" },
2472 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2477 static struct ValueTextInfo options_action_arg_direction[] =
2479 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2480 { CA_ARG_DIRECTION_NONE, "none" },
2481 { CA_ARG_DIRECTION_LEFT, "left" },
2482 { CA_ARG_DIRECTION_RIGHT, "right" },
2483 { CA_ARG_DIRECTION_UP, "up" },
2484 { CA_ARG_DIRECTION_DOWN, "down" },
2485 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2486 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2491 static struct ValueTextInfo options_action_arg_scan_mode[] =
2493 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2494 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2495 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2500 static struct ValueTextInfo options_action_arg_inventory[] =
2502 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2503 { CA_ARG_ELEMENT_TARGET, "+ target" },
2504 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2505 { CA_ARG_ELEMENT_ACTION, "+ action" },
2506 { CA_ARG_UNDEFINED, " " },
2507 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2508 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2509 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2510 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2511 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2512 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2513 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2514 { CA_ARG_UNDEFINED, " " },
2515 { CA_ARG_INVENTORY_RESET, "reset" },
2520 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2521 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2526 static struct ValueTextInfo options_group_choice_mode[] =
2528 { ANIM_RANDOM, "random" },
2529 { ANIM_LOOP, "loop" },
2530 { ANIM_LINEAR, "linear" },
2531 { ANIM_PINGPONG, "pingpong" },
2532 { ANIM_PINGPONG2, "pingpong 2" },
2533 { ANIM_LEVEL_NR, "level number" },
2538 static struct ValueTextInfo options_bd_scheduling_type[] =
2540 { GD_SCHEDULING_MILLISECONDS, "Milliseconds" },
2541 { GD_SCHEDULING_BD1, "BD1" },
2542 { GD_SCHEDULING_BD2, "BD2" },
2543 { GD_SCHEDULING_PLCK, "Construction Kit" },
2544 { GD_SCHEDULING_CRDR, "Crazy Dream 7" },
2545 { GD_SCHEDULING_BD1_ATARI, "Atari BD1" },
2546 { GD_SCHEDULING_BD2_PLCK_ATARI,"Atari BD2 / PLCK" },
2551 static struct ValueTextInfo *action_arg_modes[] =
2553 options_action_mode_none,
2554 options_action_mode_assign,
2555 options_action_mode_add_remove,
2556 options_action_mode_calculate,
2563 struct ValueTextInfo *options;
2565 action_arg_options[] =
2567 { CA_NO_ACTION, 0, options_action_arg_none, },
2568 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2569 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2570 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2571 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2572 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2573 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2574 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2575 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2576 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2577 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2578 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2579 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2580 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2581 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2582 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2583 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2584 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2585 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2586 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2587 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2588 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2598 int gadget_id_align;
2599 int size; // char size of selectbox or '-1' (dynamically determined)
2600 struct ValueTextInfo *options;
2602 char *text_above, *text_left, *text_right, *infotext;
2603 } selectbox_info[ED_NUM_SELECTBOX] =
2605 // ---------- level and editor settings -------------------------------------
2608 ED_SELECTBOX_ID_TIME_OR_STEPS,
2609 -1, ED_LEVEL_SETTINGS_YPOS(8),
2610 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2612 options_time_or_steps,
2613 &level.use_step_counter,
2614 NULL, NULL, "(0 => no limit)", "time or step limit"
2617 ED_SELECTBOX_ID_TIME_SCORE_BASE,
2618 -1, ED_LEVEL_SETTINGS_YPOS(10),
2619 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2621 options_time_score_base,
2622 &level.time_score_base,
2623 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2626 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
2627 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2628 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2630 options_game_engine_type,
2631 &level.game_engine_type,
2632 NULL, "game engine:", NULL, "game engine"
2635 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
2636 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2637 GADGET_ID_BD_SCHEDULING_TYPE, GADGET_ID_NONE,
2639 options_bd_scheduling_type,
2640 &level.bd_scheduling_type,
2641 NULL, "scheduling type:", NULL, "level timing"
2644 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
2645 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2646 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2648 options_levelset_save_mode,
2649 &levelset_save_mode,
2650 "Action:", NULL, NULL, "action when saving level set"
2653 // ---------- element settings: configure (several elements) ----------------
2656 ED_SELECTBOX_ID_WIND_DIRECTION,
2657 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2658 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2660 options_wind_direction,
2661 &level.wind_direction_initial,
2662 NULL, "initial wind direction:", NULL, "initial wind direction"
2665 ED_SELECTBOX_ID_PLAYER_SPEED,
2666 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2667 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2669 options_player_speed,
2670 &level.initial_player_stepsize[0],
2671 NULL, "initial player speed:", NULL, "initial player speed"
2674 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
2675 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2676 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2678 options_group_choice_mode,
2679 &level.mm_ball_choice_mode,
2680 NULL, "choice type:", NULL, "type of content choice"
2683 // ---------- element settings: configure 1 (custom elements) ---------------
2686 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
2687 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2688 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2690 options_access_type,
2691 &custom_element.access_type,
2692 NULL, NULL, NULL, "type of access to this field"
2695 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
2696 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2697 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2699 options_access_layer,
2700 &custom_element.access_layer,
2701 NULL, NULL, NULL, "layer of access for this field"
2704 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
2705 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2706 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2708 options_access_protected,
2709 &custom_element.access_protected,
2710 NULL, NULL, NULL, "protected access for this field"
2713 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
2714 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2715 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2717 options_access_direction,
2718 &custom_element.access_direction,
2719 NULL, "from", NULL, "access direction for this field"
2722 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
2723 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2724 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2726 options_walk_to_action,
2727 &custom_element.walk_to_action,
2728 NULL, NULL, NULL, "diggable/collectible/pushable"
2731 // ---------- element settings: configure 2 (custom elements) ---------------
2734 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
2735 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2736 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2738 options_move_pattern,
2739 &custom_element.move_pattern,
2740 NULL, "can move", NULL, "element move pattern"
2743 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
2744 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2745 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2747 options_move_direction,
2748 &custom_element.move_direction_initial,
2749 NULL, "starts moving", NULL, "initial element move direction"
2752 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
2753 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2754 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2756 options_move_stepsize,
2757 &custom_element.move_stepsize,
2758 NULL, "move/fall speed", NULL, "speed of element movement"
2761 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
2762 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2763 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2765 options_move_leave_type,
2766 &custom_element.move_leave_type,
2767 // left text with leading spaces to place gadget next to "can dig" gadget
2768 // (needed because drawing area gadgets created after selectbox gadgets)
2769 // NULL, "can dig: can", ":", "leave behind or change element"
2770 NULL, " can", ":", "leave behind or change element"
2773 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
2774 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2775 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2777 options_smash_targets,
2778 &custom_element.smash_targets,
2779 NULL, "can smash", NULL, "elements that can be smashed"
2782 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
2783 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2784 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2786 options_slippery_type,
2787 &custom_element.slippery_type,
2788 NULL, "slippery", NULL, "where other elements fall down"
2791 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
2792 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2793 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2796 &custom_element.deadliness,
2797 NULL, "deadly when", NULL, "deadliness of element"
2800 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
2801 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2802 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2804 options_explosion_type,
2805 &custom_element.explosion_type,
2806 NULL, "can explode", NULL, "explosion type"
2809 // ---------- element settings: advanced (custom elements) ------------------
2812 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
2813 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2814 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2817 &custom_element_change.delay_frames,
2818 NULL, "delay time given in", NULL, "delay time units for change"
2821 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
2822 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2823 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2825 options_change_direct_action,
2826 &custom_element_change.direct_action,
2827 NULL, NULL, NULL, "type of direct action"
2830 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
2831 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2832 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2834 options_change_other_action,
2835 &custom_element_change.other_action,
2836 NULL, NULL, "element:", "type of other element action"
2839 ED_SELECTBOX_ID_CHANGE_SIDE,
2840 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2841 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2843 options_change_trigger_side,
2844 &custom_element_change.trigger_side,
2845 NULL, "at", "side", "element side triggering change"
2848 ED_SELECTBOX_ID_CHANGE_PLAYER,
2849 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2850 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2852 options_change_trigger_player,
2853 &custom_element_change.trigger_player,
2854 NULL, "player:", " ", "player that causes change"
2857 ED_SELECTBOX_ID_CHANGE_PAGE,
2858 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2859 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2861 options_change_trigger_page,
2862 &custom_element_change.trigger_page,
2863 NULL, "page:", NULL, "change page that causes change"
2866 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
2867 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2868 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2870 options_change_replace_when,
2871 &custom_element_change.replace_when,
2872 NULL, "replace when", NULL, "which elements can be replaced"
2875 ED_SELECTBOX_ID_ACTION_TYPE,
2876 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2877 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2879 options_action_type,
2880 &custom_element_change.action_type,
2881 NULL, NULL, NULL, "action on specified condition"
2884 ED_SELECTBOX_ID_ACTION_MODE,
2885 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2886 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2888 options_action_mode_none,
2889 &custom_element_change.action_mode,
2890 NULL, NULL, NULL, "action operator"
2893 ED_SELECTBOX_ID_ACTION_ARG,
2894 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2895 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2897 options_action_arg_none,
2898 &custom_element_change.action_arg,
2899 NULL, NULL, NULL, "action parameter"
2902 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
2903 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2904 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2906 options_change_page,
2907 &custom_element.current_change_page,
2908 NULL, NULL, NULL, "element change page"
2911 // ---------- element settings: configure (group elements) ------------------
2914 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
2915 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2916 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2918 options_group_choice_mode,
2919 &group_element_info.choice_mode,
2920 NULL, "choice type:", NULL, "type of group element choice"
2929 int gadget_id_align;
2932 char *text_above, *text_left, *text_right, *infotext;
2933 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2935 // ---------- level and editor settings (tabs) ------------------------------
2938 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
2939 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2940 GADGET_ID_LEVELCONFIG_LEVEL, GADGET_ID_NONE,
2942 NULL, NULL, NULL, "Configure level settings"
2945 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
2947 GADGET_ID_LEVELCONFIG_LEVELSET, GADGET_ID_LEVELCONFIG_LEVEL,
2949 NULL, NULL, NULL, "Update this or create new level set"
2952 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
2954 GADGET_ID_LEVELCONFIG_EDITOR, GADGET_ID_LEVELCONFIG_LEVELSET,
2956 NULL, NULL, NULL, "Configure editor settings"
2959 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
2961 GADGET_ID_LEVELCONFIG_ENGINE, GADGET_ID_LEVELCONFIG_EDITOR,
2963 NULL, NULL, NULL, "Configure engine settings"
2966 // ---------- element settings (tabs) ---------------------------------------
2969 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
2970 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2971 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2973 NULL, NULL, NULL, "Show information about element"
2976 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
2978 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2980 NULL, NULL, NULL, "Configure element properties"
2983 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
2985 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2987 NULL, NULL, NULL, "Configure element properties, part 1"
2990 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
2992 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2994 NULL, NULL, NULL, "Configure element properties, part 2"
2997 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
2999 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
3001 NULL, NULL, NULL, "Configure custom element change pages"
3004 // ---------- level and editor settings (buttons) ---------------------------
3007 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
3008 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
3009 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
3011 NULL, NULL, NULL, "Update or create level set"
3014 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
3015 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3016 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
3018 NULL, NULL, "this level as level template",
3019 "Save current settings as new template"
3022 // ---------- element settings (buttons) ------------------------------------
3025 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
3027 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
3029 NULL, " ", "As Template",
3030 "Save current settings as new template"
3033 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
3035 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
3037 NULL, NULL, NULL, "Add new change page"
3040 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
3042 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
3044 NULL, NULL, NULL, "Delete current change page"
3054 int gadget_id_align;
3055 char *text_left, *text_right, *infotext;
3056 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
3059 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
3060 IMG_EDITOR_COUNTER_DOWN,
3061 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3062 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
3063 NULL, NULL, "select previous change page"
3066 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
3067 IMG_EDITOR_COUNTER_UP,
3068 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3069 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
3070 NULL, "change page", "select next change page"
3073 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
3074 IMG_GFX_EDITOR_BUTTON_CP_COPY,
3075 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3076 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
3077 " ", NULL, "copy settings from this change page"
3080 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
3081 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
3082 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3083 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
3084 NULL, NULL, "paste settings to this change page"
3091 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
3099 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
3102 ED_SCROLLBUTTON_ID_AREA_UP,
3103 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
3104 GADGET_ID_SCROLL_UP,
3105 "scroll level editing area up"
3108 ED_SCROLLBUTTON_ID_AREA_DOWN,
3109 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
3110 GADGET_ID_SCROLL_DOWN,
3111 "scroll level editing area down"
3114 ED_SCROLLBUTTON_ID_AREA_LEFT,
3115 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
3116 GADGET_ID_SCROLL_LEFT,
3117 "scroll level editing area left"
3120 ED_SCROLLBUTTON_ID_AREA_RIGHT,
3121 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
3122 GADGET_ID_SCROLL_RIGHT,
3123 "scroll level editing area right"
3126 ED_SCROLLBUTTON_ID_LIST_UP,
3127 IMG_EDITOR_PALETTE_SCROLL_UP,
3128 GADGET_ID_SCROLL_LIST_UP,
3129 "scroll element list up ('Page Up')"
3132 ED_SCROLLBUTTON_ID_LIST_DOWN,
3133 IMG_EDITOR_PALETTE_SCROLL_DOWN,
3134 GADGET_ID_SCROLL_LIST_DOWN,
3135 "scroll element list down ('Page Down')"
3143 int wheel_x, wheel_y;
3144 int wheel_width, wheel_height;
3145 } scrollbar_pos[ED_NUM_SCROLLBARS];
3154 } scrollbar_info[ED_NUM_SCROLLBARS] =
3157 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
3158 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3159 GD_TYPE_SCROLLBAR_HORIZONTAL,
3160 GADGET_ID_SCROLL_HORIZONTAL,
3161 "scroll level editing area horizontally"
3164 ED_SCROLLBAR_ID_AREA_VERTICAL,
3165 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3166 GD_TYPE_SCROLLBAR_VERTICAL,
3167 GADGET_ID_SCROLL_VERTICAL,
3168 "scroll level editing area vertically"
3171 ED_SCROLLBAR_ID_LIST_VERTICAL,
3172 IMG_EDITOR_PALETTE_SCROLLBAR,
3173 GD_TYPE_SCROLLBAR_VERTICAL,
3174 GADGET_ID_SCROLL_LIST_VERTICAL,
3175 "scroll element list vertically"
3185 int gadget_id_align;
3186 int radio_button_nr;
3189 char *text_left, *text_right, *infotext;
3190 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3193 ED_RADIOBUTTON_ID_PERCENTAGE,
3194 -1, ED_LEVEL_SETTINGS_YPOS(0),
3195 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3196 RADIO_NR_RANDOM_ELEMENTS,
3197 &random_placement_method, RANDOM_USE_PERCENTAGE,
3198 " ", "percentage", "use percentage for random elements"
3201 ED_RADIOBUTTON_ID_QUANTITY,
3202 -1, ED_LEVEL_SETTINGS_YPOS(0),
3203 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3204 RADIO_NR_RANDOM_ELEMENTS,
3205 &random_placement_method, RANDOM_USE_QUANTITY,
3206 " ", "quantity", "use quantity for random elements"
3215 int gadget_id_align;
3217 char *text_above, *text_left, *text_right, *infotext;
3218 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3220 // ---------- level and editor settings -------------------------------------
3223 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
3224 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3225 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3226 &level.auto_count_gems,
3228 "automatically count gems needed", "set counter to number of gems"
3231 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
3232 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3233 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3234 &level.rate_time_over_score,
3236 "rate time/steps used over score", "sort high scores by playing time/steps"
3239 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
3240 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3241 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3242 &levelset_use_levelset_artwork,
3244 "use current custom artwork", "use custom artwork of this level set"
3247 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
3248 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3249 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3250 &levelset_copy_level_template,
3252 "copy current level template", "copy level template of this level set"
3255 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
3256 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3257 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3258 &random_placement_background_restricted,
3260 "restrict random placement to:", "set random placement restriction"
3263 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
3264 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3265 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3266 &setup.editor.use_template_for_new_levels,
3267 "Template for new levels and CE/GE:", NULL,
3268 "use template for new levels", "use template for level properties"
3271 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
3272 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3273 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3274 &level.use_custom_template,
3276 "use template for custom elements", "use template for custom properties"
3279 ED_CHECKBUTTON_ID_BD_INTERMISSION,
3280 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
3281 GADGET_ID_BD_INTERMISSION, GADGET_ID_NONE,
3282 &level.bd_intermission,
3283 "Boulder Dash game engine settings:", NULL,
3284 "intermission", "level is an intermission level"
3287 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
3288 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
3289 GADGET_ID_BD_PAL_TIMING, GADGET_ID_NONE,
3290 &level.bd_pal_timing,
3292 "PAL timing", "use slower timer (like PAL C64)"
3295 // ---------- element settings: configure (various elements) ----------------
3298 ED_CHECKBUTTON_ID_STICK_ELEMENT,
3299 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3300 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3301 &stick_element_properties_window,
3303 "stick this screen to edit content","stick this screen to edit content"
3306 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
3307 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3308 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3309 &level.em_slippery_gems,
3311 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3314 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
3315 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3316 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3317 &level.em_explodes_by_fire,
3319 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3322 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
3323 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3324 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3325 &level.use_spring_bug,
3327 "use spring pushing bug", "use odd spring pushing behaviour"
3330 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
3331 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3332 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3333 &level.use_time_orb_bug,
3335 "use time orb bug", "use odd time orb behaviour"
3338 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
3339 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3340 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3341 &level.use_life_bugs,
3343 "use buggy element behaviour", "use odd (historic) element behaviour"
3346 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
3347 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3348 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3351 "create single random element", "only create one element from content"
3354 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
3355 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3356 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3357 &level.ball_active_initial,
3359 "magic ball initially activated", "activate magic ball after level start"
3362 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
3363 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3364 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3365 &level.grow_into_diggable,
3367 "can grow into anything diggable", "grow into more than just sand"
3370 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
3371 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3372 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3373 &level.sb_fields_needed,
3375 "all fields need to be filled", "require all SB fields to be solved"
3378 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
3379 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3380 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3381 &level.sb_objects_needed,
3383 "all objects need to be placed", "require all SB objects to be solved"
3386 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
3387 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3388 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3389 &level.auto_exit_sokoban,
3391 "exit level if all tasks solved", "automatically finish Sokoban levels"
3394 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
3395 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3396 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3397 &level.solved_by_one_player,
3399 "only one player must enter exit", "level solved by first player in exit"
3402 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
3403 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3404 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3405 &level.finish_dig_collect,
3407 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3410 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
3411 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3412 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3413 &level.keep_walkable_ce,
3415 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3418 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
3419 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3420 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3421 &level.continuous_snapping,
3423 "continuous snapping", "use snapping without releasing key"
3426 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
3427 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3428 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3429 &level.block_snap_field,
3431 "block snapped field when snapping", "use snapping delay to show animation"
3434 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
3435 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3436 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3437 &level.block_last_field,
3439 "block last field when moving", "player blocks last field when moving"
3442 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
3443 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3444 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3445 &level.sp_block_last_field,
3447 "block last field when moving", "player blocks last field when moving"
3450 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
3451 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3452 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3453 &level.instant_relocation,
3455 "no scrolling when relocating", "player gets relocated without delay"
3458 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
3459 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3460 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3461 &level.shifted_relocation,
3463 "no centering when relocating", "level not centered after relocation"
3466 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
3467 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3468 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3469 &level.lazy_relocation,
3471 "only redraw off-screen relocation","no redraw if relocation target visible"
3474 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
3475 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3476 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3477 &level.use_start_element[0],
3479 "use level start element:", "start level at this element's position"
3482 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
3483 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3484 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3485 &level.use_artwork_element[0],
3487 "use artwork from element:", "use player artwork from other element"
3490 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
3491 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3492 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3493 &level.use_explosion_element[0],
3495 "use explosion from element:", "use explosion properties from element"
3498 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
3499 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3500 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3501 &level.initial_player_gravity[0],
3503 "use initial gravity", "set initial player gravity"
3506 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
3507 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3508 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3509 &level.use_initial_inventory[0],
3511 "use initial inventory:", "use collected elements on level start"
3514 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
3515 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3516 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3517 &level.can_pass_to_walkable,
3519 "can pass to walkable element", "player can pass to empty or walkable"
3522 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
3523 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3524 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3525 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3527 "can fall into acid (with gravity)","player can fall into acid pool"
3530 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
3531 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3532 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3533 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3535 "can move into acid", "element can move into acid pool"
3538 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
3539 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3540 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3541 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3543 "deadly when colliding with", "element is deadly when hitting player"
3546 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
3547 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3548 GADGET_ID_BD_DIAGONAL_MOVEMENTS, GADGET_ID_NONE,
3549 &level.bd_diagonal_movements,
3551 "can move diagonally", "player can move diagonally"
3554 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
3555 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3556 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3557 &level.envelope[0].autowrap,
3559 "auto-wrap", "automatically wrap envelope text"
3562 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
3563 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3564 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3565 &level.envelope[0].centered,
3567 "centered", "automatically center envelope text"
3570 ED_CHECKBUTTON_ID_MM_LASER_RED,
3571 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3572 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3573 &level.mm_laser_red,
3574 "choose color components for laser:", NULL,
3575 "red", "use red color components in laser"
3578 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
3579 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3580 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3581 &level.mm_laser_green,
3583 "green", "use green color components in laser"
3586 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
3587 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3588 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3589 &level.mm_laser_blue,
3591 "blue", "use blue color components in laser"
3594 ED_CHECKBUTTON_ID_DF_LASER_RED,
3595 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3596 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3597 &level.df_laser_red,
3598 "choose color components for laser:", NULL,
3599 "red", "use red color components in laser"
3602 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
3603 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3604 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3605 &level.df_laser_green,
3607 "green", "use green color components in laser"
3610 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
3611 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3612 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3613 &level.df_laser_blue,
3615 "blue", "use blue color components in laser"
3618 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
3619 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3620 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3621 &level.rotate_mm_ball_content,
3623 "randomly rotate created content", "randomly rotate newly created content"
3626 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
3627 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3628 GADGET_ID_EXPLODE_MM_BALL, GADGET_ID_NONE,
3629 &level.explode_mm_ball,
3631 "explode ball instead of melting", "use explosion to release ball content"
3634 // ---------- element settings: configure 1 (custom elements) ---------------
3637 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
3638 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3639 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3640 &custom_element.use_gfx_element,
3642 "use graphic of element:", "use existing element graphic"
3645 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
3646 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3647 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3648 &level.use_custom_template,
3650 "use template", "use template for custom properties"
3653 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
3654 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3655 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3656 &custom_element_properties[EP_ACCESSIBLE],
3658 NULL, "player can walk to or pass this field"
3661 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
3662 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3663 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3664 &custom_element_properties[EP_GRAVITY_REACHABLE],
3666 "reachable despite gravity", "player can walk/dig despite gravity"
3669 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
3670 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3671 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3672 &custom_element.use_last_ce_value,
3674 "use last CE value after change", "use last CE value after change"
3677 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
3678 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3679 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3680 &custom_element_properties[EP_WALK_TO_OBJECT],
3682 NULL, "player can dig/collect/push element"
3685 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
3686 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3687 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3688 &custom_element_properties[EP_INDESTRUCTIBLE],
3690 "indestructible", "element is indestructible"
3693 // ---------- element settings: configure 2 (custom elements) ---------------
3696 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
3697 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3698 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3699 &custom_element_properties[EP_CAN_MOVE],
3701 NULL, "element can move with some pattern"
3704 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
3705 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3706 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3707 &custom_element_properties[EP_CAN_FALL],
3709 "can fall", "element can fall down"
3712 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
3713 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3714 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3715 &custom_element_properties[EP_CAN_SMASH],
3717 NULL, "element can smash other elements"
3720 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
3721 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3722 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3723 &custom_element_properties[EP_SLIPPERY],
3725 NULL, "other elements can fall down from it"
3728 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
3729 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3730 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3731 &custom_element_properties[EP_DEADLY],
3733 NULL, "element can kill the player"
3736 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
3737 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3738 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3739 &custom_element_properties[EP_CAN_EXPLODE],
3741 NULL, "element can explode"
3744 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
3745 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3746 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3747 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3749 "by fire", "element can explode by fire/explosion"
3752 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
3753 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3754 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3755 &custom_element_properties[EP_EXPLODES_SMASHED],
3757 "smashed", "element can explode when smashed"
3760 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
3761 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3762 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3763 &custom_element_properties[EP_EXPLODES_IMPACT],
3765 "impact", "element can explode on impact"
3768 // ---------- element settings: advanced (custom elements) ------------------
3771 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
3772 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3773 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3774 &custom_element_change.can_change,
3776 "element changes to:", "change element on specified condition"
3779 ED_CHECKBUTTON_ID_CHANGE_DELAY,
3780 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3781 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3782 &custom_element_change_events[CE_DELAY],
3784 NULL, "element changes after delay"
3787 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
3788 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3789 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3790 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3792 NULL, "element changes by direct action"
3795 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
3796 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3797 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3798 &custom_element_change_events[CE_BY_OTHER_ACTION],
3800 NULL, "element changes by other element"
3803 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
3804 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3805 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3806 &custom_element_change.explode,
3808 "explode instead of change", "element explodes instead of change"
3811 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
3812 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3813 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3814 &custom_element_change.use_target_content,
3816 "use extended change target:", "element changes to more elements"
3819 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
3820 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3821 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3822 &custom_element_change.only_if_complete,
3824 "replace all or nothing", "only replace when all can be changed"
3827 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
3828 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3829 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3830 &custom_element_change.use_random_replace,
3832 NULL, "use percentage for random replace"
3835 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
3836 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3837 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3838 &custom_element_change.has_action,
3840 NULL, "execute action on specified condition"
3848 int xoffset, yoffset;
3850 int gadget_id_align;
3852 int area_xsize, area_ysize;
3853 char *text_left, *text_right, *text_above, *text_below, *infotext;
3854 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3856 // ---------- level playfield content ---------------------------------------
3859 ED_DRAWING_ID_DRAWING_LEVEL,
3862 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3864 -1, -1, // these values are not constant, but can change at runtime
3865 NULL, NULL, NULL, NULL, NULL
3868 // ---------- yam yam content -----------------------------------------------
3871 ED_DRAWING_ID_YAMYAM_CONTENT_0,
3872 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3873 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3874 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3875 &level.yamyam_content[0].e[0][0], 3, 3,
3876 NULL, NULL, NULL, "1", NULL
3879 ED_DRAWING_ID_YAMYAM_CONTENT_1,
3880 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3881 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3882 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3883 &level.yamyam_content[1].e[0][0], 3, 3,
3884 NULL, NULL, NULL, "2", NULL
3887 ED_DRAWING_ID_YAMYAM_CONTENT_2,
3888 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3889 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3890 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3891 &level.yamyam_content[2].e[0][0], 3, 3,
3892 NULL, NULL, NULL, "3", NULL
3895 ED_DRAWING_ID_YAMYAM_CONTENT_3,
3896 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3897 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3898 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3899 &level.yamyam_content[3].e[0][0], 3, 3,
3900 NULL, NULL, NULL, "4", NULL
3903 ED_DRAWING_ID_YAMYAM_CONTENT_4,
3904 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3905 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3906 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3907 &level.yamyam_content[4].e[0][0], 3, 3,
3908 NULL, NULL, NULL, "5", NULL
3911 ED_DRAWING_ID_YAMYAM_CONTENT_5,
3912 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3913 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3914 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3915 &level.yamyam_content[5].e[0][0], 3, 3,
3916 NULL, NULL, NULL, "6", NULL
3919 ED_DRAWING_ID_YAMYAM_CONTENT_6,
3920 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3921 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3922 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3923 &level.yamyam_content[6].e[0][0], 3, 3,
3924 NULL, NULL, NULL, "7", NULL
3927 ED_DRAWING_ID_YAMYAM_CONTENT_7,
3928 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3929 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3930 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3931 &level.yamyam_content[7].e[0][0], 3, 3,
3932 NULL, NULL, NULL, "8", NULL
3935 // ---------- magic ball content --------------------------------------------
3938 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
3939 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3940 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3941 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3942 &level.ball_content[0].e[0][0], 3, 3,
3943 NULL, NULL, NULL, "1", NULL
3946 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
3947 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3948 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3949 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3950 &level.ball_content[1].e[0][0], 3, 3,
3951 NULL, NULL, NULL, "2", NULL
3954 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
3955 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3956 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3957 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3958 &level.ball_content[2].e[0][0], 3, 3,
3959 NULL, NULL, NULL, "3", NULL
3962 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
3963 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3964 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3965 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3966 &level.ball_content[3].e[0][0], 3, 3,
3967 NULL, NULL, NULL, "4", NULL
3970 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
3971 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3972 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3973 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3974 &level.ball_content[4].e[0][0], 3, 3,
3975 NULL, NULL, NULL, "5", NULL
3978 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
3979 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3980 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3981 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3982 &level.ball_content[5].e[0][0], 3, 3,
3983 NULL, NULL, NULL, "6", NULL
3986 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
3987 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3988 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3989 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3990 &level.ball_content[6].e[0][0], 3, 3,
3991 NULL, NULL, NULL, "7", NULL
3994 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
3995 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3996 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3997 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3998 &level.ball_content[7].e[0][0], 3, 3,
3999 NULL, NULL, NULL, "8", NULL
4002 // ---------- android content -----------------------------------------------
4005 ED_DRAWING_ID_ANDROID_CONTENT,
4006 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
4007 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4008 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
4009 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
4010 NULL, NULL, "elements:", NULL, "elements android can clone"
4013 // ---------- amoeba content ------------------------------------------------
4016 ED_DRAWING_ID_AMOEBA_CONTENT,
4017 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
4018 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4019 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
4020 &level.amoeba_content, 1, 1,
4021 "content:", NULL, NULL, NULL, "amoeba content"
4024 // ---------- level start element -------------------------------------------
4027 ED_DRAWING_ID_START_ELEMENT,
4028 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
4029 0, ED_AREA_1X1_SETTINGS_YOFF,
4030 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
4031 &level.start_element[0], 1, 1,
4032 NULL, NULL, NULL, NULL, "level start element"
4035 // ---------- player artwork element ----------------------------------------
4038 ED_DRAWING_ID_ARTWORK_ELEMENT,
4039 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
4040 0, ED_AREA_1X1_SETTINGS_YOFF,
4041 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
4042 &level.artwork_element[0], 1, 1,
4043 NULL, NULL, NULL, NULL, "element for player artwork"
4046 // ---------- player explosion element --------------------------------------
4049 ED_DRAWING_ID_EXPLOSION_ELEMENT,
4050 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
4051 0, ED_AREA_1X1_SETTINGS_YOFF,
4052 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
4053 &level.explosion_element[0], 1, 1,
4054 NULL, NULL, NULL, NULL, "element for player explosion"
4057 // ---------- player initial inventory --------------------------------------
4060 ED_DRAWING_ID_INVENTORY_CONTENT,
4061 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4062 0, ED_AREA_1X1_SETTINGS_YOFF,
4063 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
4064 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
4065 NULL, NULL, NULL, NULL, "content for initial inventory"
4068 // ---------- gray ball content -----------------------------------------
4071 ED_DRAWING_ID_MM_BALL_CONTENT,
4072 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4073 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4074 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
4075 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
4076 "content:", NULL, NULL, NULL, "content for gray ball"
4079 // ---------- element settings: configure 1 (custom elements) ---------------
4081 // ---------- custom graphic ------------------------------------------------
4084 ED_DRAWING_ID_CUSTOM_GRAPHIC,
4085 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4086 0, ED_AREA_1X1_SETTINGS_YOFF,
4087 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
4088 &custom_element.gfx_element_initial, 1, 1,
4089 NULL, NULL, NULL, NULL, "custom graphic element"
4092 // ---------- element settings: configure 2 (custom elements) ---------------
4094 // ---------- custom content (when exploding) -------------------------------
4097 ED_DRAWING_ID_CUSTOM_CONTENT,
4098 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
4099 0, ED_AREA_3X3_SETTINGS_YOFF,
4100 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
4101 &custom_element.content.e[0][0], 3, 3,
4102 "content:", NULL, NULL, NULL, NULL
4105 // ---------- custom enter and leave element (when moving) ------------------
4108 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
4109 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
4110 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4111 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
4112 &custom_element.move_enter_element, 1, 1,
4113 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
4116 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
4117 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
4118 0, ED_AREA_1X1_SETTINGS_YOFF,
4119 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
4120 &custom_element.move_leave_element, 1, 1,
4121 NULL, NULL, NULL, NULL, "element that will be left behind"
4124 // ---------- element settings: advanced (custom elements) ------------------
4126 // ---------- custom change target ------------------------------------------
4129 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
4130 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4131 0, ED_AREA_1X1_SETTINGS_YOFF,
4132 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
4133 &custom_element_change.target_element, 1, 1,
4134 NULL, "after/when:", NULL, NULL, "new target element after change"
4137 // ---------- custom change content (extended change target) ----------------
4140 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
4141 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
4142 0, ED_AREA_3X3_SETTINGS_YOFF,
4143 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
4144 &custom_element_change.target_content.e[0][0], 3, 3,
4145 NULL, NULL, NULL, NULL, "new extended elements after change"
4148 // ---------- custom change trigger (element causing change) ----------------
4151 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
4152 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
4153 0, ED_AREA_1X1_SETTINGS_YOFF,
4154 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
4155 &custom_element_change.initial_trigger_element, 1, 1,
4156 NULL, NULL, NULL, NULL, "other element triggering change"
4159 // ---------- custom change action (element used for action) ----------------
4162 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
4163 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
4164 0, ED_AREA_1X1_SETTINGS_YOFF,
4165 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
4166 &custom_element_change.action_element, 1, 1,
4167 NULL, NULL, NULL, NULL, "element used as action parameter"
4170 // ---------- group element content -----------------------------------------
4173 ED_DRAWING_ID_GROUP_CONTENT,
4174 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4175 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4176 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
4177 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
4178 "content:", NULL, NULL, NULL, NULL
4181 // ---------- random background (for random painting) -----------------------
4184 ED_DRAWING_ID_RANDOM_BACKGROUND,
4185 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
4186 0, ED_AREA_1X1_LSETTINGS_YOFF,
4187 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
4188 &random_placement_background_element, 1, 1,
4189 NULL, NULL, NULL, NULL, "random placement background"
4194 // ----------------------------------------------------------------------------
4195 // some internally used variables
4196 // ----------------------------------------------------------------------------
4198 // maximal size of level editor drawing area
4199 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
4201 // actual size of level editor drawing area
4202 static int ed_fieldx, ed_fieldy;
4204 // actual position of level editor drawing area in level playfield
4205 static int level_xpos = -1, level_ypos = -1;
4207 // actual tile size used to display playfield drawing area
4208 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
4209 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
4211 #define IN_ED_FIELD(x, y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
4213 // drawing elements on the three mouse buttons
4214 static int new_element1 = EL_WALL;
4215 static int new_element2 = EL_EMPTY;
4216 static int new_element3 = EL_SAND;
4218 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
4219 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
4220 (button) == 2 ? new_element2 : \
4221 (button) == 3 ? new_element3 : EL_EMPTY)
4223 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
4225 static int use_permanent_palette = TRUE;
4227 #define PX (use_permanent_palette ? DX : SX)
4228 #define PY (use_permanent_palette ? DY : SY)
4229 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
4230 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
4232 // forward declaration for internal use
4233 static void CopyBrushToCursor(int, int);
4234 static void DeleteBrushFromCursor(void);
4235 static void ModifyEditorCounterValue(int, int);
4236 static void ModifyEditorCounterLimits(int, int, int);
4237 static void ModifyEditorSelectboxValue(int, int);
4238 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
4239 static void ModifyEditorDrawingArea(int, int, int);
4240 static void ModifyEditorElementList(void);
4241 static void AdjustElementListScrollbar(void);
4242 static void RedrawDrawingElements(void);
4243 static void DrawDrawingWindowExt(boolean);
4244 static void DrawDrawingWindow(void);
4245 static void DrawLevelConfigWindow(void);
4246 static void DrawPropertiesWindow(void);
4247 static void DrawPaletteWindow(void);
4248 static void UpdateCustomElementGraphicGadgets(void);
4249 static boolean checkPropertiesConfig(int);
4250 static void SetAutomaticNumberOfGemsNeeded(void);
4251 static void ClearEditorGadgetInfoText(void);
4252 static void CopyLevelToUndoBuffer(int);
4253 static void HandleDrawingAreas(struct GadgetInfo *);
4254 static void HandleCounterButtons(struct GadgetInfo *);
4255 static void HandleTextInputGadgets(struct GadgetInfo *);
4256 static void HandleTextAreaGadgets(struct GadgetInfo *);
4257 static void HandleSelectboxGadgets(struct GadgetInfo *);
4258 static void HandleTextbuttonGadgets(struct GadgetInfo *);
4259 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
4260 static void HandleRadiobuttons(struct GadgetInfo *);
4261 static void HandleCheckbuttons(struct GadgetInfo *);
4262 static void HandleControlButtons(struct GadgetInfo *);
4263 static void HandleDrawingAreaInfo(struct GadgetInfo *);
4264 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
4265 static boolean AskToCopyAndModifyLevelTemplate(void);
4266 static boolean getDrawModeHiRes(void);
4267 static int getTabulatorBarWidth(void);
4268 static int getTabulatorBarHeight(void);
4269 static Pixel getTabulatorBarColor(void);
4270 static int numHiresTiles(int);
4272 static int num_editor_gadgets = 0; // dynamically determined
4274 static struct GadgetInfo **level_editor_gadget = NULL;
4275 static int *right_gadget_border = NULL;
4277 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
4278 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
4279 static boolean draw_with_brush = FALSE;
4280 static int properties_element = 0;
4282 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4283 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4284 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4285 static int undo_buffer_position = 0;
4286 static int undo_buffer_steps = 0;
4287 static int redo_buffer_steps = 0;
4289 static int edit_mode;
4290 static int edit_mode_levelconfig;
4291 static int edit_mode_properties;
4293 static int element_shift = 0;
4295 static int editor_el_players[] =
4302 static int *editor_el_players_ptr = editor_el_players;
4303 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4305 static int editor_hl_boulderdash[] =
4307 EL_INTERNAL_CASCADE_BD_ACTIVE,
4313 static int editor_el_boulderdash[] =
4322 EL_BD_EXPANDABLE_WALL,
4330 EL_BD_BUTTERFLY_LEFT,
4332 EL_BD_BUTTERFLY_RIGHT,
4333 EL_BD_FIREFLY_RIGHT,
4336 EL_BD_BUTTERFLY_DOWN,
4340 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4341 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4342 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4343 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4345 static int editor_hl_boulderdash_native[] =
4347 EL_INTERNAL_CASCADE_BD_NATIVE_ACTIVE,
4353 static int editor_el_boulderdash_native[] =
4370 EL_BD_BUTTERFLY_LEFT,
4372 EL_BD_BUTTERFLY_RIGHT,
4373 EL_BD_FIREFLY_RIGHT,
4376 EL_BD_BUTTERFLY_DOWN,
4381 EL_BD_BUTTERFLY_2_UP,
4385 EL_BD_BUTTERFLY_2_LEFT,
4386 EL_BD_FIREFLY_2_LEFT,
4387 EL_BD_BUTTERFLY_2_RIGHT,
4388 EL_BD_FIREFLY_2_RIGHT,
4391 EL_BD_BUTTERFLY_2_DOWN,
4392 EL_BD_FIREFLY_2_DOWN,
4400 EL_BD_DRAGONFLY_LEFT,
4401 EL_BD_STONEFLY_LEFT,
4402 EL_BD_DRAGONFLY_RIGHT,
4403 EL_BD_STONEFLY_RIGHT,
4406 EL_BD_DRAGONFLY_DOWN,
4407 EL_BD_STONEFLY_DOWN,
4430 EL_BD_SAND_SLOPED_UP_LEFT,
4431 EL_BD_SAND_SLOPED_UP_RIGHT,
4432 EL_BD_WALL_SLOPED_UP_LEFT,
4433 EL_BD_WALL_SLOPED_UP_RIGHT,
4435 EL_BD_SAND_SLOPED_DOWN_LEFT,
4436 EL_BD_SAND_SLOPED_DOWN_RIGHT,
4437 EL_BD_WALL_SLOPED_DOWN_LEFT,
4438 EL_BD_WALL_SLOPED_DOWN_RIGHT,
4440 EL_BD_FLYING_DIAMOND,
4442 EL_BD_STEELWALL_SLOPED_UP_LEFT,
4443 EL_BD_STEELWALL_SLOPED_UP_RIGHT,
4447 EL_BD_STEELWALL_SLOPED_DOWN_LEFT,
4448 EL_BD_STEELWALL_SLOPED_DOWN_RIGHT,
4451 EL_BD_WALL_NON_SLOPED,
4457 EL_BD_INVISIBLE_EXIT_CLOSED,
4458 EL_BD_INVISIBLE_EXIT_OPEN,
4461 EL_BD_STEELWALL_EXPLODABLE,
4462 EL_BD_STEELWALL_DIGGABLE,
4463 EL_BD_WALL_DIGGABLE,
4465 EL_BD_EXPANDABLE_WALL_HORIZONTAL,
4466 EL_BD_EXPANDABLE_WALL_VERTICAL,
4467 EL_BD_EXPANDABLE_WALL_ANY,
4468 EL_BD_CREATURE_SWITCH,
4470 EL_BD_EXPANDABLE_STEELWALL_HORIZONTAL,
4471 EL_BD_EXPANDABLE_STEELWALL_VERTICAL,
4472 EL_BD_EXPANDABLE_STEELWALL_ANY,
4473 EL_BD_EXPANDABLE_WALL_SWITCH_HORIZONTAL,
4475 EL_BD_BITER_SWITCH_1,
4476 EL_BD_REPLICATOR_SWITCH,
4477 EL_BD_CONVEYOR_SWITCH,
4478 EL_BD_CONVEYOR_DIR_SWITCH_RIGHT,
4487 EL_BD_DIAMOND_GLUED,
4490 EL_BD_TRAPPED_DIAMOND,
4510 EL_BD_GRAVITY_SWITCH,
4511 EL_BD_PNEUMATIC_HAMMER,
4518 EL_BD_BLADDER_SPENDER,
4520 EL_BD_CONVEYOR_LEFT,
4521 EL_BD_CONVEYOR_RIGHT,
4536 EL_BD_PLAYER_WITH_BOMB,
4538 EL_BD_PLAYER_STIRRING,
4540 static int *editor_hl_boulderdash_native_ptr = editor_hl_boulderdash_native;
4541 static int *editor_el_boulderdash_native_ptr = editor_el_boulderdash_native;
4542 static int num_editor_hl_boulderdash_native = ARRAY_SIZE(editor_hl_boulderdash_native);
4543 static int num_editor_el_boulderdash_native = ARRAY_SIZE(editor_el_boulderdash_native);
4545 static int editor_hl_emerald_mine[] =
4547 EL_INTERNAL_CASCADE_EM_ACTIVE,
4553 static int editor_el_emerald_mine[] =
4571 EL_EM_DYNAMITE_ACTIVE,
4590 EL_ACID_POOL_TOPLEFT,
4592 EL_ACID_POOL_TOPRIGHT,
4595 EL_ACID_POOL_BOTTOMLEFT,
4596 EL_ACID_POOL_BOTTOM,
4597 EL_ACID_POOL_BOTTOMRIGHT,
4615 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4616 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4617 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4618 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4620 static int editor_hl_emerald_mine_club[] =
4622 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4628 static int editor_el_emerald_mine_club[] =
4655 EL_EMC_WALL_SLIPPERY_1,
4656 EL_EMC_WALL_SLIPPERY_2,
4657 EL_EMC_WALL_SLIPPERY_3,
4658 EL_EMC_WALL_SLIPPERY_4,
4681 EL_EMC_MAGIC_BALL_SWITCH,
4688 EL_EMC_SPRING_BUMPER,
4692 EL_BALLOON_SWITCH_UP,
4693 EL_BALLOON_SWITCH_ANY,
4696 EL_BALLOON_SWITCH_LEFT,
4698 EL_BALLOON_SWITCH_RIGHT,
4702 EL_BALLOON_SWITCH_DOWN,
4703 EL_BALLOON_SWITCH_NONE,
4705 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4706 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4707 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4708 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4710 static int editor_hl_rnd[] =
4712 EL_INTERNAL_CASCADE_RND_ACTIVE,
4718 static int editor_el_rnd[] =
4721 EL_DYNAMITE_ACTIVE, // RND
4755 EL_WALL_EMERALD_YELLOW,
4756 EL_WALL_EMERALD_RED,
4757 EL_WALL_EMERALD_PURPLE,
4775 EL_DYNABOMB_INCREASE_NUMBER,
4776 EL_DYNABOMB_INCREASE_SIZE,
4777 EL_DYNABOMB_INCREASE_POWER,
4797 EL_INVISIBLE_STEELWALL,
4801 EL_EXPANDABLE_WALL_HORIZONTAL,
4802 EL_EXPANDABLE_WALL_VERTICAL,
4803 EL_EXPANDABLE_WALL_ANY,
4805 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4806 static int *editor_el_rnd_ptr = editor_el_rnd;
4807 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4808 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4810 static int editor_hl_sokoban[] =
4812 EL_INTERNAL_CASCADE_SB_ACTIVE,
4818 static int editor_el_sokoban[] =
4821 EL_SOKOBAN_FIELD_EMPTY,
4822 EL_SOKOBAN_FIELD_FULL,
4823 EL_SOKOBAN_FIELD_PLAYER,
4825 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4826 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4827 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4828 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4830 static int editor_hl_supaplex[] =
4832 EL_INTERNAL_CASCADE_SP_ACTIVE,
4838 static int editor_el_supaplex[] =
4856 EL_SP_PORT_HORIZONTAL,
4857 EL_SP_PORT_VERTICAL,
4865 EL_SP_GRAVITY_PORT_LEFT,
4866 EL_SP_GRAVITY_PORT_RIGHT,
4867 EL_SP_GRAVITY_PORT_UP,
4868 EL_SP_GRAVITY_PORT_DOWN,
4870 EL_SP_GRAVITY_ON_PORT_LEFT,
4871 EL_SP_GRAVITY_ON_PORT_RIGHT,
4872 EL_SP_GRAVITY_ON_PORT_UP,
4873 EL_SP_GRAVITY_ON_PORT_DOWN,
4875 EL_SP_GRAVITY_OFF_PORT_LEFT,
4876 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4877 EL_SP_GRAVITY_OFF_PORT_UP,
4878 EL_SP_GRAVITY_OFF_PORT_DOWN,
4880 EL_SP_HARDWARE_GRAY,
4881 EL_SP_HARDWARE_GREEN,
4882 EL_SP_HARDWARE_BLUE,
4885 EL_SP_HARDWARE_BASE_1,
4886 EL_SP_HARDWARE_BASE_2,
4887 EL_SP_HARDWARE_BASE_3,
4888 EL_SP_HARDWARE_BASE_4,
4890 EL_SP_HARDWARE_BASE_5,
4891 EL_SP_HARDWARE_BASE_6,
4892 EL_SP_HARDWARE_YELLOW,
4900 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4901 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4902 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4903 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4905 static int editor_hl_diamond_caves[] =
4907 EL_INTERNAL_CASCADE_DC_ACTIVE,
4913 static int editor_el_diamond_caves[] =
4915 EL_EM_STEEL_EXIT_CLOSED, // DC2
4916 EL_EM_STEEL_EXIT_OPEN, // DC2
4917 EL_WALL_EMERALD, // DC2
4918 EL_WALL_DIAMOND, // DC2
4925 EL_CONVEYOR_BELT_1_LEFT,
4926 EL_CONVEYOR_BELT_1_MIDDLE,
4927 EL_CONVEYOR_BELT_1_RIGHT,
4928 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4930 EL_CONVEYOR_BELT_2_LEFT,
4931 EL_CONVEYOR_BELT_2_MIDDLE,
4932 EL_CONVEYOR_BELT_2_RIGHT,
4933 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4935 EL_CONVEYOR_BELT_3_LEFT,
4936 EL_CONVEYOR_BELT_3_MIDDLE,
4937 EL_CONVEYOR_BELT_3_RIGHT,
4938 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4940 EL_CONVEYOR_BELT_4_LEFT,
4941 EL_CONVEYOR_BELT_4_MIDDLE,
4942 EL_CONVEYOR_BELT_4_RIGHT,
4943 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4945 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4946 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4947 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4948 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4950 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4951 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4952 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4953 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4958 EL_DC_TIMEGATE_SWITCH,
4960 EL_SWITCHGATE_CLOSED,
4962 EL_SWITCHGATE_SWITCH_UP,
4963 EL_SWITCHGATE_SWITCH_DOWN,
4966 EL_LIGHT_SWITCH_ACTIVE,
4967 EL_DC_SWITCHGATE_SWITCH_UP,
4968 EL_DC_SWITCHGATE_SWITCH_DOWN,
4970 EL_STEEL_EXIT_CLOSED,
4972 EL_STEELWALL_SLIPPERY,
4975 EL_QUICKSAND_FAST_EMPTY,
4976 EL_QUICKSAND_FAST_FULL,
4990 EL_SIGN_RADIOACTIVITY,
4996 EL_SIGN_ENTRY_FORBIDDEN,
4997 EL_SIGN_EMERGENCY_EXIT,
5022 EL_DC_STEELWALL_2_SINGLE,
5023 EL_DC_STEELWALL_2_TOP,
5024 EL_SIGN_EXCLAMATION,
5027 EL_DC_STEELWALL_2_LEFT,
5028 EL_DC_STEELWALL_2_MIDDLE,
5029 EL_DC_STEELWALL_2_HORIZONTAL,
5030 EL_DC_STEELWALL_2_RIGHT,
5032 EL_DC_STEELWALL_1_TOPLEFT,
5033 EL_DC_STEELWALL_2_VERTICAL,
5034 EL_DC_STEELWALL_1_TOPRIGHT,
5037 EL_DC_STEELWALL_1_VERTICAL,
5038 EL_DC_STEELWALL_2_BOTTOM,
5040 EL_DC_GATE_WHITE_GRAY,
5042 EL_DC_STEELWALL_1_BOTTOMLEFT,
5043 EL_DC_STEELWALL_1_HORIZONTAL,
5044 EL_DC_STEELWALL_1_BOTTOMRIGHT,
5045 EL_DC_GATE_FAKE_GRAY,
5047 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
5048 EL_DC_STEELWALL_1_BOTTOM,
5049 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
5050 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
5052 EL_DC_STEELWALL_1_RIGHT,
5054 EL_DC_STEELWALL_1_LEFT,
5055 EL_EXPANDABLE_STEELWALL_VERTICAL,
5057 EL_DC_STEELWALL_1_TOPRIGHT_2,
5058 EL_DC_STEELWALL_1_TOP,
5059 EL_DC_STEELWALL_1_TOPLEFT_2,
5060 EL_EXPANDABLE_STEELWALL_ANY,
5062 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
5063 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
5064 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
5065 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
5067 static int editor_hl_dx_boulderdash[] =
5069 EL_INTERNAL_CASCADE_DX_ACTIVE,
5075 static int editor_el_dx_boulderdash[] =
5079 EL_TUBE_HORIZONTAL_DOWN,
5083 EL_TUBE_VERTICAL_RIGHT,
5085 EL_TUBE_VERTICAL_LEFT,
5089 EL_TUBE_HORIZONTAL_UP,
5097 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
5098 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
5099 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
5100 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
5102 static int editor_hl_mirror_magic[] =
5104 EL_INTERNAL_CASCADE_MM_ACTIVE,
5110 static int editor_el_mirror_magic[] =
5112 EL_MM_MCDUFFIN_RIGHT,
5114 EL_MM_MCDUFFIN_LEFT,
5115 EL_MM_MCDUFFIN_DOWN,
5118 EL_MM_MIRROR_FIXED_START,
5119 EL_MM_POLARIZER_START,
5120 EL_MM_POLARIZER_CROSS_START,
5122 EL_MM_TELEPORTER_RED_START,
5123 EL_MM_TELEPORTER_YELLOW_START,
5124 EL_MM_TELEPORTER_GREEN_START,
5125 EL_MM_TELEPORTER_BLUE_START,
5138 EL_MM_LIGHTBULB_ACTIVE,
5152 EL_MM_STEEL_GRID_FIXED_1,
5153 EL_MM_STEEL_GRID_FIXED_2,
5154 EL_MM_STEEL_GRID_FIXED_3,
5155 EL_MM_STEEL_GRID_FIXED_4,
5157 EL_MM_WOODEN_GRID_FIXED_1,
5158 EL_MM_WOODEN_GRID_FIXED_2,
5159 EL_MM_WOODEN_GRID_FIXED_3,
5160 EL_MM_WOODEN_GRID_FIXED_4,
5167 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
5168 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
5169 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
5170 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
5172 static int editor_hl_deflektor[] =
5174 EL_INTERNAL_CASCADE_DF_ACTIVE,
5180 static int editor_el_deflektor[] =
5187 EL_DF_RECEIVER_RIGHT,
5189 EL_DF_RECEIVER_LEFT,
5190 EL_DF_RECEIVER_DOWN,
5193 EL_DF_MIRROR_ROTATING_START,
5194 EL_DF_MIRROR_FIXED_START,
5197 EL_DF_FIBRE_OPTIC_RED_1,
5198 EL_DF_FIBRE_OPTIC_YELLOW_1,
5199 EL_DF_FIBRE_OPTIC_GREEN_1,
5200 EL_DF_FIBRE_OPTIC_BLUE_1,
5202 EL_DF_STEEL_GRID_FIXED_START,
5203 EL_DF_STEEL_GRID_ROTATING_START,
5204 EL_DF_WOODEN_GRID_FIXED_START,
5205 EL_DF_WOODEN_GRID_ROTATING_START,
5217 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
5218 static int *editor_el_deflektor_ptr = editor_el_deflektor;
5219 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
5220 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
5222 static int editor_hl_chars[] =
5224 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
5230 static int editor_el_chars[] =
5312 EL_CHAR(CHAR_BYTE_COPYRIGHT),
5313 EL_CHAR(CHAR_BYTE_UMLAUT_A),
5314 EL_CHAR(CHAR_BYTE_UMLAUT_O),
5315 EL_CHAR(CHAR_BYTE_UMLAUT_U),
5317 EL_CHAR(CHAR_BYTE_DEGREE),
5318 EL_CHAR(CHAR_BYTE_REGISTERED),
5319 EL_CHAR(FONT_ASCII_CURSOR),
5320 EL_CHAR(FONT_ASCII_BUTTON),
5322 EL_CHAR(FONT_ASCII_UP),
5323 EL_CHAR(FONT_ASCII_DOWN),
5327 static int *editor_hl_chars_ptr = editor_hl_chars;
5328 static int *editor_el_chars_ptr = editor_el_chars;
5329 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
5330 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
5332 static int editor_hl_steel_chars[] =
5334 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
5340 static int editor_el_steel_chars[] =
5350 EL_STEEL_CHAR('\''),
5417 EL_STEEL_CHAR('\\'),
5422 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
5423 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
5424 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
5425 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
5427 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
5428 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
5429 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
5430 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
5432 EL_STEEL_CHAR(FONT_ASCII_UP),
5433 EL_STEEL_CHAR(FONT_ASCII_DOWN),
5437 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
5438 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
5439 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
5440 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
5442 static int editor_hl_custom[] =
5444 EL_INTERNAL_CASCADE_CE_ACTIVE,
5450 static int editor_el_custom[] =
5452 EL_CUSTOM_START + 0,
5453 EL_CUSTOM_START + 1,
5454 EL_CUSTOM_START + 2,
5455 EL_CUSTOM_START + 3,
5457 EL_CUSTOM_START + 4,
5458 EL_CUSTOM_START + 5,
5459 EL_CUSTOM_START + 6,
5460 EL_CUSTOM_START + 7,
5462 EL_CUSTOM_START + 8,
5463 EL_CUSTOM_START + 9,
5464 EL_CUSTOM_START + 10,
5465 EL_CUSTOM_START + 11,
5467 EL_CUSTOM_START + 12,
5468 EL_CUSTOM_START + 13,
5469 EL_CUSTOM_START + 14,
5470 EL_CUSTOM_START + 15,
5472 EL_CUSTOM_START + 16,
5473 EL_CUSTOM_START + 17,
5474 EL_CUSTOM_START + 18,
5475 EL_CUSTOM_START + 19,
5477 EL_CUSTOM_START + 20,
5478 EL_CUSTOM_START + 21,
5479 EL_CUSTOM_START + 22,
5480 EL_CUSTOM_START + 23,
5482 EL_CUSTOM_START + 24,
5483 EL_CUSTOM_START + 25,
5484 EL_CUSTOM_START + 26,
5485 EL_CUSTOM_START + 27,
5487 EL_CUSTOM_START + 28,
5488 EL_CUSTOM_START + 29,
5489 EL_CUSTOM_START + 30,
5490 EL_CUSTOM_START + 31,
5492 EL_CUSTOM_START + 32,
5493 EL_CUSTOM_START + 33,
5494 EL_CUSTOM_START + 34,
5495 EL_CUSTOM_START + 35,
5497 EL_CUSTOM_START + 36,
5498 EL_CUSTOM_START + 37,
5499 EL_CUSTOM_START + 38,
5500 EL_CUSTOM_START + 39,
5502 EL_CUSTOM_START + 40,
5503 EL_CUSTOM_START + 41,
5504 EL_CUSTOM_START + 42,
5505 EL_CUSTOM_START + 43,
5507 EL_CUSTOM_START + 44,
5508 EL_CUSTOM_START + 45,
5509 EL_CUSTOM_START + 46,
5510 EL_CUSTOM_START + 47,
5512 EL_CUSTOM_START + 48,
5513 EL_CUSTOM_START + 49,
5514 EL_CUSTOM_START + 50,
5515 EL_CUSTOM_START + 51,
5517 EL_CUSTOM_START + 52,
5518 EL_CUSTOM_START + 53,
5519 EL_CUSTOM_START + 54,
5520 EL_CUSTOM_START + 55,
5522 EL_CUSTOM_START + 56,
5523 EL_CUSTOM_START + 57,
5524 EL_CUSTOM_START + 58,
5525 EL_CUSTOM_START + 59,
5527 EL_CUSTOM_START + 60,
5528 EL_CUSTOM_START + 61,
5529 EL_CUSTOM_START + 62,
5530 EL_CUSTOM_START + 63,
5532 EL_CUSTOM_START + 64,
5533 EL_CUSTOM_START + 65,
5534 EL_CUSTOM_START + 66,
5535 EL_CUSTOM_START + 67,
5537 EL_CUSTOM_START + 68,
5538 EL_CUSTOM_START + 69,
5539 EL_CUSTOM_START + 70,
5540 EL_CUSTOM_START + 71,
5542 EL_CUSTOM_START + 72,
5543 EL_CUSTOM_START + 73,
5544 EL_CUSTOM_START + 74,
5545 EL_CUSTOM_START + 75,
5547 EL_CUSTOM_START + 76,
5548 EL_CUSTOM_START + 77,
5549 EL_CUSTOM_START + 78,
5550 EL_CUSTOM_START + 79,
5552 EL_CUSTOM_START + 80,
5553 EL_CUSTOM_START + 81,
5554 EL_CUSTOM_START + 82,
5555 EL_CUSTOM_START + 83,
5557 EL_CUSTOM_START + 84,
5558 EL_CUSTOM_START + 85,
5559 EL_CUSTOM_START + 86,
5560 EL_CUSTOM_START + 87,
5562 EL_CUSTOM_START + 88,
5563 EL_CUSTOM_START + 89,
5564 EL_CUSTOM_START + 90,
5565 EL_CUSTOM_START + 91,
5567 EL_CUSTOM_START + 92,
5568 EL_CUSTOM_START + 93,
5569 EL_CUSTOM_START + 94,
5570 EL_CUSTOM_START + 95,
5572 EL_CUSTOM_START + 96,
5573 EL_CUSTOM_START + 97,
5574 EL_CUSTOM_START + 98,
5575 EL_CUSTOM_START + 99,
5577 EL_CUSTOM_START + 100,
5578 EL_CUSTOM_START + 101,
5579 EL_CUSTOM_START + 102,
5580 EL_CUSTOM_START + 103,
5582 EL_CUSTOM_START + 104,
5583 EL_CUSTOM_START + 105,
5584 EL_CUSTOM_START + 106,
5585 EL_CUSTOM_START + 107,
5587 EL_CUSTOM_START + 108,
5588 EL_CUSTOM_START + 109,
5589 EL_CUSTOM_START + 110,
5590 EL_CUSTOM_START + 111,
5592 EL_CUSTOM_START + 112,
5593 EL_CUSTOM_START + 113,
5594 EL_CUSTOM_START + 114,
5595 EL_CUSTOM_START + 115,
5597 EL_CUSTOM_START + 116,
5598 EL_CUSTOM_START + 117,
5599 EL_CUSTOM_START + 118,
5600 EL_CUSTOM_START + 119,
5602 EL_CUSTOM_START + 120,
5603 EL_CUSTOM_START + 121,
5604 EL_CUSTOM_START + 122,
5605 EL_CUSTOM_START + 123,
5607 EL_CUSTOM_START + 124,
5608 EL_CUSTOM_START + 125,
5609 EL_CUSTOM_START + 126,
5610 EL_CUSTOM_START + 127,
5612 EL_CUSTOM_START + 128,
5613 EL_CUSTOM_START + 129,
5614 EL_CUSTOM_START + 130,
5615 EL_CUSTOM_START + 131,
5617 EL_CUSTOM_START + 132,
5618 EL_CUSTOM_START + 133,
5619 EL_CUSTOM_START + 134,
5620 EL_CUSTOM_START + 135,
5622 EL_CUSTOM_START + 136,
5623 EL_CUSTOM_START + 137,
5624 EL_CUSTOM_START + 138,
5625 EL_CUSTOM_START + 139,
5627 EL_CUSTOM_START + 140,
5628 EL_CUSTOM_START + 141,
5629 EL_CUSTOM_START + 142,
5630 EL_CUSTOM_START + 143,
5632 EL_CUSTOM_START + 144,
5633 EL_CUSTOM_START + 145,
5634 EL_CUSTOM_START + 146,
5635 EL_CUSTOM_START + 147,
5637 EL_CUSTOM_START + 148,
5638 EL_CUSTOM_START + 149,
5639 EL_CUSTOM_START + 150,
5640 EL_CUSTOM_START + 151,
5642 EL_CUSTOM_START + 152,
5643 EL_CUSTOM_START + 153,
5644 EL_CUSTOM_START + 154,
5645 EL_CUSTOM_START + 155,
5647 EL_CUSTOM_START + 156,
5648 EL_CUSTOM_START + 157,
5649 EL_CUSTOM_START + 158,
5650 EL_CUSTOM_START + 159,
5652 EL_CUSTOM_START + 160,
5653 EL_CUSTOM_START + 161,
5654 EL_CUSTOM_START + 162,
5655 EL_CUSTOM_START + 163,
5657 EL_CUSTOM_START + 164,
5658 EL_CUSTOM_START + 165,
5659 EL_CUSTOM_START + 166,
5660 EL_CUSTOM_START + 167,
5662 EL_CUSTOM_START + 168,
5663 EL_CUSTOM_START + 169,
5664 EL_CUSTOM_START + 170,
5665 EL_CUSTOM_START + 171,
5667 EL_CUSTOM_START + 172,
5668 EL_CUSTOM_START + 173,
5669 EL_CUSTOM_START + 174,
5670 EL_CUSTOM_START + 175,
5672 EL_CUSTOM_START + 176,
5673 EL_CUSTOM_START + 177,
5674 EL_CUSTOM_START + 178,
5675 EL_CUSTOM_START + 179,
5677 EL_CUSTOM_START + 180,
5678 EL_CUSTOM_START + 181,
5679 EL_CUSTOM_START + 182,
5680 EL_CUSTOM_START + 183,
5682 EL_CUSTOM_START + 184,
5683 EL_CUSTOM_START + 185,
5684 EL_CUSTOM_START + 186,
5685 EL_CUSTOM_START + 187,
5687 EL_CUSTOM_START + 188,
5688 EL_CUSTOM_START + 189,
5689 EL_CUSTOM_START + 190,
5690 EL_CUSTOM_START + 191,
5692 EL_CUSTOM_START + 192,
5693 EL_CUSTOM_START + 193,
5694 EL_CUSTOM_START + 194,
5695 EL_CUSTOM_START + 195,
5697 EL_CUSTOM_START + 196,
5698 EL_CUSTOM_START + 197,
5699 EL_CUSTOM_START + 198,
5700 EL_CUSTOM_START + 199,
5702 EL_CUSTOM_START + 200,
5703 EL_CUSTOM_START + 201,
5704 EL_CUSTOM_START + 202,
5705 EL_CUSTOM_START + 203,
5707 EL_CUSTOM_START + 204,
5708 EL_CUSTOM_START + 205,
5709 EL_CUSTOM_START + 206,
5710 EL_CUSTOM_START + 207,
5712 EL_CUSTOM_START + 208,
5713 EL_CUSTOM_START + 209,
5714 EL_CUSTOM_START + 210,
5715 EL_CUSTOM_START + 211,
5717 EL_CUSTOM_START + 212,
5718 EL_CUSTOM_START + 213,
5719 EL_CUSTOM_START + 214,
5720 EL_CUSTOM_START + 215,
5722 EL_CUSTOM_START + 216,
5723 EL_CUSTOM_START + 217,
5724 EL_CUSTOM_START + 218,
5725 EL_CUSTOM_START + 219,
5727 EL_CUSTOM_START + 220,
5728 EL_CUSTOM_START + 221,
5729 EL_CUSTOM_START + 222,
5730 EL_CUSTOM_START + 223,
5732 EL_CUSTOM_START + 224,
5733 EL_CUSTOM_START + 225,
5734 EL_CUSTOM_START + 226,
5735 EL_CUSTOM_START + 227,
5737 EL_CUSTOM_START + 228,
5738 EL_CUSTOM_START + 229,
5739 EL_CUSTOM_START + 230,
5740 EL_CUSTOM_START + 231,
5742 EL_CUSTOM_START + 232,
5743 EL_CUSTOM_START + 233,
5744 EL_CUSTOM_START + 234,
5745 EL_CUSTOM_START + 235,
5747 EL_CUSTOM_START + 236,
5748 EL_CUSTOM_START + 237,
5749 EL_CUSTOM_START + 238,
5750 EL_CUSTOM_START + 239,
5752 EL_CUSTOM_START + 240,
5753 EL_CUSTOM_START + 241,
5754 EL_CUSTOM_START + 242,
5755 EL_CUSTOM_START + 243,
5757 EL_CUSTOM_START + 244,
5758 EL_CUSTOM_START + 245,
5759 EL_CUSTOM_START + 246,
5760 EL_CUSTOM_START + 247,
5762 EL_CUSTOM_START + 248,
5763 EL_CUSTOM_START + 249,
5764 EL_CUSTOM_START + 250,
5765 EL_CUSTOM_START + 251,
5767 EL_CUSTOM_START + 252,
5768 EL_CUSTOM_START + 253,
5769 EL_CUSTOM_START + 254,
5770 EL_CUSTOM_START + 255
5772 static int *editor_hl_custom_ptr = editor_hl_custom;
5773 static int *editor_el_custom_ptr = editor_el_custom;
5774 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5775 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5777 static int editor_hl_group[] =
5779 EL_INTERNAL_CASCADE_GE_ACTIVE,
5785 static int editor_el_group[] =
5799 EL_GROUP_START + 10,
5800 EL_GROUP_START + 11,
5802 EL_GROUP_START + 12,
5803 EL_GROUP_START + 13,
5804 EL_GROUP_START + 14,
5805 EL_GROUP_START + 15,
5807 EL_GROUP_START + 16,
5808 EL_GROUP_START + 17,
5809 EL_GROUP_START + 18,
5810 EL_GROUP_START + 19,
5812 EL_GROUP_START + 20,
5813 EL_GROUP_START + 21,
5814 EL_GROUP_START + 22,
5815 EL_GROUP_START + 23,
5817 EL_GROUP_START + 24,
5818 EL_GROUP_START + 25,
5819 EL_GROUP_START + 26,
5820 EL_GROUP_START + 27,
5822 EL_GROUP_START + 28,
5823 EL_GROUP_START + 29,
5824 EL_GROUP_START + 30,
5827 static int *editor_hl_group_ptr = editor_hl_group;
5828 static int *editor_el_group_ptr = editor_el_group;
5829 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5830 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5832 static int editor_hl_empty_space[] =
5834 EL_INTERNAL_CASCADE_ES_ACTIVE,
5840 static int editor_el_empty_space[] =
5862 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
5863 static int *editor_el_empty_space_ptr = editor_el_empty_space;
5864 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
5865 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
5867 static int editor_hl_reference[] =
5869 EL_INTERNAL_CASCADE_REF_ACTIVE,
5875 static int editor_el_reference[] =
5879 EL_TRIGGER_CE_VALUE,
5880 EL_TRIGGER_CE_SCORE,
5884 EL_CURRENT_CE_VALUE,
5885 EL_CURRENT_CE_SCORE,
5907 static int *editor_hl_reference_ptr = editor_hl_reference;
5908 static int *editor_el_reference_ptr = editor_el_reference;
5909 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5910 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5912 static int editor_hl_user_defined[] =
5914 EL_INTERNAL_CASCADE_USER_ACTIVE,
5920 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5921 static int *editor_el_user_defined_ptr = NULL;
5922 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5923 static int num_editor_el_user_defined = 0;
5925 static int editor_hl_dynamic[] =
5927 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5933 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5934 static int *editor_el_dynamic_ptr = NULL;
5935 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5936 static int num_editor_el_dynamic = 0;
5938 static int editor_hl_empty[] = { EL_EMPTY };
5939 static int *editor_el_empty = NULL; // dynamically allocated
5941 static int *editor_hl_empty_ptr = editor_hl_empty;
5942 static int *editor_el_empty_ptr = NULL;
5943 static int num_editor_hl_empty = 0;
5944 static int num_editor_el_empty = 0; // dynamically determined, if needed
5946 static boolean use_el_empty = FALSE;
5948 static int *editor_elements = NULL; // dynamically allocated
5949 static int num_editor_elements = 0; // dynamically determined
5951 static boolean setup_editor_cascade_never = FALSE;
5953 static boolean setup_editor_el_players = TRUE;
5954 static boolean setup_editor_el_boulderdash = TRUE;
5955 static boolean setup_editor_el_boulderdash_native = TRUE;
5956 static boolean setup_editor_el_emerald_mine = TRUE;
5957 static boolean setup_editor_el_emerald_mine_club = TRUE;
5958 static boolean setup_editor_el_more = TRUE;
5959 static boolean setup_editor_el_sokoban = TRUE;
5960 static boolean setup_editor_el_supaplex = TRUE;
5961 static boolean setup_editor_el_diamond_caves = TRUE;
5962 static boolean setup_editor_el_dx_boulderdash = TRUE;
5963 static boolean setup_editor_el_mirror_magic = TRUE;
5964 static boolean setup_editor_el_deflektor = TRUE;
5965 static boolean setup_editor_el_chars = TRUE;
5966 static boolean setup_editor_el_steel_chars = TRUE;
5967 static boolean setup_editor_el_custom = TRUE;
5968 static boolean setup_editor_el_user_defined = TRUE;
5969 static boolean setup_editor_el_dynamic = TRUE;
5971 static int editor_hl_unused[] = { EL_EMPTY };
5972 static int *editor_hl_unused_ptr = editor_hl_unused;
5973 static int num_editor_hl_unused = 0;
5977 boolean *setup_value;
5978 boolean *setup_cascade_value;
5980 int **headline_list;
5981 int *headline_list_size;
5984 int *element_list_size;
5986 boolean last_setup_value;
5988 editor_elements_info[] =
5991 &setup_editor_el_players,
5992 &setup_editor_cascade_never,
5993 &editor_hl_unused_ptr, &num_editor_hl_unused,
5994 &editor_el_players_ptr, &num_editor_el_players
5997 &setup_editor_el_boulderdash,
5998 &setup.editor_cascade.el_bd,
5999 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
6000 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
6003 &setup_editor_el_boulderdash_native,
6004 &setup.editor_cascade.el_bd_native,
6005 &editor_hl_boulderdash_native_ptr, &num_editor_hl_boulderdash_native,
6006 &editor_el_boulderdash_native_ptr, &num_editor_el_boulderdash_native
6009 &setup_editor_el_emerald_mine,
6010 &setup.editor_cascade.el_em,
6011 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
6012 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
6015 &setup_editor_el_emerald_mine_club,
6016 &setup.editor_cascade.el_emc,
6017 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
6018 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
6021 &setup_editor_el_more,
6022 &setup.editor_cascade.el_rnd,
6023 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
6024 &editor_el_rnd_ptr, &num_editor_el_rnd
6027 &setup_editor_el_sokoban,
6028 &setup.editor_cascade.el_sb,
6029 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
6030 &editor_el_sokoban_ptr, &num_editor_el_sokoban
6033 &setup_editor_el_supaplex,
6034 &setup.editor_cascade.el_sp,
6035 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
6036 &editor_el_supaplex_ptr, &num_editor_el_supaplex
6039 &setup_editor_el_diamond_caves,
6040 &setup.editor_cascade.el_dc,
6041 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
6042 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
6045 &setup_editor_el_dx_boulderdash,
6046 &setup.editor_cascade.el_dx,
6047 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
6048 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
6051 &setup_editor_el_mirror_magic,
6052 &setup.editor_cascade.el_mm,
6053 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
6054 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
6057 &setup_editor_el_deflektor,
6058 &setup.editor_cascade.el_df,
6059 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
6060 &editor_el_deflektor_ptr, &num_editor_el_deflektor
6063 &setup_editor_el_chars,
6064 &setup.editor_cascade.el_chars,
6065 &editor_hl_chars_ptr, &num_editor_hl_chars,
6066 &editor_el_chars_ptr, &num_editor_el_chars
6069 &setup_editor_el_steel_chars,
6070 &setup.editor_cascade.el_steel_chars,
6071 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
6072 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
6075 &setup_editor_el_custom,
6076 &setup.editor_cascade.el_ce,
6077 &editor_hl_custom_ptr, &num_editor_hl_custom,
6078 &editor_el_custom_ptr, &num_editor_el_custom
6081 &setup_editor_el_custom,
6082 &setup.editor_cascade.el_ge,
6083 &editor_hl_group_ptr, &num_editor_hl_group,
6084 &editor_el_group_ptr, &num_editor_el_group
6087 &setup_editor_el_custom,
6088 &setup.editor_cascade.el_es,
6089 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
6090 &editor_el_empty_space_ptr, &num_editor_el_empty_space
6093 &setup_editor_el_custom,
6094 &setup.editor_cascade.el_ref,
6095 &editor_hl_reference_ptr, &num_editor_hl_reference,
6096 &editor_el_reference_ptr, &num_editor_el_reference
6099 &setup_editor_el_user_defined,
6100 &setup.editor_cascade.el_user,
6101 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
6102 &editor_el_user_defined_ptr, &num_editor_el_user_defined
6105 &setup_editor_el_dynamic,
6106 &setup.editor_cascade.el_dynamic,
6107 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
6108 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
6113 &editor_hl_empty_ptr, &num_editor_hl_empty,
6114 &editor_el_empty_ptr, &num_editor_el_empty,
6124 static struct XY xy_directions[] =
6133 // ----------------------------------------------------------------------------
6135 // ----------------------------------------------------------------------------
6137 static int getMaxInfoTextLength(void)
6139 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
6142 static int getTextWidthForGadget(char *text)
6147 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
6150 static int getTextWidthForDrawingArea(char *text)
6155 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
6158 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
6160 return (gi->x + gi->width + getTextWidthForGadget(text));
6163 static char *getElementInfoText(int element)
6165 char *info_text = NULL;
6167 if (element < MAX_NUM_ELEMENTS)
6169 if (strlen(element_info[element].description) > 0)
6170 info_text = element_info[element].description;
6171 else if (element_info[element].custom_description != NULL)
6172 info_text = element_info[element].custom_description;
6173 else if (element_info[element].editor_description != NULL)
6174 info_text = element_info[element].editor_description;
6177 if (info_text == NULL)
6178 info_text = INFOTEXT_UNKNOWN_ELEMENT;
6183 static char *getElementDescriptionFilenameExt(char *basename)
6185 char *elements_subdir = ELEMENTS_DIRECTORY;
6186 static char *elements_subdir2 = NULL;
6187 static char *filename = NULL;
6189 if (elements_subdir2 == NULL)
6190 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
6192 checked_free(filename);
6194 // 1st try: look for element description in current level set directory
6195 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
6196 if (fileExists(filename))
6201 // 2nd try: look for element description in the game's base directory
6202 filename = getPath3(options.docs_directory, elements_subdir, basename);
6203 if (fileExists(filename))
6209 static char *getElementDescriptionFilename(int element)
6211 char basename[MAX_FILENAME_LEN];
6214 // 1st try: look for element description file for exactly this element
6215 sprintf(basename, "%s.txt", element_info[element].token_name);
6216 filename = getElementDescriptionFilenameExt(basename);
6217 if (filename != NULL)
6220 // 2nd try: look for element description file for this element's class
6221 sprintf(basename, "%s.txt", element_info[element].class_name);
6222 filename = getElementDescriptionFilenameExt(basename);
6223 if (filename != NULL)
6226 // 3rd try: look for generic fallback text file for any element
6227 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
6228 if (filename != NULL)
6234 static boolean suppressBorderElement(void)
6236 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
6237 lev_fieldx <= MAX_ED_FIELDX &&
6238 lev_fieldy <= MAX_ED_FIELDY);
6241 static void InitDynamicEditorElementList(int **elements, int *num_elements)
6243 boolean element_found[NUM_FILE_ELEMENTS];
6246 // initialize list of used elements to "not used"
6247 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6248 element_found[i] = FALSE;
6250 // find all elements used in current level
6251 for (y = 0; y < lev_fieldy; y++)
6253 for (x = 0; x < lev_fieldx; x++)
6255 if (Tile[x][y] >= NUM_FILE_ELEMENTS) // should never happen
6258 if (IS_MM_WALL(Tile[x][y]))
6259 element_found[map_mm_wall_element(Tile[x][y])] = TRUE;
6261 element_found[Tile[x][y]] = TRUE;
6267 // count number of elements used in current level
6268 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6269 if (element_found[i])
6272 // add space for up to 3 more elements for padding that may be needed
6275 // free memory for old list of elements, if needed
6276 checked_free(*elements);
6278 // allocate memory for new list of elements
6279 *elements = checked_malloc(*num_elements * sizeof(int));
6283 // add all elements used in current level (non-custom/group/empty elements)
6284 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6285 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) ||
6286 IS_GROUP_ELEMENT(i) ||
6287 IS_EMPTY_ELEMENT(i)))
6288 (*elements)[(*num_elements)++] = i;
6290 // add all elements used in current level (custom/group/empty elements)
6291 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6292 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) ||
6293 IS_GROUP_ELEMENT(i) ||
6294 IS_EMPTY_ELEMENT(i)))
6295 (*elements)[(*num_elements)++] = i;
6297 while (*num_elements % 4) // pad with empty elements, if needed
6298 (*elements)[(*num_elements)++] = EL_EMPTY;
6301 static void ReinitializeElementList_EnableSections(void)
6303 // default: enable all element sections
6305 setup_editor_el_players = TRUE;
6306 setup_editor_el_boulderdash = TRUE;
6307 setup_editor_el_boulderdash_native = TRUE;
6308 setup_editor_el_emerald_mine = TRUE;
6309 setup_editor_el_emerald_mine_club = TRUE;
6310 setup_editor_el_more = TRUE;
6311 setup_editor_el_sokoban = TRUE;
6312 setup_editor_el_supaplex = TRUE;
6313 setup_editor_el_diamond_caves = TRUE;
6314 setup_editor_el_dx_boulderdash = TRUE;
6315 setup_editor_el_mirror_magic = TRUE;
6316 setup_editor_el_deflektor = TRUE;
6317 setup_editor_el_chars = TRUE;
6318 setup_editor_el_steel_chars = TRUE;
6320 setup_editor_el_custom = TRUE;
6321 setup_editor_el_user_defined = TRUE;
6322 setup_editor_el_dynamic = TRUE;
6324 // now disable all element sections not to be displayed
6326 if (!setup.editor.el_classic)
6328 setup_editor_el_players = FALSE;
6329 setup_editor_el_boulderdash = FALSE;
6330 setup_editor_el_boulderdash_native = FALSE;
6331 setup_editor_el_emerald_mine = FALSE;
6332 setup_editor_el_emerald_mine_club = FALSE;
6333 setup_editor_el_more = FALSE;
6334 setup_editor_el_sokoban = FALSE;
6335 setup_editor_el_supaplex = FALSE;
6336 setup_editor_el_diamond_caves = FALSE;
6337 setup_editor_el_dx_boulderdash = FALSE;
6338 setup_editor_el_mirror_magic = FALSE;
6339 setup_editor_el_deflektor = FALSE;
6340 setup_editor_el_chars = FALSE;
6341 setup_editor_el_steel_chars = FALSE;
6344 if (!setup.editor.el_custom)
6346 setup_editor_el_custom = FALSE;
6349 if (!setup.editor.el_user_defined)
6351 setup_editor_el_user_defined = FALSE;
6354 if (!setup.editor.el_dynamic)
6356 setup_editor_el_dynamic = FALSE;
6359 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
6361 setup_editor_el_boulderdash_native = FALSE;
6362 setup_editor_el_mirror_magic = FALSE;
6363 setup_editor_el_deflektor = FALSE;
6365 else if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
6367 setup_editor_el_players = FALSE;
6368 setup_editor_el_boulderdash = FALSE;
6369 setup_editor_el_emerald_mine = FALSE;
6370 setup_editor_el_emerald_mine_club = FALSE;
6371 setup_editor_el_more = FALSE;
6372 setup_editor_el_sokoban = FALSE;
6373 setup_editor_el_supaplex = FALSE;
6374 setup_editor_el_diamond_caves = FALSE;
6375 setup_editor_el_dx_boulderdash = FALSE;
6376 setup_editor_el_mirror_magic = FALSE;
6377 setup_editor_el_deflektor = FALSE;
6378 setup_editor_el_chars = FALSE;
6379 setup_editor_el_steel_chars = FALSE;
6381 setup_editor_el_custom = FALSE;
6383 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
6385 setup_editor_el_boulderdash = FALSE;
6386 setup_editor_el_boulderdash_native = FALSE;
6387 setup_editor_el_more = FALSE;
6388 setup_editor_el_sokoban = FALSE;
6389 setup_editor_el_supaplex = FALSE;
6390 setup_editor_el_diamond_caves = FALSE;
6391 setup_editor_el_dx_boulderdash = FALSE;
6392 setup_editor_el_mirror_magic = FALSE;
6393 setup_editor_el_deflektor = FALSE;
6394 setup_editor_el_steel_chars = FALSE;
6396 setup_editor_el_custom = FALSE;
6398 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
6400 setup_editor_el_players = FALSE;
6401 setup_editor_el_boulderdash = FALSE;
6402 setup_editor_el_boulderdash_native = FALSE;
6403 setup_editor_el_emerald_mine = FALSE;
6404 setup_editor_el_emerald_mine_club = FALSE;
6405 setup_editor_el_more = FALSE;
6406 setup_editor_el_sokoban = FALSE;
6407 setup_editor_el_diamond_caves = FALSE;
6408 setup_editor_el_dx_boulderdash = FALSE;
6409 setup_editor_el_mirror_magic = FALSE;
6410 setup_editor_el_deflektor = FALSE;
6411 setup_editor_el_chars = FALSE;
6412 setup_editor_el_steel_chars = FALSE;
6414 setup_editor_el_custom = FALSE;
6416 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
6418 setup_editor_el_players = FALSE;
6419 setup_editor_el_boulderdash = FALSE;
6420 setup_editor_el_boulderdash_native = FALSE;
6421 setup_editor_el_emerald_mine = FALSE;
6422 setup_editor_el_emerald_mine_club = FALSE;
6423 setup_editor_el_more = FALSE;
6424 setup_editor_el_sokoban = FALSE;
6425 setup_editor_el_supaplex = FALSE;
6426 setup_editor_el_diamond_caves = FALSE;
6427 setup_editor_el_dx_boulderdash = FALSE;
6428 setup_editor_el_steel_chars = FALSE;
6430 setup_editor_el_custom = FALSE;
6434 static void ReinitializeElementList(void)
6436 static boolean initialization_needed = TRUE;
6440 ReinitializeElementList_EnableSections();
6442 if (initialization_needed)
6444 LoadSetup_EditorCascade(); // load last editor cascade state
6446 // initialize editor cascade element from saved cascade state
6447 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6449 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
6450 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
6452 if (IS_EDITOR_CASCADE(*cascade_element))
6454 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
6455 EL_CASCADE_INACTIVE(*cascade_element));
6458 initialization_needed = FALSE;
6461 checked_free(editor_elements);
6463 // reload optional user defined element list for each invocation of editor
6464 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
6465 &num_editor_el_user_defined);
6467 // initialize dynamic level element list for each invocation of editor
6468 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
6469 &num_editor_el_dynamic);
6471 // initialize list of empty elements (used for padding, if needed)
6472 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6473 editor_el_empty[i] = EL_EMPTY;
6475 // do some sanity checks for each element from element list
6476 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6478 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6480 int element = (*editor_elements_info[i].element_list)[j];
6482 if (element >= NUM_FILE_ELEMENTS)
6483 Warn("editor element %d is runtime element", element);
6485 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
6486 Warn("no element description text for element %d", element);
6490 num_editor_elements = 0;
6491 use_el_empty = FALSE;
6493 // determine size of element list
6494 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6496 if (*editor_elements_info[i].setup_value)
6498 boolean found_inactive_cascade = FALSE;
6500 if (setup.editor.el_headlines)
6502 // required for correct padding of palette headline buttons
6503 if (*editor_elements_info[i].headline_list_size > 0)
6504 num_editor_elements += ED_ELEMENTLIST_COLS;
6506 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6508 int element = (*editor_elements_info[i].headline_list)[j];
6510 if (IS_EDITOR_CASCADE_INACTIVE(element))
6511 found_inactive_cascade = TRUE;
6515 if (found_inactive_cascade)
6518 // required for correct padding of palette element buttons
6519 int element_list_size = *editor_elements_info[i].element_list_size;
6521 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6522 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6524 num_editor_elements += element_buttons;
6528 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
6530 // offer at least as many elements as element buttons exist
6531 use_el_empty = TRUE;
6532 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
6534 num_editor_elements += num_editor_el_empty;
6538 num_editor_el_empty = 0;
6541 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
6543 // fill element list
6544 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6546 boolean found_inactive_cascade = FALSE;
6548 if (*editor_elements_info[i].setup_value)
6550 if (setup.editor.el_headlines)
6552 // required for correct padding of palette headline buttons
6553 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6554 ED_ELEMENTLIST_COLS : 0);
6556 for (j = 0; j < headline_size; j++)
6558 // use empty elements for padding of palette headline buttons
6559 int element = (j < *editor_elements_info[i].headline_list_size ?
6560 (*editor_elements_info[i].headline_list)[j] :
6561 editor_el_empty[0]);
6563 editor_elements[pos++] = element;
6565 if (IS_EDITOR_CASCADE_INACTIVE(element))
6566 found_inactive_cascade = TRUE;
6570 if (found_inactive_cascade)
6573 // required for correct padding of palette element buttons
6574 int element_list_size = *editor_elements_info[i].element_list_size;
6576 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6577 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6579 // copy all elements from element list
6580 for (j = 0; j < element_list_size; j++)
6581 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6583 // use empty elements for padding of palette element buttons
6584 for (j = 0; j < element_buttons - element_list_size; j++)
6585 editor_elements[pos++] = editor_el_empty[0];
6589 // (this function is also called before editor gadgets are initialized!)
6590 AdjustElementListScrollbar();
6593 void PrintEditorElementList(void)
6595 boolean *stop = &setup_editor_el_user_defined;
6598 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6600 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6602 if (IS_EDITOR_CASCADE(cascade_element))
6604 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6605 char *headline = element_info[cascade_element_show].editor_description;
6607 PrintLineWithPrefix("# ", "-", 77);
6608 Print("# %s\n", headline);
6609 PrintLineWithPrefix("# ", "-", 77);
6612 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6614 int element = (*editor_elements_info[i].headline_list)[j];
6616 if (IS_EDITOR_CASCADE(element))
6617 element = EL_CHAR_MINUS;
6619 Print("# %s\n", element_info[element].token_name);
6625 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6627 int element = (*editor_elements_info[i].element_list)[j];
6629 Print("# %s\n", element_info[element].token_name);
6637 static void ReinitializeElementListButtons(void)
6639 static boolean last_setup_value_headlines = FALSE;
6640 static boolean initialization_needed = TRUE;
6643 if (!initialization_needed) // check if editor element setup has changed
6645 if (last_setup_value_headlines != setup.editor.el_headlines)
6646 initialization_needed = TRUE;
6648 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6649 if (editor_elements_info[i].last_setup_value !=
6650 *editor_elements_info[i].setup_value)
6651 initialization_needed = TRUE;
6654 if (!initialization_needed)
6657 FreeLevelEditorGadgets();
6658 CreateLevelEditorGadgets();
6660 // store current setup values for next invocation of this function
6661 last_setup_value_headlines = setup.editor.el_headlines;
6662 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6663 editor_elements_info[i].last_setup_value =
6664 *editor_elements_info[i].setup_value;
6666 initialization_needed = FALSE;
6669 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6672 int border_graphic =
6673 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6674 struct GraphicInfo *g = &graphic_info[border_graphic];
6675 Bitmap *src_bitmap = g->bitmap;
6676 int src_x = g->src_x;
6677 int src_y = g->src_y;
6678 int border_size = g->border_size;
6679 int border_xpos = g->width - border_size;
6680 int border_ypos = g->height - border_size;
6681 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6684 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6685 border_size, border_size,
6686 dest_x - border_size, dest_y - border_size);
6687 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6688 border_size, border_size,
6689 dest_x + width, dest_y - border_size);
6690 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6691 border_size, border_size,
6692 dest_x - border_size, dest_y + height);
6693 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6694 border_size, border_size,
6695 dest_x + width, dest_y + height);
6697 for (i = 0; i < width / tilesize; i++)
6699 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6700 tilesize, border_size,
6701 dest_x + i * tilesize, dest_y - border_size);
6702 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6703 tilesize, border_size,
6704 dest_x + i * tilesize, dest_y + height);
6707 for (i = 0; i < height / tilesize; i++)
6709 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6710 border_size, tilesize,
6711 dest_x - border_size, dest_y + i * tilesize);
6712 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6713 border_size, tilesize,
6714 dest_x + width, dest_y + i * tilesize);
6717 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6720 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6722 int xsize_tile = MAX(ed_tilesize, xsize);
6723 int ysize_tile = MAX(ed_tilesize, ysize);
6724 int xsize_full = xsize + 1;
6725 int ysize_full = ysize + 1;
6726 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6727 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6728 Pixel line_color = getTabulatorBarColor();
6730 if (line_color == BLACK_PIXEL) // black => transparent
6733 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6734 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6735 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6738 static void DrawEditorLevelBorderLinesIfNeeded(void)
6740 int xsize = lev_fieldx * ed_tilesize;
6741 int ysize = lev_fieldy * ed_tilesize;
6742 int line_size = getTabulatorBarHeight();
6744 if (!suppressBorderElement())
6747 // draw little border line around editable level playfield
6750 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6753 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6755 if (xsize < SXSIZE && ysize < SYSIZE)
6756 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6759 static void DrawEditorElement(int x, int y, int element)
6761 DrawSizedElement(x, y, element, ed_tilesize);
6764 static void DrawEditorElementThruMask(int x, int y, int element)
6766 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6769 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6771 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6774 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6776 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6777 DrawEditorLevelBorderLinesIfNeeded();
6780 static void DrawDrawingArea(int id)
6782 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6785 int *value = drawingarea_info[id].value;
6786 int area_xsize = drawingarea_info[id].area_xsize;
6787 int area_ysize = drawingarea_info[id].area_ysize;
6788 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6790 for (x = 0; x < area_xsize; x++)
6791 for (y = 0; y < area_ysize; y++)
6792 DrawSizedGraphicExt(drawto,
6793 gi->x + x * tilesize,
6794 gi->y + y * tilesize,
6795 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6798 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6801 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6802 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6804 BlitBitmap(drawto, drawto,
6805 SX + (dx == -1 ? ed_tilesize : 0),
6806 SY + (dy == -1 ? ed_tilesize : 0),
6807 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6808 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6809 SX + (dx == +1 ? ed_tilesize : 0),
6810 SY + (dy == +1 ? ed_tilesize : 0));
6814 x = (dx == 1 ? 0 : ed_fieldx - 1);
6815 for (y = 0; y < ed_fieldy; y++)
6816 DrawEditorElementOrWall(x, y, from_x, from_y);
6820 y = (dy == 1 ? 0 : ed_fieldy - 1);
6821 for (x = 0; x < ed_fieldx; x++)
6822 DrawEditorElementOrWall(x, y, from_x, from_y);
6825 redraw_mask |= REDRAW_FIELD;
6829 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6832 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6835 static void CreateControlButtons(void)
6837 struct GadgetInfo *gi;
6840 // create toolbox buttons
6841 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6843 int type_id = controlbutton_info[i].gadget_id; // same as gadget ID here
6844 int id = controlbutton_info[i].gadget_id;
6845 int type = controlbutton_info[i].gadget_type;
6846 int graphic = controlbutton_info[i].graphic;
6847 struct XYTileSize *pos = controlbutton_info[i].pos;
6848 struct GraphicInfo *gd = &graphic_info[graphic];
6849 Bitmap *deco_bitmap = NULL;
6850 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6851 int tile_size = 0, deco_shift = 0;
6852 boolean deco_masked = FALSE;
6853 int gd_x1 = gd->src_x;
6854 int gd_y1 = gd->src_y;
6855 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6856 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6857 int gd_x1a = gd->src_x + gd->active_xoffset;
6858 int gd_y1a = gd->src_y + gd->active_yoffset;
6859 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6860 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6863 unsigned int event_mask;
6864 int radio_button_nr = RADIO_NR_NONE;
6865 boolean checked = FALSE;
6868 Fail("'controlbutton_info' structure corrupted at index %d -- please fix", i);
6870 if (type == GD_TYPE_RADIO_BUTTON)
6872 event_mask = GD_EVENT_PRESSED;
6873 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6875 if (id == drawing_function)
6880 if (id == GADGET_ID_WRAP_LEFT ||
6881 id == GADGET_ID_WRAP_RIGHT ||
6882 id == GADGET_ID_WRAP_UP ||
6883 id == GADGET_ID_WRAP_DOWN)
6884 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6886 event_mask = GD_EVENT_RELEASED;
6889 if (id == GADGET_ID_PROPERTIES ||
6890 id == GADGET_ID_PALETTE)
6895 else if (id == GADGET_ID_ELEMENT_LEFT ||
6896 id == GADGET_ID_ELEMENT_MIDDLE ||
6897 id == GADGET_ID_ELEMENT_RIGHT)
6902 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6903 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6904 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6906 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6907 editor.button.element_left.tile_size :
6908 id == GADGET_ID_ELEMENT_MIDDLE ?
6909 editor.button.element_middle.tile_size :
6910 id == GADGET_ID_ELEMENT_RIGHT ?
6911 editor.button.element_right.tile_size : 0);
6913 // make sure that decoration does not overlap gadget border
6914 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6916 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6918 deco_xpos = (gd->width - tile_size) / 2;
6919 deco_ypos = (gd->height - tile_size) / 2;
6921 deco_masked = gd->draw_masked;
6929 gi = CreateGadget(GDI_CUSTOM_ID, id,
6930 GDI_CUSTOM_TYPE_ID, type_id,
6931 GDI_IMAGE_ID, graphic,
6932 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6935 GDI_WIDTH, gd->width,
6936 GDI_HEIGHT, gd->height,
6938 GDI_STATE, GD_BUTTON_UNPRESSED,
6939 GDI_RADIO_NR, radio_button_nr,
6940 GDI_CHECKED, checked,
6941 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6942 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6943 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6944 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6945 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6946 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6947 GDI_DECORATION_SIZE, tile_size, tile_size,
6948 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6949 GDI_DECORATION_MASKED, deco_masked,
6950 GDI_EVENT_MASK, event_mask,
6951 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6952 GDI_CALLBACK_ACTION, HandleControlButtons,
6956 Fail("cannot create gadget");
6958 level_editor_gadget[id] = gi;
6961 // these values are not constant, but can change at runtime
6962 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6963 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6964 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6965 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6966 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6967 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6968 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6969 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6970 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6971 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6972 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6973 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6975 // create buttons for scrolling of drawing area and element list
6976 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6978 int id = scrollbutton_info[i].gadget_id;
6979 int type_id = scrollbutton_info[i].gadget_type_id;
6980 int graphic = scrollbutton_info[i].graphic;
6981 struct GraphicInfo *gd = &graphic_info[graphic];
6982 Bitmap *gd_bitmap = gd->bitmap;
6983 int gd_x1 = gd->src_x;
6984 int gd_y1 = gd->src_y;
6985 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6986 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6987 int width = gd->width;
6988 int height = gd->height;
6989 int x = scrollbutton_pos[i].x;
6990 int y = scrollbutton_pos[i].y;
6991 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6994 Fail("'scrollbutton_info' structure corrupted at index %d -- please fix", i);
6996 if (id == GADGET_ID_SCROLL_LIST_UP ||
6997 id == GADGET_ID_SCROLL_LIST_DOWN)
7008 gi = CreateGadget(GDI_CUSTOM_ID, id,
7009 GDI_CUSTOM_TYPE_ID, type_id,
7010 GDI_IMAGE_ID, graphic,
7011 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
7016 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7017 GDI_STATE, GD_BUTTON_UNPRESSED,
7018 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7019 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7020 GDI_EVENT_MASK, event_mask,
7021 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7022 GDI_CALLBACK_ACTION, HandleControlButtons,
7026 Fail("cannot create gadget");
7028 level_editor_gadget[id] = gi;
7031 // create buttons for element list
7032 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7035 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
7036 int graphic = IMG_EDITOR_PALETTE_BUTTON;
7037 struct GraphicInfo *gd = &graphic_info[graphic];
7038 Bitmap *gd_bitmap = gd->bitmap;
7039 Bitmap *deco_bitmap;
7040 int deco_x, deco_y, deco_xpos, deco_ypos;
7041 int gd_x1 = gd->src_x;
7042 int gd_y1 = gd->src_y;
7043 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7044 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7045 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
7046 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
7047 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
7048 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
7049 int element = editor_elements[i];
7050 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
7051 unsigned int event_mask = GD_EVENT_RELEASED;
7053 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
7055 deco_xpos = (gd->width - tile_size) / 2;
7056 deco_ypos = (gd->height - tile_size) / 2;
7058 gi = CreateGadget(GDI_CUSTOM_ID, id,
7059 GDI_CUSTOM_TYPE_ID, type_id,
7060 GDI_IMAGE_ID, graphic,
7061 GDI_INFO_TEXT, getElementInfoText(element),
7064 GDI_WIDTH, gd->width,
7065 GDI_HEIGHT, gd->height,
7066 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7067 GDI_STATE, GD_BUTTON_UNPRESSED,
7068 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7069 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7070 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7071 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7072 GDI_DECORATION_SIZE, tile_size, tile_size,
7073 GDI_DECORATION_SHIFTING, 1, 1,
7074 GDI_EVENT_MASK, event_mask,
7075 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7076 GDI_CALLBACK_ACTION, HandleControlButtons,
7080 Fail("cannot create gadget");
7082 level_editor_gadget[id] = gi;
7086 static void CreateCounterButtons(void)
7088 int max_infotext_len = getMaxInfoTextLength();
7091 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
7093 int type_id = counterbutton_info[i].gadget_type_id;
7094 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
7095 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
7099 Fail("'counterbutton_info' structure corrupted at index %d -- please fix", i);
7101 // determine horizontal position to the right of specified gadget
7102 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7103 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
7104 ED_GADGET_TEXT_DISTANCE);
7106 // determine horizontal offset for leading text
7107 if (counterbutton_info[i].text_left != NULL)
7108 x += getTextWidthForGadget(counterbutton_info[i].text_left);
7110 for (j = 0; j < 2; j++)
7112 struct GadgetInfo *gi;
7114 counterbutton_info[i].gadget_id_down :
7115 counterbutton_info[i].gadget_id_up);
7117 struct GraphicInfo *gd;
7118 int gd_x1, gd_x2, gd_y1, gd_y2;
7119 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7120 char infotext[max_infotext_len + 1];
7122 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7125 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
7126 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
7128 event_mask |= GD_EVENT_RELEASED;
7132 x = DX + editor.button.prev_level.x;
7133 y = DY + editor.button.prev_level.y;
7137 x = DX + editor.button.next_level.x;
7138 y = DY + editor.button.next_level.y;
7144 IMG_EDITOR_COUNTER_DOWN :
7145 IMG_EDITOR_COUNTER_UP);
7148 gd = &graphic_info[graphic];
7152 gd_x2 = gd->src_x + gd->pressed_xoffset;
7153 gd_y2 = gd->src_y + gd->pressed_yoffset;
7155 sprintf(infotext, "%s counter value by 1, 5 or 10",
7156 (j == 0 ? "decrease" : "increase"));
7158 gi = CreateGadget(GDI_CUSTOM_ID, id,
7159 GDI_CUSTOM_TYPE_ID, type_id,
7160 GDI_IMAGE_ID, graphic,
7161 GDI_INFO_TEXT, infotext,
7164 GDI_WIDTH, gd->width,
7165 GDI_HEIGHT, gd->height,
7166 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7167 GDI_STATE, GD_BUTTON_UNPRESSED,
7168 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7169 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7170 GDI_EVENT_MASK, event_mask,
7171 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7172 GDI_CALLBACK_ACTION, HandleCounterButtons,
7176 Fail("cannot create gadget");
7178 level_editor_gadget[id] = gi;
7179 right_gadget_border[id] =
7180 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7182 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
7186 int font_type = FONT_INPUT_1;
7187 int font_type_active = FONT_INPUT_1_ACTIVE;
7189 id = counterbutton_info[i].gadget_id_text;
7191 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7193 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7195 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
7197 font_type = FONT_LEVEL_NUMBER;
7198 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
7200 x = DX + editor.input.level_number.x;
7201 y = DY + editor.input.level_number.y;
7205 graphic = IMG_EDITOR_COUNTER_INPUT;
7208 gd = &graphic_info[graphic];
7212 gd_x2 = gd->src_x + gd->active_xoffset;
7213 gd_y2 = gd->src_y + gd->active_yoffset;
7215 gi = CreateGadget(GDI_CUSTOM_ID, id,
7216 GDI_CUSTOM_TYPE_ID, type_id,
7217 GDI_IMAGE_ID, graphic,
7218 GDI_INFO_TEXT, "enter counter value",
7221 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
7222 GDI_NUMBER_VALUE, 0,
7223 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
7224 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
7225 GDI_TEXT_SIZE, 3, // minimal counter text size
7226 GDI_TEXT_FONT, font_type,
7227 GDI_TEXT_FONT_ACTIVE, font_type_active,
7228 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7229 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7230 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7231 GDI_DESIGN_WIDTH, gd->width,
7232 GDI_EVENT_MASK, event_mask,
7233 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7234 GDI_CALLBACK_ACTION, HandleCounterButtons,
7238 Fail("cannot create gadget");
7240 level_editor_gadget[id] = gi;
7241 right_gadget_border[id] =
7242 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7244 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
7250 static void CreateDrawingAreas(void)
7254 // these values are not constant, but can change at runtime
7255 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
7256 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
7258 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
7260 struct GadgetInfo *gi;
7261 int id = drawingarea_info[i].gadget_id;
7262 int type_id = drawingarea_info[i].gadget_type_id;
7263 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
7264 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
7265 int area_xsize = drawingarea_info[i].area_xsize;
7266 int area_ysize = drawingarea_info[i].area_ysize;
7267 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
7268 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
7269 unsigned int event_mask =
7270 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
7271 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
7274 Fail("'drawingarea_info' structure corrupted at index %d -- please fix", i);
7276 // determine horizontal position to the right of specified gadget
7277 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
7278 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
7279 ED_DRAWINGAREA_TEXT_DISTANCE);
7281 // determine horizontal offset for leading text
7282 if (drawingarea_info[i].text_left != NULL)
7283 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
7285 gi = CreateGadget(GDI_CUSTOM_ID, id,
7286 GDI_CUSTOM_TYPE_ID, type_id,
7289 GDI_TYPE, GD_TYPE_DRAWING_AREA,
7290 GDI_AREA_SIZE, area_xsize, area_ysize,
7291 GDI_ITEM_SIZE, item_size, item_size,
7292 GDI_EVENT_MASK, event_mask,
7293 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
7294 GDI_CALLBACK_ACTION, HandleDrawingAreas,
7298 Fail("cannot create gadget");
7300 level_editor_gadget[id] = gi;
7301 right_gadget_border[id] =
7302 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
7306 static void CreateTextInputGadgets(void)
7308 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
7309 int max_infotext_len = getMaxInfoTextLength();
7312 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
7314 int gd_x1 = gd->src_x;
7315 int gd_y1 = gd->src_y;
7316 int gd_x2 = gd->src_x + gd->active_xoffset;
7317 int gd_y2 = gd->src_y + gd->active_yoffset;
7318 struct GadgetInfo *gi;
7319 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7320 char infotext[MAX_OUTPUT_LINESIZE + 1];
7321 int id = textinput_info[i].gadget_id;
7322 int type_id = textinput_info[i].gadget_type_id;
7326 Fail("'textinput_info' structure corrupted at index %d -- please fix", i);
7328 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
7330 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
7331 int border_size = gd->border_size;
7332 int font_nr = FONT_INPUT_1;
7333 int font_height = getFontHeight(font_nr);
7334 int xoffset = element_border + TILEX + element_border + 3 * border_size;
7335 int yoffset = element_border + (TILEY - font_height) / 2;
7337 x = (editor.settings.element_name.x != -1 ?
7338 editor.settings.element_name.x :
7339 editor.settings.element_graphic.x + xoffset) - border_size;
7340 y = (editor.settings.element_name.y != -1 ?
7341 editor.settings.element_name.y :
7342 editor.settings.element_graphic.y + yoffset) - border_size;
7346 x = ED_SETTINGS_X(textinput_info[i].x);
7347 y = ED_SETTINGS_Y(textinput_info[i].y);
7350 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
7351 infotext[max_infotext_len] = '\0';
7353 gi = CreateGadget(GDI_CUSTOM_ID, id,
7354 GDI_CUSTOM_TYPE_ID, type_id,
7355 GDI_INFO_TEXT, infotext,
7358 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
7359 GDI_TEXT_VALUE, textinput_info[i].value,
7360 GDI_TEXT_SIZE, textinput_info[i].size,
7361 GDI_TEXT_FONT, FONT_INPUT_1,
7362 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7363 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7364 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7365 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7366 GDI_DESIGN_WIDTH, gd->width,
7367 GDI_EVENT_MASK, event_mask,
7368 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7369 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
7373 Fail("cannot create gadget");
7375 level_editor_gadget[id] = gi;
7379 static void CreateTextAreaGadgets(void)
7381 int max_infotext_len = getMaxInfoTextLength();
7384 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
7386 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
7387 int gd_x1 = gd->src_x;
7388 int gd_y1 = gd->src_y;
7389 int gd_x2 = gd->src_x + gd->active_xoffset;
7390 int gd_y2 = gd->src_y + gd->active_yoffset;
7391 struct GadgetInfo *gi;
7392 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
7393 char infotext[MAX_OUTPUT_LINESIZE + 1];
7394 int id = textarea_info[i].gadget_id;
7395 int type_id = textarea_info[i].gadget_type_id;
7396 int area_xsize = textarea_info[i].xsize;
7397 int area_ysize = textarea_info[i].ysize;
7400 Fail("'textarea_info' structure corrupted at index %d -- please fix", i);
7402 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
7403 infotext[max_infotext_len] = '\0';
7405 gi = CreateGadget(GDI_CUSTOM_ID, id,
7406 GDI_CUSTOM_TYPE_ID, type_id,
7407 GDI_INFO_TEXT, infotext,
7408 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
7409 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
7410 GDI_TYPE, GD_TYPE_TEXT_AREA,
7411 GDI_AREA_SIZE, area_xsize, area_ysize,
7412 GDI_TEXT_FONT, FONT_INPUT_1,
7413 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7414 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7415 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7416 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7417 GDI_DESIGN_WIDTH, gd->width,
7418 GDI_EVENT_MASK, event_mask,
7419 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7420 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
7424 Fail("cannot create gadget");
7426 level_editor_gadget[id] = gi;
7430 static void CreateSelectboxGadgets(void)
7432 int max_infotext_len = getMaxInfoTextLength();
7435 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7437 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
7438 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
7439 int gd_x1 = gd->src_x;
7440 int gd_y1 = gd->src_y;
7441 int gd_x2 = gd->src_x + gd->active_xoffset;
7442 int gd_y2 = gd->src_y + gd->active_yoffset;
7443 int selectbox_button_xsize = gd2->width;
7444 struct GadgetInfo *gi;
7445 char infotext[MAX_OUTPUT_LINESIZE + 1];
7446 int id = selectbox_info[i].gadget_id;
7447 int type_id = selectbox_info[i].gadget_type_id;
7448 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
7449 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
7450 unsigned int event_mask =
7451 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7454 Fail("'selectbox_info' structure corrupted at index %d -- please fix", i);
7456 if (selectbox_info[i].size == -1) // dynamically determine size
7458 // (we cannot use -1 for uninitialized values if we directly compare
7459 // with results from strlen(), because the '<' and '>' operation will
7460 // implicitely cast -1 to an unsigned integer value!)
7461 selectbox_info[i].size = 0;
7463 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
7464 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
7465 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
7467 selectbox_info[i].size++; // add one character empty space
7470 // determine horizontal position to the right of specified gadget
7471 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
7472 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
7473 ED_GADGET_TEXT_DISTANCE);
7475 // determine horizontal offset for leading text
7476 if (selectbox_info[i].text_left != NULL)
7477 x += getTextWidthForGadget(selectbox_info[i].text_left);
7479 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
7480 infotext[max_infotext_len] = '\0';
7482 gi = CreateGadget(GDI_CUSTOM_ID, id,
7483 GDI_CUSTOM_TYPE_ID, type_id,
7484 GDI_INFO_TEXT, infotext,
7487 GDI_TYPE, GD_TYPE_SELECTBOX,
7488 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
7489 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
7490 GDI_TEXT_SIZE, selectbox_info[i].size,
7491 GDI_TEXT_FONT, FONT_INPUT_1,
7492 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7493 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
7494 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7495 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7496 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7497 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
7498 GDI_DESIGN_WIDTH, gd->width,
7499 GDI_EVENT_MASK, event_mask,
7500 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7501 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
7505 Fail("cannot create gadget");
7507 level_editor_gadget[id] = gi;
7508 right_gadget_border[id] =
7509 getRightGadgetBorder(gi, selectbox_info[i].text_right);
7513 static void CreateTextbuttonGadgets(void)
7515 int max_infotext_len = getMaxInfoTextLength();
7518 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
7520 int id = textbutton_info[i].gadget_id;
7521 int type_id = textbutton_info[i].gadget_type_id;
7523 ((id >= GADGET_ID_LEVELCONFIG_LEVEL && id <= GADGET_ID_LEVELCONFIG_ENGINE) ||
7524 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
7526 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
7527 int gadget_distance =
7528 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
7529 struct GraphicInfo *gd = &graphic_info[graphic];
7530 int gd_x1 = gd->src_x;
7531 int gd_y1 = gd->src_y;
7532 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7533 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7534 int gd_x1a = gd->src_x + gd->active_xoffset;
7535 int gd_y1a = gd->src_y + gd->active_yoffset;
7536 int border_xsize = gd->border_size + gd->draw_xoffset;
7537 int border_ysize = gd->border_size;
7538 struct GadgetInfo *gi;
7539 unsigned int event_mask = GD_EVENT_RELEASED;
7540 char infotext[MAX_OUTPUT_LINESIZE + 1];
7541 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
7542 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
7545 Fail("'textbutton_info' structure corrupted at index %d -- please fix", i);
7547 if (textbutton_info[i].size == -1) // dynamically determine size
7548 textbutton_info[i].size = strlen(textbutton_info[i].text);
7550 sprintf(infotext, "%s", textbutton_info[i].infotext);
7551 infotext[max_infotext_len] = '\0';
7553 // determine horizontal position to the right of specified gadget
7554 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7556 int gadget_id_align = textbutton_info[i].gadget_id_align;
7558 x = right_gadget_border[gadget_id_align] + gadget_distance;
7560 if (textbutton_info[i].y == -1)
7561 y = level_editor_gadget[gadget_id_align]->y;
7564 // determine horizontal offset for leading text
7565 if (textbutton_info[i].text_left != NULL)
7566 x += getTextWidthForGadget(textbutton_info[i].text_left);
7568 gi = CreateGadget(GDI_CUSTOM_ID, id,
7569 GDI_CUSTOM_TYPE_ID, type_id,
7570 GDI_IMAGE_ID, graphic,
7571 GDI_INFO_TEXT, infotext,
7574 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
7575 GDI_TEXT_VALUE, textbutton_info[i].text,
7576 GDI_TEXT_SIZE, textbutton_info[i].size,
7577 GDI_TEXT_FONT, FONT_INPUT_2,
7578 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
7579 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7580 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7581 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7582 GDI_BORDER_SIZE, border_xsize, border_ysize,
7583 GDI_DESIGN_WIDTH, gd->width,
7584 GDI_DECORATION_SHIFTING, 1, 1,
7585 GDI_EVENT_MASK, event_mask,
7586 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7587 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7591 Fail("cannot create gadget");
7593 level_editor_gadget[id] = gi;
7594 right_gadget_border[id] =
7595 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7599 static void CreateGraphicbuttonGadgets(void)
7601 struct GadgetInfo *gi;
7604 // create buttons for scrolling of drawing area and element list
7605 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7607 int id = graphicbutton_info[i].gadget_id;
7608 int type_id = graphicbutton_info[i].gadget_type_id;
7609 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7610 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7611 int graphic = graphicbutton_info[i].graphic;
7612 struct GraphicInfo *gd = &graphic_info[graphic];
7613 int gd_x1 = gd->src_x;
7614 int gd_y1 = gd->src_y;
7615 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7616 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7617 unsigned int event_mask = GD_EVENT_RELEASED;
7620 Fail("'graphicbutton_info' structure corrupted at index %d -- please fix", i);
7622 // determine horizontal position to the right of specified gadget
7623 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7624 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7625 ED_GADGET_TEXT_DISTANCE);
7627 // determine horizontal offset for leading text
7628 if (graphicbutton_info[i].text_left != NULL)
7629 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7631 gi = CreateGadget(GDI_CUSTOM_ID, id,
7632 GDI_CUSTOM_TYPE_ID, type_id,
7633 GDI_IMAGE_ID, graphic,
7634 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7637 GDI_WIDTH, gd->width,
7638 GDI_HEIGHT, gd->height,
7639 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7640 GDI_STATE, GD_BUTTON_UNPRESSED,
7641 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7642 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7643 GDI_EVENT_MASK, event_mask,
7644 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7645 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7649 Fail("cannot create gadget");
7651 level_editor_gadget[id] = gi;
7652 right_gadget_border[id] =
7653 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7657 static void CreateScrollbarGadgets(void)
7661 // these values are not constant, but can change at runtime
7662 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7663 SX + ED_SCROLL_HORIZONTAL_XPOS;
7664 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7665 SY + ED_SCROLL_HORIZONTAL_YPOS;
7666 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7667 ED_SCROLL_HORIZONTAL_XSIZE;
7668 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7669 ED_SCROLL_HORIZONTAL_YSIZE;
7670 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7671 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7672 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7673 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7675 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7676 SX + ED_SCROLL_VERTICAL_XPOS;
7677 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7678 SY + ED_SCROLL_VERTICAL_YPOS;
7679 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7680 ED_SCROLL_VERTICAL_XSIZE;
7681 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7682 ED_SCROLL_VERTICAL_YSIZE;
7683 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7684 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7685 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7686 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7688 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7689 PX + ED_SCROLL2_VERTICAL_XPOS;
7690 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7691 PY + ED_SCROLL2_VERTICAL_YPOS;
7692 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7693 ED_SCROLL2_VERTICAL_XSIZE;
7694 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7695 ED_SCROLL2_VERTICAL_YSIZE;
7696 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7697 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7698 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7699 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7701 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7703 int id = scrollbar_info[i].gadget_id;
7704 int type_id = scrollbar_info[i].gadget_type_id;
7705 int graphic = scrollbar_info[i].graphic;
7706 struct GraphicInfo *gd = &graphic_info[graphic];
7707 int gd_x1 = gd->src_x;
7708 int gd_y1 = gd->src_y;
7709 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7710 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7711 struct GadgetInfo *gi;
7712 int items_max, items_visible, item_position;
7713 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7716 Fail("'scrollbar_info' structure corrupted at index %d -- please fix", i);
7718 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7720 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7721 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7722 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7724 else // drawing area scrollbars
7726 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7728 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7729 items_visible = ed_fieldx;
7734 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7735 items_visible = ed_fieldy;
7740 gi = CreateGadget(GDI_CUSTOM_ID, id,
7741 GDI_CUSTOM_TYPE_ID, type_id,
7742 GDI_IMAGE_ID, graphic,
7743 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7744 GDI_X, scrollbar_pos[i].x,
7745 GDI_Y, scrollbar_pos[i].y,
7746 GDI_WIDTH, scrollbar_pos[i].width,
7747 GDI_HEIGHT, scrollbar_pos[i].height,
7748 GDI_TYPE, scrollbar_info[i].type,
7749 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7750 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7751 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7752 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7753 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7754 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7755 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7756 GDI_STATE, GD_BUTTON_UNPRESSED,
7757 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7758 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7759 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7760 GDI_EVENT_MASK, event_mask,
7761 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7762 GDI_CALLBACK_ACTION, HandleControlButtons,
7766 Fail("cannot create gadget");
7768 level_editor_gadget[id] = gi;
7772 static void CreateCheckbuttonGadgets(void)
7774 struct GadgetInfo *gi;
7777 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7779 int id = checkbutton_info[i].gadget_id;
7780 int type_id = checkbutton_info[i].gadget_type_id;
7781 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7782 IMG_EDITOR_CHECKBOX);
7783 struct GraphicInfo *gd = &graphic_info[graphic];
7784 int gd_x1 = gd->src_x;
7785 int gd_y1 = gd->src_y;
7786 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7787 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7788 int gd_x1a = gd->src_x + gd->active_xoffset;
7789 int gd_y1a = gd->src_y + gd->active_yoffset;
7790 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7791 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7792 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7793 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7794 unsigned int event_mask = GD_EVENT_PRESSED;
7797 Fail("'checkbutton_info' structure corrupted at index %d -- please fix", i);
7799 // determine horizontal position to the right of specified gadget
7800 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7801 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7802 ED_GADGET_TEXT_DISTANCE);
7804 // determine horizontal offset for leading text
7805 if (checkbutton_info[i].text_left != NULL)
7806 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7808 gi = CreateGadget(GDI_CUSTOM_ID, id,
7809 GDI_CUSTOM_TYPE_ID, type_id,
7810 GDI_IMAGE_ID, graphic,
7811 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7814 GDI_WIDTH, gd->width,
7815 GDI_HEIGHT, gd->height,
7816 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7817 GDI_CHECKED, *checkbutton_info[i].value,
7818 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7819 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7820 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7821 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7822 GDI_EVENT_MASK, event_mask,
7823 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7824 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7828 Fail("cannot create gadget");
7830 level_editor_gadget[id] = gi;
7831 right_gadget_border[id] =
7832 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7836 static void CreateRadiobuttonGadgets(void)
7838 int graphic = IMG_EDITOR_RADIOBUTTON;
7839 struct GraphicInfo *gd = &graphic_info[graphic];
7840 int gd_x1 = gd->src_x;
7841 int gd_y1 = gd->src_y;
7842 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7843 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7844 int gd_x1a = gd->src_x + gd->active_xoffset;
7845 int gd_y1a = gd->src_y + gd->active_yoffset;
7846 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7847 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7848 struct GadgetInfo *gi;
7851 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7853 int id = radiobutton_info[i].gadget_id;
7854 int type_id = radiobutton_info[i].gadget_type_id;
7855 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7856 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7857 unsigned int event_mask = GD_EVENT_PRESSED;
7860 Fail("'radiobutton_info' structure corrupted at index %d -- please fix", i);
7863 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7865 // determine horizontal position to the right of specified gadget
7866 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7867 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7868 ED_GADGET_TEXT_DISTANCE);
7870 // determine horizontal offset for leading text
7871 if (radiobutton_info[i].text_left != NULL)
7872 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7874 gi = CreateGadget(GDI_CUSTOM_ID, id,
7875 GDI_CUSTOM_TYPE_ID, type_id,
7876 GDI_IMAGE_ID, graphic,
7877 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7880 GDI_WIDTH, gd->width,
7881 GDI_HEIGHT, gd->height,
7882 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7883 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7884 GDI_CHECKED, checked,
7885 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7886 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7887 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7888 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7889 GDI_EVENT_MASK, event_mask,
7890 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7891 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7895 Fail("cannot create gadget");
7897 level_editor_gadget[id] = gi;
7898 right_gadget_border[id] =
7899 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7903 void CreateLevelEditorGadgets(void)
7905 // force EDITOR font inside level editor
7906 SetFontStatus(GAME_MODE_EDITOR);
7908 // these values are not constant, but can change at runtime
7909 ed_fieldx = MAX_ED_FIELDX - 1;
7910 ed_fieldy = MAX_ED_FIELDY - 1;
7912 num_editor_gadgets = NUM_EDITOR_GADGETS;
7914 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7916 level_editor_gadget =
7917 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7918 right_gadget_border =
7919 checked_calloc(num_editor_gadgets * sizeof(int));
7921 // set number of empty (padding) element buttons to maximum number of buttons
7922 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7924 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7925 editor_el_empty_ptr = editor_el_empty;
7927 use_permanent_palette = !editor.palette.show_as_separate_screen;
7929 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
7931 ReinitializeElementList();
7933 CreateControlButtons();
7934 CreateScrollbarGadgets();
7936 // order of function calls is important because of cross-references
7937 CreateCheckbuttonGadgets();
7938 CreateCounterButtons();
7939 CreateRadiobuttonGadgets();
7940 CreateTextInputGadgets();
7941 CreateTextAreaGadgets();
7942 CreateSelectboxGadgets();
7943 CreateGraphicbuttonGadgets();
7944 CreateTextbuttonGadgets();
7945 CreateDrawingAreas();
7950 void FreeLevelEditorGadgets(void)
7954 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
7956 for (i = 0; i < num_editor_gadgets; i++)
7958 FreeGadget(level_editor_gadget[i]);
7960 level_editor_gadget[i] = NULL;
7963 checked_free(level_editor_gadget);
7964 checked_free(right_gadget_border);
7966 checked_free(editor_el_empty);
7969 static void MapCounterButtons(int id)
7971 int font_nr = FONT_TEXT_1;
7972 int font_height = getFontHeight(font_nr);
7973 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7974 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7975 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7976 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7977 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7978 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7979 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7980 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7981 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7982 int yoffset = (gi_down->height - font_height) / 2;
7983 int x_left = gi_down->x - xoffset_left;
7984 int x_right; // set after gadget position was modified
7985 int y_above = gi_down->y - yoffset_above;
7987 int y; // set after gadget position was modified
7989 // counter limits must be changed first to prevent value truncation
7990 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7991 counterbutton_info[id].max_value);
7993 // right text position might have changed after setting position above
7994 x_right = gi_up->x + gi_up->width + xoffset_right;
7996 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7998 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
7999 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
8000 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
8002 ModifyGadget(gi_down, GDI_Y,
8003 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8004 ModifyGadget(gi_text, GDI_Y,
8005 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8006 ModifyGadget(gi_up, GDI_Y,
8007 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8010 // vertical position might have changed after setting position above
8011 y = gi_up->y + yoffset;
8013 if (counterbutton_info[id].text_above)
8014 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
8016 if (counterbutton_info[id].text_left)
8017 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
8019 if (counterbutton_info[id].text_right)
8020 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
8027 static void MapControlButtons(void)
8032 // map toolbox buttons (excluding special CE toolbox buttons)
8033 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
8034 MapGadget(level_editor_gadget[i]);
8036 // map toolbox buttons (element properties buttons)
8037 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
8038 MapGadget(level_editor_gadget[i]);
8040 if (use_permanent_palette)
8042 // map buttons to select elements
8043 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8044 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
8045 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
8046 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
8047 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
8050 // map buttons to select level
8051 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
8052 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
8053 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
8054 MapCounterButtons(counter_id);
8057 static void MapDrawingArea(int id)
8059 int font_nr = FONT_TEXT_1;
8060 int font_height = getFontHeight(font_nr);
8061 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8062 int area_xsize = gi->drawing.area_xsize;
8063 int area_ysize = gi->drawing.area_ysize;
8064 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8065 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
8066 int x_left = gi->x - xoffset_left;
8067 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
8068 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
8069 int x_below = gi->x + (gi->width - xoffset_below) / 2;
8070 int y_side = gi->y + (gi->height - font_height) / 2;
8071 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
8072 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
8074 if (drawingarea_info[id].text_left)
8075 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
8077 if (drawingarea_info[id].text_right)
8078 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
8080 if (drawingarea_info[id].text_above)
8081 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
8083 if (drawingarea_info[id].text_below)
8084 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
8086 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
8088 DrawElementBorder(gi->x, gi->y,
8089 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
8090 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
8092 DrawDrawingArea(id);
8098 static void MapTextInputGadget(int id)
8100 int font_nr = FONT_TEXT_1;
8101 int font_height = getFontHeight(font_nr);
8102 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
8103 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8104 int x_above = ED_SETTINGS_X(textinput_info[id].x);
8105 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
8107 if (textinput_info[id].text_above)
8108 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
8110 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
8115 static void MapTextAreaGadget(int id)
8117 int font_nr = FONT_TEXT_1;
8118 int font_height = getFontHeight(font_nr);
8119 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8120 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8121 int x_above = ED_SETTINGS_X(textarea_info[id].x);
8122 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
8123 char *text_above = textarea_info[id].text_above;
8125 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
8126 text_above = textarea_info[id].text_above_cropped;
8129 DrawTextS(x_above, y_above, font_nr, text_above);
8131 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
8136 static void MapSelectboxGadget(int id)
8138 int font_nr = FONT_TEXT_1;
8139 int font_height = getFontHeight(font_nr);
8140 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
8141 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
8142 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8143 int yoffset_above = font_height + ED_GADGET_LINE_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_above = gi->y - yoffset_above;
8149 int y = gi->y + yoffset;
8151 if (selectbox_info[id].text_above)
8152 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
8154 if (selectbox_info[id].text_left)
8155 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
8157 if (selectbox_info[id].text_right)
8158 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
8160 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
8165 static void MapTextbuttonGadget(int id)
8167 int font_nr = FONT_TEXT_1;
8168 int font_height = getFontHeight(font_nr);
8169 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
8170 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
8171 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8172 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8173 int yoffset = (gi->height - font_height) / 2;
8174 int x_left = gi->x - xoffset_left;
8175 int x_right = gi->x + gi->width + xoffset_right;
8176 int y_above = gi->y - yoffset_above;
8178 int y = gi->y + yoffset;
8180 // only show button to delete change pages when more than minimum pages
8181 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
8182 custom_element.num_change_pages == MIN_CHANGE_PAGES)
8185 if (textbutton_info[id].text_above)
8186 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
8188 if (textbutton_info[id].text_left)
8189 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
8191 if (textbutton_info[id].text_right)
8192 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
8197 static void MapGraphicbuttonGadget(int id)
8199 int font_nr = FONT_TEXT_1;
8200 int font_height = getFontHeight(font_nr);
8201 struct GadgetInfo *gi = level_editor_gadget[graphicbutton_info[id].gadget_id];
8202 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
8203 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8204 int yoffset = (gi->height - font_height) / 2;
8205 int x_left = gi->x - xoffset_left;
8206 int x_right = gi->x + gi->width + xoffset_right;
8207 int y = gi->y + yoffset;
8209 if (graphicbutton_info[id].text_left)
8210 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
8212 if (graphicbutton_info[id].text_right)
8213 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
8218 static void MapRadiobuttonGadget(int id)
8220 int font_nr = FONT_TEXT_1;
8221 int font_height = getFontHeight(font_nr);
8222 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
8223 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8224 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8225 int yoffset = (gi->height - font_height) / 2;
8226 int x_left = gi->x - xoffset_left;
8227 int x_right = gi->x + gi->width + xoffset_right;
8228 int y = gi->y + yoffset;
8230 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
8232 if (radiobutton_info[id].text_left)
8233 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
8235 if (radiobutton_info[id].text_right)
8236 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
8238 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
8243 static void MapCheckbuttonGadget(int id)
8245 int font_nr = FONT_TEXT_1;
8246 int font_height = getFontHeight(font_nr);
8247 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
8248 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8249 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8250 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8251 int yoffset = (gi->height - font_height) / 2;
8252 int y_above = gi->y - yoffset_above;
8254 int x_left, x_right, y; // set after gadget position was modified
8256 // set position for gadgets with dynamically determined position
8257 if (checkbutton_info[id].x != -1) // do not change dynamic positions
8258 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x), GDI_END);
8259 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
8261 x_left = gi->x - xoffset_left;
8262 x_right = gi->x + gi->width + xoffset_right;
8263 y = gi->y + yoffset;
8265 if (checkbutton_info[id].text_above)
8266 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
8268 if (checkbutton_info[id].text_left)
8269 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
8271 if (checkbutton_info[id].text_right)
8272 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
8274 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
8279 static void MapMainDrawingArea(void)
8281 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
8282 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
8285 if (suppressBorderElement())
8287 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
8288 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
8291 for (i = ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
8293 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
8294 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
8295 no_horizontal_scrollbar) ||
8296 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
8297 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
8298 no_vertical_scrollbar))
8301 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
8304 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
8306 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
8307 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
8310 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
8313 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
8316 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
8320 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
8322 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
8323 i == GADGET_ID_CUSTOM_COPY_TO ||
8324 i == GADGET_ID_CUSTOM_EXCHANGE ||
8325 i == GADGET_ID_CUSTOM_COPY ||
8326 i == GADGET_ID_CUSTOM_PASTE)
8329 MapGadget(level_editor_gadget[i]);
8331 UnmapGadget(level_editor_gadget[i]);
8336 static void MapLevelEditorToolboxCustomGadgets(void)
8338 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
8341 static void MapLevelEditorToolboxCustomGadgetsIfNeeded(void)
8343 if (IS_CUSTOM_ELEMENT(properties_element) ||
8344 IS_GROUP_ELEMENT(properties_element) ||
8345 IS_EMPTY_ELEMENT(properties_element))
8346 MapLevelEditorToolboxCustomGadgets();
8349 static void UnmapLevelEditorToolboxCustomGadgets(void)
8351 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
8354 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
8358 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
8360 if (i != GADGET_ID_SINGLE_ITEMS &&
8361 i != GADGET_ID_PICK_ELEMENT)
8363 struct GadgetInfo *gi = level_editor_gadget[i];
8371 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
8372 struct GraphicInfo *gd = &graphic_info[graphic];
8376 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
8377 gi->width, gi->height, gi->x, gi->y);
8379 redraw_mask |= REDRAW_DOOR_3;
8385 static void MapLevelEditorToolboxDrawingGadgets(void)
8387 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
8390 static void UnmapLevelEditorToolboxDrawingGadgets(void)
8392 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
8395 static void UnmapDrawingArea(int id)
8397 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
8400 static void UnmapLevelEditorFieldGadgets(void)
8404 for (i = 0; i < num_editor_gadgets; i++)
8405 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
8406 level_editor_gadget[i]->y))
8407 UnmapGadget(level_editor_gadget[i]);
8410 void UnmapLevelEditorGadgets(void)
8414 for (i = 0; i < num_editor_gadgets; i++)
8415 UnmapGadget(level_editor_gadget[i]);
8418 static void ResetUndoBuffer(void)
8420 undo_buffer_position = -1;
8421 undo_buffer_steps = -1;
8422 redo_buffer_steps = 0;
8424 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8426 level.changed = FALSE;
8429 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
8431 if (remap_toolbox_gadgets)
8433 ModifyEditorElementList();
8434 RedrawDrawingElements();
8437 if (edit_mode == ED_MODE_LEVELCONFIG)
8438 DrawLevelConfigWindow();
8439 else if (edit_mode == ED_MODE_PROPERTIES)
8440 DrawPropertiesWindow();
8441 else if (edit_mode == ED_MODE_PALETTE)
8442 DrawPaletteWindow();
8443 else // edit_mode == ED_MODE_DRAWING
8444 DrawDrawingWindowExt(remap_toolbox_gadgets);
8447 static void DrawEditModeWindow(void)
8449 DrawEditModeWindowExt(TRUE);
8452 static void DrawEditModeWindow_PlayfieldOnly(void)
8454 DrawEditModeWindowExt(FALSE);
8457 static void ChangeEditModeWindow(int new_edit_mode)
8459 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
8461 DrawEditModeWindow();
8464 static boolean LevelChanged(void)
8466 boolean field_changed = FALSE;
8469 for (y = 0; y < lev_fieldy; y++)
8470 for (x = 0; x < lev_fieldx; x++)
8471 if (Tile[x][y] != level.field[x][y])
8472 field_changed = TRUE;
8474 return (level.changed || field_changed);
8477 static boolean PrepareSavingIntoPersonalLevelSet(void)
8479 static LevelDirTree *last_copied_leveldir = NULL;
8480 static LevelDirTree *last_written_leveldir = NULL;
8481 static int last_copied_level_nr = -1;
8482 static int last_written_level_nr = -1;
8483 LevelDirTree *leveldir_former = leveldir_current;
8484 int level_nr_former = level_nr;
8487 // remember last mod/save so that for current session, we write
8488 // back to the same personal copy, asking only about overwrite.
8489 if (leveldir_current == last_copied_leveldir &&
8490 level_nr == last_copied_level_nr)
8492 // "cd" to personal level set dir (as used when writing last copy)
8493 leveldir_current = last_written_leveldir;
8494 level_nr = last_written_level_nr;
8499 if (!Request("This level is read-only! "
8500 "Save into personal level set?", REQ_ASK))
8503 // "cd" to personal level set dir (for writing copy the first time)
8505 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
8507 // this may happen if "setup.internal.create_user_levelset" is FALSE
8508 // or if file "levelinfo.conf" is missing in personal user level set
8509 if (leveldir_current == NULL)
8511 Request("Cannot find personal level set?!", REQ_CONFIRM);
8513 leveldir_current = leveldir_former;
8518 // find unused level number
8519 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
8521 static char *level_filename = NULL;
8523 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
8525 if (!fileExists(level_filename))
8529 last_copied_leveldir = leveldir_former;
8530 last_copied_level_nr = level_nr_former;
8532 last_written_leveldir = leveldir_current;
8533 last_written_level_nr = level_nr = new_level_nr;
8538 static void ModifyLevelConfigForSavingIntoPersonalLevelSet(char *former_name)
8540 static char *filename_levelinfo = NULL, *mod_name = NULL;
8543 // annotate this copy-and-mod in personal levelinfo.conf
8544 setString(&filename_levelinfo,
8545 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
8547 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
8549 fprintf(file, "\n");
8550 fprintf(file, "# level %d was modified from:\n", level_nr);
8551 fprintf(file, "# - previous level set name: %s\n",
8553 fprintf(file, "# - level within previous set: %d \"%s\"\n",
8554 level.file_info.nr, level.name);
8555 fprintf(file, "# - previous author: %s\n",
8557 fprintf(file, "# - previous save date: ");
8559 if (level.creation_date.src == DATE_SRC_LEVELFILE)
8561 fprintf(file, "%04d-%02d-%02d\n",
8562 level.creation_date.year,
8563 level.creation_date.month,
8564 level.creation_date.day);
8568 fprintf(file, "not recorded\n");
8574 if (level_nr > leveldir_current->last_level)
8575 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
8577 // else: allow the save even if annotation failed
8579 // now... spray graffiti on the old level vital statistics
8580 // user can change these; just trying to set a good baseline
8582 // don't truncate names for fear of making offensive or silly:
8583 // long-named original author only recorded in levelinfo.conf.
8584 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
8585 if (!strEqual(level.author, leveldir_current->author))
8587 setString(&mod_name, getStringCat3(leveldir_current->author,
8588 " after ", level.author));
8590 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8591 setString(&mod_name,
8592 getStringCat2(leveldir_current->author, " (ed.)"));
8594 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8595 setString(&mod_name, leveldir_current->author);
8597 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
8599 // less worried about truncation here
8600 setString(&mod_name, getStringCat2("Mod: ", level.name));
8601 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
8605 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
8606 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8610 for (x = 0; x < lev_fieldx; x++)
8611 for (y = 0; y < lev_fieldy; y++)
8612 dst[x][y] = src[x][y];
8615 static int setSelectboxValue(int selectbox_id, int new_value)
8617 int new_index_value = 0;
8620 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8621 if (selectbox_info[selectbox_id].options[i].value == new_value)
8622 new_index_value = i;
8624 *selectbox_info[selectbox_id].value =
8625 selectbox_info[selectbox_id].options[new_index_value].value;
8627 return new_index_value;
8630 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8634 // change action mode and arg variables according to action type variable
8635 for (i = 0; action_arg_options[i].value != -1; i++)
8637 if (action_arg_options[i].value == custom_element_change.action_type)
8639 int mode = action_arg_options[i].mode;
8641 // only change if corresponding selectbox has changed
8642 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8643 action_arg_modes[mode])
8644 custom_element_change.action_mode = -1;
8646 // only change if corresponding selectbox has changed
8647 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8648 action_arg_options[i].options)
8649 custom_element_change.action_arg = -1;
8656 static void setSelectboxSpecialActionOptions(void)
8660 // change action mode and arg selectbox according to action type selectbox
8661 for (i = 0; action_arg_options[i].value != -1; i++)
8663 if (action_arg_options[i].value == custom_element_change.action_type)
8665 int mode = action_arg_options[i].mode;
8667 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8668 action_arg_modes[mode]);
8669 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8670 custom_element_change.action_mode);
8672 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8673 action_arg_options[i].options);
8674 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8675 custom_element_change.action_arg);
8681 static void copy_custom_element_settings(int element_from, int element_to)
8683 struct ElementInfo *ei_from = &element_info[element_from];
8684 struct ElementInfo *ei_to = &element_info[element_to];
8686 copyElementInfo(ei_from, ei_to);
8689 static void replace_custom_element_in_settings(int element_from,
8694 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8696 struct ElementInfo *ei = &element_info[i];
8698 for (y = 0; y < 3; y++)
8699 for (x = 0; x < 3; x++)
8700 if (ei->content.e[x][y] == element_from)
8701 ei->content.e[x][y] = element_to;
8703 for (j = 0; j < ei->num_change_pages; j++)
8705 struct ElementChangeInfo *change = &ei->change_page[j];
8707 if (change->target_element == element_from)
8708 change->target_element = element_to;
8710 if (change->initial_trigger_element == element_from)
8711 change->initial_trigger_element = element_to;
8713 if (change->action_element == element_from)
8714 change->action_element = element_to;
8716 for (y = 0; y < 3; y++)
8717 for (x = 0; x < 3; x++)
8718 if (change->target_content.e[x][y] == element_from)
8719 change->target_content.e[x][y] = element_to;
8722 if (ei->group != NULL) // group or internal
8723 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8724 if (ei->group->element[j] == element_from)
8725 ei->group->element[j] = element_to;
8729 static void replace_custom_element_in_playfield(int element_from,
8734 for (x = 0; x < lev_fieldx; x++)
8735 for (y = 0; y < lev_fieldy; y++)
8736 if (Tile[x][y] == element_from)
8737 Tile[x][y] = element_to;
8740 static boolean CopyCustomElement(int element_old, int element_new,
8743 int copy_mode_orig = copy_mode;
8745 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8747 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8748 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8749 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8751 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8753 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8754 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8755 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8757 level.changed = TRUE;
8759 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8761 Request("Please choose custom element!", REQ_CONFIRM);
8765 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8767 Request("Please choose group element!", REQ_CONFIRM);
8771 else if (IS_EMPTY_ELEMENT(element_old) && !IS_EMPTY_ELEMENT(element_new))
8773 Request("Please choose empty element!", REQ_CONFIRM);
8779 level.changed = TRUE;
8782 // when modifying custom/group element, ask for copying level template
8783 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8785 if (!AskToCopyAndModifyLevelTemplate())
8789 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8791 copy_custom_element_settings(element_new, element_old);
8793 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8795 copy_custom_element_settings(element_old, element_new);
8797 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8799 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8800 copy_custom_element_settings(element_new, element_old);
8801 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8803 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8804 replace_custom_element_in_settings(element_new, element_old);
8805 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8807 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8808 replace_custom_element_in_playfield(element_new, element_old);
8809 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8812 UpdateCustomElementGraphicGadgets();
8813 DrawPropertiesWindow();
8818 static void CopyCustomElementPropertiesToEditor(int element)
8821 int current_change_page = element_info[element].current_change_page;
8823 // dynamically (re)build selectbox for selecting change page
8824 for (i = 0; i < element_info[element].num_change_pages; i++)
8826 sprintf(options_change_page_strings[i], "%d", i + 1);
8828 options_change_page[i].value = i;
8829 options_change_page[i].text = options_change_page_strings[i];
8832 options_change_page[i].value = -1;
8833 options_change_page[i].text = NULL;
8835 // needed here to initialize combined element properties
8836 InitElementPropertiesEngine(level.game_version);
8838 element_info[element].change =
8839 &element_info[element].change_page[current_change_page];
8841 custom_element = element_info[element];
8842 custom_element_change = *element_info[element].change;
8844 // needed to initially set selectbox options for special action options
8845 setSelectboxSpecialActionOptions();
8847 // needed to initially set selectbox value variables to reliable defaults
8848 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8849 setSelectboxValue(i, *selectbox_info[i].value);
8851 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8852 custom_element_properties[i] = HAS_PROPERTY(element, i);
8854 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8855 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8857 // ---------- element settings: configure (custom elements) -----------------
8859 // set accessible layer selectbox help value
8860 custom_element.access_type =
8861 (IS_WALKABLE(element) ? EP_WALKABLE :
8862 IS_PASSABLE(element) ? EP_PASSABLE :
8863 custom_element.access_type);
8864 custom_element.access_layer =
8865 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8866 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8867 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8868 custom_element.access_layer);
8869 custom_element.access_protected =
8870 (IS_PROTECTED(element) ? 1 : 0);
8871 custom_element_properties[EP_ACCESSIBLE] =
8872 (IS_ACCESSIBLE_OVER(element) ||
8873 IS_ACCESSIBLE_INSIDE(element) ||
8874 IS_ACCESSIBLE_UNDER(element));
8876 // set walk-to-object action selectbox help value
8877 custom_element.walk_to_action =
8878 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8879 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8880 IS_DROPPABLE(element) ? EP_DROPPABLE :
8881 IS_THROWABLE(element) ? EP_THROWABLE :
8882 IS_PUSHABLE(element) ? EP_PUSHABLE :
8883 custom_element.walk_to_action);
8884 custom_element_properties[EP_WALK_TO_OBJECT] =
8885 (IS_DIGGABLE(element) ||
8886 IS_COLLECTIBLE_ONLY(element) ||
8887 IS_DROPPABLE(element) ||
8888 IS_THROWABLE(element) ||
8889 IS_PUSHABLE(element));
8891 // set smash targets selectbox help value
8892 custom_element.smash_targets =
8893 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8894 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8895 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8896 custom_element.smash_targets);
8897 custom_element_properties[EP_CAN_SMASH] =
8898 (CAN_SMASH_EVERYTHING(element) ||
8899 CAN_SMASH_ENEMIES(element) ||
8900 CAN_SMASH_PLAYER(element));
8902 // set deadliness selectbox help value
8903 custom_element.deadliness =
8904 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8905 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8906 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8907 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8908 custom_element.deadliness);
8909 custom_element_properties[EP_DEADLY] =
8910 (DONT_TOUCH(element) ||
8911 DONT_GET_HIT_BY(element) ||
8912 DONT_COLLIDE_WITH(element) ||
8913 DONT_RUN_INTO(element));
8915 // ---------- element settings: advanced (custom elements) ------------------
8917 // set "change by direct action" selectbox help value
8918 custom_element_change.direct_action =
8919 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
8920 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8921 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8922 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8923 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8924 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8925 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8926 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8927 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8928 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8929 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8930 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8931 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8932 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8933 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8934 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8935 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8936 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8937 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8938 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
8939 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
8940 custom_element_change.direct_action);
8942 // set "change by other element action" selectbox help value
8943 custom_element_change.other_action =
8944 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
8945 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8946 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8947 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8948 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8949 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8950 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8951 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8952 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8953 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8954 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8955 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
8956 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8957 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8958 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8959 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8960 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8961 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8962 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8963 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8964 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8965 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8966 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8967 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8968 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8969 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
8970 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
8971 custom_element_change.other_action);
8974 static void CopyGroupElementPropertiesToEditor(int element)
8976 group_element_info = *element_info[element].group;
8977 custom_element = element_info[element]; // needed for description
8980 static void CopyEmptyElementPropertiesToEditor(int element)
8982 custom_element = element_info[element];
8985 static void CopyClassicElementPropertiesToEditor(int element)
8987 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8988 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
8989 getMoveIntoAcidProperty(&level, element);
8991 if (MAYBE_DONT_COLLIDE_WITH(element))
8992 custom_element_properties[EP_DONT_COLLIDE_WITH] =
8993 getDontCollideWithProperty(&level, element);
8996 static void CopyElementPropertiesToEditor(int element)
8998 if (IS_CUSTOM_ELEMENT(element))
8999 CopyCustomElementPropertiesToEditor(element);
9000 else if (IS_GROUP_ELEMENT(element))
9001 CopyGroupElementPropertiesToEditor(element);
9002 else if (IS_EMPTY_ELEMENT(element))
9003 CopyEmptyElementPropertiesToEditor(element);
9005 CopyClassicElementPropertiesToEditor(element);
9008 static boolean AskToCopyAndModifyLevelTemplate(void)
9010 if (Request("Copy and modify settings from level template?", REQ_ASK))
9012 level.use_custom_template = FALSE;
9014 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
9015 GDI_CHECKED, FALSE, GDI_END);
9016 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
9017 GDI_CHECKED, FALSE, GDI_END);
9023 LoadLevelTemplate(-1); // this resets all element modifications ...
9025 DrawEditModeWindow(); // ... and copies them to 'custom_element'
9031 static void CopyCustomElementPropertiesToGame(int element)
9034 int access_type_and_layer;
9036 // mark that this custom element has been modified
9037 custom_element.modified_settings = TRUE;
9038 level.changed = TRUE;
9040 if (level.use_custom_template)
9041 AskToCopyAndModifyLevelTemplate();
9043 element_info[element] = custom_element;
9044 *element_info[element].change = custom_element_change;
9046 // ---------- element settings: configure (custom elements) -----------------
9048 // set accessible property from checkbox and selectbox
9049 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
9050 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
9051 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
9052 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
9053 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
9054 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
9055 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
9056 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
9057 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
9058 custom_element_properties[access_type_and_layer] =
9059 custom_element_properties[EP_ACCESSIBLE];
9060 custom_element_properties[EP_PROTECTED] =
9061 (custom_element.access_protected != 0 &&
9062 custom_element_properties[EP_ACCESSIBLE]);
9064 // set walk-to-object property from checkbox and selectbox
9065 custom_element_properties[EP_DIGGABLE] = FALSE;
9066 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
9067 custom_element_properties[EP_DROPPABLE] = FALSE;
9068 custom_element_properties[EP_THROWABLE] = FALSE;
9069 custom_element_properties[EP_PUSHABLE] = FALSE;
9070 custom_element_properties[custom_element.walk_to_action] =
9071 custom_element_properties[EP_WALK_TO_OBJECT];
9073 // set smash property from checkbox and selectbox
9074 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
9075 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
9076 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
9077 custom_element_properties[custom_element.smash_targets] =
9078 custom_element_properties[EP_CAN_SMASH];
9080 // set deadliness property from checkbox and selectbox
9081 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
9082 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
9083 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
9084 custom_element_properties[EP_DONT_TOUCH] = FALSE;
9085 custom_element_properties[custom_element.deadliness] =
9086 custom_element_properties[EP_DEADLY];
9088 // ---------- element settings: advanced (custom elements) ------------------
9090 // set player change event from checkbox and selectbox
9091 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
9092 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
9093 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
9094 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
9095 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
9096 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
9097 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
9098 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
9099 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
9100 custom_element_change_events[CE_SWITCHED] = FALSE;
9101 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
9102 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
9103 custom_element_change_events[CE_BLOCKED] = FALSE;
9104 custom_element_change_events[CE_IMPACT] = FALSE;
9105 custom_element_change_events[CE_SMASHED] = FALSE;
9106 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
9107 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
9108 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
9109 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
9110 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
9111 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
9112 custom_element_change_events[custom_element_change.direct_action] =
9113 custom_element_change_events[CE_BY_DIRECT_ACTION];
9115 // set other element action change event from checkbox and selectbox
9116 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
9117 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
9118 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
9119 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
9120 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
9121 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
9122 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
9123 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
9124 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
9125 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
9126 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
9127 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
9128 custom_element_change_events[CE_TOUCHING_X] = FALSE;
9129 custom_element_change_events[CE_HITTING_X] = FALSE;
9130 custom_element_change_events[CE_DIGGING_X] = FALSE;
9131 custom_element_change_events[CE_HIT_BY_X] = FALSE;
9132 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
9133 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
9134 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
9135 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
9136 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
9137 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
9138 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
9139 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
9140 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
9141 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
9142 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
9143 custom_element_change_events[custom_element_change.other_action] =
9144 custom_element_change_events[CE_BY_OTHER_ACTION];
9146 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
9147 SET_PROPERTY(element, i, custom_element_properties[i]);
9149 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
9150 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
9152 // copy change events also to special level editor variable
9153 custom_element = element_info[element];
9154 custom_element_change = *element_info[element].change;
9156 // needed here to restore runtime value "element_info[element].gfx_element"
9157 InitElementPropertiesGfxElement();
9160 static void CopyGroupElementPropertiesToGame(int element)
9162 // mark that this group element has been modified
9163 custom_element.modified_settings = TRUE;
9164 level.changed = TRUE;
9166 if (level.use_custom_template)
9167 AskToCopyAndModifyLevelTemplate();
9169 element_info[element] = custom_element;
9170 *element_info[element].group = group_element_info;
9172 // needed here to restore runtime value "element_info[element].gfx_element"
9173 InitElementPropertiesGfxElement();
9176 static void CopyEmptyElementPropertiesToGame(int element)
9178 // mark that this empty element has been modified
9179 custom_element.modified_settings = TRUE;
9180 level.changed = TRUE;
9182 if (level.use_custom_template)
9183 AskToCopyAndModifyLevelTemplate();
9185 element_info[element] = custom_element;
9187 // needed here to restore runtime value "element_info[element].gfx_element"
9188 InitElementPropertiesGfxElement();
9191 static void CopyClassicElementPropertiesToGame(int element)
9193 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9194 setMoveIntoAcidProperty(&level, element,
9195 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
9197 if (MAYBE_DONT_COLLIDE_WITH(element))
9198 setDontCollideWithProperty(&level, element,
9199 custom_element_properties[EP_DONT_COLLIDE_WITH]);
9202 static void CopyElementPropertiesToGame(int element)
9204 if (IS_CUSTOM_ELEMENT(element))
9205 CopyCustomElementPropertiesToGame(element);
9206 else if (IS_GROUP_ELEMENT(element))
9207 CopyGroupElementPropertiesToGame(element);
9208 else if (IS_EMPTY_ELEMENT(element))
9209 CopyEmptyElementPropertiesToGame(element);
9211 CopyClassicElementPropertiesToGame(element);
9215 static void CheckElementDescriptions(void)
9219 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
9220 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
9221 Warn("no element description file for element '%s'", EL_NAME(i));
9225 static int getMaxEdFieldX(boolean has_scrollbar)
9227 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
9228 int sxsize = SXSIZE - scrollbar_width;
9229 int max_ed_fieldx = sxsize / ed_tilesize;
9231 return max_ed_fieldx;
9234 static int getMaxEdFieldY(boolean has_scrollbar)
9236 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
9237 INFOTEXT_YSIZE_FULL : 0);
9238 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
9239 int sysize = SYSIZE - scrollbar_height - infotext_height;
9240 int max_ed_fieldy = sysize / ed_tilesize;
9242 return max_ed_fieldy;
9245 static void InitZoomLevelSettings(int zoom_tilesize)
9247 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
9249 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
9251 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
9252 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
9254 // make sure that tile size is always a power of 2
9255 ed_tilesize = (1 << log_2(ed_tilesize));
9257 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9259 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
9260 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
9264 last_game_engine_type = level.game_engine_type;
9266 // limit zoom tilesize by upper and lower bound
9267 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
9269 // store zoom tilesize in auto setup file only if it was manually changed
9270 if (zoom_tilesize != -1)
9271 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
9273 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
9274 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
9277 static void InitDrawingElements(void)
9279 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
9281 if (level.game_engine_type == game_engine_type_last)
9284 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9286 new_element1 = EL_BD_WALL;
9287 new_element2 = EL_EMPTY;
9288 new_element3 = EL_BD_SAND;
9290 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
9292 new_element1 = EL_SP_CHIP_SINGLE;
9293 new_element2 = EL_EMPTY;
9294 new_element3 = EL_SP_BASE;
9296 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9298 new_element1 = EL_MM_MIRROR_START;
9299 new_element2 = EL_EMPTY;
9300 new_element3 = EL_MM_WOODEN_WALL;
9304 new_element1 = EL_WALL;
9305 new_element2 = EL_EMPTY;
9306 new_element3 = EL_SAND;
9309 game_engine_type_last = level.game_engine_type;
9312 static void InitLevelSetInfo(void)
9314 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
9315 "%s", leveldir_current->name);
9316 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
9317 "%s", leveldir_current->author);
9319 levelset_num_levels = leveldir_current->levels;
9321 levelset_use_levelset_artwork = FALSE;
9322 levelset_copy_level_template = FALSE;
9324 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
9327 static void ChangeEditorToLevelSet(char *levelset_subdir)
9329 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
9331 // the previous level set might have used custom artwork
9332 ReloadCustomArtwork(0);
9334 LoadLevelSetup_SeriesInfo();
9336 SaveLevelSetup_LastSeries();
9337 SaveLevelSetup_SeriesInfo();
9341 LoadLevel(level_nr);
9342 LoadScore(level_nr);
9347 static boolean useEditorDoorAnimation(void)
9349 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
9350 boolean door_1_viewport_unchanged =
9351 (vp_door_1->x == DX &&
9352 vp_door_1->y == DY &&
9353 vp_door_1->width == DXSIZE &&
9354 vp_door_1->height == DYSIZE);
9355 boolean door_1_contains_toolbox =
9358 EX + EXSIZE <= DX + DXSIZE &&
9359 EY + EYSIZE <= DY + DYSIZE);
9361 return (door_1_viewport_unchanged && door_1_contains_toolbox);
9364 static void DrawEditorDoorBackground(int graphic, int x, int y,
9365 int width, int height)
9367 struct GraphicInfo *g = &graphic_info[graphic];
9369 if (g->bitmap != NULL)
9370 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
9371 MIN(width, g->width), MIN(height, g->height), x, y);
9373 ClearRectangle(drawto, x, y, width, height);
9376 static void DrawEditorDoorContent(void)
9378 // needed for gadgets drawn on background (like palette scrollbar)
9379 SetDoorBackgroundImage(IMG_UNDEFINED);
9381 // copy default editor door content to main double buffer
9382 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
9385 DrawSpecialEditorDoor();
9387 // draw new control window
9388 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
9390 // draw all toolbox gadgets to editor doors
9391 MapControlButtons();
9393 // when returning from test game to properties page, redraw toolbox gadgets
9394 if (edit_mode == ED_MODE_PROPERTIES)
9396 UnmapLevelEditorToolboxDrawingGadgets();
9397 UnmapLevelEditorToolboxCustomGadgets();
9399 MapLevelEditorToolboxCustomGadgetsIfNeeded();
9402 // draw all palette gadgets to editor doors
9403 ModifyEditorElementList();
9404 RedrawDrawingElements();
9406 // copy actual editor door content to door double buffer for OpenDoor()
9407 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
9410 void DrawLevelEd(void)
9412 int fade_mask = REDRAW_FIELD;
9414 FadeSoundsAndMusic();
9417 fade_mask = REDRAW_ALL;
9421 // needed if different viewport properties defined for editor
9422 ChangeViewportPropertiesIfNeeded();
9426 InitZoomLevelSettings(-1);
9427 InitDrawingElements();
9431 CheckElementDescriptions();
9434 if (level_editor_test_game)
9436 CopyPlayfield(level.field, Tile);
9437 CopyPlayfield(TileBackup, level.field);
9439 level_editor_test_game = FALSE;
9443 edit_mode = ED_MODE_DRAWING;
9444 edit_mode_levelconfig = ED_MODE_LEVELCONFIG_LEVEL;
9445 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
9453 // redraw_mask |= REDRAW_ALL;
9455 FreeLevelEditorGadgets();
9456 CreateLevelEditorGadgets();
9458 ReinitializeElementList(); // update dynamic level element list
9459 ReinitializeElementListButtons(); // custom element may look different
9461 InitElementPropertiesGfxElement();
9465 DrawEditModeWindow_PlayfieldOnly();
9467 DrawMaskedBorder(fade_mask);
9469 // use door animation if door 1 viewport is unchanged and contains toolbox
9470 if (useEditorDoorAnimation())
9474 DrawEditorDoorContent();
9476 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
9480 DrawEditorDoorContent();
9485 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
9488 static void AdjustDrawingAreaGadgets(void)
9490 int ed_xsize = lev_fieldx + 2;
9491 int ed_ysize = lev_fieldy + 2;
9492 int max_ed_fieldx = MAX_ED_FIELDX;
9493 int max_ed_fieldy = MAX_ED_FIELDY;
9494 boolean horizontal_scrollbar_needed;
9495 boolean vertical_scrollbar_needed;
9496 int x, y, width, height;
9498 if (suppressBorderElement())
9500 ed_xsize = lev_fieldx;
9501 ed_ysize = lev_fieldy;
9504 // check if we need any scrollbars
9505 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9506 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9508 // check if we have a smaller editor field because of scrollbars
9509 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9510 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9512 // check again if we now need more scrollbars because of less space
9513 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9514 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9516 // check if editor field gets even smaller after adding new scrollbars
9517 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9518 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9520 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
9521 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
9523 x = SX + ed_fieldx * ed_tilesize;
9524 y = SY + ed_fieldy * ed_tilesize;
9526 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
9527 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
9529 // adjust drawing area gadget
9530 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
9531 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
9532 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
9535 // adjust horizontal scrollbar gadgets
9536 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
9539 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
9540 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
9543 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9546 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
9549 // adjust vertical scrollbar gadgets
9550 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
9553 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
9555 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
9557 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9560 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
9564 static void AdjustLevelScrollPosition(void)
9566 if (level_xpos < -1)
9568 if (level_xpos > lev_fieldx - ed_fieldx + 1)
9569 level_xpos = lev_fieldx - ed_fieldx + 1;
9570 if (lev_fieldx < ed_fieldx - 2)
9573 if (level_ypos < -1)
9575 if (level_ypos > lev_fieldy - ed_fieldy + 1)
9576 level_ypos = lev_fieldy - ed_fieldy + 1;
9577 if (lev_fieldy < ed_fieldy - 2)
9580 if (suppressBorderElement())
9587 static void AdjustEditorScrollbar(int id)
9589 struct GadgetInfo *gi = level_editor_gadget[id];
9590 int items_max, items_visible, item_position;
9592 if (id == GADGET_ID_SCROLL_HORIZONTAL)
9594 items_max = MAX(lev_fieldx + 2, ed_fieldx);
9595 items_visible = ed_fieldx;
9596 item_position = level_xpos + 1;
9600 items_max = MAX(lev_fieldy + 2, ed_fieldy);
9601 items_visible = ed_fieldy;
9602 item_position = level_ypos + 1;
9605 if (item_position > items_max - items_visible)
9606 item_position = items_max - items_visible;
9608 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9609 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9612 static void AdjustElementListScrollbar(void)
9614 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
9615 int items_max, items_visible, item_position;
9617 // correct position of element list scrollbar
9618 if (element_shift < 0)
9620 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9621 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9623 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
9624 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
9625 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
9627 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9628 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
9629 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9632 static void ModifyEditorCounterValue(int counter_id, int new_value)
9634 int *counter_value = counterbutton_info[counter_id].value;
9635 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9636 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9638 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9640 if (counter_value != NULL)
9641 *counter_value = gi->textinput.number_value;
9644 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9646 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9647 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9649 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9651 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9652 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9654 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9655 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9657 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9658 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9663 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9665 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9666 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9667 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9669 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9672 static void ModifyEditorSelectboxOptions(int selectbox_id,
9673 struct ValueTextInfo *options)
9675 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9676 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9678 selectbox_info[selectbox_id].options = options;
9680 // set index to zero -- list may be shorter now (correct later, if needed)
9681 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9682 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9685 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9687 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9688 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9690 drawingarea_info[drawingarea_id].area_xsize = xsize;
9691 drawingarea_info[drawingarea_id].area_ysize = ysize;
9693 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9696 static void ModifyEditorElementList(void)
9700 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9703 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9705 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9706 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9707 struct GadgetDesign *gd = &gi->deco.design;
9708 int element = editor_elements[element_shift + i];
9709 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9713 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9715 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9721 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9723 int graphic = el2edimg(element);
9724 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9730 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9733 static void ModifyDrawingElementButton(int element, int id)
9735 struct GadgetInfo *gi = level_editor_gadget[id];
9736 Bitmap *deco_bitmap;
9738 int tile_size = gi->deco.width;
9740 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9742 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9745 static void PickDrawingElement(int button, int element)
9750 struct XYTileSize *pos;
9752 } de, drawing_elements[] =
9754 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9755 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9756 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9759 if (button < 1 || button > 3)
9762 if (IS_MM_WALL(element))
9763 element = map_mm_wall_element(element);
9765 de = drawing_elements[button - 1];
9767 *de.new_element = element; // update global drawing element variable
9769 DrawDrawingElementGraphic(element, de.pos);
9770 ModifyDrawingElementButton(element, de.id);
9772 redraw_mask |= REDRAW_DOOR_1;
9775 static void RedrawDrawingElements(void)
9777 PickDrawingElement(1, new_element1);
9778 PickDrawingElement(2, new_element2);
9779 PickDrawingElement(3, new_element3);
9782 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9784 stick_element_properties_window = FALSE;
9786 SetMainBackgroundImage(IMG_UNDEFINED);
9789 UnmapLevelEditorFieldGadgets();
9791 AdjustDrawingAreaGadgets();
9792 AdjustLevelScrollPosition();
9793 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9794 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9796 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9798 MapMainDrawingArea();
9800 if (remap_toolbox_gadgets)
9802 UnmapLevelEditorToolboxCustomGadgets();
9803 MapLevelEditorToolboxDrawingGadgets();
9807 static void DrawDrawingWindow(void)
9809 DrawDrawingWindowExt(TRUE);
9812 static int getTabulatorBarWidth(void)
9814 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9815 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9817 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9820 static int getTabulatorBarHeight(void)
9822 return ED_TAB_BAR_HEIGHT;
9825 static Pixel getTabulatorBarColor(void)
9827 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9828 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9829 int gd_x = gd->x + gd_gi1->border.width / 2;
9830 int gd_y = gd->y + gd_gi1->height - 1;
9832 return GetPixel(gd->bitmap, gd_x, gd_y);
9835 static void DrawLevelConfigTabulatorGadgets(void)
9837 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9838 Pixel tab_color = getTabulatorBarColor();
9839 int id_first = ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL;
9840 int id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR;
9843 // draw additional "engine" tabulator when using native BD engine
9844 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9845 id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE;
9847 for (i = id_first; i <= id_last; i++)
9849 int gadget_id = textbutton_info[i].gadget_id;
9850 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9851 boolean active = (i != edit_mode_levelconfig);
9853 // draw background line below tabulator button
9854 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9856 // draw solid line below inactive tabulator buttons
9857 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9858 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9859 ED_GADGET_TINY_DISTANCE, tab_color);
9861 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9862 MapTextbuttonGadget(i);
9865 // draw little border line below tabulator buttons
9866 if (tab_color != BLACK_PIXEL) // black => transparent
9867 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9868 ED_GADGET_TINY_DISTANCE,
9869 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9872 static void DrawPropertiesTabulatorGadgets(void)
9874 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9875 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9876 int gd_x = gd->x + gd_gi1->border.width / 2;
9877 int gd_y = gd->y + gd_gi1->height - 1;
9878 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9879 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9880 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9883 // draw two config tabulators for player elements
9884 if (IS_PLAYER_ELEMENT(properties_element))
9885 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9887 // draw two config and one "change" tabulator for custom elements
9888 if (IS_CUSTOM_ELEMENT(properties_element))
9889 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9891 for (i = id_first; i <= id_last; i++)
9893 int gadget_id = textbutton_info[i].gadget_id;
9894 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9895 boolean active = (i != edit_mode_properties);
9897 // use "config 1" and "config 2" instead of "config" for players and CEs
9898 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9899 (IS_PLAYER_ELEMENT(properties_element) ||
9900 IS_CUSTOM_ELEMENT(properties_element)))
9903 // draw background line below tabulator button
9904 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9906 // draw solid line below inactive tabulator buttons
9907 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9908 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9909 ED_GADGET_TINY_DISTANCE, tab_color);
9911 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9912 MapTextbuttonGadget(i);
9915 // draw little border line below tabulator buttons
9916 if (tab_color != BLACK_PIXEL) // black => transparent
9917 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9918 ED_GADGET_TINY_DISTANCE,
9919 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9922 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9924 DrawText(SX + xpos, SY + ypos, text, font_nr);
9927 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9930 int font_width = getFontWidth(font_nr);
9931 int font_height = getFontHeight(font_nr);
9932 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9933 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9935 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9936 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9937 TRUE, FALSE, FALSE);
9940 static void DrawLevelConfigLevel(void)
9944 // draw counter gadgets
9945 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9946 MapCounterButtons(i);
9948 // draw checkbutton gadgets
9949 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9950 MapCheckbuttonGadget(i);
9952 // draw selectbox gadgets
9953 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9954 MapSelectboxGadget(i);
9956 // draw text input gadgets
9957 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9958 MapTextInputGadget(i);
9961 static char *getLevelSubdirFromSaveMode(int save_mode)
9963 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9964 return getNewUserLevelSubdir();
9966 return leveldir_current->subdir;
9969 static void DrawLevelConfigLevelSet_DirectoryInfo(void)
9971 char *directory_text = "Level set directory:";
9972 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9973 int font1_nr = FONT_TEXT_1;
9974 int font2_nr = FONT_TEXT_2;
9975 int font1_height = getFontHeight(font1_nr);
9976 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
9977 int x = ED_LEVEL_SETTINGS_X(0);
9978 int y = ED_LEVEL_SETTINGS_Y(6);
9980 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
9981 PrintInfoText(directory_name, font2_nr, x, y);
9984 static void DrawLevelConfigLevelSet(void)
9986 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
9987 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
9990 // draw counter gadgets
9991 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
9992 MapCounterButtons(i);
9994 // draw checkbutton gadgets
9995 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
9997 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
9998 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
9999 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
10002 MapCheckbuttonGadget(i);
10005 // draw selectbox gadgets
10006 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
10007 MapSelectboxGadget(i);
10009 // draw text input gadgets
10010 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
10011 MapTextInputGadget(i);
10013 // draw textbutton gadgets
10014 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
10017 DrawLevelConfigLevelSet_DirectoryInfo();
10020 static void DrawLevelConfigEditor(void)
10024 // draw counter gadgets
10025 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
10026 MapCounterButtons(i);
10028 // draw checkbutton gadgets
10029 for (i = ED_CHECKBUTTON_ID_EDITOR_FIRST; i <= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
10030 MapCheckbuttonGadget(i);
10032 // draw radiobutton gadgets
10033 for (i = ED_RADIOBUTTON_ID_EDITOR_FIRST; i <= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
10034 MapRadiobuttonGadget(i);
10036 // draw drawing area
10037 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
10039 // draw textbutton gadgets
10040 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
10043 static void DrawLevelConfigEngine(void)
10047 // draw checkbutton gadgets
10048 for (i = ED_CHECKBUTTON_ID_ENGINE_FIRST; i <= ED_CHECKBUTTON_ID_ENGINE_LAST; i++)
10049 MapCheckbuttonGadget(i);
10051 // draw selectbox gadgets
10052 for (i = ED_SELECTBOX_ID_ENGINE_FIRST; i <= ED_SELECTBOX_ID_ENGINE_LAST; i++)
10053 MapSelectboxGadget(i);
10056 static void DrawLevelConfigWindow(void)
10058 char *text = "Global Settings";
10059 int font_nr = FONT_TITLE_1;
10060 struct MenuPosInfo *pos = &editor.settings.headline;
10061 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
10062 int sy = SY + pos->y;
10064 stick_element_properties_window = FALSE;
10066 SetAutomaticNumberOfGemsNeeded();
10068 UnmapLevelEditorFieldGadgets();
10070 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10073 DrawText(sx, sy, text, font_nr);
10075 DrawLevelConfigTabulatorGadgets();
10077 if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVEL)
10078 DrawLevelConfigLevel();
10079 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVELSET)
10080 DrawLevelConfigLevelSet();
10081 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_EDITOR)
10082 DrawLevelConfigEditor();
10083 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_ENGINE)
10084 DrawLevelConfigEngine();
10087 static void DrawCustomContentArea(void)
10089 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
10090 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10091 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
10092 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
10093 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
10094 int xoffset = ED_GADGET_SPACE_DISTANCE;
10096 // add distance for potential left text (without drawing area border)
10097 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
10099 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10101 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
10104 static void DrawCustomChangeContentArea(void)
10106 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
10107 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10108 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
10109 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
10110 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
10111 int xoffset = ED_GADGET_SPACE_DISTANCE;
10113 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10115 MapDrawingArea(id);
10118 static void RemoveElementContentArea(int id, int font_height)
10120 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10122 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
10123 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
10124 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10125 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
10126 ED_GADGET_TEXT_DISTANCE + font_height);
10129 static void DrawYamYamContentAreas(void)
10131 int font_nr = FONT_TEXT_1;
10132 int font_height = getFontHeight(font_nr);
10133 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10134 int yoffset = (tilesize - font_height) / 2;
10135 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
10136 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
10139 // display counter to choose number of element content areas
10140 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
10142 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10144 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
10146 if (i < level.num_yamyam_contents)
10148 MapDrawingArea(id);
10152 UnmapDrawingArea(id);
10154 // delete content areas in case of reducing number of them
10155 RemoveElementContentArea(id, font_height);
10159 DrawText(x, y + 0 * tilesize, "content", font_nr);
10160 DrawText(x, y + 1 * tilesize, "when", font_nr);
10161 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
10164 static void DrawMagicBallContentAreas(void)
10166 int font_nr = FONT_TEXT_1;
10167 int font_height = getFontHeight(font_nr);
10168 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10169 int yoffset = (tilesize - font_height) / 2;
10170 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
10171 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
10174 // display counter to choose number of element content areas
10175 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
10177 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10179 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
10181 if (i < level.num_ball_contents)
10183 MapDrawingArea(id);
10187 UnmapDrawingArea(id);
10189 // delete content areas in case of reducing number of them
10190 RemoveElementContentArea(id, font_height);
10194 DrawText(x, y + 0 * tilesize, "generated", font_nr);
10195 DrawText(x, y + 1 * tilesize, "when", font_nr);
10196 DrawText(x, y + 2 * tilesize, "active", font_nr);
10199 static void DrawAndroidElementArea(void)
10201 int id = ED_DRAWING_ID_ANDROID_CONTENT;
10202 int num_elements = level.num_android_clone_elements;
10203 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10204 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10205 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10206 int xsize = MAX_ANDROID_ELEMENTS;
10209 // display counter to choose number of element areas
10210 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
10212 if (drawingarea_info[id].text_left != NULL)
10213 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10215 UnmapDrawingArea(id);
10217 ModifyEditorDrawingArea(id, num_elements, 1);
10219 // delete content areas in case of reducing number of them
10220 DrawBackground(sx, sy,
10221 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10222 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10224 MapDrawingArea(id);
10227 static void DrawGroupElementArea(void)
10229 int id = ED_DRAWING_ID_GROUP_CONTENT;
10230 int num_elements = group_element_info.num_elements;
10231 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10232 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10233 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10234 int xsize = MAX_ELEMENTS_IN_GROUP;
10237 if (drawingarea_info[id].text_left != NULL)
10238 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10240 UnmapDrawingArea(id);
10242 ModifyEditorDrawingArea(id, num_elements, 1);
10244 // delete content areas in case of reducing number of them
10245 DrawBackground(sx, sy,
10246 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10247 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10249 MapDrawingArea(id);
10252 static void DrawPlayerInitialInventoryArea(int element)
10254 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
10255 int player_nr = GET_PLAYER_NR(element);
10256 int num_elements = level.initial_inventory_size[player_nr];
10257 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10258 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10259 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10260 int xsize = MAX_INITIAL_INVENTORY_SIZE;
10263 // determine horizontal position to the right of specified gadget
10264 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
10265 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
10266 ED_DRAWINGAREA_TEXT_DISTANCE);
10268 // determine horizontal offset for leading text
10269 if (drawingarea_info[id].text_left != NULL)
10270 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10272 UnmapDrawingArea(id);
10274 ModifyEditorDrawingArea(id, num_elements, 1);
10276 // delete content areas in case of reducing number of them
10277 DrawBackground(sx, sy,
10278 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10279 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10281 MapDrawingArea(id);
10284 static void DrawMMBallContentArea(void)
10286 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
10287 int num_elements = level.num_mm_ball_contents;
10288 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10289 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10290 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10291 int xsize = MAX_MM_BALL_CONTENTS;
10294 if (drawingarea_info[id].text_left != NULL)
10295 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10297 UnmapDrawingArea(id);
10299 ModifyEditorDrawingArea(id, num_elements, 1);
10301 // delete content areas in case of reducing number of them
10302 DrawBackground(sx, sy,
10303 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10304 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10306 MapDrawingArea(id);
10309 static void DrawEnvelopeTextArea(int envelope_nr)
10311 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
10312 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
10316 DrawBackground(gi->x, gi->y,
10317 gi->textarea.crop_width, gi->textarea.crop_height);
10319 if (envelope_nr != -1)
10320 textarea_info[id].value = level.envelope[envelope_nr].text;
10322 ModifyGadget(gi, GDI_AREA_SIZE,
10323 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
10324 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
10327 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
10330 static void DrawPropertiesInfo(void)
10339 // configurable properties
10341 { EP_WALKABLE_OVER, "- player can walk over it" },
10342 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
10343 { EP_WALKABLE_UNDER, "- player can walk under it" },
10344 { EP_PASSABLE_OVER, "- player can pass over it" },
10345 { EP_PASSABLE_INSIDE, "- player can pass through it" },
10346 { EP_PASSABLE_UNDER, "- player can pass under it" },
10347 { EP_PROTECTED, "- player is protected by it" },
10349 { EP_DIGGABLE, "- can be digged away" },
10350 { EP_COLLECTIBLE, "- can be collected" },
10351 { EP_DROPPABLE, "- can be dropped after collecting" },
10352 { EP_THROWABLE, "- can be thrown after collecting" },
10353 { EP_PUSHABLE, "- can be pushed" },
10355 { EP_CAN_FALL, "- can fall" },
10356 { EP_CAN_MOVE, "- can move" },
10358 { EP_CAN_SMASH_PLAYER, "- can smash player" },
10360 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
10362 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
10364 { EP_SLIPPERY, "- slippery for falling elements" },
10365 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
10367 { EP_DONT_RUN_INTO, "- deadly when running into" },
10368 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
10369 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
10370 { EP_DONT_TOUCH, "- deadly when touching" },
10372 { EP_INDESTRUCTIBLE, "- indestructible" },
10374 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
10375 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
10376 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
10378 { EP_CAN_CHANGE, "- can change to other element" },
10380 // pre-defined properties
10381 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
10382 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
10383 { EP_SWITCHABLE, "- can be switched" },
10385 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
10390 char *filename = getElementDescriptionFilename(properties_element);
10391 char *num_elements_text = "In this level: ";
10392 char *num_similar_text = "Similar tiles: ";
10393 char *properties_text = "Standard properties: ";
10394 char *description_text = "Description:";
10395 char *no_description_text = "No description available.";
10396 char *none_text = "None";
10398 int num_elements_in_level = 0;
10399 int num_similar_in_level = 0;
10400 int num_hires_tiles_in_level = 0;
10401 int num_standard_properties = 0;
10402 int font1_nr = FONT_TEXT_1;
10403 int font2_nr = FONT_TEXT_2;
10404 int font1_width = getFontWidth(font1_nr);
10405 int font1_height = getFontHeight(font1_nr);
10406 int font2_height = getFontHeight(font2_nr);
10407 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
10408 int font2_yoffset = (font1_height - font2_height) / 2;
10409 int num_elements_text_len = strlen(num_elements_text) * font1_width;
10410 int num_similar_text_len = strlen(num_similar_text) * font1_width;
10411 int properties_text_len = strlen(properties_text) * font1_width;
10412 int xpos = ED_ELEMENT_SETTINGS_X(0);
10413 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10416 if (setup.editor.show_element_token)
10418 int font3_nr = FONT_TEXT_3;
10419 int font3_height = getFontHeight(font3_nr);
10421 DrawTextF(xpos, ypos, font3_nr,
10422 "[%s]", element_info[properties_element].token_name);
10424 ypos += 2 * font3_height;
10427 // ----- print number of elements / percentage of this element in level
10429 for (y = 0; y < lev_fieldy; y++)
10431 for (x = 0; x < lev_fieldx; x++)
10433 if (Tile[x][y] == properties_element)
10435 num_elements_in_level++;
10437 else if (IS_MM_WALL(Tile[x][y]) &&
10438 map_mm_wall_element(Tile[x][y]) == properties_element)
10440 num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
10445 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10447 DrawTextS(xpos, ypos, font1_nr, num_elements_text);
10449 if (num_hires_tiles_in_level > 0)
10450 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10451 "%d wall tiles", num_hires_tiles_in_level);
10452 else if (num_elements_in_level > 0)
10453 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10454 "%d (%.2f %%)", num_elements_in_level, percentage);
10456 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10459 // ----- print number of similar elements / percentage of them in level
10461 for (y = 0; y < lev_fieldy; y++)
10463 for (x = 0; x < lev_fieldx; x++)
10465 if (strEqual(element_info[Tile[x][y]].class_name,
10466 element_info[properties_element].class_name))
10468 num_similar_in_level++;
10473 if (num_similar_in_level != num_elements_in_level)
10475 ypos += 1 * MAX(font1_height, font2_height);
10477 percentage = num_similar_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10479 DrawTextS(xpos, ypos, font1_nr, num_similar_text);
10481 if (num_similar_in_level > 0)
10482 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10483 "%d (%.2f %%)", num_similar_in_level, percentage);
10485 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10489 ypos += 2 * MAX(font1_height, font2_height);
10491 // ----- print standard properties of this element
10493 DrawTextS(xpos, ypos, font1_nr, properties_text);
10495 ypos += line1_height;
10497 for (i = 0; properties[i].value != -1; i++)
10499 if (!HAS_PROPERTY(properties_element, properties[i].value))
10502 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
10504 ypos += font2_height;
10506 num_standard_properties++;
10509 if (num_standard_properties == 0)
10511 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
10512 font2_nr, none_text);
10514 ypos -= (line1_height - font1_height);
10517 ypos += MAX(font1_height, font2_height);
10519 // ----- print special description of this element
10521 PrintInfoText(description_text, font1_nr, xpos, ypos);
10523 ypos += line1_height;
10525 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
10526 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
10529 #define TEXT_COLLECTING "Score for collecting"
10530 #define TEXT_COLLECTING_EXTRA "Score for extra diamonds"
10531 #define TEXT_SMASHING "Score for smashing"
10532 #define TEXT_SLURPING "Score for slurping robot"
10533 #define TEXT_CRACKING "Score for cracking"
10534 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
10535 #define TEXT_DURATION "Duration when activated"
10536 #define TEXT_DELAY_ON "Delay before activating"
10537 #define TEXT_DELAY_OFF "Delay before deactivating"
10538 #define TEXT_DELAY_CHANGING "Delay before changing"
10539 #define TEXT_DELAY_EXPLODING "Delay before exploding"
10540 #define TEXT_DELAY_MOVING "Delay before moving"
10541 #define TEXT_BALL_DELAY "Element generation delay"
10542 #define TEXT_MOVE_SPEED "Speed of android moving"
10543 #define TEXT_CLONE_SPEED "Speed of android cloning"
10544 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
10545 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
10546 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
10547 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
10548 #define TEXT_TIME_BONUS "Extra time to solve level"
10555 } elements_with_counter[] =
10557 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
10558 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
10559 { EL_BD_DIAMOND, &level.score[SC_DIAMOND_EXTRA], TEXT_COLLECTING_EXTRA },
10560 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
10561 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
10562 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10563 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
10564 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
10565 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
10566 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
10567 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
10568 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10569 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
10570 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10571 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10572 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
10573 { EL_BD_BUTTERFLY_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10574 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
10575 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10576 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10577 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
10578 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10579 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10580 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10581 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10582 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10583 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10584 { EL_BD_FIREFLY_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10585 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10586 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10587 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10588 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10589 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10590 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10591 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10592 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
10593 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
10594 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10595 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
10596 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10597 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10598 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10599 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10600 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10601 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
10602 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10603 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10604 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE], TEXT_COLLECTING },
10605 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10606 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10607 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
10608 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
10609 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
10610 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10611 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10612 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10613 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10614 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10615 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10616 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10617 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10618 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
10619 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
10620 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
10621 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
10622 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
10623 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10624 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
10625 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
10626 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
10627 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10628 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10629 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10630 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10631 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10632 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10633 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10634 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10635 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10636 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10637 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10638 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10639 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10640 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
10641 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10642 { EL_DC_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10643 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
10644 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
10645 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
10646 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
10647 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
10648 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
10649 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
10650 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
10651 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
10652 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
10653 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
10654 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
10655 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
10656 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
10657 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
10658 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
10659 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
10660 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
10661 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
10662 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
10663 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
10664 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
10665 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
10666 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
10667 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
10668 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
10669 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_CHANGING },
10670 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10671 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10676 static boolean checkPropertiesConfig(int element)
10680 // special case: empty space customization only available in R'n'D game engine
10681 if (element == EL_EMPTY_SPACE && level.game_engine_type != GAME_ENGINE_TYPE_RND)
10684 if (IS_GEM(element) ||
10685 IS_CUSTOM_ELEMENT(element) ||
10686 IS_GROUP_ELEMENT(element) ||
10687 IS_EMPTY_ELEMENT(element) ||
10688 IS_BALLOON_ELEMENT(element) ||
10689 IS_ENVELOPE(element) ||
10690 IS_MM_ENVELOPE(element) ||
10691 IS_MM_MCDUFFIN(element) ||
10692 IS_DF_LASER(element) ||
10693 IS_PLAYER_ELEMENT(element) ||
10694 IS_BD_PLAYER_ELEMENT(element) ||
10695 IS_SOKOBAN_OBJECT_OR_FIELD(element) ||
10696 HAS_EDITOR_CONTENT(element) ||
10697 CAN_GROW(element) ||
10698 COULD_MOVE_INTO_ACID(element) ||
10699 MAYBE_DONT_COLLIDE_WITH(element))
10702 for (i = 0; elements_with_counter[i].element != -1; i++)
10703 if (elements_with_counter[i].element == element)
10709 static void SetAutomaticNumberOfGemsNeeded(void)
10713 if (!level.auto_count_gems)
10716 level.gems_needed = 0;
10718 for (x = 0; x < lev_fieldx; x++)
10720 for (y = 0; y < lev_fieldy; y++)
10722 int element = Tile[x][y];
10727 case EL_EMERALD_YELLOW:
10728 case EL_EMERALD_RED:
10729 case EL_EMERALD_PURPLE:
10730 case EL_BD_DIAMOND:
10731 case EL_WALL_EMERALD:
10732 case EL_WALL_EMERALD_YELLOW:
10733 case EL_WALL_EMERALD_RED:
10734 case EL_WALL_EMERALD_PURPLE:
10735 case EL_WALL_BD_DIAMOND:
10737 case EL_SP_INFOTRON:
10740 level.gems_needed++;
10744 case EL_WALL_DIAMOND:
10745 level.gems_needed += 3;
10749 case EL_WALL_PEARL:
10750 level.gems_needed += 5;
10754 case EL_WALL_CRYSTAL:
10755 level.gems_needed += 8;
10764 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10767 static void DrawPropertiesConfig(void)
10769 boolean draw_footer_line = FALSE;
10770 int max_num_element_counters = 4;
10771 int num_element_counters = 0;
10774 if (!checkPropertiesConfig(properties_element))
10776 int xpos = ED_ELEMENT_SETTINGS_X(0);
10777 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10779 PrintInfoText("No configuration options available.",
10780 FONT_TEXT_1, xpos, ypos);
10785 // check if there are elements where a value can be chosen for
10786 for (i = 0; elements_with_counter[i].element != -1; i++)
10788 if (elements_with_counter[i].element == properties_element)
10790 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10792 counterbutton_info[counter_id].y =
10793 ED_ELEMENT_SETTINGS_YPOS(
10794 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10795 (CAN_GROW(properties_element) ? 1 : 0) +
10796 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10797 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10798 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10799 num_element_counters);
10801 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10802 counterbutton_info[counter_id].text_right = elements_with_counter[i].text;
10804 if (properties_element == EL_GAME_OF_LIFE ||
10805 properties_element == EL_BIOMAZE)
10807 counterbutton_info[counter_id].min_value = 0; // min neighbours
10808 counterbutton_info[counter_id].max_value = 8; // max neighbours
10812 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10813 counterbutton_info[counter_id].min_value = MIN_SCORE;
10814 counterbutton_info[counter_id].max_value = MAX_SCORE;
10817 MapCounterButtons(counter_id);
10819 num_element_counters++;
10820 if (num_element_counters >= max_num_element_counters)
10825 if (HAS_EDITOR_CONTENT(properties_element))
10827 // draw stickybutton gadget
10828 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10830 if (IS_AMOEBOID(properties_element))
10831 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10832 else if (properties_element == EL_YAMYAM ||
10833 properties_element == EL_YAMYAM_LEFT ||
10834 properties_element == EL_YAMYAM_RIGHT ||
10835 properties_element == EL_YAMYAM_UP ||
10836 properties_element == EL_YAMYAM_DOWN)
10837 DrawYamYamContentAreas();
10838 else if (properties_element == EL_EMC_MAGIC_BALL)
10840 DrawMagicBallContentAreas();
10842 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10843 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10845 else if (properties_element == EL_EMC_ANDROID)
10846 DrawAndroidElementArea();
10847 else if (properties_element == EL_MM_GRAY_BALL)
10849 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
10850 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
10851 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
10852 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EXPLODE_MM_BALL);
10854 DrawMMBallContentArea();
10858 if (IS_PLAYER_ELEMENT(properties_element))
10860 int player_nr = GET_PLAYER_NR(properties_element);
10862 // these properties can be set for every player individually
10864 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10866 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
10867 &level.start_element[player_nr];
10868 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
10869 &level.artwork_element[player_nr];
10870 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
10871 &level.explosion_element[player_nr];
10873 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10874 &level.use_start_element[player_nr];
10875 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10876 &level.use_artwork_element[player_nr];
10877 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10878 &level.use_explosion_element[player_nr];
10879 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10880 &level.initial_player_gravity[player_nr];
10882 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10883 &level.initial_player_stepsize[player_nr];
10885 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
10886 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
10887 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
10888 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
10889 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
10890 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
10891 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
10892 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
10893 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
10894 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
10895 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
10896 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
10897 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
10898 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
10899 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
10901 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
10902 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
10903 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
10905 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
10907 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10909 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
10910 &level.initial_inventory_content[player_nr][0];
10912 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
10913 &level.initial_inventory_size[player_nr];
10915 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
10916 &level.use_initial_inventory[player_nr];
10918 // draw checkbutton gadgets
10919 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
10920 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
10921 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
10923 // draw counter gadgets
10924 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
10926 // draw drawing area gadgets
10927 DrawPlayerInitialInventoryArea(properties_element);
10931 if (IS_BD_PLAYER_ELEMENT(properties_element))
10932 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS);
10934 // special case: slippery walls option for gems only available in R'n'D game engine
10935 if (IS_GEM(properties_element) && level.game_engine_type == GAME_ENGINE_TYPE_RND)
10937 checkbutton_info[ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS].y =
10938 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_BD_DIAMOND ? 2 : 1);
10940 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
10943 if (properties_element == EL_EM_DYNAMITE)
10944 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
10946 if (COULD_MOVE_INTO_ACID(properties_element) &&
10947 !IS_PLAYER_ELEMENT(properties_element) &&
10948 (!IS_CUSTOM_ELEMENT(properties_element) ||
10949 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
10951 // set position for checkbutton for "can move into acid"
10952 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
10953 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
10954 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
10955 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
10956 IS_BALLOON_ELEMENT(properties_element) ||
10957 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10959 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
10962 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
10963 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
10965 if (properties_element == EL_SPRING ||
10966 properties_element == EL_SPRING_LEFT ||
10967 properties_element == EL_SPRING_RIGHT)
10968 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
10970 if (properties_element == EL_TIME_ORB_FULL)
10971 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
10973 if (properties_element == EL_GAME_OF_LIFE ||
10974 properties_element == EL_BIOMAZE)
10975 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
10977 if (CAN_GROW(properties_element))
10979 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
10980 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10982 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
10985 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
10986 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
10988 if (properties_element == EL_SOKOBAN_OBJECT)
10989 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
10991 if (properties_element == EL_SOKOBAN_OBJECT ||
10992 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
10993 properties_element == EL_SOKOBAN_FIELD_FULL)
10995 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
10996 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
10999 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
11002 if (IS_BALLOON_ELEMENT(properties_element))
11003 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
11005 if (IS_ENVELOPE(properties_element) ||
11006 IS_MM_ENVELOPE(properties_element))
11008 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
11009 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
11010 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
11011 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
11012 int envelope_nr = ENVELOPE_NR(properties_element);
11014 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
11015 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
11017 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
11018 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
11020 // display counter to choose size of envelope text area
11021 MapCounterButtons(counter1_id);
11022 MapCounterButtons(counter2_id);
11024 // display checkbuttons to choose auto-wrap and alignment properties
11025 MapCheckbuttonGadget(button1_id);
11026 MapCheckbuttonGadget(button2_id);
11028 DrawEnvelopeTextArea(envelope_nr);
11031 if (IS_MM_MCDUFFIN(properties_element))
11033 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
11034 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
11035 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
11038 if (IS_DF_LASER(properties_element))
11040 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
11041 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
11042 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
11045 if (IS_CUSTOM_ELEMENT(properties_element))
11047 // draw stickybutton gadget
11048 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11050 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
11052 // draw checkbutton gadgets
11053 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
11054 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
11055 MapCheckbuttonGadget(i);
11057 // draw counter gadgets
11058 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
11059 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
11060 MapCounterButtons(i);
11062 // draw selectbox gadgets
11063 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
11064 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
11065 MapSelectboxGadget(i);
11067 // draw textbutton gadgets
11068 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11070 // draw text input gadgets
11071 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11073 // draw drawing area gadgets
11074 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11076 draw_footer_line = TRUE;
11078 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
11080 // draw checkbutton gadgets
11081 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
11082 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
11083 MapCheckbuttonGadget(i);
11085 // draw counter gadgets
11086 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
11087 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
11088 MapCounterButtons(i);
11090 // draw selectbox gadgets
11091 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
11092 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
11093 MapSelectboxGadget(i);
11095 // draw drawing area gadgets
11096 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
11097 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
11098 DrawCustomContentArea();
11101 else if (IS_GROUP_ELEMENT(properties_element))
11103 // draw stickybutton gadget
11104 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11106 // draw checkbutton gadgets
11107 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11108 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11110 // draw counter gadgets
11111 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
11113 // draw selectbox gadgets
11114 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
11116 // draw textbutton gadgets
11117 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11119 // draw drawing area gadgets
11120 DrawGroupElementArea();
11122 // draw text input gadgets
11123 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11125 // draw drawing area gadgets
11126 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11128 draw_footer_line = TRUE;
11130 else if (IS_EMPTY_ELEMENT(properties_element))
11132 // draw stickybutton gadget
11133 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11135 // draw checkbutton gadgets
11136 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11137 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11139 // draw textbutton gadgets
11140 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11142 // draw drawing area gadgets
11143 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11145 draw_footer_line = TRUE;
11148 // draw little footer border line above CE/GE use/save template gadgets
11149 if (draw_footer_line)
11151 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
11152 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
11153 int gd_x = gd->x + gd_gi1->border.width / 2;
11154 int gd_y = gd->y + gd_gi1->height - 1;
11155 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
11157 if (tab_color != BLACK_PIXEL) // black => transparent
11158 FillRectangle(drawto,
11159 SX + ED_ELEMENT_SETTINGS_X(0),
11160 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
11162 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
11166 static void DrawPropertiesChangeDrawingAreas(void)
11168 if (IS_CUSTOM_ELEMENT(properties_element))
11170 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
11171 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
11172 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
11174 DrawCustomChangeContentArea();
11177 redraw_mask |= REDRAW_FIELD;
11180 static void DrawPropertiesChange(void)
11184 // needed to initially set selectbox options for special action options
11185 setSelectboxSpecialActionOptions();
11187 // draw stickybutton gadget
11188 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11190 // draw checkbutton gadgets
11191 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
11192 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
11193 MapCheckbuttonGadget(i);
11195 // draw counter gadgets
11196 for (i = ED_COUNTER_ID_CHANGE_FIRST;
11197 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
11198 MapCounterButtons(i);
11200 // draw selectbox gadgets
11201 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
11202 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
11203 MapSelectboxGadget(i);
11205 // draw textbutton gadgets
11206 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
11207 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
11208 MapTextbuttonGadget(i);
11210 // draw graphicbutton gadgets
11211 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
11212 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
11213 MapGraphicbuttonGadget(i);
11215 // draw drawing area gadgets
11216 DrawPropertiesChangeDrawingAreas();
11219 static void DrawEditorElementAnimation(int x, int y)
11221 int graphic = el2img(properties_element);
11222 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
11223 custom_element.ce_value_fixed_initial :
11224 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
11225 custom_element.collect_score_initial : FrameCounter);
11227 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
11230 static void DrawEditorElementName(int x, int y, int font_nr)
11232 char *element_name = getElementInfoText(properties_element);
11233 int font_width = getFontWidth(font_nr);
11234 int font_height = getFontHeight(font_nr);
11235 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
11236 int max_chars_per_line = max_text_width / font_width;
11238 if (strlen(element_name) <= max_chars_per_line)
11239 DrawTextS(x, y, font_nr, element_name);
11242 char buffer[max_chars_per_line + 1];
11243 int next_pos = max_chars_per_line;
11245 strncpy(buffer, element_name, max_chars_per_line);
11246 buffer[max_chars_per_line] = '\0';
11248 if (element_name[max_chars_per_line] == ' ')
11254 for (i = max_chars_per_line - 1; i >= 0; i--)
11255 if (buffer[i] == ' ')
11258 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
11265 DrawTextS(x, y - font_height / 2, font_nr, buffer);
11267 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
11268 buffer[max_chars_per_line] = '\0';
11270 DrawTextS(x, y + font_height / 2, font_nr, buffer);
11274 static void DrawPropertiesWindow(void)
11276 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
11277 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
11278 int border_size = gd->border_size;
11279 int font_nr = FONT_TEXT_1;
11280 int font_height = getFontHeight(font_nr);
11281 int xoffset = TILEX + element_border + 3 * border_size;
11282 int yoffset = (TILEY - font_height) / 2;
11283 int x1 = editor.settings.element_graphic.x + element_border;
11284 int y1 = editor.settings.element_graphic.y + element_border;
11285 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
11286 editor.settings.element_name.x);
11287 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
11288 editor.settings.element_name.y);
11289 char *text = "Element Settings";
11290 int font2_nr = FONT_TITLE_1;
11291 struct MenuPosInfo *pos = &editor.settings.headline;
11292 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
11293 int sy = SY + pos->y;
11295 stick_element_properties_window = FALSE;
11297 // make sure that previous properties edit mode exists for this element
11298 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
11299 !IS_CUSTOM_ELEMENT(properties_element))
11300 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
11302 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
11303 !IS_PLAYER_ELEMENT(properties_element) &&
11304 !IS_CUSTOM_ELEMENT(properties_element))
11305 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
11307 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
11308 (IS_PLAYER_ELEMENT(properties_element) ||
11309 IS_CUSTOM_ELEMENT(properties_element)))
11310 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
11312 CopyElementPropertiesToEditor(properties_element);
11314 UnmapLevelEditorFieldGadgets();
11315 UnmapLevelEditorToolboxDrawingGadgets();
11316 UnmapLevelEditorToolboxCustomGadgets();
11318 MapLevelEditorToolboxCustomGadgetsIfNeeded();
11320 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11323 DrawText(sx, sy, text, font2_nr);
11325 FrameCounter = 0; // restart animation frame counter
11327 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
11328 DrawEditorElementAnimation(SX + x1, SY + y1);
11329 DrawEditorElementName(x2, y2, font_nr);
11331 DrawPropertiesTabulatorGadgets();
11333 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
11334 DrawPropertiesInfo();
11335 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
11336 DrawPropertiesChange();
11337 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
11338 DrawPropertiesConfig();
11341 static void DrawPaletteWindow(void)
11345 UnmapLevelEditorFieldGadgets();
11347 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11350 // map buttons to select elements
11351 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
11352 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
11353 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
11354 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
11355 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
11358 static void UpdateCustomElementGraphicGadgets(void)
11362 InitElementPropertiesGfxElement();
11364 ModifyEditorElementList();
11365 RedrawDrawingElements();
11367 // force redraw of all mapped drawing area gadgets
11368 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
11370 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
11377 static int getOpenDirectionFromTube(int element)
11381 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
11382 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
11383 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
11384 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
11385 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
11386 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
11387 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
11388 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
11389 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
11390 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
11391 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
11397 static int getTubeFromOpenDirection(int direction)
11401 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
11402 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
11403 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
11404 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
11405 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
11406 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
11407 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
11408 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
11409 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
11410 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
11411 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
11413 // if only one direction, fall back to simple tube with that direction
11414 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
11415 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
11416 case (MV_UP): return EL_TUBE_VERTICAL;
11417 case (MV_DOWN): return EL_TUBE_VERTICAL;
11423 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
11425 int element_new = getTubeFromOpenDirection(direction);
11427 return (element_new != EL_EMPTY ? element_new : element_old);
11430 static int getOpenDirectionFromBelt(int element)
11432 int belt_dir = getBeltDirFromBeltElement(element);
11434 return (belt_dir == MV_LEFT ? MV_RIGHT :
11435 belt_dir == MV_RIGHT ? MV_LEFT :
11436 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
11439 static int getBeltFromNrAndOpenDirection(int nr, int direction)
11441 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
11442 direction == MV_RIGHT ? MV_LEFT :
11443 direction == MV_HORIZONTAL ? MV_NONE : direction);
11445 if (direction == MV_NONE)
11448 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
11451 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
11454 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
11456 return (element_new != EL_EMPTY ? element_new : element_old);
11459 static int getOpenDirectionFromPool(int element)
11463 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
11464 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
11465 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
11466 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
11467 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
11468 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
11474 static int getPoolFromOpenDirection(int direction)
11478 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
11479 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
11480 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
11481 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
11482 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
11483 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
11489 static int getPoolFromOpenDirectionExt(int direction, int help_element)
11491 int element = getPoolFromOpenDirection(direction);
11492 int help_direction = getOpenDirectionFromPool(help_element);
11494 if (element == EL_EMPTY)
11496 int help_direction_vertical = help_direction & MV_VERTICAL;
11498 element = getPoolFromOpenDirection(direction | help_direction_vertical);
11501 if (element == EL_EMPTY)
11503 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
11505 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
11511 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
11513 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
11515 return (element_new != EL_EMPTY ? element_new : element_old);
11518 static int getOpenDirectionFromPillar(int element)
11522 case EL_EMC_WALL_1: return (MV_DOWN);
11523 case EL_EMC_WALL_2: return (MV_VERTICAL);
11524 case EL_EMC_WALL_3: return (MV_UP);
11530 static int getPillarFromOpenDirection(int direction)
11534 case (MV_DOWN): return EL_EMC_WALL_1;
11535 case (MV_VERTICAL): return EL_EMC_WALL_2;
11536 case (MV_UP): return EL_EMC_WALL_3;
11542 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
11544 int element_new = getPillarFromOpenDirection(direction);
11546 return (element_new != EL_EMPTY ? element_new : element_old);
11549 static int getOpenDirectionFromSteel2(int element)
11553 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
11554 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
11555 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
11556 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
11557 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
11558 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
11559 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
11560 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
11566 static int getSteel2FromOpenDirection(int direction)
11570 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
11571 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
11572 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
11573 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
11574 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
11575 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
11576 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
11577 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
11583 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
11585 int element_new = getSteel2FromOpenDirection(direction);
11587 return (element_new != EL_EMPTY ? element_new : element_old);
11590 static int getOpenDirectionFromChip(int element)
11594 case EL_SP_CHIP_SINGLE: return (MV_NONE);
11595 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
11596 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
11597 case EL_SP_CHIP_TOP: return (MV_DOWN);
11598 case EL_SP_CHIP_BOTTOM: return (MV_UP);
11604 static int getChipFromOpenDirection(int direction)
11608 case (MV_NONE): return EL_SP_CHIP_SINGLE;
11609 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
11610 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
11611 case (MV_UP): return EL_SP_CHIP_BOTTOM;
11612 case (MV_DOWN): return EL_SP_CHIP_TOP;
11618 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
11620 int element_new = getChipFromOpenDirection(direction);
11622 return (element_new != EL_EMPTY ? element_new : element_old);
11625 static int getClosedTube(int x, int y)
11627 struct XY *xy = xy_directions;
11628 int element_old = IntelliDrawBuffer[x][y];
11629 int direction_old = getOpenDirectionFromTube(element_old);
11630 int direction_new = MV_NONE;
11633 for (i = 0; i < NUM_DIRECTIONS; i++)
11635 int xx = x + xy[i].x;
11636 int yy = y + xy[i].y;
11637 int dir = MV_DIR_FROM_BIT(i);
11638 int dir_opposite = MV_DIR_OPPOSITE(dir);
11640 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
11641 (direction_old & dir) &&
11642 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11643 direction_new |= dir;
11646 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
11649 static int getClosedBelt(int x, int y)
11651 struct XY *xy = xy_directions;
11652 int element_old = IntelliDrawBuffer[x][y];
11653 int nr = getBeltNrFromBeltElement(element_old);
11654 int direction_old = getOpenDirectionFromBelt(element_old);
11655 int direction_new = MV_NONE;
11658 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11660 int xx = x + xy[i].x;
11661 int yy = y + xy[i].y;
11662 int dir = MV_DIR_FROM_BIT(i);
11663 int dir_opposite = MV_DIR_OPPOSITE(dir);
11665 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
11666 (direction_old & dir) &&
11667 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11668 direction_new |= dir;
11671 return getBeltFromNrAndOpenDirection(nr, direction_new);
11674 static int getClosedPool(int x, int y)
11676 struct XY *xy = xy_directions;
11677 int element_old = IntelliDrawBuffer[x][y];
11678 int direction_old = getOpenDirectionFromPool(element_old);
11679 int direction_new = MV_NONE;
11682 for (i = 0; i < NUM_DIRECTIONS; i++)
11684 int xx = x + xy[i].x;
11685 int yy = y + xy[i].y;
11686 int dir = MV_DIR_FROM_BIT(i);
11687 int dir_opposite = MV_DIR_OPPOSITE(dir);
11689 if (IN_LEV_FIELD(xx, yy) &&
11690 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
11691 (direction_old & dir) &&
11692 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11693 direction_new |= dir;
11696 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
11699 static int getClosedPillar(int x, int y)
11701 struct XY *xy = xy_directions;
11702 int element_old = IntelliDrawBuffer[x][y];
11703 int direction_old = getOpenDirectionFromPillar(element_old);
11704 int direction_new = MV_NONE;
11707 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11709 int xx = x + xy[i].x;
11710 int yy = y + xy[i].y;
11711 int dir = MV_DIR_FROM_BIT(i);
11712 int dir_opposite = MV_DIR_OPPOSITE(dir);
11714 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11715 (direction_old & dir) &&
11716 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11717 direction_new |= dir;
11720 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11723 static int getClosedSteel2(int x, int y)
11725 struct XY *xy = xy_directions;
11726 int element_old = IntelliDrawBuffer[x][y];
11727 int direction_old = getOpenDirectionFromSteel2(element_old);
11728 int direction_new = MV_NONE;
11731 for (i = 0; i < NUM_DIRECTIONS; i++)
11733 int xx = x + xy[i].x;
11734 int yy = y + xy[i].y;
11735 int dir = MV_DIR_FROM_BIT(i);
11736 int dir_opposite = MV_DIR_OPPOSITE(dir);
11738 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11739 (direction_old & dir) &&
11740 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11741 direction_new |= dir;
11744 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11747 static int getClosedChip(int x, int y)
11749 struct XY *xy = xy_directions;
11750 int element_old = IntelliDrawBuffer[x][y];
11751 int direction_old = getOpenDirectionFromChip(element_old);
11752 int direction_new = MV_NONE;
11755 for (i = 0; i < NUM_DIRECTIONS; i++)
11757 int xx = x + xy[i].x;
11758 int yy = y + xy[i].y;
11759 int dir = MV_DIR_FROM_BIT(i);
11760 int dir_opposite = MV_DIR_OPPOSITE(dir);
11762 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11763 (direction_old & dir) &&
11764 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11765 direction_new |= dir;
11768 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11771 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11772 boolean change_level)
11774 int sx = x - level_xpos;
11775 int sy = y - level_ypos;
11776 int old_element = Tile[x][y];
11777 int new_element = element;
11778 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11779 boolean draw_masked = FALSE;
11781 if (IS_MM_WALL_EDITOR(element))
11783 element = map_mm_wall_element_editor(element) | new_bitmask;
11785 if (IS_MM_WALL(old_element))
11786 element |= MM_WALL_BITS(old_element);
11789 draw_masked = TRUE;
11791 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11793 int element_changed = old_element & ~new_bitmask;
11795 if (MM_WALL_BITS(element_changed) != 0)
11796 element = element_changed;
11799 IntelliDrawBuffer[x][y] = element;
11802 Tile[x][y] = element;
11804 if (IN_ED_FIELD(sx, sy))
11806 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11807 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11808 else if (draw_masked)
11809 DrawEditorElementThruMask(sx, sy, element);
11811 DrawEditorElement(sx, sy, element);
11815 static void SetElementSimple(int x, int y, int element, boolean change_level)
11817 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11820 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11821 int x2, int y2, int *element2,
11822 int (*close_function)(int, int),
11823 boolean change_level)
11825 // set neighbour elements to newly determined connections
11826 SetElementSimple(x1, y1, *element1, change_level);
11827 SetElementSimple(x2, y2, *element2, change_level);
11829 // remove all open connections of neighbour elements
11830 *element1 = close_function(x1, y1);
11831 *element2 = close_function(x2, y2);
11833 // set neighbour elements to new, minimized connections
11834 SetElementSimple(x1, y1, *element1, change_level);
11835 SetElementSimple(x2, y2, *element2, change_level);
11838 static void SetElementIntelliDraw(int x, int y, int dx, int dy, int new_element,
11839 boolean change_level, int button)
11841 struct XY *xy = xy_directions;
11842 static int last_x = -1;
11843 static int last_y = -1;
11845 if (new_element == EL_UNDEFINED)
11853 int old_element = IntelliDrawBuffer[x][y];
11855 if (IS_TUBE(new_element))
11857 int last_element_new = EL_UNDEFINED;
11858 int direction = MV_NONE;
11861 // if old element is of same kind, keep all existing directions
11862 if (IS_TUBE(old_element))
11863 direction |= getOpenDirectionFromTube(old_element);
11865 for (i = 0; i < NUM_DIRECTIONS; i++)
11867 int xx = x + xy[i].x;
11868 int yy = y + xy[i].y;
11870 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11871 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11873 int dir = MV_DIR_FROM_BIT(i);
11874 int dir_opposite = MV_DIR_OPPOSITE(dir);
11875 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11876 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11877 int last_direction_new = last_direction_old | dir_opposite;
11879 last_element_new = getTubeFromOpenDirection(last_direction_new);
11885 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
11887 if (last_element_new != EL_UNDEFINED)
11888 MergeAndCloseNeighbourElements(x, y, &new_element,
11889 last_x, last_y, &last_element_new,
11890 getClosedTube, change_level);
11892 else if (IS_BELT(new_element))
11894 int belt_nr = getBeltNrFromBeltElement(new_element);
11895 int last_element_new = EL_UNDEFINED;
11896 int direction = MV_NONE;
11899 // if old element is of same kind, keep all existing directions
11900 if (IS_BELT(old_element))
11901 direction |= getOpenDirectionFromBelt(old_element);
11903 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11905 int xx = x + xy[i].x;
11906 int yy = y + xy[i].y;
11908 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11909 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
11911 int dir = MV_DIR_FROM_BIT(i);
11912 int dir_opposite = MV_DIR_OPPOSITE(dir);
11913 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11914 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
11915 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
11916 int last_direction_new = last_direction_old | dir_opposite;
11918 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11919 last_direction_new);
11924 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
11926 if (last_element_new != EL_UNDEFINED)
11927 MergeAndCloseNeighbourElements(x, y, &new_element,
11928 last_x, last_y, &last_element_new,
11929 getClosedBelt, change_level);
11931 else if (IS_ACID_POOL_OR_ACID(new_element))
11933 int last_element_new = EL_UNDEFINED;
11934 int direction = MV_NONE;
11937 // if old element is of same kind, keep all existing directions
11938 if (IS_ACID_POOL_OR_ACID(old_element))
11939 direction |= getOpenDirectionFromPool(old_element);
11941 for (i = 0; i < NUM_DIRECTIONS; i++)
11943 int xx = x + xy[i].x;
11944 int yy = y + xy[i].y;
11946 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11947 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
11949 int dir = MV_DIR_FROM_BIT(i);
11950 int dir_opposite = MV_DIR_OPPOSITE(dir);
11951 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11952 int last_direction_old = getOpenDirectionFromPool(last_element_old);
11953 int last_direction_new = last_direction_old | dir_opposite;
11955 last_element_new = getPoolFromOpenDirection(last_direction_new);
11961 // special corrections needed for intuitively correct acid pool drawing
11962 if (last_element_new == EL_EMPTY)
11963 last_element_new = new_element;
11964 else if (last_element_new != EL_UNDEFINED)
11965 new_element = last_element_new;
11967 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
11969 if (last_element_new != EL_UNDEFINED)
11970 MergeAndCloseNeighbourElements(x, y, &new_element,
11971 last_x, last_y, &last_element_new,
11972 getClosedPool, change_level);
11974 else if (IS_EMC_PILLAR(new_element))
11976 int last_element_new = EL_UNDEFINED;
11977 int direction = MV_NONE;
11980 // if old element is of same kind, keep all existing directions
11981 if (IS_EMC_PILLAR(old_element))
11982 direction |= getOpenDirectionFromPillar(old_element);
11984 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11986 int xx = x + xy[i].x;
11987 int yy = y + xy[i].y;
11989 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11990 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
11992 int dir = MV_DIR_FROM_BIT(i);
11993 int dir_opposite = MV_DIR_OPPOSITE(dir);
11994 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11995 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
11996 int last_direction_new = last_direction_old | dir_opposite;
11998 last_element_new = getPillarFromOpenDirection(last_direction_new);
12004 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
12006 if (last_element_new != EL_UNDEFINED)
12007 MergeAndCloseNeighbourElements(x, y, &new_element,
12008 last_x, last_y, &last_element_new,
12009 getClosedPillar, change_level);
12011 else if (IS_DC_STEELWALL_2(new_element))
12013 int last_element_new = EL_UNDEFINED;
12014 int direction = MV_NONE;
12017 // if old element is of same kind, keep all existing directions
12018 if (IS_DC_STEELWALL_2(old_element))
12019 direction |= getOpenDirectionFromSteel2(old_element);
12021 for (i = 0; i < NUM_DIRECTIONS; i++)
12023 int xx = x + xy[i].x;
12024 int yy = y + xy[i].y;
12026 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12027 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
12029 int dir = MV_DIR_FROM_BIT(i);
12030 int dir_opposite = MV_DIR_OPPOSITE(dir);
12031 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12032 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
12033 int last_direction_new = last_direction_old | dir_opposite;
12035 last_element_new = getSteel2FromOpenDirection(last_direction_new);
12041 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
12043 if (last_element_new != EL_UNDEFINED)
12044 MergeAndCloseNeighbourElements(x, y, &new_element,
12045 last_x, last_y, &last_element_new,
12046 getClosedSteel2, change_level);
12048 else if (IS_SP_CHIP(new_element))
12050 int last_element_new = EL_UNDEFINED;
12051 int direction = MV_NONE;
12054 // (do not keep existing directions, regardless of kind of old element)
12056 for (i = 0; i < NUM_DIRECTIONS; i++)
12058 int xx = x + xy[i].x;
12059 int yy = y + xy[i].y;
12061 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12062 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
12064 int dir = MV_DIR_FROM_BIT(i);
12065 int dir_opposite = MV_DIR_OPPOSITE(dir);
12066 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12067 int last_direction_old = getOpenDirectionFromChip(last_element_old);
12068 int last_direction_new = last_direction_old | dir_opposite;
12070 if (last_direction_old == MV_NONE)
12072 last_element_new = getChipFromOpenDirection(last_direction_new);
12075 else if (last_direction_old & (dir | dir_opposite))
12077 direction |= MV_DIR_OPPOSITE(last_direction_old);
12081 direction |= MV_DIR_OPPOSITE(dir);
12086 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
12088 if (last_element_new != EL_UNDEFINED)
12089 MergeAndCloseNeighbourElements(x, y, &new_element,
12090 last_x, last_y, &last_element_new,
12091 getClosedChip, change_level);
12093 else if (IS_SP_HARDWARE_BASE(new_element))
12095 int nr = GetSimpleRandom(6);
12097 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
12098 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
12099 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
12100 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
12101 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
12103 else if (new_element == EL_SP_HARDWARE_GREEN ||
12104 new_element == EL_SP_HARDWARE_BLUE ||
12105 new_element == EL_SP_HARDWARE_RED)
12107 int nr = GetSimpleRandom(3);
12109 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
12110 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
12112 else if (IS_GROUP_ELEMENT(new_element))
12114 boolean connected_drawing = FALSE;
12117 for (i = 0; i < NUM_DIRECTIONS; i++)
12119 int xx = x + xy[i].x;
12120 int yy = y + xy[i].y;
12122 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12123 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
12124 connected_drawing = TRUE;
12127 if (!connected_drawing)
12128 ResolveGroupElement(new_element);
12130 new_element = GetElementFromGroupElement(new_element);
12132 else if (IS_BELT_SWITCH(old_element))
12134 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
12135 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
12137 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
12138 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
12140 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
12144 static int swappable_elements[][2] =
12146 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
12147 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
12148 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
12149 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
12150 { EL_EMERALD, EL_WALL_EMERALD },
12151 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
12152 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
12153 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
12154 { EL_DIAMOND, EL_WALL_DIAMOND },
12155 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
12156 { EL_GATE_1, EL_GATE_1_GRAY },
12157 { EL_GATE_2, EL_GATE_2_GRAY },
12158 { EL_GATE_3, EL_GATE_3_GRAY },
12159 { EL_GATE_4, EL_GATE_4_GRAY },
12160 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
12161 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
12162 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
12163 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
12164 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
12165 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
12166 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
12167 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
12168 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
12169 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
12170 { EL_LAMP, EL_LAMP_ACTIVE },
12171 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
12172 { EL_SP_BASE, EL_SP_BUGGY_BASE },
12173 { EL_PEARL, EL_WALL_PEARL },
12174 { EL_CRYSTAL, EL_WALL_CRYSTAL },
12175 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
12176 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
12177 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
12178 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
12179 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
12180 { EL_LANDMINE, EL_DC_LANDMINE },
12181 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
12182 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
12183 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
12184 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
12185 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
12186 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
12187 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
12188 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
12189 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
12193 static int rotatable_elements_4[][4] =
12203 EL_SPACESHIP_RIGHT,
12208 EL_BD_BUTTERFLY_UP,
12209 EL_BD_BUTTERFLY_RIGHT,
12210 EL_BD_BUTTERFLY_DOWN,
12211 EL_BD_BUTTERFLY_LEFT
12215 EL_BD_FIREFLY_RIGHT,
12216 EL_BD_FIREFLY_DOWN,
12244 EL_SP_GRAVITY_PORT_UP,
12245 EL_SP_GRAVITY_PORT_RIGHT,
12246 EL_SP_GRAVITY_PORT_DOWN,
12247 EL_SP_GRAVITY_PORT_LEFT
12250 EL_SP_GRAVITY_ON_PORT_UP,
12251 EL_SP_GRAVITY_ON_PORT_RIGHT,
12252 EL_SP_GRAVITY_ON_PORT_DOWN,
12253 EL_SP_GRAVITY_ON_PORT_LEFT
12256 EL_SP_GRAVITY_OFF_PORT_UP,
12257 EL_SP_GRAVITY_OFF_PORT_RIGHT,
12258 EL_SP_GRAVITY_OFF_PORT_DOWN,
12259 EL_SP_GRAVITY_OFF_PORT_LEFT
12268 EL_BALLOON_SWITCH_UP,
12269 EL_BALLOON_SWITCH_RIGHT,
12270 EL_BALLOON_SWITCH_DOWN,
12271 EL_BALLOON_SWITCH_LEFT
12275 EL_MM_MCDUFFIN_RIGHT,
12276 EL_MM_MCDUFFIN_DOWN,
12277 EL_MM_MCDUFFIN_LEFT
12280 EL_MM_MIRROR_FIXED_1,
12281 EL_MM_MIRROR_FIXED_4,
12282 EL_MM_MIRROR_FIXED_3,
12283 EL_MM_MIRROR_FIXED_2
12286 EL_MM_STEEL_GRID_FIXED_1,
12287 EL_MM_STEEL_GRID_FIXED_4,
12288 EL_MM_STEEL_GRID_FIXED_2,
12289 EL_MM_STEEL_GRID_FIXED_3
12292 EL_MM_WOODEN_GRID_FIXED_1,
12293 EL_MM_WOODEN_GRID_FIXED_4,
12294 EL_MM_WOODEN_GRID_FIXED_2,
12295 EL_MM_WOODEN_GRID_FIXED_3
12298 EL_MM_POLARIZER_CROSS_1,
12299 EL_MM_POLARIZER_CROSS_4,
12300 EL_MM_POLARIZER_CROSS_3,
12301 EL_MM_POLARIZER_CROSS_2
12305 EL_MM_PACMAN_RIGHT,
12317 EL_DF_RECEIVER_RIGHT,
12318 EL_DF_RECEIVER_DOWN,
12319 EL_DF_RECEIVER_LEFT
12332 static int rotatable_elements_8[][8] =
12335 EL_DF_STEEL_GRID_FIXED_1,
12336 EL_DF_STEEL_GRID_FIXED_8,
12337 EL_DF_STEEL_GRID_FIXED_7,
12338 EL_DF_STEEL_GRID_FIXED_6,
12339 EL_DF_STEEL_GRID_FIXED_5,
12340 EL_DF_STEEL_GRID_FIXED_4,
12341 EL_DF_STEEL_GRID_FIXED_3,
12342 EL_DF_STEEL_GRID_FIXED_2
12345 EL_DF_WOODEN_GRID_FIXED_1,
12346 EL_DF_WOODEN_GRID_FIXED_8,
12347 EL_DF_WOODEN_GRID_FIXED_7,
12348 EL_DF_WOODEN_GRID_FIXED_6,
12349 EL_DF_WOODEN_GRID_FIXED_5,
12350 EL_DF_WOODEN_GRID_FIXED_4,
12351 EL_DF_WOODEN_GRID_FIXED_3,
12352 EL_DF_WOODEN_GRID_FIXED_2
12355 EL_DF_STEEL_GRID_ROTATING_1,
12356 EL_DF_STEEL_GRID_ROTATING_8,
12357 EL_DF_STEEL_GRID_ROTATING_7,
12358 EL_DF_STEEL_GRID_ROTATING_6,
12359 EL_DF_STEEL_GRID_ROTATING_5,
12360 EL_DF_STEEL_GRID_ROTATING_4,
12361 EL_DF_STEEL_GRID_ROTATING_3,
12362 EL_DF_STEEL_GRID_ROTATING_2
12365 EL_DF_WOODEN_GRID_ROTATING_1,
12366 EL_DF_WOODEN_GRID_ROTATING_8,
12367 EL_DF_WOODEN_GRID_ROTATING_7,
12368 EL_DF_WOODEN_GRID_ROTATING_6,
12369 EL_DF_WOODEN_GRID_ROTATING_5,
12370 EL_DF_WOODEN_GRID_ROTATING_4,
12371 EL_DF_WOODEN_GRID_ROTATING_3,
12372 EL_DF_WOODEN_GRID_ROTATING_2
12379 static int rotatable_elements_16[][16] =
12400 EL_MM_TELEPORTER_5,
12401 EL_MM_TELEPORTER_4,
12402 EL_MM_TELEPORTER_3,
12403 EL_MM_TELEPORTER_2,
12404 EL_MM_TELEPORTER_1,
12405 EL_MM_TELEPORTER_16,
12406 EL_MM_TELEPORTER_15,
12407 EL_MM_TELEPORTER_14,
12408 EL_MM_TELEPORTER_13,
12409 EL_MM_TELEPORTER_12,
12410 EL_MM_TELEPORTER_11,
12411 EL_MM_TELEPORTER_10,
12412 EL_MM_TELEPORTER_9,
12413 EL_MM_TELEPORTER_8,
12414 EL_MM_TELEPORTER_7,
12418 EL_MM_TELEPORTER_RED_5,
12419 EL_MM_TELEPORTER_RED_4,
12420 EL_MM_TELEPORTER_RED_3,
12421 EL_MM_TELEPORTER_RED_2,
12422 EL_MM_TELEPORTER_RED_1,
12423 EL_MM_TELEPORTER_RED_16,
12424 EL_MM_TELEPORTER_RED_15,
12425 EL_MM_TELEPORTER_RED_14,
12426 EL_MM_TELEPORTER_RED_13,
12427 EL_MM_TELEPORTER_RED_12,
12428 EL_MM_TELEPORTER_RED_11,
12429 EL_MM_TELEPORTER_RED_10,
12430 EL_MM_TELEPORTER_RED_9,
12431 EL_MM_TELEPORTER_RED_8,
12432 EL_MM_TELEPORTER_RED_7,
12433 EL_MM_TELEPORTER_RED_6
12436 EL_MM_TELEPORTER_YELLOW_5,
12437 EL_MM_TELEPORTER_YELLOW_4,
12438 EL_MM_TELEPORTER_YELLOW_3,
12439 EL_MM_TELEPORTER_YELLOW_2,
12440 EL_MM_TELEPORTER_YELLOW_1,
12441 EL_MM_TELEPORTER_YELLOW_16,
12442 EL_MM_TELEPORTER_YELLOW_15,
12443 EL_MM_TELEPORTER_YELLOW_14,
12444 EL_MM_TELEPORTER_YELLOW_13,
12445 EL_MM_TELEPORTER_YELLOW_12,
12446 EL_MM_TELEPORTER_YELLOW_11,
12447 EL_MM_TELEPORTER_YELLOW_10,
12448 EL_MM_TELEPORTER_YELLOW_9,
12449 EL_MM_TELEPORTER_YELLOW_8,
12450 EL_MM_TELEPORTER_YELLOW_7,
12451 EL_MM_TELEPORTER_YELLOW_6
12454 EL_MM_TELEPORTER_GREEN_5,
12455 EL_MM_TELEPORTER_GREEN_4,
12456 EL_MM_TELEPORTER_GREEN_3,
12457 EL_MM_TELEPORTER_GREEN_2,
12458 EL_MM_TELEPORTER_GREEN_1,
12459 EL_MM_TELEPORTER_GREEN_16,
12460 EL_MM_TELEPORTER_GREEN_15,
12461 EL_MM_TELEPORTER_GREEN_14,
12462 EL_MM_TELEPORTER_GREEN_13,
12463 EL_MM_TELEPORTER_GREEN_12,
12464 EL_MM_TELEPORTER_GREEN_11,
12465 EL_MM_TELEPORTER_GREEN_10,
12466 EL_MM_TELEPORTER_GREEN_9,
12467 EL_MM_TELEPORTER_GREEN_8,
12468 EL_MM_TELEPORTER_GREEN_7,
12469 EL_MM_TELEPORTER_GREEN_6
12472 EL_MM_TELEPORTER_BLUE_5,
12473 EL_MM_TELEPORTER_BLUE_4,
12474 EL_MM_TELEPORTER_BLUE_3,
12475 EL_MM_TELEPORTER_BLUE_2,
12476 EL_MM_TELEPORTER_BLUE_1,
12477 EL_MM_TELEPORTER_BLUE_16,
12478 EL_MM_TELEPORTER_BLUE_15,
12479 EL_MM_TELEPORTER_BLUE_14,
12480 EL_MM_TELEPORTER_BLUE_13,
12481 EL_MM_TELEPORTER_BLUE_12,
12482 EL_MM_TELEPORTER_BLUE_11,
12483 EL_MM_TELEPORTER_BLUE_10,
12484 EL_MM_TELEPORTER_BLUE_9,
12485 EL_MM_TELEPORTER_BLUE_8,
12486 EL_MM_TELEPORTER_BLUE_7,
12487 EL_MM_TELEPORTER_BLUE_6
12491 EL_MM_POLARIZER_16,
12492 EL_MM_POLARIZER_15,
12493 EL_MM_POLARIZER_14,
12494 EL_MM_POLARIZER_13,
12495 EL_MM_POLARIZER_12,
12496 EL_MM_POLARIZER_11,
12497 EL_MM_POLARIZER_10,
12526 EL_DF_MIRROR_ROTATING_1,
12527 EL_DF_MIRROR_ROTATING_16,
12528 EL_DF_MIRROR_ROTATING_15,
12529 EL_DF_MIRROR_ROTATING_14,
12530 EL_DF_MIRROR_ROTATING_13,
12531 EL_DF_MIRROR_ROTATING_12,
12532 EL_DF_MIRROR_ROTATING_11,
12533 EL_DF_MIRROR_ROTATING_10,
12534 EL_DF_MIRROR_ROTATING_9,
12535 EL_DF_MIRROR_ROTATING_8,
12536 EL_DF_MIRROR_ROTATING_7,
12537 EL_DF_MIRROR_ROTATING_6,
12538 EL_DF_MIRROR_ROTATING_5,
12539 EL_DF_MIRROR_ROTATING_4,
12540 EL_DF_MIRROR_ROTATING_3,
12541 EL_DF_MIRROR_ROTATING_2
12544 EL_DF_MIRROR_FIXED_1,
12545 EL_DF_MIRROR_FIXED_16,
12546 EL_DF_MIRROR_FIXED_15,
12547 EL_DF_MIRROR_FIXED_14,
12548 EL_DF_MIRROR_FIXED_13,
12549 EL_DF_MIRROR_FIXED_12,
12550 EL_DF_MIRROR_FIXED_11,
12551 EL_DF_MIRROR_FIXED_10,
12552 EL_DF_MIRROR_FIXED_9,
12553 EL_DF_MIRROR_FIXED_8,
12554 EL_DF_MIRROR_FIXED_7,
12555 EL_DF_MIRROR_FIXED_6,
12556 EL_DF_MIRROR_FIXED_5,
12557 EL_DF_MIRROR_FIXED_4,
12558 EL_DF_MIRROR_FIXED_3,
12559 EL_DF_MIRROR_FIXED_2
12568 for (i = 0; swappable_elements[i][0] != -1; i++)
12570 int element1 = swappable_elements[i][0];
12571 int element2 = swappable_elements[i][1];
12573 if (old_element == element1 || old_element == element2)
12574 new_element = (old_element == element1 ? element2 : element1);
12577 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
12579 for (j = 0; j < 4; j++)
12581 int element = rotatable_elements_4[i][j];
12583 if (old_element == element)
12584 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
12585 button == 2 ? rotatable_elements_4[i][0] :
12586 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
12591 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
12593 for (j = 0; j < 8; j++)
12595 int element = rotatable_elements_8[i][j];
12597 if (old_element == element)
12598 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
12599 button == 2 ? rotatable_elements_8[i][0] :
12600 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
12605 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
12607 for (j = 0; j < 16; j++)
12609 int element = rotatable_elements_16[i][j];
12611 if (old_element == element)
12612 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
12613 button == 2 ? rotatable_elements_16[i][0] :
12614 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
12619 if (old_element != new_element)
12621 int max_infotext_len = getMaxInfoTextLength();
12622 char infotext[MAX_OUTPUT_LINESIZE + 1];
12624 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
12625 infotext[max_infotext_len] = '\0';
12627 ClearEditorGadgetInfoText();
12629 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
12634 if (IS_MM_WALL_EDITOR(new_element))
12635 SetElementSimpleExt(x, y, dx, dy, new_element, change_level);
12637 SetElementSimple(x, y, new_element, change_level);
12643 static void ResetIntelliDraw(void)
12647 for (x = 0; x < lev_fieldx; x++)
12648 for (y = 0; y < lev_fieldy; y++)
12649 IntelliDrawBuffer[x][y] = Tile[x][y];
12651 SetElementIntelliDraw(-1, -1, -1, -1, EL_UNDEFINED, FALSE, -1);
12654 static boolean draw_mode_hires = FALSE;
12656 static boolean isHiresTileElement(int element)
12658 return (IS_MM_WALL(element) || element == EL_EMPTY);
12661 static boolean isHiresDrawElement(int element)
12663 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
12666 static int numHiresTiles(int element)
12668 if (IS_MM_WALL(element))
12669 return get_number_of_bits(MM_WALL_BITS(element));
12674 static void SetDrawModeHiRes(int element)
12677 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12678 isHiresDrawElement(element));
12681 static boolean getDrawModeHiRes(void)
12683 return draw_mode_hires;
12686 static int getLoResScreenPos(int pos)
12688 return (getDrawModeHiRes() ? pos / 2 : pos);
12691 static int getLoResScreenMod(int pos)
12693 return (getDrawModeHiRes() ? pos % 2 : 0);
12696 static void SetElementExt(int x, int y, int dx, int dy, int element,
12697 boolean change_level, int button)
12700 SetElementSimple(x, y, Tile[x][y], change_level);
12701 else if (GetKeyModState() & KMOD_Shift)
12702 SetElementIntelliDraw(x, y, dx, dy, element, change_level, button);
12704 SetElementSimpleExt(x, y, dx, dy, element, change_level);
12707 static void SetElement(int x, int y, int element)
12709 SetElementExt(x, y, 0, 0, element, TRUE, -1);
12712 static void SetElementButton(int x, int y, int dx, int dy, int element,
12715 SetElementExt(x, y, dx, dy, element, TRUE, button);
12718 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
12720 int lx = getLoResScreenPos(sx2) + level_xpos;
12721 int ly = getLoResScreenPos(sy2) + level_ypos;
12722 int dx = getLoResScreenMod(sx2);
12723 int dy = getLoResScreenMod(sy2);
12725 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
12728 static void SetLevelElementHiRes(int lx2, int ly2, int element)
12735 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
12738 static int getLevelElementHiRes(int lx2, int ly2)
12744 int element = Tile[lx][ly];
12745 unsigned int bitmask = (dx + 1) << (dy * 2);
12747 if (IS_MM_WALL(element))
12749 if (element & bitmask)
12750 return map_mm_wall_element(element);
12758 static void DrawLineElement(int x, int y, int element, boolean change_level)
12760 SetElementHiRes(x, y, element, change_level);
12763 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12764 int element, boolean change_level)
12766 int xsize = ABS(to_x - from_x);
12767 int ysize = ABS(to_y - from_y);
12768 int dx = (to_x < from_x ? -1 : +1);
12769 int dy = (to_y < from_y ? -1 : +1);
12772 if (from_y == to_y) // horizontal line
12774 for (i = 0; i <= xsize; i++)
12775 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12777 else if (from_x == to_x) // vertical line
12779 for (i = 0; i <= ysize; i++)
12780 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12782 else // diagonal line
12784 if (ysize < xsize) // a < 1
12786 float a = (float)ysize / (float)xsize;
12788 for (i = 0; i <= xsize; i++)
12791 int y = dy * (int)(a * i + 0.5);
12793 DrawLineElement(from_x + x, from_y + y, element, change_level);
12798 float a = (float)xsize / (float)ysize;
12800 for (i = 0; i <= ysize; i++)
12802 int x = dx * (int)(a * i + 0.5);
12805 DrawLineElement(from_x + x, from_y + y, element, change_level);
12811 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12812 int element, boolean change_level)
12814 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12815 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12816 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12817 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12820 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12821 int element, boolean change_level)
12826 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12828 for (y = from_y; y <= to_y; y++)
12829 DrawLine(from_x, y, to_x, y, element, change_level);
12832 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12833 int element, boolean change_level)
12835 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12836 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12837 int len_x = ABS(to_x - from_x);
12838 int len_y = ABS(to_y - from_y);
12841 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
12843 // not optimal (some points get drawn twice) but simple,
12844 // and fast enough for the few points we are drawing
12846 for (x = 0; x <= radius; x++)
12848 int sx, sy, sx2, sy2, lx, ly;
12850 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
12852 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12853 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12854 sx = getLoResScreenPos(sx2);
12855 sy = getLoResScreenPos(sy2);
12856 lx = sx + level_xpos;
12857 ly = sy + level_ypos;
12859 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12860 DrawLineElement(sx2, sy2, element, change_level);
12863 for (y = 0; y <= radius; y++)
12865 int sx, sy, sx2, sy2, lx, ly;
12867 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
12869 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12870 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12871 sx = getLoResScreenPos(sx2);
12872 sy = getLoResScreenPos(sy2);
12873 lx = sx + level_xpos;
12874 ly = sy + level_ypos;
12876 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12877 DrawLineElement(sx2, sy2, element, change_level);
12881 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
12882 int element, boolean change_level)
12884 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12885 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12887 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12890 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
12892 #if DRAW_CIRCLES_BUTTON_AVAILABLE
12893 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
12894 int element, boolean change_level)
12896 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12897 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12898 int mirror_to_x2 = from_x - (to_x2 - from_x);
12899 int mirror_to_y2 = from_y - (to_y2 - from_y);
12901 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12902 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
12903 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
12904 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element, change_level);
12908 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
12910 int from_sx, from_sy;
12914 swap_numbers(&from_x, &to_x);
12917 swap_numbers(&from_y, &to_y);
12919 from_sx = SX + from_x * ed_tilesize;
12920 from_sy = SY + from_y * ed_tilesize;
12921 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
12922 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
12924 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12925 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12926 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12927 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12929 if (from_x == to_x && from_y == to_y)
12930 MarkTileDirty(from_x/2, from_y/2);
12932 redraw_mask |= REDRAW_FIELD;
12935 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
12936 int element, boolean change_level)
12938 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
12941 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
12942 int element, boolean change_level)
12944 if (element == -1 || change_level)
12945 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
12947 DrawAreaBorder(from_x, from_y, to_x, to_y);
12950 // values for CopyBrushExt()
12951 #define CB_AREA_TO_BRUSH 0
12952 #define CB_BRUSH_TO_CURSOR 1
12953 #define CB_BRUSH_TO_LEVEL 2
12954 #define CB_DELETE_OLD_CURSOR 3
12955 #define CB_DUMP_BRUSH 4
12956 #define CB_DUMP_BRUSH_SMALL 5
12957 #define CB_CLIPBOARD_TO_BRUSH 6
12958 #define CB_BRUSH_TO_CLIPBOARD 7
12959 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
12960 #define CB_UPDATE_BRUSH_POSITION 9
12961 #define CB_FLIP_BRUSH_X 10
12962 #define CB_FLIP_BRUSH_Y 11
12963 #define CB_FLIP_BRUSH_XY 12
12965 #define MAX_CB_PART_SIZE 10
12966 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
12967 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
12968 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
12969 MAX_CB_NUM_LINES * \
12972 static int getFlippedTileExt(int map[], int element)
12976 for (i = 0; map[i] != -1; i++)
12977 if (map[i] == element)
12978 return map[i ^ 1]; // get flipped element by flipping LSB of index
12983 static int getFlippedTileX(int element)
12987 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_RIGHT,
12988 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_RIGHT,
12989 EL_BUG_LEFT, EL_BUG_RIGHT,
12990 EL_SPACESHIP_LEFT, EL_SPACESHIP_RIGHT,
12991 EL_PACMAN_LEFT, EL_PACMAN_RIGHT,
12992 EL_ARROW_LEFT, EL_ARROW_RIGHT,
12993 EL_MOLE_LEFT, EL_MOLE_RIGHT,
12994 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_RIGHT,
12995 EL_YAMYAM_LEFT, EL_YAMYAM_RIGHT,
12996 EL_SP_PORT_LEFT, EL_SP_PORT_RIGHT,
12997 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_RIGHT,
12998 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_RIGHT,
12999 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_RIGHT,
13000 EL_CONVEYOR_BELT_1_LEFT, EL_CONVEYOR_BELT_1_RIGHT,
13001 EL_CONVEYOR_BELT_2_LEFT, EL_CONVEYOR_BELT_2_RIGHT,
13002 EL_CONVEYOR_BELT_3_LEFT, EL_CONVEYOR_BELT_3_RIGHT,
13003 EL_CONVEYOR_BELT_4_LEFT, EL_CONVEYOR_BELT_4_RIGHT,
13004 EL_SPRING_LEFT, EL_SPRING_RIGHT,
13005 EL_SP_CHIP_LEFT, EL_SP_CHIP_RIGHT,
13006 EL_TUBE_VERTICAL_LEFT, EL_TUBE_VERTICAL_RIGHT,
13007 EL_TUBE_LEFT_UP, EL_TUBE_RIGHT_UP,
13008 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_DOWN,
13009 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_RIGHT,
13010 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_TOPRIGHT,
13011 EL_DC_STEELWALL_1_BOTTOMLEFT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13012 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_TOPRIGHT_2,
13013 EL_DC_STEELWALL_1_BOTTOMLEFT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13014 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_RIGHT,
13015 EL_ACID_POOL_TOPLEFT, EL_ACID_POOL_TOPRIGHT,
13016 EL_ACID_POOL_BOTTOMLEFT, EL_ACID_POOL_BOTTOMRIGHT,
13021 return getFlippedTileExt(map, element);
13024 static int getFlippedTileY(int element)
13028 EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY_DOWN,
13029 EL_BD_FIREFLY_UP, EL_BD_FIREFLY_DOWN,
13030 EL_BUG_UP, EL_BUG_DOWN,
13031 EL_SPACESHIP_UP, EL_SPACESHIP_DOWN,
13032 EL_PACMAN_UP, EL_PACMAN_DOWN,
13033 EL_ARROW_UP, EL_ARROW_DOWN,
13034 EL_MOLE_UP, EL_MOLE_DOWN,
13035 EL_BALLOON_SWITCH_UP, EL_BALLOON_SWITCH_DOWN,
13036 EL_YAMYAM_UP, EL_YAMYAM_DOWN,
13037 EL_SP_PORT_UP, EL_SP_PORT_DOWN,
13038 EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN,
13039 EL_SP_GRAVITY_ON_PORT_UP, EL_SP_GRAVITY_ON_PORT_DOWN,
13040 EL_SP_GRAVITY_OFF_PORT_UP, EL_SP_GRAVITY_OFF_PORT_DOWN,
13041 EL_SP_CHIP_TOP, EL_SP_CHIP_BOTTOM,
13042 EL_TUBE_HORIZONTAL_UP, EL_TUBE_HORIZONTAL_DOWN,
13043 EL_TUBE_LEFT_UP, EL_TUBE_LEFT_DOWN,
13044 EL_TUBE_RIGHT_UP, EL_TUBE_RIGHT_DOWN,
13045 EL_DC_STEELWALL_1_TOP, EL_DC_STEELWALL_1_BOTTOM,
13046 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13047 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13048 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13049 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13050 EL_DC_STEELWALL_2_TOP, EL_DC_STEELWALL_2_BOTTOM,
13051 EL_EMC_WALL_1, EL_EMC_WALL_3,
13056 return getFlippedTileExt(map, element);
13059 static int getFlippedTileXY(int element)
13063 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_UP,
13064 EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY_DOWN,
13065 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_UP,
13066 EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY_DOWN,
13067 EL_BUG_LEFT, EL_BUG_UP,
13068 EL_BUG_RIGHT, EL_BUG_DOWN,
13069 EL_SPACESHIP_LEFT, EL_SPACESHIP_UP,
13070 EL_SPACESHIP_RIGHT, EL_SPACESHIP_DOWN,
13071 EL_PACMAN_LEFT, EL_PACMAN_UP,
13072 EL_PACMAN_RIGHT, EL_PACMAN_DOWN,
13073 EL_ARROW_LEFT, EL_ARROW_UP,
13074 EL_ARROW_RIGHT, EL_ARROW_DOWN,
13075 EL_MOLE_LEFT, EL_MOLE_UP,
13076 EL_MOLE_RIGHT, EL_MOLE_DOWN,
13077 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_UP,
13078 EL_BALLOON_SWITCH_RIGHT, EL_BALLOON_SWITCH_DOWN,
13079 EL_YAMYAM_LEFT, EL_YAMYAM_UP,
13080 EL_YAMYAM_RIGHT, EL_YAMYAM_DOWN,
13081 EL_SP_PORT_LEFT, EL_SP_PORT_UP,
13082 EL_SP_PORT_RIGHT, EL_SP_PORT_DOWN,
13083 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_UP,
13084 EL_SP_GRAVITY_PORT_RIGHT, EL_SP_GRAVITY_PORT_DOWN,
13085 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_UP,
13086 EL_SP_GRAVITY_ON_PORT_RIGHT, EL_SP_GRAVITY_ON_PORT_DOWN,
13087 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_UP,
13088 EL_SP_GRAVITY_OFF_PORT_RIGHT, EL_SP_GRAVITY_OFF_PORT_DOWN,
13089 EL_SP_CHIP_LEFT, EL_SP_CHIP_TOP,
13090 EL_SP_CHIP_RIGHT, EL_SP_CHIP_BOTTOM,
13091 EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL,
13092 EL_TUBE_VERTICAL_LEFT, EL_TUBE_HORIZONTAL_UP,
13093 EL_TUBE_VERTICAL_RIGHT, EL_TUBE_HORIZONTAL_DOWN,
13094 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_UP,
13095 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_TOP,
13096 EL_DC_STEELWALL_1_RIGHT, EL_DC_STEELWALL_1_BOTTOM,
13097 EL_DC_STEELWALL_1_HORIZONTAL, EL_DC_STEELWALL_1_VERTICAL,
13098 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13099 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13100 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_TOP,
13101 EL_DC_STEELWALL_2_RIGHT, EL_DC_STEELWALL_2_BOTTOM,
13102 EL_DC_STEELWALL_2_HORIZONTAL, EL_DC_STEELWALL_2_VERTICAL,
13103 EL_EXPANDABLE_WALL_HORIZONTAL, EL_EXPANDABLE_WALL_VERTICAL,
13104 EL_EXPANDABLE_STEELWALL_HORIZONTAL, EL_EXPANDABLE_STEELWALL_VERTICAL,
13109 return getFlippedTileExt(map, element);
13112 static int getFlippedTile(int element, int mode)
13114 if (IS_MM_ELEMENT(element))
13116 // get MM game element
13117 element = map_element_RND_to_MM(element);
13119 // get flipped game element
13120 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX_MM(element) :
13121 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY_MM(element) :
13122 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY_MM(element) :
13125 // get RND game element again
13126 element = map_element_MM_to_RND(element);
13130 // get flipped game element
13131 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX(element) :
13132 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY(element) :
13133 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY(element) :
13140 static void SwapFlippedTiles(short *tile1, short *tile2, int mode)
13143 short tile1_flipped = getFlippedTile(*tile1, mode);
13144 short tile2_flipped = getFlippedTile(*tile2, mode);
13147 *tile1 = tile2_flipped;
13148 *tile2 = tile1_flipped;
13151 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
13153 DrawLineElement(sx, sy, element, change_level);
13156 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
13157 int button, int mode)
13159 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13160 static int brush_width, brush_height;
13161 static int last_cursor_x = -1, last_cursor_y = -1;
13162 static boolean delete_old_brush = FALSE;
13163 int new_element = BUTTON_ELEMENT(button);
13166 if (mode == CB_DUMP_BRUSH ||
13167 mode == CB_DUMP_BRUSH_SMALL ||
13168 mode == CB_BRUSH_TO_CLIPBOARD ||
13169 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13171 if (edit_mode != ED_MODE_DRAWING)
13174 char part[MAX_CB_PART_SIZE + 1] = "";
13175 char text[MAX_CB_TEXT_SIZE + 1] = "";
13176 int width = (draw_with_brush ? brush_width : lev_fieldx);
13177 int height = (draw_with_brush ? brush_height : lev_fieldy);
13178 char *format = "%s%03d";
13180 for (y = 0; y < height; y++)
13181 for (x = 0; x < width; x++)
13182 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
13185 for (y = 0; y < height; y++)
13187 for (x = 0; x < width; x++)
13189 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
13190 char *prefix = (mode == CB_DUMP_BRUSH ||
13191 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
13193 if (element >= NUM_FILE_ELEMENTS)
13194 element = EL_UNKNOWN;
13196 // copy brush to level sketch text buffer for the R'n'D forum:
13197 // - large tiles: `xxx or `xxxx (0x60 ASCII)
13198 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
13199 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
13200 strcat(text, part);
13203 strcat(text, "\n");
13206 if (mode == CB_BRUSH_TO_CLIPBOARD ||
13207 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13208 SDL_SetClipboardText(text);
13210 Print("%s", text); // print brush data to console and log file
13215 if (mode == CB_CLIPBOARD_TO_BRUSH)
13217 if (edit_mode != ED_MODE_DRAWING)
13220 if (!SDL_HasClipboardText())
13222 Request("Clipboard is empty!", REQ_CONFIRM);
13227 boolean copy_to_brush = (draw_with_brush ||
13228 drawing_function == GADGET_ID_GRAB_BRUSH);
13230 // this will delete the old brush, if already drawing with a brush
13232 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
13234 // initialization is required for "odd" (incomplete) clipboard content
13235 for (x = 0; x < MAX_LEV_FIELDX; x++)
13236 for (y = 0; y < MAX_LEV_FIELDY; y++)
13237 brush_buffer[x][y] = EL_EMPTY;
13244 char *clipboard_text = SDL_GetClipboardText();
13245 char *ptr = clipboard_text;
13246 boolean allow_new_row = FALSE;
13247 boolean stop = FALSE;
13249 while (*ptr && !stop)
13251 boolean prefix_found = FALSE;
13252 boolean start_new_row = FALSE;
13254 // level sketch element number prefixes (may be multi-byte characters)
13255 char *prefix_list[] = { "`", "¸" };
13258 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
13260 char *prefix = prefix_list[i];
13262 // check if string is large enough for prefix
13263 if (strlen(ptr) < strlen(prefix))
13270 // check if string starts with prefix
13271 if (strPrefix(ptr, prefix))
13273 ptr += strlen(prefix);
13275 prefix_found = TRUE;
13281 // check if prefix found and followed by (at least) three digits
13282 if (prefix_found &&
13283 strlen(ptr) >= 3 &&
13284 ptr[0] >= '0' && ptr[0] <= '9' &&
13285 ptr[1] >= '0' && ptr[1] <= '9' &&
13286 ptr[2] >= '0' && ptr[2] <= '9')
13288 int element = ((ptr[0] - '0') * 100 +
13289 (ptr[1] - '0') * 10 +
13294 // level sketch element number might consist of four digits
13295 if (ptr[0] >= '0' && ptr[0] <= '9')
13297 element = element * 10 + (ptr[0] - '0');
13301 // remap some (historic, now obsolete) elements
13302 element = getMappedElement(element);
13304 if (element >= NUM_FILE_ELEMENTS)
13305 element = EL_UNKNOWN;
13307 brush_buffer[x][y] = element;
13309 brush_width = MAX(x + 1, brush_width);
13310 brush_height = MAX(y + 1, brush_height);
13314 if (x >= MAX_LEV_FIELDX)
13315 start_new_row = TRUE;
13317 allow_new_row = TRUE;
13321 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
13322 start_new_row = TRUE;
13324 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
13332 if (y >= MAX_LEV_FIELDY)
13335 allow_new_row = FALSE;
13339 SDL_free(clipboard_text);
13341 if (brush_width == 0 || brush_height == 0)
13343 Request("No level sketch found in clipboard!", REQ_CONFIRM);
13350 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
13353 SDL_GetMouseState(&mx, &my);
13355 // if inside drawing area, activate and draw brush at last mouse position
13356 if (mx >= gi->x && mx < gi->x + gi->width &&
13357 my >= gi->y && my < gi->y + gi->height)
13358 CopyBrushToCursor(last_cursor_x, last_cursor_y);
13360 draw_with_brush = TRUE;
13366 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
13367 brush_width, brush_height);
13369 if (!Request(request, REQ_ASK))
13372 for (x = 0; x < MAX_LEV_FIELDX; x++)
13373 for (y = 0; y < MAX_LEV_FIELDY; y++)
13374 Tile[x][y] = brush_buffer[x][y];
13376 lev_fieldx = level.fieldx = brush_width;
13377 lev_fieldy = level.fieldy = brush_height;
13379 boolean use_bd_engine = TRUE;
13380 boolean use_em_engine = TRUE;
13381 boolean use_sp_engine = TRUE;
13382 boolean use_mm_engine = TRUE;
13384 for (x = 0; x < MAX_LEV_FIELDX; x++)
13386 for (y = 0; y < MAX_LEV_FIELDY; y++)
13388 int element = Tile[x][y];
13390 if (!IS_BD_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13391 use_bd_engine = FALSE;
13393 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13394 use_em_engine = FALSE;
13396 if (!IS_SP_ELEMENT(element))
13397 use_sp_engine = FALSE;
13399 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
13400 use_mm_engine = FALSE;
13404 level.game_engine_type = (use_bd_engine ? GAME_ENGINE_TYPE_BD :
13405 use_em_engine ? GAME_ENGINE_TYPE_EM :
13406 use_sp_engine ? GAME_ENGINE_TYPE_SP :
13407 use_mm_engine ? GAME_ENGINE_TYPE_MM :
13408 GAME_ENGINE_TYPE_RND);
13410 // update element selection list
13411 ReinitializeElementList();
13412 ModifyEditorElementList();
13414 SetBorderElement();
13416 DrawEditModeWindow();
13417 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13423 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
13426 if (mode == CB_AREA_TO_BRUSH)
13428 int from_lx, from_ly;
13431 swap_numbers(&from_x, &to_x);
13434 swap_numbers(&from_y, &to_y);
13436 brush_width = to_x - from_x + 1;
13437 brush_height = to_y - from_y + 1;
13439 from_lx = from_x + level_xpos;
13440 from_ly = from_y + level_ypos;
13442 for (y = 0; y < brush_height; y++)
13444 for (x = 0; x < brush_width; x++)
13446 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
13449 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
13454 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13456 delete_old_brush = FALSE;
13458 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
13459 mode == CB_BRUSH_TO_LEVEL)
13461 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
13462 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
13463 int cursor_from_x = cursor_x - brush_width / 2;
13464 int cursor_from_y = cursor_y - brush_height / 2;
13465 int border_from_x = cursor_x, border_from_y = cursor_y;
13466 int border_to_x = cursor_x, border_to_y = cursor_y;
13468 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
13469 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13471 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
13472 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
13474 delete_old_brush = FALSE;
13479 for (y = 0; y < brush_height; y++)
13481 for (x = 0; x < brush_width; x++)
13483 int sx = cursor_from_x + x;
13484 int sy = cursor_from_y + y;
13485 int lx = sx + level_xpos;
13486 int ly = sy + level_ypos;
13487 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
13488 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
13489 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
13490 brush_buffer[x][y] : new_element);
13492 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13494 if (sx < border_from_x)
13495 border_from_x = sx;
13496 else if (sx > border_to_x)
13498 if (sy < border_from_y)
13499 border_from_y = sy;
13500 else if (sy > border_to_y)
13503 DrawBrushElement(sx, sy, element, change_level);
13508 if (mode != CB_DELETE_OLD_CURSOR)
13509 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
13511 last_cursor_x = cursor_x;
13512 last_cursor_y = cursor_y;
13514 delete_old_brush = TRUE;
13516 else if (mode == CB_FLIP_BRUSH_X)
13518 for (y = 0; y < brush_height; y++)
13519 for (x = 0; x < (brush_width + 1) / 2; x++)
13520 SwapFlippedTiles(&brush_buffer[x][y],
13521 &brush_buffer[brush_width - x - 1][y], mode);
13523 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13525 else if (mode == CB_FLIP_BRUSH_Y)
13527 for (y = 0; y < (brush_height + 1) / 2; y++)
13528 for (x = 0; x < brush_width; x++)
13529 SwapFlippedTiles(&brush_buffer[x][y],
13530 &brush_buffer[x][brush_height - y - 1], mode);
13532 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13534 else if (mode == CB_FLIP_BRUSH_XY)
13536 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13538 for (y = 0; y < MAX(brush_width, brush_height); y++)
13539 for (x = 0; x <= y; x++)
13540 SwapFlippedTiles(&brush_buffer[x][y],
13541 &brush_buffer[y][x], mode);
13543 swap_numbers(&brush_width, &brush_height);
13545 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13548 if (mode == CB_UPDATE_BRUSH_POSITION)
13550 last_cursor_x = from_x;
13551 last_cursor_y = from_y;
13555 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
13558 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
13561 static void CopyBrushToLevel(int x, int y, int button)
13563 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
13566 static void CopyBrushToCursor(int x, int y)
13568 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13571 static void UpdateBrushPosition(int x, int y)
13573 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
13576 static void DeleteBrushFromCursor(void)
13578 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13581 static void FlipBrushX(void)
13583 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13586 static void FlipBrushY(void)
13588 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_Y);
13591 static void RotateBrush(void)
13593 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_XY);
13594 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13597 void DumpBrush(void)
13599 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
13602 void DumpBrush_Small(void)
13604 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
13607 void CopyClipboardToBrush(void)
13609 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
13612 void CopyBrushToClipboard(void)
13614 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
13617 void CopyBrushToClipboard_Small(void)
13619 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
13622 void UndoLevelEditorOperation(void)
13624 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
13627 void RedoLevelEditorOperation(void)
13629 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13632 static void FloodFill(int from_x, int from_y, int fill_element)
13634 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
13637 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
13639 int from_x = from_sx2 + 2 * level_xpos;
13640 int from_y = from_sy2 + 2 * level_ypos;
13641 int max_fillx = lev_fieldx * 2;
13642 int max_filly = lev_fieldy * 2;
13643 short Fill[max_fillx][max_filly];
13646 for (x = 0; x < max_fillx; x++)
13647 for (y = 0; y < max_filly; y++)
13648 Fill[x][y] = getLevelElementHiRes(x, y);
13650 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
13651 Fill, max_fillx, max_filly);
13653 for (x = 0; x < max_fillx; x++)
13654 for (y = 0; y < max_filly; y++)
13655 if (Fill[x][y] == fill_element)
13656 SetLevelElementHiRes(x, y, Fill[x][y]);
13659 // values for DrawLevelText() modes
13660 #define TEXT_INIT 0
13661 #define TEXT_SETCURSOR 1
13662 #define TEXT_WRITECHAR 2
13663 #define TEXT_BACKSPACE 3
13664 #define TEXT_NEWLINE 4
13666 #define TEXT_QUERY_TYPING 6
13668 static int DrawLevelText(int sx, int sy, char letter, int mode)
13670 static short delete_buffer[MAX_LEV_FIELDX];
13671 static int start_sx;
13672 static int last_sx, last_sy;
13673 static boolean typing = FALSE;
13674 int letter_element;
13675 int lx = 0, ly = 0;
13677 // map lower case letters to upper case and convert special characters
13678 if (letter >= 'a' && letter <= 'z')
13679 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
13680 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
13681 letter_element = EL_CHAR_AUMLAUT;
13682 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
13683 letter_element = EL_CHAR_OUMLAUT;
13684 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
13685 letter_element = EL_CHAR_UUMLAUT;
13686 else if (letter == '^')
13687 letter_element = EL_CHAR_COPYRIGHT;
13689 letter_element = EL_CHAR_ASCII0 + letter;
13691 if (mode != TEXT_INIT)
13696 if (mode != TEXT_SETCURSOR)
13702 lx = last_sx + level_xpos;
13703 ly = last_sy + level_ypos;
13710 DrawLevelText(0, 0, 0, TEXT_END);
13716 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
13719 case TEXT_SETCURSOR:
13720 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
13721 DrawAreaBorder(sx, sy, sx, sy);
13722 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
13723 ed_tilesize, ed_tilesize);
13728 case TEXT_WRITECHAR:
13729 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
13731 if (new_element1 >= EL_STEEL_CHAR_START &&
13732 new_element1 <= EL_STEEL_CHAR_END)
13733 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
13735 delete_buffer[sx - start_sx] = Tile[lx][ly];
13736 Tile[lx][ly] = letter_element;
13738 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
13739 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
13740 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13741 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13743 DrawLevelText(0, 0, 0, TEXT_END);
13745 level.changed = TRUE;
13749 case TEXT_BACKSPACE:
13752 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
13753 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
13754 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
13759 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13760 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13762 DrawLevelText(0, 0, 0, TEXT_END);
13766 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13767 DrawEditorElement(sx, sy, Tile[lx][ly]);
13772 case TEXT_QUERY_TYPING:
13782 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
13783 int element, boolean change_level)
13785 int lx = sx + level_xpos;
13786 int ly = sy + level_ypos;
13789 DrawEditorElement(sx, sy, Tile[lx][ly]);
13791 DrawAreaBorder(sx, sy, sx, sy);
13794 static void CheckLevelBorderElement(boolean redraw_playfield)
13796 int last_border_element = BorderElement;
13798 SetBorderElement();
13800 if (redraw_playfield && BorderElement != last_border_element)
13801 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13804 static void CopyLevelToUndoBuffer(int mode)
13806 static boolean accumulated_undo = FALSE;
13807 boolean new_undo_buffer_position = TRUE;
13810 if (undo_buffer_steps == 0)
13811 accumulated_undo = FALSE;
13815 case UNDO_IMMEDIATE:
13816 accumulated_undo = FALSE;
13819 case UNDO_ACCUMULATE:
13820 if (accumulated_undo)
13821 new_undo_buffer_position = FALSE;
13822 accumulated_undo = TRUE;
13829 if (new_undo_buffer_position)
13831 // advance position in undo buffer ring
13832 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13834 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
13835 undo_buffer_steps++;
13838 // always reset redo buffer when storing level change into undo buffer
13839 redo_buffer_steps = 0;
13841 for (x = 0; x < lev_fieldx; x++)
13842 for (y = 0; y < lev_fieldy; y++)
13843 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
13845 // check if drawing operation forces change of border style
13846 CheckLevelBorderElement(TRUE);
13848 level.changed = TRUE;
13851 static void RandomPlacement(int new_element)
13853 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13854 int num_free_positions = 0;
13855 int num_percentage, num_elements;
13858 ResetIntelliDraw();
13860 // determine number of free positions for randomly placing the new element
13861 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
13863 free_position[x][y] =
13864 (random_placement_background_restricted ?
13865 Tile[x][y] == random_placement_background_element :
13866 Tile[x][y] != new_element);
13868 if (free_position[x][y])
13869 num_free_positions++;
13872 // determine number of new elements to place there
13873 num_percentage = num_free_positions * random_placement_value / 100;
13874 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
13875 num_percentage : random_placement_value);
13877 // if less free positions than elements to place, fill all these positions
13878 if (num_free_positions < num_elements)
13880 for (x = 0; x < lev_fieldx; x++)
13881 for (y = 0; y < lev_fieldy; y++)
13882 if (free_position[x][y])
13883 SetElement(x, y, new_element);
13887 while (num_elements > 0)
13889 x = GetSimpleRandom(lev_fieldx);
13890 y = GetSimpleRandom(lev_fieldy);
13892 // don't place element at the same position twice
13893 if (free_position[x][y])
13895 free_position[x][y] = FALSE;
13896 SetElement(x, y, new_element);
13902 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13903 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13906 static void WrapLevel(int dx, int dy)
13908 int wrap_dx = lev_fieldx - dx;
13909 int wrap_dy = lev_fieldy - dy;
13912 for (x = 0; x < lev_fieldx; x++)
13913 for (y = 0; y < lev_fieldy; y++)
13914 TileBackup[x][y] = Tile[x][y];
13916 for (x = 0; x < lev_fieldx; x++)
13917 for (y = 0; y < lev_fieldy; y++)
13919 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
13921 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13922 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
13925 static void DrawAreaElementHighlight(boolean highlighted,
13926 boolean highlighted_similar)
13928 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13935 for (x = 0; x < ed_fieldx; x++)
13937 for (y = 0; y < ed_fieldy; y++)
13939 boolean highlight = FALSE;
13940 int lx = x + level_xpos;
13941 int ly = y + level_ypos;
13943 if (!IN_LEV_FIELD(lx, ly))
13946 // check if element is the same
13947 if (Tile[lx][ly] == new_element1)
13950 // check if element is similar
13951 if (highlighted_similar &&
13952 strEqual(element_info[Tile[lx][ly]].class_name,
13953 element_info[new_element1].class_name))
13956 // check if element is matching MM style wall
13957 if (IS_MM_WALL(Tile[lx][ly]) &&
13958 map_mm_wall_element(Tile[lx][ly]) == new_element1)
13964 if (IS_MM_WALL(Tile[lx][ly]) && !highlighted_similar)
13968 for (i = 0; i < 4; i++)
13970 if (!(MM_WALL_BITS(Tile[lx][ly]) & (1 << i)))
13973 int xx = x * 2 + (i % 2);
13974 int yy = y * 2 + (i / 2);
13975 int sx = SX + xx * ed_tilesize / 2;
13976 int sy = SY + yy * ed_tilesize / 2;
13979 int to_sx = sx + ed_tilesize / 2 - 1;
13980 int to_sy = sy + ed_tilesize / 2 - 1;
13982 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13983 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13984 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13985 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13990 int sx = SX + x * ed_tilesize;
13991 int sy = SY + y * ed_tilesize;
13994 int to_sx = sx + ed_tilesize - 1;
13995 int to_sy = sy + ed_tilesize - 1;
13997 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13998 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13999 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14000 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14006 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
14008 char *template_filename_old = getLocalLevelTemplateFilename();
14009 char *template_filename_new =
14010 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
14012 if (copyFile(template_filename_old, template_filename_new) != 0)
14013 Request("Cannot copy level template!", REQ_CONFIRM);
14015 free(template_filename_new);
14018 static void HandleDrawingAreas(struct GadgetInfo *gi)
14020 static boolean started_inside_drawing_area = FALSE;
14021 static int last_sx = -1;
14022 static int last_sy = -1;
14023 static int last_sx2 = -1;
14024 static int last_sy2 = -1;
14025 int id = gi->custom_id;
14026 int type_id = gi->custom_type_id;
14027 boolean button_press_event;
14028 boolean button_release_event;
14029 boolean inside_drawing_area = !gi->event.off_borders;
14030 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
14031 int actual_drawing_function;
14032 int button = gi->event.button;
14033 int new_element = BUTTON_ELEMENT(button);
14034 int sx = gi->event.x, sy = gi->event.y;
14035 int min_sx = 0, min_sy = 0;
14036 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
14037 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
14038 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
14039 int sx2 = gi->event.mx / mini_item_xsize;
14040 int sy2 = gi->event.my / mini_item_ysize;
14043 int lx = 0, ly = 0;
14046 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
14047 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
14049 // make sure to stay inside drawing area boundaries
14050 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14051 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14055 int min_lx = 0, min_ly = 0;
14056 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14058 // get positions inside level field
14059 lx = sx + level_xpos;
14060 ly = sy + level_ypos;
14062 if (!IN_LEV_FIELD(lx, ly))
14063 inside_drawing_area = FALSE;
14065 // make sure to stay inside level field boundaries
14066 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14067 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14069 // correct drawing area positions accordingly
14070 sx = lx - level_xpos;
14071 sy = ly - level_ypos;
14074 // also correct MM wall-sized (double) drawing area positions accordingly
14075 if (sx2 / 2 < sx || sx2 / 2 > sx)
14077 dx = (sx2 / 2 < sx ? 0 : 1);
14080 if (sy2 / 2 < sy || sy2 / 2 > sy)
14082 dy = (sy2 / 2 < sy ? 0 : 1);
14086 if (!button_press_event && !button_release_event)
14088 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
14089 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
14090 isHiresTileElement(old_element) &&
14091 isHiresDrawElement(new_element));
14093 // prevent handling events for every pixel position when moving mouse
14094 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
14095 (sx2 == last_sx2 && sy2 == last_sy2))
14104 if (button_press_event)
14105 started_inside_drawing_area = inside_drawing_area;
14107 if (!started_inside_drawing_area)
14110 if (!IS_VALID_BUTTON(button))
14113 // handle info callback for each invocation of action callback
14114 gi->callback_info(gi);
14116 // automatically switch to 'single item' drawing mode, if needed
14117 actual_drawing_function =
14118 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
14119 drawing_function : GADGET_ID_SINGLE_ITEMS);
14121 // clicking into drawing area with pressed Control key picks element
14122 if (GetKeyModState() & KMOD_Control)
14124 last_drawing_function = drawing_function;
14125 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14128 if (GetKeyModState() & KMOD_Shift)
14130 if (button_press_event || button_release_event)
14131 ResetIntelliDraw();
14134 SetDrawModeHiRes(-1); // reset to normal draw mode
14136 switch (actual_drawing_function)
14138 case GADGET_ID_SINGLE_ITEMS:
14141 if (button_release_event)
14143 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14145 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
14146 !inside_drawing_area)
14147 DeleteBrushFromCursor();
14152 if (draw_with_brush)
14154 CopyBrushToLevel(sx, sy, button);
14158 SetDrawModeHiRes(new_element);
14160 if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
14162 // remove player at old position
14163 for (y = 0; y < lev_fieldy; y++)
14165 for (x = 0; x < lev_fieldx; x++)
14167 int old_element = Tile[x][y];
14169 if (IS_PLAYER_ELEMENT(old_element) &&
14170 IS_PLAYER_ELEMENT(new_element))
14172 int replaced_with_element =
14173 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
14174 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
14176 old_element == EL_SOKOBAN_FIELD_PLAYER &&
14177 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
14179 new_element == EL_SOKOBAN_FIELD_PLAYER &&
14180 old_element == EL_PLAYER_1 ? EL_EMPTY :
14182 new_element >= EL_PLAYER_1 &&
14183 new_element <= EL_PLAYER_4 &&
14184 new_element == old_element ? EL_EMPTY :
14188 SetElement(x, y, replaced_with_element);
14190 else if (IS_MM_MCDUFFIN(old_element) &&
14191 IS_MM_MCDUFFIN(new_element))
14193 // remove McDuffin at old position
14194 SetElement(x, y, EL_EMPTY);
14200 SetElementButton(lx, ly, dx, dy, new_element, button);
14203 else if (!button_release_event)
14205 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14207 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
14208 DrawMiniGraphicExt(drawto,
14209 gi->x + sx * MINI_TILEX,
14210 gi->y + sy * MINI_TILEY,
14211 el2edimg(new_element));
14213 DrawFixedGraphicExt(drawto,
14214 gi->x + sx * TILEX,
14215 gi->y + sy * TILEY,
14216 el2edimg(new_element), 0);
14218 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14219 new_element = GFX_ELEMENT(new_element);
14221 drawingarea_info[type_id].value[pos] = new_element;
14223 CopyElementPropertiesToGame(properties_element);
14225 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14227 UpdateCustomElementGraphicGadgets();
14229 FrameCounter = 0; // restart animation frame counter
14234 case GADGET_ID_CONNECTED_ITEMS:
14236 static int last_sx = -1;
14237 static int last_sy = -1;
14239 if (button_release_event)
14240 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14242 SetDrawModeHiRes(new_element);
14244 if (getDrawModeHiRes())
14250 if (!button_press_event)
14251 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
14258 case GADGET_ID_LINE:
14259 case GADGET_ID_ARC:
14260 case GADGET_ID_RECTANGLE:
14261 case GADGET_ID_FILLED_BOX:
14262 SetDrawModeHiRes(new_element);
14264 if (getDrawModeHiRes())
14270 case GADGET_ID_GRAB_BRUSH:
14271 case GADGET_ID_TEXT:
14273 static int last_sx = -1;
14274 static int last_sy = -1;
14275 static int start_sx = -1;
14276 static int start_sy = -1;
14277 void (*draw_func)(int, int, int, int, int, boolean);
14279 if (drawing_function == GADGET_ID_LINE)
14280 draw_func = DrawLine;
14281 else if (drawing_function == GADGET_ID_ARC)
14282 draw_func = DrawArc;
14283 else if (drawing_function == GADGET_ID_RECTANGLE)
14284 draw_func = DrawBox;
14285 else if (drawing_function == GADGET_ID_FILLED_BOX)
14286 draw_func = DrawFilledBox;
14287 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
14288 draw_func = SelectArea;
14289 else // (drawing_function == GADGET_ID_TEXT)
14290 draw_func = SetTextCursor;
14292 if (button_press_event)
14294 draw_func(sx, sy, sx, sy, new_element, FALSE);
14295 start_sx = last_sx = sx;
14296 start_sy = last_sy = sy;
14298 if (drawing_function == GADGET_ID_TEXT)
14299 DrawLevelText(0, 0, 0, TEXT_END);
14301 else if (button_release_event)
14303 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
14304 if (drawing_function == GADGET_ID_GRAB_BRUSH)
14306 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
14307 CopyBrushToCursor(sx, sy);
14308 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14310 draw_with_brush = TRUE;
14312 else if (drawing_function == GADGET_ID_TEXT)
14313 DrawLevelText(sx, sy, 0, TEXT_INIT);
14315 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14317 else if (last_sx != sx || last_sy != sy)
14319 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
14320 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
14321 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
14322 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
14329 case GADGET_ID_FLOOD_FILL:
14330 if (button_press_event && Tile[lx][ly] != new_element)
14332 if (IS_MM_WALL_EDITOR(new_element))
14333 FloodFillWall_MM(sx2, sy2, new_element);
14335 FloodFill(lx, ly, new_element);
14337 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14338 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14342 case GADGET_ID_PICK_ELEMENT:
14343 if (button_release_event)
14344 ClickOnGadget(level_editor_gadget[last_drawing_function],
14346 else if (draw_level)
14347 PickDrawingElement(button, Tile[lx][ly]);
14350 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14352 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
14359 // do not mark level as modified for certain non-level-changing gadgets
14360 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
14361 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
14362 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
14363 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14366 level.changed = TRUE;
14369 static void HandleCounterButtons(struct GadgetInfo *gi)
14371 int gadget_id = gi->custom_id;
14372 int counter_id = gi->custom_type_id;
14373 int button = gi->event.button;
14374 int *counter_value = counterbutton_info[counter_id].value;
14375 int step = BUTTON_STEPSIZE(button) *
14376 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
14378 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14380 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
14381 boolean released = (gi->event.type == GD_EVENT_RELEASED);
14382 boolean level_changed = LevelChanged();
14384 if ((level_changed && pressed) || (!level_changed && released))
14387 if (level_changed && !Request("Level has changed! Discard changes?",
14390 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14391 ModifyEditorCounterValue(counter_id, *counter_value);
14397 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14398 *counter_value = gi->textinput.number_value;
14400 ModifyEditorCounterValue(counter_id, *counter_value + step);
14402 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14404 int last_game_engine_type = level.game_engine_type;
14406 LoadLevel(level_nr);
14407 LoadScore(level_nr);
14409 SaveLevelSetup_SeriesInfo();
14414 DrawEditModeWindow();
14416 if (level.game_engine_type != last_game_engine_type)
14418 // update element selection list
14419 ReinitializeElementList();
14420 ModifyEditorElementList();
14426 switch (counter_id)
14428 case ED_COUNTER_ID_YAMYAM_CONTENT:
14429 DrawYamYamContentAreas();
14432 case ED_COUNTER_ID_BALL_CONTENT:
14433 DrawMagicBallContentAreas();
14436 case ED_COUNTER_ID_ANDROID_CONTENT:
14437 DrawAndroidElementArea();
14440 case ED_COUNTER_ID_GROUP_CONTENT:
14441 DrawGroupElementArea();
14442 CopyGroupElementPropertiesToGame(properties_element);
14445 case ED_COUNTER_ID_INVENTORY_SIZE:
14446 DrawPlayerInitialInventoryArea(properties_element);
14449 case ED_COUNTER_ID_MM_BALL_CONTENT:
14450 DrawMMBallContentArea();
14453 case ED_COUNTER_ID_ENVELOPE_XSIZE:
14454 case ED_COUNTER_ID_ENVELOPE_YSIZE:
14455 DrawEnvelopeTextArea(-1);
14458 case ED_COUNTER_ID_LEVEL_XSIZE:
14459 case ED_COUNTER_ID_LEVEL_YSIZE:
14460 lev_fieldx = level.fieldx;
14461 lev_fieldy = level.fieldy;
14463 // check if resizing of level results in change of border border
14464 SetBorderElement();
14472 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
14473 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
14474 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
14475 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
14476 CopyElementPropertiesToGame(properties_element);
14478 // do not mark level as modified for certain non-level-changing gadgets
14479 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
14480 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
14481 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
14482 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
14485 level.changed = TRUE;
14488 static void HandleTextInputGadgets(struct GadgetInfo *gi)
14490 int type_id = gi->custom_type_id;
14492 strcpy(textinput_info[type_id].value, gi->textinput.value);
14494 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
14496 CopyElementPropertiesToGame(properties_element);
14498 ModifyEditorElementList(); // update changed button info text
14501 // do not mark level as modified for certain non-level-changing gadgets
14502 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
14503 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
14506 level.changed = TRUE;
14509 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
14511 int type_id = gi->custom_type_id;
14513 strncpy(textarea_info[type_id].value, gi->textarea.value,
14514 MAX_ENVELOPE_TEXT_LEN);
14515 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
14517 level.changed = TRUE;
14520 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
14522 int type_id = gi->custom_type_id;
14523 int value_old = *selectbox_info[type_id].value;
14524 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
14526 *selectbox_info[type_id].value = value_new;
14528 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
14530 DrawLevelConfigWindow();
14532 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14534 element_info[properties_element].current_change_page = gi->selectbox.index;
14536 DrawPropertiesWindow();
14538 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
14539 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
14540 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
14541 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
14542 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
14544 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
14546 // when changing action type, also check action mode and action arg
14547 if (value_old != value_new)
14548 setSelectboxSpecialActionVariablesIfNeeded();
14550 DrawPropertiesChange();
14553 CopyElementPropertiesToGame(properties_element);
14555 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
14557 // show or hide "engine" tabulator depending on game engine type
14558 DrawLevelConfigWindow();
14560 // update element selection list depending on game engine type
14561 ReinitializeElementList();
14562 ModifyEditorElementList();
14565 // do not mark level as modified for certain non-level-changing gadgets
14566 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
14567 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14570 level.changed = TRUE;
14573 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
14575 int type_id = gi->custom_type_id;
14578 if (type_id >= ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST &&
14579 type_id <= ED_TAB_BUTTON_ID_LEVELCONFIG_LAST)
14581 edit_mode_levelconfig = gi->custom_type_id;
14583 DrawLevelConfigWindow();
14585 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
14586 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
14588 edit_mode_properties = gi->custom_type_id;
14590 DrawPropertiesWindow();
14592 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
14593 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
14595 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
14597 // backup original "level.field" (needed to track playfield changes)
14598 CopyPlayfield(level.field, TileBackup);
14600 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
14601 CopyPlayfield(Tile, level.field);
14603 if (new_template ||
14604 Request("Save this template and kill the old?", REQ_ASK))
14605 SaveLevelTemplate();
14608 Request("Template saved!", REQ_CONFIRM);
14610 // restore original "level.field" (needed to track playfield changes)
14611 CopyPlayfield(TileBackup, level.field);
14613 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
14615 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
14617 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
14618 leveldir_current->readonly)
14620 Request("This level set is read-only!", REQ_CONFIRM);
14625 if (strEqual(levelset_name, ""))
14627 Request("Please enter level set title!", REQ_CONFIRM);
14632 if (strEqual(levelset_author, ""))
14634 Request("Please enter level set author!", REQ_CONFIRM);
14639 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
14641 if (UpdateUserLevelSet(levelset_subdir,
14644 levelset_num_levels))
14646 Request("Level set updated!", REQ_CONFIRM);
14650 Request("Updating level set failed!", REQ_CONFIRM);
14653 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
14655 if (level.changed && !Request("Level has changed! Discard changes?",
14659 if (CreateUserLevelSet(levelset_subdir,
14662 levelset_num_levels,
14663 levelset_use_levelset_artwork))
14665 if (levelset_copy_level_template)
14666 CopyLevelTemplateToUserLevelSet(levelset_subdir);
14668 Request("New level set created!", REQ_CONFIRM);
14670 AddUserLevelSetToLevelInfo(levelset_subdir);
14671 ChangeEditorToLevelSet(levelset_subdir);
14675 Request("Creating new level set failed!", REQ_CONFIRM);
14679 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
14680 custom_element.num_change_pages < MAX_CHANGE_PAGES)
14682 struct ElementInfo *ei = &element_info[properties_element];
14684 // when modifying custom element, ask for copying level template
14685 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14688 setElementChangePages(ei, ei->num_change_pages + 1);
14690 // set new change page to be new current change page
14691 ei->current_change_page = ei->num_change_pages - 1;
14692 ei->change = &ei->change_page[ei->current_change_page];
14694 setElementChangeInfoToDefaults(ei->change);
14696 DrawPropertiesWindow();
14698 level.changed = TRUE;
14700 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
14701 custom_element.num_change_pages > MIN_CHANGE_PAGES)
14703 struct ElementInfo *ei = &element_info[properties_element];
14705 // when modifying custom element, ask for copying level template
14706 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14709 // copy all change pages after change page to be deleted
14710 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
14711 ei->change_page[i] = ei->change_page[i + 1];
14713 setElementChangePages(ei, ei->num_change_pages - 1);
14715 DrawPropertiesWindow();
14717 level.changed = TRUE;
14721 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
14723 int type_id = gi->custom_type_id;
14725 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
14726 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
14728 struct ElementInfo *ei = &element_info[properties_element];
14729 int step = BUTTON_STEPSIZE(gi->event.button);
14731 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
14732 ei->current_change_page += step;
14734 if (ei->current_change_page < 0)
14735 ei->current_change_page = 0;
14736 else if (ei->current_change_page >= ei->num_change_pages)
14737 ei->current_change_page = ei->num_change_pages - 1;
14739 DrawPropertiesWindow();
14741 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
14742 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14744 struct ElementInfo *ei = &element_info[properties_element];
14745 int current_change_page = ei->current_change_page;
14747 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
14749 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
14750 ei->change_page[current_change_page];
14752 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14754 // when modifying custom element, ask for copying level template
14755 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14758 ei->change_page[current_change_page] =
14759 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
14761 level.changed = TRUE;
14764 DrawPropertiesWindow();
14768 static void HandleRadiobuttons(struct GadgetInfo *gi)
14770 int type_id = gi->custom_type_id;
14772 *radiobutton_info[type_id].value =
14773 radiobutton_info[type_id].checked_value;
14775 // do not mark level as modified for certain non-level-changing gadgets
14776 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
14777 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
14780 level.changed = TRUE;
14783 static void HandleCheckbuttons(struct GadgetInfo *gi)
14785 int type_id = gi->custom_type_id;
14787 *checkbutton_info[type_id].value ^= TRUE;
14789 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
14790 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
14791 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
14792 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
14793 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
14794 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
14795 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
14796 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
14798 CopyElementPropertiesToGame(properties_element);
14801 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
14803 UpdateCustomElementGraphicGadgets();
14805 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
14806 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
14808 boolean template_related_changes_found = FALSE;
14811 // check if any custom, group or empty elements have been changed
14812 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
14813 if ((IS_CUSTOM_ELEMENT(i) ||
14814 IS_GROUP_ELEMENT(i) ||
14815 IS_EMPTY_ELEMENT(i)) &&
14816 element_info[i].modified_settings)
14817 template_related_changes_found = TRUE;
14819 if (level.use_custom_template &&
14820 !fileExists(getGlobalLevelTemplateFilename()))
14822 Request("No level template found!", REQ_CONFIRM);
14824 level.use_custom_template = FALSE;
14826 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14831 if (level.use_custom_template &&
14832 template_related_changes_found &&
14833 !Request("Discard changes and use level template?", REQ_ASK))
14835 level.use_custom_template = FALSE;
14837 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14842 if (!level.use_custom_template &&
14843 Request("Copy settings from level template?", REQ_ASK))
14848 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
14850 DrawEditModeWindow();
14852 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
14854 if (setup.editor.use_template_for_new_levels &&
14855 !fileExists(getGlobalLevelTemplateFilename()))
14857 Request("No level template found!", REQ_CONFIRM);
14862 if (setup.editor.use_template_for_new_levels &&
14864 !Request("Discard level and load template?", REQ_ASK))
14869 if (!setup.editor.use_template_for_new_levels &&
14871 !Request("Discard level and use empty level?", REQ_ASK))
14876 LoadLevel(level_nr);
14877 LoadScore(level_nr);
14882 DrawEditModeWindow();
14884 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
14886 SetAutomaticNumberOfGemsNeeded();
14889 // do not mark level as modified for certain non-level-changing gadgets
14890 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
14891 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
14892 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
14893 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
14894 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
14895 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
14898 level.changed = TRUE;
14901 static void HandleControlButtons(struct GadgetInfo *gi)
14903 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
14904 static int last_edit_mode = ED_MODE_DRAWING;
14905 static int last_custom_copy_mode = -1;
14906 static int last_button = 0;
14907 int id = gi->custom_id;
14908 int button = gi->event.button;
14909 int step = BUTTON_STEPSIZE(button);
14910 int new_element = BUTTON_ELEMENT(button);
14911 int last_properties_element = properties_element;
14914 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
14915 DrawLevelText(0, 0, 0, TEXT_END);
14917 if (id < ED_NUM_CTRL1_BUTTONS &&
14918 id != GADGET_ID_SINGLE_ITEMS &&
14919 id != GADGET_ID_PICK_ELEMENT &&
14920 edit_mode != ED_MODE_DRAWING &&
14921 drawing_function != GADGET_ID_PICK_ELEMENT &&
14922 !(GetKeyModState() & KMOD_Control))
14923 ChangeEditModeWindow(ED_MODE_DRAWING);
14925 // element copy mode active, but no element button pressed => deactivate
14926 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
14927 last_custom_copy_mode = -1;
14929 // when showing palette on element buttons, change element of button used
14930 if (editor.palette.show_on_element_buttons &&
14931 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
14933 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
14935 id = GADGET_ID_PALETTE;
14940 case GADGET_ID_SCROLL_LEFT:
14941 if (level_xpos >= 0)
14943 if (lev_fieldx < ed_fieldx - 2)
14946 level_xpos -= step;
14947 if (level_xpos < -1)
14950 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
14952 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14954 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14955 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14959 case GADGET_ID_SCROLL_RIGHT:
14960 if (level_xpos <= lev_fieldx - ed_fieldx)
14962 if (lev_fieldx < ed_fieldx - 2)
14965 level_xpos += step;
14966 if (level_xpos > lev_fieldx - ed_fieldx + 1)
14967 level_xpos = lev_fieldx - ed_fieldx + 1;
14969 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
14971 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14973 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14974 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14978 case GADGET_ID_SCROLL_UP:
14979 if (level_ypos >= 0)
14981 if (lev_fieldy < ed_fieldy - 2)
14984 level_ypos -= step;
14985 if (level_ypos < -1)
14988 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
14990 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14992 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
14993 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
14997 case GADGET_ID_SCROLL_DOWN:
14998 if (level_ypos <= lev_fieldy - ed_fieldy)
15000 if (lev_fieldy < ed_fieldy - 2)
15003 level_ypos += step;
15004 if (level_ypos > lev_fieldy - ed_fieldy + 1)
15005 level_ypos = lev_fieldy - ed_fieldy + 1;
15007 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
15009 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15011 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15012 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15016 case GADGET_ID_SCROLL_HORIZONTAL:
15017 level_xpos = gi->event.item_position - 1;
15019 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15024 case GADGET_ID_SCROLL_VERTICAL:
15025 level_ypos = gi->event.item_position - 1;
15027 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15032 case GADGET_ID_SCROLL_LIST_UP:
15033 case GADGET_ID_SCROLL_LIST_DOWN:
15034 case GADGET_ID_SCROLL_LIST_VERTICAL:
15035 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
15036 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
15039 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
15040 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15042 if (element_shift < 0)
15044 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15045 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15047 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15048 GDI_SCROLLBAR_ITEM_POSITION,
15049 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15052 ModifyEditorElementList();
15056 case GADGET_ID_PROPERTIES:
15057 // always switch off element properties when they are already displayed
15058 last_properties_element = new_element;
15059 case GADGET_ID_ELEMENT_LEFT:
15060 case GADGET_ID_ELEMENT_MIDDLE:
15061 case GADGET_ID_ELEMENT_RIGHT:
15062 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
15063 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
15064 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
15067 if (edit_mode != ED_MODE_PROPERTIES)
15069 last_edit_mode = edit_mode;
15071 ChangeEditModeWindow(ED_MODE_PROPERTIES);
15073 last_level_drawing_function = drawing_function;
15074 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
15077 else if (properties_element != last_properties_element)
15079 DrawEditModeWindow();
15083 ChangeEditModeWindow(ED_MODE_DRAWING);
15085 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
15090 case GADGET_ID_PALETTE:
15091 if (edit_mode != ED_MODE_PALETTE)
15093 last_edit_mode = edit_mode;
15095 ChangeEditModeWindow(ED_MODE_PALETTE);
15099 ChangeEditModeWindow(last_edit_mode);
15103 case GADGET_ID_WRAP_LEFT:
15104 WrapLevel(-step, 0);
15107 case GADGET_ID_WRAP_RIGHT:
15108 WrapLevel(step, 0);
15111 case GADGET_ID_WRAP_UP:
15112 WrapLevel(0, -step);
15115 case GADGET_ID_WRAP_DOWN:
15116 WrapLevel(0, step);
15119 case GADGET_ID_SINGLE_ITEMS:
15120 case GADGET_ID_CONNECTED_ITEMS:
15121 case GADGET_ID_LINE:
15122 case GADGET_ID_ARC:
15123 case GADGET_ID_TEXT:
15124 case GADGET_ID_RECTANGLE:
15125 case GADGET_ID_FILLED_BOX:
15126 case GADGET_ID_FLOOD_FILL:
15127 case GADGET_ID_GRAB_BRUSH:
15128 case GADGET_ID_PICK_ELEMENT:
15129 if (drawing_function != GADGET_ID_PICK_ELEMENT)
15130 last_drawing_function = drawing_function;
15131 drawing_function = id;
15132 draw_with_brush = FALSE;
15135 case GADGET_ID_RANDOM_PLACEMENT:
15136 RandomPlacement(new_element);
15139 case GADGET_ID_ZOOM:
15140 // zoom level editor tile size in or out (or reset to default size)
15141 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
15142 button == 2 ? ed_tilesize_default :
15143 button == 3 ? ed_tilesize / 2 : ed_tilesize);
15145 // when using touch device, cycle through all zoom tilesizes
15146 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
15147 ed_tilesize = MICRO_TILESIZE;
15149 // limit zoom level by upper and lower bound
15150 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
15152 InitZoomLevelSettings(ed_tilesize);
15154 if (edit_mode == ED_MODE_DRAWING)
15156 DrawDrawingWindow();
15158 // redraw zoom gadget info text
15159 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15162 // save current editor zoom tilesize
15163 SaveSetup_AutoSetup();
15167 case GADGET_ID_CUSTOM_COPY_FROM:
15168 case GADGET_ID_CUSTOM_COPY_TO:
15169 case GADGET_ID_CUSTOM_EXCHANGE:
15170 last_custom_copy_mode = id;
15171 last_drawing_function = drawing_function;
15174 case GADGET_ID_CUSTOM_COPY:
15175 CopyCustomElement(properties_element, -1, id);
15178 case GADGET_ID_CUSTOM_PASTE:
15179 CopyCustomElement(-1, properties_element, id);
15182 case GADGET_ID_UNDO:
15183 if (button < 0) // keep button value (even if modifier keys are pressed)
15185 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
15188 if (button == 1 && undo_buffer_steps == 0)
15190 Request("Undo buffer empty!", REQ_CONFIRM);
15194 else if (button == 2)
15198 else if (button == 3 && redo_buffer_steps == 0)
15200 Request("Redo buffer empty!", REQ_CONFIRM);
15205 if (edit_mode != ED_MODE_DRAWING)
15206 ChangeEditModeWindow(ED_MODE_DRAWING);
15212 undo_buffer_position =
15213 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
15215 undo_buffer_steps--;
15216 redo_buffer_steps++;
15222 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
15224 undo_buffer_steps++;
15225 redo_buffer_steps--;
15228 for (x = 0; x < lev_fieldx; x++)
15229 for (y = 0; y < lev_fieldy; y++)
15230 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
15232 // check if undo operation forces change of border style
15233 CheckLevelBorderElement(FALSE);
15235 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15239 case GADGET_ID_CONF:
15240 if (edit_mode != ED_MODE_LEVELCONFIG)
15242 last_edit_mode = edit_mode;
15244 ChangeEditModeWindow(ED_MODE_LEVELCONFIG);
15248 ChangeEditModeWindow(ED_MODE_DRAWING);
15252 case GADGET_ID_CLEAR:
15253 if (edit_mode != ED_MODE_DRAWING)
15254 ChangeEditModeWindow(ED_MODE_DRAWING);
15256 for (x = 0; x < MAX_LEV_FIELDX; x++)
15257 for (y = 0; y < MAX_LEV_FIELDY; y++)
15258 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
15260 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
15262 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15265 case GADGET_ID_SAVE:
15267 // saving read-only levels into personal level set modifies global vars
15268 // "leveldir_current" and "level_nr"; restore them after saving level
15269 LevelDirTree *leveldir_former = leveldir_current;
15270 int level_nr_former = level_nr;
15271 char *level_filename;
15274 if (leveldir_current->readonly &&
15275 !PrepareSavingIntoPersonalLevelSet())
15278 level_filename = getDefaultLevelFilename(level_nr);
15279 new_level = !fileExists(level_filename);
15282 Request("Save this level and kill the old?", REQ_ASK))
15284 if (leveldir_former->readonly)
15285 ModifyLevelConfigForSavingIntoPersonalLevelSet(leveldir_former->name);
15287 SetAutomaticNumberOfGemsNeeded();
15289 CopyPlayfield(Tile, level.field);
15290 SaveLevel(level_nr);
15292 level.changed = FALSE;
15296 char level_saved_msg[64];
15298 if (leveldir_former->readonly)
15299 sprintf(level_saved_msg,
15300 "Level saved as level %d into personal level set!",
15303 strcpy(level_saved_msg, "Level saved!");
15305 Request(level_saved_msg, REQ_CONFIRM);
15309 // "cd" back to copied-from levelset (in case of saved read-only level)
15310 leveldir_current = leveldir_former;
15311 level_nr = level_nr_former;
15316 case GADGET_ID_TEST:
15317 if (LevelChanged())
15318 level.game_version = GAME_VERSION_ACTUAL;
15320 CopyPlayfield(level.field, TileBackup);
15321 CopyPlayfield(Tile, level.field);
15323 CopyNativeLevel_RND_to_Native(&level);
15325 UnmapLevelEditorGadgets();
15326 UndrawSpecialEditorDoor();
15328 CloseDoor(DOOR_CLOSE_ALL);
15330 // needed before playing if editor playfield area has different size
15331 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
15333 // redraw_mask = REDRAW_ALL;
15335 level_editor_test_game = TRUE;
15337 StartGameActions(FALSE, setup.autorecord, level.random_seed);
15341 case GADGET_ID_EXIT:
15342 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
15346 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
15347 id <= GADGET_ID_ELEMENTLIST_LAST)
15349 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
15351 new_element = editor_elements[element_position + element_shift];
15353 if (IS_EDITOR_CASCADE(new_element))
15357 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
15359 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
15360 boolean *cascade_value = editor_elements_info[i].setup_cascade_value;
15362 if (*cascade_element == new_element)
15364 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
15365 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
15367 // update element selection list
15368 ReinitializeElementList();
15369 ModifyEditorElementList();
15371 // update cascading gadget info text
15372 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15374 // save current editor cascading state
15375 SaveSetup_EditorCascade();
15384 if (last_custom_copy_mode != -1)
15386 if (CopyCustomElement(properties_element, new_element,
15387 last_custom_copy_mode))
15389 ClickOnGadget(level_editor_gadget[last_drawing_function],
15392 last_custom_copy_mode = -1;
15398 // change element of button used to show palette
15399 if (editor.palette.show_on_element_buttons)
15400 button = last_button;
15402 PickDrawingElement(button, new_element);
15404 if (!stick_element_properties_window &&
15405 drawing_function != GADGET_ID_PICK_ELEMENT &&
15406 !(GetKeyModState() & KMOD_Control))
15408 properties_element = new_element;
15409 if (edit_mode == ED_MODE_PROPERTIES)
15410 DrawPropertiesWindow();
15413 if (drawing_function == GADGET_ID_PICK_ELEMENT)
15414 ClickOnGadget(level_editor_gadget[last_drawing_function],
15417 if (!use_permanent_palette)
15418 ChangeEditModeWindow(last_edit_mode);
15421 else if (gi->event.type == GD_EVENT_PRESSED)
15422 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
15423 else if (gi->event.type == GD_EVENT_RELEASED)
15424 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
15425 else if (gi->event.type == GD_EVENT_MOVING)
15426 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
15428 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
15434 void HandleLevelEditorKeyInput(Key key)
15436 char letter = getCharFromKey(key);
15438 if (drawing_function == GADGET_ID_TEXT &&
15439 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
15442 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
15443 else if (key == KSYM_Delete || key == KSYM_BackSpace)
15444 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
15445 else if (key == KSYM_Return)
15446 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
15447 else if (key == KSYM_Escape)
15448 DrawLevelText(0, 0, 0, TEXT_END);
15453 int id = GADGET_ID_NONE;
15454 int new_element_shift = element_shift;
15455 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
15456 int button = MB_LEFTBUTTON;
15462 id = GADGET_ID_SCROLL_LEFT;
15465 id = GADGET_ID_SCROLL_RIGHT;
15468 id = GADGET_ID_SCROLL_UP;
15471 id = GADGET_ID_SCROLL_DOWN;
15475 case KSYM_Page_Down:
15476 step *= (key == KSYM_Page_Up ? -1 : +1);
15477 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15479 if (element_shift < 0)
15481 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15482 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15484 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15485 GDI_SCROLLBAR_ITEM_POSITION,
15486 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15488 ModifyEditorElementList();
15494 element_shift = (key == KSYM_Home ? 0 :
15495 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
15497 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15498 GDI_SCROLLBAR_ITEM_POSITION,
15499 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15501 ModifyEditorElementList();
15508 // this is needed to prevent interference with running "True X-Mouse"
15509 if (GetKeyModStateFromEvents() & KMOD_Control)
15512 // check for last or next editor cascade block in element list
15513 for (i = 0; i < num_editor_elements; i++)
15515 if ((key == KSYM_Insert && i == element_shift) ||
15516 (key == KSYM_Delete && new_element_shift > element_shift))
15519 // jump to next cascade block (or to start of element list)
15520 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
15521 new_element_shift = i;
15524 if (i < num_editor_elements)
15525 element_shift = new_element_shift;
15527 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15528 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15530 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15531 GDI_SCROLLBAR_ITEM_POSITION,
15532 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15534 ModifyEditorElementList();
15539 if (edit_mode == ED_MODE_DRAWING)
15540 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
15541 else if (edit_mode == ED_MODE_LEVELCONFIG)
15542 HandleControlButtons(level_editor_gadget[GADGET_ID_CONF]);
15543 else if (edit_mode == ED_MODE_PROPERTIES)
15544 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
15545 else if (edit_mode == ED_MODE_PALETTE)
15546 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
15547 else // should never happen
15548 ChangeEditModeWindow(ED_MODE_DRAWING);
15556 if (id != GADGET_ID_NONE)
15557 ClickOnGadget(level_editor_gadget[id], button);
15558 else if (letter == '1' || letter == '?')
15559 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
15560 else if (letter == '2')
15561 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
15562 else if (letter == '3')
15563 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
15564 else if (letter == '.')
15565 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
15566 else if (letter == 'U')
15567 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
15568 else if (letter == '-' || key == KSYM_KP_Subtract)
15569 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
15570 else if (letter == '0' || key == KSYM_KP_0)
15571 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
15572 else if (letter == '+' || key == KSYM_KP_Add ||
15573 letter == '=') // ("Shift-=" is "+" on US keyboards)
15574 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
15575 else if (key == KSYM_Return ||
15576 key == KSYM_space ||
15577 key == setup.shortcut.toggle_pause)
15578 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
15580 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
15581 if (letter && letter == controlbutton_info[i].shortcut)
15582 if (!anyTextGadgetActive())
15583 ClickOnGadget(level_editor_gadget[i], button);
15585 if (draw_with_brush)
15589 else if (letter == 'y')
15591 else if (letter == 'z')
15596 static void HandleLevelEditorIdle_Properties(void)
15598 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
15599 int x = editor.settings.element_graphic.x + element_border;
15600 int y = editor.settings.element_graphic.y + element_border;
15601 static DelayCounter action_delay = { 0 };
15604 action_delay.value = GameFrameDelay;
15606 if (!DelayReached(&action_delay))
15609 for (i = 0; i < ED_NUM_SELECTBOX; i++)
15611 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
15613 if (gi->mapped && gi->active && gi->selectbox.open)
15617 DrawEditorElementAnimation(SX + x, SY + y);
15619 redraw_mask |= REDRAW_FIELD;
15621 FrameCounter++; // increase animation frame counter
15624 static void HandleLevelEditorIdle_Drawing(void)
15626 static boolean last_highlighted = FALSE;
15627 static boolean last_highlighted_similar = FALSE;
15628 boolean highlighted = (GetKeyModState() & KMOD_Alt);
15629 boolean highlighted_similar = (GetKeyModState() & KMOD_Shift);
15631 if (highlighted != last_highlighted ||
15632 (highlighted && highlighted_similar != last_highlighted_similar))
15634 DrawAreaElementHighlight(highlighted, highlighted_similar);
15636 redraw_mask |= REDRAW_FIELD;
15639 last_highlighted = highlighted;
15640 last_highlighted_similar = highlighted_similar;
15643 void HandleLevelEditorIdle(void)
15645 if (edit_mode == ED_MODE_PROPERTIES)
15646 HandleLevelEditorIdle_Properties();
15647 else if (edit_mode == ED_MODE_DRAWING)
15648 HandleLevelEditorIdle_Drawing();
15651 static void ClearEditorGadgetInfoText(void)
15653 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
15656 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
15658 char infotext[MAX_OUTPUT_LINESIZE + 1];
15659 int max_infotext_len = getMaxInfoTextLength();
15661 if (gi == NULL || strlen(gi->info_text) == 0)
15664 strncpy(infotext, gi->info_text, max_infotext_len);
15665 infotext[max_infotext_len] = '\0';
15667 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
15669 int key = controlbutton_info[gi->custom_id].shortcut;
15673 char shortcut[MAX_OUTPUT_LINESIZE + 1];
15675 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
15676 sprintf(shortcut, " ('.' or '%c')", key);
15677 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
15678 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
15679 else if (gi->custom_id == GADGET_ID_TEST)
15680 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
15681 else if (gi->custom_id == GADGET_ID_UNDO)
15682 sprintf(shortcut, " ('%c/Shift-U')", key);
15683 else if (gi->custom_id == GADGET_ID_ZOOM)
15684 sprintf(shortcut, " ('%c', '0', '-')", key);
15686 sprintf(shortcut, " ('%s%c')",
15687 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
15689 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
15690 strcat(infotext, shortcut);
15694 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
15697 void HandleEditorGadgetInfoText(void *ptr)
15699 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
15701 if (game_status != GAME_MODE_EDITOR)
15704 ClearEditorGadgetInfoText();
15706 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
15709 // misuse this function to delete brush cursor, if needed
15710 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
15711 DeleteBrushFromCursor();
15713 PrintEditorGadgetInfoText(gi);
15716 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
15718 int id = gi->custom_id;
15719 int type_id = gi->custom_type_id;
15720 int sx = gi->event.x;
15721 int sy = gi->event.y;
15722 int lx = sx + level_xpos;
15723 int ly = sy + level_ypos;
15724 int min_sx = 0, min_sy = 0;
15725 int max_sx = gi->drawing.area_xsize - 1;
15726 int max_sy = gi->drawing.area_ysize - 1;
15727 int actual_drawing_function = drawing_function;
15728 int max_infotext_len = getMaxInfoTextLength();
15729 char infotext[MAX_OUTPUT_LINESIZE + 1];
15731 infotext[0] = '\0'; // start with empty info text
15733 // pressed Control key: simulate picking element
15734 if (GetKeyModState() & KMOD_Control)
15735 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
15737 ClearEditorGadgetInfoText();
15739 if (gi->event.type == GD_EVENT_INFO_LEAVING)
15742 // make sure to stay inside drawing area boundaries
15743 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
15744 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
15746 if (id == GADGET_ID_DRAWING_LEVEL)
15750 int min_lx = 0, min_ly = 0;
15751 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
15753 // get positions inside level field
15754 lx = sx + level_xpos;
15755 ly = sy + level_ypos;
15757 // make sure to stay inside level field boundaries
15758 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
15759 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
15761 // correct drawing area positions accordingly
15762 sx = lx - level_xpos;
15763 sy = ly - level_ypos;
15766 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15768 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
15770 static int start_lx = 0;
15771 static int start_ly = 0;
15774 if (gi->event.type == GD_EVENT_PRESSED)
15780 switch (actual_drawing_function)
15782 case GADGET_ID_SINGLE_ITEMS:
15783 text = "Drawing single items";
15785 case GADGET_ID_CONNECTED_ITEMS:
15786 text = "Drawing connected items";
15788 case GADGET_ID_LINE:
15789 text = "Drawing line";
15791 case GADGET_ID_ARC:
15792 text = "Drawing arc";
15794 case GADGET_ID_TEXT:
15795 text = "Setting text cursor";
15797 case GADGET_ID_RECTANGLE:
15798 text = "Drawing rectangle";
15800 case GADGET_ID_FILLED_BOX:
15801 text = "Drawing filled box";
15803 case GADGET_ID_FLOOD_FILL:
15804 text = "Flood fill";
15806 case GADGET_ID_GRAB_BRUSH:
15807 text = "Grabbing brush";
15809 case GADGET_ID_PICK_ELEMENT:
15810 text = "Picking element";
15814 text = "Drawing position";
15818 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15819 sprintf(infotext, "%s: %d, %d", text, lx, ly);
15821 sprintf(infotext, "%s: %d, %d", text,
15822 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
15824 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15825 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
15827 sprintf(infotext, "Level position: %d, %d", lx, ly);
15830 // misuse this function to draw brush cursor, if needed
15831 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
15833 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15834 CopyBrushToCursor(sx, sy);
15836 DeleteBrushFromCursor();
15839 if (!draw_with_brush)
15840 UpdateBrushPosition(sx, sy);
15842 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15844 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
15845 int element = drawingarea_info[type_id].value[pos];
15847 strncpy(infotext, getElementInfoText(element), max_infotext_len);
15851 if (id == GADGET_ID_CUSTOM_CONTENT)
15852 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
15853 else if (id == GADGET_ID_GROUP_CONTENT)
15854 sprintf(infotext, "group element position: %d", sx + 1);
15855 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
15856 id <= GADGET_ID_YAMYAM_CONTENT_7)
15857 sprintf(infotext, "content area %d position: %d, %d",
15858 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
15859 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
15860 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
15861 sprintf(infotext, "content area %d position: %d, %d",
15862 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
15863 else if (id == GADGET_ID_ANDROID_CONTENT)
15864 sprintf(infotext, "android element position: %d", sx + 1);
15865 else if (drawingarea_info[type_id].infotext != NULL)
15866 strcpy(infotext, drawingarea_info[type_id].infotext);
15869 infotext[max_infotext_len] = '\0';
15871 if (strlen(infotext) > 0)
15872 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
15875 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
15876 boolean quick_quit)
15878 if (!ask_if_level_has_changed ||
15880 Request("Level has changed! Exit without saving?",
15881 REQ_ASK | REQ_STAY_OPEN))
15883 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
15884 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
15886 // draw normal door
15887 UndrawSpecialEditorDoor();
15889 // use door animation if door 1 viewport is unchanged and contains toolbox
15890 if (useEditorDoorAnimation())
15891 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
15893 // close editor doors if viewport definition is the same as in main menu
15894 if (vp_door_1->x == DX &&
15895 vp_door_1->y == DY &&
15896 vp_door_1->width == DXSIZE &&
15897 vp_door_1->height == DYSIZE &&
15898 vp_door_2->x == VX &&
15899 vp_door_2->y == VY &&
15900 vp_door_2->width == VXSIZE &&
15901 vp_door_2->height == VYSIZE)
15902 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
15904 SetDoorState(DOOR_CLOSE_ALL);
15909 FadeSkipNextFadeIn();
15911 SetGameStatus(GAME_MODE_MAIN);
15917 if (!global.use_envelope_request)
15919 CloseDoor(DOOR_CLOSE_1);
15920 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);