1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
14 #include "libgame/libgame.h"
25 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
28 // ----------------------------------------------------------------------------
29 // screen and artwork graphic pixel position definitions
30 // ----------------------------------------------------------------------------
32 // values for the control window
33 #define ED_CTRL1_BUTTONS_HORIZ 4 // toolbox
34 #define ED_CTRL1_BUTTONS_VERT 4
35 #define ED_CTRL2_BUTTONS_HORIZ 3 // level
36 #define ED_CTRL2_BUTTONS_VERT 2
37 #define ED_CTRL3_BUTTONS_HORIZ 3 // CE and GE
38 #define ED_CTRL3_BUTTONS_VERT 1
39 #define ED_CTRL4_BUTTONS_HORIZ 2 // CE and GE
40 #define ED_CTRL4_BUTTONS_VERT 1
41 #define ED_CTRL5_BUTTONS_HORIZ 1 // properties
42 #define ED_CTRL5_BUTTONS_VERT 1
43 #define ED_CTRL6_BUTTONS_HORIZ 3 // properties
44 #define ED_CTRL6_BUTTONS_VERT 1
45 #define ED_CTRL7_BUTTONS_HORIZ 1 // palette
46 #define ED_CTRL7_BUTTONS_VERT 1
48 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
49 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
50 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
51 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
52 #define ED_NUM_CTRL5_BUTTONS (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT)
53 #define ED_NUM_CTRL6_BUTTONS (ED_CTRL6_BUTTONS_HORIZ * ED_CTRL6_BUTTONS_VERT)
54 #define ED_NUM_CTRL7_BUTTONS (ED_CTRL7_BUTTONS_HORIZ * ED_CTRL7_BUTTONS_VERT)
55 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
56 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
57 #define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS)
58 #define ED_NUM_CTRL1_5_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS)
59 #define ED_NUM_CTRL1_6_BUTTONS (ED_NUM_CTRL1_5_BUTTONS + ED_NUM_CTRL6_BUTTONS)
60 #define ED_NUM_CTRL1_7_BUTTONS (ED_NUM_CTRL1_6_BUTTONS + ED_NUM_CTRL7_BUTTONS)
61 #define ED_NUM_CTRL_BUTTONS ED_NUM_CTRL1_7_BUTTONS
63 // values for the element list
64 #define ED_ELEMENTLIST_XPOS (editor.palette.x)
65 #define ED_ELEMENTLIST_YPOS (editor.palette.y)
66 #define ED_ELEMENTLIST_XSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
67 #define ED_ELEMENTLIST_YSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
68 #define ED_ELEMENTLIST_COLS MAX(1, editor.palette.cols)
69 #define ED_ELEMENTLIST_ROWS MAX(1, editor.palette.rows)
70 #define ED_ELEMENTLIST_BUTTONS_HORIZ (ED_ELEMENTLIST_COLS)
71 #define ED_ELEMENTLIST_BUTTONS_VERT (ED_ELEMENTLIST_ROWS)
72 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
73 ED_ELEMENTLIST_BUTTONS_VERT)
76 #define ED_GADGET_NORMAL_DISTANCE (editor.gadget.normal_spacing)
77 #define ED_GADGET_SMALL_DISTANCE (editor.gadget.small_spacing)
78 #define ED_GADGET_TINY_DISTANCE (editor.gadget.tiny_spacing)
79 #define ED_GADGET_LINE_DISTANCE (editor.gadget.line_spacing)
80 #define ED_GADGET_TEXT_DISTANCE (editor.gadget.text_spacing)
81 #define ED_TAB_BAR_HEIGHT (editor.gadget.separator_line.height)
82 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
83 ED_DRAWINGAREA_BORDER_SIZE)
84 #define ED_GADGET_SPACE_DISTANCE (getFontWidth(FONT_TEXT_1))
86 // values for drawingarea gadgets
87 #define IMG_BORDER_1 IMG_EDITOR_ELEMENT_BORDER
88 #define IMG_BORDER_2 IMG_EDITOR_ELEMENT_BORDER_INPUT
89 #define ED_ELEMENT_BORDER (graphic_info[IMG_BORDER_1].border_size)
90 #define ED_DRAWINGAREA_BORDER_SIZE (graphic_info[IMG_BORDER_2].border_size)
91 #define ED_DRAWINGAREA_TILE_SIZE (editor.drawingarea.tile_size)
93 // values for checkbutton gadgets
94 #define ED_CHECKBUTTON_XSIZE (graphic_info[IMG_EDITOR_CHECKBOX].width)
95 #define ED_CHECKBUTTON_YSIZE (graphic_info[IMG_EDITOR_CHECKBOX].height)
97 #define ED_TABBUTTON_XSIZE (graphic_info[IMG_EDITOR_TABBUTTON].width)
98 #define ED_TABBUTTON_YSIZE (graphic_info[IMG_EDITOR_TABBUTTON].height)
100 #define ED_SETTINGS_LEVEL_TABS_X (editor.settings.tabs.x)
101 #define ED_SETTINGS_LEVEL_TABS_Y (editor.settings.tabs.y)
102 #define ED_SETTINGS_ELEMENT_TABS_X (editor.settings.tabs.x)
103 #define ED_SETTINGS_ELEMENT_TABS_Y (editor.settings.tabs.y + \
104 editor.settings.tabs.yoffset2)
106 #define ED_SETTINGS_TABS_XOFFSET (editor.settings.tabs.draw_xoffset)
107 #define ED_SETTINGS_TABS_YOFFSET (editor.settings.tabs.draw_yoffset)
109 #define ED_LEVEL_TABS_XSTART (ED_SETTINGS_LEVEL_TABS_X)
110 #define ED_LEVEL_TABS_YSTART (ED_SETTINGS_LEVEL_TABS_Y)
111 #define ED_LEVEL_SETTINGS_XSTART (ED_SETTINGS_LEVEL_TABS_X + \
112 ED_SETTINGS_TABS_XOFFSET)
113 #define ED_LEVEL_SETTINGS_YSTART (ED_SETTINGS_LEVEL_TABS_Y + \
114 ED_TABBUTTON_YSIZE + \
115 ED_GADGET_TINY_DISTANCE + \
116 ED_TAB_BAR_HEIGHT + \
117 ED_SETTINGS_TABS_YOFFSET + \
118 getFontHeight(FONT_TEXT_1) + \
119 ED_GADGET_TEXT_DISTANCE)
120 #define ED_ELEMENT_TABS_XSTART (ED_SETTINGS_ELEMENT_TABS_X)
121 #define ED_ELEMENT_TABS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y)
122 #define ED_ELEMENT_SETTINGS_XSTART (ED_SETTINGS_ELEMENT_TABS_X + \
123 ED_SETTINGS_TABS_XOFFSET)
124 #define ED_ELEMENT_SETTINGS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y + \
125 ED_TABBUTTON_YSIZE + \
126 ED_GADGET_TINY_DISTANCE + \
127 ED_TAB_BAR_HEIGHT + \
128 ED_SETTINGS_TABS_YOFFSET)
130 #define ED_SETTINGS_XOFFSET (ED_CHECKBUTTON_XSIZE + \
131 ED_GADGET_TEXT_DISTANCE)
132 #define ED_SETTINGS_YOFFSET (ED_CHECKBUTTON_YSIZE + \
133 ED_GADGET_LINE_DISTANCE)
135 #define ED_POS_RANGE (10000)
136 #define ED_POS_LEVEL_TABS_FIRST (1 * ED_POS_RANGE)
137 #define ED_POS_LEVEL_TABS_LAST (2 * ED_POS_RANGE - 1)
138 #define ED_POS_LEVEL_SETTINGS_FIRST (2 * ED_POS_RANGE)
139 #define ED_POS_LEVEL_SETTINGS_LAST (3 * ED_POS_RANGE - 1)
140 #define ED_POS_ELEMENT_TABS_FIRST (3 * ED_POS_RANGE)
141 #define ED_POS_ELEMENT_TABS_LAST (4 * ED_POS_RANGE - 1)
142 #define ED_POS_ELEMENT_SETTINGS_FIRST (4 * ED_POS_RANGE)
143 #define ED_POS_ELEMENT_SETTINGS_LAST (5 * ED_POS_RANGE - 1)
145 #define ED_LEVEL_TABS_XPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
146 #define ED_LEVEL_TABS_YPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
148 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
149 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
151 #define ED_ELEMENT_TABS_XPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
152 #define ED_ELEMENT_TABS_YPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
154 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
155 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
157 #define IS_POS_LEVEL_TABS(n) ((n) >= ED_POS_LEVEL_TABS_FIRST && \
158 (n) <= ED_POS_LEVEL_TABS_LAST)
159 #define IS_POS_LEVEL_SETTINGS(n) ((n) >= ED_POS_LEVEL_SETTINGS_FIRST && \
160 (n) <= ED_POS_LEVEL_SETTINGS_LAST)
161 #define IS_POS_ELEMENT_TABS(n) ((n) >= ED_POS_ELEMENT_TABS_FIRST && \
162 (n) <= ED_POS_ELEMENT_TABS_LAST)
163 #define IS_POS_ELEMENT_SETTINGS(n) ((n) >= ED_POS_ELEMENT_SETTINGS_FIRST && \
164 (n) <= ED_POS_ELEMENT_SETTINGS_LAST)
166 #define ED_LEVEL_TABS_LINE(n) ((n) - ED_POS_LEVEL_TABS_FIRST)
167 #define ED_LEVEL_SETTINGS_LINE(n) ((n) - ED_POS_LEVEL_SETTINGS_FIRST)
168 #define ED_ELEMENT_TABS_LINE(n) ((n) - ED_POS_ELEMENT_TABS_FIRST)
169 #define ED_ELEMENT_SETTINGS_LINE(n) ((n) - ED_POS_ELEMENT_SETTINGS_FIRST)
171 #define ED_LEVEL_TABS_X(n) (ED_LEVEL_TABS_XSTART + \
172 (n) * ED_SETTINGS_TABS_XOFFSET)
173 #define ED_LEVEL_TABS_Y(n) (ED_LEVEL_TABS_YSTART + \
174 (n) * ED_SETTINGS_TABS_YOFFSET)
176 #define ED_LEVEL_SETTINGS_X(n) (ED_LEVEL_SETTINGS_XSTART + \
177 (n) * ED_SETTINGS_XOFFSET)
178 #define ED_LEVEL_SETTINGS_Y(n) (ED_LEVEL_SETTINGS_YSTART + \
179 (n) * ED_SETTINGS_YOFFSET)
181 #define ED_ELEMENT_TABS_X(n) (ED_ELEMENT_TABS_XSTART + \
182 (n) * ED_SETTINGS_TABS_XOFFSET)
183 #define ED_ELEMENT_TABS_Y(n) (ED_ELEMENT_TABS_YSTART + \
184 (n) * ED_SETTINGS_TABS_YOFFSET)
186 #define ED_ELEMENT_SETTINGS_X(n) (ED_ELEMENT_SETTINGS_XSTART + \
187 (n) * ED_SETTINGS_XOFFSET)
188 #define ED_ELEMENT_SETTINGS_Y(n) (ED_ELEMENT_SETTINGS_YSTART + \
189 (n) * ED_SETTINGS_YOFFSET)
191 #define ED_POS_TO_LEVEL_TABS_X(n) \
192 (ED_LEVEL_TABS_X(ED_LEVEL_TABS_LINE(n)))
193 #define ED_POS_TO_LEVEL_TABS_Y(n) \
194 (ED_LEVEL_TABS_Y(ED_LEVEL_TABS_LINE(n)))
196 #define ED_POS_TO_LEVEL_SETTINGS_X(n) \
197 (ED_LEVEL_SETTINGS_X(ED_LEVEL_SETTINGS_LINE(n)))
198 #define ED_POS_TO_LEVEL_SETTINGS_Y(n) \
199 (ED_LEVEL_SETTINGS_Y(ED_LEVEL_SETTINGS_LINE(n)))
201 #define ED_POS_TO_ELEMENT_TABS_X(n) \
202 (ED_ELEMENT_TABS_X(ED_ELEMENT_TABS_LINE(n)))
203 #define ED_POS_TO_ELEMENT_TABS_Y(n) \
204 (ED_ELEMENT_TABS_Y(ED_ELEMENT_TABS_LINE(n)))
206 #define ED_POS_TO_ELEMENT_SETTINGS_X(n) \
207 (ED_ELEMENT_SETTINGS_X(ED_ELEMENT_SETTINGS_LINE(n)))
208 #define ED_POS_TO_ELEMENT_SETTINGS_Y(n) \
209 (ED_ELEMENT_SETTINGS_Y(ED_ELEMENT_SETTINGS_LINE(n)))
211 #define ED_SETTINGS_X(n) (IS_POS_LEVEL_TABS(n) ? \
212 ED_POS_TO_LEVEL_TABS_X(n) : \
213 IS_POS_LEVEL_SETTINGS(n) ? \
214 ED_POS_TO_LEVEL_SETTINGS_X(n) : \
215 IS_POS_ELEMENT_TABS(n) ? \
216 ED_POS_TO_ELEMENT_TABS_X(n) : \
217 IS_POS_ELEMENT_SETTINGS(n) ? \
218 ED_POS_TO_ELEMENT_SETTINGS_X(n) : (n))
219 #define ED_SETTINGS_Y(n) (IS_POS_LEVEL_TABS(n) ? \
220 ED_POS_TO_LEVEL_TABS_Y(n) : \
221 IS_POS_LEVEL_SETTINGS(n) ? \
222 ED_POS_TO_LEVEL_SETTINGS_Y(n) : \
223 IS_POS_ELEMENT_TABS(n) ? \
224 ED_POS_TO_ELEMENT_TABS_Y(n) : \
225 IS_POS_ELEMENT_SETTINGS(n) ? \
226 ED_POS_TO_ELEMENT_SETTINGS_Y(n) : (n))
228 #define ED_SETTINGS_XOFF(n) (5 * ((n) % 4) * \
229 ED_DRAWINGAREA_TILE_SIZE)
230 #define ED_SETTINGS_YOFF(n) (5 * ((n) / 4) * \
231 ED_DRAWINGAREA_TILE_SIZE)
233 #define ED_AREA_XOFFSET_1(n) ((n) != 0 ? \
234 ED_DRAWINGAREA_BORDER_SIZE : 0)
235 #define ED_AREA_YOFFSET_1(n) ((n) != 0 ? \
236 (ED_CHECKBUTTON_YSIZE - \
237 ED_DRAWINGAREA_TILE_SIZE) / 2 : 0)
239 #define ED_AREA_XOFFSET_2(n) (0)
240 #define ED_AREA_YOFFSET_2(n) ((n) == 3 ? \
241 ((n) - 1) * ED_DRAWINGAREA_TILE_SIZE / 2 : 0)
243 #define ED_AREA_SETTINGS_X(i) (ED_SETTINGS_X((i).x) + \
244 ED_SETTINGS_XOFF((i).xoffset) + \
245 ED_AREA_XOFFSET_1((i).x) - \
246 ED_AREA_XOFFSET_2((i).area_xsize))
247 #define ED_AREA_SETTINGS_Y(i) (ED_SETTINGS_Y((i).y) + \
248 ED_SETTINGS_YOFF((i).yoffset) + \
249 ED_AREA_YOFFSET_1((i).y) - \
250 ED_AREA_YOFFSET_2((i).area_ysize))
252 // values for element content drawing areas
253 #define ED_AREA_1X1_LSETTINGS_XPOS(n) ED_LEVEL_SETTINGS_XPOS(n)
254 #define ED_AREA_1X1_LSETTINGS_YPOS(n) ED_LEVEL_SETTINGS_YPOS(n)
255 #define ED_AREA_1X1_LSETTINGS_XOFF (0)
256 #define ED_AREA_1X1_LSETTINGS_YOFF (0)
258 #define ED_AREA_1X1_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
259 #define ED_AREA_1X1_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
260 #define ED_AREA_1X1_SETTINGS_XOFF (0)
261 #define ED_AREA_1X1_SETTINGS_YOFF (0)
263 #define ED_AREA_3X3_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
264 #define ED_AREA_3X3_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
265 #define ED_AREA_3X3_SETTINGS_XOFF (0)
266 #define ED_AREA_3X3_SETTINGS_YOFF (0)
269 #define ED_AREA_ELEMENT_CONTENT_XOFF(n) (n)
270 #define ED_AREA_ELEMENT_CONTENT_YOFF(n) (n)
273 #define ED_XPOS_YAM 0
274 #define ED_YPOS_YAM 5
275 #define ED_AREA_YAMYAM_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_YAM)
276 #define ED_AREA_YAMYAM_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_YAM)
277 #define ED_AREA_YAMYAM_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
278 #define ED_AREA_YAMYAM_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
279 #define ED_AREA_YAMYAM_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_YAM) + \
281 #define ED_AREA_YAMYAM_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_YAM) + \
282 ED_SETTINGS_YOFF(n) + \
283 ED_AREA_YOFFSET_1(ED_YPOS_YAM) - \
284 ED_AREA_YOFFSET_2(3))
286 // magic ball content
287 #define ED_XPOS_BALL 0
288 #define ED_YPOS_BALL 6
289 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_BALL)
290 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_BALL)
291 #define ED_AREA_MAGIC_BALL_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
292 #define ED_AREA_MAGIC_BALL_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
293 #define ED_AREA_MAGIC_BALL_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_BALL) + \
295 #define ED_AREA_MAGIC_BALL_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_BALL) + \
296 ED_SETTINGS_YOFF(n) + \
297 ED_AREA_YOFFSET_1(ED_YPOS_BALL) - \
298 ED_AREA_YOFFSET_2(3))
300 // values for scrolling gadgets for drawing area
301 #define ED_SCROLLBUTTON_XSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].width)
302 #define ED_SCROLLBUTTON_YSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].height)
304 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
305 #define ED_SCROLL_UP_YPOS (0)
306 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
307 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
308 #define ED_SCROLL_LEFT_XPOS (0)
309 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
310 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
311 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
312 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
313 ED_SCROLLBUTTON_XSIZE)
314 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
315 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
316 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
317 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
318 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
319 ED_SCROLLBUTTON_YSIZE)
320 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
321 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
323 // values for scrolling gadgets for element list
324 #define ED_SCROLLBUTTON2_XSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
325 #define ED_SCROLLBUTTON2_YSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
327 #define ED_SCROLL2_UP_XPOS (ED_ELEMENTLIST_XPOS + \
328 ED_ELEMENTLIST_BUTTONS_HORIZ * \
329 ED_ELEMENTLIST_XSIZE)
330 #define ED_SCROLL2_UP_YPOS ED_ELEMENTLIST_YPOS
331 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
332 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
333 ED_ELEMENTLIST_BUTTONS_VERT * \
334 ED_ELEMENTLIST_YSIZE - \
335 ED_SCROLLBUTTON2_YSIZE)
336 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
337 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
338 ED_SCROLLBUTTON2_YSIZE)
339 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
340 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
341 ED_ELEMENTLIST_YSIZE - \
342 2 * ED_SCROLLBUTTON2_YSIZE)
344 // values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText()
345 #define INFOTEXT_FONT FONT_TEXT_2
346 #define INFOTEXT_XSIZE SXSIZE
347 #define INFOTEXT_YSIZE getFontHeight(INFOTEXT_FONT)
348 #define INFOTEXT_YSIZE_FULL (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE)
349 #define INFOTEXT_X (editor.settings.tooltip.x)
350 #define INFOTEXT_Y (editor.settings.tooltip.y)
351 #define INFOTEXT_XY_REDEFINED (INFOTEXT_X != -1 || INFOTEXT_Y != -1)
352 #define INFOTEXT_XPOS SX + (INFOTEXT_XY_REDEFINED ? INFOTEXT_X : 0)
353 #define INFOTEXT_YPOS SY + (INFOTEXT_XY_REDEFINED ? INFOTEXT_Y : \
354 SYSIZE - INFOTEXT_YSIZE)
357 // ----------------------------------------------------------------------------
358 // editor gadget definitions
359 // ----------------------------------------------------------------------------
365 // drawing toolbox buttons
367 GADGET_ID_SINGLE_ITEMS,
368 GADGET_ID_CONNECTED_ITEMS,
372 GADGET_ID_FILLED_BOX,
375 GADGET_ID_FLOOD_FILL,
378 GADGET_ID_WRAP_RIGHT,
379 GADGET_ID_RANDOM_PLACEMENT,
380 GADGET_ID_GRAB_BRUSH,
382 GADGET_ID_PICK_ELEMENT,
391 GADGET_ID_CUSTOM_COPY_FROM,
392 GADGET_ID_CUSTOM_COPY_TO,
393 GADGET_ID_CUSTOM_EXCHANGE,
394 GADGET_ID_CUSTOM_COPY,
395 GADGET_ID_CUSTOM_PASTE,
397 GADGET_ID_PROPERTIES,
398 GADGET_ID_ELEMENT_LEFT,
399 GADGET_ID_ELEMENT_MIDDLE,
400 GADGET_ID_ELEMENT_RIGHT,
403 // counter gadget identifiers
405 GADGET_ID_SELECT_LEVEL_DOWN,
406 GADGET_ID_SELECT_LEVEL_TEXT,
407 GADGET_ID_SELECT_LEVEL_UP,
408 GADGET_ID_LEVEL_XSIZE_DOWN,
409 GADGET_ID_LEVEL_XSIZE_TEXT,
410 GADGET_ID_LEVEL_XSIZE_UP,
411 GADGET_ID_LEVEL_YSIZE_DOWN,
412 GADGET_ID_LEVEL_YSIZE_TEXT,
413 GADGET_ID_LEVEL_YSIZE_UP,
414 GADGET_ID_LEVEL_RANDOM_DOWN,
415 GADGET_ID_LEVEL_RANDOM_TEXT,
416 GADGET_ID_LEVEL_RANDOM_UP,
417 GADGET_ID_LEVEL_GEMSLIMIT_DOWN,
418 GADGET_ID_LEVEL_GEMSLIMIT_TEXT,
419 GADGET_ID_LEVEL_GEMSLIMIT_UP,
420 GADGET_ID_LEVEL_TIMELIMIT_DOWN,
421 GADGET_ID_LEVEL_TIMELIMIT_TEXT,
422 GADGET_ID_LEVEL_TIMELIMIT_UP,
423 GADGET_ID_LEVEL_TIMESCORE_DOWN,
424 GADGET_ID_LEVEL_TIMESCORE_TEXT,
425 GADGET_ID_LEVEL_TIMESCORE_UP,
426 GADGET_ID_LEVEL_RANDOM_SEED_DOWN,
427 GADGET_ID_LEVEL_RANDOM_SEED_TEXT,
428 GADGET_ID_LEVEL_RANDOM_SEED_UP,
429 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN,
430 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT,
431 GADGET_ID_LEVELSET_NUM_LEVELS_UP,
432 GADGET_ID_ELEMENT_VALUE1_DOWN,
433 GADGET_ID_ELEMENT_VALUE1_TEXT,
434 GADGET_ID_ELEMENT_VALUE1_UP,
435 GADGET_ID_ELEMENT_VALUE2_DOWN,
436 GADGET_ID_ELEMENT_VALUE2_TEXT,
437 GADGET_ID_ELEMENT_VALUE2_UP,
438 GADGET_ID_ELEMENT_VALUE3_DOWN,
439 GADGET_ID_ELEMENT_VALUE3_TEXT,
440 GADGET_ID_ELEMENT_VALUE3_UP,
441 GADGET_ID_ELEMENT_VALUE4_DOWN,
442 GADGET_ID_ELEMENT_VALUE4_TEXT,
443 GADGET_ID_ELEMENT_VALUE4_UP,
444 GADGET_ID_YAMYAM_CONTENT_DOWN,
445 GADGET_ID_YAMYAM_CONTENT_TEXT,
446 GADGET_ID_YAMYAM_CONTENT_UP,
447 GADGET_ID_BALL_CONTENT_DOWN,
448 GADGET_ID_BALL_CONTENT_TEXT,
449 GADGET_ID_BALL_CONTENT_UP,
450 GADGET_ID_ANDROID_CONTENT_DOWN,
451 GADGET_ID_ANDROID_CONTENT_TEXT,
452 GADGET_ID_ANDROID_CONTENT_UP,
453 GADGET_ID_ENVELOPE_XSIZE_DOWN,
454 GADGET_ID_ENVELOPE_XSIZE_TEXT,
455 GADGET_ID_ENVELOPE_XSIZE_UP,
456 GADGET_ID_ENVELOPE_YSIZE_DOWN,
457 GADGET_ID_ENVELOPE_YSIZE_TEXT,
458 GADGET_ID_ENVELOPE_YSIZE_UP,
459 GADGET_ID_INVENTORY_SIZE_DOWN,
460 GADGET_ID_INVENTORY_SIZE_TEXT,
461 GADGET_ID_INVENTORY_SIZE_UP,
462 GADGET_ID_MM_BALL_CONTENT_DOWN,
463 GADGET_ID_MM_BALL_CONTENT_TEXT,
464 GADGET_ID_MM_BALL_CONTENT_UP,
465 GADGET_ID_CUSTOM_SCORE_DOWN,
466 GADGET_ID_CUSTOM_SCORE_TEXT,
467 GADGET_ID_CUSTOM_SCORE_UP,
468 GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
469 GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
470 GADGET_ID_CUSTOM_GEMCOUNT_UP,
471 GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
472 GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
473 GADGET_ID_CUSTOM_VALUE_FIX_UP,
474 GADGET_ID_CUSTOM_VALUE_RND_DOWN,
475 GADGET_ID_CUSTOM_VALUE_RND_TEXT,
476 GADGET_ID_CUSTOM_VALUE_RND_UP,
477 GADGET_ID_PUSH_DELAY_FIX_DOWN,
478 GADGET_ID_PUSH_DELAY_FIX_TEXT,
479 GADGET_ID_PUSH_DELAY_FIX_UP,
480 GADGET_ID_PUSH_DELAY_RND_DOWN,
481 GADGET_ID_PUSH_DELAY_RND_TEXT,
482 GADGET_ID_PUSH_DELAY_RND_UP,
483 GADGET_ID_DROP_DELAY_FIX_DOWN,
484 GADGET_ID_DROP_DELAY_FIX_TEXT,
485 GADGET_ID_DROP_DELAY_FIX_UP,
486 GADGET_ID_DROP_DELAY_RND_DOWN,
487 GADGET_ID_DROP_DELAY_RND_TEXT,
488 GADGET_ID_DROP_DELAY_RND_UP,
489 GADGET_ID_MOVE_DELAY_FIX_DOWN,
490 GADGET_ID_MOVE_DELAY_FIX_TEXT,
491 GADGET_ID_MOVE_DELAY_FIX_UP,
492 GADGET_ID_MOVE_DELAY_RND_DOWN,
493 GADGET_ID_MOVE_DELAY_RND_TEXT,
494 GADGET_ID_MOVE_DELAY_RND_UP,
495 GADGET_ID_STEP_DELAY_FIX_DOWN,
496 GADGET_ID_STEP_DELAY_FIX_TEXT,
497 GADGET_ID_STEP_DELAY_FIX_UP,
498 GADGET_ID_STEP_DELAY_RND_DOWN,
499 GADGET_ID_STEP_DELAY_RND_TEXT,
500 GADGET_ID_STEP_DELAY_RND_UP,
501 GADGET_ID_EXPLOSION_DELAY_DOWN,
502 GADGET_ID_EXPLOSION_DELAY_TEXT,
503 GADGET_ID_EXPLOSION_DELAY_UP,
504 GADGET_ID_IGNITION_DELAY_DOWN,
505 GADGET_ID_IGNITION_DELAY_TEXT,
506 GADGET_ID_IGNITION_DELAY_UP,
507 GADGET_ID_CHANGE_DELAY_FIX_DOWN,
508 GADGET_ID_CHANGE_DELAY_FIX_TEXT,
509 GADGET_ID_CHANGE_DELAY_FIX_UP,
510 GADGET_ID_CHANGE_DELAY_RND_DOWN,
511 GADGET_ID_CHANGE_DELAY_RND_TEXT,
512 GADGET_ID_CHANGE_DELAY_RND_UP,
513 GADGET_ID_CHANGE_CONT_RND_DOWN,
514 GADGET_ID_CHANGE_CONT_RND_TEXT,
515 GADGET_ID_CHANGE_CONT_RND_UP,
516 GADGET_ID_GROUP_CONTENT_DOWN,
517 GADGET_ID_GROUP_CONTENT_TEXT,
518 GADGET_ID_GROUP_CONTENT_UP,
520 // drawing area identifiers
522 GADGET_ID_DRAWING_LEVEL,
523 GADGET_ID_YAMYAM_CONTENT_0,
524 GADGET_ID_YAMYAM_CONTENT_1,
525 GADGET_ID_YAMYAM_CONTENT_2,
526 GADGET_ID_YAMYAM_CONTENT_3,
527 GADGET_ID_YAMYAM_CONTENT_4,
528 GADGET_ID_YAMYAM_CONTENT_5,
529 GADGET_ID_YAMYAM_CONTENT_6,
530 GADGET_ID_YAMYAM_CONTENT_7,
531 GADGET_ID_MAGIC_BALL_CONTENT_0,
532 GADGET_ID_MAGIC_BALL_CONTENT_1,
533 GADGET_ID_MAGIC_BALL_CONTENT_2,
534 GADGET_ID_MAGIC_BALL_CONTENT_3,
535 GADGET_ID_MAGIC_BALL_CONTENT_4,
536 GADGET_ID_MAGIC_BALL_CONTENT_5,
537 GADGET_ID_MAGIC_BALL_CONTENT_6,
538 GADGET_ID_MAGIC_BALL_CONTENT_7,
539 GADGET_ID_ANDROID_CONTENT,
540 GADGET_ID_AMOEBA_CONTENT,
541 GADGET_ID_START_ELEMENT,
542 GADGET_ID_ARTWORK_ELEMENT,
543 GADGET_ID_EXPLOSION_ELEMENT,
544 GADGET_ID_INVENTORY_CONTENT,
545 GADGET_ID_MM_BALL_CONTENT,
546 GADGET_ID_CUSTOM_GRAPHIC,
547 GADGET_ID_CUSTOM_CONTENT,
548 GADGET_ID_CUSTOM_MOVE_ENTER,
549 GADGET_ID_CUSTOM_MOVE_LEAVE,
550 GADGET_ID_CUSTOM_CHANGE_TARGET,
551 GADGET_ID_CUSTOM_CHANGE_CONTENT,
552 GADGET_ID_CUSTOM_CHANGE_TRIGGER,
553 GADGET_ID_CUSTOM_CHANGE_ACTION,
554 GADGET_ID_GROUP_CONTENT,
555 GADGET_ID_RANDOM_BACKGROUND,
557 // text input identifiers
559 GADGET_ID_LEVEL_NAME,
560 GADGET_ID_LEVEL_AUTHOR,
561 GADGET_ID_LEVELSET_NAME,
562 GADGET_ID_LEVELSET_AUTHOR,
563 GADGET_ID_ELEMENT_NAME,
565 // text area identifiers
567 GADGET_ID_ENVELOPE_INFO,
569 // selectbox identifiers
571 GADGET_ID_TIME_OR_STEPS,
572 GADGET_ID_TIME_SCORE_BASE,
573 GADGET_ID_GAME_ENGINE_TYPE,
574 GADGET_ID_LEVELSET_SAVE_MODE,
575 GADGET_ID_WIND_DIRECTION,
576 GADGET_ID_PLAYER_SPEED,
577 GADGET_ID_MM_BALL_CHOICE_MODE,
578 GADGET_ID_CUSTOM_WALK_TO_ACTION,
579 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
580 GADGET_ID_CUSTOM_DEADLINESS,
581 GADGET_ID_CUSTOM_MOVE_PATTERN,
582 GADGET_ID_CUSTOM_MOVE_DIRECTION,
583 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
584 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
585 GADGET_ID_CUSTOM_SMASH_TARGETS,
586 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
587 GADGET_ID_CUSTOM_ACCESS_TYPE,
588 GADGET_ID_CUSTOM_ACCESS_LAYER,
589 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
590 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
591 GADGET_ID_CHANGE_TIME_UNITS,
592 GADGET_ID_CHANGE_DIRECT_ACTION,
593 GADGET_ID_CHANGE_OTHER_ACTION,
594 GADGET_ID_CHANGE_SIDE,
595 GADGET_ID_CHANGE_PLAYER,
596 GADGET_ID_CHANGE_PAGE,
597 GADGET_ID_CHANGE_REPLACE_WHEN,
598 GADGET_ID_ACTION_TYPE,
599 GADGET_ID_ACTION_MODE,
600 GADGET_ID_ACTION_ARG,
601 GADGET_ID_SELECT_CHANGE_PAGE,
602 GADGET_ID_GROUP_CHOICE_MODE,
604 // textbutton identifiers
606 GADGET_ID_LEVELCONFIG_LEVEL,
607 GADGET_ID_LEVELCONFIG_LEVELSET,
608 GADGET_ID_LEVELCONFIG_EDITOR,
609 GADGET_ID_LEVELCONFIG_ENGINE,
610 GADGET_ID_PROPERTIES_INFO,
611 GADGET_ID_PROPERTIES_CONFIG,
612 GADGET_ID_PROPERTIES_CONFIG_1,
613 GADGET_ID_PROPERTIES_CONFIG_2,
614 GADGET_ID_PROPERTIES_CHANGE,
615 GADGET_ID_SAVE_AS_TEMPLATE_1,
616 GADGET_ID_SAVE_AS_TEMPLATE_2,
617 GADGET_ID_SAVE_LEVELSET,
618 GADGET_ID_ADD_CHANGE_PAGE,
619 GADGET_ID_DEL_CHANGE_PAGE,
621 // graphicbutton identifiers
623 GADGET_ID_PREV_CHANGE_PAGE,
624 GADGET_ID_NEXT_CHANGE_PAGE,
625 GADGET_ID_COPY_CHANGE_PAGE,
626 GADGET_ID_PASTE_CHANGE_PAGE,
628 // gadgets for scrolling of drawing area
631 GADGET_ID_SCROLL_DOWN,
632 GADGET_ID_SCROLL_LEFT,
633 GADGET_ID_SCROLL_RIGHT,
634 GADGET_ID_SCROLL_HORIZONTAL,
635 GADGET_ID_SCROLL_VERTICAL,
637 // gadgets for scrolling element list
639 GADGET_ID_SCROLL_LIST_UP,
640 GADGET_ID_SCROLL_LIST_DOWN,
641 GADGET_ID_SCROLL_LIST_VERTICAL,
643 // checkbuttons/radiobuttons for level/element properties
645 GADGET_ID_AUTO_COUNT_GEMS,
646 GADGET_ID_RATE_TIME_OVER_SCORE,
647 GADGET_ID_USE_LEVELSET_ARTWORK,
648 GADGET_ID_COPY_LEVEL_TEMPLATE,
649 GADGET_ID_RANDOM_PERCENTAGE,
650 GADGET_ID_RANDOM_QUANTITY,
651 GADGET_ID_RANDOM_RESTRICTED,
652 GADGET_ID_STICK_ELEMENT,
653 GADGET_ID_EM_SLIPPERY_GEMS,
654 GADGET_ID_EM_EXPLODES_BY_FIRE,
655 GADGET_ID_USE_SPRING_BUG,
656 GADGET_ID_USE_TIME_ORB_BUG,
657 GADGET_ID_USE_LIFE_BUGS,
658 GADGET_ID_RANDOM_BALL_CONTENT,
659 GADGET_ID_INITIAL_BALL_ACTIVE,
660 GADGET_ID_GROW_INTO_DIGGABLE,
661 GADGET_ID_SB_FIELDS_NEEDED,
662 GADGET_ID_SB_OBJECTS_NEEDED,
663 GADGET_ID_AUTO_EXIT_SOKOBAN,
664 GADGET_ID_SOLVED_BY_ONE_PLAYER,
665 GADGET_ID_FINISH_DIG_COLLECT,
666 GADGET_ID_KEEP_WALKABLE_CE,
667 GADGET_ID_CONTINUOUS_SNAPPING,
668 GADGET_ID_BLOCK_SNAP_FIELD,
669 GADGET_ID_BLOCK_LAST_FIELD,
670 GADGET_ID_SP_BLOCK_LAST_FIELD,
671 GADGET_ID_INSTANT_RELOCATION,
672 GADGET_ID_SHIFTED_RELOCATION,
673 GADGET_ID_LAZY_RELOCATION,
674 GADGET_ID_USE_START_ELEMENT,
675 GADGET_ID_USE_ARTWORK_ELEMENT,
676 GADGET_ID_USE_EXPLOSION_ELEMENT,
677 GADGET_ID_INITIAL_GRAVITY,
678 GADGET_ID_USE_INITIAL_INVENTORY,
679 GADGET_ID_CAN_PASS_TO_WALKABLE,
680 GADGET_ID_CAN_FALL_INTO_ACID,
681 GADGET_ID_CAN_MOVE_INTO_ACID,
682 GADGET_ID_DONT_COLLIDE_WITH,
683 GADGET_ID_BD_DIAGONAL_MOVEMENTS,
684 GADGET_ID_ENVELOPE_AUTOWRAP,
685 GADGET_ID_ENVELOPE_CENTERED,
686 GADGET_ID_MM_LASER_RED,
687 GADGET_ID_MM_LASER_GREEN,
688 GADGET_ID_MM_LASER_BLUE,
689 GADGET_ID_DF_LASER_RED,
690 GADGET_ID_DF_LASER_GREEN,
691 GADGET_ID_DF_LASER_BLUE,
692 GADGET_ID_ROTATE_MM_BALL_CONTENT,
693 GADGET_ID_EXPLODE_MM_BALL,
694 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
695 GADGET_ID_CUSTOM_CAN_EXPLODE,
696 GADGET_ID_CUSTOM_EXPLODE_FIRE,
697 GADGET_ID_CUSTOM_EXPLODE_SMASH,
698 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
699 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
700 GADGET_ID_CUSTOM_DEADLY,
701 GADGET_ID_CUSTOM_CAN_MOVE,
702 GADGET_ID_CUSTOM_CAN_FALL,
703 GADGET_ID_CUSTOM_CAN_SMASH,
704 GADGET_ID_CUSTOM_SLIPPERY,
705 GADGET_ID_CUSTOM_ACCESSIBLE,
706 GADGET_ID_CUSTOM_GRAV_REACHABLE,
707 GADGET_ID_CUSTOM_USE_LAST_VALUE,
708 GADGET_ID_CUSTOM_USE_GRAPHIC,
709 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
710 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
711 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
712 GADGET_ID_CUSTOM_CAN_CHANGE,
713 GADGET_ID_CHANGE_USE_CONTENT,
714 GADGET_ID_CHANGE_USE_EXPLOSION,
715 GADGET_ID_CHANGE_ONLY_COMPLETE,
716 GADGET_ID_CHANGE_USE_RANDOM,
717 GADGET_ID_CHANGE_HAS_ACTION,
718 GADGET_ID_CHANGE_DELAY,
719 GADGET_ID_CHANGE_BY_DIRECT_ACT,
720 GADGET_ID_CHANGE_BY_OTHER_ACT,
722 NUM_STATIC_GADGET_IDS
725 // gadgets for buttons in element list (dynamic)
726 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
727 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
728 ED_NUM_ELEMENTLIST_BUTTONS - 1)
730 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
732 // radio button numbers
736 RADIO_NR_DRAWING_TOOLBOX,
737 RADIO_NR_RANDOM_ELEMENTS
740 // values for counter gadgets
743 ED_COUNTER_ID_SELECT_LEVEL,
744 ED_COUNTER_ID_LEVEL_XSIZE,
745 ED_COUNTER_ID_LEVEL_YSIZE,
746 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
747 ED_COUNTER_ID_LEVEL_TIMELIMIT,
748 ED_COUNTER_ID_LEVEL_TIMESCORE,
749 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
750 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
751 ED_COUNTER_ID_LEVEL_RANDOM,
752 ED_COUNTER_ID_ELEMENT_VALUE1,
753 ED_COUNTER_ID_ELEMENT_VALUE2,
754 ED_COUNTER_ID_ELEMENT_VALUE3,
755 ED_COUNTER_ID_ELEMENT_VALUE4,
756 ED_COUNTER_ID_YAMYAM_CONTENT,
757 ED_COUNTER_ID_BALL_CONTENT,
758 ED_COUNTER_ID_ANDROID_CONTENT,
759 ED_COUNTER_ID_ENVELOPE_XSIZE,
760 ED_COUNTER_ID_ENVELOPE_YSIZE,
761 ED_COUNTER_ID_INVENTORY_SIZE,
762 ED_COUNTER_ID_MM_BALL_CONTENT,
763 ED_COUNTER_ID_CUSTOM_SCORE,
764 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
765 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
766 ED_COUNTER_ID_CUSTOM_VALUE_RND,
767 ED_COUNTER_ID_PUSH_DELAY_FIX,
768 ED_COUNTER_ID_PUSH_DELAY_RND,
769 ED_COUNTER_ID_DROP_DELAY_FIX,
770 ED_COUNTER_ID_DROP_DELAY_RND,
771 ED_COUNTER_ID_MOVE_DELAY_FIX,
772 ED_COUNTER_ID_MOVE_DELAY_RND,
773 ED_COUNTER_ID_STEP_DELAY_FIX,
774 ED_COUNTER_ID_STEP_DELAY_RND,
775 ED_COUNTER_ID_EXPLOSION_DELAY,
776 ED_COUNTER_ID_IGNITION_DELAY,
777 ED_COUNTER_ID_GROUP_CONTENT,
778 ED_COUNTER_ID_CHANGE_DELAY_FIX,
779 ED_COUNTER_ID_CHANGE_DELAY_RND,
780 ED_COUNTER_ID_CHANGE_CONT_RND,
782 ED_NUM_COUNTERBUTTONS
785 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
786 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
787 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
788 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
789 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
790 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
792 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
793 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
794 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
795 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
796 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
797 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
799 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
800 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
802 // values for scrollbutton gadgets
805 ED_SCROLLBUTTON_ID_AREA_UP,
806 ED_SCROLLBUTTON_ID_AREA_DOWN,
807 ED_SCROLLBUTTON_ID_AREA_LEFT,
808 ED_SCROLLBUTTON_ID_AREA_RIGHT,
809 ED_SCROLLBUTTON_ID_LIST_UP,
810 ED_SCROLLBUTTON_ID_LIST_DOWN,
815 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
816 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
818 // values for scrollbar gadgets
821 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
822 ED_SCROLLBAR_ID_AREA_VERTICAL,
823 ED_SCROLLBAR_ID_LIST_VERTICAL,
828 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
829 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
831 // values for text input gadgets
834 ED_TEXTINPUT_ID_LEVEL_NAME,
835 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
836 ED_TEXTINPUT_ID_LEVELSET_NAME,
837 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
838 ED_TEXTINPUT_ID_ELEMENT_NAME,
843 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
844 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
846 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
847 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
849 // values for text area gadgets
852 ED_TEXTAREA_ID_ENVELOPE_INFO,
857 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
858 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
860 // values for selectbox gadgets
863 ED_SELECTBOX_ID_TIME_OR_STEPS,
864 ED_SELECTBOX_ID_TIME_SCORE_BASE,
865 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
866 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
867 ED_SELECTBOX_ID_WIND_DIRECTION,
868 ED_SELECTBOX_ID_PLAYER_SPEED,
869 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
870 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
871 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
872 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
873 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
874 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
875 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
876 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
877 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
878 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
879 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
880 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
881 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
882 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
883 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
884 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
885 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
886 ED_SELECTBOX_ID_CHANGE_SIDE,
887 ED_SELECTBOX_ID_CHANGE_PLAYER,
888 ED_SELECTBOX_ID_CHANGE_PAGE,
889 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
890 ED_SELECTBOX_ID_ACTION_TYPE,
891 ED_SELECTBOX_ID_ACTION_MODE,
892 ED_SELECTBOX_ID_ACTION_ARG,
893 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
894 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
899 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
900 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
902 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
903 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
905 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
906 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
907 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
908 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
909 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
910 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
912 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
913 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
915 // values for textbutton gadgets
918 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
919 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
920 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
921 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
922 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
923 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
924 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
925 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
926 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
927 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
928 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
929 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
930 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
931 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
936 #define ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
937 #define ED_TAB_BUTTON_ID_LEVELCONFIG_LAST ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
939 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
940 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
942 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
943 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
945 // values for graphicbutton gadgets
948 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
949 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
950 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
951 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
953 ED_NUM_GRAPHICBUTTONS
956 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
957 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
959 // values for checkbutton gadgets
962 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
963 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
964 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
965 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
966 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
967 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
968 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
969 ED_CHECKBUTTON_ID_STICK_ELEMENT,
970 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
971 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
972 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
973 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
974 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
975 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
976 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
977 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
978 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
979 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
980 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
981 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
982 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
983 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
984 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
985 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
986 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
987 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
988 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
989 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
990 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
991 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
992 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
993 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
994 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
995 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
996 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
997 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
998 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
999 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
1000 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
1001 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
1002 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
1003 ED_CHECKBUTTON_ID_MM_LASER_RED,
1004 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
1005 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1006 ED_CHECKBUTTON_ID_DF_LASER_RED,
1007 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1008 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1009 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
1010 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
1011 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1012 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1013 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1014 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1015 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1016 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1017 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1018 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1019 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1020 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1021 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1022 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1023 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1024 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1025 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1026 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1027 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1028 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1029 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1030 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1031 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1032 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1033 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1034 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1035 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1040 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1041 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1043 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1044 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1046 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1047 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1049 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1050 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1051 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1052 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1053 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1054 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1056 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1057 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1059 // values for radiobutton gadgets
1062 ED_RADIOBUTTON_ID_PERCENTAGE,
1063 ED_RADIOBUTTON_ID_QUANTITY,
1068 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1069 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1071 // values for drawing area gadgets
1074 ED_DRAWING_ID_DRAWING_LEVEL,
1075 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1076 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1077 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1078 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1079 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1080 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1081 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1082 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1083 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1084 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1085 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1086 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1087 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1088 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1089 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1090 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1091 ED_DRAWING_ID_ANDROID_CONTENT,
1092 ED_DRAWING_ID_AMOEBA_CONTENT,
1093 ED_DRAWING_ID_START_ELEMENT,
1094 ED_DRAWING_ID_ARTWORK_ELEMENT,
1095 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1096 ED_DRAWING_ID_INVENTORY_CONTENT,
1097 ED_DRAWING_ID_MM_BALL_CONTENT,
1098 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1099 ED_DRAWING_ID_CUSTOM_CONTENT,
1100 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1101 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1102 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1103 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1104 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1105 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1106 ED_DRAWING_ID_GROUP_CONTENT,
1107 ED_DRAWING_ID_RANDOM_BACKGROUND,
1109 ED_NUM_DRAWING_AREAS
1112 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1113 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1116 // ----------------------------------------------------------------------------
1117 // some internally used definitions
1118 // ----------------------------------------------------------------------------
1120 // values for CopyLevelToUndoBuffer()
1121 #define UNDO_IMMEDIATE 0
1122 #define UNDO_ACCUMULATE 1
1124 // values for scrollbars
1125 #define ED_SCROLL_NO 0
1126 #define ED_SCROLL_LEFT 1
1127 #define ED_SCROLL_RIGHT 2
1128 #define ED_SCROLL_UP 4
1129 #define ED_SCROLL_DOWN 8
1131 // screens in the level editor
1132 #define ED_MODE_DRAWING 0
1133 #define ED_MODE_LEVELCONFIG 1
1134 #define ED_MODE_PROPERTIES 2
1135 #define ED_MODE_PALETTE 3
1137 // sub-screens in the global settings section
1138 #define ED_MODE_LEVELCONFIG_LEVEL ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
1139 #define ED_MODE_LEVELCONFIG_LEVELSET ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET
1140 #define ED_MODE_LEVELCONFIG_EDITOR ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
1141 #define ED_MODE_LEVELCONFIG_ENGINE ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE
1143 // sub-screens in the element properties section
1144 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1145 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1146 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1147 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1148 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1150 // how many steps can be cancelled
1151 #define NUM_UNDO_STEPS (64 + 1)
1153 // values for elements with score for certain actions
1155 #define MAX_SCORE 999
1157 // values for elements with count for collecting
1158 #define MIN_COLLECT_COUNT 0
1159 #define MAX_COLLECT_COUNT 999
1161 // values for random placement
1162 #define RANDOM_USE_PERCENTAGE 0
1163 #define RANDOM_USE_QUANTITY 1
1165 // values for level set save mode
1166 #define LEVELSET_SAVE_MODE_UPDATE 0
1167 #define LEVELSET_SAVE_MODE_CREATE 1
1169 // default value for element tile size in drawing area
1170 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1171 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1174 // ----------------------------------------------------------------------------
1175 // some internally used data structure definitions
1176 // ----------------------------------------------------------------------------
1182 struct XYTileSize *pos;
1186 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1188 // note: some additional characters are already reserved for "cheat mode"
1189 // shortcuts (":XYZ" style) -- for details, see "events.c"
1191 // ---------- toolbox control buttons ---------------------------------------
1194 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1195 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1196 "draw single items", 's'
1199 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1200 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1201 "draw connected items", 'd'
1204 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1205 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1209 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1210 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1214 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1215 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1216 "draw outline rectangles", 'r'
1219 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1220 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1221 "draw filled rectangles", 'R'
1224 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1225 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1226 "wrap (rotate) level up", 0
1229 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1230 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1231 "enter text elements", 't'
1234 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1235 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1239 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1240 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1241 "wrap (rotate) level left", 0
1244 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1245 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1246 "zoom level tile size", '+'
1249 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1250 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1251 "wrap (rotate) level right", 0
1254 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1255 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1256 "random element placement", 0
1259 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1260 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1264 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1265 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1266 "wrap (rotate) level down", 0
1269 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1270 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1271 "pick drawing element", ','
1274 // ---------- level control buttons -----------------------------------------
1277 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1278 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1279 "undo/redo last operation", 'u'
1282 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_CONF,
1283 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1284 "level and editor settings", 'I'
1287 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1288 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1292 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1293 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1297 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1298 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1302 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1303 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1304 "exit level editor", 'E'
1307 // ---------- CE and GE control buttons -------------------------------------
1310 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1311 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1312 "copy settings from other element", 0
1315 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1316 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1317 "copy settings to other element", 0
1320 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1321 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1322 "exchange element with other element", 0
1325 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1326 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1327 "copy settings from this element", 0
1330 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1331 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1332 "paste settings to this element", 0
1335 // ---------- palette control buttons ---------------------------------------
1338 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1339 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1340 "properties of drawing element", 'p'
1343 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1344 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1345 "properties of drawing element 1", '1'
1348 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1349 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1350 "properties of drawing element 2", '2'
1353 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1354 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1355 "properties of drawing element 3", '3'
1358 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1359 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1360 "show list of elements", 'e'
1364 static int random_placement_value = 10;
1365 static int random_placement_method = RANDOM_USE_QUANTITY;
1366 static int random_placement_background_element = EL_SAND;
1367 static boolean random_placement_background_restricted = FALSE;
1368 static boolean stick_element_properties_window = FALSE;
1369 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1370 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1371 static struct ElementChangeInfo custom_element_change;
1372 static struct ElementGroupInfo group_element_info;
1373 static struct ElementInfo custom_element;
1375 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1376 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1377 static int levelset_num_levels = 100;
1378 static boolean levelset_use_levelset_artwork = FALSE;
1379 static boolean levelset_copy_level_template = FALSE;
1380 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1386 int min_value, max_value;
1387 int gadget_id_down, gadget_id_up;
1389 int gadget_id_align;
1391 char *text_above, *text_left, *text_right;
1392 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1394 // ---------- current level number ------------------------------------------
1397 ED_COUNTER_ID_SELECT_LEVEL,
1398 -1, -1, // these values are not constant, but can change at runtime
1400 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1401 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1406 // ---------- level and editor settings -------------------------------------
1409 ED_COUNTER_ID_LEVEL_XSIZE,
1410 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1411 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1412 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1413 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1415 "playfield size:", NULL, "width",
1418 ED_COUNTER_ID_LEVEL_YSIZE,
1419 -1, ED_LEVEL_SETTINGS_YPOS(4),
1420 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1421 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1422 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1424 NULL, " ", "height",
1427 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
1428 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1430 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1431 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1433 NULL, "number of gems to collect:", NULL
1436 ED_COUNTER_ID_LEVEL_TIMELIMIT,
1437 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1439 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1440 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1442 "time or step limit to solve level:", NULL, NULL
1445 ED_COUNTER_ID_LEVEL_TIMESCORE,
1446 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1448 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1449 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1450 &level.score[SC_TIME_BONUS],
1451 "score for time or steps left:", NULL, NULL
1454 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
1455 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1457 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1458 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1460 NULL, "random seed:", "(0 => random)"
1463 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
1464 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1466 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1467 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1468 &levelset_num_levels,
1469 "number of levels:", NULL, NULL,
1472 ED_COUNTER_ID_LEVEL_RANDOM,
1473 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1475 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1476 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1477 &random_placement_value,
1478 "random element placement:", NULL, "in"
1481 // ---------- element settings: configure (various elements) ----------------
1484 ED_COUNTER_ID_ELEMENT_VALUE1,
1485 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1486 MIN_SCORE, MAX_SCORE,
1487 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1488 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1489 NULL, // will be set when used
1493 ED_COUNTER_ID_ELEMENT_VALUE2,
1494 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1495 MIN_SCORE, MAX_SCORE,
1496 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1497 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1498 NULL, // will be set when used
1502 ED_COUNTER_ID_ELEMENT_VALUE3,
1503 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1504 MIN_SCORE, MAX_SCORE,
1505 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1506 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1507 NULL, // will be set when used
1511 ED_COUNTER_ID_ELEMENT_VALUE4,
1512 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1513 MIN_SCORE, MAX_SCORE,
1514 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1515 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1516 NULL, // will be set when used
1520 ED_COUNTER_ID_YAMYAM_CONTENT,
1521 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1522 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1523 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1524 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1525 &level.num_yamyam_contents,
1526 NULL, NULL, "number of content areas"
1529 ED_COUNTER_ID_BALL_CONTENT,
1530 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1531 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1532 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1533 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1534 &level.num_ball_contents,
1535 NULL, NULL, "number of content areas"
1538 ED_COUNTER_ID_ANDROID_CONTENT,
1539 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1540 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1541 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1542 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1543 &level.num_android_clone_elements,
1544 NULL, NULL, "number of clonable elements"
1547 ED_COUNTER_ID_ENVELOPE_XSIZE,
1548 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1549 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1550 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1551 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1552 NULL, // will be set when used
1553 NULL, NULL, "width",
1556 ED_COUNTER_ID_ENVELOPE_YSIZE,
1557 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1558 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1559 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1560 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1561 NULL, // will be set when used
1562 NULL, " ", "height",
1565 ED_COUNTER_ID_INVENTORY_SIZE,
1566 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1567 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1568 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1569 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1570 &level.initial_inventory_size[0],
1571 NULL, NULL, "number of inventory elements"
1574 ED_COUNTER_ID_MM_BALL_CONTENT,
1575 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1576 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1577 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1578 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1579 &level.num_mm_ball_contents,
1580 NULL, NULL, "number of content elements"
1583 // ---------- element settings: configure 1 (custom elements) ---------------
1586 ED_COUNTER_ID_CUSTOM_SCORE,
1587 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1588 MIN_SCORE, MAX_SCORE,
1589 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1590 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1591 &custom_element.collect_score_initial,
1592 NULL, "CE score", " "
1595 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
1596 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1597 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1598 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1599 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1600 &custom_element.collect_count_initial,
1601 NULL, "CE count", NULL
1604 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
1605 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1607 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1608 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1609 &custom_element.ce_value_fixed_initial,
1610 NULL, "CE value", NULL
1613 ED_COUNTER_ID_CUSTOM_VALUE_RND,
1614 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1616 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1617 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1618 &custom_element.ce_value_random_initial,
1619 NULL, "+random", NULL
1622 ED_COUNTER_ID_PUSH_DELAY_FIX,
1623 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1625 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1626 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1627 &custom_element.push_delay_fixed,
1628 NULL, "push delay", NULL
1631 ED_COUNTER_ID_PUSH_DELAY_RND,
1632 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1634 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1635 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1636 &custom_element.push_delay_random,
1637 NULL, "+random", NULL
1640 ED_COUNTER_ID_DROP_DELAY_FIX,
1641 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1643 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1644 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1645 &custom_element.drop_delay_fixed,
1646 NULL, "drop delay", NULL
1649 ED_COUNTER_ID_DROP_DELAY_RND,
1650 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1652 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1653 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1654 &custom_element.drop_delay_random,
1655 NULL, "+random", NULL
1658 // ---------- element settings: configure 2 (custom elements) ---------------
1661 ED_COUNTER_ID_MOVE_DELAY_FIX,
1662 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1664 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1665 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1666 &custom_element.move_delay_fixed,
1667 NULL, "move delay", NULL
1670 ED_COUNTER_ID_MOVE_DELAY_RND,
1671 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1673 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1674 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1675 &custom_element.move_delay_random,
1676 NULL, "+random", NULL
1679 ED_COUNTER_ID_STEP_DELAY_FIX,
1680 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1682 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1683 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1684 &custom_element.step_delay_fixed,
1685 NULL, "step delay", NULL
1688 ED_COUNTER_ID_STEP_DELAY_RND,
1689 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1691 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1692 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1693 &custom_element.step_delay_random,
1694 NULL, "+random", NULL
1697 ED_COUNTER_ID_EXPLOSION_DELAY,
1698 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1700 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1701 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1702 &custom_element.explosion_delay,
1703 NULL, "explosion delay", NULL
1706 ED_COUNTER_ID_IGNITION_DELAY,
1707 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1709 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1710 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1711 &custom_element.ignition_delay,
1712 NULL, "ignition delay", "(by fire)"
1715 // ---------- element settings: configure (group elements) ------------------
1718 ED_COUNTER_ID_GROUP_CONTENT,
1719 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1720 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1721 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1722 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1723 &group_element_info.num_elements,
1724 NULL, NULL, "number of elements in group"
1727 // ---------- element settings: advanced (custom elements) ------------------
1730 ED_COUNTER_ID_CHANGE_DELAY_FIX,
1731 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1733 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1734 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1735 &custom_element_change.delay_fixed,
1736 NULL, "CE delay", NULL,
1739 ED_COUNTER_ID_CHANGE_DELAY_RND,
1740 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1742 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1743 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1744 &custom_element_change.delay_random,
1745 NULL, "+random", NULL
1748 ED_COUNTER_ID_CHANGE_CONT_RND,
1749 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1751 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1752 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1753 &custom_element_change.random_percentage,
1754 NULL, "use random replace:", "%"
1765 char *text_above, *infotext;
1766 } textinput_info[ED_NUM_TEXTINPUT] =
1769 ED_TEXTINPUT_ID_LEVEL_NAME,
1770 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1771 GADGET_ID_LEVEL_NAME,
1774 "Title:", "Title for this level"
1777 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
1778 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1779 GADGET_ID_LEVEL_AUTHOR,
1780 MAX_LEVEL_AUTHOR_LEN,
1782 "Author:", "Author for this level"
1785 ED_TEXTINPUT_ID_LEVELSET_NAME,
1786 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1787 GADGET_ID_LEVELSET_NAME,
1790 "Title:", "Title for this or new level set"
1793 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
1794 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1795 GADGET_ID_LEVELSET_AUTHOR,
1796 MAX_LEVEL_AUTHOR_LEN,
1798 "Author:", "Author for this or new level set"
1801 ED_TEXTINPUT_ID_ELEMENT_NAME,
1802 -1, -1, // these values are not constant, but can change at runtime
1803 GADGET_ID_ELEMENT_NAME,
1804 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1805 custom_element.description,
1806 NULL, "Element name"
1817 char *text_above, *text_above_cropped, *infotext;
1818 } textarea_info[ED_NUM_TEXTAREAS] =
1821 ED_TEXTAREA_ID_ENVELOPE_INFO,
1822 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1823 GADGET_ID_ENVELOPE_INFO,
1824 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1826 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1830 static struct ValueTextInfo options_time_or_steps[] =
1838 static struct ValueTextInfo options_time_score_base[] =
1840 { 1, "per second/step" },
1841 { 10, "per 10 seconds/steps" },
1846 static struct ValueTextInfo options_game_engine_type[] =
1848 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1849 { GAME_ENGINE_TYPE_BD, "Boulder Dash" },
1850 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1851 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1852 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1857 static struct ValueTextInfo options_levelset_save_mode[] =
1859 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1860 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1865 static struct ValueTextInfo options_wind_direction[] =
1867 { MV_START_NONE, "none" },
1868 { MV_START_LEFT, "left" },
1869 { MV_START_RIGHT, "right" },
1870 { MV_START_UP, "up" },
1871 { MV_START_DOWN, "down" },
1876 static struct ValueTextInfo options_player_speed[] =
1883 { 16, "very fast" },
1884 { 32, "ultrafast" },
1889 static struct ValueTextInfo options_access_type[] =
1891 { EP_WALKABLE, "walkable" },
1892 { EP_PASSABLE, "passable" },
1897 static struct ValueTextInfo options_access_layer[] =
1899 { EP_ACCESSIBLE_OVER, "over" },
1900 { EP_ACCESSIBLE_INSIDE, "inside" },
1901 { EP_ACCESSIBLE_UNDER, "under" },
1906 static struct ValueTextInfo options_access_protected[] =
1908 { 0, "unprotected" },
1914 static struct ValueTextInfo options_access_direction[] =
1916 { MV_NO_DIRECTION, "no direction" },
1917 { MV_LEFT, "left" },
1918 { MV_RIGHT, "right" },
1920 { MV_DOWN, "down" },
1921 { MV_LEFT | MV_UP, "left + up" },
1922 { MV_LEFT | MV_DOWN, "left + down" },
1923 { MV_RIGHT | MV_UP, "right + up" },
1924 { MV_RIGHT | MV_DOWN, "right + down" },
1925 { MV_HORIZONTAL, "horizontal" },
1926 { MV_VERTICAL, "vertical" },
1927 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1928 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1929 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1930 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1931 { MV_ALL_DIRECTIONS, "all directions" },
1936 static struct ValueTextInfo options_walk_to_action[] =
1938 { EP_DIGGABLE, "diggable" },
1939 { EP_COLLECTIBLE_ONLY, "collectible" },
1940 { EP_DROPPABLE, "collectible & droppable" },
1941 { EP_THROWABLE, "collectible & throwable" },
1942 { EP_PUSHABLE, "pushable" },
1947 static struct ValueTextInfo options_move_pattern[] =
1949 { MV_LEFT, "left" },
1950 { MV_RIGHT, "right" },
1952 { MV_DOWN, "down" },
1953 { MV_HORIZONTAL, "horizontal" },
1954 { MV_VERTICAL, "vertical" },
1955 { MV_ALL_DIRECTIONS, "all directions" },
1956 { MV_WIND_DIRECTION, "wind direction" },
1957 { MV_TOWARDS_PLAYER, "towards player" },
1958 { MV_AWAY_FROM_PLAYER, "away from player" },
1959 { MV_ALONG_LEFT_SIDE, "along left side" },
1960 { MV_ALONG_RIGHT_SIDE, "along right side" },
1961 { MV_TURNING_LEFT, "turning left" },
1962 { MV_TURNING_RIGHT, "turning right" },
1963 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1964 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1965 { MV_TURNING_RANDOM, "turning random" },
1966 { MV_MAZE_RUNNER, "maze runner style" },
1967 { MV_MAZE_HUNTER, "maze hunter style" },
1968 { MV_WHEN_PUSHED, "when pushed" },
1969 { MV_WHEN_DROPPED, "when dropped/thrown" },
1974 static struct ValueTextInfo options_move_direction[] =
1976 { MV_START_AUTOMATIC, "automatic" },
1977 { MV_START_LEFT, "left" },
1978 { MV_START_RIGHT, "right" },
1979 { MV_START_UP, "up" },
1980 { MV_START_DOWN, "down" },
1981 { MV_START_RANDOM, "random" },
1982 { MV_START_PREVIOUS, "previous" },
1987 static struct ValueTextInfo options_move_stepsize[] =
1989 { 0, "not moving" },
1994 { 16, "very fast" },
1995 { 32, "even faster" },
2000 static struct ValueTextInfo options_move_leave_type[] =
2002 { LEAVE_TYPE_UNLIMITED, "leave behind" },
2003 { LEAVE_TYPE_LIMITED, "change it to" },
2008 static struct ValueTextInfo options_smash_targets[] =
2010 { EP_CAN_SMASH_PLAYER, "player" },
2012 { EP_CAN_SMASH_ENEMIES, "enemies" },
2014 { EP_CAN_SMASH_EVERYTHING, "everything" },
2019 static struct ValueTextInfo options_slippery_type[] =
2021 { SLIPPERY_ANY_RANDOM, "random" },
2022 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
2023 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
2024 { SLIPPERY_ONLY_LEFT, "only left" },
2025 { SLIPPERY_ONLY_RIGHT, "only right" },
2030 static struct ValueTextInfo options_deadliness[] =
2032 { EP_DONT_RUN_INTO, "running into" },
2033 { EP_DONT_COLLIDE_WITH, "colliding with" },
2034 { EP_DONT_GET_HIT_BY, "getting hit by" },
2035 { EP_DONT_TOUCH, "touching" },
2040 static struct ValueTextInfo options_explosion_type[] =
2042 { EXPLODES_3X3, "3x3" },
2043 { EXPLODES_CROSS, "3+3" },
2044 { EXPLODES_1X1, "1x1" },
2049 static struct ValueTextInfo options_time_units[] =
2052 { FRAMES_PER_SECOND, "seconds" },
2057 static struct ValueTextInfo options_change_direct_action[] =
2059 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2060 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2061 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2062 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2063 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2064 { CE_ENTERED_BY_PLAYER, "entered by player" },
2065 { CE_LEFT_BY_PLAYER, "left by player" },
2066 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2067 { CE_SWITCHED, "switched" },
2068 { CE_HITTING_SOMETHING, "hitting something" },
2069 { CE_HIT_BY_SOMETHING, "hit by something" },
2071 { CE_BLOCKED, "blocked" },
2073 { CE_IMPACT, "impact (on something)" },
2074 { CE_SMASHED, "smashed (from above)" },
2076 { CE_VALUE_CHANGES, "CE value changes" },
2077 { CE_SCORE_CHANGES, "CE score changes" },
2079 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2080 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2081 { CE_UNDEFINED, " " },
2082 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2083 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2084 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2085 { CE_UNDEFINED, " " },
2086 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2087 { CE_NEXT_TO_PLAYER, "next to player" },
2092 static struct ValueTextInfo options_change_other_action[] =
2094 { CE_PLAYER_TOUCHES_X, "player touches" },
2095 { CE_PLAYER_PRESSES_X, "player presses" },
2096 { CE_PLAYER_SWITCHES_X, "player switches" },
2097 { CE_PLAYER_SNAPS_X, "player snaps" },
2098 { CE_PLAYER_PUSHES_X, "player pushes" },
2099 { CE_PLAYER_ENTERS_X, "player enters" },
2100 { CE_PLAYER_LEAVES_X, "player leaves" },
2101 { CE_PLAYER_DIGS_X, "player digs" },
2102 { CE_PLAYER_COLLECTS_X, "player collects" },
2103 { CE_PLAYER_DROPS_X, "player drops/throws" },
2104 { CE_TOUCHING_X, "touching" },
2105 { CE_HITTING_X, "hitting" },
2106 { CE_DIGGING_X, "digging" },
2107 { CE_HIT_BY_X, "hit by" },
2108 { CE_SWITCH_OF_X, "switch of" },
2109 { CE_CHANGE_OF_X, "change by page of" },
2110 { CE_EXPLOSION_OF_X, "explosion of" },
2111 { CE_MOVE_OF_X, "move of" },
2112 { CE_CREATION_OF_X, "creation of" },
2113 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2114 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2115 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2116 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2117 { CE_UNDEFINED, " " },
2118 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2119 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2120 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2121 { CE_UNDEFINED, " " },
2122 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2123 { CE_PLAYER_NEXT_TO_X, "player next to" },
2124 { CE_NEXT_TO_X, "next to" },
2129 static struct ValueTextInfo options_change_trigger_side[] =
2131 { CH_SIDE_LEFT, "left" },
2132 { CH_SIDE_RIGHT, "right" },
2133 { CH_SIDE_TOP, "top" },
2134 { CH_SIDE_BOTTOM, "bottom" },
2135 { CH_SIDE_LEFT_RIGHT, "left/right" },
2136 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2137 { CH_SIDE_ANY, "any" },
2142 static struct ValueTextInfo options_change_trigger_player[] =
2144 { CH_PLAYER_1, "1" },
2145 { CH_PLAYER_2, "2" },
2146 { CH_PLAYER_3, "3" },
2147 { CH_PLAYER_4, "4" },
2148 { CH_PLAYER_ANY, "any" },
2153 static struct ValueTextInfo options_change_trigger_page[] =
2164 { (1u << 9), "10" },
2165 { (1u << 10), "11" },
2166 { (1u << 11), "12" },
2167 { (1u << 12), "13" },
2168 { (1u << 13), "14" },
2169 { (1u << 14), "15" },
2170 { (1u << 15), "16" },
2171 { (1u << 16), "17" },
2172 { (1u << 17), "18" },
2173 { (1u << 18), "19" },
2174 { (1u << 19), "20" },
2175 { (1u << 20), "21" },
2176 { (1u << 21), "22" },
2177 { (1u << 22), "23" },
2178 { (1u << 23), "24" },
2179 { (1u << 24), "25" },
2180 { (1u << 25), "26" },
2181 { (1u << 26), "27" },
2182 { (1u << 27), "28" },
2183 { (1u << 28), "29" },
2184 { (1u << 29), "30" },
2185 { (1u << 30), "31" },
2186 { (1u << 31), "32" },
2187 { CH_PAGE_ANY, "any" },
2192 static struct ValueTextInfo options_change_replace_when[] =
2194 { CP_WHEN_EMPTY, "empty" },
2195 { CP_WHEN_WALKABLE, "walkable" },
2196 { CP_WHEN_DIGGABLE, "diggable" },
2197 { CP_WHEN_COLLECTIBLE, "collectible" },
2198 { CP_WHEN_REMOVABLE, "removable" },
2199 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2204 static struct ValueTextInfo options_action_type[] =
2206 { CA_NO_ACTION, "no action" },
2207 { CA_UNDEFINED, " " },
2208 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2209 { CA_RESTART_LEVEL, "restart level" },
2210 { CA_SHOW_ENVELOPE, "show envelope" },
2211 { CA_SET_LEVEL_TIME, "set time" },
2212 { CA_SET_LEVEL_SCORE, "set score" },
2213 { CA_SET_LEVEL_GEMS, "set gems" },
2214 { CA_SET_LEVEL_WIND, "set wind dir." },
2215 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2216 { CA_UNDEFINED, " " },
2217 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2218 { CA_MOVE_PLAYER, "move player" },
2219 { CA_MOVE_PLAYER_NEW, "move player new" },
2220 { CA_EXIT_PLAYER, "exit player" },
2221 { CA_KILL_PLAYER, "kill player" },
2222 { CA_SET_PLAYER_KEYS, "set keys" },
2223 { CA_SET_PLAYER_SPEED, "set speed" },
2224 { CA_SET_PLAYER_SHIELD, "set shield" },
2225 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2226 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2227 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2228 { CA_UNDEFINED, " " },
2229 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2230 { CA_SET_CE_VALUE, "set CE value" },
2231 { CA_SET_CE_SCORE, "set CE score" },
2232 { CA_SET_CE_ARTWORK, "set CE artwork" },
2233 { CA_UNDEFINED, " " },
2234 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2235 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2240 static struct ValueTextInfo options_action_mode_none[] =
2242 { CA_MODE_UNDEFINED, " " },
2247 static struct ValueTextInfo options_action_mode_assign[] =
2249 { CA_MODE_SET, "=" },
2254 static struct ValueTextInfo options_action_mode_add_remove[] =
2256 { CA_MODE_ADD, "+" },
2257 { CA_MODE_SUBTRACT, "-" },
2262 static struct ValueTextInfo options_action_mode_calculate[] =
2264 { CA_MODE_SET, "=" },
2265 { CA_MODE_ADD, "+" },
2266 { CA_MODE_SUBTRACT, "-" },
2267 { CA_MODE_MULTIPLY, "*" },
2268 { CA_MODE_DIVIDE, "/" },
2269 { CA_MODE_MODULO, "%" },
2274 static struct ValueTextInfo options_action_arg_none[] =
2276 { CA_ARG_UNDEFINED, " " },
2281 static struct ValueTextInfo options_action_arg_player[] =
2283 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2284 { CA_ARG_PLAYER_1, "1" },
2285 { CA_ARG_PLAYER_2, "2" },
2286 { CA_ARG_PLAYER_3, "3" },
2287 { CA_ARG_PLAYER_4, "4" },
2288 { CA_ARG_PLAYER_ANY, "any" },
2289 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2290 { CA_ARG_PLAYER_ACTION, "action ->" },
2295 static struct ValueTextInfo options_action_arg_number[] =
2297 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2304 { CA_ARG_10, "10" },
2305 { CA_ARG_100, "100" },
2306 { CA_ARG_1000, "1000" },
2307 { CA_ARG_UNDEFINED, " " },
2308 { CA_ARG_NUMBER_MIN, "min" },
2309 { CA_ARG_NUMBER_MAX, "max" },
2310 { CA_ARG_UNDEFINED, " " },
2311 { CA_ARG_NUMBER_RESET, "reset" },
2312 { CA_ARG_UNDEFINED, " " },
2313 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2314 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2315 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2316 { CA_ARG_UNDEFINED, " " },
2317 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2318 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2319 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2320 { CA_ARG_UNDEFINED, " " },
2321 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2322 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2323 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2324 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2325 { CA_ARG_UNDEFINED, " " },
2326 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2327 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2328 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2329 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2334 static struct ValueTextInfo options_action_arg_value[] =
2336 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2343 { CA_ARG_10, "10" },
2344 { CA_ARG_100, "100" },
2345 { CA_ARG_1000, "1000" },
2346 { CA_ARG_UNDEFINED, " " },
2347 { CA_ARG_NUMBER_MIN, "min" },
2348 { CA_ARG_NUMBER_MAX, "max" },
2349 { CA_ARG_UNDEFINED, " " },
2350 { CA_ARG_NUMBER_RESET, "reset" },
2351 { CA_ARG_UNDEFINED, " " },
2352 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2353 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2354 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2355 { CA_ARG_UNDEFINED, " " },
2356 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2357 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2358 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2359 { CA_ARG_UNDEFINED, " " },
2360 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2361 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2362 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2363 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2364 { CA_ARG_UNDEFINED, " " },
2365 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2366 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2367 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2368 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2369 { CA_ARG_UNDEFINED, " " },
2370 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2371 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2372 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2373 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2378 static struct ValueTextInfo options_action_arg_envelope[] =
2380 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2385 { CA_ARG_UNDEFINED, " " },
2386 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2387 { CA_ARG_ELEMENT_TARGET, "target" },
2388 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2389 { CA_ARG_ELEMENT_ACTION, "action ->" },
2394 static struct ValueTextInfo options_action_arg_key[] =
2396 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2405 { CA_ARG_UNDEFINED, " " },
2406 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2407 { CA_ARG_ELEMENT_TARGET, "target" },
2408 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2409 { CA_ARG_ELEMENT_ACTION, "action ->" },
2414 static struct ValueTextInfo options_action_arg_speed[] =
2416 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2417 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2418 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2419 { CA_ARG_SPEED_SLOW, "slow" },
2420 { CA_ARG_SPEED_NORMAL, "normal" },
2421 { CA_ARG_SPEED_FAST, "fast" },
2422 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2423 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2424 { CA_ARG_UNDEFINED, " " },
2425 { CA_ARG_SPEED_SLOWER, "slower" },
2426 { CA_ARG_SPEED_FASTER, "faster" },
2427 { CA_ARG_UNDEFINED, " " },
2428 { CA_ARG_SPEED_RESET, "reset" },
2433 static struct ValueTextInfo options_action_arg_shield[] =
2435 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2436 { CA_ARG_SHIELD_OFF, "off" },
2437 { CA_ARG_SHIELD_NORMAL, "normal" },
2438 { CA_ARG_SHIELD_DEADLY, "deadly" },
2443 static struct ValueTextInfo options_action_arg_artwork[] =
2445 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2446 { CA_ARG_ELEMENT_TARGET, "target" },
2447 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2448 { CA_ARG_ELEMENT_ACTION, "action ->" },
2449 { CA_ARG_UNDEFINED, " " },
2450 { CA_ARG_ELEMENT_RESET, "reset" },
2455 static struct ValueTextInfo options_action_arg_gravity[] =
2457 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2458 { CA_ARG_GRAVITY_ON, "on" },
2459 { CA_ARG_GRAVITY_OFF, "off" },
2460 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2465 static struct ValueTextInfo options_action_arg_direction[] =
2467 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2468 { CA_ARG_DIRECTION_NONE, "none" },
2469 { CA_ARG_DIRECTION_LEFT, "left" },
2470 { CA_ARG_DIRECTION_RIGHT, "right" },
2471 { CA_ARG_DIRECTION_UP, "up" },
2472 { CA_ARG_DIRECTION_DOWN, "down" },
2473 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2474 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2479 static struct ValueTextInfo options_action_arg_scan_mode[] =
2481 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2482 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2483 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2488 static struct ValueTextInfo options_action_arg_inventory[] =
2490 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2491 { CA_ARG_ELEMENT_TARGET, "+ target" },
2492 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2493 { CA_ARG_ELEMENT_ACTION, "+ action" },
2494 { CA_ARG_UNDEFINED, " " },
2495 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2496 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2497 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2498 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2499 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2500 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2501 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2502 { CA_ARG_UNDEFINED, " " },
2503 { CA_ARG_INVENTORY_RESET, "reset" },
2508 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2509 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2514 static struct ValueTextInfo options_group_choice_mode[] =
2516 { ANIM_RANDOM, "random" },
2517 { ANIM_LOOP, "loop" },
2518 { ANIM_LINEAR, "linear" },
2519 { ANIM_PINGPONG, "pingpong" },
2520 { ANIM_PINGPONG2, "pingpong 2" },
2521 { ANIM_LEVEL_NR, "level number" },
2526 static struct ValueTextInfo *action_arg_modes[] =
2528 options_action_mode_none,
2529 options_action_mode_assign,
2530 options_action_mode_add_remove,
2531 options_action_mode_calculate,
2538 struct ValueTextInfo *options;
2540 action_arg_options[] =
2542 { CA_NO_ACTION, 0, options_action_arg_none, },
2543 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2544 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2545 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2546 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2547 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2548 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2549 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2550 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2551 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2552 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2553 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2554 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2555 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2556 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2557 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2558 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2559 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2560 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2561 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2562 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2563 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2573 int gadget_id_align;
2574 int size; // char size of selectbox or '-1' (dynamically determined)
2575 struct ValueTextInfo *options;
2577 char *text_above, *text_left, *text_right, *infotext;
2578 } selectbox_info[ED_NUM_SELECTBOX] =
2580 // ---------- level and editor settings -------------------------------------
2583 ED_SELECTBOX_ID_TIME_OR_STEPS,
2584 -1, ED_LEVEL_SETTINGS_YPOS(8),
2585 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2587 options_time_or_steps,
2588 &level.use_step_counter,
2589 NULL, NULL, "(0 => no limit)", "time or step limit"
2592 ED_SELECTBOX_ID_TIME_SCORE_BASE,
2593 -1, ED_LEVEL_SETTINGS_YPOS(10),
2594 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2596 options_time_score_base,
2597 &level.time_score_base,
2598 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2601 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
2602 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2603 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2605 options_game_engine_type,
2606 &level.game_engine_type,
2607 NULL, "game engine:", NULL, "game engine"
2610 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
2611 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2612 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2614 options_levelset_save_mode,
2615 &levelset_save_mode,
2616 "Action:", NULL, NULL, "action when saving level set"
2619 // ---------- element settings: configure (several elements) ----------------
2622 ED_SELECTBOX_ID_WIND_DIRECTION,
2623 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2624 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2626 options_wind_direction,
2627 &level.wind_direction_initial,
2628 NULL, "initial wind direction:", NULL, "initial wind direction"
2631 ED_SELECTBOX_ID_PLAYER_SPEED,
2632 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2633 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2635 options_player_speed,
2636 &level.initial_player_stepsize[0],
2637 NULL, "initial player speed:", NULL, "initial player speed"
2640 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
2641 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2642 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2644 options_group_choice_mode,
2645 &level.mm_ball_choice_mode,
2646 NULL, "choice type:", NULL, "type of content choice"
2649 // ---------- element settings: configure 1 (custom elements) ---------------
2652 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
2653 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2654 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2656 options_access_type,
2657 &custom_element.access_type,
2658 NULL, NULL, NULL, "type of access to this field"
2661 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
2662 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2663 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2665 options_access_layer,
2666 &custom_element.access_layer,
2667 NULL, NULL, NULL, "layer of access for this field"
2670 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
2671 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2672 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2674 options_access_protected,
2675 &custom_element.access_protected,
2676 NULL, NULL, NULL, "protected access for this field"
2679 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
2680 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2681 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2683 options_access_direction,
2684 &custom_element.access_direction,
2685 NULL, "from", NULL, "access direction for this field"
2688 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
2689 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2690 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2692 options_walk_to_action,
2693 &custom_element.walk_to_action,
2694 NULL, NULL, NULL, "diggable/collectible/pushable"
2697 // ---------- element settings: configure 2 (custom elements) ---------------
2700 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
2701 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2702 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2704 options_move_pattern,
2705 &custom_element.move_pattern,
2706 NULL, "can move", NULL, "element move pattern"
2709 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
2710 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2711 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2713 options_move_direction,
2714 &custom_element.move_direction_initial,
2715 NULL, "starts moving", NULL, "initial element move direction"
2718 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
2719 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2720 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2722 options_move_stepsize,
2723 &custom_element.move_stepsize,
2724 NULL, "move/fall speed", NULL, "speed of element movement"
2727 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
2728 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2729 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2731 options_move_leave_type,
2732 &custom_element.move_leave_type,
2733 // left text with leading spaces to place gadget next to "can dig" gadget
2734 // (needed because drawing area gadgets created after selectbox gadgets)
2735 // NULL, "can dig: can", ":", "leave behind or change element"
2736 NULL, " can", ":", "leave behind or change element"
2739 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
2740 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2741 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2743 options_smash_targets,
2744 &custom_element.smash_targets,
2745 NULL, "can smash", NULL, "elements that can be smashed"
2748 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
2749 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2750 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2752 options_slippery_type,
2753 &custom_element.slippery_type,
2754 NULL, "slippery", NULL, "where other elements fall down"
2757 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
2758 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2759 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2762 &custom_element.deadliness,
2763 NULL, "deadly when", NULL, "deadliness of element"
2766 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
2767 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2768 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2770 options_explosion_type,
2771 &custom_element.explosion_type,
2772 NULL, "can explode", NULL, "explosion type"
2775 // ---------- element settings: advanced (custom elements) ------------------
2778 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
2779 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2780 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2783 &custom_element_change.delay_frames,
2784 NULL, "delay time given in", NULL, "delay time units for change"
2787 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
2788 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2789 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2791 options_change_direct_action,
2792 &custom_element_change.direct_action,
2793 NULL, NULL, NULL, "type of direct action"
2796 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
2797 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2798 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2800 options_change_other_action,
2801 &custom_element_change.other_action,
2802 NULL, NULL, "element:", "type of other element action"
2805 ED_SELECTBOX_ID_CHANGE_SIDE,
2806 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2807 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2809 options_change_trigger_side,
2810 &custom_element_change.trigger_side,
2811 NULL, "at", "side", "element side triggering change"
2814 ED_SELECTBOX_ID_CHANGE_PLAYER,
2815 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2816 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2818 options_change_trigger_player,
2819 &custom_element_change.trigger_player,
2820 NULL, "player:", " ", "player that causes change"
2823 ED_SELECTBOX_ID_CHANGE_PAGE,
2824 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2825 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2827 options_change_trigger_page,
2828 &custom_element_change.trigger_page,
2829 NULL, "page:", NULL, "change page that causes change"
2832 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
2833 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2834 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2836 options_change_replace_when,
2837 &custom_element_change.replace_when,
2838 NULL, "replace when", NULL, "which elements can be replaced"
2841 ED_SELECTBOX_ID_ACTION_TYPE,
2842 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2843 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2845 options_action_type,
2846 &custom_element_change.action_type,
2847 NULL, NULL, NULL, "action on specified condition"
2850 ED_SELECTBOX_ID_ACTION_MODE,
2851 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2852 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2854 options_action_mode_none,
2855 &custom_element_change.action_mode,
2856 NULL, NULL, NULL, "action operator"
2859 ED_SELECTBOX_ID_ACTION_ARG,
2860 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2861 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2863 options_action_arg_none,
2864 &custom_element_change.action_arg,
2865 NULL, NULL, NULL, "action parameter"
2868 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
2869 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2870 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2872 options_change_page,
2873 &custom_element.current_change_page,
2874 NULL, NULL, NULL, "element change page"
2877 // ---------- element settings: configure (group elements) ------------------
2880 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
2881 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2882 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2884 options_group_choice_mode,
2885 &group_element_info.choice_mode,
2886 NULL, "choice type:", NULL, "type of group element choice"
2895 int gadget_id_align;
2898 char *text_above, *text_left, *text_right, *infotext;
2899 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2901 // ---------- level and editor settings (tabs) ------------------------------
2904 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
2905 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2906 GADGET_ID_LEVELCONFIG_LEVEL, GADGET_ID_NONE,
2908 NULL, NULL, NULL, "Configure level settings"
2911 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
2913 GADGET_ID_LEVELCONFIG_LEVELSET, GADGET_ID_LEVELCONFIG_LEVEL,
2915 NULL, NULL, NULL, "Update this or create new level set"
2918 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
2920 GADGET_ID_LEVELCONFIG_EDITOR, GADGET_ID_LEVELCONFIG_LEVELSET,
2922 NULL, NULL, NULL, "Configure editor settings"
2925 ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE,
2927 GADGET_ID_LEVELCONFIG_ENGINE, GADGET_ID_LEVELCONFIG_EDITOR,
2929 NULL, NULL, NULL, "Configure engine settings"
2932 // ---------- element settings (tabs) ---------------------------------------
2935 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
2936 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2937 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2939 NULL, NULL, NULL, "Show information about element"
2942 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
2944 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2946 NULL, NULL, NULL, "Configure element properties"
2949 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
2951 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2953 NULL, NULL, NULL, "Configure element properties, part 1"
2956 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
2958 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2960 NULL, NULL, NULL, "Configure element properties, part 2"
2963 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
2965 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2967 NULL, NULL, NULL, "Configure custom element change pages"
2970 // ---------- level and editor settings (buttons) ---------------------------
2973 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
2974 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2975 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
2977 NULL, NULL, NULL, "Update or create level set"
2980 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
2981 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2982 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2984 NULL, NULL, "this level as level template",
2985 "Save current settings as new template"
2988 // ---------- element settings (buttons) ------------------------------------
2991 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
2993 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2995 NULL, " ", "As Template",
2996 "Save current settings as new template"
2999 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
3001 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
3003 NULL, NULL, NULL, "Add new change page"
3006 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
3008 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
3010 NULL, NULL, NULL, "Delete current change page"
3020 int gadget_id_align;
3021 char *text_left, *text_right, *infotext;
3022 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
3025 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
3026 IMG_EDITOR_COUNTER_DOWN,
3027 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3028 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
3029 NULL, NULL, "select previous change page"
3032 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
3033 IMG_EDITOR_COUNTER_UP,
3034 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3035 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
3036 NULL, "change page", "select next change page"
3039 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
3040 IMG_GFX_EDITOR_BUTTON_CP_COPY,
3041 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3042 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
3043 " ", NULL, "copy settings from this change page"
3046 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
3047 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
3048 -1, ED_ELEMENT_SETTINGS_YPOS(14),
3049 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
3050 NULL, NULL, "paste settings to this change page"
3057 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
3065 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
3068 ED_SCROLLBUTTON_ID_AREA_UP,
3069 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
3070 GADGET_ID_SCROLL_UP,
3071 "scroll level editing area up"
3074 ED_SCROLLBUTTON_ID_AREA_DOWN,
3075 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
3076 GADGET_ID_SCROLL_DOWN,
3077 "scroll level editing area down"
3080 ED_SCROLLBUTTON_ID_AREA_LEFT,
3081 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
3082 GADGET_ID_SCROLL_LEFT,
3083 "scroll level editing area left"
3086 ED_SCROLLBUTTON_ID_AREA_RIGHT,
3087 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
3088 GADGET_ID_SCROLL_RIGHT,
3089 "scroll level editing area right"
3092 ED_SCROLLBUTTON_ID_LIST_UP,
3093 IMG_EDITOR_PALETTE_SCROLL_UP,
3094 GADGET_ID_SCROLL_LIST_UP,
3095 "scroll element list up ('Page Up')"
3098 ED_SCROLLBUTTON_ID_LIST_DOWN,
3099 IMG_EDITOR_PALETTE_SCROLL_DOWN,
3100 GADGET_ID_SCROLL_LIST_DOWN,
3101 "scroll element list down ('Page Down')"
3109 int wheel_x, wheel_y;
3110 int wheel_width, wheel_height;
3111 } scrollbar_pos[ED_NUM_SCROLLBARS];
3120 } scrollbar_info[ED_NUM_SCROLLBARS] =
3123 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
3124 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3125 GD_TYPE_SCROLLBAR_HORIZONTAL,
3126 GADGET_ID_SCROLL_HORIZONTAL,
3127 "scroll level editing area horizontally"
3130 ED_SCROLLBAR_ID_AREA_VERTICAL,
3131 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3132 GD_TYPE_SCROLLBAR_VERTICAL,
3133 GADGET_ID_SCROLL_VERTICAL,
3134 "scroll level editing area vertically"
3137 ED_SCROLLBAR_ID_LIST_VERTICAL,
3138 IMG_EDITOR_PALETTE_SCROLLBAR,
3139 GD_TYPE_SCROLLBAR_VERTICAL,
3140 GADGET_ID_SCROLL_LIST_VERTICAL,
3141 "scroll element list vertically"
3151 int gadget_id_align;
3152 int radio_button_nr;
3155 char *text_left, *text_right, *infotext;
3156 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3159 ED_RADIOBUTTON_ID_PERCENTAGE,
3160 -1, ED_LEVEL_SETTINGS_YPOS(0),
3161 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3162 RADIO_NR_RANDOM_ELEMENTS,
3163 &random_placement_method, RANDOM_USE_PERCENTAGE,
3164 " ", "percentage", "use percentage for random elements"
3167 ED_RADIOBUTTON_ID_QUANTITY,
3168 -1, ED_LEVEL_SETTINGS_YPOS(0),
3169 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3170 RADIO_NR_RANDOM_ELEMENTS,
3171 &random_placement_method, RANDOM_USE_QUANTITY,
3172 " ", "quantity", "use quantity for random elements"
3181 int gadget_id_align;
3183 char *text_above, *text_left, *text_right, *infotext;
3184 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3186 // ---------- level and editor settings -------------------------------------
3189 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
3190 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3191 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3192 &level.auto_count_gems,
3194 "automatically count gems needed", "set counter to number of gems"
3197 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
3198 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3199 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3200 &level.rate_time_over_score,
3202 "rate time/steps used over score", "sort high scores by playing time/steps"
3205 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
3206 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3207 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3208 &levelset_use_levelset_artwork,
3210 "use current custom artwork", "use custom artwork of this level set"
3213 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
3214 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3215 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3216 &levelset_copy_level_template,
3218 "copy current level template", "copy level template of this level set"
3221 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
3222 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3223 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3224 &random_placement_background_restricted,
3226 "restrict random placement to:", "set random placement restriction"
3229 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
3230 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3231 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3232 &setup.editor.use_template_for_new_levels,
3233 "Template for new levels and CE/GE:", NULL,
3234 "use template for new levels", "use template for level properties"
3237 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
3238 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3239 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3240 &level.use_custom_template,
3242 "use template for custom elements", "use template for custom properties"
3245 // ---------- element settings: configure (various elements) ----------------
3248 ED_CHECKBUTTON_ID_STICK_ELEMENT,
3249 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3250 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3251 &stick_element_properties_window,
3253 "stick this screen to edit content","stick this screen to edit content"
3256 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
3257 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3258 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3259 &level.em_slippery_gems,
3261 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3264 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
3265 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3266 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3267 &level.em_explodes_by_fire,
3269 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3272 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
3273 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3274 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3275 &level.use_spring_bug,
3277 "use spring pushing bug", "use odd spring pushing behaviour"
3280 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
3281 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3282 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3283 &level.use_time_orb_bug,
3285 "use time orb bug", "use odd time orb behaviour"
3288 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
3289 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3290 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3291 &level.use_life_bugs,
3293 "use buggy element behaviour", "use odd (historic) element behaviour"
3296 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
3297 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3298 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3301 "create single random element", "only create one element from content"
3304 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
3305 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3306 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3307 &level.ball_active_initial,
3309 "magic ball initially activated", "activate magic ball after level start"
3312 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
3313 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3314 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3315 &level.grow_into_diggable,
3317 "can grow into anything diggable", "grow into more than just sand"
3320 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
3321 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3322 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3323 &level.sb_fields_needed,
3325 "all fields need to be filled", "require all SB fields to be solved"
3328 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
3329 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3330 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3331 &level.sb_objects_needed,
3333 "all objects need to be placed", "require all SB objects to be solved"
3336 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
3337 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3338 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3339 &level.auto_exit_sokoban,
3341 "exit level if all tasks solved", "automatically finish Sokoban levels"
3344 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
3345 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3346 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3347 &level.solved_by_one_player,
3349 "only one player must enter exit", "level solved by first player in exit"
3352 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
3353 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3354 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3355 &level.finish_dig_collect,
3357 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3360 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
3361 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3362 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3363 &level.keep_walkable_ce,
3365 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3368 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
3369 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3370 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3371 &level.continuous_snapping,
3373 "continuous snapping", "use snapping without releasing key"
3376 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
3377 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3378 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3379 &level.block_snap_field,
3381 "block snapped field when snapping", "use snapping delay to show animation"
3384 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
3385 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3386 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3387 &level.block_last_field,
3389 "block last field when moving", "player blocks last field when moving"
3392 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
3393 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3394 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3395 &level.sp_block_last_field,
3397 "block last field when moving", "player blocks last field when moving"
3400 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
3401 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3402 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3403 &level.instant_relocation,
3405 "no scrolling when relocating", "player gets relocated without delay"
3408 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
3409 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3410 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3411 &level.shifted_relocation,
3413 "no centering when relocating", "level not centered after relocation"
3416 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
3417 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3418 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3419 &level.lazy_relocation,
3421 "only redraw off-screen relocation","no redraw if relocation target visible"
3424 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
3425 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3426 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3427 &level.use_start_element[0],
3429 "use level start element:", "start level at this element's position"
3432 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
3433 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3434 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3435 &level.use_artwork_element[0],
3437 "use artwork from element:", "use player artwork from other element"
3440 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
3441 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3442 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3443 &level.use_explosion_element[0],
3445 "use explosion from element:", "use explosion properties from element"
3448 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
3449 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3450 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3451 &level.initial_player_gravity[0],
3453 "use initial gravity", "set initial player gravity"
3456 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
3457 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3458 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3459 &level.use_initial_inventory[0],
3461 "use initial inventory:", "use collected elements on level start"
3464 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
3465 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3466 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3467 &level.can_pass_to_walkable,
3469 "can pass to walkable element", "player can pass to empty or walkable"
3472 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
3473 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3474 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3475 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3477 "can fall into acid (with gravity)","player can fall into acid pool"
3480 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
3481 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3482 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3483 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3485 "can move into acid", "element can move into acid pool"
3488 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
3489 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3490 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3491 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3493 "deadly when colliding with", "element is deadly when hitting player"
3496 ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
3497 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3498 GADGET_ID_BD_DIAGONAL_MOVEMENTS, GADGET_ID_NONE,
3499 &level.bd_diagonal_movements,
3501 "can move diagonally", "player can move diagonally"
3504 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
3505 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3506 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3507 &level.envelope[0].autowrap,
3509 "auto-wrap", "automatically wrap envelope text"
3512 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
3513 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3514 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3515 &level.envelope[0].centered,
3517 "centered", "automatically center envelope text"
3520 ED_CHECKBUTTON_ID_MM_LASER_RED,
3521 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3522 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3523 &level.mm_laser_red,
3524 "choose color components for laser:", NULL,
3525 "red", "use red color components in laser"
3528 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
3529 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3530 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3531 &level.mm_laser_green,
3533 "green", "use green color components in laser"
3536 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
3537 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3538 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3539 &level.mm_laser_blue,
3541 "blue", "use blue color components in laser"
3544 ED_CHECKBUTTON_ID_DF_LASER_RED,
3545 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3546 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3547 &level.df_laser_red,
3548 "choose color components for laser:", NULL,
3549 "red", "use red color components in laser"
3552 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
3553 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3554 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3555 &level.df_laser_green,
3557 "green", "use green color components in laser"
3560 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
3561 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3562 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3563 &level.df_laser_blue,
3565 "blue", "use blue color components in laser"
3568 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
3569 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3570 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3571 &level.rotate_mm_ball_content,
3573 "randomly rotate created content", "randomly rotate newly created content"
3576 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
3577 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3578 GADGET_ID_EXPLODE_MM_BALL, GADGET_ID_NONE,
3579 &level.explode_mm_ball,
3581 "explode ball instead of melting", "use explosion to release ball content"
3584 // ---------- element settings: configure 1 (custom elements) ---------------
3587 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
3588 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3589 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3590 &custom_element.use_gfx_element,
3592 "use graphic of element:", "use existing element graphic"
3595 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
3596 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3597 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3598 &level.use_custom_template,
3600 "use template", "use template for custom properties"
3603 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
3604 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3605 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3606 &custom_element_properties[EP_ACCESSIBLE],
3608 NULL, "player can walk to or pass this field"
3611 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
3612 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3613 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3614 &custom_element_properties[EP_GRAVITY_REACHABLE],
3616 "reachable despite gravity", "player can walk/dig despite gravity"
3619 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
3620 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3621 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3622 &custom_element.use_last_ce_value,
3624 "use last CE value after change", "use last CE value after change"
3627 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
3628 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3629 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3630 &custom_element_properties[EP_WALK_TO_OBJECT],
3632 NULL, "player can dig/collect/push element"
3635 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
3636 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3637 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3638 &custom_element_properties[EP_INDESTRUCTIBLE],
3640 "indestructible", "element is indestructible"
3643 // ---------- element settings: configure 2 (custom elements) ---------------
3646 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
3647 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3648 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3649 &custom_element_properties[EP_CAN_MOVE],
3651 NULL, "element can move with some pattern"
3654 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
3655 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3656 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3657 &custom_element_properties[EP_CAN_FALL],
3659 "can fall", "element can fall down"
3662 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
3663 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3664 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3665 &custom_element_properties[EP_CAN_SMASH],
3667 NULL, "element can smash other elements"
3670 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
3671 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3672 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3673 &custom_element_properties[EP_SLIPPERY],
3675 NULL, "other elements can fall down from it"
3678 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
3679 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3680 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3681 &custom_element_properties[EP_DEADLY],
3683 NULL, "element can kill the player"
3686 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
3687 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3688 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3689 &custom_element_properties[EP_CAN_EXPLODE],
3691 NULL, "element can explode"
3694 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
3695 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3696 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3697 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3699 "by fire", "element can explode by fire/explosion"
3702 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
3703 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3704 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3705 &custom_element_properties[EP_EXPLODES_SMASHED],
3707 "smashed", "element can explode when smashed"
3710 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
3711 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3712 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3713 &custom_element_properties[EP_EXPLODES_IMPACT],
3715 "impact", "element can explode on impact"
3718 // ---------- element settings: advanced (custom elements) ------------------
3721 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
3722 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3723 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3724 &custom_element_change.can_change,
3726 "element changes to:", "change element on specified condition"
3729 ED_CHECKBUTTON_ID_CHANGE_DELAY,
3730 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3731 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3732 &custom_element_change_events[CE_DELAY],
3734 NULL, "element changes after delay"
3737 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
3738 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3739 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3740 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3742 NULL, "element changes by direct action"
3745 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
3746 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3747 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3748 &custom_element_change_events[CE_BY_OTHER_ACTION],
3750 NULL, "element changes by other element"
3753 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
3754 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3755 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3756 &custom_element_change.explode,
3758 "explode instead of change", "element explodes instead of change"
3761 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
3762 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3763 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3764 &custom_element_change.use_target_content,
3766 "use extended change target:", "element changes to more elements"
3769 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
3770 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3771 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3772 &custom_element_change.only_if_complete,
3774 "replace all or nothing", "only replace when all can be changed"
3777 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
3778 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3779 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3780 &custom_element_change.use_random_replace,
3782 NULL, "use percentage for random replace"
3785 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
3786 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3787 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3788 &custom_element_change.has_action,
3790 NULL, "execute action on specified condition"
3798 int xoffset, yoffset;
3800 int gadget_id_align;
3802 int area_xsize, area_ysize;
3803 char *text_left, *text_right, *text_above, *text_below, *infotext;
3804 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3806 // ---------- level playfield content ---------------------------------------
3809 ED_DRAWING_ID_DRAWING_LEVEL,
3812 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3814 -1, -1, // these values are not constant, but can change at runtime
3815 NULL, NULL, NULL, NULL, NULL
3818 // ---------- yam yam content -----------------------------------------------
3821 ED_DRAWING_ID_YAMYAM_CONTENT_0,
3822 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3823 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3824 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3825 &level.yamyam_content[0].e[0][0], 3, 3,
3826 NULL, NULL, NULL, "1", NULL
3829 ED_DRAWING_ID_YAMYAM_CONTENT_1,
3830 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3831 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3832 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3833 &level.yamyam_content[1].e[0][0], 3, 3,
3834 NULL, NULL, NULL, "2", NULL
3837 ED_DRAWING_ID_YAMYAM_CONTENT_2,
3838 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3839 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3840 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3841 &level.yamyam_content[2].e[0][0], 3, 3,
3842 NULL, NULL, NULL, "3", NULL
3845 ED_DRAWING_ID_YAMYAM_CONTENT_3,
3846 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3847 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3848 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3849 &level.yamyam_content[3].e[0][0], 3, 3,
3850 NULL, NULL, NULL, "4", NULL
3853 ED_DRAWING_ID_YAMYAM_CONTENT_4,
3854 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3855 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3856 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3857 &level.yamyam_content[4].e[0][0], 3, 3,
3858 NULL, NULL, NULL, "5", NULL
3861 ED_DRAWING_ID_YAMYAM_CONTENT_5,
3862 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3863 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3864 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3865 &level.yamyam_content[5].e[0][0], 3, 3,
3866 NULL, NULL, NULL, "6", NULL
3869 ED_DRAWING_ID_YAMYAM_CONTENT_6,
3870 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3871 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3872 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3873 &level.yamyam_content[6].e[0][0], 3, 3,
3874 NULL, NULL, NULL, "7", NULL
3877 ED_DRAWING_ID_YAMYAM_CONTENT_7,
3878 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3879 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3880 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3881 &level.yamyam_content[7].e[0][0], 3, 3,
3882 NULL, NULL, NULL, "8", NULL
3885 // ---------- magic ball content --------------------------------------------
3888 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
3889 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3890 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3891 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3892 &level.ball_content[0].e[0][0], 3, 3,
3893 NULL, NULL, NULL, "1", NULL
3896 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
3897 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3898 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3899 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3900 &level.ball_content[1].e[0][0], 3, 3,
3901 NULL, NULL, NULL, "2", NULL
3904 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
3905 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3906 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3907 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3908 &level.ball_content[2].e[0][0], 3, 3,
3909 NULL, NULL, NULL, "3", NULL
3912 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
3913 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3914 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3915 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3916 &level.ball_content[3].e[0][0], 3, 3,
3917 NULL, NULL, NULL, "4", NULL
3920 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
3921 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3922 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3923 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3924 &level.ball_content[4].e[0][0], 3, 3,
3925 NULL, NULL, NULL, "5", NULL
3928 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
3929 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3930 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3931 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3932 &level.ball_content[5].e[0][0], 3, 3,
3933 NULL, NULL, NULL, "6", NULL
3936 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
3937 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3938 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3939 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3940 &level.ball_content[6].e[0][0], 3, 3,
3941 NULL, NULL, NULL, "7", NULL
3944 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
3945 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3946 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3947 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3948 &level.ball_content[7].e[0][0], 3, 3,
3949 NULL, NULL, NULL, "8", NULL
3952 // ---------- android content -----------------------------------------------
3955 ED_DRAWING_ID_ANDROID_CONTENT,
3956 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
3957 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3958 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3959 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3960 NULL, NULL, "elements:", NULL, "elements android can clone"
3963 // ---------- amoeba content ------------------------------------------------
3966 ED_DRAWING_ID_AMOEBA_CONTENT,
3967 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3968 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3969 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3970 &level.amoeba_content, 1, 1,
3971 "content:", NULL, NULL, NULL, "amoeba content"
3974 // ---------- level start element -------------------------------------------
3977 ED_DRAWING_ID_START_ELEMENT,
3978 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3979 0, ED_AREA_1X1_SETTINGS_YOFF,
3980 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3981 &level.start_element[0], 1, 1,
3982 NULL, NULL, NULL, NULL, "level start element"
3985 // ---------- player artwork element ----------------------------------------
3988 ED_DRAWING_ID_ARTWORK_ELEMENT,
3989 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3990 0, ED_AREA_1X1_SETTINGS_YOFF,
3991 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3992 &level.artwork_element[0], 1, 1,
3993 NULL, NULL, NULL, NULL, "element for player artwork"
3996 // ---------- player explosion element --------------------------------------
3999 ED_DRAWING_ID_EXPLOSION_ELEMENT,
4000 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
4001 0, ED_AREA_1X1_SETTINGS_YOFF,
4002 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
4003 &level.explosion_element[0], 1, 1,
4004 NULL, NULL, NULL, NULL, "element for player explosion"
4007 // ---------- player initial inventory --------------------------------------
4010 ED_DRAWING_ID_INVENTORY_CONTENT,
4011 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4012 0, ED_AREA_1X1_SETTINGS_YOFF,
4013 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
4014 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
4015 NULL, NULL, NULL, NULL, "content for initial inventory"
4018 // ---------- gray ball content -----------------------------------------
4021 ED_DRAWING_ID_MM_BALL_CONTENT,
4022 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4023 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4024 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
4025 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
4026 "content:", NULL, NULL, NULL, "content for gray ball"
4029 // ---------- element settings: configure 1 (custom elements) ---------------
4031 // ---------- custom graphic ------------------------------------------------
4034 ED_DRAWING_ID_CUSTOM_GRAPHIC,
4035 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4036 0, ED_AREA_1X1_SETTINGS_YOFF,
4037 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
4038 &custom_element.gfx_element_initial, 1, 1,
4039 NULL, NULL, NULL, NULL, "custom graphic element"
4042 // ---------- element settings: configure 2 (custom elements) ---------------
4044 // ---------- custom content (when exploding) -------------------------------
4047 ED_DRAWING_ID_CUSTOM_CONTENT,
4048 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
4049 0, ED_AREA_3X3_SETTINGS_YOFF,
4050 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
4051 &custom_element.content.e[0][0], 3, 3,
4052 "content:", NULL, NULL, NULL, NULL
4055 // ---------- custom enter and leave element (when moving) ------------------
4058 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
4059 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
4060 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4061 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
4062 &custom_element.move_enter_element, 1, 1,
4063 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
4066 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
4067 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
4068 0, ED_AREA_1X1_SETTINGS_YOFF,
4069 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
4070 &custom_element.move_leave_element, 1, 1,
4071 NULL, NULL, NULL, NULL, "element that will be left behind"
4074 // ---------- element settings: advanced (custom elements) ------------------
4076 // ---------- custom change target ------------------------------------------
4079 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
4080 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
4081 0, ED_AREA_1X1_SETTINGS_YOFF,
4082 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
4083 &custom_element_change.target_element, 1, 1,
4084 NULL, "after/when:", NULL, NULL, "new target element after change"
4087 // ---------- custom change content (extended change target) ----------------
4090 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
4091 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
4092 0, ED_AREA_3X3_SETTINGS_YOFF,
4093 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
4094 &custom_element_change.target_content.e[0][0], 3, 3,
4095 NULL, NULL, NULL, NULL, "new extended elements after change"
4098 // ---------- custom change trigger (element causing change) ----------------
4101 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
4102 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
4103 0, ED_AREA_1X1_SETTINGS_YOFF,
4104 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
4105 &custom_element_change.initial_trigger_element, 1, 1,
4106 NULL, NULL, NULL, NULL, "other element triggering change"
4109 // ---------- custom change action (element used for action) ----------------
4112 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
4113 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
4114 0, ED_AREA_1X1_SETTINGS_YOFF,
4115 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
4116 &custom_element_change.action_element, 1, 1,
4117 NULL, NULL, NULL, NULL, "element used as action parameter"
4120 // ---------- group element content -----------------------------------------
4123 ED_DRAWING_ID_GROUP_CONTENT,
4124 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
4125 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
4126 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
4127 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
4128 "content:", NULL, NULL, NULL, NULL
4131 // ---------- random background (for random painting) -----------------------
4134 ED_DRAWING_ID_RANDOM_BACKGROUND,
4135 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
4136 0, ED_AREA_1X1_LSETTINGS_YOFF,
4137 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
4138 &random_placement_background_element, 1, 1,
4139 NULL, NULL, NULL, NULL, "random placement background"
4144 // ----------------------------------------------------------------------------
4145 // some internally used variables
4146 // ----------------------------------------------------------------------------
4148 // maximal size of level editor drawing area
4149 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
4151 // actual size of level editor drawing area
4152 static int ed_fieldx, ed_fieldy;
4154 // actual position of level editor drawing area in level playfield
4155 static int level_xpos = -1, level_ypos = -1;
4157 // actual tile size used to display playfield drawing area
4158 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
4159 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
4161 #define IN_ED_FIELD(x, y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
4163 // drawing elements on the three mouse buttons
4164 static int new_element1 = EL_WALL;
4165 static int new_element2 = EL_EMPTY;
4166 static int new_element3 = EL_SAND;
4168 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
4169 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
4170 (button) == 2 ? new_element2 : \
4171 (button) == 3 ? new_element3 : EL_EMPTY)
4173 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
4175 static int use_permanent_palette = TRUE;
4177 #define PX (use_permanent_palette ? DX : SX)
4178 #define PY (use_permanent_palette ? DY : SY)
4179 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
4180 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
4182 // forward declaration for internal use
4183 static void CopyBrushToCursor(int, int);
4184 static void DeleteBrushFromCursor(void);
4185 static void ModifyEditorCounterValue(int, int);
4186 static void ModifyEditorCounterLimits(int, int, int);
4187 static void ModifyEditorSelectboxValue(int, int);
4188 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
4189 static void ModifyEditorDrawingArea(int, int, int);
4190 static void ModifyEditorElementList(void);
4191 static void AdjustElementListScrollbar(void);
4192 static void RedrawDrawingElements(void);
4193 static void DrawDrawingWindowExt(boolean);
4194 static void DrawDrawingWindow(void);
4195 static void DrawLevelConfigWindow(void);
4196 static void DrawPropertiesWindow(void);
4197 static void DrawPaletteWindow(void);
4198 static void UpdateCustomElementGraphicGadgets(void);
4199 static boolean checkPropertiesConfig(int);
4200 static void SetAutomaticNumberOfGemsNeeded(void);
4201 static void ClearEditorGadgetInfoText(void);
4202 static void CopyLevelToUndoBuffer(int);
4203 static void HandleDrawingAreas(struct GadgetInfo *);
4204 static void HandleCounterButtons(struct GadgetInfo *);
4205 static void HandleTextInputGadgets(struct GadgetInfo *);
4206 static void HandleTextAreaGadgets(struct GadgetInfo *);
4207 static void HandleSelectboxGadgets(struct GadgetInfo *);
4208 static void HandleTextbuttonGadgets(struct GadgetInfo *);
4209 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
4210 static void HandleRadiobuttons(struct GadgetInfo *);
4211 static void HandleCheckbuttons(struct GadgetInfo *);
4212 static void HandleControlButtons(struct GadgetInfo *);
4213 static void HandleDrawingAreaInfo(struct GadgetInfo *);
4214 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
4215 static boolean AskToCopyAndModifyLevelTemplate(void);
4216 static boolean getDrawModeHiRes(void);
4217 static int getTabulatorBarWidth(void);
4218 static int getTabulatorBarHeight(void);
4219 static Pixel getTabulatorBarColor(void);
4220 static int numHiresTiles(int);
4222 static int num_editor_gadgets = 0; // dynamically determined
4224 static struct GadgetInfo **level_editor_gadget = NULL;
4225 static int *right_gadget_border = NULL;
4227 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
4228 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
4229 static boolean draw_with_brush = FALSE;
4230 static int properties_element = 0;
4232 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4233 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4234 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
4235 static int undo_buffer_position = 0;
4236 static int undo_buffer_steps = 0;
4237 static int redo_buffer_steps = 0;
4239 static int edit_mode;
4240 static int edit_mode_levelconfig;
4241 static int edit_mode_properties;
4243 static int element_shift = 0;
4245 static int editor_el_players[] =
4252 static int *editor_el_players_ptr = editor_el_players;
4253 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4255 static int editor_hl_boulderdash[] =
4257 EL_INTERNAL_CASCADE_BD_ACTIVE,
4263 static int editor_el_boulderdash[] =
4272 EL_BD_EXPANDABLE_WALL,
4280 EL_BD_BUTTERFLY_LEFT,
4282 EL_BD_BUTTERFLY_RIGHT,
4283 EL_BD_FIREFLY_RIGHT,
4286 EL_BD_BUTTERFLY_DOWN,
4290 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4291 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4292 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4293 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4295 static int editor_hl_boulderdash_native[] =
4297 EL_INTERNAL_CASCADE_BD_NATIVE_ACTIVE,
4303 static int editor_el_boulderdash_native[] =
4320 EL_BD_BUTTERFLY_LEFT,
4322 EL_BD_BUTTERFLY_RIGHT,
4323 EL_BD_FIREFLY_RIGHT,
4326 EL_BD_BUTTERFLY_DOWN,
4331 EL_BD_BUTTERFLY_2_UP,
4335 EL_BD_BUTTERFLY_2_LEFT,
4336 EL_BD_FIREFLY_2_LEFT,
4337 EL_BD_BUTTERFLY_2_RIGHT,
4338 EL_BD_FIREFLY_2_RIGHT,
4341 EL_BD_BUTTERFLY_2_DOWN,
4342 EL_BD_FIREFLY_2_DOWN,
4350 EL_BD_DRAGONFLY_LEFT,
4351 EL_BD_STONEFLY_LEFT,
4352 EL_BD_DRAGONFLY_RIGHT,
4353 EL_BD_STONEFLY_RIGHT,
4356 EL_BD_DRAGONFLY_DOWN,
4357 EL_BD_STONEFLY_DOWN,
4380 EL_BD_SAND_SLOPED_UP_LEFT,
4381 EL_BD_SAND_SLOPED_UP_RIGHT,
4382 EL_BD_WALL_SLOPED_UP_LEFT,
4383 EL_BD_WALL_SLOPED_UP_RIGHT,
4385 EL_BD_SAND_SLOPED_DOWN_LEFT,
4386 EL_BD_SAND_SLOPED_DOWN_RIGHT,
4387 EL_BD_WALL_SLOPED_DOWN_LEFT,
4388 EL_BD_WALL_SLOPED_DOWN_RIGHT,
4390 EL_BD_FLYING_DIAMOND,
4392 EL_BD_STEELWALL_SLOPED_UP_LEFT,
4393 EL_BD_STEELWALL_SLOPED_UP_RIGHT,
4397 EL_BD_STEELWALL_SLOPED_DOWN_LEFT,
4398 EL_BD_STEELWALL_SLOPED_DOWN_RIGHT,
4401 EL_BD_WALL_NON_SLOPED,
4407 EL_BD_INVISIBLE_EXIT_CLOSED,
4408 EL_BD_INVISIBLE_EXIT_OPEN,
4411 EL_BD_STEELWALL_EXPLODABLE,
4412 EL_BD_STEELWALL_DIGGABLE,
4413 EL_BD_WALL_DIGGABLE,
4415 EL_BD_EXPANDABLE_WALL_HORIZONTAL,
4416 EL_BD_EXPANDABLE_WALL_VERTICAL,
4417 EL_BD_EXPANDABLE_WALL_ANY,
4418 EL_BD_CREATURE_SWITCH,
4420 EL_BD_EXPANDABLE_STEELWALL_HORIZONTAL,
4421 EL_BD_EXPANDABLE_STEELWALL_VERTICAL,
4422 EL_BD_EXPANDABLE_STEELWALL_ANY,
4423 EL_BD_EXPANDABLE_WALL_SWITCH_HORIZONTAL,
4425 EL_BD_BITER_SWITCH_1,
4426 EL_BD_REPLICATOR_SWITCH,
4427 EL_BD_CONVEYOR_SWITCH,
4428 EL_BD_CONVEYOR_DIR_SWITCH_RIGHT,
4437 EL_BD_DIAMOND_GLUED,
4440 EL_BD_TRAPPED_DIAMOND,
4460 EL_BD_GRAVITY_SWITCH,
4461 EL_BD_PNEUMATIC_HAMMER,
4468 EL_BD_BLADDER_SPENDER,
4470 EL_BD_CONVEYOR_LEFT,
4471 EL_BD_CONVEYOR_RIGHT,
4486 EL_BD_PLAYER_WITH_BOMB,
4488 EL_BD_PLAYER_STIRRING,
4490 static int *editor_hl_boulderdash_native_ptr = editor_hl_boulderdash_native;
4491 static int *editor_el_boulderdash_native_ptr = editor_el_boulderdash_native;
4492 static int num_editor_hl_boulderdash_native = ARRAY_SIZE(editor_hl_boulderdash_native);
4493 static int num_editor_el_boulderdash_native = ARRAY_SIZE(editor_el_boulderdash_native);
4495 static int editor_hl_emerald_mine[] =
4497 EL_INTERNAL_CASCADE_EM_ACTIVE,
4503 static int editor_el_emerald_mine[] =
4521 EL_EM_DYNAMITE_ACTIVE,
4540 EL_ACID_POOL_TOPLEFT,
4542 EL_ACID_POOL_TOPRIGHT,
4545 EL_ACID_POOL_BOTTOMLEFT,
4546 EL_ACID_POOL_BOTTOM,
4547 EL_ACID_POOL_BOTTOMRIGHT,
4565 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4566 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4567 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4568 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4570 static int editor_hl_emerald_mine_club[] =
4572 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4578 static int editor_el_emerald_mine_club[] =
4605 EL_EMC_WALL_SLIPPERY_1,
4606 EL_EMC_WALL_SLIPPERY_2,
4607 EL_EMC_WALL_SLIPPERY_3,
4608 EL_EMC_WALL_SLIPPERY_4,
4631 EL_EMC_MAGIC_BALL_SWITCH,
4638 EL_EMC_SPRING_BUMPER,
4642 EL_BALLOON_SWITCH_UP,
4643 EL_BALLOON_SWITCH_ANY,
4646 EL_BALLOON_SWITCH_LEFT,
4648 EL_BALLOON_SWITCH_RIGHT,
4652 EL_BALLOON_SWITCH_DOWN,
4653 EL_BALLOON_SWITCH_NONE,
4655 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4656 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4657 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4658 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4660 static int editor_hl_rnd[] =
4662 EL_INTERNAL_CASCADE_RND_ACTIVE,
4668 static int editor_el_rnd[] =
4671 EL_DYNAMITE_ACTIVE, // RND
4705 EL_WALL_EMERALD_YELLOW,
4706 EL_WALL_EMERALD_RED,
4707 EL_WALL_EMERALD_PURPLE,
4725 EL_DYNABOMB_INCREASE_NUMBER,
4726 EL_DYNABOMB_INCREASE_SIZE,
4727 EL_DYNABOMB_INCREASE_POWER,
4747 EL_INVISIBLE_STEELWALL,
4751 EL_EXPANDABLE_WALL_HORIZONTAL,
4752 EL_EXPANDABLE_WALL_VERTICAL,
4753 EL_EXPANDABLE_WALL_ANY,
4755 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4756 static int *editor_el_rnd_ptr = editor_el_rnd;
4757 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4758 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4760 static int editor_hl_sokoban[] =
4762 EL_INTERNAL_CASCADE_SB_ACTIVE,
4768 static int editor_el_sokoban[] =
4771 EL_SOKOBAN_FIELD_EMPTY,
4772 EL_SOKOBAN_FIELD_FULL,
4773 EL_SOKOBAN_FIELD_PLAYER,
4775 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4776 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4777 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4778 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4780 static int editor_hl_supaplex[] =
4782 EL_INTERNAL_CASCADE_SP_ACTIVE,
4788 static int editor_el_supaplex[] =
4806 EL_SP_PORT_HORIZONTAL,
4807 EL_SP_PORT_VERTICAL,
4815 EL_SP_GRAVITY_PORT_LEFT,
4816 EL_SP_GRAVITY_PORT_RIGHT,
4817 EL_SP_GRAVITY_PORT_UP,
4818 EL_SP_GRAVITY_PORT_DOWN,
4820 EL_SP_GRAVITY_ON_PORT_LEFT,
4821 EL_SP_GRAVITY_ON_PORT_RIGHT,
4822 EL_SP_GRAVITY_ON_PORT_UP,
4823 EL_SP_GRAVITY_ON_PORT_DOWN,
4825 EL_SP_GRAVITY_OFF_PORT_LEFT,
4826 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4827 EL_SP_GRAVITY_OFF_PORT_UP,
4828 EL_SP_GRAVITY_OFF_PORT_DOWN,
4830 EL_SP_HARDWARE_GRAY,
4831 EL_SP_HARDWARE_GREEN,
4832 EL_SP_HARDWARE_BLUE,
4835 EL_SP_HARDWARE_BASE_1,
4836 EL_SP_HARDWARE_BASE_2,
4837 EL_SP_HARDWARE_BASE_3,
4838 EL_SP_HARDWARE_BASE_4,
4840 EL_SP_HARDWARE_BASE_5,
4841 EL_SP_HARDWARE_BASE_6,
4842 EL_SP_HARDWARE_YELLOW,
4850 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4851 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4852 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4853 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4855 static int editor_hl_diamond_caves[] =
4857 EL_INTERNAL_CASCADE_DC_ACTIVE,
4863 static int editor_el_diamond_caves[] =
4865 EL_EM_STEEL_EXIT_CLOSED, // DC2
4866 EL_EM_STEEL_EXIT_OPEN, // DC2
4867 EL_WALL_EMERALD, // DC2
4868 EL_WALL_DIAMOND, // DC2
4875 EL_CONVEYOR_BELT_1_LEFT,
4876 EL_CONVEYOR_BELT_1_MIDDLE,
4877 EL_CONVEYOR_BELT_1_RIGHT,
4878 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4880 EL_CONVEYOR_BELT_2_LEFT,
4881 EL_CONVEYOR_BELT_2_MIDDLE,
4882 EL_CONVEYOR_BELT_2_RIGHT,
4883 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4885 EL_CONVEYOR_BELT_3_LEFT,
4886 EL_CONVEYOR_BELT_3_MIDDLE,
4887 EL_CONVEYOR_BELT_3_RIGHT,
4888 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4890 EL_CONVEYOR_BELT_4_LEFT,
4891 EL_CONVEYOR_BELT_4_MIDDLE,
4892 EL_CONVEYOR_BELT_4_RIGHT,
4893 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4895 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4896 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4897 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4898 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4900 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4901 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4902 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4903 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4908 EL_DC_TIMEGATE_SWITCH,
4910 EL_SWITCHGATE_CLOSED,
4912 EL_SWITCHGATE_SWITCH_UP,
4913 EL_SWITCHGATE_SWITCH_DOWN,
4916 EL_LIGHT_SWITCH_ACTIVE,
4917 EL_DC_SWITCHGATE_SWITCH_UP,
4918 EL_DC_SWITCHGATE_SWITCH_DOWN,
4920 EL_STEEL_EXIT_CLOSED,
4922 EL_STEELWALL_SLIPPERY,
4925 EL_QUICKSAND_FAST_EMPTY,
4926 EL_QUICKSAND_FAST_FULL,
4940 EL_SIGN_RADIOACTIVITY,
4946 EL_SIGN_ENTRY_FORBIDDEN,
4947 EL_SIGN_EMERGENCY_EXIT,
4972 EL_DC_STEELWALL_2_SINGLE,
4973 EL_DC_STEELWALL_2_TOP,
4974 EL_SIGN_EXCLAMATION,
4977 EL_DC_STEELWALL_2_LEFT,
4978 EL_DC_STEELWALL_2_MIDDLE,
4979 EL_DC_STEELWALL_2_HORIZONTAL,
4980 EL_DC_STEELWALL_2_RIGHT,
4982 EL_DC_STEELWALL_1_TOPLEFT,
4983 EL_DC_STEELWALL_2_VERTICAL,
4984 EL_DC_STEELWALL_1_TOPRIGHT,
4987 EL_DC_STEELWALL_1_VERTICAL,
4988 EL_DC_STEELWALL_2_BOTTOM,
4990 EL_DC_GATE_WHITE_GRAY,
4992 EL_DC_STEELWALL_1_BOTTOMLEFT,
4993 EL_DC_STEELWALL_1_HORIZONTAL,
4994 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4995 EL_DC_GATE_FAKE_GRAY,
4997 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4998 EL_DC_STEELWALL_1_BOTTOM,
4999 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
5000 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
5002 EL_DC_STEELWALL_1_RIGHT,
5004 EL_DC_STEELWALL_1_LEFT,
5005 EL_EXPANDABLE_STEELWALL_VERTICAL,
5007 EL_DC_STEELWALL_1_TOPRIGHT_2,
5008 EL_DC_STEELWALL_1_TOP,
5009 EL_DC_STEELWALL_1_TOPLEFT_2,
5010 EL_EXPANDABLE_STEELWALL_ANY,
5012 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
5013 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
5014 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
5015 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
5017 static int editor_hl_dx_boulderdash[] =
5019 EL_INTERNAL_CASCADE_DX_ACTIVE,
5025 static int editor_el_dx_boulderdash[] =
5029 EL_TUBE_HORIZONTAL_DOWN,
5033 EL_TUBE_VERTICAL_RIGHT,
5035 EL_TUBE_VERTICAL_LEFT,
5039 EL_TUBE_HORIZONTAL_UP,
5047 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
5048 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
5049 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
5050 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
5052 static int editor_hl_mirror_magic[] =
5054 EL_INTERNAL_CASCADE_MM_ACTIVE,
5060 static int editor_el_mirror_magic[] =
5062 EL_MM_MCDUFFIN_RIGHT,
5064 EL_MM_MCDUFFIN_LEFT,
5065 EL_MM_MCDUFFIN_DOWN,
5068 EL_MM_MIRROR_FIXED_START,
5069 EL_MM_POLARIZER_START,
5070 EL_MM_POLARIZER_CROSS_START,
5072 EL_MM_TELEPORTER_RED_START,
5073 EL_MM_TELEPORTER_YELLOW_START,
5074 EL_MM_TELEPORTER_GREEN_START,
5075 EL_MM_TELEPORTER_BLUE_START,
5088 EL_MM_LIGHTBULB_ACTIVE,
5102 EL_MM_STEEL_GRID_FIXED_1,
5103 EL_MM_STEEL_GRID_FIXED_2,
5104 EL_MM_STEEL_GRID_FIXED_3,
5105 EL_MM_STEEL_GRID_FIXED_4,
5107 EL_MM_WOODEN_GRID_FIXED_1,
5108 EL_MM_WOODEN_GRID_FIXED_2,
5109 EL_MM_WOODEN_GRID_FIXED_3,
5110 EL_MM_WOODEN_GRID_FIXED_4,
5117 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
5118 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
5119 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
5120 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
5122 static int editor_hl_deflektor[] =
5124 EL_INTERNAL_CASCADE_DF_ACTIVE,
5130 static int editor_el_deflektor[] =
5137 EL_DF_RECEIVER_RIGHT,
5139 EL_DF_RECEIVER_LEFT,
5140 EL_DF_RECEIVER_DOWN,
5143 EL_DF_MIRROR_ROTATING_START,
5144 EL_DF_MIRROR_FIXED_START,
5147 EL_DF_FIBRE_OPTIC_RED_1,
5148 EL_DF_FIBRE_OPTIC_YELLOW_1,
5149 EL_DF_FIBRE_OPTIC_GREEN_1,
5150 EL_DF_FIBRE_OPTIC_BLUE_1,
5152 EL_DF_STEEL_GRID_FIXED_START,
5153 EL_DF_STEEL_GRID_ROTATING_START,
5154 EL_DF_WOODEN_GRID_FIXED_START,
5155 EL_DF_WOODEN_GRID_ROTATING_START,
5167 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
5168 static int *editor_el_deflektor_ptr = editor_el_deflektor;
5169 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
5170 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
5172 static int editor_hl_chars[] =
5174 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
5180 static int editor_el_chars[] =
5262 EL_CHAR(CHAR_BYTE_COPYRIGHT),
5263 EL_CHAR(CHAR_BYTE_UMLAUT_A),
5264 EL_CHAR(CHAR_BYTE_UMLAUT_O),
5265 EL_CHAR(CHAR_BYTE_UMLAUT_U),
5267 EL_CHAR(CHAR_BYTE_DEGREE),
5268 EL_CHAR(CHAR_BYTE_REGISTERED),
5269 EL_CHAR(FONT_ASCII_CURSOR),
5270 EL_CHAR(FONT_ASCII_BUTTON),
5272 EL_CHAR(FONT_ASCII_UP),
5273 EL_CHAR(FONT_ASCII_DOWN),
5277 static int *editor_hl_chars_ptr = editor_hl_chars;
5278 static int *editor_el_chars_ptr = editor_el_chars;
5279 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
5280 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
5282 static int editor_hl_steel_chars[] =
5284 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
5290 static int editor_el_steel_chars[] =
5300 EL_STEEL_CHAR('\''),
5367 EL_STEEL_CHAR('\\'),
5372 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
5373 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
5374 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
5375 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
5377 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
5378 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
5379 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
5380 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
5382 EL_STEEL_CHAR(FONT_ASCII_UP),
5383 EL_STEEL_CHAR(FONT_ASCII_DOWN),
5387 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
5388 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
5389 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
5390 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
5392 static int editor_hl_custom[] =
5394 EL_INTERNAL_CASCADE_CE_ACTIVE,
5400 static int editor_el_custom[] =
5402 EL_CUSTOM_START + 0,
5403 EL_CUSTOM_START + 1,
5404 EL_CUSTOM_START + 2,
5405 EL_CUSTOM_START + 3,
5407 EL_CUSTOM_START + 4,
5408 EL_CUSTOM_START + 5,
5409 EL_CUSTOM_START + 6,
5410 EL_CUSTOM_START + 7,
5412 EL_CUSTOM_START + 8,
5413 EL_CUSTOM_START + 9,
5414 EL_CUSTOM_START + 10,
5415 EL_CUSTOM_START + 11,
5417 EL_CUSTOM_START + 12,
5418 EL_CUSTOM_START + 13,
5419 EL_CUSTOM_START + 14,
5420 EL_CUSTOM_START + 15,
5422 EL_CUSTOM_START + 16,
5423 EL_CUSTOM_START + 17,
5424 EL_CUSTOM_START + 18,
5425 EL_CUSTOM_START + 19,
5427 EL_CUSTOM_START + 20,
5428 EL_CUSTOM_START + 21,
5429 EL_CUSTOM_START + 22,
5430 EL_CUSTOM_START + 23,
5432 EL_CUSTOM_START + 24,
5433 EL_CUSTOM_START + 25,
5434 EL_CUSTOM_START + 26,
5435 EL_CUSTOM_START + 27,
5437 EL_CUSTOM_START + 28,
5438 EL_CUSTOM_START + 29,
5439 EL_CUSTOM_START + 30,
5440 EL_CUSTOM_START + 31,
5442 EL_CUSTOM_START + 32,
5443 EL_CUSTOM_START + 33,
5444 EL_CUSTOM_START + 34,
5445 EL_CUSTOM_START + 35,
5447 EL_CUSTOM_START + 36,
5448 EL_CUSTOM_START + 37,
5449 EL_CUSTOM_START + 38,
5450 EL_CUSTOM_START + 39,
5452 EL_CUSTOM_START + 40,
5453 EL_CUSTOM_START + 41,
5454 EL_CUSTOM_START + 42,
5455 EL_CUSTOM_START + 43,
5457 EL_CUSTOM_START + 44,
5458 EL_CUSTOM_START + 45,
5459 EL_CUSTOM_START + 46,
5460 EL_CUSTOM_START + 47,
5462 EL_CUSTOM_START + 48,
5463 EL_CUSTOM_START + 49,
5464 EL_CUSTOM_START + 50,
5465 EL_CUSTOM_START + 51,
5467 EL_CUSTOM_START + 52,
5468 EL_CUSTOM_START + 53,
5469 EL_CUSTOM_START + 54,
5470 EL_CUSTOM_START + 55,
5472 EL_CUSTOM_START + 56,
5473 EL_CUSTOM_START + 57,
5474 EL_CUSTOM_START + 58,
5475 EL_CUSTOM_START + 59,
5477 EL_CUSTOM_START + 60,
5478 EL_CUSTOM_START + 61,
5479 EL_CUSTOM_START + 62,
5480 EL_CUSTOM_START + 63,
5482 EL_CUSTOM_START + 64,
5483 EL_CUSTOM_START + 65,
5484 EL_CUSTOM_START + 66,
5485 EL_CUSTOM_START + 67,
5487 EL_CUSTOM_START + 68,
5488 EL_CUSTOM_START + 69,
5489 EL_CUSTOM_START + 70,
5490 EL_CUSTOM_START + 71,
5492 EL_CUSTOM_START + 72,
5493 EL_CUSTOM_START + 73,
5494 EL_CUSTOM_START + 74,
5495 EL_CUSTOM_START + 75,
5497 EL_CUSTOM_START + 76,
5498 EL_CUSTOM_START + 77,
5499 EL_CUSTOM_START + 78,
5500 EL_CUSTOM_START + 79,
5502 EL_CUSTOM_START + 80,
5503 EL_CUSTOM_START + 81,
5504 EL_CUSTOM_START + 82,
5505 EL_CUSTOM_START + 83,
5507 EL_CUSTOM_START + 84,
5508 EL_CUSTOM_START + 85,
5509 EL_CUSTOM_START + 86,
5510 EL_CUSTOM_START + 87,
5512 EL_CUSTOM_START + 88,
5513 EL_CUSTOM_START + 89,
5514 EL_CUSTOM_START + 90,
5515 EL_CUSTOM_START + 91,
5517 EL_CUSTOM_START + 92,
5518 EL_CUSTOM_START + 93,
5519 EL_CUSTOM_START + 94,
5520 EL_CUSTOM_START + 95,
5522 EL_CUSTOM_START + 96,
5523 EL_CUSTOM_START + 97,
5524 EL_CUSTOM_START + 98,
5525 EL_CUSTOM_START + 99,
5527 EL_CUSTOM_START + 100,
5528 EL_CUSTOM_START + 101,
5529 EL_CUSTOM_START + 102,
5530 EL_CUSTOM_START + 103,
5532 EL_CUSTOM_START + 104,
5533 EL_CUSTOM_START + 105,
5534 EL_CUSTOM_START + 106,
5535 EL_CUSTOM_START + 107,
5537 EL_CUSTOM_START + 108,
5538 EL_CUSTOM_START + 109,
5539 EL_CUSTOM_START + 110,
5540 EL_CUSTOM_START + 111,
5542 EL_CUSTOM_START + 112,
5543 EL_CUSTOM_START + 113,
5544 EL_CUSTOM_START + 114,
5545 EL_CUSTOM_START + 115,
5547 EL_CUSTOM_START + 116,
5548 EL_CUSTOM_START + 117,
5549 EL_CUSTOM_START + 118,
5550 EL_CUSTOM_START + 119,
5552 EL_CUSTOM_START + 120,
5553 EL_CUSTOM_START + 121,
5554 EL_CUSTOM_START + 122,
5555 EL_CUSTOM_START + 123,
5557 EL_CUSTOM_START + 124,
5558 EL_CUSTOM_START + 125,
5559 EL_CUSTOM_START + 126,
5560 EL_CUSTOM_START + 127,
5562 EL_CUSTOM_START + 128,
5563 EL_CUSTOM_START + 129,
5564 EL_CUSTOM_START + 130,
5565 EL_CUSTOM_START + 131,
5567 EL_CUSTOM_START + 132,
5568 EL_CUSTOM_START + 133,
5569 EL_CUSTOM_START + 134,
5570 EL_CUSTOM_START + 135,
5572 EL_CUSTOM_START + 136,
5573 EL_CUSTOM_START + 137,
5574 EL_CUSTOM_START + 138,
5575 EL_CUSTOM_START + 139,
5577 EL_CUSTOM_START + 140,
5578 EL_CUSTOM_START + 141,
5579 EL_CUSTOM_START + 142,
5580 EL_CUSTOM_START + 143,
5582 EL_CUSTOM_START + 144,
5583 EL_CUSTOM_START + 145,
5584 EL_CUSTOM_START + 146,
5585 EL_CUSTOM_START + 147,
5587 EL_CUSTOM_START + 148,
5588 EL_CUSTOM_START + 149,
5589 EL_CUSTOM_START + 150,
5590 EL_CUSTOM_START + 151,
5592 EL_CUSTOM_START + 152,
5593 EL_CUSTOM_START + 153,
5594 EL_CUSTOM_START + 154,
5595 EL_CUSTOM_START + 155,
5597 EL_CUSTOM_START + 156,
5598 EL_CUSTOM_START + 157,
5599 EL_CUSTOM_START + 158,
5600 EL_CUSTOM_START + 159,
5602 EL_CUSTOM_START + 160,
5603 EL_CUSTOM_START + 161,
5604 EL_CUSTOM_START + 162,
5605 EL_CUSTOM_START + 163,
5607 EL_CUSTOM_START + 164,
5608 EL_CUSTOM_START + 165,
5609 EL_CUSTOM_START + 166,
5610 EL_CUSTOM_START + 167,
5612 EL_CUSTOM_START + 168,
5613 EL_CUSTOM_START + 169,
5614 EL_CUSTOM_START + 170,
5615 EL_CUSTOM_START + 171,
5617 EL_CUSTOM_START + 172,
5618 EL_CUSTOM_START + 173,
5619 EL_CUSTOM_START + 174,
5620 EL_CUSTOM_START + 175,
5622 EL_CUSTOM_START + 176,
5623 EL_CUSTOM_START + 177,
5624 EL_CUSTOM_START + 178,
5625 EL_CUSTOM_START + 179,
5627 EL_CUSTOM_START + 180,
5628 EL_CUSTOM_START + 181,
5629 EL_CUSTOM_START + 182,
5630 EL_CUSTOM_START + 183,
5632 EL_CUSTOM_START + 184,
5633 EL_CUSTOM_START + 185,
5634 EL_CUSTOM_START + 186,
5635 EL_CUSTOM_START + 187,
5637 EL_CUSTOM_START + 188,
5638 EL_CUSTOM_START + 189,
5639 EL_CUSTOM_START + 190,
5640 EL_CUSTOM_START + 191,
5642 EL_CUSTOM_START + 192,
5643 EL_CUSTOM_START + 193,
5644 EL_CUSTOM_START + 194,
5645 EL_CUSTOM_START + 195,
5647 EL_CUSTOM_START + 196,
5648 EL_CUSTOM_START + 197,
5649 EL_CUSTOM_START + 198,
5650 EL_CUSTOM_START + 199,
5652 EL_CUSTOM_START + 200,
5653 EL_CUSTOM_START + 201,
5654 EL_CUSTOM_START + 202,
5655 EL_CUSTOM_START + 203,
5657 EL_CUSTOM_START + 204,
5658 EL_CUSTOM_START + 205,
5659 EL_CUSTOM_START + 206,
5660 EL_CUSTOM_START + 207,
5662 EL_CUSTOM_START + 208,
5663 EL_CUSTOM_START + 209,
5664 EL_CUSTOM_START + 210,
5665 EL_CUSTOM_START + 211,
5667 EL_CUSTOM_START + 212,
5668 EL_CUSTOM_START + 213,
5669 EL_CUSTOM_START + 214,
5670 EL_CUSTOM_START + 215,
5672 EL_CUSTOM_START + 216,
5673 EL_CUSTOM_START + 217,
5674 EL_CUSTOM_START + 218,
5675 EL_CUSTOM_START + 219,
5677 EL_CUSTOM_START + 220,
5678 EL_CUSTOM_START + 221,
5679 EL_CUSTOM_START + 222,
5680 EL_CUSTOM_START + 223,
5682 EL_CUSTOM_START + 224,
5683 EL_CUSTOM_START + 225,
5684 EL_CUSTOM_START + 226,
5685 EL_CUSTOM_START + 227,
5687 EL_CUSTOM_START + 228,
5688 EL_CUSTOM_START + 229,
5689 EL_CUSTOM_START + 230,
5690 EL_CUSTOM_START + 231,
5692 EL_CUSTOM_START + 232,
5693 EL_CUSTOM_START + 233,
5694 EL_CUSTOM_START + 234,
5695 EL_CUSTOM_START + 235,
5697 EL_CUSTOM_START + 236,
5698 EL_CUSTOM_START + 237,
5699 EL_CUSTOM_START + 238,
5700 EL_CUSTOM_START + 239,
5702 EL_CUSTOM_START + 240,
5703 EL_CUSTOM_START + 241,
5704 EL_CUSTOM_START + 242,
5705 EL_CUSTOM_START + 243,
5707 EL_CUSTOM_START + 244,
5708 EL_CUSTOM_START + 245,
5709 EL_CUSTOM_START + 246,
5710 EL_CUSTOM_START + 247,
5712 EL_CUSTOM_START + 248,
5713 EL_CUSTOM_START + 249,
5714 EL_CUSTOM_START + 250,
5715 EL_CUSTOM_START + 251,
5717 EL_CUSTOM_START + 252,
5718 EL_CUSTOM_START + 253,
5719 EL_CUSTOM_START + 254,
5720 EL_CUSTOM_START + 255
5722 static int *editor_hl_custom_ptr = editor_hl_custom;
5723 static int *editor_el_custom_ptr = editor_el_custom;
5724 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5725 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5727 static int editor_hl_group[] =
5729 EL_INTERNAL_CASCADE_GE_ACTIVE,
5735 static int editor_el_group[] =
5749 EL_GROUP_START + 10,
5750 EL_GROUP_START + 11,
5752 EL_GROUP_START + 12,
5753 EL_GROUP_START + 13,
5754 EL_GROUP_START + 14,
5755 EL_GROUP_START + 15,
5757 EL_GROUP_START + 16,
5758 EL_GROUP_START + 17,
5759 EL_GROUP_START + 18,
5760 EL_GROUP_START + 19,
5762 EL_GROUP_START + 20,
5763 EL_GROUP_START + 21,
5764 EL_GROUP_START + 22,
5765 EL_GROUP_START + 23,
5767 EL_GROUP_START + 24,
5768 EL_GROUP_START + 25,
5769 EL_GROUP_START + 26,
5770 EL_GROUP_START + 27,
5772 EL_GROUP_START + 28,
5773 EL_GROUP_START + 29,
5774 EL_GROUP_START + 30,
5777 static int *editor_hl_group_ptr = editor_hl_group;
5778 static int *editor_el_group_ptr = editor_el_group;
5779 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5780 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5782 static int editor_hl_empty_space[] =
5784 EL_INTERNAL_CASCADE_ES_ACTIVE,
5790 static int editor_el_empty_space[] =
5812 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
5813 static int *editor_el_empty_space_ptr = editor_el_empty_space;
5814 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
5815 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
5817 static int editor_hl_reference[] =
5819 EL_INTERNAL_CASCADE_REF_ACTIVE,
5825 static int editor_el_reference[] =
5829 EL_TRIGGER_CE_VALUE,
5830 EL_TRIGGER_CE_SCORE,
5834 EL_CURRENT_CE_VALUE,
5835 EL_CURRENT_CE_SCORE,
5857 static int *editor_hl_reference_ptr = editor_hl_reference;
5858 static int *editor_el_reference_ptr = editor_el_reference;
5859 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5860 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5862 static int editor_hl_user_defined[] =
5864 EL_INTERNAL_CASCADE_USER_ACTIVE,
5870 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5871 static int *editor_el_user_defined_ptr = NULL;
5872 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5873 static int num_editor_el_user_defined = 0;
5875 static int editor_hl_dynamic[] =
5877 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5883 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5884 static int *editor_el_dynamic_ptr = NULL;
5885 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5886 static int num_editor_el_dynamic = 0;
5888 static int editor_hl_empty[] = { EL_EMPTY };
5889 static int *editor_el_empty = NULL; // dynamically allocated
5891 static int *editor_hl_empty_ptr = editor_hl_empty;
5892 static int *editor_el_empty_ptr = NULL;
5893 static int num_editor_hl_empty = 0;
5894 static int num_editor_el_empty = 0; // dynamically determined, if needed
5896 static boolean use_el_empty = FALSE;
5898 static int *editor_elements = NULL; // dynamically allocated
5899 static int num_editor_elements = 0; // dynamically determined
5901 static boolean setup_editor_cascade_never = FALSE;
5903 static boolean setup_editor_el_players = TRUE;
5904 static boolean setup_editor_el_boulderdash = TRUE;
5905 static boolean setup_editor_el_boulderdash_native = TRUE;
5906 static boolean setup_editor_el_emerald_mine = TRUE;
5907 static boolean setup_editor_el_emerald_mine_club = TRUE;
5908 static boolean setup_editor_el_more = TRUE;
5909 static boolean setup_editor_el_sokoban = TRUE;
5910 static boolean setup_editor_el_supaplex = TRUE;
5911 static boolean setup_editor_el_diamond_caves = TRUE;
5912 static boolean setup_editor_el_dx_boulderdash = TRUE;
5913 static boolean setup_editor_el_mirror_magic = TRUE;
5914 static boolean setup_editor_el_deflektor = TRUE;
5915 static boolean setup_editor_el_chars = TRUE;
5916 static boolean setup_editor_el_steel_chars = TRUE;
5917 static boolean setup_editor_el_custom = TRUE;
5918 static boolean setup_editor_el_user_defined = TRUE;
5919 static boolean setup_editor_el_dynamic = TRUE;
5921 static int editor_hl_unused[] = { EL_EMPTY };
5922 static int *editor_hl_unused_ptr = editor_hl_unused;
5923 static int num_editor_hl_unused = 0;
5927 boolean *setup_value;
5928 boolean *setup_cascade_value;
5930 int **headline_list;
5931 int *headline_list_size;
5934 int *element_list_size;
5936 boolean last_setup_value;
5938 editor_elements_info[] =
5941 &setup_editor_el_players,
5942 &setup_editor_cascade_never,
5943 &editor_hl_unused_ptr, &num_editor_hl_unused,
5944 &editor_el_players_ptr, &num_editor_el_players
5947 &setup_editor_el_boulderdash,
5948 &setup.editor_cascade.el_bd,
5949 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5950 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5953 &setup_editor_el_boulderdash_native,
5954 &setup.editor_cascade.el_bd_native,
5955 &editor_hl_boulderdash_native_ptr, &num_editor_hl_boulderdash_native,
5956 &editor_el_boulderdash_native_ptr, &num_editor_el_boulderdash_native
5959 &setup_editor_el_emerald_mine,
5960 &setup.editor_cascade.el_em,
5961 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5962 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5965 &setup_editor_el_emerald_mine_club,
5966 &setup.editor_cascade.el_emc,
5967 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5968 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5971 &setup_editor_el_more,
5972 &setup.editor_cascade.el_rnd,
5973 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5974 &editor_el_rnd_ptr, &num_editor_el_rnd
5977 &setup_editor_el_sokoban,
5978 &setup.editor_cascade.el_sb,
5979 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5980 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5983 &setup_editor_el_supaplex,
5984 &setup.editor_cascade.el_sp,
5985 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5986 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5989 &setup_editor_el_diamond_caves,
5990 &setup.editor_cascade.el_dc,
5991 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5992 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5995 &setup_editor_el_dx_boulderdash,
5996 &setup.editor_cascade.el_dx,
5997 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5998 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
6001 &setup_editor_el_mirror_magic,
6002 &setup.editor_cascade.el_mm,
6003 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
6004 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
6007 &setup_editor_el_deflektor,
6008 &setup.editor_cascade.el_df,
6009 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
6010 &editor_el_deflektor_ptr, &num_editor_el_deflektor
6013 &setup_editor_el_chars,
6014 &setup.editor_cascade.el_chars,
6015 &editor_hl_chars_ptr, &num_editor_hl_chars,
6016 &editor_el_chars_ptr, &num_editor_el_chars
6019 &setup_editor_el_steel_chars,
6020 &setup.editor_cascade.el_steel_chars,
6021 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
6022 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
6025 &setup_editor_el_custom,
6026 &setup.editor_cascade.el_ce,
6027 &editor_hl_custom_ptr, &num_editor_hl_custom,
6028 &editor_el_custom_ptr, &num_editor_el_custom
6031 &setup_editor_el_custom,
6032 &setup.editor_cascade.el_ge,
6033 &editor_hl_group_ptr, &num_editor_hl_group,
6034 &editor_el_group_ptr, &num_editor_el_group
6037 &setup_editor_el_custom,
6038 &setup.editor_cascade.el_es,
6039 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
6040 &editor_el_empty_space_ptr, &num_editor_el_empty_space
6043 &setup_editor_el_custom,
6044 &setup.editor_cascade.el_ref,
6045 &editor_hl_reference_ptr, &num_editor_hl_reference,
6046 &editor_el_reference_ptr, &num_editor_el_reference
6049 &setup_editor_el_user_defined,
6050 &setup.editor_cascade.el_user,
6051 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
6052 &editor_el_user_defined_ptr, &num_editor_el_user_defined
6055 &setup_editor_el_dynamic,
6056 &setup.editor_cascade.el_dynamic,
6057 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
6058 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
6063 &editor_hl_empty_ptr, &num_editor_hl_empty,
6064 &editor_el_empty_ptr, &num_editor_el_empty,
6074 static struct XY xy_directions[] =
6083 // ----------------------------------------------------------------------------
6085 // ----------------------------------------------------------------------------
6087 static int getMaxInfoTextLength(void)
6089 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
6092 static int getTextWidthForGadget(char *text)
6097 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
6100 static int getTextWidthForDrawingArea(char *text)
6105 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
6108 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
6110 return (gi->x + gi->width + getTextWidthForGadget(text));
6113 static char *getElementInfoText(int element)
6115 char *info_text = NULL;
6117 if (element < MAX_NUM_ELEMENTS)
6119 if (strlen(element_info[element].description) > 0)
6120 info_text = element_info[element].description;
6121 else if (element_info[element].custom_description != NULL)
6122 info_text = element_info[element].custom_description;
6123 else if (element_info[element].editor_description != NULL)
6124 info_text = element_info[element].editor_description;
6127 if (info_text == NULL)
6128 info_text = INFOTEXT_UNKNOWN_ELEMENT;
6133 static char *getElementDescriptionFilenameExt(char *basename)
6135 char *elements_subdir = ELEMENTS_DIRECTORY;
6136 static char *elements_subdir2 = NULL;
6137 static char *filename = NULL;
6139 if (elements_subdir2 == NULL)
6140 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
6142 checked_free(filename);
6144 // 1st try: look for element description in current level set directory
6145 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
6146 if (fileExists(filename))
6151 // 2nd try: look for element description in the game's base directory
6152 filename = getPath3(options.docs_directory, elements_subdir, basename);
6153 if (fileExists(filename))
6159 static char *getElementDescriptionFilename(int element)
6161 char basename[MAX_FILENAME_LEN];
6164 // 1st try: look for element description file for exactly this element
6165 sprintf(basename, "%s.txt", element_info[element].token_name);
6166 filename = getElementDescriptionFilenameExt(basename);
6167 if (filename != NULL)
6170 // 2nd try: look for element description file for this element's class
6171 sprintf(basename, "%s.txt", element_info[element].class_name);
6172 filename = getElementDescriptionFilenameExt(basename);
6173 if (filename != NULL)
6176 // 3rd try: look for generic fallback text file for any element
6177 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
6178 if (filename != NULL)
6184 static boolean suppressBorderElement(void)
6186 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
6187 lev_fieldx <= MAX_ED_FIELDX &&
6188 lev_fieldy <= MAX_ED_FIELDY);
6191 static void InitDynamicEditorElementList(int **elements, int *num_elements)
6193 boolean element_found[NUM_FILE_ELEMENTS];
6196 // initialize list of used elements to "not used"
6197 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6198 element_found[i] = FALSE;
6200 // find all elements used in current level
6201 for (y = 0; y < lev_fieldy; y++)
6203 for (x = 0; x < lev_fieldx; x++)
6205 if (Tile[x][y] >= NUM_FILE_ELEMENTS) // should never happen
6208 if (IS_MM_WALL(Tile[x][y]))
6209 element_found[map_mm_wall_element(Tile[x][y])] = TRUE;
6211 element_found[Tile[x][y]] = TRUE;
6217 // count number of elements used in current level
6218 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6219 if (element_found[i])
6222 // add space for up to 3 more elements for padding that may be needed
6225 // free memory for old list of elements, if needed
6226 checked_free(*elements);
6228 // allocate memory for new list of elements
6229 *elements = checked_malloc(*num_elements * sizeof(int));
6233 // add all elements used in current level (non-custom/group/empty elements)
6234 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6235 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) ||
6236 IS_GROUP_ELEMENT(i) ||
6237 IS_EMPTY_ELEMENT(i)))
6238 (*elements)[(*num_elements)++] = i;
6240 // add all elements used in current level (custom/group/empty elements)
6241 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6242 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) ||
6243 IS_GROUP_ELEMENT(i) ||
6244 IS_EMPTY_ELEMENT(i)))
6245 (*elements)[(*num_elements)++] = i;
6247 while (*num_elements % 4) // pad with empty elements, if needed
6248 (*elements)[(*num_elements)++] = EL_EMPTY;
6251 static void ReinitializeElementList_EnableSections(void)
6253 // default: enable all element sections
6255 setup_editor_el_players = TRUE;
6256 setup_editor_el_boulderdash = TRUE;
6257 setup_editor_el_boulderdash_native = TRUE;
6258 setup_editor_el_emerald_mine = TRUE;
6259 setup_editor_el_emerald_mine_club = TRUE;
6260 setup_editor_el_more = TRUE;
6261 setup_editor_el_sokoban = TRUE;
6262 setup_editor_el_supaplex = TRUE;
6263 setup_editor_el_diamond_caves = TRUE;
6264 setup_editor_el_dx_boulderdash = TRUE;
6265 setup_editor_el_mirror_magic = TRUE;
6266 setup_editor_el_deflektor = TRUE;
6267 setup_editor_el_chars = TRUE;
6268 setup_editor_el_steel_chars = TRUE;
6270 setup_editor_el_custom = TRUE;
6271 setup_editor_el_user_defined = TRUE;
6272 setup_editor_el_dynamic = TRUE;
6274 // now disable all element sections not to be displayed
6276 if (!setup.editor.el_classic)
6278 setup_editor_el_players = FALSE;
6279 setup_editor_el_boulderdash = FALSE;
6280 setup_editor_el_boulderdash_native = FALSE;
6281 setup_editor_el_emerald_mine = FALSE;
6282 setup_editor_el_emerald_mine_club = FALSE;
6283 setup_editor_el_more = FALSE;
6284 setup_editor_el_sokoban = FALSE;
6285 setup_editor_el_supaplex = FALSE;
6286 setup_editor_el_diamond_caves = FALSE;
6287 setup_editor_el_dx_boulderdash = FALSE;
6288 setup_editor_el_mirror_magic = FALSE;
6289 setup_editor_el_deflektor = FALSE;
6290 setup_editor_el_chars = FALSE;
6291 setup_editor_el_steel_chars = FALSE;
6294 if (!setup.editor.el_custom)
6296 setup_editor_el_custom = FALSE;
6299 if (!setup.editor.el_user_defined)
6301 setup_editor_el_user_defined = FALSE;
6304 if (!setup.editor.el_dynamic)
6306 setup_editor_el_dynamic = FALSE;
6309 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
6311 setup_editor_el_boulderdash_native = FALSE;
6312 setup_editor_el_mirror_magic = FALSE;
6313 setup_editor_el_deflektor = FALSE;
6315 else if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
6317 setup_editor_el_players = FALSE;
6318 setup_editor_el_boulderdash = FALSE;
6319 setup_editor_el_emerald_mine = FALSE;
6320 setup_editor_el_emerald_mine_club = FALSE;
6321 setup_editor_el_more = FALSE;
6322 setup_editor_el_sokoban = FALSE;
6323 setup_editor_el_supaplex = FALSE;
6324 setup_editor_el_diamond_caves = FALSE;
6325 setup_editor_el_dx_boulderdash = FALSE;
6326 setup_editor_el_mirror_magic = FALSE;
6327 setup_editor_el_deflektor = FALSE;
6328 setup_editor_el_chars = FALSE;
6329 setup_editor_el_steel_chars = FALSE;
6331 setup_editor_el_custom = FALSE;
6333 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
6335 setup_editor_el_boulderdash = FALSE;
6336 setup_editor_el_boulderdash_native = FALSE;
6337 setup_editor_el_more = FALSE;
6338 setup_editor_el_sokoban = FALSE;
6339 setup_editor_el_supaplex = FALSE;
6340 setup_editor_el_diamond_caves = FALSE;
6341 setup_editor_el_dx_boulderdash = FALSE;
6342 setup_editor_el_mirror_magic = FALSE;
6343 setup_editor_el_deflektor = FALSE;
6344 setup_editor_el_steel_chars = FALSE;
6346 setup_editor_el_custom = FALSE;
6348 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
6350 setup_editor_el_players = FALSE;
6351 setup_editor_el_boulderdash = FALSE;
6352 setup_editor_el_boulderdash_native = FALSE;
6353 setup_editor_el_emerald_mine = FALSE;
6354 setup_editor_el_emerald_mine_club = FALSE;
6355 setup_editor_el_more = FALSE;
6356 setup_editor_el_sokoban = FALSE;
6357 setup_editor_el_diamond_caves = FALSE;
6358 setup_editor_el_dx_boulderdash = FALSE;
6359 setup_editor_el_mirror_magic = FALSE;
6360 setup_editor_el_deflektor = FALSE;
6361 setup_editor_el_chars = FALSE;
6362 setup_editor_el_steel_chars = FALSE;
6364 setup_editor_el_custom = FALSE;
6366 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
6368 setup_editor_el_players = FALSE;
6369 setup_editor_el_boulderdash = FALSE;
6370 setup_editor_el_boulderdash_native = FALSE;
6371 setup_editor_el_emerald_mine = FALSE;
6372 setup_editor_el_emerald_mine_club = FALSE;
6373 setup_editor_el_more = FALSE;
6374 setup_editor_el_sokoban = FALSE;
6375 setup_editor_el_supaplex = FALSE;
6376 setup_editor_el_diamond_caves = FALSE;
6377 setup_editor_el_dx_boulderdash = FALSE;
6378 setup_editor_el_steel_chars = FALSE;
6380 setup_editor_el_custom = FALSE;
6384 static void ReinitializeElementList(void)
6386 static boolean initialization_needed = TRUE;
6390 ReinitializeElementList_EnableSections();
6392 if (initialization_needed)
6394 LoadSetup_EditorCascade(); // load last editor cascade state
6396 // initialize editor cascade element from saved cascade state
6397 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6399 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
6400 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
6402 if (IS_EDITOR_CASCADE(*cascade_element))
6404 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
6405 EL_CASCADE_INACTIVE(*cascade_element));
6408 initialization_needed = FALSE;
6411 checked_free(editor_elements);
6413 // reload optional user defined element list for each invocation of editor
6414 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
6415 &num_editor_el_user_defined);
6417 // initialize dynamic level element list for each invocation of editor
6418 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
6419 &num_editor_el_dynamic);
6421 // initialize list of empty elements (used for padding, if needed)
6422 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6423 editor_el_empty[i] = EL_EMPTY;
6425 // do some sanity checks for each element from element list
6426 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6428 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6430 int element = (*editor_elements_info[i].element_list)[j];
6432 if (element >= NUM_FILE_ELEMENTS)
6433 Warn("editor element %d is runtime element", element);
6435 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
6436 Warn("no element description text for element %d", element);
6440 num_editor_elements = 0;
6441 use_el_empty = FALSE;
6443 // determine size of element list
6444 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6446 if (*editor_elements_info[i].setup_value)
6448 boolean found_inactive_cascade = FALSE;
6450 if (setup.editor.el_headlines)
6452 // required for correct padding of palette headline buttons
6453 if (*editor_elements_info[i].headline_list_size > 0)
6454 num_editor_elements += ED_ELEMENTLIST_COLS;
6456 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6458 int element = (*editor_elements_info[i].headline_list)[j];
6460 if (IS_EDITOR_CASCADE_INACTIVE(element))
6461 found_inactive_cascade = TRUE;
6465 if (found_inactive_cascade)
6468 // required for correct padding of palette element buttons
6469 int element_list_size = *editor_elements_info[i].element_list_size;
6471 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6472 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6474 num_editor_elements += element_buttons;
6478 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
6480 // offer at least as many elements as element buttons exist
6481 use_el_empty = TRUE;
6482 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
6484 num_editor_elements += num_editor_el_empty;
6488 num_editor_el_empty = 0;
6491 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
6493 // fill element list
6494 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6496 boolean found_inactive_cascade = FALSE;
6498 if (*editor_elements_info[i].setup_value)
6500 if (setup.editor.el_headlines)
6502 // required for correct padding of palette headline buttons
6503 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6504 ED_ELEMENTLIST_COLS : 0);
6506 for (j = 0; j < headline_size; j++)
6508 // use empty elements for padding of palette headline buttons
6509 int element = (j < *editor_elements_info[i].headline_list_size ?
6510 (*editor_elements_info[i].headline_list)[j] :
6511 editor_el_empty[0]);
6513 editor_elements[pos++] = element;
6515 if (IS_EDITOR_CASCADE_INACTIVE(element))
6516 found_inactive_cascade = TRUE;
6520 if (found_inactive_cascade)
6523 // required for correct padding of palette element buttons
6524 int element_list_size = *editor_elements_info[i].element_list_size;
6526 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6527 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6529 // copy all elements from element list
6530 for (j = 0; j < element_list_size; j++)
6531 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6533 // use empty elements for padding of palette element buttons
6534 for (j = 0; j < element_buttons - element_list_size; j++)
6535 editor_elements[pos++] = editor_el_empty[0];
6539 // (this function is also called before editor gadgets are initialized!)
6540 AdjustElementListScrollbar();
6543 void PrintEditorElementList(void)
6545 boolean *stop = &setup_editor_el_user_defined;
6548 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6550 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6552 if (IS_EDITOR_CASCADE(cascade_element))
6554 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6555 char *headline = element_info[cascade_element_show].editor_description;
6557 PrintLineWithPrefix("# ", "-", 77);
6558 Print("# %s\n", headline);
6559 PrintLineWithPrefix("# ", "-", 77);
6562 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6564 int element = (*editor_elements_info[i].headline_list)[j];
6566 if (IS_EDITOR_CASCADE(element))
6567 element = EL_CHAR_MINUS;
6569 Print("# %s\n", element_info[element].token_name);
6575 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6577 int element = (*editor_elements_info[i].element_list)[j];
6579 Print("# %s\n", element_info[element].token_name);
6587 static void ReinitializeElementListButtons(void)
6589 static boolean last_setup_value_headlines = FALSE;
6590 static boolean initialization_needed = TRUE;
6593 if (!initialization_needed) // check if editor element setup has changed
6595 if (last_setup_value_headlines != setup.editor.el_headlines)
6596 initialization_needed = TRUE;
6598 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6599 if (editor_elements_info[i].last_setup_value !=
6600 *editor_elements_info[i].setup_value)
6601 initialization_needed = TRUE;
6604 if (!initialization_needed)
6607 FreeLevelEditorGadgets();
6608 CreateLevelEditorGadgets();
6610 // store current setup values for next invocation of this function
6611 last_setup_value_headlines = setup.editor.el_headlines;
6612 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6613 editor_elements_info[i].last_setup_value =
6614 *editor_elements_info[i].setup_value;
6616 initialization_needed = FALSE;
6619 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6622 int border_graphic =
6623 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6624 struct GraphicInfo *g = &graphic_info[border_graphic];
6625 Bitmap *src_bitmap = g->bitmap;
6626 int src_x = g->src_x;
6627 int src_y = g->src_y;
6628 int border_size = g->border_size;
6629 int border_xpos = g->width - border_size;
6630 int border_ypos = g->height - border_size;
6631 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6634 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6635 border_size, border_size,
6636 dest_x - border_size, dest_y - border_size);
6637 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6638 border_size, border_size,
6639 dest_x + width, dest_y - border_size);
6640 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6641 border_size, border_size,
6642 dest_x - border_size, dest_y + height);
6643 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6644 border_size, border_size,
6645 dest_x + width, dest_y + height);
6647 for (i = 0; i < width / tilesize; i++)
6649 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6650 tilesize, border_size,
6651 dest_x + i * tilesize, dest_y - border_size);
6652 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6653 tilesize, border_size,
6654 dest_x + i * tilesize, dest_y + height);
6657 for (i = 0; i < height / tilesize; i++)
6659 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6660 border_size, tilesize,
6661 dest_x - border_size, dest_y + i * tilesize);
6662 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6663 border_size, tilesize,
6664 dest_x + width, dest_y + i * tilesize);
6667 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6670 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6672 int xsize_tile = MAX(ed_tilesize, xsize);
6673 int ysize_tile = MAX(ed_tilesize, ysize);
6674 int xsize_full = xsize + 1;
6675 int ysize_full = ysize + 1;
6676 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6677 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6678 Pixel line_color = getTabulatorBarColor();
6680 if (line_color == BLACK_PIXEL) // black => transparent
6683 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6684 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6685 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6688 static void DrawEditorLevelBorderLinesIfNeeded(void)
6690 int xsize = lev_fieldx * ed_tilesize;
6691 int ysize = lev_fieldy * ed_tilesize;
6692 int line_size = getTabulatorBarHeight();
6694 if (!suppressBorderElement())
6697 // draw little border line around editable level playfield
6700 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6703 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6705 if (xsize < SXSIZE && ysize < SYSIZE)
6706 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6709 static void DrawEditorElement(int x, int y, int element)
6711 DrawSizedElement(x, y, element, ed_tilesize);
6714 static void DrawEditorElementThruMask(int x, int y, int element)
6716 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6719 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6721 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6724 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6726 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6727 DrawEditorLevelBorderLinesIfNeeded();
6730 static void DrawDrawingArea(int id)
6732 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6735 int *value = drawingarea_info[id].value;
6736 int area_xsize = drawingarea_info[id].area_xsize;
6737 int area_ysize = drawingarea_info[id].area_ysize;
6738 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6740 for (x = 0; x < area_xsize; x++)
6741 for (y = 0; y < area_ysize; y++)
6742 DrawSizedGraphicExt(drawto,
6743 gi->x + x * tilesize,
6744 gi->y + y * tilesize,
6745 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6748 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6751 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6752 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6754 BlitBitmap(drawto, drawto,
6755 SX + (dx == -1 ? ed_tilesize : 0),
6756 SY + (dy == -1 ? ed_tilesize : 0),
6757 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6758 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6759 SX + (dx == +1 ? ed_tilesize : 0),
6760 SY + (dy == +1 ? ed_tilesize : 0));
6764 x = (dx == 1 ? 0 : ed_fieldx - 1);
6765 for (y = 0; y < ed_fieldy; y++)
6766 DrawEditorElementOrWall(x, y, from_x, from_y);
6770 y = (dy == 1 ? 0 : ed_fieldy - 1);
6771 for (x = 0; x < ed_fieldx; x++)
6772 DrawEditorElementOrWall(x, y, from_x, from_y);
6775 redraw_mask |= REDRAW_FIELD;
6779 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6782 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6785 static void CreateControlButtons(void)
6787 struct GadgetInfo *gi;
6790 // create toolbox buttons
6791 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6793 int type_id = controlbutton_info[i].gadget_id; // same as gadget ID here
6794 int id = controlbutton_info[i].gadget_id;
6795 int type = controlbutton_info[i].gadget_type;
6796 int graphic = controlbutton_info[i].graphic;
6797 struct XYTileSize *pos = controlbutton_info[i].pos;
6798 struct GraphicInfo *gd = &graphic_info[graphic];
6799 Bitmap *deco_bitmap = NULL;
6800 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6801 int tile_size = 0, deco_shift = 0;
6802 boolean deco_masked = FALSE;
6803 int gd_x1 = gd->src_x;
6804 int gd_y1 = gd->src_y;
6805 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6806 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6807 int gd_x1a = gd->src_x + gd->active_xoffset;
6808 int gd_y1a = gd->src_y + gd->active_yoffset;
6809 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6810 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6813 unsigned int event_mask;
6814 int radio_button_nr = RADIO_NR_NONE;
6815 boolean checked = FALSE;
6818 Fail("'controlbutton_info' structure corrupted at index %d -- please fix", i);
6820 if (type == GD_TYPE_RADIO_BUTTON)
6822 event_mask = GD_EVENT_PRESSED;
6823 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6825 if (id == drawing_function)
6830 if (id == GADGET_ID_WRAP_LEFT ||
6831 id == GADGET_ID_WRAP_RIGHT ||
6832 id == GADGET_ID_WRAP_UP ||
6833 id == GADGET_ID_WRAP_DOWN)
6834 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6836 event_mask = GD_EVENT_RELEASED;
6839 if (id == GADGET_ID_PROPERTIES ||
6840 id == GADGET_ID_PALETTE)
6845 else if (id == GADGET_ID_ELEMENT_LEFT ||
6846 id == GADGET_ID_ELEMENT_MIDDLE ||
6847 id == GADGET_ID_ELEMENT_RIGHT)
6852 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6853 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6854 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6856 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6857 editor.button.element_left.tile_size :
6858 id == GADGET_ID_ELEMENT_MIDDLE ?
6859 editor.button.element_middle.tile_size :
6860 id == GADGET_ID_ELEMENT_RIGHT ?
6861 editor.button.element_right.tile_size : 0);
6863 // make sure that decoration does not overlap gadget border
6864 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6866 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6868 deco_xpos = (gd->width - tile_size) / 2;
6869 deco_ypos = (gd->height - tile_size) / 2;
6871 deco_masked = gd->draw_masked;
6879 gi = CreateGadget(GDI_CUSTOM_ID, id,
6880 GDI_CUSTOM_TYPE_ID, type_id,
6881 GDI_IMAGE_ID, graphic,
6882 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6885 GDI_WIDTH, gd->width,
6886 GDI_HEIGHT, gd->height,
6888 GDI_STATE, GD_BUTTON_UNPRESSED,
6889 GDI_RADIO_NR, radio_button_nr,
6890 GDI_CHECKED, checked,
6891 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6892 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6893 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6894 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6895 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6896 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6897 GDI_DECORATION_SIZE, tile_size, tile_size,
6898 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6899 GDI_DECORATION_MASKED, deco_masked,
6900 GDI_EVENT_MASK, event_mask,
6901 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6902 GDI_CALLBACK_ACTION, HandleControlButtons,
6906 Fail("cannot create gadget");
6908 level_editor_gadget[id] = gi;
6911 // these values are not constant, but can change at runtime
6912 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6913 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6914 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6915 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6916 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6917 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6918 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6919 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6920 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6921 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6922 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6923 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6925 // create buttons for scrolling of drawing area and element list
6926 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6928 int id = scrollbutton_info[i].gadget_id;
6929 int type_id = scrollbutton_info[i].gadget_type_id;
6930 int graphic = scrollbutton_info[i].graphic;
6931 struct GraphicInfo *gd = &graphic_info[graphic];
6932 Bitmap *gd_bitmap = gd->bitmap;
6933 int gd_x1 = gd->src_x;
6934 int gd_y1 = gd->src_y;
6935 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6936 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6937 int width = gd->width;
6938 int height = gd->height;
6939 int x = scrollbutton_pos[i].x;
6940 int y = scrollbutton_pos[i].y;
6941 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6944 Fail("'scrollbutton_info' structure corrupted at index %d -- please fix", i);
6946 if (id == GADGET_ID_SCROLL_LIST_UP ||
6947 id == GADGET_ID_SCROLL_LIST_DOWN)
6958 gi = CreateGadget(GDI_CUSTOM_ID, id,
6959 GDI_CUSTOM_TYPE_ID, type_id,
6960 GDI_IMAGE_ID, graphic,
6961 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6966 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6967 GDI_STATE, GD_BUTTON_UNPRESSED,
6968 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6969 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6970 GDI_EVENT_MASK, event_mask,
6971 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6972 GDI_CALLBACK_ACTION, HandleControlButtons,
6976 Fail("cannot create gadget");
6978 level_editor_gadget[id] = gi;
6981 // create buttons for element list
6982 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6985 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6986 int graphic = IMG_EDITOR_PALETTE_BUTTON;
6987 struct GraphicInfo *gd = &graphic_info[graphic];
6988 Bitmap *gd_bitmap = gd->bitmap;
6989 Bitmap *deco_bitmap;
6990 int deco_x, deco_y, deco_xpos, deco_ypos;
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 xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
6996 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
6997 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
6998 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
6999 int element = editor_elements[i];
7000 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
7001 unsigned int event_mask = GD_EVENT_RELEASED;
7003 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
7005 deco_xpos = (gd->width - tile_size) / 2;
7006 deco_ypos = (gd->height - tile_size) / 2;
7008 gi = CreateGadget(GDI_CUSTOM_ID, id,
7009 GDI_CUSTOM_TYPE_ID, type_id,
7010 GDI_IMAGE_ID, graphic,
7011 GDI_INFO_TEXT, getElementInfoText(element),
7014 GDI_WIDTH, gd->width,
7015 GDI_HEIGHT, gd->height,
7016 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7017 GDI_STATE, GD_BUTTON_UNPRESSED,
7018 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
7019 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
7020 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
7021 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
7022 GDI_DECORATION_SIZE, tile_size, tile_size,
7023 GDI_DECORATION_SHIFTING, 1, 1,
7024 GDI_EVENT_MASK, event_mask,
7025 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7026 GDI_CALLBACK_ACTION, HandleControlButtons,
7030 Fail("cannot create gadget");
7032 level_editor_gadget[id] = gi;
7036 static void CreateCounterButtons(void)
7038 int max_infotext_len = getMaxInfoTextLength();
7041 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
7043 int type_id = counterbutton_info[i].gadget_type_id;
7044 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
7045 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
7049 Fail("'counterbutton_info' structure corrupted at index %d -- please fix", i);
7051 // determine horizontal position to the right of specified gadget
7052 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7053 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
7054 ED_GADGET_TEXT_DISTANCE);
7056 // determine horizontal offset for leading text
7057 if (counterbutton_info[i].text_left != NULL)
7058 x += getTextWidthForGadget(counterbutton_info[i].text_left);
7060 for (j = 0; j < 2; j++)
7062 struct GadgetInfo *gi;
7064 counterbutton_info[i].gadget_id_down :
7065 counterbutton_info[i].gadget_id_up);
7067 struct GraphicInfo *gd;
7068 int gd_x1, gd_x2, gd_y1, gd_y2;
7069 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7070 char infotext[max_infotext_len + 1];
7072 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7075 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
7076 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
7078 event_mask |= GD_EVENT_RELEASED;
7082 x = DX + editor.button.prev_level.x;
7083 y = DY + editor.button.prev_level.y;
7087 x = DX + editor.button.next_level.x;
7088 y = DY + editor.button.next_level.y;
7094 IMG_EDITOR_COUNTER_DOWN :
7095 IMG_EDITOR_COUNTER_UP);
7098 gd = &graphic_info[graphic];
7102 gd_x2 = gd->src_x + gd->pressed_xoffset;
7103 gd_y2 = gd->src_y + gd->pressed_yoffset;
7105 sprintf(infotext, "%s counter value by 1, 5 or 10",
7106 (j == 0 ? "decrease" : "increase"));
7108 gi = CreateGadget(GDI_CUSTOM_ID, id,
7109 GDI_CUSTOM_TYPE_ID, type_id,
7110 GDI_IMAGE_ID, graphic,
7111 GDI_INFO_TEXT, infotext,
7114 GDI_WIDTH, gd->width,
7115 GDI_HEIGHT, gd->height,
7116 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7117 GDI_STATE, GD_BUTTON_UNPRESSED,
7118 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7119 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7120 GDI_EVENT_MASK, event_mask,
7121 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7122 GDI_CALLBACK_ACTION, HandleCounterButtons,
7126 Fail("cannot create gadget");
7128 level_editor_gadget[id] = gi;
7129 right_gadget_border[id] =
7130 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7132 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
7136 int font_type = FONT_INPUT_1;
7137 int font_type_active = FONT_INPUT_1_ACTIVE;
7139 id = counterbutton_info[i].gadget_id_text;
7141 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7143 if (i == ED_COUNTER_ID_SELECT_LEVEL)
7145 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
7147 font_type = FONT_LEVEL_NUMBER;
7148 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
7150 x = DX + editor.input.level_number.x;
7151 y = DY + editor.input.level_number.y;
7155 graphic = IMG_EDITOR_COUNTER_INPUT;
7158 gd = &graphic_info[graphic];
7162 gd_x2 = gd->src_x + gd->active_xoffset;
7163 gd_y2 = gd->src_y + gd->active_yoffset;
7165 gi = CreateGadget(GDI_CUSTOM_ID, id,
7166 GDI_CUSTOM_TYPE_ID, type_id,
7167 GDI_IMAGE_ID, graphic,
7168 GDI_INFO_TEXT, "enter counter value",
7171 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
7172 GDI_NUMBER_VALUE, 0,
7173 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
7174 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
7175 GDI_TEXT_SIZE, 3, // minimal counter text size
7176 GDI_TEXT_FONT, font_type,
7177 GDI_TEXT_FONT_ACTIVE, font_type_active,
7178 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7179 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7180 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7181 GDI_DESIGN_WIDTH, gd->width,
7182 GDI_EVENT_MASK, event_mask,
7183 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7184 GDI_CALLBACK_ACTION, HandleCounterButtons,
7188 Fail("cannot create gadget");
7190 level_editor_gadget[id] = gi;
7191 right_gadget_border[id] =
7192 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
7194 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
7200 static void CreateDrawingAreas(void)
7204 // these values are not constant, but can change at runtime
7205 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
7206 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
7208 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
7210 struct GadgetInfo *gi;
7211 int id = drawingarea_info[i].gadget_id;
7212 int type_id = drawingarea_info[i].gadget_type_id;
7213 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
7214 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
7215 int area_xsize = drawingarea_info[i].area_xsize;
7216 int area_ysize = drawingarea_info[i].area_ysize;
7217 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
7218 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
7219 unsigned int event_mask =
7220 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
7221 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
7224 Fail("'drawingarea_info' structure corrupted at index %d -- please fix", i);
7226 // determine horizontal position to the right of specified gadget
7227 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
7228 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
7229 ED_DRAWINGAREA_TEXT_DISTANCE);
7231 // determine horizontal offset for leading text
7232 if (drawingarea_info[i].text_left != NULL)
7233 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
7235 gi = CreateGadget(GDI_CUSTOM_ID, id,
7236 GDI_CUSTOM_TYPE_ID, type_id,
7239 GDI_TYPE, GD_TYPE_DRAWING_AREA,
7240 GDI_AREA_SIZE, area_xsize, area_ysize,
7241 GDI_ITEM_SIZE, item_size, item_size,
7242 GDI_EVENT_MASK, event_mask,
7243 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
7244 GDI_CALLBACK_ACTION, HandleDrawingAreas,
7248 Fail("cannot create gadget");
7250 level_editor_gadget[id] = gi;
7251 right_gadget_border[id] =
7252 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
7256 static void CreateTextInputGadgets(void)
7258 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
7259 int max_infotext_len = getMaxInfoTextLength();
7262 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
7264 int gd_x1 = gd->src_x;
7265 int gd_y1 = gd->src_y;
7266 int gd_x2 = gd->src_x + gd->active_xoffset;
7267 int gd_y2 = gd->src_y + gd->active_yoffset;
7268 struct GadgetInfo *gi;
7269 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7270 char infotext[MAX_OUTPUT_LINESIZE + 1];
7271 int id = textinput_info[i].gadget_id;
7272 int type_id = textinput_info[i].gadget_type_id;
7276 Fail("'textinput_info' structure corrupted at index %d -- please fix", i);
7278 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
7280 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
7281 int border_size = gd->border_size;
7282 int font_nr = FONT_INPUT_1;
7283 int font_height = getFontHeight(font_nr);
7284 int xoffset = element_border + TILEX + element_border + 3 * border_size;
7285 int yoffset = element_border + (TILEY - font_height) / 2;
7287 x = (editor.settings.element_name.x != -1 ?
7288 editor.settings.element_name.x :
7289 editor.settings.element_graphic.x + xoffset) - border_size;
7290 y = (editor.settings.element_name.y != -1 ?
7291 editor.settings.element_name.y :
7292 editor.settings.element_graphic.y + yoffset) - border_size;
7296 x = ED_SETTINGS_X(textinput_info[i].x);
7297 y = ED_SETTINGS_Y(textinput_info[i].y);
7300 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
7301 infotext[max_infotext_len] = '\0';
7303 gi = CreateGadget(GDI_CUSTOM_ID, id,
7304 GDI_CUSTOM_TYPE_ID, type_id,
7305 GDI_INFO_TEXT, infotext,
7308 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
7309 GDI_TEXT_VALUE, textinput_info[i].value,
7310 GDI_TEXT_SIZE, textinput_info[i].size,
7311 GDI_TEXT_FONT, FONT_INPUT_1,
7312 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7313 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7314 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7315 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7316 GDI_DESIGN_WIDTH, gd->width,
7317 GDI_EVENT_MASK, event_mask,
7318 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7319 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
7323 Fail("cannot create gadget");
7325 level_editor_gadget[id] = gi;
7329 static void CreateTextAreaGadgets(void)
7331 int max_infotext_len = getMaxInfoTextLength();
7334 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
7336 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
7337 int gd_x1 = gd->src_x;
7338 int gd_y1 = gd->src_y;
7339 int gd_x2 = gd->src_x + gd->active_xoffset;
7340 int gd_y2 = gd->src_y + gd->active_yoffset;
7341 struct GadgetInfo *gi;
7342 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
7343 char infotext[MAX_OUTPUT_LINESIZE + 1];
7344 int id = textarea_info[i].gadget_id;
7345 int type_id = textarea_info[i].gadget_type_id;
7346 int area_xsize = textarea_info[i].xsize;
7347 int area_ysize = textarea_info[i].ysize;
7350 Fail("'textarea_info' structure corrupted at index %d -- please fix", i);
7352 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
7353 infotext[max_infotext_len] = '\0';
7355 gi = CreateGadget(GDI_CUSTOM_ID, id,
7356 GDI_CUSTOM_TYPE_ID, type_id,
7357 GDI_INFO_TEXT, infotext,
7358 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
7359 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
7360 GDI_TYPE, GD_TYPE_TEXT_AREA,
7361 GDI_AREA_SIZE, area_xsize, area_ysize,
7362 GDI_TEXT_FONT, FONT_INPUT_1,
7363 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7364 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7365 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7366 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7367 GDI_DESIGN_WIDTH, gd->width,
7368 GDI_EVENT_MASK, event_mask,
7369 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7370 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
7374 Fail("cannot create gadget");
7376 level_editor_gadget[id] = gi;
7380 static void CreateSelectboxGadgets(void)
7382 int max_infotext_len = getMaxInfoTextLength();
7385 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7387 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
7388 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
7389 int gd_x1 = gd->src_x;
7390 int gd_y1 = gd->src_y;
7391 int gd_x2 = gd->src_x + gd->active_xoffset;
7392 int gd_y2 = gd->src_y + gd->active_yoffset;
7393 int selectbox_button_xsize = gd2->width;
7394 struct GadgetInfo *gi;
7395 char infotext[MAX_OUTPUT_LINESIZE + 1];
7396 int id = selectbox_info[i].gadget_id;
7397 int type_id = selectbox_info[i].gadget_type_id;
7398 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
7399 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
7400 unsigned int event_mask =
7401 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7404 Fail("'selectbox_info' structure corrupted at index %d -- please fix", i);
7406 if (selectbox_info[i].size == -1) // dynamically determine size
7408 // (we cannot use -1 for uninitialized values if we directly compare
7409 // with results from strlen(), because the '<' and '>' operation will
7410 // implicitely cast -1 to an unsigned integer value!)
7411 selectbox_info[i].size = 0;
7413 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
7414 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
7415 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
7417 selectbox_info[i].size++; // add one character empty space
7420 // determine horizontal position to the right of specified gadget
7421 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
7422 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
7423 ED_GADGET_TEXT_DISTANCE);
7425 // determine horizontal offset for leading text
7426 if (selectbox_info[i].text_left != NULL)
7427 x += getTextWidthForGadget(selectbox_info[i].text_left);
7429 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
7430 infotext[max_infotext_len] = '\0';
7432 gi = CreateGadget(GDI_CUSTOM_ID, id,
7433 GDI_CUSTOM_TYPE_ID, type_id,
7434 GDI_INFO_TEXT, infotext,
7437 GDI_TYPE, GD_TYPE_SELECTBOX,
7438 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
7439 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
7440 GDI_TEXT_SIZE, selectbox_info[i].size,
7441 GDI_TEXT_FONT, FONT_INPUT_1,
7442 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7443 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
7444 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7445 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7446 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7447 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
7448 GDI_DESIGN_WIDTH, gd->width,
7449 GDI_EVENT_MASK, event_mask,
7450 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7451 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
7455 Fail("cannot create gadget");
7457 level_editor_gadget[id] = gi;
7458 right_gadget_border[id] =
7459 getRightGadgetBorder(gi, selectbox_info[i].text_right);
7463 static void CreateTextbuttonGadgets(void)
7465 int max_infotext_len = getMaxInfoTextLength();
7468 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
7470 int id = textbutton_info[i].gadget_id;
7471 int type_id = textbutton_info[i].gadget_type_id;
7473 ((id >= GADGET_ID_LEVELCONFIG_LEVEL && id <= GADGET_ID_LEVELCONFIG_ENGINE) ||
7474 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
7476 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
7477 int gadget_distance =
7478 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
7479 struct GraphicInfo *gd = &graphic_info[graphic];
7480 int gd_x1 = gd->src_x;
7481 int gd_y1 = gd->src_y;
7482 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7483 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7484 int gd_x1a = gd->src_x + gd->active_xoffset;
7485 int gd_y1a = gd->src_y + gd->active_yoffset;
7486 int border_xsize = gd->border_size + gd->draw_xoffset;
7487 int border_ysize = gd->border_size;
7488 struct GadgetInfo *gi;
7489 unsigned int event_mask = GD_EVENT_RELEASED;
7490 char infotext[MAX_OUTPUT_LINESIZE + 1];
7491 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
7492 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
7495 Fail("'textbutton_info' structure corrupted at index %d -- please fix", i);
7497 if (textbutton_info[i].size == -1) // dynamically determine size
7498 textbutton_info[i].size = strlen(textbutton_info[i].text);
7500 sprintf(infotext, "%s", textbutton_info[i].infotext);
7501 infotext[max_infotext_len] = '\0';
7503 // determine horizontal position to the right of specified gadget
7504 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7506 int gadget_id_align = textbutton_info[i].gadget_id_align;
7508 x = right_gadget_border[gadget_id_align] + gadget_distance;
7510 if (textbutton_info[i].y == -1)
7511 y = level_editor_gadget[gadget_id_align]->y;
7514 // determine horizontal offset for leading text
7515 if (textbutton_info[i].text_left != NULL)
7516 x += getTextWidthForGadget(textbutton_info[i].text_left);
7518 gi = CreateGadget(GDI_CUSTOM_ID, id,
7519 GDI_CUSTOM_TYPE_ID, type_id,
7520 GDI_IMAGE_ID, graphic,
7521 GDI_INFO_TEXT, infotext,
7524 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
7525 GDI_TEXT_VALUE, textbutton_info[i].text,
7526 GDI_TEXT_SIZE, textbutton_info[i].size,
7527 GDI_TEXT_FONT, FONT_INPUT_2,
7528 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
7529 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7530 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7531 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7532 GDI_BORDER_SIZE, border_xsize, border_ysize,
7533 GDI_DESIGN_WIDTH, gd->width,
7534 GDI_DECORATION_SHIFTING, 1, 1,
7535 GDI_EVENT_MASK, event_mask,
7536 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7537 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7541 Fail("cannot create gadget");
7543 level_editor_gadget[id] = gi;
7544 right_gadget_border[id] =
7545 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7549 static void CreateGraphicbuttonGadgets(void)
7551 struct GadgetInfo *gi;
7554 // create buttons for scrolling of drawing area and element list
7555 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7557 int id = graphicbutton_info[i].gadget_id;
7558 int type_id = graphicbutton_info[i].gadget_type_id;
7559 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7560 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7561 int graphic = graphicbutton_info[i].graphic;
7562 struct GraphicInfo *gd = &graphic_info[graphic];
7563 int gd_x1 = gd->src_x;
7564 int gd_y1 = gd->src_y;
7565 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7566 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7567 unsigned int event_mask = GD_EVENT_RELEASED;
7570 Fail("'graphicbutton_info' structure corrupted at index %d -- please fix", i);
7572 // determine horizontal position to the right of specified gadget
7573 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7574 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7575 ED_GADGET_TEXT_DISTANCE);
7577 // determine horizontal offset for leading text
7578 if (graphicbutton_info[i].text_left != NULL)
7579 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7581 gi = CreateGadget(GDI_CUSTOM_ID, id,
7582 GDI_CUSTOM_TYPE_ID, type_id,
7583 GDI_IMAGE_ID, graphic,
7584 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7587 GDI_WIDTH, gd->width,
7588 GDI_HEIGHT, gd->height,
7589 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7590 GDI_STATE, GD_BUTTON_UNPRESSED,
7591 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7592 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7593 GDI_EVENT_MASK, event_mask,
7594 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7595 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7599 Fail("cannot create gadget");
7601 level_editor_gadget[id] = gi;
7602 right_gadget_border[id] =
7603 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7607 static void CreateScrollbarGadgets(void)
7611 // these values are not constant, but can change at runtime
7612 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7613 SX + ED_SCROLL_HORIZONTAL_XPOS;
7614 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7615 SY + ED_SCROLL_HORIZONTAL_YPOS;
7616 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7617 ED_SCROLL_HORIZONTAL_XSIZE;
7618 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7619 ED_SCROLL_HORIZONTAL_YSIZE;
7620 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7621 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7622 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7623 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7625 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7626 SX + ED_SCROLL_VERTICAL_XPOS;
7627 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7628 SY + ED_SCROLL_VERTICAL_YPOS;
7629 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7630 ED_SCROLL_VERTICAL_XSIZE;
7631 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7632 ED_SCROLL_VERTICAL_YSIZE;
7633 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7634 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7635 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7636 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7638 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7639 PX + ED_SCROLL2_VERTICAL_XPOS;
7640 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7641 PY + ED_SCROLL2_VERTICAL_YPOS;
7642 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7643 ED_SCROLL2_VERTICAL_XSIZE;
7644 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7645 ED_SCROLL2_VERTICAL_YSIZE;
7646 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7647 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7648 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7649 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7651 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7653 int id = scrollbar_info[i].gadget_id;
7654 int type_id = scrollbar_info[i].gadget_type_id;
7655 int graphic = scrollbar_info[i].graphic;
7656 struct GraphicInfo *gd = &graphic_info[graphic];
7657 int gd_x1 = gd->src_x;
7658 int gd_y1 = gd->src_y;
7659 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7660 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7661 struct GadgetInfo *gi;
7662 int items_max, items_visible, item_position;
7663 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7666 Fail("'scrollbar_info' structure corrupted at index %d -- please fix", i);
7668 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7670 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7671 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7672 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7674 else // drawing area scrollbars
7676 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7678 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7679 items_visible = ed_fieldx;
7684 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7685 items_visible = ed_fieldy;
7690 gi = CreateGadget(GDI_CUSTOM_ID, id,
7691 GDI_CUSTOM_TYPE_ID, type_id,
7692 GDI_IMAGE_ID, graphic,
7693 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7694 GDI_X, scrollbar_pos[i].x,
7695 GDI_Y, scrollbar_pos[i].y,
7696 GDI_WIDTH, scrollbar_pos[i].width,
7697 GDI_HEIGHT, scrollbar_pos[i].height,
7698 GDI_TYPE, scrollbar_info[i].type,
7699 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7700 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7701 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7702 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7703 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7704 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7705 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7706 GDI_STATE, GD_BUTTON_UNPRESSED,
7707 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7708 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7709 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7710 GDI_EVENT_MASK, event_mask,
7711 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7712 GDI_CALLBACK_ACTION, HandleControlButtons,
7716 Fail("cannot create gadget");
7718 level_editor_gadget[id] = gi;
7722 static void CreateCheckbuttonGadgets(void)
7724 struct GadgetInfo *gi;
7727 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7729 int id = checkbutton_info[i].gadget_id;
7730 int type_id = checkbutton_info[i].gadget_type_id;
7731 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7732 IMG_EDITOR_CHECKBOX);
7733 struct GraphicInfo *gd = &graphic_info[graphic];
7734 int gd_x1 = gd->src_x;
7735 int gd_y1 = gd->src_y;
7736 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7737 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7738 int gd_x1a = gd->src_x + gd->active_xoffset;
7739 int gd_y1a = gd->src_y + gd->active_yoffset;
7740 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7741 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7742 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7743 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7744 unsigned int event_mask = GD_EVENT_PRESSED;
7747 Fail("'checkbutton_info' structure corrupted at index %d -- please fix", i);
7749 // determine horizontal position to the right of specified gadget
7750 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7751 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7752 ED_GADGET_TEXT_DISTANCE);
7754 // determine horizontal offset for leading text
7755 if (checkbutton_info[i].text_left != NULL)
7756 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7758 gi = CreateGadget(GDI_CUSTOM_ID, id,
7759 GDI_CUSTOM_TYPE_ID, type_id,
7760 GDI_IMAGE_ID, graphic,
7761 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7764 GDI_WIDTH, gd->width,
7765 GDI_HEIGHT, gd->height,
7766 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7767 GDI_CHECKED, *checkbutton_info[i].value,
7768 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7769 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7770 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7771 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7772 GDI_EVENT_MASK, event_mask,
7773 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7774 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7778 Fail("cannot create gadget");
7780 level_editor_gadget[id] = gi;
7781 right_gadget_border[id] =
7782 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7786 static void CreateRadiobuttonGadgets(void)
7788 int graphic = IMG_EDITOR_RADIOBUTTON;
7789 struct GraphicInfo *gd = &graphic_info[graphic];
7790 int gd_x1 = gd->src_x;
7791 int gd_y1 = gd->src_y;
7792 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7793 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7794 int gd_x1a = gd->src_x + gd->active_xoffset;
7795 int gd_y1a = gd->src_y + gd->active_yoffset;
7796 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7797 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7798 struct GadgetInfo *gi;
7801 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7803 int id = radiobutton_info[i].gadget_id;
7804 int type_id = radiobutton_info[i].gadget_type_id;
7805 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7806 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7807 unsigned int event_mask = GD_EVENT_PRESSED;
7810 Fail("'radiobutton_info' structure corrupted at index %d -- please fix", i);
7813 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7815 // determine horizontal position to the right of specified gadget
7816 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7817 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7818 ED_GADGET_TEXT_DISTANCE);
7820 // determine horizontal offset for leading text
7821 if (radiobutton_info[i].text_left != NULL)
7822 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7824 gi = CreateGadget(GDI_CUSTOM_ID, id,
7825 GDI_CUSTOM_TYPE_ID, type_id,
7826 GDI_IMAGE_ID, graphic,
7827 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7830 GDI_WIDTH, gd->width,
7831 GDI_HEIGHT, gd->height,
7832 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7833 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7834 GDI_CHECKED, checked,
7835 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7836 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7837 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7838 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7839 GDI_EVENT_MASK, event_mask,
7840 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7841 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7845 Fail("cannot create gadget");
7847 level_editor_gadget[id] = gi;
7848 right_gadget_border[id] =
7849 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7853 void CreateLevelEditorGadgets(void)
7855 // force EDITOR font inside level editor
7856 SetFontStatus(GAME_MODE_EDITOR);
7858 // these values are not constant, but can change at runtime
7859 ed_fieldx = MAX_ED_FIELDX - 1;
7860 ed_fieldy = MAX_ED_FIELDY - 1;
7862 num_editor_gadgets = NUM_EDITOR_GADGETS;
7864 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7866 level_editor_gadget =
7867 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7868 right_gadget_border =
7869 checked_calloc(num_editor_gadgets * sizeof(int));
7871 // set number of empty (padding) element buttons to maximum number of buttons
7872 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7874 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7875 editor_el_empty_ptr = editor_el_empty;
7877 use_permanent_palette = !editor.palette.show_as_separate_screen;
7879 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
7881 ReinitializeElementList();
7883 CreateControlButtons();
7884 CreateScrollbarGadgets();
7886 // order of function calls is important because of cross-references
7887 CreateCheckbuttonGadgets();
7888 CreateCounterButtons();
7889 CreateRadiobuttonGadgets();
7890 CreateTextInputGadgets();
7891 CreateTextAreaGadgets();
7892 CreateSelectboxGadgets();
7893 CreateGraphicbuttonGadgets();
7894 CreateTextbuttonGadgets();
7895 CreateDrawingAreas();
7900 void FreeLevelEditorGadgets(void)
7904 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
7906 for (i = 0; i < num_editor_gadgets; i++)
7908 FreeGadget(level_editor_gadget[i]);
7910 level_editor_gadget[i] = NULL;
7913 checked_free(level_editor_gadget);
7914 checked_free(right_gadget_border);
7916 checked_free(editor_el_empty);
7919 static void MapCounterButtons(int id)
7921 int font_nr = FONT_TEXT_1;
7922 int font_height = getFontHeight(font_nr);
7923 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7924 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7925 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7926 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7927 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7928 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7929 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7930 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7931 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7932 int yoffset = (gi_down->height - font_height) / 2;
7933 int x_left = gi_down->x - xoffset_left;
7934 int x_right; // set after gadget position was modified
7935 int y_above = gi_down->y - yoffset_above;
7937 int y; // set after gadget position was modified
7939 // counter limits must be changed first to prevent value truncation
7940 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7941 counterbutton_info[id].max_value);
7943 // right text position might have changed after setting position above
7944 x_right = gi_up->x + gi_up->width + xoffset_right;
7946 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7948 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
7949 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7950 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7952 ModifyGadget(gi_down, GDI_Y,
7953 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7954 ModifyGadget(gi_text, GDI_Y,
7955 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7956 ModifyGadget(gi_up, GDI_Y,
7957 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7960 // vertical position might have changed after setting position above
7961 y = gi_up->y + yoffset;
7963 if (counterbutton_info[id].text_above)
7964 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
7966 if (counterbutton_info[id].text_left)
7967 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7969 if (counterbutton_info[id].text_right)
7970 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7977 static void MapControlButtons(void)
7982 // map toolbox buttons (excluding special CE toolbox buttons)
7983 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7984 MapGadget(level_editor_gadget[i]);
7986 // map toolbox buttons (element properties buttons)
7987 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
7988 MapGadget(level_editor_gadget[i]);
7990 if (use_permanent_palette)
7992 // map buttons to select elements
7993 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7994 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
7995 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
7996 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
7997 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
8000 // map buttons to select level
8001 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
8002 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
8003 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
8004 MapCounterButtons(counter_id);
8007 static void MapDrawingArea(int id)
8009 int font_nr = FONT_TEXT_1;
8010 int font_height = getFontHeight(font_nr);
8011 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
8012 int area_xsize = gi->drawing.area_xsize;
8013 int area_ysize = gi->drawing.area_ysize;
8014 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
8015 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
8016 int x_left = gi->x - xoffset_left;
8017 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
8018 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
8019 int x_below = gi->x + (gi->width - xoffset_below) / 2;
8020 int y_side = gi->y + (gi->height - font_height) / 2;
8021 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
8022 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
8024 if (drawingarea_info[id].text_left)
8025 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
8027 if (drawingarea_info[id].text_right)
8028 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
8030 if (drawingarea_info[id].text_above)
8031 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
8033 if (drawingarea_info[id].text_below)
8034 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
8036 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
8038 DrawElementBorder(gi->x, gi->y,
8039 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
8040 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
8042 DrawDrawingArea(id);
8048 static void MapTextInputGadget(int id)
8050 int font_nr = FONT_TEXT_1;
8051 int font_height = getFontHeight(font_nr);
8052 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
8053 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8054 int x_above = ED_SETTINGS_X(textinput_info[id].x);
8055 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
8057 if (textinput_info[id].text_above)
8058 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
8060 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
8065 static void MapTextAreaGadget(int id)
8067 int font_nr = FONT_TEXT_1;
8068 int font_height = getFontHeight(font_nr);
8069 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
8070 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8071 int x_above = ED_SETTINGS_X(textarea_info[id].x);
8072 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
8073 char *text_above = textarea_info[id].text_above;
8075 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
8076 text_above = textarea_info[id].text_above_cropped;
8079 DrawTextS(x_above, y_above, font_nr, text_above);
8081 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
8086 static void MapSelectboxGadget(int id)
8088 int font_nr = FONT_TEXT_1;
8089 int font_height = getFontHeight(font_nr);
8090 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
8091 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
8092 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8093 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8094 int yoffset = (gi->height - font_height) / 2;
8095 int x_left = gi->x - xoffset_left;
8096 int x_right = gi->x + gi->width + xoffset_right;
8097 int y_above = gi->y - yoffset_above;
8099 int y = gi->y + yoffset;
8101 if (selectbox_info[id].text_above)
8102 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
8104 if (selectbox_info[id].text_left)
8105 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
8107 if (selectbox_info[id].text_right)
8108 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
8110 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
8115 static void MapTextbuttonGadget(int id)
8117 int font_nr = FONT_TEXT_1;
8118 int font_height = getFontHeight(font_nr);
8119 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
8120 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
8121 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8122 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8123 int yoffset = (gi->height - font_height) / 2;
8124 int x_left = gi->x - xoffset_left;
8125 int x_right = gi->x + gi->width + xoffset_right;
8126 int y_above = gi->y - yoffset_above;
8128 int y = gi->y + yoffset;
8130 // only show button to delete change pages when more than minimum pages
8131 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
8132 custom_element.num_change_pages == MIN_CHANGE_PAGES)
8135 if (textbutton_info[id].text_above)
8136 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
8138 if (textbutton_info[id].text_left)
8139 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
8141 if (textbutton_info[id].text_right)
8142 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
8147 static void MapGraphicbuttonGadget(int id)
8149 int font_nr = FONT_TEXT_1;
8150 int font_height = getFontHeight(font_nr);
8151 struct GadgetInfo *gi = level_editor_gadget[graphicbutton_info[id].gadget_id];
8152 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
8153 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8154 int yoffset = (gi->height - font_height) / 2;
8155 int x_left = gi->x - xoffset_left;
8156 int x_right = gi->x + gi->width + xoffset_right;
8157 int y = gi->y + yoffset;
8159 if (graphicbutton_info[id].text_left)
8160 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
8162 if (graphicbutton_info[id].text_right)
8163 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
8168 static void MapRadiobuttonGadget(int id)
8170 int font_nr = FONT_TEXT_1;
8171 int font_height = getFontHeight(font_nr);
8172 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
8173 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8174 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8175 int yoffset = (gi->height - font_height) / 2;
8176 int x_left = gi->x - xoffset_left;
8177 int x_right = gi->x + gi->width + xoffset_right;
8178 int y = gi->y + yoffset;
8180 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
8182 if (radiobutton_info[id].text_left)
8183 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
8185 if (radiobutton_info[id].text_right)
8186 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
8188 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
8193 static void MapCheckbuttonGadget(int id)
8195 int font_nr = FONT_TEXT_1;
8196 int font_height = getFontHeight(font_nr);
8197 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
8198 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
8199 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
8200 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
8201 int yoffset = (gi->height - font_height) / 2;
8202 int y_above = gi->y - yoffset_above;
8204 int x_left, x_right, y; // set after gadget position was modified
8206 // set position for gadgets with dynamically determined position
8207 if (checkbutton_info[id].x != -1) // do not change dynamic positions
8208 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x), GDI_END);
8209 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
8211 x_left = gi->x - xoffset_left;
8212 x_right = gi->x + gi->width + xoffset_right;
8213 y = gi->y + yoffset;
8215 if (checkbutton_info[id].text_above)
8216 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
8218 if (checkbutton_info[id].text_left)
8219 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
8221 if (checkbutton_info[id].text_right)
8222 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
8224 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
8229 static void MapMainDrawingArea(void)
8231 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
8232 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
8235 if (suppressBorderElement())
8237 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
8238 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
8241 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
8243 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
8244 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
8245 no_horizontal_scrollbar) ||
8246 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
8247 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
8248 no_vertical_scrollbar))
8251 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
8254 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
8256 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
8257 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
8260 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
8263 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
8266 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
8270 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
8272 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
8273 i == GADGET_ID_CUSTOM_COPY_TO ||
8274 i == GADGET_ID_CUSTOM_EXCHANGE ||
8275 i == GADGET_ID_CUSTOM_COPY ||
8276 i == GADGET_ID_CUSTOM_PASTE)
8279 MapGadget(level_editor_gadget[i]);
8281 UnmapGadget(level_editor_gadget[i]);
8286 static void MapLevelEditorToolboxCustomGadgets(void)
8288 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
8291 static void MapLevelEditorToolboxCustomGadgetsIfNeeded(void)
8293 if (IS_CUSTOM_ELEMENT(properties_element) ||
8294 IS_GROUP_ELEMENT(properties_element) ||
8295 IS_EMPTY_ELEMENT(properties_element))
8296 MapLevelEditorToolboxCustomGadgets();
8299 static void UnmapLevelEditorToolboxCustomGadgets(void)
8301 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
8304 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
8308 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
8310 if (i != GADGET_ID_SINGLE_ITEMS &&
8311 i != GADGET_ID_PICK_ELEMENT)
8313 struct GadgetInfo *gi = level_editor_gadget[i];
8321 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
8322 struct GraphicInfo *gd = &graphic_info[graphic];
8326 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
8327 gi->width, gi->height, gi->x, gi->y);
8329 redraw_mask |= REDRAW_DOOR_3;
8335 static void MapLevelEditorToolboxDrawingGadgets(void)
8337 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
8340 static void UnmapLevelEditorToolboxDrawingGadgets(void)
8342 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
8345 static void UnmapDrawingArea(int id)
8347 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
8350 static void UnmapLevelEditorFieldGadgets(void)
8354 for (i = 0; i < num_editor_gadgets; i++)
8355 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
8356 level_editor_gadget[i]->y))
8357 UnmapGadget(level_editor_gadget[i]);
8360 void UnmapLevelEditorGadgets(void)
8364 for (i = 0; i < num_editor_gadgets; i++)
8365 UnmapGadget(level_editor_gadget[i]);
8368 static void ResetUndoBuffer(void)
8370 undo_buffer_position = -1;
8371 undo_buffer_steps = -1;
8372 redo_buffer_steps = 0;
8374 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8376 level.changed = FALSE;
8379 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
8381 if (remap_toolbox_gadgets)
8383 ModifyEditorElementList();
8384 RedrawDrawingElements();
8387 if (edit_mode == ED_MODE_LEVELCONFIG)
8388 DrawLevelConfigWindow();
8389 else if (edit_mode == ED_MODE_PROPERTIES)
8390 DrawPropertiesWindow();
8391 else if (edit_mode == ED_MODE_PALETTE)
8392 DrawPaletteWindow();
8393 else // edit_mode == ED_MODE_DRAWING
8394 DrawDrawingWindowExt(remap_toolbox_gadgets);
8397 static void DrawEditModeWindow(void)
8399 DrawEditModeWindowExt(TRUE);
8402 static void DrawEditModeWindow_PlayfieldOnly(void)
8404 DrawEditModeWindowExt(FALSE);
8407 static void ChangeEditModeWindow(int new_edit_mode)
8409 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
8411 DrawEditModeWindow();
8414 static boolean LevelChanged(void)
8416 boolean field_changed = FALSE;
8419 for (y = 0; y < lev_fieldy; y++)
8420 for (x = 0; x < lev_fieldx; x++)
8421 if (Tile[x][y] != level.field[x][y])
8422 field_changed = TRUE;
8424 return (level.changed || field_changed);
8427 static boolean PrepareSavingIntoPersonalLevelSet(void)
8429 static LevelDirTree *last_copied_leveldir = NULL;
8430 static LevelDirTree *last_written_leveldir = NULL;
8431 static int last_copied_level_nr = -1;
8432 static int last_written_level_nr = -1;
8433 LevelDirTree *leveldir_former = leveldir_current;
8434 int level_nr_former = level_nr;
8437 // remember last mod/save so that for current session, we write
8438 // back to the same personal copy, asking only about overwrite.
8439 if (leveldir_current == last_copied_leveldir &&
8440 level_nr == last_copied_level_nr)
8442 // "cd" to personal level set dir (as used when writing last copy)
8443 leveldir_current = last_written_leveldir;
8444 level_nr = last_written_level_nr;
8449 if (!Request("This level is read-only! "
8450 "Save into personal level set?", REQ_ASK))
8453 // "cd" to personal level set dir (for writing copy the first time)
8455 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
8457 // this may happen if "setup.internal.create_user_levelset" is FALSE
8458 // or if file "levelinfo.conf" is missing in personal user level set
8459 if (leveldir_current == NULL)
8461 Request("Cannot find personal level set?!", REQ_CONFIRM);
8463 leveldir_current = leveldir_former;
8468 // find unused level number
8469 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
8471 static char *level_filename = NULL;
8473 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
8475 if (!fileExists(level_filename))
8479 last_copied_leveldir = leveldir_former;
8480 last_copied_level_nr = level_nr_former;
8482 last_written_leveldir = leveldir_current;
8483 last_written_level_nr = level_nr = new_level_nr;
8488 static void ModifyLevelConfigForSavingIntoPersonalLevelSet(char *former_name)
8490 static char *filename_levelinfo = NULL, *mod_name = NULL;
8493 // annotate this copy-and-mod in personal levelinfo.conf
8494 setString(&filename_levelinfo,
8495 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
8497 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
8499 fprintf(file, "\n");
8500 fprintf(file, "# level %d was modified from:\n", level_nr);
8501 fprintf(file, "# - previous level set name: %s\n",
8503 fprintf(file, "# - level within previous set: %d \"%s\"\n",
8504 level.file_info.nr, level.name);
8505 fprintf(file, "# - previous author: %s\n",
8507 fprintf(file, "# - previous save date: ");
8509 if (level.creation_date.src == DATE_SRC_LEVELFILE)
8511 fprintf(file, "%04d-%02d-%02d\n",
8512 level.creation_date.year,
8513 level.creation_date.month,
8514 level.creation_date.day);
8518 fprintf(file, "not recorded\n");
8524 if (level_nr > leveldir_current->last_level)
8525 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
8527 // else: allow the save even if annotation failed
8529 // now... spray graffiti on the old level vital statistics
8530 // user can change these; just trying to set a good baseline
8532 // don't truncate names for fear of making offensive or silly:
8533 // long-named original author only recorded in levelinfo.conf.
8534 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
8535 if (!strEqual(level.author, leveldir_current->author))
8537 setString(&mod_name, getStringCat3(leveldir_current->author,
8538 " after ", level.author));
8540 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8541 setString(&mod_name,
8542 getStringCat2(leveldir_current->author, " (ed.)"));
8544 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8545 setString(&mod_name, leveldir_current->author);
8547 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
8549 // less worried about truncation here
8550 setString(&mod_name, getStringCat2("Mod: ", level.name));
8551 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
8555 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
8556 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8560 for (x = 0; x < lev_fieldx; x++)
8561 for (y = 0; y < lev_fieldy; y++)
8562 dst[x][y] = src[x][y];
8565 static int setSelectboxValue(int selectbox_id, int new_value)
8567 int new_index_value = 0;
8570 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8571 if (selectbox_info[selectbox_id].options[i].value == new_value)
8572 new_index_value = i;
8574 *selectbox_info[selectbox_id].value =
8575 selectbox_info[selectbox_id].options[new_index_value].value;
8577 return new_index_value;
8580 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8584 // change action mode and arg variables according to action type variable
8585 for (i = 0; action_arg_options[i].value != -1; i++)
8587 if (action_arg_options[i].value == custom_element_change.action_type)
8589 int mode = action_arg_options[i].mode;
8591 // only change if corresponding selectbox has changed
8592 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8593 action_arg_modes[mode])
8594 custom_element_change.action_mode = -1;
8596 // only change if corresponding selectbox has changed
8597 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8598 action_arg_options[i].options)
8599 custom_element_change.action_arg = -1;
8606 static void setSelectboxSpecialActionOptions(void)
8610 // change action mode and arg selectbox according to action type selectbox
8611 for (i = 0; action_arg_options[i].value != -1; i++)
8613 if (action_arg_options[i].value == custom_element_change.action_type)
8615 int mode = action_arg_options[i].mode;
8617 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8618 action_arg_modes[mode]);
8619 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8620 custom_element_change.action_mode);
8622 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8623 action_arg_options[i].options);
8624 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8625 custom_element_change.action_arg);
8631 static void copy_custom_element_settings(int element_from, int element_to)
8633 struct ElementInfo *ei_from = &element_info[element_from];
8634 struct ElementInfo *ei_to = &element_info[element_to];
8636 copyElementInfo(ei_from, ei_to);
8639 static void replace_custom_element_in_settings(int element_from,
8644 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8646 struct ElementInfo *ei = &element_info[i];
8648 for (y = 0; y < 3; y++)
8649 for (x = 0; x < 3; x++)
8650 if (ei->content.e[x][y] == element_from)
8651 ei->content.e[x][y] = element_to;
8653 for (j = 0; j < ei->num_change_pages; j++)
8655 struct ElementChangeInfo *change = &ei->change_page[j];
8657 if (change->target_element == element_from)
8658 change->target_element = element_to;
8660 if (change->initial_trigger_element == element_from)
8661 change->initial_trigger_element = element_to;
8663 if (change->action_element == element_from)
8664 change->action_element = element_to;
8666 for (y = 0; y < 3; y++)
8667 for (x = 0; x < 3; x++)
8668 if (change->target_content.e[x][y] == element_from)
8669 change->target_content.e[x][y] = element_to;
8672 if (ei->group != NULL) // group or internal
8673 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8674 if (ei->group->element[j] == element_from)
8675 ei->group->element[j] = element_to;
8679 static void replace_custom_element_in_playfield(int element_from,
8684 for (x = 0; x < lev_fieldx; x++)
8685 for (y = 0; y < lev_fieldy; y++)
8686 if (Tile[x][y] == element_from)
8687 Tile[x][y] = element_to;
8690 static boolean CopyCustomElement(int element_old, int element_new,
8693 int copy_mode_orig = copy_mode;
8695 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8697 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8698 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8699 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8701 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8703 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8704 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8705 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8707 level.changed = TRUE;
8709 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8711 Request("Please choose custom element!", REQ_CONFIRM);
8715 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8717 Request("Please choose group element!", REQ_CONFIRM);
8721 else if (IS_EMPTY_ELEMENT(element_old) && !IS_EMPTY_ELEMENT(element_new))
8723 Request("Please choose empty element!", REQ_CONFIRM);
8729 level.changed = TRUE;
8732 // when modifying custom/group element, ask for copying level template
8733 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8735 if (!AskToCopyAndModifyLevelTemplate())
8739 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8741 copy_custom_element_settings(element_new, element_old);
8743 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8745 copy_custom_element_settings(element_old, element_new);
8747 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8749 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8750 copy_custom_element_settings(element_new, element_old);
8751 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8753 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8754 replace_custom_element_in_settings(element_new, element_old);
8755 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8757 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8758 replace_custom_element_in_playfield(element_new, element_old);
8759 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8762 UpdateCustomElementGraphicGadgets();
8763 DrawPropertiesWindow();
8768 static void CopyCustomElementPropertiesToEditor(int element)
8771 int current_change_page = element_info[element].current_change_page;
8773 // dynamically (re)build selectbox for selecting change page
8774 for (i = 0; i < element_info[element].num_change_pages; i++)
8776 sprintf(options_change_page_strings[i], "%d", i + 1);
8778 options_change_page[i].value = i;
8779 options_change_page[i].text = options_change_page_strings[i];
8782 options_change_page[i].value = -1;
8783 options_change_page[i].text = NULL;
8785 // needed here to initialize combined element properties
8786 InitElementPropertiesEngine(level.game_version);
8788 element_info[element].change =
8789 &element_info[element].change_page[current_change_page];
8791 custom_element = element_info[element];
8792 custom_element_change = *element_info[element].change;
8794 // needed to initially set selectbox options for special action options
8795 setSelectboxSpecialActionOptions();
8797 // needed to initially set selectbox value variables to reliable defaults
8798 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8799 setSelectboxValue(i, *selectbox_info[i].value);
8801 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8802 custom_element_properties[i] = HAS_PROPERTY(element, i);
8804 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8805 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8807 // ---------- element settings: configure (custom elements) -----------------
8809 // set accessible layer selectbox help value
8810 custom_element.access_type =
8811 (IS_WALKABLE(element) ? EP_WALKABLE :
8812 IS_PASSABLE(element) ? EP_PASSABLE :
8813 custom_element.access_type);
8814 custom_element.access_layer =
8815 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8816 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8817 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8818 custom_element.access_layer);
8819 custom_element.access_protected =
8820 (IS_PROTECTED(element) ? 1 : 0);
8821 custom_element_properties[EP_ACCESSIBLE] =
8822 (IS_ACCESSIBLE_OVER(element) ||
8823 IS_ACCESSIBLE_INSIDE(element) ||
8824 IS_ACCESSIBLE_UNDER(element));
8826 // set walk-to-object action selectbox help value
8827 custom_element.walk_to_action =
8828 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8829 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8830 IS_DROPPABLE(element) ? EP_DROPPABLE :
8831 IS_THROWABLE(element) ? EP_THROWABLE :
8832 IS_PUSHABLE(element) ? EP_PUSHABLE :
8833 custom_element.walk_to_action);
8834 custom_element_properties[EP_WALK_TO_OBJECT] =
8835 (IS_DIGGABLE(element) ||
8836 IS_COLLECTIBLE_ONLY(element) ||
8837 IS_DROPPABLE(element) ||
8838 IS_THROWABLE(element) ||
8839 IS_PUSHABLE(element));
8841 // set smash targets selectbox help value
8842 custom_element.smash_targets =
8843 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8844 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8845 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8846 custom_element.smash_targets);
8847 custom_element_properties[EP_CAN_SMASH] =
8848 (CAN_SMASH_EVERYTHING(element) ||
8849 CAN_SMASH_ENEMIES(element) ||
8850 CAN_SMASH_PLAYER(element));
8852 // set deadliness selectbox help value
8853 custom_element.deadliness =
8854 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8855 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8856 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8857 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8858 custom_element.deadliness);
8859 custom_element_properties[EP_DEADLY] =
8860 (DONT_TOUCH(element) ||
8861 DONT_GET_HIT_BY(element) ||
8862 DONT_COLLIDE_WITH(element) ||
8863 DONT_RUN_INTO(element));
8865 // ---------- element settings: advanced (custom elements) ------------------
8867 // set "change by direct action" selectbox help value
8868 custom_element_change.direct_action =
8869 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
8870 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8871 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8872 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8873 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8874 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8875 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8876 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8877 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8878 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8879 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8880 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8881 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8882 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8883 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8884 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8885 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8886 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8887 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8888 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
8889 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
8890 custom_element_change.direct_action);
8892 // set "change by other element action" selectbox help value
8893 custom_element_change.other_action =
8894 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
8895 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8896 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8897 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8898 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8899 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8900 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8901 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8902 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8903 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8904 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8905 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
8906 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8907 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8908 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8909 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8910 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8911 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8912 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8913 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8914 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8915 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8916 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8917 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8918 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8919 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
8920 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
8921 custom_element_change.other_action);
8924 static void CopyGroupElementPropertiesToEditor(int element)
8926 group_element_info = *element_info[element].group;
8927 custom_element = element_info[element]; // needed for description
8930 static void CopyEmptyElementPropertiesToEditor(int element)
8932 custom_element = element_info[element];
8935 static void CopyClassicElementPropertiesToEditor(int element)
8937 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8938 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
8939 getMoveIntoAcidProperty(&level, element);
8941 if (MAYBE_DONT_COLLIDE_WITH(element))
8942 custom_element_properties[EP_DONT_COLLIDE_WITH] =
8943 getDontCollideWithProperty(&level, element);
8946 static void CopyElementPropertiesToEditor(int element)
8948 if (IS_CUSTOM_ELEMENT(element))
8949 CopyCustomElementPropertiesToEditor(element);
8950 else if (IS_GROUP_ELEMENT(element))
8951 CopyGroupElementPropertiesToEditor(element);
8952 else if (IS_EMPTY_ELEMENT(element))
8953 CopyEmptyElementPropertiesToEditor(element);
8955 CopyClassicElementPropertiesToEditor(element);
8958 static boolean AskToCopyAndModifyLevelTemplate(void)
8960 if (Request("Copy and modify settings from level template?", REQ_ASK))
8962 level.use_custom_template = FALSE;
8964 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
8965 GDI_CHECKED, FALSE, GDI_END);
8966 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
8967 GDI_CHECKED, FALSE, GDI_END);
8973 LoadLevelTemplate(-1); // this resets all element modifications ...
8975 DrawEditModeWindow(); // ... and copies them to 'custom_element'
8981 static void CopyCustomElementPropertiesToGame(int element)
8984 int access_type_and_layer;
8986 // mark that this custom element has been modified
8987 custom_element.modified_settings = TRUE;
8988 level.changed = TRUE;
8990 if (level.use_custom_template)
8991 AskToCopyAndModifyLevelTemplate();
8993 element_info[element] = custom_element;
8994 *element_info[element].change = custom_element_change;
8996 // ---------- element settings: configure (custom elements) -----------------
8998 // set accessible property from checkbox and selectbox
8999 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
9000 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
9001 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
9002 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
9003 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
9004 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
9005 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
9006 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
9007 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
9008 custom_element_properties[access_type_and_layer] =
9009 custom_element_properties[EP_ACCESSIBLE];
9010 custom_element_properties[EP_PROTECTED] =
9011 (custom_element.access_protected != 0 &&
9012 custom_element_properties[EP_ACCESSIBLE]);
9014 // set walk-to-object property from checkbox and selectbox
9015 custom_element_properties[EP_DIGGABLE] = FALSE;
9016 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
9017 custom_element_properties[EP_DROPPABLE] = FALSE;
9018 custom_element_properties[EP_THROWABLE] = FALSE;
9019 custom_element_properties[EP_PUSHABLE] = FALSE;
9020 custom_element_properties[custom_element.walk_to_action] =
9021 custom_element_properties[EP_WALK_TO_OBJECT];
9023 // set smash property from checkbox and selectbox
9024 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
9025 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
9026 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
9027 custom_element_properties[custom_element.smash_targets] =
9028 custom_element_properties[EP_CAN_SMASH];
9030 // set deadliness property from checkbox and selectbox
9031 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
9032 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
9033 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
9034 custom_element_properties[EP_DONT_TOUCH] = FALSE;
9035 custom_element_properties[custom_element.deadliness] =
9036 custom_element_properties[EP_DEADLY];
9038 // ---------- element settings: advanced (custom elements) ------------------
9040 // set player change event from checkbox and selectbox
9041 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
9042 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
9043 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
9044 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
9045 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
9046 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
9047 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
9048 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
9049 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
9050 custom_element_change_events[CE_SWITCHED] = FALSE;
9051 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
9052 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
9053 custom_element_change_events[CE_BLOCKED] = FALSE;
9054 custom_element_change_events[CE_IMPACT] = FALSE;
9055 custom_element_change_events[CE_SMASHED] = FALSE;
9056 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
9057 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
9058 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
9059 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
9060 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
9061 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
9062 custom_element_change_events[custom_element_change.direct_action] =
9063 custom_element_change_events[CE_BY_DIRECT_ACTION];
9065 // set other element action change event from checkbox and selectbox
9066 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
9067 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
9068 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
9069 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
9070 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
9071 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
9072 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
9073 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
9074 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
9075 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
9076 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
9077 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
9078 custom_element_change_events[CE_TOUCHING_X] = FALSE;
9079 custom_element_change_events[CE_HITTING_X] = FALSE;
9080 custom_element_change_events[CE_DIGGING_X] = FALSE;
9081 custom_element_change_events[CE_HIT_BY_X] = FALSE;
9082 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
9083 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
9084 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
9085 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
9086 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
9087 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
9088 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
9089 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
9090 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
9091 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
9092 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
9093 custom_element_change_events[custom_element_change.other_action] =
9094 custom_element_change_events[CE_BY_OTHER_ACTION];
9096 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
9097 SET_PROPERTY(element, i, custom_element_properties[i]);
9099 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
9100 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
9102 // copy change events also to special level editor variable
9103 custom_element = element_info[element];
9104 custom_element_change = *element_info[element].change;
9106 // needed here to restore runtime value "element_info[element].gfx_element"
9107 InitElementPropertiesGfxElement();
9110 static void CopyGroupElementPropertiesToGame(int element)
9112 // mark that this group element has been modified
9113 custom_element.modified_settings = TRUE;
9114 level.changed = TRUE;
9116 if (level.use_custom_template)
9117 AskToCopyAndModifyLevelTemplate();
9119 element_info[element] = custom_element;
9120 *element_info[element].group = group_element_info;
9122 // needed here to restore runtime value "element_info[element].gfx_element"
9123 InitElementPropertiesGfxElement();
9126 static void CopyEmptyElementPropertiesToGame(int element)
9128 // mark that this empty element has been modified
9129 custom_element.modified_settings = TRUE;
9130 level.changed = TRUE;
9132 if (level.use_custom_template)
9133 AskToCopyAndModifyLevelTemplate();
9135 element_info[element] = custom_element;
9137 // needed here to restore runtime value "element_info[element].gfx_element"
9138 InitElementPropertiesGfxElement();
9141 static void CopyClassicElementPropertiesToGame(int element)
9143 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
9144 setMoveIntoAcidProperty(&level, element,
9145 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
9147 if (MAYBE_DONT_COLLIDE_WITH(element))
9148 setDontCollideWithProperty(&level, element,
9149 custom_element_properties[EP_DONT_COLLIDE_WITH]);
9152 static void CopyElementPropertiesToGame(int element)
9154 if (IS_CUSTOM_ELEMENT(element))
9155 CopyCustomElementPropertiesToGame(element);
9156 else if (IS_GROUP_ELEMENT(element))
9157 CopyGroupElementPropertiesToGame(element);
9158 else if (IS_EMPTY_ELEMENT(element))
9159 CopyEmptyElementPropertiesToGame(element);
9161 CopyClassicElementPropertiesToGame(element);
9165 static void CheckElementDescriptions(void)
9169 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
9170 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
9171 Warn("no element description file for element '%s'", EL_NAME(i));
9175 static int getMaxEdFieldX(boolean has_scrollbar)
9177 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
9178 int sxsize = SXSIZE - scrollbar_width;
9179 int max_ed_fieldx = sxsize / ed_tilesize;
9181 return max_ed_fieldx;
9184 static int getMaxEdFieldY(boolean has_scrollbar)
9186 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
9187 INFOTEXT_YSIZE_FULL : 0);
9188 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
9189 int sysize = SYSIZE - scrollbar_height - infotext_height;
9190 int max_ed_fieldy = sysize / ed_tilesize;
9192 return max_ed_fieldy;
9195 static void InitZoomLevelSettings(int zoom_tilesize)
9197 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
9199 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
9201 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
9202 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
9204 // make sure that tile size is always a power of 2
9205 ed_tilesize = (1 << log_2(ed_tilesize));
9207 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9209 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
9210 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
9214 last_game_engine_type = level.game_engine_type;
9216 // limit zoom tilesize by upper and lower bound
9217 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
9219 // store zoom tilesize in auto setup file only if it was manually changed
9220 if (zoom_tilesize != -1)
9221 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
9223 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
9224 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
9227 static void InitDrawingElements(void)
9229 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
9231 if (level.game_engine_type == game_engine_type_last)
9234 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9236 new_element1 = EL_BD_WALL;
9237 new_element2 = EL_EMPTY;
9238 new_element3 = EL_BD_SAND;
9240 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
9242 new_element1 = EL_SP_CHIP_SINGLE;
9243 new_element2 = EL_EMPTY;
9244 new_element3 = EL_SP_BASE;
9246 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
9248 new_element1 = EL_MM_MIRROR_START;
9249 new_element2 = EL_EMPTY;
9250 new_element3 = EL_MM_WOODEN_WALL;
9254 new_element1 = EL_WALL;
9255 new_element2 = EL_EMPTY;
9256 new_element3 = EL_SAND;
9259 game_engine_type_last = level.game_engine_type;
9262 static void InitLevelSetInfo(void)
9264 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
9265 "%s", leveldir_current->name);
9266 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
9267 "%s", leveldir_current->author);
9269 levelset_num_levels = leveldir_current->levels;
9271 levelset_use_levelset_artwork = FALSE;
9272 levelset_copy_level_template = FALSE;
9274 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
9277 static void ChangeEditorToLevelSet(char *levelset_subdir)
9279 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
9281 // the previous level set might have used custom artwork
9282 ReloadCustomArtwork(0);
9284 LoadLevelSetup_SeriesInfo();
9286 SaveLevelSetup_LastSeries();
9287 SaveLevelSetup_SeriesInfo();
9291 LoadLevel(level_nr);
9292 LoadScore(level_nr);
9297 static boolean useEditorDoorAnimation(void)
9299 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
9300 boolean door_1_viewport_unchanged =
9301 (vp_door_1->x == DX &&
9302 vp_door_1->y == DY &&
9303 vp_door_1->width == DXSIZE &&
9304 vp_door_1->height == DYSIZE);
9305 boolean door_1_contains_toolbox =
9308 EX + EXSIZE <= DX + DXSIZE &&
9309 EY + EYSIZE <= DY + DYSIZE);
9311 return (door_1_viewport_unchanged && door_1_contains_toolbox);
9314 static void DrawEditorDoorBackground(int graphic, int x, int y,
9315 int width, int height)
9317 struct GraphicInfo *g = &graphic_info[graphic];
9319 if (g->bitmap != NULL)
9320 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
9321 MIN(width, g->width), MIN(height, g->height), x, y);
9323 ClearRectangle(drawto, x, y, width, height);
9326 static void DrawEditorDoorContent(void)
9328 // needed for gadgets drawn on background (like palette scrollbar)
9329 SetDoorBackgroundImage(IMG_UNDEFINED);
9331 // copy default editor door content to main double buffer
9332 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
9335 DrawSpecialEditorDoor();
9337 // draw new control window
9338 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
9340 // draw all toolbox gadgets to editor doors
9341 MapControlButtons();
9343 // when returning from test game to properties page, redraw toolbox gadgets
9344 if (edit_mode == ED_MODE_PROPERTIES)
9346 UnmapLevelEditorToolboxDrawingGadgets();
9347 UnmapLevelEditorToolboxCustomGadgets();
9349 MapLevelEditorToolboxCustomGadgetsIfNeeded();
9352 // draw all palette gadgets to editor doors
9353 ModifyEditorElementList();
9354 RedrawDrawingElements();
9356 // copy actual editor door content to door double buffer for OpenDoor()
9357 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
9360 void DrawLevelEd(void)
9362 int fade_mask = REDRAW_FIELD;
9364 FadeSoundsAndMusic();
9367 fade_mask = REDRAW_ALL;
9371 // needed if different viewport properties defined for editor
9372 ChangeViewportPropertiesIfNeeded();
9376 InitZoomLevelSettings(-1);
9377 InitDrawingElements();
9381 CheckElementDescriptions();
9384 if (level_editor_test_game)
9386 CopyPlayfield(level.field, Tile);
9387 CopyPlayfield(TileBackup, level.field);
9389 level_editor_test_game = FALSE;
9393 edit_mode = ED_MODE_DRAWING;
9394 edit_mode_levelconfig = ED_MODE_LEVELCONFIG_LEVEL;
9395 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
9403 // redraw_mask |= REDRAW_ALL;
9405 FreeLevelEditorGadgets();
9406 CreateLevelEditorGadgets();
9408 ReinitializeElementList(); // update dynamic level element list
9409 ReinitializeElementListButtons(); // custom element may look different
9411 InitElementPropertiesGfxElement();
9415 DrawEditModeWindow_PlayfieldOnly();
9417 DrawMaskedBorder(fade_mask);
9419 // use door animation if door 1 viewport is unchanged and contains toolbox
9420 if (useEditorDoorAnimation())
9424 DrawEditorDoorContent();
9426 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
9430 DrawEditorDoorContent();
9435 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
9438 static void AdjustDrawingAreaGadgets(void)
9440 int ed_xsize = lev_fieldx + 2;
9441 int ed_ysize = lev_fieldy + 2;
9442 int max_ed_fieldx = MAX_ED_FIELDX;
9443 int max_ed_fieldy = MAX_ED_FIELDY;
9444 boolean horizontal_scrollbar_needed;
9445 boolean vertical_scrollbar_needed;
9446 int x, y, width, height;
9448 if (suppressBorderElement())
9450 ed_xsize = lev_fieldx;
9451 ed_ysize = lev_fieldy;
9454 // check if we need any scrollbars
9455 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9456 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9458 // check if we have a smaller editor field because of scrollbars
9459 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9460 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9462 // check again if we now need more scrollbars because of less space
9463 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9464 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9466 // check if editor field gets even smaller after adding new scrollbars
9467 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9468 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9470 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
9471 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
9473 x = SX + ed_fieldx * ed_tilesize;
9474 y = SY + ed_fieldy * ed_tilesize;
9476 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
9477 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
9479 // adjust drawing area gadget
9480 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
9481 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
9482 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
9485 // adjust horizontal scrollbar gadgets
9486 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
9489 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
9490 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
9493 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9496 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
9499 // adjust vertical scrollbar gadgets
9500 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
9503 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
9505 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
9507 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9510 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
9514 static void AdjustLevelScrollPosition(void)
9516 if (level_xpos < -1)
9518 if (level_xpos > lev_fieldx - ed_fieldx + 1)
9519 level_xpos = lev_fieldx - ed_fieldx + 1;
9520 if (lev_fieldx < ed_fieldx - 2)
9523 if (level_ypos < -1)
9525 if (level_ypos > lev_fieldy - ed_fieldy + 1)
9526 level_ypos = lev_fieldy - ed_fieldy + 1;
9527 if (lev_fieldy < ed_fieldy - 2)
9530 if (suppressBorderElement())
9537 static void AdjustEditorScrollbar(int id)
9539 struct GadgetInfo *gi = level_editor_gadget[id];
9540 int items_max, items_visible, item_position;
9542 if (id == GADGET_ID_SCROLL_HORIZONTAL)
9544 items_max = MAX(lev_fieldx + 2, ed_fieldx);
9545 items_visible = ed_fieldx;
9546 item_position = level_xpos + 1;
9550 items_max = MAX(lev_fieldy + 2, ed_fieldy);
9551 items_visible = ed_fieldy;
9552 item_position = level_ypos + 1;
9555 if (item_position > items_max - items_visible)
9556 item_position = items_max - items_visible;
9558 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9559 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9562 static void AdjustElementListScrollbar(void)
9564 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
9565 int items_max, items_visible, item_position;
9567 // correct position of element list scrollbar
9568 if (element_shift < 0)
9570 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9571 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9573 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
9574 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
9575 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
9577 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9578 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
9579 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9582 static void ModifyEditorCounterValue(int counter_id, int new_value)
9584 int *counter_value = counterbutton_info[counter_id].value;
9585 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9586 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9588 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9590 if (counter_value != NULL)
9591 *counter_value = gi->textinput.number_value;
9594 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9596 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9597 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9599 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9601 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9602 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9604 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9605 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9607 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9608 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9613 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9615 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9616 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9617 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9619 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9622 static void ModifyEditorSelectboxOptions(int selectbox_id,
9623 struct ValueTextInfo *options)
9625 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9626 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9628 selectbox_info[selectbox_id].options = options;
9630 // set index to zero -- list may be shorter now (correct later, if needed)
9631 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9632 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9635 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9637 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9638 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9640 drawingarea_info[drawingarea_id].area_xsize = xsize;
9641 drawingarea_info[drawingarea_id].area_ysize = ysize;
9643 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9646 static void ModifyEditorElementList(void)
9650 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9653 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9655 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9656 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9657 struct GadgetDesign *gd = &gi->deco.design;
9658 int element = editor_elements[element_shift + i];
9659 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9663 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9665 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9671 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9673 int graphic = el2edimg(element);
9674 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9680 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9683 static void ModifyDrawingElementButton(int element, int id)
9685 struct GadgetInfo *gi = level_editor_gadget[id];
9686 Bitmap *deco_bitmap;
9688 int tile_size = gi->deco.width;
9690 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9692 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9695 static void PickDrawingElement(int button, int element)
9700 struct XYTileSize *pos;
9702 } de, drawing_elements[] =
9704 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9705 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9706 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9709 if (button < 1 || button > 3)
9712 if (IS_MM_WALL(element))
9713 element = map_mm_wall_element(element);
9715 de = drawing_elements[button - 1];
9717 *de.new_element = element; // update global drawing element variable
9719 DrawDrawingElementGraphic(element, de.pos);
9720 ModifyDrawingElementButton(element, de.id);
9722 redraw_mask |= REDRAW_DOOR_1;
9725 static void RedrawDrawingElements(void)
9727 PickDrawingElement(1, new_element1);
9728 PickDrawingElement(2, new_element2);
9729 PickDrawingElement(3, new_element3);
9732 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9734 stick_element_properties_window = FALSE;
9736 SetMainBackgroundImage(IMG_UNDEFINED);
9739 UnmapLevelEditorFieldGadgets();
9741 AdjustDrawingAreaGadgets();
9742 AdjustLevelScrollPosition();
9743 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9744 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9746 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9748 MapMainDrawingArea();
9750 if (remap_toolbox_gadgets)
9752 UnmapLevelEditorToolboxCustomGadgets();
9753 MapLevelEditorToolboxDrawingGadgets();
9757 static void DrawDrawingWindow(void)
9759 DrawDrawingWindowExt(TRUE);
9762 static int getTabulatorBarWidth(void)
9764 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9765 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9767 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9770 static int getTabulatorBarHeight(void)
9772 return ED_TAB_BAR_HEIGHT;
9775 static Pixel getTabulatorBarColor(void)
9777 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9778 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9779 int gd_x = gd->x + gd_gi1->border.width / 2;
9780 int gd_y = gd->y + gd_gi1->height - 1;
9782 return GetPixel(gd->bitmap, gd_x, gd_y);
9785 static void DrawLevelConfigTabulatorGadgets(void)
9787 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9788 Pixel tab_color = getTabulatorBarColor();
9789 int id_first = ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL;
9790 int id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR;
9793 // draw additional "engine" tabulator when using native BD engine
9794 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
9795 id_last = ED_TEXTBUTTON_ID_LEVELCONFIG_ENGINE;
9797 for (i = id_first; i <= id_last; i++)
9799 int gadget_id = textbutton_info[i].gadget_id;
9800 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9801 boolean active = (i != edit_mode_levelconfig);
9803 // draw background line below tabulator button
9804 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9806 // draw solid line below inactive tabulator buttons
9807 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9808 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9809 ED_GADGET_TINY_DISTANCE, tab_color);
9811 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9812 MapTextbuttonGadget(i);
9815 // draw little border line below tabulator buttons
9816 if (tab_color != BLACK_PIXEL) // black => transparent
9817 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9818 ED_GADGET_TINY_DISTANCE,
9819 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9822 static void DrawPropertiesTabulatorGadgets(void)
9824 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9825 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9826 int gd_x = gd->x + gd_gi1->border.width / 2;
9827 int gd_y = gd->y + gd_gi1->height - 1;
9828 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9829 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9830 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9833 // draw two config tabulators for player elements
9834 if (IS_PLAYER_ELEMENT(properties_element))
9835 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9837 // draw two config and one "change" tabulator for custom elements
9838 if (IS_CUSTOM_ELEMENT(properties_element))
9839 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9841 for (i = id_first; i <= id_last; i++)
9843 int gadget_id = textbutton_info[i].gadget_id;
9844 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9845 boolean active = (i != edit_mode_properties);
9847 // use "config 1" and "config 2" instead of "config" for players and CEs
9848 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9849 (IS_PLAYER_ELEMENT(properties_element) ||
9850 IS_CUSTOM_ELEMENT(properties_element)))
9853 // draw background line below tabulator button
9854 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9856 // draw solid line below inactive tabulator buttons
9857 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9858 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9859 ED_GADGET_TINY_DISTANCE, tab_color);
9861 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9862 MapTextbuttonGadget(i);
9865 // draw little border line below tabulator buttons
9866 if (tab_color != BLACK_PIXEL) // black => transparent
9867 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9868 ED_GADGET_TINY_DISTANCE,
9869 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9872 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9874 DrawText(SX + xpos, SY + ypos, text, font_nr);
9877 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9880 int font_width = getFontWidth(font_nr);
9881 int font_height = getFontHeight(font_nr);
9882 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9883 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9885 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9886 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9887 TRUE, FALSE, FALSE);
9890 static void DrawLevelConfigLevel(void)
9894 // draw counter gadgets
9895 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9896 MapCounterButtons(i);
9898 // draw checkbutton gadgets
9899 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9900 MapCheckbuttonGadget(i);
9902 // draw selectbox gadgets
9903 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9904 MapSelectboxGadget(i);
9906 // draw text input gadgets
9907 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9908 MapTextInputGadget(i);
9911 static char *getLevelSubdirFromSaveMode(int save_mode)
9913 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9914 return getNewUserLevelSubdir();
9916 return leveldir_current->subdir;
9919 static void DrawLevelConfigLevelSet_DirectoryInfo(void)
9921 char *directory_text = "Level set directory:";
9922 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9923 int font1_nr = FONT_TEXT_1;
9924 int font2_nr = FONT_TEXT_2;
9925 int font1_height = getFontHeight(font1_nr);
9926 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
9927 int x = ED_LEVEL_SETTINGS_X(0);
9928 int y = ED_LEVEL_SETTINGS_Y(6);
9930 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
9931 PrintInfoText(directory_name, font2_nr, x, y);
9934 static void DrawLevelConfigLevelSet(void)
9936 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
9937 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
9940 // draw counter gadgets
9941 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
9942 MapCounterButtons(i);
9944 // draw checkbutton gadgets
9945 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
9947 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
9948 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
9949 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
9952 MapCheckbuttonGadget(i);
9955 // draw selectbox gadgets
9956 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
9957 MapSelectboxGadget(i);
9959 // draw text input gadgets
9960 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
9961 MapTextInputGadget(i);
9963 // draw textbutton gadgets
9964 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
9967 DrawLevelConfigLevelSet_DirectoryInfo();
9970 static void DrawLevelConfigEditor(void)
9974 // draw counter gadgets
9975 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
9976 MapCounterButtons(i);
9978 // draw checkbutton gadgets
9979 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
9980 MapCheckbuttonGadget(i);
9982 // draw radiobutton gadgets
9983 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
9984 MapRadiobuttonGadget(i);
9986 // draw drawing area
9987 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
9989 // draw textbutton gadgets
9990 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
9993 static void DrawLevelConfigEngine(void)
9997 static void DrawLevelConfigWindow(void)
9999 char *text = "Global Settings";
10000 int font_nr = FONT_TITLE_1;
10001 struct MenuPosInfo *pos = &editor.settings.headline;
10002 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
10003 int sy = SY + pos->y;
10005 stick_element_properties_window = FALSE;
10007 SetAutomaticNumberOfGemsNeeded();
10009 UnmapLevelEditorFieldGadgets();
10011 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10014 DrawText(sx, sy, text, font_nr);
10016 DrawLevelConfigTabulatorGadgets();
10018 if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVEL)
10019 DrawLevelConfigLevel();
10020 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVELSET)
10021 DrawLevelConfigLevelSet();
10022 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_EDITOR)
10023 DrawLevelConfigEditor();
10024 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_ENGINE)
10025 DrawLevelConfigEngine();
10028 static void DrawCustomContentArea(void)
10030 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
10031 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10032 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
10033 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
10034 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
10035 int xoffset = ED_GADGET_SPACE_DISTANCE;
10037 // add distance for potential left text (without drawing area border)
10038 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
10040 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10042 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
10045 static void DrawCustomChangeContentArea(void)
10047 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
10048 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
10049 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
10050 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
10051 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
10052 int xoffset = ED_GADGET_SPACE_DISTANCE;
10054 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
10056 MapDrawingArea(id);
10059 static void RemoveElementContentArea(int id, int font_height)
10061 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10063 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
10064 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
10065 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10066 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
10067 ED_GADGET_TEXT_DISTANCE + font_height);
10070 static void DrawYamYamContentAreas(void)
10072 int font_nr = FONT_TEXT_1;
10073 int font_height = getFontHeight(font_nr);
10074 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10075 int yoffset = (tilesize - font_height) / 2;
10076 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
10077 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
10080 // display counter to choose number of element content areas
10081 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
10083 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10085 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
10087 if (i < level.num_yamyam_contents)
10089 MapDrawingArea(id);
10093 UnmapDrawingArea(id);
10095 // delete content areas in case of reducing number of them
10096 RemoveElementContentArea(id, font_height);
10100 DrawText(x, y + 0 * tilesize, "content", font_nr);
10101 DrawText(x, y + 1 * tilesize, "when", font_nr);
10102 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
10105 static void DrawMagicBallContentAreas(void)
10107 int font_nr = FONT_TEXT_1;
10108 int font_height = getFontHeight(font_nr);
10109 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
10110 int yoffset = (tilesize - font_height) / 2;
10111 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
10112 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
10115 // display counter to choose number of element content areas
10116 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
10118 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
10120 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
10122 if (i < level.num_ball_contents)
10124 MapDrawingArea(id);
10128 UnmapDrawingArea(id);
10130 // delete content areas in case of reducing number of them
10131 RemoveElementContentArea(id, font_height);
10135 DrawText(x, y + 0 * tilesize, "generated", font_nr);
10136 DrawText(x, y + 1 * tilesize, "when", font_nr);
10137 DrawText(x, y + 2 * tilesize, "active", font_nr);
10140 static void DrawAndroidElementArea(void)
10142 int id = ED_DRAWING_ID_ANDROID_CONTENT;
10143 int num_elements = level.num_android_clone_elements;
10144 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10145 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10146 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10147 int xsize = MAX_ANDROID_ELEMENTS;
10150 // display counter to choose number of element areas
10151 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
10153 if (drawingarea_info[id].text_left != NULL)
10154 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10156 UnmapDrawingArea(id);
10158 ModifyEditorDrawingArea(id, num_elements, 1);
10160 // delete content areas in case of reducing number of them
10161 DrawBackground(sx, sy,
10162 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10163 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10165 MapDrawingArea(id);
10168 static void DrawGroupElementArea(void)
10170 int id = ED_DRAWING_ID_GROUP_CONTENT;
10171 int num_elements = group_element_info.num_elements;
10172 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10173 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10174 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10175 int xsize = MAX_ELEMENTS_IN_GROUP;
10178 if (drawingarea_info[id].text_left != NULL)
10179 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10181 UnmapDrawingArea(id);
10183 ModifyEditorDrawingArea(id, num_elements, 1);
10185 // delete content areas in case of reducing number of them
10186 DrawBackground(sx, sy,
10187 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10188 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10190 MapDrawingArea(id);
10193 static void DrawPlayerInitialInventoryArea(int element)
10195 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
10196 int player_nr = GET_PLAYER_NR(element);
10197 int num_elements = level.initial_inventory_size[player_nr];
10198 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10199 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10200 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10201 int xsize = MAX_INITIAL_INVENTORY_SIZE;
10204 // determine horizontal position to the right of specified gadget
10205 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
10206 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
10207 ED_DRAWINGAREA_TEXT_DISTANCE);
10209 // determine horizontal offset for leading text
10210 if (drawingarea_info[id].text_left != NULL)
10211 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10213 UnmapDrawingArea(id);
10215 ModifyEditorDrawingArea(id, num_elements, 1);
10217 // delete content areas in case of reducing number of them
10218 DrawBackground(sx, sy,
10219 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10220 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10222 MapDrawingArea(id);
10225 static void DrawMMBallContentArea(void)
10227 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
10228 int num_elements = level.num_mm_ball_contents;
10229 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
10230 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
10231 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
10232 int xsize = MAX_MM_BALL_CONTENTS;
10235 if (drawingarea_info[id].text_left != NULL)
10236 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
10238 UnmapDrawingArea(id);
10240 ModifyEditorDrawingArea(id, num_elements, 1);
10242 // delete content areas in case of reducing number of them
10243 DrawBackground(sx, sy,
10244 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
10245 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
10247 MapDrawingArea(id);
10250 static void DrawEnvelopeTextArea(int envelope_nr)
10252 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
10253 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
10257 DrawBackground(gi->x, gi->y,
10258 gi->textarea.crop_width, gi->textarea.crop_height);
10260 if (envelope_nr != -1)
10261 textarea_info[id].value = level.envelope[envelope_nr].text;
10263 ModifyGadget(gi, GDI_AREA_SIZE,
10264 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
10265 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
10268 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
10271 static void DrawPropertiesInfo(void)
10280 // configurable properties
10282 { EP_WALKABLE_OVER, "- player can walk over it" },
10283 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
10284 { EP_WALKABLE_UNDER, "- player can walk under it" },
10285 { EP_PASSABLE_OVER, "- player can pass over it" },
10286 { EP_PASSABLE_INSIDE, "- player can pass through it" },
10287 { EP_PASSABLE_UNDER, "- player can pass under it" },
10288 { EP_PROTECTED, "- player is protected by it" },
10290 { EP_DIGGABLE, "- can be digged away" },
10291 { EP_COLLECTIBLE, "- can be collected" },
10292 { EP_DROPPABLE, "- can be dropped after collecting" },
10293 { EP_THROWABLE, "- can be thrown after collecting" },
10294 { EP_PUSHABLE, "- can be pushed" },
10296 { EP_CAN_FALL, "- can fall" },
10297 { EP_CAN_MOVE, "- can move" },
10299 { EP_CAN_SMASH_PLAYER, "- can smash player" },
10301 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
10303 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
10305 { EP_SLIPPERY, "- slippery for falling elements" },
10306 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
10308 { EP_DONT_RUN_INTO, "- deadly when running into" },
10309 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
10310 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
10311 { EP_DONT_TOUCH, "- deadly when touching" },
10313 { EP_INDESTRUCTIBLE, "- indestructible" },
10315 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
10316 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
10317 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
10319 { EP_CAN_CHANGE, "- can change to other element" },
10321 // pre-defined properties
10322 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
10323 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
10324 { EP_SWITCHABLE, "- can be switched" },
10326 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
10331 char *filename = getElementDescriptionFilename(properties_element);
10332 char *num_elements_text = "In this level: ";
10333 char *num_similar_text = "Similar tiles: ";
10334 char *properties_text = "Standard properties: ";
10335 char *description_text = "Description:";
10336 char *no_description_text = "No description available.";
10337 char *none_text = "None";
10339 int num_elements_in_level = 0;
10340 int num_similar_in_level = 0;
10341 int num_hires_tiles_in_level = 0;
10342 int num_standard_properties = 0;
10343 int font1_nr = FONT_TEXT_1;
10344 int font2_nr = FONT_TEXT_2;
10345 int font1_width = getFontWidth(font1_nr);
10346 int font1_height = getFontHeight(font1_nr);
10347 int font2_height = getFontHeight(font2_nr);
10348 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
10349 int font2_yoffset = (font1_height - font2_height) / 2;
10350 int num_elements_text_len = strlen(num_elements_text) * font1_width;
10351 int num_similar_text_len = strlen(num_similar_text) * font1_width;
10352 int properties_text_len = strlen(properties_text) * font1_width;
10353 int xpos = ED_ELEMENT_SETTINGS_X(0);
10354 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10357 if (setup.editor.show_element_token)
10359 int font3_nr = FONT_TEXT_3;
10360 int font3_height = getFontHeight(font3_nr);
10362 DrawTextF(xpos, ypos, font3_nr,
10363 "[%s]", element_info[properties_element].token_name);
10365 ypos += 2 * font3_height;
10368 // ----- print number of elements / percentage of this element in level
10370 for (y = 0; y < lev_fieldy; y++)
10372 for (x = 0; x < lev_fieldx; x++)
10374 if (Tile[x][y] == properties_element)
10376 num_elements_in_level++;
10378 else if (IS_MM_WALL(Tile[x][y]) &&
10379 map_mm_wall_element(Tile[x][y]) == properties_element)
10381 num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
10386 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10388 DrawTextS(xpos, ypos, font1_nr, num_elements_text);
10390 if (num_hires_tiles_in_level > 0)
10391 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10392 "%d wall tiles", num_hires_tiles_in_level);
10393 else if (num_elements_in_level > 0)
10394 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10395 "%d (%.2f %%)", num_elements_in_level, percentage);
10397 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10400 // ----- print number of similar elements / percentage of them in level
10402 for (y = 0; y < lev_fieldy; y++)
10404 for (x = 0; x < lev_fieldx; x++)
10406 if (strEqual(element_info[Tile[x][y]].class_name,
10407 element_info[properties_element].class_name))
10409 num_similar_in_level++;
10414 if (num_similar_in_level != num_elements_in_level)
10416 ypos += 1 * MAX(font1_height, font2_height);
10418 percentage = num_similar_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10420 DrawTextS(xpos, ypos, font1_nr, num_similar_text);
10422 if (num_similar_in_level > 0)
10423 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10424 "%d (%.2f %%)", num_similar_in_level, percentage);
10426 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10430 ypos += 2 * MAX(font1_height, font2_height);
10432 // ----- print standard properties of this element
10434 DrawTextS(xpos, ypos, font1_nr, properties_text);
10436 ypos += line1_height;
10438 for (i = 0; properties[i].value != -1; i++)
10440 if (!HAS_PROPERTY(properties_element, properties[i].value))
10443 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
10445 ypos += font2_height;
10447 num_standard_properties++;
10450 if (num_standard_properties == 0)
10452 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
10453 font2_nr, none_text);
10455 ypos -= (line1_height - font1_height);
10458 ypos += MAX(font1_height, font2_height);
10460 // ----- print special description of this element
10462 PrintInfoText(description_text, font1_nr, xpos, ypos);
10464 ypos += line1_height;
10466 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
10467 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
10470 #define TEXT_COLLECTING "Score for collecting"
10471 #define TEXT_SMASHING "Score for smashing"
10472 #define TEXT_SLURPING "Score for slurping robot"
10473 #define TEXT_CRACKING "Score for cracking"
10474 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
10475 #define TEXT_DURATION "Duration when activated"
10476 #define TEXT_DELAY_ON "Delay before activating"
10477 #define TEXT_DELAY_OFF "Delay before deactivating"
10478 #define TEXT_DELAY_CHANGING "Delay before changing"
10479 #define TEXT_DELAY_EXPLODING "Delay before exploding"
10480 #define TEXT_DELAY_MOVING "Delay before moving"
10481 #define TEXT_BALL_DELAY "Element generation delay"
10482 #define TEXT_MOVE_SPEED "Speed of android moving"
10483 #define TEXT_CLONE_SPEED "Speed of android cloning"
10484 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
10485 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
10486 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
10487 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
10488 #define TEXT_TIME_BONUS "Extra time to solve level"
10495 } elements_with_counter[] =
10497 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
10498 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
10499 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
10500 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
10501 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10502 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
10503 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
10504 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
10505 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
10506 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
10507 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10508 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
10509 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10510 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10511 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
10512 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
10513 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
10514 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10515 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10516 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
10517 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10518 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10519 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10520 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10521 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10522 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10523 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
10524 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10525 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10526 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10527 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10528 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10529 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10530 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10531 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
10532 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
10533 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10534 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
10535 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10536 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10537 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10538 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10539 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10540 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
10541 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10542 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10543 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE], TEXT_COLLECTING },
10544 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10545 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10546 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
10547 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
10548 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
10549 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10550 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10551 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10552 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10553 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10554 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10555 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10556 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10557 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
10558 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
10559 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
10560 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
10561 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
10562 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10563 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
10564 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
10565 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
10566 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10567 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10568 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10569 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10570 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10571 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10572 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10573 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10574 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10575 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10576 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10577 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10578 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10579 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
10581 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10582 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
10583 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
10584 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
10585 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
10586 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
10587 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
10588 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
10589 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
10590 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
10591 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
10592 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
10593 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
10594 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
10595 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
10596 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
10598 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
10599 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
10600 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
10601 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
10602 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
10603 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
10604 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
10605 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
10606 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
10607 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
10608 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
10609 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
10610 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_CHANGING },
10611 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10612 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10617 static boolean checkPropertiesConfig(int element)
10621 if (IS_GEM(element) ||
10622 IS_CUSTOM_ELEMENT(element) ||
10623 IS_GROUP_ELEMENT(element) ||
10624 IS_EMPTY_ELEMENT(element) ||
10625 IS_BALLOON_ELEMENT(element) ||
10626 IS_ENVELOPE(element) ||
10627 IS_MM_ENVELOPE(element) ||
10628 IS_MM_MCDUFFIN(element) ||
10629 IS_DF_LASER(element) ||
10630 IS_PLAYER_ELEMENT(element) ||
10631 IS_BD_PLAYER_ELEMENT(element) ||
10632 IS_SOKOBAN_OBJECT_OR_FIELD(element) ||
10633 HAS_EDITOR_CONTENT(element) ||
10634 CAN_GROW(element) ||
10635 COULD_MOVE_INTO_ACID(element) ||
10636 MAYBE_DONT_COLLIDE_WITH(element))
10639 for (i = 0; elements_with_counter[i].element != -1; i++)
10640 if (elements_with_counter[i].element == element)
10646 static void SetAutomaticNumberOfGemsNeeded(void)
10650 if (!level.auto_count_gems)
10653 level.gems_needed = 0;
10655 for (x = 0; x < lev_fieldx; x++)
10657 for (y = 0; y < lev_fieldy; y++)
10659 int element = Tile[x][y];
10664 case EL_EMERALD_YELLOW:
10665 case EL_EMERALD_RED:
10666 case EL_EMERALD_PURPLE:
10667 case EL_BD_DIAMOND:
10668 case EL_WALL_EMERALD:
10669 case EL_WALL_EMERALD_YELLOW:
10670 case EL_WALL_EMERALD_RED:
10671 case EL_WALL_EMERALD_PURPLE:
10672 case EL_WALL_BD_DIAMOND:
10674 case EL_SP_INFOTRON:
10677 level.gems_needed++;
10681 case EL_WALL_DIAMOND:
10682 level.gems_needed += 3;
10686 case EL_WALL_PEARL:
10687 level.gems_needed += 5;
10691 case EL_WALL_CRYSTAL:
10692 level.gems_needed += 8;
10701 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10704 static void DrawPropertiesConfig(void)
10706 boolean draw_footer_line = FALSE;
10707 int max_num_element_counters = 4;
10708 int num_element_counters = 0;
10711 if (!checkPropertiesConfig(properties_element))
10713 int xpos = ED_ELEMENT_SETTINGS_X(0);
10714 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10716 PrintInfoText("No configuration options available.",
10717 FONT_TEXT_1, xpos, ypos);
10722 // check if there are elements where a value can be chosen for
10723 for (i = 0; elements_with_counter[i].element != -1; i++)
10725 if (elements_with_counter[i].element == properties_element)
10727 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10729 counterbutton_info[counter_id].y =
10730 ED_ELEMENT_SETTINGS_YPOS(
10731 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10732 (CAN_GROW(properties_element) ? 1 : 0) +
10733 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10734 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10735 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10736 num_element_counters);
10738 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10739 counterbutton_info[counter_id].text_right = elements_with_counter[i].text;
10741 if (properties_element == EL_GAME_OF_LIFE ||
10742 properties_element == EL_BIOMAZE)
10744 counterbutton_info[counter_id].min_value = 0; // min neighbours
10745 counterbutton_info[counter_id].max_value = 8; // max neighbours
10749 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10750 counterbutton_info[counter_id].min_value = MIN_SCORE;
10751 counterbutton_info[counter_id].max_value = MAX_SCORE;
10754 MapCounterButtons(counter_id);
10756 num_element_counters++;
10757 if (num_element_counters >= max_num_element_counters)
10762 if (HAS_EDITOR_CONTENT(properties_element))
10764 // draw stickybutton gadget
10765 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10767 if (IS_AMOEBOID(properties_element))
10768 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10769 else if (properties_element == EL_YAMYAM ||
10770 properties_element == EL_YAMYAM_LEFT ||
10771 properties_element == EL_YAMYAM_RIGHT ||
10772 properties_element == EL_YAMYAM_UP ||
10773 properties_element == EL_YAMYAM_DOWN)
10774 DrawYamYamContentAreas();
10775 else if (properties_element == EL_EMC_MAGIC_BALL)
10777 DrawMagicBallContentAreas();
10779 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10780 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10782 else if (properties_element == EL_EMC_ANDROID)
10783 DrawAndroidElementArea();
10784 else if (properties_element == EL_MM_GRAY_BALL)
10786 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
10787 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
10788 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
10789 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EXPLODE_MM_BALL);
10791 DrawMMBallContentArea();
10795 if (IS_PLAYER_ELEMENT(properties_element))
10797 int player_nr = GET_PLAYER_NR(properties_element);
10799 // these properties can be set for every player individually
10801 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10803 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
10804 &level.start_element[player_nr];
10805 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
10806 &level.artwork_element[player_nr];
10807 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
10808 &level.explosion_element[player_nr];
10810 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10811 &level.use_start_element[player_nr];
10812 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10813 &level.use_artwork_element[player_nr];
10814 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10815 &level.use_explosion_element[player_nr];
10816 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10817 &level.initial_player_gravity[player_nr];
10819 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10820 &level.initial_player_stepsize[player_nr];
10822 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
10823 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
10824 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
10825 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
10826 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
10827 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
10828 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
10829 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
10830 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
10831 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
10832 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
10833 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
10834 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
10835 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
10836 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
10838 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
10839 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
10840 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
10842 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
10844 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10846 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
10847 &level.initial_inventory_content[player_nr][0];
10849 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
10850 &level.initial_inventory_size[player_nr];
10852 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
10853 &level.use_initial_inventory[player_nr];
10855 // draw checkbutton gadgets
10856 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
10857 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
10858 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
10860 // draw counter gadgets
10861 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
10863 // draw drawing area gadgets
10864 DrawPlayerInitialInventoryArea(properties_element);
10868 if (IS_BD_PLAYER_ELEMENT(properties_element))
10869 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS);
10871 if (IS_GEM(properties_element))
10872 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
10874 if (properties_element == EL_EM_DYNAMITE)
10875 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
10877 if (COULD_MOVE_INTO_ACID(properties_element) &&
10878 !IS_PLAYER_ELEMENT(properties_element) &&
10879 (!IS_CUSTOM_ELEMENT(properties_element) ||
10880 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
10882 // set position for checkbutton for "can move into acid"
10883 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
10884 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
10885 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
10886 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
10887 IS_BALLOON_ELEMENT(properties_element) ||
10888 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10890 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
10893 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
10894 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
10896 if (properties_element == EL_SPRING ||
10897 properties_element == EL_SPRING_LEFT ||
10898 properties_element == EL_SPRING_RIGHT)
10899 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
10901 if (properties_element == EL_TIME_ORB_FULL)
10902 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
10904 if (properties_element == EL_GAME_OF_LIFE ||
10905 properties_element == EL_BIOMAZE)
10906 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
10908 if (CAN_GROW(properties_element))
10910 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
10911 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10913 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
10916 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
10917 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
10919 if (properties_element == EL_SOKOBAN_OBJECT)
10920 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
10922 if (properties_element == EL_SOKOBAN_OBJECT ||
10923 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
10924 properties_element == EL_SOKOBAN_FIELD_FULL)
10926 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
10927 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
10930 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
10933 if (IS_BALLOON_ELEMENT(properties_element))
10934 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
10936 if (IS_ENVELOPE(properties_element) ||
10937 IS_MM_ENVELOPE(properties_element))
10939 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
10940 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
10941 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
10942 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
10943 int envelope_nr = ENVELOPE_NR(properties_element);
10945 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
10946 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
10948 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
10949 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
10951 // display counter to choose size of envelope text area
10952 MapCounterButtons(counter1_id);
10953 MapCounterButtons(counter2_id);
10955 // display checkbuttons to choose auto-wrap and alignment properties
10956 MapCheckbuttonGadget(button1_id);
10957 MapCheckbuttonGadget(button2_id);
10959 DrawEnvelopeTextArea(envelope_nr);
10962 if (IS_MM_MCDUFFIN(properties_element))
10964 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
10965 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
10966 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
10969 if (IS_DF_LASER(properties_element))
10971 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
10972 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
10973 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
10976 if (IS_CUSTOM_ELEMENT(properties_element))
10978 // draw stickybutton gadget
10979 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10981 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10983 // draw checkbutton gadgets
10984 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
10985 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
10986 MapCheckbuttonGadget(i);
10988 // draw counter gadgets
10989 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
10990 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
10991 MapCounterButtons(i);
10993 // draw selectbox gadgets
10994 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
10995 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
10996 MapSelectboxGadget(i);
10998 // draw textbutton gadgets
10999 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11001 // draw text input gadgets
11002 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11004 // draw drawing area gadgets
11005 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11007 draw_footer_line = TRUE;
11009 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
11011 // draw checkbutton gadgets
11012 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
11013 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
11014 MapCheckbuttonGadget(i);
11016 // draw counter gadgets
11017 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
11018 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
11019 MapCounterButtons(i);
11021 // draw selectbox gadgets
11022 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
11023 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
11024 MapSelectboxGadget(i);
11026 // draw drawing area gadgets
11027 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
11028 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
11029 DrawCustomContentArea();
11032 else if (IS_GROUP_ELEMENT(properties_element))
11034 // draw stickybutton gadget
11035 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11037 // draw checkbutton gadgets
11038 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11039 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11041 // draw counter gadgets
11042 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
11044 // draw selectbox gadgets
11045 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
11047 // draw textbutton gadgets
11048 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11050 // draw drawing area gadgets
11051 DrawGroupElementArea();
11053 // draw text input gadgets
11054 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
11056 // draw drawing area gadgets
11057 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11059 draw_footer_line = TRUE;
11061 else if (IS_EMPTY_ELEMENT(properties_element))
11063 // draw stickybutton gadget
11064 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11066 // draw checkbutton gadgets
11067 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
11068 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
11070 // draw textbutton gadgets
11071 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
11073 // draw drawing area gadgets
11074 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
11076 draw_footer_line = TRUE;
11079 // draw little footer border line above CE/GE use/save template gadgets
11080 if (draw_footer_line)
11082 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
11083 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
11084 int gd_x = gd->x + gd_gi1->border.width / 2;
11085 int gd_y = gd->y + gd_gi1->height - 1;
11086 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
11088 if (tab_color != BLACK_PIXEL) // black => transparent
11089 FillRectangle(drawto,
11090 SX + ED_ELEMENT_SETTINGS_X(0),
11091 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
11093 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
11097 static void DrawPropertiesChangeDrawingAreas(void)
11099 if (IS_CUSTOM_ELEMENT(properties_element))
11101 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
11102 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
11103 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
11105 DrawCustomChangeContentArea();
11108 redraw_mask |= REDRAW_FIELD;
11111 static void DrawPropertiesChange(void)
11115 // needed to initially set selectbox options for special action options
11116 setSelectboxSpecialActionOptions();
11118 // draw stickybutton gadget
11119 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
11121 // draw checkbutton gadgets
11122 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
11123 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
11124 MapCheckbuttonGadget(i);
11126 // draw counter gadgets
11127 for (i = ED_COUNTER_ID_CHANGE_FIRST;
11128 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
11129 MapCounterButtons(i);
11131 // draw selectbox gadgets
11132 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
11133 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
11134 MapSelectboxGadget(i);
11136 // draw textbutton gadgets
11137 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
11138 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
11139 MapTextbuttonGadget(i);
11141 // draw graphicbutton gadgets
11142 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
11143 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
11144 MapGraphicbuttonGadget(i);
11146 // draw drawing area gadgets
11147 DrawPropertiesChangeDrawingAreas();
11150 static void DrawEditorElementAnimation(int x, int y)
11152 int graphic = el2img(properties_element);
11153 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
11154 custom_element.ce_value_fixed_initial :
11155 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
11156 custom_element.collect_score_initial : FrameCounter);
11158 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
11161 static void DrawEditorElementName(int x, int y, int font_nr)
11163 char *element_name = getElementInfoText(properties_element);
11164 int font_width = getFontWidth(font_nr);
11165 int font_height = getFontHeight(font_nr);
11166 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
11167 int max_chars_per_line = max_text_width / font_width;
11169 if (strlen(element_name) <= max_chars_per_line)
11170 DrawTextS(x, y, font_nr, element_name);
11173 char buffer[max_chars_per_line + 1];
11174 int next_pos = max_chars_per_line;
11176 strncpy(buffer, element_name, max_chars_per_line);
11177 buffer[max_chars_per_line] = '\0';
11179 if (element_name[max_chars_per_line] == ' ')
11185 for (i = max_chars_per_line - 1; i >= 0; i--)
11186 if (buffer[i] == ' ')
11189 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
11196 DrawTextS(x, y - font_height / 2, font_nr, buffer);
11198 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
11199 buffer[max_chars_per_line] = '\0';
11201 DrawTextS(x, y + font_height / 2, font_nr, buffer);
11205 static void DrawPropertiesWindow(void)
11207 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
11208 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
11209 int border_size = gd->border_size;
11210 int font_nr = FONT_TEXT_1;
11211 int font_height = getFontHeight(font_nr);
11212 int xoffset = TILEX + element_border + 3 * border_size;
11213 int yoffset = (TILEY - font_height) / 2;
11214 int x1 = editor.settings.element_graphic.x + element_border;
11215 int y1 = editor.settings.element_graphic.y + element_border;
11216 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
11217 editor.settings.element_name.x);
11218 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
11219 editor.settings.element_name.y);
11220 char *text = "Element Settings";
11221 int font2_nr = FONT_TITLE_1;
11222 struct MenuPosInfo *pos = &editor.settings.headline;
11223 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
11224 int sy = SY + pos->y;
11226 stick_element_properties_window = FALSE;
11228 // make sure that previous properties edit mode exists for this element
11229 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
11230 !IS_CUSTOM_ELEMENT(properties_element))
11231 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
11233 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
11234 !IS_PLAYER_ELEMENT(properties_element) &&
11235 !IS_CUSTOM_ELEMENT(properties_element))
11236 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
11238 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
11239 (IS_PLAYER_ELEMENT(properties_element) ||
11240 IS_CUSTOM_ELEMENT(properties_element)))
11241 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
11243 CopyElementPropertiesToEditor(properties_element);
11245 UnmapLevelEditorFieldGadgets();
11246 UnmapLevelEditorToolboxDrawingGadgets();
11247 UnmapLevelEditorToolboxCustomGadgets();
11249 MapLevelEditorToolboxCustomGadgetsIfNeeded();
11251 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11254 DrawText(sx, sy, text, font2_nr);
11256 FrameCounter = 0; // restart animation frame counter
11258 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
11259 DrawEditorElementAnimation(SX + x1, SY + y1);
11260 DrawEditorElementName(x2, y2, font_nr);
11262 DrawPropertiesTabulatorGadgets();
11264 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
11265 DrawPropertiesInfo();
11266 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
11267 DrawPropertiesChange();
11268 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
11269 DrawPropertiesConfig();
11272 static void DrawPaletteWindow(void)
11276 UnmapLevelEditorFieldGadgets();
11278 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
11281 // map buttons to select elements
11282 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
11283 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
11284 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
11285 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
11286 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
11289 static void UpdateCustomElementGraphicGadgets(void)
11293 InitElementPropertiesGfxElement();
11295 ModifyEditorElementList();
11296 RedrawDrawingElements();
11298 // force redraw of all mapped drawing area gadgets
11299 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
11301 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
11308 static int getOpenDirectionFromTube(int element)
11312 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
11313 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
11314 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
11315 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
11316 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
11317 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
11318 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
11319 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
11320 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
11321 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
11322 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
11328 static int getTubeFromOpenDirection(int direction)
11332 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
11333 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
11334 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
11335 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
11336 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
11337 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
11338 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
11339 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
11340 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
11341 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
11342 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
11344 // if only one direction, fall back to simple tube with that direction
11345 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
11346 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
11347 case (MV_UP): return EL_TUBE_VERTICAL;
11348 case (MV_DOWN): return EL_TUBE_VERTICAL;
11354 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
11356 int element_new = getTubeFromOpenDirection(direction);
11358 return (element_new != EL_EMPTY ? element_new : element_old);
11361 static int getOpenDirectionFromBelt(int element)
11363 int belt_dir = getBeltDirFromBeltElement(element);
11365 return (belt_dir == MV_LEFT ? MV_RIGHT :
11366 belt_dir == MV_RIGHT ? MV_LEFT :
11367 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
11370 static int getBeltFromNrAndOpenDirection(int nr, int direction)
11372 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
11373 direction == MV_RIGHT ? MV_LEFT :
11374 direction == MV_HORIZONTAL ? MV_NONE : direction);
11376 if (direction == MV_NONE)
11379 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
11382 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
11385 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
11387 return (element_new != EL_EMPTY ? element_new : element_old);
11390 static int getOpenDirectionFromPool(int element)
11394 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
11395 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
11396 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
11397 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
11398 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
11399 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
11405 static int getPoolFromOpenDirection(int direction)
11409 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
11410 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
11411 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
11412 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
11413 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
11414 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
11420 static int getPoolFromOpenDirectionExt(int direction, int help_element)
11422 int element = getPoolFromOpenDirection(direction);
11423 int help_direction = getOpenDirectionFromPool(help_element);
11425 if (element == EL_EMPTY)
11427 int help_direction_vertical = help_direction & MV_VERTICAL;
11429 element = getPoolFromOpenDirection(direction | help_direction_vertical);
11432 if (element == EL_EMPTY)
11434 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
11436 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
11442 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
11444 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
11446 return (element_new != EL_EMPTY ? element_new : element_old);
11449 static int getOpenDirectionFromPillar(int element)
11453 case EL_EMC_WALL_1: return (MV_DOWN);
11454 case EL_EMC_WALL_2: return (MV_VERTICAL);
11455 case EL_EMC_WALL_3: return (MV_UP);
11461 static int getPillarFromOpenDirection(int direction)
11465 case (MV_DOWN): return EL_EMC_WALL_1;
11466 case (MV_VERTICAL): return EL_EMC_WALL_2;
11467 case (MV_UP): return EL_EMC_WALL_3;
11473 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
11475 int element_new = getPillarFromOpenDirection(direction);
11477 return (element_new != EL_EMPTY ? element_new : element_old);
11480 static int getOpenDirectionFromSteel2(int element)
11484 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
11485 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
11486 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
11487 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
11488 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
11489 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
11490 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
11491 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
11497 static int getSteel2FromOpenDirection(int direction)
11501 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
11502 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
11503 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
11504 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
11505 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
11506 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
11507 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
11508 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
11514 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
11516 int element_new = getSteel2FromOpenDirection(direction);
11518 return (element_new != EL_EMPTY ? element_new : element_old);
11521 static int getOpenDirectionFromChip(int element)
11525 case EL_SP_CHIP_SINGLE: return (MV_NONE);
11526 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
11527 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
11528 case EL_SP_CHIP_TOP: return (MV_DOWN);
11529 case EL_SP_CHIP_BOTTOM: return (MV_UP);
11535 static int getChipFromOpenDirection(int direction)
11539 case (MV_NONE): return EL_SP_CHIP_SINGLE;
11540 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
11541 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
11542 case (MV_UP): return EL_SP_CHIP_BOTTOM;
11543 case (MV_DOWN): return EL_SP_CHIP_TOP;
11549 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
11551 int element_new = getChipFromOpenDirection(direction);
11553 return (element_new != EL_EMPTY ? element_new : element_old);
11556 static int getClosedTube(int x, int y)
11558 struct XY *xy = xy_directions;
11559 int element_old = IntelliDrawBuffer[x][y];
11560 int direction_old = getOpenDirectionFromTube(element_old);
11561 int direction_new = MV_NONE;
11564 for (i = 0; i < NUM_DIRECTIONS; i++)
11566 int xx = x + xy[i].x;
11567 int yy = y + xy[i].y;
11568 int dir = MV_DIR_FROM_BIT(i);
11569 int dir_opposite = MV_DIR_OPPOSITE(dir);
11571 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
11572 (direction_old & dir) &&
11573 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11574 direction_new |= dir;
11577 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
11580 static int getClosedBelt(int x, int y)
11582 struct XY *xy = xy_directions;
11583 int element_old = IntelliDrawBuffer[x][y];
11584 int nr = getBeltNrFromBeltElement(element_old);
11585 int direction_old = getOpenDirectionFromBelt(element_old);
11586 int direction_new = MV_NONE;
11589 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11591 int xx = x + xy[i].x;
11592 int yy = y + xy[i].y;
11593 int dir = MV_DIR_FROM_BIT(i);
11594 int dir_opposite = MV_DIR_OPPOSITE(dir);
11596 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
11597 (direction_old & dir) &&
11598 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11599 direction_new |= dir;
11602 return getBeltFromNrAndOpenDirection(nr, direction_new);
11605 static int getClosedPool(int x, int y)
11607 struct XY *xy = xy_directions;
11608 int element_old = IntelliDrawBuffer[x][y];
11609 int direction_old = getOpenDirectionFromPool(element_old);
11610 int direction_new = MV_NONE;
11613 for (i = 0; i < NUM_DIRECTIONS; i++)
11615 int xx = x + xy[i].x;
11616 int yy = y + xy[i].y;
11617 int dir = MV_DIR_FROM_BIT(i);
11618 int dir_opposite = MV_DIR_OPPOSITE(dir);
11620 if (IN_LEV_FIELD(xx, yy) &&
11621 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
11622 (direction_old & dir) &&
11623 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11624 direction_new |= dir;
11627 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
11630 static int getClosedPillar(int x, int y)
11632 struct XY *xy = xy_directions;
11633 int element_old = IntelliDrawBuffer[x][y];
11634 int direction_old = getOpenDirectionFromPillar(element_old);
11635 int direction_new = MV_NONE;
11638 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11640 int xx = x + xy[i].x;
11641 int yy = y + xy[i].y;
11642 int dir = MV_DIR_FROM_BIT(i);
11643 int dir_opposite = MV_DIR_OPPOSITE(dir);
11645 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11646 (direction_old & dir) &&
11647 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11648 direction_new |= dir;
11651 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11654 static int getClosedSteel2(int x, int y)
11656 struct XY *xy = xy_directions;
11657 int element_old = IntelliDrawBuffer[x][y];
11658 int direction_old = getOpenDirectionFromSteel2(element_old);
11659 int direction_new = MV_NONE;
11662 for (i = 0; i < NUM_DIRECTIONS; i++)
11664 int xx = x + xy[i].x;
11665 int yy = y + xy[i].y;
11666 int dir = MV_DIR_FROM_BIT(i);
11667 int dir_opposite = MV_DIR_OPPOSITE(dir);
11669 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11670 (direction_old & dir) &&
11671 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11672 direction_new |= dir;
11675 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11678 static int getClosedChip(int x, int y)
11680 struct XY *xy = xy_directions;
11681 int element_old = IntelliDrawBuffer[x][y];
11682 int direction_old = getOpenDirectionFromChip(element_old);
11683 int direction_new = MV_NONE;
11686 for (i = 0; i < NUM_DIRECTIONS; i++)
11688 int xx = x + xy[i].x;
11689 int yy = y + xy[i].y;
11690 int dir = MV_DIR_FROM_BIT(i);
11691 int dir_opposite = MV_DIR_OPPOSITE(dir);
11693 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11694 (direction_old & dir) &&
11695 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11696 direction_new |= dir;
11699 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11702 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11703 boolean change_level)
11705 int sx = x - level_xpos;
11706 int sy = y - level_ypos;
11707 int old_element = Tile[x][y];
11708 int new_element = element;
11709 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11710 boolean draw_masked = FALSE;
11712 if (IS_MM_WALL_EDITOR(element))
11714 element = map_mm_wall_element_editor(element) | new_bitmask;
11716 if (IS_MM_WALL(old_element))
11717 element |= MM_WALL_BITS(old_element);
11720 draw_masked = TRUE;
11722 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11724 int element_changed = old_element & ~new_bitmask;
11726 if (MM_WALL_BITS(element_changed) != 0)
11727 element = element_changed;
11730 IntelliDrawBuffer[x][y] = element;
11733 Tile[x][y] = element;
11735 if (IN_ED_FIELD(sx, sy))
11737 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11738 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11739 else if (draw_masked)
11740 DrawEditorElementThruMask(sx, sy, element);
11742 DrawEditorElement(sx, sy, element);
11746 static void SetElementSimple(int x, int y, int element, boolean change_level)
11748 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11751 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11752 int x2, int y2, int *element2,
11753 int (*close_function)(int, int),
11754 boolean change_level)
11756 // set neighbour elements to newly determined connections
11757 SetElementSimple(x1, y1, *element1, change_level);
11758 SetElementSimple(x2, y2, *element2, change_level);
11760 // remove all open connections of neighbour elements
11761 *element1 = close_function(x1, y1);
11762 *element2 = close_function(x2, y2);
11764 // set neighbour elements to new, minimized connections
11765 SetElementSimple(x1, y1, *element1, change_level);
11766 SetElementSimple(x2, y2, *element2, change_level);
11769 static void SetElementIntelliDraw(int x, int y, int dx, int dy, int new_element,
11770 boolean change_level, int button)
11772 struct XY *xy = xy_directions;
11773 static int last_x = -1;
11774 static int last_y = -1;
11776 if (new_element == EL_UNDEFINED)
11784 int old_element = IntelliDrawBuffer[x][y];
11786 if (IS_TUBE(new_element))
11788 int last_element_new = EL_UNDEFINED;
11789 int direction = MV_NONE;
11792 // if old element is of same kind, keep all existing directions
11793 if (IS_TUBE(old_element))
11794 direction |= getOpenDirectionFromTube(old_element);
11796 for (i = 0; i < NUM_DIRECTIONS; i++)
11798 int xx = x + xy[i].x;
11799 int yy = y + xy[i].y;
11801 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11802 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11804 int dir = MV_DIR_FROM_BIT(i);
11805 int dir_opposite = MV_DIR_OPPOSITE(dir);
11806 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11807 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11808 int last_direction_new = last_direction_old | dir_opposite;
11810 last_element_new = getTubeFromOpenDirection(last_direction_new);
11816 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
11818 if (last_element_new != EL_UNDEFINED)
11819 MergeAndCloseNeighbourElements(x, y, &new_element,
11820 last_x, last_y, &last_element_new,
11821 getClosedTube, change_level);
11823 else if (IS_BELT(new_element))
11825 int belt_nr = getBeltNrFromBeltElement(new_element);
11826 int last_element_new = EL_UNDEFINED;
11827 int direction = MV_NONE;
11830 // if old element is of same kind, keep all existing directions
11831 if (IS_BELT(old_element))
11832 direction |= getOpenDirectionFromBelt(old_element);
11834 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11836 int xx = x + xy[i].x;
11837 int yy = y + xy[i].y;
11839 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11840 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
11842 int dir = MV_DIR_FROM_BIT(i);
11843 int dir_opposite = MV_DIR_OPPOSITE(dir);
11844 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11845 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
11846 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
11847 int last_direction_new = last_direction_old | dir_opposite;
11849 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11850 last_direction_new);
11855 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
11857 if (last_element_new != EL_UNDEFINED)
11858 MergeAndCloseNeighbourElements(x, y, &new_element,
11859 last_x, last_y, &last_element_new,
11860 getClosedBelt, change_level);
11862 else if (IS_ACID_POOL_OR_ACID(new_element))
11864 int last_element_new = EL_UNDEFINED;
11865 int direction = MV_NONE;
11868 // if old element is of same kind, keep all existing directions
11869 if (IS_ACID_POOL_OR_ACID(old_element))
11870 direction |= getOpenDirectionFromPool(old_element);
11872 for (i = 0; i < NUM_DIRECTIONS; i++)
11874 int xx = x + xy[i].x;
11875 int yy = y + xy[i].y;
11877 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11878 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
11880 int dir = MV_DIR_FROM_BIT(i);
11881 int dir_opposite = MV_DIR_OPPOSITE(dir);
11882 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11883 int last_direction_old = getOpenDirectionFromPool(last_element_old);
11884 int last_direction_new = last_direction_old | dir_opposite;
11886 last_element_new = getPoolFromOpenDirection(last_direction_new);
11892 // special corrections needed for intuitively correct acid pool drawing
11893 if (last_element_new == EL_EMPTY)
11894 last_element_new = new_element;
11895 else if (last_element_new != EL_UNDEFINED)
11896 new_element = last_element_new;
11898 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
11900 if (last_element_new != EL_UNDEFINED)
11901 MergeAndCloseNeighbourElements(x, y, &new_element,
11902 last_x, last_y, &last_element_new,
11903 getClosedPool, change_level);
11905 else if (IS_EMC_PILLAR(new_element))
11907 int last_element_new = EL_UNDEFINED;
11908 int direction = MV_NONE;
11911 // if old element is of same kind, keep all existing directions
11912 if (IS_EMC_PILLAR(old_element))
11913 direction |= getOpenDirectionFromPillar(old_element);
11915 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11917 int xx = x + xy[i].x;
11918 int yy = y + xy[i].y;
11920 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11921 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
11923 int dir = MV_DIR_FROM_BIT(i);
11924 int dir_opposite = MV_DIR_OPPOSITE(dir);
11925 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11926 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
11927 int last_direction_new = last_direction_old | dir_opposite;
11929 last_element_new = getPillarFromOpenDirection(last_direction_new);
11935 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
11937 if (last_element_new != EL_UNDEFINED)
11938 MergeAndCloseNeighbourElements(x, y, &new_element,
11939 last_x, last_y, &last_element_new,
11940 getClosedPillar, change_level);
11942 else if (IS_DC_STEELWALL_2(new_element))
11944 int last_element_new = EL_UNDEFINED;
11945 int direction = MV_NONE;
11948 // if old element is of same kind, keep all existing directions
11949 if (IS_DC_STEELWALL_2(old_element))
11950 direction |= getOpenDirectionFromSteel2(old_element);
11952 for (i = 0; i < NUM_DIRECTIONS; i++)
11954 int xx = x + xy[i].x;
11955 int yy = y + xy[i].y;
11957 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11958 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
11960 int dir = MV_DIR_FROM_BIT(i);
11961 int dir_opposite = MV_DIR_OPPOSITE(dir);
11962 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11963 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
11964 int last_direction_new = last_direction_old | dir_opposite;
11966 last_element_new = getSteel2FromOpenDirection(last_direction_new);
11972 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
11974 if (last_element_new != EL_UNDEFINED)
11975 MergeAndCloseNeighbourElements(x, y, &new_element,
11976 last_x, last_y, &last_element_new,
11977 getClosedSteel2, change_level);
11979 else if (IS_SP_CHIP(new_element))
11981 int last_element_new = EL_UNDEFINED;
11982 int direction = MV_NONE;
11985 // (do not keep existing directions, regardless of kind of old element)
11987 for (i = 0; i < NUM_DIRECTIONS; i++)
11989 int xx = x + xy[i].x;
11990 int yy = y + xy[i].y;
11992 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11993 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
11995 int dir = MV_DIR_FROM_BIT(i);
11996 int dir_opposite = MV_DIR_OPPOSITE(dir);
11997 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11998 int last_direction_old = getOpenDirectionFromChip(last_element_old);
11999 int last_direction_new = last_direction_old | dir_opposite;
12001 if (last_direction_old == MV_NONE)
12003 last_element_new = getChipFromOpenDirection(last_direction_new);
12006 else if (last_direction_old & (dir | dir_opposite))
12008 direction |= MV_DIR_OPPOSITE(last_direction_old);
12012 direction |= MV_DIR_OPPOSITE(dir);
12017 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
12019 if (last_element_new != EL_UNDEFINED)
12020 MergeAndCloseNeighbourElements(x, y, &new_element,
12021 last_x, last_y, &last_element_new,
12022 getClosedChip, change_level);
12024 else if (IS_SP_HARDWARE_BASE(new_element))
12026 int nr = GetSimpleRandom(6);
12028 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
12029 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
12030 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
12031 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
12032 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
12034 else if (new_element == EL_SP_HARDWARE_GREEN ||
12035 new_element == EL_SP_HARDWARE_BLUE ||
12036 new_element == EL_SP_HARDWARE_RED)
12038 int nr = GetSimpleRandom(3);
12040 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
12041 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
12043 else if (IS_GROUP_ELEMENT(new_element))
12045 boolean connected_drawing = FALSE;
12048 for (i = 0; i < NUM_DIRECTIONS; i++)
12050 int xx = x + xy[i].x;
12051 int yy = y + xy[i].y;
12053 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
12054 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
12055 connected_drawing = TRUE;
12058 if (!connected_drawing)
12059 ResolveGroupElement(new_element);
12061 new_element = GetElementFromGroupElement(new_element);
12063 else if (IS_BELT_SWITCH(old_element))
12065 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
12066 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
12068 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
12069 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
12071 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
12075 static int swappable_elements[][2] =
12077 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
12078 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
12079 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
12080 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
12081 { EL_EMERALD, EL_WALL_EMERALD },
12082 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
12083 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
12084 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
12085 { EL_DIAMOND, EL_WALL_DIAMOND },
12086 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
12087 { EL_GATE_1, EL_GATE_1_GRAY },
12088 { EL_GATE_2, EL_GATE_2_GRAY },
12089 { EL_GATE_3, EL_GATE_3_GRAY },
12090 { EL_GATE_4, EL_GATE_4_GRAY },
12091 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
12092 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
12093 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
12094 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
12095 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
12096 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
12097 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
12098 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
12099 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
12100 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
12101 { EL_LAMP, EL_LAMP_ACTIVE },
12102 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
12103 { EL_SP_BASE, EL_SP_BUGGY_BASE },
12104 { EL_PEARL, EL_WALL_PEARL },
12105 { EL_CRYSTAL, EL_WALL_CRYSTAL },
12106 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
12107 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
12108 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
12109 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
12110 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
12111 { EL_LANDMINE, EL_DC_LANDMINE },
12112 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
12113 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
12114 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
12115 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
12116 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
12117 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
12118 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
12119 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
12120 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
12124 static int rotatable_elements_4[][4] =
12134 EL_SPACESHIP_RIGHT,
12139 EL_BD_BUTTERFLY_UP,
12140 EL_BD_BUTTERFLY_RIGHT,
12141 EL_BD_BUTTERFLY_DOWN,
12142 EL_BD_BUTTERFLY_LEFT
12146 EL_BD_FIREFLY_RIGHT,
12147 EL_BD_FIREFLY_DOWN,
12175 EL_SP_GRAVITY_PORT_UP,
12176 EL_SP_GRAVITY_PORT_RIGHT,
12177 EL_SP_GRAVITY_PORT_DOWN,
12178 EL_SP_GRAVITY_PORT_LEFT
12181 EL_SP_GRAVITY_ON_PORT_UP,
12182 EL_SP_GRAVITY_ON_PORT_RIGHT,
12183 EL_SP_GRAVITY_ON_PORT_DOWN,
12184 EL_SP_GRAVITY_ON_PORT_LEFT
12187 EL_SP_GRAVITY_OFF_PORT_UP,
12188 EL_SP_GRAVITY_OFF_PORT_RIGHT,
12189 EL_SP_GRAVITY_OFF_PORT_DOWN,
12190 EL_SP_GRAVITY_OFF_PORT_LEFT
12199 EL_BALLOON_SWITCH_UP,
12200 EL_BALLOON_SWITCH_RIGHT,
12201 EL_BALLOON_SWITCH_DOWN,
12202 EL_BALLOON_SWITCH_LEFT
12206 EL_MM_MCDUFFIN_RIGHT,
12207 EL_MM_MCDUFFIN_DOWN,
12208 EL_MM_MCDUFFIN_LEFT
12211 EL_MM_MIRROR_FIXED_1,
12212 EL_MM_MIRROR_FIXED_4,
12213 EL_MM_MIRROR_FIXED_3,
12214 EL_MM_MIRROR_FIXED_2
12217 EL_MM_STEEL_GRID_FIXED_1,
12218 EL_MM_STEEL_GRID_FIXED_4,
12219 EL_MM_STEEL_GRID_FIXED_2,
12220 EL_MM_STEEL_GRID_FIXED_3
12223 EL_MM_WOODEN_GRID_FIXED_1,
12224 EL_MM_WOODEN_GRID_FIXED_4,
12225 EL_MM_WOODEN_GRID_FIXED_2,
12226 EL_MM_WOODEN_GRID_FIXED_3
12229 EL_MM_POLARIZER_CROSS_1,
12230 EL_MM_POLARIZER_CROSS_4,
12231 EL_MM_POLARIZER_CROSS_3,
12232 EL_MM_POLARIZER_CROSS_2
12236 EL_MM_PACMAN_RIGHT,
12248 EL_DF_RECEIVER_RIGHT,
12249 EL_DF_RECEIVER_DOWN,
12250 EL_DF_RECEIVER_LEFT
12263 static int rotatable_elements_8[][8] =
12266 EL_DF_STEEL_GRID_FIXED_1,
12267 EL_DF_STEEL_GRID_FIXED_8,
12268 EL_DF_STEEL_GRID_FIXED_7,
12269 EL_DF_STEEL_GRID_FIXED_6,
12270 EL_DF_STEEL_GRID_FIXED_5,
12271 EL_DF_STEEL_GRID_FIXED_4,
12272 EL_DF_STEEL_GRID_FIXED_3,
12273 EL_DF_STEEL_GRID_FIXED_2
12276 EL_DF_WOODEN_GRID_FIXED_1,
12277 EL_DF_WOODEN_GRID_FIXED_8,
12278 EL_DF_WOODEN_GRID_FIXED_7,
12279 EL_DF_WOODEN_GRID_FIXED_6,
12280 EL_DF_WOODEN_GRID_FIXED_5,
12281 EL_DF_WOODEN_GRID_FIXED_4,
12282 EL_DF_WOODEN_GRID_FIXED_3,
12283 EL_DF_WOODEN_GRID_FIXED_2
12286 EL_DF_STEEL_GRID_ROTATING_1,
12287 EL_DF_STEEL_GRID_ROTATING_8,
12288 EL_DF_STEEL_GRID_ROTATING_7,
12289 EL_DF_STEEL_GRID_ROTATING_6,
12290 EL_DF_STEEL_GRID_ROTATING_5,
12291 EL_DF_STEEL_GRID_ROTATING_4,
12292 EL_DF_STEEL_GRID_ROTATING_3,
12293 EL_DF_STEEL_GRID_ROTATING_2
12296 EL_DF_WOODEN_GRID_ROTATING_1,
12297 EL_DF_WOODEN_GRID_ROTATING_8,
12298 EL_DF_WOODEN_GRID_ROTATING_7,
12299 EL_DF_WOODEN_GRID_ROTATING_6,
12300 EL_DF_WOODEN_GRID_ROTATING_5,
12301 EL_DF_WOODEN_GRID_ROTATING_4,
12302 EL_DF_WOODEN_GRID_ROTATING_3,
12303 EL_DF_WOODEN_GRID_ROTATING_2
12310 static int rotatable_elements_16[][16] =
12331 EL_MM_TELEPORTER_5,
12332 EL_MM_TELEPORTER_4,
12333 EL_MM_TELEPORTER_3,
12334 EL_MM_TELEPORTER_2,
12335 EL_MM_TELEPORTER_1,
12336 EL_MM_TELEPORTER_16,
12337 EL_MM_TELEPORTER_15,
12338 EL_MM_TELEPORTER_14,
12339 EL_MM_TELEPORTER_13,
12340 EL_MM_TELEPORTER_12,
12341 EL_MM_TELEPORTER_11,
12342 EL_MM_TELEPORTER_10,
12343 EL_MM_TELEPORTER_9,
12344 EL_MM_TELEPORTER_8,
12345 EL_MM_TELEPORTER_7,
12349 EL_MM_TELEPORTER_RED_5,
12350 EL_MM_TELEPORTER_RED_4,
12351 EL_MM_TELEPORTER_RED_3,
12352 EL_MM_TELEPORTER_RED_2,
12353 EL_MM_TELEPORTER_RED_1,
12354 EL_MM_TELEPORTER_RED_16,
12355 EL_MM_TELEPORTER_RED_15,
12356 EL_MM_TELEPORTER_RED_14,
12357 EL_MM_TELEPORTER_RED_13,
12358 EL_MM_TELEPORTER_RED_12,
12359 EL_MM_TELEPORTER_RED_11,
12360 EL_MM_TELEPORTER_RED_10,
12361 EL_MM_TELEPORTER_RED_9,
12362 EL_MM_TELEPORTER_RED_8,
12363 EL_MM_TELEPORTER_RED_7,
12364 EL_MM_TELEPORTER_RED_6
12367 EL_MM_TELEPORTER_YELLOW_5,
12368 EL_MM_TELEPORTER_YELLOW_4,
12369 EL_MM_TELEPORTER_YELLOW_3,
12370 EL_MM_TELEPORTER_YELLOW_2,
12371 EL_MM_TELEPORTER_YELLOW_1,
12372 EL_MM_TELEPORTER_YELLOW_16,
12373 EL_MM_TELEPORTER_YELLOW_15,
12374 EL_MM_TELEPORTER_YELLOW_14,
12375 EL_MM_TELEPORTER_YELLOW_13,
12376 EL_MM_TELEPORTER_YELLOW_12,
12377 EL_MM_TELEPORTER_YELLOW_11,
12378 EL_MM_TELEPORTER_YELLOW_10,
12379 EL_MM_TELEPORTER_YELLOW_9,
12380 EL_MM_TELEPORTER_YELLOW_8,
12381 EL_MM_TELEPORTER_YELLOW_7,
12382 EL_MM_TELEPORTER_YELLOW_6
12385 EL_MM_TELEPORTER_GREEN_5,
12386 EL_MM_TELEPORTER_GREEN_4,
12387 EL_MM_TELEPORTER_GREEN_3,
12388 EL_MM_TELEPORTER_GREEN_2,
12389 EL_MM_TELEPORTER_GREEN_1,
12390 EL_MM_TELEPORTER_GREEN_16,
12391 EL_MM_TELEPORTER_GREEN_15,
12392 EL_MM_TELEPORTER_GREEN_14,
12393 EL_MM_TELEPORTER_GREEN_13,
12394 EL_MM_TELEPORTER_GREEN_12,
12395 EL_MM_TELEPORTER_GREEN_11,
12396 EL_MM_TELEPORTER_GREEN_10,
12397 EL_MM_TELEPORTER_GREEN_9,
12398 EL_MM_TELEPORTER_GREEN_8,
12399 EL_MM_TELEPORTER_GREEN_7,
12400 EL_MM_TELEPORTER_GREEN_6
12403 EL_MM_TELEPORTER_BLUE_5,
12404 EL_MM_TELEPORTER_BLUE_4,
12405 EL_MM_TELEPORTER_BLUE_3,
12406 EL_MM_TELEPORTER_BLUE_2,
12407 EL_MM_TELEPORTER_BLUE_1,
12408 EL_MM_TELEPORTER_BLUE_16,
12409 EL_MM_TELEPORTER_BLUE_15,
12410 EL_MM_TELEPORTER_BLUE_14,
12411 EL_MM_TELEPORTER_BLUE_13,
12412 EL_MM_TELEPORTER_BLUE_12,
12413 EL_MM_TELEPORTER_BLUE_11,
12414 EL_MM_TELEPORTER_BLUE_10,
12415 EL_MM_TELEPORTER_BLUE_9,
12416 EL_MM_TELEPORTER_BLUE_8,
12417 EL_MM_TELEPORTER_BLUE_7,
12418 EL_MM_TELEPORTER_BLUE_6
12422 EL_MM_POLARIZER_16,
12423 EL_MM_POLARIZER_15,
12424 EL_MM_POLARIZER_14,
12425 EL_MM_POLARIZER_13,
12426 EL_MM_POLARIZER_12,
12427 EL_MM_POLARIZER_11,
12428 EL_MM_POLARIZER_10,
12457 EL_DF_MIRROR_ROTATING_1,
12458 EL_DF_MIRROR_ROTATING_16,
12459 EL_DF_MIRROR_ROTATING_15,
12460 EL_DF_MIRROR_ROTATING_14,
12461 EL_DF_MIRROR_ROTATING_13,
12462 EL_DF_MIRROR_ROTATING_12,
12463 EL_DF_MIRROR_ROTATING_11,
12464 EL_DF_MIRROR_ROTATING_10,
12465 EL_DF_MIRROR_ROTATING_9,
12466 EL_DF_MIRROR_ROTATING_8,
12467 EL_DF_MIRROR_ROTATING_7,
12468 EL_DF_MIRROR_ROTATING_6,
12469 EL_DF_MIRROR_ROTATING_5,
12470 EL_DF_MIRROR_ROTATING_4,
12471 EL_DF_MIRROR_ROTATING_3,
12472 EL_DF_MIRROR_ROTATING_2
12475 EL_DF_MIRROR_FIXED_1,
12476 EL_DF_MIRROR_FIXED_16,
12477 EL_DF_MIRROR_FIXED_15,
12478 EL_DF_MIRROR_FIXED_14,
12479 EL_DF_MIRROR_FIXED_13,
12480 EL_DF_MIRROR_FIXED_12,
12481 EL_DF_MIRROR_FIXED_11,
12482 EL_DF_MIRROR_FIXED_10,
12483 EL_DF_MIRROR_FIXED_9,
12484 EL_DF_MIRROR_FIXED_8,
12485 EL_DF_MIRROR_FIXED_7,
12486 EL_DF_MIRROR_FIXED_6,
12487 EL_DF_MIRROR_FIXED_5,
12488 EL_DF_MIRROR_FIXED_4,
12489 EL_DF_MIRROR_FIXED_3,
12490 EL_DF_MIRROR_FIXED_2
12499 for (i = 0; swappable_elements[i][0] != -1; i++)
12501 int element1 = swappable_elements[i][0];
12502 int element2 = swappable_elements[i][1];
12504 if (old_element == element1 || old_element == element2)
12505 new_element = (old_element == element1 ? element2 : element1);
12508 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
12510 for (j = 0; j < 4; j++)
12512 int element = rotatable_elements_4[i][j];
12514 if (old_element == element)
12515 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
12516 button == 2 ? rotatable_elements_4[i][0] :
12517 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
12522 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
12524 for (j = 0; j < 8; j++)
12526 int element = rotatable_elements_8[i][j];
12528 if (old_element == element)
12529 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
12530 button == 2 ? rotatable_elements_8[i][0] :
12531 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
12536 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
12538 for (j = 0; j < 16; j++)
12540 int element = rotatable_elements_16[i][j];
12542 if (old_element == element)
12543 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
12544 button == 2 ? rotatable_elements_16[i][0] :
12545 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
12550 if (old_element != new_element)
12552 int max_infotext_len = getMaxInfoTextLength();
12553 char infotext[MAX_OUTPUT_LINESIZE + 1];
12555 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
12556 infotext[max_infotext_len] = '\0';
12558 ClearEditorGadgetInfoText();
12560 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
12565 if (IS_MM_WALL_EDITOR(new_element))
12566 SetElementSimpleExt(x, y, dx, dy, new_element, change_level);
12568 SetElementSimple(x, y, new_element, change_level);
12574 static void ResetIntelliDraw(void)
12578 for (x = 0; x < lev_fieldx; x++)
12579 for (y = 0; y < lev_fieldy; y++)
12580 IntelliDrawBuffer[x][y] = Tile[x][y];
12582 SetElementIntelliDraw(-1, -1, -1, -1, EL_UNDEFINED, FALSE, -1);
12585 static boolean draw_mode_hires = FALSE;
12587 static boolean isHiresTileElement(int element)
12589 return (IS_MM_WALL(element) || element == EL_EMPTY);
12592 static boolean isHiresDrawElement(int element)
12594 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
12597 static int numHiresTiles(int element)
12599 if (IS_MM_WALL(element))
12600 return get_number_of_bits(MM_WALL_BITS(element));
12605 static void SetDrawModeHiRes(int element)
12608 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12609 isHiresDrawElement(element));
12612 static boolean getDrawModeHiRes(void)
12614 return draw_mode_hires;
12617 static int getLoResScreenPos(int pos)
12619 return (getDrawModeHiRes() ? pos / 2 : pos);
12622 static int getLoResScreenMod(int pos)
12624 return (getDrawModeHiRes() ? pos % 2 : 0);
12627 static void SetElementExt(int x, int y, int dx, int dy, int element,
12628 boolean change_level, int button)
12631 SetElementSimple(x, y, Tile[x][y], change_level);
12632 else if (GetKeyModState() & KMOD_Shift)
12633 SetElementIntelliDraw(x, y, dx, dy, element, change_level, button);
12635 SetElementSimpleExt(x, y, dx, dy, element, change_level);
12638 static void SetElement(int x, int y, int element)
12640 SetElementExt(x, y, 0, 0, element, TRUE, -1);
12643 static void SetElementButton(int x, int y, int dx, int dy, int element,
12646 SetElementExt(x, y, dx, dy, element, TRUE, button);
12649 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
12651 int lx = getLoResScreenPos(sx2) + level_xpos;
12652 int ly = getLoResScreenPos(sy2) + level_ypos;
12653 int dx = getLoResScreenMod(sx2);
12654 int dy = getLoResScreenMod(sy2);
12656 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
12659 static void SetLevelElementHiRes(int lx2, int ly2, int element)
12666 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
12669 static int getLevelElementHiRes(int lx2, int ly2)
12675 int element = Tile[lx][ly];
12676 unsigned int bitmask = (dx + 1) << (dy * 2);
12678 if (IS_MM_WALL(element))
12680 if (element & bitmask)
12681 return map_mm_wall_element(element);
12689 static void DrawLineElement(int x, int y, int element, boolean change_level)
12691 SetElementHiRes(x, y, element, change_level);
12694 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12695 int element, boolean change_level)
12697 int xsize = ABS(to_x - from_x);
12698 int ysize = ABS(to_y - from_y);
12699 int dx = (to_x < from_x ? -1 : +1);
12700 int dy = (to_y < from_y ? -1 : +1);
12703 if (from_y == to_y) // horizontal line
12705 for (i = 0; i <= xsize; i++)
12706 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12708 else if (from_x == to_x) // vertical line
12710 for (i = 0; i <= ysize; i++)
12711 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12713 else // diagonal line
12715 if (ysize < xsize) // a < 1
12717 float a = (float)ysize / (float)xsize;
12719 for (i = 0; i <= xsize; i++)
12722 int y = dy * (int)(a * i + 0.5);
12724 DrawLineElement(from_x + x, from_y + y, element, change_level);
12729 float a = (float)xsize / (float)ysize;
12731 for (i = 0; i <= ysize; i++)
12733 int x = dx * (int)(a * i + 0.5);
12736 DrawLineElement(from_x + x, from_y + y, element, change_level);
12742 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12743 int element, boolean change_level)
12745 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12746 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12747 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12748 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12751 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12752 int element, boolean change_level)
12757 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12759 for (y = from_y; y <= to_y; y++)
12760 DrawLine(from_x, y, to_x, y, element, change_level);
12763 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12764 int element, boolean change_level)
12766 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12767 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12768 int len_x = ABS(to_x - from_x);
12769 int len_y = ABS(to_y - from_y);
12772 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
12774 // not optimal (some points get drawn twice) but simple,
12775 // and fast enough for the few points we are drawing
12777 for (x = 0; x <= radius; x++)
12779 int sx, sy, sx2, sy2, lx, ly;
12781 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
12783 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12784 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12785 sx = getLoResScreenPos(sx2);
12786 sy = getLoResScreenPos(sy2);
12787 lx = sx + level_xpos;
12788 ly = sy + level_ypos;
12790 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12791 DrawLineElement(sx2, sy2, element, change_level);
12794 for (y = 0; y <= radius; y++)
12796 int sx, sy, sx2, sy2, lx, ly;
12798 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
12800 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12801 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12802 sx = getLoResScreenPos(sx2);
12803 sy = getLoResScreenPos(sy2);
12804 lx = sx + level_xpos;
12805 ly = sy + level_ypos;
12807 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12808 DrawLineElement(sx2, sy2, element, change_level);
12812 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
12813 int element, boolean change_level)
12815 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12816 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12818 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12821 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
12823 #if DRAW_CIRCLES_BUTTON_AVAILABLE
12824 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
12825 int element, boolean change_level)
12827 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12828 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12829 int mirror_to_x2 = from_x - (to_x2 - from_x);
12830 int mirror_to_y2 = from_y - (to_y2 - from_y);
12832 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12833 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
12834 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
12835 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element, change_level);
12839 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
12841 int from_sx, from_sy;
12845 swap_numbers(&from_x, &to_x);
12848 swap_numbers(&from_y, &to_y);
12850 from_sx = SX + from_x * ed_tilesize;
12851 from_sy = SY + from_y * ed_tilesize;
12852 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
12853 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
12855 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12856 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12857 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12858 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12860 if (from_x == to_x && from_y == to_y)
12861 MarkTileDirty(from_x/2, from_y/2);
12863 redraw_mask |= REDRAW_FIELD;
12866 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
12867 int element, boolean change_level)
12869 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
12872 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
12873 int element, boolean change_level)
12875 if (element == -1 || change_level)
12876 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
12878 DrawAreaBorder(from_x, from_y, to_x, to_y);
12881 // values for CopyBrushExt()
12882 #define CB_AREA_TO_BRUSH 0
12883 #define CB_BRUSH_TO_CURSOR 1
12884 #define CB_BRUSH_TO_LEVEL 2
12885 #define CB_DELETE_OLD_CURSOR 3
12886 #define CB_DUMP_BRUSH 4
12887 #define CB_DUMP_BRUSH_SMALL 5
12888 #define CB_CLIPBOARD_TO_BRUSH 6
12889 #define CB_BRUSH_TO_CLIPBOARD 7
12890 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
12891 #define CB_UPDATE_BRUSH_POSITION 9
12892 #define CB_FLIP_BRUSH_X 10
12893 #define CB_FLIP_BRUSH_Y 11
12894 #define CB_FLIP_BRUSH_XY 12
12896 #define MAX_CB_PART_SIZE 10
12897 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
12898 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
12899 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
12900 MAX_CB_NUM_LINES * \
12903 static int getFlippedTileExt(int map[], int element)
12907 for (i = 0; map[i] != -1; i++)
12908 if (map[i] == element)
12909 return map[i ^ 1]; // get flipped element by flipping LSB of index
12914 static int getFlippedTileX(int element)
12918 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_RIGHT,
12919 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_RIGHT,
12920 EL_BUG_LEFT, EL_BUG_RIGHT,
12921 EL_SPACESHIP_LEFT, EL_SPACESHIP_RIGHT,
12922 EL_PACMAN_LEFT, EL_PACMAN_RIGHT,
12923 EL_ARROW_LEFT, EL_ARROW_RIGHT,
12924 EL_MOLE_LEFT, EL_MOLE_RIGHT,
12925 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_RIGHT,
12926 EL_YAMYAM_LEFT, EL_YAMYAM_RIGHT,
12927 EL_SP_PORT_LEFT, EL_SP_PORT_RIGHT,
12928 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_RIGHT,
12929 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_RIGHT,
12930 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_RIGHT,
12931 EL_CONVEYOR_BELT_1_LEFT, EL_CONVEYOR_BELT_1_RIGHT,
12932 EL_CONVEYOR_BELT_2_LEFT, EL_CONVEYOR_BELT_2_RIGHT,
12933 EL_CONVEYOR_BELT_3_LEFT, EL_CONVEYOR_BELT_3_RIGHT,
12934 EL_CONVEYOR_BELT_4_LEFT, EL_CONVEYOR_BELT_4_RIGHT,
12935 EL_SPRING_LEFT, EL_SPRING_RIGHT,
12936 EL_SP_CHIP_LEFT, EL_SP_CHIP_RIGHT,
12937 EL_TUBE_VERTICAL_LEFT, EL_TUBE_VERTICAL_RIGHT,
12938 EL_TUBE_LEFT_UP, EL_TUBE_RIGHT_UP,
12939 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_DOWN,
12940 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_RIGHT,
12941 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_TOPRIGHT,
12942 EL_DC_STEELWALL_1_BOTTOMLEFT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
12943 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_TOPRIGHT_2,
12944 EL_DC_STEELWALL_1_BOTTOMLEFT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
12945 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_RIGHT,
12946 EL_ACID_POOL_TOPLEFT, EL_ACID_POOL_TOPRIGHT,
12947 EL_ACID_POOL_BOTTOMLEFT, EL_ACID_POOL_BOTTOMRIGHT,
12952 return getFlippedTileExt(map, element);
12955 static int getFlippedTileY(int element)
12959 EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY_DOWN,
12960 EL_BD_FIREFLY_UP, EL_BD_FIREFLY_DOWN,
12961 EL_BUG_UP, EL_BUG_DOWN,
12962 EL_SPACESHIP_UP, EL_SPACESHIP_DOWN,
12963 EL_PACMAN_UP, EL_PACMAN_DOWN,
12964 EL_ARROW_UP, EL_ARROW_DOWN,
12965 EL_MOLE_UP, EL_MOLE_DOWN,
12966 EL_BALLOON_SWITCH_UP, EL_BALLOON_SWITCH_DOWN,
12967 EL_YAMYAM_UP, EL_YAMYAM_DOWN,
12968 EL_SP_PORT_UP, EL_SP_PORT_DOWN,
12969 EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN,
12970 EL_SP_GRAVITY_ON_PORT_UP, EL_SP_GRAVITY_ON_PORT_DOWN,
12971 EL_SP_GRAVITY_OFF_PORT_UP, EL_SP_GRAVITY_OFF_PORT_DOWN,
12972 EL_SP_CHIP_TOP, EL_SP_CHIP_BOTTOM,
12973 EL_TUBE_HORIZONTAL_UP, EL_TUBE_HORIZONTAL_DOWN,
12974 EL_TUBE_LEFT_UP, EL_TUBE_LEFT_DOWN,
12975 EL_TUBE_RIGHT_UP, EL_TUBE_RIGHT_DOWN,
12976 EL_DC_STEELWALL_1_TOP, EL_DC_STEELWALL_1_BOTTOM,
12977 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_BOTTOMLEFT,
12978 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
12979 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
12980 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
12981 EL_DC_STEELWALL_2_TOP, EL_DC_STEELWALL_2_BOTTOM,
12982 EL_EMC_WALL_1, EL_EMC_WALL_3,
12987 return getFlippedTileExt(map, element);
12990 static int getFlippedTileXY(int element)
12994 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_UP,
12995 EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY_DOWN,
12996 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_UP,
12997 EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY_DOWN,
12998 EL_BUG_LEFT, EL_BUG_UP,
12999 EL_BUG_RIGHT, EL_BUG_DOWN,
13000 EL_SPACESHIP_LEFT, EL_SPACESHIP_UP,
13001 EL_SPACESHIP_RIGHT, EL_SPACESHIP_DOWN,
13002 EL_PACMAN_LEFT, EL_PACMAN_UP,
13003 EL_PACMAN_RIGHT, EL_PACMAN_DOWN,
13004 EL_ARROW_LEFT, EL_ARROW_UP,
13005 EL_ARROW_RIGHT, EL_ARROW_DOWN,
13006 EL_MOLE_LEFT, EL_MOLE_UP,
13007 EL_MOLE_RIGHT, EL_MOLE_DOWN,
13008 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_UP,
13009 EL_BALLOON_SWITCH_RIGHT, EL_BALLOON_SWITCH_DOWN,
13010 EL_YAMYAM_LEFT, EL_YAMYAM_UP,
13011 EL_YAMYAM_RIGHT, EL_YAMYAM_DOWN,
13012 EL_SP_PORT_LEFT, EL_SP_PORT_UP,
13013 EL_SP_PORT_RIGHT, EL_SP_PORT_DOWN,
13014 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_UP,
13015 EL_SP_GRAVITY_PORT_RIGHT, EL_SP_GRAVITY_PORT_DOWN,
13016 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_UP,
13017 EL_SP_GRAVITY_ON_PORT_RIGHT, EL_SP_GRAVITY_ON_PORT_DOWN,
13018 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_UP,
13019 EL_SP_GRAVITY_OFF_PORT_RIGHT, EL_SP_GRAVITY_OFF_PORT_DOWN,
13020 EL_SP_CHIP_LEFT, EL_SP_CHIP_TOP,
13021 EL_SP_CHIP_RIGHT, EL_SP_CHIP_BOTTOM,
13022 EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL,
13023 EL_TUBE_VERTICAL_LEFT, EL_TUBE_HORIZONTAL_UP,
13024 EL_TUBE_VERTICAL_RIGHT, EL_TUBE_HORIZONTAL_DOWN,
13025 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_UP,
13026 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_TOP,
13027 EL_DC_STEELWALL_1_RIGHT, EL_DC_STEELWALL_1_BOTTOM,
13028 EL_DC_STEELWALL_1_HORIZONTAL, EL_DC_STEELWALL_1_VERTICAL,
13029 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMLEFT,
13030 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
13031 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_TOP,
13032 EL_DC_STEELWALL_2_RIGHT, EL_DC_STEELWALL_2_BOTTOM,
13033 EL_DC_STEELWALL_2_HORIZONTAL, EL_DC_STEELWALL_2_VERTICAL,
13034 EL_EXPANDABLE_WALL_HORIZONTAL, EL_EXPANDABLE_WALL_VERTICAL,
13035 EL_EXPANDABLE_STEELWALL_HORIZONTAL, EL_EXPANDABLE_STEELWALL_VERTICAL,
13040 return getFlippedTileExt(map, element);
13043 static int getFlippedTile(int element, int mode)
13045 if (IS_MM_ELEMENT(element))
13047 // get MM game element
13048 element = map_element_RND_to_MM(element);
13050 // get flipped game element
13051 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX_MM(element) :
13052 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY_MM(element) :
13053 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY_MM(element) :
13056 // get RND game element again
13057 element = map_element_MM_to_RND(element);
13061 // get flipped game element
13062 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX(element) :
13063 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY(element) :
13064 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY(element) :
13071 static void SwapFlippedTiles(short *tile1, short *tile2, int mode)
13074 short tile1_flipped = getFlippedTile(*tile1, mode);
13075 short tile2_flipped = getFlippedTile(*tile2, mode);
13078 *tile1 = tile2_flipped;
13079 *tile2 = tile1_flipped;
13082 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
13084 DrawLineElement(sx, sy, element, change_level);
13087 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
13088 int button, int mode)
13090 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13091 static int brush_width, brush_height;
13092 static int last_cursor_x = -1, last_cursor_y = -1;
13093 static boolean delete_old_brush = FALSE;
13094 int new_element = BUTTON_ELEMENT(button);
13097 if (mode == CB_DUMP_BRUSH ||
13098 mode == CB_DUMP_BRUSH_SMALL ||
13099 mode == CB_BRUSH_TO_CLIPBOARD ||
13100 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13102 if (edit_mode != ED_MODE_DRAWING)
13105 char part[MAX_CB_PART_SIZE + 1] = "";
13106 char text[MAX_CB_TEXT_SIZE + 1] = "";
13107 int width = (draw_with_brush ? brush_width : lev_fieldx);
13108 int height = (draw_with_brush ? brush_height : lev_fieldy);
13109 char *format = "%s%03d";
13111 for (y = 0; y < height; y++)
13112 for (x = 0; x < width; x++)
13113 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
13116 for (y = 0; y < height; y++)
13118 for (x = 0; x < width; x++)
13120 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
13121 char *prefix = (mode == CB_DUMP_BRUSH ||
13122 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
13124 if (element >= NUM_FILE_ELEMENTS)
13125 element = EL_UNKNOWN;
13127 // copy brush to level sketch text buffer for the R'n'D forum:
13128 // - large tiles: `xxx or `xxxx (0x60 ASCII)
13129 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
13130 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
13131 strcat(text, part);
13134 strcat(text, "\n");
13137 if (mode == CB_BRUSH_TO_CLIPBOARD ||
13138 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
13139 SDL_SetClipboardText(text);
13141 Print("%s", text); // print brush data to console and log file
13146 if (mode == CB_CLIPBOARD_TO_BRUSH)
13148 if (edit_mode != ED_MODE_DRAWING)
13151 if (!SDL_HasClipboardText())
13153 Request("Clipboard is empty!", REQ_CONFIRM);
13158 boolean copy_to_brush = (draw_with_brush ||
13159 drawing_function == GADGET_ID_GRAB_BRUSH);
13161 // this will delete the old brush, if already drawing with a brush
13163 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
13165 // initialization is required for "odd" (incomplete) clipboard content
13166 for (x = 0; x < MAX_LEV_FIELDX; x++)
13167 for (y = 0; y < MAX_LEV_FIELDY; y++)
13168 brush_buffer[x][y] = EL_EMPTY;
13175 char *clipboard_text = SDL_GetClipboardText();
13176 char *ptr = clipboard_text;
13177 boolean allow_new_row = FALSE;
13178 boolean stop = FALSE;
13180 while (*ptr && !stop)
13182 boolean prefix_found = FALSE;
13183 boolean start_new_row = FALSE;
13185 // level sketch element number prefixes (may be multi-byte characters)
13186 char *prefix_list[] = { "`", "¸" };
13189 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
13191 char *prefix = prefix_list[i];
13193 // check if string is large enough for prefix
13194 if (strlen(ptr) < strlen(prefix))
13201 // check if string starts with prefix
13202 if (strPrefix(ptr, prefix))
13204 ptr += strlen(prefix);
13206 prefix_found = TRUE;
13212 // check if prefix found and followed by (at least) three digits
13213 if (prefix_found &&
13214 strlen(ptr) >= 3 &&
13215 ptr[0] >= '0' && ptr[0] <= '9' &&
13216 ptr[1] >= '0' && ptr[1] <= '9' &&
13217 ptr[2] >= '0' && ptr[2] <= '9')
13219 int element = ((ptr[0] - '0') * 100 +
13220 (ptr[1] - '0') * 10 +
13225 // level sketch element number might consist of four digits
13226 if (ptr[0] >= '0' && ptr[0] <= '9')
13228 element = element * 10 + (ptr[0] - '0');
13232 // remap some (historic, now obsolete) elements
13233 element = getMappedElement(element);
13235 if (element >= NUM_FILE_ELEMENTS)
13236 element = EL_UNKNOWN;
13238 brush_buffer[x][y] = element;
13240 brush_width = MAX(x + 1, brush_width);
13241 brush_height = MAX(y + 1, brush_height);
13245 if (x >= MAX_LEV_FIELDX)
13246 start_new_row = TRUE;
13248 allow_new_row = TRUE;
13252 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
13253 start_new_row = TRUE;
13255 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
13263 if (y >= MAX_LEV_FIELDY)
13266 allow_new_row = FALSE;
13270 SDL_free(clipboard_text);
13272 if (brush_width == 0 || brush_height == 0)
13274 Request("No level sketch found in clipboard!", REQ_CONFIRM);
13281 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
13284 SDL_GetMouseState(&mx, &my);
13286 // if inside drawing area, activate and draw brush at last mouse position
13287 if (mx >= gi->x && mx < gi->x + gi->width &&
13288 my >= gi->y && my < gi->y + gi->height)
13289 CopyBrushToCursor(last_cursor_x, last_cursor_y);
13291 draw_with_brush = TRUE;
13297 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
13298 brush_width, brush_height);
13300 if (!Request(request, REQ_ASK))
13303 for (x = 0; x < MAX_LEV_FIELDX; x++)
13304 for (y = 0; y < MAX_LEV_FIELDY; y++)
13305 Tile[x][y] = brush_buffer[x][y];
13307 lev_fieldx = level.fieldx = brush_width;
13308 lev_fieldy = level.fieldy = brush_height;
13310 boolean use_bd_engine = TRUE;
13311 boolean use_em_engine = TRUE;
13312 boolean use_sp_engine = TRUE;
13313 boolean use_mm_engine = TRUE;
13315 for (x = 0; x < MAX_LEV_FIELDX; x++)
13317 for (y = 0; y < MAX_LEV_FIELDY; y++)
13319 int element = Tile[x][y];
13321 if (!IS_BD_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13322 use_bd_engine = FALSE;
13324 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13325 use_em_engine = FALSE;
13327 if (!IS_SP_ELEMENT(element))
13328 use_sp_engine = FALSE;
13330 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
13331 use_mm_engine = FALSE;
13335 level.game_engine_type = (use_bd_engine ? GAME_ENGINE_TYPE_BD :
13336 use_em_engine ? GAME_ENGINE_TYPE_EM :
13337 use_sp_engine ? GAME_ENGINE_TYPE_SP :
13338 use_mm_engine ? GAME_ENGINE_TYPE_MM :
13339 GAME_ENGINE_TYPE_RND);
13341 // update element selection list
13342 ReinitializeElementList();
13343 ModifyEditorElementList();
13345 SetBorderElement();
13347 DrawEditModeWindow();
13348 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13354 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
13357 if (mode == CB_AREA_TO_BRUSH)
13359 int from_lx, from_ly;
13362 swap_numbers(&from_x, &to_x);
13365 swap_numbers(&from_y, &to_y);
13367 brush_width = to_x - from_x + 1;
13368 brush_height = to_y - from_y + 1;
13370 from_lx = from_x + level_xpos;
13371 from_ly = from_y + level_ypos;
13373 for (y = 0; y < brush_height; y++)
13375 for (x = 0; x < brush_width; x++)
13377 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
13380 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
13385 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13387 delete_old_brush = FALSE;
13389 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
13390 mode == CB_BRUSH_TO_LEVEL)
13392 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
13393 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
13394 int cursor_from_x = cursor_x - brush_width / 2;
13395 int cursor_from_y = cursor_y - brush_height / 2;
13396 int border_from_x = cursor_x, border_from_y = cursor_y;
13397 int border_to_x = cursor_x, border_to_y = cursor_y;
13399 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
13400 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13402 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
13403 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
13405 delete_old_brush = FALSE;
13410 for (y = 0; y < brush_height; y++)
13412 for (x = 0; x < brush_width; x++)
13414 int sx = cursor_from_x + x;
13415 int sy = cursor_from_y + y;
13416 int lx = sx + level_xpos;
13417 int ly = sy + level_ypos;
13418 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
13419 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
13420 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
13421 brush_buffer[x][y] : new_element);
13423 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13425 if (sx < border_from_x)
13426 border_from_x = sx;
13427 else if (sx > border_to_x)
13429 if (sy < border_from_y)
13430 border_from_y = sy;
13431 else if (sy > border_to_y)
13434 DrawBrushElement(sx, sy, element, change_level);
13439 if (mode != CB_DELETE_OLD_CURSOR)
13440 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
13442 last_cursor_x = cursor_x;
13443 last_cursor_y = cursor_y;
13445 delete_old_brush = TRUE;
13447 else if (mode == CB_FLIP_BRUSH_X)
13449 for (y = 0; y < brush_height; y++)
13450 for (x = 0; x < (brush_width + 1) / 2; x++)
13451 SwapFlippedTiles(&brush_buffer[x][y],
13452 &brush_buffer[brush_width - x - 1][y], mode);
13454 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13456 else if (mode == CB_FLIP_BRUSH_Y)
13458 for (y = 0; y < (brush_height + 1) / 2; y++)
13459 for (x = 0; x < brush_width; x++)
13460 SwapFlippedTiles(&brush_buffer[x][y],
13461 &brush_buffer[x][brush_height - y - 1], mode);
13463 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13465 else if (mode == CB_FLIP_BRUSH_XY)
13467 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13469 for (y = 0; y < MAX(brush_width, brush_height); y++)
13470 for (x = 0; x <= y; x++)
13471 SwapFlippedTiles(&brush_buffer[x][y],
13472 &brush_buffer[y][x], mode);
13474 swap_numbers(&brush_width, &brush_height);
13476 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13479 if (mode == CB_UPDATE_BRUSH_POSITION)
13481 last_cursor_x = from_x;
13482 last_cursor_y = from_y;
13486 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
13489 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
13492 static void CopyBrushToLevel(int x, int y, int button)
13494 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
13497 static void CopyBrushToCursor(int x, int y)
13499 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13502 static void UpdateBrushPosition(int x, int y)
13504 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
13507 static void DeleteBrushFromCursor(void)
13509 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13512 static void FlipBrushX(void)
13514 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13517 static void FlipBrushY(void)
13519 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_Y);
13522 static void RotateBrush(void)
13524 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_XY);
13525 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13528 void DumpBrush(void)
13530 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
13533 void DumpBrush_Small(void)
13535 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
13538 void CopyClipboardToBrush(void)
13540 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
13543 void CopyBrushToClipboard(void)
13545 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
13548 void CopyBrushToClipboard_Small(void)
13550 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
13553 void UndoLevelEditorOperation(void)
13555 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
13558 void RedoLevelEditorOperation(void)
13560 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13563 static void FloodFill(int from_x, int from_y, int fill_element)
13565 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
13568 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
13570 int from_x = from_sx2 + 2 * level_xpos;
13571 int from_y = from_sy2 + 2 * level_ypos;
13572 int max_fillx = lev_fieldx * 2;
13573 int max_filly = lev_fieldy * 2;
13574 short Fill[max_fillx][max_filly];
13577 for (x = 0; x < max_fillx; x++)
13578 for (y = 0; y < max_filly; y++)
13579 Fill[x][y] = getLevelElementHiRes(x, y);
13581 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
13582 Fill, max_fillx, max_filly);
13584 for (x = 0; x < max_fillx; x++)
13585 for (y = 0; y < max_filly; y++)
13586 if (Fill[x][y] == fill_element)
13587 SetLevelElementHiRes(x, y, Fill[x][y]);
13590 // values for DrawLevelText() modes
13591 #define TEXT_INIT 0
13592 #define TEXT_SETCURSOR 1
13593 #define TEXT_WRITECHAR 2
13594 #define TEXT_BACKSPACE 3
13595 #define TEXT_NEWLINE 4
13597 #define TEXT_QUERY_TYPING 6
13599 static int DrawLevelText(int sx, int sy, char letter, int mode)
13601 static short delete_buffer[MAX_LEV_FIELDX];
13602 static int start_sx;
13603 static int last_sx, last_sy;
13604 static boolean typing = FALSE;
13605 int letter_element;
13606 int lx = 0, ly = 0;
13608 // map lower case letters to upper case and convert special characters
13609 if (letter >= 'a' && letter <= 'z')
13610 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
13611 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
13612 letter_element = EL_CHAR_AUMLAUT;
13613 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
13614 letter_element = EL_CHAR_OUMLAUT;
13615 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
13616 letter_element = EL_CHAR_UUMLAUT;
13617 else if (letter == '^')
13618 letter_element = EL_CHAR_COPYRIGHT;
13620 letter_element = EL_CHAR_ASCII0 + letter;
13622 if (mode != TEXT_INIT)
13627 if (mode != TEXT_SETCURSOR)
13633 lx = last_sx + level_xpos;
13634 ly = last_sy + level_ypos;
13641 DrawLevelText(0, 0, 0, TEXT_END);
13647 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
13650 case TEXT_SETCURSOR:
13651 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
13652 DrawAreaBorder(sx, sy, sx, sy);
13653 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
13654 ed_tilesize, ed_tilesize);
13659 case TEXT_WRITECHAR:
13660 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
13662 if (new_element1 >= EL_STEEL_CHAR_START &&
13663 new_element1 <= EL_STEEL_CHAR_END)
13664 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
13666 delete_buffer[sx - start_sx] = Tile[lx][ly];
13667 Tile[lx][ly] = letter_element;
13669 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
13670 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
13671 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13672 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13674 DrawLevelText(0, 0, 0, TEXT_END);
13676 level.changed = TRUE;
13680 case TEXT_BACKSPACE:
13683 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
13684 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
13685 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
13690 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13691 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13693 DrawLevelText(0, 0, 0, TEXT_END);
13697 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13698 DrawEditorElement(sx, sy, Tile[lx][ly]);
13703 case TEXT_QUERY_TYPING:
13713 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
13714 int element, boolean change_level)
13716 int lx = sx + level_xpos;
13717 int ly = sy + level_ypos;
13720 DrawEditorElement(sx, sy, Tile[lx][ly]);
13722 DrawAreaBorder(sx, sy, sx, sy);
13725 static void CheckLevelBorderElement(boolean redraw_playfield)
13727 int last_border_element = BorderElement;
13729 SetBorderElement();
13731 if (redraw_playfield && BorderElement != last_border_element)
13732 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13735 static void CopyLevelToUndoBuffer(int mode)
13737 static boolean accumulated_undo = FALSE;
13738 boolean new_undo_buffer_position = TRUE;
13741 if (undo_buffer_steps == 0)
13742 accumulated_undo = FALSE;
13746 case UNDO_IMMEDIATE:
13747 accumulated_undo = FALSE;
13750 case UNDO_ACCUMULATE:
13751 if (accumulated_undo)
13752 new_undo_buffer_position = FALSE;
13753 accumulated_undo = TRUE;
13760 if (new_undo_buffer_position)
13762 // advance position in undo buffer ring
13763 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13765 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
13766 undo_buffer_steps++;
13769 // always reset redo buffer when storing level change into undo buffer
13770 redo_buffer_steps = 0;
13772 for (x = 0; x < lev_fieldx; x++)
13773 for (y = 0; y < lev_fieldy; y++)
13774 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
13776 // check if drawing operation forces change of border style
13777 CheckLevelBorderElement(TRUE);
13779 level.changed = TRUE;
13782 static void RandomPlacement(int new_element)
13784 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13785 int num_free_positions = 0;
13786 int num_percentage, num_elements;
13789 ResetIntelliDraw();
13791 // determine number of free positions for randomly placing the new element
13792 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
13794 free_position[x][y] =
13795 (random_placement_background_restricted ?
13796 Tile[x][y] == random_placement_background_element :
13797 Tile[x][y] != new_element);
13799 if (free_position[x][y])
13800 num_free_positions++;
13803 // determine number of new elements to place there
13804 num_percentage = num_free_positions * random_placement_value / 100;
13805 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
13806 num_percentage : random_placement_value);
13808 // if less free positions than elements to place, fill all these positions
13809 if (num_free_positions < num_elements)
13811 for (x = 0; x < lev_fieldx; x++)
13812 for (y = 0; y < lev_fieldy; y++)
13813 if (free_position[x][y])
13814 SetElement(x, y, new_element);
13818 while (num_elements > 0)
13820 x = GetSimpleRandom(lev_fieldx);
13821 y = GetSimpleRandom(lev_fieldy);
13823 // don't place element at the same position twice
13824 if (free_position[x][y])
13826 free_position[x][y] = FALSE;
13827 SetElement(x, y, new_element);
13833 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13834 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13837 static void WrapLevel(int dx, int dy)
13839 int wrap_dx = lev_fieldx - dx;
13840 int wrap_dy = lev_fieldy - dy;
13843 for (x = 0; x < lev_fieldx; x++)
13844 for (y = 0; y < lev_fieldy; y++)
13845 TileBackup[x][y] = Tile[x][y];
13847 for (x = 0; x < lev_fieldx; x++)
13848 for (y = 0; y < lev_fieldy; y++)
13850 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
13852 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13853 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
13856 static void DrawAreaElementHighlight(boolean highlighted,
13857 boolean highlighted_similar)
13859 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13866 for (x = 0; x < ed_fieldx; x++)
13868 for (y = 0; y < ed_fieldy; y++)
13870 boolean highlight = FALSE;
13871 int lx = x + level_xpos;
13872 int ly = y + level_ypos;
13874 if (!IN_LEV_FIELD(lx, ly))
13877 // check if element is the same
13878 if (Tile[lx][ly] == new_element1)
13881 // check if element is similar
13882 if (highlighted_similar &&
13883 strEqual(element_info[Tile[lx][ly]].class_name,
13884 element_info[new_element1].class_name))
13887 // check if element is matching MM style wall
13888 if (IS_MM_WALL(Tile[lx][ly]) &&
13889 map_mm_wall_element(Tile[lx][ly]) == new_element1)
13895 if (IS_MM_WALL(Tile[lx][ly]) && !highlighted_similar)
13899 for (i = 0; i < 4; i++)
13901 if (!(MM_WALL_BITS(Tile[lx][ly]) & (1 << i)))
13904 int xx = x * 2 + (i % 2);
13905 int yy = y * 2 + (i / 2);
13906 int sx = SX + xx * ed_tilesize / 2;
13907 int sy = SY + yy * ed_tilesize / 2;
13910 int to_sx = sx + ed_tilesize / 2 - 1;
13911 int to_sy = sy + ed_tilesize / 2 - 1;
13913 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13914 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13915 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13916 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13921 int sx = SX + x * ed_tilesize;
13922 int sy = SY + y * ed_tilesize;
13925 int to_sx = sx + ed_tilesize - 1;
13926 int to_sy = sy + ed_tilesize - 1;
13928 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13929 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13930 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13931 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13937 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
13939 char *template_filename_old = getLocalLevelTemplateFilename();
13940 char *template_filename_new =
13941 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
13943 if (copyFile(template_filename_old, template_filename_new) != 0)
13944 Request("Cannot copy level template!", REQ_CONFIRM);
13946 free(template_filename_new);
13949 static void HandleDrawingAreas(struct GadgetInfo *gi)
13951 static boolean started_inside_drawing_area = FALSE;
13952 static int last_sx = -1;
13953 static int last_sy = -1;
13954 static int last_sx2 = -1;
13955 static int last_sy2 = -1;
13956 int id = gi->custom_id;
13957 int type_id = gi->custom_type_id;
13958 boolean button_press_event;
13959 boolean button_release_event;
13960 boolean inside_drawing_area = !gi->event.off_borders;
13961 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
13962 int actual_drawing_function;
13963 int button = gi->event.button;
13964 int new_element = BUTTON_ELEMENT(button);
13965 int sx = gi->event.x, sy = gi->event.y;
13966 int min_sx = 0, min_sy = 0;
13967 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
13968 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
13969 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
13970 int sx2 = gi->event.mx / mini_item_xsize;
13971 int sy2 = gi->event.my / mini_item_ysize;
13974 int lx = 0, ly = 0;
13977 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
13978 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
13980 // make sure to stay inside drawing area boundaries
13981 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
13982 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
13986 int min_lx = 0, min_ly = 0;
13987 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
13989 // get positions inside level field
13990 lx = sx + level_xpos;
13991 ly = sy + level_ypos;
13993 if (!IN_LEV_FIELD(lx, ly))
13994 inside_drawing_area = FALSE;
13996 // make sure to stay inside level field boundaries
13997 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
13998 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14000 // correct drawing area positions accordingly
14001 sx = lx - level_xpos;
14002 sy = ly - level_ypos;
14005 // also correct MM wall-sized (double) drawing area positions accordingly
14006 if (sx2 / 2 < sx || sx2 / 2 > sx)
14008 dx = (sx2 / 2 < sx ? 0 : 1);
14011 if (sy2 / 2 < sy || sy2 / 2 > sy)
14013 dy = (sy2 / 2 < sy ? 0 : 1);
14017 if (!button_press_event && !button_release_event)
14019 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
14020 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
14021 isHiresTileElement(old_element) &&
14022 isHiresDrawElement(new_element));
14024 // prevent handling events for every pixel position when moving mouse
14025 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
14026 (sx2 == last_sx2 && sy2 == last_sy2))
14035 if (button_press_event)
14036 started_inside_drawing_area = inside_drawing_area;
14038 if (!started_inside_drawing_area)
14041 if (!IS_VALID_BUTTON(button))
14044 // handle info callback for each invocation of action callback
14045 gi->callback_info(gi);
14047 // automatically switch to 'single item' drawing mode, if needed
14048 actual_drawing_function =
14049 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
14050 drawing_function : GADGET_ID_SINGLE_ITEMS);
14052 // clicking into drawing area with pressed Control key picks element
14053 if (GetKeyModState() & KMOD_Control)
14055 last_drawing_function = drawing_function;
14056 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14059 if (GetKeyModState() & KMOD_Shift)
14061 if (button_press_event || button_release_event)
14062 ResetIntelliDraw();
14065 SetDrawModeHiRes(-1); // reset to normal draw mode
14067 switch (actual_drawing_function)
14069 case GADGET_ID_SINGLE_ITEMS:
14072 if (button_release_event)
14074 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14076 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
14077 !inside_drawing_area)
14078 DeleteBrushFromCursor();
14083 if (draw_with_brush)
14085 CopyBrushToLevel(sx, sy, button);
14089 SetDrawModeHiRes(new_element);
14091 if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
14093 // remove player at old position
14094 for (y = 0; y < lev_fieldy; y++)
14096 for (x = 0; x < lev_fieldx; x++)
14098 int old_element = Tile[x][y];
14100 if (IS_PLAYER_ELEMENT(old_element) &&
14101 IS_PLAYER_ELEMENT(new_element))
14103 int replaced_with_element =
14104 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
14105 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
14107 old_element == EL_SOKOBAN_FIELD_PLAYER &&
14108 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
14110 new_element == EL_SOKOBAN_FIELD_PLAYER &&
14111 old_element == EL_PLAYER_1 ? EL_EMPTY :
14113 new_element >= EL_PLAYER_1 &&
14114 new_element <= EL_PLAYER_4 &&
14115 new_element == old_element ? EL_EMPTY :
14119 SetElement(x, y, replaced_with_element);
14121 else if (IS_MM_MCDUFFIN(old_element) &&
14122 IS_MM_MCDUFFIN(new_element))
14124 // remove McDuffin at old position
14125 SetElement(x, y, EL_EMPTY);
14131 SetElementButton(lx, ly, dx, dy, new_element, button);
14134 else if (!button_release_event)
14136 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14138 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
14139 DrawMiniGraphicExt(drawto,
14140 gi->x + sx * MINI_TILEX,
14141 gi->y + sy * MINI_TILEY,
14142 el2edimg(new_element));
14144 DrawFixedGraphicExt(drawto,
14145 gi->x + sx * TILEX,
14146 gi->y + sy * TILEY,
14147 el2edimg(new_element), 0);
14149 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14150 new_element = GFX_ELEMENT(new_element);
14152 drawingarea_info[type_id].value[pos] = new_element;
14154 CopyElementPropertiesToGame(properties_element);
14156 if (id == GADGET_ID_CUSTOM_GRAPHIC)
14158 UpdateCustomElementGraphicGadgets();
14160 FrameCounter = 0; // restart animation frame counter
14165 case GADGET_ID_CONNECTED_ITEMS:
14167 static int last_sx = -1;
14168 static int last_sy = -1;
14170 if (button_release_event)
14171 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14173 SetDrawModeHiRes(new_element);
14175 if (getDrawModeHiRes())
14181 if (!button_press_event)
14182 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
14189 case GADGET_ID_LINE:
14190 case GADGET_ID_ARC:
14191 case GADGET_ID_RECTANGLE:
14192 case GADGET_ID_FILLED_BOX:
14193 SetDrawModeHiRes(new_element);
14195 if (getDrawModeHiRes())
14201 case GADGET_ID_GRAB_BRUSH:
14202 case GADGET_ID_TEXT:
14204 static int last_sx = -1;
14205 static int last_sy = -1;
14206 static int start_sx = -1;
14207 static int start_sy = -1;
14208 void (*draw_func)(int, int, int, int, int, boolean);
14210 if (drawing_function == GADGET_ID_LINE)
14211 draw_func = DrawLine;
14212 else if (drawing_function == GADGET_ID_ARC)
14213 draw_func = DrawArc;
14214 else if (drawing_function == GADGET_ID_RECTANGLE)
14215 draw_func = DrawBox;
14216 else if (drawing_function == GADGET_ID_FILLED_BOX)
14217 draw_func = DrawFilledBox;
14218 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
14219 draw_func = SelectArea;
14220 else // (drawing_function == GADGET_ID_TEXT)
14221 draw_func = SetTextCursor;
14223 if (button_press_event)
14225 draw_func(sx, sy, sx, sy, new_element, FALSE);
14226 start_sx = last_sx = sx;
14227 start_sy = last_sy = sy;
14229 if (drawing_function == GADGET_ID_TEXT)
14230 DrawLevelText(0, 0, 0, TEXT_END);
14232 else if (button_release_event)
14234 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
14235 if (drawing_function == GADGET_ID_GRAB_BRUSH)
14237 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
14238 CopyBrushToCursor(sx, sy);
14239 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14241 draw_with_brush = TRUE;
14243 else if (drawing_function == GADGET_ID_TEXT)
14244 DrawLevelText(sx, sy, 0, TEXT_INIT);
14246 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14248 else if (last_sx != sx || last_sy != sy)
14250 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
14251 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
14252 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
14253 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
14260 case GADGET_ID_FLOOD_FILL:
14261 if (button_press_event && Tile[lx][ly] != new_element)
14263 if (IS_MM_WALL_EDITOR(new_element))
14264 FloodFillWall_MM(sx2, sy2, new_element);
14266 FloodFill(lx, ly, new_element);
14268 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14269 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
14273 case GADGET_ID_PICK_ELEMENT:
14274 if (button_release_event)
14275 ClickOnGadget(level_editor_gadget[last_drawing_function],
14277 else if (draw_level)
14278 PickDrawingElement(button, Tile[lx][ly]);
14281 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14283 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
14290 // do not mark level as modified for certain non-level-changing gadgets
14291 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
14292 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
14293 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
14294 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14297 level.changed = TRUE;
14300 static void HandleCounterButtons(struct GadgetInfo *gi)
14302 int gadget_id = gi->custom_id;
14303 int counter_id = gi->custom_type_id;
14304 int button = gi->event.button;
14305 int *counter_value = counterbutton_info[counter_id].value;
14306 int step = BUTTON_STEPSIZE(button) *
14307 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
14309 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14311 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
14312 boolean released = (gi->event.type == GD_EVENT_RELEASED);
14313 boolean level_changed = LevelChanged();
14315 if ((level_changed && pressed) || (!level_changed && released))
14318 if (level_changed && !Request("Level has changed! Discard changes?",
14321 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14322 ModifyEditorCounterValue(counter_id, *counter_value);
14328 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14329 *counter_value = gi->textinput.number_value;
14331 ModifyEditorCounterValue(counter_id, *counter_value + step);
14333 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14335 int last_game_engine_type = level.game_engine_type;
14337 LoadLevel(level_nr);
14338 LoadScore(level_nr);
14340 SaveLevelSetup_SeriesInfo();
14345 DrawEditModeWindow();
14347 if (level.game_engine_type != last_game_engine_type)
14349 // update element selection list
14350 ReinitializeElementList();
14351 ModifyEditorElementList();
14357 switch (counter_id)
14359 case ED_COUNTER_ID_YAMYAM_CONTENT:
14360 DrawYamYamContentAreas();
14363 case ED_COUNTER_ID_BALL_CONTENT:
14364 DrawMagicBallContentAreas();
14367 case ED_COUNTER_ID_ANDROID_CONTENT:
14368 DrawAndroidElementArea();
14371 case ED_COUNTER_ID_GROUP_CONTENT:
14372 DrawGroupElementArea();
14373 CopyGroupElementPropertiesToGame(properties_element);
14376 case ED_COUNTER_ID_INVENTORY_SIZE:
14377 DrawPlayerInitialInventoryArea(properties_element);
14380 case ED_COUNTER_ID_MM_BALL_CONTENT:
14381 DrawMMBallContentArea();
14384 case ED_COUNTER_ID_ENVELOPE_XSIZE:
14385 case ED_COUNTER_ID_ENVELOPE_YSIZE:
14386 DrawEnvelopeTextArea(-1);
14389 case ED_COUNTER_ID_LEVEL_XSIZE:
14390 case ED_COUNTER_ID_LEVEL_YSIZE:
14391 lev_fieldx = level.fieldx;
14392 lev_fieldy = level.fieldy;
14394 // check if resizing of level results in change of border border
14395 SetBorderElement();
14403 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
14404 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
14405 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
14406 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
14407 CopyElementPropertiesToGame(properties_element);
14409 // do not mark level as modified for certain non-level-changing gadgets
14410 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
14411 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
14412 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
14413 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
14416 level.changed = TRUE;
14419 static void HandleTextInputGadgets(struct GadgetInfo *gi)
14421 int type_id = gi->custom_type_id;
14423 strcpy(textinput_info[type_id].value, gi->textinput.value);
14425 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
14427 CopyElementPropertiesToGame(properties_element);
14429 ModifyEditorElementList(); // update changed button info text
14432 // do not mark level as modified for certain non-level-changing gadgets
14433 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
14434 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
14437 level.changed = TRUE;
14440 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
14442 int type_id = gi->custom_type_id;
14444 strncpy(textarea_info[type_id].value, gi->textarea.value,
14445 MAX_ENVELOPE_TEXT_LEN);
14446 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
14448 level.changed = TRUE;
14451 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
14453 int type_id = gi->custom_type_id;
14454 int value_old = *selectbox_info[type_id].value;
14455 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
14457 *selectbox_info[type_id].value = value_new;
14459 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
14461 DrawLevelConfigWindow();
14463 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14465 element_info[properties_element].current_change_page = gi->selectbox.index;
14467 DrawPropertiesWindow();
14469 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
14470 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
14471 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
14472 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
14473 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
14475 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
14477 // when changing action type, also check action mode and action arg
14478 if (value_old != value_new)
14479 setSelectboxSpecialActionVariablesIfNeeded();
14481 DrawPropertiesChange();
14484 CopyElementPropertiesToGame(properties_element);
14486 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
14488 // show or hide "engine" tabulator depending on game engine type
14489 DrawLevelConfigWindow();
14491 // update element selection list depending on game engine type
14492 ReinitializeElementList();
14493 ModifyEditorElementList();
14496 // do not mark level as modified for certain non-level-changing gadgets
14497 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
14498 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14501 level.changed = TRUE;
14504 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
14506 int type_id = gi->custom_type_id;
14509 if (type_id >= ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST &&
14510 type_id <= ED_TAB_BUTTON_ID_LEVELCONFIG_LAST)
14512 edit_mode_levelconfig = gi->custom_type_id;
14514 DrawLevelConfigWindow();
14516 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
14517 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
14519 edit_mode_properties = gi->custom_type_id;
14521 DrawPropertiesWindow();
14523 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
14524 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
14526 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
14528 // backup original "level.field" (needed to track playfield changes)
14529 CopyPlayfield(level.field, TileBackup);
14531 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
14532 CopyPlayfield(Tile, level.field);
14534 if (new_template ||
14535 Request("Save this template and kill the old?", REQ_ASK))
14536 SaveLevelTemplate();
14539 Request("Template saved!", REQ_CONFIRM);
14541 // restore original "level.field" (needed to track playfield changes)
14542 CopyPlayfield(TileBackup, level.field);
14544 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
14546 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
14548 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
14549 leveldir_current->readonly)
14551 Request("This level set is read-only!", REQ_CONFIRM);
14556 if (strEqual(levelset_name, ""))
14558 Request("Please enter level set title!", REQ_CONFIRM);
14563 if (strEqual(levelset_author, ""))
14565 Request("Please enter level set author!", REQ_CONFIRM);
14570 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
14572 if (UpdateUserLevelSet(levelset_subdir,
14575 levelset_num_levels))
14577 Request("Level set updated!", REQ_CONFIRM);
14581 Request("Updating level set failed!", REQ_CONFIRM);
14584 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
14586 if (level.changed && !Request("Level has changed! Discard changes?",
14590 if (CreateUserLevelSet(levelset_subdir,
14593 levelset_num_levels,
14594 levelset_use_levelset_artwork))
14596 if (levelset_copy_level_template)
14597 CopyLevelTemplateToUserLevelSet(levelset_subdir);
14599 Request("New level set created!", REQ_CONFIRM);
14601 AddUserLevelSetToLevelInfo(levelset_subdir);
14602 ChangeEditorToLevelSet(levelset_subdir);
14606 Request("Creating new level set failed!", REQ_CONFIRM);
14610 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
14611 custom_element.num_change_pages < MAX_CHANGE_PAGES)
14613 struct ElementInfo *ei = &element_info[properties_element];
14615 // when modifying custom element, ask for copying level template
14616 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14619 setElementChangePages(ei, ei->num_change_pages + 1);
14621 // set new change page to be new current change page
14622 ei->current_change_page = ei->num_change_pages - 1;
14623 ei->change = &ei->change_page[ei->current_change_page];
14625 setElementChangeInfoToDefaults(ei->change);
14627 DrawPropertiesWindow();
14629 level.changed = TRUE;
14631 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
14632 custom_element.num_change_pages > MIN_CHANGE_PAGES)
14634 struct ElementInfo *ei = &element_info[properties_element];
14636 // when modifying custom element, ask for copying level template
14637 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14640 // copy all change pages after change page to be deleted
14641 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
14642 ei->change_page[i] = ei->change_page[i + 1];
14644 setElementChangePages(ei, ei->num_change_pages - 1);
14646 DrawPropertiesWindow();
14648 level.changed = TRUE;
14652 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
14654 int type_id = gi->custom_type_id;
14656 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
14657 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
14659 struct ElementInfo *ei = &element_info[properties_element];
14660 int step = BUTTON_STEPSIZE(gi->event.button);
14662 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
14663 ei->current_change_page += step;
14665 if (ei->current_change_page < 0)
14666 ei->current_change_page = 0;
14667 else if (ei->current_change_page >= ei->num_change_pages)
14668 ei->current_change_page = ei->num_change_pages - 1;
14670 DrawPropertiesWindow();
14672 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
14673 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14675 struct ElementInfo *ei = &element_info[properties_element];
14676 int current_change_page = ei->current_change_page;
14678 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
14680 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
14681 ei->change_page[current_change_page];
14683 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14685 // when modifying custom element, ask for copying level template
14686 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14689 ei->change_page[current_change_page] =
14690 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
14692 level.changed = TRUE;
14695 DrawPropertiesWindow();
14699 static void HandleRadiobuttons(struct GadgetInfo *gi)
14701 int type_id = gi->custom_type_id;
14703 *radiobutton_info[type_id].value =
14704 radiobutton_info[type_id].checked_value;
14706 // do not mark level as modified for certain non-level-changing gadgets
14707 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
14708 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
14711 level.changed = TRUE;
14714 static void HandleCheckbuttons(struct GadgetInfo *gi)
14716 int type_id = gi->custom_type_id;
14718 *checkbutton_info[type_id].value ^= TRUE;
14720 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
14721 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
14722 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
14723 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
14724 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
14725 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
14726 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
14727 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
14729 CopyElementPropertiesToGame(properties_element);
14732 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
14734 UpdateCustomElementGraphicGadgets();
14736 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
14737 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
14739 boolean template_related_changes_found = FALSE;
14742 // check if any custom, group or empty elements have been changed
14743 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
14744 if ((IS_CUSTOM_ELEMENT(i) ||
14745 IS_GROUP_ELEMENT(i) ||
14746 IS_EMPTY_ELEMENT(i)) &&
14747 element_info[i].modified_settings)
14748 template_related_changes_found = TRUE;
14750 if (level.use_custom_template &&
14751 !fileExists(getGlobalLevelTemplateFilename()))
14753 Request("No level template found!", REQ_CONFIRM);
14755 level.use_custom_template = FALSE;
14757 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14762 if (level.use_custom_template &&
14763 template_related_changes_found &&
14764 !Request("Discard changes and use level template?", REQ_ASK))
14766 level.use_custom_template = FALSE;
14768 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14773 if (!level.use_custom_template &&
14774 Request("Copy settings from level template?", REQ_ASK))
14779 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
14781 DrawEditModeWindow();
14783 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
14785 if (setup.editor.use_template_for_new_levels &&
14786 !fileExists(getGlobalLevelTemplateFilename()))
14788 Request("No level template found!", REQ_CONFIRM);
14793 if (setup.editor.use_template_for_new_levels &&
14795 !Request("Discard level and load template?", REQ_ASK))
14800 if (!setup.editor.use_template_for_new_levels &&
14802 !Request("Discard level and use empty level?", REQ_ASK))
14807 LoadLevel(level_nr);
14808 LoadScore(level_nr);
14813 DrawEditModeWindow();
14815 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
14817 SetAutomaticNumberOfGemsNeeded();
14820 // do not mark level as modified for certain non-level-changing gadgets
14821 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
14822 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
14823 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
14824 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
14825 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
14826 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
14829 level.changed = TRUE;
14832 static void HandleControlButtons(struct GadgetInfo *gi)
14834 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
14835 static int last_edit_mode = ED_MODE_DRAWING;
14836 static int last_custom_copy_mode = -1;
14837 static int last_button = 0;
14838 int id = gi->custom_id;
14839 int button = gi->event.button;
14840 int step = BUTTON_STEPSIZE(button);
14841 int new_element = BUTTON_ELEMENT(button);
14842 int last_properties_element = properties_element;
14845 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
14846 DrawLevelText(0, 0, 0, TEXT_END);
14848 if (id < ED_NUM_CTRL1_BUTTONS &&
14849 id != GADGET_ID_SINGLE_ITEMS &&
14850 id != GADGET_ID_PICK_ELEMENT &&
14851 edit_mode != ED_MODE_DRAWING &&
14852 drawing_function != GADGET_ID_PICK_ELEMENT &&
14853 !(GetKeyModState() & KMOD_Control))
14854 ChangeEditModeWindow(ED_MODE_DRAWING);
14856 // element copy mode active, but no element button pressed => deactivate
14857 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
14858 last_custom_copy_mode = -1;
14860 // when showing palette on element buttons, change element of button used
14861 if (editor.palette.show_on_element_buttons &&
14862 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
14864 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
14866 id = GADGET_ID_PALETTE;
14871 case GADGET_ID_SCROLL_LEFT:
14872 if (level_xpos >= 0)
14874 if (lev_fieldx < ed_fieldx - 2)
14877 level_xpos -= step;
14878 if (level_xpos < -1)
14881 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
14883 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14885 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14886 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14890 case GADGET_ID_SCROLL_RIGHT:
14891 if (level_xpos <= lev_fieldx - ed_fieldx)
14893 if (lev_fieldx < ed_fieldx - 2)
14896 level_xpos += step;
14897 if (level_xpos > lev_fieldx - ed_fieldx + 1)
14898 level_xpos = lev_fieldx - ed_fieldx + 1;
14900 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
14902 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14904 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14905 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14909 case GADGET_ID_SCROLL_UP:
14910 if (level_ypos >= 0)
14912 if (lev_fieldy < ed_fieldy - 2)
14915 level_ypos -= step;
14916 if (level_ypos < -1)
14919 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
14921 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14923 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
14924 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
14928 case GADGET_ID_SCROLL_DOWN:
14929 if (level_ypos <= lev_fieldy - ed_fieldy)
14931 if (lev_fieldy < ed_fieldy - 2)
14934 level_ypos += step;
14935 if (level_ypos > lev_fieldy - ed_fieldy + 1)
14936 level_ypos = lev_fieldy - ed_fieldy + 1;
14938 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
14940 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14942 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
14943 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
14947 case GADGET_ID_SCROLL_HORIZONTAL:
14948 level_xpos = gi->event.item_position - 1;
14950 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14955 case GADGET_ID_SCROLL_VERTICAL:
14956 level_ypos = gi->event.item_position - 1;
14958 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14963 case GADGET_ID_SCROLL_LIST_UP:
14964 case GADGET_ID_SCROLL_LIST_DOWN:
14965 case GADGET_ID_SCROLL_LIST_VERTICAL:
14966 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
14967 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
14970 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
14971 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
14973 if (element_shift < 0)
14975 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14976 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14978 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14979 GDI_SCROLLBAR_ITEM_POSITION,
14980 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14983 ModifyEditorElementList();
14987 case GADGET_ID_PROPERTIES:
14988 // always switch off element properties when they are already displayed
14989 last_properties_element = new_element;
14990 case GADGET_ID_ELEMENT_LEFT:
14991 case GADGET_ID_ELEMENT_MIDDLE:
14992 case GADGET_ID_ELEMENT_RIGHT:
14993 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
14994 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
14995 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
14998 if (edit_mode != ED_MODE_PROPERTIES)
15000 last_edit_mode = edit_mode;
15002 ChangeEditModeWindow(ED_MODE_PROPERTIES);
15004 last_level_drawing_function = drawing_function;
15005 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
15008 else if (properties_element != last_properties_element)
15010 DrawEditModeWindow();
15014 ChangeEditModeWindow(ED_MODE_DRAWING);
15016 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
15021 case GADGET_ID_PALETTE:
15022 if (edit_mode != ED_MODE_PALETTE)
15024 last_edit_mode = edit_mode;
15026 ChangeEditModeWindow(ED_MODE_PALETTE);
15030 ChangeEditModeWindow(last_edit_mode);
15034 case GADGET_ID_WRAP_LEFT:
15035 WrapLevel(-step, 0);
15038 case GADGET_ID_WRAP_RIGHT:
15039 WrapLevel(step, 0);
15042 case GADGET_ID_WRAP_UP:
15043 WrapLevel(0, -step);
15046 case GADGET_ID_WRAP_DOWN:
15047 WrapLevel(0, step);
15050 case GADGET_ID_SINGLE_ITEMS:
15051 case GADGET_ID_CONNECTED_ITEMS:
15052 case GADGET_ID_LINE:
15053 case GADGET_ID_ARC:
15054 case GADGET_ID_TEXT:
15055 case GADGET_ID_RECTANGLE:
15056 case GADGET_ID_FILLED_BOX:
15057 case GADGET_ID_FLOOD_FILL:
15058 case GADGET_ID_GRAB_BRUSH:
15059 case GADGET_ID_PICK_ELEMENT:
15060 if (drawing_function != GADGET_ID_PICK_ELEMENT)
15061 last_drawing_function = drawing_function;
15062 drawing_function = id;
15063 draw_with_brush = FALSE;
15066 case GADGET_ID_RANDOM_PLACEMENT:
15067 RandomPlacement(new_element);
15070 case GADGET_ID_ZOOM:
15071 // zoom level editor tile size in or out (or reset to default size)
15072 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
15073 button == 2 ? ed_tilesize_default :
15074 button == 3 ? ed_tilesize / 2 : ed_tilesize);
15076 // when using touch device, cycle through all zoom tilesizes
15077 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
15078 ed_tilesize = MICRO_TILESIZE;
15080 // limit zoom level by upper and lower bound
15081 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
15083 InitZoomLevelSettings(ed_tilesize);
15085 if (edit_mode == ED_MODE_DRAWING)
15087 DrawDrawingWindow();
15089 // redraw zoom gadget info text
15090 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15093 // save current editor zoom tilesize
15094 SaveSetup_AutoSetup();
15098 case GADGET_ID_CUSTOM_COPY_FROM:
15099 case GADGET_ID_CUSTOM_COPY_TO:
15100 case GADGET_ID_CUSTOM_EXCHANGE:
15101 last_custom_copy_mode = id;
15102 last_drawing_function = drawing_function;
15105 case GADGET_ID_CUSTOM_COPY:
15106 CopyCustomElement(properties_element, -1, id);
15109 case GADGET_ID_CUSTOM_PASTE:
15110 CopyCustomElement(-1, properties_element, id);
15113 case GADGET_ID_UNDO:
15114 if (button < 0) // keep button value (even if modifier keys are pressed)
15116 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
15119 if (button == 1 && undo_buffer_steps == 0)
15121 Request("Undo buffer empty!", REQ_CONFIRM);
15125 else if (button == 2)
15129 else if (button == 3 && redo_buffer_steps == 0)
15131 Request("Redo buffer empty!", REQ_CONFIRM);
15136 if (edit_mode != ED_MODE_DRAWING)
15137 ChangeEditModeWindow(ED_MODE_DRAWING);
15143 undo_buffer_position =
15144 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
15146 undo_buffer_steps--;
15147 redo_buffer_steps++;
15153 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
15155 undo_buffer_steps++;
15156 redo_buffer_steps--;
15159 for (x = 0; x < lev_fieldx; x++)
15160 for (y = 0; y < lev_fieldy; y++)
15161 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
15163 // check if undo operation forces change of border style
15164 CheckLevelBorderElement(FALSE);
15166 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15170 case GADGET_ID_CONF:
15171 if (edit_mode != ED_MODE_LEVELCONFIG)
15173 last_edit_mode = edit_mode;
15175 ChangeEditModeWindow(ED_MODE_LEVELCONFIG);
15179 ChangeEditModeWindow(ED_MODE_DRAWING);
15183 case GADGET_ID_CLEAR:
15184 if (edit_mode != ED_MODE_DRAWING)
15185 ChangeEditModeWindow(ED_MODE_DRAWING);
15187 for (x = 0; x < MAX_LEV_FIELDX; x++)
15188 for (y = 0; y < MAX_LEV_FIELDY; y++)
15189 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
15191 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
15193 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
15196 case GADGET_ID_SAVE:
15198 // saving read-only levels into personal level set modifies global vars
15199 // "leveldir_current" and "level_nr"; restore them after saving level
15200 LevelDirTree *leveldir_former = leveldir_current;
15201 int level_nr_former = level_nr;
15202 char *level_filename;
15205 if (leveldir_current->readonly &&
15206 !PrepareSavingIntoPersonalLevelSet())
15209 level_filename = getDefaultLevelFilename(level_nr);
15210 new_level = !fileExists(level_filename);
15213 Request("Save this level and kill the old?", REQ_ASK))
15215 if (leveldir_former->readonly)
15216 ModifyLevelConfigForSavingIntoPersonalLevelSet(leveldir_former->name);
15218 SetAutomaticNumberOfGemsNeeded();
15220 CopyPlayfield(Tile, level.field);
15221 SaveLevel(level_nr);
15223 level.changed = FALSE;
15227 char level_saved_msg[64];
15229 if (leveldir_former->readonly)
15230 sprintf(level_saved_msg,
15231 "Level saved as level %d into personal level set!",
15234 strcpy(level_saved_msg, "Level saved!");
15236 Request(level_saved_msg, REQ_CONFIRM);
15240 // "cd" back to copied-from levelset (in case of saved read-only level)
15241 leveldir_current = leveldir_former;
15242 level_nr = level_nr_former;
15247 case GADGET_ID_TEST:
15248 if (LevelChanged())
15249 level.game_version = GAME_VERSION_ACTUAL;
15251 CopyPlayfield(level.field, TileBackup);
15252 CopyPlayfield(Tile, level.field);
15254 CopyNativeLevel_RND_to_Native(&level);
15256 UnmapLevelEditorGadgets();
15257 UndrawSpecialEditorDoor();
15259 CloseDoor(DOOR_CLOSE_ALL);
15261 // needed before playing if editor playfield area has different size
15262 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
15264 // redraw_mask = REDRAW_ALL;
15266 level_editor_test_game = TRUE;
15268 StartGameActions(FALSE, setup.autorecord, level.random_seed);
15272 case GADGET_ID_EXIT:
15273 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
15277 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
15278 id <= GADGET_ID_ELEMENTLIST_LAST)
15280 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
15282 new_element = editor_elements[element_position + element_shift];
15284 if (IS_EDITOR_CASCADE(new_element))
15288 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
15290 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
15291 boolean *cascade_value = editor_elements_info[i].setup_cascade_value;
15293 if (*cascade_element == new_element)
15295 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
15296 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
15298 // update element selection list
15299 ReinitializeElementList();
15300 ModifyEditorElementList();
15302 // update cascading gadget info text
15303 PrintEditorGadgetInfoText(level_editor_gadget[id]);
15305 // save current editor cascading state
15306 SaveSetup_EditorCascade();
15315 if (last_custom_copy_mode != -1)
15317 if (CopyCustomElement(properties_element, new_element,
15318 last_custom_copy_mode))
15320 ClickOnGadget(level_editor_gadget[last_drawing_function],
15323 last_custom_copy_mode = -1;
15329 // change element of button used to show palette
15330 if (editor.palette.show_on_element_buttons)
15331 button = last_button;
15333 PickDrawingElement(button, new_element);
15335 if (!stick_element_properties_window &&
15336 drawing_function != GADGET_ID_PICK_ELEMENT &&
15337 !(GetKeyModState() & KMOD_Control))
15339 properties_element = new_element;
15340 if (edit_mode == ED_MODE_PROPERTIES)
15341 DrawPropertiesWindow();
15344 if (drawing_function == GADGET_ID_PICK_ELEMENT)
15345 ClickOnGadget(level_editor_gadget[last_drawing_function],
15348 if (!use_permanent_palette)
15349 ChangeEditModeWindow(last_edit_mode);
15352 else if (gi->event.type == GD_EVENT_PRESSED)
15353 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
15354 else if (gi->event.type == GD_EVENT_RELEASED)
15355 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
15356 else if (gi->event.type == GD_EVENT_MOVING)
15357 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
15359 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
15365 void HandleLevelEditorKeyInput(Key key)
15367 char letter = getCharFromKey(key);
15369 if (drawing_function == GADGET_ID_TEXT &&
15370 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
15373 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
15374 else if (key == KSYM_Delete || key == KSYM_BackSpace)
15375 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
15376 else if (key == KSYM_Return)
15377 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
15378 else if (key == KSYM_Escape)
15379 DrawLevelText(0, 0, 0, TEXT_END);
15384 int id = GADGET_ID_NONE;
15385 int new_element_shift = element_shift;
15386 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
15387 int button = MB_LEFTBUTTON;
15393 id = GADGET_ID_SCROLL_LEFT;
15396 id = GADGET_ID_SCROLL_RIGHT;
15399 id = GADGET_ID_SCROLL_UP;
15402 id = GADGET_ID_SCROLL_DOWN;
15406 case KSYM_Page_Down:
15407 step *= (key == KSYM_Page_Up ? -1 : +1);
15408 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15410 if (element_shift < 0)
15412 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15413 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15415 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15416 GDI_SCROLLBAR_ITEM_POSITION,
15417 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15419 ModifyEditorElementList();
15425 element_shift = (key == KSYM_Home ? 0 :
15426 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
15428 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15429 GDI_SCROLLBAR_ITEM_POSITION,
15430 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15432 ModifyEditorElementList();
15439 // this is needed to prevent interference with running "True X-Mouse"
15440 if (GetKeyModStateFromEvents() & KMOD_Control)
15443 // check for last or next editor cascade block in element list
15444 for (i = 0; i < num_editor_elements; i++)
15446 if ((key == KSYM_Insert && i == element_shift) ||
15447 (key == KSYM_Delete && new_element_shift > element_shift))
15450 // jump to next cascade block (or to start of element list)
15451 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
15452 new_element_shift = i;
15455 if (i < num_editor_elements)
15456 element_shift = new_element_shift;
15458 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15459 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15461 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15462 GDI_SCROLLBAR_ITEM_POSITION,
15463 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15465 ModifyEditorElementList();
15470 if (edit_mode == ED_MODE_DRAWING)
15471 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
15472 else if (edit_mode == ED_MODE_LEVELCONFIG)
15473 HandleControlButtons(level_editor_gadget[GADGET_ID_CONF]);
15474 else if (edit_mode == ED_MODE_PROPERTIES)
15475 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
15476 else if (edit_mode == ED_MODE_PALETTE)
15477 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
15478 else // should never happen
15479 ChangeEditModeWindow(ED_MODE_DRAWING);
15487 if (id != GADGET_ID_NONE)
15488 ClickOnGadget(level_editor_gadget[id], button);
15489 else if (letter == '1' || letter == '?')
15490 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
15491 else if (letter == '2')
15492 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
15493 else if (letter == '3')
15494 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
15495 else if (letter == '.')
15496 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
15497 else if (letter == 'U')
15498 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
15499 else if (letter == '-' || key == KSYM_KP_Subtract)
15500 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
15501 else if (letter == '0' || key == KSYM_KP_0)
15502 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
15503 else if (letter == '+' || key == KSYM_KP_Add ||
15504 letter == '=') // ("Shift-=" is "+" on US keyboards)
15505 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
15506 else if (key == KSYM_Return ||
15507 key == KSYM_space ||
15508 key == setup.shortcut.toggle_pause)
15509 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
15511 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
15512 if (letter && letter == controlbutton_info[i].shortcut)
15513 if (!anyTextGadgetActive())
15514 ClickOnGadget(level_editor_gadget[i], button);
15516 if (draw_with_brush)
15520 else if (letter == 'y')
15522 else if (letter == 'z')
15527 static void HandleLevelEditorIdle_Properties(void)
15529 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
15530 int x = editor.settings.element_graphic.x + element_border;
15531 int y = editor.settings.element_graphic.y + element_border;
15532 static DelayCounter action_delay = { 0 };
15535 action_delay.value = GameFrameDelay;
15537 if (!DelayReached(&action_delay))
15540 for (i = 0; i < ED_NUM_SELECTBOX; i++)
15542 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
15544 if (gi->mapped && gi->active && gi->selectbox.open)
15548 DrawEditorElementAnimation(SX + x, SY + y);
15550 redraw_mask |= REDRAW_FIELD;
15552 FrameCounter++; // increase animation frame counter
15555 static void HandleLevelEditorIdle_Drawing(void)
15557 static boolean last_highlighted = FALSE;
15558 static boolean last_highlighted_similar = FALSE;
15559 boolean highlighted = (GetKeyModState() & KMOD_Alt);
15560 boolean highlighted_similar = (GetKeyModState() & KMOD_Shift);
15562 if (highlighted != last_highlighted ||
15563 (highlighted && highlighted_similar != last_highlighted_similar))
15565 DrawAreaElementHighlight(highlighted, highlighted_similar);
15567 redraw_mask |= REDRAW_FIELD;
15570 last_highlighted = highlighted;
15571 last_highlighted_similar = highlighted_similar;
15574 void HandleLevelEditorIdle(void)
15576 if (edit_mode == ED_MODE_PROPERTIES)
15577 HandleLevelEditorIdle_Properties();
15578 else if (edit_mode == ED_MODE_DRAWING)
15579 HandleLevelEditorIdle_Drawing();
15582 static void ClearEditorGadgetInfoText(void)
15584 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
15587 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
15589 char infotext[MAX_OUTPUT_LINESIZE + 1];
15590 int max_infotext_len = getMaxInfoTextLength();
15592 if (gi == NULL || strlen(gi->info_text) == 0)
15595 strncpy(infotext, gi->info_text, max_infotext_len);
15596 infotext[max_infotext_len] = '\0';
15598 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
15600 int key = controlbutton_info[gi->custom_id].shortcut;
15604 char shortcut[MAX_OUTPUT_LINESIZE + 1];
15606 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
15607 sprintf(shortcut, " ('.' or '%c')", key);
15608 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
15609 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
15610 else if (gi->custom_id == GADGET_ID_TEST)
15611 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
15612 else if (gi->custom_id == GADGET_ID_UNDO)
15613 sprintf(shortcut, " ('%c/Shift-U')", key);
15614 else if (gi->custom_id == GADGET_ID_ZOOM)
15615 sprintf(shortcut, " ('%c', '0', '-')", key);
15617 sprintf(shortcut, " ('%s%c')",
15618 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
15620 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
15621 strcat(infotext, shortcut);
15625 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
15628 void HandleEditorGadgetInfoText(void *ptr)
15630 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
15632 if (game_status != GAME_MODE_EDITOR)
15635 ClearEditorGadgetInfoText();
15637 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
15640 // misuse this function to delete brush cursor, if needed
15641 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
15642 DeleteBrushFromCursor();
15644 PrintEditorGadgetInfoText(gi);
15647 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
15649 int id = gi->custom_id;
15650 int type_id = gi->custom_type_id;
15651 int sx = gi->event.x;
15652 int sy = gi->event.y;
15653 int lx = sx + level_xpos;
15654 int ly = sy + level_ypos;
15655 int min_sx = 0, min_sy = 0;
15656 int max_sx = gi->drawing.area_xsize - 1;
15657 int max_sy = gi->drawing.area_ysize - 1;
15658 int actual_drawing_function = drawing_function;
15659 int max_infotext_len = getMaxInfoTextLength();
15660 char infotext[MAX_OUTPUT_LINESIZE + 1];
15662 infotext[0] = '\0'; // start with empty info text
15664 // pressed Control key: simulate picking element
15665 if (GetKeyModState() & KMOD_Control)
15666 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
15668 ClearEditorGadgetInfoText();
15670 if (gi->event.type == GD_EVENT_INFO_LEAVING)
15673 // make sure to stay inside drawing area boundaries
15674 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
15675 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
15677 if (id == GADGET_ID_DRAWING_LEVEL)
15681 int min_lx = 0, min_ly = 0;
15682 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
15684 // get positions inside level field
15685 lx = sx + level_xpos;
15686 ly = sy + level_ypos;
15688 // make sure to stay inside level field boundaries
15689 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
15690 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
15692 // correct drawing area positions accordingly
15693 sx = lx - level_xpos;
15694 sy = ly - level_ypos;
15697 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15699 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
15701 static int start_lx = 0;
15702 static int start_ly = 0;
15705 if (gi->event.type == GD_EVENT_PRESSED)
15711 switch (actual_drawing_function)
15713 case GADGET_ID_SINGLE_ITEMS:
15714 text = "Drawing single items";
15716 case GADGET_ID_CONNECTED_ITEMS:
15717 text = "Drawing connected items";
15719 case GADGET_ID_LINE:
15720 text = "Drawing line";
15722 case GADGET_ID_ARC:
15723 text = "Drawing arc";
15725 case GADGET_ID_TEXT:
15726 text = "Setting text cursor";
15728 case GADGET_ID_RECTANGLE:
15729 text = "Drawing rectangle";
15731 case GADGET_ID_FILLED_BOX:
15732 text = "Drawing filled box";
15734 case GADGET_ID_FLOOD_FILL:
15735 text = "Flood fill";
15737 case GADGET_ID_GRAB_BRUSH:
15738 text = "Grabbing brush";
15740 case GADGET_ID_PICK_ELEMENT:
15741 text = "Picking element";
15745 text = "Drawing position";
15749 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15750 sprintf(infotext, "%s: %d, %d", text, lx, ly);
15752 sprintf(infotext, "%s: %d, %d", text,
15753 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
15755 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15756 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
15758 sprintf(infotext, "Level position: %d, %d", lx, ly);
15761 // misuse this function to draw brush cursor, if needed
15762 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
15764 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15765 CopyBrushToCursor(sx, sy);
15767 DeleteBrushFromCursor();
15770 if (!draw_with_brush)
15771 UpdateBrushPosition(sx, sy);
15773 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15775 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
15776 int element = drawingarea_info[type_id].value[pos];
15778 strncpy(infotext, getElementInfoText(element), max_infotext_len);
15782 if (id == GADGET_ID_CUSTOM_CONTENT)
15783 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
15784 else if (id == GADGET_ID_GROUP_CONTENT)
15785 sprintf(infotext, "group element position: %d", sx + 1);
15786 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
15787 id <= GADGET_ID_YAMYAM_CONTENT_7)
15788 sprintf(infotext, "content area %d position: %d, %d",
15789 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
15790 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
15791 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
15792 sprintf(infotext, "content area %d position: %d, %d",
15793 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
15794 else if (id == GADGET_ID_ANDROID_CONTENT)
15795 sprintf(infotext, "android element position: %d", sx + 1);
15796 else if (drawingarea_info[type_id].infotext != NULL)
15797 strcpy(infotext, drawingarea_info[type_id].infotext);
15800 infotext[max_infotext_len] = '\0';
15802 if (strlen(infotext) > 0)
15803 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
15806 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
15807 boolean quick_quit)
15809 if (!ask_if_level_has_changed ||
15811 Request("Level has changed! Exit without saving?",
15812 REQ_ASK | REQ_STAY_OPEN))
15814 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
15815 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
15817 // draw normal door
15818 UndrawSpecialEditorDoor();
15820 // use door animation if door 1 viewport is unchanged and contains toolbox
15821 if (useEditorDoorAnimation())
15822 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
15824 // close editor doors if viewport definition is the same as in main menu
15825 if (vp_door_1->x == DX &&
15826 vp_door_1->y == DY &&
15827 vp_door_1->width == DXSIZE &&
15828 vp_door_1->height == DYSIZE &&
15829 vp_door_2->x == VX &&
15830 vp_door_2->y == VY &&
15831 vp_door_2->width == VXSIZE &&
15832 vp_door_2->height == VYSIZE)
15833 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
15835 SetDoorState(DOOR_CLOSE_ALL);
15840 FadeSkipNextFadeIn();
15842 SetGameStatus(GAME_MODE_MAIN);
15848 if (!global.use_envelope_request)
15850 CloseDoor(DOOR_CLOSE_1);
15851 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);