1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
14 #include "libgame/libgame.h"
25 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
28 // ----------------------------------------------------------------------------
29 // screen and artwork graphic pixel position definitions
30 // ----------------------------------------------------------------------------
32 // values for the control window
33 #define ED_CTRL1_BUTTONS_HORIZ 4 // toolbox
34 #define ED_CTRL1_BUTTONS_VERT 4
35 #define ED_CTRL2_BUTTONS_HORIZ 3 // level
36 #define ED_CTRL2_BUTTONS_VERT 2
37 #define ED_CTRL3_BUTTONS_HORIZ 3 // CE and GE
38 #define ED_CTRL3_BUTTONS_VERT 1
39 #define ED_CTRL4_BUTTONS_HORIZ 2 // CE and GE
40 #define ED_CTRL4_BUTTONS_VERT 1
41 #define ED_CTRL5_BUTTONS_HORIZ 1 // properties
42 #define ED_CTRL5_BUTTONS_VERT 1
43 #define ED_CTRL6_BUTTONS_HORIZ 3 // properties
44 #define ED_CTRL6_BUTTONS_VERT 1
45 #define ED_CTRL7_BUTTONS_HORIZ 1 // palette
46 #define ED_CTRL7_BUTTONS_VERT 1
48 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
49 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
50 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
51 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
52 #define ED_NUM_CTRL5_BUTTONS (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT)
53 #define ED_NUM_CTRL6_BUTTONS (ED_CTRL6_BUTTONS_HORIZ * ED_CTRL6_BUTTONS_VERT)
54 #define ED_NUM_CTRL7_BUTTONS (ED_CTRL7_BUTTONS_HORIZ * ED_CTRL7_BUTTONS_VERT)
55 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
56 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
57 #define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS)
58 #define ED_NUM_CTRL1_5_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS)
59 #define ED_NUM_CTRL1_6_BUTTONS (ED_NUM_CTRL1_5_BUTTONS + ED_NUM_CTRL6_BUTTONS)
60 #define ED_NUM_CTRL1_7_BUTTONS (ED_NUM_CTRL1_6_BUTTONS + ED_NUM_CTRL7_BUTTONS)
61 #define ED_NUM_CTRL_BUTTONS ED_NUM_CTRL1_7_BUTTONS
63 // values for the element list
64 #define ED_ELEMENTLIST_XPOS (editor.palette.x)
65 #define ED_ELEMENTLIST_YPOS (editor.palette.y)
66 #define ED_ELEMENTLIST_XSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
67 #define ED_ELEMENTLIST_YSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
68 #define ED_ELEMENTLIST_COLS MAX(1, editor.palette.cols)
69 #define ED_ELEMENTLIST_ROWS MAX(1, editor.palette.rows)
70 #define ED_ELEMENTLIST_BUTTONS_HORIZ (ED_ELEMENTLIST_COLS)
71 #define ED_ELEMENTLIST_BUTTONS_VERT (ED_ELEMENTLIST_ROWS)
72 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
73 ED_ELEMENTLIST_BUTTONS_VERT)
76 #define ED_GADGET_NORMAL_DISTANCE (editor.gadget.normal_spacing)
77 #define ED_GADGET_SMALL_DISTANCE (editor.gadget.small_spacing)
78 #define ED_GADGET_TINY_DISTANCE (editor.gadget.tiny_spacing)
79 #define ED_GADGET_LINE_DISTANCE (editor.gadget.line_spacing)
80 #define ED_GADGET_TEXT_DISTANCE (editor.gadget.text_spacing)
81 #define ED_TAB_BAR_HEIGHT (editor.gadget.separator_line.height)
82 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
83 ED_DRAWINGAREA_BORDER_SIZE)
84 #define ED_GADGET_SPACE_DISTANCE (getFontWidth(FONT_TEXT_1))
86 // values for drawingarea gadgets
87 #define IMG_BORDER_1 IMG_EDITOR_ELEMENT_BORDER
88 #define IMG_BORDER_2 IMG_EDITOR_ELEMENT_BORDER_INPUT
89 #define ED_ELEMENT_BORDER (graphic_info[IMG_BORDER_1].border_size)
90 #define ED_DRAWINGAREA_BORDER_SIZE (graphic_info[IMG_BORDER_2].border_size)
91 #define ED_DRAWINGAREA_TILE_SIZE (editor.drawingarea.tile_size)
93 // values for checkbutton gadgets
94 #define ED_CHECKBUTTON_XSIZE (graphic_info[IMG_EDITOR_CHECKBOX].width)
95 #define ED_CHECKBUTTON_YSIZE (graphic_info[IMG_EDITOR_CHECKBOX].height)
97 #define ED_TABBUTTON_XSIZE (graphic_info[IMG_EDITOR_TABBUTTON].width)
98 #define ED_TABBUTTON_YSIZE (graphic_info[IMG_EDITOR_TABBUTTON].height)
100 #define ED_SETTINGS_LEVEL_TABS_X (editor.settings.tabs.x)
101 #define ED_SETTINGS_LEVEL_TABS_Y (editor.settings.tabs.y)
102 #define ED_SETTINGS_ELEMENT_TABS_X (editor.settings.tabs.x)
103 #define ED_SETTINGS_ELEMENT_TABS_Y (editor.settings.tabs.y + \
104 editor.settings.tabs.yoffset2)
106 #define ED_SETTINGS_TABS_XOFFSET (editor.settings.tabs.draw_xoffset)
107 #define ED_SETTINGS_TABS_YOFFSET (editor.settings.tabs.draw_yoffset)
109 #define ED_LEVEL_TABS_XSTART (ED_SETTINGS_LEVEL_TABS_X)
110 #define ED_LEVEL_TABS_YSTART (ED_SETTINGS_LEVEL_TABS_Y)
111 #define ED_LEVEL_SETTINGS_XSTART (ED_SETTINGS_LEVEL_TABS_X + \
112 ED_SETTINGS_TABS_XOFFSET)
113 #define ED_LEVEL_SETTINGS_YSTART (ED_SETTINGS_LEVEL_TABS_Y + \
114 ED_TABBUTTON_YSIZE + \
115 ED_GADGET_TINY_DISTANCE + \
116 ED_TAB_BAR_HEIGHT + \
117 ED_SETTINGS_TABS_YOFFSET + \
118 getFontHeight(FONT_TEXT_1) + \
119 ED_GADGET_TEXT_DISTANCE)
120 #define ED_ELEMENT_TABS_XSTART (ED_SETTINGS_ELEMENT_TABS_X)
121 #define ED_ELEMENT_TABS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y)
122 #define ED_ELEMENT_SETTINGS_XSTART (ED_SETTINGS_ELEMENT_TABS_X + \
123 ED_SETTINGS_TABS_XOFFSET)
124 #define ED_ELEMENT_SETTINGS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y + \
125 ED_TABBUTTON_YSIZE + \
126 ED_GADGET_TINY_DISTANCE + \
127 ED_TAB_BAR_HEIGHT + \
128 ED_SETTINGS_TABS_YOFFSET)
130 #define ED_SETTINGS_XOFFSET (ED_CHECKBUTTON_XSIZE + \
131 ED_GADGET_TEXT_DISTANCE)
132 #define ED_SETTINGS_YOFFSET (ED_CHECKBUTTON_YSIZE + \
133 ED_GADGET_LINE_DISTANCE)
135 #define ED_POS_RANGE (10000)
136 #define ED_POS_LEVEL_TABS_FIRST (1 * ED_POS_RANGE)
137 #define ED_POS_LEVEL_TABS_LAST (2 * ED_POS_RANGE - 1)
138 #define ED_POS_LEVEL_SETTINGS_FIRST (2 * ED_POS_RANGE)
139 #define ED_POS_LEVEL_SETTINGS_LAST (3 * ED_POS_RANGE - 1)
140 #define ED_POS_ELEMENT_TABS_FIRST (3 * ED_POS_RANGE)
141 #define ED_POS_ELEMENT_TABS_LAST (4 * ED_POS_RANGE - 1)
142 #define ED_POS_ELEMENT_SETTINGS_FIRST (4 * ED_POS_RANGE)
143 #define ED_POS_ELEMENT_SETTINGS_LAST (5 * ED_POS_RANGE - 1)
145 #define ED_LEVEL_TABS_XPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
146 #define ED_LEVEL_TABS_YPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
148 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
149 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
151 #define ED_ELEMENT_TABS_XPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
152 #define ED_ELEMENT_TABS_YPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
154 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
155 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
157 #define IS_POS_LEVEL_TABS(n) ((n) >= ED_POS_LEVEL_TABS_FIRST && \
158 (n) <= ED_POS_LEVEL_TABS_LAST)
159 #define IS_POS_LEVEL_SETTINGS(n) ((n) >= ED_POS_LEVEL_SETTINGS_FIRST && \
160 (n) <= ED_POS_LEVEL_SETTINGS_LAST)
161 #define IS_POS_ELEMENT_TABS(n) ((n) >= ED_POS_ELEMENT_TABS_FIRST && \
162 (n) <= ED_POS_ELEMENT_TABS_LAST)
163 #define IS_POS_ELEMENT_SETTINGS(n) ((n) >= ED_POS_ELEMENT_SETTINGS_FIRST && \
164 (n) <= ED_POS_ELEMENT_SETTINGS_LAST)
166 #define ED_LEVEL_TABS_LINE(n) ((n) - ED_POS_LEVEL_TABS_FIRST)
167 #define ED_LEVEL_SETTINGS_LINE(n) ((n) - ED_POS_LEVEL_SETTINGS_FIRST)
168 #define ED_ELEMENT_TABS_LINE(n) ((n) - ED_POS_ELEMENT_TABS_FIRST)
169 #define ED_ELEMENT_SETTINGS_LINE(n) ((n) - ED_POS_ELEMENT_SETTINGS_FIRST)
171 #define ED_LEVEL_TABS_X(n) (ED_LEVEL_TABS_XSTART + \
172 (n) * ED_SETTINGS_TABS_XOFFSET)
173 #define ED_LEVEL_TABS_Y(n) (ED_LEVEL_TABS_YSTART + \
174 (n) * ED_SETTINGS_TABS_YOFFSET)
176 #define ED_LEVEL_SETTINGS_X(n) (ED_LEVEL_SETTINGS_XSTART + \
177 (n) * ED_SETTINGS_XOFFSET)
178 #define ED_LEVEL_SETTINGS_Y(n) (ED_LEVEL_SETTINGS_YSTART + \
179 (n) * ED_SETTINGS_YOFFSET)
181 #define ED_ELEMENT_TABS_X(n) (ED_ELEMENT_TABS_XSTART + \
182 (n) * ED_SETTINGS_TABS_XOFFSET)
183 #define ED_ELEMENT_TABS_Y(n) (ED_ELEMENT_TABS_YSTART + \
184 (n) * ED_SETTINGS_TABS_YOFFSET)
186 #define ED_ELEMENT_SETTINGS_X(n) (ED_ELEMENT_SETTINGS_XSTART + \
187 (n) * ED_SETTINGS_XOFFSET)
188 #define ED_ELEMENT_SETTINGS_Y(n) (ED_ELEMENT_SETTINGS_YSTART + \
189 (n) * ED_SETTINGS_YOFFSET)
191 #define ED_POS_TO_LEVEL_TABS_X(n) \
192 (ED_LEVEL_TABS_X(ED_LEVEL_TABS_LINE(n)))
193 #define ED_POS_TO_LEVEL_TABS_Y(n) \
194 (ED_LEVEL_TABS_Y(ED_LEVEL_TABS_LINE(n)))
196 #define ED_POS_TO_LEVEL_SETTINGS_X(n) \
197 (ED_LEVEL_SETTINGS_X(ED_LEVEL_SETTINGS_LINE(n)))
198 #define ED_POS_TO_LEVEL_SETTINGS_Y(n) \
199 (ED_LEVEL_SETTINGS_Y(ED_LEVEL_SETTINGS_LINE(n)))
201 #define ED_POS_TO_ELEMENT_TABS_X(n) \
202 (ED_ELEMENT_TABS_X(ED_ELEMENT_TABS_LINE(n)))
203 #define ED_POS_TO_ELEMENT_TABS_Y(n) \
204 (ED_ELEMENT_TABS_Y(ED_ELEMENT_TABS_LINE(n)))
206 #define ED_POS_TO_ELEMENT_SETTINGS_X(n) \
207 (ED_ELEMENT_SETTINGS_X(ED_ELEMENT_SETTINGS_LINE(n)))
208 #define ED_POS_TO_ELEMENT_SETTINGS_Y(n) \
209 (ED_ELEMENT_SETTINGS_Y(ED_ELEMENT_SETTINGS_LINE(n)))
211 #define ED_SETTINGS_X(n) (IS_POS_LEVEL_TABS(n) ? \
212 ED_POS_TO_LEVEL_TABS_X(n) : \
213 IS_POS_LEVEL_SETTINGS(n) ? \
214 ED_POS_TO_LEVEL_SETTINGS_X(n) : \
215 IS_POS_ELEMENT_TABS(n) ? \
216 ED_POS_TO_ELEMENT_TABS_X(n) : \
217 IS_POS_ELEMENT_SETTINGS(n) ? \
218 ED_POS_TO_ELEMENT_SETTINGS_X(n) : (n))
219 #define ED_SETTINGS_Y(n) (IS_POS_LEVEL_TABS(n) ? \
220 ED_POS_TO_LEVEL_TABS_Y(n) : \
221 IS_POS_LEVEL_SETTINGS(n) ? \
222 ED_POS_TO_LEVEL_SETTINGS_Y(n) : \
223 IS_POS_ELEMENT_TABS(n) ? \
224 ED_POS_TO_ELEMENT_TABS_Y(n) : \
225 IS_POS_ELEMENT_SETTINGS(n) ? \
226 ED_POS_TO_ELEMENT_SETTINGS_Y(n) : (n))
228 #define ED_SETTINGS_XOFF(n) (5 * ((n) % 4) * \
229 ED_DRAWINGAREA_TILE_SIZE)
230 #define ED_SETTINGS_YOFF(n) (5 * ((n) / 4) * \
231 ED_DRAWINGAREA_TILE_SIZE)
233 #define ED_AREA_XOFFSET_1(n) ((n) != 0 ? \
234 ED_DRAWINGAREA_BORDER_SIZE : 0)
235 #define ED_AREA_YOFFSET_1(n) ((n) != 0 ? \
236 (ED_CHECKBUTTON_YSIZE - \
237 ED_DRAWINGAREA_TILE_SIZE) / 2 : 0)
239 #define ED_AREA_XOFFSET_2(n) (0)
240 #define ED_AREA_YOFFSET_2(n) ((n) == 3 ? \
241 ((n) - 1) * ED_DRAWINGAREA_TILE_SIZE / 2 : 0)
243 #define ED_AREA_SETTINGS_X(i) (ED_SETTINGS_X((i).x) + \
244 ED_SETTINGS_XOFF((i).xoffset) + \
245 ED_AREA_XOFFSET_1((i).x) - \
246 ED_AREA_XOFFSET_2((i).area_xsize))
247 #define ED_AREA_SETTINGS_Y(i) (ED_SETTINGS_Y((i).y) + \
248 ED_SETTINGS_YOFF((i).yoffset) + \
249 ED_AREA_YOFFSET_1((i).y) - \
250 ED_AREA_YOFFSET_2((i).area_ysize))
252 // values for element content drawing areas
253 #define ED_AREA_1X1_LSETTINGS_XPOS(n) ED_LEVEL_SETTINGS_XPOS(n)
254 #define ED_AREA_1X1_LSETTINGS_YPOS(n) ED_LEVEL_SETTINGS_YPOS(n)
255 #define ED_AREA_1X1_LSETTINGS_XOFF (0)
256 #define ED_AREA_1X1_LSETTINGS_YOFF (0)
258 #define ED_AREA_1X1_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
259 #define ED_AREA_1X1_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
260 #define ED_AREA_1X1_SETTINGS_XOFF (0)
261 #define ED_AREA_1X1_SETTINGS_YOFF (0)
263 #define ED_AREA_3X3_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
264 #define ED_AREA_3X3_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
265 #define ED_AREA_3X3_SETTINGS_XOFF (0)
266 #define ED_AREA_3X3_SETTINGS_YOFF (0)
269 #define ED_AREA_ELEMENT_CONTENT_XOFF(n) (n)
270 #define ED_AREA_ELEMENT_CONTENT_YOFF(n) (n)
273 #define ED_XPOS_YAM 0
274 #define ED_YPOS_YAM 5
275 #define ED_AREA_YAMYAM_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_YAM)
276 #define ED_AREA_YAMYAM_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_YAM)
277 #define ED_AREA_YAMYAM_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
278 #define ED_AREA_YAMYAM_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
279 #define ED_AREA_YAMYAM_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_YAM) + \
281 #define ED_AREA_YAMYAM_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_YAM) + \
282 ED_SETTINGS_YOFF(n) + \
283 ED_AREA_YOFFSET_1(ED_YPOS_YAM) - \
284 ED_AREA_YOFFSET_2(3))
286 // magic ball content
287 #define ED_XPOS_BALL 0
288 #define ED_YPOS_BALL 6
289 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_BALL)
290 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_BALL)
291 #define ED_AREA_MAGIC_BALL_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
292 #define ED_AREA_MAGIC_BALL_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
293 #define ED_AREA_MAGIC_BALL_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_BALL) + \
295 #define ED_AREA_MAGIC_BALL_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_BALL) + \
296 ED_SETTINGS_YOFF(n) + \
297 ED_AREA_YOFFSET_1(ED_YPOS_BALL) - \
298 ED_AREA_YOFFSET_2(3))
300 // values for scrolling gadgets for drawing area
301 #define ED_SCROLLBUTTON_XSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].width)
302 #define ED_SCROLLBUTTON_YSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].height)
304 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
305 #define ED_SCROLL_UP_YPOS (0)
306 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
307 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
308 #define ED_SCROLL_LEFT_XPOS (0)
309 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
310 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
311 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
312 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
313 ED_SCROLLBUTTON_XSIZE)
314 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
315 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
316 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
317 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
318 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
319 ED_SCROLLBUTTON_YSIZE)
320 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
321 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
323 // values for scrolling gadgets for element list
324 #define ED_SCROLLBUTTON2_XSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
325 #define ED_SCROLLBUTTON2_YSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
327 #define ED_SCROLL2_UP_XPOS (ED_ELEMENTLIST_XPOS + \
328 ED_ELEMENTLIST_BUTTONS_HORIZ * \
329 ED_ELEMENTLIST_XSIZE)
330 #define ED_SCROLL2_UP_YPOS ED_ELEMENTLIST_YPOS
331 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
332 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
333 ED_ELEMENTLIST_BUTTONS_VERT * \
334 ED_ELEMENTLIST_YSIZE - \
335 ED_SCROLLBUTTON2_YSIZE)
336 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
337 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
338 ED_SCROLLBUTTON2_YSIZE)
339 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
340 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
341 ED_ELEMENTLIST_YSIZE - \
342 2 * ED_SCROLLBUTTON2_YSIZE)
344 // values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText()
345 #define INFOTEXT_FONT FONT_TEXT_2
346 #define INFOTEXT_XSIZE SXSIZE
347 #define INFOTEXT_YSIZE getFontHeight(INFOTEXT_FONT)
348 #define INFOTEXT_YSIZE_FULL (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE)
349 #define INFOTEXT_X (editor.settings.tooltip.x)
350 #define INFOTEXT_Y (editor.settings.tooltip.y)
351 #define INFOTEXT_XY_REDEFINED (INFOTEXT_X != -1 || INFOTEXT_Y != -1)
352 #define INFOTEXT_XPOS SX + (INFOTEXT_XY_REDEFINED ? INFOTEXT_X : 0)
353 #define INFOTEXT_YPOS SY + (INFOTEXT_XY_REDEFINED ? INFOTEXT_Y : \
354 SYSIZE - INFOTEXT_YSIZE)
357 // ----------------------------------------------------------------------------
358 // editor gadget definitions
359 // ----------------------------------------------------------------------------
365 // drawing toolbox buttons
367 GADGET_ID_SINGLE_ITEMS,
368 GADGET_ID_CONNECTED_ITEMS,
372 GADGET_ID_FILLED_BOX,
375 GADGET_ID_FLOOD_FILL,
378 GADGET_ID_WRAP_RIGHT,
379 GADGET_ID_RANDOM_PLACEMENT,
380 GADGET_ID_GRAB_BRUSH,
382 GADGET_ID_PICK_ELEMENT,
391 GADGET_ID_CUSTOM_COPY_FROM,
392 GADGET_ID_CUSTOM_COPY_TO,
393 GADGET_ID_CUSTOM_EXCHANGE,
394 GADGET_ID_CUSTOM_COPY,
395 GADGET_ID_CUSTOM_PASTE,
397 GADGET_ID_PROPERTIES,
398 GADGET_ID_ELEMENT_LEFT,
399 GADGET_ID_ELEMENT_MIDDLE,
400 GADGET_ID_ELEMENT_RIGHT,
403 // counter gadget identifiers
405 GADGET_ID_SELECT_LEVEL_DOWN,
406 GADGET_ID_SELECT_LEVEL_TEXT,
407 GADGET_ID_SELECT_LEVEL_UP,
408 GADGET_ID_LEVEL_XSIZE_DOWN,
409 GADGET_ID_LEVEL_XSIZE_TEXT,
410 GADGET_ID_LEVEL_XSIZE_UP,
411 GADGET_ID_LEVEL_YSIZE_DOWN,
412 GADGET_ID_LEVEL_YSIZE_TEXT,
413 GADGET_ID_LEVEL_YSIZE_UP,
414 GADGET_ID_LEVEL_RANDOM_DOWN,
415 GADGET_ID_LEVEL_RANDOM_TEXT,
416 GADGET_ID_LEVEL_RANDOM_UP,
417 GADGET_ID_LEVEL_GEMSLIMIT_DOWN,
418 GADGET_ID_LEVEL_GEMSLIMIT_TEXT,
419 GADGET_ID_LEVEL_GEMSLIMIT_UP,
420 GADGET_ID_LEVEL_TIMELIMIT_DOWN,
421 GADGET_ID_LEVEL_TIMELIMIT_TEXT,
422 GADGET_ID_LEVEL_TIMELIMIT_UP,
423 GADGET_ID_LEVEL_TIMESCORE_DOWN,
424 GADGET_ID_LEVEL_TIMESCORE_TEXT,
425 GADGET_ID_LEVEL_TIMESCORE_UP,
426 GADGET_ID_LEVEL_RANDOM_SEED_DOWN,
427 GADGET_ID_LEVEL_RANDOM_SEED_TEXT,
428 GADGET_ID_LEVEL_RANDOM_SEED_UP,
429 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN,
430 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT,
431 GADGET_ID_LEVELSET_NUM_LEVELS_UP,
432 GADGET_ID_ELEMENT_VALUE1_DOWN,
433 GADGET_ID_ELEMENT_VALUE1_TEXT,
434 GADGET_ID_ELEMENT_VALUE1_UP,
435 GADGET_ID_ELEMENT_VALUE2_DOWN,
436 GADGET_ID_ELEMENT_VALUE2_TEXT,
437 GADGET_ID_ELEMENT_VALUE2_UP,
438 GADGET_ID_ELEMENT_VALUE3_DOWN,
439 GADGET_ID_ELEMENT_VALUE3_TEXT,
440 GADGET_ID_ELEMENT_VALUE3_UP,
441 GADGET_ID_ELEMENT_VALUE4_DOWN,
442 GADGET_ID_ELEMENT_VALUE4_TEXT,
443 GADGET_ID_ELEMENT_VALUE4_UP,
444 GADGET_ID_YAMYAM_CONTENT_DOWN,
445 GADGET_ID_YAMYAM_CONTENT_TEXT,
446 GADGET_ID_YAMYAM_CONTENT_UP,
447 GADGET_ID_BALL_CONTENT_DOWN,
448 GADGET_ID_BALL_CONTENT_TEXT,
449 GADGET_ID_BALL_CONTENT_UP,
450 GADGET_ID_ANDROID_CONTENT_DOWN,
451 GADGET_ID_ANDROID_CONTENT_TEXT,
452 GADGET_ID_ANDROID_CONTENT_UP,
453 GADGET_ID_ENVELOPE_XSIZE_DOWN,
454 GADGET_ID_ENVELOPE_XSIZE_TEXT,
455 GADGET_ID_ENVELOPE_XSIZE_UP,
456 GADGET_ID_ENVELOPE_YSIZE_DOWN,
457 GADGET_ID_ENVELOPE_YSIZE_TEXT,
458 GADGET_ID_ENVELOPE_YSIZE_UP,
459 GADGET_ID_INVENTORY_SIZE_DOWN,
460 GADGET_ID_INVENTORY_SIZE_TEXT,
461 GADGET_ID_INVENTORY_SIZE_UP,
462 GADGET_ID_MM_BALL_CONTENT_DOWN,
463 GADGET_ID_MM_BALL_CONTENT_TEXT,
464 GADGET_ID_MM_BALL_CONTENT_UP,
465 GADGET_ID_CUSTOM_SCORE_DOWN,
466 GADGET_ID_CUSTOM_SCORE_TEXT,
467 GADGET_ID_CUSTOM_SCORE_UP,
468 GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
469 GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
470 GADGET_ID_CUSTOM_GEMCOUNT_UP,
471 GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
472 GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
473 GADGET_ID_CUSTOM_VALUE_FIX_UP,
474 GADGET_ID_CUSTOM_VALUE_RND_DOWN,
475 GADGET_ID_CUSTOM_VALUE_RND_TEXT,
476 GADGET_ID_CUSTOM_VALUE_RND_UP,
477 GADGET_ID_PUSH_DELAY_FIX_DOWN,
478 GADGET_ID_PUSH_DELAY_FIX_TEXT,
479 GADGET_ID_PUSH_DELAY_FIX_UP,
480 GADGET_ID_PUSH_DELAY_RND_DOWN,
481 GADGET_ID_PUSH_DELAY_RND_TEXT,
482 GADGET_ID_PUSH_DELAY_RND_UP,
483 GADGET_ID_DROP_DELAY_FIX_DOWN,
484 GADGET_ID_DROP_DELAY_FIX_TEXT,
485 GADGET_ID_DROP_DELAY_FIX_UP,
486 GADGET_ID_DROP_DELAY_RND_DOWN,
487 GADGET_ID_DROP_DELAY_RND_TEXT,
488 GADGET_ID_DROP_DELAY_RND_UP,
489 GADGET_ID_MOVE_DELAY_FIX_DOWN,
490 GADGET_ID_MOVE_DELAY_FIX_TEXT,
491 GADGET_ID_MOVE_DELAY_FIX_UP,
492 GADGET_ID_MOVE_DELAY_RND_DOWN,
493 GADGET_ID_MOVE_DELAY_RND_TEXT,
494 GADGET_ID_MOVE_DELAY_RND_UP,
495 GADGET_ID_STEP_DELAY_FIX_DOWN,
496 GADGET_ID_STEP_DELAY_FIX_TEXT,
497 GADGET_ID_STEP_DELAY_FIX_UP,
498 GADGET_ID_STEP_DELAY_RND_DOWN,
499 GADGET_ID_STEP_DELAY_RND_TEXT,
500 GADGET_ID_STEP_DELAY_RND_UP,
501 GADGET_ID_EXPLOSION_DELAY_DOWN,
502 GADGET_ID_EXPLOSION_DELAY_TEXT,
503 GADGET_ID_EXPLOSION_DELAY_UP,
504 GADGET_ID_IGNITION_DELAY_DOWN,
505 GADGET_ID_IGNITION_DELAY_TEXT,
506 GADGET_ID_IGNITION_DELAY_UP,
507 GADGET_ID_CHANGE_DELAY_FIX_DOWN,
508 GADGET_ID_CHANGE_DELAY_FIX_TEXT,
509 GADGET_ID_CHANGE_DELAY_FIX_UP,
510 GADGET_ID_CHANGE_DELAY_RND_DOWN,
511 GADGET_ID_CHANGE_DELAY_RND_TEXT,
512 GADGET_ID_CHANGE_DELAY_RND_UP,
513 GADGET_ID_CHANGE_CONT_RND_DOWN,
514 GADGET_ID_CHANGE_CONT_RND_TEXT,
515 GADGET_ID_CHANGE_CONT_RND_UP,
516 GADGET_ID_GROUP_CONTENT_DOWN,
517 GADGET_ID_GROUP_CONTENT_TEXT,
518 GADGET_ID_GROUP_CONTENT_UP,
520 // drawing area identifiers
522 GADGET_ID_DRAWING_LEVEL,
523 GADGET_ID_YAMYAM_CONTENT_0,
524 GADGET_ID_YAMYAM_CONTENT_1,
525 GADGET_ID_YAMYAM_CONTENT_2,
526 GADGET_ID_YAMYAM_CONTENT_3,
527 GADGET_ID_YAMYAM_CONTENT_4,
528 GADGET_ID_YAMYAM_CONTENT_5,
529 GADGET_ID_YAMYAM_CONTENT_6,
530 GADGET_ID_YAMYAM_CONTENT_7,
531 GADGET_ID_MAGIC_BALL_CONTENT_0,
532 GADGET_ID_MAGIC_BALL_CONTENT_1,
533 GADGET_ID_MAGIC_BALL_CONTENT_2,
534 GADGET_ID_MAGIC_BALL_CONTENT_3,
535 GADGET_ID_MAGIC_BALL_CONTENT_4,
536 GADGET_ID_MAGIC_BALL_CONTENT_5,
537 GADGET_ID_MAGIC_BALL_CONTENT_6,
538 GADGET_ID_MAGIC_BALL_CONTENT_7,
539 GADGET_ID_ANDROID_CONTENT,
540 GADGET_ID_AMOEBA_CONTENT,
541 GADGET_ID_START_ELEMENT,
542 GADGET_ID_ARTWORK_ELEMENT,
543 GADGET_ID_EXPLOSION_ELEMENT,
544 GADGET_ID_INVENTORY_CONTENT,
545 GADGET_ID_MM_BALL_CONTENT,
546 GADGET_ID_CUSTOM_GRAPHIC,
547 GADGET_ID_CUSTOM_CONTENT,
548 GADGET_ID_CUSTOM_MOVE_ENTER,
549 GADGET_ID_CUSTOM_MOVE_LEAVE,
550 GADGET_ID_CUSTOM_CHANGE_TARGET,
551 GADGET_ID_CUSTOM_CHANGE_CONTENT,
552 GADGET_ID_CUSTOM_CHANGE_TRIGGER,
553 GADGET_ID_CUSTOM_CHANGE_ACTION,
554 GADGET_ID_GROUP_CONTENT,
555 GADGET_ID_RANDOM_BACKGROUND,
557 // text input identifiers
559 GADGET_ID_LEVEL_NAME,
560 GADGET_ID_LEVEL_AUTHOR,
561 GADGET_ID_LEVELSET_NAME,
562 GADGET_ID_LEVELSET_AUTHOR,
563 GADGET_ID_ELEMENT_NAME,
565 // text area identifiers
567 GADGET_ID_ENVELOPE_INFO,
569 // selectbox identifiers
571 GADGET_ID_TIME_OR_STEPS,
572 GADGET_ID_TIME_SCORE_BASE,
573 GADGET_ID_GAME_ENGINE_TYPE,
574 GADGET_ID_LEVELSET_SAVE_MODE,
575 GADGET_ID_WIND_DIRECTION,
576 GADGET_ID_PLAYER_SPEED,
577 GADGET_ID_MM_BALL_CHOICE_MODE,
578 GADGET_ID_CUSTOM_WALK_TO_ACTION,
579 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
580 GADGET_ID_CUSTOM_DEADLINESS,
581 GADGET_ID_CUSTOM_MOVE_PATTERN,
582 GADGET_ID_CUSTOM_MOVE_DIRECTION,
583 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
584 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
585 GADGET_ID_CUSTOM_SMASH_TARGETS,
586 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
587 GADGET_ID_CUSTOM_ACCESS_TYPE,
588 GADGET_ID_CUSTOM_ACCESS_LAYER,
589 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
590 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
591 GADGET_ID_CHANGE_TIME_UNITS,
592 GADGET_ID_CHANGE_DIRECT_ACTION,
593 GADGET_ID_CHANGE_OTHER_ACTION,
594 GADGET_ID_CHANGE_SIDE,
595 GADGET_ID_CHANGE_PLAYER,
596 GADGET_ID_CHANGE_PAGE,
597 GADGET_ID_CHANGE_REPLACE_WHEN,
598 GADGET_ID_ACTION_TYPE,
599 GADGET_ID_ACTION_MODE,
600 GADGET_ID_ACTION_ARG,
601 GADGET_ID_SELECT_CHANGE_PAGE,
602 GADGET_ID_GROUP_CHOICE_MODE,
604 // textbutton identifiers
606 GADGET_ID_LEVELCONFIG_LEVEL,
607 GADGET_ID_LEVELCONFIG_LEVELSET,
608 GADGET_ID_LEVELCONFIG_EDITOR,
609 GADGET_ID_PROPERTIES_INFO,
610 GADGET_ID_PROPERTIES_CONFIG,
611 GADGET_ID_PROPERTIES_CONFIG_1,
612 GADGET_ID_PROPERTIES_CONFIG_2,
613 GADGET_ID_PROPERTIES_CHANGE,
614 GADGET_ID_SAVE_AS_TEMPLATE_1,
615 GADGET_ID_SAVE_AS_TEMPLATE_2,
616 GADGET_ID_SAVE_LEVELSET,
617 GADGET_ID_ADD_CHANGE_PAGE,
618 GADGET_ID_DEL_CHANGE_PAGE,
620 // graphicbutton identifiers
622 GADGET_ID_PREV_CHANGE_PAGE,
623 GADGET_ID_NEXT_CHANGE_PAGE,
624 GADGET_ID_COPY_CHANGE_PAGE,
625 GADGET_ID_PASTE_CHANGE_PAGE,
627 // gadgets for scrolling of drawing area
630 GADGET_ID_SCROLL_DOWN,
631 GADGET_ID_SCROLL_LEFT,
632 GADGET_ID_SCROLL_RIGHT,
633 GADGET_ID_SCROLL_HORIZONTAL,
634 GADGET_ID_SCROLL_VERTICAL,
636 // gadgets for scrolling element list
638 GADGET_ID_SCROLL_LIST_UP,
639 GADGET_ID_SCROLL_LIST_DOWN,
640 GADGET_ID_SCROLL_LIST_VERTICAL,
642 // checkbuttons/radiobuttons for level/element properties
644 GADGET_ID_AUTO_COUNT_GEMS,
645 GADGET_ID_RATE_TIME_OVER_SCORE,
646 GADGET_ID_USE_LEVELSET_ARTWORK,
647 GADGET_ID_COPY_LEVEL_TEMPLATE,
648 GADGET_ID_RANDOM_PERCENTAGE,
649 GADGET_ID_RANDOM_QUANTITY,
650 GADGET_ID_RANDOM_RESTRICTED,
651 GADGET_ID_STICK_ELEMENT,
652 GADGET_ID_EM_SLIPPERY_GEMS,
653 GADGET_ID_EM_EXPLODES_BY_FIRE,
654 GADGET_ID_USE_SPRING_BUG,
655 GADGET_ID_USE_TIME_ORB_BUG,
656 GADGET_ID_USE_LIFE_BUGS,
657 GADGET_ID_RANDOM_BALL_CONTENT,
658 GADGET_ID_INITIAL_BALL_ACTIVE,
659 GADGET_ID_GROW_INTO_DIGGABLE,
660 GADGET_ID_SB_FIELDS_NEEDED,
661 GADGET_ID_SB_OBJECTS_NEEDED,
662 GADGET_ID_AUTO_EXIT_SOKOBAN,
663 GADGET_ID_SOLVED_BY_ONE_PLAYER,
664 GADGET_ID_FINISH_DIG_COLLECT,
665 GADGET_ID_KEEP_WALKABLE_CE,
666 GADGET_ID_CONTINUOUS_SNAPPING,
667 GADGET_ID_BLOCK_SNAP_FIELD,
668 GADGET_ID_BLOCK_LAST_FIELD,
669 GADGET_ID_SP_BLOCK_LAST_FIELD,
670 GADGET_ID_INSTANT_RELOCATION,
671 GADGET_ID_SHIFTED_RELOCATION,
672 GADGET_ID_LAZY_RELOCATION,
673 GADGET_ID_USE_START_ELEMENT,
674 GADGET_ID_USE_ARTWORK_ELEMENT,
675 GADGET_ID_USE_EXPLOSION_ELEMENT,
676 GADGET_ID_INITIAL_GRAVITY,
677 GADGET_ID_USE_INITIAL_INVENTORY,
678 GADGET_ID_CAN_PASS_TO_WALKABLE,
679 GADGET_ID_CAN_FALL_INTO_ACID,
680 GADGET_ID_CAN_MOVE_INTO_ACID,
681 GADGET_ID_DONT_COLLIDE_WITH,
682 GADGET_ID_ENVELOPE_AUTOWRAP,
683 GADGET_ID_ENVELOPE_CENTERED,
684 GADGET_ID_MM_LASER_RED,
685 GADGET_ID_MM_LASER_GREEN,
686 GADGET_ID_MM_LASER_BLUE,
687 GADGET_ID_DF_LASER_RED,
688 GADGET_ID_DF_LASER_GREEN,
689 GADGET_ID_DF_LASER_BLUE,
690 GADGET_ID_ROTATE_MM_BALL_CONTENT,
691 GADGET_ID_EXPLODE_MM_BALL,
692 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
693 GADGET_ID_CUSTOM_CAN_EXPLODE,
694 GADGET_ID_CUSTOM_EXPLODE_FIRE,
695 GADGET_ID_CUSTOM_EXPLODE_SMASH,
696 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
697 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
698 GADGET_ID_CUSTOM_DEADLY,
699 GADGET_ID_CUSTOM_CAN_MOVE,
700 GADGET_ID_CUSTOM_CAN_FALL,
701 GADGET_ID_CUSTOM_CAN_SMASH,
702 GADGET_ID_CUSTOM_SLIPPERY,
703 GADGET_ID_CUSTOM_ACCESSIBLE,
704 GADGET_ID_CUSTOM_GRAV_REACHABLE,
705 GADGET_ID_CUSTOM_USE_LAST_VALUE,
706 GADGET_ID_CUSTOM_USE_GRAPHIC,
707 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
708 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
709 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
710 GADGET_ID_CUSTOM_CAN_CHANGE,
711 GADGET_ID_CHANGE_USE_CONTENT,
712 GADGET_ID_CHANGE_USE_EXPLOSION,
713 GADGET_ID_CHANGE_ONLY_COMPLETE,
714 GADGET_ID_CHANGE_USE_RANDOM,
715 GADGET_ID_CHANGE_HAS_ACTION,
716 GADGET_ID_CHANGE_DELAY,
717 GADGET_ID_CHANGE_BY_DIRECT_ACT,
718 GADGET_ID_CHANGE_BY_OTHER_ACT,
720 NUM_STATIC_GADGET_IDS
723 // gadgets for buttons in element list (dynamic)
724 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
725 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
726 ED_NUM_ELEMENTLIST_BUTTONS - 1)
728 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
730 // radio button numbers
734 RADIO_NR_DRAWING_TOOLBOX,
735 RADIO_NR_RANDOM_ELEMENTS
738 // values for counter gadgets
741 ED_COUNTER_ID_SELECT_LEVEL,
742 ED_COUNTER_ID_LEVEL_XSIZE,
743 ED_COUNTER_ID_LEVEL_YSIZE,
744 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
745 ED_COUNTER_ID_LEVEL_TIMELIMIT,
746 ED_COUNTER_ID_LEVEL_TIMESCORE,
747 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
748 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
749 ED_COUNTER_ID_LEVEL_RANDOM,
750 ED_COUNTER_ID_ELEMENT_VALUE1,
751 ED_COUNTER_ID_ELEMENT_VALUE2,
752 ED_COUNTER_ID_ELEMENT_VALUE3,
753 ED_COUNTER_ID_ELEMENT_VALUE4,
754 ED_COUNTER_ID_YAMYAM_CONTENT,
755 ED_COUNTER_ID_BALL_CONTENT,
756 ED_COUNTER_ID_ANDROID_CONTENT,
757 ED_COUNTER_ID_ENVELOPE_XSIZE,
758 ED_COUNTER_ID_ENVELOPE_YSIZE,
759 ED_COUNTER_ID_INVENTORY_SIZE,
760 ED_COUNTER_ID_MM_BALL_CONTENT,
761 ED_COUNTER_ID_CUSTOM_SCORE,
762 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
763 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
764 ED_COUNTER_ID_CUSTOM_VALUE_RND,
765 ED_COUNTER_ID_PUSH_DELAY_FIX,
766 ED_COUNTER_ID_PUSH_DELAY_RND,
767 ED_COUNTER_ID_DROP_DELAY_FIX,
768 ED_COUNTER_ID_DROP_DELAY_RND,
769 ED_COUNTER_ID_MOVE_DELAY_FIX,
770 ED_COUNTER_ID_MOVE_DELAY_RND,
771 ED_COUNTER_ID_STEP_DELAY_FIX,
772 ED_COUNTER_ID_STEP_DELAY_RND,
773 ED_COUNTER_ID_EXPLOSION_DELAY,
774 ED_COUNTER_ID_IGNITION_DELAY,
775 ED_COUNTER_ID_GROUP_CONTENT,
776 ED_COUNTER_ID_CHANGE_DELAY_FIX,
777 ED_COUNTER_ID_CHANGE_DELAY_RND,
778 ED_COUNTER_ID_CHANGE_CONT_RND,
780 ED_NUM_COUNTERBUTTONS
783 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
784 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
785 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
786 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
787 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
788 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
790 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
791 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
792 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
793 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
794 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
795 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
797 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
798 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
800 // values for scrollbutton gadgets
803 ED_SCROLLBUTTON_ID_AREA_UP,
804 ED_SCROLLBUTTON_ID_AREA_DOWN,
805 ED_SCROLLBUTTON_ID_AREA_LEFT,
806 ED_SCROLLBUTTON_ID_AREA_RIGHT,
807 ED_SCROLLBUTTON_ID_LIST_UP,
808 ED_SCROLLBUTTON_ID_LIST_DOWN,
813 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
814 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
816 // values for scrollbar gadgets
819 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
820 ED_SCROLLBAR_ID_AREA_VERTICAL,
821 ED_SCROLLBAR_ID_LIST_VERTICAL,
826 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
827 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
829 // values for text input gadgets
832 ED_TEXTINPUT_ID_LEVEL_NAME,
833 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
834 ED_TEXTINPUT_ID_LEVELSET_NAME,
835 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
836 ED_TEXTINPUT_ID_ELEMENT_NAME,
841 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
842 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
844 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
845 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
847 // values for text area gadgets
850 ED_TEXTAREA_ID_ENVELOPE_INFO,
855 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
856 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
858 // values for selectbox gadgets
861 ED_SELECTBOX_ID_TIME_OR_STEPS,
862 ED_SELECTBOX_ID_TIME_SCORE_BASE,
863 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
864 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
865 ED_SELECTBOX_ID_WIND_DIRECTION,
866 ED_SELECTBOX_ID_PLAYER_SPEED,
867 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
868 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
869 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
870 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
871 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
872 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
873 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
874 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
875 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
876 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
877 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
878 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
879 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
880 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
881 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
882 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
883 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
884 ED_SELECTBOX_ID_CHANGE_SIDE,
885 ED_SELECTBOX_ID_CHANGE_PLAYER,
886 ED_SELECTBOX_ID_CHANGE_PAGE,
887 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
888 ED_SELECTBOX_ID_ACTION_TYPE,
889 ED_SELECTBOX_ID_ACTION_MODE,
890 ED_SELECTBOX_ID_ACTION_ARG,
891 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
892 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
897 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
898 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
900 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
901 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
903 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
904 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
905 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
906 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
907 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
908 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
910 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
911 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
913 // values for textbutton gadgets
916 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
917 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
918 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
919 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
920 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
921 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
922 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
923 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
924 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
925 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
926 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
927 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
928 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
933 #define ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
934 #define ED_TAB_BUTTON_ID_LEVELCONFIG_LAST ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
936 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
937 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
939 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
940 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
942 // values for graphicbutton gadgets
945 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
946 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
947 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
948 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
950 ED_NUM_GRAPHICBUTTONS
953 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
954 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
956 // values for checkbutton gadgets
959 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
960 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
961 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
962 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
963 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
964 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
965 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
966 ED_CHECKBUTTON_ID_STICK_ELEMENT,
967 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
968 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
969 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
970 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
971 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
972 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
973 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
974 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
975 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
976 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
977 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
978 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
979 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
980 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
981 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
982 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
983 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
984 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
985 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
986 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
987 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
988 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
989 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
990 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
991 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
992 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
993 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
994 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
995 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
996 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
997 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
998 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
999 ED_CHECKBUTTON_ID_MM_LASER_RED,
1000 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
1001 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1002 ED_CHECKBUTTON_ID_DF_LASER_RED,
1003 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1004 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1005 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
1006 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
1007 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1008 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1009 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1010 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1011 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1012 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1013 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1014 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1015 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1016 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1017 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1018 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1019 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1020 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1021 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1022 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1023 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1024 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1025 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1026 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1027 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1028 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1029 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1030 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1031 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1036 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1037 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1039 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1040 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1042 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1043 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1045 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1046 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1047 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1048 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1049 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1050 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1052 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1053 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1055 // values for radiobutton gadgets
1058 ED_RADIOBUTTON_ID_PERCENTAGE,
1059 ED_RADIOBUTTON_ID_QUANTITY,
1064 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1065 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1067 // values for drawing area gadgets
1070 ED_DRAWING_ID_DRAWING_LEVEL,
1071 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1072 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1073 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1074 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1075 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1076 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1077 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1078 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1079 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1080 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1081 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1082 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1083 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1084 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1085 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1086 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1087 ED_DRAWING_ID_ANDROID_CONTENT,
1088 ED_DRAWING_ID_AMOEBA_CONTENT,
1089 ED_DRAWING_ID_START_ELEMENT,
1090 ED_DRAWING_ID_ARTWORK_ELEMENT,
1091 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1092 ED_DRAWING_ID_INVENTORY_CONTENT,
1093 ED_DRAWING_ID_MM_BALL_CONTENT,
1094 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1095 ED_DRAWING_ID_CUSTOM_CONTENT,
1096 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1097 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1098 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1099 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1100 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1101 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1102 ED_DRAWING_ID_GROUP_CONTENT,
1103 ED_DRAWING_ID_RANDOM_BACKGROUND,
1105 ED_NUM_DRAWING_AREAS
1108 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1109 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1112 // ----------------------------------------------------------------------------
1113 // some internally used definitions
1114 // ----------------------------------------------------------------------------
1116 // values for CopyLevelToUndoBuffer()
1117 #define UNDO_IMMEDIATE 0
1118 #define UNDO_ACCUMULATE 1
1120 // values for scrollbars
1121 #define ED_SCROLL_NO 0
1122 #define ED_SCROLL_LEFT 1
1123 #define ED_SCROLL_RIGHT 2
1124 #define ED_SCROLL_UP 4
1125 #define ED_SCROLL_DOWN 8
1127 // screens in the level editor
1128 #define ED_MODE_DRAWING 0
1129 #define ED_MODE_LEVELCONFIG 1
1130 #define ED_MODE_PROPERTIES 2
1131 #define ED_MODE_PALETTE 3
1133 // sub-screens in the global settings section
1134 #define ED_MODE_LEVELCONFIG_LEVEL ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
1135 #define ED_MODE_LEVELCONFIG_LEVELSET ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET
1136 #define ED_MODE_LEVELCONFIG_EDITOR ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
1138 // sub-screens in the element properties section
1139 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1140 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1141 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1142 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1143 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1145 // how many steps can be cancelled
1146 #define NUM_UNDO_STEPS (64 + 1)
1148 // values for elements with score for certain actions
1150 #define MAX_SCORE 999
1152 // values for elements with count for collecting
1153 #define MIN_COLLECT_COUNT 0
1154 #define MAX_COLLECT_COUNT 999
1156 // values for random placement
1157 #define RANDOM_USE_PERCENTAGE 0
1158 #define RANDOM_USE_QUANTITY 1
1160 // values for level set save mode
1161 #define LEVELSET_SAVE_MODE_UPDATE 0
1162 #define LEVELSET_SAVE_MODE_CREATE 1
1164 // default value for element tile size in drawing area
1165 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1166 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1169 // ----------------------------------------------------------------------------
1170 // some internally used data structure definitions
1171 // ----------------------------------------------------------------------------
1177 struct XYTileSize *pos;
1181 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1183 // note: some additional characters are already reserved for "cheat mode"
1184 // shortcuts (":XYZ" style) -- for details, see "events.c"
1186 // ---------- toolbox control buttons ---------------------------------------
1189 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1190 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1191 "draw single items", 's'
1194 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1195 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1196 "draw connected items", 'd'
1199 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1200 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1204 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1205 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1209 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1210 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1211 "draw outline rectangles", 'r'
1214 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1215 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1216 "draw filled rectangles", 'R'
1219 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1220 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1221 "wrap (rotate) level up", 0
1224 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1225 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1226 "enter text elements", 't'
1229 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1230 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1234 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1235 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1236 "wrap (rotate) level left", 0
1239 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1240 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1241 "zoom level tile size", '+'
1244 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1245 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1246 "wrap (rotate) level right", 0
1249 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1250 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1251 "random element placement", 0
1254 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1255 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1259 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1260 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1261 "wrap (rotate) level down", 0
1264 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1265 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1266 "pick drawing element", ','
1269 // ---------- level control buttons -----------------------------------------
1272 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1273 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1274 "undo/redo last operation", 'u'
1277 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_CONF,
1278 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1279 "level and editor settings", 'I'
1282 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1283 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1287 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1288 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1292 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1293 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1297 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1298 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1299 "exit level editor", 'E'
1302 // ---------- CE and GE control buttons -------------------------------------
1305 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1306 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1307 "copy settings from other element", 0
1310 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1311 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1312 "copy settings to other element", 0
1315 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1316 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1317 "exchange element with other element", 0
1320 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1321 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1322 "copy settings from this element", 0
1325 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1326 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1327 "paste settings to this element", 0
1330 // ---------- palette control buttons ---------------------------------------
1333 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1334 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1335 "properties of drawing element", 'p'
1338 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1339 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1340 "properties of drawing element 1", '1'
1343 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1344 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1345 "properties of drawing element 2", '2'
1348 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1349 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1350 "properties of drawing element 3", '3'
1353 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1354 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1355 "show list of elements", 'e'
1359 static int random_placement_value = 10;
1360 static int random_placement_method = RANDOM_USE_QUANTITY;
1361 static int random_placement_background_element = EL_SAND;
1362 static boolean random_placement_background_restricted = FALSE;
1363 static boolean stick_element_properties_window = FALSE;
1364 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1365 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1366 static struct ElementChangeInfo custom_element_change;
1367 static struct ElementGroupInfo group_element_info;
1368 static struct ElementInfo custom_element;
1370 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1371 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1372 static int levelset_num_levels = 100;
1373 static boolean levelset_use_levelset_artwork = FALSE;
1374 static boolean levelset_copy_level_template = FALSE;
1375 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1380 int min_value, max_value;
1381 int gadget_id_down, gadget_id_up;
1383 int gadget_id_align;
1385 char *text_above, *text_left, *text_right;
1386 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1388 // ---------- current level number ------------------------------------------
1391 -1, -1, // these values are not constant, but can change at runtime
1393 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1394 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1399 // ---------- level and editor settings -------------------------------------
1402 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1403 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1404 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1405 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1407 "playfield size:", NULL, "width",
1410 -1, ED_LEVEL_SETTINGS_YPOS(4),
1411 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1412 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1413 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1415 NULL, " ", "height",
1418 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1420 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1421 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1423 NULL, "number of gems to collect:", NULL
1426 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1428 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1429 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1431 "time or step limit to solve level:", NULL, NULL
1434 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1436 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1437 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1438 &level.score[SC_TIME_BONUS],
1439 "score for time or steps left:", NULL, NULL
1442 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1444 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1445 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1447 NULL, "random seed:", "(0 => random)"
1450 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1452 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1453 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1454 &levelset_num_levels,
1455 "number of levels:", NULL, NULL,
1458 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1460 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1461 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1462 &random_placement_value,
1463 "random element placement:", NULL, "in"
1466 // ---------- element settings: configure (various elements) ----------------
1469 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1470 MIN_SCORE, MAX_SCORE,
1471 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1472 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1473 NULL, // will be set when used
1477 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1478 MIN_SCORE, MAX_SCORE,
1479 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1480 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1481 NULL, // will be set when used
1485 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1486 MIN_SCORE, MAX_SCORE,
1487 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1488 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1489 NULL, // will be set when used
1493 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1494 MIN_SCORE, MAX_SCORE,
1495 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1496 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1497 NULL, // will be set when used
1501 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1502 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1503 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1504 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1505 &level.num_yamyam_contents,
1506 NULL, NULL, "number of content areas"
1509 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1510 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1511 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1512 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1513 &level.num_ball_contents,
1514 NULL, NULL, "number of content areas"
1517 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1518 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1519 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1520 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1521 &level.num_android_clone_elements,
1522 NULL, NULL, "number of clonable elements"
1525 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1526 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1527 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1528 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1529 NULL, // will be set when used
1530 NULL, NULL, "width",
1533 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1534 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1535 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1536 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1537 NULL, // will be set when used
1538 NULL, " ", "height",
1541 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1542 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1543 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1544 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1545 &level.initial_inventory_size[0],
1546 NULL, NULL, "number of inventory elements"
1549 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1550 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1551 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1552 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1553 &level.num_mm_ball_contents,
1554 NULL, NULL, "number of content elements"
1557 // ---------- element settings: configure 1 (custom elements) ---------------
1560 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1561 MIN_SCORE, MAX_SCORE,
1562 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1563 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1564 &custom_element.collect_score_initial,
1565 NULL, "CE score", " "
1568 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1569 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1570 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1571 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1572 &custom_element.collect_count_initial,
1573 NULL, "CE count", NULL
1576 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1578 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1579 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1580 &custom_element.ce_value_fixed_initial,
1581 NULL, "CE value", NULL
1584 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1586 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1587 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1588 &custom_element.ce_value_random_initial,
1589 NULL, "+random", NULL
1592 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1594 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1595 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1596 &custom_element.push_delay_fixed,
1597 NULL, "push delay", NULL
1600 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1602 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1603 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1604 &custom_element.push_delay_random,
1605 NULL, "+random", NULL
1608 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1610 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1611 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1612 &custom_element.drop_delay_fixed,
1613 NULL, "drop delay", NULL
1616 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1618 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1619 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1620 &custom_element.drop_delay_random,
1621 NULL, "+random", NULL
1624 // ---------- element settings: configure 2 (custom elements) ---------------
1627 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1629 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1630 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1631 &custom_element.move_delay_fixed,
1632 NULL, "move delay", NULL
1635 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1637 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1638 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1639 &custom_element.move_delay_random,
1640 NULL, "+random", NULL
1643 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1645 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1646 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1647 &custom_element.step_delay_fixed,
1648 NULL, "step delay", NULL
1651 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1653 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1654 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1655 &custom_element.step_delay_random,
1656 NULL, "+random", NULL
1659 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1661 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1662 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1663 &custom_element.explosion_delay,
1664 NULL, "explosion delay", NULL
1667 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1669 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1670 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1671 &custom_element.ignition_delay,
1672 NULL, "ignition delay", "(by fire)"
1675 // ---------- element settings: configure (group elements) ------------------
1678 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1679 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1680 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1681 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1682 &group_element_info.num_elements,
1683 NULL, NULL, "number of elements in group"
1686 // ---------- element settings: advanced (custom elements) ------------------
1689 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1691 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1692 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1693 &custom_element_change.delay_fixed,
1694 NULL, "CE delay", NULL,
1697 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1699 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1700 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1701 &custom_element_change.delay_random,
1702 NULL, "+random", NULL
1705 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1707 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1708 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1709 &custom_element_change.random_percentage,
1710 NULL, "use random replace:", "%"
1720 char *text_above, *infotext;
1721 } textinput_info[ED_NUM_TEXTINPUT] =
1724 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1725 GADGET_ID_LEVEL_NAME,
1728 "Title:", "Title for this level"
1731 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1732 GADGET_ID_LEVEL_AUTHOR,
1733 MAX_LEVEL_AUTHOR_LEN,
1735 "Author:", "Author for this level"
1738 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1739 GADGET_ID_LEVELSET_NAME,
1742 "Title:", "Title for this or new level set"
1745 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1746 GADGET_ID_LEVELSET_AUTHOR,
1747 MAX_LEVEL_AUTHOR_LEN,
1749 "Author:", "Author for this or new level set"
1752 -1, -1, // these values are not constant, but can change at runtime
1753 GADGET_ID_ELEMENT_NAME,
1754 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1755 custom_element.description,
1756 NULL, "Element name"
1766 char *text_above, *text_above_cropped, *infotext;
1767 } textarea_info[ED_NUM_TEXTAREAS] =
1770 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1771 GADGET_ID_ENVELOPE_INFO,
1772 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1774 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1778 static struct ValueTextInfo options_time_or_steps[] =
1786 static struct ValueTextInfo options_time_score_base[] =
1788 { 1, "per second/step" },
1789 { 10, "per 10 seconds/steps" },
1794 static struct ValueTextInfo options_game_engine_type[] =
1796 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1797 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1798 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1799 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1804 static struct ValueTextInfo options_levelset_save_mode[] =
1806 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1807 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1812 static struct ValueTextInfo options_wind_direction[] =
1814 { MV_START_NONE, "none" },
1815 { MV_START_LEFT, "left" },
1816 { MV_START_RIGHT, "right" },
1817 { MV_START_UP, "up" },
1818 { MV_START_DOWN, "down" },
1823 static struct ValueTextInfo options_player_speed[] =
1830 { 16, "very fast" },
1831 { 32, "ultrafast" },
1836 static struct ValueTextInfo options_access_type[] =
1838 { EP_WALKABLE, "walkable" },
1839 { EP_PASSABLE, "passable" },
1844 static struct ValueTextInfo options_access_layer[] =
1846 { EP_ACCESSIBLE_OVER, "over" },
1847 { EP_ACCESSIBLE_INSIDE, "inside" },
1848 { EP_ACCESSIBLE_UNDER, "under" },
1853 static struct ValueTextInfo options_access_protected[] =
1855 { 0, "unprotected" },
1861 static struct ValueTextInfo options_access_direction[] =
1863 { MV_NO_DIRECTION, "no direction" },
1864 { MV_LEFT, "left" },
1865 { MV_RIGHT, "right" },
1867 { MV_DOWN, "down" },
1868 { MV_LEFT | MV_UP, "left + up" },
1869 { MV_LEFT | MV_DOWN, "left + down" },
1870 { MV_RIGHT | MV_UP, "right + up" },
1871 { MV_RIGHT | MV_DOWN, "right + down" },
1872 { MV_HORIZONTAL, "horizontal" },
1873 { MV_VERTICAL, "vertical" },
1874 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1875 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1876 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1877 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1878 { MV_ALL_DIRECTIONS, "all directions" },
1883 static struct ValueTextInfo options_walk_to_action[] =
1885 { EP_DIGGABLE, "diggable" },
1886 { EP_COLLECTIBLE_ONLY, "collectible" },
1887 { EP_DROPPABLE, "collectible & droppable" },
1888 { EP_THROWABLE, "collectible & throwable" },
1889 { EP_PUSHABLE, "pushable" },
1894 static struct ValueTextInfo options_move_pattern[] =
1896 { MV_LEFT, "left" },
1897 { MV_RIGHT, "right" },
1899 { MV_DOWN, "down" },
1900 { MV_HORIZONTAL, "horizontal" },
1901 { MV_VERTICAL, "vertical" },
1902 { MV_ALL_DIRECTIONS, "all directions" },
1903 { MV_WIND_DIRECTION, "wind direction" },
1904 { MV_TOWARDS_PLAYER, "towards player" },
1905 { MV_AWAY_FROM_PLAYER, "away from player" },
1906 { MV_ALONG_LEFT_SIDE, "along left side" },
1907 { MV_ALONG_RIGHT_SIDE, "along right side" },
1908 { MV_TURNING_LEFT, "turning left" },
1909 { MV_TURNING_RIGHT, "turning right" },
1910 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1911 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1912 { MV_TURNING_RANDOM, "turning random" },
1913 { MV_MAZE_RUNNER, "maze runner style" },
1914 { MV_MAZE_HUNTER, "maze hunter style" },
1915 { MV_WHEN_PUSHED, "when pushed" },
1916 { MV_WHEN_DROPPED, "when dropped/thrown" },
1921 static struct ValueTextInfo options_move_direction[] =
1923 { MV_START_AUTOMATIC, "automatic" },
1924 { MV_START_LEFT, "left" },
1925 { MV_START_RIGHT, "right" },
1926 { MV_START_UP, "up" },
1927 { MV_START_DOWN, "down" },
1928 { MV_START_RANDOM, "random" },
1929 { MV_START_PREVIOUS, "previous" },
1934 static struct ValueTextInfo options_move_stepsize[] =
1936 { 0, "not moving" },
1941 { 16, "very fast" },
1942 { 32, "even faster" },
1947 static struct ValueTextInfo options_move_leave_type[] =
1949 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1950 { LEAVE_TYPE_LIMITED, "change it to" },
1955 static struct ValueTextInfo options_smash_targets[] =
1957 { EP_CAN_SMASH_PLAYER, "player" },
1959 { EP_CAN_SMASH_ENEMIES, "enemies" },
1961 { EP_CAN_SMASH_EVERYTHING, "everything" },
1966 static struct ValueTextInfo options_slippery_type[] =
1968 { SLIPPERY_ANY_RANDOM, "random" },
1969 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1970 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1971 { SLIPPERY_ONLY_LEFT, "only left" },
1972 { SLIPPERY_ONLY_RIGHT, "only right" },
1977 static struct ValueTextInfo options_deadliness[] =
1979 { EP_DONT_RUN_INTO, "running into" },
1980 { EP_DONT_COLLIDE_WITH, "colliding with" },
1981 { EP_DONT_GET_HIT_BY, "getting hit by" },
1982 { EP_DONT_TOUCH, "touching" },
1987 static struct ValueTextInfo options_explosion_type[] =
1989 { EXPLODES_3X3, "3x3" },
1990 { EXPLODES_CROSS, "3+3" },
1991 { EXPLODES_1X1, "1x1" },
1996 static struct ValueTextInfo options_time_units[] =
1999 { FRAMES_PER_SECOND, "seconds" },
2004 static struct ValueTextInfo options_change_direct_action[] =
2006 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2007 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2008 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2009 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2010 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2011 { CE_ENTERED_BY_PLAYER, "entered by player" },
2012 { CE_LEFT_BY_PLAYER, "left by player" },
2013 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2014 { CE_SWITCHED, "switched" },
2015 { CE_HITTING_SOMETHING, "hitting something" },
2016 { CE_HIT_BY_SOMETHING, "hit by something" },
2018 { CE_BLOCKED, "blocked" },
2020 { CE_IMPACT, "impact (on something)" },
2021 { CE_SMASHED, "smashed (from above)" },
2023 { CE_VALUE_CHANGES, "CE value changes" },
2024 { CE_SCORE_CHANGES, "CE score changes" },
2026 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2027 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2028 { CE_UNDEFINED, " " },
2029 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2030 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2031 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2032 { CE_UNDEFINED, " " },
2033 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2034 { CE_NEXT_TO_PLAYER, "next to player" },
2039 static struct ValueTextInfo options_change_other_action[] =
2041 { CE_PLAYER_TOUCHES_X, "player touches" },
2042 { CE_PLAYER_PRESSES_X, "player presses" },
2043 { CE_PLAYER_SWITCHES_X, "player switches" },
2044 { CE_PLAYER_SNAPS_X, "player snaps" },
2045 { CE_PLAYER_PUSHES_X, "player pushes" },
2046 { CE_PLAYER_ENTERS_X, "player enters" },
2047 { CE_PLAYER_LEAVES_X, "player leaves" },
2048 { CE_PLAYER_DIGS_X, "player digs" },
2049 { CE_PLAYER_COLLECTS_X, "player collects" },
2050 { CE_PLAYER_DROPS_X, "player drops/throws" },
2051 { CE_TOUCHING_X, "touching" },
2052 { CE_HITTING_X, "hitting" },
2053 { CE_DIGGING_X, "digging" },
2054 { CE_HIT_BY_X, "hit by" },
2055 { CE_SWITCH_OF_X, "switch of" },
2056 { CE_CHANGE_OF_X, "change by page of" },
2057 { CE_EXPLOSION_OF_X, "explosion of" },
2058 { CE_MOVE_OF_X, "move of" },
2059 { CE_CREATION_OF_X, "creation of" },
2060 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2061 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2062 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2063 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2064 { CE_UNDEFINED, " " },
2065 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2066 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2067 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2068 { CE_UNDEFINED, " " },
2069 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2070 { CE_PLAYER_NEXT_TO_X, "player next to" },
2071 { CE_NEXT_TO_X, "next to" },
2076 static struct ValueTextInfo options_change_trigger_side[] =
2078 { CH_SIDE_LEFT, "left" },
2079 { CH_SIDE_RIGHT, "right" },
2080 { CH_SIDE_TOP, "top" },
2081 { CH_SIDE_BOTTOM, "bottom" },
2082 { CH_SIDE_LEFT_RIGHT, "left/right" },
2083 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2084 { CH_SIDE_ANY, "any" },
2089 static struct ValueTextInfo options_change_trigger_player[] =
2091 { CH_PLAYER_1, "1" },
2092 { CH_PLAYER_2, "2" },
2093 { CH_PLAYER_3, "3" },
2094 { CH_PLAYER_4, "4" },
2095 { CH_PLAYER_ANY, "any" },
2100 static struct ValueTextInfo options_change_trigger_page[] =
2111 { (1u << 9), "10" },
2112 { (1u << 10), "11" },
2113 { (1u << 11), "12" },
2114 { (1u << 12), "13" },
2115 { (1u << 13), "14" },
2116 { (1u << 14), "15" },
2117 { (1u << 15), "16" },
2118 { (1u << 16), "17" },
2119 { (1u << 17), "18" },
2120 { (1u << 18), "19" },
2121 { (1u << 19), "20" },
2122 { (1u << 20), "21" },
2123 { (1u << 21), "22" },
2124 { (1u << 22), "23" },
2125 { (1u << 23), "24" },
2126 { (1u << 24), "25" },
2127 { (1u << 25), "26" },
2128 { (1u << 26), "27" },
2129 { (1u << 27), "28" },
2130 { (1u << 28), "29" },
2131 { (1u << 29), "30" },
2132 { (1u << 30), "31" },
2133 { (1u << 31), "32" },
2134 { CH_PAGE_ANY, "any" },
2139 static struct ValueTextInfo options_change_replace_when[] =
2141 { CP_WHEN_EMPTY, "empty" },
2142 { CP_WHEN_WALKABLE, "walkable" },
2143 { CP_WHEN_DIGGABLE, "diggable" },
2144 { CP_WHEN_COLLECTIBLE, "collectible" },
2145 { CP_WHEN_REMOVABLE, "removable" },
2146 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2151 static struct ValueTextInfo options_action_type[] =
2153 { CA_NO_ACTION, "no action" },
2154 { CA_UNDEFINED, " " },
2155 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2156 { CA_RESTART_LEVEL, "restart level" },
2157 { CA_SHOW_ENVELOPE, "show envelope" },
2158 { CA_SET_LEVEL_TIME, "set time" },
2159 { CA_SET_LEVEL_SCORE, "set score" },
2160 { CA_SET_LEVEL_GEMS, "set gems" },
2161 { CA_SET_LEVEL_WIND, "set wind dir." },
2162 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2163 { CA_UNDEFINED, " " },
2164 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2165 { CA_MOVE_PLAYER, "move player" },
2166 { CA_MOVE_PLAYER_NEW, "move player new" },
2167 { CA_EXIT_PLAYER, "exit player" },
2168 { CA_KILL_PLAYER, "kill player" },
2169 { CA_SET_PLAYER_KEYS, "set keys" },
2170 { CA_SET_PLAYER_SPEED, "set speed" },
2171 { CA_SET_PLAYER_SHIELD, "set shield" },
2172 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2173 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2174 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2175 { CA_UNDEFINED, " " },
2176 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2177 { CA_SET_CE_VALUE, "set CE value" },
2178 { CA_SET_CE_SCORE, "set CE score" },
2179 { CA_SET_CE_ARTWORK, "set CE artwork" },
2180 { CA_UNDEFINED, " " },
2181 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2182 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2187 static struct ValueTextInfo options_action_mode_none[] =
2189 { CA_MODE_UNDEFINED, " " },
2194 static struct ValueTextInfo options_action_mode_assign[] =
2196 { CA_MODE_SET, "=" },
2201 static struct ValueTextInfo options_action_mode_add_remove[] =
2203 { CA_MODE_ADD, "+" },
2204 { CA_MODE_SUBTRACT, "-" },
2209 static struct ValueTextInfo options_action_mode_calculate[] =
2211 { CA_MODE_SET, "=" },
2212 { CA_MODE_ADD, "+" },
2213 { CA_MODE_SUBTRACT, "-" },
2214 { CA_MODE_MULTIPLY, "*" },
2215 { CA_MODE_DIVIDE, "/" },
2216 { CA_MODE_MODULO, "%" },
2221 static struct ValueTextInfo options_action_arg_none[] =
2223 { CA_ARG_UNDEFINED, " " },
2228 static struct ValueTextInfo options_action_arg_player[] =
2230 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2231 { CA_ARG_PLAYER_1, "1" },
2232 { CA_ARG_PLAYER_2, "2" },
2233 { CA_ARG_PLAYER_3, "3" },
2234 { CA_ARG_PLAYER_4, "4" },
2235 { CA_ARG_PLAYER_ANY, "any" },
2236 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2237 { CA_ARG_PLAYER_ACTION, "action ->" },
2242 static struct ValueTextInfo options_action_arg_number[] =
2244 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2251 { CA_ARG_10, "10" },
2252 { CA_ARG_100, "100" },
2253 { CA_ARG_1000, "1000" },
2254 { CA_ARG_UNDEFINED, " " },
2255 { CA_ARG_NUMBER_MIN, "min" },
2256 { CA_ARG_NUMBER_MAX, "max" },
2257 { CA_ARG_UNDEFINED, " " },
2258 { CA_ARG_NUMBER_RESET, "reset" },
2259 { CA_ARG_UNDEFINED, " " },
2260 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2261 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2262 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2263 { CA_ARG_UNDEFINED, " " },
2264 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2265 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2266 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2267 { CA_ARG_UNDEFINED, " " },
2268 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2269 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2270 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2271 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2272 { CA_ARG_UNDEFINED, " " },
2273 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2274 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2275 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2276 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2281 static struct ValueTextInfo options_action_arg_value[] =
2283 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2290 { CA_ARG_10, "10" },
2291 { CA_ARG_100, "100" },
2292 { CA_ARG_1000, "1000" },
2293 { CA_ARG_UNDEFINED, " " },
2294 { CA_ARG_NUMBER_MIN, "min" },
2295 { CA_ARG_NUMBER_MAX, "max" },
2296 { CA_ARG_UNDEFINED, " " },
2297 { CA_ARG_NUMBER_RESET, "reset" },
2298 { CA_ARG_UNDEFINED, " " },
2299 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2300 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2301 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2302 { CA_ARG_UNDEFINED, " " },
2303 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2304 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2305 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2306 { CA_ARG_UNDEFINED, " " },
2307 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2308 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2309 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2310 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2311 { CA_ARG_UNDEFINED, " " },
2312 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2313 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2314 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2315 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2316 { CA_ARG_UNDEFINED, " " },
2317 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2318 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2319 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2320 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2325 static struct ValueTextInfo options_action_arg_envelope[] =
2327 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2332 { CA_ARG_UNDEFINED, " " },
2333 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2334 { CA_ARG_ELEMENT_TARGET, "target" },
2335 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2336 { CA_ARG_ELEMENT_ACTION, "action ->" },
2341 static struct ValueTextInfo options_action_arg_key[] =
2343 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2352 { CA_ARG_UNDEFINED, " " },
2353 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2354 { CA_ARG_ELEMENT_TARGET, "target" },
2355 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2356 { CA_ARG_ELEMENT_ACTION, "action ->" },
2361 static struct ValueTextInfo options_action_arg_speed[] =
2363 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2364 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2365 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2366 { CA_ARG_SPEED_SLOW, "slow" },
2367 { CA_ARG_SPEED_NORMAL, "normal" },
2368 { CA_ARG_SPEED_FAST, "fast" },
2369 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2370 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2371 { CA_ARG_UNDEFINED, " " },
2372 { CA_ARG_SPEED_SLOWER, "slower" },
2373 { CA_ARG_SPEED_FASTER, "faster" },
2374 { CA_ARG_UNDEFINED, " " },
2375 { CA_ARG_SPEED_RESET, "reset" },
2380 static struct ValueTextInfo options_action_arg_shield[] =
2382 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2383 { CA_ARG_SHIELD_OFF, "off" },
2384 { CA_ARG_SHIELD_NORMAL, "normal" },
2385 { CA_ARG_SHIELD_DEADLY, "deadly" },
2390 static struct ValueTextInfo options_action_arg_artwork[] =
2392 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2393 { CA_ARG_ELEMENT_TARGET, "target" },
2394 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2395 { CA_ARG_ELEMENT_ACTION, "action ->" },
2396 { CA_ARG_UNDEFINED, " " },
2397 { CA_ARG_ELEMENT_RESET, "reset" },
2402 static struct ValueTextInfo options_action_arg_gravity[] =
2404 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2405 { CA_ARG_GRAVITY_ON, "on" },
2406 { CA_ARG_GRAVITY_OFF, "off" },
2407 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2412 static struct ValueTextInfo options_action_arg_direction[] =
2414 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2415 { CA_ARG_DIRECTION_NONE, "none" },
2416 { CA_ARG_DIRECTION_LEFT, "left" },
2417 { CA_ARG_DIRECTION_RIGHT, "right" },
2418 { CA_ARG_DIRECTION_UP, "up" },
2419 { CA_ARG_DIRECTION_DOWN, "down" },
2420 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2421 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2426 static struct ValueTextInfo options_action_arg_scan_mode[] =
2428 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2429 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2430 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2435 static struct ValueTextInfo options_action_arg_inventory[] =
2437 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2438 { CA_ARG_ELEMENT_TARGET, "+ target" },
2439 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2440 { CA_ARG_ELEMENT_ACTION, "+ action" },
2441 { CA_ARG_UNDEFINED, " " },
2442 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2443 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2444 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2445 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2446 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2447 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2448 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2449 { CA_ARG_UNDEFINED, " " },
2450 { CA_ARG_INVENTORY_RESET, "reset" },
2455 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2456 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2461 static struct ValueTextInfo options_group_choice_mode[] =
2463 { ANIM_RANDOM, "random" },
2464 { ANIM_LOOP, "loop" },
2465 { ANIM_LINEAR, "linear" },
2466 { ANIM_PINGPONG, "pingpong" },
2467 { ANIM_PINGPONG2, "pingpong 2" },
2468 { ANIM_LEVEL_NR, "level number" },
2473 static struct ValueTextInfo *action_arg_modes[] =
2475 options_action_mode_none,
2476 options_action_mode_assign,
2477 options_action_mode_add_remove,
2478 options_action_mode_calculate,
2485 struct ValueTextInfo *options;
2487 action_arg_options[] =
2489 { CA_NO_ACTION, 0, options_action_arg_none, },
2490 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2491 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2492 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2493 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2494 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2495 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2496 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2497 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2498 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2499 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2500 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2501 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2502 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2503 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2504 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2505 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2506 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2507 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2508 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2509 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2510 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2519 int gadget_id_align;
2520 int size; // char size of selectbox or '-1' (dynamically determined)
2521 struct ValueTextInfo *options;
2523 char *text_above, *text_left, *text_right, *infotext;
2524 } selectbox_info[ED_NUM_SELECTBOX] =
2526 // ---------- level and editor settings -------------------------------------
2529 -1, ED_LEVEL_SETTINGS_YPOS(8),
2530 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2532 options_time_or_steps,
2533 &level.use_step_counter,
2534 NULL, NULL, "(0 => no limit)", "time or step limit"
2537 -1, ED_LEVEL_SETTINGS_YPOS(10),
2538 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2540 options_time_score_base,
2541 &level.time_score_base,
2542 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2545 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2546 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2548 options_game_engine_type,
2549 &level.game_engine_type,
2550 NULL, "game engine:", NULL, "game engine"
2553 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2554 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2556 options_levelset_save_mode,
2557 &levelset_save_mode,
2558 "Action:", NULL, NULL, "action when saving level set"
2561 // ---------- element settings: configure (several elements) ----------------
2564 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2565 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2567 options_wind_direction,
2568 &level.wind_direction_initial,
2569 NULL, "initial wind direction:", NULL, "initial wind direction"
2572 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2573 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2575 options_player_speed,
2576 &level.initial_player_stepsize[0],
2577 NULL, "initial player speed:", NULL, "initial player speed"
2580 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2581 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2583 options_group_choice_mode,
2584 &level.mm_ball_choice_mode,
2585 NULL, "choice type:", NULL, "type of content choice"
2588 // ---------- element settings: configure 1 (custom elements) ---------------
2591 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2592 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2594 options_access_type,
2595 &custom_element.access_type,
2596 NULL, NULL, NULL, "type of access to this field"
2599 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2600 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2602 options_access_layer,
2603 &custom_element.access_layer,
2604 NULL, NULL, NULL, "layer of access for this field"
2607 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2608 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2610 options_access_protected,
2611 &custom_element.access_protected,
2612 NULL, NULL, NULL, "protected access for this field"
2615 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2616 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2618 options_access_direction,
2619 &custom_element.access_direction,
2620 NULL, "from", NULL, "access direction for this field"
2623 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2624 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2626 options_walk_to_action,
2627 &custom_element.walk_to_action,
2628 NULL, NULL, NULL, "diggable/collectible/pushable"
2631 // ---------- element settings: configure 2 (custom elements) ---------------
2634 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2635 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2637 options_move_pattern,
2638 &custom_element.move_pattern,
2639 NULL, "can move", NULL, "element move pattern"
2642 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2643 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2645 options_move_direction,
2646 &custom_element.move_direction_initial,
2647 NULL, "starts moving", NULL, "initial element move direction"
2650 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2651 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2653 options_move_stepsize,
2654 &custom_element.move_stepsize,
2655 NULL, "move/fall speed", NULL, "speed of element movement"
2658 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2659 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2661 options_move_leave_type,
2662 &custom_element.move_leave_type,
2663 // left text with leading spaces to place gadget next to "can dig" gadget
2664 // (needed because drawing area gadgets created after selectbox gadgets)
2665 // NULL, "can dig: can", ":", "leave behind or change element"
2666 NULL, " can", ":", "leave behind or change element"
2669 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2670 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2672 options_smash_targets,
2673 &custom_element.smash_targets,
2674 NULL, "can smash", NULL, "elements that can be smashed"
2677 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2678 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2680 options_slippery_type,
2681 &custom_element.slippery_type,
2682 NULL, "slippery", NULL, "where other elements fall down"
2685 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2686 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2689 &custom_element.deadliness,
2690 NULL, "deadly when", NULL, "deadliness of element"
2693 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2694 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2696 options_explosion_type,
2697 &custom_element.explosion_type,
2698 NULL, "can explode", NULL, "explosion type"
2701 // ---------- element settings: advanced (custom elements) ------------------
2704 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2705 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2708 &custom_element_change.delay_frames,
2709 NULL, "delay time given in", NULL, "delay time units for change"
2712 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2713 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2715 options_change_direct_action,
2716 &custom_element_change.direct_action,
2717 NULL, NULL, NULL, "type of direct action"
2720 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2721 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2723 options_change_other_action,
2724 &custom_element_change.other_action,
2725 NULL, NULL, "element:", "type of other element action"
2728 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2729 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2731 options_change_trigger_side,
2732 &custom_element_change.trigger_side,
2733 NULL, "at", "side", "element side triggering change"
2736 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2737 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2739 options_change_trigger_player,
2740 &custom_element_change.trigger_player,
2741 NULL, "player:", " ", "player that causes change"
2744 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2745 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2747 options_change_trigger_page,
2748 &custom_element_change.trigger_page,
2749 NULL, "page:", NULL, "change page that causes change"
2752 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2753 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2755 options_change_replace_when,
2756 &custom_element_change.replace_when,
2757 NULL, "replace when", NULL, "which elements can be replaced"
2760 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2761 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2763 options_action_type,
2764 &custom_element_change.action_type,
2765 NULL, NULL, NULL, "action on specified condition"
2768 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2769 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2771 options_action_mode_none,
2772 &custom_element_change.action_mode,
2773 NULL, NULL, NULL, "action operator"
2776 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2777 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2779 options_action_arg_none,
2780 &custom_element_change.action_arg,
2781 NULL, NULL, NULL, "action parameter"
2784 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2785 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2787 options_change_page,
2788 &custom_element.current_change_page,
2789 NULL, NULL, NULL, "element change page"
2792 // ---------- element settings: configure (group elements) ------------------
2795 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2796 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2798 options_group_choice_mode,
2799 &group_element_info.choice_mode,
2800 NULL, "choice type:", NULL, "type of group element choice"
2808 int gadget_id_align;
2811 char *text_above, *text_left, *text_right, *infotext;
2812 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2814 // ---------- level and editor settings (tabs) ------------------------------
2817 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2818 GADGET_ID_LEVELCONFIG_LEVEL, GADGET_ID_NONE,
2820 NULL, NULL, NULL, "Configure level settings"
2824 GADGET_ID_LEVELCONFIG_LEVELSET, GADGET_ID_LEVELCONFIG_LEVEL,
2826 NULL, NULL, NULL, "Update this or create new level set"
2830 GADGET_ID_LEVELCONFIG_EDITOR, GADGET_ID_LEVELCONFIG_LEVELSET,
2832 NULL, NULL, NULL, "Configure editor settings"
2835 // ---------- element settings (tabs) ---------------------------------------
2838 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2839 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2841 NULL, NULL, NULL, "Show information about element"
2845 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2847 NULL, NULL, NULL, "Configure element properties"
2851 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2853 NULL, NULL, NULL, "Configure element properties, part 1"
2857 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2859 NULL, NULL, NULL, "Configure element properties, part 2"
2863 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2865 NULL, NULL, NULL, "Configure custom element change pages"
2868 // ---------- level and editor settings (buttons) ---------------------------
2871 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2872 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
2874 NULL, NULL, NULL, "Update or create level set"
2877 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2878 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2880 NULL, NULL, "this level as level template",
2881 "Save current settings as new template"
2884 // ---------- element settings (buttons) ------------------------------------
2888 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2890 NULL, " ", "As Template",
2891 "Save current settings as new template"
2895 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2897 NULL, NULL, NULL, "Add new change page"
2901 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2903 NULL, NULL, NULL, "Delete current change page"
2912 int gadget_id_align;
2913 char *text_left, *text_right, *infotext;
2914 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2917 IMG_EDITOR_COUNTER_DOWN,
2918 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2919 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2920 NULL, NULL, "select previous change page"
2923 IMG_EDITOR_COUNTER_UP,
2924 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2925 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2926 NULL, "change page", "select next change page"
2929 IMG_GFX_EDITOR_BUTTON_CP_COPY,
2930 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2931 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2932 " ", NULL, "copy settings from this change page"
2935 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
2936 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2937 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2938 NULL, NULL, "paste settings to this change page"
2945 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2952 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2955 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2956 GADGET_ID_SCROLL_UP,
2957 "scroll level editing area up"
2960 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2961 GADGET_ID_SCROLL_DOWN,
2962 "scroll level editing area down"
2965 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2966 GADGET_ID_SCROLL_LEFT,
2967 "scroll level editing area left"
2970 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2971 GADGET_ID_SCROLL_RIGHT,
2972 "scroll level editing area right"
2975 IMG_EDITOR_PALETTE_SCROLL_UP,
2976 GADGET_ID_SCROLL_LIST_UP,
2977 "scroll element list up ('Page Up')"
2980 IMG_EDITOR_PALETTE_SCROLL_DOWN,
2981 GADGET_ID_SCROLL_LIST_DOWN,
2982 "scroll element list down ('Page Down')"
2990 int wheel_x, wheel_y;
2991 int wheel_width, wheel_height;
2992 } scrollbar_pos[ED_NUM_SCROLLBARS];
3000 } scrollbar_info[ED_NUM_SCROLLBARS] =
3003 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3004 GD_TYPE_SCROLLBAR_HORIZONTAL,
3005 GADGET_ID_SCROLL_HORIZONTAL,
3006 "scroll level editing area horizontally"
3009 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3010 GD_TYPE_SCROLLBAR_VERTICAL,
3011 GADGET_ID_SCROLL_VERTICAL,
3012 "scroll level editing area vertically"
3015 IMG_EDITOR_PALETTE_SCROLLBAR,
3016 GD_TYPE_SCROLLBAR_VERTICAL,
3017 GADGET_ID_SCROLL_LIST_VERTICAL,
3018 "scroll element list vertically"
3027 int gadget_id_align;
3028 int radio_button_nr;
3031 char *text_left, *text_right, *infotext;
3032 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3035 -1, ED_LEVEL_SETTINGS_YPOS(0),
3036 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3037 RADIO_NR_RANDOM_ELEMENTS,
3038 &random_placement_method, RANDOM_USE_PERCENTAGE,
3039 " ", "percentage", "use percentage for random elements"
3042 -1, ED_LEVEL_SETTINGS_YPOS(0),
3043 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3044 RADIO_NR_RANDOM_ELEMENTS,
3045 &random_placement_method, RANDOM_USE_QUANTITY,
3046 " ", "quantity", "use quantity for random elements"
3054 int gadget_id_align;
3056 char *text_above, *text_left, *text_right, *infotext;
3057 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3059 // ---------- level and editor settings -------------------------------------
3062 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3063 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3064 &level.auto_count_gems,
3066 "automatically count gems needed", "set counter to number of gems"
3069 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3070 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3071 &level.rate_time_over_score,
3073 "rate time/steps used over score", "sort high scores by playing time/steps"
3076 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3077 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3078 &levelset_use_levelset_artwork,
3080 "use current custom artwork", "use custom artwork of this level set"
3083 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3084 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3085 &levelset_copy_level_template,
3087 "copy current level template", "copy level template of this level set"
3090 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3091 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3092 &random_placement_background_restricted,
3094 "restrict random placement to:", "set random placement restriction"
3097 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3098 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3099 &setup.editor.use_template_for_new_levels,
3100 "Template for new levels and CE/GE:", NULL,
3101 "use template for new levels", "use template for level properties"
3104 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3105 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3106 &level.use_custom_template,
3108 "use template for custom elements", "use template for custom properties"
3111 // ---------- element settings: configure (various elements) ----------------
3114 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3115 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3116 &stick_element_properties_window,
3118 "stick this screen to edit content","stick this screen to edit content"
3121 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3122 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3123 &level.em_slippery_gems,
3125 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3128 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3129 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3130 &level.em_explodes_by_fire,
3132 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3135 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3136 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3137 &level.use_spring_bug,
3139 "use spring pushing bug", "use odd spring pushing behaviour"
3142 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3143 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3144 &level.use_time_orb_bug,
3146 "use time orb bug", "use odd time orb behaviour"
3149 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3150 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3151 &level.use_life_bugs,
3153 "use buggy element behaviour", "use odd (historic) element behaviour"
3156 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3157 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3160 "create single random element", "only create one element from content"
3163 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3164 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3165 &level.ball_active_initial,
3167 "magic ball initially activated", "activate magic ball after level start"
3170 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3171 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3172 &level.grow_into_diggable,
3174 "can grow into anything diggable", "grow into more than just sand"
3177 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3178 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3179 &level.sb_fields_needed,
3181 "all fields need to be filled", "require all SB fields to be solved"
3184 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3185 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3186 &level.sb_objects_needed,
3188 "all objects need to be placed", "require all SB objects to be solved"
3191 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3192 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3193 &level.auto_exit_sokoban,
3195 "exit level if all tasks solved", "automatically finish Sokoban levels"
3198 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3199 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3200 &level.solved_by_one_player,
3202 "only one player must enter exit", "level solved by first player in exit"
3205 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3206 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3207 &level.finish_dig_collect,
3209 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3212 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3213 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3214 &level.keep_walkable_ce,
3216 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3219 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3220 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3221 &level.continuous_snapping,
3223 "continuous snapping", "use snapping without releasing key"
3226 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3227 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3228 &level.block_snap_field,
3230 "block snapped field when snapping", "use snapping delay to show animation"
3233 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3234 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3235 &level.block_last_field,
3237 "block last field when moving", "player blocks last field when moving"
3240 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3241 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3242 &level.sp_block_last_field,
3244 "block last field when moving", "player blocks last field when moving"
3247 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3248 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3249 &level.instant_relocation,
3251 "no scrolling when relocating", "player gets relocated without delay"
3254 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3255 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3256 &level.shifted_relocation,
3258 "no centering when relocating", "level not centered after relocation"
3261 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3262 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3263 &level.lazy_relocation,
3265 "only redraw off-screen relocation","no redraw if relocation target visible"
3268 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3269 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3270 &level.use_start_element[0],
3272 "use level start element:", "start level at this element's position"
3275 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3276 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3277 &level.use_artwork_element[0],
3279 "use artwork from element:", "use player artwork from other element"
3282 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3283 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3284 &level.use_explosion_element[0],
3286 "use explosion from element:", "use explosion properties from element"
3289 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3290 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3291 &level.initial_player_gravity[0],
3293 "use initial gravity", "set initial player gravity"
3296 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3297 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3298 &level.use_initial_inventory[0],
3300 "use initial inventory:", "use collected elements on level start"
3303 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3304 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3305 &level.can_pass_to_walkable,
3307 "can pass to walkable element", "player can pass to empty or walkable"
3310 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3311 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3312 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3314 "can fall into acid (with gravity)","player can fall into acid pool"
3317 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3318 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3319 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3321 "can move into acid", "element can move into acid pool"
3324 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3325 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3326 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3328 "deadly when colliding with", "element is deadly when hitting player"
3331 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3332 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3333 &level.envelope[0].autowrap,
3335 "auto-wrap", "automatically wrap envelope text"
3338 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3339 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3340 &level.envelope[0].centered,
3342 "centered", "automatically center envelope text"
3345 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3346 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3347 &level.mm_laser_red,
3348 "choose color components for laser:", NULL,
3349 "red", "use red color components in laser"
3352 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3353 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3354 &level.mm_laser_green,
3356 "green", "use green color components in laser"
3359 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3360 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3361 &level.mm_laser_blue,
3363 "blue", "use blue color components in laser"
3366 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3367 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3368 &level.df_laser_red,
3369 "choose color components for laser:", NULL,
3370 "red", "use red color components in laser"
3373 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3374 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3375 &level.df_laser_green,
3377 "green", "use green color components in laser"
3380 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3381 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3382 &level.df_laser_blue,
3384 "blue", "use blue color components in laser"
3387 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3388 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3389 &level.rotate_mm_ball_content,
3391 "randomly rotate created content", "randomly rotate newly created content"
3394 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3395 GADGET_ID_EXPLODE_MM_BALL, GADGET_ID_NONE,
3396 &level.explode_mm_ball,
3398 "explode ball instead of melting", "use explosion to release ball content"
3401 // ---------- element settings: configure 1 (custom elements) ---------------
3404 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3405 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3406 &custom_element.use_gfx_element,
3408 "use graphic of element:", "use existing element graphic"
3411 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3412 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3413 &level.use_custom_template,
3415 "use template", "use template for custom properties"
3418 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3419 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3420 &custom_element_properties[EP_ACCESSIBLE],
3422 NULL, "player can walk to or pass this field"
3425 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3426 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3427 &custom_element_properties[EP_GRAVITY_REACHABLE],
3429 "reachable despite gravity", "player can walk/dig despite gravity"
3432 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3433 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3434 &custom_element.use_last_ce_value,
3436 "use last CE value after change", "use last CE value after change"
3439 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3440 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3441 &custom_element_properties[EP_WALK_TO_OBJECT],
3443 NULL, "player can dig/collect/push element"
3446 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3447 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3448 &custom_element_properties[EP_INDESTRUCTIBLE],
3450 "indestructible", "element is indestructible"
3453 // ---------- element settings: configure 2 (custom elements) ---------------
3456 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3457 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3458 &custom_element_properties[EP_CAN_MOVE],
3460 NULL, "element can move with some pattern"
3463 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3464 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3465 &custom_element_properties[EP_CAN_FALL],
3467 "can fall", "element can fall down"
3470 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3471 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3472 &custom_element_properties[EP_CAN_SMASH],
3474 NULL, "element can smash other elements"
3477 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3478 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3479 &custom_element_properties[EP_SLIPPERY],
3481 NULL, "other elements can fall down from it"
3484 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3485 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3486 &custom_element_properties[EP_DEADLY],
3488 NULL, "element can kill the player"
3491 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3492 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3493 &custom_element_properties[EP_CAN_EXPLODE],
3495 NULL, "element can explode"
3498 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3499 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3500 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3502 "by fire", "element can explode by fire/explosion"
3505 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3506 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3507 &custom_element_properties[EP_EXPLODES_SMASHED],
3509 "smashed", "element can explode when smashed"
3512 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3513 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3514 &custom_element_properties[EP_EXPLODES_IMPACT],
3516 "impact", "element can explode on impact"
3519 // ---------- element settings: advanced (custom elements) ------------------
3522 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3523 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3524 &custom_element_change.can_change,
3526 "element changes to:", "change element on specified condition"
3529 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3530 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3531 &custom_element_change_events[CE_DELAY],
3533 NULL, "element changes after delay"
3536 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3537 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3538 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3540 NULL, "element changes by direct action"
3543 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3544 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3545 &custom_element_change_events[CE_BY_OTHER_ACTION],
3547 NULL, "element changes by other element"
3550 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3551 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3552 &custom_element_change.explode,
3554 "explode instead of change", "element explodes instead of change"
3557 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3558 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3559 &custom_element_change.use_target_content,
3561 "use extended change target:", "element changes to more elements"
3564 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3565 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3566 &custom_element_change.only_if_complete,
3568 "replace all or nothing", "only replace when all can be changed"
3571 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3572 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3573 &custom_element_change.use_random_replace,
3575 NULL, "use percentage for random replace"
3578 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3579 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3580 &custom_element_change.has_action,
3582 NULL, "execute action on specified condition"
3589 int xoffset, yoffset;
3591 int gadget_id_align;
3593 int area_xsize, area_ysize;
3594 char *text_left, *text_right, *text_above, *text_below, *infotext;
3595 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3597 // ---------- level playfield content ---------------------------------------
3602 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3604 -1, -1, // these values are not constant, but can change at runtime
3605 NULL, NULL, NULL, NULL, NULL
3608 // ---------- yam yam content -----------------------------------------------
3611 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3612 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3613 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3614 &level.yamyam_content[0].e[0][0], 3, 3,
3615 NULL, NULL, NULL, "1", NULL
3618 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3619 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3620 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3621 &level.yamyam_content[1].e[0][0], 3, 3,
3622 NULL, NULL, NULL, "2", NULL
3625 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3626 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3627 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3628 &level.yamyam_content[2].e[0][0], 3, 3,
3629 NULL, NULL, NULL, "3", NULL
3632 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3633 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3634 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3635 &level.yamyam_content[3].e[0][0], 3, 3,
3636 NULL, NULL, NULL, "4", NULL
3639 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3640 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3641 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3642 &level.yamyam_content[4].e[0][0], 3, 3,
3643 NULL, NULL, NULL, "5", NULL
3646 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3647 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3648 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3649 &level.yamyam_content[5].e[0][0], 3, 3,
3650 NULL, NULL, NULL, "6", NULL
3653 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3654 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3655 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3656 &level.yamyam_content[6].e[0][0], 3, 3,
3657 NULL, NULL, NULL, "7", NULL
3660 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3661 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3662 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3663 &level.yamyam_content[7].e[0][0], 3, 3,
3664 NULL, NULL, NULL, "8", NULL
3667 // ---------- magic ball content --------------------------------------------
3670 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3671 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3672 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3673 &level.ball_content[0].e[0][0], 3, 3,
3674 NULL, NULL, NULL, "1", NULL
3677 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3678 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3679 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3680 &level.ball_content[1].e[0][0], 3, 3,
3681 NULL, NULL, NULL, "2", NULL
3684 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3685 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3686 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3687 &level.ball_content[2].e[0][0], 3, 3,
3688 NULL, NULL, NULL, "3", NULL
3691 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3692 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3693 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3694 &level.ball_content[3].e[0][0], 3, 3,
3695 NULL, NULL, NULL, "4", NULL
3698 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3699 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3700 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3701 &level.ball_content[4].e[0][0], 3, 3,
3702 NULL, NULL, NULL, "5", NULL
3705 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3706 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3707 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3708 &level.ball_content[5].e[0][0], 3, 3,
3709 NULL, NULL, NULL, "6", NULL
3712 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3713 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3714 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3715 &level.ball_content[6].e[0][0], 3, 3,
3716 NULL, NULL, NULL, "7", NULL
3719 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3720 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3721 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3722 &level.ball_content[7].e[0][0], 3, 3,
3723 NULL, NULL, NULL, "8", NULL
3726 // ---------- android content -----------------------------------------------
3729 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
3730 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3731 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3732 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3733 NULL, NULL, "elements:", NULL, "elements android can clone"
3736 // ---------- amoeba content ------------------------------------------------
3739 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3740 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3741 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3742 &level.amoeba_content, 1, 1,
3743 "content:", NULL, NULL, NULL, "amoeba content"
3746 // ---------- level start element -------------------------------------------
3749 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3750 0, ED_AREA_1X1_SETTINGS_YOFF,
3751 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3752 &level.start_element[0], 1, 1,
3753 NULL, NULL, NULL, NULL, "level start element"
3756 // ---------- player artwork element ----------------------------------------
3759 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3760 0, ED_AREA_1X1_SETTINGS_YOFF,
3761 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3762 &level.artwork_element[0], 1, 1,
3763 NULL, NULL, NULL, NULL, "element for player artwork"
3766 // ---------- player explosion element --------------------------------------
3769 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
3770 0, ED_AREA_1X1_SETTINGS_YOFF,
3771 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3772 &level.explosion_element[0], 1, 1,
3773 NULL, NULL, NULL, NULL, "element for player explosion"
3776 // ---------- player initial inventory --------------------------------------
3779 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3780 0, ED_AREA_1X1_SETTINGS_YOFF,
3781 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3782 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3783 NULL, NULL, NULL, NULL, "content for initial inventory"
3786 // ---------- gray ball content -----------------------------------------
3789 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3790 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3791 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
3792 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
3793 "content:", NULL, NULL, NULL, "content for gray ball"
3796 // ---------- element settings: configure 1 (custom elements) ---------------
3798 // ---------- custom graphic ------------------------------------------------
3801 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3802 0, ED_AREA_1X1_SETTINGS_YOFF,
3803 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3804 &custom_element.gfx_element_initial, 1, 1,
3805 NULL, NULL, NULL, NULL, "custom graphic element"
3808 // ---------- element settings: configure 2 (custom elements) ---------------
3810 // ---------- custom content (when exploding) -------------------------------
3813 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
3814 0, ED_AREA_3X3_SETTINGS_YOFF,
3815 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
3816 &custom_element.content.e[0][0], 3, 3,
3817 "content:", NULL, NULL, NULL, NULL
3820 // ---------- custom enter and leave element (when moving) ------------------
3823 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3824 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3825 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3826 &custom_element.move_enter_element, 1, 1,
3827 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
3830 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3831 0, ED_AREA_1X1_SETTINGS_YOFF,
3832 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3833 &custom_element.move_leave_element, 1, 1,
3834 NULL, NULL, NULL, NULL, "element that will be left behind"
3837 // ---------- element settings: advanced (custom elements) ------------------
3839 // ---------- custom change target ------------------------------------------
3842 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3843 0, ED_AREA_1X1_SETTINGS_YOFF,
3844 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3845 &custom_element_change.target_element, 1, 1,
3846 NULL, "after/when:", NULL, NULL, "new target element after change"
3849 // ---------- custom change content (extended change target) ----------------
3852 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3853 0, ED_AREA_3X3_SETTINGS_YOFF,
3854 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
3855 &custom_element_change.target_content.e[0][0], 3, 3,
3856 NULL, NULL, NULL, NULL, "new extended elements after change"
3859 // ---------- custom change trigger (element causing change) ----------------
3862 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3863 0, ED_AREA_1X1_SETTINGS_YOFF,
3864 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3865 &custom_element_change.initial_trigger_element, 1, 1,
3866 NULL, NULL, NULL, NULL, "other element triggering change"
3869 // ---------- custom change action (element used for action) ----------------
3872 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3873 0, ED_AREA_1X1_SETTINGS_YOFF,
3874 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3875 &custom_element_change.action_element, 1, 1,
3876 NULL, NULL, NULL, NULL, "element used as action parameter"
3879 // ---------- group element content -----------------------------------------
3882 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3883 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3884 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3885 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3886 "content:", NULL, NULL, NULL, NULL
3889 // ---------- random background (for random painting) -----------------------
3892 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
3893 0, ED_AREA_1X1_LSETTINGS_YOFF,
3894 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3895 &random_placement_background_element, 1, 1,
3896 NULL, NULL, NULL, NULL, "random placement background"
3901 // ----------------------------------------------------------------------------
3902 // some internally used variables
3903 // ----------------------------------------------------------------------------
3905 // maximal size of level editor drawing area
3906 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3908 // actual size of level editor drawing area
3909 static int ed_fieldx, ed_fieldy;
3911 // actual position of level editor drawing area in level playfield
3912 static int level_xpos = -1, level_ypos = -1;
3914 // actual tile size used to display playfield drawing area
3915 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3916 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
3918 #define IN_ED_FIELD(x, y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3920 // drawing elements on the three mouse buttons
3921 static int new_element1 = EL_WALL;
3922 static int new_element2 = EL_EMPTY;
3923 static int new_element3 = EL_SAND;
3925 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3926 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3927 (button) == 2 ? new_element2 : \
3928 (button) == 3 ? new_element3 : EL_EMPTY)
3930 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
3932 static int use_permanent_palette = TRUE;
3934 #define PX (use_permanent_palette ? DX : SX)
3935 #define PY (use_permanent_palette ? DY : SY)
3936 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
3937 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
3939 // forward declaration for internal use
3940 static void CopyBrushToCursor(int, int);
3941 static void DeleteBrushFromCursor(void);
3942 static void ModifyEditorCounterValue(int, int);
3943 static void ModifyEditorCounterLimits(int, int, int);
3944 static void ModifyEditorSelectboxValue(int, int);
3945 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3946 static void ModifyEditorDrawingArea(int, int, int);
3947 static void ModifyEditorElementList(void);
3948 static void AdjustElementListScrollbar(void);
3949 static void RedrawDrawingElements(void);
3950 static void DrawDrawingWindowExt(boolean);
3951 static void DrawDrawingWindow(void);
3952 static void DrawLevelConfigWindow(void);
3953 static void DrawPropertiesWindow(void);
3954 static void DrawPaletteWindow(void);
3955 static void UpdateCustomElementGraphicGadgets(void);
3956 static boolean checkPropertiesConfig(int);
3957 static void SetAutomaticNumberOfGemsNeeded(void);
3958 static void ClearEditorGadgetInfoText(void);
3959 static void CopyLevelToUndoBuffer(int);
3960 static void HandleDrawingAreas(struct GadgetInfo *);
3961 static void HandleCounterButtons(struct GadgetInfo *);
3962 static void HandleTextInputGadgets(struct GadgetInfo *);
3963 static void HandleTextAreaGadgets(struct GadgetInfo *);
3964 static void HandleSelectboxGadgets(struct GadgetInfo *);
3965 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3966 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3967 static void HandleRadiobuttons(struct GadgetInfo *);
3968 static void HandleCheckbuttons(struct GadgetInfo *);
3969 static void HandleControlButtons(struct GadgetInfo *);
3970 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3971 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3972 static boolean AskToCopyAndModifyLevelTemplate(void);
3973 static boolean getDrawModeHiRes(void);
3974 static int getTabulatorBarWidth(void);
3975 static int getTabulatorBarHeight(void);
3976 static Pixel getTabulatorBarColor(void);
3977 static int numHiresTiles(int);
3979 static int num_editor_gadgets = 0; // dynamically determined
3981 static struct GadgetInfo **level_editor_gadget = NULL;
3982 static int *right_gadget_border = NULL;
3984 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3985 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3986 static boolean draw_with_brush = FALSE;
3987 static int properties_element = 0;
3989 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3990 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3991 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3992 static int undo_buffer_position = 0;
3993 static int undo_buffer_steps = 0;
3994 static int redo_buffer_steps = 0;
3996 static int edit_mode;
3997 static int edit_mode_levelconfig;
3998 static int edit_mode_properties;
4000 static int element_shift = 0;
4002 static int editor_el_players[] =
4009 static int *editor_el_players_ptr = editor_el_players;
4010 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4012 static int editor_hl_boulderdash[] =
4014 EL_INTERNAL_CASCADE_BD_ACTIVE,
4020 static int editor_el_boulderdash[] =
4029 EL_BD_EXPANDABLE_WALL,
4037 EL_BD_BUTTERFLY_LEFT,
4039 EL_BD_BUTTERFLY_RIGHT,
4040 EL_BD_FIREFLY_RIGHT,
4043 EL_BD_BUTTERFLY_DOWN,
4047 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4048 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4049 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4050 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4052 static int editor_hl_boulderdash_native[] =
4054 EL_INTERNAL_CASCADE_BD_NATIVE_ACTIVE,
4060 static int editor_el_boulderdash_native[] =
4067 EL_BD_SAND_SLOPED_UP_RIGHT,
4068 EL_BD_SAND_SLOPED_UP_LEFT,
4069 EL_BD_SAND_SLOPED_DOWN_LEFT,
4070 EL_BD_SAND_SLOPED_DOWN_RIGHT,
4072 EL_BD_WALL_SLOPED_UP_RIGHT,
4073 EL_BD_WALL_SLOPED_UP_LEFT,
4074 EL_BD_WALL_SLOPED_DOWN_LEFT,
4075 EL_BD_WALL_SLOPED_DOWN_RIGHT,
4078 EL_BD_WALL_NON_SLOPED,
4084 EL_BD_INVISIBLE_EXIT_CLOSED,
4085 EL_BD_INVISIBLE_EXIT_OPEN,
4087 EL_BD_STEELWALL_SLOPED_UP_RIGHT,
4088 EL_BD_STEELWALL_SLOPED_UP_LEFT,
4089 EL_BD_STEELWALL_SLOPED_DOWN_LEFT,
4090 EL_BD_STEELWALL_SLOPED_DOWN_RIGHT,
4093 EL_BD_STEELWALL_EXPLODABLE,
4094 EL_BD_STEELWALL_DIGGABLE,
4095 EL_BD_WALL_DIGGABLE,
4102 EL_BD_FLYING_DIAMOND,
4104 EL_BD_BLADDER_SPENDER,
4107 EL_BD_EXPANDABLE_WALL_HORIZONTAL,
4108 EL_BD_EXPANDABLE_WALL_VERTICAL,
4109 EL_BD_EXPANDABLE_WALL_ANY,
4110 EL_BD_CREATURE_SWITCH,
4112 EL_BD_EXPANDABLE_STEELWALL_HORIZONTAL,
4113 EL_BD_EXPANDABLE_STEELWALL_VERTICAL,
4114 EL_BD_EXPANDABLE_STEELWALL_ANY,
4115 EL_BD_EXPANDABLE_WALL_SWITCH_HORIZONTAL,
4117 EL_BD_BITER_SWITCH_1,
4118 EL_BD_REPLICATOR_SWITCH,
4119 EL_BD_CONVEYOR_SWITCH,
4120 EL_BD_CONVEYOR_DIR_SWITCH_RIGHT,
4129 EL_BD_DIAMOND_GLUED,
4132 EL_BD_TRAPPED_DIAMOND,
4152 EL_BD_GRAVITY_SWITCH,
4153 EL_BD_PNEUMATIC_HAMMER,
4162 EL_BD_CONVEYOR_LEFT,
4163 EL_BD_CONVEYOR_RIGHT,
4184 EL_BD_FIREFLY_RIGHT,
4187 EL_BD_FIREFLY_2_LEFT,
4189 EL_BD_FIREFLY_2_RIGHT,
4190 EL_BD_FIREFLY_2_DOWN,
4192 EL_BD_BUTTERFLY_LEFT,
4194 EL_BD_BUTTERFLY_RIGHT,
4195 EL_BD_BUTTERFLY_DOWN,
4197 EL_BD_BUTTERFLY_2_LEFT,
4198 EL_BD_BUTTERFLY_2_UP,
4199 EL_BD_BUTTERFLY_2_RIGHT,
4200 EL_BD_BUTTERFLY_2_DOWN,
4202 EL_BD_STONEFLY_LEFT,
4204 EL_BD_STONEFLY_RIGHT,
4205 EL_BD_STONEFLY_DOWN,
4212 EL_BD_DRAGONFLY_LEFT,
4214 EL_BD_DRAGONFLY_RIGHT,
4215 EL_BD_DRAGONFLY_DOWN,
4218 EL_BD_PLAYER_WITH_BOMB,
4220 EL_BD_PLAYER_STIRRING,
4222 static int *editor_hl_boulderdash_native_ptr = editor_hl_boulderdash_native;
4223 static int *editor_el_boulderdash_native_ptr = editor_el_boulderdash_native;
4224 static int num_editor_hl_boulderdash_native = ARRAY_SIZE(editor_hl_boulderdash_native);
4225 static int num_editor_el_boulderdash_native = ARRAY_SIZE(editor_el_boulderdash_native);
4227 static int editor_hl_emerald_mine[] =
4229 EL_INTERNAL_CASCADE_EM_ACTIVE,
4235 static int editor_el_emerald_mine[] =
4253 EL_EM_DYNAMITE_ACTIVE,
4272 EL_ACID_POOL_TOPLEFT,
4274 EL_ACID_POOL_TOPRIGHT,
4277 EL_ACID_POOL_BOTTOMLEFT,
4278 EL_ACID_POOL_BOTTOM,
4279 EL_ACID_POOL_BOTTOMRIGHT,
4297 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4298 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4299 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4300 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4302 static int editor_hl_emerald_mine_club[] =
4304 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4310 static int editor_el_emerald_mine_club[] =
4337 EL_EMC_WALL_SLIPPERY_1,
4338 EL_EMC_WALL_SLIPPERY_2,
4339 EL_EMC_WALL_SLIPPERY_3,
4340 EL_EMC_WALL_SLIPPERY_4,
4363 EL_EMC_MAGIC_BALL_SWITCH,
4370 EL_EMC_SPRING_BUMPER,
4374 EL_BALLOON_SWITCH_UP,
4375 EL_BALLOON_SWITCH_ANY,
4378 EL_BALLOON_SWITCH_LEFT,
4380 EL_BALLOON_SWITCH_RIGHT,
4384 EL_BALLOON_SWITCH_DOWN,
4385 EL_BALLOON_SWITCH_NONE,
4387 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4388 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4389 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4390 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4392 static int editor_hl_rnd[] =
4394 EL_INTERNAL_CASCADE_RND_ACTIVE,
4400 static int editor_el_rnd[] =
4403 EL_DYNAMITE_ACTIVE, // RND
4437 EL_WALL_EMERALD_YELLOW,
4438 EL_WALL_EMERALD_RED,
4439 EL_WALL_EMERALD_PURPLE,
4457 EL_DYNABOMB_INCREASE_NUMBER,
4458 EL_DYNABOMB_INCREASE_SIZE,
4459 EL_DYNABOMB_INCREASE_POWER,
4479 EL_INVISIBLE_STEELWALL,
4483 EL_EXPANDABLE_WALL_HORIZONTAL,
4484 EL_EXPANDABLE_WALL_VERTICAL,
4485 EL_EXPANDABLE_WALL_ANY,
4487 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4488 static int *editor_el_rnd_ptr = editor_el_rnd;
4489 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4490 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4492 static int editor_hl_sokoban[] =
4494 EL_INTERNAL_CASCADE_SB_ACTIVE,
4500 static int editor_el_sokoban[] =
4503 EL_SOKOBAN_FIELD_EMPTY,
4504 EL_SOKOBAN_FIELD_FULL,
4505 EL_SOKOBAN_FIELD_PLAYER,
4507 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4508 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4509 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4510 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4512 static int editor_hl_supaplex[] =
4514 EL_INTERNAL_CASCADE_SP_ACTIVE,
4520 static int editor_el_supaplex[] =
4538 EL_SP_PORT_HORIZONTAL,
4539 EL_SP_PORT_VERTICAL,
4547 EL_SP_GRAVITY_PORT_LEFT,
4548 EL_SP_GRAVITY_PORT_RIGHT,
4549 EL_SP_GRAVITY_PORT_UP,
4550 EL_SP_GRAVITY_PORT_DOWN,
4552 EL_SP_GRAVITY_ON_PORT_LEFT,
4553 EL_SP_GRAVITY_ON_PORT_RIGHT,
4554 EL_SP_GRAVITY_ON_PORT_UP,
4555 EL_SP_GRAVITY_ON_PORT_DOWN,
4557 EL_SP_GRAVITY_OFF_PORT_LEFT,
4558 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4559 EL_SP_GRAVITY_OFF_PORT_UP,
4560 EL_SP_GRAVITY_OFF_PORT_DOWN,
4562 EL_SP_HARDWARE_GRAY,
4563 EL_SP_HARDWARE_GREEN,
4564 EL_SP_HARDWARE_BLUE,
4567 EL_SP_HARDWARE_BASE_1,
4568 EL_SP_HARDWARE_BASE_2,
4569 EL_SP_HARDWARE_BASE_3,
4570 EL_SP_HARDWARE_BASE_4,
4572 EL_SP_HARDWARE_BASE_5,
4573 EL_SP_HARDWARE_BASE_6,
4574 EL_SP_HARDWARE_YELLOW,
4582 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4583 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4584 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4585 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4587 static int editor_hl_diamond_caves[] =
4589 EL_INTERNAL_CASCADE_DC_ACTIVE,
4595 static int editor_el_diamond_caves[] =
4597 EL_EM_STEEL_EXIT_CLOSED, // DC2
4598 EL_EM_STEEL_EXIT_OPEN, // DC2
4599 EL_WALL_EMERALD, // DC2
4600 EL_WALL_DIAMOND, // DC2
4607 EL_CONVEYOR_BELT_1_LEFT,
4608 EL_CONVEYOR_BELT_1_MIDDLE,
4609 EL_CONVEYOR_BELT_1_RIGHT,
4610 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4612 EL_CONVEYOR_BELT_2_LEFT,
4613 EL_CONVEYOR_BELT_2_MIDDLE,
4614 EL_CONVEYOR_BELT_2_RIGHT,
4615 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4617 EL_CONVEYOR_BELT_3_LEFT,
4618 EL_CONVEYOR_BELT_3_MIDDLE,
4619 EL_CONVEYOR_BELT_3_RIGHT,
4620 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4622 EL_CONVEYOR_BELT_4_LEFT,
4623 EL_CONVEYOR_BELT_4_MIDDLE,
4624 EL_CONVEYOR_BELT_4_RIGHT,
4625 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4627 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4628 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4629 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4630 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4632 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4633 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4634 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4635 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4640 EL_DC_TIMEGATE_SWITCH,
4642 EL_SWITCHGATE_CLOSED,
4644 EL_SWITCHGATE_SWITCH_UP,
4645 EL_SWITCHGATE_SWITCH_DOWN,
4648 EL_LIGHT_SWITCH_ACTIVE,
4649 EL_DC_SWITCHGATE_SWITCH_UP,
4650 EL_DC_SWITCHGATE_SWITCH_DOWN,
4652 EL_STEEL_EXIT_CLOSED,
4654 EL_STEELWALL_SLIPPERY,
4657 EL_QUICKSAND_FAST_EMPTY,
4658 EL_QUICKSAND_FAST_FULL,
4672 EL_SIGN_RADIOACTIVITY,
4678 EL_SIGN_ENTRY_FORBIDDEN,
4679 EL_SIGN_EMERGENCY_EXIT,
4704 EL_DC_STEELWALL_2_SINGLE,
4705 EL_DC_STEELWALL_2_TOP,
4706 EL_SIGN_EXCLAMATION,
4709 EL_DC_STEELWALL_2_LEFT,
4710 EL_DC_STEELWALL_2_MIDDLE,
4711 EL_DC_STEELWALL_2_HORIZONTAL,
4712 EL_DC_STEELWALL_2_RIGHT,
4714 EL_DC_STEELWALL_1_TOPLEFT,
4715 EL_DC_STEELWALL_2_VERTICAL,
4716 EL_DC_STEELWALL_1_TOPRIGHT,
4719 EL_DC_STEELWALL_1_VERTICAL,
4720 EL_DC_STEELWALL_2_BOTTOM,
4722 EL_DC_GATE_WHITE_GRAY,
4724 EL_DC_STEELWALL_1_BOTTOMLEFT,
4725 EL_DC_STEELWALL_1_HORIZONTAL,
4726 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4727 EL_DC_GATE_FAKE_GRAY,
4729 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4730 EL_DC_STEELWALL_1_BOTTOM,
4731 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
4732 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
4734 EL_DC_STEELWALL_1_RIGHT,
4736 EL_DC_STEELWALL_1_LEFT,
4737 EL_EXPANDABLE_STEELWALL_VERTICAL,
4739 EL_DC_STEELWALL_1_TOPRIGHT_2,
4740 EL_DC_STEELWALL_1_TOP,
4741 EL_DC_STEELWALL_1_TOPLEFT_2,
4742 EL_EXPANDABLE_STEELWALL_ANY,
4744 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
4745 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
4746 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
4747 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
4749 static int editor_hl_dx_boulderdash[] =
4751 EL_INTERNAL_CASCADE_DX_ACTIVE,
4757 static int editor_el_dx_boulderdash[] =
4761 EL_TUBE_HORIZONTAL_DOWN,
4765 EL_TUBE_VERTICAL_RIGHT,
4767 EL_TUBE_VERTICAL_LEFT,
4771 EL_TUBE_HORIZONTAL_UP,
4779 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
4780 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
4781 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
4782 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
4784 static int editor_hl_mirror_magic[] =
4786 EL_INTERNAL_CASCADE_MM_ACTIVE,
4792 static int editor_el_mirror_magic[] =
4794 EL_MM_MCDUFFIN_RIGHT,
4796 EL_MM_MCDUFFIN_LEFT,
4797 EL_MM_MCDUFFIN_DOWN,
4800 EL_MM_MIRROR_FIXED_START,
4801 EL_MM_POLARIZER_START,
4802 EL_MM_POLARIZER_CROSS_START,
4804 EL_MM_TELEPORTER_RED_START,
4805 EL_MM_TELEPORTER_YELLOW_START,
4806 EL_MM_TELEPORTER_GREEN_START,
4807 EL_MM_TELEPORTER_BLUE_START,
4820 EL_MM_LIGHTBULB_ACTIVE,
4834 EL_MM_STEEL_GRID_FIXED_1,
4835 EL_MM_STEEL_GRID_FIXED_2,
4836 EL_MM_STEEL_GRID_FIXED_3,
4837 EL_MM_STEEL_GRID_FIXED_4,
4839 EL_MM_WOODEN_GRID_FIXED_1,
4840 EL_MM_WOODEN_GRID_FIXED_2,
4841 EL_MM_WOODEN_GRID_FIXED_3,
4842 EL_MM_WOODEN_GRID_FIXED_4,
4849 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
4850 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
4851 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
4852 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
4854 static int editor_hl_deflektor[] =
4856 EL_INTERNAL_CASCADE_DF_ACTIVE,
4862 static int editor_el_deflektor[] =
4869 EL_DF_RECEIVER_RIGHT,
4871 EL_DF_RECEIVER_LEFT,
4872 EL_DF_RECEIVER_DOWN,
4875 EL_DF_MIRROR_ROTATING_START,
4876 EL_DF_MIRROR_FIXED_START,
4879 EL_DF_FIBRE_OPTIC_RED_1,
4880 EL_DF_FIBRE_OPTIC_YELLOW_1,
4881 EL_DF_FIBRE_OPTIC_GREEN_1,
4882 EL_DF_FIBRE_OPTIC_BLUE_1,
4884 EL_DF_STEEL_GRID_FIXED_START,
4885 EL_DF_STEEL_GRID_ROTATING_START,
4886 EL_DF_WOODEN_GRID_FIXED_START,
4887 EL_DF_WOODEN_GRID_ROTATING_START,
4899 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
4900 static int *editor_el_deflektor_ptr = editor_el_deflektor;
4901 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
4902 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
4904 static int editor_hl_chars[] =
4906 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
4912 static int editor_el_chars[] =
4994 EL_CHAR(CHAR_BYTE_COPYRIGHT),
4995 EL_CHAR(CHAR_BYTE_UMLAUT_A),
4996 EL_CHAR(CHAR_BYTE_UMLAUT_O),
4997 EL_CHAR(CHAR_BYTE_UMLAUT_U),
4999 EL_CHAR(CHAR_BYTE_DEGREE),
5000 EL_CHAR(CHAR_BYTE_REGISTERED),
5001 EL_CHAR(FONT_ASCII_CURSOR),
5002 EL_CHAR(FONT_ASCII_BUTTON),
5004 EL_CHAR(FONT_ASCII_UP),
5005 EL_CHAR(FONT_ASCII_DOWN),
5009 static int *editor_hl_chars_ptr = editor_hl_chars;
5010 static int *editor_el_chars_ptr = editor_el_chars;
5011 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
5012 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
5014 static int editor_hl_steel_chars[] =
5016 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
5022 static int editor_el_steel_chars[] =
5032 EL_STEEL_CHAR('\''),
5099 EL_STEEL_CHAR('\\'),
5104 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
5105 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
5106 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
5107 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
5109 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
5110 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
5111 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
5112 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
5114 EL_STEEL_CHAR(FONT_ASCII_UP),
5115 EL_STEEL_CHAR(FONT_ASCII_DOWN),
5119 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
5120 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
5121 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
5122 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
5124 static int editor_hl_custom[] =
5126 EL_INTERNAL_CASCADE_CE_ACTIVE,
5132 static int editor_el_custom[] =
5134 EL_CUSTOM_START + 0,
5135 EL_CUSTOM_START + 1,
5136 EL_CUSTOM_START + 2,
5137 EL_CUSTOM_START + 3,
5139 EL_CUSTOM_START + 4,
5140 EL_CUSTOM_START + 5,
5141 EL_CUSTOM_START + 6,
5142 EL_CUSTOM_START + 7,
5144 EL_CUSTOM_START + 8,
5145 EL_CUSTOM_START + 9,
5146 EL_CUSTOM_START + 10,
5147 EL_CUSTOM_START + 11,
5149 EL_CUSTOM_START + 12,
5150 EL_CUSTOM_START + 13,
5151 EL_CUSTOM_START + 14,
5152 EL_CUSTOM_START + 15,
5154 EL_CUSTOM_START + 16,
5155 EL_CUSTOM_START + 17,
5156 EL_CUSTOM_START + 18,
5157 EL_CUSTOM_START + 19,
5159 EL_CUSTOM_START + 20,
5160 EL_CUSTOM_START + 21,
5161 EL_CUSTOM_START + 22,
5162 EL_CUSTOM_START + 23,
5164 EL_CUSTOM_START + 24,
5165 EL_CUSTOM_START + 25,
5166 EL_CUSTOM_START + 26,
5167 EL_CUSTOM_START + 27,
5169 EL_CUSTOM_START + 28,
5170 EL_CUSTOM_START + 29,
5171 EL_CUSTOM_START + 30,
5172 EL_CUSTOM_START + 31,
5174 EL_CUSTOM_START + 32,
5175 EL_CUSTOM_START + 33,
5176 EL_CUSTOM_START + 34,
5177 EL_CUSTOM_START + 35,
5179 EL_CUSTOM_START + 36,
5180 EL_CUSTOM_START + 37,
5181 EL_CUSTOM_START + 38,
5182 EL_CUSTOM_START + 39,
5184 EL_CUSTOM_START + 40,
5185 EL_CUSTOM_START + 41,
5186 EL_CUSTOM_START + 42,
5187 EL_CUSTOM_START + 43,
5189 EL_CUSTOM_START + 44,
5190 EL_CUSTOM_START + 45,
5191 EL_CUSTOM_START + 46,
5192 EL_CUSTOM_START + 47,
5194 EL_CUSTOM_START + 48,
5195 EL_CUSTOM_START + 49,
5196 EL_CUSTOM_START + 50,
5197 EL_CUSTOM_START + 51,
5199 EL_CUSTOM_START + 52,
5200 EL_CUSTOM_START + 53,
5201 EL_CUSTOM_START + 54,
5202 EL_CUSTOM_START + 55,
5204 EL_CUSTOM_START + 56,
5205 EL_CUSTOM_START + 57,
5206 EL_CUSTOM_START + 58,
5207 EL_CUSTOM_START + 59,
5209 EL_CUSTOM_START + 60,
5210 EL_CUSTOM_START + 61,
5211 EL_CUSTOM_START + 62,
5212 EL_CUSTOM_START + 63,
5214 EL_CUSTOM_START + 64,
5215 EL_CUSTOM_START + 65,
5216 EL_CUSTOM_START + 66,
5217 EL_CUSTOM_START + 67,
5219 EL_CUSTOM_START + 68,
5220 EL_CUSTOM_START + 69,
5221 EL_CUSTOM_START + 70,
5222 EL_CUSTOM_START + 71,
5224 EL_CUSTOM_START + 72,
5225 EL_CUSTOM_START + 73,
5226 EL_CUSTOM_START + 74,
5227 EL_CUSTOM_START + 75,
5229 EL_CUSTOM_START + 76,
5230 EL_CUSTOM_START + 77,
5231 EL_CUSTOM_START + 78,
5232 EL_CUSTOM_START + 79,
5234 EL_CUSTOM_START + 80,
5235 EL_CUSTOM_START + 81,
5236 EL_CUSTOM_START + 82,
5237 EL_CUSTOM_START + 83,
5239 EL_CUSTOM_START + 84,
5240 EL_CUSTOM_START + 85,
5241 EL_CUSTOM_START + 86,
5242 EL_CUSTOM_START + 87,
5244 EL_CUSTOM_START + 88,
5245 EL_CUSTOM_START + 89,
5246 EL_CUSTOM_START + 90,
5247 EL_CUSTOM_START + 91,
5249 EL_CUSTOM_START + 92,
5250 EL_CUSTOM_START + 93,
5251 EL_CUSTOM_START + 94,
5252 EL_CUSTOM_START + 95,
5254 EL_CUSTOM_START + 96,
5255 EL_CUSTOM_START + 97,
5256 EL_CUSTOM_START + 98,
5257 EL_CUSTOM_START + 99,
5259 EL_CUSTOM_START + 100,
5260 EL_CUSTOM_START + 101,
5261 EL_CUSTOM_START + 102,
5262 EL_CUSTOM_START + 103,
5264 EL_CUSTOM_START + 104,
5265 EL_CUSTOM_START + 105,
5266 EL_CUSTOM_START + 106,
5267 EL_CUSTOM_START + 107,
5269 EL_CUSTOM_START + 108,
5270 EL_CUSTOM_START + 109,
5271 EL_CUSTOM_START + 110,
5272 EL_CUSTOM_START + 111,
5274 EL_CUSTOM_START + 112,
5275 EL_CUSTOM_START + 113,
5276 EL_CUSTOM_START + 114,
5277 EL_CUSTOM_START + 115,
5279 EL_CUSTOM_START + 116,
5280 EL_CUSTOM_START + 117,
5281 EL_CUSTOM_START + 118,
5282 EL_CUSTOM_START + 119,
5284 EL_CUSTOM_START + 120,
5285 EL_CUSTOM_START + 121,
5286 EL_CUSTOM_START + 122,
5287 EL_CUSTOM_START + 123,
5289 EL_CUSTOM_START + 124,
5290 EL_CUSTOM_START + 125,
5291 EL_CUSTOM_START + 126,
5292 EL_CUSTOM_START + 127,
5294 EL_CUSTOM_START + 128,
5295 EL_CUSTOM_START + 129,
5296 EL_CUSTOM_START + 130,
5297 EL_CUSTOM_START + 131,
5299 EL_CUSTOM_START + 132,
5300 EL_CUSTOM_START + 133,
5301 EL_CUSTOM_START + 134,
5302 EL_CUSTOM_START + 135,
5304 EL_CUSTOM_START + 136,
5305 EL_CUSTOM_START + 137,
5306 EL_CUSTOM_START + 138,
5307 EL_CUSTOM_START + 139,
5309 EL_CUSTOM_START + 140,
5310 EL_CUSTOM_START + 141,
5311 EL_CUSTOM_START + 142,
5312 EL_CUSTOM_START + 143,
5314 EL_CUSTOM_START + 144,
5315 EL_CUSTOM_START + 145,
5316 EL_CUSTOM_START + 146,
5317 EL_CUSTOM_START + 147,
5319 EL_CUSTOM_START + 148,
5320 EL_CUSTOM_START + 149,
5321 EL_CUSTOM_START + 150,
5322 EL_CUSTOM_START + 151,
5324 EL_CUSTOM_START + 152,
5325 EL_CUSTOM_START + 153,
5326 EL_CUSTOM_START + 154,
5327 EL_CUSTOM_START + 155,
5329 EL_CUSTOM_START + 156,
5330 EL_CUSTOM_START + 157,
5331 EL_CUSTOM_START + 158,
5332 EL_CUSTOM_START + 159,
5334 EL_CUSTOM_START + 160,
5335 EL_CUSTOM_START + 161,
5336 EL_CUSTOM_START + 162,
5337 EL_CUSTOM_START + 163,
5339 EL_CUSTOM_START + 164,
5340 EL_CUSTOM_START + 165,
5341 EL_CUSTOM_START + 166,
5342 EL_CUSTOM_START + 167,
5344 EL_CUSTOM_START + 168,
5345 EL_CUSTOM_START + 169,
5346 EL_CUSTOM_START + 170,
5347 EL_CUSTOM_START + 171,
5349 EL_CUSTOM_START + 172,
5350 EL_CUSTOM_START + 173,
5351 EL_CUSTOM_START + 174,
5352 EL_CUSTOM_START + 175,
5354 EL_CUSTOM_START + 176,
5355 EL_CUSTOM_START + 177,
5356 EL_CUSTOM_START + 178,
5357 EL_CUSTOM_START + 179,
5359 EL_CUSTOM_START + 180,
5360 EL_CUSTOM_START + 181,
5361 EL_CUSTOM_START + 182,
5362 EL_CUSTOM_START + 183,
5364 EL_CUSTOM_START + 184,
5365 EL_CUSTOM_START + 185,
5366 EL_CUSTOM_START + 186,
5367 EL_CUSTOM_START + 187,
5369 EL_CUSTOM_START + 188,
5370 EL_CUSTOM_START + 189,
5371 EL_CUSTOM_START + 190,
5372 EL_CUSTOM_START + 191,
5374 EL_CUSTOM_START + 192,
5375 EL_CUSTOM_START + 193,
5376 EL_CUSTOM_START + 194,
5377 EL_CUSTOM_START + 195,
5379 EL_CUSTOM_START + 196,
5380 EL_CUSTOM_START + 197,
5381 EL_CUSTOM_START + 198,
5382 EL_CUSTOM_START + 199,
5384 EL_CUSTOM_START + 200,
5385 EL_CUSTOM_START + 201,
5386 EL_CUSTOM_START + 202,
5387 EL_CUSTOM_START + 203,
5389 EL_CUSTOM_START + 204,
5390 EL_CUSTOM_START + 205,
5391 EL_CUSTOM_START + 206,
5392 EL_CUSTOM_START + 207,
5394 EL_CUSTOM_START + 208,
5395 EL_CUSTOM_START + 209,
5396 EL_CUSTOM_START + 210,
5397 EL_CUSTOM_START + 211,
5399 EL_CUSTOM_START + 212,
5400 EL_CUSTOM_START + 213,
5401 EL_CUSTOM_START + 214,
5402 EL_CUSTOM_START + 215,
5404 EL_CUSTOM_START + 216,
5405 EL_CUSTOM_START + 217,
5406 EL_CUSTOM_START + 218,
5407 EL_CUSTOM_START + 219,
5409 EL_CUSTOM_START + 220,
5410 EL_CUSTOM_START + 221,
5411 EL_CUSTOM_START + 222,
5412 EL_CUSTOM_START + 223,
5414 EL_CUSTOM_START + 224,
5415 EL_CUSTOM_START + 225,
5416 EL_CUSTOM_START + 226,
5417 EL_CUSTOM_START + 227,
5419 EL_CUSTOM_START + 228,
5420 EL_CUSTOM_START + 229,
5421 EL_CUSTOM_START + 230,
5422 EL_CUSTOM_START + 231,
5424 EL_CUSTOM_START + 232,
5425 EL_CUSTOM_START + 233,
5426 EL_CUSTOM_START + 234,
5427 EL_CUSTOM_START + 235,
5429 EL_CUSTOM_START + 236,
5430 EL_CUSTOM_START + 237,
5431 EL_CUSTOM_START + 238,
5432 EL_CUSTOM_START + 239,
5434 EL_CUSTOM_START + 240,
5435 EL_CUSTOM_START + 241,
5436 EL_CUSTOM_START + 242,
5437 EL_CUSTOM_START + 243,
5439 EL_CUSTOM_START + 244,
5440 EL_CUSTOM_START + 245,
5441 EL_CUSTOM_START + 246,
5442 EL_CUSTOM_START + 247,
5444 EL_CUSTOM_START + 248,
5445 EL_CUSTOM_START + 249,
5446 EL_CUSTOM_START + 250,
5447 EL_CUSTOM_START + 251,
5449 EL_CUSTOM_START + 252,
5450 EL_CUSTOM_START + 253,
5451 EL_CUSTOM_START + 254,
5452 EL_CUSTOM_START + 255
5454 static int *editor_hl_custom_ptr = editor_hl_custom;
5455 static int *editor_el_custom_ptr = editor_el_custom;
5456 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5457 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5459 static int editor_hl_group[] =
5461 EL_INTERNAL_CASCADE_GE_ACTIVE,
5467 static int editor_el_group[] =
5481 EL_GROUP_START + 10,
5482 EL_GROUP_START + 11,
5484 EL_GROUP_START + 12,
5485 EL_GROUP_START + 13,
5486 EL_GROUP_START + 14,
5487 EL_GROUP_START + 15,
5489 EL_GROUP_START + 16,
5490 EL_GROUP_START + 17,
5491 EL_GROUP_START + 18,
5492 EL_GROUP_START + 19,
5494 EL_GROUP_START + 20,
5495 EL_GROUP_START + 21,
5496 EL_GROUP_START + 22,
5497 EL_GROUP_START + 23,
5499 EL_GROUP_START + 24,
5500 EL_GROUP_START + 25,
5501 EL_GROUP_START + 26,
5502 EL_GROUP_START + 27,
5504 EL_GROUP_START + 28,
5505 EL_GROUP_START + 29,
5506 EL_GROUP_START + 30,
5509 static int *editor_hl_group_ptr = editor_hl_group;
5510 static int *editor_el_group_ptr = editor_el_group;
5511 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5512 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5514 static int editor_hl_empty_space[] =
5516 EL_INTERNAL_CASCADE_ES_ACTIVE,
5522 static int editor_el_empty_space[] =
5544 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
5545 static int *editor_el_empty_space_ptr = editor_el_empty_space;
5546 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
5547 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
5549 static int editor_hl_reference[] =
5551 EL_INTERNAL_CASCADE_REF_ACTIVE,
5557 static int editor_el_reference[] =
5561 EL_TRIGGER_CE_VALUE,
5562 EL_TRIGGER_CE_SCORE,
5566 EL_CURRENT_CE_VALUE,
5567 EL_CURRENT_CE_SCORE,
5589 static int *editor_hl_reference_ptr = editor_hl_reference;
5590 static int *editor_el_reference_ptr = editor_el_reference;
5591 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5592 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5594 static int editor_hl_user_defined[] =
5596 EL_INTERNAL_CASCADE_USER_ACTIVE,
5602 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5603 static int *editor_el_user_defined_ptr = NULL;
5604 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5605 static int num_editor_el_user_defined = 0;
5607 static int editor_hl_dynamic[] =
5609 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5615 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5616 static int *editor_el_dynamic_ptr = NULL;
5617 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5618 static int num_editor_el_dynamic = 0;
5620 static int editor_hl_empty[] = { EL_EMPTY };
5621 static int *editor_el_empty = NULL; // dynamically allocated
5623 static int *editor_hl_empty_ptr = editor_hl_empty;
5624 static int *editor_el_empty_ptr = NULL;
5625 static int num_editor_hl_empty = 0;
5626 static int num_editor_el_empty = 0; // dynamically determined, if needed
5628 static boolean use_el_empty = FALSE;
5630 static int *editor_elements = NULL; // dynamically allocated
5631 static int num_editor_elements = 0; // dynamically determined
5633 static boolean setup_editor_cascade_never = FALSE;
5635 static boolean setup_editor_el_players = TRUE;
5636 static boolean setup_editor_el_boulderdash = TRUE;
5637 static boolean setup_editor_el_boulderdash_native = TRUE;
5638 static boolean setup_editor_el_emerald_mine = TRUE;
5639 static boolean setup_editor_el_emerald_mine_club = TRUE;
5640 static boolean setup_editor_el_more = TRUE;
5641 static boolean setup_editor_el_sokoban = TRUE;
5642 static boolean setup_editor_el_supaplex = TRUE;
5643 static boolean setup_editor_el_diamond_caves = TRUE;
5644 static boolean setup_editor_el_dx_boulderdash = TRUE;
5645 static boolean setup_editor_el_mirror_magic = TRUE;
5646 static boolean setup_editor_el_deflektor = TRUE;
5647 static boolean setup_editor_el_chars = TRUE;
5648 static boolean setup_editor_el_steel_chars = TRUE;
5649 static boolean setup_editor_el_custom = TRUE;
5650 static boolean setup_editor_el_user_defined = TRUE;
5651 static boolean setup_editor_el_dynamic = TRUE;
5653 static int editor_hl_unused[] = { EL_EMPTY };
5654 static int *editor_hl_unused_ptr = editor_hl_unused;
5655 static int num_editor_hl_unused = 0;
5659 boolean *setup_value;
5660 boolean *setup_cascade_value;
5662 int **headline_list;
5663 int *headline_list_size;
5666 int *element_list_size;
5668 boolean last_setup_value;
5670 editor_elements_info[] =
5673 &setup_editor_el_players,
5674 &setup_editor_cascade_never,
5675 &editor_hl_unused_ptr, &num_editor_hl_unused,
5676 &editor_el_players_ptr, &num_editor_el_players
5679 &setup_editor_el_boulderdash,
5680 &setup.editor_cascade.el_bd,
5681 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5682 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5685 &setup_editor_el_boulderdash_native,
5686 &setup.editor_cascade.el_bd_native,
5687 &editor_hl_boulderdash_native_ptr, &num_editor_hl_boulderdash_native,
5688 &editor_el_boulderdash_native_ptr, &num_editor_el_boulderdash_native
5691 &setup_editor_el_emerald_mine,
5692 &setup.editor_cascade.el_em,
5693 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5694 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5697 &setup_editor_el_emerald_mine_club,
5698 &setup.editor_cascade.el_emc,
5699 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5700 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5703 &setup_editor_el_more,
5704 &setup.editor_cascade.el_rnd,
5705 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5706 &editor_el_rnd_ptr, &num_editor_el_rnd
5709 &setup_editor_el_sokoban,
5710 &setup.editor_cascade.el_sb,
5711 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5712 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5715 &setup_editor_el_supaplex,
5716 &setup.editor_cascade.el_sp,
5717 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5718 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5721 &setup_editor_el_diamond_caves,
5722 &setup.editor_cascade.el_dc,
5723 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5724 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5727 &setup_editor_el_dx_boulderdash,
5728 &setup.editor_cascade.el_dx,
5729 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5730 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
5733 &setup_editor_el_mirror_magic,
5734 &setup.editor_cascade.el_mm,
5735 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
5736 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
5739 &setup_editor_el_deflektor,
5740 &setup.editor_cascade.el_df,
5741 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
5742 &editor_el_deflektor_ptr, &num_editor_el_deflektor
5745 &setup_editor_el_chars,
5746 &setup.editor_cascade.el_chars,
5747 &editor_hl_chars_ptr, &num_editor_hl_chars,
5748 &editor_el_chars_ptr, &num_editor_el_chars
5751 &setup_editor_el_steel_chars,
5752 &setup.editor_cascade.el_steel_chars,
5753 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
5754 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
5757 &setup_editor_el_custom,
5758 &setup.editor_cascade.el_ce,
5759 &editor_hl_custom_ptr, &num_editor_hl_custom,
5760 &editor_el_custom_ptr, &num_editor_el_custom
5763 &setup_editor_el_custom,
5764 &setup.editor_cascade.el_ge,
5765 &editor_hl_group_ptr, &num_editor_hl_group,
5766 &editor_el_group_ptr, &num_editor_el_group
5769 &setup_editor_el_custom,
5770 &setup.editor_cascade.el_es,
5771 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
5772 &editor_el_empty_space_ptr, &num_editor_el_empty_space
5775 &setup_editor_el_custom,
5776 &setup.editor_cascade.el_ref,
5777 &editor_hl_reference_ptr, &num_editor_hl_reference,
5778 &editor_el_reference_ptr, &num_editor_el_reference
5781 &setup_editor_el_user_defined,
5782 &setup.editor_cascade.el_user,
5783 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
5784 &editor_el_user_defined_ptr, &num_editor_el_user_defined
5787 &setup_editor_el_dynamic,
5788 &setup.editor_cascade.el_dynamic,
5789 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
5790 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
5795 &editor_hl_empty_ptr, &num_editor_hl_empty,
5796 &editor_el_empty_ptr, &num_editor_el_empty,
5806 static struct XY xy_directions[] =
5815 // ----------------------------------------------------------------------------
5817 // ----------------------------------------------------------------------------
5819 static int getMaxInfoTextLength(void)
5821 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
5824 static int getTextWidthForGadget(char *text)
5829 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
5832 static int getTextWidthForDrawingArea(char *text)
5837 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
5840 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
5842 return (gi->x + gi->width + getTextWidthForGadget(text));
5845 static char *getElementInfoText(int element)
5847 char *info_text = NULL;
5849 if (element < MAX_NUM_ELEMENTS)
5851 if (strlen(element_info[element].description) > 0)
5852 info_text = element_info[element].description;
5853 else if (element_info[element].custom_description != NULL)
5854 info_text = element_info[element].custom_description;
5855 else if (element_info[element].editor_description != NULL)
5856 info_text = element_info[element].editor_description;
5859 if (info_text == NULL)
5860 info_text = INFOTEXT_UNKNOWN_ELEMENT;
5865 static char *getElementDescriptionFilenameExt(char *basename)
5867 char *elements_subdir = ELEMENTS_DIRECTORY;
5868 static char *elements_subdir2 = NULL;
5869 static char *filename = NULL;
5871 if (elements_subdir2 == NULL)
5872 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
5874 checked_free(filename);
5876 // 1st try: look for element description in current level set directory
5877 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
5878 if (fileExists(filename))
5883 // 2nd try: look for element description in the game's base directory
5884 filename = getPath3(options.docs_directory, elements_subdir, basename);
5885 if (fileExists(filename))
5891 static char *getElementDescriptionFilename(int element)
5893 char basename[MAX_FILENAME_LEN];
5896 // 1st try: look for element description file for exactly this element
5897 sprintf(basename, "%s.txt", element_info[element].token_name);
5898 filename = getElementDescriptionFilenameExt(basename);
5899 if (filename != NULL)
5902 // 2nd try: look for element description file for this element's class
5903 sprintf(basename, "%s.txt", element_info[element].class_name);
5904 filename = getElementDescriptionFilenameExt(basename);
5905 if (filename != NULL)
5908 // 3rd try: look for generic fallback text file for any element
5909 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
5910 if (filename != NULL)
5916 static boolean suppressBorderElement(void)
5918 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
5919 lev_fieldx <= MAX_ED_FIELDX &&
5920 lev_fieldy <= MAX_ED_FIELDY);
5923 static void InitDynamicEditorElementList(int **elements, int *num_elements)
5925 boolean element_found[NUM_FILE_ELEMENTS];
5928 // initialize list of used elements to "not used"
5929 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5930 element_found[i] = FALSE;
5932 // find all elements used in current level
5933 for (y = 0; y < lev_fieldy; y++)
5935 for (x = 0; x < lev_fieldx; x++)
5937 if (Tile[x][y] >= NUM_FILE_ELEMENTS) // should never happen
5940 if (IS_MM_WALL(Tile[x][y]))
5941 element_found[map_mm_wall_element(Tile[x][y])] = TRUE;
5943 element_found[Tile[x][y]] = TRUE;
5949 // count number of elements used in current level
5950 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5951 if (element_found[i])
5954 // add space for up to 3 more elements for padding that may be needed
5957 // free memory for old list of elements, if needed
5958 checked_free(*elements);
5960 // allocate memory for new list of elements
5961 *elements = checked_malloc(*num_elements * sizeof(int));
5965 // add all elements used in current level (non-custom/group/empty elements)
5966 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5967 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) ||
5968 IS_GROUP_ELEMENT(i) ||
5969 IS_EMPTY_ELEMENT(i)))
5970 (*elements)[(*num_elements)++] = i;
5972 // add all elements used in current level (custom/group/empty elements)
5973 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5974 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) ||
5975 IS_GROUP_ELEMENT(i) ||
5976 IS_EMPTY_ELEMENT(i)))
5977 (*elements)[(*num_elements)++] = i;
5979 while (*num_elements % 4) // pad with empty elements, if needed
5980 (*elements)[(*num_elements)++] = EL_EMPTY;
5983 static void ReinitializeElementList_EnableSections(void)
5985 // default: enable all element sections
5987 setup_editor_el_players = TRUE;
5988 setup_editor_el_boulderdash = TRUE;
5989 setup_editor_el_boulderdash_native = TRUE;
5990 setup_editor_el_emerald_mine = TRUE;
5991 setup_editor_el_emerald_mine_club = TRUE;
5992 setup_editor_el_more = TRUE;
5993 setup_editor_el_sokoban = TRUE;
5994 setup_editor_el_supaplex = TRUE;
5995 setup_editor_el_diamond_caves = TRUE;
5996 setup_editor_el_dx_boulderdash = TRUE;
5997 setup_editor_el_mirror_magic = TRUE;
5998 setup_editor_el_deflektor = TRUE;
5999 setup_editor_el_chars = TRUE;
6000 setup_editor_el_steel_chars = TRUE;
6002 setup_editor_el_custom = TRUE;
6003 setup_editor_el_user_defined = TRUE;
6004 setup_editor_el_dynamic = TRUE;
6006 // now disable all element sections not to be displayed
6008 if (!setup.editor.el_classic)
6010 setup_editor_el_players = FALSE;
6011 setup_editor_el_boulderdash = FALSE;
6012 setup_editor_el_boulderdash_native = FALSE;
6013 setup_editor_el_emerald_mine = FALSE;
6014 setup_editor_el_emerald_mine_club = FALSE;
6015 setup_editor_el_more = FALSE;
6016 setup_editor_el_sokoban = FALSE;
6017 setup_editor_el_supaplex = FALSE;
6018 setup_editor_el_diamond_caves = FALSE;
6019 setup_editor_el_dx_boulderdash = FALSE;
6020 setup_editor_el_mirror_magic = FALSE;
6021 setup_editor_el_deflektor = FALSE;
6022 setup_editor_el_chars = FALSE;
6023 setup_editor_el_steel_chars = FALSE;
6026 if (!setup.editor.el_custom)
6028 setup_editor_el_custom = FALSE;
6031 if (!setup.editor.el_user_defined)
6033 setup_editor_el_user_defined = FALSE;
6036 if (!setup.editor.el_dynamic)
6038 setup_editor_el_dynamic = FALSE;
6041 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
6043 setup_editor_el_boulderdash_native = FALSE;
6044 setup_editor_el_mirror_magic = FALSE;
6045 setup_editor_el_deflektor = FALSE;
6047 else if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
6049 setup_editor_el_boulderdash = FALSE;
6050 setup_editor_el_emerald_mine = FALSE;
6051 setup_editor_el_emerald_mine_club = FALSE;
6052 setup_editor_el_more = FALSE;
6053 setup_editor_el_sokoban = FALSE;
6054 setup_editor_el_supaplex = FALSE;
6055 setup_editor_el_diamond_caves = FALSE;
6056 setup_editor_el_dx_boulderdash = FALSE;
6057 setup_editor_el_mirror_magic = FALSE;
6058 setup_editor_el_deflektor = FALSE;
6059 setup_editor_el_chars = FALSE;
6060 setup_editor_el_steel_chars = FALSE;
6062 setup_editor_el_custom = FALSE;
6064 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
6066 setup_editor_el_boulderdash = FALSE;
6067 setup_editor_el_boulderdash_native = FALSE;
6068 setup_editor_el_more = FALSE;
6069 setup_editor_el_sokoban = FALSE;
6070 setup_editor_el_supaplex = FALSE;
6071 setup_editor_el_diamond_caves = FALSE;
6072 setup_editor_el_dx_boulderdash = FALSE;
6073 setup_editor_el_mirror_magic = FALSE;
6074 setup_editor_el_deflektor = FALSE;
6075 setup_editor_el_steel_chars = FALSE;
6077 setup_editor_el_custom = FALSE;
6079 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
6081 setup_editor_el_players = FALSE;
6082 setup_editor_el_boulderdash = FALSE;
6083 setup_editor_el_boulderdash_native = FALSE;
6084 setup_editor_el_emerald_mine = FALSE;
6085 setup_editor_el_emerald_mine_club = FALSE;
6086 setup_editor_el_more = FALSE;
6087 setup_editor_el_sokoban = FALSE;
6088 setup_editor_el_diamond_caves = FALSE;
6089 setup_editor_el_dx_boulderdash = FALSE;
6090 setup_editor_el_mirror_magic = FALSE;
6091 setup_editor_el_deflektor = FALSE;
6092 setup_editor_el_chars = FALSE;
6093 setup_editor_el_steel_chars = FALSE;
6095 setup_editor_el_custom = FALSE;
6097 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
6099 setup_editor_el_players = FALSE;
6100 setup_editor_el_boulderdash = FALSE;
6101 setup_editor_el_boulderdash_native = FALSE;
6102 setup_editor_el_emerald_mine = FALSE;
6103 setup_editor_el_emerald_mine_club = FALSE;
6104 setup_editor_el_more = FALSE;
6105 setup_editor_el_sokoban = FALSE;
6106 setup_editor_el_supaplex = FALSE;
6107 setup_editor_el_diamond_caves = FALSE;
6108 setup_editor_el_dx_boulderdash = FALSE;
6109 setup_editor_el_steel_chars = FALSE;
6111 setup_editor_el_custom = FALSE;
6115 static void ReinitializeElementList(void)
6117 static boolean initialization_needed = TRUE;
6121 ReinitializeElementList_EnableSections();
6123 if (initialization_needed)
6125 LoadSetup_EditorCascade(); // load last editor cascade state
6127 // initialize editor cascade element from saved cascade state
6128 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6130 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
6131 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
6133 if (IS_EDITOR_CASCADE(*cascade_element))
6135 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
6136 EL_CASCADE_INACTIVE(*cascade_element));
6139 initialization_needed = FALSE;
6142 checked_free(editor_elements);
6144 // reload optional user defined element list for each invocation of editor
6145 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
6146 &num_editor_el_user_defined);
6148 // initialize dynamic level element list for each invocation of editor
6149 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
6150 &num_editor_el_dynamic);
6152 // initialize list of empty elements (used for padding, if needed)
6153 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6154 editor_el_empty[i] = EL_EMPTY;
6156 // do some sanity checks for each element from element list
6157 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6159 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6161 int element = (*editor_elements_info[i].element_list)[j];
6163 if (element >= NUM_FILE_ELEMENTS)
6164 Warn("editor element %d is runtime element", element);
6166 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
6167 Warn("no element description text for element %d", element);
6171 num_editor_elements = 0;
6172 use_el_empty = FALSE;
6174 // determine size of element list
6175 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6177 if (*editor_elements_info[i].setup_value)
6179 boolean found_inactive_cascade = FALSE;
6181 if (setup.editor.el_headlines)
6183 // required for correct padding of palette headline buttons
6184 if (*editor_elements_info[i].headline_list_size > 0)
6185 num_editor_elements += ED_ELEMENTLIST_COLS;
6187 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6189 int element = (*editor_elements_info[i].headline_list)[j];
6191 if (IS_EDITOR_CASCADE_INACTIVE(element))
6192 found_inactive_cascade = TRUE;
6196 if (found_inactive_cascade)
6199 // required for correct padding of palette element buttons
6200 int element_list_size = *editor_elements_info[i].element_list_size;
6202 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6203 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6205 num_editor_elements += element_buttons;
6209 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
6211 // offer at least as many elements as element buttons exist
6212 use_el_empty = TRUE;
6213 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
6215 num_editor_elements += num_editor_el_empty;
6219 num_editor_el_empty = 0;
6222 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
6224 // fill element list
6225 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6227 boolean found_inactive_cascade = FALSE;
6229 if (*editor_elements_info[i].setup_value)
6231 if (setup.editor.el_headlines)
6233 // required for correct padding of palette headline buttons
6234 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6235 ED_ELEMENTLIST_COLS : 0);
6237 for (j = 0; j < headline_size; j++)
6239 // use empty elements for padding of palette headline buttons
6240 int element = (j < *editor_elements_info[i].headline_list_size ?
6241 (*editor_elements_info[i].headline_list)[j] :
6242 editor_el_empty[0]);
6244 editor_elements[pos++] = element;
6246 if (IS_EDITOR_CASCADE_INACTIVE(element))
6247 found_inactive_cascade = TRUE;
6251 if (found_inactive_cascade)
6254 // required for correct padding of palette element buttons
6255 int element_list_size = *editor_elements_info[i].element_list_size;
6257 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6258 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6260 // copy all elements from element list
6261 for (j = 0; j < element_list_size; j++)
6262 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6264 // use empty elements for padding of palette element buttons
6265 for (j = 0; j < element_buttons - element_list_size; j++)
6266 editor_elements[pos++] = editor_el_empty[0];
6270 // (this function is also called before editor gadgets are initialized!)
6271 AdjustElementListScrollbar();
6274 void PrintEditorElementList(void)
6276 boolean *stop = &setup_editor_el_user_defined;
6279 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6281 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6283 if (IS_EDITOR_CASCADE(cascade_element))
6285 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6286 char *headline = element_info[cascade_element_show].editor_description;
6288 PrintLineWithPrefix("# ", "-", 77);
6289 Print("# %s\n", headline);
6290 PrintLineWithPrefix("# ", "-", 77);
6293 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6295 int element = (*editor_elements_info[i].headline_list)[j];
6297 if (IS_EDITOR_CASCADE(element))
6298 element = EL_CHAR_MINUS;
6300 Print("# %s\n", element_info[element].token_name);
6306 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6308 int element = (*editor_elements_info[i].element_list)[j];
6310 Print("# %s\n", element_info[element].token_name);
6318 static void ReinitializeElementListButtons(void)
6320 static boolean last_setup_value_headlines = FALSE;
6321 static boolean initialization_needed = TRUE;
6324 if (!initialization_needed) // check if editor element setup has changed
6326 if (last_setup_value_headlines != setup.editor.el_headlines)
6327 initialization_needed = TRUE;
6329 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6330 if (editor_elements_info[i].last_setup_value !=
6331 *editor_elements_info[i].setup_value)
6332 initialization_needed = TRUE;
6335 if (!initialization_needed)
6338 FreeLevelEditorGadgets();
6339 CreateLevelEditorGadgets();
6341 // store current setup values for next invocation of this function
6342 last_setup_value_headlines = setup.editor.el_headlines;
6343 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6344 editor_elements_info[i].last_setup_value =
6345 *editor_elements_info[i].setup_value;
6347 initialization_needed = FALSE;
6350 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6353 int border_graphic =
6354 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6355 struct GraphicInfo *g = &graphic_info[border_graphic];
6356 Bitmap *src_bitmap = g->bitmap;
6357 int src_x = g->src_x;
6358 int src_y = g->src_y;
6359 int border_size = g->border_size;
6360 int border_xpos = g->width - border_size;
6361 int border_ypos = g->height - border_size;
6362 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6365 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6366 border_size, border_size,
6367 dest_x - border_size, dest_y - border_size);
6368 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6369 border_size, border_size,
6370 dest_x + width, dest_y - border_size);
6371 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6372 border_size, border_size,
6373 dest_x - border_size, dest_y + height);
6374 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6375 border_size, border_size,
6376 dest_x + width, dest_y + height);
6378 for (i = 0; i < width / tilesize; i++)
6380 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6381 tilesize, border_size,
6382 dest_x + i * tilesize, dest_y - border_size);
6383 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6384 tilesize, border_size,
6385 dest_x + i * tilesize, dest_y + height);
6388 for (i = 0; i < height / tilesize; i++)
6390 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6391 border_size, tilesize,
6392 dest_x - border_size, dest_y + i * tilesize);
6393 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6394 border_size, tilesize,
6395 dest_x + width, dest_y + i * tilesize);
6398 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6401 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6403 int xsize_tile = MAX(ed_tilesize, xsize);
6404 int ysize_tile = MAX(ed_tilesize, ysize);
6405 int xsize_full = xsize + 1;
6406 int ysize_full = ysize + 1;
6407 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6408 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6409 Pixel line_color = getTabulatorBarColor();
6411 if (line_color == BLACK_PIXEL) // black => transparent
6414 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6415 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6416 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6419 static void DrawEditorLevelBorderLinesIfNeeded(void)
6421 int xsize = lev_fieldx * ed_tilesize;
6422 int ysize = lev_fieldy * ed_tilesize;
6423 int line_size = getTabulatorBarHeight();
6425 if (!suppressBorderElement())
6428 // draw little border line around editable level playfield
6431 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6434 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6436 if (xsize < SXSIZE && ysize < SYSIZE)
6437 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6440 static void DrawEditorElement(int x, int y, int element)
6442 DrawSizedElement(x, y, element, ed_tilesize);
6445 static void DrawEditorElementThruMask(int x, int y, int element)
6447 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6450 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6452 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6455 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6457 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6458 DrawEditorLevelBorderLinesIfNeeded();
6461 static void DrawDrawingArea(int id)
6463 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6466 int *value = drawingarea_info[id].value;
6467 int area_xsize = drawingarea_info[id].area_xsize;
6468 int area_ysize = drawingarea_info[id].area_ysize;
6469 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6471 for (x = 0; x < area_xsize; x++)
6472 for (y = 0; y < area_ysize; y++)
6473 DrawSizedGraphicExt(drawto,
6474 gi->x + x * tilesize,
6475 gi->y + y * tilesize,
6476 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6479 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6482 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6483 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6485 BlitBitmap(drawto, drawto,
6486 SX + (dx == -1 ? ed_tilesize : 0),
6487 SY + (dy == -1 ? ed_tilesize : 0),
6488 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6489 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6490 SX + (dx == +1 ? ed_tilesize : 0),
6491 SY + (dy == +1 ? ed_tilesize : 0));
6495 x = (dx == 1 ? 0 : ed_fieldx - 1);
6496 for (y = 0; y < ed_fieldy; y++)
6497 DrawEditorElementOrWall(x, y, from_x, from_y);
6501 y = (dy == 1 ? 0 : ed_fieldy - 1);
6502 for (x = 0; x < ed_fieldx; x++)
6503 DrawEditorElementOrWall(x, y, from_x, from_y);
6506 redraw_mask |= REDRAW_FIELD;
6510 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6513 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6516 static void CreateControlButtons(void)
6518 struct GadgetInfo *gi;
6521 // create toolbox buttons
6522 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6524 int id = controlbutton_info[i].gadget_id;
6525 int type = controlbutton_info[i].gadget_type;
6526 int graphic = controlbutton_info[i].graphic;
6527 struct XYTileSize *pos = controlbutton_info[i].pos;
6528 struct GraphicInfo *gd = &graphic_info[graphic];
6529 Bitmap *deco_bitmap = NULL;
6530 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6531 int tile_size = 0, deco_shift = 0;
6532 boolean deco_masked = FALSE;
6533 int gd_x1 = gd->src_x;
6534 int gd_y1 = gd->src_y;
6535 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6536 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6537 int gd_x1a = gd->src_x + gd->active_xoffset;
6538 int gd_y1a = gd->src_y + gd->active_yoffset;
6539 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6540 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6543 unsigned int event_mask;
6544 int radio_button_nr = RADIO_NR_NONE;
6545 boolean checked = FALSE;
6547 if (type == GD_TYPE_RADIO_BUTTON)
6549 event_mask = GD_EVENT_PRESSED;
6550 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6552 if (id == drawing_function)
6557 if (id == GADGET_ID_WRAP_LEFT ||
6558 id == GADGET_ID_WRAP_RIGHT ||
6559 id == GADGET_ID_WRAP_UP ||
6560 id == GADGET_ID_WRAP_DOWN)
6561 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6563 event_mask = GD_EVENT_RELEASED;
6566 if (id == GADGET_ID_PROPERTIES ||
6567 id == GADGET_ID_PALETTE)
6572 else if (id == GADGET_ID_ELEMENT_LEFT ||
6573 id == GADGET_ID_ELEMENT_MIDDLE ||
6574 id == GADGET_ID_ELEMENT_RIGHT)
6579 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6580 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6581 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6583 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6584 editor.button.element_left.tile_size :
6585 id == GADGET_ID_ELEMENT_MIDDLE ?
6586 editor.button.element_middle.tile_size :
6587 id == GADGET_ID_ELEMENT_RIGHT ?
6588 editor.button.element_right.tile_size : 0);
6590 // make sure that decoration does not overlap gadget border
6591 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6593 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6595 deco_xpos = (gd->width - tile_size) / 2;
6596 deco_ypos = (gd->height - tile_size) / 2;
6598 deco_masked = gd->draw_masked;
6606 gi = CreateGadget(GDI_CUSTOM_ID, id,
6607 GDI_CUSTOM_TYPE_ID, i,
6608 GDI_IMAGE_ID, graphic,
6609 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6612 GDI_WIDTH, gd->width,
6613 GDI_HEIGHT, gd->height,
6615 GDI_STATE, GD_BUTTON_UNPRESSED,
6616 GDI_RADIO_NR, radio_button_nr,
6617 GDI_CHECKED, checked,
6618 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6619 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6620 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6621 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6622 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6623 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6624 GDI_DECORATION_SIZE, tile_size, tile_size,
6625 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6626 GDI_DECORATION_MASKED, deco_masked,
6627 GDI_EVENT_MASK, event_mask,
6628 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6629 GDI_CALLBACK_ACTION, HandleControlButtons,
6633 Fail("cannot create gadget");
6635 level_editor_gadget[id] = gi;
6638 // these values are not constant, but can change at runtime
6639 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6640 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6641 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6642 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6643 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6644 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6645 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6646 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6647 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6648 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6649 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6650 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6652 // create buttons for scrolling of drawing area and element list
6653 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6655 int id = scrollbutton_info[i].gadget_id;
6656 int graphic = scrollbutton_info[i].graphic;
6657 struct GraphicInfo *gd = &graphic_info[graphic];
6658 Bitmap *gd_bitmap = gd->bitmap;
6659 int gd_x1 = gd->src_x;
6660 int gd_y1 = gd->src_y;
6661 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6662 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6663 int width = gd->width;
6664 int height = gd->height;
6665 int x = scrollbutton_pos[i].x;
6666 int y = scrollbutton_pos[i].y;
6667 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6669 if (id == GADGET_ID_SCROLL_LIST_UP ||
6670 id == GADGET_ID_SCROLL_LIST_DOWN)
6681 gi = CreateGadget(GDI_CUSTOM_ID, id,
6682 GDI_CUSTOM_TYPE_ID, i,
6683 GDI_IMAGE_ID, graphic,
6684 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6689 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6690 GDI_STATE, GD_BUTTON_UNPRESSED,
6691 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6692 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6693 GDI_EVENT_MASK, event_mask,
6694 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6695 GDI_CALLBACK_ACTION, HandleControlButtons,
6699 Fail("cannot create gadget");
6701 level_editor_gadget[id] = gi;
6704 // create buttons for element list
6705 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6707 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6708 int graphic = IMG_EDITOR_PALETTE_BUTTON;
6709 struct GraphicInfo *gd = &graphic_info[graphic];
6710 Bitmap *gd_bitmap = gd->bitmap;
6711 Bitmap *deco_bitmap;
6712 int deco_x, deco_y, deco_xpos, deco_ypos;
6713 int gd_x1 = gd->src_x;
6714 int gd_y1 = gd->src_y;
6715 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6716 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6717 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
6718 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
6719 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
6720 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
6721 int element = editor_elements[i];
6722 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
6723 unsigned int event_mask = GD_EVENT_RELEASED;
6725 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
6727 deco_xpos = (gd->width - tile_size) / 2;
6728 deco_ypos = (gd->height - tile_size) / 2;
6730 gi = CreateGadget(GDI_CUSTOM_ID, id,
6731 GDI_CUSTOM_TYPE_ID, i,
6732 GDI_IMAGE_ID, graphic,
6733 GDI_INFO_TEXT, getElementInfoText(element),
6736 GDI_WIDTH, gd->width,
6737 GDI_HEIGHT, gd->height,
6738 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6739 GDI_STATE, GD_BUTTON_UNPRESSED,
6740 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6741 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6742 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6743 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6744 GDI_DECORATION_SIZE, tile_size, tile_size,
6745 GDI_DECORATION_SHIFTING, 1, 1,
6746 GDI_EVENT_MASK, event_mask,
6747 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6748 GDI_CALLBACK_ACTION, HandleControlButtons,
6752 Fail("cannot create gadget");
6754 level_editor_gadget[id] = gi;
6758 static void CreateCounterButtons(void)
6760 int max_infotext_len = getMaxInfoTextLength();
6763 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
6766 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
6767 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
6769 // determine horizontal position to the right of specified gadget
6770 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6771 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
6772 ED_GADGET_TEXT_DISTANCE);
6774 // determine horizontal offset for leading text
6775 if (counterbutton_info[i].text_left != NULL)
6776 x += getTextWidthForGadget(counterbutton_info[i].text_left);
6778 for (j = 0; j < 2; j++)
6780 struct GadgetInfo *gi;
6782 counterbutton_info[i].gadget_id_down :
6783 counterbutton_info[i].gadget_id_up);
6785 struct GraphicInfo *gd;
6786 int gd_x1, gd_x2, gd_y1, gd_y2;
6787 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6788 char infotext[max_infotext_len + 1];
6790 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6793 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
6794 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
6796 event_mask |= GD_EVENT_RELEASED;
6800 x = DX + editor.button.prev_level.x;
6801 y = DY + editor.button.prev_level.y;
6805 x = DX + editor.button.next_level.x;
6806 y = DY + editor.button.next_level.y;
6812 IMG_EDITOR_COUNTER_DOWN :
6813 IMG_EDITOR_COUNTER_UP);
6816 gd = &graphic_info[graphic];
6820 gd_x2 = gd->src_x + gd->pressed_xoffset;
6821 gd_y2 = gd->src_y + gd->pressed_yoffset;
6823 sprintf(infotext, "%s counter value by 1, 5 or 10",
6824 (j == 0 ? "decrease" : "increase"));
6826 gi = CreateGadget(GDI_CUSTOM_ID, id,
6827 GDI_CUSTOM_TYPE_ID, i,
6828 GDI_IMAGE_ID, graphic,
6829 GDI_INFO_TEXT, infotext,
6832 GDI_WIDTH, gd->width,
6833 GDI_HEIGHT, gd->height,
6834 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6835 GDI_STATE, GD_BUTTON_UNPRESSED,
6836 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6837 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6838 GDI_EVENT_MASK, event_mask,
6839 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6840 GDI_CALLBACK_ACTION, HandleCounterButtons,
6844 Fail("cannot create gadget");
6846 level_editor_gadget[id] = gi;
6847 right_gadget_border[id] =
6848 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6850 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
6854 int font_type = FONT_INPUT_1;
6855 int font_type_active = FONT_INPUT_1_ACTIVE;
6857 id = counterbutton_info[i].gadget_id_text;
6859 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6861 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6863 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
6865 font_type = FONT_LEVEL_NUMBER;
6866 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
6868 x = DX + editor.input.level_number.x;
6869 y = DY + editor.input.level_number.y;
6873 graphic = IMG_EDITOR_COUNTER_INPUT;
6876 gd = &graphic_info[graphic];
6880 gd_x2 = gd->src_x + gd->active_xoffset;
6881 gd_y2 = gd->src_y + gd->active_yoffset;
6883 gi = CreateGadget(GDI_CUSTOM_ID, id,
6884 GDI_CUSTOM_TYPE_ID, i,
6885 GDI_IMAGE_ID, graphic,
6886 GDI_INFO_TEXT, "enter counter value",
6889 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
6890 GDI_NUMBER_VALUE, 0,
6891 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
6892 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
6893 GDI_TEXT_SIZE, 3, // minimal counter text size
6894 GDI_TEXT_FONT, font_type,
6895 GDI_TEXT_FONT_ACTIVE, font_type_active,
6896 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6897 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6898 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6899 GDI_DESIGN_WIDTH, gd->width,
6900 GDI_EVENT_MASK, event_mask,
6901 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6902 GDI_CALLBACK_ACTION, HandleCounterButtons,
6906 Fail("cannot create gadget");
6908 level_editor_gadget[id] = gi;
6909 right_gadget_border[id] =
6910 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6912 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
6918 static void CreateDrawingAreas(void)
6922 // these values are not constant, but can change at runtime
6923 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
6924 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
6926 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
6928 struct GadgetInfo *gi;
6929 int id = drawingarea_info[i].gadget_id;
6930 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
6931 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
6932 int area_xsize = drawingarea_info[i].area_xsize;
6933 int area_ysize = drawingarea_info[i].area_ysize;
6934 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
6935 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
6936 unsigned int event_mask =
6937 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
6938 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
6940 // determine horizontal position to the right of specified gadget
6941 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
6942 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
6943 ED_DRAWINGAREA_TEXT_DISTANCE);
6945 // determine horizontal offset for leading text
6946 if (drawingarea_info[i].text_left != NULL)
6947 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
6949 gi = CreateGadget(GDI_CUSTOM_ID, id,
6950 GDI_CUSTOM_TYPE_ID, i,
6953 GDI_TYPE, GD_TYPE_DRAWING_AREA,
6954 GDI_AREA_SIZE, area_xsize, area_ysize,
6955 GDI_ITEM_SIZE, item_size, item_size,
6956 GDI_EVENT_MASK, event_mask,
6957 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
6958 GDI_CALLBACK_ACTION, HandleDrawingAreas,
6962 Fail("cannot create gadget");
6964 level_editor_gadget[id] = gi;
6965 right_gadget_border[id] =
6966 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
6970 static void CreateTextInputGadgets(void)
6972 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
6973 int max_infotext_len = getMaxInfoTextLength();
6976 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
6978 int gd_x1 = gd->src_x;
6979 int gd_y1 = gd->src_y;
6980 int gd_x2 = gd->src_x + gd->active_xoffset;
6981 int gd_y2 = gd->src_y + gd->active_yoffset;
6982 struct GadgetInfo *gi;
6983 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6984 char infotext[MAX_OUTPUT_LINESIZE + 1];
6985 int id = textinput_info[i].gadget_id;
6988 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
6990 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
6991 int border_size = gd->border_size;
6992 int font_nr = FONT_INPUT_1;
6993 int font_height = getFontHeight(font_nr);
6994 int xoffset = element_border + TILEX + element_border + 3 * border_size;
6995 int yoffset = element_border + (TILEY - font_height) / 2;
6997 x = (editor.settings.element_name.x != -1 ?
6998 editor.settings.element_name.x :
6999 editor.settings.element_graphic.x + xoffset) - border_size;
7000 y = (editor.settings.element_name.y != -1 ?
7001 editor.settings.element_name.y :
7002 editor.settings.element_graphic.y + yoffset) - border_size;
7006 x = ED_SETTINGS_X(textinput_info[i].x);
7007 y = ED_SETTINGS_Y(textinput_info[i].y);
7010 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
7011 infotext[max_infotext_len] = '\0';
7013 gi = CreateGadget(GDI_CUSTOM_ID, id,
7014 GDI_CUSTOM_TYPE_ID, i,
7015 GDI_INFO_TEXT, infotext,
7018 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
7019 GDI_TEXT_VALUE, textinput_info[i].value,
7020 GDI_TEXT_SIZE, textinput_info[i].size,
7021 GDI_TEXT_FONT, FONT_INPUT_1,
7022 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7023 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7024 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7025 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7026 GDI_DESIGN_WIDTH, gd->width,
7027 GDI_EVENT_MASK, event_mask,
7028 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7029 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
7033 Fail("cannot create gadget");
7035 level_editor_gadget[id] = gi;
7039 static void CreateTextAreaGadgets(void)
7041 int max_infotext_len = getMaxInfoTextLength();
7044 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
7046 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
7047 int gd_x1 = gd->src_x;
7048 int gd_y1 = gd->src_y;
7049 int gd_x2 = gd->src_x + gd->active_xoffset;
7050 int gd_y2 = gd->src_y + gd->active_yoffset;
7051 struct GadgetInfo *gi;
7052 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
7053 char infotext[MAX_OUTPUT_LINESIZE + 1];
7054 int id = textarea_info[i].gadget_id;
7055 int area_xsize = textarea_info[i].xsize;
7056 int area_ysize = textarea_info[i].ysize;
7058 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
7059 infotext[max_infotext_len] = '\0';
7061 gi = CreateGadget(GDI_CUSTOM_ID, id,
7062 GDI_CUSTOM_TYPE_ID, i,
7063 GDI_INFO_TEXT, infotext,
7064 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
7065 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
7066 GDI_TYPE, GD_TYPE_TEXT_AREA,
7067 GDI_AREA_SIZE, area_xsize, area_ysize,
7068 GDI_TEXT_FONT, FONT_INPUT_1,
7069 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7070 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7071 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7072 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7073 GDI_DESIGN_WIDTH, gd->width,
7074 GDI_EVENT_MASK, event_mask,
7075 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7076 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
7080 Fail("cannot create gadget");
7082 level_editor_gadget[id] = gi;
7086 static void CreateSelectboxGadgets(void)
7088 int max_infotext_len = getMaxInfoTextLength();
7091 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7093 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
7094 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
7095 int gd_x1 = gd->src_x;
7096 int gd_y1 = gd->src_y;
7097 int gd_x2 = gd->src_x + gd->active_xoffset;
7098 int gd_y2 = gd->src_y + gd->active_yoffset;
7099 int selectbox_button_xsize = gd2->width;
7100 struct GadgetInfo *gi;
7101 char infotext[MAX_OUTPUT_LINESIZE + 1];
7102 int id = selectbox_info[i].gadget_id;
7103 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
7104 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
7105 unsigned int event_mask =
7106 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7108 if (selectbox_info[i].size == -1) // dynamically determine size
7110 // (we cannot use -1 for uninitialized values if we directly compare
7111 // with results from strlen(), because the '<' and '>' operation will
7112 // implicitely cast -1 to an unsigned integer value!)
7113 selectbox_info[i].size = 0;
7115 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
7116 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
7117 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
7119 selectbox_info[i].size++; // add one character empty space
7122 // determine horizontal position to the right of specified gadget
7123 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
7124 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
7125 ED_GADGET_TEXT_DISTANCE);
7127 // determine horizontal offset for leading text
7128 if (selectbox_info[i].text_left != NULL)
7129 x += getTextWidthForGadget(selectbox_info[i].text_left);
7131 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
7132 infotext[max_infotext_len] = '\0';
7134 gi = CreateGadget(GDI_CUSTOM_ID, id,
7135 GDI_CUSTOM_TYPE_ID, i,
7136 GDI_INFO_TEXT, infotext,
7139 GDI_TYPE, GD_TYPE_SELECTBOX,
7140 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
7141 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
7142 GDI_TEXT_SIZE, selectbox_info[i].size,
7143 GDI_TEXT_FONT, FONT_INPUT_1,
7144 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7145 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
7146 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7147 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7148 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7149 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
7150 GDI_DESIGN_WIDTH, gd->width,
7151 GDI_EVENT_MASK, event_mask,
7152 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7153 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
7157 Fail("cannot create gadget");
7159 level_editor_gadget[id] = gi;
7160 right_gadget_border[id] =
7161 getRightGadgetBorder(gi, selectbox_info[i].text_right);
7165 static void CreateTextbuttonGadgets(void)
7167 int max_infotext_len = getMaxInfoTextLength();
7170 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
7172 int id = textbutton_info[i].gadget_id;
7174 ((id >= GADGET_ID_LEVELCONFIG_LEVEL && id <= GADGET_ID_LEVELCONFIG_EDITOR) ||
7175 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
7177 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
7178 int gadget_distance =
7179 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
7180 struct GraphicInfo *gd = &graphic_info[graphic];
7181 int gd_x1 = gd->src_x;
7182 int gd_y1 = gd->src_y;
7183 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7184 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7185 int gd_x1a = gd->src_x + gd->active_xoffset;
7186 int gd_y1a = gd->src_y + gd->active_yoffset;
7187 int border_xsize = gd->border_size + gd->draw_xoffset;
7188 int border_ysize = gd->border_size;
7189 struct GadgetInfo *gi;
7190 unsigned int event_mask = GD_EVENT_RELEASED;
7191 char infotext[MAX_OUTPUT_LINESIZE + 1];
7192 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
7193 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
7195 if (textbutton_info[i].size == -1) // dynamically determine size
7196 textbutton_info[i].size = strlen(textbutton_info[i].text);
7198 sprintf(infotext, "%s", textbutton_info[i].infotext);
7199 infotext[max_infotext_len] = '\0';
7201 // determine horizontal position to the right of specified gadget
7202 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7204 int gadget_id_align = textbutton_info[i].gadget_id_align;
7206 x = right_gadget_border[gadget_id_align] + gadget_distance;
7208 if (textbutton_info[i].y == -1)
7209 y = level_editor_gadget[gadget_id_align]->y;
7212 // determine horizontal offset for leading text
7213 if (textbutton_info[i].text_left != NULL)
7214 x += getTextWidthForGadget(textbutton_info[i].text_left);
7216 gi = CreateGadget(GDI_CUSTOM_ID, id,
7217 GDI_CUSTOM_TYPE_ID, i,
7218 GDI_IMAGE_ID, graphic,
7219 GDI_INFO_TEXT, infotext,
7222 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
7223 GDI_TEXT_VALUE, textbutton_info[i].text,
7224 GDI_TEXT_SIZE, textbutton_info[i].size,
7225 GDI_TEXT_FONT, FONT_INPUT_2,
7226 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
7227 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7228 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7229 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7230 GDI_BORDER_SIZE, border_xsize, border_ysize,
7231 GDI_DESIGN_WIDTH, gd->width,
7232 GDI_DECORATION_SHIFTING, 1, 1,
7233 GDI_EVENT_MASK, event_mask,
7234 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7235 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7239 Fail("cannot create gadget");
7241 level_editor_gadget[id] = gi;
7242 right_gadget_border[id] =
7243 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7247 static void CreateGraphicbuttonGadgets(void)
7249 struct GadgetInfo *gi;
7252 // create buttons for scrolling of drawing area and element list
7253 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7255 int id = graphicbutton_info[i].gadget_id;
7256 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7257 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7258 int graphic = graphicbutton_info[i].graphic;
7259 struct GraphicInfo *gd = &graphic_info[graphic];
7260 int gd_x1 = gd->src_x;
7261 int gd_y1 = gd->src_y;
7262 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7263 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7264 unsigned int event_mask = GD_EVENT_RELEASED;
7266 // determine horizontal position to the right of specified gadget
7267 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7268 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7269 ED_GADGET_TEXT_DISTANCE);
7271 // determine horizontal offset for leading text
7272 if (graphicbutton_info[i].text_left != NULL)
7273 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7275 gi = CreateGadget(GDI_CUSTOM_ID, id,
7276 GDI_CUSTOM_TYPE_ID, i,
7277 GDI_IMAGE_ID, graphic,
7278 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7281 GDI_WIDTH, gd->width,
7282 GDI_HEIGHT, gd->height,
7283 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7284 GDI_STATE, GD_BUTTON_UNPRESSED,
7285 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7286 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7287 GDI_EVENT_MASK, event_mask,
7288 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7289 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7293 Fail("cannot create gadget");
7295 level_editor_gadget[id] = gi;
7296 right_gadget_border[id] =
7297 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7301 static void CreateScrollbarGadgets(void)
7305 // these values are not constant, but can change at runtime
7306 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7307 SX + ED_SCROLL_HORIZONTAL_XPOS;
7308 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7309 SY + ED_SCROLL_HORIZONTAL_YPOS;
7310 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7311 ED_SCROLL_HORIZONTAL_XSIZE;
7312 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7313 ED_SCROLL_HORIZONTAL_YSIZE;
7314 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7315 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7316 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7317 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7319 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7320 SX + ED_SCROLL_VERTICAL_XPOS;
7321 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7322 SY + ED_SCROLL_VERTICAL_YPOS;
7323 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7324 ED_SCROLL_VERTICAL_XSIZE;
7325 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7326 ED_SCROLL_VERTICAL_YSIZE;
7327 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7328 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7329 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7330 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7332 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7333 PX + ED_SCROLL2_VERTICAL_XPOS;
7334 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7335 PY + ED_SCROLL2_VERTICAL_YPOS;
7336 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7337 ED_SCROLL2_VERTICAL_XSIZE;
7338 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7339 ED_SCROLL2_VERTICAL_YSIZE;
7340 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7341 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7342 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7343 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7345 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7347 int id = scrollbar_info[i].gadget_id;
7348 int graphic = scrollbar_info[i].graphic;
7349 struct GraphicInfo *gd = &graphic_info[graphic];
7350 int gd_x1 = gd->src_x;
7351 int gd_y1 = gd->src_y;
7352 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7353 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7354 struct GadgetInfo *gi;
7355 int items_max, items_visible, item_position;
7356 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7358 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7360 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7361 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7362 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7364 else // drawing area scrollbars
7366 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7368 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7369 items_visible = ed_fieldx;
7374 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7375 items_visible = ed_fieldy;
7380 gi = CreateGadget(GDI_CUSTOM_ID, id,
7381 GDI_CUSTOM_TYPE_ID, i,
7382 GDI_IMAGE_ID, graphic,
7383 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7384 GDI_X, scrollbar_pos[i].x,
7385 GDI_Y, scrollbar_pos[i].y,
7386 GDI_WIDTH, scrollbar_pos[i].width,
7387 GDI_HEIGHT, scrollbar_pos[i].height,
7388 GDI_TYPE, scrollbar_info[i].type,
7389 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7390 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7391 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7392 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7393 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7394 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7395 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7396 GDI_STATE, GD_BUTTON_UNPRESSED,
7397 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7398 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7399 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7400 GDI_EVENT_MASK, event_mask,
7401 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7402 GDI_CALLBACK_ACTION, HandleControlButtons,
7406 Fail("cannot create gadget");
7408 level_editor_gadget[id] = gi;
7412 static void CreateCheckbuttonGadgets(void)
7414 struct GadgetInfo *gi;
7417 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7419 int id = checkbutton_info[i].gadget_id;
7420 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7421 IMG_EDITOR_CHECKBOX);
7422 struct GraphicInfo *gd = &graphic_info[graphic];
7423 int gd_x1 = gd->src_x;
7424 int gd_y1 = gd->src_y;
7425 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7426 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7427 int gd_x1a = gd->src_x + gd->active_xoffset;
7428 int gd_y1a = gd->src_y + gd->active_yoffset;
7429 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7430 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7431 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7432 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7433 unsigned int event_mask = GD_EVENT_PRESSED;
7435 // determine horizontal position to the right of specified gadget
7436 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7437 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7438 ED_GADGET_TEXT_DISTANCE);
7440 // determine horizontal offset for leading text
7441 if (checkbutton_info[i].text_left != NULL)
7442 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7444 gi = CreateGadget(GDI_CUSTOM_ID, id,
7445 GDI_CUSTOM_TYPE_ID, i,
7446 GDI_IMAGE_ID, graphic,
7447 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7450 GDI_WIDTH, gd->width,
7451 GDI_HEIGHT, gd->height,
7452 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7453 GDI_CHECKED, *checkbutton_info[i].value,
7454 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7455 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7456 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7457 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7458 GDI_EVENT_MASK, event_mask,
7459 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7460 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7464 Fail("cannot create gadget");
7466 level_editor_gadget[id] = gi;
7467 right_gadget_border[id] =
7468 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7472 static void CreateRadiobuttonGadgets(void)
7474 int graphic = IMG_EDITOR_RADIOBUTTON;
7475 struct GraphicInfo *gd = &graphic_info[graphic];
7476 int gd_x1 = gd->src_x;
7477 int gd_y1 = gd->src_y;
7478 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7479 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7480 int gd_x1a = gd->src_x + gd->active_xoffset;
7481 int gd_y1a = gd->src_y + gd->active_yoffset;
7482 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7483 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7484 struct GadgetInfo *gi;
7487 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7489 int id = radiobutton_info[i].gadget_id;
7490 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7491 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7492 unsigned int event_mask = GD_EVENT_PRESSED;
7495 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7497 // determine horizontal position to the right of specified gadget
7498 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7499 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7500 ED_GADGET_TEXT_DISTANCE);
7502 // determine horizontal offset for leading text
7503 if (radiobutton_info[i].text_left != NULL)
7504 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7506 gi = CreateGadget(GDI_CUSTOM_ID, id,
7507 GDI_CUSTOM_TYPE_ID, i,
7508 GDI_IMAGE_ID, graphic,
7509 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7512 GDI_WIDTH, gd->width,
7513 GDI_HEIGHT, gd->height,
7514 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7515 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7516 GDI_CHECKED, checked,
7517 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7518 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7519 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7520 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7521 GDI_EVENT_MASK, event_mask,
7522 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7523 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7527 Fail("cannot create gadget");
7529 level_editor_gadget[id] = gi;
7530 right_gadget_border[id] =
7531 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7535 void CreateLevelEditorGadgets(void)
7537 // force EDITOR font inside level editor
7538 SetFontStatus(GAME_MODE_EDITOR);
7540 // these values are not constant, but can change at runtime
7541 ed_fieldx = MAX_ED_FIELDX - 1;
7542 ed_fieldy = MAX_ED_FIELDY - 1;
7544 num_editor_gadgets = NUM_EDITOR_GADGETS;
7546 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7548 level_editor_gadget =
7549 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7550 right_gadget_border =
7551 checked_calloc(num_editor_gadgets * sizeof(int));
7553 // set number of empty (padding) element buttons to maximum number of buttons
7554 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7556 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7557 editor_el_empty_ptr = editor_el_empty;
7559 use_permanent_palette = !editor.palette.show_as_separate_screen;
7561 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
7563 ReinitializeElementList();
7565 CreateControlButtons();
7566 CreateScrollbarGadgets();
7568 // order of function calls is important because of cross-references
7569 CreateCheckbuttonGadgets();
7570 CreateCounterButtons();
7571 CreateRadiobuttonGadgets();
7572 CreateTextInputGadgets();
7573 CreateTextAreaGadgets();
7574 CreateSelectboxGadgets();
7575 CreateGraphicbuttonGadgets();
7576 CreateTextbuttonGadgets();
7577 CreateDrawingAreas();
7582 void FreeLevelEditorGadgets(void)
7586 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
7588 for (i = 0; i < num_editor_gadgets; i++)
7590 FreeGadget(level_editor_gadget[i]);
7592 level_editor_gadget[i] = NULL;
7595 checked_free(level_editor_gadget);
7596 checked_free(right_gadget_border);
7598 checked_free(editor_el_empty);
7601 static void MapCounterButtons(int id)
7603 int font_nr = FONT_TEXT_1;
7604 int font_height = getFontHeight(font_nr);
7605 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7606 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7607 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7608 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7609 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7610 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7611 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7612 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7613 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7614 int yoffset = (gi_down->height - font_height) / 2;
7615 int x_left = gi_down->x - xoffset_left;
7616 int x_right; // set after gadget position was modified
7617 int y_above = gi_down->y - yoffset_above;
7619 int y; // set after gadget position was modified
7621 // counter limits must be changed first to prevent value truncation
7622 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7623 counterbutton_info[id].max_value);
7625 // right text position might have changed after setting position above
7626 x_right = gi_up->x + gi_up->width + xoffset_right;
7628 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7630 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
7631 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7632 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7634 ModifyGadget(gi_down, GDI_Y,
7635 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7636 ModifyGadget(gi_text, GDI_Y,
7637 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7638 ModifyGadget(gi_up, GDI_Y,
7639 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7642 // vertical position might have changed after setting position above
7643 y = gi_up->y + yoffset;
7645 if (counterbutton_info[id].text_above)
7646 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
7648 if (counterbutton_info[id].text_left)
7649 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7651 if (counterbutton_info[id].text_right)
7652 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7659 static void MapControlButtons(void)
7664 // map toolbox buttons (excluding special CE toolbox buttons)
7665 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7666 MapGadget(level_editor_gadget[i]);
7668 // map toolbox buttons (element properties buttons)
7669 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
7670 MapGadget(level_editor_gadget[i]);
7672 if (use_permanent_palette)
7674 // map buttons to select elements
7675 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7676 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
7677 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
7678 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
7679 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
7682 // map buttons to select level
7683 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
7684 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
7685 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
7686 MapCounterButtons(counter_id);
7689 static void MapDrawingArea(int id)
7691 int font_nr = FONT_TEXT_1;
7692 int font_height = getFontHeight(font_nr);
7693 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7694 int area_xsize = gi->drawing.area_xsize;
7695 int area_ysize = gi->drawing.area_ysize;
7696 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7697 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
7698 int x_left = gi->x - xoffset_left;
7699 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
7700 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
7701 int x_below = gi->x + (gi->width - xoffset_below) / 2;
7702 int y_side = gi->y + (gi->height - font_height) / 2;
7703 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
7704 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
7706 if (drawingarea_info[id].text_left)
7707 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
7709 if (drawingarea_info[id].text_right)
7710 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
7712 if (drawingarea_info[id].text_above)
7713 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
7715 if (drawingarea_info[id].text_below)
7716 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
7718 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
7720 DrawElementBorder(gi->x, gi->y,
7721 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
7722 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
7724 DrawDrawingArea(id);
7730 static void MapTextInputGadget(int id)
7732 int font_nr = FONT_TEXT_1;
7733 int font_height = getFontHeight(font_nr);
7734 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
7735 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7736 int x_above = ED_SETTINGS_X(textinput_info[id].x);
7737 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
7739 if (textinput_info[id].text_above)
7740 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
7742 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
7747 static void MapTextAreaGadget(int id)
7749 int font_nr = FONT_TEXT_1;
7750 int font_height = getFontHeight(font_nr);
7751 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7752 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7753 int x_above = ED_SETTINGS_X(textarea_info[id].x);
7754 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
7755 char *text_above = textarea_info[id].text_above;
7757 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
7758 text_above = textarea_info[id].text_above_cropped;
7761 DrawTextS(x_above, y_above, font_nr, text_above);
7763 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
7768 static void MapSelectboxGadget(int id)
7770 int font_nr = FONT_TEXT_1;
7771 int font_height = getFontHeight(font_nr);
7772 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
7773 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
7774 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7775 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7776 int yoffset = (gi->height - font_height) / 2;
7777 int x_left = gi->x - xoffset_left;
7778 int x_right = gi->x + gi->width + xoffset_right;
7779 int y_above = gi->y - yoffset_above;
7781 int y = gi->y + yoffset;
7783 if (selectbox_info[id].text_above)
7784 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
7786 if (selectbox_info[id].text_left)
7787 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
7789 if (selectbox_info[id].text_right)
7790 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
7792 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
7797 static void MapTextbuttonGadget(int id)
7799 int font_nr = FONT_TEXT_1;
7800 int font_height = getFontHeight(font_nr);
7801 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
7802 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
7803 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7804 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7805 int yoffset = (gi->height - font_height) / 2;
7806 int x_left = gi->x - xoffset_left;
7807 int x_right = gi->x + gi->width + xoffset_right;
7808 int y_above = gi->y - yoffset_above;
7810 int y = gi->y + yoffset;
7812 // only show button to delete change pages when more than minimum pages
7813 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
7814 custom_element.num_change_pages == MIN_CHANGE_PAGES)
7817 if (textbutton_info[id].text_above)
7818 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
7820 if (textbutton_info[id].text_left)
7821 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
7823 if (textbutton_info[id].text_right)
7824 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
7829 static void MapGraphicbuttonGadget(int id)
7831 int font_nr = FONT_TEXT_1;
7832 int font_height = getFontHeight(font_nr);
7833 struct GadgetInfo *gi = level_editor_gadget[graphicbutton_info[id].gadget_id];
7834 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
7835 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7836 int yoffset = (gi->height - font_height) / 2;
7837 int x_left = gi->x - xoffset_left;
7838 int x_right = gi->x + gi->width + xoffset_right;
7839 int y = gi->y + yoffset;
7841 if (graphicbutton_info[id].text_left)
7842 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
7844 if (graphicbutton_info[id].text_right)
7845 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
7850 static void MapRadiobuttonGadget(int id)
7852 int font_nr = FONT_TEXT_1;
7853 int font_height = getFontHeight(font_nr);
7854 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
7855 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7856 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7857 int yoffset = (gi->height - font_height) / 2;
7858 int x_left = gi->x - xoffset_left;
7859 int x_right = gi->x + gi->width + xoffset_right;
7860 int y = gi->y + yoffset;
7862 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
7864 if (radiobutton_info[id].text_left)
7865 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
7867 if (radiobutton_info[id].text_right)
7868 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
7870 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
7875 static void MapCheckbuttonGadget(int id)
7877 int font_nr = FONT_TEXT_1;
7878 int font_height = getFontHeight(font_nr);
7879 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
7880 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7881 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7882 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7883 int yoffset = (gi->height - font_height) / 2;
7884 int y_above = gi->y - yoffset_above;
7886 int x_left, x_right, y; // set after gadget position was modified
7888 // set position for gadgets with dynamically determined position
7889 if (checkbutton_info[id].x != -1) // do not change dynamic positions
7890 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x), GDI_END);
7891 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
7893 x_left = gi->x - xoffset_left;
7894 x_right = gi->x + gi->width + xoffset_right;
7895 y = gi->y + yoffset;
7897 if (checkbutton_info[id].text_above)
7898 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
7900 if (checkbutton_info[id].text_left)
7901 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
7903 if (checkbutton_info[id].text_right)
7904 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
7906 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
7911 static void MapMainDrawingArea(void)
7913 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
7914 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
7917 if (suppressBorderElement())
7919 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
7920 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
7923 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
7925 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
7926 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
7927 no_horizontal_scrollbar) ||
7928 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
7929 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
7930 no_vertical_scrollbar))
7933 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
7936 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
7938 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
7939 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
7942 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
7945 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
7948 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
7952 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
7954 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
7955 i == GADGET_ID_CUSTOM_COPY_TO ||
7956 i == GADGET_ID_CUSTOM_EXCHANGE ||
7957 i == GADGET_ID_CUSTOM_COPY ||
7958 i == GADGET_ID_CUSTOM_PASTE)
7961 MapGadget(level_editor_gadget[i]);
7963 UnmapGadget(level_editor_gadget[i]);
7968 static void MapLevelEditorToolboxCustomGadgets(void)
7970 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
7973 static void MapLevelEditorToolboxCustomGadgetsIfNeeded(void)
7975 if (IS_CUSTOM_ELEMENT(properties_element) ||
7976 IS_GROUP_ELEMENT(properties_element) ||
7977 IS_EMPTY_ELEMENT(properties_element))
7978 MapLevelEditorToolboxCustomGadgets();
7981 static void UnmapLevelEditorToolboxCustomGadgets(void)
7983 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
7986 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
7990 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
7992 if (i != GADGET_ID_SINGLE_ITEMS &&
7993 i != GADGET_ID_PICK_ELEMENT)
7995 struct GadgetInfo *gi = level_editor_gadget[i];
8003 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
8004 struct GraphicInfo *gd = &graphic_info[graphic];
8008 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
8009 gi->width, gi->height, gi->x, gi->y);
8011 redraw_mask |= REDRAW_DOOR_3;
8017 static void MapLevelEditorToolboxDrawingGadgets(void)
8019 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
8022 static void UnmapLevelEditorToolboxDrawingGadgets(void)
8024 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
8027 static void UnmapDrawingArea(int id)
8029 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
8032 static void UnmapLevelEditorFieldGadgets(void)
8036 for (i = 0; i < num_editor_gadgets; i++)
8037 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
8038 level_editor_gadget[i]->y))
8039 UnmapGadget(level_editor_gadget[i]);
8042 void UnmapLevelEditorGadgets(void)
8046 for (i = 0; i < num_editor_gadgets; i++)
8047 UnmapGadget(level_editor_gadget[i]);
8050 static void ResetUndoBuffer(void)
8052 undo_buffer_position = -1;
8053 undo_buffer_steps = -1;
8054 redo_buffer_steps = 0;
8056 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8058 level.changed = FALSE;
8061 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
8063 if (remap_toolbox_gadgets)
8065 ModifyEditorElementList();
8066 RedrawDrawingElements();
8069 if (edit_mode == ED_MODE_LEVELCONFIG)
8070 DrawLevelConfigWindow();
8071 else if (edit_mode == ED_MODE_PROPERTIES)
8072 DrawPropertiesWindow();
8073 else if (edit_mode == ED_MODE_PALETTE)
8074 DrawPaletteWindow();
8075 else // edit_mode == ED_MODE_DRAWING
8076 DrawDrawingWindowExt(remap_toolbox_gadgets);
8079 static void DrawEditModeWindow(void)
8081 DrawEditModeWindowExt(TRUE);
8084 static void DrawEditModeWindow_PlayfieldOnly(void)
8086 DrawEditModeWindowExt(FALSE);
8089 static void ChangeEditModeWindow(int new_edit_mode)
8091 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
8093 DrawEditModeWindow();
8096 static boolean LevelChanged(void)
8098 boolean field_changed = FALSE;
8101 for (y = 0; y < lev_fieldy; y++)
8102 for (x = 0; x < lev_fieldx; x++)
8103 if (Tile[x][y] != level.field[x][y])
8104 field_changed = TRUE;
8106 return (level.changed || field_changed);
8109 static boolean PrepareSavingIntoPersonalLevelSet(void)
8111 static LevelDirTree *last_copied_leveldir = NULL;
8112 static LevelDirTree *last_written_leveldir = NULL;
8113 static int last_copied_level_nr = -1;
8114 static int last_written_level_nr = -1;
8115 LevelDirTree *leveldir_former = leveldir_current;
8116 int level_nr_former = level_nr;
8119 // remember last mod/save so that for current session, we write
8120 // back to the same personal copy, asking only about overwrite.
8121 if (leveldir_current == last_copied_leveldir &&
8122 level_nr == last_copied_level_nr)
8124 // "cd" to personal level set dir (as used when writing last copy)
8125 leveldir_current = last_written_leveldir;
8126 level_nr = last_written_level_nr;
8131 if (!Request("This level is read-only! "
8132 "Save into personal level set?", REQ_ASK))
8135 // "cd" to personal level set dir (for writing copy the first time)
8137 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
8139 // this may happen if "setup.internal.create_user_levelset" is FALSE
8140 // or if file "levelinfo.conf" is missing in personal user level set
8141 if (leveldir_current == NULL)
8143 Request("Cannot find personal level set?!", REQ_CONFIRM);
8145 leveldir_current = leveldir_former;
8150 // find unused level number
8151 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
8153 static char *level_filename = NULL;
8155 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
8157 if (!fileExists(level_filename))
8161 last_copied_leveldir = leveldir_former;
8162 last_copied_level_nr = level_nr_former;
8164 last_written_leveldir = leveldir_current;
8165 last_written_level_nr = level_nr = new_level_nr;
8170 static void ModifyLevelConfigForSavingIntoPersonalLevelSet(char *former_name)
8172 static char *filename_levelinfo = NULL, *mod_name = NULL;
8175 // annotate this copy-and-mod in personal levelinfo.conf
8176 setString(&filename_levelinfo,
8177 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
8179 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
8181 fprintf(file, "\n");
8182 fprintf(file, "# level %d was modified from:\n", level_nr);
8183 fprintf(file, "# - previous level set name: %s\n",
8185 fprintf(file, "# - level within previous set: %d \"%s\"\n",
8186 level.file_info.nr, level.name);
8187 fprintf(file, "# - previous author: %s\n",
8189 fprintf(file, "# - previous save date: ");
8191 if (level.creation_date.src == DATE_SRC_LEVELFILE)
8193 fprintf(file, "%04d-%02d-%02d\n",
8194 level.creation_date.year,
8195 level.creation_date.month,
8196 level.creation_date.day);
8200 fprintf(file, "not recorded\n");
8206 if (level_nr > leveldir_current->last_level)
8207 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
8209 // else: allow the save even if annotation failed
8211 // now... spray graffiti on the old level vital statistics
8212 // user can change these; just trying to set a good baseline
8214 // don't truncate names for fear of making offensive or silly:
8215 // long-named original author only recorded in levelinfo.conf.
8216 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
8217 if (!strEqual(level.author, leveldir_current->author))
8219 setString(&mod_name, getStringCat3(leveldir_current->author,
8220 " after ", level.author));
8222 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8223 setString(&mod_name,
8224 getStringCat2(leveldir_current->author, " (ed.)"));
8226 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8227 setString(&mod_name, leveldir_current->author);
8229 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
8231 // less worried about truncation here
8232 setString(&mod_name, getStringCat2("Mod: ", level.name));
8233 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
8237 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
8238 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8242 for (x = 0; x < lev_fieldx; x++)
8243 for (y = 0; y < lev_fieldy; y++)
8244 dst[x][y] = src[x][y];
8247 static int setSelectboxValue(int selectbox_id, int new_value)
8249 int new_index_value = 0;
8252 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8253 if (selectbox_info[selectbox_id].options[i].value == new_value)
8254 new_index_value = i;
8256 *selectbox_info[selectbox_id].value =
8257 selectbox_info[selectbox_id].options[new_index_value].value;
8259 return new_index_value;
8262 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8266 // change action mode and arg variables according to action type variable
8267 for (i = 0; action_arg_options[i].value != -1; i++)
8269 if (action_arg_options[i].value == custom_element_change.action_type)
8271 int mode = action_arg_options[i].mode;
8273 // only change if corresponding selectbox has changed
8274 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8275 action_arg_modes[mode])
8276 custom_element_change.action_mode = -1;
8278 // only change if corresponding selectbox has changed
8279 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8280 action_arg_options[i].options)
8281 custom_element_change.action_arg = -1;
8288 static void setSelectboxSpecialActionOptions(void)
8292 // change action mode and arg selectbox according to action type selectbox
8293 for (i = 0; action_arg_options[i].value != -1; i++)
8295 if (action_arg_options[i].value == custom_element_change.action_type)
8297 int mode = action_arg_options[i].mode;
8299 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8300 action_arg_modes[mode]);
8301 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8302 custom_element_change.action_mode);
8304 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8305 action_arg_options[i].options);
8306 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8307 custom_element_change.action_arg);
8313 static void copy_custom_element_settings(int element_from, int element_to)
8315 struct ElementInfo *ei_from = &element_info[element_from];
8316 struct ElementInfo *ei_to = &element_info[element_to];
8318 copyElementInfo(ei_from, ei_to);
8321 static void replace_custom_element_in_settings(int element_from,
8326 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8328 struct ElementInfo *ei = &element_info[i];
8330 for (y = 0; y < 3; y++)
8331 for (x = 0; x < 3; x++)
8332 if (ei->content.e[x][y] == element_from)
8333 ei->content.e[x][y] = element_to;
8335 for (j = 0; j < ei->num_change_pages; j++)
8337 struct ElementChangeInfo *change = &ei->change_page[j];
8339 if (change->target_element == element_from)
8340 change->target_element = element_to;
8342 if (change->initial_trigger_element == element_from)
8343 change->initial_trigger_element = element_to;
8345 if (change->action_element == element_from)
8346 change->action_element = element_to;
8348 for (y = 0; y < 3; y++)
8349 for (x = 0; x < 3; x++)
8350 if (change->target_content.e[x][y] == element_from)
8351 change->target_content.e[x][y] = element_to;
8354 if (ei->group != NULL) // group or internal
8355 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8356 if (ei->group->element[j] == element_from)
8357 ei->group->element[j] = element_to;
8361 static void replace_custom_element_in_playfield(int element_from,
8366 for (x = 0; x < lev_fieldx; x++)
8367 for (y = 0; y < lev_fieldy; y++)
8368 if (Tile[x][y] == element_from)
8369 Tile[x][y] = element_to;
8372 static boolean CopyCustomElement(int element_old, int element_new,
8375 int copy_mode_orig = copy_mode;
8377 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8379 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8380 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8381 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8383 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8385 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8386 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8387 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8389 level.changed = TRUE;
8391 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8393 Request("Please choose custom element!", REQ_CONFIRM);
8397 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8399 Request("Please choose group element!", REQ_CONFIRM);
8403 else if (IS_EMPTY_ELEMENT(element_old) && !IS_EMPTY_ELEMENT(element_new))
8405 Request("Please choose empty element!", REQ_CONFIRM);
8411 level.changed = TRUE;
8414 // when modifying custom/group element, ask for copying level template
8415 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8417 if (!AskToCopyAndModifyLevelTemplate())
8421 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8423 copy_custom_element_settings(element_new, element_old);
8425 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8427 copy_custom_element_settings(element_old, element_new);
8429 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8431 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8432 copy_custom_element_settings(element_new, element_old);
8433 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8435 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8436 replace_custom_element_in_settings(element_new, element_old);
8437 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8439 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8440 replace_custom_element_in_playfield(element_new, element_old);
8441 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8444 UpdateCustomElementGraphicGadgets();
8445 DrawPropertiesWindow();
8450 static void CopyCustomElementPropertiesToEditor(int element)
8453 int current_change_page = element_info[element].current_change_page;
8455 // dynamically (re)build selectbox for selecting change page
8456 for (i = 0; i < element_info[element].num_change_pages; i++)
8458 sprintf(options_change_page_strings[i], "%d", i + 1);
8460 options_change_page[i].value = i;
8461 options_change_page[i].text = options_change_page_strings[i];
8464 options_change_page[i].value = -1;
8465 options_change_page[i].text = NULL;
8467 // needed here to initialize combined element properties
8468 InitElementPropertiesEngine(level.game_version);
8470 element_info[element].change =
8471 &element_info[element].change_page[current_change_page];
8473 custom_element = element_info[element];
8474 custom_element_change = *element_info[element].change;
8476 // needed to initially set selectbox options for special action options
8477 setSelectboxSpecialActionOptions();
8479 // needed to initially set selectbox value variables to reliable defaults
8480 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8481 setSelectboxValue(i, *selectbox_info[i].value);
8483 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8484 custom_element_properties[i] = HAS_PROPERTY(element, i);
8486 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8487 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8489 // ---------- element settings: configure (custom elements) -----------------
8491 // set accessible layer selectbox help value
8492 custom_element.access_type =
8493 (IS_WALKABLE(element) ? EP_WALKABLE :
8494 IS_PASSABLE(element) ? EP_PASSABLE :
8495 custom_element.access_type);
8496 custom_element.access_layer =
8497 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8498 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8499 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8500 custom_element.access_layer);
8501 custom_element.access_protected =
8502 (IS_PROTECTED(element) ? 1 : 0);
8503 custom_element_properties[EP_ACCESSIBLE] =
8504 (IS_ACCESSIBLE_OVER(element) ||
8505 IS_ACCESSIBLE_INSIDE(element) ||
8506 IS_ACCESSIBLE_UNDER(element));
8508 // set walk-to-object action selectbox help value
8509 custom_element.walk_to_action =
8510 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8511 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8512 IS_DROPPABLE(element) ? EP_DROPPABLE :
8513 IS_THROWABLE(element) ? EP_THROWABLE :
8514 IS_PUSHABLE(element) ? EP_PUSHABLE :
8515 custom_element.walk_to_action);
8516 custom_element_properties[EP_WALK_TO_OBJECT] =
8517 (IS_DIGGABLE(element) ||
8518 IS_COLLECTIBLE_ONLY(element) ||
8519 IS_DROPPABLE(element) ||
8520 IS_THROWABLE(element) ||
8521 IS_PUSHABLE(element));
8523 // set smash targets selectbox help value
8524 custom_element.smash_targets =
8525 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8526 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8527 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8528 custom_element.smash_targets);
8529 custom_element_properties[EP_CAN_SMASH] =
8530 (CAN_SMASH_EVERYTHING(element) ||
8531 CAN_SMASH_ENEMIES(element) ||
8532 CAN_SMASH_PLAYER(element));
8534 // set deadliness selectbox help value
8535 custom_element.deadliness =
8536 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8537 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8538 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8539 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8540 custom_element.deadliness);
8541 custom_element_properties[EP_DEADLY] =
8542 (DONT_TOUCH(element) ||
8543 DONT_GET_HIT_BY(element) ||
8544 DONT_COLLIDE_WITH(element) ||
8545 DONT_RUN_INTO(element));
8547 // ---------- element settings: advanced (custom elements) ------------------
8549 // set "change by direct action" selectbox help value
8550 custom_element_change.direct_action =
8551 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
8552 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8553 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8554 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8555 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8556 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8557 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8558 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8559 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8560 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8561 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8562 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8563 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8564 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8565 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8566 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8567 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8568 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8569 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8570 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
8571 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
8572 custom_element_change.direct_action);
8574 // set "change by other element action" selectbox help value
8575 custom_element_change.other_action =
8576 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
8577 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8578 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8579 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8580 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8581 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8582 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8583 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8584 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8585 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8586 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8587 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
8588 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8589 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8590 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8591 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8592 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8593 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8594 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8595 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8596 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8597 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8598 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8599 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8600 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8601 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
8602 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
8603 custom_element_change.other_action);
8606 static void CopyGroupElementPropertiesToEditor(int element)
8608 group_element_info = *element_info[element].group;
8609 custom_element = element_info[element]; // needed for description
8612 static void CopyEmptyElementPropertiesToEditor(int element)
8614 custom_element = element_info[element];
8617 static void CopyClassicElementPropertiesToEditor(int element)
8619 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8620 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
8621 getMoveIntoAcidProperty(&level, element);
8623 if (MAYBE_DONT_COLLIDE_WITH(element))
8624 custom_element_properties[EP_DONT_COLLIDE_WITH] =
8625 getDontCollideWithProperty(&level, element);
8628 static void CopyElementPropertiesToEditor(int element)
8630 if (IS_CUSTOM_ELEMENT(element))
8631 CopyCustomElementPropertiesToEditor(element);
8632 else if (IS_GROUP_ELEMENT(element))
8633 CopyGroupElementPropertiesToEditor(element);
8634 else if (IS_EMPTY_ELEMENT(element))
8635 CopyEmptyElementPropertiesToEditor(element);
8637 CopyClassicElementPropertiesToEditor(element);
8640 static boolean AskToCopyAndModifyLevelTemplate(void)
8642 if (Request("Copy and modify settings from level template?", REQ_ASK))
8644 level.use_custom_template = FALSE;
8646 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
8647 GDI_CHECKED, FALSE, GDI_END);
8648 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
8649 GDI_CHECKED, FALSE, GDI_END);
8655 LoadLevelTemplate(-1); // this resets all element modifications ...
8657 DrawEditModeWindow(); // ... and copies them to 'custom_element'
8663 static void CopyCustomElementPropertiesToGame(int element)
8666 int access_type_and_layer;
8668 // mark that this custom element has been modified
8669 custom_element.modified_settings = TRUE;
8670 level.changed = TRUE;
8672 if (level.use_custom_template)
8673 AskToCopyAndModifyLevelTemplate();
8675 element_info[element] = custom_element;
8676 *element_info[element].change = custom_element_change;
8678 // ---------- element settings: configure (custom elements) -----------------
8680 // set accessible property from checkbox and selectbox
8681 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
8682 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
8683 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
8684 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
8685 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
8686 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
8687 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
8688 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
8689 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
8690 custom_element_properties[access_type_and_layer] =
8691 custom_element_properties[EP_ACCESSIBLE];
8692 custom_element_properties[EP_PROTECTED] =
8693 (custom_element.access_protected != 0 &&
8694 custom_element_properties[EP_ACCESSIBLE]);
8696 // set walk-to-object property from checkbox and selectbox
8697 custom_element_properties[EP_DIGGABLE] = FALSE;
8698 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
8699 custom_element_properties[EP_DROPPABLE] = FALSE;
8700 custom_element_properties[EP_THROWABLE] = FALSE;
8701 custom_element_properties[EP_PUSHABLE] = FALSE;
8702 custom_element_properties[custom_element.walk_to_action] =
8703 custom_element_properties[EP_WALK_TO_OBJECT];
8705 // set smash property from checkbox and selectbox
8706 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
8707 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
8708 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
8709 custom_element_properties[custom_element.smash_targets] =
8710 custom_element_properties[EP_CAN_SMASH];
8712 // set deadliness property from checkbox and selectbox
8713 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
8714 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
8715 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
8716 custom_element_properties[EP_DONT_TOUCH] = FALSE;
8717 custom_element_properties[custom_element.deadliness] =
8718 custom_element_properties[EP_DEADLY];
8720 // ---------- element settings: advanced (custom elements) ------------------
8722 // set player change event from checkbox and selectbox
8723 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
8724 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
8725 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
8726 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
8727 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
8728 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
8729 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
8730 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
8731 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
8732 custom_element_change_events[CE_SWITCHED] = FALSE;
8733 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
8734 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
8735 custom_element_change_events[CE_BLOCKED] = FALSE;
8736 custom_element_change_events[CE_IMPACT] = FALSE;
8737 custom_element_change_events[CE_SMASHED] = FALSE;
8738 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
8739 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
8740 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
8741 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
8742 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
8743 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
8744 custom_element_change_events[custom_element_change.direct_action] =
8745 custom_element_change_events[CE_BY_DIRECT_ACTION];
8747 // set other element action change event from checkbox and selectbox
8748 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
8749 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
8750 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
8751 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
8752 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
8753 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
8754 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
8755 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
8756 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
8757 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
8758 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
8759 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
8760 custom_element_change_events[CE_TOUCHING_X] = FALSE;
8761 custom_element_change_events[CE_HITTING_X] = FALSE;
8762 custom_element_change_events[CE_DIGGING_X] = FALSE;
8763 custom_element_change_events[CE_HIT_BY_X] = FALSE;
8764 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
8765 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
8766 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
8767 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
8768 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
8769 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
8770 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
8771 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
8772 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
8773 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
8774 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
8775 custom_element_change_events[custom_element_change.other_action] =
8776 custom_element_change_events[CE_BY_OTHER_ACTION];
8778 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8779 SET_PROPERTY(element, i, custom_element_properties[i]);
8781 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8782 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
8784 // copy change events also to special level editor variable
8785 custom_element = element_info[element];
8786 custom_element_change = *element_info[element].change;
8788 // needed here to restore runtime value "element_info[element].gfx_element"
8789 InitElementPropertiesGfxElement();
8792 static void CopyGroupElementPropertiesToGame(int element)
8794 // mark that this group element has been modified
8795 custom_element.modified_settings = TRUE;
8796 level.changed = TRUE;
8798 if (level.use_custom_template)
8799 AskToCopyAndModifyLevelTemplate();
8801 element_info[element] = custom_element;
8802 *element_info[element].group = group_element_info;
8804 // needed here to restore runtime value "element_info[element].gfx_element"
8805 InitElementPropertiesGfxElement();
8808 static void CopyEmptyElementPropertiesToGame(int element)
8810 // mark that this empty element has been modified
8811 custom_element.modified_settings = TRUE;
8812 level.changed = TRUE;
8814 if (level.use_custom_template)
8815 AskToCopyAndModifyLevelTemplate();
8817 element_info[element] = custom_element;
8819 // needed here to restore runtime value "element_info[element].gfx_element"
8820 InitElementPropertiesGfxElement();
8823 static void CopyClassicElementPropertiesToGame(int element)
8825 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8826 setMoveIntoAcidProperty(&level, element,
8827 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
8829 if (MAYBE_DONT_COLLIDE_WITH(element))
8830 setDontCollideWithProperty(&level, element,
8831 custom_element_properties[EP_DONT_COLLIDE_WITH]);
8834 static void CopyElementPropertiesToGame(int element)
8836 if (IS_CUSTOM_ELEMENT(element))
8837 CopyCustomElementPropertiesToGame(element);
8838 else if (IS_GROUP_ELEMENT(element))
8839 CopyGroupElementPropertiesToGame(element);
8840 else if (IS_EMPTY_ELEMENT(element))
8841 CopyEmptyElementPropertiesToGame(element);
8843 CopyClassicElementPropertiesToGame(element);
8847 static void CheckElementDescriptions(void)
8851 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8852 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
8853 Warn("no element description file for element '%s'", EL_NAME(i));
8857 static int getMaxEdFieldX(boolean has_scrollbar)
8859 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
8860 int sxsize = SXSIZE - scrollbar_width;
8861 int max_ed_fieldx = sxsize / ed_tilesize;
8863 return max_ed_fieldx;
8866 static int getMaxEdFieldY(boolean has_scrollbar)
8868 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
8869 INFOTEXT_YSIZE_FULL : 0);
8870 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
8871 int sysize = SYSIZE - scrollbar_height - infotext_height;
8872 int max_ed_fieldy = sysize / ed_tilesize;
8874 return max_ed_fieldy;
8877 static void InitZoomLevelSettings(int zoom_tilesize)
8879 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
8881 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
8883 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
8884 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
8886 // make sure that tile size is always a power of 2
8887 ed_tilesize = (1 << log_2(ed_tilesize));
8889 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8891 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
8892 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
8896 last_game_engine_type = level.game_engine_type;
8898 // limit zoom tilesize by upper and lower bound
8899 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
8901 // store zoom tilesize in auto setup file only if it was manually changed
8902 if (zoom_tilesize != -1)
8903 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
8905 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
8906 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
8909 static void InitDrawingElements(void)
8911 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
8913 if (level.game_engine_type == game_engine_type_last)
8916 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
8918 new_element1 = EL_BD_WALL;
8919 new_element2 = EL_EMPTY;
8920 new_element3 = EL_BD_SAND;
8922 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
8924 new_element1 = EL_SP_CHIP_SINGLE;
8925 new_element2 = EL_EMPTY;
8926 new_element3 = EL_SP_BASE;
8928 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8930 new_element1 = EL_MM_MIRROR_START;
8931 new_element2 = EL_EMPTY;
8932 new_element3 = EL_MM_WOODEN_WALL;
8936 new_element1 = EL_WALL;
8937 new_element2 = EL_EMPTY;
8938 new_element3 = EL_SAND;
8941 game_engine_type_last = level.game_engine_type;
8944 static void InitLevelSetInfo(void)
8946 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
8947 "%s", leveldir_current->name);
8948 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
8949 "%s", leveldir_current->author);
8951 levelset_num_levels = leveldir_current->levels;
8953 levelset_use_levelset_artwork = FALSE;
8954 levelset_copy_level_template = FALSE;
8956 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
8959 static void ChangeEditorToLevelSet(char *levelset_subdir)
8961 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
8963 // the previous level set might have used custom artwork
8964 ReloadCustomArtwork(0);
8966 LoadLevelSetup_SeriesInfo();
8968 SaveLevelSetup_LastSeries();
8969 SaveLevelSetup_SeriesInfo();
8973 LoadLevel(level_nr);
8974 LoadScore(level_nr);
8979 static boolean useEditorDoorAnimation(void)
8981 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
8982 boolean door_1_viewport_unchanged =
8983 (vp_door_1->x == DX &&
8984 vp_door_1->y == DY &&
8985 vp_door_1->width == DXSIZE &&
8986 vp_door_1->height == DYSIZE);
8987 boolean door_1_contains_toolbox =
8990 EX + EXSIZE <= DX + DXSIZE &&
8991 EY + EYSIZE <= DY + DYSIZE);
8993 return (door_1_viewport_unchanged && door_1_contains_toolbox);
8996 static void DrawEditorDoorBackground(int graphic, int x, int y,
8997 int width, int height)
8999 struct GraphicInfo *g = &graphic_info[graphic];
9001 if (g->bitmap != NULL)
9002 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
9003 MIN(width, g->width), MIN(height, g->height), x, y);
9005 ClearRectangle(drawto, x, y, width, height);
9008 static void DrawEditorDoorContent(void)
9010 // needed for gadgets drawn on background (like palette scrollbar)
9011 SetDoorBackgroundImage(IMG_UNDEFINED);
9013 // copy default editor door content to main double buffer
9014 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
9017 DrawSpecialEditorDoor();
9019 // draw new control window
9020 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
9022 // draw all toolbox gadgets to editor doors
9023 MapControlButtons();
9025 // when returning from test game to properties page, redraw toolbox gadgets
9026 if (edit_mode == ED_MODE_PROPERTIES)
9028 UnmapLevelEditorToolboxDrawingGadgets();
9029 UnmapLevelEditorToolboxCustomGadgets();
9031 MapLevelEditorToolboxCustomGadgetsIfNeeded();
9034 // draw all palette gadgets to editor doors
9035 ModifyEditorElementList();
9036 RedrawDrawingElements();
9038 // copy actual editor door content to door double buffer for OpenDoor()
9039 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
9042 void DrawLevelEd(void)
9044 int fade_mask = REDRAW_FIELD;
9046 FadeSoundsAndMusic();
9049 fade_mask = REDRAW_ALL;
9053 // needed if different viewport properties defined for editor
9054 ChangeViewportPropertiesIfNeeded();
9058 InitZoomLevelSettings(-1);
9059 InitDrawingElements();
9063 CheckElementDescriptions();
9066 if (level_editor_test_game)
9068 CopyPlayfield(level.field, Tile);
9069 CopyPlayfield(TileBackup, level.field);
9071 level_editor_test_game = FALSE;
9075 edit_mode = ED_MODE_DRAWING;
9076 edit_mode_levelconfig = ED_MODE_LEVELCONFIG_LEVEL;
9077 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
9085 // redraw_mask |= REDRAW_ALL;
9087 FreeLevelEditorGadgets();
9088 CreateLevelEditorGadgets();
9090 ReinitializeElementList(); // update dynamic level element list
9091 ReinitializeElementListButtons(); // custom element may look different
9093 InitElementPropertiesGfxElement();
9097 DrawEditModeWindow_PlayfieldOnly();
9099 DrawMaskedBorder(fade_mask);
9101 // use door animation if door 1 viewport is unchanged and contains toolbox
9102 if (useEditorDoorAnimation())
9106 DrawEditorDoorContent();
9108 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
9112 DrawEditorDoorContent();
9117 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
9120 static void AdjustDrawingAreaGadgets(void)
9122 int ed_xsize = lev_fieldx + 2;
9123 int ed_ysize = lev_fieldy + 2;
9124 int max_ed_fieldx = MAX_ED_FIELDX;
9125 int max_ed_fieldy = MAX_ED_FIELDY;
9126 boolean horizontal_scrollbar_needed;
9127 boolean vertical_scrollbar_needed;
9128 int x, y, width, height;
9130 if (suppressBorderElement())
9132 ed_xsize = lev_fieldx;
9133 ed_ysize = lev_fieldy;
9136 // check if we need any scrollbars
9137 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9138 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9140 // check if we have a smaller editor field because of scrollbars
9141 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9142 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9144 // check again if we now need more scrollbars because of less space
9145 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9146 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9148 // check if editor field gets even smaller after adding new scrollbars
9149 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9150 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9152 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
9153 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
9155 x = SX + ed_fieldx * ed_tilesize;
9156 y = SY + ed_fieldy * ed_tilesize;
9158 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
9159 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
9161 // adjust drawing area gadget
9162 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
9163 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
9164 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
9167 // adjust horizontal scrollbar gadgets
9168 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
9171 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
9172 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
9175 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9178 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
9181 // adjust vertical scrollbar gadgets
9182 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
9185 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
9187 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
9189 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9192 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
9196 static void AdjustLevelScrollPosition(void)
9198 if (level_xpos < -1)
9200 if (level_xpos > lev_fieldx - ed_fieldx + 1)
9201 level_xpos = lev_fieldx - ed_fieldx + 1;
9202 if (lev_fieldx < ed_fieldx - 2)
9205 if (level_ypos < -1)
9207 if (level_ypos > lev_fieldy - ed_fieldy + 1)
9208 level_ypos = lev_fieldy - ed_fieldy + 1;
9209 if (lev_fieldy < ed_fieldy - 2)
9212 if (suppressBorderElement())
9219 static void AdjustEditorScrollbar(int id)
9221 struct GadgetInfo *gi = level_editor_gadget[id];
9222 int items_max, items_visible, item_position;
9224 if (id == GADGET_ID_SCROLL_HORIZONTAL)
9226 items_max = MAX(lev_fieldx + 2, ed_fieldx);
9227 items_visible = ed_fieldx;
9228 item_position = level_xpos + 1;
9232 items_max = MAX(lev_fieldy + 2, ed_fieldy);
9233 items_visible = ed_fieldy;
9234 item_position = level_ypos + 1;
9237 if (item_position > items_max - items_visible)
9238 item_position = items_max - items_visible;
9240 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9241 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9244 static void AdjustElementListScrollbar(void)
9246 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
9247 int items_max, items_visible, item_position;
9249 // correct position of element list scrollbar
9250 if (element_shift < 0)
9252 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9253 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9255 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
9256 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
9257 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
9259 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9260 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
9261 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9264 static void ModifyEditorCounterValue(int counter_id, int new_value)
9266 int *counter_value = counterbutton_info[counter_id].value;
9267 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9268 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9270 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9272 if (counter_value != NULL)
9273 *counter_value = gi->textinput.number_value;
9276 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9278 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9279 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9281 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9283 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9284 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9286 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9287 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9289 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9290 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9295 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9297 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9298 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9299 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9301 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9304 static void ModifyEditorSelectboxOptions(int selectbox_id,
9305 struct ValueTextInfo *options)
9307 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9308 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9310 selectbox_info[selectbox_id].options = options;
9312 // set index to zero -- list may be shorter now (correct later, if needed)
9313 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9314 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9317 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9319 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9320 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9322 drawingarea_info[drawingarea_id].area_xsize = xsize;
9323 drawingarea_info[drawingarea_id].area_ysize = ysize;
9325 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9328 static void ModifyEditorElementList(void)
9332 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9335 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9337 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9338 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9339 struct GadgetDesign *gd = &gi->deco.design;
9340 int element = editor_elements[element_shift + i];
9341 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9345 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9347 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9353 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9355 int graphic = el2edimg(element);
9356 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9362 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9365 static void ModifyDrawingElementButton(int element, int id)
9367 struct GadgetInfo *gi = level_editor_gadget[id];
9368 Bitmap *deco_bitmap;
9370 int tile_size = gi->deco.width;
9372 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9374 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9377 static void PickDrawingElement(int button, int element)
9382 struct XYTileSize *pos;
9384 } de, drawing_elements[] =
9386 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9387 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9388 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9391 if (button < 1 || button > 3)
9394 if (IS_MM_WALL(element))
9395 element = map_mm_wall_element(element);
9397 de = drawing_elements[button - 1];
9399 *de.new_element = element; // update global drawing element variable
9401 DrawDrawingElementGraphic(element, de.pos);
9402 ModifyDrawingElementButton(element, de.id);
9404 redraw_mask |= REDRAW_DOOR_1;
9407 static void RedrawDrawingElements(void)
9409 PickDrawingElement(1, new_element1);
9410 PickDrawingElement(2, new_element2);
9411 PickDrawingElement(3, new_element3);
9414 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9416 stick_element_properties_window = FALSE;
9418 SetMainBackgroundImage(IMG_UNDEFINED);
9421 UnmapLevelEditorFieldGadgets();
9423 AdjustDrawingAreaGadgets();
9424 AdjustLevelScrollPosition();
9425 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9426 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9428 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9430 MapMainDrawingArea();
9432 if (remap_toolbox_gadgets)
9434 UnmapLevelEditorToolboxCustomGadgets();
9435 MapLevelEditorToolboxDrawingGadgets();
9439 static void DrawDrawingWindow(void)
9441 DrawDrawingWindowExt(TRUE);
9444 static int getTabulatorBarWidth(void)
9446 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9447 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9449 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9452 static int getTabulatorBarHeight(void)
9454 return ED_TAB_BAR_HEIGHT;
9457 static Pixel getTabulatorBarColor(void)
9459 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9460 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9461 int gd_x = gd->x + gd_gi1->border.width / 2;
9462 int gd_y = gd->y + gd_gi1->height - 1;
9464 return GetPixel(gd->bitmap, gd_x, gd_y);
9467 static void DrawLevelConfigTabulatorGadgets(void)
9469 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9470 Pixel tab_color = getTabulatorBarColor();
9471 int id_first = ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST;
9472 int id_last = ED_TAB_BUTTON_ID_LEVELCONFIG_LAST;
9475 for (i = id_first; i <= id_last; i++)
9477 int gadget_id = textbutton_info[i].gadget_id;
9478 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9479 boolean active = (i != edit_mode_levelconfig);
9481 // draw background line below tabulator button
9482 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9484 // draw solid line below inactive tabulator buttons
9485 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9486 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9487 ED_GADGET_TINY_DISTANCE, tab_color);
9489 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9490 MapTextbuttonGadget(i);
9493 // draw little border line below tabulator buttons
9494 if (tab_color != BLACK_PIXEL) // black => transparent
9495 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9496 ED_GADGET_TINY_DISTANCE,
9497 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9500 static void DrawPropertiesTabulatorGadgets(void)
9502 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9503 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9504 int gd_x = gd->x + gd_gi1->border.width / 2;
9505 int gd_y = gd->y + gd_gi1->height - 1;
9506 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9507 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9508 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9511 // draw two config tabulators for player elements
9512 if (IS_PLAYER_ELEMENT(properties_element))
9513 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9515 // draw two config and one "change" tabulator for custom elements
9516 if (IS_CUSTOM_ELEMENT(properties_element))
9517 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9519 for (i = id_first; i <= id_last; i++)
9521 int gadget_id = textbutton_info[i].gadget_id;
9522 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9523 boolean active = (i != edit_mode_properties);
9525 // use "config 1" and "config 2" instead of "config" for players and CEs
9526 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9527 (IS_PLAYER_ELEMENT(properties_element) ||
9528 IS_CUSTOM_ELEMENT(properties_element)))
9531 // draw background line below tabulator button
9532 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9534 // draw solid line below inactive tabulator buttons
9535 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9536 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9537 ED_GADGET_TINY_DISTANCE, tab_color);
9539 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9540 MapTextbuttonGadget(i);
9543 // draw little border line below tabulator buttons
9544 if (tab_color != BLACK_PIXEL) // black => transparent
9545 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9546 ED_GADGET_TINY_DISTANCE,
9547 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9550 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9552 DrawText(SX + xpos, SY + ypos, text, font_nr);
9555 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9558 int font_width = getFontWidth(font_nr);
9559 int font_height = getFontHeight(font_nr);
9560 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9561 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9563 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9564 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9565 TRUE, FALSE, FALSE);
9568 static void DrawLevelConfigLevel(void)
9572 // draw counter gadgets
9573 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9574 MapCounterButtons(i);
9576 // draw checkbutton gadgets
9577 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9578 MapCheckbuttonGadget(i);
9580 // draw selectbox gadgets
9581 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9582 MapSelectboxGadget(i);
9584 // draw text input gadgets
9585 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9586 MapTextInputGadget(i);
9589 static char *getLevelSubdirFromSaveMode(int save_mode)
9591 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9592 return getNewUserLevelSubdir();
9594 return leveldir_current->subdir;
9597 static void DrawLevelConfigLevelSet_DirectoryInfo(void)
9599 char *directory_text = "Level set directory:";
9600 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9601 int font1_nr = FONT_TEXT_1;
9602 int font2_nr = FONT_TEXT_2;
9603 int font1_height = getFontHeight(font1_nr);
9604 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
9605 int x = ED_LEVEL_SETTINGS_X(0);
9606 int y = ED_LEVEL_SETTINGS_Y(6);
9608 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
9609 PrintInfoText(directory_name, font2_nr, x, y);
9612 static void DrawLevelConfigLevelSet(void)
9614 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
9615 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
9618 // draw counter gadgets
9619 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
9620 MapCounterButtons(i);
9622 // draw checkbutton gadgets
9623 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
9625 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
9626 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
9627 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
9630 MapCheckbuttonGadget(i);
9633 // draw selectbox gadgets
9634 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
9635 MapSelectboxGadget(i);
9637 // draw text input gadgets
9638 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
9639 MapTextInputGadget(i);
9641 // draw textbutton gadgets
9642 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
9645 DrawLevelConfigLevelSet_DirectoryInfo();
9648 static void DrawLevelConfigEditor(void)
9652 // draw counter gadgets
9653 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
9654 MapCounterButtons(i);
9656 // draw checkbutton gadgets
9657 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
9658 MapCheckbuttonGadget(i);
9660 // draw radiobutton gadgets
9661 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
9662 MapRadiobuttonGadget(i);
9664 // draw drawing area
9665 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
9667 // draw textbutton gadgets
9668 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
9671 static void DrawLevelConfigWindow(void)
9673 char *text = "Global Settings";
9674 int font_nr = FONT_TITLE_1;
9675 struct MenuPosInfo *pos = &editor.settings.headline;
9676 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
9677 int sy = SY + pos->y;
9679 stick_element_properties_window = FALSE;
9681 SetAutomaticNumberOfGemsNeeded();
9683 UnmapLevelEditorFieldGadgets();
9685 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9688 DrawText(sx, sy, text, font_nr);
9690 DrawLevelConfigTabulatorGadgets();
9692 if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVEL)
9693 DrawLevelConfigLevel();
9694 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVELSET)
9695 DrawLevelConfigLevelSet();
9696 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_EDITOR)
9697 DrawLevelConfigEditor();
9700 static void DrawCustomContentArea(void)
9702 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
9703 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9704 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
9705 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
9706 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
9707 int xoffset = ED_GADGET_SPACE_DISTANCE;
9709 // add distance for potential left text (without drawing area border)
9710 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
9712 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9714 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
9717 static void DrawCustomChangeContentArea(void)
9719 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
9720 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9721 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
9722 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
9723 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
9724 int xoffset = ED_GADGET_SPACE_DISTANCE;
9726 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9731 static void RemoveElementContentArea(int id, int font_height)
9733 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9735 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
9736 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
9737 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9738 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
9739 ED_GADGET_TEXT_DISTANCE + font_height);
9742 static void DrawYamYamContentAreas(void)
9744 int font_nr = FONT_TEXT_1;
9745 int font_height = getFontHeight(font_nr);
9746 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9747 int yoffset = (tilesize - font_height) / 2;
9748 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
9749 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
9752 // display counter to choose number of element content areas
9753 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
9755 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9757 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
9759 if (i < level.num_yamyam_contents)
9765 UnmapDrawingArea(id);
9767 // delete content areas in case of reducing number of them
9768 RemoveElementContentArea(id, font_height);
9772 DrawText(x, y + 0 * tilesize, "content", font_nr);
9773 DrawText(x, y + 1 * tilesize, "when", font_nr);
9774 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
9777 static void DrawMagicBallContentAreas(void)
9779 int font_nr = FONT_TEXT_1;
9780 int font_height = getFontHeight(font_nr);
9781 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9782 int yoffset = (tilesize - font_height) / 2;
9783 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
9784 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
9787 // display counter to choose number of element content areas
9788 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
9790 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9792 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
9794 if (i < level.num_ball_contents)
9800 UnmapDrawingArea(id);
9802 // delete content areas in case of reducing number of them
9803 RemoveElementContentArea(id, font_height);
9807 DrawText(x, y + 0 * tilesize, "generated", font_nr);
9808 DrawText(x, y + 1 * tilesize, "when", font_nr);
9809 DrawText(x, y + 2 * tilesize, "active", font_nr);
9812 static void DrawAndroidElementArea(void)
9814 int id = ED_DRAWING_ID_ANDROID_CONTENT;
9815 int num_elements = level.num_android_clone_elements;
9816 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9817 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9818 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9819 int xsize = MAX_ANDROID_ELEMENTS;
9822 // display counter to choose number of element areas
9823 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
9825 if (drawingarea_info[id].text_left != NULL)
9826 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9828 UnmapDrawingArea(id);
9830 ModifyEditorDrawingArea(id, num_elements, 1);
9832 // delete content areas in case of reducing number of them
9833 DrawBackground(sx, sy,
9834 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9835 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9840 static void DrawGroupElementArea(void)
9842 int id = ED_DRAWING_ID_GROUP_CONTENT;
9843 int num_elements = group_element_info.num_elements;
9844 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9845 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9846 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9847 int xsize = MAX_ELEMENTS_IN_GROUP;
9850 if (drawingarea_info[id].text_left != NULL)
9851 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9853 UnmapDrawingArea(id);
9855 ModifyEditorDrawingArea(id, num_elements, 1);
9857 // delete content areas in case of reducing number of them
9858 DrawBackground(sx, sy,
9859 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9860 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9865 static void DrawPlayerInitialInventoryArea(int element)
9867 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
9868 int player_nr = GET_PLAYER_NR(element);
9869 int num_elements = level.initial_inventory_size[player_nr];
9870 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9871 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9872 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9873 int xsize = MAX_INITIAL_INVENTORY_SIZE;
9876 // determine horizontal position to the right of specified gadget
9877 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
9878 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
9879 ED_DRAWINGAREA_TEXT_DISTANCE);
9881 // determine horizontal offset for leading text
9882 if (drawingarea_info[id].text_left != NULL)
9883 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9885 UnmapDrawingArea(id);
9887 ModifyEditorDrawingArea(id, num_elements, 1);
9889 // delete content areas in case of reducing number of them
9890 DrawBackground(sx, sy,
9891 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9892 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9897 static void DrawMMBallContentArea(void)
9899 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
9900 int num_elements = level.num_mm_ball_contents;
9901 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9902 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9903 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9904 int xsize = MAX_MM_BALL_CONTENTS;
9907 if (drawingarea_info[id].text_left != NULL)
9908 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9910 UnmapDrawingArea(id);
9912 ModifyEditorDrawingArea(id, num_elements, 1);
9914 // delete content areas in case of reducing number of them
9915 DrawBackground(sx, sy,
9916 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9917 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9922 static void DrawEnvelopeTextArea(int envelope_nr)
9924 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
9925 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
9929 DrawBackground(gi->x, gi->y,
9930 gi->textarea.crop_width, gi->textarea.crop_height);
9932 if (envelope_nr != -1)
9933 textarea_info[id].value = level.envelope[envelope_nr].text;
9935 ModifyGadget(gi, GDI_AREA_SIZE,
9936 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
9937 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
9940 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
9943 static void DrawPropertiesInfo(void)
9952 // configurable properties
9954 { EP_WALKABLE_OVER, "- player can walk over it" },
9955 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
9956 { EP_WALKABLE_UNDER, "- player can walk under it" },
9957 { EP_PASSABLE_OVER, "- player can pass over it" },
9958 { EP_PASSABLE_INSIDE, "- player can pass through it" },
9959 { EP_PASSABLE_UNDER, "- player can pass under it" },
9960 { EP_PROTECTED, "- player is protected by it" },
9962 { EP_DIGGABLE, "- can be digged away" },
9963 { EP_COLLECTIBLE, "- can be collected" },
9964 { EP_DROPPABLE, "- can be dropped after collecting" },
9965 { EP_THROWABLE, "- can be thrown after collecting" },
9966 { EP_PUSHABLE, "- can be pushed" },
9968 { EP_CAN_FALL, "- can fall" },
9969 { EP_CAN_MOVE, "- can move" },
9971 { EP_CAN_SMASH_PLAYER, "- can smash player" },
9973 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
9975 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
9977 { EP_SLIPPERY, "- slippery for falling elements" },
9978 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
9980 { EP_DONT_RUN_INTO, "- deadly when running into" },
9981 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
9982 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
9983 { EP_DONT_TOUCH, "- deadly when touching" },
9985 { EP_INDESTRUCTIBLE, "- indestructible" },
9987 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
9988 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
9989 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
9991 { EP_CAN_CHANGE, "- can change to other element" },
9993 // pre-defined properties
9994 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
9995 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
9996 { EP_SWITCHABLE, "- can be switched" },
9998 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
10003 char *filename = getElementDescriptionFilename(properties_element);
10004 char *num_elements_text = "In this level: ";
10005 char *num_similar_text = "Similar tiles: ";
10006 char *properties_text = "Standard properties: ";
10007 char *description_text = "Description:";
10008 char *no_description_text = "No description available.";
10009 char *none_text = "None";
10011 int num_elements_in_level = 0;
10012 int num_similar_in_level = 0;
10013 int num_hires_tiles_in_level = 0;
10014 int num_standard_properties = 0;
10015 int font1_nr = FONT_TEXT_1;
10016 int font2_nr = FONT_TEXT_2;
10017 int font1_width = getFontWidth(font1_nr);
10018 int font1_height = getFontHeight(font1_nr);
10019 int font2_height = getFontHeight(font2_nr);
10020 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
10021 int font2_yoffset = (font1_height - font2_height) / 2;
10022 int num_elements_text_len = strlen(num_elements_text) * font1_width;
10023 int num_similar_text_len = strlen(num_similar_text) * font1_width;
10024 int properties_text_len = strlen(properties_text) * font1_width;
10025 int xpos = ED_ELEMENT_SETTINGS_X(0);
10026 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10029 if (setup.editor.show_element_token)
10031 int font3_nr = FONT_TEXT_3;
10032 int font3_height = getFontHeight(font3_nr);
10034 DrawTextF(xpos, ypos, font3_nr,
10035 "[%s]", element_info[properties_element].token_name);
10037 ypos += 2 * font3_height;
10040 // ----- print number of elements / percentage of this element in level
10042 for (y = 0; y < lev_fieldy; y++)
10044 for (x = 0; x < lev_fieldx; x++)
10046 if (Tile[x][y] == properties_element)
10048 num_elements_in_level++;
10050 else if (IS_MM_WALL(Tile[x][y]) &&
10051 map_mm_wall_element(Tile[x][y]) == properties_element)
10053 num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
10058 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10060 DrawTextS(xpos, ypos, font1_nr, num_elements_text);
10062 if (num_hires_tiles_in_level > 0)
10063 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10064 "%d wall tiles", num_hires_tiles_in_level);
10065 else if (num_elements_in_level > 0)
10066 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10067 "%d (%.2f %%)", num_elements_in_level, percentage);
10069 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10072 // ----- print number of similar elements / percentage of them in level
10074 for (y = 0; y < lev_fieldy; y++)
10076 for (x = 0; x < lev_fieldx; x++)
10078 if (strEqual(element_info[Tile[x][y]].class_name,
10079 element_info[properties_element].class_name))
10081 num_similar_in_level++;
10086 if (num_similar_in_level != num_elements_in_level)
10088 ypos += 1 * MAX(font1_height, font2_height);
10090 percentage = num_similar_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10092 DrawTextS(xpos, ypos, font1_nr, num_similar_text);
10094 if (num_similar_in_level > 0)
10095 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10096 "%d (%.2f %%)", num_similar_in_level, percentage);
10098 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10102 ypos += 2 * MAX(font1_height, font2_height);
10104 // ----- print standard properties of this element
10106 DrawTextS(xpos, ypos, font1_nr, properties_text);
10108 ypos += line1_height;
10110 for (i = 0; properties[i].value != -1; i++)
10112 if (!HAS_PROPERTY(properties_element, properties[i].value))
10115 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
10117 ypos += font2_height;
10119 num_standard_properties++;
10122 if (num_standard_properties == 0)
10124 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
10125 font2_nr, none_text);
10127 ypos -= (line1_height - font1_height);
10130 ypos += MAX(font1_height, font2_height);
10132 // ----- print special description of this element
10134 PrintInfoText(description_text, font1_nr, xpos, ypos);
10136 ypos += line1_height;
10138 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
10139 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
10142 #define TEXT_COLLECTING "Score for collecting"
10143 #define TEXT_SMASHING "Score for smashing"
10144 #define TEXT_SLURPING "Score for slurping robot"
10145 #define TEXT_CRACKING "Score for cracking"
10146 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
10147 #define TEXT_DURATION "Duration when activated"
10148 #define TEXT_DELAY_ON "Delay before activating"
10149 #define TEXT_DELAY_OFF "Delay before deactivating"
10150 #define TEXT_DELAY_CHANGING "Delay before changing"
10151 #define TEXT_DELAY_EXPLODING "Delay before exploding"
10152 #define TEXT_DELAY_MOVING "Delay before moving"
10153 #define TEXT_BALL_DELAY "Element generation delay"
10154 #define TEXT_MOVE_SPEED "Speed of android moving"
10155 #define TEXT_CLONE_SPEED "Speed of android cloning"
10156 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
10157 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
10158 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
10159 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
10160 #define TEXT_TIME_BONUS "Extra time to solve level"
10167 } elements_with_counter[] =
10169 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
10170 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
10171 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
10172 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
10173 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10174 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
10175 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
10176 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
10177 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
10178 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
10179 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10180 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
10181 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10182 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10183 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
10184 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
10185 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
10186 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10187 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10188 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
10189 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10190 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10191 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10192 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10193 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10194 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10195 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
10196 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10197 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10198 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10199 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10200 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10201 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10202 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10203 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
10204 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
10205 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10206 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
10207 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10208 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10209 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10210 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10211 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10212 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
10213 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10214 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10215 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE], TEXT_COLLECTING },
10216 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10217 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10218 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
10219 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
10220 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
10221 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10222 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10223 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10224 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10225 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10226 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10227 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10228 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10229 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
10230 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
10231 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
10232 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
10233 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
10234 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10235 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
10236 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
10237 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
10238 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10239 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10240 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10241 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10242 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10243 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10244 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10245 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10246 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10247 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10248 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10249 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10250 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10251 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
10253 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10254 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
10255 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
10256 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
10257 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
10258 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
10259 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
10260 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
10261 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
10262 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
10263 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
10264 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
10265 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
10266 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
10267 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
10268 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
10270 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
10271 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
10272 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
10273 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
10274 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
10275 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
10276 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
10277 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
10278 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
10279 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
10280 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
10281 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
10282 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_CHANGING },
10283 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10284 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10289 static boolean checkPropertiesConfig(int element)
10293 if (IS_GEM(element) ||
10294 IS_CUSTOM_ELEMENT(element) ||
10295 IS_GROUP_ELEMENT(element) ||
10296 IS_EMPTY_ELEMENT(element) ||
10297 IS_BALLOON_ELEMENT(element) ||
10298 IS_ENVELOPE(element) ||
10299 IS_MM_ENVELOPE(element) ||
10300 IS_MM_MCDUFFIN(element) ||
10301 IS_DF_LASER(element) ||
10302 IS_PLAYER_ELEMENT(element) ||
10303 HAS_EDITOR_CONTENT(element) ||
10304 CAN_GROW(element) ||
10305 COULD_MOVE_INTO_ACID(element) ||
10306 MAYBE_DONT_COLLIDE_WITH(element) ||
10307 element == EL_SOKOBAN_OBJECT ||
10308 element == EL_SOKOBAN_FIELD_EMPTY ||
10309 element == EL_SOKOBAN_FIELD_FULL)
10312 for (i = 0; elements_with_counter[i].element != -1; i++)
10313 if (elements_with_counter[i].element == element)
10319 static void SetAutomaticNumberOfGemsNeeded(void)
10323 if (!level.auto_count_gems)
10326 level.gems_needed = 0;
10328 for (x = 0; x < lev_fieldx; x++)
10330 for (y = 0; y < lev_fieldy; y++)
10332 int element = Tile[x][y];
10337 case EL_EMERALD_YELLOW:
10338 case EL_EMERALD_RED:
10339 case EL_EMERALD_PURPLE:
10340 case EL_BD_DIAMOND:
10341 case EL_WALL_EMERALD:
10342 case EL_WALL_EMERALD_YELLOW:
10343 case EL_WALL_EMERALD_RED:
10344 case EL_WALL_EMERALD_PURPLE:
10345 case EL_WALL_BD_DIAMOND:
10347 case EL_SP_INFOTRON:
10350 level.gems_needed++;
10354 case EL_WALL_DIAMOND:
10355 level.gems_needed += 3;
10359 case EL_WALL_PEARL:
10360 level.gems_needed += 5;
10364 case EL_WALL_CRYSTAL:
10365 level.gems_needed += 8;
10374 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10377 static void DrawPropertiesConfig(void)
10379 boolean draw_footer_line = FALSE;
10380 int max_num_element_counters = 4;
10381 int num_element_counters = 0;
10384 if (!checkPropertiesConfig(properties_element))
10386 int xpos = ED_ELEMENT_SETTINGS_X(0);
10387 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10389 PrintInfoText("No configuration options available.",
10390 FONT_TEXT_1, xpos, ypos);
10395 // check if there are elements where a value can be chosen for
10396 for (i = 0; elements_with_counter[i].element != -1; i++)
10398 if (elements_with_counter[i].element == properties_element)
10400 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10402 counterbutton_info[counter_id].y =
10403 ED_ELEMENT_SETTINGS_YPOS(
10404 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10405 (CAN_GROW(properties_element) ? 1 : 0) +
10406 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10407 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10408 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10409 num_element_counters);
10411 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10412 counterbutton_info[counter_id].text_right = elements_with_counter[i].text;
10414 if (properties_element == EL_GAME_OF_LIFE ||
10415 properties_element == EL_BIOMAZE)
10417 counterbutton_info[counter_id].min_value = 0; // min neighbours
10418 counterbutton_info[counter_id].max_value = 8; // max neighbours
10422 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10423 counterbutton_info[counter_id].min_value = MIN_SCORE;
10424 counterbutton_info[counter_id].max_value = MAX_SCORE;
10427 MapCounterButtons(counter_id);
10429 num_element_counters++;
10430 if (num_element_counters >= max_num_element_counters)
10435 if (HAS_EDITOR_CONTENT(properties_element))
10437 // draw stickybutton gadget
10438 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10440 if (IS_AMOEBOID(properties_element))
10441 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10442 else if (properties_element == EL_YAMYAM ||
10443 properties_element == EL_YAMYAM_LEFT ||
10444 properties_element == EL_YAMYAM_RIGHT ||
10445 properties_element == EL_YAMYAM_UP ||
10446 properties_element == EL_YAMYAM_DOWN)
10447 DrawYamYamContentAreas();
10448 else if (properties_element == EL_EMC_MAGIC_BALL)
10450 DrawMagicBallContentAreas();
10452 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10453 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10455 else if (properties_element == EL_EMC_ANDROID)
10456 DrawAndroidElementArea();
10457 else if (properties_element == EL_MM_GRAY_BALL)
10459 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
10460 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
10461 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
10462 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EXPLODE_MM_BALL);
10464 DrawMMBallContentArea();
10468 if (IS_PLAYER_ELEMENT(properties_element))
10470 int player_nr = GET_PLAYER_NR(properties_element);
10472 // these properties can be set for every player individually
10474 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10476 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
10477 &level.start_element[player_nr];
10478 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
10479 &level.artwork_element[player_nr];
10480 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
10481 &level.explosion_element[player_nr];
10483 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10484 &level.use_start_element[player_nr];
10485 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10486 &level.use_artwork_element[player_nr];
10487 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10488 &level.use_explosion_element[player_nr];
10489 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10490 &level.initial_player_gravity[player_nr];
10492 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10493 &level.initial_player_stepsize[player_nr];
10495 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
10496 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
10497 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
10498 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
10499 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
10500 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
10501 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
10502 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
10503 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
10504 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
10505 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
10506 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
10507 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
10508 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
10509 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
10511 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
10512 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
10513 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
10515 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
10517 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10519 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
10520 &level.initial_inventory_content[player_nr][0];
10522 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
10523 &level.initial_inventory_size[player_nr];
10525 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
10526 &level.use_initial_inventory[player_nr];
10528 // draw checkbutton gadgets
10529 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
10530 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
10531 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
10533 // draw counter gadgets
10534 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
10536 // draw drawing area gadgets
10537 DrawPlayerInitialInventoryArea(properties_element);
10541 if (IS_GEM(properties_element))
10542 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
10544 if (properties_element == EL_EM_DYNAMITE)
10545 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
10547 if (COULD_MOVE_INTO_ACID(properties_element) &&
10548 !IS_PLAYER_ELEMENT(properties_element) &&
10549 (!IS_CUSTOM_ELEMENT(properties_element) ||
10550 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
10552 // set position for checkbutton for "can move into acid"
10553 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
10554 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
10555 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
10556 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
10557 IS_BALLOON_ELEMENT(properties_element) ||
10558 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10560 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
10563 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
10564 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
10566 if (properties_element == EL_SPRING ||
10567 properties_element == EL_SPRING_LEFT ||
10568 properties_element == EL_SPRING_RIGHT)
10569 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
10571 if (properties_element == EL_TIME_ORB_FULL)
10572 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
10574 if (properties_element == EL_GAME_OF_LIFE ||
10575 properties_element == EL_BIOMAZE)
10576 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
10578 if (CAN_GROW(properties_element))
10580 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
10581 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10583 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
10586 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
10587 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
10589 if (properties_element == EL_SOKOBAN_OBJECT)
10590 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
10592 if (properties_element == EL_SOKOBAN_OBJECT ||
10593 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
10594 properties_element == EL_SOKOBAN_FIELD_FULL)
10596 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
10597 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
10600 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
10603 if (IS_BALLOON_ELEMENT(properties_element))
10604 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
10606 if (IS_ENVELOPE(properties_element) ||
10607 IS_MM_ENVELOPE(properties_element))
10609 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
10610 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
10611 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
10612 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
10613 int envelope_nr = ENVELOPE_NR(properties_element);
10615 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
10616 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
10618 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
10619 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
10621 // display counter to choose size of envelope text area
10622 MapCounterButtons(counter1_id);
10623 MapCounterButtons(counter2_id);
10625 // display checkbuttons to choose auto-wrap and alignment properties
10626 MapCheckbuttonGadget(button1_id);
10627 MapCheckbuttonGadget(button2_id);
10629 DrawEnvelopeTextArea(envelope_nr);
10632 if (IS_MM_MCDUFFIN(properties_element))
10634 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
10635 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
10636 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
10639 if (IS_DF_LASER(properties_element))
10641 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
10642 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
10643 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
10646 if (IS_CUSTOM_ELEMENT(properties_element))
10648 // draw stickybutton gadget
10649 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10651 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10653 // draw checkbutton gadgets
10654 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
10655 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
10656 MapCheckbuttonGadget(i);
10658 // draw counter gadgets
10659 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
10660 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
10661 MapCounterButtons(i);
10663 // draw selectbox gadgets
10664 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
10665 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
10666 MapSelectboxGadget(i);
10668 // draw textbutton gadgets
10669 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10671 // draw text input gadgets
10672 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10674 // draw drawing area gadgets
10675 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10677 draw_footer_line = TRUE;
10679 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10681 // draw checkbutton gadgets
10682 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
10683 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
10684 MapCheckbuttonGadget(i);
10686 // draw counter gadgets
10687 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
10688 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
10689 MapCounterButtons(i);
10691 // draw selectbox gadgets
10692 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
10693 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
10694 MapSelectboxGadget(i);
10696 // draw drawing area gadgets
10697 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
10698 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
10699 DrawCustomContentArea();
10702 else if (IS_GROUP_ELEMENT(properties_element))
10704 // draw stickybutton gadget
10705 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10707 // draw checkbutton gadgets
10708 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10709 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10711 // draw counter gadgets
10712 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
10714 // draw selectbox gadgets
10715 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
10717 // draw textbutton gadgets
10718 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10720 // draw drawing area gadgets
10721 DrawGroupElementArea();
10723 // draw text input gadgets
10724 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10726 // draw drawing area gadgets
10727 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10729 draw_footer_line = TRUE;
10731 else if (IS_EMPTY_ELEMENT(properties_element))
10733 // draw stickybutton gadget
10734 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10736 // draw checkbutton gadgets
10737 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10738 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10740 // draw textbutton gadgets
10741 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10743 // draw drawing area gadgets
10744 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10746 draw_footer_line = TRUE;
10749 // draw little footer border line above CE/GE use/save template gadgets
10750 if (draw_footer_line)
10752 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
10753 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
10754 int gd_x = gd->x + gd_gi1->border.width / 2;
10755 int gd_y = gd->y + gd_gi1->height - 1;
10756 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
10758 if (tab_color != BLACK_PIXEL) // black => transparent
10759 FillRectangle(drawto,
10760 SX + ED_ELEMENT_SETTINGS_X(0),
10761 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
10763 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10767 static void DrawPropertiesChangeDrawingAreas(void)
10769 if (IS_CUSTOM_ELEMENT(properties_element))
10771 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
10772 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
10773 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
10775 DrawCustomChangeContentArea();
10778 redraw_mask |= REDRAW_FIELD;
10781 static void DrawPropertiesChange(void)
10785 // needed to initially set selectbox options for special action options
10786 setSelectboxSpecialActionOptions();
10788 // draw stickybutton gadget
10789 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10791 // draw checkbutton gadgets
10792 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
10793 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
10794 MapCheckbuttonGadget(i);
10796 // draw counter gadgets
10797 for (i = ED_COUNTER_ID_CHANGE_FIRST;
10798 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
10799 MapCounterButtons(i);
10801 // draw selectbox gadgets
10802 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
10803 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
10804 MapSelectboxGadget(i);
10806 // draw textbutton gadgets
10807 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
10808 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
10809 MapTextbuttonGadget(i);
10811 // draw graphicbutton gadgets
10812 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
10813 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
10814 MapGraphicbuttonGadget(i);
10816 // draw drawing area gadgets
10817 DrawPropertiesChangeDrawingAreas();
10820 static void DrawEditorElementAnimation(int x, int y)
10822 int graphic = el2img(properties_element);
10823 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
10824 custom_element.ce_value_fixed_initial :
10825 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
10826 custom_element.collect_score_initial : FrameCounter);
10828 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
10831 static void DrawEditorElementName(int x, int y, int font_nr)
10833 char *element_name = getElementInfoText(properties_element);
10834 int font_width = getFontWidth(font_nr);
10835 int font_height = getFontHeight(font_nr);
10836 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
10837 int max_chars_per_line = max_text_width / font_width;
10839 if (strlen(element_name) <= max_chars_per_line)
10840 DrawTextS(x, y, font_nr, element_name);
10843 char buffer[max_chars_per_line + 1];
10844 int next_pos = max_chars_per_line;
10846 strncpy(buffer, element_name, max_chars_per_line);
10847 buffer[max_chars_per_line] = '\0';
10849 if (element_name[max_chars_per_line] == ' ')
10855 for (i = max_chars_per_line - 1; i >= 0; i--)
10856 if (buffer[i] == ' ')
10859 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
10866 DrawTextS(x, y - font_height / 2, font_nr, buffer);
10868 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
10869 buffer[max_chars_per_line] = '\0';
10871 DrawTextS(x, y + font_height / 2, font_nr, buffer);
10875 static void DrawPropertiesWindow(void)
10877 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
10878 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
10879 int border_size = gd->border_size;
10880 int font_nr = FONT_TEXT_1;
10881 int font_height = getFontHeight(font_nr);
10882 int xoffset = TILEX + element_border + 3 * border_size;
10883 int yoffset = (TILEY - font_height) / 2;
10884 int x1 = editor.settings.element_graphic.x + element_border;
10885 int y1 = editor.settings.element_graphic.y + element_border;
10886 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
10887 editor.settings.element_name.x);
10888 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
10889 editor.settings.element_name.y);
10890 char *text = "Element Settings";
10891 int font2_nr = FONT_TITLE_1;
10892 struct MenuPosInfo *pos = &editor.settings.headline;
10893 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
10894 int sy = SY + pos->y;
10896 stick_element_properties_window = FALSE;
10898 // make sure that previous properties edit mode exists for this element
10899 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
10900 !IS_CUSTOM_ELEMENT(properties_element))
10901 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
10903 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
10904 !IS_PLAYER_ELEMENT(properties_element) &&
10905 !IS_CUSTOM_ELEMENT(properties_element))
10906 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
10908 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
10909 (IS_PLAYER_ELEMENT(properties_element) ||
10910 IS_CUSTOM_ELEMENT(properties_element)))
10911 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
10913 CopyElementPropertiesToEditor(properties_element);
10915 UnmapLevelEditorFieldGadgets();
10916 UnmapLevelEditorToolboxDrawingGadgets();
10917 UnmapLevelEditorToolboxCustomGadgets();
10919 MapLevelEditorToolboxCustomGadgetsIfNeeded();
10921 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10924 DrawText(sx, sy, text, font2_nr);
10926 FrameCounter = 0; // restart animation frame counter
10928 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
10929 DrawEditorElementAnimation(SX + x1, SY + y1);
10930 DrawEditorElementName(x2, y2, font_nr);
10932 DrawPropertiesTabulatorGadgets();
10934 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
10935 DrawPropertiesInfo();
10936 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
10937 DrawPropertiesChange();
10938 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
10939 DrawPropertiesConfig();
10942 static void DrawPaletteWindow(void)
10946 UnmapLevelEditorFieldGadgets();
10948 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10951 // map buttons to select elements
10952 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
10953 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
10954 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
10955 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
10956 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
10959 static void UpdateCustomElementGraphicGadgets(void)
10963 InitElementPropertiesGfxElement();
10965 ModifyEditorElementList();
10966 RedrawDrawingElements();
10968 // force redraw of all mapped drawing area gadgets
10969 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
10971 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
10978 static int getOpenDirectionFromTube(int element)
10982 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
10983 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
10984 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
10985 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
10986 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
10987 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
10988 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
10989 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
10990 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
10991 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
10992 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
10998 static int getTubeFromOpenDirection(int direction)
11002 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
11003 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
11004 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
11005 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
11006 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
11007 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
11008 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
11009 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
11010 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
11011 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
11012 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
11014 // if only one direction, fall back to simple tube with that direction
11015 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
11016 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
11017 case (MV_UP): return EL_TUBE_VERTICAL;
11018 case (MV_DOWN): return EL_TUBE_VERTICAL;
11024 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
11026 int element_new = getTubeFromOpenDirection(direction);
11028 return (element_new != EL_EMPTY ? element_new : element_old);
11031 static int getOpenDirectionFromBelt(int element)
11033 int belt_dir = getBeltDirFromBeltElement(element);
11035 return (belt_dir == MV_LEFT ? MV_RIGHT :
11036 belt_dir == MV_RIGHT ? MV_LEFT :
11037 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
11040 static int getBeltFromNrAndOpenDirection(int nr, int direction)
11042 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
11043 direction == MV_RIGHT ? MV_LEFT :
11044 direction == MV_HORIZONTAL ? MV_NONE : direction);
11046 if (direction == MV_NONE)
11049 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
11052 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
11055 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
11057 return (element_new != EL_EMPTY ? element_new : element_old);
11060 static int getOpenDirectionFromPool(int element)
11064 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
11065 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
11066 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
11067 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
11068 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
11069 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
11075 static int getPoolFromOpenDirection(int direction)
11079 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
11080 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
11081 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
11082 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
11083 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
11084 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
11090 static int getPoolFromOpenDirectionExt(int direction, int help_element)
11092 int element = getPoolFromOpenDirection(direction);
11093 int help_direction = getOpenDirectionFromPool(help_element);
11095 if (element == EL_EMPTY)
11097 int help_direction_vertical = help_direction & MV_VERTICAL;
11099 element = getPoolFromOpenDirection(direction | help_direction_vertical);
11102 if (element == EL_EMPTY)
11104 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
11106 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
11112 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
11114 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
11116 return (element_new != EL_EMPTY ? element_new : element_old);
11119 static int getOpenDirectionFromPillar(int element)
11123 case EL_EMC_WALL_1: return (MV_DOWN);
11124 case EL_EMC_WALL_2: return (MV_VERTICAL);
11125 case EL_EMC_WALL_3: return (MV_UP);
11131 static int getPillarFromOpenDirection(int direction)
11135 case (MV_DOWN): return EL_EMC_WALL_1;
11136 case (MV_VERTICAL): return EL_EMC_WALL_2;
11137 case (MV_UP): return EL_EMC_WALL_3;
11143 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
11145 int element_new = getPillarFromOpenDirection(direction);
11147 return (element_new != EL_EMPTY ? element_new : element_old);
11150 static int getOpenDirectionFromSteel2(int element)
11154 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
11155 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
11156 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
11157 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
11158 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
11159 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
11160 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
11161 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
11167 static int getSteel2FromOpenDirection(int direction)
11171 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
11172 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
11173 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
11174 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
11175 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
11176 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
11177 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
11178 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
11184 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
11186 int element_new = getSteel2FromOpenDirection(direction);
11188 return (element_new != EL_EMPTY ? element_new : element_old);
11191 static int getOpenDirectionFromChip(int element)
11195 case EL_SP_CHIP_SINGLE: return (MV_NONE);
11196 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
11197 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
11198 case EL_SP_CHIP_TOP: return (MV_DOWN);
11199 case EL_SP_CHIP_BOTTOM: return (MV_UP);
11205 static int getChipFromOpenDirection(int direction)
11209 case (MV_NONE): return EL_SP_CHIP_SINGLE;
11210 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
11211 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
11212 case (MV_UP): return EL_SP_CHIP_BOTTOM;
11213 case (MV_DOWN): return EL_SP_CHIP_TOP;
11219 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
11221 int element_new = getChipFromOpenDirection(direction);
11223 return (element_new != EL_EMPTY ? element_new : element_old);
11226 static int getClosedTube(int x, int y)
11228 struct XY *xy = xy_directions;
11229 int element_old = IntelliDrawBuffer[x][y];
11230 int direction_old = getOpenDirectionFromTube(element_old);
11231 int direction_new = MV_NONE;
11234 for (i = 0; i < NUM_DIRECTIONS; i++)
11236 int xx = x + xy[i].x;
11237 int yy = y + xy[i].y;
11238 int dir = MV_DIR_FROM_BIT(i);
11239 int dir_opposite = MV_DIR_OPPOSITE(dir);
11241 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
11242 (direction_old & dir) &&
11243 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11244 direction_new |= dir;
11247 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
11250 static int getClosedBelt(int x, int y)
11252 struct XY *xy = xy_directions;
11253 int element_old = IntelliDrawBuffer[x][y];
11254 int nr = getBeltNrFromBeltElement(element_old);
11255 int direction_old = getOpenDirectionFromBelt(element_old);
11256 int direction_new = MV_NONE;
11259 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11261 int xx = x + xy[i].x;
11262 int yy = y + xy[i].y;
11263 int dir = MV_DIR_FROM_BIT(i);
11264 int dir_opposite = MV_DIR_OPPOSITE(dir);
11266 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
11267 (direction_old & dir) &&
11268 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11269 direction_new |= dir;
11272 return getBeltFromNrAndOpenDirection(nr, direction_new);
11275 static int getClosedPool(int x, int y)
11277 struct XY *xy = xy_directions;
11278 int element_old = IntelliDrawBuffer[x][y];
11279 int direction_old = getOpenDirectionFromPool(element_old);
11280 int direction_new = MV_NONE;
11283 for (i = 0; i < NUM_DIRECTIONS; i++)
11285 int xx = x + xy[i].x;
11286 int yy = y + xy[i].y;
11287 int dir = MV_DIR_FROM_BIT(i);
11288 int dir_opposite = MV_DIR_OPPOSITE(dir);
11290 if (IN_LEV_FIELD(xx, yy) &&
11291 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
11292 (direction_old & dir) &&
11293 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11294 direction_new |= dir;
11297 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
11300 static int getClosedPillar(int x, int y)
11302 struct XY *xy = xy_directions;
11303 int element_old = IntelliDrawBuffer[x][y];
11304 int direction_old = getOpenDirectionFromPillar(element_old);
11305 int direction_new = MV_NONE;
11308 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11310 int xx = x + xy[i].x;
11311 int yy = y + xy[i].y;
11312 int dir = MV_DIR_FROM_BIT(i);
11313 int dir_opposite = MV_DIR_OPPOSITE(dir);
11315 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11316 (direction_old & dir) &&
11317 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11318 direction_new |= dir;
11321 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11324 static int getClosedSteel2(int x, int y)
11326 struct XY *xy = xy_directions;
11327 int element_old = IntelliDrawBuffer[x][y];
11328 int direction_old = getOpenDirectionFromSteel2(element_old);
11329 int direction_new = MV_NONE;
11332 for (i = 0; i < NUM_DIRECTIONS; i++)
11334 int xx = x + xy[i].x;
11335 int yy = y + xy[i].y;
11336 int dir = MV_DIR_FROM_BIT(i);
11337 int dir_opposite = MV_DIR_OPPOSITE(dir);
11339 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11340 (direction_old & dir) &&
11341 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11342 direction_new |= dir;
11345 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11348 static int getClosedChip(int x, int y)
11350 struct XY *xy = xy_directions;
11351 int element_old = IntelliDrawBuffer[x][y];
11352 int direction_old = getOpenDirectionFromChip(element_old);
11353 int direction_new = MV_NONE;
11356 for (i = 0; i < NUM_DIRECTIONS; i++)
11358 int xx = x + xy[i].x;
11359 int yy = y + xy[i].y;
11360 int dir = MV_DIR_FROM_BIT(i);
11361 int dir_opposite = MV_DIR_OPPOSITE(dir);
11363 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11364 (direction_old & dir) &&
11365 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11366 direction_new |= dir;
11369 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11372 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11373 boolean change_level)
11375 int sx = x - level_xpos;
11376 int sy = y - level_ypos;
11377 int old_element = Tile[x][y];
11378 int new_element = element;
11379 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11380 boolean draw_masked = FALSE;
11382 if (IS_MM_WALL_EDITOR(element))
11384 element = map_mm_wall_element_editor(element) | new_bitmask;
11386 if (IS_MM_WALL(old_element))
11387 element |= MM_WALL_BITS(old_element);
11390 draw_masked = TRUE;
11392 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11394 int element_changed = old_element & ~new_bitmask;
11396 if (MM_WALL_BITS(element_changed) != 0)
11397 element = element_changed;
11400 IntelliDrawBuffer[x][y] = element;
11403 Tile[x][y] = element;
11405 if (IN_ED_FIELD(sx, sy))
11407 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11408 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11409 else if (draw_masked)
11410 DrawEditorElementThruMask(sx, sy, element);
11412 DrawEditorElement(sx, sy, element);
11416 static void SetElementSimple(int x, int y, int element, boolean change_level)
11418 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11421 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11422 int x2, int y2, int *element2,
11423 int (*close_function)(int, int),
11424 boolean change_level)
11426 // set neighbour elements to newly determined connections
11427 SetElementSimple(x1, y1, *element1, change_level);
11428 SetElementSimple(x2, y2, *element2, change_level);
11430 // remove all open connections of neighbour elements
11431 *element1 = close_function(x1, y1);
11432 *element2 = close_function(x2, y2);
11434 // set neighbour elements to new, minimized connections
11435 SetElementSimple(x1, y1, *element1, change_level);
11436 SetElementSimple(x2, y2, *element2, change_level);
11439 static void SetElementIntelliDraw(int x, int y, int dx, int dy, int new_element,
11440 boolean change_level, int button)
11442 struct XY *xy = xy_directions;
11443 static int last_x = -1;
11444 static int last_y = -1;
11446 if (new_element == EL_UNDEFINED)
11454 int old_element = IntelliDrawBuffer[x][y];
11456 if (IS_TUBE(new_element))
11458 int last_element_new = EL_UNDEFINED;
11459 int direction = MV_NONE;
11462 // if old element is of same kind, keep all existing directions
11463 if (IS_TUBE(old_element))
11464 direction |= getOpenDirectionFromTube(old_element);
11466 for (i = 0; i < NUM_DIRECTIONS; i++)
11468 int xx = x + xy[i].x;
11469 int yy = y + xy[i].y;
11471 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11472 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11474 int dir = MV_DIR_FROM_BIT(i);
11475 int dir_opposite = MV_DIR_OPPOSITE(dir);
11476 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11477 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11478 int last_direction_new = last_direction_old | dir_opposite;
11480 last_element_new = getTubeFromOpenDirection(last_direction_new);
11486 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
11488 if (last_element_new != EL_UNDEFINED)
11489 MergeAndCloseNeighbourElements(x, y, &new_element,
11490 last_x, last_y, &last_element_new,
11491 getClosedTube, change_level);
11493 else if (IS_BELT(new_element))
11495 int belt_nr = getBeltNrFromBeltElement(new_element);
11496 int last_element_new = EL_UNDEFINED;
11497 int direction = MV_NONE;
11500 // if old element is of same kind, keep all existing directions
11501 if (IS_BELT(old_element))
11502 direction |= getOpenDirectionFromBelt(old_element);
11504 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11506 int xx = x + xy[i].x;
11507 int yy = y + xy[i].y;
11509 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11510 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
11512 int dir = MV_DIR_FROM_BIT(i);
11513 int dir_opposite = MV_DIR_OPPOSITE(dir);
11514 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11515 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
11516 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
11517 int last_direction_new = last_direction_old | dir_opposite;
11519 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11520 last_direction_new);
11525 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
11527 if (last_element_new != EL_UNDEFINED)
11528 MergeAndCloseNeighbourElements(x, y, &new_element,
11529 last_x, last_y, &last_element_new,
11530 getClosedBelt, change_level);
11532 else if (IS_ACID_POOL_OR_ACID(new_element))
11534 int last_element_new = EL_UNDEFINED;
11535 int direction = MV_NONE;
11538 // if old element is of same kind, keep all existing directions
11539 if (IS_ACID_POOL_OR_ACID(old_element))
11540 direction |= getOpenDirectionFromPool(old_element);
11542 for (i = 0; i < NUM_DIRECTIONS; i++)
11544 int xx = x + xy[i].x;
11545 int yy = y + xy[i].y;
11547 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11548 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
11550 int dir = MV_DIR_FROM_BIT(i);
11551 int dir_opposite = MV_DIR_OPPOSITE(dir);
11552 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11553 int last_direction_old = getOpenDirectionFromPool(last_element_old);
11554 int last_direction_new = last_direction_old | dir_opposite;
11556 last_element_new = getPoolFromOpenDirection(last_direction_new);
11562 // special corrections needed for intuitively correct acid pool drawing
11563 if (last_element_new == EL_EMPTY)
11564 last_element_new = new_element;
11565 else if (last_element_new != EL_UNDEFINED)
11566 new_element = last_element_new;
11568 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
11570 if (last_element_new != EL_UNDEFINED)
11571 MergeAndCloseNeighbourElements(x, y, &new_element,
11572 last_x, last_y, &last_element_new,
11573 getClosedPool, change_level);
11575 else if (IS_EMC_PILLAR(new_element))
11577 int last_element_new = EL_UNDEFINED;
11578 int direction = MV_NONE;
11581 // if old element is of same kind, keep all existing directions
11582 if (IS_EMC_PILLAR(old_element))
11583 direction |= getOpenDirectionFromPillar(old_element);
11585 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11587 int xx = x + xy[i].x;
11588 int yy = y + xy[i].y;
11590 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11591 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
11593 int dir = MV_DIR_FROM_BIT(i);
11594 int dir_opposite = MV_DIR_OPPOSITE(dir);
11595 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11596 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
11597 int last_direction_new = last_direction_old | dir_opposite;
11599 last_element_new = getPillarFromOpenDirection(last_direction_new);
11605 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
11607 if (last_element_new != EL_UNDEFINED)
11608 MergeAndCloseNeighbourElements(x, y, &new_element,
11609 last_x, last_y, &last_element_new,
11610 getClosedPillar, change_level);
11612 else if (IS_DC_STEELWALL_2(new_element))
11614 int last_element_new = EL_UNDEFINED;
11615 int direction = MV_NONE;
11618 // if old element is of same kind, keep all existing directions
11619 if (IS_DC_STEELWALL_2(old_element))
11620 direction |= getOpenDirectionFromSteel2(old_element);
11622 for (i = 0; i < NUM_DIRECTIONS; i++)
11624 int xx = x + xy[i].x;
11625 int yy = y + xy[i].y;
11627 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11628 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
11630 int dir = MV_DIR_FROM_BIT(i);
11631 int dir_opposite = MV_DIR_OPPOSITE(dir);
11632 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11633 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
11634 int last_direction_new = last_direction_old | dir_opposite;
11636 last_element_new = getSteel2FromOpenDirection(last_direction_new);
11642 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
11644 if (last_element_new != EL_UNDEFINED)
11645 MergeAndCloseNeighbourElements(x, y, &new_element,
11646 last_x, last_y, &last_element_new,
11647 getClosedSteel2, change_level);
11649 else if (IS_SP_CHIP(new_element))
11651 int last_element_new = EL_UNDEFINED;
11652 int direction = MV_NONE;
11655 // (do not keep existing directions, regardless of kind of old element)
11657 for (i = 0; i < NUM_DIRECTIONS; i++)
11659 int xx = x + xy[i].x;
11660 int yy = y + xy[i].y;
11662 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11663 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
11665 int dir = MV_DIR_FROM_BIT(i);
11666 int dir_opposite = MV_DIR_OPPOSITE(dir);
11667 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11668 int last_direction_old = getOpenDirectionFromChip(last_element_old);
11669 int last_direction_new = last_direction_old | dir_opposite;
11671 if (last_direction_old == MV_NONE)
11673 last_element_new = getChipFromOpenDirection(last_direction_new);
11676 else if (last_direction_old & (dir | dir_opposite))
11678 direction |= MV_DIR_OPPOSITE(last_direction_old);
11682 direction |= MV_DIR_OPPOSITE(dir);
11687 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
11689 if (last_element_new != EL_UNDEFINED)
11690 MergeAndCloseNeighbourElements(x, y, &new_element,
11691 last_x, last_y, &last_element_new,
11692 getClosedChip, change_level);
11694 else if (IS_SP_HARDWARE_BASE(new_element))
11696 int nr = GetSimpleRandom(6);
11698 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
11699 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
11700 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
11701 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
11702 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
11704 else if (new_element == EL_SP_HARDWARE_GREEN ||
11705 new_element == EL_SP_HARDWARE_BLUE ||
11706 new_element == EL_SP_HARDWARE_RED)
11708 int nr = GetSimpleRandom(3);
11710 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
11711 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
11713 else if (IS_GROUP_ELEMENT(new_element))
11715 boolean connected_drawing = FALSE;
11718 for (i = 0; i < NUM_DIRECTIONS; i++)
11720 int xx = x + xy[i].x;
11721 int yy = y + xy[i].y;
11723 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11724 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
11725 connected_drawing = TRUE;
11728 if (!connected_drawing)
11729 ResolveGroupElement(new_element);
11731 new_element = GetElementFromGroupElement(new_element);
11733 else if (IS_BELT_SWITCH(old_element))
11735 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
11736 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
11738 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
11739 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
11741 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
11745 static int swappable_elements[][2] =
11747 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
11748 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
11749 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
11750 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
11751 { EL_EMERALD, EL_WALL_EMERALD },
11752 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
11753 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
11754 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
11755 { EL_DIAMOND, EL_WALL_DIAMOND },
11756 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
11757 { EL_GATE_1, EL_GATE_1_GRAY },
11758 { EL_GATE_2, EL_GATE_2_GRAY },
11759 { EL_GATE_3, EL_GATE_3_GRAY },
11760 { EL_GATE_4, EL_GATE_4_GRAY },
11761 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
11762 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
11763 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
11764 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
11765 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
11766 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
11767 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
11768 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
11769 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
11770 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
11771 { EL_LAMP, EL_LAMP_ACTIVE },
11772 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
11773 { EL_SP_BASE, EL_SP_BUGGY_BASE },
11774 { EL_PEARL, EL_WALL_PEARL },
11775 { EL_CRYSTAL, EL_WALL_CRYSTAL },
11776 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
11777 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
11778 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
11779 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
11780 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
11781 { EL_LANDMINE, EL_DC_LANDMINE },
11782 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
11783 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
11784 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
11785 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
11786 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
11787 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
11788 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
11789 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
11790 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
11794 static int rotatable_elements_4[][4] =
11804 EL_SPACESHIP_RIGHT,
11809 EL_BD_BUTTERFLY_UP,
11810 EL_BD_BUTTERFLY_RIGHT,
11811 EL_BD_BUTTERFLY_DOWN,
11812 EL_BD_BUTTERFLY_LEFT
11816 EL_BD_FIREFLY_RIGHT,
11817 EL_BD_FIREFLY_DOWN,
11845 EL_SP_GRAVITY_PORT_UP,
11846 EL_SP_GRAVITY_PORT_RIGHT,
11847 EL_SP_GRAVITY_PORT_DOWN,
11848 EL_SP_GRAVITY_PORT_LEFT
11851 EL_SP_GRAVITY_ON_PORT_UP,
11852 EL_SP_GRAVITY_ON_PORT_RIGHT,
11853 EL_SP_GRAVITY_ON_PORT_DOWN,
11854 EL_SP_GRAVITY_ON_PORT_LEFT
11857 EL_SP_GRAVITY_OFF_PORT_UP,
11858 EL_SP_GRAVITY_OFF_PORT_RIGHT,
11859 EL_SP_GRAVITY_OFF_PORT_DOWN,
11860 EL_SP_GRAVITY_OFF_PORT_LEFT
11869 EL_BALLOON_SWITCH_UP,
11870 EL_BALLOON_SWITCH_RIGHT,
11871 EL_BALLOON_SWITCH_DOWN,
11872 EL_BALLOON_SWITCH_LEFT
11876 EL_MM_MCDUFFIN_RIGHT,
11877 EL_MM_MCDUFFIN_DOWN,
11878 EL_MM_MCDUFFIN_LEFT
11881 EL_MM_MIRROR_FIXED_1,
11882 EL_MM_MIRROR_FIXED_4,
11883 EL_MM_MIRROR_FIXED_3,
11884 EL_MM_MIRROR_FIXED_2
11887 EL_MM_STEEL_GRID_FIXED_1,
11888 EL_MM_STEEL_GRID_FIXED_4,
11889 EL_MM_STEEL_GRID_FIXED_2,
11890 EL_MM_STEEL_GRID_FIXED_3
11893 EL_MM_WOODEN_GRID_FIXED_1,
11894 EL_MM_WOODEN_GRID_FIXED_4,
11895 EL_MM_WOODEN_GRID_FIXED_2,
11896 EL_MM_WOODEN_GRID_FIXED_3
11899 EL_MM_POLARIZER_CROSS_1,
11900 EL_MM_POLARIZER_CROSS_4,
11901 EL_MM_POLARIZER_CROSS_3,
11902 EL_MM_POLARIZER_CROSS_2
11906 EL_MM_PACMAN_RIGHT,
11918 EL_DF_RECEIVER_RIGHT,
11919 EL_DF_RECEIVER_DOWN,
11920 EL_DF_RECEIVER_LEFT
11933 static int rotatable_elements_8[][8] =
11936 EL_DF_STEEL_GRID_FIXED_1,
11937 EL_DF_STEEL_GRID_FIXED_8,
11938 EL_DF_STEEL_GRID_FIXED_7,
11939 EL_DF_STEEL_GRID_FIXED_6,
11940 EL_DF_STEEL_GRID_FIXED_5,
11941 EL_DF_STEEL_GRID_FIXED_4,
11942 EL_DF_STEEL_GRID_FIXED_3,
11943 EL_DF_STEEL_GRID_FIXED_2
11946 EL_DF_WOODEN_GRID_FIXED_1,
11947 EL_DF_WOODEN_GRID_FIXED_8,
11948 EL_DF_WOODEN_GRID_FIXED_7,
11949 EL_DF_WOODEN_GRID_FIXED_6,
11950 EL_DF_WOODEN_GRID_FIXED_5,
11951 EL_DF_WOODEN_GRID_FIXED_4,
11952 EL_DF_WOODEN_GRID_FIXED_3,
11953 EL_DF_WOODEN_GRID_FIXED_2
11956 EL_DF_STEEL_GRID_ROTATING_1,
11957 EL_DF_STEEL_GRID_ROTATING_8,
11958 EL_DF_STEEL_GRID_ROTATING_7,
11959 EL_DF_STEEL_GRID_ROTATING_6,
11960 EL_DF_STEEL_GRID_ROTATING_5,
11961 EL_DF_STEEL_GRID_ROTATING_4,
11962 EL_DF_STEEL_GRID_ROTATING_3,
11963 EL_DF_STEEL_GRID_ROTATING_2
11966 EL_DF_WOODEN_GRID_ROTATING_1,
11967 EL_DF_WOODEN_GRID_ROTATING_8,
11968 EL_DF_WOODEN_GRID_ROTATING_7,
11969 EL_DF_WOODEN_GRID_ROTATING_6,
11970 EL_DF_WOODEN_GRID_ROTATING_5,
11971 EL_DF_WOODEN_GRID_ROTATING_4,
11972 EL_DF_WOODEN_GRID_ROTATING_3,
11973 EL_DF_WOODEN_GRID_ROTATING_2
11980 static int rotatable_elements_16[][16] =
12001 EL_MM_TELEPORTER_5,
12002 EL_MM_TELEPORTER_4,
12003 EL_MM_TELEPORTER_3,
12004 EL_MM_TELEPORTER_2,
12005 EL_MM_TELEPORTER_1,
12006 EL_MM_TELEPORTER_16,
12007 EL_MM_TELEPORTER_15,
12008 EL_MM_TELEPORTER_14,
12009 EL_MM_TELEPORTER_13,
12010 EL_MM_TELEPORTER_12,
12011 EL_MM_TELEPORTER_11,
12012 EL_MM_TELEPORTER_10,
12013 EL_MM_TELEPORTER_9,
12014 EL_MM_TELEPORTER_8,
12015 EL_MM_TELEPORTER_7,
12019 EL_MM_TELEPORTER_RED_5,
12020 EL_MM_TELEPORTER_RED_4,
12021 EL_MM_TELEPORTER_RED_3,
12022 EL_MM_TELEPORTER_RED_2,
12023 EL_MM_TELEPORTER_RED_1,
12024 EL_MM_TELEPORTER_RED_16,
12025 EL_MM_TELEPORTER_RED_15,
12026 EL_MM_TELEPORTER_RED_14,
12027 EL_MM_TELEPORTER_RED_13,
12028 EL_MM_TELEPORTER_RED_12,
12029 EL_MM_TELEPORTER_RED_11,
12030 EL_MM_TELEPORTER_RED_10,
12031 EL_MM_TELEPORTER_RED_9,
12032 EL_MM_TELEPORTER_RED_8,
12033 EL_MM_TELEPORTER_RED_7,
12034 EL_MM_TELEPORTER_RED_6
12037 EL_MM_TELEPORTER_YELLOW_5,
12038 EL_MM_TELEPORTER_YELLOW_4,
12039 EL_MM_TELEPORTER_YELLOW_3,
12040 EL_MM_TELEPORTER_YELLOW_2,
12041 EL_MM_TELEPORTER_YELLOW_1,
12042 EL_MM_TELEPORTER_YELLOW_16,
12043 EL_MM_TELEPORTER_YELLOW_15,
12044 EL_MM_TELEPORTER_YELLOW_14,
12045 EL_MM_TELEPORTER_YELLOW_13,
12046 EL_MM_TELEPORTER_YELLOW_12,
12047 EL_MM_TELEPORTER_YELLOW_11,
12048 EL_MM_TELEPORTER_YELLOW_10,
12049 EL_MM_TELEPORTER_YELLOW_9,
12050 EL_MM_TELEPORTER_YELLOW_8,
12051 EL_MM_TELEPORTER_YELLOW_7,
12052 EL_MM_TELEPORTER_YELLOW_6
12055 EL_MM_TELEPORTER_GREEN_5,
12056 EL_MM_TELEPORTER_GREEN_4,
12057 EL_MM_TELEPORTER_GREEN_3,
12058 EL_MM_TELEPORTER_GREEN_2,
12059 EL_MM_TELEPORTER_GREEN_1,
12060 EL_MM_TELEPORTER_GREEN_16,
12061 EL_MM_TELEPORTER_GREEN_15,
12062 EL_MM_TELEPORTER_GREEN_14,
12063 EL_MM_TELEPORTER_GREEN_13,
12064 EL_MM_TELEPORTER_GREEN_12,
12065 EL_MM_TELEPORTER_GREEN_11,
12066 EL_MM_TELEPORTER_GREEN_10,
12067 EL_MM_TELEPORTER_GREEN_9,
12068 EL_MM_TELEPORTER_GREEN_8,
12069 EL_MM_TELEPORTER_GREEN_7,
12070 EL_MM_TELEPORTER_GREEN_6
12073 EL_MM_TELEPORTER_BLUE_5,
12074 EL_MM_TELEPORTER_BLUE_4,
12075 EL_MM_TELEPORTER_BLUE_3,
12076 EL_MM_TELEPORTER_BLUE_2,
12077 EL_MM_TELEPORTER_BLUE_1,
12078 EL_MM_TELEPORTER_BLUE_16,
12079 EL_MM_TELEPORTER_BLUE_15,
12080 EL_MM_TELEPORTER_BLUE_14,
12081 EL_MM_TELEPORTER_BLUE_13,
12082 EL_MM_TELEPORTER_BLUE_12,
12083 EL_MM_TELEPORTER_BLUE_11,
12084 EL_MM_TELEPORTER_BLUE_10,
12085 EL_MM_TELEPORTER_BLUE_9,
12086 EL_MM_TELEPORTER_BLUE_8,
12087 EL_MM_TELEPORTER_BLUE_7,
12088 EL_MM_TELEPORTER_BLUE_6
12092 EL_MM_POLARIZER_16,
12093 EL_MM_POLARIZER_15,
12094 EL_MM_POLARIZER_14,
12095 EL_MM_POLARIZER_13,
12096 EL_MM_POLARIZER_12,
12097 EL_MM_POLARIZER_11,
12098 EL_MM_POLARIZER_10,
12127 EL_DF_MIRROR_ROTATING_1,
12128 EL_DF_MIRROR_ROTATING_16,
12129 EL_DF_MIRROR_ROTATING_15,
12130 EL_DF_MIRROR_ROTATING_14,
12131 EL_DF_MIRROR_ROTATING_13,
12132 EL_DF_MIRROR_ROTATING_12,
12133 EL_DF_MIRROR_ROTATING_11,
12134 EL_DF_MIRROR_ROTATING_10,
12135 EL_DF_MIRROR_ROTATING_9,
12136 EL_DF_MIRROR_ROTATING_8,
12137 EL_DF_MIRROR_ROTATING_7,
12138 EL_DF_MIRROR_ROTATING_6,
12139 EL_DF_MIRROR_ROTATING_5,
12140 EL_DF_MIRROR_ROTATING_4,
12141 EL_DF_MIRROR_ROTATING_3,
12142 EL_DF_MIRROR_ROTATING_2
12145 EL_DF_MIRROR_FIXED_1,
12146 EL_DF_MIRROR_FIXED_16,
12147 EL_DF_MIRROR_FIXED_15,
12148 EL_DF_MIRROR_FIXED_14,
12149 EL_DF_MIRROR_FIXED_13,
12150 EL_DF_MIRROR_FIXED_12,
12151 EL_DF_MIRROR_FIXED_11,
12152 EL_DF_MIRROR_FIXED_10,
12153 EL_DF_MIRROR_FIXED_9,
12154 EL_DF_MIRROR_FIXED_8,
12155 EL_DF_MIRROR_FIXED_7,
12156 EL_DF_MIRROR_FIXED_6,
12157 EL_DF_MIRROR_FIXED_5,
12158 EL_DF_MIRROR_FIXED_4,
12159 EL_DF_MIRROR_FIXED_3,
12160 EL_DF_MIRROR_FIXED_2
12169 for (i = 0; swappable_elements[i][0] != -1; i++)
12171 int element1 = swappable_elements[i][0];
12172 int element2 = swappable_elements[i][1];
12174 if (old_element == element1 || old_element == element2)
12175 new_element = (old_element == element1 ? element2 : element1);
12178 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
12180 for (j = 0; j < 4; j++)
12182 int element = rotatable_elements_4[i][j];
12184 if (old_element == element)
12185 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
12186 button == 2 ? rotatable_elements_4[i][0] :
12187 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
12192 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
12194 for (j = 0; j < 8; j++)
12196 int element = rotatable_elements_8[i][j];
12198 if (old_element == element)
12199 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
12200 button == 2 ? rotatable_elements_8[i][0] :
12201 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
12206 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
12208 for (j = 0; j < 16; j++)
12210 int element = rotatable_elements_16[i][j];
12212 if (old_element == element)
12213 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
12214 button == 2 ? rotatable_elements_16[i][0] :
12215 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
12220 if (old_element != new_element)
12222 int max_infotext_len = getMaxInfoTextLength();
12223 char infotext[MAX_OUTPUT_LINESIZE + 1];
12225 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
12226 infotext[max_infotext_len] = '\0';
12228 ClearEditorGadgetInfoText();
12230 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
12235 if (IS_MM_WALL_EDITOR(new_element))
12236 SetElementSimpleExt(x, y, dx, dy, new_element, change_level);
12238 SetElementSimple(x, y, new_element, change_level);
12244 static void ResetIntelliDraw(void)
12248 for (x = 0; x < lev_fieldx; x++)
12249 for (y = 0; y < lev_fieldy; y++)
12250 IntelliDrawBuffer[x][y] = Tile[x][y];
12252 SetElementIntelliDraw(-1, -1, -1, -1, EL_UNDEFINED, FALSE, -1);
12255 static boolean draw_mode_hires = FALSE;
12257 static boolean isHiresTileElement(int element)
12259 return (IS_MM_WALL(element) || element == EL_EMPTY);
12262 static boolean isHiresDrawElement(int element)
12264 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
12267 static int numHiresTiles(int element)
12269 if (IS_MM_WALL(element))
12270 return get_number_of_bits(MM_WALL_BITS(element));
12275 static void SetDrawModeHiRes(int element)
12278 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12279 isHiresDrawElement(element));
12282 static boolean getDrawModeHiRes(void)
12284 return draw_mode_hires;
12287 static int getLoResScreenPos(int pos)
12289 return (getDrawModeHiRes() ? pos / 2 : pos);
12292 static int getLoResScreenMod(int pos)
12294 return (getDrawModeHiRes() ? pos % 2 : 0);
12297 static void SetElementExt(int x, int y, int dx, int dy, int element,
12298 boolean change_level, int button)
12301 SetElementSimple(x, y, Tile[x][y], change_level);
12302 else if (GetKeyModState() & KMOD_Shift)
12303 SetElementIntelliDraw(x, y, dx, dy, element, change_level, button);
12305 SetElementSimpleExt(x, y, dx, dy, element, change_level);
12308 static void SetElement(int x, int y, int element)
12310 SetElementExt(x, y, 0, 0, element, TRUE, -1);
12313 static void SetElementButton(int x, int y, int dx, int dy, int element,
12316 SetElementExt(x, y, dx, dy, element, TRUE, button);
12319 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
12321 int lx = getLoResScreenPos(sx2) + level_xpos;
12322 int ly = getLoResScreenPos(sy2) + level_ypos;
12323 int dx = getLoResScreenMod(sx2);
12324 int dy = getLoResScreenMod(sy2);
12326 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
12329 static void SetLevelElementHiRes(int lx2, int ly2, int element)
12336 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
12339 static int getLevelElementHiRes(int lx2, int ly2)
12345 int element = Tile[lx][ly];
12346 unsigned int bitmask = (dx + 1) << (dy * 2);
12348 if (IS_MM_WALL(element))
12350 if (element & bitmask)
12351 return map_mm_wall_element(element);
12359 static void DrawLineElement(int x, int y, int element, boolean change_level)
12361 SetElementHiRes(x, y, element, change_level);
12364 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12365 int element, boolean change_level)
12367 int xsize = ABS(to_x - from_x);
12368 int ysize = ABS(to_y - from_y);
12369 int dx = (to_x < from_x ? -1 : +1);
12370 int dy = (to_y < from_y ? -1 : +1);
12373 if (from_y == to_y) // horizontal line
12375 for (i = 0; i <= xsize; i++)
12376 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12378 else if (from_x == to_x) // vertical line
12380 for (i = 0; i <= ysize; i++)
12381 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12383 else // diagonal line
12385 if (ysize < xsize) // a < 1
12387 float a = (float)ysize / (float)xsize;
12389 for (i = 0; i <= xsize; i++)
12392 int y = dy * (int)(a * i + 0.5);
12394 DrawLineElement(from_x + x, from_y + y, element, change_level);
12399 float a = (float)xsize / (float)ysize;
12401 for (i = 0; i <= ysize; i++)
12403 int x = dx * (int)(a * i + 0.5);
12406 DrawLineElement(from_x + x, from_y + y, element, change_level);
12412 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12413 int element, boolean change_level)
12415 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12416 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12417 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12418 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12421 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12422 int element, boolean change_level)
12427 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12429 for (y = from_y; y <= to_y; y++)
12430 DrawLine(from_x, y, to_x, y, element, change_level);
12433 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12434 int element, boolean change_level)
12436 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12437 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12438 int len_x = ABS(to_x - from_x);
12439 int len_y = ABS(to_y - from_y);
12442 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
12444 // not optimal (some points get drawn twice) but simple,
12445 // and fast enough for the few points we are drawing
12447 for (x = 0; x <= radius; x++)
12449 int sx, sy, sx2, sy2, lx, ly;
12451 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
12453 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12454 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12455 sx = getLoResScreenPos(sx2);
12456 sy = getLoResScreenPos(sy2);
12457 lx = sx + level_xpos;
12458 ly = sy + level_ypos;
12460 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12461 DrawLineElement(sx2, sy2, element, change_level);
12464 for (y = 0; y <= radius; y++)
12466 int sx, sy, sx2, sy2, lx, ly;
12468 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
12470 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12471 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12472 sx = getLoResScreenPos(sx2);
12473 sy = getLoResScreenPos(sy2);
12474 lx = sx + level_xpos;
12475 ly = sy + level_ypos;
12477 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12478 DrawLineElement(sx2, sy2, element, change_level);
12482 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
12483 int element, boolean change_level)
12485 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12486 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12488 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12491 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
12493 #if DRAW_CIRCLES_BUTTON_AVAILABLE
12494 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
12495 int element, boolean change_level)
12497 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12498 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12499 int mirror_to_x2 = from_x - (to_x2 - from_x);
12500 int mirror_to_y2 = from_y - (to_y2 - from_y);
12502 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12503 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
12504 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
12505 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element, change_level);
12509 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
12511 int from_sx, from_sy;
12515 swap_numbers(&from_x, &to_x);
12518 swap_numbers(&from_y, &to_y);
12520 from_sx = SX + from_x * ed_tilesize;
12521 from_sy = SY + from_y * ed_tilesize;
12522 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
12523 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
12525 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12526 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12527 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12528 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12530 if (from_x == to_x && from_y == to_y)
12531 MarkTileDirty(from_x/2, from_y/2);
12533 redraw_mask |= REDRAW_FIELD;
12536 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
12537 int element, boolean change_level)
12539 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
12542 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
12543 int element, boolean change_level)
12545 if (element == -1 || change_level)
12546 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
12548 DrawAreaBorder(from_x, from_y, to_x, to_y);
12551 // values for CopyBrushExt()
12552 #define CB_AREA_TO_BRUSH 0
12553 #define CB_BRUSH_TO_CURSOR 1
12554 #define CB_BRUSH_TO_LEVEL 2
12555 #define CB_DELETE_OLD_CURSOR 3
12556 #define CB_DUMP_BRUSH 4
12557 #define CB_DUMP_BRUSH_SMALL 5
12558 #define CB_CLIPBOARD_TO_BRUSH 6
12559 #define CB_BRUSH_TO_CLIPBOARD 7
12560 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
12561 #define CB_UPDATE_BRUSH_POSITION 9
12562 #define CB_FLIP_BRUSH_X 10
12563 #define CB_FLIP_BRUSH_Y 11
12564 #define CB_FLIP_BRUSH_XY 12
12566 #define MAX_CB_PART_SIZE 10
12567 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
12568 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
12569 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
12570 MAX_CB_NUM_LINES * \
12573 static int getFlippedTileExt(int map[], int element)
12577 for (i = 0; map[i] != -1; i++)
12578 if (map[i] == element)
12579 return map[i ^ 1]; // get flipped element by flipping LSB of index
12584 static int getFlippedTileX(int element)
12588 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_RIGHT,
12589 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_RIGHT,
12590 EL_BUG_LEFT, EL_BUG_RIGHT,
12591 EL_SPACESHIP_LEFT, EL_SPACESHIP_RIGHT,
12592 EL_PACMAN_LEFT, EL_PACMAN_RIGHT,
12593 EL_ARROW_LEFT, EL_ARROW_RIGHT,
12594 EL_MOLE_LEFT, EL_MOLE_RIGHT,
12595 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_RIGHT,
12596 EL_YAMYAM_LEFT, EL_YAMYAM_RIGHT,
12597 EL_SP_PORT_LEFT, EL_SP_PORT_RIGHT,
12598 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_RIGHT,
12599 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_RIGHT,
12600 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_RIGHT,
12601 EL_CONVEYOR_BELT_1_LEFT, EL_CONVEYOR_BELT_1_RIGHT,
12602 EL_CONVEYOR_BELT_2_LEFT, EL_CONVEYOR_BELT_2_RIGHT,
12603 EL_CONVEYOR_BELT_3_LEFT, EL_CONVEYOR_BELT_3_RIGHT,
12604 EL_CONVEYOR_BELT_4_LEFT, EL_CONVEYOR_BELT_4_RIGHT,
12605 EL_SPRING_LEFT, EL_SPRING_RIGHT,
12606 EL_SP_CHIP_LEFT, EL_SP_CHIP_RIGHT,
12607 EL_TUBE_VERTICAL_LEFT, EL_TUBE_VERTICAL_RIGHT,
12608 EL_TUBE_LEFT_UP, EL_TUBE_RIGHT_UP,
12609 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_DOWN,
12610 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_RIGHT,
12611 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_TOPRIGHT,
12612 EL_DC_STEELWALL_1_BOTTOMLEFT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
12613 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_TOPRIGHT_2,
12614 EL_DC_STEELWALL_1_BOTTOMLEFT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
12615 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_RIGHT,
12616 EL_ACID_POOL_TOPLEFT, EL_ACID_POOL_TOPRIGHT,
12617 EL_ACID_POOL_BOTTOMLEFT, EL_ACID_POOL_BOTTOMRIGHT,
12622 return getFlippedTileExt(map, element);
12625 static int getFlippedTileY(int element)
12629 EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY_DOWN,
12630 EL_BD_FIREFLY_UP, EL_BD_FIREFLY_DOWN,
12631 EL_BUG_UP, EL_BUG_DOWN,
12632 EL_SPACESHIP_UP, EL_SPACESHIP_DOWN,
12633 EL_PACMAN_UP, EL_PACMAN_DOWN,
12634 EL_ARROW_UP, EL_ARROW_DOWN,
12635 EL_MOLE_UP, EL_MOLE_DOWN,
12636 EL_BALLOON_SWITCH_UP, EL_BALLOON_SWITCH_DOWN,
12637 EL_YAMYAM_UP, EL_YAMYAM_DOWN,
12638 EL_SP_PORT_UP, EL_SP_PORT_DOWN,
12639 EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN,
12640 EL_SP_GRAVITY_ON_PORT_UP, EL_SP_GRAVITY_ON_PORT_DOWN,
12641 EL_SP_GRAVITY_OFF_PORT_UP, EL_SP_GRAVITY_OFF_PORT_DOWN,
12642 EL_SP_CHIP_TOP, EL_SP_CHIP_BOTTOM,
12643 EL_TUBE_HORIZONTAL_UP, EL_TUBE_HORIZONTAL_DOWN,
12644 EL_TUBE_LEFT_UP, EL_TUBE_LEFT_DOWN,
12645 EL_TUBE_RIGHT_UP, EL_TUBE_RIGHT_DOWN,
12646 EL_DC_STEELWALL_1_TOP, EL_DC_STEELWALL_1_BOTTOM,
12647 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_BOTTOMLEFT,
12648 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
12649 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
12650 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
12651 EL_DC_STEELWALL_2_TOP, EL_DC_STEELWALL_2_BOTTOM,
12652 EL_EMC_WALL_1, EL_EMC_WALL_3,
12657 return getFlippedTileExt(map, element);
12660 static int getFlippedTileXY(int element)
12664 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_UP,
12665 EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY_DOWN,
12666 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_UP,
12667 EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY_DOWN,
12668 EL_BUG_LEFT, EL_BUG_UP,
12669 EL_BUG_RIGHT, EL_BUG_DOWN,
12670 EL_SPACESHIP_LEFT, EL_SPACESHIP_UP,
12671 EL_SPACESHIP_RIGHT, EL_SPACESHIP_DOWN,
12672 EL_PACMAN_LEFT, EL_PACMAN_UP,
12673 EL_PACMAN_RIGHT, EL_PACMAN_DOWN,
12674 EL_ARROW_LEFT, EL_ARROW_UP,
12675 EL_ARROW_RIGHT, EL_ARROW_DOWN,
12676 EL_MOLE_LEFT, EL_MOLE_UP,
12677 EL_MOLE_RIGHT, EL_MOLE_DOWN,
12678 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_UP,
12679 EL_BALLOON_SWITCH_RIGHT, EL_BALLOON_SWITCH_DOWN,
12680 EL_YAMYAM_LEFT, EL_YAMYAM_UP,
12681 EL_YAMYAM_RIGHT, EL_YAMYAM_DOWN,
12682 EL_SP_PORT_LEFT, EL_SP_PORT_UP,
12683 EL_SP_PORT_RIGHT, EL_SP_PORT_DOWN,
12684 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_UP,
12685 EL_SP_GRAVITY_PORT_RIGHT, EL_SP_GRAVITY_PORT_DOWN,
12686 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_UP,
12687 EL_SP_GRAVITY_ON_PORT_RIGHT, EL_SP_GRAVITY_ON_PORT_DOWN,
12688 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_UP,
12689 EL_SP_GRAVITY_OFF_PORT_RIGHT, EL_SP_GRAVITY_OFF_PORT_DOWN,
12690 EL_SP_CHIP_LEFT, EL_SP_CHIP_TOP,
12691 EL_SP_CHIP_RIGHT, EL_SP_CHIP_BOTTOM,
12692 EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL,
12693 EL_TUBE_VERTICAL_LEFT, EL_TUBE_HORIZONTAL_UP,
12694 EL_TUBE_VERTICAL_RIGHT, EL_TUBE_HORIZONTAL_DOWN,
12695 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_UP,
12696 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_TOP,
12697 EL_DC_STEELWALL_1_RIGHT, EL_DC_STEELWALL_1_BOTTOM,
12698 EL_DC_STEELWALL_1_HORIZONTAL, EL_DC_STEELWALL_1_VERTICAL,
12699 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMLEFT,
12700 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
12701 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_TOP,
12702 EL_DC_STEELWALL_2_RIGHT, EL_DC_STEELWALL_2_BOTTOM,
12703 EL_DC_STEELWALL_2_HORIZONTAL, EL_DC_STEELWALL_2_VERTICAL,
12704 EL_EXPANDABLE_WALL_HORIZONTAL, EL_EXPANDABLE_WALL_VERTICAL,
12705 EL_EXPANDABLE_STEELWALL_HORIZONTAL, EL_EXPANDABLE_STEELWALL_VERTICAL,
12710 return getFlippedTileExt(map, element);
12713 static int getFlippedTile(int element, int mode)
12715 if (IS_MM_ELEMENT(element))
12717 // get MM game element
12718 element = map_element_RND_to_MM(element);
12720 // get flipped game element
12721 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX_MM(element) :
12722 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY_MM(element) :
12723 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY_MM(element) :
12726 // get RND game element again
12727 element = map_element_MM_to_RND(element);
12731 // get flipped game element
12732 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX(element) :
12733 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY(element) :
12734 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY(element) :
12741 static void SwapFlippedTiles(short *tile1, short *tile2, int mode)
12744 short tile1_flipped = getFlippedTile(*tile1, mode);
12745 short tile2_flipped = getFlippedTile(*tile2, mode);
12748 *tile1 = tile2_flipped;
12749 *tile2 = tile1_flipped;
12752 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
12754 DrawLineElement(sx, sy, element, change_level);
12757 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
12758 int button, int mode)
12760 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12761 static int brush_width, brush_height;
12762 static int last_cursor_x = -1, last_cursor_y = -1;
12763 static boolean delete_old_brush = FALSE;
12764 int new_element = BUTTON_ELEMENT(button);
12767 if (mode == CB_DUMP_BRUSH ||
12768 mode == CB_DUMP_BRUSH_SMALL ||
12769 mode == CB_BRUSH_TO_CLIPBOARD ||
12770 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12772 if (edit_mode != ED_MODE_DRAWING)
12775 char part[MAX_CB_PART_SIZE + 1] = "";
12776 char text[MAX_CB_TEXT_SIZE + 1] = "";
12777 int width = (draw_with_brush ? brush_width : lev_fieldx);
12778 int height = (draw_with_brush ? brush_height : lev_fieldy);
12779 char *format = "%s%03d";
12781 for (y = 0; y < height; y++)
12782 for (x = 0; x < width; x++)
12783 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
12786 for (y = 0; y < height; y++)
12788 for (x = 0; x < width; x++)
12790 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
12791 char *prefix = (mode == CB_DUMP_BRUSH ||
12792 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
12794 if (element >= NUM_FILE_ELEMENTS)
12795 element = EL_UNKNOWN;
12797 // copy brush to level sketch text buffer for the R'n'D forum:
12798 // - large tiles: `xxx or `xxxx (0x60 ASCII)
12799 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
12800 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
12801 strcat(text, part);
12804 strcat(text, "\n");
12807 if (mode == CB_BRUSH_TO_CLIPBOARD ||
12808 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12809 SDL_SetClipboardText(text);
12811 Print("%s", text); // print brush data to console and log file
12816 if (mode == CB_CLIPBOARD_TO_BRUSH)
12818 if (edit_mode != ED_MODE_DRAWING)
12821 if (!SDL_HasClipboardText())
12823 Request("Clipboard is empty!", REQ_CONFIRM);
12828 boolean copy_to_brush = (draw_with_brush ||
12829 drawing_function == GADGET_ID_GRAB_BRUSH);
12831 // this will delete the old brush, if already drawing with a brush
12833 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
12835 // initialization is required for "odd" (incomplete) clipboard content
12836 for (x = 0; x < MAX_LEV_FIELDX; x++)
12837 for (y = 0; y < MAX_LEV_FIELDY; y++)
12838 brush_buffer[x][y] = EL_EMPTY;
12845 char *clipboard_text = SDL_GetClipboardText();
12846 char *ptr = clipboard_text;
12847 boolean allow_new_row = FALSE;
12848 boolean stop = FALSE;
12850 while (*ptr && !stop)
12852 boolean prefix_found = FALSE;
12853 boolean start_new_row = FALSE;
12855 // level sketch element number prefixes (may be multi-byte characters)
12856 char *prefix_list[] = { "`", "¸" };
12859 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
12861 char *prefix = prefix_list[i];
12863 // check if string is large enough for prefix
12864 if (strlen(ptr) < strlen(prefix))
12871 // check if string starts with prefix
12872 if (strPrefix(ptr, prefix))
12874 ptr += strlen(prefix);
12876 prefix_found = TRUE;
12882 // check if prefix found and followed by (at least) three digits
12883 if (prefix_found &&
12884 strlen(ptr) >= 3 &&
12885 ptr[0] >= '0' && ptr[0] <= '9' &&
12886 ptr[1] >= '0' && ptr[1] <= '9' &&
12887 ptr[2] >= '0' && ptr[2] <= '9')
12889 int element = ((ptr[0] - '0') * 100 +
12890 (ptr[1] - '0') * 10 +
12895 // level sketch element number might consist of four digits
12896 if (ptr[0] >= '0' && ptr[0] <= '9')
12898 element = element * 10 + (ptr[0] - '0');
12902 // remap some (historic, now obsolete) elements
12903 element = getMappedElement(element);
12905 if (element >= NUM_FILE_ELEMENTS)
12906 element = EL_UNKNOWN;
12908 brush_buffer[x][y] = element;
12910 brush_width = MAX(x + 1, brush_width);
12911 brush_height = MAX(y + 1, brush_height);
12915 if (x >= MAX_LEV_FIELDX)
12916 start_new_row = TRUE;
12918 allow_new_row = TRUE;
12922 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
12923 start_new_row = TRUE;
12925 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
12933 if (y >= MAX_LEV_FIELDY)
12936 allow_new_row = FALSE;
12940 SDL_free(clipboard_text);
12942 if (brush_width == 0 || brush_height == 0)
12944 Request("No level sketch found in clipboard!", REQ_CONFIRM);
12951 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
12954 SDL_GetMouseState(&mx, &my);
12956 // if inside drawing area, activate and draw brush at last mouse position
12957 if (mx >= gi->x && mx < gi->x + gi->width &&
12958 my >= gi->y && my < gi->y + gi->height)
12959 CopyBrushToCursor(last_cursor_x, last_cursor_y);
12961 draw_with_brush = TRUE;
12967 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
12968 brush_width, brush_height);
12970 if (!Request(request, REQ_ASK))
12973 for (x = 0; x < MAX_LEV_FIELDX; x++)
12974 for (y = 0; y < MAX_LEV_FIELDY; y++)
12975 Tile[x][y] = brush_buffer[x][y];
12977 lev_fieldx = level.fieldx = brush_width;
12978 lev_fieldy = level.fieldy = brush_height;
12980 boolean use_bd_engine = TRUE;
12981 boolean use_em_engine = TRUE;
12982 boolean use_sp_engine = TRUE;
12983 boolean use_mm_engine = TRUE;
12985 for (x = 0; x < MAX_LEV_FIELDX; x++)
12987 for (y = 0; y < MAX_LEV_FIELDY; y++)
12989 int element = Tile[x][y];
12991 if (!IS_BD_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
12992 use_bd_engine = FALSE;
12994 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
12995 use_em_engine = FALSE;
12997 if (!IS_SP_ELEMENT(element))
12998 use_sp_engine = FALSE;
13000 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
13001 use_mm_engine = FALSE;
13005 level.game_engine_type = (use_bd_engine ? GAME_ENGINE_TYPE_BD :
13006 use_em_engine ? GAME_ENGINE_TYPE_EM :
13007 use_sp_engine ? GAME_ENGINE_TYPE_SP :
13008 use_mm_engine ? GAME_ENGINE_TYPE_MM :
13009 GAME_ENGINE_TYPE_RND);
13011 // update element selection list
13012 ReinitializeElementList();
13013 ModifyEditorElementList();
13015 SetBorderElement();
13017 DrawEditModeWindow();
13018 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13024 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
13027 if (mode == CB_AREA_TO_BRUSH)
13029 int from_lx, from_ly;
13032 swap_numbers(&from_x, &to_x);
13035 swap_numbers(&from_y, &to_y);
13037 brush_width = to_x - from_x + 1;
13038 brush_height = to_y - from_y + 1;
13040 from_lx = from_x + level_xpos;
13041 from_ly = from_y + level_ypos;
13043 for (y = 0; y < brush_height; y++)
13045 for (x = 0; x < brush_width; x++)
13047 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
13050 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
13055 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13057 delete_old_brush = FALSE;
13059 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
13060 mode == CB_BRUSH_TO_LEVEL)
13062 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
13063 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
13064 int cursor_from_x = cursor_x - brush_width / 2;
13065 int cursor_from_y = cursor_y - brush_height / 2;
13066 int border_from_x = cursor_x, border_from_y = cursor_y;
13067 int border_to_x = cursor_x, border_to_y = cursor_y;
13069 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
13070 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13072 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
13073 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
13075 delete_old_brush = FALSE;
13080 for (y = 0; y < brush_height; y++)
13082 for (x = 0; x < brush_width; x++)
13084 int sx = cursor_from_x + x;
13085 int sy = cursor_from_y + y;
13086 int lx = sx + level_xpos;
13087 int ly = sy + level_ypos;
13088 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
13089 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
13090 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
13091 brush_buffer[x][y] : new_element);
13093 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13095 if (sx < border_from_x)
13096 border_from_x = sx;
13097 else if (sx > border_to_x)
13099 if (sy < border_from_y)
13100 border_from_y = sy;
13101 else if (sy > border_to_y)
13104 DrawBrushElement(sx, sy, element, change_level);
13109 if (mode != CB_DELETE_OLD_CURSOR)
13110 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
13112 last_cursor_x = cursor_x;
13113 last_cursor_y = cursor_y;
13115 delete_old_brush = TRUE;
13117 else if (mode == CB_FLIP_BRUSH_X)
13119 for (y = 0; y < brush_height; y++)
13120 for (x = 0; x < (brush_width + 1) / 2; x++)
13121 SwapFlippedTiles(&brush_buffer[x][y],
13122 &brush_buffer[brush_width - x - 1][y], mode);
13124 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13126 else if (mode == CB_FLIP_BRUSH_Y)
13128 for (y = 0; y < (brush_height + 1) / 2; y++)
13129 for (x = 0; x < brush_width; x++)
13130 SwapFlippedTiles(&brush_buffer[x][y],
13131 &brush_buffer[x][brush_height - y - 1], mode);
13133 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13135 else if (mode == CB_FLIP_BRUSH_XY)
13137 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13139 for (y = 0; y < MAX(brush_width, brush_height); y++)
13140 for (x = 0; x <= y; x++)
13141 SwapFlippedTiles(&brush_buffer[x][y],
13142 &brush_buffer[y][x], mode);
13144 swap_numbers(&brush_width, &brush_height);
13146 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13149 if (mode == CB_UPDATE_BRUSH_POSITION)
13151 last_cursor_x = from_x;
13152 last_cursor_y = from_y;
13156 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
13159 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
13162 static void CopyBrushToLevel(int x, int y, int button)
13164 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
13167 static void CopyBrushToCursor(int x, int y)
13169 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13172 static void UpdateBrushPosition(int x, int y)
13174 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
13177 static void DeleteBrushFromCursor(void)
13179 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13182 static void FlipBrushX(void)
13184 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13187 static void FlipBrushY(void)
13189 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_Y);
13192 static void RotateBrush(void)
13194 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_XY);
13195 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13198 void DumpBrush(void)
13200 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
13203 void DumpBrush_Small(void)
13205 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
13208 void CopyClipboardToBrush(void)
13210 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
13213 void CopyBrushToClipboard(void)
13215 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
13218 void CopyBrushToClipboard_Small(void)
13220 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
13223 void UndoLevelEditorOperation(void)
13225 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
13228 void RedoLevelEditorOperation(void)
13230 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13233 static void FloodFill(int from_x, int from_y, int fill_element)
13235 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
13238 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
13240 int from_x = from_sx2 + 2 * level_xpos;
13241 int from_y = from_sy2 + 2 * level_ypos;
13242 int max_fillx = lev_fieldx * 2;
13243 int max_filly = lev_fieldy * 2;
13244 short Fill[max_fillx][max_filly];
13247 for (x = 0; x < max_fillx; x++)
13248 for (y = 0; y < max_filly; y++)
13249 Fill[x][y] = getLevelElementHiRes(x, y);
13251 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
13252 Fill, max_fillx, max_filly);
13254 for (x = 0; x < max_fillx; x++)
13255 for (y = 0; y < max_filly; y++)
13256 if (Fill[x][y] == fill_element)
13257 SetLevelElementHiRes(x, y, Fill[x][y]);
13260 // values for DrawLevelText() modes
13261 #define TEXT_INIT 0
13262 #define TEXT_SETCURSOR 1
13263 #define TEXT_WRITECHAR 2
13264 #define TEXT_BACKSPACE 3
13265 #define TEXT_NEWLINE 4
13267 #define TEXT_QUERY_TYPING 6
13269 static int DrawLevelText(int sx, int sy, char letter, int mode)
13271 static short delete_buffer[MAX_LEV_FIELDX];
13272 static int start_sx;
13273 static int last_sx, last_sy;
13274 static boolean typing = FALSE;
13275 int letter_element;
13276 int lx = 0, ly = 0;
13278 // map lower case letters to upper case and convert special characters
13279 if (letter >= 'a' && letter <= 'z')
13280 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
13281 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
13282 letter_element = EL_CHAR_AUMLAUT;
13283 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
13284 letter_element = EL_CHAR_OUMLAUT;
13285 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
13286 letter_element = EL_CHAR_UUMLAUT;
13287 else if (letter == '^')
13288 letter_element = EL_CHAR_COPYRIGHT;
13290 letter_element = EL_CHAR_ASCII0 + letter;
13292 if (mode != TEXT_INIT)
13297 if (mode != TEXT_SETCURSOR)
13303 lx = last_sx + level_xpos;
13304 ly = last_sy + level_ypos;
13311 DrawLevelText(0, 0, 0, TEXT_END);
13317 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
13320 case TEXT_SETCURSOR:
13321 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
13322 DrawAreaBorder(sx, sy, sx, sy);
13323 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
13324 ed_tilesize, ed_tilesize);
13329 case TEXT_WRITECHAR:
13330 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
13332 if (new_element1 >= EL_STEEL_CHAR_START &&
13333 new_element1 <= EL_STEEL_CHAR_END)
13334 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
13336 delete_buffer[sx - start_sx] = Tile[lx][ly];
13337 Tile[lx][ly] = letter_element;
13339 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
13340 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
13341 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13342 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13344 DrawLevelText(0, 0, 0, TEXT_END);
13346 level.changed = TRUE;
13350 case TEXT_BACKSPACE:
13353 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
13354 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
13355 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
13360 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13361 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13363 DrawLevelText(0, 0, 0, TEXT_END);
13367 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13368 DrawEditorElement(sx, sy, Tile[lx][ly]);
13373 case TEXT_QUERY_TYPING:
13383 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
13384 int element, boolean change_level)
13386 int lx = sx + level_xpos;
13387 int ly = sy + level_ypos;
13390 DrawEditorElement(sx, sy, Tile[lx][ly]);
13392 DrawAreaBorder(sx, sy, sx, sy);
13395 static void CheckLevelBorderElement(boolean redraw_playfield)
13397 int last_border_element = BorderElement;
13399 SetBorderElement();
13401 if (redraw_playfield && BorderElement != last_border_element)
13402 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13405 static void CopyLevelToUndoBuffer(int mode)
13407 static boolean accumulated_undo = FALSE;
13408 boolean new_undo_buffer_position = TRUE;
13411 if (undo_buffer_steps == 0)
13412 accumulated_undo = FALSE;
13416 case UNDO_IMMEDIATE:
13417 accumulated_undo = FALSE;
13420 case UNDO_ACCUMULATE:
13421 if (accumulated_undo)
13422 new_undo_buffer_position = FALSE;
13423 accumulated_undo = TRUE;
13430 if (new_undo_buffer_position)
13432 // advance position in undo buffer ring
13433 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13435 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
13436 undo_buffer_steps++;
13439 // always reset redo buffer when storing level change into undo buffer
13440 redo_buffer_steps = 0;
13442 for (x = 0; x < lev_fieldx; x++)
13443 for (y = 0; y < lev_fieldy; y++)
13444 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
13446 // check if drawing operation forces change of border style
13447 CheckLevelBorderElement(TRUE);
13449 level.changed = TRUE;
13452 static void RandomPlacement(int new_element)
13454 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13455 int num_free_positions = 0;
13456 int num_percentage, num_elements;
13459 ResetIntelliDraw();
13461 // determine number of free positions for randomly placing the new element
13462 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
13464 free_position[x][y] =
13465 (random_placement_background_restricted ?
13466 Tile[x][y] == random_placement_background_element :
13467 Tile[x][y] != new_element);
13469 if (free_position[x][y])
13470 num_free_positions++;
13473 // determine number of new elements to place there
13474 num_percentage = num_free_positions * random_placement_value / 100;
13475 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
13476 num_percentage : random_placement_value);
13478 // if less free positions than elements to place, fill all these positions
13479 if (num_free_positions < num_elements)
13481 for (x = 0; x < lev_fieldx; x++)
13482 for (y = 0; y < lev_fieldy; y++)
13483 if (free_position[x][y])
13484 SetElement(x, y, new_element);
13488 while (num_elements > 0)
13490 x = GetSimpleRandom(lev_fieldx);
13491 y = GetSimpleRandom(lev_fieldy);
13493 // don't place element at the same position twice
13494 if (free_position[x][y])
13496 free_position[x][y] = FALSE;
13497 SetElement(x, y, new_element);
13503 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13504 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13507 static void WrapLevel(int dx, int dy)
13509 int wrap_dx = lev_fieldx - dx;
13510 int wrap_dy = lev_fieldy - dy;
13513 for (x = 0; x < lev_fieldx; x++)
13514 for (y = 0; y < lev_fieldy; y++)
13515 TileBackup[x][y] = Tile[x][y];
13517 for (x = 0; x < lev_fieldx; x++)
13518 for (y = 0; y < lev_fieldy; y++)
13520 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
13522 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13523 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
13526 static void DrawAreaElementHighlight(boolean highlighted,
13527 boolean highlighted_similar)
13529 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13536 for (x = 0; x < ed_fieldx; x++)
13538 for (y = 0; y < ed_fieldy; y++)
13540 boolean highlight = FALSE;
13541 int lx = x + level_xpos;
13542 int ly = y + level_ypos;
13544 if (!IN_LEV_FIELD(lx, ly))
13547 // check if element is the same
13548 if (Tile[lx][ly] == new_element1)
13551 // check if element is similar
13552 if (highlighted_similar &&
13553 strEqual(element_info[Tile[lx][ly]].class_name,
13554 element_info[new_element1].class_name))
13557 // check if element is matching MM style wall
13558 if (IS_MM_WALL(Tile[lx][ly]) &&
13559 map_mm_wall_element(Tile[lx][ly]) == new_element1)
13565 if (IS_MM_WALL(Tile[lx][ly]) && !highlighted_similar)
13569 for (i = 0; i < 4; i++)
13571 if (!(MM_WALL_BITS(Tile[lx][ly]) & (1 << i)))
13574 int xx = x * 2 + (i % 2);
13575 int yy = y * 2 + (i / 2);
13576 int sx = SX + xx * ed_tilesize / 2;
13577 int sy = SY + yy * ed_tilesize / 2;
13580 int to_sx = sx + ed_tilesize / 2 - 1;
13581 int to_sy = sy + ed_tilesize / 2 - 1;
13583 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13584 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13585 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13586 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13591 int sx = SX + x * ed_tilesize;
13592 int sy = SY + y * ed_tilesize;
13595 int to_sx = sx + ed_tilesize - 1;
13596 int to_sy = sy + ed_tilesize - 1;
13598 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13599 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13600 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13601 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13607 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
13609 char *template_filename_old = getLocalLevelTemplateFilename();
13610 char *template_filename_new =
13611 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
13613 if (copyFile(template_filename_old, template_filename_new) != 0)
13614 Request("Cannot copy level template!", REQ_CONFIRM);
13616 free(template_filename_new);
13619 static void HandleDrawingAreas(struct GadgetInfo *gi)
13621 static boolean started_inside_drawing_area = FALSE;
13622 static int last_sx = -1;
13623 static int last_sy = -1;
13624 static int last_sx2 = -1;
13625 static int last_sy2 = -1;
13626 int id = gi->custom_id;
13627 int type_id = gi->custom_type_id;
13628 boolean button_press_event;
13629 boolean button_release_event;
13630 boolean inside_drawing_area = !gi->event.off_borders;
13631 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
13632 int actual_drawing_function;
13633 int button = gi->event.button;
13634 int new_element = BUTTON_ELEMENT(button);
13635 int sx = gi->event.x, sy = gi->event.y;
13636 int min_sx = 0, min_sy = 0;
13637 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
13638 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
13639 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
13640 int sx2 = gi->event.mx / mini_item_xsize;
13641 int sy2 = gi->event.my / mini_item_ysize;
13644 int lx = 0, ly = 0;
13647 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
13648 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
13650 // make sure to stay inside drawing area boundaries
13651 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
13652 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
13656 int min_lx = 0, min_ly = 0;
13657 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
13659 // get positions inside level field
13660 lx = sx + level_xpos;
13661 ly = sy + level_ypos;
13663 if (!IN_LEV_FIELD(lx, ly))
13664 inside_drawing_area = FALSE;
13666 // make sure to stay inside level field boundaries
13667 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
13668 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
13670 // correct drawing area positions accordingly
13671 sx = lx - level_xpos;
13672 sy = ly - level_ypos;
13675 // also correct MM wall-sized (double) drawing area positions accordingly
13676 if (sx2 / 2 < sx || sx2 / 2 > sx)
13678 dx = (sx2 / 2 < sx ? 0 : 1);
13681 if (sy2 / 2 < sy || sy2 / 2 > sy)
13683 dy = (sy2 / 2 < sy ? 0 : 1);
13687 if (!button_press_event && !button_release_event)
13689 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
13690 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
13691 isHiresTileElement(old_element) &&
13692 isHiresDrawElement(new_element));
13694 // prevent handling events for every pixel position when moving mouse
13695 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
13696 (sx2 == last_sx2 && sy2 == last_sy2))
13705 if (button_press_event)
13706 started_inside_drawing_area = inside_drawing_area;
13708 if (!started_inside_drawing_area)
13711 if (!IS_VALID_BUTTON(button))
13714 // handle info callback for each invocation of action callback
13715 gi->callback_info(gi);
13717 // automatically switch to 'single item' drawing mode, if needed
13718 actual_drawing_function =
13719 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
13720 drawing_function : GADGET_ID_SINGLE_ITEMS);
13722 // clicking into drawing area with pressed Control key picks element
13723 if (GetKeyModState() & KMOD_Control)
13725 last_drawing_function = drawing_function;
13726 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
13729 if (GetKeyModState() & KMOD_Shift)
13731 if (button_press_event || button_release_event)
13732 ResetIntelliDraw();
13735 SetDrawModeHiRes(-1); // reset to normal draw mode
13737 switch (actual_drawing_function)
13739 case GADGET_ID_SINGLE_ITEMS:
13742 if (button_release_event)
13744 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13746 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
13747 !inside_drawing_area)
13748 DeleteBrushFromCursor();
13753 if (draw_with_brush)
13755 CopyBrushToLevel(sx, sy, button);
13759 SetDrawModeHiRes(new_element);
13761 if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
13763 // remove player at old position
13764 for (y = 0; y < lev_fieldy; y++)
13766 for (x = 0; x < lev_fieldx; x++)
13768 int old_element = Tile[x][y];
13770 if (IS_PLAYER_ELEMENT(old_element) &&
13771 IS_PLAYER_ELEMENT(new_element))
13773 int replaced_with_element =
13774 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
13775 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
13777 old_element == EL_SOKOBAN_FIELD_PLAYER &&
13778 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
13780 new_element == EL_SOKOBAN_FIELD_PLAYER &&
13781 old_element == EL_PLAYER_1 ? EL_EMPTY :
13783 new_element >= EL_PLAYER_1 &&
13784 new_element <= EL_PLAYER_4 &&
13785 new_element == old_element ? EL_EMPTY :
13789 SetElement(x, y, replaced_with_element);
13791 else if (IS_MM_MCDUFFIN(old_element) &&
13792 IS_MM_MCDUFFIN(new_element))
13794 // remove McDuffin at old position
13795 SetElement(x, y, EL_EMPTY);
13801 SetElementButton(lx, ly, dx, dy, new_element, button);
13804 else if (!button_release_event)
13806 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13808 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
13809 DrawMiniGraphicExt(drawto,
13810 gi->x + sx * MINI_TILEX,
13811 gi->y + sy * MINI_TILEY,
13812 el2edimg(new_element));
13814 DrawFixedGraphicExt(drawto,
13815 gi->x + sx * TILEX,
13816 gi->y + sy * TILEY,
13817 el2edimg(new_element), 0);
13819 if (id == GADGET_ID_CUSTOM_GRAPHIC)
13820 new_element = GFX_ELEMENT(new_element);
13822 drawingarea_info[type_id].value[pos] = new_element;
13824 CopyElementPropertiesToGame(properties_element);
13826 if (id == GADGET_ID_CUSTOM_GRAPHIC)
13828 UpdateCustomElementGraphicGadgets();
13830 FrameCounter = 0; // restart animation frame counter
13835 case GADGET_ID_CONNECTED_ITEMS:
13837 static int last_sx = -1;
13838 static int last_sy = -1;
13840 if (button_release_event)
13841 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13843 SetDrawModeHiRes(new_element);
13845 if (getDrawModeHiRes())
13851 if (!button_press_event)
13852 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
13859 case GADGET_ID_LINE:
13860 case GADGET_ID_ARC:
13861 case GADGET_ID_RECTANGLE:
13862 case GADGET_ID_FILLED_BOX:
13863 SetDrawModeHiRes(new_element);
13865 if (getDrawModeHiRes())
13871 case GADGET_ID_GRAB_BRUSH:
13872 case GADGET_ID_TEXT:
13874 static int last_sx = -1;
13875 static int last_sy = -1;
13876 static int start_sx = -1;
13877 static int start_sy = -1;
13878 void (*draw_func)(int, int, int, int, int, boolean);
13880 if (drawing_function == GADGET_ID_LINE)
13881 draw_func = DrawLine;
13882 else if (drawing_function == GADGET_ID_ARC)
13883 draw_func = DrawArc;
13884 else if (drawing_function == GADGET_ID_RECTANGLE)
13885 draw_func = DrawBox;
13886 else if (drawing_function == GADGET_ID_FILLED_BOX)
13887 draw_func = DrawFilledBox;
13888 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
13889 draw_func = SelectArea;
13890 else // (drawing_function == GADGET_ID_TEXT)
13891 draw_func = SetTextCursor;
13893 if (button_press_event)
13895 draw_func(sx, sy, sx, sy, new_element, FALSE);
13896 start_sx = last_sx = sx;
13897 start_sy = last_sy = sy;
13899 if (drawing_function == GADGET_ID_TEXT)
13900 DrawLevelText(0, 0, 0, TEXT_END);
13902 else if (button_release_event)
13904 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
13905 if (drawing_function == GADGET_ID_GRAB_BRUSH)
13907 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
13908 CopyBrushToCursor(sx, sy);
13909 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
13911 draw_with_brush = TRUE;
13913 else if (drawing_function == GADGET_ID_TEXT)
13914 DrawLevelText(sx, sy, 0, TEXT_INIT);
13916 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13918 else if (last_sx != sx || last_sy != sy)
13920 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
13921 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
13922 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
13923 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
13930 case GADGET_ID_FLOOD_FILL:
13931 if (button_press_event && Tile[lx][ly] != new_element)
13933 if (IS_MM_WALL_EDITOR(new_element))
13934 FloodFillWall_MM(sx2, sy2, new_element);
13936 FloodFill(lx, ly, new_element);
13938 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13939 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13943 case GADGET_ID_PICK_ELEMENT:
13944 if (button_release_event)
13945 ClickOnGadget(level_editor_gadget[last_drawing_function],
13947 else if (draw_level)
13948 PickDrawingElement(button, Tile[lx][ly]);
13951 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13953 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
13960 // do not mark level as modified for certain non-level-changing gadgets
13961 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
13962 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
13963 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
13964 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
13967 level.changed = TRUE;
13970 static void HandleCounterButtons(struct GadgetInfo *gi)
13972 int gadget_id = gi->custom_id;
13973 int counter_id = gi->custom_type_id;
13974 int button = gi->event.button;
13975 int *counter_value = counterbutton_info[counter_id].value;
13976 int step = BUTTON_STEPSIZE(button) *
13977 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
13979 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
13981 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
13982 boolean released = (gi->event.type == GD_EVENT_RELEASED);
13983 boolean level_changed = LevelChanged();
13985 if ((level_changed && pressed) || (!level_changed && released))
13988 if (level_changed && !Request("Level has changed! Discard changes?",
13991 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
13992 ModifyEditorCounterValue(counter_id, *counter_value);
13998 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
13999 *counter_value = gi->textinput.number_value;
14001 ModifyEditorCounterValue(counter_id, *counter_value + step);
14003 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14005 int last_game_engine_type = level.game_engine_type;
14007 LoadLevel(level_nr);
14008 LoadScore(level_nr);
14010 SaveLevelSetup_SeriesInfo();
14015 DrawEditModeWindow();
14017 if (level.game_engine_type != last_game_engine_type)
14019 // update element selection list
14020 ReinitializeElementList();
14021 ModifyEditorElementList();
14027 switch (counter_id)
14029 case ED_COUNTER_ID_YAMYAM_CONTENT:
14030 DrawYamYamContentAreas();
14033 case ED_COUNTER_ID_BALL_CONTENT:
14034 DrawMagicBallContentAreas();
14037 case ED_COUNTER_ID_ANDROID_CONTENT:
14038 DrawAndroidElementArea();
14041 case ED_COUNTER_ID_GROUP_CONTENT:
14042 DrawGroupElementArea();
14043 CopyGroupElementPropertiesToGame(properties_element);
14046 case ED_COUNTER_ID_INVENTORY_SIZE:
14047 DrawPlayerInitialInventoryArea(properties_element);
14050 case ED_COUNTER_ID_MM_BALL_CONTENT:
14051 DrawMMBallContentArea();
14054 case ED_COUNTER_ID_ENVELOPE_XSIZE:
14055 case ED_COUNTER_ID_ENVELOPE_YSIZE:
14056 DrawEnvelopeTextArea(-1);
14059 case ED_COUNTER_ID_LEVEL_XSIZE:
14060 case ED_COUNTER_ID_LEVEL_YSIZE:
14061 lev_fieldx = level.fieldx;
14062 lev_fieldy = level.fieldy;
14064 // check if resizing of level results in change of border border
14065 SetBorderElement();
14073 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
14074 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
14075 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
14076 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
14077 CopyElementPropertiesToGame(properties_element);
14079 // do not mark level as modified for certain non-level-changing gadgets
14080 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
14081 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
14082 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
14083 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
14086 level.changed = TRUE;
14089 static void HandleTextInputGadgets(struct GadgetInfo *gi)
14091 int type_id = gi->custom_type_id;
14093 strcpy(textinput_info[type_id].value, gi->textinput.value);
14095 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
14097 CopyElementPropertiesToGame(properties_element);
14099 ModifyEditorElementList(); // update changed button info text
14102 // do not mark level as modified for certain non-level-changing gadgets
14103 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
14104 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
14107 level.changed = TRUE;
14110 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
14112 int type_id = gi->custom_type_id;
14114 strncpy(textarea_info[type_id].value, gi->textarea.value,
14115 MAX_ENVELOPE_TEXT_LEN);
14116 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
14118 level.changed = TRUE;
14121 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
14123 int type_id = gi->custom_type_id;
14124 int value_old = *selectbox_info[type_id].value;
14125 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
14127 *selectbox_info[type_id].value = value_new;
14129 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
14131 DrawLevelConfigWindow();
14133 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14135 element_info[properties_element].current_change_page = gi->selectbox.index;
14137 DrawPropertiesWindow();
14139 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
14140 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
14141 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
14142 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
14143 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
14145 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
14147 // when changing action type, also check action mode and action arg
14148 if (value_old != value_new)
14149 setSelectboxSpecialActionVariablesIfNeeded();
14151 DrawPropertiesChange();
14154 CopyElementPropertiesToGame(properties_element);
14156 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
14158 // update element selection list
14159 ReinitializeElementList();
14160 ModifyEditorElementList();
14163 // do not mark level as modified for certain non-level-changing gadgets
14164 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
14165 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14168 level.changed = TRUE;
14171 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
14173 int type_id = gi->custom_type_id;
14176 if (type_id >= ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST &&
14177 type_id <= ED_TAB_BUTTON_ID_LEVELCONFIG_LAST)
14179 edit_mode_levelconfig = gi->custom_type_id;
14181 DrawLevelConfigWindow();
14183 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
14184 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
14186 edit_mode_properties = gi->custom_type_id;
14188 DrawPropertiesWindow();
14190 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
14191 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
14193 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
14195 // backup original "level.field" (needed to track playfield changes)
14196 CopyPlayfield(level.field, TileBackup);
14198 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
14199 CopyPlayfield(Tile, level.field);
14201 if (new_template ||
14202 Request("Save this template and kill the old?", REQ_ASK))
14203 SaveLevelTemplate();
14206 Request("Template saved!", REQ_CONFIRM);
14208 // restore original "level.field" (needed to track playfield changes)
14209 CopyPlayfield(TileBackup, level.field);
14211 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
14213 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
14215 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
14216 leveldir_current->readonly)
14218 Request("This level set is read-only!", REQ_CONFIRM);
14223 if (strEqual(levelset_name, ""))
14225 Request("Please enter level set title!", REQ_CONFIRM);
14230 if (strEqual(levelset_author, ""))
14232 Request("Please enter level set author!", REQ_CONFIRM);
14237 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
14239 if (UpdateUserLevelSet(levelset_subdir,
14242 levelset_num_levels))
14244 Request("Level set updated!", REQ_CONFIRM);
14248 Request("Updating level set failed!", REQ_CONFIRM);
14251 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
14253 if (level.changed && !Request("Level has changed! Discard changes?",
14257 if (CreateUserLevelSet(levelset_subdir,
14260 levelset_num_levels,
14261 levelset_use_levelset_artwork))
14263 if (levelset_copy_level_template)
14264 CopyLevelTemplateToUserLevelSet(levelset_subdir);
14266 Request("New level set created!", REQ_CONFIRM);
14268 AddUserLevelSetToLevelInfo(levelset_subdir);
14269 ChangeEditorToLevelSet(levelset_subdir);
14273 Request("Creating new level set failed!", REQ_CONFIRM);
14277 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
14278 custom_element.num_change_pages < MAX_CHANGE_PAGES)
14280 struct ElementInfo *ei = &element_info[properties_element];
14282 // when modifying custom element, ask for copying level template
14283 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14286 setElementChangePages(ei, ei->num_change_pages + 1);
14288 // set new change page to be new current change page
14289 ei->current_change_page = ei->num_change_pages - 1;
14290 ei->change = &ei->change_page[ei->current_change_page];
14292 setElementChangeInfoToDefaults(ei->change);
14294 DrawPropertiesWindow();
14296 level.changed = TRUE;
14298 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
14299 custom_element.num_change_pages > MIN_CHANGE_PAGES)
14301 struct ElementInfo *ei = &element_info[properties_element];
14303 // when modifying custom element, ask for copying level template
14304 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14307 // copy all change pages after change page to be deleted
14308 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
14309 ei->change_page[i] = ei->change_page[i + 1];
14311 setElementChangePages(ei, ei->num_change_pages - 1);
14313 DrawPropertiesWindow();
14315 level.changed = TRUE;
14319 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
14321 int type_id = gi->custom_type_id;
14323 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
14324 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
14326 struct ElementInfo *ei = &element_info[properties_element];
14327 int step = BUTTON_STEPSIZE(gi->event.button);
14329 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
14330 ei->current_change_page += step;
14332 if (ei->current_change_page < 0)
14333 ei->current_change_page = 0;
14334 else if (ei->current_change_page >= ei->num_change_pages)
14335 ei->current_change_page = ei->num_change_pages - 1;
14337 DrawPropertiesWindow();
14339 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
14340 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14342 struct ElementInfo *ei = &element_info[properties_element];
14343 int current_change_page = ei->current_change_page;
14345 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
14347 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
14348 ei->change_page[current_change_page];
14350 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14352 // when modifying custom element, ask for copying level template
14353 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14356 ei->change_page[current_change_page] =
14357 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
14359 level.changed = TRUE;
14362 DrawPropertiesWindow();
14366 static void HandleRadiobuttons(struct GadgetInfo *gi)
14368 int type_id = gi->custom_type_id;
14370 *radiobutton_info[type_id].value =
14371 radiobutton_info[type_id].checked_value;
14373 // do not mark level as modified for certain non-level-changing gadgets
14374 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
14375 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
14378 level.changed = TRUE;
14381 static void HandleCheckbuttons(struct GadgetInfo *gi)
14383 int type_id = gi->custom_type_id;
14385 *checkbutton_info[type_id].value ^= TRUE;
14387 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
14388 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
14389 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
14390 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
14391 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
14392 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
14393 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
14394 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
14396 CopyElementPropertiesToGame(properties_element);
14399 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
14401 UpdateCustomElementGraphicGadgets();
14403 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
14404 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
14406 boolean template_related_changes_found = FALSE;
14409 // check if any custom, group or empty elements have been changed
14410 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
14411 if ((IS_CUSTOM_ELEMENT(i) ||
14412 IS_GROUP_ELEMENT(i) ||
14413 IS_EMPTY_ELEMENT(i)) &&
14414 element_info[i].modified_settings)
14415 template_related_changes_found = TRUE;
14417 if (level.use_custom_template &&
14418 !fileExists(getGlobalLevelTemplateFilename()))
14420 Request("No level template found!", REQ_CONFIRM);
14422 level.use_custom_template = FALSE;
14424 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14429 if (level.use_custom_template &&
14430 template_related_changes_found &&
14431 !Request("Discard changes and use level template?", REQ_ASK))
14433 level.use_custom_template = FALSE;
14435 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14440 if (!level.use_custom_template &&
14441 Request("Copy settings from level template?", REQ_ASK))
14446 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
14448 DrawEditModeWindow();
14450 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
14452 if (setup.editor.use_template_for_new_levels &&
14453 !fileExists(getGlobalLevelTemplateFilename()))
14455 Request("No level template found!", REQ_CONFIRM);
14460 if (setup.editor.use_template_for_new_levels &&
14462 !Request("Discard level and load template?", REQ_ASK))
14467 if (!setup.editor.use_template_for_new_levels &&
14469 !Request("Discard level and use empty level?", REQ_ASK))
14474 LoadLevel(level_nr);
14475 LoadScore(level_nr);
14480 DrawEditModeWindow();
14482 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
14484 SetAutomaticNumberOfGemsNeeded();
14487 // do not mark level as modified for certain non-level-changing gadgets
14488 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
14489 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
14490 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
14491 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
14492 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
14493 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
14496 level.changed = TRUE;
14499 static void HandleControlButtons(struct GadgetInfo *gi)
14501 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
14502 static int last_edit_mode = ED_MODE_DRAWING;
14503 static int last_custom_copy_mode = -1;
14504 static int last_button = 0;
14505 int id = gi->custom_id;
14506 int button = gi->event.button;
14507 int step = BUTTON_STEPSIZE(button);
14508 int new_element = BUTTON_ELEMENT(button);
14509 int last_properties_element = properties_element;
14512 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
14513 DrawLevelText(0, 0, 0, TEXT_END);
14515 if (id < ED_NUM_CTRL1_BUTTONS &&
14516 id != GADGET_ID_SINGLE_ITEMS &&
14517 id != GADGET_ID_PICK_ELEMENT &&
14518 edit_mode != ED_MODE_DRAWING &&
14519 drawing_function != GADGET_ID_PICK_ELEMENT &&
14520 !(GetKeyModState() & KMOD_Control))
14521 ChangeEditModeWindow(ED_MODE_DRAWING);
14523 // element copy mode active, but no element button pressed => deactivate
14524 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
14525 last_custom_copy_mode = -1;
14527 // when showing palette on element buttons, change element of button used
14528 if (editor.palette.show_on_element_buttons &&
14529 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
14531 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
14533 id = GADGET_ID_PALETTE;
14538 case GADGET_ID_SCROLL_LEFT:
14539 if (level_xpos >= 0)
14541 if (lev_fieldx < ed_fieldx - 2)
14544 level_xpos -= step;
14545 if (level_xpos < -1)
14548 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
14550 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14552 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14553 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14557 case GADGET_ID_SCROLL_RIGHT:
14558 if (level_xpos <= lev_fieldx - ed_fieldx)
14560 if (lev_fieldx < ed_fieldx - 2)
14563 level_xpos += step;
14564 if (level_xpos > lev_fieldx - ed_fieldx + 1)
14565 level_xpos = lev_fieldx - ed_fieldx + 1;
14567 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
14569 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14571 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14572 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14576 case GADGET_ID_SCROLL_UP:
14577 if (level_ypos >= 0)
14579 if (lev_fieldy < ed_fieldy - 2)
14582 level_ypos -= step;
14583 if (level_ypos < -1)
14586 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
14588 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14590 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
14591 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
14595 case GADGET_ID_SCROLL_DOWN:
14596 if (level_ypos <= lev_fieldy - ed_fieldy)
14598 if (lev_fieldy < ed_fieldy - 2)
14601 level_ypos += step;
14602 if (level_ypos > lev_fieldy - ed_fieldy + 1)
14603 level_ypos = lev_fieldy - ed_fieldy + 1;
14605 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
14607 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14609 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
14610 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
14614 case GADGET_ID_SCROLL_HORIZONTAL:
14615 level_xpos = gi->event.item_position - 1;
14617 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14622 case GADGET_ID_SCROLL_VERTICAL:
14623 level_ypos = gi->event.item_position - 1;
14625 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14630 case GADGET_ID_SCROLL_LIST_UP:
14631 case GADGET_ID_SCROLL_LIST_DOWN:
14632 case GADGET_ID_SCROLL_LIST_VERTICAL:
14633 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
14634 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
14637 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
14638 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
14640 if (element_shift < 0)
14642 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14643 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14645 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14646 GDI_SCROLLBAR_ITEM_POSITION,
14647 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14650 ModifyEditorElementList();
14654 case GADGET_ID_PROPERTIES:
14655 // always switch off element properties when they are already displayed
14656 last_properties_element = new_element;
14657 case GADGET_ID_ELEMENT_LEFT:
14658 case GADGET_ID_ELEMENT_MIDDLE:
14659 case GADGET_ID_ELEMENT_RIGHT:
14660 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
14661 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
14662 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
14665 if (edit_mode != ED_MODE_PROPERTIES)
14667 last_edit_mode = edit_mode;
14669 ChangeEditModeWindow(ED_MODE_PROPERTIES);
14671 last_level_drawing_function = drawing_function;
14672 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14675 else if (properties_element != last_properties_element)
14677 DrawEditModeWindow();
14681 ChangeEditModeWindow(ED_MODE_DRAWING);
14683 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
14688 case GADGET_ID_PALETTE:
14689 if (edit_mode != ED_MODE_PALETTE)
14691 last_edit_mode = edit_mode;
14693 ChangeEditModeWindow(ED_MODE_PALETTE);
14697 ChangeEditModeWindow(last_edit_mode);
14701 case GADGET_ID_WRAP_LEFT:
14702 WrapLevel(-step, 0);
14705 case GADGET_ID_WRAP_RIGHT:
14706 WrapLevel(step, 0);
14709 case GADGET_ID_WRAP_UP:
14710 WrapLevel(0, -step);
14713 case GADGET_ID_WRAP_DOWN:
14714 WrapLevel(0, step);
14717 case GADGET_ID_SINGLE_ITEMS:
14718 case GADGET_ID_CONNECTED_ITEMS:
14719 case GADGET_ID_LINE:
14720 case GADGET_ID_ARC:
14721 case GADGET_ID_TEXT:
14722 case GADGET_ID_RECTANGLE:
14723 case GADGET_ID_FILLED_BOX:
14724 case GADGET_ID_FLOOD_FILL:
14725 case GADGET_ID_GRAB_BRUSH:
14726 case GADGET_ID_PICK_ELEMENT:
14727 if (drawing_function != GADGET_ID_PICK_ELEMENT)
14728 last_drawing_function = drawing_function;
14729 drawing_function = id;
14730 draw_with_brush = FALSE;
14733 case GADGET_ID_RANDOM_PLACEMENT:
14734 RandomPlacement(new_element);
14737 case GADGET_ID_ZOOM:
14738 // zoom level editor tile size in or out (or reset to default size)
14739 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
14740 button == 2 ? ed_tilesize_default :
14741 button == 3 ? ed_tilesize / 2 : ed_tilesize);
14743 // when using touch device, cycle through all zoom tilesizes
14744 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
14745 ed_tilesize = MICRO_TILESIZE;
14747 // limit zoom level by upper and lower bound
14748 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
14750 InitZoomLevelSettings(ed_tilesize);
14752 if (edit_mode == ED_MODE_DRAWING)
14754 DrawDrawingWindow();
14756 // redraw zoom gadget info text
14757 PrintEditorGadgetInfoText(level_editor_gadget[id]);
14760 // save current editor zoom tilesize
14761 SaveSetup_AutoSetup();
14765 case GADGET_ID_CUSTOM_COPY_FROM:
14766 case GADGET_ID_CUSTOM_COPY_TO:
14767 case GADGET_ID_CUSTOM_EXCHANGE:
14768 last_custom_copy_mode = id;
14769 last_drawing_function = drawing_function;
14772 case GADGET_ID_CUSTOM_COPY:
14773 CopyCustomElement(properties_element, -1, id);
14776 case GADGET_ID_CUSTOM_PASTE:
14777 CopyCustomElement(-1, properties_element, id);
14780 case GADGET_ID_UNDO:
14781 if (button < 0) // keep button value (even if modifier keys are pressed)
14783 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
14786 if (button == 1 && undo_buffer_steps == 0)
14788 Request("Undo buffer empty!", REQ_CONFIRM);
14792 else if (button == 2)
14796 else if (button == 3 && redo_buffer_steps == 0)
14798 Request("Redo buffer empty!", REQ_CONFIRM);
14803 if (edit_mode != ED_MODE_DRAWING)
14804 ChangeEditModeWindow(ED_MODE_DRAWING);
14810 undo_buffer_position =
14811 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
14813 undo_buffer_steps--;
14814 redo_buffer_steps++;
14820 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
14822 undo_buffer_steps++;
14823 redo_buffer_steps--;
14826 for (x = 0; x < lev_fieldx; x++)
14827 for (y = 0; y < lev_fieldy; y++)
14828 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
14830 // check if undo operation forces change of border style
14831 CheckLevelBorderElement(FALSE);
14833 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14837 case GADGET_ID_CONF:
14838 if (edit_mode != ED_MODE_LEVELCONFIG)
14840 last_edit_mode = edit_mode;
14842 ChangeEditModeWindow(ED_MODE_LEVELCONFIG);
14846 ChangeEditModeWindow(ED_MODE_DRAWING);
14850 case GADGET_ID_CLEAR:
14851 if (edit_mode != ED_MODE_DRAWING)
14852 ChangeEditModeWindow(ED_MODE_DRAWING);
14854 for (x = 0; x < MAX_LEV_FIELDX; x++)
14855 for (y = 0; y < MAX_LEV_FIELDY; y++)
14856 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
14858 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
14860 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14863 case GADGET_ID_SAVE:
14865 // saving read-only levels into personal level set modifies global vars
14866 // "leveldir_current" and "level_nr"; restore them after saving level
14867 LevelDirTree *leveldir_former = leveldir_current;
14868 int level_nr_former = level_nr;
14869 char *level_filename;
14872 if (leveldir_current->readonly &&
14873 !PrepareSavingIntoPersonalLevelSet())
14876 level_filename = getDefaultLevelFilename(level_nr);
14877 new_level = !fileExists(level_filename);
14880 Request("Save this level and kill the old?", REQ_ASK))
14882 if (leveldir_former->readonly)
14883 ModifyLevelConfigForSavingIntoPersonalLevelSet(leveldir_former->name);
14885 SetAutomaticNumberOfGemsNeeded();
14887 CopyPlayfield(Tile, level.field);
14888 SaveLevel(level_nr);
14890 level.changed = FALSE;
14894 char level_saved_msg[64];
14896 if (leveldir_former->readonly)
14897 sprintf(level_saved_msg,
14898 "Level saved as level %d into personal level set!",
14901 strcpy(level_saved_msg, "Level saved!");
14903 Request(level_saved_msg, REQ_CONFIRM);
14907 // "cd" back to copied-from levelset (in case of saved read-only level)
14908 leveldir_current = leveldir_former;
14909 level_nr = level_nr_former;
14914 case GADGET_ID_TEST:
14915 if (LevelChanged())
14916 level.game_version = GAME_VERSION_ACTUAL;
14918 CopyPlayfield(level.field, TileBackup);
14919 CopyPlayfield(Tile, level.field);
14921 CopyNativeLevel_RND_to_Native(&level);
14923 UnmapLevelEditorGadgets();
14924 UndrawSpecialEditorDoor();
14926 CloseDoor(DOOR_CLOSE_ALL);
14928 // needed before playing if editor playfield area has different size
14929 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
14931 // redraw_mask = REDRAW_ALL;
14933 level_editor_test_game = TRUE;
14935 StartGameActions(FALSE, setup.autorecord, level.random_seed);
14939 case GADGET_ID_EXIT:
14940 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
14944 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
14945 id <= GADGET_ID_ELEMENTLIST_LAST)
14947 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
14949 new_element = editor_elements[element_position + element_shift];
14951 if (IS_EDITOR_CASCADE(new_element))
14955 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
14957 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
14958 boolean *cascade_value = editor_elements_info[i].setup_cascade_value;
14960 if (*cascade_element == new_element)
14962 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
14963 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
14965 // update element selection list
14966 ReinitializeElementList();
14967 ModifyEditorElementList();
14969 // update cascading gadget info text
14970 PrintEditorGadgetInfoText(level_editor_gadget[id]);
14972 // save current editor cascading state
14973 SaveSetup_EditorCascade();
14982 if (last_custom_copy_mode != -1)
14984 if (CopyCustomElement(properties_element, new_element,
14985 last_custom_copy_mode))
14987 ClickOnGadget(level_editor_gadget[last_drawing_function],
14990 last_custom_copy_mode = -1;
14996 // change element of button used to show palette
14997 if (editor.palette.show_on_element_buttons)
14998 button = last_button;
15000 PickDrawingElement(button, new_element);
15002 if (!stick_element_properties_window &&
15003 drawing_function != GADGET_ID_PICK_ELEMENT &&
15004 !(GetKeyModState() & KMOD_Control))
15006 properties_element = new_element;
15007 if (edit_mode == ED_MODE_PROPERTIES)
15008 DrawPropertiesWindow();
15011 if (drawing_function == GADGET_ID_PICK_ELEMENT)
15012 ClickOnGadget(level_editor_gadget[last_drawing_function],
15015 if (!use_permanent_palette)
15016 ChangeEditModeWindow(last_edit_mode);
15019 else if (gi->event.type == GD_EVENT_PRESSED)
15020 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
15021 else if (gi->event.type == GD_EVENT_RELEASED)
15022 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
15023 else if (gi->event.type == GD_EVENT_MOVING)
15024 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
15026 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
15032 void HandleLevelEditorKeyInput(Key key)
15034 char letter = getCharFromKey(key);
15036 if (drawing_function == GADGET_ID_TEXT &&
15037 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
15040 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
15041 else if (key == KSYM_Delete || key == KSYM_BackSpace)
15042 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
15043 else if (key == KSYM_Return)
15044 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
15045 else if (key == KSYM_Escape)
15046 DrawLevelText(0, 0, 0, TEXT_END);
15051 int id = GADGET_ID_NONE;
15052 int new_element_shift = element_shift;
15053 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
15054 int button = MB_LEFTBUTTON;
15060 id = GADGET_ID_SCROLL_LEFT;
15063 id = GADGET_ID_SCROLL_RIGHT;
15066 id = GADGET_ID_SCROLL_UP;
15069 id = GADGET_ID_SCROLL_DOWN;
15073 case KSYM_Page_Down:
15074 step *= (key == KSYM_Page_Up ? -1 : +1);
15075 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15077 if (element_shift < 0)
15079 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15080 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15082 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15083 GDI_SCROLLBAR_ITEM_POSITION,
15084 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15086 ModifyEditorElementList();
15092 element_shift = (key == KSYM_Home ? 0 :
15093 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
15095 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15096 GDI_SCROLLBAR_ITEM_POSITION,
15097 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15099 ModifyEditorElementList();
15106 // this is needed to prevent interference with running "True X-Mouse"
15107 if (GetKeyModStateFromEvents() & KMOD_Control)
15110 // check for last or next editor cascade block in element list
15111 for (i = 0; i < num_editor_elements; i++)
15113 if ((key == KSYM_Insert && i == element_shift) ||
15114 (key == KSYM_Delete && new_element_shift > element_shift))
15117 // jump to next cascade block (or to start of element list)
15118 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
15119 new_element_shift = i;
15122 if (i < num_editor_elements)
15123 element_shift = new_element_shift;
15125 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15126 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15128 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15129 GDI_SCROLLBAR_ITEM_POSITION,
15130 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15132 ModifyEditorElementList();
15137 if (edit_mode == ED_MODE_DRAWING)
15138 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
15139 else if (edit_mode == ED_MODE_LEVELCONFIG)
15140 HandleControlButtons(level_editor_gadget[GADGET_ID_CONF]);
15141 else if (edit_mode == ED_MODE_PROPERTIES)
15142 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
15143 else if (edit_mode == ED_MODE_PALETTE)
15144 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
15145 else // should never happen
15146 ChangeEditModeWindow(ED_MODE_DRAWING);
15154 if (id != GADGET_ID_NONE)
15155 ClickOnGadget(level_editor_gadget[id], button);
15156 else if (letter == '1' || letter == '?')
15157 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
15158 else if (letter == '2')
15159 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
15160 else if (letter == '3')
15161 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
15162 else if (letter == '.')
15163 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
15164 else if (letter == 'U')
15165 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
15166 else if (letter == '-' || key == KSYM_KP_Subtract)
15167 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
15168 else if (letter == '0' || key == KSYM_KP_0)
15169 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
15170 else if (letter == '+' || key == KSYM_KP_Add ||
15171 letter == '=') // ("Shift-=" is "+" on US keyboards)
15172 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
15173 else if (key == KSYM_Return ||
15174 key == KSYM_space ||
15175 key == setup.shortcut.toggle_pause)
15176 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
15178 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
15179 if (letter && letter == controlbutton_info[i].shortcut)
15180 if (!anyTextGadgetActive())
15181 ClickOnGadget(level_editor_gadget[i], button);
15183 if (draw_with_brush)
15187 else if (letter == 'y')
15189 else if (letter == 'z')
15194 static void HandleLevelEditorIdle_Properties(void)
15196 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
15197 int x = editor.settings.element_graphic.x + element_border;
15198 int y = editor.settings.element_graphic.y + element_border;
15199 static DelayCounter action_delay = { 0 };
15202 action_delay.value = GameFrameDelay;
15204 if (!DelayReached(&action_delay))
15207 for (i = 0; i < ED_NUM_SELECTBOX; i++)
15209 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
15211 if (gi->mapped && gi->active && gi->selectbox.open)
15215 DrawEditorElementAnimation(SX + x, SY + y);
15217 redraw_mask |= REDRAW_FIELD;
15219 FrameCounter++; // increase animation frame counter
15222 static void HandleLevelEditorIdle_Drawing(void)
15224 static boolean last_highlighted = FALSE;
15225 static boolean last_highlighted_similar = FALSE;
15226 boolean highlighted = (GetKeyModState() & KMOD_Alt);
15227 boolean highlighted_similar = (GetKeyModState() & KMOD_Shift);
15229 if (highlighted != last_highlighted ||
15230 (highlighted && highlighted_similar != last_highlighted_similar))
15232 DrawAreaElementHighlight(highlighted, highlighted_similar);
15234 redraw_mask |= REDRAW_FIELD;
15237 last_highlighted = highlighted;
15238 last_highlighted_similar = highlighted_similar;
15241 void HandleLevelEditorIdle(void)
15243 if (edit_mode == ED_MODE_PROPERTIES)
15244 HandleLevelEditorIdle_Properties();
15245 else if (edit_mode == ED_MODE_DRAWING)
15246 HandleLevelEditorIdle_Drawing();
15249 static void ClearEditorGadgetInfoText(void)
15251 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
15254 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
15256 char infotext[MAX_OUTPUT_LINESIZE + 1];
15257 int max_infotext_len = getMaxInfoTextLength();
15259 if (gi == NULL || strlen(gi->info_text) == 0)
15262 strncpy(infotext, gi->info_text, max_infotext_len);
15263 infotext[max_infotext_len] = '\0';
15265 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
15267 int key = controlbutton_info[gi->custom_id].shortcut;
15271 char shortcut[MAX_OUTPUT_LINESIZE + 1];
15273 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
15274 sprintf(shortcut, " ('.' or '%c')", key);
15275 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
15276 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
15277 else if (gi->custom_id == GADGET_ID_TEST)
15278 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
15279 else if (gi->custom_id == GADGET_ID_UNDO)
15280 sprintf(shortcut, " ('%c/Shift-U')", key);
15281 else if (gi->custom_id == GADGET_ID_ZOOM)
15282 sprintf(shortcut, " ('%c', '0', '-')", key);
15284 sprintf(shortcut, " ('%s%c')",
15285 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
15287 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
15288 strcat(infotext, shortcut);
15292 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
15295 void HandleEditorGadgetInfoText(void *ptr)
15297 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
15299 if (game_status != GAME_MODE_EDITOR)
15302 ClearEditorGadgetInfoText();
15304 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
15307 // misuse this function to delete brush cursor, if needed
15308 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
15309 DeleteBrushFromCursor();
15311 PrintEditorGadgetInfoText(gi);
15314 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
15316 int id = gi->custom_id;
15317 int type_id = gi->custom_type_id;
15318 int sx = gi->event.x;
15319 int sy = gi->event.y;
15320 int lx = sx + level_xpos;
15321 int ly = sy + level_ypos;
15322 int min_sx = 0, min_sy = 0;
15323 int max_sx = gi->drawing.area_xsize - 1;
15324 int max_sy = gi->drawing.area_ysize - 1;
15325 int actual_drawing_function = drawing_function;
15326 int max_infotext_len = getMaxInfoTextLength();
15327 char infotext[MAX_OUTPUT_LINESIZE + 1];
15329 infotext[0] = '\0'; // start with empty info text
15331 // pressed Control key: simulate picking element
15332 if (GetKeyModState() & KMOD_Control)
15333 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
15335 ClearEditorGadgetInfoText();
15337 if (gi->event.type == GD_EVENT_INFO_LEAVING)
15340 // make sure to stay inside drawing area boundaries
15341 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
15342 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
15344 if (id == GADGET_ID_DRAWING_LEVEL)
15348 int min_lx = 0, min_ly = 0;
15349 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
15351 // get positions inside level field
15352 lx = sx + level_xpos;
15353 ly = sy + level_ypos;
15355 // make sure to stay inside level field boundaries
15356 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
15357 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
15359 // correct drawing area positions accordingly
15360 sx = lx - level_xpos;
15361 sy = ly - level_ypos;
15364 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15366 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
15368 static int start_lx = 0;
15369 static int start_ly = 0;
15372 if (gi->event.type == GD_EVENT_PRESSED)
15378 switch (actual_drawing_function)
15380 case GADGET_ID_SINGLE_ITEMS:
15381 text = "Drawing single items";
15383 case GADGET_ID_CONNECTED_ITEMS:
15384 text = "Drawing connected items";
15386 case GADGET_ID_LINE:
15387 text = "Drawing line";
15389 case GADGET_ID_ARC:
15390 text = "Drawing arc";
15392 case GADGET_ID_TEXT:
15393 text = "Setting text cursor";
15395 case GADGET_ID_RECTANGLE:
15396 text = "Drawing rectangle";
15398 case GADGET_ID_FILLED_BOX:
15399 text = "Drawing filled box";
15401 case GADGET_ID_FLOOD_FILL:
15402 text = "Flood fill";
15404 case GADGET_ID_GRAB_BRUSH:
15405 text = "Grabbing brush";
15407 case GADGET_ID_PICK_ELEMENT:
15408 text = "Picking element";
15412 text = "Drawing position";
15416 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15417 sprintf(infotext, "%s: %d, %d", text, lx, ly);
15419 sprintf(infotext, "%s: %d, %d", text,
15420 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
15422 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15423 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
15425 sprintf(infotext, "Level position: %d, %d", lx, ly);
15428 // misuse this function to draw brush cursor, if needed
15429 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
15431 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15432 CopyBrushToCursor(sx, sy);
15434 DeleteBrushFromCursor();
15437 if (!draw_with_brush)
15438 UpdateBrushPosition(sx, sy);
15440 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15442 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
15443 int element = drawingarea_info[type_id].value[pos];
15445 strncpy(infotext, getElementInfoText(element), max_infotext_len);
15449 if (id == GADGET_ID_CUSTOM_CONTENT)
15450 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
15451 else if (id == GADGET_ID_GROUP_CONTENT)
15452 sprintf(infotext, "group element position: %d", sx + 1);
15453 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
15454 id <= GADGET_ID_YAMYAM_CONTENT_7)
15455 sprintf(infotext, "content area %d position: %d, %d",
15456 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
15457 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
15458 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
15459 sprintf(infotext, "content area %d position: %d, %d",
15460 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
15461 else if (id == GADGET_ID_ANDROID_CONTENT)
15462 sprintf(infotext, "android element position: %d", sx + 1);
15463 else if (drawingarea_info[type_id].infotext != NULL)
15464 strcpy(infotext, drawingarea_info[type_id].infotext);
15467 infotext[max_infotext_len] = '\0';
15469 if (strlen(infotext) > 0)
15470 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
15473 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
15474 boolean quick_quit)
15476 if (!ask_if_level_has_changed ||
15478 Request("Level has changed! Exit without saving?",
15479 REQ_ASK | REQ_STAY_OPEN))
15481 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
15482 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
15484 // draw normal door
15485 UndrawSpecialEditorDoor();
15487 // use door animation if door 1 viewport is unchanged and contains toolbox
15488 if (useEditorDoorAnimation())
15489 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
15491 // close editor doors if viewport definition is the same as in main menu
15492 if (vp_door_1->x == DX &&
15493 vp_door_1->y == DY &&
15494 vp_door_1->width == DXSIZE &&
15495 vp_door_1->height == DYSIZE &&
15496 vp_door_2->x == VX &&
15497 vp_door_2->y == VY &&
15498 vp_door_2->width == VXSIZE &&
15499 vp_door_2->height == VYSIZE)
15500 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
15502 SetDoorState(DOOR_CLOSE_ALL);
15507 FadeSkipNextFadeIn();
15509 SetGameStatus(GAME_MODE_MAIN);
15515 if (!global.use_envelope_request)
15517 CloseDoor(DOOR_CLOSE_1);
15518 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);