1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
14 #include "libgame/libgame.h"
25 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
28 // ----------------------------------------------------------------------------
29 // screen and artwork graphic pixel position definitions
30 // ----------------------------------------------------------------------------
32 // values for the control window
33 #define ED_CTRL1_BUTTONS_HORIZ 4 // toolbox
34 #define ED_CTRL1_BUTTONS_VERT 4
35 #define ED_CTRL2_BUTTONS_HORIZ 3 // level
36 #define ED_CTRL2_BUTTONS_VERT 2
37 #define ED_CTRL3_BUTTONS_HORIZ 3 // CE and GE
38 #define ED_CTRL3_BUTTONS_VERT 1
39 #define ED_CTRL4_BUTTONS_HORIZ 2 // CE and GE
40 #define ED_CTRL4_BUTTONS_VERT 1
41 #define ED_CTRL5_BUTTONS_HORIZ 1 // properties
42 #define ED_CTRL5_BUTTONS_VERT 1
43 #define ED_CTRL6_BUTTONS_HORIZ 3 // properties
44 #define ED_CTRL6_BUTTONS_VERT 1
45 #define ED_CTRL7_BUTTONS_HORIZ 1 // palette
46 #define ED_CTRL7_BUTTONS_VERT 1
48 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
49 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
50 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
51 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
52 #define ED_NUM_CTRL5_BUTTONS (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT)
53 #define ED_NUM_CTRL6_BUTTONS (ED_CTRL6_BUTTONS_HORIZ * ED_CTRL6_BUTTONS_VERT)
54 #define ED_NUM_CTRL7_BUTTONS (ED_CTRL7_BUTTONS_HORIZ * ED_CTRL7_BUTTONS_VERT)
55 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
56 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
57 #define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS)
58 #define ED_NUM_CTRL1_5_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS)
59 #define ED_NUM_CTRL1_6_BUTTONS (ED_NUM_CTRL1_5_BUTTONS + ED_NUM_CTRL6_BUTTONS)
60 #define ED_NUM_CTRL1_7_BUTTONS (ED_NUM_CTRL1_6_BUTTONS + ED_NUM_CTRL7_BUTTONS)
61 #define ED_NUM_CTRL_BUTTONS ED_NUM_CTRL1_7_BUTTONS
63 // values for the element list
64 #define ED_ELEMENTLIST_XPOS (editor.palette.x)
65 #define ED_ELEMENTLIST_YPOS (editor.palette.y)
66 #define ED_ELEMENTLIST_XSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
67 #define ED_ELEMENTLIST_YSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
68 #define ED_ELEMENTLIST_COLS MAX(1, editor.palette.cols)
69 #define ED_ELEMENTLIST_ROWS MAX(1, editor.palette.rows)
70 #define ED_ELEMENTLIST_BUTTONS_HORIZ (ED_ELEMENTLIST_COLS)
71 #define ED_ELEMENTLIST_BUTTONS_VERT (ED_ELEMENTLIST_ROWS)
72 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
73 ED_ELEMENTLIST_BUTTONS_VERT)
76 #define ED_GADGET_NORMAL_DISTANCE (editor.gadget.normal_spacing)
77 #define ED_GADGET_SMALL_DISTANCE (editor.gadget.small_spacing)
78 #define ED_GADGET_TINY_DISTANCE (editor.gadget.tiny_spacing)
79 #define ED_GADGET_LINE_DISTANCE (editor.gadget.line_spacing)
80 #define ED_GADGET_TEXT_DISTANCE (editor.gadget.text_spacing)
81 #define ED_TAB_BAR_HEIGHT (editor.gadget.separator_line.height)
82 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
83 ED_DRAWINGAREA_BORDER_SIZE)
84 #define ED_GADGET_SPACE_DISTANCE (getFontWidth(FONT_TEXT_1))
86 // values for drawingarea gadgets
87 #define IMG_BORDER_1 IMG_EDITOR_ELEMENT_BORDER
88 #define IMG_BORDER_2 IMG_EDITOR_ELEMENT_BORDER_INPUT
89 #define ED_ELEMENT_BORDER (graphic_info[IMG_BORDER_1].border_size)
90 #define ED_DRAWINGAREA_BORDER_SIZE (graphic_info[IMG_BORDER_2].border_size)
91 #define ED_DRAWINGAREA_TILE_SIZE (editor.drawingarea.tile_size)
93 // values for checkbutton gadgets
94 #define ED_CHECKBUTTON_XSIZE (graphic_info[IMG_EDITOR_CHECKBOX].width)
95 #define ED_CHECKBUTTON_YSIZE (graphic_info[IMG_EDITOR_CHECKBOX].height)
97 #define ED_TABBUTTON_XSIZE (graphic_info[IMG_EDITOR_TABBUTTON].width)
98 #define ED_TABBUTTON_YSIZE (graphic_info[IMG_EDITOR_TABBUTTON].height)
100 #define ED_SETTINGS_LEVEL_TABS_X (editor.settings.tabs.x)
101 #define ED_SETTINGS_LEVEL_TABS_Y (editor.settings.tabs.y)
102 #define ED_SETTINGS_ELEMENT_TABS_X (editor.settings.tabs.x)
103 #define ED_SETTINGS_ELEMENT_TABS_Y (editor.settings.tabs.y + \
104 editor.settings.tabs.yoffset2)
106 #define ED_SETTINGS_TABS_XOFFSET (editor.settings.tabs.draw_xoffset)
107 #define ED_SETTINGS_TABS_YOFFSET (editor.settings.tabs.draw_yoffset)
109 #define ED_LEVEL_TABS_XSTART (ED_SETTINGS_LEVEL_TABS_X)
110 #define ED_LEVEL_TABS_YSTART (ED_SETTINGS_LEVEL_TABS_Y)
111 #define ED_LEVEL_SETTINGS_XSTART (ED_SETTINGS_LEVEL_TABS_X + \
112 ED_SETTINGS_TABS_XOFFSET)
113 #define ED_LEVEL_SETTINGS_YSTART (ED_SETTINGS_LEVEL_TABS_Y + \
114 ED_TABBUTTON_YSIZE + \
115 ED_GADGET_TINY_DISTANCE + \
116 ED_TAB_BAR_HEIGHT + \
117 ED_SETTINGS_TABS_YOFFSET + \
118 getFontHeight(FONT_TEXT_1) + \
119 ED_GADGET_TEXT_DISTANCE)
120 #define ED_ELEMENT_TABS_XSTART (ED_SETTINGS_ELEMENT_TABS_X)
121 #define ED_ELEMENT_TABS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y)
122 #define ED_ELEMENT_SETTINGS_XSTART (ED_SETTINGS_ELEMENT_TABS_X + \
123 ED_SETTINGS_TABS_XOFFSET)
124 #define ED_ELEMENT_SETTINGS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y + \
125 ED_TABBUTTON_YSIZE + \
126 ED_GADGET_TINY_DISTANCE + \
127 ED_TAB_BAR_HEIGHT + \
128 ED_SETTINGS_TABS_YOFFSET)
130 #define ED_SETTINGS_XOFFSET (ED_CHECKBUTTON_XSIZE + \
131 ED_GADGET_TEXT_DISTANCE)
132 #define ED_SETTINGS_YOFFSET (ED_CHECKBUTTON_YSIZE + \
133 ED_GADGET_LINE_DISTANCE)
135 #define ED_POS_RANGE (10000)
136 #define ED_POS_LEVEL_TABS_FIRST (1 * ED_POS_RANGE)
137 #define ED_POS_LEVEL_TABS_LAST (2 * ED_POS_RANGE - 1)
138 #define ED_POS_LEVEL_SETTINGS_FIRST (2 * ED_POS_RANGE)
139 #define ED_POS_LEVEL_SETTINGS_LAST (3 * ED_POS_RANGE - 1)
140 #define ED_POS_ELEMENT_TABS_FIRST (3 * ED_POS_RANGE)
141 #define ED_POS_ELEMENT_TABS_LAST (4 * ED_POS_RANGE - 1)
142 #define ED_POS_ELEMENT_SETTINGS_FIRST (4 * ED_POS_RANGE)
143 #define ED_POS_ELEMENT_SETTINGS_LAST (5 * ED_POS_RANGE - 1)
145 #define ED_LEVEL_TABS_XPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
146 #define ED_LEVEL_TABS_YPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
148 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
149 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
151 #define ED_ELEMENT_TABS_XPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
152 #define ED_ELEMENT_TABS_YPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
154 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
155 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
157 #define IS_POS_LEVEL_TABS(n) ((n) >= ED_POS_LEVEL_TABS_FIRST && \
158 (n) <= ED_POS_LEVEL_TABS_LAST)
159 #define IS_POS_LEVEL_SETTINGS(n) ((n) >= ED_POS_LEVEL_SETTINGS_FIRST && \
160 (n) <= ED_POS_LEVEL_SETTINGS_LAST)
161 #define IS_POS_ELEMENT_TABS(n) ((n) >= ED_POS_ELEMENT_TABS_FIRST && \
162 (n) <= ED_POS_ELEMENT_TABS_LAST)
163 #define IS_POS_ELEMENT_SETTINGS(n) ((n) >= ED_POS_ELEMENT_SETTINGS_FIRST && \
164 (n) <= ED_POS_ELEMENT_SETTINGS_LAST)
166 #define ED_LEVEL_TABS_LINE(n) ((n) - ED_POS_LEVEL_TABS_FIRST)
167 #define ED_LEVEL_SETTINGS_LINE(n) ((n) - ED_POS_LEVEL_SETTINGS_FIRST)
168 #define ED_ELEMENT_TABS_LINE(n) ((n) - ED_POS_ELEMENT_TABS_FIRST)
169 #define ED_ELEMENT_SETTINGS_LINE(n) ((n) - ED_POS_ELEMENT_SETTINGS_FIRST)
171 #define ED_LEVEL_TABS_X(n) (ED_LEVEL_TABS_XSTART + \
172 (n) * ED_SETTINGS_TABS_XOFFSET)
173 #define ED_LEVEL_TABS_Y(n) (ED_LEVEL_TABS_YSTART + \
174 (n) * ED_SETTINGS_TABS_YOFFSET)
176 #define ED_LEVEL_SETTINGS_X(n) (ED_LEVEL_SETTINGS_XSTART + \
177 (n) * ED_SETTINGS_XOFFSET)
178 #define ED_LEVEL_SETTINGS_Y(n) (ED_LEVEL_SETTINGS_YSTART + \
179 (n) * ED_SETTINGS_YOFFSET)
181 #define ED_ELEMENT_TABS_X(n) (ED_ELEMENT_TABS_XSTART + \
182 (n) * ED_SETTINGS_TABS_XOFFSET)
183 #define ED_ELEMENT_TABS_Y(n) (ED_ELEMENT_TABS_YSTART + \
184 (n) * ED_SETTINGS_TABS_YOFFSET)
186 #define ED_ELEMENT_SETTINGS_X(n) (ED_ELEMENT_SETTINGS_XSTART + \
187 (n) * ED_SETTINGS_XOFFSET)
188 #define ED_ELEMENT_SETTINGS_Y(n) (ED_ELEMENT_SETTINGS_YSTART + \
189 (n) * ED_SETTINGS_YOFFSET)
191 #define ED_POS_TO_LEVEL_TABS_X(n) \
192 (ED_LEVEL_TABS_X(ED_LEVEL_TABS_LINE(n)))
193 #define ED_POS_TO_LEVEL_TABS_Y(n) \
194 (ED_LEVEL_TABS_Y(ED_LEVEL_TABS_LINE(n)))
196 #define ED_POS_TO_LEVEL_SETTINGS_X(n) \
197 (ED_LEVEL_SETTINGS_X(ED_LEVEL_SETTINGS_LINE(n)))
198 #define ED_POS_TO_LEVEL_SETTINGS_Y(n) \
199 (ED_LEVEL_SETTINGS_Y(ED_LEVEL_SETTINGS_LINE(n)))
201 #define ED_POS_TO_ELEMENT_TABS_X(n) \
202 (ED_ELEMENT_TABS_X(ED_ELEMENT_TABS_LINE(n)))
203 #define ED_POS_TO_ELEMENT_TABS_Y(n) \
204 (ED_ELEMENT_TABS_Y(ED_ELEMENT_TABS_LINE(n)))
206 #define ED_POS_TO_ELEMENT_SETTINGS_X(n) \
207 (ED_ELEMENT_SETTINGS_X(ED_ELEMENT_SETTINGS_LINE(n)))
208 #define ED_POS_TO_ELEMENT_SETTINGS_Y(n) \
209 (ED_ELEMENT_SETTINGS_Y(ED_ELEMENT_SETTINGS_LINE(n)))
211 #define ED_SETTINGS_X(n) (IS_POS_LEVEL_TABS(n) ? \
212 ED_POS_TO_LEVEL_TABS_X(n) : \
213 IS_POS_LEVEL_SETTINGS(n) ? \
214 ED_POS_TO_LEVEL_SETTINGS_X(n) : \
215 IS_POS_ELEMENT_TABS(n) ? \
216 ED_POS_TO_ELEMENT_TABS_X(n) : \
217 IS_POS_ELEMENT_SETTINGS(n) ? \
218 ED_POS_TO_ELEMENT_SETTINGS_X(n) : (n))
219 #define ED_SETTINGS_Y(n) (IS_POS_LEVEL_TABS(n) ? \
220 ED_POS_TO_LEVEL_TABS_Y(n) : \
221 IS_POS_LEVEL_SETTINGS(n) ? \
222 ED_POS_TO_LEVEL_SETTINGS_Y(n) : \
223 IS_POS_ELEMENT_TABS(n) ? \
224 ED_POS_TO_ELEMENT_TABS_Y(n) : \
225 IS_POS_ELEMENT_SETTINGS(n) ? \
226 ED_POS_TO_ELEMENT_SETTINGS_Y(n) : (n))
228 #define ED_SETTINGS_XOFF(n) (5 * ((n) % 4) * \
229 ED_DRAWINGAREA_TILE_SIZE)
230 #define ED_SETTINGS_YOFF(n) (5 * ((n) / 4) * \
231 ED_DRAWINGAREA_TILE_SIZE)
233 #define ED_AREA_XOFFSET_1(n) ((n) != 0 ? \
234 ED_DRAWINGAREA_BORDER_SIZE : 0)
235 #define ED_AREA_YOFFSET_1(n) ((n) != 0 ? \
236 (ED_CHECKBUTTON_YSIZE - \
237 ED_DRAWINGAREA_TILE_SIZE) / 2 : 0)
239 #define ED_AREA_XOFFSET_2(n) (0)
240 #define ED_AREA_YOFFSET_2(n) ((n) == 3 ? \
241 ((n) - 1) * ED_DRAWINGAREA_TILE_SIZE / 2 : 0)
243 #define ED_AREA_SETTINGS_X(i) (ED_SETTINGS_X((i).x) + \
244 ED_SETTINGS_XOFF((i).xoffset) + \
245 ED_AREA_XOFFSET_1((i).x) - \
246 ED_AREA_XOFFSET_2((i).area_xsize))
247 #define ED_AREA_SETTINGS_Y(i) (ED_SETTINGS_Y((i).y) + \
248 ED_SETTINGS_YOFF((i).yoffset) + \
249 ED_AREA_YOFFSET_1((i).y) - \
250 ED_AREA_YOFFSET_2((i).area_ysize))
252 // values for element content drawing areas
253 #define ED_AREA_1X1_LSETTINGS_XPOS(n) ED_LEVEL_SETTINGS_XPOS(n)
254 #define ED_AREA_1X1_LSETTINGS_YPOS(n) ED_LEVEL_SETTINGS_YPOS(n)
255 #define ED_AREA_1X1_LSETTINGS_XOFF (0)
256 #define ED_AREA_1X1_LSETTINGS_YOFF (0)
258 #define ED_AREA_1X1_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
259 #define ED_AREA_1X1_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
260 #define ED_AREA_1X1_SETTINGS_XOFF (0)
261 #define ED_AREA_1X1_SETTINGS_YOFF (0)
263 #define ED_AREA_3X3_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
264 #define ED_AREA_3X3_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
265 #define ED_AREA_3X3_SETTINGS_XOFF (0)
266 #define ED_AREA_3X3_SETTINGS_YOFF (0)
269 #define ED_AREA_ELEMENT_CONTENT_XOFF(n) (n)
270 #define ED_AREA_ELEMENT_CONTENT_YOFF(n) (n)
273 #define ED_XPOS_YAM 0
274 #define ED_YPOS_YAM 5
275 #define ED_AREA_YAMYAM_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_YAM)
276 #define ED_AREA_YAMYAM_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_YAM)
277 #define ED_AREA_YAMYAM_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
278 #define ED_AREA_YAMYAM_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
279 #define ED_AREA_YAMYAM_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_YAM) + \
281 #define ED_AREA_YAMYAM_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_YAM) + \
282 ED_SETTINGS_YOFF(n) + \
283 ED_AREA_YOFFSET_1(ED_YPOS_YAM) - \
284 ED_AREA_YOFFSET_2(3))
286 // magic ball content
287 #define ED_XPOS_BALL 0
288 #define ED_YPOS_BALL 6
289 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_BALL)
290 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_BALL)
291 #define ED_AREA_MAGIC_BALL_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
292 #define ED_AREA_MAGIC_BALL_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
293 #define ED_AREA_MAGIC_BALL_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_BALL) + \
295 #define ED_AREA_MAGIC_BALL_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_BALL) + \
296 ED_SETTINGS_YOFF(n) + \
297 ED_AREA_YOFFSET_1(ED_YPOS_BALL) - \
298 ED_AREA_YOFFSET_2(3))
300 // values for scrolling gadgets for drawing area
301 #define ED_SCROLLBUTTON_XSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].width)
302 #define ED_SCROLLBUTTON_YSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].height)
304 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
305 #define ED_SCROLL_UP_YPOS (0)
306 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
307 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
308 #define ED_SCROLL_LEFT_XPOS (0)
309 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
310 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
311 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
312 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
313 ED_SCROLLBUTTON_XSIZE)
314 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
315 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
316 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
317 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
318 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
319 ED_SCROLLBUTTON_YSIZE)
320 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
321 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
323 // values for scrolling gadgets for element list
324 #define ED_SCROLLBUTTON2_XSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
325 #define ED_SCROLLBUTTON2_YSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
327 #define ED_SCROLL2_UP_XPOS (ED_ELEMENTLIST_XPOS + \
328 ED_ELEMENTLIST_BUTTONS_HORIZ * \
329 ED_ELEMENTLIST_XSIZE)
330 #define ED_SCROLL2_UP_YPOS ED_ELEMENTLIST_YPOS
331 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
332 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
333 ED_ELEMENTLIST_BUTTONS_VERT * \
334 ED_ELEMENTLIST_YSIZE - \
335 ED_SCROLLBUTTON2_YSIZE)
336 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
337 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
338 ED_SCROLLBUTTON2_YSIZE)
339 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
340 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
341 ED_ELEMENTLIST_YSIZE - \
342 2 * ED_SCROLLBUTTON2_YSIZE)
344 // values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText()
345 #define INFOTEXT_FONT FONT_TEXT_2
346 #define INFOTEXT_XSIZE SXSIZE
347 #define INFOTEXT_YSIZE getFontHeight(INFOTEXT_FONT)
348 #define INFOTEXT_YSIZE_FULL (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE)
349 #define INFOTEXT_X (editor.settings.tooltip.x)
350 #define INFOTEXT_Y (editor.settings.tooltip.y)
351 #define INFOTEXT_XY_REDEFINED (INFOTEXT_X != -1 || INFOTEXT_Y != -1)
352 #define INFOTEXT_XPOS SX + (INFOTEXT_XY_REDEFINED ? INFOTEXT_X : 0)
353 #define INFOTEXT_YPOS SY + (INFOTEXT_XY_REDEFINED ? INFOTEXT_Y : \
354 SYSIZE - INFOTEXT_YSIZE)
357 // ----------------------------------------------------------------------------
358 // editor gadget definitions
359 // ----------------------------------------------------------------------------
365 // drawing toolbox buttons
367 GADGET_ID_SINGLE_ITEMS,
368 GADGET_ID_CONNECTED_ITEMS,
372 GADGET_ID_FILLED_BOX,
375 GADGET_ID_FLOOD_FILL,
378 GADGET_ID_WRAP_RIGHT,
379 GADGET_ID_RANDOM_PLACEMENT,
380 GADGET_ID_GRAB_BRUSH,
382 GADGET_ID_PICK_ELEMENT,
391 GADGET_ID_CUSTOM_COPY_FROM,
392 GADGET_ID_CUSTOM_COPY_TO,
393 GADGET_ID_CUSTOM_EXCHANGE,
394 GADGET_ID_CUSTOM_COPY,
395 GADGET_ID_CUSTOM_PASTE,
397 GADGET_ID_PROPERTIES,
398 GADGET_ID_ELEMENT_LEFT,
399 GADGET_ID_ELEMENT_MIDDLE,
400 GADGET_ID_ELEMENT_RIGHT,
403 // counter gadget identifiers
405 GADGET_ID_SELECT_LEVEL_DOWN,
406 GADGET_ID_SELECT_LEVEL_TEXT,
407 GADGET_ID_SELECT_LEVEL_UP,
408 GADGET_ID_LEVEL_XSIZE_DOWN,
409 GADGET_ID_LEVEL_XSIZE_TEXT,
410 GADGET_ID_LEVEL_XSIZE_UP,
411 GADGET_ID_LEVEL_YSIZE_DOWN,
412 GADGET_ID_LEVEL_YSIZE_TEXT,
413 GADGET_ID_LEVEL_YSIZE_UP,
414 GADGET_ID_LEVEL_RANDOM_DOWN,
415 GADGET_ID_LEVEL_RANDOM_TEXT,
416 GADGET_ID_LEVEL_RANDOM_UP,
417 GADGET_ID_LEVEL_GEMSLIMIT_DOWN,
418 GADGET_ID_LEVEL_GEMSLIMIT_TEXT,
419 GADGET_ID_LEVEL_GEMSLIMIT_UP,
420 GADGET_ID_LEVEL_TIMELIMIT_DOWN,
421 GADGET_ID_LEVEL_TIMELIMIT_TEXT,
422 GADGET_ID_LEVEL_TIMELIMIT_UP,
423 GADGET_ID_LEVEL_TIMESCORE_DOWN,
424 GADGET_ID_LEVEL_TIMESCORE_TEXT,
425 GADGET_ID_LEVEL_TIMESCORE_UP,
426 GADGET_ID_LEVEL_RANDOM_SEED_DOWN,
427 GADGET_ID_LEVEL_RANDOM_SEED_TEXT,
428 GADGET_ID_LEVEL_RANDOM_SEED_UP,
429 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN,
430 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT,
431 GADGET_ID_LEVELSET_NUM_LEVELS_UP,
432 GADGET_ID_BD_CYCLE_DELAY_MS_DOWN,
433 GADGET_ID_BD_CYCLE_DELAY_MS_TEXT,
434 GADGET_ID_BD_CYCLE_DELAY_MS_UP,
435 GADGET_ID_BD_CYCLE_DELAY_C64_DOWN,
436 GADGET_ID_BD_CYCLE_DELAY_C64_TEXT,
437 GADGET_ID_BD_CYCLE_DELAY_C64_UP,
438 GADGET_ID_BD_HATCHING_DELAY_CYCLES_DOWN,
439 GADGET_ID_BD_HATCHING_DELAY_CYCLES_TEXT,
440 GADGET_ID_BD_HATCHING_DELAY_CYCLES_UP,
441 GADGET_ID_BD_HATCHING_DELAY_SECONDS_DOWN,
442 GADGET_ID_BD_HATCHING_DELAY_SECONDS_TEXT,
443 GADGET_ID_BD_HATCHING_DELAY_SECONDS_UP,
444 GADGET_ID_BD_PUSHING_PROB_DOWN,
445 GADGET_ID_BD_PUSHING_PROB_TEXT,
446 GADGET_ID_BD_PUSHING_PROB_UP,
447 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_DOWN,
448 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_TEXT,
449 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_UP,
450 GADGET_ID_ELEMENT_VALUE1_DOWN,
451 GADGET_ID_ELEMENT_VALUE1_TEXT,
452 GADGET_ID_ELEMENT_VALUE1_UP,
453 GADGET_ID_ELEMENT_VALUE2_DOWN,
454 GADGET_ID_ELEMENT_VALUE2_TEXT,
455 GADGET_ID_ELEMENT_VALUE2_UP,
456 GADGET_ID_ELEMENT_VALUE3_DOWN,
457 GADGET_ID_ELEMENT_VALUE3_TEXT,
458 GADGET_ID_ELEMENT_VALUE3_UP,
459 GADGET_ID_ELEMENT_VALUE4_DOWN,
460 GADGET_ID_ELEMENT_VALUE4_TEXT,
461 GADGET_ID_ELEMENT_VALUE4_UP,
462 GADGET_ID_YAMYAM_CONTENT_DOWN,
463 GADGET_ID_YAMYAM_CONTENT_TEXT,
464 GADGET_ID_YAMYAM_CONTENT_UP,
465 GADGET_ID_BALL_CONTENT_DOWN,
466 GADGET_ID_BALL_CONTENT_TEXT,
467 GADGET_ID_BALL_CONTENT_UP,
468 GADGET_ID_ANDROID_CONTENT_DOWN,
469 GADGET_ID_ANDROID_CONTENT_TEXT,
470 GADGET_ID_ANDROID_CONTENT_UP,
471 GADGET_ID_ENVELOPE_XSIZE_DOWN,
472 GADGET_ID_ENVELOPE_XSIZE_TEXT,
473 GADGET_ID_ENVELOPE_XSIZE_UP,
474 GADGET_ID_ENVELOPE_YSIZE_DOWN,
475 GADGET_ID_ENVELOPE_YSIZE_TEXT,
476 GADGET_ID_ENVELOPE_YSIZE_UP,
477 GADGET_ID_INVENTORY_SIZE_DOWN,
478 GADGET_ID_INVENTORY_SIZE_TEXT,
479 GADGET_ID_INVENTORY_SIZE_UP,
480 GADGET_ID_MM_BALL_CONTENT_DOWN,
481 GADGET_ID_MM_BALL_CONTENT_TEXT,
482 GADGET_ID_MM_BALL_CONTENT_UP,
483 GADGET_ID_CUSTOM_SCORE_DOWN,
484 GADGET_ID_CUSTOM_SCORE_TEXT,
485 GADGET_ID_CUSTOM_SCORE_UP,
486 GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
487 GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
488 GADGET_ID_CUSTOM_GEMCOUNT_UP,
489 GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
490 GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
491 GADGET_ID_CUSTOM_VALUE_FIX_UP,
492 GADGET_ID_CUSTOM_VALUE_RND_DOWN,
493 GADGET_ID_CUSTOM_VALUE_RND_TEXT,
494 GADGET_ID_CUSTOM_VALUE_RND_UP,
495 GADGET_ID_PUSH_DELAY_FIX_DOWN,
496 GADGET_ID_PUSH_DELAY_FIX_TEXT,
497 GADGET_ID_PUSH_DELAY_FIX_UP,
498 GADGET_ID_PUSH_DELAY_RND_DOWN,
499 GADGET_ID_PUSH_DELAY_RND_TEXT,
500 GADGET_ID_PUSH_DELAY_RND_UP,
501 GADGET_ID_DROP_DELAY_FIX_DOWN,
502 GADGET_ID_DROP_DELAY_FIX_TEXT,
503 GADGET_ID_DROP_DELAY_FIX_UP,
504 GADGET_ID_DROP_DELAY_RND_DOWN,
505 GADGET_ID_DROP_DELAY_RND_TEXT,
506 GADGET_ID_DROP_DELAY_RND_UP,
507 GADGET_ID_MOVE_DELAY_FIX_DOWN,
508 GADGET_ID_MOVE_DELAY_FIX_TEXT,
509 GADGET_ID_MOVE_DELAY_FIX_UP,
510 GADGET_ID_MOVE_DELAY_RND_DOWN,
511 GADGET_ID_MOVE_DELAY_RND_TEXT,
512 GADGET_ID_MOVE_DELAY_RND_UP,
513 GADGET_ID_STEP_DELAY_FIX_DOWN,
514 GADGET_ID_STEP_DELAY_FIX_TEXT,
515 GADGET_ID_STEP_DELAY_FIX_UP,
516 GADGET_ID_STEP_DELAY_RND_DOWN,
517 GADGET_ID_STEP_DELAY_RND_TEXT,
518 GADGET_ID_STEP_DELAY_RND_UP,
519 GADGET_ID_EXPLOSION_DELAY_DOWN,
520 GADGET_ID_EXPLOSION_DELAY_TEXT,
521 GADGET_ID_EXPLOSION_DELAY_UP,
522 GADGET_ID_IGNITION_DELAY_DOWN,
523 GADGET_ID_IGNITION_DELAY_TEXT,
524 GADGET_ID_IGNITION_DELAY_UP,
525 GADGET_ID_CHANGE_DELAY_FIX_DOWN,
526 GADGET_ID_CHANGE_DELAY_FIX_TEXT,
527 GADGET_ID_CHANGE_DELAY_FIX_UP,
528 GADGET_ID_CHANGE_DELAY_RND_DOWN,
529 GADGET_ID_CHANGE_DELAY_RND_TEXT,
530 GADGET_ID_CHANGE_DELAY_RND_UP,
531 GADGET_ID_CHANGE_CONT_RND_DOWN,
532 GADGET_ID_CHANGE_CONT_RND_TEXT,
533 GADGET_ID_CHANGE_CONT_RND_UP,
534 GADGET_ID_GROUP_CONTENT_DOWN,
535 GADGET_ID_GROUP_CONTENT_TEXT,
536 GADGET_ID_GROUP_CONTENT_UP,
538 // drawing area identifiers
540 GADGET_ID_DRAWING_LEVEL,
541 GADGET_ID_YAMYAM_CONTENT_0,
542 GADGET_ID_YAMYAM_CONTENT_1,
543 GADGET_ID_YAMYAM_CONTENT_2,
544 GADGET_ID_YAMYAM_CONTENT_3,
545 GADGET_ID_YAMYAM_CONTENT_4,
546 GADGET_ID_YAMYAM_CONTENT_5,
547 GADGET_ID_YAMYAM_CONTENT_6,
548 GADGET_ID_YAMYAM_CONTENT_7,
549 GADGET_ID_MAGIC_BALL_CONTENT_0,
550 GADGET_ID_MAGIC_BALL_CONTENT_1,
551 GADGET_ID_MAGIC_BALL_CONTENT_2,
552 GADGET_ID_MAGIC_BALL_CONTENT_3,
553 GADGET_ID_MAGIC_BALL_CONTENT_4,
554 GADGET_ID_MAGIC_BALL_CONTENT_5,
555 GADGET_ID_MAGIC_BALL_CONTENT_6,
556 GADGET_ID_MAGIC_BALL_CONTENT_7,
557 GADGET_ID_ANDROID_CONTENT,
558 GADGET_ID_AMOEBA_CONTENT,
559 GADGET_ID_START_ELEMENT,
560 GADGET_ID_ARTWORK_ELEMENT,
561 GADGET_ID_EXPLOSION_ELEMENT,
562 GADGET_ID_INVENTORY_CONTENT,
563 GADGET_ID_MM_BALL_CONTENT,
564 GADGET_ID_CUSTOM_GRAPHIC,
565 GADGET_ID_CUSTOM_CONTENT,
566 GADGET_ID_CUSTOM_MOVE_ENTER,
567 GADGET_ID_CUSTOM_MOVE_LEAVE,
568 GADGET_ID_CUSTOM_CHANGE_TARGET,
569 GADGET_ID_CUSTOM_CHANGE_CONTENT,
570 GADGET_ID_CUSTOM_CHANGE_TRIGGER,
571 GADGET_ID_CUSTOM_CHANGE_ACTION,
572 GADGET_ID_GROUP_CONTENT,
573 GADGET_ID_RANDOM_BACKGROUND,
575 // text input identifiers
577 GADGET_ID_LEVEL_NAME,
578 GADGET_ID_LEVEL_AUTHOR,
579 GADGET_ID_LEVELSET_NAME,
580 GADGET_ID_LEVELSET_AUTHOR,
581 GADGET_ID_ELEMENT_NAME,
583 // text area identifiers
585 GADGET_ID_ENVELOPE_INFO,
587 // selectbox identifiers
589 GADGET_ID_TIME_OR_STEPS,
590 GADGET_ID_TIME_SCORE_BASE,
591 GADGET_ID_GAME_ENGINE_TYPE,
592 GADGET_ID_BD_SCHEDULING_TYPE,
593 GADGET_ID_LEVELSET_SAVE_MODE,
594 GADGET_ID_WIND_DIRECTION,
595 GADGET_ID_PLAYER_SPEED,
596 GADGET_ID_MM_BALL_CHOICE_MODE,
597 GADGET_ID_CUSTOM_WALK_TO_ACTION,
598 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
599 GADGET_ID_CUSTOM_DEADLINESS,
600 GADGET_ID_CUSTOM_MOVE_PATTERN,
601 GADGET_ID_CUSTOM_MOVE_DIRECTION,
602 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
603 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
604 GADGET_ID_CUSTOM_SMASH_TARGETS,
605 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
606 GADGET_ID_CUSTOM_ACCESS_TYPE,
607 GADGET_ID_CUSTOM_ACCESS_LAYER,
608 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
609 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
610 GADGET_ID_CHANGE_TIME_UNITS,
611 GADGET_ID_CHANGE_DIRECT_ACTION,
612 GADGET_ID_CHANGE_OTHER_ACTION,
613 GADGET_ID_CHANGE_SIDE,
614 GADGET_ID_CHANGE_PLAYER,
615 GADGET_ID_CHANGE_PAGE,
616 GADGET_ID_CHANGE_REPLACE_WHEN,
617 GADGET_ID_ACTION_TYPE,
618 GADGET_ID_ACTION_MODE,
619 GADGET_ID_ACTION_ARG,
620 GADGET_ID_SELECT_CHANGE_PAGE,
621 GADGET_ID_GROUP_CHOICE_MODE,
623 // textbutton identifiers
625 GADGET_ID_LEVELCONFIG_LEVEL,
626 GADGET_ID_LEVELCONFIG_LEVELSET,
627 GADGET_ID_LEVELCONFIG_EDITOR,
628 GADGET_ID_LEVELCONFIG_ENGINE,
629 GADGET_ID_PROPERTIES_INFO,
630 GADGET_ID_PROPERTIES_CONFIG,
631 GADGET_ID_PROPERTIES_CONFIG_1,
632 GADGET_ID_PROPERTIES_CONFIG_2,
633 GADGET_ID_PROPERTIES_CHANGE,
634 GADGET_ID_SAVE_AS_TEMPLATE_1,
635 GADGET_ID_SAVE_AS_TEMPLATE_2,
636 GADGET_ID_SAVE_LEVELSET,
637 GADGET_ID_ADD_CHANGE_PAGE,
638 GADGET_ID_DEL_CHANGE_PAGE,
640 // graphicbutton identifiers
642 GADGET_ID_PREV_CHANGE_PAGE,
643 GADGET_ID_NEXT_CHANGE_PAGE,
644 GADGET_ID_COPY_CHANGE_PAGE,
645 GADGET_ID_PASTE_CHANGE_PAGE,
647 // gadgets for scrolling of drawing area
650 GADGET_ID_SCROLL_DOWN,
651 GADGET_ID_SCROLL_LEFT,
652 GADGET_ID_SCROLL_RIGHT,
653 GADGET_ID_SCROLL_HORIZONTAL,
654 GADGET_ID_SCROLL_VERTICAL,
656 // gadgets for scrolling element list
658 GADGET_ID_SCROLL_LIST_UP,
659 GADGET_ID_SCROLL_LIST_DOWN,
660 GADGET_ID_SCROLL_LIST_VERTICAL,
662 // checkbuttons/radiobuttons for level/element properties
664 GADGET_ID_AUTO_COUNT_GEMS,
665 GADGET_ID_RATE_TIME_OVER_SCORE,
666 GADGET_ID_USE_LEVELSET_ARTWORK,
667 GADGET_ID_COPY_LEVEL_TEMPLATE,
668 GADGET_ID_RANDOM_PERCENTAGE,
669 GADGET_ID_RANDOM_QUANTITY,
670 GADGET_ID_RANDOM_RESTRICTED,
671 GADGET_ID_BD_INTERMISSION,
672 GADGET_ID_BD_PAL_TIMING,
673 GADGET_ID_BD_LINE_SHIFTING_BORDERS,
674 GADGET_ID_BD_SCAN_FIRST_AND_LAST_ROW,
675 GADGET_ID_BD_SHORT_EXPLOSIONS,
676 GADGET_ID_BD_GRAVITY_AFFECTS_ALL,
677 GADGET_ID_STICK_ELEMENT,
678 GADGET_ID_EM_SLIPPERY_GEMS,
679 GADGET_ID_EM_EXPLODES_BY_FIRE,
680 GADGET_ID_USE_SPRING_BUG,
681 GADGET_ID_USE_TIME_ORB_BUG,
682 GADGET_ID_USE_LIFE_BUGS,
683 GADGET_ID_RANDOM_BALL_CONTENT,
684 GADGET_ID_INITIAL_BALL_ACTIVE,
685 GADGET_ID_GROW_INTO_DIGGABLE,
686 GADGET_ID_SB_FIELDS_NEEDED,
687 GADGET_ID_SB_OBJECTS_NEEDED,
688 GADGET_ID_AUTO_EXIT_SOKOBAN,
689 GADGET_ID_SOLVED_BY_ONE_PLAYER,
690 GADGET_ID_FINISH_DIG_COLLECT,
691 GADGET_ID_KEEP_WALKABLE_CE,
692 GADGET_ID_CONTINUOUS_SNAPPING,
693 GADGET_ID_BLOCK_SNAP_FIELD,
694 GADGET_ID_BLOCK_LAST_FIELD,
695 GADGET_ID_SP_BLOCK_LAST_FIELD,
696 GADGET_ID_INSTANT_RELOCATION,
697 GADGET_ID_SHIFTED_RELOCATION,
698 GADGET_ID_LAZY_RELOCATION,
699 GADGET_ID_USE_START_ELEMENT,
700 GADGET_ID_USE_ARTWORK_ELEMENT,
701 GADGET_ID_USE_EXPLOSION_ELEMENT,
702 GADGET_ID_INITIAL_GRAVITY,
703 GADGET_ID_USE_INITIAL_INVENTORY,
704 GADGET_ID_CAN_PASS_TO_WALKABLE,
705 GADGET_ID_CAN_FALL_INTO_ACID,
706 GADGET_ID_CAN_MOVE_INTO_ACID,
707 GADGET_ID_DONT_COLLIDE_WITH,
708 GADGET_ID_BD_DIAGONAL_MOVEMENTS,
709 GADGET_ID_BD_TOPMOST_PLAYER_ACTIVE,
710 GADGET_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET,
711 GADGET_ID_ENVELOPE_AUTOWRAP,
712 GADGET_ID_ENVELOPE_CENTERED,
713 GADGET_ID_MM_LASER_RED,
714 GADGET_ID_MM_LASER_GREEN,
715 GADGET_ID_MM_LASER_BLUE,
716 GADGET_ID_DF_LASER_RED,
717 GADGET_ID_DF_LASER_GREEN,
718 GADGET_ID_DF_LASER_BLUE,
719 GADGET_ID_ROTATE_MM_BALL_CONTENT,
720 GADGET_ID_EXPLODE_MM_BALL,
721 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
722 GADGET_ID_CUSTOM_CAN_EXPLODE,
723 GADGET_ID_CUSTOM_EXPLODE_FIRE,
724 GADGET_ID_CUSTOM_EXPLODE_SMASH,
725 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
726 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
727 GADGET_ID_CUSTOM_DEADLY,
728 GADGET_ID_CUSTOM_CAN_MOVE,
729 GADGET_ID_CUSTOM_CAN_FALL,
730 GADGET_ID_CUSTOM_CAN_SMASH,
731 GADGET_ID_CUSTOM_SLIPPERY,
732 GADGET_ID_CUSTOM_ACCESSIBLE,
733 GADGET_ID_CUSTOM_GRAV_REACHABLE,
734 GADGET_ID_CUSTOM_USE_LAST_VALUE,
735 GADGET_ID_CUSTOM_USE_GRAPHIC,
736 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
737 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
738 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
739 GADGET_ID_CUSTOM_CAN_CHANGE,
740 GADGET_ID_CHANGE_USE_CONTENT,
741 GADGET_ID_CHANGE_USE_EXPLOSION,
742 GADGET_ID_CHANGE_ONLY_COMPLETE,
743 GADGET_ID_CHANGE_USE_RANDOM,
744 GADGET_ID_CHANGE_HAS_ACTION,
745 GADGET_ID_CHANGE_DELAY,
746 GADGET_ID_CHANGE_BY_DIRECT_ACT,
747 GADGET_ID_CHANGE_BY_OTHER_ACT,
749 NUM_STATIC_GADGET_IDS
752 // gadgets for buttons in element list (dynamic)
753 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
754 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
755 ED_NUM_ELEMENTLIST_BUTTONS - 1)
757 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
759 // radio button numbers
763 RADIO_NR_DRAWING_TOOLBOX,
764 RADIO_NR_RANDOM_ELEMENTS
767 // values for counter gadgets
770 ED_COUNTER_ID_SELECT_LEVEL,
771 ED_COUNTER_ID_LEVEL_XSIZE,
772 ED_COUNTER_ID_LEVEL_YSIZE,
773 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
774 ED_COUNTER_ID_LEVEL_TIMELIMIT,
775 ED_COUNTER_ID_LEVEL_TIMESCORE,
776 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
777 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
778 ED_COUNTER_ID_LEVEL_RANDOM,
779 ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
780 ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
781 ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES,
782 ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS,
783 ED_COUNTER_ID_BD_PUSHING_PROB,
784 ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET,
785 ED_COUNTER_ID_ELEMENT_VALUE1,
786 ED_COUNTER_ID_ELEMENT_VALUE2,
787 ED_COUNTER_ID_ELEMENT_VALUE3,
788 ED_COUNTER_ID_ELEMENT_VALUE4,
789 ED_COUNTER_ID_YAMYAM_CONTENT,
790 ED_COUNTER_ID_BALL_CONTENT,
791 ED_COUNTER_ID_ANDROID_CONTENT,
792 ED_COUNTER_ID_ENVELOPE_XSIZE,
793 ED_COUNTER_ID_ENVELOPE_YSIZE,
794 ED_COUNTER_ID_INVENTORY_SIZE,
795 ED_COUNTER_ID_MM_BALL_CONTENT,
796 ED_COUNTER_ID_CUSTOM_SCORE,
797 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
798 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
799 ED_COUNTER_ID_CUSTOM_VALUE_RND,
800 ED_COUNTER_ID_PUSH_DELAY_FIX,
801 ED_COUNTER_ID_PUSH_DELAY_RND,
802 ED_COUNTER_ID_DROP_DELAY_FIX,
803 ED_COUNTER_ID_DROP_DELAY_RND,
804 ED_COUNTER_ID_MOVE_DELAY_FIX,
805 ED_COUNTER_ID_MOVE_DELAY_RND,
806 ED_COUNTER_ID_STEP_DELAY_FIX,
807 ED_COUNTER_ID_STEP_DELAY_RND,
808 ED_COUNTER_ID_EXPLOSION_DELAY,
809 ED_COUNTER_ID_IGNITION_DELAY,
810 ED_COUNTER_ID_GROUP_CONTENT,
811 ED_COUNTER_ID_CHANGE_DELAY_FIX,
812 ED_COUNTER_ID_CHANGE_DELAY_RND,
813 ED_COUNTER_ID_CHANGE_CONT_RND,
815 ED_NUM_COUNTERBUTTONS
818 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
819 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
820 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
821 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
822 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
823 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
825 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
826 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
827 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
828 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
829 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
830 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
832 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
833 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
835 // values for scrollbutton gadgets
838 ED_SCROLLBUTTON_ID_AREA_UP,
839 ED_SCROLLBUTTON_ID_AREA_DOWN,
840 ED_SCROLLBUTTON_ID_AREA_LEFT,
841 ED_SCROLLBUTTON_ID_AREA_RIGHT,
842 ED_SCROLLBUTTON_ID_LIST_UP,
843 ED_SCROLLBUTTON_ID_LIST_DOWN,
848 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
849 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
851 // values for scrollbar gadgets
854 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
855 ED_SCROLLBAR_ID_AREA_VERTICAL,
856 ED_SCROLLBAR_ID_LIST_VERTICAL,
861 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
862 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
864 // values for text input gadgets
867 ED_TEXTINPUT_ID_LEVEL_NAME,
868 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
869 ED_TEXTINPUT_ID_LEVELSET_NAME,
870 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
871 ED_TEXTINPUT_ID_ELEMENT_NAME,
876 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
877 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
879 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
880 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
882 // values for text area gadgets
885 ED_TEXTAREA_ID_ENVELOPE_INFO,
890 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
891 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
893 // values for selectbox gadgets
896 ED_SELECTBOX_ID_TIME_OR_STEPS,
897 ED_SELECTBOX_ID_TIME_SCORE_BASE,
898 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
899 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
900 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
901 ED_SELECTBOX_ID_WIND_DIRECTION,
902 ED_SELECTBOX_ID_PLAYER_SPEED,
903 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
904 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
905 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
906 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
907 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
908 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
909 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
910 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
911 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
912 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
913 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
914 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
915 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
916 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
917 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
918 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
919 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
920 ED_SELECTBOX_ID_CHANGE_SIDE,
921 ED_SELECTBOX_ID_CHANGE_PLAYER,
922 ED_SELECTBOX_ID_CHANGE_PAGE,
923 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
924 ED_SELECTBOX_ID_ACTION_TYPE,
925 ED_SELECTBOX_ID_ACTION_MODE,
926 ED_SELECTBOX_ID_ACTION_ARG,
927 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
928 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
933 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
934 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
936 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
937 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
939 #define ED_SELECTBOX_ID_ENGINE_FIRST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
940 #define ED_SELECTBOX_ID_ENGINE_LAST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE
942 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
943 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
944 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
945 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
946 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
947 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
949 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
950 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
952 // values for textbutton gadgets
955 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
956 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
957 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
958 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
959 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
960 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
961 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
962 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
963 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
964 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
965 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
966 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
967 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
968 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
973 #define ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
974 #define ED_TAB_BUTTON_ID_LEVELCONFIG_LAST ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
976 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
977 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
979 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
980 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
982 // values for graphicbutton gadgets
985 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
986 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
987 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
988 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
990 ED_NUM_GRAPHICBUTTONS
993 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
994 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
996 // values for checkbutton gadgets
999 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
1000 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
1001 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
1002 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
1003 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
1004 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
1005 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
1006 ED_CHECKBUTTON_ID_BD_INTERMISSION,
1007 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
1008 ED_CHECKBUTTON_ID_BD_LINE_SHIFTING_BORDERS,
1009 ED_CHECKBUTTON_ID_BD_SCAN_FIRST_AND_LAST_ROW,
1010 ED_CHECKBUTTON_ID_BD_SHORT_EXPLOSIONS,
1011 ED_CHECKBUTTON_ID_BD_GRAVITY_AFFECTS_ALL,
1012 ED_CHECKBUTTON_ID_STICK_ELEMENT,
1013 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
1014 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
1015 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
1016 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
1017 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
1018 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
1019 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
1020 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
1021 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
1022 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
1023 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
1024 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
1025 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
1026 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
1027 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
1028 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
1029 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
1030 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
1031 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
1032 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
1033 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
1034 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
1035 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
1036 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
1037 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
1038 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
1039 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
1040 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
1041 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
1042 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
1043 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
1044 ED_CHECKBUTTON_ID_BD_TOPMOST_PLAYER_ACTIVE,
1045 ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET,
1046 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
1047 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
1048 ED_CHECKBUTTON_ID_MM_LASER_RED,
1049 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
1050 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1051 ED_CHECKBUTTON_ID_DF_LASER_RED,
1052 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1053 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1054 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
1055 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
1056 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1057 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1058 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1059 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1060 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1061 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1062 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1063 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1064 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1065 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1066 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1067 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1068 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1069 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1070 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1071 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1072 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1073 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1074 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1075 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1076 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1077 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1078 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1079 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1080 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1085 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1086 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1088 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1089 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1091 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1092 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1094 #define ED_CHECKBUTTON_ID_ENGINE_FIRST ED_CHECKBUTTON_ID_BD_INTERMISSION
1095 #define ED_CHECKBUTTON_ID_ENGINE_LAST ED_CHECKBUTTON_ID_BD_GRAVITY_AFFECTS_ALL
1097 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1098 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1099 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1100 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1101 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1102 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1104 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1105 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1107 // values for radiobutton gadgets
1110 ED_RADIOBUTTON_ID_PERCENTAGE,
1111 ED_RADIOBUTTON_ID_QUANTITY,
1116 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1117 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1119 // values for drawing area gadgets
1122 ED_DRAWING_ID_DRAWING_LEVEL,
1123 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1124 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1125 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1126 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1127 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1128 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1129 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1130 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1131 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1132 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1133 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1134 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1135 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1136 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1137 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1138 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1139 ED_DRAWING_ID_ANDROID_CONTENT,
1140 ED_DRAWING_ID_AMOEBA_CONTENT,
1141 ED_DRAWING_ID_START_ELEMENT,
1142 ED_DRAWING_ID_ARTWORK_ELEMENT,
1143 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1144 ED_DRAWING_ID_INVENTORY_CONTENT,
1145 ED_DRAWING_ID_MM_BALL_CONTENT,
1146 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1147 ED_DRAWING_ID_CUSTOM_CONTENT,
1148 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1149 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1150 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1151 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1152 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1153 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1154 ED_DRAWING_ID_GROUP_CONTENT,
1155 ED_DRAWING_ID_RANDOM_BACKGROUND,
1157 ED_NUM_DRAWING_AREAS
1160 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1161 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1164 // ----------------------------------------------------------------------------
1165 // some internally used definitions
1166 // ----------------------------------------------------------------------------
1168 // values for CopyLevelToUndoBuffer()
1169 #define UNDO_IMMEDIATE 0
1170 #define UNDO_ACCUMULATE 1
1172 // values for scrollbars
1173 #define ED_SCROLL_NO 0
1174 #define ED_SCROLL_LEFT 1
1175 #define ED_SCROLL_RIGHT 2
1176 #define ED_SCROLL_UP 4
1177 #define ED_SCROLL_DOWN 8
1179 // screens in the level editor
1180 #define ED_MODE_DRAWING 0
1181 #define ED_MODE_LEVELCONFIG 1
1182 #define ED_MODE_PROPERTIES 2
1183 #define ED_MODE_PALETTE 3
1185 // sub-screens in the global settings section
1186 #define ED_MODE_LEVELCONFIG_LEVEL ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
1187 #define ED_MODE_LEVELCONFIG_LEVELSET ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET
1188 #define ED_MODE_LEVELCONFIG_EDITOR ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
1189 #define ED_MODE_LEVELCONFIG_ENGINE ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
1191 // sub-screens in the element properties section
1192 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1193 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1194 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1195 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1196 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1198 // how many steps can be cancelled
1199 #define NUM_UNDO_STEPS (64 + 1)
1201 // values for elements with score for certain actions
1203 #define MAX_SCORE 999
1205 // values for elements with count for collecting
1206 #define MIN_COLLECT_COUNT 0
1207 #define MAX_COLLECT_COUNT 999
1209 // values for random placement
1210 #define RANDOM_USE_PERCENTAGE 0
1211 #define RANDOM_USE_QUANTITY 1
1213 // values for level set save mode
1214 #define LEVELSET_SAVE_MODE_UPDATE 0
1215 #define LEVELSET_SAVE_MODE_CREATE 1
1217 // default value for element tile size in drawing area
1218 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1219 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1222 // ----------------------------------------------------------------------------
1223 // some internally used data structure definitions
1224 // ----------------------------------------------------------------------------
1230 struct XYTileSize *pos;
1234 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1236 // note: some additional characters are already reserved for "cheat mode"
1237 // shortcuts (":XYZ" style) -- for details, see "events.c"
1239 // ---------- toolbox control buttons ---------------------------------------
1242 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1243 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1244 "draw single items", 's'
1247 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1248 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1249 "draw connected items", 'd'
1252 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1253 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1257 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1258 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1262 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1263 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1264 "draw outline rectangles", 'r'
1267 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1268 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1269 "draw filled rectangles", 'R'
1272 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1273 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1274 "wrap (rotate) level up", 0
1277 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1278 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1279 "enter text elements", 't'
1282 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1283 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1287 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1288 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1289 "wrap (rotate) level left", 0
1292 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1293 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1294 "zoom level tile size", '+'
1297 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1298 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1299 "wrap (rotate) level right", 0
1302 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1303 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1304 "random element placement", 0
1307 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1308 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1312 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1313 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1314 "wrap (rotate) level down", 0
1317 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1318 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1319 "pick drawing element", ','
1322 // ---------- level control buttons -----------------------------------------
1325 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1326 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1327 "undo/redo last operation", 'u'
1330 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_CONF,
1331 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1332 "level and editor settings", 'I'
1335 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1336 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1340 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1341 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1345 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1346 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1350 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1351 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1352 "exit level editor", 'E'
1355 // ---------- CE and GE control buttons -------------------------------------
1358 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1359 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1360 "copy settings from other element", 0
1363 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1364 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1365 "copy settings to other element", 0
1368 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1369 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1370 "exchange element with other element", 0
1373 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1374 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1375 "copy settings from this element", 0
1378 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1379 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1380 "paste settings to this element", 0
1383 // ---------- palette control buttons ---------------------------------------
1386 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1387 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1388 "properties of drawing element", 'p'
1391 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1392 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1393 "properties of drawing element 1", '1'
1396 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1397 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1398 "properties of drawing element 2", '2'
1401 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1402 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1403 "properties of drawing element 3", '3'
1406 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1407 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1408 "show list of elements", 'e'
1412 static int random_placement_value = 10;
1413 static int random_placement_method = RANDOM_USE_QUANTITY;
1414 static int random_placement_background_element = EL_SAND;
1415 static boolean random_placement_background_restricted = FALSE;
1416 static boolean stick_element_properties_window = FALSE;
1417 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1418 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1419 static struct ElementChangeInfo custom_element_change;
1420 static struct ElementGroupInfo group_element_info;
1421 static struct ElementInfo custom_element;
1423 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1424 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1425 static int levelset_num_levels = 100;
1426 static boolean levelset_use_levelset_artwork = FALSE;
1427 static boolean levelset_copy_level_template = FALSE;
1428 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1434 int min_value, max_value;
1435 int gadget_id_down, gadget_id_up;
1437 int gadget_id_align;
1439 char *text_above, *text_left, *text_right;
1440 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1442 // ---------- current level number ------------------------------------------
1445 ED_COUNTER_ID_SELECT_LEVEL,
1446 -1, -1, // these values are not constant, but can change at runtime
1448 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1449 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1454 // ---------- level and editor settings -------------------------------------
1457 ED_COUNTER_ID_LEVEL_XSIZE,
1458 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1459 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1460 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1461 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1463 "playfield size:", NULL, "width",
1466 ED_COUNTER_ID_LEVEL_YSIZE,
1467 -1, ED_LEVEL_SETTINGS_YPOS(4),
1468 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1469 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1470 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1472 NULL, " ", "height",
1475 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
1476 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1478 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1479 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1481 NULL, "number of gems to collect:", NULL
1484 ED_COUNTER_ID_LEVEL_TIMELIMIT,
1485 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1487 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1488 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1490 "time or step limit to solve level:", NULL, NULL
1493 ED_COUNTER_ID_LEVEL_TIMESCORE,
1494 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1496 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1497 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1498 &level.score[SC_TIME_BONUS],
1499 "score for time or steps left:", NULL, NULL
1502 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
1503 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1505 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1506 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1508 NULL, "random seed:", "(0 => random)"
1511 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
1512 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1514 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1515 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1516 &levelset_num_levels,
1517 "number of levels:", NULL, NULL,
1520 ED_COUNTER_ID_LEVEL_RANDOM,
1521 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1523 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1524 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1525 &random_placement_value,
1526 "random element placement:", NULL, "in"
1529 ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
1530 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3),
1532 GADGET_ID_BD_CYCLE_DELAY_MS_DOWN, GADGET_ID_BD_CYCLE_DELAY_MS_UP,
1533 GADGET_ID_BD_CYCLE_DELAY_MS_TEXT, GADGET_ID_NONE,
1534 &level.bd_cycle_delay_ms,
1535 NULL, NULL, "game cycle delay (ms)"
1538 ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
1539 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3),
1541 GADGET_ID_BD_CYCLE_DELAY_C64_DOWN, GADGET_ID_BD_CYCLE_DELAY_C64_UP,
1542 GADGET_ID_BD_CYCLE_DELAY_C64_TEXT, GADGET_ID_NONE,
1543 &level.bd_cycle_delay_c64,
1544 NULL, NULL, "game cycle delay (C64-style)"
1547 ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES,
1548 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1550 GADGET_ID_BD_HATCHING_DELAY_CYCLES_DOWN, GADGET_ID_BD_HATCHING_DELAY_CYCLES_UP,
1551 GADGET_ID_BD_HATCHING_DELAY_CYCLES_TEXT, GADGET_ID_NONE,
1552 &level.bd_hatching_delay_cycles,
1553 NULL, NULL, "hatching delay (cycles)"
1556 ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS,
1557 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1559 GADGET_ID_BD_HATCHING_DELAY_SECONDS_DOWN, GADGET_ID_BD_HATCHING_DELAY_SECONDS_UP,
1560 GADGET_ID_BD_HATCHING_DELAY_SECONDS_TEXT, GADGET_ID_NONE,
1561 &level.bd_hatching_delay_seconds,
1562 NULL, NULL, "hatching delay (seconds)"
1565 // ---------- element settings: configure (various elements) ----------------
1568 ED_COUNTER_ID_BD_PUSHING_PROB,
1569 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1571 GADGET_ID_BD_PUSHING_PROB_DOWN, GADGET_ID_BD_PUSHING_PROB_UP,
1572 GADGET_ID_BD_PUSHING_PROB_TEXT, GADGET_ID_NONE,
1573 &level.bd_pushing_prob,
1574 NULL, NULL, "probability to push rocks"
1577 ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET,
1578 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1580 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_DOWN, GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_UP,
1581 GADGET_ID_BD_PUSHING_PROB_WITH_SWEET_TEXT, GADGET_ID_NONE,
1582 &level.bd_pushing_prob_with_sweet,
1583 NULL, NULL, "as above, after eating sweet"
1586 ED_COUNTER_ID_ELEMENT_VALUE1,
1587 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1588 MIN_SCORE, MAX_SCORE,
1589 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1590 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1591 NULL, // will be set when used
1595 ED_COUNTER_ID_ELEMENT_VALUE2,
1596 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1597 MIN_SCORE, MAX_SCORE,
1598 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1599 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1600 NULL, // will be set when used
1604 ED_COUNTER_ID_ELEMENT_VALUE3,
1605 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1606 MIN_SCORE, MAX_SCORE,
1607 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1608 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1609 NULL, // will be set when used
1613 ED_COUNTER_ID_ELEMENT_VALUE4,
1614 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1615 MIN_SCORE, MAX_SCORE,
1616 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1617 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1618 NULL, // will be set when used
1622 ED_COUNTER_ID_YAMYAM_CONTENT,
1623 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1624 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1625 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1626 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1627 &level.num_yamyam_contents,
1628 NULL, NULL, "number of content areas"
1631 ED_COUNTER_ID_BALL_CONTENT,
1632 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1633 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1634 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1635 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1636 &level.num_ball_contents,
1637 NULL, NULL, "number of content areas"
1640 ED_COUNTER_ID_ANDROID_CONTENT,
1641 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1642 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1643 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1644 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1645 &level.num_android_clone_elements,
1646 NULL, NULL, "number of clonable elements"
1649 ED_COUNTER_ID_ENVELOPE_XSIZE,
1650 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1651 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1652 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1653 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1654 NULL, // will be set when used
1655 NULL, NULL, "width",
1658 ED_COUNTER_ID_ENVELOPE_YSIZE,
1659 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1660 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1661 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1662 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1663 NULL, // will be set when used
1664 NULL, " ", "height",
1667 ED_COUNTER_ID_INVENTORY_SIZE,
1668 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1669 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1670 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1671 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1672 &level.initial_inventory_size[0],
1673 NULL, NULL, "number of inventory elements"
1676 ED_COUNTER_ID_MM_BALL_CONTENT,
1677 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1678 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1679 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1680 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1681 &level.num_mm_ball_contents,
1682 NULL, NULL, "number of content elements"
1685 // ---------- element settings: configure 1 (custom elements) ---------------
1688 ED_COUNTER_ID_CUSTOM_SCORE,
1689 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1690 MIN_SCORE, MAX_SCORE,
1691 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1692 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1693 &custom_element.collect_score_initial,
1694 NULL, "CE score", " "
1697 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
1698 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1699 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1700 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1701 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1702 &custom_element.collect_count_initial,
1703 NULL, "CE count", NULL
1706 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
1707 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1709 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1710 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1711 &custom_element.ce_value_fixed_initial,
1712 NULL, "CE value", NULL
1715 ED_COUNTER_ID_CUSTOM_VALUE_RND,
1716 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1718 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1719 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1720 &custom_element.ce_value_random_initial,
1721 NULL, "+random", NULL
1724 ED_COUNTER_ID_PUSH_DELAY_FIX,
1725 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1727 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1728 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1729 &custom_element.push_delay_fixed,
1730 NULL, "push delay", NULL
1733 ED_COUNTER_ID_PUSH_DELAY_RND,
1734 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1736 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1737 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1738 &custom_element.push_delay_random,
1739 NULL, "+random", NULL
1742 ED_COUNTER_ID_DROP_DELAY_FIX,
1743 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1745 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1746 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1747 &custom_element.drop_delay_fixed,
1748 NULL, "drop delay", NULL
1751 ED_COUNTER_ID_DROP_DELAY_RND,
1752 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1754 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1755 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1756 &custom_element.drop_delay_random,
1757 NULL, "+random", NULL
1760 // ---------- element settings: configure 2 (custom elements) ---------------
1763 ED_COUNTER_ID_MOVE_DELAY_FIX,
1764 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1766 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1767 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1768 &custom_element.move_delay_fixed,
1769 NULL, "move delay", NULL
1772 ED_COUNTER_ID_MOVE_DELAY_RND,
1773 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1775 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1776 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1777 &custom_element.move_delay_random,
1778 NULL, "+random", NULL
1781 ED_COUNTER_ID_STEP_DELAY_FIX,
1782 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1784 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1785 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1786 &custom_element.step_delay_fixed,
1787 NULL, "step delay", NULL
1790 ED_COUNTER_ID_STEP_DELAY_RND,
1791 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1793 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1794 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1795 &custom_element.step_delay_random,
1796 NULL, "+random", NULL
1799 ED_COUNTER_ID_EXPLOSION_DELAY,
1800 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1802 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1803 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1804 &custom_element.explosion_delay,
1805 NULL, "explosion delay", NULL
1808 ED_COUNTER_ID_IGNITION_DELAY,
1809 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1811 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1812 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1813 &custom_element.ignition_delay,
1814 NULL, "ignition delay", "(by fire)"
1817 // ---------- element settings: configure (group elements) ------------------
1820 ED_COUNTER_ID_GROUP_CONTENT,
1821 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1822 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1823 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1824 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1825 &group_element_info.num_elements,
1826 NULL, NULL, "number of elements in group"
1829 // ---------- element settings: advanced (custom elements) ------------------
1832 ED_COUNTER_ID_CHANGE_DELAY_FIX,
1833 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1835 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1836 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1837 &custom_element_change.delay_fixed,
1838 NULL, "CE delay", NULL,
1841 ED_COUNTER_ID_CHANGE_DELAY_RND,
1842 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1844 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1845 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1846 &custom_element_change.delay_random,
1847 NULL, "+random", NULL
1850 ED_COUNTER_ID_CHANGE_CONT_RND,
1851 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1853 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1854 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1855 &custom_element_change.random_percentage,
1856 NULL, "use random replace:", "%"
1867 char *text_above, *infotext;
1868 } textinput_info[ED_NUM_TEXTINPUT] =
1871 ED_TEXTINPUT_ID_LEVEL_NAME,
1872 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1873 GADGET_ID_LEVEL_NAME,
1876 "Title:", "Title for this level"
1879 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
1880 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1881 GADGET_ID_LEVEL_AUTHOR,
1882 MAX_LEVEL_AUTHOR_LEN,
1884 "Author:", "Author for this level"
1887 ED_TEXTINPUT_ID_LEVELSET_NAME,
1888 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1889 GADGET_ID_LEVELSET_NAME,
1892 "Title:", "Title for this or new level set"
1895 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
1896 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1897 GADGET_ID_LEVELSET_AUTHOR,
1898 MAX_LEVEL_AUTHOR_LEN,
1900 "Author:", "Author for this or new level set"
1903 ED_TEXTINPUT_ID_ELEMENT_NAME,
1904 -1, -1, // these values are not constant, but can change at runtime
1905 GADGET_ID_ELEMENT_NAME,
1906 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1907 custom_element.description,
1908 NULL, "Element name"
1919 char *text_above, *text_above_cropped, *infotext;
1920 } textarea_info[ED_NUM_TEXTAREAS] =
1923 ED_TEXTAREA_ID_ENVELOPE_INFO,
1924 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1925 GADGET_ID_ENVELOPE_INFO,
1926 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1928 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1932 static struct ValueTextInfo options_time_or_steps[] =
1940 static struct ValueTextInfo options_time_score_base[] =
1942 { 1, "per second/step" },
1943 { 10, "per 10 seconds/steps" },
1948 static struct ValueTextInfo options_game_engine_type[] =
1950 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1951 { GAME_ENGINE_TYPE_BD, "Boulder Dash" },
1952 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1953 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1954 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1959 static struct ValueTextInfo options_levelset_save_mode[] =
1961 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1962 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1967 static struct ValueTextInfo options_wind_direction[] =
1969 { MV_START_NONE, "none" },
1970 { MV_START_LEFT, "left" },
1971 { MV_START_RIGHT, "right" },
1972 { MV_START_UP, "up" },
1973 { MV_START_DOWN, "down" },
1978 static struct ValueTextInfo options_player_speed[] =
1985 { 16, "very fast" },
1986 { 32, "ultrafast" },
1991 static struct ValueTextInfo options_access_type[] =
1993 { EP_WALKABLE, "walkable" },
1994 { EP_PASSABLE, "passable" },
1999 static struct ValueTextInfo options_access_layer[] =
2001 { EP_ACCESSIBLE_OVER, "over" },
2002 { EP_ACCESSIBLE_INSIDE, "inside" },
2003 { EP_ACCESSIBLE_UNDER, "under" },
2008 static struct ValueTextInfo options_access_protected[] =
2010 { 0, "unprotected" },
2016 static struct ValueTextInfo options_access_direction[] =
2018 { MV_NO_DIRECTION, "no direction" },
2019 { MV_LEFT, "left" },
2020 { MV_RIGHT, "right" },
2022 { MV_DOWN, "down" },
2023 { MV_LEFT | MV_UP, "left + up" },
2024 { MV_LEFT | MV_DOWN, "left + down" },
2025 { MV_RIGHT | MV_UP, "right + up" },
2026 { MV_RIGHT | MV_DOWN, "right + down" },
2027 { MV_HORIZONTAL, "horizontal" },
2028 { MV_VERTICAL, "vertical" },
2029 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
2030 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
2031 { MV_VERTICAL | MV_LEFT, "vertical + left" },
2032 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
2033 { MV_ALL_DIRECTIONS, "all directions" },
2038 static struct ValueTextInfo options_walk_to_action[] =
2040 { EP_DIGGABLE, "diggable" },
2041 { EP_COLLECTIBLE_ONLY, "collectible" },
2042 { EP_DROPPABLE, "collectible & droppable" },
2043 { EP_THROWABLE, "collectible & throwable" },
2044 { EP_PUSHABLE, "pushable" },
2049 static struct ValueTextInfo options_move_pattern[] =
2051 { MV_LEFT, "left" },
2052 { MV_RIGHT, "right" },
2054 { MV_DOWN, "down" },
2055 { MV_HORIZONTAL, "horizontal" },
2056 { MV_VERTICAL, "vertical" },
2057 { MV_ALL_DIRECTIONS, "all directions" },
2058 { MV_WIND_DIRECTION, "wind direction" },
2059 { MV_TOWARDS_PLAYER, "towards player" },
2060 { MV_AWAY_FROM_PLAYER, "away from player" },
2061 { MV_ALONG_LEFT_SIDE, "along left side" },
2062 { MV_ALONG_RIGHT_SIDE, "along right side" },
2063 { MV_TURNING_LEFT, "turning left" },
2064 { MV_TURNING_RIGHT, "turning right" },
2065 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
2066 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
2067 { MV_TURNING_RANDOM, "turning random" },
2068 { MV_MAZE_RUNNER, "maze runner style" },
2069 { MV_MAZE_HUNTER, "maze hunter style" },
2070 { MV_WHEN_PUSHED, "when pushed" },
2071 { MV_WHEN_DROPPED, "when dropped/thrown" },
2076 static struct ValueTextInfo options_move_direction[] =
2078 { MV_START_AUTOMATIC, "automatic" },
2079 { MV_START_LEFT, "left" },
2080 { MV_START_RIGHT, "right" },
2081 { MV_START_UP, "up" },
2082 { MV_START_DOWN, "down" },
2083 { MV_START_RANDOM, "random" },
2084 { MV_START_PREVIOUS, "previous" },
2089 static struct ValueTextInfo options_move_stepsize[] =
2091 { 0, "not moving" },
2096 { 16, "very fast" },
2097 { 32, "even faster" },
2102 static struct ValueTextInfo options_move_leave_type[] =
2104 { LEAVE_TYPE_UNLIMITED, "leave behind" },
2105 { LEAVE_TYPE_LIMITED, "change it to" },
2110 static struct ValueTextInfo options_smash_targets[] =
2112 { EP_CAN_SMASH_PLAYER, "player" },
2114 { EP_CAN_SMASH_ENEMIES, "enemies" },
2116 { EP_CAN_SMASH_EVERYTHING, "everything" },
2121 static struct ValueTextInfo options_slippery_type[] =
2123 { SLIPPERY_ANY_RANDOM, "random" },
2124 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
2125 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
2126 { SLIPPERY_ONLY_LEFT, "only left" },
2127 { SLIPPERY_ONLY_RIGHT, "only right" },
2132 static struct ValueTextInfo options_deadliness[] =
2134 { EP_DONT_RUN_INTO, "running into" },
2135 { EP_DONT_COLLIDE_WITH, "colliding with" },
2136 { EP_DONT_GET_HIT_BY, "getting hit by" },
2137 { EP_DONT_TOUCH, "touching" },
2142 static struct ValueTextInfo options_explosion_type[] =
2144 { EXPLODES_3X3, "3x3" },
2145 { EXPLODES_CROSS, "3+3" },
2146 { EXPLODES_1X1, "1x1" },
2151 static struct ValueTextInfo options_time_units[] =
2154 { FRAMES_PER_SECOND, "seconds" },
2159 static struct ValueTextInfo options_change_direct_action[] =
2161 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2162 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2163 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2164 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2165 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2166 { CE_ENTERED_BY_PLAYER, "entered by player" },
2167 { CE_LEFT_BY_PLAYER, "left by player" },
2168 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2169 { CE_SWITCHED, "switched" },
2170 { CE_HITTING_SOMETHING, "hitting something" },
2171 { CE_HIT_BY_SOMETHING, "hit by something" },
2173 { CE_BLOCKED, "blocked" },
2175 { CE_IMPACT, "impact (on something)" },
2176 { CE_SMASHED, "smashed (from above)" },
2178 { CE_VALUE_CHANGES, "CE value changes" },
2179 { CE_SCORE_CHANGES, "CE score changes" },
2181 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2182 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2183 { CE_UNDEFINED, " " },
2184 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2185 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2186 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2187 { CE_UNDEFINED, " " },
2188 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2189 { CE_NEXT_TO_PLAYER, "next to player" },
2194 static struct ValueTextInfo options_change_other_action[] =
2196 { CE_PLAYER_TOUCHES_X, "player touches" },
2197 { CE_PLAYER_PRESSES_X, "player presses" },
2198 { CE_PLAYER_SWITCHES_X, "player switches" },
2199 { CE_PLAYER_SNAPS_X, "player snaps" },
2200 { CE_PLAYER_PUSHES_X, "player pushes" },
2201 { CE_PLAYER_ENTERS_X, "player enters" },
2202 { CE_PLAYER_LEAVES_X, "player leaves" },
2203 { CE_PLAYER_DIGS_X, "player digs" },
2204 { CE_PLAYER_COLLECTS_X, "player collects" },
2205 { CE_PLAYER_DROPS_X, "player drops/throws" },
2206 { CE_TOUCHING_X, "touching" },
2207 { CE_HITTING_X, "hitting" },
2208 { CE_DIGGING_X, "digging" },
2209 { CE_HIT_BY_X, "hit by" },
2210 { CE_SWITCH_OF_X, "switch of" },
2211 { CE_CHANGE_OF_X, "change by page of" },
2212 { CE_EXPLOSION_OF_X, "explosion of" },
2213 { CE_MOVE_OF_X, "move of" },
2214 { CE_CREATION_OF_X, "creation of" },
2215 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2216 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2217 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2218 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2219 { CE_UNDEFINED, " " },
2220 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2221 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2222 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2223 { CE_UNDEFINED, " " },
2224 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2225 { CE_PLAYER_NEXT_TO_X, "player next to" },
2226 { CE_NEXT_TO_X, "next to" },
2231 static struct ValueTextInfo options_change_trigger_side[] =
2233 { CH_SIDE_LEFT, "left" },
2234 { CH_SIDE_RIGHT, "right" },
2235 { CH_SIDE_TOP, "top" },
2236 { CH_SIDE_BOTTOM, "bottom" },
2237 { CH_SIDE_LEFT_RIGHT, "left/right" },
2238 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2239 { CH_SIDE_ANY, "any" },
2244 static struct ValueTextInfo options_change_trigger_player[] =
2246 { CH_PLAYER_1, "1" },
2247 { CH_PLAYER_2, "2" },
2248 { CH_PLAYER_3, "3" },
2249 { CH_PLAYER_4, "4" },
2250 { CH_PLAYER_ANY, "any" },
2255 static struct ValueTextInfo options_change_trigger_page[] =
2266 { (1u << 9), "10" },
2267 { (1u << 10), "11" },
2268 { (1u << 11), "12" },
2269 { (1u << 12), "13" },
2270 { (1u << 13), "14" },
2271 { (1u << 14), "15" },
2272 { (1u << 15), "16" },
2273 { (1u << 16), "17" },
2274 { (1u << 17), "18" },
2275 { (1u << 18), "19" },
2276 { (1u << 19), "20" },
2277 { (1u << 20), "21" },
2278 { (1u << 21), "22" },
2279 { (1u << 22), "23" },
2280 { (1u << 23), "24" },
2281 { (1u << 24), "25" },
2282 { (1u << 25), "26" },
2283 { (1u << 26), "27" },
2284 { (1u << 27), "28" },
2285 { (1u << 28), "29" },
2286 { (1u << 29), "30" },
2287 { (1u << 30), "31" },
2288 { (1u << 31), "32" },
2289 { CH_PAGE_ANY, "any" },
2294 static struct ValueTextInfo options_change_replace_when[] =
2296 { CP_WHEN_EMPTY, "empty" },
2297 { CP_WHEN_WALKABLE, "walkable" },
2298 { CP_WHEN_DIGGABLE, "diggable" },
2299 { CP_WHEN_COLLECTIBLE, "collectible" },
2300 { CP_WHEN_REMOVABLE, "removable" },
2301 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2306 static struct ValueTextInfo options_action_type[] =
2308 { CA_NO_ACTION, "no action" },
2309 { CA_UNDEFINED, " " },
2310 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2311 { CA_RESTART_LEVEL, "restart level" },
2312 { CA_SHOW_ENVELOPE, "show envelope" },
2313 { CA_SET_LEVEL_TIME, "set time" },
2314 { CA_SET_LEVEL_SCORE, "set score" },
2315 { CA_SET_LEVEL_GEMS, "set gems" },
2316 { CA_SET_LEVEL_WIND, "set wind dir." },
2317 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2318 { CA_UNDEFINED, " " },
2319 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2320 { CA_MOVE_PLAYER, "move player" },
2321 { CA_MOVE_PLAYER_NEW, "move player new" },
2322 { CA_EXIT_PLAYER, "exit player" },
2323 { CA_KILL_PLAYER, "kill player" },
2324 { CA_SET_PLAYER_KEYS, "set keys" },
2325 { CA_SET_PLAYER_SPEED, "set speed" },
2326 { CA_SET_PLAYER_SHIELD, "set shield" },
2327 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2328 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2329 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2330 { CA_UNDEFINED, " " },
2331 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2332 { CA_SET_CE_VALUE, "set CE value" },
2333 { CA_SET_CE_SCORE, "set CE score" },
2334 { CA_SET_CE_ARTWORK, "set CE artwork" },
2335 { CA_UNDEFINED, " " },
2336 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2337 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2342 static struct ValueTextInfo options_action_mode_none[] =
2344 { CA_MODE_UNDEFINED, " " },
2349 static struct ValueTextInfo options_action_mode_assign[] =
2351 { CA_MODE_SET, "=" },
2356 static struct ValueTextInfo options_action_mode_add_remove[] =
2358 { CA_MODE_ADD, "+" },
2359 { CA_MODE_SUBTRACT, "-" },
2364 static struct ValueTextInfo options_action_mode_calculate[] =
2366 { CA_MODE_SET, "=" },
2367 { CA_MODE_ADD, "+" },
2368 { CA_MODE_SUBTRACT, "-" },
2369 { CA_MODE_MULTIPLY, "*" },
2370 { CA_MODE_DIVIDE, "/" },
2371 { CA_MODE_MODULO, "%" },
2376 static struct ValueTextInfo options_action_arg_none[] =
2378 { CA_ARG_UNDEFINED, " " },
2383 static struct ValueTextInfo options_action_arg_player[] =
2385 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2386 { CA_ARG_PLAYER_1, "1" },
2387 { CA_ARG_PLAYER_2, "2" },
2388 { CA_ARG_PLAYER_3, "3" },
2389 { CA_ARG_PLAYER_4, "4" },
2390 { CA_ARG_PLAYER_ANY, "any" },
2391 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2392 { CA_ARG_PLAYER_ACTION, "action ->" },
2397 static struct ValueTextInfo options_action_arg_number[] =
2399 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2406 { CA_ARG_10, "10" },
2407 { CA_ARG_100, "100" },
2408 { CA_ARG_1000, "1000" },
2409 { CA_ARG_UNDEFINED, " " },
2410 { CA_ARG_NUMBER_MIN, "min" },
2411 { CA_ARG_NUMBER_MAX, "max" },
2412 { CA_ARG_UNDEFINED, " " },
2413 { CA_ARG_NUMBER_RESET, "reset" },
2414 { CA_ARG_UNDEFINED, " " },
2415 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2416 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2417 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2418 { CA_ARG_UNDEFINED, " " },
2419 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2420 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2421 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2422 { CA_ARG_UNDEFINED, " " },
2423 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2424 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2425 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2426 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2427 { CA_ARG_UNDEFINED, " " },
2428 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2429 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2430 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2431 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2436 static struct ValueTextInfo options_action_arg_value[] =
2438 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2445 { CA_ARG_10, "10" },
2446 { CA_ARG_100, "100" },
2447 { CA_ARG_1000, "1000" },
2448 { CA_ARG_UNDEFINED, " " },
2449 { CA_ARG_NUMBER_MIN, "min" },
2450 { CA_ARG_NUMBER_MAX, "max" },
2451 { CA_ARG_UNDEFINED, " " },
2452 { CA_ARG_NUMBER_RESET, "reset" },
2453 { CA_ARG_UNDEFINED, " " },
2454 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2455 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2456 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2457 { CA_ARG_UNDEFINED, " " },
2458 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2459 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2460 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2461 { CA_ARG_UNDEFINED, " " },
2462 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2463 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2464 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2465 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2466 { CA_ARG_UNDEFINED, " " },
2467 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2468 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2469 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2470 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2471 { CA_ARG_UNDEFINED, " " },
2472 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2473 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2474 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2475 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2480 static struct ValueTextInfo options_action_arg_envelope[] =
2482 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2487 { CA_ARG_UNDEFINED, " " },
2488 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2489 { CA_ARG_ELEMENT_TARGET, "target" },
2490 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2491 { CA_ARG_ELEMENT_ACTION, "action ->" },
2496 static struct ValueTextInfo options_action_arg_key[] =
2498 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2507 { CA_ARG_UNDEFINED, " " },
2508 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2509 { CA_ARG_ELEMENT_TARGET, "target" },
2510 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2511 { CA_ARG_ELEMENT_ACTION, "action ->" },
2516 static struct ValueTextInfo options_action_arg_speed[] =
2518 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2519 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2520 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2521 { CA_ARG_SPEED_SLOW, "slow" },
2522 { CA_ARG_SPEED_NORMAL, "normal" },
2523 { CA_ARG_SPEED_FAST, "fast" },
2524 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2525 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2526 { CA_ARG_UNDEFINED, " " },
2527 { CA_ARG_SPEED_SLOWER, "slower" },
2528 { CA_ARG_SPEED_FASTER, "faster" },
2529 { CA_ARG_UNDEFINED, " " },
2530 { CA_ARG_SPEED_RESET, "reset" },
2535 static struct ValueTextInfo options_action_arg_shield[] =
2537 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2538 { CA_ARG_SHIELD_OFF, "off" },
2539 { CA_ARG_SHIELD_NORMAL, "normal" },
2540 { CA_ARG_SHIELD_DEADLY, "deadly" },
2545 static struct ValueTextInfo options_action_arg_artwork[] =
2547 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2548 { CA_ARG_ELEMENT_TARGET, "target" },
2549 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2550 { CA_ARG_ELEMENT_ACTION, "action ->" },
2551 { CA_ARG_UNDEFINED, " " },
2552 { CA_ARG_ELEMENT_RESET, "reset" },
2557 static struct ValueTextInfo options_action_arg_gravity[] =
2559 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2560 { CA_ARG_GRAVITY_ON, "on" },
2561 { CA_ARG_GRAVITY_OFF, "off" },
2562 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2567 static struct ValueTextInfo options_action_arg_direction[] =
2569 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2570 { CA_ARG_DIRECTION_NONE, "none" },
2571 { CA_ARG_DIRECTION_LEFT, "left" },
2572 { CA_ARG_DIRECTION_RIGHT, "right" },
2573 { CA_ARG_DIRECTION_UP, "up" },
2574 { CA_ARG_DIRECTION_DOWN, "down" },
2575 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2576 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2581 static struct ValueTextInfo options_action_arg_scan_mode[] =
2583 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2584 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2585 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2590 static struct ValueTextInfo options_action_arg_inventory[] =
2592 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2593 { CA_ARG_ELEMENT_TARGET, "+ target" },
2594 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2595 { CA_ARG_ELEMENT_ACTION, "+ action" },
2596 { CA_ARG_UNDEFINED, " " },
2597 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2598 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2599 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2600 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2601 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2602 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2603 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2604 { CA_ARG_UNDEFINED, " " },
2605 { CA_ARG_INVENTORY_RESET, "reset" },
2610 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2611 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2616 static struct ValueTextInfo options_group_choice_mode[] =
2618 { ANIM_RANDOM, "random" },
2619 { ANIM_LOOP, "loop" },
2620 { ANIM_LINEAR, "linear" },
2621 { ANIM_PINGPONG, "pingpong" },
2622 { ANIM_PINGPONG2, "pingpong 2" },
2623 { ANIM_LEVEL_NR, "level number" },
2628 static struct ValueTextInfo options_bd_scheduling_type[] =
2630 { GD_SCHEDULING_MILLISECONDS, "Milliseconds" },
2631 { GD_SCHEDULING_BD1, "BD1" },
2632 { GD_SCHEDULING_BD2, "BD2" },
2633 { GD_SCHEDULING_PLCK, "Construction Kit" },
2634 { GD_SCHEDULING_CRDR, "Crazy Dream 7" },
2635 { GD_SCHEDULING_BD1_ATARI, "Atari BD1" },
2636 { GD_SCHEDULING_BD2_PLCK_ATARI, "Atari BD2 / PLCK" },
2641 static struct ValueTextInfo *action_arg_modes[] =
2643 options_action_mode_none,
2644 options_action_mode_assign,
2645 options_action_mode_add_remove,
2646 options_action_mode_calculate,
2653 struct ValueTextInfo *options;
2655 action_arg_options[] =
2657 { CA_NO_ACTION, 0, options_action_arg_none, },
2658 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2659 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2660 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2661 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2662 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2663 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2664 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2665 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2666 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2667 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2668 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2669 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2670 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2671 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2672 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2673 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2674 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2675 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2676 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2677 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2678 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2688 int gadget_id_align;
2689 int size; // char size of selectbox or '-1' (dynamically determined)
2690 struct ValueTextInfo *options;
2692 char *text_above, *text_left, *text_right, *infotext;
2693 } selectbox_info[ED_NUM_SELECTBOX] =
2695 // ---------- level and editor settings -------------------------------------
2698 ED_SELECTBOX_ID_TIME_OR_STEPS,
2699 -1, ED_LEVEL_SETTINGS_YPOS(8),
2700 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2702 options_time_or_steps,
2703 &level.use_step_counter,
2704 NULL, NULL, "(0 => no limit)", "time or step limit"
2707 ED_SELECTBOX_ID_TIME_SCORE_BASE,
2708 -1, ED_LEVEL_SETTINGS_YPOS(10),
2709 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2711 options_time_score_base,
2712 &level.time_score_base,
2713 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2716 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
2717 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2718 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2720 options_game_engine_type,
2721 &level.game_engine_type,
2722 NULL, "game engine:", NULL, "game engine"
2725 ED_SELECTBOX_ID_BD_SCHEDULING_TYPE,
2726 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2727 GADGET_ID_BD_SCHEDULING_TYPE, GADGET_ID_NONE,
2729 options_bd_scheduling_type,
2730 &level.bd_scheduling_type,
2731 NULL, "scheduling type:", NULL, "level timing"
2734 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
2735 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2736 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2738 options_levelset_save_mode,
2739 &levelset_save_mode,
2740 "Action:", NULL, NULL, "action when saving level set"
2743 // ---------- element settings: configure (several elements) ----------------
2746 ED_SELECTBOX_ID_WIND_DIRECTION,
2747 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2748 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2750 options_wind_direction,
2751 &level.wind_direction_initial,
2752 NULL, "initial wind direction:", NULL, "initial wind direction"
2755 ED_SELECTBOX_ID_PLAYER_SPEED,
2756 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2757 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2759 options_player_speed,
2760 &level.initial_player_stepsize[0],
2761 NULL, "initial player speed:", NULL, "initial player speed"
2764 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
2765 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2766 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2768 options_group_choice_mode,
2769 &level.mm_ball_choice_mode,
2770 NULL, "choice type:", NULL, "type of content choice"
2773 // ---------- element settings: configure 1 (custom elements) ---------------
2776 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
2777 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2778 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2780 options_access_type,
2781 &custom_element.access_type,
2782 NULL, NULL, NULL, "type of access to this field"
2785 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
2786 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2787 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2789 options_access_layer,
2790 &custom_element.access_layer,
2791 NULL, NULL, NULL, "layer of access for this field"
2794 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
2795 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2796 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2798 options_access_protected,
2799 &custom_element.access_protected,
2800 NULL, NULL, NULL, "protected access for this field"
2803 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
2804 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2805 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2807 options_access_direction,
2808 &custom_element.access_direction,
2809 NULL, "from", NULL, "access direction for this field"
2812 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
2813 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2814 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2816 options_walk_to_action,
2817 &custom_element.walk_to_action,
2818 NULL, NULL, NULL, "diggable/collectible/pushable"
2821 // ---------- element settings: configure 2 (custom elements) ---------------
2824 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
2825 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2826 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2828 options_move_pattern,
2829 &custom_element.move_pattern,
2830 NULL, "can move", NULL, "element move pattern"
2833 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
2834 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2835 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2837 options_move_direction,
2838 &custom_element.move_direction_initial,
2839 NULL, "starts moving", NULL, "initial element move direction"
2842 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
2843 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2844 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2846 options_move_stepsize,
2847 &custom_element.move_stepsize,
2848 NULL, "move/fall speed", NULL, "speed of element movement"
2851 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
2852 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2853 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2855 options_move_leave_type,
2856 &custom_element.move_leave_type,
2857 // left text with leading spaces to place gadget next to "can dig" gadget
2858 // (needed because drawing area gadgets created after selectbox gadgets)
2859 // NULL, "can dig: can", ":", "leave behind or change element"
2860 NULL, " can", ":", "leave behind or change element"
2863 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
2864 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2865 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2867 options_smash_targets,
2868 &custom_element.smash_targets,
2869 NULL, "can smash", NULL, "elements that can be smashed"
2872 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
2873 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2874 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2876 options_slippery_type,
2877 &custom_element.slippery_type,
2878 NULL, "slippery", NULL, "where other elements fall down"
2881 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
2882 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2883 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2886 &custom_element.deadliness,
2887 NULL, "deadly when", NULL, "deadliness of element"
2890 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
2891 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2892 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2894 options_explosion_type,
2895 &custom_element.explosion_type,
2896 NULL, "can explode", NULL, "explosion type"
2899 // ---------- element settings: advanced (custom elements) ------------------
2902 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
2903 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2904 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2907 &custom_element_change.delay_frames,
2908 NULL, "delay time given in", NULL, "delay time units for change"
2911 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
2912 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2913 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2915 options_change_direct_action,
2916 &custom_element_change.direct_action,
2917 NULL, NULL, NULL, "type of direct action"
2920 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
2921 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2922 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2924 options_change_other_action,
2925 &custom_element_change.other_action,
2926 NULL, NULL, "element:", "type of other element action"
2929 ED_SELECTBOX_ID_CHANGE_SIDE,
2930 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2931 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2933 options_change_trigger_side,
2934 &custom_element_change.trigger_side,
2935 NULL, "at", "side", "element side triggering change"
2938 ED_SELECTBOX_ID_CHANGE_PLAYER,
2939 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2940 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2942 options_change_trigger_player,
2943 &custom_element_change.trigger_player,
2944 NULL, "player:", " ", "player that causes change"
2947 ED_SELECTBOX_ID_CHANGE_PAGE,
2948 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2949 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2951 options_change_trigger_page,
2952 &custom_element_change.trigger_page,
2953 NULL, "page:", NULL, "change page that causes change"
2956 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
2957 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2958 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2960 options_change_replace_when,
2961 &custom_element_change.replace_when,
2962 NULL, "replace when", NULL, "which elements can be replaced"
2965 ED_SELECTBOX_ID_ACTION_TYPE,
2966 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2967 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2969 options_action_type,
2970 &custom_element_change.action_type,
2971 NULL, NULL, NULL, "action on specified condition"
2974 ED_SELECTBOX_ID_ACTION_MODE,
2975 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2976 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2978 options_action_mode_none,
2979 &custom_element_change.action_mode,
2980 NULL, NULL, NULL, "action operator"
2983 ED_SELECTBOX_ID_ACTION_ARG,
2984 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2985 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2987 options_action_arg_none,
2988 &custom_element_change.action_arg,
2989 NULL, NULL, NULL, "action parameter"
2992 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
2993 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2994 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2996 options_change_page,
2997 &custom_element.current_change_page,
2998 NULL, NULL, NULL, "element change page"
3001 // ---------- element settings: configure (group elements) ------------------
3004 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
3005 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3006 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
3008 options_group_choice_mode,
3009 &group_element_info.choice_mode,
3010 NULL, "choice type:", NULL, "type of group element choice"
3019 int gadget_id_align;
3022 char *text_above, *text_left, *text_right, *infotext;
3023 } textbutton_info[ED_NUM_TEXTBUTTONS] =
3025 // ---------- level and editor settings (tabs) ------------------------------
3028 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
3029 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
3030 GADGET_ID_LEVELCONFIG_LEVEL, GADGET_ID_NONE,
3032 NULL, NULL, NULL, "Configure level settings"
3035 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
3037 GADGET_ID_LEVELCONFIG_LEVELSET, GADGET_ID_LEVELCONFIG_LEVEL,
3039 NULL, NULL, NULL, "Update this or create new level set"
3042 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
3044 GADGET_ID_LEVELCONFIG_EDITOR, GADGET_ID_LEVELCONFIG_LEVELSET,
3046 NULL, NULL, NULL, "Configure editor settings"
3049 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
3051 GADGET_ID_LEVELCONFIG_ENGINE, GADGET_ID_LEVELCONFIG_EDITOR,
3053 NULL, NULL, NULL, "Configure engine settings"
3056 // ---------- element settings (tabs) ---------------------------------------
3059 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
3060 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
3061 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
3063 NULL, NULL, NULL, "Show information about element"
3066 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
3068 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
3070 NULL, NULL, NULL, "Configure element properties"
3073 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
3075 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
3077 NULL, NULL, NULL, "Configure element properties, part 1"
3080 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
3082 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
3084 NULL, NULL, NULL, "Configure element properties, part 2"
3087 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
3089 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
3091 NULL, NULL, NULL, "Configure custom element change pages"
3094 // ---------- level and editor settings (buttons) ---------------------------
3097 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
3098 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
3099 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
3101 NULL, NULL, NULL, "Update or create level set"
3104 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
3105 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3106 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
3108 NULL, NULL, "this level as level template",
3109 "Save current settings as new template"
3112 // ---------- element settings (buttons) ------------------------------------
3115 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
3117 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
3119 NULL, " ", "As Template",
3120 "Save current settings as new template"
3123 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
3125 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
3127 NULL, NULL, NULL, "Add new change page"
3130 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
3132 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
3134 NULL, NULL, NULL, "Delete current change page"
3144 int gadget_id_align;
3145 char *text_left, *text_right, *infotext;
3146 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
3149 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
3150 IMG_EDITOR_COUNTER_DOWN,
3151 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3152 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
3153 NULL, NULL, "select previous change page"
3156 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
3157 IMG_EDITOR_COUNTER_UP,
3158 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3159 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
3160 NULL, "change page", "select next change page"
3163 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
3164 IMG_GFX_EDITOR_BUTTON_CP_COPY,
3165 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3166 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
3167 " ", NULL, "copy settings from this change page"
3170 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
3171 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
3172 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3173 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
3174 NULL, NULL, "paste settings to this change page"
3181 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
3189 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
3192 ED_SCROLLBUTTON_ID_AREA_UP,
3193 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
3194 GADGET_ID_SCROLL_UP,
3195 "scroll level editing area up"
3198 ED_SCROLLBUTTON_ID_AREA_DOWN,
3199 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
3200 GADGET_ID_SCROLL_DOWN,
3201 "scroll level editing area down"
3204 ED_SCROLLBUTTON_ID_AREA_LEFT,
3205 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
3206 GADGET_ID_SCROLL_LEFT,
3207 "scroll level editing area left"
3210 ED_SCROLLBUTTON_ID_AREA_RIGHT,
3211 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
3212 GADGET_ID_SCROLL_RIGHT,
3213 "scroll level editing area right"
3216 ED_SCROLLBUTTON_ID_LIST_UP,
3217 IMG_EDITOR_PALETTE_SCROLL_UP,
3218 GADGET_ID_SCROLL_LIST_UP,
3219 "scroll element list up ('Page Up')"
3222 ED_SCROLLBUTTON_ID_LIST_DOWN,
3223 IMG_EDITOR_PALETTE_SCROLL_DOWN,
3224 GADGET_ID_SCROLL_LIST_DOWN,
3225 "scroll element list down ('Page Down')"
3233 int wheel_x, wheel_y;
3234 int wheel_width, wheel_height;
3235 } scrollbar_pos[ED_NUM_SCROLLBARS];
3244 } scrollbar_info[ED_NUM_SCROLLBARS] =
3247 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
3248 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3249 GD_TYPE_SCROLLBAR_HORIZONTAL,
3250 GADGET_ID_SCROLL_HORIZONTAL,
3251 "scroll level editing area horizontally"
3254 ED_SCROLLBAR_ID_AREA_VERTICAL,
3255 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3256 GD_TYPE_SCROLLBAR_VERTICAL,
3257 GADGET_ID_SCROLL_VERTICAL,
3258 "scroll level editing area vertically"
3261 ED_SCROLLBAR_ID_LIST_VERTICAL,
3262 IMG_EDITOR_PALETTE_SCROLLBAR,
3263 GD_TYPE_SCROLLBAR_VERTICAL,
3264 GADGET_ID_SCROLL_LIST_VERTICAL,
3265 "scroll element list vertically"
3275 int gadget_id_align;
3276 int radio_button_nr;
3279 char *text_left, *text_right, *infotext;
3280 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3283 ED_RADIOBUTTON_ID_PERCENTAGE,
3284 -1, ED_LEVEL_SETTINGS_YPOS(0),
3285 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3286 RADIO_NR_RANDOM_ELEMENTS,
3287 &random_placement_method, RANDOM_USE_PERCENTAGE,
3288 " ", "percentage", "use percentage for random elements"
3291 ED_RADIOBUTTON_ID_QUANTITY,
3292 -1, ED_LEVEL_SETTINGS_YPOS(0),
3293 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3294 RADIO_NR_RANDOM_ELEMENTS,
3295 &random_placement_method, RANDOM_USE_QUANTITY,
3296 " ", "quantity", "use quantity for random elements"
3305 int gadget_id_align;
3307 char *text_above, *text_left, *text_right, *infotext;
3308 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3310 // ---------- level and editor settings -------------------------------------
3313 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
3314 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3315 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3316 &level.auto_count_gems,
3318 "automatically count gems needed", "set counter to number of gems"
3321 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
3322 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3323 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3324 &level.rate_time_over_score,
3326 "rate time/steps used over score", "sort high scores by playing time/steps"
3329 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
3330 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3331 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3332 &levelset_use_levelset_artwork,
3334 "use current custom artwork", "use custom artwork of this level set"
3337 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
3338 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3339 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3340 &levelset_copy_level_template,
3342 "copy current level template", "copy level template of this level set"
3345 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
3346 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3347 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3348 &random_placement_background_restricted,
3350 "restrict random placement to:", "set random placement restriction"
3353 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
3354 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3355 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3356 &setup.editor.use_template_for_new_levels,
3357 "Template for new levels and CE/GE:", NULL,
3358 "use template for new levels", "use template for level properties"
3361 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
3362 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3363 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3364 &level.use_custom_template,
3366 "use template for custom elements", "use template for custom properties"
3369 ED_CHECKBUTTON_ID_BD_INTERMISSION,
3370 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
3371 GADGET_ID_BD_INTERMISSION, GADGET_ID_NONE,
3372 &level.bd_intermission,
3373 "Boulder Dash game engine settings:", NULL,
3374 "intermission", "level is an intermission level"
3377 ED_CHECKBUTTON_ID_BD_PAL_TIMING,
3378 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
3379 GADGET_ID_BD_PAL_TIMING, GADGET_ID_NONE,
3380 &level.bd_pal_timing,
3382 "PAL timing", "use slower timer (like PAL C64)"
3385 ED_CHECKBUTTON_ID_BD_LINE_SHIFTING_BORDERS,
3386 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3387 GADGET_ID_BD_LINE_SHIFTING_BORDERS, GADGET_ID_NONE,
3388 &level.bd_line_shifting_borders,
3389 "Compatibility settings:", NULL,
3390 "line-shifting borders", "use line-shifting wrap-around"
3393 ED_CHECKBUTTON_ID_BD_SCAN_FIRST_AND_LAST_ROW,
3394 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3395 GADGET_ID_BD_SCAN_FIRST_AND_LAST_ROW, GADGET_ID_NONE,
3396 &level.bd_scan_first_and_last_row,
3398 "scan first and last row", "also process top/bottom border rows"
3401 ED_CHECKBUTTON_ID_BD_SHORT_EXPLOSIONS,
3402 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3403 GADGET_ID_BD_SHORT_EXPLOSIONS, GADGET_ID_NONE,
3404 &level.bd_short_explosions,
3406 "short explosions", "use four game cycles for explosions"
3409 ED_CHECKBUTTON_ID_BD_GRAVITY_AFFECTS_ALL,
3410 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(9),
3411 GADGET_ID_BD_GRAVITY_AFFECTS_ALL, GADGET_ID_NONE,
3412 &level.bd_gravity_affects_all,
3414 "gravity change affects everything", "gravity affects all falling objects"
3417 // ---------- element settings: configure (various elements) ----------------
3420 ED_CHECKBUTTON_ID_STICK_ELEMENT,
3421 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3422 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3423 &stick_element_properties_window,
3425 "stick this screen to edit content","stick this screen to edit content"
3428 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
3429 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3430 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3431 &level.em_slippery_gems,
3433 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3436 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
3437 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3438 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3439 &level.em_explodes_by_fire,
3441 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3444 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
3445 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3446 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3447 &level.use_spring_bug,
3449 "use spring pushing bug", "use odd spring pushing behaviour"
3452 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
3453 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3454 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3455 &level.use_time_orb_bug,
3457 "use time orb bug", "use odd time orb behaviour"
3460 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
3461 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3462 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3463 &level.use_life_bugs,
3465 "use buggy element behaviour", "use odd (historic) element behaviour"
3468 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
3469 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3470 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3473 "create single random element", "only create one element from content"
3476 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
3477 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3478 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3479 &level.ball_active_initial,
3481 "magic ball initially activated", "activate magic ball after level start"
3484 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
3485 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3486 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3487 &level.grow_into_diggable,
3489 "can grow into anything diggable", "grow into more than just sand"
3492 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
3493 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3494 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3495 &level.sb_fields_needed,
3497 "all fields need to be filled", "require all SB fields to be solved"
3500 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
3501 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3502 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3503 &level.sb_objects_needed,
3505 "all objects need to be placed", "require all SB objects to be solved"
3508 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
3509 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3510 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3511 &level.auto_exit_sokoban,
3513 "exit level if all tasks solved", "automatically finish Sokoban levels"
3516 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
3517 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3518 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3519 &level.solved_by_one_player,
3521 "only one player must enter exit", "level solved by first player in exit"
3524 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
3525 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3526 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3527 &level.finish_dig_collect,
3529 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3532 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
3533 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3534 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3535 &level.keep_walkable_ce,
3537 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3540 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
3541 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3542 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3543 &level.continuous_snapping,
3545 "continuous snapping", "use snapping without releasing key"
3548 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
3549 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3550 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3551 &level.block_snap_field,
3553 "block snapped field when snapping", "use snapping delay to show animation"
3556 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
3557 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3558 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3559 &level.block_last_field,
3561 "block last field when moving", "player blocks last field when moving"
3564 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
3565 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3566 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3567 &level.sp_block_last_field,
3569 "block last field when moving", "player blocks last field when moving"
3572 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
3573 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3574 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3575 &level.instant_relocation,
3577 "no scrolling when relocating", "player gets relocated without delay"
3580 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
3581 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3582 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3583 &level.shifted_relocation,
3585 "no centering when relocating", "level not centered after relocation"
3588 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
3589 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3590 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3591 &level.lazy_relocation,
3593 "only redraw off-screen relocation","no redraw if relocation target visible"
3596 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
3597 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3598 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3599 &level.use_start_element[0],
3601 "use level start element:", "start level at this element's position"
3604 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
3605 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3606 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3607 &level.use_artwork_element[0],
3609 "use artwork from element:", "use player artwork from other element"
3612 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
3613 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3614 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3615 &level.use_explosion_element[0],
3617 "use explosion from element:", "use explosion properties from element"
3620 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
3621 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3622 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3623 &level.initial_player_gravity[0],
3625 "use initial gravity", "set initial player gravity"
3628 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
3629 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3630 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3631 &level.use_initial_inventory[0],
3633 "use initial inventory:", "use collected elements on level start"
3636 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
3637 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3638 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3639 &level.can_pass_to_walkable,
3641 "can pass to walkable element", "player can pass to empty or walkable"
3644 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
3645 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3646 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3647 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3649 "can fall into acid (with gravity)","player can fall into acid pool"
3652 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
3653 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3654 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3655 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3657 "can move into acid", "element can move into acid pool"
3660 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
3661 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3662 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3663 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3665 "deadly when colliding with", "element is deadly when hitting player"
3668 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
3669 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3670 GADGET_ID_BD_DIAGONAL_MOVEMENTS, GADGET_ID_NONE,
3671 &level.bd_diagonal_movements,
3673 "can move diagonally", "player can move diagonally"
3676 ED_CHECKBUTTON_ID_BD_TOPMOST_PLAYER_ACTIVE,
3677 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3678 GADGET_ID_BD_TOPMOST_PLAYER_ACTIVE, GADGET_ID_NONE,
3679 &level.bd_topmost_player_active,
3681 "topmost player is active", "use first player found on playfield"
3684 ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET,
3685 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3686 GADGET_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET, GADGET_ID_NONE,
3687 &level.bd_push_mega_rock_with_sweet,
3689 "mega rocks pushable with sweet", "push mega rocks after eating sweet"
3692 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
3693 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3694 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3695 &level.envelope[0].autowrap,
3697 "auto-wrap", "automatically wrap envelope text"
3700 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
3701 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3702 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3703 &level.envelope[0].centered,
3705 "centered", "automatically center envelope text"
3708 ED_CHECKBUTTON_ID_MM_LASER_RED,
3709 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3710 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3711 &level.mm_laser_red,
3712 "choose color components for laser:", NULL,
3713 "red", "use red color components in laser"
3716 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
3717 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3718 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3719 &level.mm_laser_green,
3721 "green", "use green color components in laser"
3724 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
3725 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3726 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3727 &level.mm_laser_blue,
3729 "blue", "use blue color components in laser"
3732 ED_CHECKBUTTON_ID_DF_LASER_RED,
3733 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3734 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3735 &level.df_laser_red,
3736 "choose color components for laser:", NULL,
3737 "red", "use red color components in laser"
3740 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
3741 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3742 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3743 &level.df_laser_green,
3745 "green", "use green color components in laser"
3748 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
3749 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3750 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3751 &level.df_laser_blue,
3753 "blue", "use blue color components in laser"
3756 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
3757 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3758 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3759 &level.rotate_mm_ball_content,
3761 "randomly rotate created content", "randomly rotate newly created content"
3764 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
3765 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3766 GADGET_ID_EXPLODE_MM_BALL, GADGET_ID_NONE,
3767 &level.explode_mm_ball,
3769 "explode ball instead of melting", "use explosion to release ball content"
3772 // ---------- element settings: configure 1 (custom elements) ---------------
3775 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
3776 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3777 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3778 &custom_element.use_gfx_element,
3780 "use graphic of element:", "use existing element graphic"
3783 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
3784 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3785 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3786 &level.use_custom_template,
3788 "use template", "use template for custom properties"
3791 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
3792 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3793 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3794 &custom_element_properties[EP_ACCESSIBLE],
3796 NULL, "player can walk to or pass this field"
3799 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
3800 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3801 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3802 &custom_element_properties[EP_GRAVITY_REACHABLE],
3804 "reachable despite gravity", "player can walk/dig despite gravity"
3807 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
3808 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3809 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3810 &custom_element.use_last_ce_value,
3812 "use last CE value after change", "use last CE value after change"
3815 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
3816 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3817 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3818 &custom_element_properties[EP_WALK_TO_OBJECT],
3820 NULL, "player can dig/collect/push element"
3823 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
3824 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3825 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3826 &custom_element_properties[EP_INDESTRUCTIBLE],
3828 "indestructible", "element is indestructible"
3831 // ---------- element settings: configure 2 (custom elements) ---------------
3834 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
3835 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3836 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3837 &custom_element_properties[EP_CAN_MOVE],
3839 NULL, "element can move with some pattern"
3842 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
3843 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3844 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3845 &custom_element_properties[EP_CAN_FALL],
3847 "can fall", "element can fall down"
3850 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
3851 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3852 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3853 &custom_element_properties[EP_CAN_SMASH],
3855 NULL, "element can smash other elements"
3858 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
3859 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3860 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3861 &custom_element_properties[EP_SLIPPERY],
3863 NULL, "other elements can fall down from it"
3866 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
3867 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3868 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3869 &custom_element_properties[EP_DEADLY],
3871 NULL, "element can kill the player"
3874 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
3875 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3876 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3877 &custom_element_properties[EP_CAN_EXPLODE],
3879 NULL, "element can explode"
3882 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
3883 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3884 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3885 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3887 "by fire", "element can explode by fire/explosion"
3890 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
3891 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3892 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3893 &custom_element_properties[EP_EXPLODES_SMASHED],
3895 "smashed", "element can explode when smashed"
3898 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
3899 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3900 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3901 &custom_element_properties[EP_EXPLODES_IMPACT],
3903 "impact", "element can explode on impact"
3906 // ---------- element settings: advanced (custom elements) ------------------
3909 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
3910 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3911 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3912 &custom_element_change.can_change,
3914 "element changes to:", "change element on specified condition"
3917 ED_CHECKBUTTON_ID_CHANGE_DELAY,
3918 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3919 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3920 &custom_element_change_events[CE_DELAY],
3922 NULL, "element changes after delay"
3925 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
3926 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3927 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3928 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3930 NULL, "element changes by direct action"
3933 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
3934 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3935 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3936 &custom_element_change_events[CE_BY_OTHER_ACTION],
3938 NULL, "element changes by other element"
3941 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
3942 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3943 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3944 &custom_element_change.explode,
3946 "explode instead of change", "element explodes instead of change"
3949 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
3950 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3951 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3952 &custom_element_change.use_target_content,
3954 "use extended change target:", "element changes to more elements"
3957 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
3958 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3959 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3960 &custom_element_change.only_if_complete,
3962 "replace all or nothing", "only replace when all can be changed"
3965 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
3966 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3967 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3968 &custom_element_change.use_random_replace,
3970 NULL, "use percentage for random replace"
3973 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
3974 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3975 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3976 &custom_element_change.has_action,
3978 NULL, "execute action on specified condition"
3986 int xoffset, yoffset;
3988 int gadget_id_align;
3990 int area_xsize, area_ysize;
3991 char *text_left, *text_right, *text_above, *text_below, *infotext;
3992 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3994 // ---------- level playfield content ---------------------------------------
3997 ED_DRAWING_ID_DRAWING_LEVEL,
4000 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
4002 -1, -1, // these values are not constant, but can change at runtime
4003 NULL, NULL, NULL, NULL, NULL
4006 // ---------- yam yam content -----------------------------------------------
4009 ED_DRAWING_ID_YAMYAM_CONTENT_0,
4010 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4011 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
4012 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
4013 &level.yamyam_content[0].e[0][0], 3, 3,
4014 NULL, NULL, NULL, "1", NULL
4017 ED_DRAWING_ID_YAMYAM_CONTENT_1,
4018 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4019 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
4020 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
4021 &level.yamyam_content[1].e[0][0], 3, 3,
4022 NULL, NULL, NULL, "2", NULL
4025 ED_DRAWING_ID_YAMYAM_CONTENT_2,
4026 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4027 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
4028 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
4029 &level.yamyam_content[2].e[0][0], 3, 3,
4030 NULL, NULL, NULL, "3", NULL
4033 ED_DRAWING_ID_YAMYAM_CONTENT_3,
4034 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4035 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
4036 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
4037 &level.yamyam_content[3].e[0][0], 3, 3,
4038 NULL, NULL, NULL, "4", NULL
4041 ED_DRAWING_ID_YAMYAM_CONTENT_4,
4042 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4043 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
4044 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
4045 &level.yamyam_content[4].e[0][0], 3, 3,
4046 NULL, NULL, NULL, "5", NULL
4049 ED_DRAWING_ID_YAMYAM_CONTENT_5,
4050 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4051 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
4052 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
4053 &level.yamyam_content[5].e[0][0], 3, 3,
4054 NULL, NULL, NULL, "6", NULL
4057 ED_DRAWING_ID_YAMYAM_CONTENT_6,
4058 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4059 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
4060 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
4061 &level.yamyam_content[6].e[0][0], 3, 3,
4062 NULL, NULL, NULL, "7", NULL
4065 ED_DRAWING_ID_YAMYAM_CONTENT_7,
4066 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
4067 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
4068 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
4069 &level.yamyam_content[7].e[0][0], 3, 3,
4070 NULL, NULL, NULL, "8", NULL
4073 // ---------- magic ball content --------------------------------------------
4076 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
4077 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4078 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
4079 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
4080 &level.ball_content[0].e[0][0], 3, 3,
4081 NULL, NULL, NULL, "1", NULL
4084 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
4085 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4086 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
4087 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
4088 &level.ball_content[1].e[0][0], 3, 3,
4089 NULL, NULL, NULL, "2", NULL
4092 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
4093 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4094 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
4095 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
4096 &level.ball_content[2].e[0][0], 3, 3,
4097 NULL, NULL, NULL, "3", NULL
4100 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
4101 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4102 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
4103 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
4104 &level.ball_content[3].e[0][0], 3, 3,
4105 NULL, NULL, NULL, "4", NULL
4108 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
4109 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4110 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
4111 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
4112 &level.ball_content[4].e[0][0], 3, 3,
4113 NULL, NULL, NULL, "5", NULL
4116 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
4117 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4118 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
4119 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
4120 &level.ball_content[5].e[0][0], 3, 3,
4121 NULL, NULL, NULL, "6", NULL
4124 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
4125 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4126 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
4127 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
4128 &level.ball_content[6].e[0][0], 3, 3,
4129 NULL, NULL, NULL, "7", NULL
4132 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
4133 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
4134 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
4135 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
4136 &level.ball_content[7].e[0][0], 3, 3,
4137 NULL, NULL, NULL, "8", NULL
4140 // ---------- android content -----------------------------------------------
4143 ED_DRAWING_ID_ANDROID_CONTENT,
4144 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
4145 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4146 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
4147 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
4148 NULL, NULL, "elements:", NULL, "elements android can clone"
4151 // ---------- amoeba content ------------------------------------------------
4154 ED_DRAWING_ID_AMOEBA_CONTENT,
4155 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
4156 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4157 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
4158 &level.amoeba_content, 1, 1,
4159 "content:", NULL, NULL, NULL, "amoeba content"
4162 // ---------- level start element -------------------------------------------
4165 ED_DRAWING_ID_START_ELEMENT,
4166 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
4167 0, ED_AREA_1X1_SETTINGS_YOFF,
4168 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
4169 &level.start_element[0], 1, 1,
4170 NULL, NULL, NULL, NULL, "level start element"
4173 // ---------- player artwork element ----------------------------------------
4176 ED_DRAWING_ID_ARTWORK_ELEMENT,
4177 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
4178 0, ED_AREA_1X1_SETTINGS_YOFF,
4179 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
4180 &level.artwork_element[0], 1, 1,
4181 NULL, NULL, NULL, NULL, "element for player artwork"
4184 // ---------- player explosion element --------------------------------------
4187 ED_DRAWING_ID_EXPLOSION_ELEMENT,
4188 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
4189 0, ED_AREA_1X1_SETTINGS_YOFF,
4190 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
4191 &level.explosion_element[0], 1, 1,
4192 NULL, NULL, NULL, NULL, "element for player explosion"
4195 // ---------- player initial inventory --------------------------------------
4198 ED_DRAWING_ID_INVENTORY_CONTENT,
4199 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4200 0, ED_AREA_1X1_SETTINGS_YOFF,
4201 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
4202 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
4203 NULL, NULL, NULL, NULL, "content for initial inventory"
4206 // ---------- gray ball content -----------------------------------------
4209 ED_DRAWING_ID_MM_BALL_CONTENT,
4210 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4211 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4212 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
4213 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
4214 "content:", NULL, NULL, NULL, "content for gray ball"
4217 // ---------- element settings: configure 1 (custom elements) ---------------
4219 // ---------- custom graphic ------------------------------------------------
4222 ED_DRAWING_ID_CUSTOM_GRAPHIC,
4223 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4224 0, ED_AREA_1X1_SETTINGS_YOFF,
4225 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
4226 &custom_element.gfx_element_initial, 1, 1,
4227 NULL, NULL, NULL, NULL, "custom graphic element"
4230 // ---------- element settings: configure 2 (custom elements) ---------------
4232 // ---------- custom content (when exploding) -------------------------------
4235 ED_DRAWING_ID_CUSTOM_CONTENT,
4236 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
4237 0, ED_AREA_3X3_SETTINGS_YOFF,
4238 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
4239 &custom_element.content.e[0][0], 3, 3,
4240 "content:", NULL, NULL, NULL, NULL
4243 // ---------- custom enter and leave element (when moving) ------------------
4246 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
4247 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
4248 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4249 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
4250 &custom_element.move_enter_element, 1, 1,
4251 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
4254 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
4255 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
4256 0, ED_AREA_1X1_SETTINGS_YOFF,
4257 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
4258 &custom_element.move_leave_element, 1, 1,
4259 NULL, NULL, NULL, NULL, "element that will be left behind"
4262 // ---------- element settings: advanced (custom elements) ------------------
4264 // ---------- custom change target ------------------------------------------
4267 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
4268 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4269 0, ED_AREA_1X1_SETTINGS_YOFF,
4270 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
4271 &custom_element_change.target_element, 1, 1,
4272 NULL, "after/when:", NULL, NULL, "new target element after change"
4275 // ---------- custom change content (extended change target) ----------------
4278 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
4279 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
4280 0, ED_AREA_3X3_SETTINGS_YOFF,
4281 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
4282 &custom_element_change.target_content.e[0][0], 3, 3,
4283 NULL, NULL, NULL, NULL, "new extended elements after change"
4286 // ---------- custom change trigger (element causing change) ----------------
4289 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
4290 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
4291 0, ED_AREA_1X1_SETTINGS_YOFF,
4292 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
4293 &custom_element_change.initial_trigger_element, 1, 1,
4294 NULL, NULL, NULL, NULL, "other element triggering change"
4297 // ---------- custom change action (element used for action) ----------------
4300 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
4301 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
4302 0, ED_AREA_1X1_SETTINGS_YOFF,
4303 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
4304 &custom_element_change.action_element, 1, 1,
4305 NULL, NULL, NULL, NULL, "element used as action parameter"
4308 // ---------- group element content -----------------------------------------
4311 ED_DRAWING_ID_GROUP_CONTENT,
4312 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4313 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4314 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
4315 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
4316 "content:", NULL, NULL, NULL, NULL
4319 // ---------- random background (for random painting) -----------------------
4322 ED_DRAWING_ID_RANDOM_BACKGROUND,
4323 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
4324 0, ED_AREA_1X1_LSETTINGS_YOFF,
4325 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
4326 &random_placement_background_element, 1, 1,
4327 NULL, NULL, NULL, NULL, "random placement background"
4332 // ----------------------------------------------------------------------------
4333 // some internally used variables
4334 // ----------------------------------------------------------------------------
4336 // maximal size of level editor drawing area
4337 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
4339 // actual size of level editor drawing area
4340 static int ed_fieldx, ed_fieldy;
4342 // actual position of level editor drawing area in level playfield
4343 static int level_xpos = -1, level_ypos = -1;
4345 // actual tile size used to display playfield drawing area
4346 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
4347 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
4349 #define IN_ED_FIELD(x, y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
4351 // drawing elements on the three mouse buttons
4352 static int new_element1 = EL_WALL;
4353 static int new_element2 = EL_EMPTY;
4354 static int new_element3 = EL_SAND;
4356 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
4357 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
4358 (button) == 2 ? new_element2 : \
4359 (button) == 3 ? new_element3 : EL_EMPTY)
4361 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
4363 static int use_permanent_palette = TRUE;
4365 #define PX (use_permanent_palette ? DX : SX)
4366 #define PY (use_permanent_palette ? DY : SY)
4367 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
4368 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
4370 // forward declaration for internal use
4371 static void CopyBrushToCursor(int, int);
4372 static void DeleteBrushFromCursor(void);
4373 static void ModifyEditorCounterValue(int, int);
4374 static void ModifyEditorCounterLimits(int, int, int);
4375 static void ModifyEditorSelectboxValue(int, int);
4376 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
4377 static void ModifyEditorDrawingArea(int, int, int);
4378 static void ModifyEditorElementList(void);
4379 static void AdjustElementListScrollbar(void);
4380 static void RedrawDrawingElements(void);
4381 static void DrawDrawingWindowExt(boolean);
4382 static void DrawDrawingWindow(void);
4383 static void DrawLevelConfigWindow(void);
4384 static void DrawPropertiesWindow(void);
4385 static void DrawPaletteWindow(void);
4386 static void UpdateCustomElementGraphicGadgets(void);
4387 static boolean checkPropertiesConfig(int);
4388 static void SetAutomaticNumberOfGemsNeeded(void);
4389 static void ClearEditorGadgetInfoText(void);
4390 static void CopyLevelToUndoBuffer(int);
4391 static void HandleDrawingAreas(struct GadgetInfo *);
4392 static void HandleCounterButtons(struct GadgetInfo *);
4393 static void HandleTextInputGadgets(struct GadgetInfo *);
4394 static void HandleTextAreaGadgets(struct GadgetInfo *);
4395 static void HandleSelectboxGadgets(struct GadgetInfo *);
4396 static void HandleTextbuttonGadgets(struct GadgetInfo *);
4397 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
4398 static void HandleRadiobuttons(struct GadgetInfo *);
4399 static void HandleCheckbuttons(struct GadgetInfo *);
4400 static void HandleControlButtons(struct GadgetInfo *);
4401 static void HandleDrawingAreaInfo(struct GadgetInfo *);
4402 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
4403 static boolean AskToCopyAndModifyLevelTemplate(void);
4404 static boolean getDrawModeHiRes(void);
4405 static int getTabulatorBarWidth(void);
4406 static int getTabulatorBarHeight(void);
4407 static Pixel getTabulatorBarColor(void);
4408 static int numHiresTiles(int);
4410 static int num_editor_gadgets = 0; // dynamically determined
4412 static struct GadgetInfo **level_editor_gadget = NULL;
4413 static int *right_gadget_border = NULL;
4415 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
4416 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
4417 static boolean draw_with_brush = FALSE;
4418 static int properties_element = 0;
4420 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4421 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4422 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4423 static int undo_buffer_position = 0;
4424 static int undo_buffer_steps = 0;
4425 static int redo_buffer_steps = 0;
4427 static int edit_mode;
4428 static int edit_mode_levelconfig;
4429 static int edit_mode_properties;
4431 static int element_shift = 0;
4433 static int editor_el_players[] =
4440 static int *editor_el_players_ptr = editor_el_players;
4441 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4443 static int editor_hl_boulderdash[] =
4445 EL_INTERNAL_CASCADE_BD_ACTIVE,
4451 static int editor_el_boulderdash[] =
4460 EL_BD_EXPANDABLE_WALL,
4468 EL_BD_BUTTERFLY_LEFT,
4470 EL_BD_BUTTERFLY_RIGHT,
4471 EL_BD_FIREFLY_RIGHT,
4474 EL_BD_BUTTERFLY_DOWN,
4478 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4479 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4480 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4481 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4483 static int editor_hl_boulderdash_native[] =
4485 EL_INTERNAL_CASCADE_BD_NATIVE_ACTIVE,
4491 static int editor_el_boulderdash_native[] =
4508 EL_BD_BUTTERFLY_LEFT,
4510 EL_BD_BUTTERFLY_RIGHT,
4511 EL_BD_FIREFLY_RIGHT,
4514 EL_BD_BUTTERFLY_DOWN,
4519 EL_BD_BUTTERFLY_2_UP,
4523 EL_BD_BUTTERFLY_2_LEFT,
4524 EL_BD_FIREFLY_2_LEFT,
4525 EL_BD_BUTTERFLY_2_RIGHT,
4526 EL_BD_FIREFLY_2_RIGHT,
4529 EL_BD_BUTTERFLY_2_DOWN,
4530 EL_BD_FIREFLY_2_DOWN,
4538 EL_BD_DRAGONFLY_LEFT,
4539 EL_BD_STONEFLY_LEFT,
4540 EL_BD_DRAGONFLY_RIGHT,
4541 EL_BD_STONEFLY_RIGHT,
4544 EL_BD_DRAGONFLY_DOWN,
4545 EL_BD_STONEFLY_DOWN,
4568 EL_BD_SAND_SLOPED_UP_LEFT,
4569 EL_BD_SAND_SLOPED_UP_RIGHT,
4570 EL_BD_WALL_SLOPED_UP_LEFT,
4571 EL_BD_WALL_SLOPED_UP_RIGHT,
4573 EL_BD_SAND_SLOPED_DOWN_LEFT,
4574 EL_BD_SAND_SLOPED_DOWN_RIGHT,
4575 EL_BD_WALL_SLOPED_DOWN_LEFT,
4576 EL_BD_WALL_SLOPED_DOWN_RIGHT,
4578 EL_BD_FLYING_DIAMOND,
4580 EL_BD_STEELWALL_SLOPED_UP_LEFT,
4581 EL_BD_STEELWALL_SLOPED_UP_RIGHT,
4585 EL_BD_STEELWALL_SLOPED_DOWN_LEFT,
4586 EL_BD_STEELWALL_SLOPED_DOWN_RIGHT,
4589 EL_BD_WALL_NON_SLOPED,
4595 EL_BD_INVISIBLE_EXIT_CLOSED,
4596 EL_BD_INVISIBLE_EXIT_OPEN,
4599 EL_BD_STEELWALL_EXPLODABLE,
4600 EL_BD_STEELWALL_DIGGABLE,
4601 EL_BD_WALL_DIGGABLE,
4603 EL_BD_EXPANDABLE_WALL_HORIZONTAL,
4604 EL_BD_EXPANDABLE_WALL_VERTICAL,
4605 EL_BD_EXPANDABLE_WALL_ANY,
4606 EL_BD_CREATURE_SWITCH,
4608 EL_BD_EXPANDABLE_STEELWALL_HORIZONTAL,
4609 EL_BD_EXPANDABLE_STEELWALL_VERTICAL,
4610 EL_BD_EXPANDABLE_STEELWALL_ANY,
4611 EL_BD_EXPANDABLE_WALL_SWITCH_HORIZONTAL,
4613 EL_BD_BITER_SWITCH_1,
4614 EL_BD_REPLICATOR_SWITCH,
4615 EL_BD_CONVEYOR_SWITCH,
4616 EL_BD_CONVEYOR_DIR_SWITCH_RIGHT,
4625 EL_BD_DIAMOND_GLUED,
4628 EL_BD_TRAPPED_DIAMOND,
4648 EL_BD_GRAVITY_SWITCH,
4649 EL_BD_PNEUMATIC_HAMMER,
4656 EL_BD_BLADDER_SPENDER,
4658 EL_BD_CONVEYOR_LEFT,
4659 EL_BD_CONVEYOR_RIGHT,
4674 EL_BD_PLAYER_WITH_BOMB,
4676 EL_BD_PLAYER_STIRRING,
4678 static int *editor_hl_boulderdash_native_ptr = editor_hl_boulderdash_native;
4679 static int *editor_el_boulderdash_native_ptr = editor_el_boulderdash_native;
4680 static int num_editor_hl_boulderdash_native = ARRAY_SIZE(editor_hl_boulderdash_native);
4681 static int num_editor_el_boulderdash_native = ARRAY_SIZE(editor_el_boulderdash_native);
4683 static int editor_hl_emerald_mine[] =
4685 EL_INTERNAL_CASCADE_EM_ACTIVE,
4691 static int editor_el_emerald_mine[] =
4709 EL_EM_DYNAMITE_ACTIVE,
4728 EL_ACID_POOL_TOPLEFT,
4730 EL_ACID_POOL_TOPRIGHT,
4733 EL_ACID_POOL_BOTTOMLEFT,
4734 EL_ACID_POOL_BOTTOM,
4735 EL_ACID_POOL_BOTTOMRIGHT,
4753 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4754 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4755 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4756 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4758 static int editor_hl_emerald_mine_club[] =
4760 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4766 static int editor_el_emerald_mine_club[] =
4793 EL_EMC_WALL_SLIPPERY_1,
4794 EL_EMC_WALL_SLIPPERY_2,
4795 EL_EMC_WALL_SLIPPERY_3,
4796 EL_EMC_WALL_SLIPPERY_4,
4819 EL_EMC_MAGIC_BALL_SWITCH,
4826 EL_EMC_SPRING_BUMPER,
4830 EL_BALLOON_SWITCH_UP,
4831 EL_BALLOON_SWITCH_ANY,
4834 EL_BALLOON_SWITCH_LEFT,
4836 EL_BALLOON_SWITCH_RIGHT,
4840 EL_BALLOON_SWITCH_DOWN,
4841 EL_BALLOON_SWITCH_NONE,
4843 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4844 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4845 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4846 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4848 static int editor_hl_rnd[] =
4850 EL_INTERNAL_CASCADE_RND_ACTIVE,
4856 static int editor_el_rnd[] =
4859 EL_DYNAMITE_ACTIVE, // RND
4893 EL_WALL_EMERALD_YELLOW,
4894 EL_WALL_EMERALD_RED,
4895 EL_WALL_EMERALD_PURPLE,
4913 EL_DYNABOMB_INCREASE_NUMBER,
4914 EL_DYNABOMB_INCREASE_SIZE,
4915 EL_DYNABOMB_INCREASE_POWER,
4935 EL_INVISIBLE_STEELWALL,
4939 EL_EXPANDABLE_WALL_HORIZONTAL,
4940 EL_EXPANDABLE_WALL_VERTICAL,
4941 EL_EXPANDABLE_WALL_ANY,
4943 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4944 static int *editor_el_rnd_ptr = editor_el_rnd;
4945 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4946 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4948 static int editor_hl_sokoban[] =
4950 EL_INTERNAL_CASCADE_SB_ACTIVE,
4956 static int editor_el_sokoban[] =
4959 EL_SOKOBAN_FIELD_EMPTY,
4960 EL_SOKOBAN_FIELD_FULL,
4961 EL_SOKOBAN_FIELD_PLAYER,
4963 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4964 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4965 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4966 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4968 static int editor_hl_supaplex[] =
4970 EL_INTERNAL_CASCADE_SP_ACTIVE,
4976 static int editor_el_supaplex[] =
4994 EL_SP_PORT_HORIZONTAL,
4995 EL_SP_PORT_VERTICAL,
5003 EL_SP_GRAVITY_PORT_LEFT,
5004 EL_SP_GRAVITY_PORT_RIGHT,
5005 EL_SP_GRAVITY_PORT_UP,
5006 EL_SP_GRAVITY_PORT_DOWN,
5008 EL_SP_GRAVITY_ON_PORT_LEFT,
5009 EL_SP_GRAVITY_ON_PORT_RIGHT,
5010 EL_SP_GRAVITY_ON_PORT_UP,
5011 EL_SP_GRAVITY_ON_PORT_DOWN,
5013 EL_SP_GRAVITY_OFF_PORT_LEFT,
5014 EL_SP_GRAVITY_OFF_PORT_RIGHT,
5015 EL_SP_GRAVITY_OFF_PORT_UP,
5016 EL_SP_GRAVITY_OFF_PORT_DOWN,
5018 EL_SP_HARDWARE_GRAY,
5019 EL_SP_HARDWARE_GREEN,
5020 EL_SP_HARDWARE_BLUE,
5023 EL_SP_HARDWARE_BASE_1,
5024 EL_SP_HARDWARE_BASE_2,
5025 EL_SP_HARDWARE_BASE_3,
5026 EL_SP_HARDWARE_BASE_4,
5028 EL_SP_HARDWARE_BASE_5,
5029 EL_SP_HARDWARE_BASE_6,
5030 EL_SP_HARDWARE_YELLOW,
5038 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
5039 static int *editor_el_supaplex_ptr = editor_el_supaplex;
5040 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
5041 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
5043 static int editor_hl_diamond_caves[] =
5045 EL_INTERNAL_CASCADE_DC_ACTIVE,
5051 static int editor_el_diamond_caves[] =
5053 EL_EM_STEEL_EXIT_CLOSED, // DC2
5054 EL_EM_STEEL_EXIT_OPEN, // DC2
5055 EL_WALL_EMERALD, // DC2
5056 EL_WALL_DIAMOND, // DC2
5063 EL_CONVEYOR_BELT_1_LEFT,
5064 EL_CONVEYOR_BELT_1_MIDDLE,
5065 EL_CONVEYOR_BELT_1_RIGHT,
5066 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
5068 EL_CONVEYOR_BELT_2_LEFT,
5069 EL_CONVEYOR_BELT_2_MIDDLE,
5070 EL_CONVEYOR_BELT_2_RIGHT,
5071 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
5073 EL_CONVEYOR_BELT_3_LEFT,
5074 EL_CONVEYOR_BELT_3_MIDDLE,
5075 EL_CONVEYOR_BELT_3_RIGHT,
5076 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
5078 EL_CONVEYOR_BELT_4_LEFT,
5079 EL_CONVEYOR_BELT_4_MIDDLE,
5080 EL_CONVEYOR_BELT_4_RIGHT,
5081 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
5083 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
5084 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
5085 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
5086 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
5088 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
5089 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
5090 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
5091 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
5096 EL_DC_TIMEGATE_SWITCH,
5098 EL_SWITCHGATE_CLOSED,
5100 EL_SWITCHGATE_SWITCH_UP,
5101 EL_SWITCHGATE_SWITCH_DOWN,
5104 EL_LIGHT_SWITCH_ACTIVE,
5105 EL_DC_SWITCHGATE_SWITCH_UP,
5106 EL_DC_SWITCHGATE_SWITCH_DOWN,
5108 EL_STEEL_EXIT_CLOSED,
5110 EL_STEELWALL_SLIPPERY,
5113 EL_QUICKSAND_FAST_EMPTY,
5114 EL_QUICKSAND_FAST_FULL,
5128 EL_SIGN_RADIOACTIVITY,
5134 EL_SIGN_ENTRY_FORBIDDEN,
5135 EL_SIGN_EMERGENCY_EXIT,
5160 EL_DC_STEELWALL_2_SINGLE,
5161 EL_DC_STEELWALL_2_TOP,
5162 EL_SIGN_EXCLAMATION,
5165 EL_DC_STEELWALL_2_LEFT,
5166 EL_DC_STEELWALL_2_MIDDLE,
5167 EL_DC_STEELWALL_2_HORIZONTAL,
5168 EL_DC_STEELWALL_2_RIGHT,
5170 EL_DC_STEELWALL_1_TOPLEFT,
5171 EL_DC_STEELWALL_2_VERTICAL,
5172 EL_DC_STEELWALL_1_TOPRIGHT,
5175 EL_DC_STEELWALL_1_VERTICAL,
5176 EL_DC_STEELWALL_2_BOTTOM,
5178 EL_DC_GATE_WHITE_GRAY,
5180 EL_DC_STEELWALL_1_BOTTOMLEFT,
5181 EL_DC_STEELWALL_1_HORIZONTAL,
5182 EL_DC_STEELWALL_1_BOTTOMRIGHT,
5183 EL_DC_GATE_FAKE_GRAY,
5185 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
5186 EL_DC_STEELWALL_1_BOTTOM,
5187 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
5188 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
5190 EL_DC_STEELWALL_1_RIGHT,
5192 EL_DC_STEELWALL_1_LEFT,
5193 EL_EXPANDABLE_STEELWALL_VERTICAL,
5195 EL_DC_STEELWALL_1_TOPRIGHT_2,
5196 EL_DC_STEELWALL_1_TOP,
5197 EL_DC_STEELWALL_1_TOPLEFT_2,
5198 EL_EXPANDABLE_STEELWALL_ANY,
5200 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
5201 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
5202 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
5203 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
5205 static int editor_hl_dx_boulderdash[] =
5207 EL_INTERNAL_CASCADE_DX_ACTIVE,
5213 static int editor_el_dx_boulderdash[] =
5217 EL_TUBE_HORIZONTAL_DOWN,
5221 EL_TUBE_VERTICAL_RIGHT,
5223 EL_TUBE_VERTICAL_LEFT,
5227 EL_TUBE_HORIZONTAL_UP,
5235 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
5236 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
5237 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
5238 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
5240 static int editor_hl_mirror_magic[] =
5242 EL_INTERNAL_CASCADE_MM_ACTIVE,
5248 static int editor_el_mirror_magic[] =
5250 EL_MM_MCDUFFIN_RIGHT,
5252 EL_MM_MCDUFFIN_LEFT,
5253 EL_MM_MCDUFFIN_DOWN,
5256 EL_MM_MIRROR_FIXED_START,
5257 EL_MM_POLARIZER_START,
5258 EL_MM_POLARIZER_CROSS_START,
5260 EL_MM_TELEPORTER_RED_START,
5261 EL_MM_TELEPORTER_YELLOW_START,
5262 EL_MM_TELEPORTER_GREEN_START,
5263 EL_MM_TELEPORTER_BLUE_START,
5276 EL_MM_LIGHTBULB_ACTIVE,
5290 EL_MM_STEEL_GRID_FIXED_1,
5291 EL_MM_STEEL_GRID_FIXED_2,
5292 EL_MM_STEEL_GRID_FIXED_3,
5293 EL_MM_STEEL_GRID_FIXED_4,
5295 EL_MM_WOODEN_GRID_FIXED_1,
5296 EL_MM_WOODEN_GRID_FIXED_2,
5297 EL_MM_WOODEN_GRID_FIXED_3,
5298 EL_MM_WOODEN_GRID_FIXED_4,
5305 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
5306 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
5307 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
5308 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
5310 static int editor_hl_deflektor[] =
5312 EL_INTERNAL_CASCADE_DF_ACTIVE,
5318 static int editor_el_deflektor[] =
5325 EL_DF_RECEIVER_RIGHT,
5327 EL_DF_RECEIVER_LEFT,
5328 EL_DF_RECEIVER_DOWN,
5331 EL_DF_MIRROR_ROTATING_START,
5332 EL_DF_MIRROR_FIXED_START,
5335 EL_DF_FIBRE_OPTIC_RED_1,
5336 EL_DF_FIBRE_OPTIC_YELLOW_1,
5337 EL_DF_FIBRE_OPTIC_GREEN_1,
5338 EL_DF_FIBRE_OPTIC_BLUE_1,
5340 EL_DF_STEEL_GRID_FIXED_START,
5341 EL_DF_STEEL_GRID_ROTATING_START,
5342 EL_DF_WOODEN_GRID_FIXED_START,
5343 EL_DF_WOODEN_GRID_ROTATING_START,
5355 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
5356 static int *editor_el_deflektor_ptr = editor_el_deflektor;
5357 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
5358 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
5360 static int editor_hl_chars[] =
5362 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
5368 static int editor_el_chars[] =
5450 EL_CHAR(CHAR_BYTE_COPYRIGHT),
5451 EL_CHAR(CHAR_BYTE_UMLAUT_A),
5452 EL_CHAR(CHAR_BYTE_UMLAUT_O),
5453 EL_CHAR(CHAR_BYTE_UMLAUT_U),
5455 EL_CHAR(CHAR_BYTE_DEGREE),
5456 EL_CHAR(CHAR_BYTE_REGISTERED),
5457 EL_CHAR(FONT_ASCII_CURSOR),
5458 EL_CHAR(FONT_ASCII_BUTTON),
5460 EL_CHAR(FONT_ASCII_UP),
5461 EL_CHAR(FONT_ASCII_DOWN),
5465 static int *editor_hl_chars_ptr = editor_hl_chars;
5466 static int *editor_el_chars_ptr = editor_el_chars;
5467 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
5468 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
5470 static int editor_hl_steel_chars[] =
5472 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
5478 static int editor_el_steel_chars[] =
5488 EL_STEEL_CHAR('\''),
5555 EL_STEEL_CHAR('\\'),
5560 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
5561 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
5562 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
5563 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
5565 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
5566 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
5567 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
5568 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
5570 EL_STEEL_CHAR(FONT_ASCII_UP),
5571 EL_STEEL_CHAR(FONT_ASCII_DOWN),
5575 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
5576 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
5577 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
5578 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
5580 static int editor_hl_custom[] =
5582 EL_INTERNAL_CASCADE_CE_ACTIVE,
5588 static int editor_el_custom[] =
5590 EL_CUSTOM_START + 0,
5591 EL_CUSTOM_START + 1,
5592 EL_CUSTOM_START + 2,
5593 EL_CUSTOM_START + 3,
5595 EL_CUSTOM_START + 4,
5596 EL_CUSTOM_START + 5,
5597 EL_CUSTOM_START + 6,
5598 EL_CUSTOM_START + 7,
5600 EL_CUSTOM_START + 8,
5601 EL_CUSTOM_START + 9,
5602 EL_CUSTOM_START + 10,
5603 EL_CUSTOM_START + 11,
5605 EL_CUSTOM_START + 12,
5606 EL_CUSTOM_START + 13,
5607 EL_CUSTOM_START + 14,
5608 EL_CUSTOM_START + 15,
5610 EL_CUSTOM_START + 16,
5611 EL_CUSTOM_START + 17,
5612 EL_CUSTOM_START + 18,
5613 EL_CUSTOM_START + 19,
5615 EL_CUSTOM_START + 20,
5616 EL_CUSTOM_START + 21,
5617 EL_CUSTOM_START + 22,
5618 EL_CUSTOM_START + 23,
5620 EL_CUSTOM_START + 24,
5621 EL_CUSTOM_START + 25,
5622 EL_CUSTOM_START + 26,
5623 EL_CUSTOM_START + 27,
5625 EL_CUSTOM_START + 28,
5626 EL_CUSTOM_START + 29,
5627 EL_CUSTOM_START + 30,
5628 EL_CUSTOM_START + 31,
5630 EL_CUSTOM_START + 32,
5631 EL_CUSTOM_START + 33,
5632 EL_CUSTOM_START + 34,
5633 EL_CUSTOM_START + 35,
5635 EL_CUSTOM_START + 36,
5636 EL_CUSTOM_START + 37,
5637 EL_CUSTOM_START + 38,
5638 EL_CUSTOM_START + 39,
5640 EL_CUSTOM_START + 40,
5641 EL_CUSTOM_START + 41,
5642 EL_CUSTOM_START + 42,
5643 EL_CUSTOM_START + 43,
5645 EL_CUSTOM_START + 44,
5646 EL_CUSTOM_START + 45,
5647 EL_CUSTOM_START + 46,
5648 EL_CUSTOM_START + 47,
5650 EL_CUSTOM_START + 48,
5651 EL_CUSTOM_START + 49,
5652 EL_CUSTOM_START + 50,
5653 EL_CUSTOM_START + 51,
5655 EL_CUSTOM_START + 52,
5656 EL_CUSTOM_START + 53,
5657 EL_CUSTOM_START + 54,
5658 EL_CUSTOM_START + 55,
5660 EL_CUSTOM_START + 56,
5661 EL_CUSTOM_START + 57,
5662 EL_CUSTOM_START + 58,
5663 EL_CUSTOM_START + 59,
5665 EL_CUSTOM_START + 60,
5666 EL_CUSTOM_START + 61,
5667 EL_CUSTOM_START + 62,
5668 EL_CUSTOM_START + 63,
5670 EL_CUSTOM_START + 64,
5671 EL_CUSTOM_START + 65,
5672 EL_CUSTOM_START + 66,
5673 EL_CUSTOM_START + 67,
5675 EL_CUSTOM_START + 68,
5676 EL_CUSTOM_START + 69,
5677 EL_CUSTOM_START + 70,
5678 EL_CUSTOM_START + 71,
5680 EL_CUSTOM_START + 72,
5681 EL_CUSTOM_START + 73,
5682 EL_CUSTOM_START + 74,
5683 EL_CUSTOM_START + 75,
5685 EL_CUSTOM_START + 76,
5686 EL_CUSTOM_START + 77,
5687 EL_CUSTOM_START + 78,
5688 EL_CUSTOM_START + 79,
5690 EL_CUSTOM_START + 80,
5691 EL_CUSTOM_START + 81,
5692 EL_CUSTOM_START + 82,
5693 EL_CUSTOM_START + 83,
5695 EL_CUSTOM_START + 84,
5696 EL_CUSTOM_START + 85,
5697 EL_CUSTOM_START + 86,
5698 EL_CUSTOM_START + 87,
5700 EL_CUSTOM_START + 88,
5701 EL_CUSTOM_START + 89,
5702 EL_CUSTOM_START + 90,
5703 EL_CUSTOM_START + 91,
5705 EL_CUSTOM_START + 92,
5706 EL_CUSTOM_START + 93,
5707 EL_CUSTOM_START + 94,
5708 EL_CUSTOM_START + 95,
5710 EL_CUSTOM_START + 96,
5711 EL_CUSTOM_START + 97,
5712 EL_CUSTOM_START + 98,
5713 EL_CUSTOM_START + 99,
5715 EL_CUSTOM_START + 100,
5716 EL_CUSTOM_START + 101,
5717 EL_CUSTOM_START + 102,
5718 EL_CUSTOM_START + 103,
5720 EL_CUSTOM_START + 104,
5721 EL_CUSTOM_START + 105,
5722 EL_CUSTOM_START + 106,
5723 EL_CUSTOM_START + 107,
5725 EL_CUSTOM_START + 108,
5726 EL_CUSTOM_START + 109,
5727 EL_CUSTOM_START + 110,
5728 EL_CUSTOM_START + 111,
5730 EL_CUSTOM_START + 112,
5731 EL_CUSTOM_START + 113,
5732 EL_CUSTOM_START + 114,
5733 EL_CUSTOM_START + 115,
5735 EL_CUSTOM_START + 116,
5736 EL_CUSTOM_START + 117,
5737 EL_CUSTOM_START + 118,
5738 EL_CUSTOM_START + 119,
5740 EL_CUSTOM_START + 120,
5741 EL_CUSTOM_START + 121,
5742 EL_CUSTOM_START + 122,
5743 EL_CUSTOM_START + 123,
5745 EL_CUSTOM_START + 124,
5746 EL_CUSTOM_START + 125,
5747 EL_CUSTOM_START + 126,
5748 EL_CUSTOM_START + 127,
5750 EL_CUSTOM_START + 128,
5751 EL_CUSTOM_START + 129,
5752 EL_CUSTOM_START + 130,
5753 EL_CUSTOM_START + 131,
5755 EL_CUSTOM_START + 132,
5756 EL_CUSTOM_START + 133,
5757 EL_CUSTOM_START + 134,
5758 EL_CUSTOM_START + 135,
5760 EL_CUSTOM_START + 136,
5761 EL_CUSTOM_START + 137,
5762 EL_CUSTOM_START + 138,
5763 EL_CUSTOM_START + 139,
5765 EL_CUSTOM_START + 140,
5766 EL_CUSTOM_START + 141,
5767 EL_CUSTOM_START + 142,
5768 EL_CUSTOM_START + 143,
5770 EL_CUSTOM_START + 144,
5771 EL_CUSTOM_START + 145,
5772 EL_CUSTOM_START + 146,
5773 EL_CUSTOM_START + 147,
5775 EL_CUSTOM_START + 148,
5776 EL_CUSTOM_START + 149,
5777 EL_CUSTOM_START + 150,
5778 EL_CUSTOM_START + 151,
5780 EL_CUSTOM_START + 152,
5781 EL_CUSTOM_START + 153,
5782 EL_CUSTOM_START + 154,
5783 EL_CUSTOM_START + 155,
5785 EL_CUSTOM_START + 156,
5786 EL_CUSTOM_START + 157,
5787 EL_CUSTOM_START + 158,
5788 EL_CUSTOM_START + 159,
5790 EL_CUSTOM_START + 160,
5791 EL_CUSTOM_START + 161,
5792 EL_CUSTOM_START + 162,
5793 EL_CUSTOM_START + 163,
5795 EL_CUSTOM_START + 164,
5796 EL_CUSTOM_START + 165,
5797 EL_CUSTOM_START + 166,
5798 EL_CUSTOM_START + 167,
5800 EL_CUSTOM_START + 168,
5801 EL_CUSTOM_START + 169,
5802 EL_CUSTOM_START + 170,
5803 EL_CUSTOM_START + 171,
5805 EL_CUSTOM_START + 172,
5806 EL_CUSTOM_START + 173,
5807 EL_CUSTOM_START + 174,
5808 EL_CUSTOM_START + 175,
5810 EL_CUSTOM_START + 176,
5811 EL_CUSTOM_START + 177,
5812 EL_CUSTOM_START + 178,
5813 EL_CUSTOM_START + 179,
5815 EL_CUSTOM_START + 180,
5816 EL_CUSTOM_START + 181,
5817 EL_CUSTOM_START + 182,
5818 EL_CUSTOM_START + 183,
5820 EL_CUSTOM_START + 184,
5821 EL_CUSTOM_START + 185,
5822 EL_CUSTOM_START + 186,
5823 EL_CUSTOM_START + 187,
5825 EL_CUSTOM_START + 188,
5826 EL_CUSTOM_START + 189,
5827 EL_CUSTOM_START + 190,
5828 EL_CUSTOM_START + 191,
5830 EL_CUSTOM_START + 192,
5831 EL_CUSTOM_START + 193,
5832 EL_CUSTOM_START + 194,
5833 EL_CUSTOM_START + 195,
5835 EL_CUSTOM_START + 196,
5836 EL_CUSTOM_START + 197,
5837 EL_CUSTOM_START + 198,
5838 EL_CUSTOM_START + 199,
5840 EL_CUSTOM_START + 200,
5841 EL_CUSTOM_START + 201,
5842 EL_CUSTOM_START + 202,
5843 EL_CUSTOM_START + 203,
5845 EL_CUSTOM_START + 204,
5846 EL_CUSTOM_START + 205,
5847 EL_CUSTOM_START + 206,
5848 EL_CUSTOM_START + 207,
5850 EL_CUSTOM_START + 208,
5851 EL_CUSTOM_START + 209,
5852 EL_CUSTOM_START + 210,
5853 EL_CUSTOM_START + 211,
5855 EL_CUSTOM_START + 212,
5856 EL_CUSTOM_START + 213,
5857 EL_CUSTOM_START + 214,
5858 EL_CUSTOM_START + 215,
5860 EL_CUSTOM_START + 216,
5861 EL_CUSTOM_START + 217,
5862 EL_CUSTOM_START + 218,
5863 EL_CUSTOM_START + 219,
5865 EL_CUSTOM_START + 220,
5866 EL_CUSTOM_START + 221,
5867 EL_CUSTOM_START + 222,
5868 EL_CUSTOM_START + 223,
5870 EL_CUSTOM_START + 224,
5871 EL_CUSTOM_START + 225,
5872 EL_CUSTOM_START + 226,
5873 EL_CUSTOM_START + 227,
5875 EL_CUSTOM_START + 228,
5876 EL_CUSTOM_START + 229,
5877 EL_CUSTOM_START + 230,
5878 EL_CUSTOM_START + 231,
5880 EL_CUSTOM_START + 232,
5881 EL_CUSTOM_START + 233,
5882 EL_CUSTOM_START + 234,
5883 EL_CUSTOM_START + 235,
5885 EL_CUSTOM_START + 236,
5886 EL_CUSTOM_START + 237,
5887 EL_CUSTOM_START + 238,
5888 EL_CUSTOM_START + 239,
5890 EL_CUSTOM_START + 240,
5891 EL_CUSTOM_START + 241,
5892 EL_CUSTOM_START + 242,
5893 EL_CUSTOM_START + 243,
5895 EL_CUSTOM_START + 244,
5896 EL_CUSTOM_START + 245,
5897 EL_CUSTOM_START + 246,
5898 EL_CUSTOM_START + 247,
5900 EL_CUSTOM_START + 248,
5901 EL_CUSTOM_START + 249,
5902 EL_CUSTOM_START + 250,
5903 EL_CUSTOM_START + 251,
5905 EL_CUSTOM_START + 252,
5906 EL_CUSTOM_START + 253,
5907 EL_CUSTOM_START + 254,
5908 EL_CUSTOM_START + 255
5910 static int *editor_hl_custom_ptr = editor_hl_custom;
5911 static int *editor_el_custom_ptr = editor_el_custom;
5912 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5913 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5915 static int editor_hl_group[] =
5917 EL_INTERNAL_CASCADE_GE_ACTIVE,
5923 static int editor_el_group[] =
5937 EL_GROUP_START + 10,
5938 EL_GROUP_START + 11,
5940 EL_GROUP_START + 12,
5941 EL_GROUP_START + 13,
5942 EL_GROUP_START + 14,
5943 EL_GROUP_START + 15,
5945 EL_GROUP_START + 16,
5946 EL_GROUP_START + 17,
5947 EL_GROUP_START + 18,
5948 EL_GROUP_START + 19,
5950 EL_GROUP_START + 20,
5951 EL_GROUP_START + 21,
5952 EL_GROUP_START + 22,
5953 EL_GROUP_START + 23,
5955 EL_GROUP_START + 24,
5956 EL_GROUP_START + 25,
5957 EL_GROUP_START + 26,
5958 EL_GROUP_START + 27,
5960 EL_GROUP_START + 28,
5961 EL_GROUP_START + 29,
5962 EL_GROUP_START + 30,
5965 static int *editor_hl_group_ptr = editor_hl_group;
5966 static int *editor_el_group_ptr = editor_el_group;
5967 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5968 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5970 static int editor_hl_empty_space[] =
5972 EL_INTERNAL_CASCADE_ES_ACTIVE,
5978 static int editor_el_empty_space[] =
6000 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
6001 static int *editor_el_empty_space_ptr = editor_el_empty_space;
6002 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
6003 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
6005 static int editor_hl_reference[] =
6007 EL_INTERNAL_CASCADE_REF_ACTIVE,
6013 static int editor_el_reference[] =
6017 EL_TRIGGER_CE_VALUE,
6018 EL_TRIGGER_CE_SCORE,
6022 EL_CURRENT_CE_VALUE,
6023 EL_CURRENT_CE_SCORE,
6045 static int *editor_hl_reference_ptr = editor_hl_reference;
6046 static int *editor_el_reference_ptr = editor_el_reference;
6047 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
6048 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
6050 static int editor_hl_user_defined[] =
6052 EL_INTERNAL_CASCADE_USER_ACTIVE,
6058 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
6059 static int *editor_el_user_defined_ptr = NULL;
6060 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
6061 static int num_editor_el_user_defined = 0;
6063 static int editor_hl_dynamic[] =
6065 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
6071 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
6072 static int *editor_el_dynamic_ptr = NULL;
6073 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
6074 static int num_editor_el_dynamic = 0;
6076 static int editor_hl_empty[] = { EL_EMPTY };
6077 static int *editor_el_empty = NULL; // dynamically allocated
6079 static int *editor_hl_empty_ptr = editor_hl_empty;
6080 static int *editor_el_empty_ptr = NULL;
6081 static int num_editor_hl_empty = 0;
6082 static int num_editor_el_empty = 0; // dynamically determined, if needed
6084 static boolean use_el_empty = FALSE;
6086 static int *editor_elements = NULL; // dynamically allocated
6087 static int num_editor_elements = 0; // dynamically determined
6089 static boolean setup_editor_cascade_never = FALSE;
6091 static boolean setup_editor_el_players = TRUE;
6092 static boolean setup_editor_el_boulderdash = TRUE;
6093 static boolean setup_editor_el_boulderdash_native = TRUE;
6094 static boolean setup_editor_el_emerald_mine = TRUE;
6095 static boolean setup_editor_el_emerald_mine_club = TRUE;
6096 static boolean setup_editor_el_more = TRUE;
6097 static boolean setup_editor_el_sokoban = TRUE;
6098 static boolean setup_editor_el_supaplex = TRUE;
6099 static boolean setup_editor_el_diamond_caves = TRUE;
6100 static boolean setup_editor_el_dx_boulderdash = TRUE;
6101 static boolean setup_editor_el_mirror_magic = TRUE;
6102 static boolean setup_editor_el_deflektor = TRUE;
6103 static boolean setup_editor_el_chars = TRUE;
6104 static boolean setup_editor_el_steel_chars = TRUE;
6105 static boolean setup_editor_el_custom = TRUE;
6106 static boolean setup_editor_el_user_defined = TRUE;
6107 static boolean setup_editor_el_dynamic = TRUE;
6109 static int editor_hl_unused[] = { EL_EMPTY };
6110 static int *editor_hl_unused_ptr = editor_hl_unused;
6111 static int num_editor_hl_unused = 0;
6115 boolean *setup_value;
6116 boolean *setup_cascade_value;
6118 int **headline_list;
6119 int *headline_list_size;
6122 int *element_list_size;
6124 boolean last_setup_value;
6126 editor_elements_info[] =
6129 &setup_editor_el_players,
6130 &setup_editor_cascade_never,
6131 &editor_hl_unused_ptr, &num_editor_hl_unused,
6132 &editor_el_players_ptr, &num_editor_el_players
6135 &setup_editor_el_boulderdash,
6136 &setup.editor_cascade.el_bd,
6137 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
6138 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
6141 &setup_editor_el_boulderdash_native,
6142 &setup.editor_cascade.el_bd_native,
6143 &editor_hl_boulderdash_native_ptr, &num_editor_hl_boulderdash_native,
6144 &editor_el_boulderdash_native_ptr, &num_editor_el_boulderdash_native
6147 &setup_editor_el_emerald_mine,
6148 &setup.editor_cascade.el_em,
6149 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
6150 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
6153 &setup_editor_el_emerald_mine_club,
6154 &setup.editor_cascade.el_emc,
6155 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
6156 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
6159 &setup_editor_el_more,
6160 &setup.editor_cascade.el_rnd,
6161 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
6162 &editor_el_rnd_ptr, &num_editor_el_rnd
6165 &setup_editor_el_sokoban,
6166 &setup.editor_cascade.el_sb,
6167 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
6168 &editor_el_sokoban_ptr, &num_editor_el_sokoban
6171 &setup_editor_el_supaplex,
6172 &setup.editor_cascade.el_sp,
6173 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
6174 &editor_el_supaplex_ptr, &num_editor_el_supaplex
6177 &setup_editor_el_diamond_caves,
6178 &setup.editor_cascade.el_dc,
6179 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
6180 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
6183 &setup_editor_el_dx_boulderdash,
6184 &setup.editor_cascade.el_dx,
6185 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
6186 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
6189 &setup_editor_el_mirror_magic,
6190 &setup.editor_cascade.el_mm,
6191 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
6192 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
6195 &setup_editor_el_deflektor,
6196 &setup.editor_cascade.el_df,
6197 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
6198 &editor_el_deflektor_ptr, &num_editor_el_deflektor
6201 &setup_editor_el_chars,
6202 &setup.editor_cascade.el_chars,
6203 &editor_hl_chars_ptr, &num_editor_hl_chars,
6204 &editor_el_chars_ptr, &num_editor_el_chars
6207 &setup_editor_el_steel_chars,
6208 &setup.editor_cascade.el_steel_chars,
6209 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
6210 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
6213 &setup_editor_el_custom,
6214 &setup.editor_cascade.el_ce,
6215 &editor_hl_custom_ptr, &num_editor_hl_custom,
6216 &editor_el_custom_ptr, &num_editor_el_custom
6219 &setup_editor_el_custom,
6220 &setup.editor_cascade.el_ge,
6221 &editor_hl_group_ptr, &num_editor_hl_group,
6222 &editor_el_group_ptr, &num_editor_el_group
6225 &setup_editor_el_custom,
6226 &setup.editor_cascade.el_es,
6227 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
6228 &editor_el_empty_space_ptr, &num_editor_el_empty_space
6231 &setup_editor_el_custom,
6232 &setup.editor_cascade.el_ref,
6233 &editor_hl_reference_ptr, &num_editor_hl_reference,
6234 &editor_el_reference_ptr, &num_editor_el_reference
6237 &setup_editor_el_user_defined,
6238 &setup.editor_cascade.el_user,
6239 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
6240 &editor_el_user_defined_ptr, &num_editor_el_user_defined
6243 &setup_editor_el_dynamic,
6244 &setup.editor_cascade.el_dynamic,
6245 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
6246 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
6251 &editor_hl_empty_ptr, &num_editor_hl_empty,
6252 &editor_el_empty_ptr, &num_editor_el_empty,
6262 static struct XY xy_directions[] =
6271 // ----------------------------------------------------------------------------
6273 // ----------------------------------------------------------------------------
6275 static int getMaxInfoTextLength(void)
6277 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
6280 static int getTextWidthForGadget(char *text)
6285 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
6288 static int getTextWidthForDrawingArea(char *text)
6293 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
6296 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
6298 return (gi->x + gi->width + getTextWidthForGadget(text));
6301 static char *getElementInfoText(int element)
6303 char *info_text = NULL;
6305 if (element < MAX_NUM_ELEMENTS)
6307 if (strlen(element_info[element].description) > 0)
6308 info_text = element_info[element].description;
6309 else if (element_info[element].custom_description != NULL)
6310 info_text = element_info[element].custom_description;
6311 else if (element_info[element].editor_description != NULL)
6312 info_text = element_info[element].editor_description;
6315 if (info_text == NULL)
6316 info_text = INFOTEXT_UNKNOWN_ELEMENT;
6321 static char *getElementDescriptionFilenameExt(char *basename)
6323 char *elements_subdir = ELEMENTS_DIRECTORY;
6324 static char *elements_subdir2 = NULL;
6325 static char *filename = NULL;
6327 if (elements_subdir2 == NULL)
6328 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
6330 checked_free(filename);
6332 // 1st try: look for element description in current level set directory
6333 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
6334 if (fileExists(filename))
6339 // 2nd try: look for element description in the game's base directory
6340 filename = getPath3(options.docs_directory, elements_subdir, basename);
6341 if (fileExists(filename))
6347 static char *getElementDescriptionFilename(int element)
6349 char basename[MAX_FILENAME_LEN];
6352 // 1st try: look for element description file for exactly this element
6353 sprintf(basename, "%s.txt", element_info[element].token_name);
6354 filename = getElementDescriptionFilenameExt(basename);
6355 if (filename != NULL)
6358 // 2nd try: look for element description file for this element's class
6359 sprintf(basename, "%s.txt", element_info[element].class_name);
6360 filename = getElementDescriptionFilenameExt(basename);
6361 if (filename != NULL)
6364 // 3rd try: look for generic fallback text file for any element
6365 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
6366 if (filename != NULL)
6372 static boolean suppressBorderElement(void)
6374 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
6375 lev_fieldx <= MAX_ED_FIELDX &&
6376 lev_fieldy <= MAX_ED_FIELDY);
6379 static void InitDynamicEditorElementList(int **elements, int *num_elements)
6381 boolean element_found[NUM_FILE_ELEMENTS];
6384 // initialize list of used elements to "not used"
6385 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6386 element_found[i] = FALSE;
6388 // find all elements used in current level
6389 for (y = 0; y < lev_fieldy; y++)
6391 for (x = 0; x < lev_fieldx; x++)
6393 if (Tile[x][y] >= NUM_FILE_ELEMENTS) // should never happen
6396 if (IS_MM_WALL(Tile[x][y]))
6397 element_found[map_mm_wall_element(Tile[x][y])] = TRUE;
6399 element_found[Tile[x][y]] = TRUE;
6405 // count number of elements used in current level
6406 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6407 if (element_found[i])
6410 // add space for up to 3 more elements for padding that may be needed
6413 // free memory for old list of elements, if needed
6414 checked_free(*elements);
6416 // allocate memory for new list of elements
6417 *elements = checked_malloc(*num_elements * sizeof(int));
6421 // add all elements used in current level (non-custom/group/empty elements)
6422 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6423 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) ||
6424 IS_GROUP_ELEMENT(i) ||
6425 IS_EMPTY_ELEMENT(i)))
6426 (*elements)[(*num_elements)++] = i;
6428 // add all elements used in current level (custom/group/empty elements)
6429 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6430 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) ||
6431 IS_GROUP_ELEMENT(i) ||
6432 IS_EMPTY_ELEMENT(i)))
6433 (*elements)[(*num_elements)++] = i;
6435 while (*num_elements % 4) // pad with empty elements, if needed
6436 (*elements)[(*num_elements)++] = EL_EMPTY;
6439 static void ReinitializeElementList_EnableSections(void)
6441 // default: enable all element sections
6443 setup_editor_el_players = TRUE;
6444 setup_editor_el_boulderdash = TRUE;
6445 setup_editor_el_boulderdash_native = TRUE;
6446 setup_editor_el_emerald_mine = TRUE;
6447 setup_editor_el_emerald_mine_club = TRUE;
6448 setup_editor_el_more = TRUE;
6449 setup_editor_el_sokoban = TRUE;
6450 setup_editor_el_supaplex = TRUE;
6451 setup_editor_el_diamond_caves = TRUE;
6452 setup_editor_el_dx_boulderdash = TRUE;
6453 setup_editor_el_mirror_magic = TRUE;
6454 setup_editor_el_deflektor = TRUE;
6455 setup_editor_el_chars = TRUE;
6456 setup_editor_el_steel_chars = TRUE;
6458 setup_editor_el_custom = TRUE;
6459 setup_editor_el_user_defined = TRUE;
6460 setup_editor_el_dynamic = TRUE;
6462 // now disable all element sections not to be displayed
6464 if (!setup.editor.el_classic)
6466 setup_editor_el_players = FALSE;
6467 setup_editor_el_boulderdash = FALSE;
6468 setup_editor_el_boulderdash_native = FALSE;
6469 setup_editor_el_emerald_mine = FALSE;
6470 setup_editor_el_emerald_mine_club = FALSE;
6471 setup_editor_el_more = FALSE;
6472 setup_editor_el_sokoban = FALSE;
6473 setup_editor_el_supaplex = FALSE;
6474 setup_editor_el_diamond_caves = FALSE;
6475 setup_editor_el_dx_boulderdash = FALSE;
6476 setup_editor_el_mirror_magic = FALSE;
6477 setup_editor_el_deflektor = FALSE;
6478 setup_editor_el_chars = FALSE;
6479 setup_editor_el_steel_chars = FALSE;
6482 if (!setup.editor.el_custom)
6484 setup_editor_el_custom = FALSE;
6487 if (!setup.editor.el_user_defined)
6489 setup_editor_el_user_defined = FALSE;
6492 if (!setup.editor.el_dynamic)
6494 setup_editor_el_dynamic = FALSE;
6497 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
6499 setup_editor_el_boulderdash_native = FALSE;
6500 setup_editor_el_mirror_magic = FALSE;
6501 setup_editor_el_deflektor = FALSE;
6503 else if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
6505 setup_editor_el_players = FALSE;
6506 setup_editor_el_boulderdash = FALSE;
6507 setup_editor_el_emerald_mine = FALSE;
6508 setup_editor_el_emerald_mine_club = FALSE;
6509 setup_editor_el_more = FALSE;
6510 setup_editor_el_sokoban = FALSE;
6511 setup_editor_el_supaplex = FALSE;
6512 setup_editor_el_diamond_caves = FALSE;
6513 setup_editor_el_dx_boulderdash = FALSE;
6514 setup_editor_el_mirror_magic = FALSE;
6515 setup_editor_el_deflektor = FALSE;
6516 setup_editor_el_chars = FALSE;
6517 setup_editor_el_steel_chars = FALSE;
6519 setup_editor_el_custom = FALSE;
6521 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
6523 setup_editor_el_boulderdash = FALSE;
6524 setup_editor_el_boulderdash_native = FALSE;
6525 setup_editor_el_more = FALSE;
6526 setup_editor_el_sokoban = FALSE;
6527 setup_editor_el_supaplex = FALSE;
6528 setup_editor_el_diamond_caves = FALSE;
6529 setup_editor_el_dx_boulderdash = FALSE;
6530 setup_editor_el_mirror_magic = FALSE;
6531 setup_editor_el_deflektor = FALSE;
6532 setup_editor_el_steel_chars = FALSE;
6534 setup_editor_el_custom = FALSE;
6536 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
6538 setup_editor_el_players = FALSE;
6539 setup_editor_el_boulderdash = FALSE;
6540 setup_editor_el_boulderdash_native = FALSE;
6541 setup_editor_el_emerald_mine = FALSE;
6542 setup_editor_el_emerald_mine_club = FALSE;
6543 setup_editor_el_more = FALSE;
6544 setup_editor_el_sokoban = FALSE;
6545 setup_editor_el_diamond_caves = FALSE;
6546 setup_editor_el_dx_boulderdash = FALSE;
6547 setup_editor_el_mirror_magic = FALSE;
6548 setup_editor_el_deflektor = FALSE;
6549 setup_editor_el_chars = FALSE;
6550 setup_editor_el_steel_chars = FALSE;
6552 setup_editor_el_custom = FALSE;
6554 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
6556 setup_editor_el_players = FALSE;
6557 setup_editor_el_boulderdash = FALSE;
6558 setup_editor_el_boulderdash_native = FALSE;
6559 setup_editor_el_emerald_mine = FALSE;
6560 setup_editor_el_emerald_mine_club = FALSE;
6561 setup_editor_el_more = FALSE;
6562 setup_editor_el_sokoban = FALSE;
6563 setup_editor_el_supaplex = FALSE;
6564 setup_editor_el_diamond_caves = FALSE;
6565 setup_editor_el_dx_boulderdash = FALSE;
6566 setup_editor_el_steel_chars = FALSE;
6568 setup_editor_el_custom = FALSE;
6572 static void ReinitializeElementList(void)
6574 static boolean initialization_needed = TRUE;
6578 ReinitializeElementList_EnableSections();
6580 if (initialization_needed)
6582 LoadSetup_EditorCascade(); // load last editor cascade state
6584 // initialize editor cascade element from saved cascade state
6585 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6587 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
6588 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
6590 if (IS_EDITOR_CASCADE(*cascade_element))
6592 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
6593 EL_CASCADE_INACTIVE(*cascade_element));
6596 initialization_needed = FALSE;
6599 checked_free(editor_elements);
6601 // reload optional user defined element list for each invocation of editor
6602 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
6603 &num_editor_el_user_defined);
6605 // initialize dynamic level element list for each invocation of editor
6606 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
6607 &num_editor_el_dynamic);
6609 // initialize list of empty elements (used for padding, if needed)
6610 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6611 editor_el_empty[i] = EL_EMPTY;
6613 // do some sanity checks for each element from element list
6614 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6616 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6618 int element = (*editor_elements_info[i].element_list)[j];
6620 if (element >= NUM_FILE_ELEMENTS)
6621 Warn("editor element %d is runtime element", element);
6623 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
6624 Warn("no element description text for element %d", element);
6628 num_editor_elements = 0;
6629 use_el_empty = FALSE;
6631 // determine size of element list
6632 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6634 if (*editor_elements_info[i].setup_value)
6636 boolean found_inactive_cascade = FALSE;
6638 if (setup.editor.el_headlines)
6640 // required for correct padding of palette headline buttons
6641 if (*editor_elements_info[i].headline_list_size > 0)
6642 num_editor_elements += ED_ELEMENTLIST_COLS;
6644 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6646 int element = (*editor_elements_info[i].headline_list)[j];
6648 if (IS_EDITOR_CASCADE_INACTIVE(element))
6649 found_inactive_cascade = TRUE;
6653 if (found_inactive_cascade)
6656 // required for correct padding of palette element buttons
6657 int element_list_size = *editor_elements_info[i].element_list_size;
6659 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6660 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6662 num_editor_elements += element_buttons;
6666 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
6668 // offer at least as many elements as element buttons exist
6669 use_el_empty = TRUE;
6670 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
6672 num_editor_elements += num_editor_el_empty;
6676 num_editor_el_empty = 0;
6679 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
6681 // fill element list
6682 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6684 boolean found_inactive_cascade = FALSE;
6686 if (*editor_elements_info[i].setup_value)
6688 if (setup.editor.el_headlines)
6690 // required for correct padding of palette headline buttons
6691 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6692 ED_ELEMENTLIST_COLS : 0);
6694 for (j = 0; j < headline_size; j++)
6696 // use empty elements for padding of palette headline buttons
6697 int element = (j < *editor_elements_info[i].headline_list_size ?
6698 (*editor_elements_info[i].headline_list)[j] :
6699 editor_el_empty[0]);
6701 editor_elements[pos++] = element;
6703 if (IS_EDITOR_CASCADE_INACTIVE(element))
6704 found_inactive_cascade = TRUE;
6708 if (found_inactive_cascade)
6711 // required for correct padding of palette element buttons
6712 int element_list_size = *editor_elements_info[i].element_list_size;
6714 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6715 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6717 // copy all elements from element list
6718 for (j = 0; j < element_list_size; j++)
6719 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6721 // use empty elements for padding of palette element buttons
6722 for (j = 0; j < element_buttons - element_list_size; j++)
6723 editor_elements[pos++] = editor_el_empty[0];
6727 // (this function is also called before editor gadgets are initialized!)
6728 AdjustElementListScrollbar();
6731 void PrintEditorElementList(void)
6733 boolean *stop = &setup_editor_el_user_defined;
6736 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6738 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6740 if (IS_EDITOR_CASCADE(cascade_element))
6742 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6743 char *headline = element_info[cascade_element_show].editor_description;
6745 PrintLineWithPrefix("# ", "-", 77);
6746 Print("# %s\n", headline);
6747 PrintLineWithPrefix("# ", "-", 77);
6750 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6752 int element = (*editor_elements_info[i].headline_list)[j];
6754 if (IS_EDITOR_CASCADE(element))
6755 element = EL_CHAR_MINUS;
6757 Print("# %s\n", element_info[element].token_name);
6763 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6765 int element = (*editor_elements_info[i].element_list)[j];
6767 Print("# %s\n", element_info[element].token_name);
6775 static void ReinitializeElementListButtons(void)
6777 static boolean last_setup_value_headlines = FALSE;
6778 static boolean initialization_needed = TRUE;
6781 if (!initialization_needed) // check if editor element setup has changed
6783 if (last_setup_value_headlines != setup.editor.el_headlines)
6784 initialization_needed = TRUE;
6786 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6787 if (editor_elements_info[i].last_setup_value !=
6788 *editor_elements_info[i].setup_value)
6789 initialization_needed = TRUE;
6792 if (!initialization_needed)
6795 FreeLevelEditorGadgets();
6796 CreateLevelEditorGadgets();
6798 // store current setup values for next invocation of this function
6799 last_setup_value_headlines = setup.editor.el_headlines;
6800 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6801 editor_elements_info[i].last_setup_value =
6802 *editor_elements_info[i].setup_value;
6804 initialization_needed = FALSE;
6807 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6810 int border_graphic =
6811 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6812 struct GraphicInfo *g = &graphic_info[border_graphic];
6813 Bitmap *src_bitmap = g->bitmap;
6814 int src_x = g->src_x;
6815 int src_y = g->src_y;
6816 int border_size = g->border_size;
6817 int border_xpos = g->width - border_size;
6818 int border_ypos = g->height - border_size;
6819 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6822 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6823 border_size, border_size,
6824 dest_x - border_size, dest_y - border_size);
6825 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6826 border_size, border_size,
6827 dest_x + width, dest_y - border_size);
6828 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6829 border_size, border_size,
6830 dest_x - border_size, dest_y + height);
6831 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6832 border_size, border_size,
6833 dest_x + width, dest_y + height);
6835 for (i = 0; i < width / tilesize; i++)
6837 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6838 tilesize, border_size,
6839 dest_x + i * tilesize, dest_y - border_size);
6840 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6841 tilesize, border_size,
6842 dest_x + i * tilesize, dest_y + height);
6845 for (i = 0; i < height / tilesize; i++)
6847 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6848 border_size, tilesize,
6849 dest_x - border_size, dest_y + i * tilesize);
6850 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6851 border_size, tilesize,
6852 dest_x + width, dest_y + i * tilesize);
6855 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6858 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6860 int xsize_tile = MAX(ed_tilesize, xsize);
6861 int ysize_tile = MAX(ed_tilesize, ysize);
6862 int xsize_full = xsize + 1;
6863 int ysize_full = ysize + 1;
6864 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6865 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6866 Pixel line_color = getTabulatorBarColor();
6868 if (line_color == BLACK_PIXEL) // black => transparent
6871 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6872 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6873 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6876 static void DrawEditorLevelBorderLinesIfNeeded(void)
6878 int xsize = lev_fieldx * ed_tilesize;
6879 int ysize = lev_fieldy * ed_tilesize;
6880 int line_size = getTabulatorBarHeight();
6882 if (!suppressBorderElement())
6885 // draw little border line around editable level playfield
6888 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6891 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6893 if (xsize < SXSIZE && ysize < SYSIZE)
6894 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6897 static void DrawEditorElement(int x, int y, int element)
6899 DrawSizedElement(x, y, element, ed_tilesize);
6902 static void DrawEditorElementThruMask(int x, int y, int element)
6904 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6907 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6909 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6912 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6914 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6915 DrawEditorLevelBorderLinesIfNeeded();
6918 static void DrawDrawingArea(int id)
6920 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6923 int *value = drawingarea_info[id].value;
6924 int area_xsize = drawingarea_info[id].area_xsize;
6925 int area_ysize = drawingarea_info[id].area_ysize;
6926 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6928 for (x = 0; x < area_xsize; x++)
6929 for (y = 0; y < area_ysize; y++)
6930 DrawSizedGraphicExt(drawto,
6931 gi->x + x * tilesize,
6932 gi->y + y * tilesize,
6933 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6936 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6939 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6940 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6942 BlitBitmap(drawto, drawto,
6943 SX + (dx == -1 ? ed_tilesize : 0),
6944 SY + (dy == -1 ? ed_tilesize : 0),
6945 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6946 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6947 SX + (dx == +1 ? ed_tilesize : 0),
6948 SY + (dy == +1 ? ed_tilesize : 0));
6952 x = (dx == 1 ? 0 : ed_fieldx - 1);
6953 for (y = 0; y < ed_fieldy; y++)
6954 DrawEditorElementOrWall(x, y, from_x, from_y);
6958 y = (dy == 1 ? 0 : ed_fieldy - 1);
6959 for (x = 0; x < ed_fieldx; x++)
6960 DrawEditorElementOrWall(x, y, from_x, from_y);
6963 redraw_mask |= REDRAW_FIELD;
6967 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6970 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6973 static void CreateControlButtons(void)
6975 struct GadgetInfo *gi;
6978 // create toolbox buttons
6979 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6981 int type_id = controlbutton_info[i].gadget_id; // same as gadget ID here
6982 int id = controlbutton_info[i].gadget_id;
6983 int type = controlbutton_info[i].gadget_type;
6984 int graphic = controlbutton_info[i].graphic;
6985 struct XYTileSize *pos = controlbutton_info[i].pos;
6986 struct GraphicInfo *gd = &graphic_info[graphic];
6987 Bitmap *deco_bitmap = NULL;
6988 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6989 int tile_size = 0, deco_shift = 0;
6990 boolean deco_masked = FALSE;
6991 int gd_x1 = gd->src_x;
6992 int gd_y1 = gd->src_y;
6993 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6994 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6995 int gd_x1a = gd->src_x + gd->active_xoffset;
6996 int gd_y1a = gd->src_y + gd->active_yoffset;
6997 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6998 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7001 unsigned int event_mask;
7002 int radio_button_nr = RADIO_NR_NONE;
7003 boolean checked = FALSE;
7006 Fail("'controlbutton_info' structure corrupted at index %d -- please fix", i);
7008 if (type == GD_TYPE_RADIO_BUTTON)
7010 event_mask = GD_EVENT_PRESSED;
7011 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
7013 if (id == drawing_function)
7018 if (id == GADGET_ID_WRAP_LEFT ||
7019 id == GADGET_ID_WRAP_RIGHT ||
7020 id == GADGET_ID_WRAP_UP ||
7021 id == GADGET_ID_WRAP_DOWN)
7022 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7024 event_mask = GD_EVENT_RELEASED;
7027 if (id == GADGET_ID_PROPERTIES ||
7028 id == GADGET_ID_PALETTE)
7033 else if (id == GADGET_ID_ELEMENT_LEFT ||
7034 id == GADGET_ID_ELEMENT_MIDDLE ||
7035 id == GADGET_ID_ELEMENT_RIGHT)
7040 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
7041 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
7042 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
7044 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
7045 editor.button.element_left.tile_size :
7046 id == GADGET_ID_ELEMENT_MIDDLE ?
7047 editor.button.element_middle.tile_size :
7048 id == GADGET_ID_ELEMENT_RIGHT ?
7049 editor.button.element_right.tile_size : 0);
7051 // make sure that decoration does not overlap gadget border
7052 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
7054 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
7056 deco_xpos = (gd->width - tile_size) / 2;
7057 deco_ypos = (gd->height - tile_size) / 2;
7059 deco_masked = gd->draw_masked;
7067 gi = CreateGadget(GDI_CUSTOM_ID, id,
7068 GDI_CUSTOM_TYPE_ID, type_id,
7069 GDI_IMAGE_ID, graphic,
7070 GDI_INFO_TEXT, controlbutton_info[i].infotext,
7073 GDI_WIDTH, gd->width,
7074 GDI_HEIGHT, gd->height,
7076 GDI_STATE, GD_BUTTON_UNPRESSED,
7077 GDI_RADIO_NR, radio_button_nr,
7078 GDI_CHECKED, checked,
7079 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7080 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7081 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7082 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7083 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7084 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7085 GDI_DECORATION_SIZE, tile_size, tile_size,
7086 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
7087 GDI_DECORATION_MASKED, deco_masked,
7088 GDI_EVENT_MASK, event_mask,
7089 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7090 GDI_CALLBACK_ACTION, HandleControlButtons,
7094 Fail("cannot create gadget");
7096 level_editor_gadget[id] = gi;
7099 // these values are not constant, but can change at runtime
7100 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
7101 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
7102 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
7103 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
7104 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
7105 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
7106 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
7107 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
7108 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
7109 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
7110 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
7111 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
7113 // create buttons for scrolling of drawing area and element list
7114 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
7116 int id = scrollbutton_info[i].gadget_id;
7117 int type_id = scrollbutton_info[i].gadget_type_id;
7118 int graphic = scrollbutton_info[i].graphic;
7119 struct GraphicInfo *gd = &graphic_info[graphic];
7120 Bitmap *gd_bitmap = gd->bitmap;
7121 int gd_x1 = gd->src_x;
7122 int gd_y1 = gd->src_y;
7123 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7124 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7125 int width = gd->width;
7126 int height = gd->height;
7127 int x = scrollbutton_pos[i].x;
7128 int y = scrollbutton_pos[i].y;
7129 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7132 Fail("'scrollbutton_info' structure corrupted at index %d -- please fix", i);
7134 if (id == GADGET_ID_SCROLL_LIST_UP ||
7135 id == GADGET_ID_SCROLL_LIST_DOWN)
7146 gi = CreateGadget(GDI_CUSTOM_ID, id,
7147 GDI_CUSTOM_TYPE_ID, type_id,
7148 GDI_IMAGE_ID, graphic,
7149 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
7154 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7155 GDI_STATE, GD_BUTTON_UNPRESSED,
7156 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7157 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7158 GDI_EVENT_MASK, event_mask,
7159 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7160 GDI_CALLBACK_ACTION, HandleControlButtons,
7164 Fail("cannot create gadget");
7166 level_editor_gadget[id] = gi;
7169 // create buttons for element list
7170 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7173 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
7174 int graphic = IMG_EDITOR_PALETTE_BUTTON;
7175 struct GraphicInfo *gd = &graphic_info[graphic];
7176 Bitmap *gd_bitmap = gd->bitmap;
7177 Bitmap *deco_bitmap;
7178 int deco_x, deco_y, deco_xpos, deco_ypos;
7179 int gd_x1 = gd->src_x;
7180 int gd_y1 = gd->src_y;
7181 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7182 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7183 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
7184 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
7185 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
7186 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
7187 int element = editor_elements[i];
7188 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
7189 unsigned int event_mask = GD_EVENT_RELEASED;
7191 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
7193 deco_xpos = (gd->width - tile_size) / 2;
7194 deco_ypos = (gd->height - tile_size) / 2;
7196 gi = CreateGadget(GDI_CUSTOM_ID, id,
7197 GDI_CUSTOM_TYPE_ID, type_id,
7198 GDI_IMAGE_ID, graphic,
7199 GDI_INFO_TEXT, getElementInfoText(element),
7202 GDI_WIDTH, gd->width,
7203 GDI_HEIGHT, gd->height,
7204 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7205 GDI_STATE, GD_BUTTON_UNPRESSED,
7206 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7207 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7208 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7209 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7210 GDI_DECORATION_SIZE, tile_size, tile_size,
7211 GDI_DECORATION_SHIFTING, 1, 1,
7212 GDI_EVENT_MASK, event_mask,
7213 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7214 GDI_CALLBACK_ACTION, HandleControlButtons,
7218 Fail("cannot create gadget");
7220 level_editor_gadget[id] = gi;
7224 static void CreateCounterButtons(void)
7226 int max_infotext_len = getMaxInfoTextLength();
7229 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
7231 int type_id = counterbutton_info[i].gadget_type_id;
7232 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
7233 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
7237 Fail("'counterbutton_info' structure corrupted at index %d -- please fix", i);
7239 // determine horizontal position to the right of specified gadget
7240 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7241 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
7242 ED_GADGET_TEXT_DISTANCE);
7244 // determine horizontal offset for leading text
7245 if (counterbutton_info[i].text_left != NULL)
7246 x += getTextWidthForGadget(counterbutton_info[i].text_left);
7248 for (j = 0; j < 2; j++)
7250 struct GadgetInfo *gi;
7252 counterbutton_info[i].gadget_id_down :
7253 counterbutton_info[i].gadget_id_up);
7255 struct GraphicInfo *gd;
7256 int gd_x1, gd_x2, gd_y1, gd_y2;
7257 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7258 char infotext[max_infotext_len + 1];
7260 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7263 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
7264 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
7266 event_mask |= GD_EVENT_RELEASED;
7270 x = DX + editor.button.prev_level.x;
7271 y = DY + editor.button.prev_level.y;
7275 x = DX + editor.button.next_level.x;
7276 y = DY + editor.button.next_level.y;
7282 IMG_EDITOR_COUNTER_DOWN :
7283 IMG_EDITOR_COUNTER_UP);
7286 gd = &graphic_info[graphic];
7290 gd_x2 = gd->src_x + gd->pressed_xoffset;
7291 gd_y2 = gd->src_y + gd->pressed_yoffset;
7293 sprintf(infotext, "%s counter value by 1, 5 or 10",
7294 (j == 0 ? "decrease" : "increase"));
7296 gi = CreateGadget(GDI_CUSTOM_ID, id,
7297 GDI_CUSTOM_TYPE_ID, type_id,
7298 GDI_IMAGE_ID, graphic,
7299 GDI_INFO_TEXT, infotext,
7302 GDI_WIDTH, gd->width,
7303 GDI_HEIGHT, gd->height,
7304 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7305 GDI_STATE, GD_BUTTON_UNPRESSED,
7306 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7307 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7308 GDI_EVENT_MASK, event_mask,
7309 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7310 GDI_CALLBACK_ACTION, HandleCounterButtons,
7314 Fail("cannot create gadget");
7316 level_editor_gadget[id] = gi;
7317 right_gadget_border[id] =
7318 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7320 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
7324 int font_type = FONT_INPUT_1;
7325 int font_type_active = FONT_INPUT_1_ACTIVE;
7327 id = counterbutton_info[i].gadget_id_text;
7329 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7331 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7333 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
7335 font_type = FONT_LEVEL_NUMBER;
7336 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
7338 x = DX + editor.input.level_number.x;
7339 y = DY + editor.input.level_number.y;
7343 graphic = IMG_EDITOR_COUNTER_INPUT;
7346 gd = &graphic_info[graphic];
7350 gd_x2 = gd->src_x + gd->active_xoffset;
7351 gd_y2 = gd->src_y + gd->active_yoffset;
7353 gi = CreateGadget(GDI_CUSTOM_ID, id,
7354 GDI_CUSTOM_TYPE_ID, type_id,
7355 GDI_IMAGE_ID, graphic,
7356 GDI_INFO_TEXT, "enter counter value",
7359 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
7360 GDI_NUMBER_VALUE, 0,
7361 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
7362 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
7363 GDI_TEXT_SIZE, 3, // minimal counter text size
7364 GDI_TEXT_FONT, font_type,
7365 GDI_TEXT_FONT_ACTIVE, font_type_active,
7366 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7367 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7368 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7369 GDI_DESIGN_WIDTH, gd->width,
7370 GDI_EVENT_MASK, event_mask,
7371 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7372 GDI_CALLBACK_ACTION, HandleCounterButtons,
7376 Fail("cannot create gadget");
7378 level_editor_gadget[id] = gi;
7379 right_gadget_border[id] =
7380 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7382 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
7388 static void CreateDrawingAreas(void)
7392 // these values are not constant, but can change at runtime
7393 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
7394 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
7396 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
7398 struct GadgetInfo *gi;
7399 int id = drawingarea_info[i].gadget_id;
7400 int type_id = drawingarea_info[i].gadget_type_id;
7401 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
7402 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
7403 int area_xsize = drawingarea_info[i].area_xsize;
7404 int area_ysize = drawingarea_info[i].area_ysize;
7405 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
7406 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
7407 unsigned int event_mask =
7408 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
7409 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
7412 Fail("'drawingarea_info' structure corrupted at index %d -- please fix", i);
7414 // determine horizontal position to the right of specified gadget
7415 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
7416 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
7417 ED_DRAWINGAREA_TEXT_DISTANCE);
7419 // determine horizontal offset for leading text
7420 if (drawingarea_info[i].text_left != NULL)
7421 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
7423 gi = CreateGadget(GDI_CUSTOM_ID, id,
7424 GDI_CUSTOM_TYPE_ID, type_id,
7427 GDI_TYPE, GD_TYPE_DRAWING_AREA,
7428 GDI_AREA_SIZE, area_xsize, area_ysize,
7429 GDI_ITEM_SIZE, item_size, item_size,
7430 GDI_EVENT_MASK, event_mask,
7431 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
7432 GDI_CALLBACK_ACTION, HandleDrawingAreas,
7436 Fail("cannot create gadget");
7438 level_editor_gadget[id] = gi;
7439 right_gadget_border[id] =
7440 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
7444 static void CreateTextInputGadgets(void)
7446 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
7447 int max_infotext_len = getMaxInfoTextLength();
7450 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
7452 int gd_x1 = gd->src_x;
7453 int gd_y1 = gd->src_y;
7454 int gd_x2 = gd->src_x + gd->active_xoffset;
7455 int gd_y2 = gd->src_y + gd->active_yoffset;
7456 struct GadgetInfo *gi;
7457 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7458 char infotext[MAX_OUTPUT_LINESIZE + 1];
7459 int id = textinput_info[i].gadget_id;
7460 int type_id = textinput_info[i].gadget_type_id;
7464 Fail("'textinput_info' structure corrupted at index %d -- please fix", i);
7466 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
7468 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
7469 int border_size = gd->border_size;
7470 int font_nr = FONT_INPUT_1;
7471 int font_height = getFontHeight(font_nr);
7472 int xoffset = element_border + TILEX + element_border + 3 * border_size;
7473 int yoffset = element_border + (TILEY - font_height) / 2;
7475 x = (editor.settings.element_name.x != -1 ?
7476 editor.settings.element_name.x :
7477 editor.settings.element_graphic.x + xoffset) - border_size;
7478 y = (editor.settings.element_name.y != -1 ?
7479 editor.settings.element_name.y :
7480 editor.settings.element_graphic.y + yoffset) - border_size;
7484 x = ED_SETTINGS_X(textinput_info[i].x);
7485 y = ED_SETTINGS_Y(textinput_info[i].y);
7488 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
7489 infotext[max_infotext_len] = '\0';
7491 gi = CreateGadget(GDI_CUSTOM_ID, id,
7492 GDI_CUSTOM_TYPE_ID, type_id,
7493 GDI_INFO_TEXT, infotext,
7496 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
7497 GDI_TEXT_VALUE, textinput_info[i].value,
7498 GDI_TEXT_SIZE, textinput_info[i].size,
7499 GDI_TEXT_FONT, FONT_INPUT_1,
7500 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7501 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7502 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7503 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7504 GDI_DESIGN_WIDTH, gd->width,
7505 GDI_EVENT_MASK, event_mask,
7506 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7507 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
7511 Fail("cannot create gadget");
7513 level_editor_gadget[id] = gi;
7517 static void CreateTextAreaGadgets(void)
7519 int max_infotext_len = getMaxInfoTextLength();
7522 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
7524 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
7525 int gd_x1 = gd->src_x;
7526 int gd_y1 = gd->src_y;
7527 int gd_x2 = gd->src_x + gd->active_xoffset;
7528 int gd_y2 = gd->src_y + gd->active_yoffset;
7529 struct GadgetInfo *gi;
7530 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
7531 char infotext[MAX_OUTPUT_LINESIZE + 1];
7532 int id = textarea_info[i].gadget_id;
7533 int type_id = textarea_info[i].gadget_type_id;
7534 int area_xsize = textarea_info[i].xsize;
7535 int area_ysize = textarea_info[i].ysize;
7538 Fail("'textarea_info' structure corrupted at index %d -- please fix", i);
7540 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
7541 infotext[max_infotext_len] = '\0';
7543 gi = CreateGadget(GDI_CUSTOM_ID, id,
7544 GDI_CUSTOM_TYPE_ID, type_id,
7545 GDI_INFO_TEXT, infotext,
7546 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
7547 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
7548 GDI_TYPE, GD_TYPE_TEXT_AREA,
7549 GDI_AREA_SIZE, area_xsize, area_ysize,
7550 GDI_TEXT_FONT, FONT_INPUT_1,
7551 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7552 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7553 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7554 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7555 GDI_DESIGN_WIDTH, gd->width,
7556 GDI_EVENT_MASK, event_mask,
7557 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7558 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
7562 Fail("cannot create gadget");
7564 level_editor_gadget[id] = gi;
7568 static void CreateSelectboxGadgets(void)
7570 int max_infotext_len = getMaxInfoTextLength();
7573 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7575 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
7576 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
7577 int gd_x1 = gd->src_x;
7578 int gd_y1 = gd->src_y;
7579 int gd_x2 = gd->src_x + gd->active_xoffset;
7580 int gd_y2 = gd->src_y + gd->active_yoffset;
7581 int selectbox_button_xsize = gd2->width;
7582 struct GadgetInfo *gi;
7583 char infotext[MAX_OUTPUT_LINESIZE + 1];
7584 int id = selectbox_info[i].gadget_id;
7585 int type_id = selectbox_info[i].gadget_type_id;
7586 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
7587 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
7588 unsigned int event_mask =
7589 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7592 Fail("'selectbox_info' structure corrupted at index %d -- please fix", i);
7594 if (selectbox_info[i].size == -1) // dynamically determine size
7596 // (we cannot use -1 for uninitialized values if we directly compare
7597 // with results from strlen(), because the '<' and '>' operation will
7598 // implicitely cast -1 to an unsigned integer value!)
7599 selectbox_info[i].size = 0;
7601 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
7602 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
7603 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
7605 selectbox_info[i].size++; // add one character empty space
7608 // determine horizontal position to the right of specified gadget
7609 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
7610 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
7611 ED_GADGET_TEXT_DISTANCE);
7613 // determine horizontal offset for leading text
7614 if (selectbox_info[i].text_left != NULL)
7615 x += getTextWidthForGadget(selectbox_info[i].text_left);
7617 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
7618 infotext[max_infotext_len] = '\0';
7620 gi = CreateGadget(GDI_CUSTOM_ID, id,
7621 GDI_CUSTOM_TYPE_ID, type_id,
7622 GDI_INFO_TEXT, infotext,
7625 GDI_TYPE, GD_TYPE_SELECTBOX,
7626 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
7627 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
7628 GDI_TEXT_SIZE, selectbox_info[i].size,
7629 GDI_TEXT_FONT, FONT_INPUT_1,
7630 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7631 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
7632 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7633 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7634 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7635 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
7636 GDI_DESIGN_WIDTH, gd->width,
7637 GDI_EVENT_MASK, event_mask,
7638 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7639 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
7643 Fail("cannot create gadget");
7645 level_editor_gadget[id] = gi;
7646 right_gadget_border[id] =
7647 getRightGadgetBorder(gi, selectbox_info[i].text_right);
7651 static void CreateTextbuttonGadgets(void)
7653 int max_infotext_len = getMaxInfoTextLength();
7656 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
7658 int id = textbutton_info[i].gadget_id;
7659 int type_id = textbutton_info[i].gadget_type_id;
7661 ((id >= GADGET_ID_LEVELCONFIG_LEVEL && id <= GADGET_ID_LEVELCONFIG_ENGINE) ||
7662 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
7664 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
7665 int gadget_distance =
7666 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
7667 struct GraphicInfo *gd = &graphic_info[graphic];
7668 int gd_x1 = gd->src_x;
7669 int gd_y1 = gd->src_y;
7670 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7671 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7672 int gd_x1a = gd->src_x + gd->active_xoffset;
7673 int gd_y1a = gd->src_y + gd->active_yoffset;
7674 int border_xsize = gd->border_size + gd->draw_xoffset;
7675 int border_ysize = gd->border_size;
7676 struct GadgetInfo *gi;
7677 unsigned int event_mask = GD_EVENT_RELEASED;
7678 char infotext[MAX_OUTPUT_LINESIZE + 1];
7679 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
7680 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
7683 Fail("'textbutton_info' structure corrupted at index %d -- please fix", i);
7685 if (textbutton_info[i].size == -1) // dynamically determine size
7686 textbutton_info[i].size = strlen(textbutton_info[i].text);
7688 sprintf(infotext, "%s", textbutton_info[i].infotext);
7689 infotext[max_infotext_len] = '\0';
7691 // determine horizontal position to the right of specified gadget
7692 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7694 int gadget_id_align = textbutton_info[i].gadget_id_align;
7696 x = right_gadget_border[gadget_id_align] + gadget_distance;
7698 if (textbutton_info[i].y == -1)
7699 y = level_editor_gadget[gadget_id_align]->y;
7702 // determine horizontal offset for leading text
7703 if (textbutton_info[i].text_left != NULL)
7704 x += getTextWidthForGadget(textbutton_info[i].text_left);
7706 gi = CreateGadget(GDI_CUSTOM_ID, id,
7707 GDI_CUSTOM_TYPE_ID, type_id,
7708 GDI_IMAGE_ID, graphic,
7709 GDI_INFO_TEXT, infotext,
7712 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
7713 GDI_TEXT_VALUE, textbutton_info[i].text,
7714 GDI_TEXT_SIZE, textbutton_info[i].size,
7715 GDI_TEXT_FONT, FONT_INPUT_2,
7716 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
7717 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7718 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7719 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7720 GDI_BORDER_SIZE, border_xsize, border_ysize,
7721 GDI_DESIGN_WIDTH, gd->width,
7722 GDI_DECORATION_SHIFTING, 1, 1,
7723 GDI_EVENT_MASK, event_mask,
7724 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7725 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7729 Fail("cannot create gadget");
7731 level_editor_gadget[id] = gi;
7732 right_gadget_border[id] =
7733 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7737 static void CreateGraphicbuttonGadgets(void)
7739 struct GadgetInfo *gi;
7742 // create buttons for scrolling of drawing area and element list
7743 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7745 int id = graphicbutton_info[i].gadget_id;
7746 int type_id = graphicbutton_info[i].gadget_type_id;
7747 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7748 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7749 int graphic = graphicbutton_info[i].graphic;
7750 struct GraphicInfo *gd = &graphic_info[graphic];
7751 int gd_x1 = gd->src_x;
7752 int gd_y1 = gd->src_y;
7753 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7754 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7755 unsigned int event_mask = GD_EVENT_RELEASED;
7758 Fail("'graphicbutton_info' structure corrupted at index %d -- please fix", i);
7760 // determine horizontal position to the right of specified gadget
7761 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7762 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7763 ED_GADGET_TEXT_DISTANCE);
7765 // determine horizontal offset for leading text
7766 if (graphicbutton_info[i].text_left != NULL)
7767 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7769 gi = CreateGadget(GDI_CUSTOM_ID, id,
7770 GDI_CUSTOM_TYPE_ID, type_id,
7771 GDI_IMAGE_ID, graphic,
7772 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7775 GDI_WIDTH, gd->width,
7776 GDI_HEIGHT, gd->height,
7777 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7778 GDI_STATE, GD_BUTTON_UNPRESSED,
7779 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7780 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7781 GDI_EVENT_MASK, event_mask,
7782 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7783 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7787 Fail("cannot create gadget");
7789 level_editor_gadget[id] = gi;
7790 right_gadget_border[id] =
7791 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7795 static void CreateScrollbarGadgets(void)
7799 // these values are not constant, but can change at runtime
7800 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7801 SX + ED_SCROLL_HORIZONTAL_XPOS;
7802 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7803 SY + ED_SCROLL_HORIZONTAL_YPOS;
7804 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7805 ED_SCROLL_HORIZONTAL_XSIZE;
7806 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7807 ED_SCROLL_HORIZONTAL_YSIZE;
7808 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7809 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7810 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7811 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7813 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7814 SX + ED_SCROLL_VERTICAL_XPOS;
7815 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7816 SY + ED_SCROLL_VERTICAL_YPOS;
7817 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7818 ED_SCROLL_VERTICAL_XSIZE;
7819 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7820 ED_SCROLL_VERTICAL_YSIZE;
7821 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7822 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7823 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7824 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7826 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7827 PX + ED_SCROLL2_VERTICAL_XPOS;
7828 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7829 PY + ED_SCROLL2_VERTICAL_YPOS;
7830 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7831 ED_SCROLL2_VERTICAL_XSIZE;
7832 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7833 ED_SCROLL2_VERTICAL_YSIZE;
7834 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7835 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7836 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7837 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7839 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7841 int id = scrollbar_info[i].gadget_id;
7842 int type_id = scrollbar_info[i].gadget_type_id;
7843 int graphic = scrollbar_info[i].graphic;
7844 struct GraphicInfo *gd = &graphic_info[graphic];
7845 int gd_x1 = gd->src_x;
7846 int gd_y1 = gd->src_y;
7847 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7848 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7849 struct GadgetInfo *gi;
7850 int items_max, items_visible, item_position;
7851 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7854 Fail("'scrollbar_info' structure corrupted at index %d -- please fix", i);
7856 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7858 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7859 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7860 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7862 else // drawing area scrollbars
7864 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7866 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7867 items_visible = ed_fieldx;
7872 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7873 items_visible = ed_fieldy;
7878 gi = CreateGadget(GDI_CUSTOM_ID, id,
7879 GDI_CUSTOM_TYPE_ID, type_id,
7880 GDI_IMAGE_ID, graphic,
7881 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7882 GDI_X, scrollbar_pos[i].x,
7883 GDI_Y, scrollbar_pos[i].y,
7884 GDI_WIDTH, scrollbar_pos[i].width,
7885 GDI_HEIGHT, scrollbar_pos[i].height,
7886 GDI_TYPE, scrollbar_info[i].type,
7887 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7888 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7889 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7890 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7891 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7892 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7893 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7894 GDI_STATE, GD_BUTTON_UNPRESSED,
7895 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7896 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7897 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7898 GDI_EVENT_MASK, event_mask,
7899 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7900 GDI_CALLBACK_ACTION, HandleControlButtons,
7904 Fail("cannot create gadget");
7906 level_editor_gadget[id] = gi;
7910 static void CreateCheckbuttonGadgets(void)
7912 struct GadgetInfo *gi;
7915 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7917 int id = checkbutton_info[i].gadget_id;
7918 int type_id = checkbutton_info[i].gadget_type_id;
7919 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7920 IMG_EDITOR_CHECKBOX);
7921 struct GraphicInfo *gd = &graphic_info[graphic];
7922 int gd_x1 = gd->src_x;
7923 int gd_y1 = gd->src_y;
7924 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7925 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7926 int gd_x1a = gd->src_x + gd->active_xoffset;
7927 int gd_y1a = gd->src_y + gd->active_yoffset;
7928 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7929 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7930 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7931 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7932 unsigned int event_mask = GD_EVENT_PRESSED;
7935 Fail("'checkbutton_info' structure corrupted at index %d -- please fix", i);
7937 // determine horizontal position to the right of specified gadget
7938 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7939 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7940 ED_GADGET_TEXT_DISTANCE);
7942 // determine horizontal offset for leading text
7943 if (checkbutton_info[i].text_left != NULL)
7944 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7946 gi = CreateGadget(GDI_CUSTOM_ID, id,
7947 GDI_CUSTOM_TYPE_ID, type_id,
7948 GDI_IMAGE_ID, graphic,
7949 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7952 GDI_WIDTH, gd->width,
7953 GDI_HEIGHT, gd->height,
7954 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7955 GDI_CHECKED, *checkbutton_info[i].value,
7956 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7957 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7958 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7959 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7960 GDI_EVENT_MASK, event_mask,
7961 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7962 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7966 Fail("cannot create gadget");
7968 level_editor_gadget[id] = gi;
7969 right_gadget_border[id] =
7970 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7974 static void CreateRadiobuttonGadgets(void)
7976 int graphic = IMG_EDITOR_RADIOBUTTON;
7977 struct GraphicInfo *gd = &graphic_info[graphic];
7978 int gd_x1 = gd->src_x;
7979 int gd_y1 = gd->src_y;
7980 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7981 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7982 int gd_x1a = gd->src_x + gd->active_xoffset;
7983 int gd_y1a = gd->src_y + gd->active_yoffset;
7984 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7985 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7986 struct GadgetInfo *gi;
7989 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7991 int id = radiobutton_info[i].gadget_id;
7992 int type_id = radiobutton_info[i].gadget_type_id;
7993 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7994 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7995 unsigned int event_mask = GD_EVENT_PRESSED;
7998 Fail("'radiobutton_info' structure corrupted at index %d -- please fix", i);
8001 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
8003 // determine horizontal position to the right of specified gadget
8004 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
8005 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
8006 ED_GADGET_TEXT_DISTANCE);
8008 // determine horizontal offset for leading text
8009 if (radiobutton_info[i].text_left != NULL)
8010 x += getTextWidthForGadget(radiobutton_info[i].text_left);
8012 gi = CreateGadget(GDI_CUSTOM_ID, id,
8013 GDI_CUSTOM_TYPE_ID, type_id,
8014 GDI_IMAGE_ID, graphic,
8015 GDI_INFO_TEXT, radiobutton_info[i].infotext,
8018 GDI_WIDTH, gd->width,
8019 GDI_HEIGHT, gd->height,
8020 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
8021 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
8022 GDI_CHECKED, checked,
8023 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
8024 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
8025 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
8026 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
8027 GDI_EVENT_MASK, event_mask,
8028 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
8029 GDI_CALLBACK_ACTION, HandleRadiobuttons,
8033 Fail("cannot create gadget");
8035 level_editor_gadget[id] = gi;
8036 right_gadget_border[id] =
8037 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
8041 void CreateLevelEditorGadgets(void)
8043 // force EDITOR font inside level editor
8044 SetFontStatus(GAME_MODE_EDITOR);
8046 // these values are not constant, but can change at runtime
8047 ed_fieldx = MAX_ED_FIELDX - 1;
8048 ed_fieldy = MAX_ED_FIELDY - 1;
8050 num_editor_gadgets = NUM_EDITOR_GADGETS;
8052 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
8054 level_editor_gadget =
8055 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
8056 right_gadget_border =
8057 checked_calloc(num_editor_gadgets * sizeof(int));
8059 // set number of empty (padding) element buttons to maximum number of buttons
8060 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
8062 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
8063 editor_el_empty_ptr = editor_el_empty;
8065 use_permanent_palette = !editor.palette.show_as_separate_screen;
8067 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
8069 ReinitializeElementList();
8071 CreateControlButtons();
8072 CreateScrollbarGadgets();
8074 // order of function calls is important because of cross-references
8075 CreateCheckbuttonGadgets();
8076 CreateCounterButtons();
8077 CreateRadiobuttonGadgets();
8078 CreateTextInputGadgets();
8079 CreateTextAreaGadgets();
8080 CreateSelectboxGadgets();
8081 CreateGraphicbuttonGadgets();
8082 CreateTextbuttonGadgets();
8083 CreateDrawingAreas();
8088 void FreeLevelEditorGadgets(void)
8092 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
8094 for (i = 0; i < num_editor_gadgets; i++)
8096 FreeGadget(level_editor_gadget[i]);
8098 level_editor_gadget[i] = NULL;
8101 checked_free(level_editor_gadget);
8102 checked_free(right_gadget_border);
8104 checked_free(editor_el_empty);
8107 static void MapCounterButtons(int id)
8109 int font_nr = FONT_TEXT_1;
8110 int font_height = getFontHeight(font_nr);
8111 int gadget_id_down = counterbutton_info[id].gadget_id_down;
8112 int gadget_id_text = counterbutton_info[id].gadget_id_text;
8113 int gadget_id_up = counterbutton_info[id].gadget_id_up;
8114 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
8115 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
8116 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8117 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
8118 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8119 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8120 int yoffset = (gi_down->height - font_height) / 2;
8121 int x_left = gi_down->x - xoffset_left;
8122 int x_right; // set after gadget position was modified
8123 int y_above = gi_down->y - yoffset_above;
8125 int y; // set after gadget position was modified
8127 // counter limits must be changed first to prevent value truncation
8128 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
8129 counterbutton_info[id].max_value);
8131 // right text position might have changed after setting position above
8132 x_right = gi_up->x + gi_up->width + xoffset_right;
8134 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
8136 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
8137 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
8138 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
8140 ModifyGadget(gi_down, GDI_Y,
8141 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8142 ModifyGadget(gi_text, GDI_Y,
8143 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8144 ModifyGadget(gi_up, GDI_Y,
8145 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
8148 // vertical position might have changed after setting position above
8149 y = gi_up->y + yoffset;
8151 if (counterbutton_info[id].text_above)
8152 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
8154 if (counterbutton_info[id].text_left)
8155 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
8157 if (counterbutton_info[id].text_right)
8158 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
8165 static void MapControlButtons(void)
8170 // map toolbox buttons (excluding special CE toolbox buttons)
8171 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
8172 MapGadget(level_editor_gadget[i]);
8174 // map toolbox buttons (element properties buttons)
8175 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
8176 MapGadget(level_editor_gadget[i]);
8178 if (use_permanent_palette)
8180 // map buttons to select elements
8181 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8182 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
8183 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
8184 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
8185 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
8188 // map buttons to select level
8189 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
8190 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
8191 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
8192 MapCounterButtons(counter_id);
8195 static void MapDrawingArea(int id)
8197 int font_nr = FONT_TEXT_1;
8198 int font_height = getFontHeight(font_nr);
8199 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8200 int area_xsize = gi->drawing.area_xsize;
8201 int area_ysize = gi->drawing.area_ysize;
8202 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8203 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
8204 int x_left = gi->x - xoffset_left;
8205 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
8206 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
8207 int x_below = gi->x + (gi->width - xoffset_below) / 2;
8208 int y_side = gi->y + (gi->height - font_height) / 2;
8209 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
8210 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
8212 if (drawingarea_info[id].text_left)
8213 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
8215 if (drawingarea_info[id].text_right)
8216 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
8218 if (drawingarea_info[id].text_above)
8219 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
8221 if (drawingarea_info[id].text_below)
8222 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
8224 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
8226 DrawElementBorder(gi->x, gi->y,
8227 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
8228 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
8230 DrawDrawingArea(id);
8236 static void MapTextInputGadget(int id)
8238 int font_nr = FONT_TEXT_1;
8239 int font_height = getFontHeight(font_nr);
8240 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
8241 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8242 int x_above = ED_SETTINGS_X(textinput_info[id].x);
8243 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
8245 if (textinput_info[id].text_above)
8246 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
8248 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
8253 static void MapTextAreaGadget(int id)
8255 int font_nr = FONT_TEXT_1;
8256 int font_height = getFontHeight(font_nr);
8257 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8258 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8259 int x_above = ED_SETTINGS_X(textarea_info[id].x);
8260 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
8261 char *text_above = textarea_info[id].text_above;
8263 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
8264 text_above = textarea_info[id].text_above_cropped;
8267 DrawTextS(x_above, y_above, font_nr, text_above);
8269 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
8274 static void MapSelectboxGadget(int id)
8276 int font_nr = FONT_TEXT_1;
8277 int font_height = getFontHeight(font_nr);
8278 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
8279 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
8280 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8281 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8282 int yoffset = (gi->height - font_height) / 2;
8283 int x_left = gi->x - xoffset_left;
8284 int x_right = gi->x + gi->width + xoffset_right;
8285 int y_above = gi->y - yoffset_above;
8287 int y = gi->y + yoffset;
8289 if (selectbox_info[id].text_above)
8290 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
8292 if (selectbox_info[id].text_left)
8293 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
8295 if (selectbox_info[id].text_right)
8296 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
8298 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
8303 static void MapTextbuttonGadget(int id)
8305 int font_nr = FONT_TEXT_1;
8306 int font_height = getFontHeight(font_nr);
8307 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
8308 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
8309 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8310 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8311 int yoffset = (gi->height - font_height) / 2;
8312 int x_left = gi->x - xoffset_left;
8313 int x_right = gi->x + gi->width + xoffset_right;
8314 int y_above = gi->y - yoffset_above;
8316 int y = gi->y + yoffset;
8318 // only show button to delete change pages when more than minimum pages
8319 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
8320 custom_element.num_change_pages == MIN_CHANGE_PAGES)
8323 if (textbutton_info[id].text_above)
8324 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
8326 if (textbutton_info[id].text_left)
8327 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
8329 if (textbutton_info[id].text_right)
8330 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
8335 static void MapGraphicbuttonGadget(int id)
8337 int font_nr = FONT_TEXT_1;
8338 int font_height = getFontHeight(font_nr);
8339 struct GadgetInfo *gi = level_editor_gadget[graphicbutton_info[id].gadget_id];
8340 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
8341 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8342 int yoffset = (gi->height - font_height) / 2;
8343 int x_left = gi->x - xoffset_left;
8344 int x_right = gi->x + gi->width + xoffset_right;
8345 int y = gi->y + yoffset;
8347 if (graphicbutton_info[id].text_left)
8348 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
8350 if (graphicbutton_info[id].text_right)
8351 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
8356 static void MapRadiobuttonGadget(int id)
8358 int font_nr = FONT_TEXT_1;
8359 int font_height = getFontHeight(font_nr);
8360 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
8361 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8362 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8363 int yoffset = (gi->height - font_height) / 2;
8364 int x_left = gi->x - xoffset_left;
8365 int x_right = gi->x + gi->width + xoffset_right;
8366 int y = gi->y + yoffset;
8368 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
8370 if (radiobutton_info[id].text_left)
8371 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
8373 if (radiobutton_info[id].text_right)
8374 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
8376 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
8381 static void MapCheckbuttonGadget(int id)
8383 int font_nr = FONT_TEXT_1;
8384 int font_height = getFontHeight(font_nr);
8385 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
8386 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8387 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8388 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8389 int yoffset = (gi->height - font_height) / 2;
8390 int y_above = gi->y - yoffset_above;
8392 int x_left, x_right, y; // set after gadget position was modified
8394 // set position for gadgets with dynamically determined position
8395 if (checkbutton_info[id].x != -1) // do not change dynamic positions
8396 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x), GDI_END);
8397 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
8399 x_left = gi->x - xoffset_left;
8400 x_right = gi->x + gi->width + xoffset_right;
8401 y = gi->y + yoffset;
8403 if (checkbutton_info[id].text_above)
8404 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
8406 if (checkbutton_info[id].text_left)
8407 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
8409 if (checkbutton_info[id].text_right)
8410 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
8412 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
8417 static void MapMainDrawingArea(void)
8419 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
8420 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
8423 if (suppressBorderElement())
8425 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
8426 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
8429 for (i = ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
8431 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
8432 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
8433 no_horizontal_scrollbar) ||
8434 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
8435 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
8436 no_vertical_scrollbar))
8439 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
8442 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
8444 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
8445 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
8448 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
8451 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
8454 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
8458 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
8460 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
8461 i == GADGET_ID_CUSTOM_COPY_TO ||
8462 i == GADGET_ID_CUSTOM_EXCHANGE ||
8463 i == GADGET_ID_CUSTOM_COPY ||
8464 i == GADGET_ID_CUSTOM_PASTE)
8467 MapGadget(level_editor_gadget[i]);
8469 UnmapGadget(level_editor_gadget[i]);
8474 static void MapLevelEditorToolboxCustomGadgets(void)
8476 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
8479 static void MapLevelEditorToolboxCustomGadgetsIfNeeded(void)
8481 if (IS_CUSTOM_ELEMENT(properties_element) ||
8482 IS_GROUP_ELEMENT(properties_element) ||
8483 IS_EMPTY_ELEMENT(properties_element))
8484 MapLevelEditorToolboxCustomGadgets();
8487 static void UnmapLevelEditorToolboxCustomGadgets(void)
8489 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
8492 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
8496 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
8498 if (i != GADGET_ID_SINGLE_ITEMS &&
8499 i != GADGET_ID_PICK_ELEMENT)
8501 struct GadgetInfo *gi = level_editor_gadget[i];
8509 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
8510 struct GraphicInfo *gd = &graphic_info[graphic];
8514 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
8515 gi->width, gi->height, gi->x, gi->y);
8517 redraw_mask |= REDRAW_DOOR_3;
8523 static void MapLevelEditorToolboxDrawingGadgets(void)
8525 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
8528 static void UnmapLevelEditorToolboxDrawingGadgets(void)
8530 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
8533 static void UnmapDrawingArea(int id)
8535 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
8538 static void UnmapLevelEditorFieldGadgets(void)
8542 for (i = 0; i < num_editor_gadgets; i++)
8543 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
8544 level_editor_gadget[i]->y))
8545 UnmapGadget(level_editor_gadget[i]);
8548 void UnmapLevelEditorGadgets(void)
8552 for (i = 0; i < num_editor_gadgets; i++)
8553 UnmapGadget(level_editor_gadget[i]);
8556 static void ResetUndoBuffer(void)
8558 undo_buffer_position = -1;
8559 undo_buffer_steps = -1;
8560 redo_buffer_steps = 0;
8562 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8564 level.changed = FALSE;
8567 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
8569 if (remap_toolbox_gadgets)
8571 ModifyEditorElementList();
8572 RedrawDrawingElements();
8575 if (edit_mode == ED_MODE_LEVELCONFIG)
8576 DrawLevelConfigWindow();
8577 else if (edit_mode == ED_MODE_PROPERTIES)
8578 DrawPropertiesWindow();
8579 else if (edit_mode == ED_MODE_PALETTE)
8580 DrawPaletteWindow();
8581 else // edit_mode == ED_MODE_DRAWING
8582 DrawDrawingWindowExt(remap_toolbox_gadgets);
8585 static void DrawEditModeWindow(void)
8587 DrawEditModeWindowExt(TRUE);
8590 static void DrawEditModeWindow_PlayfieldOnly(void)
8592 DrawEditModeWindowExt(FALSE);
8595 static void ChangeEditModeWindow(int new_edit_mode)
8597 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
8599 DrawEditModeWindow();
8602 static boolean LevelChanged(void)
8604 boolean field_changed = FALSE;
8607 for (y = 0; y < lev_fieldy; y++)
8608 for (x = 0; x < lev_fieldx; x++)
8609 if (Tile[x][y] != level.field[x][y])
8610 field_changed = TRUE;
8612 return (level.changed || field_changed);
8615 static boolean PrepareSavingIntoPersonalLevelSet(void)
8617 static LevelDirTree *last_copied_leveldir = NULL;
8618 static LevelDirTree *last_written_leveldir = NULL;
8619 static int last_copied_level_nr = -1;
8620 static int last_written_level_nr = -1;
8621 LevelDirTree *leveldir_former = leveldir_current;
8622 int level_nr_former = level_nr;
8625 // remember last mod/save so that for current session, we write
8626 // back to the same personal copy, asking only about overwrite.
8627 if (leveldir_current == last_copied_leveldir &&
8628 level_nr == last_copied_level_nr)
8630 // "cd" to personal level set dir (as used when writing last copy)
8631 leveldir_current = last_written_leveldir;
8632 level_nr = last_written_level_nr;
8637 if (!Request("This level is read-only! "
8638 "Save into personal level set?", REQ_ASK))
8641 // "cd" to personal level set dir (for writing copy the first time)
8643 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
8645 // this may happen if "setup.internal.create_user_levelset" is FALSE
8646 // or if file "levelinfo.conf" is missing in personal user level set
8647 if (leveldir_current == NULL)
8649 Request("Cannot find personal level set?!", REQ_CONFIRM);
8651 leveldir_current = leveldir_former;
8656 // find unused level number
8657 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
8659 static char *level_filename = NULL;
8661 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
8663 if (!fileExists(level_filename))
8667 last_copied_leveldir = leveldir_former;
8668 last_copied_level_nr = level_nr_former;
8670 last_written_leveldir = leveldir_current;
8671 last_written_level_nr = level_nr = new_level_nr;
8676 static void ModifyLevelConfigForSavingIntoPersonalLevelSet(char *former_name)
8678 static char *filename_levelinfo = NULL, *mod_name = NULL;
8681 // annotate this copy-and-mod in personal levelinfo.conf
8682 setString(&filename_levelinfo,
8683 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
8685 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
8687 fprintf(file, "\n");
8688 fprintf(file, "# level %d was modified from:\n", level_nr);
8689 fprintf(file, "# - previous level set name: %s\n",
8691 fprintf(file, "# - level within previous set: %d \"%s\"\n",
8692 level.file_info.nr, level.name);
8693 fprintf(file, "# - previous author: %s\n",
8695 fprintf(file, "# - previous save date: ");
8697 if (level.creation_date.src == DATE_SRC_LEVELFILE)
8699 fprintf(file, "%04d-%02d-%02d\n",
8700 level.creation_date.year,
8701 level.creation_date.month,
8702 level.creation_date.day);
8706 fprintf(file, "not recorded\n");
8712 if (level_nr > leveldir_current->last_level)
8713 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
8715 // else: allow the save even if annotation failed
8717 // now... spray graffiti on the old level vital statistics
8718 // user can change these; just trying to set a good baseline
8720 // don't truncate names for fear of making offensive or silly:
8721 // long-named original author only recorded in levelinfo.conf.
8722 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
8723 if (!strEqual(level.author, leveldir_current->author))
8725 setString(&mod_name, getStringCat3(leveldir_current->author,
8726 " after ", level.author));
8728 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8729 setString(&mod_name,
8730 getStringCat2(leveldir_current->author, " (ed.)"));
8732 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8733 setString(&mod_name, leveldir_current->author);
8735 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
8737 // less worried about truncation here
8738 setString(&mod_name, getStringCat2("Mod: ", level.name));
8739 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
8743 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
8744 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8748 for (x = 0; x < lev_fieldx; x++)
8749 for (y = 0; y < lev_fieldy; y++)
8750 dst[x][y] = src[x][y];
8753 static int setSelectboxValue(int selectbox_id, int new_value)
8755 int new_index_value = 0;
8758 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8759 if (selectbox_info[selectbox_id].options[i].value == new_value)
8760 new_index_value = i;
8762 *selectbox_info[selectbox_id].value =
8763 selectbox_info[selectbox_id].options[new_index_value].value;
8765 return new_index_value;
8768 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8772 // change action mode and arg variables according to action type variable
8773 for (i = 0; action_arg_options[i].value != -1; i++)
8775 if (action_arg_options[i].value == custom_element_change.action_type)
8777 int mode = action_arg_options[i].mode;
8779 // only change if corresponding selectbox has changed
8780 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8781 action_arg_modes[mode])
8782 custom_element_change.action_mode = -1;
8784 // only change if corresponding selectbox has changed
8785 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8786 action_arg_options[i].options)
8787 custom_element_change.action_arg = -1;
8794 static void setSelectboxSpecialActionOptions(void)
8798 // change action mode and arg selectbox according to action type selectbox
8799 for (i = 0; action_arg_options[i].value != -1; i++)
8801 if (action_arg_options[i].value == custom_element_change.action_type)
8803 int mode = action_arg_options[i].mode;
8805 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8806 action_arg_modes[mode]);
8807 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8808 custom_element_change.action_mode);
8810 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8811 action_arg_options[i].options);
8812 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8813 custom_element_change.action_arg);
8819 static void copy_custom_element_settings(int element_from, int element_to)
8821 struct ElementInfo *ei_from = &element_info[element_from];
8822 struct ElementInfo *ei_to = &element_info[element_to];
8824 copyElementInfo(ei_from, ei_to);
8827 static void replace_custom_element_in_settings(int element_from,
8832 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8834 struct ElementInfo *ei = &element_info[i];
8836 for (y = 0; y < 3; y++)
8837 for (x = 0; x < 3; x++)
8838 if (ei->content.e[x][y] == element_from)
8839 ei->content.e[x][y] = element_to;
8841 for (j = 0; j < ei->num_change_pages; j++)
8843 struct ElementChangeInfo *change = &ei->change_page[j];
8845 if (change->target_element == element_from)
8846 change->target_element = element_to;
8848 if (change->initial_trigger_element == element_from)
8849 change->initial_trigger_element = element_to;
8851 if (change->action_element == element_from)
8852 change->action_element = element_to;
8854 for (y = 0; y < 3; y++)
8855 for (x = 0; x < 3; x++)
8856 if (change->target_content.e[x][y] == element_from)
8857 change->target_content.e[x][y] = element_to;
8860 if (ei->group != NULL) // group or internal
8861 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8862 if (ei->group->element[j] == element_from)
8863 ei->group->element[j] = element_to;
8867 static void replace_custom_element_in_playfield(int element_from,
8872 for (x = 0; x < lev_fieldx; x++)
8873 for (y = 0; y < lev_fieldy; y++)
8874 if (Tile[x][y] == element_from)
8875 Tile[x][y] = element_to;
8878 static boolean CopyCustomElement(int element_old, int element_new,
8881 int copy_mode_orig = copy_mode;
8883 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8885 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8886 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8887 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8889 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8891 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8892 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8893 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8895 level.changed = TRUE;
8897 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8899 Request("Please choose custom element!", REQ_CONFIRM);
8903 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8905 Request("Please choose group element!", REQ_CONFIRM);
8909 else if (IS_EMPTY_ELEMENT(element_old) && !IS_EMPTY_ELEMENT(element_new))
8911 Request("Please choose empty element!", REQ_CONFIRM);
8917 level.changed = TRUE;
8920 // when modifying custom/group element, ask for copying level template
8921 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8923 if (!AskToCopyAndModifyLevelTemplate())
8927 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8929 copy_custom_element_settings(element_new, element_old);
8931 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8933 copy_custom_element_settings(element_old, element_new);
8935 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8937 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8938 copy_custom_element_settings(element_new, element_old);
8939 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8941 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8942 replace_custom_element_in_settings(element_new, element_old);
8943 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8945 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8946 replace_custom_element_in_playfield(element_new, element_old);
8947 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8950 UpdateCustomElementGraphicGadgets();
8951 DrawPropertiesWindow();
8956 static void CopyCustomElementPropertiesToEditor(int element)
8959 int current_change_page = element_info[element].current_change_page;
8961 // dynamically (re)build selectbox for selecting change page
8962 for (i = 0; i < element_info[element].num_change_pages; i++)
8964 sprintf(options_change_page_strings[i], "%d", i + 1);
8966 options_change_page[i].value = i;
8967 options_change_page[i].text = options_change_page_strings[i];
8970 options_change_page[i].value = -1;
8971 options_change_page[i].text = NULL;
8973 // needed here to initialize combined element properties
8974 InitElementPropertiesEngine(level.game_version);
8976 element_info[element].change =
8977 &element_info[element].change_page[current_change_page];
8979 custom_element = element_info[element];
8980 custom_element_change = *element_info[element].change;
8982 // needed to initially set selectbox options for special action options
8983 setSelectboxSpecialActionOptions();
8985 // needed to initially set selectbox value variables to reliable defaults
8986 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8987 setSelectboxValue(i, *selectbox_info[i].value);
8989 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8990 custom_element_properties[i] = HAS_PROPERTY(element, i);
8992 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8993 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8995 // ---------- element settings: configure (custom elements) -----------------
8997 // set accessible layer selectbox help value
8998 custom_element.access_type =
8999 (IS_WALKABLE(element) ? EP_WALKABLE :
9000 IS_PASSABLE(element) ? EP_PASSABLE :
9001 custom_element.access_type);
9002 custom_element.access_layer =
9003 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
9004 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
9005 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
9006 custom_element.access_layer);
9007 custom_element.access_protected =
9008 (IS_PROTECTED(element) ? 1 : 0);
9009 custom_element_properties[EP_ACCESSIBLE] =
9010 (IS_ACCESSIBLE_OVER(element) ||
9011 IS_ACCESSIBLE_INSIDE(element) ||
9012 IS_ACCESSIBLE_UNDER(element));
9014 // set walk-to-object action selectbox help value
9015 custom_element.walk_to_action =
9016 (IS_DIGGABLE(element) ? EP_DIGGABLE :
9017 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
9018 IS_DROPPABLE(element) ? EP_DROPPABLE :
9019 IS_THROWABLE(element) ? EP_THROWABLE :
9020 IS_PUSHABLE(element) ? EP_PUSHABLE :
9021 custom_element.walk_to_action);
9022 custom_element_properties[EP_WALK_TO_OBJECT] =
9023 (IS_DIGGABLE(element) ||
9024 IS_COLLECTIBLE_ONLY(element) ||
9025 IS_DROPPABLE(element) ||
9026 IS_THROWABLE(element) ||
9027 IS_PUSHABLE(element));
9029 // set smash targets selectbox help value
9030 custom_element.smash_targets =
9031 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
9032 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
9033 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
9034 custom_element.smash_targets);
9035 custom_element_properties[EP_CAN_SMASH] =
9036 (CAN_SMASH_EVERYTHING(element) ||
9037 CAN_SMASH_ENEMIES(element) ||
9038 CAN_SMASH_PLAYER(element));
9040 // set deadliness selectbox help value
9041 custom_element.deadliness =
9042 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
9043 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
9044 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
9045 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
9046 custom_element.deadliness);
9047 custom_element_properties[EP_DEADLY] =
9048 (DONT_TOUCH(element) ||
9049 DONT_GET_HIT_BY(element) ||
9050 DONT_COLLIDE_WITH(element) ||
9051 DONT_RUN_INTO(element));
9053 // ---------- element settings: advanced (custom elements) ------------------
9055 // set "change by direct action" selectbox help value
9056 custom_element_change.direct_action =
9057 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
9058 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
9059 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
9060 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
9061 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
9062 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
9063 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
9064 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
9065 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
9066 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
9067 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
9068 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
9069 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
9070 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
9071 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
9072 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
9073 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
9074 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
9075 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
9076 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
9077 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
9078 custom_element_change.direct_action);
9080 // set "change by other element action" selectbox help value
9081 custom_element_change.other_action =
9082 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
9083 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
9084 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
9085 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
9086 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
9087 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
9088 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
9089 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
9090 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
9091 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
9092 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
9093 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
9094 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
9095 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
9096 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
9097 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
9098 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
9099 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
9100 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
9101 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
9102 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
9103 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
9104 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
9105 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
9106 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
9107 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
9108 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
9109 custom_element_change.other_action);
9112 static void CopyGroupElementPropertiesToEditor(int element)
9114 group_element_info = *element_info[element].group;
9115 custom_element = element_info[element]; // needed for description
9118 static void CopyEmptyElementPropertiesToEditor(int element)
9120 custom_element = element_info[element];
9123 static void CopyClassicElementPropertiesToEditor(int element)
9125 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9126 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
9127 getMoveIntoAcidProperty(&level, element);
9129 if (MAYBE_DONT_COLLIDE_WITH(element))
9130 custom_element_properties[EP_DONT_COLLIDE_WITH] =
9131 getDontCollideWithProperty(&level, element);
9134 static void CopyElementPropertiesToEditor(int element)
9136 if (IS_CUSTOM_ELEMENT(element))
9137 CopyCustomElementPropertiesToEditor(element);
9138 else if (IS_GROUP_ELEMENT(element))
9139 CopyGroupElementPropertiesToEditor(element);
9140 else if (IS_EMPTY_ELEMENT(element))
9141 CopyEmptyElementPropertiesToEditor(element);
9143 CopyClassicElementPropertiesToEditor(element);
9146 static boolean AskToCopyAndModifyLevelTemplate(void)
9148 if (Request("Copy and modify settings from level template?", REQ_ASK))
9150 level.use_custom_template = FALSE;
9152 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
9153 GDI_CHECKED, FALSE, GDI_END);
9154 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
9155 GDI_CHECKED, FALSE, GDI_END);
9161 LoadLevelTemplate(-1); // this resets all element modifications ...
9163 DrawEditModeWindow(); // ... and copies them to 'custom_element'
9169 static void CopyCustomElementPropertiesToGame(int element)
9172 int access_type_and_layer;
9174 // mark that this custom element has been modified
9175 custom_element.modified_settings = TRUE;
9176 level.changed = TRUE;
9178 if (level.use_custom_template)
9179 AskToCopyAndModifyLevelTemplate();
9181 element_info[element] = custom_element;
9182 *element_info[element].change = custom_element_change;
9184 // ---------- element settings: configure (custom elements) -----------------
9186 // set accessible property from checkbox and selectbox
9187 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
9188 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
9189 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
9190 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
9191 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
9192 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
9193 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
9194 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
9195 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
9196 custom_element_properties[access_type_and_layer] =
9197 custom_element_properties[EP_ACCESSIBLE];
9198 custom_element_properties[EP_PROTECTED] =
9199 (custom_element.access_protected != 0 &&
9200 custom_element_properties[EP_ACCESSIBLE]);
9202 // set walk-to-object property from checkbox and selectbox
9203 custom_element_properties[EP_DIGGABLE] = FALSE;
9204 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
9205 custom_element_properties[EP_DROPPABLE] = FALSE;
9206 custom_element_properties[EP_THROWABLE] = FALSE;
9207 custom_element_properties[EP_PUSHABLE] = FALSE;
9208 custom_element_properties[custom_element.walk_to_action] =
9209 custom_element_properties[EP_WALK_TO_OBJECT];
9211 // set smash property from checkbox and selectbox
9212 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
9213 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
9214 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
9215 custom_element_properties[custom_element.smash_targets] =
9216 custom_element_properties[EP_CAN_SMASH];
9218 // set deadliness property from checkbox and selectbox
9219 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
9220 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
9221 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
9222 custom_element_properties[EP_DONT_TOUCH] = FALSE;
9223 custom_element_properties[custom_element.deadliness] =
9224 custom_element_properties[EP_DEADLY];
9226 // ---------- element settings: advanced (custom elements) ------------------
9228 // set player change event from checkbox and selectbox
9229 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
9230 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
9231 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
9232 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
9233 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
9234 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
9235 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
9236 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
9237 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
9238 custom_element_change_events[CE_SWITCHED] = FALSE;
9239 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
9240 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
9241 custom_element_change_events[CE_BLOCKED] = FALSE;
9242 custom_element_change_events[CE_IMPACT] = FALSE;
9243 custom_element_change_events[CE_SMASHED] = FALSE;
9244 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
9245 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
9246 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
9247 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
9248 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
9249 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
9250 custom_element_change_events[custom_element_change.direct_action] =
9251 custom_element_change_events[CE_BY_DIRECT_ACTION];
9253 // set other element action change event from checkbox and selectbox
9254 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
9255 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
9256 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
9257 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
9258 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
9259 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
9260 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
9261 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
9262 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
9263 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
9264 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
9265 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
9266 custom_element_change_events[CE_TOUCHING_X] = FALSE;
9267 custom_element_change_events[CE_HITTING_X] = FALSE;
9268 custom_element_change_events[CE_DIGGING_X] = FALSE;
9269 custom_element_change_events[CE_HIT_BY_X] = FALSE;
9270 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
9271 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
9272 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
9273 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
9274 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
9275 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
9276 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
9277 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
9278 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
9279 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
9280 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
9281 custom_element_change_events[custom_element_change.other_action] =
9282 custom_element_change_events[CE_BY_OTHER_ACTION];
9284 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
9285 SET_PROPERTY(element, i, custom_element_properties[i]);
9287 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
9288 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
9290 // copy change events also to special level editor variable
9291 custom_element = element_info[element];
9292 custom_element_change = *element_info[element].change;
9294 // needed here to restore runtime value "element_info[element].gfx_element"
9295 InitElementPropertiesGfxElement();
9298 static void CopyGroupElementPropertiesToGame(int element)
9300 // mark that this group element has been modified
9301 custom_element.modified_settings = TRUE;
9302 level.changed = TRUE;
9304 if (level.use_custom_template)
9305 AskToCopyAndModifyLevelTemplate();
9307 element_info[element] = custom_element;
9308 *element_info[element].group = group_element_info;
9310 // needed here to restore runtime value "element_info[element].gfx_element"
9311 InitElementPropertiesGfxElement();
9314 static void CopyEmptyElementPropertiesToGame(int element)
9316 // mark that this empty element has been modified
9317 custom_element.modified_settings = TRUE;
9318 level.changed = TRUE;
9320 if (level.use_custom_template)
9321 AskToCopyAndModifyLevelTemplate();
9323 element_info[element] = custom_element;
9325 // needed here to restore runtime value "element_info[element].gfx_element"
9326 InitElementPropertiesGfxElement();
9329 static void CopyClassicElementPropertiesToGame(int element)
9331 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9332 setMoveIntoAcidProperty(&level, element,
9333 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
9335 if (MAYBE_DONT_COLLIDE_WITH(element))
9336 setDontCollideWithProperty(&level, element,
9337 custom_element_properties[EP_DONT_COLLIDE_WITH]);
9340 static void CopyElementPropertiesToGame(int element)
9342 if (IS_CUSTOM_ELEMENT(element))
9343 CopyCustomElementPropertiesToGame(element);
9344 else if (IS_GROUP_ELEMENT(element))
9345 CopyGroupElementPropertiesToGame(element);
9346 else if (IS_EMPTY_ELEMENT(element))
9347 CopyEmptyElementPropertiesToGame(element);
9349 CopyClassicElementPropertiesToGame(element);
9353 static void CheckElementDescriptions(void)
9357 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
9358 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
9359 Warn("no element description file for element '%s'", EL_NAME(i));
9363 static int getMaxEdFieldX(boolean has_scrollbar)
9365 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
9366 int sxsize = SXSIZE - scrollbar_width;
9367 int max_ed_fieldx = sxsize / ed_tilesize;
9369 return max_ed_fieldx;
9372 static int getMaxEdFieldY(boolean has_scrollbar)
9374 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
9375 INFOTEXT_YSIZE_FULL : 0);
9376 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
9377 int sysize = SYSIZE - scrollbar_height - infotext_height;
9378 int max_ed_fieldy = sysize / ed_tilesize;
9380 return max_ed_fieldy;
9383 static void InitZoomLevelSettings(int zoom_tilesize)
9385 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
9387 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
9389 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
9390 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
9392 // make sure that tile size is always a power of 2
9393 ed_tilesize = (1 << log_2(ed_tilesize));
9395 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9397 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
9398 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
9402 last_game_engine_type = level.game_engine_type;
9404 // limit zoom tilesize by upper and lower bound
9405 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
9407 // store zoom tilesize in auto setup file only if it was manually changed
9408 if (zoom_tilesize != -1)
9409 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
9411 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
9412 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
9415 static void InitDrawingElements(void)
9417 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
9419 if (level.game_engine_type == game_engine_type_last)
9422 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9424 new_element1 = EL_BD_WALL;
9425 new_element2 = EL_EMPTY;
9426 new_element3 = EL_BD_SAND;
9428 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
9430 new_element1 = EL_SP_CHIP_SINGLE;
9431 new_element2 = EL_EMPTY;
9432 new_element3 = EL_SP_BASE;
9434 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9436 new_element1 = EL_MM_MIRROR_START;
9437 new_element2 = EL_EMPTY;
9438 new_element3 = EL_MM_WOODEN_WALL;
9442 new_element1 = EL_WALL;
9443 new_element2 = EL_EMPTY;
9444 new_element3 = EL_SAND;
9447 game_engine_type_last = level.game_engine_type;
9450 static void InitLevelSetInfo(void)
9452 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
9453 "%s", leveldir_current->name);
9454 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
9455 "%s", leveldir_current->author);
9457 levelset_num_levels = leveldir_current->levels;
9459 levelset_use_levelset_artwork = FALSE;
9460 levelset_copy_level_template = FALSE;
9462 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
9465 static void ChangeEditorToLevelSet(char *levelset_subdir)
9467 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
9469 // the previous level set might have used custom artwork
9470 ReloadCustomArtwork(0);
9472 LoadLevelSetup_SeriesInfo();
9474 SaveLevelSetup_LastSeries();
9475 SaveLevelSetup_SeriesInfo();
9479 LoadLevel(level_nr);
9480 LoadScore(level_nr);
9485 static boolean useEditorDoorAnimation(void)
9487 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
9488 boolean door_1_viewport_unchanged =
9489 (vp_door_1->x == DX &&
9490 vp_door_1->y == DY &&
9491 vp_door_1->width == DXSIZE &&
9492 vp_door_1->height == DYSIZE);
9493 boolean door_1_contains_toolbox =
9496 EX + EXSIZE <= DX + DXSIZE &&
9497 EY + EYSIZE <= DY + DYSIZE);
9499 return (door_1_viewport_unchanged && door_1_contains_toolbox);
9502 static void DrawEditorDoorBackground(int graphic, int x, int y,
9503 int width, int height)
9505 struct GraphicInfo *g = &graphic_info[graphic];
9507 if (g->bitmap != NULL)
9508 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
9509 MIN(width, g->width), MIN(height, g->height), x, y);
9511 ClearRectangle(drawto, x, y, width, height);
9514 static void DrawEditorDoorContent(void)
9516 // needed for gadgets drawn on background (like palette scrollbar)
9517 SetDoorBackgroundImage(IMG_UNDEFINED);
9519 // copy default editor door content to main double buffer
9520 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
9523 DrawSpecialEditorDoor();
9525 // draw new control window
9526 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
9528 // draw all toolbox gadgets to editor doors
9529 MapControlButtons();
9531 // when returning from test game to properties page, redraw toolbox gadgets
9532 if (edit_mode == ED_MODE_PROPERTIES)
9534 UnmapLevelEditorToolboxDrawingGadgets();
9535 UnmapLevelEditorToolboxCustomGadgets();
9537 MapLevelEditorToolboxCustomGadgetsIfNeeded();
9540 // draw all palette gadgets to editor doors
9541 ModifyEditorElementList();
9542 RedrawDrawingElements();
9544 // copy actual editor door content to door double buffer for OpenDoor()
9545 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
9548 void DrawLevelEd(void)
9550 int fade_mask = REDRAW_FIELD;
9552 FadeSoundsAndMusic();
9555 fade_mask = REDRAW_ALL;
9559 // needed if different viewport properties defined for editor
9560 ChangeViewportPropertiesIfNeeded();
9564 InitZoomLevelSettings(-1);
9565 InitDrawingElements();
9569 CheckElementDescriptions();
9572 if (level_editor_test_game)
9574 CopyPlayfield(level.field, Tile);
9575 CopyPlayfield(TileBackup, level.field);
9577 level_editor_test_game = FALSE;
9581 edit_mode = ED_MODE_DRAWING;
9582 edit_mode_levelconfig = ED_MODE_LEVELCONFIG_LEVEL;
9583 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
9591 // redraw_mask |= REDRAW_ALL;
9593 FreeLevelEditorGadgets();
9594 CreateLevelEditorGadgets();
9596 ReinitializeElementList(); // update dynamic level element list
9597 ReinitializeElementListButtons(); // custom element may look different
9599 InitElementPropertiesGfxElement();
9603 DrawEditModeWindow_PlayfieldOnly();
9605 DrawMaskedBorder(fade_mask);
9607 // use door animation if door 1 viewport is unchanged and contains toolbox
9608 if (useEditorDoorAnimation())
9612 DrawEditorDoorContent();
9614 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
9618 DrawEditorDoorContent();
9623 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
9626 static void AdjustDrawingAreaGadgets(void)
9628 int ed_xsize = lev_fieldx + 2;
9629 int ed_ysize = lev_fieldy + 2;
9630 int max_ed_fieldx = MAX_ED_FIELDX;
9631 int max_ed_fieldy = MAX_ED_FIELDY;
9632 boolean horizontal_scrollbar_needed;
9633 boolean vertical_scrollbar_needed;
9634 int x, y, width, height;
9636 if (suppressBorderElement())
9638 ed_xsize = lev_fieldx;
9639 ed_ysize = lev_fieldy;
9642 // check if we need any scrollbars
9643 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9644 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9646 // check if we have a smaller editor field because of scrollbars
9647 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9648 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9650 // check again if we now need more scrollbars because of less space
9651 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9652 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9654 // check if editor field gets even smaller after adding new scrollbars
9655 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9656 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9658 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
9659 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
9661 x = SX + ed_fieldx * ed_tilesize;
9662 y = SY + ed_fieldy * ed_tilesize;
9664 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
9665 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
9667 // adjust drawing area gadget
9668 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
9669 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
9670 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
9673 // adjust horizontal scrollbar gadgets
9674 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
9677 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
9678 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
9681 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9684 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
9687 // adjust vertical scrollbar gadgets
9688 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
9691 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
9693 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
9695 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9698 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
9702 static void AdjustLevelScrollPosition(void)
9704 if (level_xpos < -1)
9706 if (level_xpos > lev_fieldx - ed_fieldx + 1)
9707 level_xpos = lev_fieldx - ed_fieldx + 1;
9708 if (lev_fieldx < ed_fieldx - 2)
9711 if (level_ypos < -1)
9713 if (level_ypos > lev_fieldy - ed_fieldy + 1)
9714 level_ypos = lev_fieldy - ed_fieldy + 1;
9715 if (lev_fieldy < ed_fieldy - 2)
9718 if (suppressBorderElement())
9725 static void AdjustEditorScrollbar(int id)
9727 struct GadgetInfo *gi = level_editor_gadget[id];
9728 int items_max, items_visible, item_position;
9730 if (id == GADGET_ID_SCROLL_HORIZONTAL)
9732 items_max = MAX(lev_fieldx + 2, ed_fieldx);
9733 items_visible = ed_fieldx;
9734 item_position = level_xpos + 1;
9738 items_max = MAX(lev_fieldy + 2, ed_fieldy);
9739 items_visible = ed_fieldy;
9740 item_position = level_ypos + 1;
9743 if (item_position > items_max - items_visible)
9744 item_position = items_max - items_visible;
9746 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9747 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9750 static void AdjustElementListScrollbar(void)
9752 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
9753 int items_max, items_visible, item_position;
9755 // correct position of element list scrollbar
9756 if (element_shift < 0)
9758 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9759 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9761 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
9762 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
9763 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
9765 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9766 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
9767 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9770 static void ModifyEditorCounterValue(int counter_id, int new_value)
9772 int *counter_value = counterbutton_info[counter_id].value;
9773 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9774 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9776 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9778 if (counter_value != NULL)
9779 *counter_value = gi->textinput.number_value;
9782 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9784 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9785 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9787 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9789 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9790 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9792 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9793 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9795 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9796 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9801 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9803 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9804 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9805 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9807 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9810 static void ModifyEditorSelectboxOptions(int selectbox_id,
9811 struct ValueTextInfo *options)
9813 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9814 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9816 selectbox_info[selectbox_id].options = options;
9818 // set index to zero -- list may be shorter now (correct later, if needed)
9819 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9820 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9823 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9825 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9826 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9828 drawingarea_info[drawingarea_id].area_xsize = xsize;
9829 drawingarea_info[drawingarea_id].area_ysize = ysize;
9831 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9834 static void ModifyEditorElementList(void)
9838 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9841 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9843 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9844 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9845 struct GadgetDesign *gd = &gi->deco.design;
9846 int element = editor_elements[element_shift + i];
9847 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9851 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9853 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9859 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9861 int graphic = el2edimg(element);
9862 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9868 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9871 static void ModifyDrawingElementButton(int element, int id)
9873 struct GadgetInfo *gi = level_editor_gadget[id];
9874 Bitmap *deco_bitmap;
9876 int tile_size = gi->deco.width;
9878 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9880 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9883 static void PickDrawingElement(int button, int element)
9888 struct XYTileSize *pos;
9890 } de, drawing_elements[] =
9892 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9893 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9894 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9897 if (button < 1 || button > 3)
9900 if (IS_MM_WALL(element))
9901 element = map_mm_wall_element(element);
9903 de = drawing_elements[button - 1];
9905 *de.new_element = element; // update global drawing element variable
9907 DrawDrawingElementGraphic(element, de.pos);
9908 ModifyDrawingElementButton(element, de.id);
9910 redraw_mask |= REDRAW_DOOR_1;
9913 static void RedrawDrawingElements(void)
9915 PickDrawingElement(1, new_element1);
9916 PickDrawingElement(2, new_element2);
9917 PickDrawingElement(3, new_element3);
9920 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9922 stick_element_properties_window = FALSE;
9924 SetMainBackgroundImage(IMG_UNDEFINED);
9927 UnmapLevelEditorFieldGadgets();
9929 AdjustDrawingAreaGadgets();
9930 AdjustLevelScrollPosition();
9931 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9932 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9934 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9936 MapMainDrawingArea();
9938 if (remap_toolbox_gadgets)
9940 UnmapLevelEditorToolboxCustomGadgets();
9941 MapLevelEditorToolboxDrawingGadgets();
9945 static void DrawDrawingWindow(void)
9947 DrawDrawingWindowExt(TRUE);
9950 static int getTabulatorBarWidth(void)
9952 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9953 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9955 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9958 static int getTabulatorBarHeight(void)
9960 return ED_TAB_BAR_HEIGHT;
9963 static Pixel getTabulatorBarColor(void)
9965 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9966 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9967 int gd_x = gd->x + gd_gi1->border.width / 2;
9968 int gd_y = gd->y + gd_gi1->height - 1;
9970 return GetPixel(gd->bitmap, gd_x, gd_y);
9973 static void DrawLevelConfigTabulatorGadgets(void)
9975 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9976 Pixel tab_color = getTabulatorBarColor();
9977 int id_first = ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL;
9978 int id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR;
9981 // draw additional "engine" tabulator when using native BD engine
9982 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9983 id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE;
9985 for (i = id_first; i <= id_last; i++)
9987 int gadget_id = textbutton_info[i].gadget_id;
9988 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9989 boolean active = (i != edit_mode_levelconfig);
9991 // draw background line below tabulator button
9992 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9994 // draw solid line below inactive tabulator buttons
9995 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9996 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9997 ED_GADGET_TINY_DISTANCE, tab_color);
9999 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
10000 MapTextbuttonGadget(i);
10003 // draw little border line below tabulator buttons
10004 if (tab_color != BLACK_PIXEL) // black => transparent
10005 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
10006 ED_GADGET_TINY_DISTANCE,
10007 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10010 static void DrawPropertiesTabulatorGadgets(void)
10012 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
10013 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
10014 int gd_x = gd->x + gd_gi1->border.width / 2;
10015 int gd_y = gd->y + gd_gi1->height - 1;
10016 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
10017 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
10018 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
10021 // draw two config tabulators for player elements
10022 if (IS_PLAYER_ELEMENT(properties_element))
10023 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
10025 // draw two config and one "change" tabulator for custom elements
10026 if (IS_CUSTOM_ELEMENT(properties_element))
10027 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
10029 for (i = id_first; i <= id_last; i++)
10031 int gadget_id = textbutton_info[i].gadget_id;
10032 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
10033 boolean active = (i != edit_mode_properties);
10035 // use "config 1" and "config 2" instead of "config" for players and CEs
10036 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
10037 (IS_PLAYER_ELEMENT(properties_element) ||
10038 IS_CUSTOM_ELEMENT(properties_element)))
10041 // draw background line below tabulator button
10042 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
10044 // draw solid line below inactive tabulator buttons
10045 if (!active && tab_color != BLACK_PIXEL) // black => transparent
10046 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
10047 ED_GADGET_TINY_DISTANCE, tab_color);
10049 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
10050 MapTextbuttonGadget(i);
10053 // draw little border line below tabulator buttons
10054 if (tab_color != BLACK_PIXEL) // black => transparent
10055 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
10056 ED_GADGET_TINY_DISTANCE,
10057 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10060 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
10062 DrawText(SX + xpos, SY + ypos, text, font_nr);
10065 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
10066 int xpos, int ypos)
10068 int font_width = getFontWidth(font_nr);
10069 int font_height = getFontHeight(font_nr);
10070 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
10071 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
10073 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
10074 max_chars_per_line, -1, max_lines_drawable, 0, -1,
10075 TRUE, FALSE, FALSE);
10078 static void DrawLevelConfigLevel(void)
10082 // draw counter gadgets
10083 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
10084 MapCounterButtons(i);
10086 // draw checkbutton gadgets
10087 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
10088 MapCheckbuttonGadget(i);
10090 // draw selectbox gadgets
10091 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
10092 MapSelectboxGadget(i);
10094 // draw text input gadgets
10095 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
10096 MapTextInputGadget(i);
10099 static char *getLevelSubdirFromSaveMode(int save_mode)
10101 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
10102 return getNewUserLevelSubdir();
10104 return leveldir_current->subdir;
10107 static void DrawLevelConfigLevelSet_DirectoryInfo(void)
10109 char *directory_text = "Level set directory:";
10110 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
10111 int font1_nr = FONT_TEXT_1;
10112 int font2_nr = FONT_TEXT_2;
10113 int font1_height = getFontHeight(font1_nr);
10114 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
10115 int x = ED_LEVEL_SETTINGS_X(0);
10116 int y = ED_LEVEL_SETTINGS_Y(6);
10118 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
10119 PrintInfoText(directory_name, font2_nr, x, y);
10122 static void DrawLevelConfigLevelSet(void)
10124 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
10125 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
10128 // draw counter gadgets
10129 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
10130 MapCounterButtons(i);
10132 // draw checkbutton gadgets
10133 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
10135 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
10136 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
10137 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
10140 MapCheckbuttonGadget(i);
10143 // draw selectbox gadgets
10144 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
10145 MapSelectboxGadget(i);
10147 // draw text input gadgets
10148 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
10149 MapTextInputGadget(i);
10151 // draw textbutton gadgets
10152 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
10155 DrawLevelConfigLevelSet_DirectoryInfo();
10158 static void DrawLevelConfigEditor(void)
10162 // draw counter gadgets
10163 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
10164 MapCounterButtons(i);
10166 // draw checkbutton gadgets
10167 for (i = ED_CHECKBUTTON_ID_EDITOR_FIRST; i <= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
10168 MapCheckbuttonGadget(i);
10170 // draw radiobutton gadgets
10171 for (i = ED_RADIOBUTTON_ID_EDITOR_FIRST; i <= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
10172 MapRadiobuttonGadget(i);
10174 // draw drawing area
10175 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
10177 // draw textbutton gadgets
10178 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
10181 static void DrawLevelConfigEngine(void)
10185 // draw counter gadgets
10186 if (level.bd_scheduling_type == GD_SCHEDULING_MILLISECONDS)
10188 MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_MS);
10189 MapCounterButtons(ED_COUNTER_ID_BD_HATCHING_DELAY_CYCLES);
10193 MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_C64);
10194 MapCounterButtons(ED_COUNTER_ID_BD_HATCHING_DELAY_SECONDS);
10197 // draw checkbutton gadgets
10198 for (i = ED_CHECKBUTTON_ID_ENGINE_FIRST; i <= ED_CHECKBUTTON_ID_ENGINE_LAST; i++)
10199 MapCheckbuttonGadget(i);
10201 // draw selectbox gadgets
10202 for (i = ED_SELECTBOX_ID_ENGINE_FIRST; i <= ED_SELECTBOX_ID_ENGINE_LAST; i++)
10203 MapSelectboxGadget(i);
10206 static void DrawLevelConfigWindow(void)
10208 char *text = "Global Settings";
10209 int font_nr = FONT_TITLE_1;
10210 struct MenuPosInfo *pos = &editor.settings.headline;
10211 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
10212 int sy = SY + pos->y;
10214 stick_element_properties_window = FALSE;
10216 SetAutomaticNumberOfGemsNeeded();
10218 UnmapLevelEditorFieldGadgets();
10220 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10223 DrawText(sx, sy, text, font_nr);
10225 DrawLevelConfigTabulatorGadgets();
10227 if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVEL)
10228 DrawLevelConfigLevel();
10229 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVELSET)
10230 DrawLevelConfigLevelSet();
10231 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_EDITOR)
10232 DrawLevelConfigEditor();
10233 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_ENGINE)
10234 DrawLevelConfigEngine();
10237 static void DrawCustomContentArea(void)
10239 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
10240 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10241 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
10242 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
10243 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
10244 int xoffset = ED_GADGET_SPACE_DISTANCE;
10246 // add distance for potential left text (without drawing area border)
10247 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
10249 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10251 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
10254 static void DrawCustomChangeContentArea(void)
10256 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
10257 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10258 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
10259 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
10260 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
10261 int xoffset = ED_GADGET_SPACE_DISTANCE;
10263 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10265 MapDrawingArea(id);
10268 static void RemoveElementContentArea(int id, int font_height)
10270 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10272 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
10273 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
10274 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10275 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
10276 ED_GADGET_TEXT_DISTANCE + font_height);
10279 static void DrawYamYamContentAreas(void)
10281 int font_nr = FONT_TEXT_1;
10282 int font_height = getFontHeight(font_nr);
10283 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10284 int yoffset = (tilesize - font_height) / 2;
10285 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
10286 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
10289 // display counter to choose number of element content areas
10290 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
10292 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10294 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
10296 if (i < level.num_yamyam_contents)
10298 MapDrawingArea(id);
10302 UnmapDrawingArea(id);
10304 // delete content areas in case of reducing number of them
10305 RemoveElementContentArea(id, font_height);
10309 DrawText(x, y + 0 * tilesize, "content", font_nr);
10310 DrawText(x, y + 1 * tilesize, "when", font_nr);
10311 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
10314 static void DrawMagicBallContentAreas(void)
10316 int font_nr = FONT_TEXT_1;
10317 int font_height = getFontHeight(font_nr);
10318 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10319 int yoffset = (tilesize - font_height) / 2;
10320 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
10321 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
10324 // display counter to choose number of element content areas
10325 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
10327 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10329 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
10331 if (i < level.num_ball_contents)
10333 MapDrawingArea(id);
10337 UnmapDrawingArea(id);
10339 // delete content areas in case of reducing number of them
10340 RemoveElementContentArea(id, font_height);
10344 DrawText(x, y + 0 * tilesize, "generated", font_nr);
10345 DrawText(x, y + 1 * tilesize, "when", font_nr);
10346 DrawText(x, y + 2 * tilesize, "active", font_nr);
10349 static void DrawAndroidElementArea(void)
10351 int id = ED_DRAWING_ID_ANDROID_CONTENT;
10352 int num_elements = level.num_android_clone_elements;
10353 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10354 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10355 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10356 int xsize = MAX_ANDROID_ELEMENTS;
10359 // display counter to choose number of element areas
10360 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
10362 if (drawingarea_info[id].text_left != NULL)
10363 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10365 UnmapDrawingArea(id);
10367 ModifyEditorDrawingArea(id, num_elements, 1);
10369 // delete content areas in case of reducing number of them
10370 DrawBackground(sx, sy,
10371 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10372 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10374 MapDrawingArea(id);
10377 static void DrawGroupElementArea(void)
10379 int id = ED_DRAWING_ID_GROUP_CONTENT;
10380 int num_elements = group_element_info.num_elements;
10381 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10382 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10383 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10384 int xsize = MAX_ELEMENTS_IN_GROUP;
10387 if (drawingarea_info[id].text_left != NULL)
10388 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10390 UnmapDrawingArea(id);
10392 ModifyEditorDrawingArea(id, num_elements, 1);
10394 // delete content areas in case of reducing number of them
10395 DrawBackground(sx, sy,
10396 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10397 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10399 MapDrawingArea(id);
10402 static void DrawPlayerInitialInventoryArea(int element)
10404 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
10405 int player_nr = GET_PLAYER_NR(element);
10406 int num_elements = level.initial_inventory_size[player_nr];
10407 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10408 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10409 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10410 int xsize = MAX_INITIAL_INVENTORY_SIZE;
10413 // determine horizontal position to the right of specified gadget
10414 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
10415 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
10416 ED_DRAWINGAREA_TEXT_DISTANCE);
10418 // determine horizontal offset for leading text
10419 if (drawingarea_info[id].text_left != NULL)
10420 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10422 UnmapDrawingArea(id);
10424 ModifyEditorDrawingArea(id, num_elements, 1);
10426 // delete content areas in case of reducing number of them
10427 DrawBackground(sx, sy,
10428 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10429 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10431 MapDrawingArea(id);
10434 static void DrawMMBallContentArea(void)
10436 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
10437 int num_elements = level.num_mm_ball_contents;
10438 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10439 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10440 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10441 int xsize = MAX_MM_BALL_CONTENTS;
10444 if (drawingarea_info[id].text_left != NULL)
10445 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10447 UnmapDrawingArea(id);
10449 ModifyEditorDrawingArea(id, num_elements, 1);
10451 // delete content areas in case of reducing number of them
10452 DrawBackground(sx, sy,
10453 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10454 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10456 MapDrawingArea(id);
10459 static void DrawEnvelopeTextArea(int envelope_nr)
10461 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
10462 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
10466 DrawBackground(gi->x, gi->y,
10467 gi->textarea.crop_width, gi->textarea.crop_height);
10469 if (envelope_nr != -1)
10470 textarea_info[id].value = level.envelope[envelope_nr].text;
10472 ModifyGadget(gi, GDI_AREA_SIZE,
10473 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
10474 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
10477 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
10480 static void DrawPropertiesInfo(void)
10489 // configurable properties
10491 { EP_WALKABLE_OVER, "- player can walk over it" },
10492 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
10493 { EP_WALKABLE_UNDER, "- player can walk under it" },
10494 { EP_PASSABLE_OVER, "- player can pass over it" },
10495 { EP_PASSABLE_INSIDE, "- player can pass through it" },
10496 { EP_PASSABLE_UNDER, "- player can pass under it" },
10497 { EP_PROTECTED, "- player is protected by it" },
10499 { EP_DIGGABLE, "- can be digged away" },
10500 { EP_COLLECTIBLE, "- can be collected" },
10501 { EP_DROPPABLE, "- can be dropped after collecting" },
10502 { EP_THROWABLE, "- can be thrown after collecting" },
10503 { EP_PUSHABLE, "- can be pushed" },
10505 { EP_CAN_FALL, "- can fall" },
10506 { EP_CAN_MOVE, "- can move" },
10508 { EP_CAN_SMASH_PLAYER, "- can smash player" },
10510 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
10512 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
10514 { EP_SLIPPERY, "- slippery for falling elements" },
10515 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
10517 { EP_DONT_RUN_INTO, "- deadly when running into" },
10518 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
10519 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
10520 { EP_DONT_TOUCH, "- deadly when touching" },
10522 { EP_INDESTRUCTIBLE, "- indestructible" },
10524 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
10525 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
10526 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
10528 { EP_CAN_CHANGE, "- can change to other element" },
10530 // pre-defined properties
10531 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
10532 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
10533 { EP_SWITCHABLE, "- can be switched" },
10535 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
10540 char *filename = getElementDescriptionFilename(properties_element);
10541 char *num_elements_text = "In this level: ";
10542 char *num_similar_text = "Similar tiles: ";
10543 char *properties_text = "Standard properties: ";
10544 char *description_text = "Description:";
10545 char *no_description_text = "No description available.";
10546 char *none_text = "None";
10548 int num_elements_in_level = 0;
10549 int num_similar_in_level = 0;
10550 int num_hires_tiles_in_level = 0;
10551 int num_standard_properties = 0;
10552 int font1_nr = FONT_TEXT_1;
10553 int font2_nr = FONT_TEXT_2;
10554 int font1_width = getFontWidth(font1_nr);
10555 int font1_height = getFontHeight(font1_nr);
10556 int font2_height = getFontHeight(font2_nr);
10557 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
10558 int font2_yoffset = (font1_height - font2_height) / 2;
10559 int num_elements_text_len = strlen(num_elements_text) * font1_width;
10560 int num_similar_text_len = strlen(num_similar_text) * font1_width;
10561 int properties_text_len = strlen(properties_text) * font1_width;
10562 int xpos = ED_ELEMENT_SETTINGS_X(0);
10563 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10566 if (setup.editor.show_element_token)
10568 int font3_nr = FONT_TEXT_3;
10569 int font3_height = getFontHeight(font3_nr);
10571 DrawTextF(xpos, ypos, font3_nr,
10572 "[%s]", element_info[properties_element].token_name);
10574 ypos += 2 * font3_height;
10577 // ----- print number of elements / percentage of this element in level
10579 for (y = 0; y < lev_fieldy; y++)
10581 for (x = 0; x < lev_fieldx; x++)
10583 if (Tile[x][y] == properties_element)
10585 num_elements_in_level++;
10587 else if (IS_MM_WALL(Tile[x][y]) &&
10588 map_mm_wall_element(Tile[x][y]) == properties_element)
10590 num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
10595 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10597 DrawTextS(xpos, ypos, font1_nr, num_elements_text);
10599 if (num_hires_tiles_in_level > 0)
10600 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10601 "%d wall tiles", num_hires_tiles_in_level);
10602 else if (num_elements_in_level > 0)
10603 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10604 "%d (%.2f %%)", num_elements_in_level, percentage);
10606 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10609 // ----- print number of similar elements / percentage of them in level
10611 for (y = 0; y < lev_fieldy; y++)
10613 for (x = 0; x < lev_fieldx; x++)
10615 if (strEqual(element_info[Tile[x][y]].class_name,
10616 element_info[properties_element].class_name))
10618 num_similar_in_level++;
10623 if (num_similar_in_level != num_elements_in_level)
10625 ypos += 1 * MAX(font1_height, font2_height);
10627 percentage = num_similar_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10629 DrawTextS(xpos, ypos, font1_nr, num_similar_text);
10631 if (num_similar_in_level > 0)
10632 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10633 "%d (%.2f %%)", num_similar_in_level, percentage);
10635 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10639 ypos += 2 * MAX(font1_height, font2_height);
10641 // ----- print standard properties of this element
10643 DrawTextS(xpos, ypos, font1_nr, properties_text);
10645 ypos += line1_height;
10647 for (i = 0; properties[i].value != -1; i++)
10649 if (!HAS_PROPERTY(properties_element, properties[i].value))
10652 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
10654 ypos += font2_height;
10656 num_standard_properties++;
10659 if (num_standard_properties == 0)
10661 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
10662 font2_nr, none_text);
10664 ypos -= (line1_height - font1_height);
10667 ypos += MAX(font1_height, font2_height);
10669 // ----- print special description of this element
10671 PrintInfoText(description_text, font1_nr, xpos, ypos);
10673 ypos += line1_height;
10675 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
10676 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
10679 #define TEXT_COLLECTING "Score for collecting"
10680 #define TEXT_COLLECTING_EXTRA "Score for extra diamonds"
10681 #define TEXT_SMASHING "Score for smashing"
10682 #define TEXT_SLURPING "Score for slurping robot"
10683 #define TEXT_CRACKING "Score for cracking"
10684 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
10685 #define TEXT_DURATION "Duration when activated"
10686 #define TEXT_DELAY_ON "Delay before activating"
10687 #define TEXT_DELAY_OFF "Delay before deactivating"
10688 #define TEXT_DELAY_CHANGING "Delay before changing"
10689 #define TEXT_DELAY_EXPLODING "Delay before exploding"
10690 #define TEXT_DELAY_MOVING "Delay before moving"
10691 #define TEXT_BALL_DELAY "Element generation delay"
10692 #define TEXT_MOVE_SPEED "Speed of android moving"
10693 #define TEXT_CLONE_SPEED "Speed of android cloning"
10694 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
10695 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
10696 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
10697 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
10698 #define TEXT_TIME_BONUS "Extra time to solve level"
10705 } elements_with_counter[] =
10707 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
10708 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
10709 { EL_BD_DIAMOND, &level.score[SC_DIAMOND_EXTRA], TEXT_COLLECTING_EXTRA },
10710 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
10711 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
10712 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10713 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
10714 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
10715 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
10716 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
10717 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
10718 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10719 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
10720 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10721 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10722 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
10723 { EL_BD_BUTTERFLY_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10724 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
10725 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10726 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10727 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
10728 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10729 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10730 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10731 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10732 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10733 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10734 { EL_BD_FIREFLY_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10735 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10736 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10737 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10738 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10739 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10740 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10741 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10742 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
10743 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
10744 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10745 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
10746 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10747 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10748 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10749 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10750 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10751 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
10752 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10753 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10754 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE], TEXT_COLLECTING },
10755 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10756 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10757 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
10758 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
10759 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
10760 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10761 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10762 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10763 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10764 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10765 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10766 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10767 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10768 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
10769 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
10770 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
10771 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
10772 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
10773 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10774 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
10775 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
10776 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
10777 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10778 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10779 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10780 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10781 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10782 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10783 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10784 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10785 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10786 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10787 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10788 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10789 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10790 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
10791 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10792 { EL_DC_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10793 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
10794 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
10795 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
10796 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
10797 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
10798 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
10799 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
10800 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
10801 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
10802 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
10803 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
10804 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
10805 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
10806 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
10807 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
10808 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
10809 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
10810 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
10811 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
10812 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
10813 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
10814 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
10815 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
10816 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
10817 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
10818 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
10819 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_CHANGING },
10820 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10821 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10826 static boolean checkPropertiesConfig(int element)
10830 // special case: empty space customization only available in R'n'D game engine
10831 if (element == EL_EMPTY_SPACE && level.game_engine_type != GAME_ENGINE_TYPE_RND)
10834 if (IS_GEM(element) ||
10835 IS_CUSTOM_ELEMENT(element) ||
10836 IS_GROUP_ELEMENT(element) ||
10837 IS_EMPTY_ELEMENT(element) ||
10838 IS_BALLOON_ELEMENT(element) ||
10839 IS_ENVELOPE(element) ||
10840 IS_MM_ENVELOPE(element) ||
10841 IS_MM_MCDUFFIN(element) ||
10842 IS_DF_LASER(element) ||
10843 IS_PLAYER_ELEMENT(element) ||
10844 IS_BD_PLAYER_ELEMENT(element) ||
10845 IS_SOKOBAN_OBJECT_OR_FIELD(element) ||
10846 HAS_EDITOR_CONTENT(element) ||
10847 CAN_GROW(element) ||
10848 COULD_MOVE_INTO_ACID(element) ||
10849 MAYBE_DONT_COLLIDE_WITH(element))
10852 for (i = 0; elements_with_counter[i].element != -1; i++)
10853 if (elements_with_counter[i].element == element)
10859 static void SetAutomaticNumberOfGemsNeeded(void)
10863 if (!level.auto_count_gems)
10866 level.gems_needed = 0;
10868 for (x = 0; x < lev_fieldx; x++)
10870 for (y = 0; y < lev_fieldy; y++)
10872 int element = Tile[x][y];
10877 case EL_EMERALD_YELLOW:
10878 case EL_EMERALD_RED:
10879 case EL_EMERALD_PURPLE:
10880 case EL_BD_DIAMOND:
10881 case EL_WALL_EMERALD:
10882 case EL_WALL_EMERALD_YELLOW:
10883 case EL_WALL_EMERALD_RED:
10884 case EL_WALL_EMERALD_PURPLE:
10885 case EL_WALL_BD_DIAMOND:
10887 case EL_SP_INFOTRON:
10890 level.gems_needed++;
10894 case EL_WALL_DIAMOND:
10895 level.gems_needed += 3;
10899 case EL_WALL_PEARL:
10900 level.gems_needed += 5;
10904 case EL_WALL_CRYSTAL:
10905 level.gems_needed += 8;
10914 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10917 static void DrawPropertiesConfig(void)
10919 boolean draw_footer_line = FALSE;
10920 int max_num_element_counters = 4;
10921 int num_element_counters = 0;
10924 if (!checkPropertiesConfig(properties_element))
10926 int xpos = ED_ELEMENT_SETTINGS_X(0);
10927 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10929 PrintInfoText("No configuration options available.",
10930 FONT_TEXT_1, xpos, ypos);
10935 // check if there are elements where a value can be chosen for
10936 for (i = 0; elements_with_counter[i].element != -1; i++)
10938 if (elements_with_counter[i].element == properties_element)
10940 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10942 counterbutton_info[counter_id].y =
10943 ED_ELEMENT_SETTINGS_YPOS(
10944 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10945 (CAN_GROW(properties_element) ? 1 : 0) +
10946 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10947 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10948 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10949 num_element_counters);
10951 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10952 counterbutton_info[counter_id].text_right = elements_with_counter[i].text;
10954 if (properties_element == EL_GAME_OF_LIFE ||
10955 properties_element == EL_BIOMAZE)
10957 counterbutton_info[counter_id].min_value = 0; // min neighbours
10958 counterbutton_info[counter_id].max_value = 8; // max neighbours
10962 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10963 counterbutton_info[counter_id].min_value = MIN_SCORE;
10964 counterbutton_info[counter_id].max_value = MAX_SCORE;
10967 MapCounterButtons(counter_id);
10969 num_element_counters++;
10970 if (num_element_counters >= max_num_element_counters)
10975 if (HAS_EDITOR_CONTENT(properties_element))
10977 // draw stickybutton gadget
10978 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10980 if (IS_AMOEBOID(properties_element))
10981 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10982 else if (properties_element == EL_YAMYAM ||
10983 properties_element == EL_YAMYAM_LEFT ||
10984 properties_element == EL_YAMYAM_RIGHT ||
10985 properties_element == EL_YAMYAM_UP ||
10986 properties_element == EL_YAMYAM_DOWN)
10987 DrawYamYamContentAreas();
10988 else if (properties_element == EL_EMC_MAGIC_BALL)
10990 DrawMagicBallContentAreas();
10992 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10993 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10995 else if (properties_element == EL_EMC_ANDROID)
10996 DrawAndroidElementArea();
10997 else if (properties_element == EL_MM_GRAY_BALL)
10999 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
11000 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
11001 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
11002 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EXPLODE_MM_BALL);
11004 DrawMMBallContentArea();
11008 if (IS_PLAYER_ELEMENT(properties_element))
11010 int player_nr = GET_PLAYER_NR(properties_element);
11012 // these properties can be set for every player individually
11014 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
11016 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
11017 &level.start_element[player_nr];
11018 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
11019 &level.artwork_element[player_nr];
11020 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
11021 &level.explosion_element[player_nr];
11023 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
11024 &level.use_start_element[player_nr];
11025 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
11026 &level.use_artwork_element[player_nr];
11027 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
11028 &level.use_explosion_element[player_nr];
11029 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
11030 &level.initial_player_gravity[player_nr];
11032 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
11033 &level.initial_player_stepsize[player_nr];
11035 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
11036 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
11037 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
11038 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
11039 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
11040 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
11041 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
11042 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
11043 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
11044 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
11045 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
11046 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
11047 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
11048 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
11049 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
11051 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
11052 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
11053 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
11055 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
11057 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
11059 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
11060 &level.initial_inventory_content[player_nr][0];
11062 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
11063 &level.initial_inventory_size[player_nr];
11065 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
11066 &level.use_initial_inventory[player_nr];
11068 // draw checkbutton gadgets
11069 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
11070 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
11071 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
11073 // draw counter gadgets
11074 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
11076 // draw drawing area gadgets
11077 DrawPlayerInitialInventoryArea(properties_element);
11081 if (IS_BD_PLAYER_ELEMENT(properties_element))
11083 // draw checkbutton gadgets
11084 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS);
11085 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_TOPMOST_PLAYER_ACTIVE);
11086 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_PUSH_MEGA_ROCK_WITH_SWEET);
11088 // draw counter gadgets
11089 MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB);
11090 MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET);
11093 // special case: slippery walls option for gems only available in R'n'D game engine
11094 if (IS_GEM(properties_element) && level.game_engine_type == GAME_ENGINE_TYPE_RND)
11096 checkbutton_info[ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS].y =
11097 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_BD_DIAMOND ? 2 : 1);
11099 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
11102 if (properties_element == EL_EM_DYNAMITE)
11103 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
11105 if (COULD_MOVE_INTO_ACID(properties_element) &&
11106 !IS_PLAYER_ELEMENT(properties_element) &&
11107 (!IS_CUSTOM_ELEMENT(properties_element) ||
11108 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
11110 // set position for checkbutton for "can move into acid"
11111 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
11112 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
11113 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
11114 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
11115 IS_BALLOON_ELEMENT(properties_element) ||
11116 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
11118 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
11121 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
11122 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
11124 if (properties_element == EL_SPRING ||
11125 properties_element == EL_SPRING_LEFT ||
11126 properties_element == EL_SPRING_RIGHT)
11127 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
11129 if (properties_element == EL_TIME_ORB_FULL)
11130 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
11132 if (properties_element == EL_GAME_OF_LIFE ||
11133 properties_element == EL_BIOMAZE)
11134 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
11136 if (CAN_GROW(properties_element))
11138 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
11139 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
11141 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
11144 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
11145 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
11147 if (properties_element == EL_SOKOBAN_OBJECT)
11148 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
11150 if (properties_element == EL_SOKOBAN_OBJECT ||
11151 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
11152 properties_element == EL_SOKOBAN_FIELD_FULL)
11154 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
11155 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
11158 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
11161 if (IS_BALLOON_ELEMENT(properties_element))
11162 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
11164 if (IS_ENVELOPE(properties_element) ||
11165 IS_MM_ENVELOPE(properties_element))
11167 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
11168 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
11169 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
11170 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
11171 int envelope_nr = ENVELOPE_NR(properties_element);
11173 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
11174 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
11176 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
11177 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
11179 // display counter to choose size of envelope text area
11180 MapCounterButtons(counter1_id);
11181 MapCounterButtons(counter2_id);
11183 // display checkbuttons to choose auto-wrap and alignment properties
11184 MapCheckbuttonGadget(button1_id);
11185 MapCheckbuttonGadget(button2_id);
11187 DrawEnvelopeTextArea(envelope_nr);
11190 if (IS_MM_MCDUFFIN(properties_element))
11192 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
11193 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
11194 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
11197 if (IS_DF_LASER(properties_element))
11199 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
11200 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
11201 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
11204 if (IS_CUSTOM_ELEMENT(properties_element))
11206 // draw stickybutton gadget
11207 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11209 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
11211 // draw checkbutton gadgets
11212 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
11213 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
11214 MapCheckbuttonGadget(i);
11216 // draw counter gadgets
11217 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
11218 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
11219 MapCounterButtons(i);
11221 // draw selectbox gadgets
11222 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
11223 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
11224 MapSelectboxGadget(i);
11226 // draw textbutton gadgets
11227 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11229 // draw text input gadgets
11230 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11232 // draw drawing area gadgets
11233 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11235 draw_footer_line = TRUE;
11237 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
11239 // draw checkbutton gadgets
11240 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
11241 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
11242 MapCheckbuttonGadget(i);
11244 // draw counter gadgets
11245 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
11246 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
11247 MapCounterButtons(i);
11249 // draw selectbox gadgets
11250 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
11251 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
11252 MapSelectboxGadget(i);
11254 // draw drawing area gadgets
11255 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
11256 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
11257 DrawCustomContentArea();
11260 else if (IS_GROUP_ELEMENT(properties_element))
11262 // draw stickybutton gadget
11263 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11265 // draw checkbutton gadgets
11266 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11267 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11269 // draw counter gadgets
11270 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
11272 // draw selectbox gadgets
11273 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
11275 // draw textbutton gadgets
11276 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11278 // draw drawing area gadgets
11279 DrawGroupElementArea();
11281 // draw text input gadgets
11282 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11284 // draw drawing area gadgets
11285 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11287 draw_footer_line = TRUE;
11289 else if (IS_EMPTY_ELEMENT(properties_element))
11291 // draw stickybutton gadget
11292 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11294 // draw checkbutton gadgets
11295 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11296 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11298 // draw textbutton gadgets
11299 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11301 // draw drawing area gadgets
11302 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11304 draw_footer_line = TRUE;
11307 // draw little footer border line above CE/GE use/save template gadgets
11308 if (draw_footer_line)
11310 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
11311 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
11312 int gd_x = gd->x + gd_gi1->border.width / 2;
11313 int gd_y = gd->y + gd_gi1->height - 1;
11314 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
11316 if (tab_color != BLACK_PIXEL) // black => transparent
11317 FillRectangle(drawto,
11318 SX + ED_ELEMENT_SETTINGS_X(0),
11319 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
11321 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
11325 static void DrawPropertiesChangeDrawingAreas(void)
11327 if (IS_CUSTOM_ELEMENT(properties_element))
11329 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
11330 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
11331 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
11333 DrawCustomChangeContentArea();
11336 redraw_mask |= REDRAW_FIELD;
11339 static void DrawPropertiesChange(void)
11343 // needed to initially set selectbox options for special action options
11344 setSelectboxSpecialActionOptions();
11346 // draw stickybutton gadget
11347 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11349 // draw checkbutton gadgets
11350 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
11351 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
11352 MapCheckbuttonGadget(i);
11354 // draw counter gadgets
11355 for (i = ED_COUNTER_ID_CHANGE_FIRST;
11356 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
11357 MapCounterButtons(i);
11359 // draw selectbox gadgets
11360 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
11361 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
11362 MapSelectboxGadget(i);
11364 // draw textbutton gadgets
11365 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
11366 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
11367 MapTextbuttonGadget(i);
11369 // draw graphicbutton gadgets
11370 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
11371 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
11372 MapGraphicbuttonGadget(i);
11374 // draw drawing area gadgets
11375 DrawPropertiesChangeDrawingAreas();
11378 static void DrawEditorElementAnimation(int x, int y)
11380 int graphic = el2img(properties_element);
11381 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
11382 custom_element.ce_value_fixed_initial :
11383 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
11384 custom_element.collect_score_initial : FrameCounter);
11386 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
11389 static void DrawEditorElementName(int x, int y, int font_nr)
11391 char *element_name = getElementInfoText(properties_element);
11392 int font_width = getFontWidth(font_nr);
11393 int font_height = getFontHeight(font_nr);
11394 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
11395 int max_chars_per_line = max_text_width / font_width;
11397 if (strlen(element_name) <= max_chars_per_line)
11398 DrawTextS(x, y, font_nr, element_name);
11401 char buffer[max_chars_per_line + 1];
11402 int next_pos = max_chars_per_line;
11404 strncpy(buffer, element_name, max_chars_per_line);
11405 buffer[max_chars_per_line] = '\0';
11407 if (element_name[max_chars_per_line] == ' ')
11413 for (i = max_chars_per_line - 1; i >= 0; i--)
11414 if (buffer[i] == ' ')
11417 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
11424 DrawTextS(x, y - font_height / 2, font_nr, buffer);
11426 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
11427 buffer[max_chars_per_line] = '\0';
11429 DrawTextS(x, y + font_height / 2, font_nr, buffer);
11433 static void DrawPropertiesWindow(void)
11435 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
11436 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
11437 int border_size = gd->border_size;
11438 int font_nr = FONT_TEXT_1;
11439 int font_height = getFontHeight(font_nr);
11440 int xoffset = TILEX + element_border + 3 * border_size;
11441 int yoffset = (TILEY - font_height) / 2;
11442 int x1 = editor.settings.element_graphic.x + element_border;
11443 int y1 = editor.settings.element_graphic.y + element_border;
11444 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
11445 editor.settings.element_name.x);
11446 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
11447 editor.settings.element_name.y);
11448 char *text = "Element Settings";
11449 int font2_nr = FONT_TITLE_1;
11450 struct MenuPosInfo *pos = &editor.settings.headline;
11451 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
11452 int sy = SY + pos->y;
11454 stick_element_properties_window = FALSE;
11456 // make sure that previous properties edit mode exists for this element
11457 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
11458 !IS_CUSTOM_ELEMENT(properties_element))
11459 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
11461 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
11462 !IS_PLAYER_ELEMENT(properties_element) &&
11463 !IS_CUSTOM_ELEMENT(properties_element))
11464 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
11466 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
11467 (IS_PLAYER_ELEMENT(properties_element) ||
11468 IS_CUSTOM_ELEMENT(properties_element)))
11469 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
11471 CopyElementPropertiesToEditor(properties_element);
11473 UnmapLevelEditorFieldGadgets();
11474 UnmapLevelEditorToolboxDrawingGadgets();
11475 UnmapLevelEditorToolboxCustomGadgets();
11477 MapLevelEditorToolboxCustomGadgetsIfNeeded();
11479 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11482 DrawText(sx, sy, text, font2_nr);
11484 FrameCounter = 0; // restart animation frame counter
11486 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
11487 DrawEditorElementAnimation(SX + x1, SY + y1);
11488 DrawEditorElementName(x2, y2, font_nr);
11490 DrawPropertiesTabulatorGadgets();
11492 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
11493 DrawPropertiesInfo();
11494 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
11495 DrawPropertiesChange();
11496 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
11497 DrawPropertiesConfig();
11500 static void DrawPaletteWindow(void)
11504 UnmapLevelEditorFieldGadgets();
11506 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11509 // map buttons to select elements
11510 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
11511 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
11512 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
11513 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
11514 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
11517 static void UpdateCustomElementGraphicGadgets(void)
11521 InitElementPropertiesGfxElement();
11523 ModifyEditorElementList();
11524 RedrawDrawingElements();
11526 // force redraw of all mapped drawing area gadgets
11527 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
11529 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
11536 static int getOpenDirectionFromTube(int element)
11540 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
11541 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
11542 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
11543 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
11544 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
11545 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
11546 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
11547 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
11548 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
11549 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
11550 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
11556 static int getTubeFromOpenDirection(int direction)
11560 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
11561 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
11562 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
11563 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
11564 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
11565 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
11566 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
11567 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
11568 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
11569 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
11570 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
11572 // if only one direction, fall back to simple tube with that direction
11573 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
11574 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
11575 case (MV_UP): return EL_TUBE_VERTICAL;
11576 case (MV_DOWN): return EL_TUBE_VERTICAL;
11582 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
11584 int element_new = getTubeFromOpenDirection(direction);
11586 return (element_new != EL_EMPTY ? element_new : element_old);
11589 static int getOpenDirectionFromBelt(int element)
11591 int belt_dir = getBeltDirFromBeltElement(element);
11593 return (belt_dir == MV_LEFT ? MV_RIGHT :
11594 belt_dir == MV_RIGHT ? MV_LEFT :
11595 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
11598 static int getBeltFromNrAndOpenDirection(int nr, int direction)
11600 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
11601 direction == MV_RIGHT ? MV_LEFT :
11602 direction == MV_HORIZONTAL ? MV_NONE : direction);
11604 if (direction == MV_NONE)
11607 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
11610 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
11613 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
11615 return (element_new != EL_EMPTY ? element_new : element_old);
11618 static int getOpenDirectionFromPool(int element)
11622 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
11623 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
11624 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
11625 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
11626 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
11627 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
11633 static int getPoolFromOpenDirection(int direction)
11637 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
11638 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
11639 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
11640 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
11641 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
11642 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
11648 static int getPoolFromOpenDirectionExt(int direction, int help_element)
11650 int element = getPoolFromOpenDirection(direction);
11651 int help_direction = getOpenDirectionFromPool(help_element);
11653 if (element == EL_EMPTY)
11655 int help_direction_vertical = help_direction & MV_VERTICAL;
11657 element = getPoolFromOpenDirection(direction | help_direction_vertical);
11660 if (element == EL_EMPTY)
11662 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
11664 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
11670 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
11672 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
11674 return (element_new != EL_EMPTY ? element_new : element_old);
11677 static int getOpenDirectionFromPillar(int element)
11681 case EL_EMC_WALL_1: return (MV_DOWN);
11682 case EL_EMC_WALL_2: return (MV_VERTICAL);
11683 case EL_EMC_WALL_3: return (MV_UP);
11689 static int getPillarFromOpenDirection(int direction)
11693 case (MV_DOWN): return EL_EMC_WALL_1;
11694 case (MV_VERTICAL): return EL_EMC_WALL_2;
11695 case (MV_UP): return EL_EMC_WALL_3;
11701 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
11703 int element_new = getPillarFromOpenDirection(direction);
11705 return (element_new != EL_EMPTY ? element_new : element_old);
11708 static int getOpenDirectionFromSteel2(int element)
11712 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
11713 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
11714 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
11715 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
11716 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
11717 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
11718 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
11719 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
11725 static int getSteel2FromOpenDirection(int direction)
11729 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
11730 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
11731 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
11732 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
11733 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
11734 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
11735 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
11736 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
11742 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
11744 int element_new = getSteel2FromOpenDirection(direction);
11746 return (element_new != EL_EMPTY ? element_new : element_old);
11749 static int getOpenDirectionFromChip(int element)
11753 case EL_SP_CHIP_SINGLE: return (MV_NONE);
11754 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
11755 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
11756 case EL_SP_CHIP_TOP: return (MV_DOWN);
11757 case EL_SP_CHIP_BOTTOM: return (MV_UP);
11763 static int getChipFromOpenDirection(int direction)
11767 case (MV_NONE): return EL_SP_CHIP_SINGLE;
11768 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
11769 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
11770 case (MV_UP): return EL_SP_CHIP_BOTTOM;
11771 case (MV_DOWN): return EL_SP_CHIP_TOP;
11777 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
11779 int element_new = getChipFromOpenDirection(direction);
11781 return (element_new != EL_EMPTY ? element_new : element_old);
11784 static int getClosedTube(int x, int y)
11786 struct XY *xy = xy_directions;
11787 int element_old = IntelliDrawBuffer[x][y];
11788 int direction_old = getOpenDirectionFromTube(element_old);
11789 int direction_new = MV_NONE;
11792 for (i = 0; i < NUM_DIRECTIONS; i++)
11794 int xx = x + xy[i].x;
11795 int yy = y + xy[i].y;
11796 int dir = MV_DIR_FROM_BIT(i);
11797 int dir_opposite = MV_DIR_OPPOSITE(dir);
11799 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
11800 (direction_old & dir) &&
11801 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11802 direction_new |= dir;
11805 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
11808 static int getClosedBelt(int x, int y)
11810 struct XY *xy = xy_directions;
11811 int element_old = IntelliDrawBuffer[x][y];
11812 int nr = getBeltNrFromBeltElement(element_old);
11813 int direction_old = getOpenDirectionFromBelt(element_old);
11814 int direction_new = MV_NONE;
11817 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11819 int xx = x + xy[i].x;
11820 int yy = y + xy[i].y;
11821 int dir = MV_DIR_FROM_BIT(i);
11822 int dir_opposite = MV_DIR_OPPOSITE(dir);
11824 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
11825 (direction_old & dir) &&
11826 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11827 direction_new |= dir;
11830 return getBeltFromNrAndOpenDirection(nr, direction_new);
11833 static int getClosedPool(int x, int y)
11835 struct XY *xy = xy_directions;
11836 int element_old = IntelliDrawBuffer[x][y];
11837 int direction_old = getOpenDirectionFromPool(element_old);
11838 int direction_new = MV_NONE;
11841 for (i = 0; i < NUM_DIRECTIONS; i++)
11843 int xx = x + xy[i].x;
11844 int yy = y + xy[i].y;
11845 int dir = MV_DIR_FROM_BIT(i);
11846 int dir_opposite = MV_DIR_OPPOSITE(dir);
11848 if (IN_LEV_FIELD(xx, yy) &&
11849 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
11850 (direction_old & dir) &&
11851 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11852 direction_new |= dir;
11855 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
11858 static int getClosedPillar(int x, int y)
11860 struct XY *xy = xy_directions;
11861 int element_old = IntelliDrawBuffer[x][y];
11862 int direction_old = getOpenDirectionFromPillar(element_old);
11863 int direction_new = MV_NONE;
11866 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11868 int xx = x + xy[i].x;
11869 int yy = y + xy[i].y;
11870 int dir = MV_DIR_FROM_BIT(i);
11871 int dir_opposite = MV_DIR_OPPOSITE(dir);
11873 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11874 (direction_old & dir) &&
11875 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11876 direction_new |= dir;
11879 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11882 static int getClosedSteel2(int x, int y)
11884 struct XY *xy = xy_directions;
11885 int element_old = IntelliDrawBuffer[x][y];
11886 int direction_old = getOpenDirectionFromSteel2(element_old);
11887 int direction_new = MV_NONE;
11890 for (i = 0; i < NUM_DIRECTIONS; i++)
11892 int xx = x + xy[i].x;
11893 int yy = y + xy[i].y;
11894 int dir = MV_DIR_FROM_BIT(i);
11895 int dir_opposite = MV_DIR_OPPOSITE(dir);
11897 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11898 (direction_old & dir) &&
11899 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11900 direction_new |= dir;
11903 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11906 static int getClosedChip(int x, int y)
11908 struct XY *xy = xy_directions;
11909 int element_old = IntelliDrawBuffer[x][y];
11910 int direction_old = getOpenDirectionFromChip(element_old);
11911 int direction_new = MV_NONE;
11914 for (i = 0; i < NUM_DIRECTIONS; i++)
11916 int xx = x + xy[i].x;
11917 int yy = y + xy[i].y;
11918 int dir = MV_DIR_FROM_BIT(i);
11919 int dir_opposite = MV_DIR_OPPOSITE(dir);
11921 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11922 (direction_old & dir) &&
11923 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11924 direction_new |= dir;
11927 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11930 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11931 boolean change_level)
11933 int sx = x - level_xpos;
11934 int sy = y - level_ypos;
11935 int old_element = Tile[x][y];
11936 int new_element = element;
11937 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11938 boolean draw_masked = FALSE;
11940 if (IS_MM_WALL_EDITOR(element))
11942 element = map_mm_wall_element_editor(element) | new_bitmask;
11944 if (IS_MM_WALL(old_element))
11945 element |= MM_WALL_BITS(old_element);
11948 draw_masked = TRUE;
11950 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11952 int element_changed = old_element & ~new_bitmask;
11954 if (MM_WALL_BITS(element_changed) != 0)
11955 element = element_changed;
11958 IntelliDrawBuffer[x][y] = element;
11961 Tile[x][y] = element;
11963 if (IN_ED_FIELD(sx, sy))
11965 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11966 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11967 else if (draw_masked)
11968 DrawEditorElementThruMask(sx, sy, element);
11970 DrawEditorElement(sx, sy, element);
11974 static void SetElementSimple(int x, int y, int element, boolean change_level)
11976 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11979 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11980 int x2, int y2, int *element2,
11981 int (*close_function)(int, int),
11982 boolean change_level)
11984 // set neighbour elements to newly determined connections
11985 SetElementSimple(x1, y1, *element1, change_level);
11986 SetElementSimple(x2, y2, *element2, change_level);
11988 // remove all open connections of neighbour elements
11989 *element1 = close_function(x1, y1);
11990 *element2 = close_function(x2, y2);
11992 // set neighbour elements to new, minimized connections
11993 SetElementSimple(x1, y1, *element1, change_level);
11994 SetElementSimple(x2, y2, *element2, change_level);
11997 static void SetElementIntelliDraw(int x, int y, int dx, int dy, int new_element,
11998 boolean change_level, int button)
12000 struct XY *xy = xy_directions;
12001 static int last_x = -1;
12002 static int last_y = -1;
12004 if (new_element == EL_UNDEFINED)
12012 int old_element = IntelliDrawBuffer[x][y];
12014 if (IS_TUBE(new_element))
12016 int last_element_new = EL_UNDEFINED;
12017 int direction = MV_NONE;
12020 // if old element is of same kind, keep all existing directions
12021 if (IS_TUBE(old_element))
12022 direction |= getOpenDirectionFromTube(old_element);
12024 for (i = 0; i < NUM_DIRECTIONS; i++)
12026 int xx = x + xy[i].x;
12027 int yy = y + xy[i].y;
12029 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12030 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
12032 int dir = MV_DIR_FROM_BIT(i);
12033 int dir_opposite = MV_DIR_OPPOSITE(dir);
12034 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12035 int last_direction_old = getOpenDirectionFromTube(last_element_old);
12036 int last_direction_new = last_direction_old | dir_opposite;
12038 last_element_new = getTubeFromOpenDirection(last_direction_new);
12044 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
12046 if (last_element_new != EL_UNDEFINED)
12047 MergeAndCloseNeighbourElements(x, y, &new_element,
12048 last_x, last_y, &last_element_new,
12049 getClosedTube, change_level);
12051 else if (IS_BELT(new_element))
12053 int belt_nr = getBeltNrFromBeltElement(new_element);
12054 int last_element_new = EL_UNDEFINED;
12055 int direction = MV_NONE;
12058 // if old element is of same kind, keep all existing directions
12059 if (IS_BELT(old_element))
12060 direction |= getOpenDirectionFromBelt(old_element);
12062 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
12064 int xx = x + xy[i].x;
12065 int yy = y + xy[i].y;
12067 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12068 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
12070 int dir = MV_DIR_FROM_BIT(i);
12071 int dir_opposite = MV_DIR_OPPOSITE(dir);
12072 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12073 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
12074 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
12075 int last_direction_new = last_direction_old | dir_opposite;
12077 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
12078 last_direction_new);
12083 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
12085 if (last_element_new != EL_UNDEFINED)
12086 MergeAndCloseNeighbourElements(x, y, &new_element,
12087 last_x, last_y, &last_element_new,
12088 getClosedBelt, change_level);
12090 else if (IS_ACID_POOL_OR_ACID(new_element))
12092 int last_element_new = EL_UNDEFINED;
12093 int direction = MV_NONE;
12096 // if old element is of same kind, keep all existing directions
12097 if (IS_ACID_POOL_OR_ACID(old_element))
12098 direction |= getOpenDirectionFromPool(old_element);
12100 for (i = 0; i < NUM_DIRECTIONS; i++)
12102 int xx = x + xy[i].x;
12103 int yy = y + xy[i].y;
12105 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12106 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
12108 int dir = MV_DIR_FROM_BIT(i);
12109 int dir_opposite = MV_DIR_OPPOSITE(dir);
12110 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12111 int last_direction_old = getOpenDirectionFromPool(last_element_old);
12112 int last_direction_new = last_direction_old | dir_opposite;
12114 last_element_new = getPoolFromOpenDirection(last_direction_new);
12120 // special corrections needed for intuitively correct acid pool drawing
12121 if (last_element_new == EL_EMPTY)
12122 last_element_new = new_element;
12123 else if (last_element_new != EL_UNDEFINED)
12124 new_element = last_element_new;
12126 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
12128 if (last_element_new != EL_UNDEFINED)
12129 MergeAndCloseNeighbourElements(x, y, &new_element,
12130 last_x, last_y, &last_element_new,
12131 getClosedPool, change_level);
12133 else if (IS_EMC_PILLAR(new_element))
12135 int last_element_new = EL_UNDEFINED;
12136 int direction = MV_NONE;
12139 // if old element is of same kind, keep all existing directions
12140 if (IS_EMC_PILLAR(old_element))
12141 direction |= getOpenDirectionFromPillar(old_element);
12143 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
12145 int xx = x + xy[i].x;
12146 int yy = y + xy[i].y;
12148 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12149 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
12151 int dir = MV_DIR_FROM_BIT(i);
12152 int dir_opposite = MV_DIR_OPPOSITE(dir);
12153 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12154 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
12155 int last_direction_new = last_direction_old | dir_opposite;
12157 last_element_new = getPillarFromOpenDirection(last_direction_new);
12163 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
12165 if (last_element_new != EL_UNDEFINED)
12166 MergeAndCloseNeighbourElements(x, y, &new_element,
12167 last_x, last_y, &last_element_new,
12168 getClosedPillar, change_level);
12170 else if (IS_DC_STEELWALL_2(new_element))
12172 int last_element_new = EL_UNDEFINED;
12173 int direction = MV_NONE;
12176 // if old element is of same kind, keep all existing directions
12177 if (IS_DC_STEELWALL_2(old_element))
12178 direction |= getOpenDirectionFromSteel2(old_element);
12180 for (i = 0; i < NUM_DIRECTIONS; i++)
12182 int xx = x + xy[i].x;
12183 int yy = y + xy[i].y;
12185 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12186 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
12188 int dir = MV_DIR_FROM_BIT(i);
12189 int dir_opposite = MV_DIR_OPPOSITE(dir);
12190 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12191 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
12192 int last_direction_new = last_direction_old | dir_opposite;
12194 last_element_new = getSteel2FromOpenDirection(last_direction_new);
12200 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
12202 if (last_element_new != EL_UNDEFINED)
12203 MergeAndCloseNeighbourElements(x, y, &new_element,
12204 last_x, last_y, &last_element_new,
12205 getClosedSteel2, change_level);
12207 else if (IS_SP_CHIP(new_element))
12209 int last_element_new = EL_UNDEFINED;
12210 int direction = MV_NONE;
12213 // (do not keep existing directions, regardless of kind of old element)
12215 for (i = 0; i < NUM_DIRECTIONS; i++)
12217 int xx = x + xy[i].x;
12218 int yy = y + xy[i].y;
12220 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12221 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
12223 int dir = MV_DIR_FROM_BIT(i);
12224 int dir_opposite = MV_DIR_OPPOSITE(dir);
12225 int last_element_old = IntelliDrawBuffer[last_x][last_y];
12226 int last_direction_old = getOpenDirectionFromChip(last_element_old);
12227 int last_direction_new = last_direction_old | dir_opposite;
12229 if (last_direction_old == MV_NONE)
12231 last_element_new = getChipFromOpenDirection(last_direction_new);
12234 else if (last_direction_old & (dir | dir_opposite))
12236 direction |= MV_DIR_OPPOSITE(last_direction_old);
12240 direction |= MV_DIR_OPPOSITE(dir);
12245 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
12247 if (last_element_new != EL_UNDEFINED)
12248 MergeAndCloseNeighbourElements(x, y, &new_element,
12249 last_x, last_y, &last_element_new,
12250 getClosedChip, change_level);
12252 else if (IS_SP_HARDWARE_BASE(new_element))
12254 int nr = GetSimpleRandom(6);
12256 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
12257 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
12258 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
12259 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
12260 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
12262 else if (new_element == EL_SP_HARDWARE_GREEN ||
12263 new_element == EL_SP_HARDWARE_BLUE ||
12264 new_element == EL_SP_HARDWARE_RED)
12266 int nr = GetSimpleRandom(3);
12268 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
12269 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
12271 else if (IS_GROUP_ELEMENT(new_element))
12273 boolean connected_drawing = FALSE;
12276 for (i = 0; i < NUM_DIRECTIONS; i++)
12278 int xx = x + xy[i].x;
12279 int yy = y + xy[i].y;
12281 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12282 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
12283 connected_drawing = TRUE;
12286 if (!connected_drawing)
12287 ResolveGroupElement(new_element);
12289 new_element = GetElementFromGroupElement(new_element);
12291 else if (IS_BELT_SWITCH(old_element))
12293 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
12294 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
12296 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
12297 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
12299 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
12303 static int swappable_elements[][2] =
12305 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
12306 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
12307 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
12308 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
12309 { EL_EMERALD, EL_WALL_EMERALD },
12310 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
12311 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
12312 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
12313 { EL_DIAMOND, EL_WALL_DIAMOND },
12314 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
12315 { EL_GATE_1, EL_GATE_1_GRAY },
12316 { EL_GATE_2, EL_GATE_2_GRAY },
12317 { EL_GATE_3, EL_GATE_3_GRAY },
12318 { EL_GATE_4, EL_GATE_4_GRAY },
12319 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
12320 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
12321 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
12322 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
12323 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
12324 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
12325 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
12326 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
12327 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
12328 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
12329 { EL_LAMP, EL_LAMP_ACTIVE },
12330 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
12331 { EL_SP_BASE, EL_SP_BUGGY_BASE },
12332 { EL_PEARL, EL_WALL_PEARL },
12333 { EL_CRYSTAL, EL_WALL_CRYSTAL },
12334 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
12335 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
12336 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
12337 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
12338 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
12339 { EL_LANDMINE, EL_DC_LANDMINE },
12340 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
12341 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
12342 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
12343 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
12344 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
12345 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
12346 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
12347 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
12348 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
12352 static int rotatable_elements_4[][4] =
12362 EL_SPACESHIP_RIGHT,
12367 EL_BD_BUTTERFLY_UP,
12368 EL_BD_BUTTERFLY_RIGHT,
12369 EL_BD_BUTTERFLY_DOWN,
12370 EL_BD_BUTTERFLY_LEFT
12374 EL_BD_FIREFLY_RIGHT,
12375 EL_BD_FIREFLY_DOWN,
12403 EL_SP_GRAVITY_PORT_UP,
12404 EL_SP_GRAVITY_PORT_RIGHT,
12405 EL_SP_GRAVITY_PORT_DOWN,
12406 EL_SP_GRAVITY_PORT_LEFT
12409 EL_SP_GRAVITY_ON_PORT_UP,
12410 EL_SP_GRAVITY_ON_PORT_RIGHT,
12411 EL_SP_GRAVITY_ON_PORT_DOWN,
12412 EL_SP_GRAVITY_ON_PORT_LEFT
12415 EL_SP_GRAVITY_OFF_PORT_UP,
12416 EL_SP_GRAVITY_OFF_PORT_RIGHT,
12417 EL_SP_GRAVITY_OFF_PORT_DOWN,
12418 EL_SP_GRAVITY_OFF_PORT_LEFT
12427 EL_BALLOON_SWITCH_UP,
12428 EL_BALLOON_SWITCH_RIGHT,
12429 EL_BALLOON_SWITCH_DOWN,
12430 EL_BALLOON_SWITCH_LEFT
12434 EL_MM_MCDUFFIN_RIGHT,
12435 EL_MM_MCDUFFIN_DOWN,
12436 EL_MM_MCDUFFIN_LEFT
12439 EL_MM_MIRROR_FIXED_1,
12440 EL_MM_MIRROR_FIXED_4,
12441 EL_MM_MIRROR_FIXED_3,
12442 EL_MM_MIRROR_FIXED_2
12445 EL_MM_STEEL_GRID_FIXED_1,
12446 EL_MM_STEEL_GRID_FIXED_4,
12447 EL_MM_STEEL_GRID_FIXED_2,
12448 EL_MM_STEEL_GRID_FIXED_3
12451 EL_MM_WOODEN_GRID_FIXED_1,
12452 EL_MM_WOODEN_GRID_FIXED_4,
12453 EL_MM_WOODEN_GRID_FIXED_2,
12454 EL_MM_WOODEN_GRID_FIXED_3
12457 EL_MM_POLARIZER_CROSS_1,
12458 EL_MM_POLARIZER_CROSS_4,
12459 EL_MM_POLARIZER_CROSS_3,
12460 EL_MM_POLARIZER_CROSS_2
12464 EL_MM_PACMAN_RIGHT,
12476 EL_DF_RECEIVER_RIGHT,
12477 EL_DF_RECEIVER_DOWN,
12478 EL_DF_RECEIVER_LEFT
12491 static int rotatable_elements_8[][8] =
12494 EL_DF_STEEL_GRID_FIXED_1,
12495 EL_DF_STEEL_GRID_FIXED_8,
12496 EL_DF_STEEL_GRID_FIXED_7,
12497 EL_DF_STEEL_GRID_FIXED_6,
12498 EL_DF_STEEL_GRID_FIXED_5,
12499 EL_DF_STEEL_GRID_FIXED_4,
12500 EL_DF_STEEL_GRID_FIXED_3,
12501 EL_DF_STEEL_GRID_FIXED_2
12504 EL_DF_WOODEN_GRID_FIXED_1,
12505 EL_DF_WOODEN_GRID_FIXED_8,
12506 EL_DF_WOODEN_GRID_FIXED_7,
12507 EL_DF_WOODEN_GRID_FIXED_6,
12508 EL_DF_WOODEN_GRID_FIXED_5,
12509 EL_DF_WOODEN_GRID_FIXED_4,
12510 EL_DF_WOODEN_GRID_FIXED_3,
12511 EL_DF_WOODEN_GRID_FIXED_2
12514 EL_DF_STEEL_GRID_ROTATING_1,
12515 EL_DF_STEEL_GRID_ROTATING_8,
12516 EL_DF_STEEL_GRID_ROTATING_7,
12517 EL_DF_STEEL_GRID_ROTATING_6,
12518 EL_DF_STEEL_GRID_ROTATING_5,
12519 EL_DF_STEEL_GRID_ROTATING_4,
12520 EL_DF_STEEL_GRID_ROTATING_3,
12521 EL_DF_STEEL_GRID_ROTATING_2
12524 EL_DF_WOODEN_GRID_ROTATING_1,
12525 EL_DF_WOODEN_GRID_ROTATING_8,
12526 EL_DF_WOODEN_GRID_ROTATING_7,
12527 EL_DF_WOODEN_GRID_ROTATING_6,
12528 EL_DF_WOODEN_GRID_ROTATING_5,
12529 EL_DF_WOODEN_GRID_ROTATING_4,
12530 EL_DF_WOODEN_GRID_ROTATING_3,
12531 EL_DF_WOODEN_GRID_ROTATING_2
12538 static int rotatable_elements_16[][16] =
12559 EL_MM_TELEPORTER_5,
12560 EL_MM_TELEPORTER_4,
12561 EL_MM_TELEPORTER_3,
12562 EL_MM_TELEPORTER_2,
12563 EL_MM_TELEPORTER_1,
12564 EL_MM_TELEPORTER_16,
12565 EL_MM_TELEPORTER_15,
12566 EL_MM_TELEPORTER_14,
12567 EL_MM_TELEPORTER_13,
12568 EL_MM_TELEPORTER_12,
12569 EL_MM_TELEPORTER_11,
12570 EL_MM_TELEPORTER_10,
12571 EL_MM_TELEPORTER_9,
12572 EL_MM_TELEPORTER_8,
12573 EL_MM_TELEPORTER_7,
12577 EL_MM_TELEPORTER_RED_5,
12578 EL_MM_TELEPORTER_RED_4,
12579 EL_MM_TELEPORTER_RED_3,
12580 EL_MM_TELEPORTER_RED_2,
12581 EL_MM_TELEPORTER_RED_1,
12582 EL_MM_TELEPORTER_RED_16,
12583 EL_MM_TELEPORTER_RED_15,
12584 EL_MM_TELEPORTER_RED_14,
12585 EL_MM_TELEPORTER_RED_13,
12586 EL_MM_TELEPORTER_RED_12,
12587 EL_MM_TELEPORTER_RED_11,
12588 EL_MM_TELEPORTER_RED_10,
12589 EL_MM_TELEPORTER_RED_9,
12590 EL_MM_TELEPORTER_RED_8,
12591 EL_MM_TELEPORTER_RED_7,
12592 EL_MM_TELEPORTER_RED_6
12595 EL_MM_TELEPORTER_YELLOW_5,
12596 EL_MM_TELEPORTER_YELLOW_4,
12597 EL_MM_TELEPORTER_YELLOW_3,
12598 EL_MM_TELEPORTER_YELLOW_2,
12599 EL_MM_TELEPORTER_YELLOW_1,
12600 EL_MM_TELEPORTER_YELLOW_16,
12601 EL_MM_TELEPORTER_YELLOW_15,
12602 EL_MM_TELEPORTER_YELLOW_14,
12603 EL_MM_TELEPORTER_YELLOW_13,
12604 EL_MM_TELEPORTER_YELLOW_12,
12605 EL_MM_TELEPORTER_YELLOW_11,
12606 EL_MM_TELEPORTER_YELLOW_10,
12607 EL_MM_TELEPORTER_YELLOW_9,
12608 EL_MM_TELEPORTER_YELLOW_8,
12609 EL_MM_TELEPORTER_YELLOW_7,
12610 EL_MM_TELEPORTER_YELLOW_6
12613 EL_MM_TELEPORTER_GREEN_5,
12614 EL_MM_TELEPORTER_GREEN_4,
12615 EL_MM_TELEPORTER_GREEN_3,
12616 EL_MM_TELEPORTER_GREEN_2,
12617 EL_MM_TELEPORTER_GREEN_1,
12618 EL_MM_TELEPORTER_GREEN_16,
12619 EL_MM_TELEPORTER_GREEN_15,
12620 EL_MM_TELEPORTER_GREEN_14,
12621 EL_MM_TELEPORTER_GREEN_13,
12622 EL_MM_TELEPORTER_GREEN_12,
12623 EL_MM_TELEPORTER_GREEN_11,
12624 EL_MM_TELEPORTER_GREEN_10,
12625 EL_MM_TELEPORTER_GREEN_9,
12626 EL_MM_TELEPORTER_GREEN_8,
12627 EL_MM_TELEPORTER_GREEN_7,
12628 EL_MM_TELEPORTER_GREEN_6
12631 EL_MM_TELEPORTER_BLUE_5,
12632 EL_MM_TELEPORTER_BLUE_4,
12633 EL_MM_TELEPORTER_BLUE_3,
12634 EL_MM_TELEPORTER_BLUE_2,
12635 EL_MM_TELEPORTER_BLUE_1,
12636 EL_MM_TELEPORTER_BLUE_16,
12637 EL_MM_TELEPORTER_BLUE_15,
12638 EL_MM_TELEPORTER_BLUE_14,
12639 EL_MM_TELEPORTER_BLUE_13,
12640 EL_MM_TELEPORTER_BLUE_12,
12641 EL_MM_TELEPORTER_BLUE_11,
12642 EL_MM_TELEPORTER_BLUE_10,
12643 EL_MM_TELEPORTER_BLUE_9,
12644 EL_MM_TELEPORTER_BLUE_8,
12645 EL_MM_TELEPORTER_BLUE_7,
12646 EL_MM_TELEPORTER_BLUE_6
12650 EL_MM_POLARIZER_16,
12651 EL_MM_POLARIZER_15,
12652 EL_MM_POLARIZER_14,
12653 EL_MM_POLARIZER_13,
12654 EL_MM_POLARIZER_12,
12655 EL_MM_POLARIZER_11,
12656 EL_MM_POLARIZER_10,
12685 EL_DF_MIRROR_ROTATING_1,
12686 EL_DF_MIRROR_ROTATING_16,
12687 EL_DF_MIRROR_ROTATING_15,
12688 EL_DF_MIRROR_ROTATING_14,
12689 EL_DF_MIRROR_ROTATING_13,
12690 EL_DF_MIRROR_ROTATING_12,
12691 EL_DF_MIRROR_ROTATING_11,
12692 EL_DF_MIRROR_ROTATING_10,
12693 EL_DF_MIRROR_ROTATING_9,
12694 EL_DF_MIRROR_ROTATING_8,
12695 EL_DF_MIRROR_ROTATING_7,
12696 EL_DF_MIRROR_ROTATING_6,
12697 EL_DF_MIRROR_ROTATING_5,
12698 EL_DF_MIRROR_ROTATING_4,
12699 EL_DF_MIRROR_ROTATING_3,
12700 EL_DF_MIRROR_ROTATING_2
12703 EL_DF_MIRROR_FIXED_1,
12704 EL_DF_MIRROR_FIXED_16,
12705 EL_DF_MIRROR_FIXED_15,
12706 EL_DF_MIRROR_FIXED_14,
12707 EL_DF_MIRROR_FIXED_13,
12708 EL_DF_MIRROR_FIXED_12,
12709 EL_DF_MIRROR_FIXED_11,
12710 EL_DF_MIRROR_FIXED_10,
12711 EL_DF_MIRROR_FIXED_9,
12712 EL_DF_MIRROR_FIXED_8,
12713 EL_DF_MIRROR_FIXED_7,
12714 EL_DF_MIRROR_FIXED_6,
12715 EL_DF_MIRROR_FIXED_5,
12716 EL_DF_MIRROR_FIXED_4,
12717 EL_DF_MIRROR_FIXED_3,
12718 EL_DF_MIRROR_FIXED_2
12727 for (i = 0; swappable_elements[i][0] != -1; i++)
12729 int element1 = swappable_elements[i][0];
12730 int element2 = swappable_elements[i][1];
12732 if (old_element == element1 || old_element == element2)
12733 new_element = (old_element == element1 ? element2 : element1);
12736 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
12738 for (j = 0; j < 4; j++)
12740 int element = rotatable_elements_4[i][j];
12742 if (old_element == element)
12743 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
12744 button == 2 ? rotatable_elements_4[i][0] :
12745 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
12750 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
12752 for (j = 0; j < 8; j++)
12754 int element = rotatable_elements_8[i][j];
12756 if (old_element == element)
12757 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
12758 button == 2 ? rotatable_elements_8[i][0] :
12759 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
12764 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
12766 for (j = 0; j < 16; j++)
12768 int element = rotatable_elements_16[i][j];
12770 if (old_element == element)
12771 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
12772 button == 2 ? rotatable_elements_16[i][0] :
12773 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
12778 if (old_element != new_element)
12780 int max_infotext_len = getMaxInfoTextLength();
12781 char infotext[MAX_OUTPUT_LINESIZE + 1];
12783 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
12784 infotext[max_infotext_len] = '\0';
12786 ClearEditorGadgetInfoText();
12788 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
12793 if (IS_MM_WALL_EDITOR(new_element))
12794 SetElementSimpleExt(x, y, dx, dy, new_element, change_level);
12796 SetElementSimple(x, y, new_element, change_level);
12802 static void ResetIntelliDraw(void)
12806 for (x = 0; x < lev_fieldx; x++)
12807 for (y = 0; y < lev_fieldy; y++)
12808 IntelliDrawBuffer[x][y] = Tile[x][y];
12810 SetElementIntelliDraw(-1, -1, -1, -1, EL_UNDEFINED, FALSE, -1);
12813 static boolean draw_mode_hires = FALSE;
12815 static boolean isHiresTileElement(int element)
12817 return (IS_MM_WALL(element) || element == EL_EMPTY);
12820 static boolean isHiresDrawElement(int element)
12822 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
12825 static int numHiresTiles(int element)
12827 if (IS_MM_WALL(element))
12828 return get_number_of_bits(MM_WALL_BITS(element));
12833 static void SetDrawModeHiRes(int element)
12836 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12837 isHiresDrawElement(element));
12840 static boolean getDrawModeHiRes(void)
12842 return draw_mode_hires;
12845 static int getLoResScreenPos(int pos)
12847 return (getDrawModeHiRes() ? pos / 2 : pos);
12850 static int getLoResScreenMod(int pos)
12852 return (getDrawModeHiRes() ? pos % 2 : 0);
12855 static void SetElementExt(int x, int y, int dx, int dy, int element,
12856 boolean change_level, int button)
12859 SetElementSimple(x, y, Tile[x][y], change_level);
12860 else if (GetKeyModState() & KMOD_Shift)
12861 SetElementIntelliDraw(x, y, dx, dy, element, change_level, button);
12863 SetElementSimpleExt(x, y, dx, dy, element, change_level);
12866 static void SetElement(int x, int y, int element)
12868 SetElementExt(x, y, 0, 0, element, TRUE, -1);
12871 static void SetElementButton(int x, int y, int dx, int dy, int element,
12874 SetElementExt(x, y, dx, dy, element, TRUE, button);
12877 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
12879 int lx = getLoResScreenPos(sx2) + level_xpos;
12880 int ly = getLoResScreenPos(sy2) + level_ypos;
12881 int dx = getLoResScreenMod(sx2);
12882 int dy = getLoResScreenMod(sy2);
12884 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
12887 static void SetLevelElementHiRes(int lx2, int ly2, int element)
12894 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
12897 static int getLevelElementHiRes(int lx2, int ly2)
12903 int element = Tile[lx][ly];
12904 unsigned int bitmask = (dx + 1) << (dy * 2);
12906 if (IS_MM_WALL(element))
12908 if (element & bitmask)
12909 return map_mm_wall_element(element);
12917 static void DrawLineElement(int x, int y, int element, boolean change_level)
12919 SetElementHiRes(x, y, element, change_level);
12922 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12923 int element, boolean change_level)
12925 int xsize = ABS(to_x - from_x);
12926 int ysize = ABS(to_y - from_y);
12927 int dx = (to_x < from_x ? -1 : +1);
12928 int dy = (to_y < from_y ? -1 : +1);
12931 if (from_y == to_y) // horizontal line
12933 for (i = 0; i <= xsize; i++)
12934 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12936 else if (from_x == to_x) // vertical line
12938 for (i = 0; i <= ysize; i++)
12939 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12941 else // diagonal line
12943 if (ysize < xsize) // a < 1
12945 float a = (float)ysize / (float)xsize;
12947 for (i = 0; i <= xsize; i++)
12950 int y = dy * (int)(a * i + 0.5);
12952 DrawLineElement(from_x + x, from_y + y, element, change_level);
12957 float a = (float)xsize / (float)ysize;
12959 for (i = 0; i <= ysize; i++)
12961 int x = dx * (int)(a * i + 0.5);
12964 DrawLineElement(from_x + x, from_y + y, element, change_level);
12970 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12971 int element, boolean change_level)
12973 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12974 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12975 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12976 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12979 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12980 int element, boolean change_level)
12985 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12987 for (y = from_y; y <= to_y; y++)
12988 DrawLine(from_x, y, to_x, y, element, change_level);
12991 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12992 int element, boolean change_level)
12994 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12995 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12996 int len_x = ABS(to_x - from_x);
12997 int len_y = ABS(to_y - from_y);
13000 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
13002 // not optimal (some points get drawn twice) but simple,
13003 // and fast enough for the few points we are drawing
13005 for (x = 0; x <= radius; x++)
13007 int sx, sy, sx2, sy2, lx, ly;
13009 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
13011 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
13012 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
13013 sx = getLoResScreenPos(sx2);
13014 sy = getLoResScreenPos(sy2);
13015 lx = sx + level_xpos;
13016 ly = sy + level_ypos;
13018 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13019 DrawLineElement(sx2, sy2, element, change_level);
13022 for (y = 0; y <= radius; y++)
13024 int sx, sy, sx2, sy2, lx, ly;
13026 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
13028 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
13029 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
13030 sx = getLoResScreenPos(sx2);
13031 sy = getLoResScreenPos(sy2);
13032 lx = sx + level_xpos;
13033 ly = sy + level_ypos;
13035 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13036 DrawLineElement(sx2, sy2, element, change_level);
13040 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
13041 int element, boolean change_level)
13043 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
13044 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
13046 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
13049 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
13051 #if DRAW_CIRCLES_BUTTON_AVAILABLE
13052 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
13053 int element, boolean change_level)
13055 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
13056 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
13057 int mirror_to_x2 = from_x - (to_x2 - from_x);
13058 int mirror_to_y2 = from_y - (to_y2 - from_y);
13060 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
13061 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
13062 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
13063 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element, change_level);
13067 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
13069 int from_sx, from_sy;
13073 swap_numbers(&from_x, &to_x);
13076 swap_numbers(&from_y, &to_y);
13078 from_sx = SX + from_x * ed_tilesize;
13079 from_sy = SY + from_y * ed_tilesize;
13080 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
13081 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
13083 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13084 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13085 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13086 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13088 if (from_x == to_x && from_y == to_y)
13089 MarkTileDirty(from_x/2, from_y/2);
13091 redraw_mask |= REDRAW_FIELD;
13094 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
13095 int element, boolean change_level)
13097 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
13100 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
13101 int element, boolean change_level)
13103 if (element == -1 || change_level)
13104 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
13106 DrawAreaBorder(from_x, from_y, to_x, to_y);
13109 // values for CopyBrushExt()
13110 #define CB_AREA_TO_BRUSH 0
13111 #define CB_BRUSH_TO_CURSOR 1
13112 #define CB_BRUSH_TO_LEVEL 2
13113 #define CB_DELETE_OLD_CURSOR 3
13114 #define CB_DUMP_BRUSH 4
13115 #define CB_DUMP_BRUSH_SMALL 5
13116 #define CB_CLIPBOARD_TO_BRUSH 6
13117 #define CB_BRUSH_TO_CLIPBOARD 7
13118 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
13119 #define CB_UPDATE_BRUSH_POSITION 9
13120 #define CB_FLIP_BRUSH_X 10
13121 #define CB_FLIP_BRUSH_Y 11
13122 #define CB_FLIP_BRUSH_XY 12
13124 #define MAX_CB_PART_SIZE 10
13125 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
13126 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
13127 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
13128 MAX_CB_NUM_LINES * \
13131 static int getFlippedTileExt(int map[], int element)
13135 for (i = 0; map[i] != -1; i++)
13136 if (map[i] == element)
13137 return map[i ^ 1]; // get flipped element by flipping LSB of index
13142 static int getFlippedTileX(int element)
13146 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_RIGHT,
13147 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_RIGHT,
13148 EL_BUG_LEFT, EL_BUG_RIGHT,
13149 EL_SPACESHIP_LEFT, EL_SPACESHIP_RIGHT,
13150 EL_PACMAN_LEFT, EL_PACMAN_RIGHT,
13151 EL_ARROW_LEFT, EL_ARROW_RIGHT,
13152 EL_MOLE_LEFT, EL_MOLE_RIGHT,
13153 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_RIGHT,
13154 EL_YAMYAM_LEFT, EL_YAMYAM_RIGHT,
13155 EL_SP_PORT_LEFT, EL_SP_PORT_RIGHT,
13156 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_RIGHT,
13157 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_RIGHT,
13158 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_RIGHT,
13159 EL_CONVEYOR_BELT_1_LEFT, EL_CONVEYOR_BELT_1_RIGHT,
13160 EL_CONVEYOR_BELT_2_LEFT, EL_CONVEYOR_BELT_2_RIGHT,
13161 EL_CONVEYOR_BELT_3_LEFT, EL_CONVEYOR_BELT_3_RIGHT,
13162 EL_CONVEYOR_BELT_4_LEFT, EL_CONVEYOR_BELT_4_RIGHT,
13163 EL_SPRING_LEFT, EL_SPRING_RIGHT,
13164 EL_SP_CHIP_LEFT, EL_SP_CHIP_RIGHT,
13165 EL_TUBE_VERTICAL_LEFT, EL_TUBE_VERTICAL_RIGHT,
13166 EL_TUBE_LEFT_UP, EL_TUBE_RIGHT_UP,
13167 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_DOWN,
13168 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_RIGHT,
13169 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_TOPRIGHT,
13170 EL_DC_STEELWALL_1_BOTTOMLEFT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13171 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_TOPRIGHT_2,
13172 EL_DC_STEELWALL_1_BOTTOMLEFT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13173 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_RIGHT,
13174 EL_ACID_POOL_TOPLEFT, EL_ACID_POOL_TOPRIGHT,
13175 EL_ACID_POOL_BOTTOMLEFT, EL_ACID_POOL_BOTTOMRIGHT,
13180 return getFlippedTileExt(map, element);
13183 static int getFlippedTileY(int element)
13187 EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY_DOWN,
13188 EL_BD_FIREFLY_UP, EL_BD_FIREFLY_DOWN,
13189 EL_BUG_UP, EL_BUG_DOWN,
13190 EL_SPACESHIP_UP, EL_SPACESHIP_DOWN,
13191 EL_PACMAN_UP, EL_PACMAN_DOWN,
13192 EL_ARROW_UP, EL_ARROW_DOWN,
13193 EL_MOLE_UP, EL_MOLE_DOWN,
13194 EL_BALLOON_SWITCH_UP, EL_BALLOON_SWITCH_DOWN,
13195 EL_YAMYAM_UP, EL_YAMYAM_DOWN,
13196 EL_SP_PORT_UP, EL_SP_PORT_DOWN,
13197 EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN,
13198 EL_SP_GRAVITY_ON_PORT_UP, EL_SP_GRAVITY_ON_PORT_DOWN,
13199 EL_SP_GRAVITY_OFF_PORT_UP, EL_SP_GRAVITY_OFF_PORT_DOWN,
13200 EL_SP_CHIP_TOP, EL_SP_CHIP_BOTTOM,
13201 EL_TUBE_HORIZONTAL_UP, EL_TUBE_HORIZONTAL_DOWN,
13202 EL_TUBE_LEFT_UP, EL_TUBE_LEFT_DOWN,
13203 EL_TUBE_RIGHT_UP, EL_TUBE_RIGHT_DOWN,
13204 EL_DC_STEELWALL_1_TOP, EL_DC_STEELWALL_1_BOTTOM,
13205 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13206 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
13207 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13208 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
13209 EL_DC_STEELWALL_2_TOP, EL_DC_STEELWALL_2_BOTTOM,
13210 EL_EMC_WALL_1, EL_EMC_WALL_3,
13215 return getFlippedTileExt(map, element);
13218 static int getFlippedTileXY(int element)
13222 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_UP,
13223 EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY_DOWN,
13224 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_UP,
13225 EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY_DOWN,
13226 EL_BUG_LEFT, EL_BUG_UP,
13227 EL_BUG_RIGHT, EL_BUG_DOWN,
13228 EL_SPACESHIP_LEFT, EL_SPACESHIP_UP,
13229 EL_SPACESHIP_RIGHT, EL_SPACESHIP_DOWN,
13230 EL_PACMAN_LEFT, EL_PACMAN_UP,
13231 EL_PACMAN_RIGHT, EL_PACMAN_DOWN,
13232 EL_ARROW_LEFT, EL_ARROW_UP,
13233 EL_ARROW_RIGHT, EL_ARROW_DOWN,
13234 EL_MOLE_LEFT, EL_MOLE_UP,
13235 EL_MOLE_RIGHT, EL_MOLE_DOWN,
13236 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_UP,
13237 EL_BALLOON_SWITCH_RIGHT, EL_BALLOON_SWITCH_DOWN,
13238 EL_YAMYAM_LEFT, EL_YAMYAM_UP,
13239 EL_YAMYAM_RIGHT, EL_YAMYAM_DOWN,
13240 EL_SP_PORT_LEFT, EL_SP_PORT_UP,
13241 EL_SP_PORT_RIGHT, EL_SP_PORT_DOWN,
13242 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_UP,
13243 EL_SP_GRAVITY_PORT_RIGHT, EL_SP_GRAVITY_PORT_DOWN,
13244 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_UP,
13245 EL_SP_GRAVITY_ON_PORT_RIGHT, EL_SP_GRAVITY_ON_PORT_DOWN,
13246 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_UP,
13247 EL_SP_GRAVITY_OFF_PORT_RIGHT, EL_SP_GRAVITY_OFF_PORT_DOWN,
13248 EL_SP_CHIP_LEFT, EL_SP_CHIP_TOP,
13249 EL_SP_CHIP_RIGHT, EL_SP_CHIP_BOTTOM,
13250 EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL,
13251 EL_TUBE_VERTICAL_LEFT, EL_TUBE_HORIZONTAL_UP,
13252 EL_TUBE_VERTICAL_RIGHT, EL_TUBE_HORIZONTAL_DOWN,
13253 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_UP,
13254 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_TOP,
13255 EL_DC_STEELWALL_1_RIGHT, EL_DC_STEELWALL_1_BOTTOM,
13256 EL_DC_STEELWALL_1_HORIZONTAL, EL_DC_STEELWALL_1_VERTICAL,
13257 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13258 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13259 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_TOP,
13260 EL_DC_STEELWALL_2_RIGHT, EL_DC_STEELWALL_2_BOTTOM,
13261 EL_DC_STEELWALL_2_HORIZONTAL, EL_DC_STEELWALL_2_VERTICAL,
13262 EL_EXPANDABLE_WALL_HORIZONTAL, EL_EXPANDABLE_WALL_VERTICAL,
13263 EL_EXPANDABLE_STEELWALL_HORIZONTAL, EL_EXPANDABLE_STEELWALL_VERTICAL,
13268 return getFlippedTileExt(map, element);
13271 static int getFlippedTile(int element, int mode)
13273 if (IS_MM_ELEMENT(element))
13275 // get MM game element
13276 element = map_element_RND_to_MM(element);
13278 // get flipped game element
13279 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX_MM(element) :
13280 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY_MM(element) :
13281 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY_MM(element) :
13284 // get RND game element again
13285 element = map_element_MM_to_RND(element);
13289 // get flipped game element
13290 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX(element) :
13291 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY(element) :
13292 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY(element) :
13299 static void SwapFlippedTiles(short *tile1, short *tile2, int mode)
13302 short tile1_flipped = getFlippedTile(*tile1, mode);
13303 short tile2_flipped = getFlippedTile(*tile2, mode);
13306 *tile1 = tile2_flipped;
13307 *tile2 = tile1_flipped;
13310 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
13312 DrawLineElement(sx, sy, element, change_level);
13315 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
13316 int button, int mode)
13318 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13319 static int brush_width, brush_height;
13320 static int last_cursor_x = -1, last_cursor_y = -1;
13321 static boolean delete_old_brush = FALSE;
13322 int new_element = BUTTON_ELEMENT(button);
13325 if (mode == CB_DUMP_BRUSH ||
13326 mode == CB_DUMP_BRUSH_SMALL ||
13327 mode == CB_BRUSH_TO_CLIPBOARD ||
13328 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13330 if (edit_mode != ED_MODE_DRAWING)
13333 char part[MAX_CB_PART_SIZE + 1] = "";
13334 char text[MAX_CB_TEXT_SIZE + 1] = "";
13335 int width = (draw_with_brush ? brush_width : lev_fieldx);
13336 int height = (draw_with_brush ? brush_height : lev_fieldy);
13337 char *format = "%s%03d";
13339 for (y = 0; y < height; y++)
13340 for (x = 0; x < width; x++)
13341 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
13344 for (y = 0; y < height; y++)
13346 for (x = 0; x < width; x++)
13348 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
13349 char *prefix = (mode == CB_DUMP_BRUSH ||
13350 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
13352 if (element >= NUM_FILE_ELEMENTS)
13353 element = EL_UNKNOWN;
13355 // copy brush to level sketch text buffer for the R'n'D forum:
13356 // - large tiles: `xxx or `xxxx (0x60 ASCII)
13357 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
13358 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
13359 strcat(text, part);
13362 strcat(text, "\n");
13365 if (mode == CB_BRUSH_TO_CLIPBOARD ||
13366 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13367 SDL_SetClipboardText(text);
13369 Print("%s", text); // print brush data to console and log file
13374 if (mode == CB_CLIPBOARD_TO_BRUSH)
13376 if (edit_mode != ED_MODE_DRAWING)
13379 if (!SDL_HasClipboardText())
13381 Request("Clipboard is empty!", REQ_CONFIRM);
13386 boolean copy_to_brush = (draw_with_brush ||
13387 drawing_function == GADGET_ID_GRAB_BRUSH);
13389 // this will delete the old brush, if already drawing with a brush
13391 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
13393 // initialization is required for "odd" (incomplete) clipboard content
13394 for (x = 0; x < MAX_LEV_FIELDX; x++)
13395 for (y = 0; y < MAX_LEV_FIELDY; y++)
13396 brush_buffer[x][y] = EL_EMPTY;
13403 char *clipboard_text = SDL_GetClipboardText();
13404 char *ptr = clipboard_text;
13405 boolean allow_new_row = FALSE;
13406 boolean stop = FALSE;
13408 while (*ptr && !stop)
13410 boolean prefix_found = FALSE;
13411 boolean start_new_row = FALSE;
13413 // level sketch element number prefixes (may be multi-byte characters)
13414 char *prefix_list[] = { "`", "¸" };
13417 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
13419 char *prefix = prefix_list[i];
13421 // check if string is large enough for prefix
13422 if (strlen(ptr) < strlen(prefix))
13429 // check if string starts with prefix
13430 if (strPrefix(ptr, prefix))
13432 ptr += strlen(prefix);
13434 prefix_found = TRUE;
13440 // check if prefix found and followed by (at least) three digits
13441 if (prefix_found &&
13442 strlen(ptr) >= 3 &&
13443 ptr[0] >= '0' && ptr[0] <= '9' &&
13444 ptr[1] >= '0' && ptr[1] <= '9' &&
13445 ptr[2] >= '0' && ptr[2] <= '9')
13447 int element = ((ptr[0] - '0') * 100 +
13448 (ptr[1] - '0') * 10 +
13453 // level sketch element number might consist of four digits
13454 if (ptr[0] >= '0' && ptr[0] <= '9')
13456 element = element * 10 + (ptr[0] - '0');
13460 // remap some (historic, now obsolete) elements
13461 element = getMappedElement(element);
13463 if (element >= NUM_FILE_ELEMENTS)
13464 element = EL_UNKNOWN;
13466 brush_buffer[x][y] = element;
13468 brush_width = MAX(x + 1, brush_width);
13469 brush_height = MAX(y + 1, brush_height);
13473 if (x >= MAX_LEV_FIELDX)
13474 start_new_row = TRUE;
13476 allow_new_row = TRUE;
13480 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
13481 start_new_row = TRUE;
13483 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
13491 if (y >= MAX_LEV_FIELDY)
13494 allow_new_row = FALSE;
13498 SDL_free(clipboard_text);
13500 if (brush_width == 0 || brush_height == 0)
13502 Request("No level sketch found in clipboard!", REQ_CONFIRM);
13509 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
13512 SDL_GetMouseState(&mx, &my);
13514 // if inside drawing area, activate and draw brush at last mouse position
13515 if (mx >= gi->x && mx < gi->x + gi->width &&
13516 my >= gi->y && my < gi->y + gi->height)
13517 CopyBrushToCursor(last_cursor_x, last_cursor_y);
13519 draw_with_brush = TRUE;
13525 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
13526 brush_width, brush_height);
13528 if (!Request(request, REQ_ASK))
13531 for (x = 0; x < MAX_LEV_FIELDX; x++)
13532 for (y = 0; y < MAX_LEV_FIELDY; y++)
13533 Tile[x][y] = brush_buffer[x][y];
13535 lev_fieldx = level.fieldx = brush_width;
13536 lev_fieldy = level.fieldy = brush_height;
13538 boolean use_bd_engine = TRUE;
13539 boolean use_em_engine = TRUE;
13540 boolean use_sp_engine = TRUE;
13541 boolean use_mm_engine = TRUE;
13543 for (x = 0; x < MAX_LEV_FIELDX; x++)
13545 for (y = 0; y < MAX_LEV_FIELDY; y++)
13547 int element = Tile[x][y];
13549 if (!IS_BD_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13550 use_bd_engine = FALSE;
13552 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13553 use_em_engine = FALSE;
13555 if (!IS_SP_ELEMENT(element))
13556 use_sp_engine = FALSE;
13558 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
13559 use_mm_engine = FALSE;
13563 level.game_engine_type = (use_bd_engine ? GAME_ENGINE_TYPE_BD :
13564 use_em_engine ? GAME_ENGINE_TYPE_EM :
13565 use_sp_engine ? GAME_ENGINE_TYPE_SP :
13566 use_mm_engine ? GAME_ENGINE_TYPE_MM :
13567 GAME_ENGINE_TYPE_RND);
13569 // update element selection list
13570 ReinitializeElementList();
13571 ModifyEditorElementList();
13573 SetBorderElement();
13575 DrawEditModeWindow();
13576 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13582 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
13585 if (mode == CB_AREA_TO_BRUSH)
13587 int from_lx, from_ly;
13590 swap_numbers(&from_x, &to_x);
13593 swap_numbers(&from_y, &to_y);
13595 brush_width = to_x - from_x + 1;
13596 brush_height = to_y - from_y + 1;
13598 from_lx = from_x + level_xpos;
13599 from_ly = from_y + level_ypos;
13601 for (y = 0; y < brush_height; y++)
13603 for (x = 0; x < brush_width; x++)
13605 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
13608 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
13613 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13615 delete_old_brush = FALSE;
13617 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
13618 mode == CB_BRUSH_TO_LEVEL)
13620 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
13621 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
13622 int cursor_from_x = cursor_x - brush_width / 2;
13623 int cursor_from_y = cursor_y - brush_height / 2;
13624 int border_from_x = cursor_x, border_from_y = cursor_y;
13625 int border_to_x = cursor_x, border_to_y = cursor_y;
13627 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
13628 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13630 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
13631 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
13633 delete_old_brush = FALSE;
13638 for (y = 0; y < brush_height; y++)
13640 for (x = 0; x < brush_width; x++)
13642 int sx = cursor_from_x + x;
13643 int sy = cursor_from_y + y;
13644 int lx = sx + level_xpos;
13645 int ly = sy + level_ypos;
13646 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
13647 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
13648 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
13649 brush_buffer[x][y] : new_element);
13651 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13653 if (sx < border_from_x)
13654 border_from_x = sx;
13655 else if (sx > border_to_x)
13657 if (sy < border_from_y)
13658 border_from_y = sy;
13659 else if (sy > border_to_y)
13662 DrawBrushElement(sx, sy, element, change_level);
13667 if (mode != CB_DELETE_OLD_CURSOR)
13668 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
13670 last_cursor_x = cursor_x;
13671 last_cursor_y = cursor_y;
13673 delete_old_brush = TRUE;
13675 else if (mode == CB_FLIP_BRUSH_X)
13677 for (y = 0; y < brush_height; y++)
13678 for (x = 0; x < (brush_width + 1) / 2; x++)
13679 SwapFlippedTiles(&brush_buffer[x][y],
13680 &brush_buffer[brush_width - x - 1][y], mode);
13682 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13684 else if (mode == CB_FLIP_BRUSH_Y)
13686 for (y = 0; y < (brush_height + 1) / 2; y++)
13687 for (x = 0; x < brush_width; x++)
13688 SwapFlippedTiles(&brush_buffer[x][y],
13689 &brush_buffer[x][brush_height - y - 1], mode);
13691 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13693 else if (mode == CB_FLIP_BRUSH_XY)
13695 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13697 for (y = 0; y < MAX(brush_width, brush_height); y++)
13698 for (x = 0; x <= y; x++)
13699 SwapFlippedTiles(&brush_buffer[x][y],
13700 &brush_buffer[y][x], mode);
13702 swap_numbers(&brush_width, &brush_height);
13704 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13707 if (mode == CB_UPDATE_BRUSH_POSITION)
13709 last_cursor_x = from_x;
13710 last_cursor_y = from_y;
13714 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
13717 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
13720 static void CopyBrushToLevel(int x, int y, int button)
13722 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
13725 static void CopyBrushToCursor(int x, int y)
13727 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13730 static void UpdateBrushPosition(int x, int y)
13732 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
13735 static void DeleteBrushFromCursor(void)
13737 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13740 static void FlipBrushX(void)
13742 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13745 static void FlipBrushY(void)
13747 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_Y);
13750 static void RotateBrush(void)
13752 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_XY);
13753 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13756 void DumpBrush(void)
13758 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
13761 void DumpBrush_Small(void)
13763 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
13766 void CopyClipboardToBrush(void)
13768 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
13771 void CopyBrushToClipboard(void)
13773 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
13776 void CopyBrushToClipboard_Small(void)
13778 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
13781 void UndoLevelEditorOperation(void)
13783 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
13786 void RedoLevelEditorOperation(void)
13788 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13791 static void FloodFill(int from_x, int from_y, int fill_element)
13793 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
13796 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
13798 int from_x = from_sx2 + 2 * level_xpos;
13799 int from_y = from_sy2 + 2 * level_ypos;
13800 int max_fillx = lev_fieldx * 2;
13801 int max_filly = lev_fieldy * 2;
13802 short Fill[max_fillx][max_filly];
13805 for (x = 0; x < max_fillx; x++)
13806 for (y = 0; y < max_filly; y++)
13807 Fill[x][y] = getLevelElementHiRes(x, y);
13809 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
13810 Fill, max_fillx, max_filly);
13812 for (x = 0; x < max_fillx; x++)
13813 for (y = 0; y < max_filly; y++)
13814 if (Fill[x][y] == fill_element)
13815 SetLevelElementHiRes(x, y, Fill[x][y]);
13818 // values for DrawLevelText() modes
13819 #define TEXT_INIT 0
13820 #define TEXT_SETCURSOR 1
13821 #define TEXT_WRITECHAR 2
13822 #define TEXT_BACKSPACE 3
13823 #define TEXT_NEWLINE 4
13825 #define TEXT_QUERY_TYPING 6
13827 static int DrawLevelText(int sx, int sy, char letter, int mode)
13829 static short delete_buffer[MAX_LEV_FIELDX];
13830 static int start_sx;
13831 static int last_sx, last_sy;
13832 static boolean typing = FALSE;
13833 int letter_element;
13834 int lx = 0, ly = 0;
13836 // map lower case letters to upper case and convert special characters
13837 if (letter >= 'a' && letter <= 'z')
13838 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
13839 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
13840 letter_element = EL_CHAR_AUMLAUT;
13841 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
13842 letter_element = EL_CHAR_OUMLAUT;
13843 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
13844 letter_element = EL_CHAR_UUMLAUT;
13845 else if (letter == '^')
13846 letter_element = EL_CHAR_COPYRIGHT;
13848 letter_element = EL_CHAR_ASCII0 + letter;
13850 if (mode != TEXT_INIT)
13855 if (mode != TEXT_SETCURSOR)
13861 lx = last_sx + level_xpos;
13862 ly = last_sy + level_ypos;
13869 DrawLevelText(0, 0, 0, TEXT_END);
13875 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
13878 case TEXT_SETCURSOR:
13879 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
13880 DrawAreaBorder(sx, sy, sx, sy);
13881 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
13882 ed_tilesize, ed_tilesize);
13887 case TEXT_WRITECHAR:
13888 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
13890 if (new_element1 >= EL_STEEL_CHAR_START &&
13891 new_element1 <= EL_STEEL_CHAR_END)
13892 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
13894 delete_buffer[sx - start_sx] = Tile[lx][ly];
13895 Tile[lx][ly] = letter_element;
13897 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
13898 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
13899 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13900 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13902 DrawLevelText(0, 0, 0, TEXT_END);
13904 level.changed = TRUE;
13908 case TEXT_BACKSPACE:
13911 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
13912 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
13913 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
13918 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13919 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13921 DrawLevelText(0, 0, 0, TEXT_END);
13925 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13926 DrawEditorElement(sx, sy, Tile[lx][ly]);
13931 case TEXT_QUERY_TYPING:
13941 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
13942 int element, boolean change_level)
13944 int lx = sx + level_xpos;
13945 int ly = sy + level_ypos;
13948 DrawEditorElement(sx, sy, Tile[lx][ly]);
13950 DrawAreaBorder(sx, sy, sx, sy);
13953 static void CheckLevelBorderElement(boolean redraw_playfield)
13955 int last_border_element = BorderElement;
13957 SetBorderElement();
13959 if (redraw_playfield && BorderElement != last_border_element)
13960 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13963 static void CopyLevelToUndoBuffer(int mode)
13965 static boolean accumulated_undo = FALSE;
13966 boolean new_undo_buffer_position = TRUE;
13969 if (undo_buffer_steps == 0)
13970 accumulated_undo = FALSE;
13974 case UNDO_IMMEDIATE:
13975 accumulated_undo = FALSE;
13978 case UNDO_ACCUMULATE:
13979 if (accumulated_undo)
13980 new_undo_buffer_position = FALSE;
13981 accumulated_undo = TRUE;
13988 if (new_undo_buffer_position)
13990 // advance position in undo buffer ring
13991 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13993 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
13994 undo_buffer_steps++;
13997 // always reset redo buffer when storing level change into undo buffer
13998 redo_buffer_steps = 0;
14000 for (x = 0; x < lev_fieldx; x++)
14001 for (y = 0; y < lev_fieldy; y++)
14002 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
14004 // check if drawing operation forces change of border style
14005 CheckLevelBorderElement(TRUE);
14007 level.changed = TRUE;
14010 static void RandomPlacement(int new_element)
14012 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
14013 int num_free_positions = 0;
14014 int num_percentage, num_elements;
14017 ResetIntelliDraw();
14019 // determine number of free positions for randomly placing the new element
14020 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
14022 free_position[x][y] =
14023 (random_placement_background_restricted ?
14024 Tile[x][y] == random_placement_background_element :
14025 Tile[x][y] != new_element);
14027 if (free_position[x][y])
14028 num_free_positions++;
14031 // determine number of new elements to place there
14032 num_percentage = num_free_positions * random_placement_value / 100;
14033 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
14034 num_percentage : random_placement_value);
14036 // if less free positions than elements to place, fill all these positions
14037 if (num_free_positions < num_elements)
14039 for (x = 0; x < lev_fieldx; x++)
14040 for (y = 0; y < lev_fieldy; y++)
14041 if (free_position[x][y])
14042 SetElement(x, y, new_element);
14046 while (num_elements > 0)
14048 x = GetSimpleRandom(lev_fieldx);
14049 y = GetSimpleRandom(lev_fieldy);
14051 // don't place element at the same position twice
14052 if (free_position[x][y])
14054 free_position[x][y] = FALSE;
14055 SetElement(x, y, new_element);
14061 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14062 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14065 static void WrapLevel(int dx, int dy)
14067 int wrap_dx = lev_fieldx - dx;
14068 int wrap_dy = lev_fieldy - dy;
14071 for (x = 0; x < lev_fieldx; x++)
14072 for (y = 0; y < lev_fieldy; y++)
14073 TileBackup[x][y] = Tile[x][y];
14075 for (x = 0; x < lev_fieldx; x++)
14076 for (y = 0; y < lev_fieldy; y++)
14078 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
14080 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14081 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
14084 static void DrawAreaElementHighlight(boolean highlighted,
14085 boolean highlighted_similar)
14087 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14094 for (x = 0; x < ed_fieldx; x++)
14096 for (y = 0; y < ed_fieldy; y++)
14098 boolean highlight = FALSE;
14099 int lx = x + level_xpos;
14100 int ly = y + level_ypos;
14102 if (!IN_LEV_FIELD(lx, ly))
14105 // check if element is the same
14106 if (Tile[lx][ly] == new_element1)
14109 // check if element is similar
14110 if (highlighted_similar &&
14111 strEqual(element_info[Tile[lx][ly]].class_name,
14112 element_info[new_element1].class_name))
14115 // check if element is matching MM style wall
14116 if (IS_MM_WALL(Tile[lx][ly]) &&
14117 map_mm_wall_element(Tile[lx][ly]) == new_element1)
14123 if (IS_MM_WALL(Tile[lx][ly]) && !highlighted_similar)
14127 for (i = 0; i < 4; i++)
14129 if (!(MM_WALL_BITS(Tile[lx][ly]) & (1 << i)))
14132 int xx = x * 2 + (i % 2);
14133 int yy = y * 2 + (i / 2);
14134 int sx = SX + xx * ed_tilesize / 2;
14135 int sy = SY + yy * ed_tilesize / 2;
14138 int to_sx = sx + ed_tilesize / 2 - 1;
14139 int to_sy = sy + ed_tilesize / 2 - 1;
14141 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
14142 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
14143 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14144 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14149 int sx = SX + x * ed_tilesize;
14150 int sy = SY + y * ed_tilesize;
14153 int to_sx = sx + ed_tilesize - 1;
14154 int to_sy = sy + ed_tilesize - 1;
14156 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
14157 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
14158 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
14159 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
14165 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
14167 char *template_filename_old = getLocalLevelTemplateFilename();
14168 char *template_filename_new =
14169 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
14171 if (copyFile(template_filename_old, template_filename_new) != 0)
14172 Request("Cannot copy level template!", REQ_CONFIRM);
14174 free(template_filename_new);
14177 static void HandleDrawingAreas(struct GadgetInfo *gi)
14179 static boolean started_inside_drawing_area = FALSE;
14180 static int last_sx = -1;
14181 static int last_sy = -1;
14182 static int last_sx2 = -1;
14183 static int last_sy2 = -1;
14184 int id = gi->custom_id;
14185 int type_id = gi->custom_type_id;
14186 boolean button_press_event;
14187 boolean button_release_event;
14188 boolean inside_drawing_area = !gi->event.off_borders;
14189 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
14190 int actual_drawing_function;
14191 int button = gi->event.button;
14192 int new_element = BUTTON_ELEMENT(button);
14193 int sx = gi->event.x, sy = gi->event.y;
14194 int min_sx = 0, min_sy = 0;
14195 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
14196 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
14197 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
14198 int sx2 = gi->event.mx / mini_item_xsize;
14199 int sy2 = gi->event.my / mini_item_ysize;
14202 int lx = 0, ly = 0;
14205 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
14206 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
14208 // make sure to stay inside drawing area boundaries
14209 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14210 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14214 int min_lx = 0, min_ly = 0;
14215 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14217 // get positions inside level field
14218 lx = sx + level_xpos;
14219 ly = sy + level_ypos;
14221 if (!IN_LEV_FIELD(lx, ly))
14222 inside_drawing_area = FALSE;
14224 // make sure to stay inside level field boundaries
14225 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14226 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14228 // correct drawing area positions accordingly
14229 sx = lx - level_xpos;
14230 sy = ly - level_ypos;
14233 // also correct MM wall-sized (double) drawing area positions accordingly
14234 if (sx2 / 2 < sx || sx2 / 2 > sx)
14236 dx = (sx2 / 2 < sx ? 0 : 1);
14239 if (sy2 / 2 < sy || sy2 / 2 > sy)
14241 dy = (sy2 / 2 < sy ? 0 : 1);
14245 if (!button_press_event && !button_release_event)
14247 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
14248 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
14249 isHiresTileElement(old_element) &&
14250 isHiresDrawElement(new_element));
14252 // prevent handling events for every pixel position when moving mouse
14253 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
14254 (sx2 == last_sx2 && sy2 == last_sy2))
14263 if (button_press_event)
14264 started_inside_drawing_area = inside_drawing_area;
14266 if (!started_inside_drawing_area)
14269 if (!IS_VALID_BUTTON(button))
14272 // handle info callback for each invocation of action callback
14273 gi->callback_info(gi);
14275 // automatically switch to 'single item' drawing mode, if needed
14276 actual_drawing_function =
14277 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
14278 drawing_function : GADGET_ID_SINGLE_ITEMS);
14280 // clicking into drawing area with pressed Control key picks element
14281 if (GetKeyModState() & KMOD_Control)
14283 last_drawing_function = drawing_function;
14284 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14287 if (GetKeyModState() & KMOD_Shift)
14289 if (button_press_event || button_release_event)
14290 ResetIntelliDraw();
14293 SetDrawModeHiRes(-1); // reset to normal draw mode
14295 switch (actual_drawing_function)
14297 case GADGET_ID_SINGLE_ITEMS:
14300 if (button_release_event)
14302 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14304 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
14305 !inside_drawing_area)
14306 DeleteBrushFromCursor();
14311 if (draw_with_brush)
14313 CopyBrushToLevel(sx, sy, button);
14317 SetDrawModeHiRes(new_element);
14319 if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
14321 // remove player at old position
14322 for (y = 0; y < lev_fieldy; y++)
14324 for (x = 0; x < lev_fieldx; x++)
14326 int old_element = Tile[x][y];
14328 if (IS_PLAYER_ELEMENT(old_element) &&
14329 IS_PLAYER_ELEMENT(new_element))
14331 int replaced_with_element =
14332 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
14333 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
14335 old_element == EL_SOKOBAN_FIELD_PLAYER &&
14336 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
14338 new_element == EL_SOKOBAN_FIELD_PLAYER &&
14339 old_element == EL_PLAYER_1 ? EL_EMPTY :
14341 new_element >= EL_PLAYER_1 &&
14342 new_element <= EL_PLAYER_4 &&
14343 new_element == old_element ? EL_EMPTY :
14347 SetElement(x, y, replaced_with_element);
14349 else if (IS_MM_MCDUFFIN(old_element) &&
14350 IS_MM_MCDUFFIN(new_element))
14352 // remove McDuffin at old position
14353 SetElement(x, y, EL_EMPTY);
14359 SetElementButton(lx, ly, dx, dy, new_element, button);
14362 else if (!button_release_event)
14364 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14366 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
14367 DrawMiniGraphicExt(drawto,
14368 gi->x + sx * MINI_TILEX,
14369 gi->y + sy * MINI_TILEY,
14370 el2edimg(new_element));
14372 DrawFixedGraphicExt(drawto,
14373 gi->x + sx * TILEX,
14374 gi->y + sy * TILEY,
14375 el2edimg(new_element), 0);
14377 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14378 new_element = GFX_ELEMENT(new_element);
14380 drawingarea_info[type_id].value[pos] = new_element;
14382 CopyElementPropertiesToGame(properties_element);
14384 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14386 UpdateCustomElementGraphicGadgets();
14388 FrameCounter = 0; // restart animation frame counter
14393 case GADGET_ID_CONNECTED_ITEMS:
14395 static int last_sx = -1;
14396 static int last_sy = -1;
14398 if (button_release_event)
14399 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14401 SetDrawModeHiRes(new_element);
14403 if (getDrawModeHiRes())
14409 if (!button_press_event)
14410 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
14417 case GADGET_ID_LINE:
14418 case GADGET_ID_ARC:
14419 case GADGET_ID_RECTANGLE:
14420 case GADGET_ID_FILLED_BOX:
14421 SetDrawModeHiRes(new_element);
14423 if (getDrawModeHiRes())
14429 case GADGET_ID_GRAB_BRUSH:
14430 case GADGET_ID_TEXT:
14432 static int last_sx = -1;
14433 static int last_sy = -1;
14434 static int start_sx = -1;
14435 static int start_sy = -1;
14436 void (*draw_func)(int, int, int, int, int, boolean);
14438 if (drawing_function == GADGET_ID_LINE)
14439 draw_func = DrawLine;
14440 else if (drawing_function == GADGET_ID_ARC)
14441 draw_func = DrawArc;
14442 else if (drawing_function == GADGET_ID_RECTANGLE)
14443 draw_func = DrawBox;
14444 else if (drawing_function == GADGET_ID_FILLED_BOX)
14445 draw_func = DrawFilledBox;
14446 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
14447 draw_func = SelectArea;
14448 else // (drawing_function == GADGET_ID_TEXT)
14449 draw_func = SetTextCursor;
14451 if (button_press_event)
14453 draw_func(sx, sy, sx, sy, new_element, FALSE);
14454 start_sx = last_sx = sx;
14455 start_sy = last_sy = sy;
14457 if (drawing_function == GADGET_ID_TEXT)
14458 DrawLevelText(0, 0, 0, TEXT_END);
14460 else if (button_release_event)
14462 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
14463 if (drawing_function == GADGET_ID_GRAB_BRUSH)
14465 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
14466 CopyBrushToCursor(sx, sy);
14467 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14469 draw_with_brush = TRUE;
14471 else if (drawing_function == GADGET_ID_TEXT)
14472 DrawLevelText(sx, sy, 0, TEXT_INIT);
14474 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14476 else if (last_sx != sx || last_sy != sy)
14478 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
14479 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
14480 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
14481 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
14488 case GADGET_ID_FLOOD_FILL:
14489 if (button_press_event && Tile[lx][ly] != new_element)
14491 if (IS_MM_WALL_EDITOR(new_element))
14492 FloodFillWall_MM(sx2, sy2, new_element);
14494 FloodFill(lx, ly, new_element);
14496 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14497 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14501 case GADGET_ID_PICK_ELEMENT:
14502 if (button_release_event)
14503 ClickOnGadget(level_editor_gadget[last_drawing_function],
14505 else if (draw_level)
14506 PickDrawingElement(button, Tile[lx][ly]);
14509 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14511 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
14518 // do not mark level as modified for certain non-level-changing gadgets
14519 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
14520 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
14521 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
14522 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14525 level.changed = TRUE;
14528 static void HandleCounterButtons(struct GadgetInfo *gi)
14530 int gadget_id = gi->custom_id;
14531 int counter_id = gi->custom_type_id;
14532 int button = gi->event.button;
14533 int *counter_value = counterbutton_info[counter_id].value;
14534 int step = BUTTON_STEPSIZE(button) *
14535 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
14537 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14539 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
14540 boolean released = (gi->event.type == GD_EVENT_RELEASED);
14541 boolean level_changed = LevelChanged();
14543 if ((level_changed && pressed) || (!level_changed && released))
14546 if (level_changed && !Request("Level has changed! Discard changes?",
14549 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14550 ModifyEditorCounterValue(counter_id, *counter_value);
14556 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14557 *counter_value = gi->textinput.number_value;
14559 ModifyEditorCounterValue(counter_id, *counter_value + step);
14561 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14563 int last_game_engine_type = level.game_engine_type;
14565 LoadLevel(level_nr);
14566 LoadScore(level_nr);
14568 SaveLevelSetup_SeriesInfo();
14573 DrawEditModeWindow();
14575 if (level.game_engine_type != last_game_engine_type)
14577 // update element selection list
14578 ReinitializeElementList();
14579 ModifyEditorElementList();
14585 switch (counter_id)
14587 case ED_COUNTER_ID_YAMYAM_CONTENT:
14588 DrawYamYamContentAreas();
14591 case ED_COUNTER_ID_BALL_CONTENT:
14592 DrawMagicBallContentAreas();
14595 case ED_COUNTER_ID_ANDROID_CONTENT:
14596 DrawAndroidElementArea();
14599 case ED_COUNTER_ID_GROUP_CONTENT:
14600 DrawGroupElementArea();
14601 CopyGroupElementPropertiesToGame(properties_element);
14604 case ED_COUNTER_ID_INVENTORY_SIZE:
14605 DrawPlayerInitialInventoryArea(properties_element);
14608 case ED_COUNTER_ID_MM_BALL_CONTENT:
14609 DrawMMBallContentArea();
14612 case ED_COUNTER_ID_ENVELOPE_XSIZE:
14613 case ED_COUNTER_ID_ENVELOPE_YSIZE:
14614 DrawEnvelopeTextArea(-1);
14617 case ED_COUNTER_ID_LEVEL_XSIZE:
14618 case ED_COUNTER_ID_LEVEL_YSIZE:
14619 lev_fieldx = level.fieldx;
14620 lev_fieldy = level.fieldy;
14622 // check if resizing of level results in change of border border
14623 SetBorderElement();
14631 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
14632 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
14633 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
14634 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
14635 CopyElementPropertiesToGame(properties_element);
14637 // do not mark level as modified for certain non-level-changing gadgets
14638 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
14639 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
14640 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
14641 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
14644 level.changed = TRUE;
14647 static void HandleTextInputGadgets(struct GadgetInfo *gi)
14649 int type_id = gi->custom_type_id;
14651 strcpy(textinput_info[type_id].value, gi->textinput.value);
14653 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
14655 CopyElementPropertiesToGame(properties_element);
14657 ModifyEditorElementList(); // update changed button info text
14660 // do not mark level as modified for certain non-level-changing gadgets
14661 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
14662 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
14665 level.changed = TRUE;
14668 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
14670 int type_id = gi->custom_type_id;
14672 strncpy(textarea_info[type_id].value, gi->textarea.value,
14673 MAX_ENVELOPE_TEXT_LEN);
14674 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
14676 level.changed = TRUE;
14679 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
14681 int type_id = gi->custom_type_id;
14682 int value_old = *selectbox_info[type_id].value;
14683 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
14685 *selectbox_info[type_id].value = value_new;
14687 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
14689 DrawLevelConfigWindow();
14691 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14693 element_info[properties_element].current_change_page = gi->selectbox.index;
14695 DrawPropertiesWindow();
14697 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
14698 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
14699 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
14700 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
14701 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
14703 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
14705 // when changing action type, also check action mode and action arg
14706 if (value_old != value_new)
14707 setSelectboxSpecialActionVariablesIfNeeded();
14709 DrawPropertiesChange();
14712 CopyElementPropertiesToGame(properties_element);
14714 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
14716 // show or hide "engine" tabulator depending on game engine type
14717 DrawLevelConfigWindow();
14719 // update element selection list depending on game engine type
14720 ReinitializeElementList();
14721 ModifyEditorElementList();
14723 else if (type_id == ED_SELECTBOX_ID_BD_SCHEDULING_TYPE)
14725 // update BD cycle delay counter gadgets depending on BD scheduling type
14726 DrawLevelConfigWindow();
14729 // do not mark level as modified for certain non-level-changing gadgets
14730 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
14731 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14734 level.changed = TRUE;
14737 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
14739 int type_id = gi->custom_type_id;
14742 if (type_id >= ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST &&
14743 type_id <= ED_TAB_BUTTON_ID_LEVELCONFIG_LAST)
14745 edit_mode_levelconfig = gi->custom_type_id;
14747 DrawLevelConfigWindow();
14749 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
14750 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
14752 edit_mode_properties = gi->custom_type_id;
14754 DrawPropertiesWindow();
14756 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
14757 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
14759 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
14761 // backup original "level.field" (needed to track playfield changes)
14762 CopyPlayfield(level.field, TileBackup);
14764 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
14765 CopyPlayfield(Tile, level.field);
14767 if (new_template ||
14768 Request("Save this template and kill the old?", REQ_ASK))
14769 SaveLevelTemplate();
14772 Request("Template saved!", REQ_CONFIRM);
14774 // restore original "level.field" (needed to track playfield changes)
14775 CopyPlayfield(TileBackup, level.field);
14777 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
14779 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
14781 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
14782 leveldir_current->readonly)
14784 Request("This level set is read-only!", REQ_CONFIRM);
14789 if (strEqual(levelset_name, ""))
14791 Request("Please enter level set title!", REQ_CONFIRM);
14796 if (strEqual(levelset_author, ""))
14798 Request("Please enter level set author!", REQ_CONFIRM);
14803 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
14805 if (UpdateUserLevelSet(levelset_subdir,
14808 levelset_num_levels))
14810 Request("Level set updated!", REQ_CONFIRM);
14814 Request("Updating level set failed!", REQ_CONFIRM);
14817 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
14819 if (level.changed && !Request("Level has changed! Discard changes?",
14823 if (CreateUserLevelSet(levelset_subdir,
14826 levelset_num_levels,
14827 levelset_use_levelset_artwork))
14829 if (levelset_copy_level_template)
14830 CopyLevelTemplateToUserLevelSet(levelset_subdir);
14832 Request("New level set created!", REQ_CONFIRM);
14834 AddUserLevelSetToLevelInfo(levelset_subdir);
14835 ChangeEditorToLevelSet(levelset_subdir);
14839 Request("Creating new level set failed!", REQ_CONFIRM);
14843 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
14844 custom_element.num_change_pages < MAX_CHANGE_PAGES)
14846 struct ElementInfo *ei = &element_info[properties_element];
14848 // when modifying custom element, ask for copying level template
14849 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14852 setElementChangePages(ei, ei->num_change_pages + 1);
14854 // set new change page to be new current change page
14855 ei->current_change_page = ei->num_change_pages - 1;
14856 ei->change = &ei->change_page[ei->current_change_page];
14858 setElementChangeInfoToDefaults(ei->change);
14860 DrawPropertiesWindow();
14862 level.changed = TRUE;
14864 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
14865 custom_element.num_change_pages > MIN_CHANGE_PAGES)
14867 struct ElementInfo *ei = &element_info[properties_element];
14869 // when modifying custom element, ask for copying level template
14870 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14873 // copy all change pages after change page to be deleted
14874 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
14875 ei->change_page[i] = ei->change_page[i + 1];
14877 setElementChangePages(ei, ei->num_change_pages - 1);
14879 DrawPropertiesWindow();
14881 level.changed = TRUE;
14885 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
14887 int type_id = gi->custom_type_id;
14889 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
14890 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
14892 struct ElementInfo *ei = &element_info[properties_element];
14893 int step = BUTTON_STEPSIZE(gi->event.button);
14895 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
14896 ei->current_change_page += step;
14898 if (ei->current_change_page < 0)
14899 ei->current_change_page = 0;
14900 else if (ei->current_change_page >= ei->num_change_pages)
14901 ei->current_change_page = ei->num_change_pages - 1;
14903 DrawPropertiesWindow();
14905 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
14906 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14908 struct ElementInfo *ei = &element_info[properties_element];
14909 int current_change_page = ei->current_change_page;
14911 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
14913 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
14914 ei->change_page[current_change_page];
14916 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14918 // when modifying custom element, ask for copying level template
14919 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14922 ei->change_page[current_change_page] =
14923 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
14925 level.changed = TRUE;
14928 DrawPropertiesWindow();
14932 static void HandleRadiobuttons(struct GadgetInfo *gi)
14934 int type_id = gi->custom_type_id;
14936 *radiobutton_info[type_id].value =
14937 radiobutton_info[type_id].checked_value;
14939 // do not mark level as modified for certain non-level-changing gadgets
14940 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
14941 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
14944 level.changed = TRUE;
14947 static void HandleCheckbuttons(struct GadgetInfo *gi)
14949 int type_id = gi->custom_type_id;
14951 *checkbutton_info[type_id].value ^= TRUE;
14953 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
14954 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
14955 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
14956 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
14957 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
14958 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
14959 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
14960 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
14962 CopyElementPropertiesToGame(properties_element);
14965 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
14967 UpdateCustomElementGraphicGadgets();
14969 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
14970 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
14972 boolean template_related_changes_found = FALSE;
14975 // check if any custom, group or empty elements have been changed
14976 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
14977 if ((IS_CUSTOM_ELEMENT(i) ||
14978 IS_GROUP_ELEMENT(i) ||
14979 IS_EMPTY_ELEMENT(i)) &&
14980 element_info[i].modified_settings)
14981 template_related_changes_found = TRUE;
14983 if (level.use_custom_template &&
14984 !fileExists(getGlobalLevelTemplateFilename()))
14986 Request("No level template found!", REQ_CONFIRM);
14988 level.use_custom_template = FALSE;
14990 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14995 if (level.use_custom_template &&
14996 template_related_changes_found &&
14997 !Request("Discard changes and use level template?", REQ_ASK))
14999 level.use_custom_template = FALSE;
15001 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
15006 if (!level.use_custom_template &&
15007 Request("Copy settings from level template?", REQ_ASK))
15012 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
15014 DrawEditModeWindow();
15016 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
15018 if (setup.editor.use_template_for_new_levels &&
15019 !fileExists(getGlobalLevelTemplateFilename()))
15021 Request("No level template found!", REQ_CONFIRM);
15026 if (setup.editor.use_template_for_new_levels &&
15028 !Request("Discard level and load template?", REQ_ASK))
15033 if (!setup.editor.use_template_for_new_levels &&
15035 !Request("Discard level and use empty level?", REQ_ASK))
15040 LoadLevel(level_nr);
15041 LoadScore(level_nr);
15046 DrawEditModeWindow();
15048 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
15050 SetAutomaticNumberOfGemsNeeded();
15053 // do not mark level as modified for certain non-level-changing gadgets
15054 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
15055 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
15056 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
15057 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
15058 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
15059 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
15062 level.changed = TRUE;
15065 static void HandleControlButtons(struct GadgetInfo *gi)
15067 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
15068 static int last_edit_mode = ED_MODE_DRAWING;
15069 static int last_custom_copy_mode = -1;
15070 static int last_button = 0;
15071 int id = gi->custom_id;
15072 int button = gi->event.button;
15073 int step = BUTTON_STEPSIZE(button);
15074 int new_element = BUTTON_ELEMENT(button);
15075 int last_properties_element = properties_element;
15078 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
15079 DrawLevelText(0, 0, 0, TEXT_END);
15081 if (id < ED_NUM_CTRL1_BUTTONS &&
15082 id != GADGET_ID_SINGLE_ITEMS &&
15083 id != GADGET_ID_PICK_ELEMENT &&
15084 edit_mode != ED_MODE_DRAWING &&
15085 drawing_function != GADGET_ID_PICK_ELEMENT &&
15086 !(GetKeyModState() & KMOD_Control))
15087 ChangeEditModeWindow(ED_MODE_DRAWING);
15089 // element copy mode active, but no element button pressed => deactivate
15090 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
15091 last_custom_copy_mode = -1;
15093 // when showing palette on element buttons, change element of button used
15094 if (editor.palette.show_on_element_buttons &&
15095 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
15097 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
15099 id = GADGET_ID_PALETTE;
15104 case GADGET_ID_SCROLL_LEFT:
15105 if (level_xpos >= 0)
15107 if (lev_fieldx < ed_fieldx - 2)
15110 level_xpos -= step;
15111 if (level_xpos < -1)
15114 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
15116 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15118 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
15119 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
15123 case GADGET_ID_SCROLL_RIGHT:
15124 if (level_xpos <= lev_fieldx - ed_fieldx)
15126 if (lev_fieldx < ed_fieldx - 2)
15129 level_xpos += step;
15130 if (level_xpos > lev_fieldx - ed_fieldx + 1)
15131 level_xpos = lev_fieldx - ed_fieldx + 1;
15133 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
15135 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15137 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
15138 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
15142 case GADGET_ID_SCROLL_UP:
15143 if (level_ypos >= 0)
15145 if (lev_fieldy < ed_fieldy - 2)
15148 level_ypos -= step;
15149 if (level_ypos < -1)
15152 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
15154 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15156 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15157 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15161 case GADGET_ID_SCROLL_DOWN:
15162 if (level_ypos <= lev_fieldy - ed_fieldy)
15164 if (lev_fieldy < ed_fieldy - 2)
15167 level_ypos += step;
15168 if (level_ypos > lev_fieldy - ed_fieldy + 1)
15169 level_ypos = lev_fieldy - ed_fieldy + 1;
15171 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
15173 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15175 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
15176 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
15180 case GADGET_ID_SCROLL_HORIZONTAL:
15181 level_xpos = gi->event.item_position - 1;
15183 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15188 case GADGET_ID_SCROLL_VERTICAL:
15189 level_ypos = gi->event.item_position - 1;
15191 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15196 case GADGET_ID_SCROLL_LIST_UP:
15197 case GADGET_ID_SCROLL_LIST_DOWN:
15198 case GADGET_ID_SCROLL_LIST_VERTICAL:
15199 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
15200 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
15203 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
15204 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15206 if (element_shift < 0)
15208 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15209 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15211 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15212 GDI_SCROLLBAR_ITEM_POSITION,
15213 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15216 ModifyEditorElementList();
15220 case GADGET_ID_PROPERTIES:
15221 // always switch off element properties when they are already displayed
15222 last_properties_element = new_element;
15223 case GADGET_ID_ELEMENT_LEFT:
15224 case GADGET_ID_ELEMENT_MIDDLE:
15225 case GADGET_ID_ELEMENT_RIGHT:
15226 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
15227 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
15228 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
15231 if (edit_mode != ED_MODE_PROPERTIES)
15233 last_edit_mode = edit_mode;
15235 ChangeEditModeWindow(ED_MODE_PROPERTIES);
15237 last_level_drawing_function = drawing_function;
15238 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
15241 else if (properties_element != last_properties_element)
15243 DrawEditModeWindow();
15247 ChangeEditModeWindow(ED_MODE_DRAWING);
15249 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
15254 case GADGET_ID_PALETTE:
15255 if (edit_mode != ED_MODE_PALETTE)
15257 last_edit_mode = edit_mode;
15259 ChangeEditModeWindow(ED_MODE_PALETTE);
15263 ChangeEditModeWindow(last_edit_mode);
15267 case GADGET_ID_WRAP_LEFT:
15268 WrapLevel(-step, 0);
15271 case GADGET_ID_WRAP_RIGHT:
15272 WrapLevel(step, 0);
15275 case GADGET_ID_WRAP_UP:
15276 WrapLevel(0, -step);
15279 case GADGET_ID_WRAP_DOWN:
15280 WrapLevel(0, step);
15283 case GADGET_ID_SINGLE_ITEMS:
15284 case GADGET_ID_CONNECTED_ITEMS:
15285 case GADGET_ID_LINE:
15286 case GADGET_ID_ARC:
15287 case GADGET_ID_TEXT:
15288 case GADGET_ID_RECTANGLE:
15289 case GADGET_ID_FILLED_BOX:
15290 case GADGET_ID_FLOOD_FILL:
15291 case GADGET_ID_GRAB_BRUSH:
15292 case GADGET_ID_PICK_ELEMENT:
15293 if (drawing_function != GADGET_ID_PICK_ELEMENT)
15294 last_drawing_function = drawing_function;
15295 drawing_function = id;
15296 draw_with_brush = FALSE;
15299 case GADGET_ID_RANDOM_PLACEMENT:
15300 RandomPlacement(new_element);
15303 case GADGET_ID_ZOOM:
15304 // zoom level editor tile size in or out (or reset to default size)
15305 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
15306 button == 2 ? ed_tilesize_default :
15307 button == 3 ? ed_tilesize / 2 : ed_tilesize);
15309 // when using touch device, cycle through all zoom tilesizes
15310 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
15311 ed_tilesize = MICRO_TILESIZE;
15313 // limit zoom level by upper and lower bound
15314 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
15316 InitZoomLevelSettings(ed_tilesize);
15318 if (edit_mode == ED_MODE_DRAWING)
15320 DrawDrawingWindow();
15322 // redraw zoom gadget info text
15323 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15326 // save current editor zoom tilesize
15327 SaveSetup_AutoSetup();
15331 case GADGET_ID_CUSTOM_COPY_FROM:
15332 case GADGET_ID_CUSTOM_COPY_TO:
15333 case GADGET_ID_CUSTOM_EXCHANGE:
15334 last_custom_copy_mode = id;
15335 last_drawing_function = drawing_function;
15338 case GADGET_ID_CUSTOM_COPY:
15339 CopyCustomElement(properties_element, -1, id);
15342 case GADGET_ID_CUSTOM_PASTE:
15343 CopyCustomElement(-1, properties_element, id);
15346 case GADGET_ID_UNDO:
15347 if (button < 0) // keep button value (even if modifier keys are pressed)
15349 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
15352 if (button == 1 && undo_buffer_steps == 0)
15354 Request("Undo buffer empty!", REQ_CONFIRM);
15358 else if (button == 2)
15362 else if (button == 3 && redo_buffer_steps == 0)
15364 Request("Redo buffer empty!", REQ_CONFIRM);
15369 if (edit_mode != ED_MODE_DRAWING)
15370 ChangeEditModeWindow(ED_MODE_DRAWING);
15376 undo_buffer_position =
15377 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
15379 undo_buffer_steps--;
15380 redo_buffer_steps++;
15386 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
15388 undo_buffer_steps++;
15389 redo_buffer_steps--;
15392 for (x = 0; x < lev_fieldx; x++)
15393 for (y = 0; y < lev_fieldy; y++)
15394 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
15396 // check if undo operation forces change of border style
15397 CheckLevelBorderElement(FALSE);
15399 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15403 case GADGET_ID_CONF:
15404 if (edit_mode != ED_MODE_LEVELCONFIG)
15406 last_edit_mode = edit_mode;
15408 ChangeEditModeWindow(ED_MODE_LEVELCONFIG);
15412 ChangeEditModeWindow(ED_MODE_DRAWING);
15416 case GADGET_ID_CLEAR:
15417 if (edit_mode != ED_MODE_DRAWING)
15418 ChangeEditModeWindow(ED_MODE_DRAWING);
15420 for (x = 0; x < MAX_LEV_FIELDX; x++)
15421 for (y = 0; y < MAX_LEV_FIELDY; y++)
15422 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
15424 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
15426 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15429 case GADGET_ID_SAVE:
15431 // saving read-only levels into personal level set modifies global vars
15432 // "leveldir_current" and "level_nr"; restore them after saving level
15433 LevelDirTree *leveldir_former = leveldir_current;
15434 int level_nr_former = level_nr;
15435 char *level_filename;
15438 if (leveldir_current->readonly &&
15439 !PrepareSavingIntoPersonalLevelSet())
15442 level_filename = getDefaultLevelFilename(level_nr);
15443 new_level = !fileExists(level_filename);
15446 Request("Save this level and kill the old?", REQ_ASK))
15448 if (leveldir_former->readonly)
15449 ModifyLevelConfigForSavingIntoPersonalLevelSet(leveldir_former->name);
15451 SetAutomaticNumberOfGemsNeeded();
15453 CopyPlayfield(Tile, level.field);
15454 SaveLevel(level_nr);
15456 level.changed = FALSE;
15460 char level_saved_msg[64];
15462 if (leveldir_former->readonly)
15463 sprintf(level_saved_msg,
15464 "Level saved as level %d into personal level set!",
15467 strcpy(level_saved_msg, "Level saved!");
15469 Request(level_saved_msg, REQ_CONFIRM);
15473 // "cd" back to copied-from levelset (in case of saved read-only level)
15474 leveldir_current = leveldir_former;
15475 level_nr = level_nr_former;
15480 case GADGET_ID_TEST:
15481 if (LevelChanged())
15482 level.game_version = GAME_VERSION_ACTUAL;
15484 CopyPlayfield(level.field, TileBackup);
15485 CopyPlayfield(Tile, level.field);
15487 CopyNativeLevel_RND_to_Native(&level);
15489 UnmapLevelEditorGadgets();
15490 UndrawSpecialEditorDoor();
15492 CloseDoor(DOOR_CLOSE_ALL);
15494 // needed before playing if editor playfield area has different size
15495 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
15497 // redraw_mask = REDRAW_ALL;
15499 level_editor_test_game = TRUE;
15501 StartGameActions(FALSE, setup.autorecord, level.random_seed);
15505 case GADGET_ID_EXIT:
15506 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
15510 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
15511 id <= GADGET_ID_ELEMENTLIST_LAST)
15513 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
15515 new_element = editor_elements[element_position + element_shift];
15517 if (IS_EDITOR_CASCADE(new_element))
15521 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
15523 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
15524 boolean *cascade_value = editor_elements_info[i].setup_cascade_value;
15526 if (*cascade_element == new_element)
15528 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
15529 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
15531 // update element selection list
15532 ReinitializeElementList();
15533 ModifyEditorElementList();
15535 // update cascading gadget info text
15536 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15538 // save current editor cascading state
15539 SaveSetup_EditorCascade();
15548 if (last_custom_copy_mode != -1)
15550 if (CopyCustomElement(properties_element, new_element,
15551 last_custom_copy_mode))
15553 ClickOnGadget(level_editor_gadget[last_drawing_function],
15556 last_custom_copy_mode = -1;
15562 // change element of button used to show palette
15563 if (editor.palette.show_on_element_buttons)
15564 button = last_button;
15566 PickDrawingElement(button, new_element);
15568 if (!stick_element_properties_window &&
15569 drawing_function != GADGET_ID_PICK_ELEMENT &&
15570 !(GetKeyModState() & KMOD_Control))
15572 properties_element = new_element;
15573 if (edit_mode == ED_MODE_PROPERTIES)
15574 DrawPropertiesWindow();
15577 if (drawing_function == GADGET_ID_PICK_ELEMENT)
15578 ClickOnGadget(level_editor_gadget[last_drawing_function],
15581 if (!use_permanent_palette)
15582 ChangeEditModeWindow(last_edit_mode);
15585 else if (gi->event.type == GD_EVENT_PRESSED)
15586 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
15587 else if (gi->event.type == GD_EVENT_RELEASED)
15588 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
15589 else if (gi->event.type == GD_EVENT_MOVING)
15590 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
15592 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
15598 void HandleLevelEditorKeyInput(Key key)
15600 char letter = getCharFromKey(key);
15602 if (drawing_function == GADGET_ID_TEXT &&
15603 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
15606 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
15607 else if (key == KSYM_Delete || key == KSYM_BackSpace)
15608 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
15609 else if (key == KSYM_Return)
15610 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
15611 else if (key == KSYM_Escape)
15612 DrawLevelText(0, 0, 0, TEXT_END);
15617 int id = GADGET_ID_NONE;
15618 int new_element_shift = element_shift;
15619 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
15620 int button = MB_LEFTBUTTON;
15626 id = GADGET_ID_SCROLL_LEFT;
15629 id = GADGET_ID_SCROLL_RIGHT;
15632 id = GADGET_ID_SCROLL_UP;
15635 id = GADGET_ID_SCROLL_DOWN;
15639 case KSYM_Page_Down:
15640 step *= (key == KSYM_Page_Up ? -1 : +1);
15641 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15643 if (element_shift < 0)
15645 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15646 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15648 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15649 GDI_SCROLLBAR_ITEM_POSITION,
15650 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15652 ModifyEditorElementList();
15658 element_shift = (key == KSYM_Home ? 0 :
15659 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
15661 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15662 GDI_SCROLLBAR_ITEM_POSITION,
15663 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15665 ModifyEditorElementList();
15672 // this is needed to prevent interference with running "True X-Mouse"
15673 if (GetKeyModStateFromEvents() & KMOD_Control)
15676 // check for last or next editor cascade block in element list
15677 for (i = 0; i < num_editor_elements; i++)
15679 if ((key == KSYM_Insert && i == element_shift) ||
15680 (key == KSYM_Delete && new_element_shift > element_shift))
15683 // jump to next cascade block (or to start of element list)
15684 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
15685 new_element_shift = i;
15688 if (i < num_editor_elements)
15689 element_shift = new_element_shift;
15691 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15692 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15694 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15695 GDI_SCROLLBAR_ITEM_POSITION,
15696 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15698 ModifyEditorElementList();
15703 if (edit_mode == ED_MODE_DRAWING)
15704 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
15705 else if (edit_mode == ED_MODE_LEVELCONFIG)
15706 HandleControlButtons(level_editor_gadget[GADGET_ID_CONF]);
15707 else if (edit_mode == ED_MODE_PROPERTIES)
15708 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
15709 else if (edit_mode == ED_MODE_PALETTE)
15710 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
15711 else // should never happen
15712 ChangeEditModeWindow(ED_MODE_DRAWING);
15720 if (id != GADGET_ID_NONE)
15721 ClickOnGadget(level_editor_gadget[id], button);
15722 else if (letter == '1' || letter == '?')
15723 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
15724 else if (letter == '2')
15725 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
15726 else if (letter == '3')
15727 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
15728 else if (letter == '.')
15729 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
15730 else if (letter == 'U')
15731 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
15732 else if (letter == '-' || key == KSYM_KP_Subtract)
15733 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
15734 else if (letter == '0' || key == KSYM_KP_0)
15735 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
15736 else if (letter == '+' || key == KSYM_KP_Add ||
15737 letter == '=') // ("Shift-=" is "+" on US keyboards)
15738 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
15739 else if (key == KSYM_Return ||
15740 key == KSYM_space ||
15741 key == setup.shortcut.toggle_pause)
15742 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
15744 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
15745 if (letter && letter == controlbutton_info[i].shortcut)
15746 if (!anyTextGadgetActive())
15747 ClickOnGadget(level_editor_gadget[i], button);
15749 if (draw_with_brush)
15753 else if (letter == 'y')
15755 else if (letter == 'z')
15760 static void HandleLevelEditorIdle_Properties(void)
15762 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
15763 int x = editor.settings.element_graphic.x + element_border;
15764 int y = editor.settings.element_graphic.y + element_border;
15765 static DelayCounter action_delay = { 0 };
15768 action_delay.value = GameFrameDelay;
15770 if (!DelayReached(&action_delay))
15773 for (i = 0; i < ED_NUM_SELECTBOX; i++)
15775 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
15777 if (gi->mapped && gi->active && gi->selectbox.open)
15781 DrawEditorElementAnimation(SX + x, SY + y);
15783 redraw_mask |= REDRAW_FIELD;
15785 FrameCounter++; // increase animation frame counter
15788 static void HandleLevelEditorIdle_Drawing(void)
15790 static boolean last_highlighted = FALSE;
15791 static boolean last_highlighted_similar = FALSE;
15792 boolean highlighted = (GetKeyModState() & KMOD_Alt);
15793 boolean highlighted_similar = (GetKeyModState() & KMOD_Shift);
15795 if (highlighted != last_highlighted ||
15796 (highlighted && highlighted_similar != last_highlighted_similar))
15798 DrawAreaElementHighlight(highlighted, highlighted_similar);
15800 redraw_mask |= REDRAW_FIELD;
15803 last_highlighted = highlighted;
15804 last_highlighted_similar = highlighted_similar;
15807 void HandleLevelEditorIdle(void)
15809 if (edit_mode == ED_MODE_PROPERTIES)
15810 HandleLevelEditorIdle_Properties();
15811 else if (edit_mode == ED_MODE_DRAWING)
15812 HandleLevelEditorIdle_Drawing();
15815 static void ClearEditorGadgetInfoText(void)
15817 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
15820 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
15822 char infotext[MAX_OUTPUT_LINESIZE + 1];
15823 int max_infotext_len = getMaxInfoTextLength();
15825 if (gi == NULL || strlen(gi->info_text) == 0)
15828 strncpy(infotext, gi->info_text, max_infotext_len);
15829 infotext[max_infotext_len] = '\0';
15831 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
15833 int key = controlbutton_info[gi->custom_id].shortcut;
15837 char shortcut[MAX_OUTPUT_LINESIZE + 1];
15839 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
15840 sprintf(shortcut, " ('.' or '%c')", key);
15841 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
15842 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
15843 else if (gi->custom_id == GADGET_ID_TEST)
15844 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
15845 else if (gi->custom_id == GADGET_ID_UNDO)
15846 sprintf(shortcut, " ('%c/Shift-U')", key);
15847 else if (gi->custom_id == GADGET_ID_ZOOM)
15848 sprintf(shortcut, " ('%c', '0', '-')", key);
15850 sprintf(shortcut, " ('%s%c')",
15851 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
15853 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
15854 strcat(infotext, shortcut);
15858 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
15861 void HandleEditorGadgetInfoText(void *ptr)
15863 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
15865 if (game_status != GAME_MODE_EDITOR)
15868 ClearEditorGadgetInfoText();
15870 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
15873 // misuse this function to delete brush cursor, if needed
15874 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
15875 DeleteBrushFromCursor();
15877 PrintEditorGadgetInfoText(gi);
15880 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
15882 int id = gi->custom_id;
15883 int type_id = gi->custom_type_id;
15884 int sx = gi->event.x;
15885 int sy = gi->event.y;
15886 int lx = sx + level_xpos;
15887 int ly = sy + level_ypos;
15888 int min_sx = 0, min_sy = 0;
15889 int max_sx = gi->drawing.area_xsize - 1;
15890 int max_sy = gi->drawing.area_ysize - 1;
15891 int actual_drawing_function = drawing_function;
15892 int max_infotext_len = getMaxInfoTextLength();
15893 char infotext[MAX_OUTPUT_LINESIZE + 1];
15895 infotext[0] = '\0'; // start with empty info text
15897 // pressed Control key: simulate picking element
15898 if (GetKeyModState() & KMOD_Control)
15899 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
15901 ClearEditorGadgetInfoText();
15903 if (gi->event.type == GD_EVENT_INFO_LEAVING)
15906 // make sure to stay inside drawing area boundaries
15907 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
15908 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
15910 if (id == GADGET_ID_DRAWING_LEVEL)
15914 int min_lx = 0, min_ly = 0;
15915 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
15917 // get positions inside level field
15918 lx = sx + level_xpos;
15919 ly = sy + level_ypos;
15921 // make sure to stay inside level field boundaries
15922 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
15923 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
15925 // correct drawing area positions accordingly
15926 sx = lx - level_xpos;
15927 sy = ly - level_ypos;
15930 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15932 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
15934 static int start_lx = 0;
15935 static int start_ly = 0;
15938 if (gi->event.type == GD_EVENT_PRESSED)
15944 switch (actual_drawing_function)
15946 case GADGET_ID_SINGLE_ITEMS:
15947 text = "Drawing single items";
15949 case GADGET_ID_CONNECTED_ITEMS:
15950 text = "Drawing connected items";
15952 case GADGET_ID_LINE:
15953 text = "Drawing line";
15955 case GADGET_ID_ARC:
15956 text = "Drawing arc";
15958 case GADGET_ID_TEXT:
15959 text = "Setting text cursor";
15961 case GADGET_ID_RECTANGLE:
15962 text = "Drawing rectangle";
15964 case GADGET_ID_FILLED_BOX:
15965 text = "Drawing filled box";
15967 case GADGET_ID_FLOOD_FILL:
15968 text = "Flood fill";
15970 case GADGET_ID_GRAB_BRUSH:
15971 text = "Grabbing brush";
15973 case GADGET_ID_PICK_ELEMENT:
15974 text = "Picking element";
15978 text = "Drawing position";
15982 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15983 sprintf(infotext, "%s: %d, %d", text, lx, ly);
15985 sprintf(infotext, "%s: %d, %d", text,
15986 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
15988 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15989 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
15991 sprintf(infotext, "Level position: %d, %d", lx, ly);
15994 // misuse this function to draw brush cursor, if needed
15995 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
15997 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15998 CopyBrushToCursor(sx, sy);
16000 DeleteBrushFromCursor();
16003 if (!draw_with_brush)
16004 UpdateBrushPosition(sx, sy);
16006 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
16008 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
16009 int element = drawingarea_info[type_id].value[pos];
16011 strncpy(infotext, getElementInfoText(element), max_infotext_len);
16015 if (id == GADGET_ID_CUSTOM_CONTENT)
16016 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
16017 else if (id == GADGET_ID_GROUP_CONTENT)
16018 sprintf(infotext, "group element position: %d", sx + 1);
16019 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
16020 id <= GADGET_ID_YAMYAM_CONTENT_7)
16021 sprintf(infotext, "content area %d position: %d, %d",
16022 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
16023 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
16024 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
16025 sprintf(infotext, "content area %d position: %d, %d",
16026 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
16027 else if (id == GADGET_ID_ANDROID_CONTENT)
16028 sprintf(infotext, "android element position: %d", sx + 1);
16029 else if (drawingarea_info[type_id].infotext != NULL)
16030 strcpy(infotext, drawingarea_info[type_id].infotext);
16033 infotext[max_infotext_len] = '\0';
16035 if (strlen(infotext) > 0)
16036 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
16039 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
16040 boolean quick_quit)
16042 if (!ask_if_level_has_changed ||
16044 Request("Level has changed! Exit without saving?",
16045 REQ_ASK | REQ_STAY_OPEN))
16047 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
16048 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
16050 // draw normal door
16051 UndrawSpecialEditorDoor();
16053 // use door animation if door 1 viewport is unchanged and contains toolbox
16054 if (useEditorDoorAnimation())
16055 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
16057 // close editor doors if viewport definition is the same as in main menu
16058 if (vp_door_1->x == DX &&
16059 vp_door_1->y == DY &&
16060 vp_door_1->width == DXSIZE &&
16061 vp_door_1->height == DYSIZE &&
16062 vp_door_2->x == VX &&
16063 vp_door_2->y == VY &&
16064 vp_door_2->width == VXSIZE &&
16065 vp_door_2->height == VYSIZE)
16066 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
16068 SetDoorState(DOOR_CLOSE_ALL);
16073 FadeSkipNextFadeIn();
16075 SetGameStatus(GAME_MODE_MAIN);
16081 if (!global.use_envelope_request)
16083 CloseDoor(DOOR_CLOSE_1);
16084 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);