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_BD, "Boulder Dash" },
1798 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1799 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1800 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1805 static struct ValueTextInfo options_levelset_save_mode[] =
1807 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1808 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1813 static struct ValueTextInfo options_wind_direction[] =
1815 { MV_START_NONE, "none" },
1816 { MV_START_LEFT, "left" },
1817 { MV_START_RIGHT, "right" },
1818 { MV_START_UP, "up" },
1819 { MV_START_DOWN, "down" },
1824 static struct ValueTextInfo options_player_speed[] =
1831 { 16, "very fast" },
1832 { 32, "ultrafast" },
1837 static struct ValueTextInfo options_access_type[] =
1839 { EP_WALKABLE, "walkable" },
1840 { EP_PASSABLE, "passable" },
1845 static struct ValueTextInfo options_access_layer[] =
1847 { EP_ACCESSIBLE_OVER, "over" },
1848 { EP_ACCESSIBLE_INSIDE, "inside" },
1849 { EP_ACCESSIBLE_UNDER, "under" },
1854 static struct ValueTextInfo options_access_protected[] =
1856 { 0, "unprotected" },
1862 static struct ValueTextInfo options_access_direction[] =
1864 { MV_NO_DIRECTION, "no direction" },
1865 { MV_LEFT, "left" },
1866 { MV_RIGHT, "right" },
1868 { MV_DOWN, "down" },
1869 { MV_LEFT | MV_UP, "left + up" },
1870 { MV_LEFT | MV_DOWN, "left + down" },
1871 { MV_RIGHT | MV_UP, "right + up" },
1872 { MV_RIGHT | MV_DOWN, "right + down" },
1873 { MV_HORIZONTAL, "horizontal" },
1874 { MV_VERTICAL, "vertical" },
1875 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1876 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1877 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1878 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1879 { MV_ALL_DIRECTIONS, "all directions" },
1884 static struct ValueTextInfo options_walk_to_action[] =
1886 { EP_DIGGABLE, "diggable" },
1887 { EP_COLLECTIBLE_ONLY, "collectible" },
1888 { EP_DROPPABLE, "collectible & droppable" },
1889 { EP_THROWABLE, "collectible & throwable" },
1890 { EP_PUSHABLE, "pushable" },
1895 static struct ValueTextInfo options_move_pattern[] =
1897 { MV_LEFT, "left" },
1898 { MV_RIGHT, "right" },
1900 { MV_DOWN, "down" },
1901 { MV_HORIZONTAL, "horizontal" },
1902 { MV_VERTICAL, "vertical" },
1903 { MV_ALL_DIRECTIONS, "all directions" },
1904 { MV_WIND_DIRECTION, "wind direction" },
1905 { MV_TOWARDS_PLAYER, "towards player" },
1906 { MV_AWAY_FROM_PLAYER, "away from player" },
1907 { MV_ALONG_LEFT_SIDE, "along left side" },
1908 { MV_ALONG_RIGHT_SIDE, "along right side" },
1909 { MV_TURNING_LEFT, "turning left" },
1910 { MV_TURNING_RIGHT, "turning right" },
1911 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1912 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1913 { MV_TURNING_RANDOM, "turning random" },
1914 { MV_MAZE_RUNNER, "maze runner style" },
1915 { MV_MAZE_HUNTER, "maze hunter style" },
1916 { MV_WHEN_PUSHED, "when pushed" },
1917 { MV_WHEN_DROPPED, "when dropped/thrown" },
1922 static struct ValueTextInfo options_move_direction[] =
1924 { MV_START_AUTOMATIC, "automatic" },
1925 { MV_START_LEFT, "left" },
1926 { MV_START_RIGHT, "right" },
1927 { MV_START_UP, "up" },
1928 { MV_START_DOWN, "down" },
1929 { MV_START_RANDOM, "random" },
1930 { MV_START_PREVIOUS, "previous" },
1935 static struct ValueTextInfo options_move_stepsize[] =
1937 { 0, "not moving" },
1942 { 16, "very fast" },
1943 { 32, "even faster" },
1948 static struct ValueTextInfo options_move_leave_type[] =
1950 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1951 { LEAVE_TYPE_LIMITED, "change it to" },
1956 static struct ValueTextInfo options_smash_targets[] =
1958 { EP_CAN_SMASH_PLAYER, "player" },
1960 { EP_CAN_SMASH_ENEMIES, "enemies" },
1962 { EP_CAN_SMASH_EVERYTHING, "everything" },
1967 static struct ValueTextInfo options_slippery_type[] =
1969 { SLIPPERY_ANY_RANDOM, "random" },
1970 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1971 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1972 { SLIPPERY_ONLY_LEFT, "only left" },
1973 { SLIPPERY_ONLY_RIGHT, "only right" },
1978 static struct ValueTextInfo options_deadliness[] =
1980 { EP_DONT_RUN_INTO, "running into" },
1981 { EP_DONT_COLLIDE_WITH, "colliding with" },
1982 { EP_DONT_GET_HIT_BY, "getting hit by" },
1983 { EP_DONT_TOUCH, "touching" },
1988 static struct ValueTextInfo options_explosion_type[] =
1990 { EXPLODES_3X3, "3x3" },
1991 { EXPLODES_CROSS, "3+3" },
1992 { EXPLODES_1X1, "1x1" },
1997 static struct ValueTextInfo options_time_units[] =
2000 { FRAMES_PER_SECOND, "seconds" },
2005 static struct ValueTextInfo options_change_direct_action[] =
2007 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2008 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2009 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2010 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2011 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2012 { CE_ENTERED_BY_PLAYER, "entered by player" },
2013 { CE_LEFT_BY_PLAYER, "left by player" },
2014 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2015 { CE_SWITCHED, "switched" },
2016 { CE_HITTING_SOMETHING, "hitting something" },
2017 { CE_HIT_BY_SOMETHING, "hit by something" },
2019 { CE_BLOCKED, "blocked" },
2021 { CE_IMPACT, "impact (on something)" },
2022 { CE_SMASHED, "smashed (from above)" },
2024 { CE_VALUE_CHANGES, "CE value changes" },
2025 { CE_SCORE_CHANGES, "CE score changes" },
2027 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2028 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2029 { CE_UNDEFINED, " " },
2030 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2031 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2032 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2033 { CE_UNDEFINED, " " },
2034 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2035 { CE_NEXT_TO_PLAYER, "next to player" },
2040 static struct ValueTextInfo options_change_other_action[] =
2042 { CE_PLAYER_TOUCHES_X, "player touches" },
2043 { CE_PLAYER_PRESSES_X, "player presses" },
2044 { CE_PLAYER_SWITCHES_X, "player switches" },
2045 { CE_PLAYER_SNAPS_X, "player snaps" },
2046 { CE_PLAYER_PUSHES_X, "player pushes" },
2047 { CE_PLAYER_ENTERS_X, "player enters" },
2048 { CE_PLAYER_LEAVES_X, "player leaves" },
2049 { CE_PLAYER_DIGS_X, "player digs" },
2050 { CE_PLAYER_COLLECTS_X, "player collects" },
2051 { CE_PLAYER_DROPS_X, "player drops/throws" },
2052 { CE_TOUCHING_X, "touching" },
2053 { CE_HITTING_X, "hitting" },
2054 { CE_DIGGING_X, "digging" },
2055 { CE_HIT_BY_X, "hit by" },
2056 { CE_SWITCH_OF_X, "switch of" },
2057 { CE_CHANGE_OF_X, "change by page of" },
2058 { CE_EXPLOSION_OF_X, "explosion of" },
2059 { CE_MOVE_OF_X, "move of" },
2060 { CE_CREATION_OF_X, "creation of" },
2061 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2062 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2063 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2064 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2065 { CE_UNDEFINED, " " },
2066 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2067 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2068 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2069 { CE_UNDEFINED, " " },
2070 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2071 { CE_PLAYER_NEXT_TO_X, "player next to" },
2072 { CE_NEXT_TO_X, "next to" },
2077 static struct ValueTextInfo options_change_trigger_side[] =
2079 { CH_SIDE_LEFT, "left" },
2080 { CH_SIDE_RIGHT, "right" },
2081 { CH_SIDE_TOP, "top" },
2082 { CH_SIDE_BOTTOM, "bottom" },
2083 { CH_SIDE_LEFT_RIGHT, "left/right" },
2084 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2085 { CH_SIDE_ANY, "any" },
2090 static struct ValueTextInfo options_change_trigger_player[] =
2092 { CH_PLAYER_1, "1" },
2093 { CH_PLAYER_2, "2" },
2094 { CH_PLAYER_3, "3" },
2095 { CH_PLAYER_4, "4" },
2096 { CH_PLAYER_ANY, "any" },
2101 static struct ValueTextInfo options_change_trigger_page[] =
2112 { (1u << 9), "10" },
2113 { (1u << 10), "11" },
2114 { (1u << 11), "12" },
2115 { (1u << 12), "13" },
2116 { (1u << 13), "14" },
2117 { (1u << 14), "15" },
2118 { (1u << 15), "16" },
2119 { (1u << 16), "17" },
2120 { (1u << 17), "18" },
2121 { (1u << 18), "19" },
2122 { (1u << 19), "20" },
2123 { (1u << 20), "21" },
2124 { (1u << 21), "22" },
2125 { (1u << 22), "23" },
2126 { (1u << 23), "24" },
2127 { (1u << 24), "25" },
2128 { (1u << 25), "26" },
2129 { (1u << 26), "27" },
2130 { (1u << 27), "28" },
2131 { (1u << 28), "29" },
2132 { (1u << 29), "30" },
2133 { (1u << 30), "31" },
2134 { (1u << 31), "32" },
2135 { CH_PAGE_ANY, "any" },
2140 static struct ValueTextInfo options_change_replace_when[] =
2142 { CP_WHEN_EMPTY, "empty" },
2143 { CP_WHEN_WALKABLE, "walkable" },
2144 { CP_WHEN_DIGGABLE, "diggable" },
2145 { CP_WHEN_COLLECTIBLE, "collectible" },
2146 { CP_WHEN_REMOVABLE, "removable" },
2147 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2152 static struct ValueTextInfo options_action_type[] =
2154 { CA_NO_ACTION, "no action" },
2155 { CA_UNDEFINED, " " },
2156 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2157 { CA_RESTART_LEVEL, "restart level" },
2158 { CA_SHOW_ENVELOPE, "show envelope" },
2159 { CA_SET_LEVEL_TIME, "set time" },
2160 { CA_SET_LEVEL_SCORE, "set score" },
2161 { CA_SET_LEVEL_GEMS, "set gems" },
2162 { CA_SET_LEVEL_WIND, "set wind dir." },
2163 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2164 { CA_UNDEFINED, " " },
2165 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2166 { CA_MOVE_PLAYER, "move player" },
2167 { CA_MOVE_PLAYER_NEW, "move player new" },
2168 { CA_EXIT_PLAYER, "exit player" },
2169 { CA_KILL_PLAYER, "kill player" },
2170 { CA_SET_PLAYER_KEYS, "set keys" },
2171 { CA_SET_PLAYER_SPEED, "set speed" },
2172 { CA_SET_PLAYER_SHIELD, "set shield" },
2173 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2174 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2175 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2176 { CA_UNDEFINED, " " },
2177 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2178 { CA_SET_CE_VALUE, "set CE value" },
2179 { CA_SET_CE_SCORE, "set CE score" },
2180 { CA_SET_CE_ARTWORK, "set CE artwork" },
2181 { CA_UNDEFINED, " " },
2182 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2183 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2188 static struct ValueTextInfo options_action_mode_none[] =
2190 { CA_MODE_UNDEFINED, " " },
2195 static struct ValueTextInfo options_action_mode_assign[] =
2197 { CA_MODE_SET, "=" },
2202 static struct ValueTextInfo options_action_mode_add_remove[] =
2204 { CA_MODE_ADD, "+" },
2205 { CA_MODE_SUBTRACT, "-" },
2210 static struct ValueTextInfo options_action_mode_calculate[] =
2212 { CA_MODE_SET, "=" },
2213 { CA_MODE_ADD, "+" },
2214 { CA_MODE_SUBTRACT, "-" },
2215 { CA_MODE_MULTIPLY, "*" },
2216 { CA_MODE_DIVIDE, "/" },
2217 { CA_MODE_MODULO, "%" },
2222 static struct ValueTextInfo options_action_arg_none[] =
2224 { CA_ARG_UNDEFINED, " " },
2229 static struct ValueTextInfo options_action_arg_player[] =
2231 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2232 { CA_ARG_PLAYER_1, "1" },
2233 { CA_ARG_PLAYER_2, "2" },
2234 { CA_ARG_PLAYER_3, "3" },
2235 { CA_ARG_PLAYER_4, "4" },
2236 { CA_ARG_PLAYER_ANY, "any" },
2237 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2238 { CA_ARG_PLAYER_ACTION, "action ->" },
2243 static struct ValueTextInfo options_action_arg_number[] =
2245 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2252 { CA_ARG_10, "10" },
2253 { CA_ARG_100, "100" },
2254 { CA_ARG_1000, "1000" },
2255 { CA_ARG_UNDEFINED, " " },
2256 { CA_ARG_NUMBER_MIN, "min" },
2257 { CA_ARG_NUMBER_MAX, "max" },
2258 { CA_ARG_UNDEFINED, " " },
2259 { CA_ARG_NUMBER_RESET, "reset" },
2260 { CA_ARG_UNDEFINED, " " },
2261 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2262 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2263 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2264 { CA_ARG_UNDEFINED, " " },
2265 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2266 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2267 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2268 { CA_ARG_UNDEFINED, " " },
2269 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2270 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2271 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2272 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2273 { CA_ARG_UNDEFINED, " " },
2274 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2275 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2276 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2277 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2282 static struct ValueTextInfo options_action_arg_value[] =
2284 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2291 { CA_ARG_10, "10" },
2292 { CA_ARG_100, "100" },
2293 { CA_ARG_1000, "1000" },
2294 { CA_ARG_UNDEFINED, " " },
2295 { CA_ARG_NUMBER_MIN, "min" },
2296 { CA_ARG_NUMBER_MAX, "max" },
2297 { CA_ARG_UNDEFINED, " " },
2298 { CA_ARG_NUMBER_RESET, "reset" },
2299 { CA_ARG_UNDEFINED, " " },
2300 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2301 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2302 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2303 { CA_ARG_UNDEFINED, " " },
2304 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2305 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2306 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2307 { CA_ARG_UNDEFINED, " " },
2308 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2309 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2310 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2311 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2312 { CA_ARG_UNDEFINED, " " },
2313 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2314 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2315 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2316 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2317 { CA_ARG_UNDEFINED, " " },
2318 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2319 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2320 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2321 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2326 static struct ValueTextInfo options_action_arg_envelope[] =
2328 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2333 { CA_ARG_UNDEFINED, " " },
2334 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2335 { CA_ARG_ELEMENT_TARGET, "target" },
2336 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2337 { CA_ARG_ELEMENT_ACTION, "action ->" },
2342 static struct ValueTextInfo options_action_arg_key[] =
2344 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2353 { CA_ARG_UNDEFINED, " " },
2354 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2355 { CA_ARG_ELEMENT_TARGET, "target" },
2356 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2357 { CA_ARG_ELEMENT_ACTION, "action ->" },
2362 static struct ValueTextInfo options_action_arg_speed[] =
2364 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2365 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2366 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2367 { CA_ARG_SPEED_SLOW, "slow" },
2368 { CA_ARG_SPEED_NORMAL, "normal" },
2369 { CA_ARG_SPEED_FAST, "fast" },
2370 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2371 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2372 { CA_ARG_UNDEFINED, " " },
2373 { CA_ARG_SPEED_SLOWER, "slower" },
2374 { CA_ARG_SPEED_FASTER, "faster" },
2375 { CA_ARG_UNDEFINED, " " },
2376 { CA_ARG_SPEED_RESET, "reset" },
2381 static struct ValueTextInfo options_action_arg_shield[] =
2383 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2384 { CA_ARG_SHIELD_OFF, "off" },
2385 { CA_ARG_SHIELD_NORMAL, "normal" },
2386 { CA_ARG_SHIELD_DEADLY, "deadly" },
2391 static struct ValueTextInfo options_action_arg_artwork[] =
2393 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2394 { CA_ARG_ELEMENT_TARGET, "target" },
2395 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2396 { CA_ARG_ELEMENT_ACTION, "action ->" },
2397 { CA_ARG_UNDEFINED, " " },
2398 { CA_ARG_ELEMENT_RESET, "reset" },
2403 static struct ValueTextInfo options_action_arg_gravity[] =
2405 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2406 { CA_ARG_GRAVITY_ON, "on" },
2407 { CA_ARG_GRAVITY_OFF, "off" },
2408 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2413 static struct ValueTextInfo options_action_arg_direction[] =
2415 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2416 { CA_ARG_DIRECTION_NONE, "none" },
2417 { CA_ARG_DIRECTION_LEFT, "left" },
2418 { CA_ARG_DIRECTION_RIGHT, "right" },
2419 { CA_ARG_DIRECTION_UP, "up" },
2420 { CA_ARG_DIRECTION_DOWN, "down" },
2421 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2422 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2427 static struct ValueTextInfo options_action_arg_scan_mode[] =
2429 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2430 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2431 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2436 static struct ValueTextInfo options_action_arg_inventory[] =
2438 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2439 { CA_ARG_ELEMENT_TARGET, "+ target" },
2440 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2441 { CA_ARG_ELEMENT_ACTION, "+ action" },
2442 { CA_ARG_UNDEFINED, " " },
2443 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2444 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2445 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2446 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2447 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2448 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2449 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2450 { CA_ARG_UNDEFINED, " " },
2451 { CA_ARG_INVENTORY_RESET, "reset" },
2456 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2457 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2462 static struct ValueTextInfo options_group_choice_mode[] =
2464 { ANIM_RANDOM, "random" },
2465 { ANIM_LOOP, "loop" },
2466 { ANIM_LINEAR, "linear" },
2467 { ANIM_PINGPONG, "pingpong" },
2468 { ANIM_PINGPONG2, "pingpong 2" },
2469 { ANIM_LEVEL_NR, "level number" },
2474 static struct ValueTextInfo *action_arg_modes[] =
2476 options_action_mode_none,
2477 options_action_mode_assign,
2478 options_action_mode_add_remove,
2479 options_action_mode_calculate,
2486 struct ValueTextInfo *options;
2488 action_arg_options[] =
2490 { CA_NO_ACTION, 0, options_action_arg_none, },
2491 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2492 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2493 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2494 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2495 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2496 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2497 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2498 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2499 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2500 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2501 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2502 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2503 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2504 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2505 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2506 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2507 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2508 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2509 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2510 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2511 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2520 int gadget_id_align;
2521 int size; // char size of selectbox or '-1' (dynamically determined)
2522 struct ValueTextInfo *options;
2524 char *text_above, *text_left, *text_right, *infotext;
2525 } selectbox_info[ED_NUM_SELECTBOX] =
2527 // ---------- level and editor settings -------------------------------------
2530 -1, ED_LEVEL_SETTINGS_YPOS(8),
2531 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2533 options_time_or_steps,
2534 &level.use_step_counter,
2535 NULL, NULL, "(0 => no limit)", "time or step limit"
2538 -1, ED_LEVEL_SETTINGS_YPOS(10),
2539 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2541 options_time_score_base,
2542 &level.time_score_base,
2543 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2546 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2547 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2549 options_game_engine_type,
2550 &level.game_engine_type,
2551 NULL, "game engine:", NULL, "game engine"
2554 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2555 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2557 options_levelset_save_mode,
2558 &levelset_save_mode,
2559 "Action:", NULL, NULL, "action when saving level set"
2562 // ---------- element settings: configure (several elements) ----------------
2565 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2566 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2568 options_wind_direction,
2569 &level.wind_direction_initial,
2570 NULL, "initial wind direction:", NULL, "initial wind direction"
2573 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2574 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2576 options_player_speed,
2577 &level.initial_player_stepsize[0],
2578 NULL, "initial player speed:", NULL, "initial player speed"
2581 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2582 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2584 options_group_choice_mode,
2585 &level.mm_ball_choice_mode,
2586 NULL, "choice type:", NULL, "type of content choice"
2589 // ---------- element settings: configure 1 (custom elements) ---------------
2592 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2593 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2595 options_access_type,
2596 &custom_element.access_type,
2597 NULL, NULL, NULL, "type of access to this field"
2600 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2601 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2603 options_access_layer,
2604 &custom_element.access_layer,
2605 NULL, NULL, NULL, "layer of access for this field"
2608 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2609 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2611 options_access_protected,
2612 &custom_element.access_protected,
2613 NULL, NULL, NULL, "protected access for this field"
2616 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2617 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2619 options_access_direction,
2620 &custom_element.access_direction,
2621 NULL, "from", NULL, "access direction for this field"
2624 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2625 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2627 options_walk_to_action,
2628 &custom_element.walk_to_action,
2629 NULL, NULL, NULL, "diggable/collectible/pushable"
2632 // ---------- element settings: configure 2 (custom elements) ---------------
2635 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2636 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2638 options_move_pattern,
2639 &custom_element.move_pattern,
2640 NULL, "can move", NULL, "element move pattern"
2643 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2644 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2646 options_move_direction,
2647 &custom_element.move_direction_initial,
2648 NULL, "starts moving", NULL, "initial element move direction"
2651 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2652 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2654 options_move_stepsize,
2655 &custom_element.move_stepsize,
2656 NULL, "move/fall speed", NULL, "speed of element movement"
2659 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2660 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2662 options_move_leave_type,
2663 &custom_element.move_leave_type,
2664 // left text with leading spaces to place gadget next to "can dig" gadget
2665 // (needed because drawing area gadgets created after selectbox gadgets)
2666 // NULL, "can dig: can", ":", "leave behind or change element"
2667 NULL, " can", ":", "leave behind or change element"
2670 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2671 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2673 options_smash_targets,
2674 &custom_element.smash_targets,
2675 NULL, "can smash", NULL, "elements that can be smashed"
2678 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2679 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2681 options_slippery_type,
2682 &custom_element.slippery_type,
2683 NULL, "slippery", NULL, "where other elements fall down"
2686 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2687 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2690 &custom_element.deadliness,
2691 NULL, "deadly when", NULL, "deadliness of element"
2694 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2695 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2697 options_explosion_type,
2698 &custom_element.explosion_type,
2699 NULL, "can explode", NULL, "explosion type"
2702 // ---------- element settings: advanced (custom elements) ------------------
2705 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2706 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2709 &custom_element_change.delay_frames,
2710 NULL, "delay time given in", NULL, "delay time units for change"
2713 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2714 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2716 options_change_direct_action,
2717 &custom_element_change.direct_action,
2718 NULL, NULL, NULL, "type of direct action"
2721 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2722 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2724 options_change_other_action,
2725 &custom_element_change.other_action,
2726 NULL, NULL, "element:", "type of other element action"
2729 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2730 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2732 options_change_trigger_side,
2733 &custom_element_change.trigger_side,
2734 NULL, "at", "side", "element side triggering change"
2737 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2738 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2740 options_change_trigger_player,
2741 &custom_element_change.trigger_player,
2742 NULL, "player:", " ", "player that causes change"
2745 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2746 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2748 options_change_trigger_page,
2749 &custom_element_change.trigger_page,
2750 NULL, "page:", NULL, "change page that causes change"
2753 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2754 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2756 options_change_replace_when,
2757 &custom_element_change.replace_when,
2758 NULL, "replace when", NULL, "which elements can be replaced"
2761 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2762 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2764 options_action_type,
2765 &custom_element_change.action_type,
2766 NULL, NULL, NULL, "action on specified condition"
2769 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2770 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2772 options_action_mode_none,
2773 &custom_element_change.action_mode,
2774 NULL, NULL, NULL, "action operator"
2777 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2778 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2780 options_action_arg_none,
2781 &custom_element_change.action_arg,
2782 NULL, NULL, NULL, "action parameter"
2785 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2786 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2788 options_change_page,
2789 &custom_element.current_change_page,
2790 NULL, NULL, NULL, "element change page"
2793 // ---------- element settings: configure (group elements) ------------------
2796 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2797 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2799 options_group_choice_mode,
2800 &group_element_info.choice_mode,
2801 NULL, "choice type:", NULL, "type of group element choice"
2809 int gadget_id_align;
2812 char *text_above, *text_left, *text_right, *infotext;
2813 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2815 // ---------- level and editor settings (tabs) ------------------------------
2818 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2819 GADGET_ID_LEVELCONFIG_LEVEL, GADGET_ID_NONE,
2821 NULL, NULL, NULL, "Configure level settings"
2825 GADGET_ID_LEVELCONFIG_LEVELSET, GADGET_ID_LEVELCONFIG_LEVEL,
2827 NULL, NULL, NULL, "Update this or create new level set"
2831 GADGET_ID_LEVELCONFIG_EDITOR, GADGET_ID_LEVELCONFIG_LEVELSET,
2833 NULL, NULL, NULL, "Configure editor settings"
2836 // ---------- element settings (tabs) ---------------------------------------
2839 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2840 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2842 NULL, NULL, NULL, "Show information about element"
2846 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2848 NULL, NULL, NULL, "Configure element properties"
2852 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2854 NULL, NULL, NULL, "Configure element properties, part 1"
2858 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2860 NULL, NULL, NULL, "Configure element properties, part 2"
2864 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2866 NULL, NULL, NULL, "Configure custom element change pages"
2869 // ---------- level and editor settings (buttons) ---------------------------
2872 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2873 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
2875 NULL, NULL, NULL, "Update or create level set"
2878 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2879 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2881 NULL, NULL, "this level as level template",
2882 "Save current settings as new template"
2885 // ---------- element settings (buttons) ------------------------------------
2889 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2891 NULL, " ", "As Template",
2892 "Save current settings as new template"
2896 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2898 NULL, NULL, NULL, "Add new change page"
2902 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2904 NULL, NULL, NULL, "Delete current change page"
2913 int gadget_id_align;
2914 char *text_left, *text_right, *infotext;
2915 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2918 IMG_EDITOR_COUNTER_DOWN,
2919 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2920 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2921 NULL, NULL, "select previous change page"
2924 IMG_EDITOR_COUNTER_UP,
2925 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2926 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2927 NULL, "change page", "select next change page"
2930 IMG_GFX_EDITOR_BUTTON_CP_COPY,
2931 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2932 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2933 " ", NULL, "copy settings from this change page"
2936 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
2937 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2938 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2939 NULL, NULL, "paste settings to this change page"
2946 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2953 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2956 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2957 GADGET_ID_SCROLL_UP,
2958 "scroll level editing area up"
2961 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2962 GADGET_ID_SCROLL_DOWN,
2963 "scroll level editing area down"
2966 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2967 GADGET_ID_SCROLL_LEFT,
2968 "scroll level editing area left"
2971 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2972 GADGET_ID_SCROLL_RIGHT,
2973 "scroll level editing area right"
2976 IMG_EDITOR_PALETTE_SCROLL_UP,
2977 GADGET_ID_SCROLL_LIST_UP,
2978 "scroll element list up ('Page Up')"
2981 IMG_EDITOR_PALETTE_SCROLL_DOWN,
2982 GADGET_ID_SCROLL_LIST_DOWN,
2983 "scroll element list down ('Page Down')"
2991 int wheel_x, wheel_y;
2992 int wheel_width, wheel_height;
2993 } scrollbar_pos[ED_NUM_SCROLLBARS];
3001 } scrollbar_info[ED_NUM_SCROLLBARS] =
3004 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3005 GD_TYPE_SCROLLBAR_HORIZONTAL,
3006 GADGET_ID_SCROLL_HORIZONTAL,
3007 "scroll level editing area horizontally"
3010 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3011 GD_TYPE_SCROLLBAR_VERTICAL,
3012 GADGET_ID_SCROLL_VERTICAL,
3013 "scroll level editing area vertically"
3016 IMG_EDITOR_PALETTE_SCROLLBAR,
3017 GD_TYPE_SCROLLBAR_VERTICAL,
3018 GADGET_ID_SCROLL_LIST_VERTICAL,
3019 "scroll element list vertically"
3028 int gadget_id_align;
3029 int radio_button_nr;
3032 char *text_left, *text_right, *infotext;
3033 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3036 -1, ED_LEVEL_SETTINGS_YPOS(0),
3037 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3038 RADIO_NR_RANDOM_ELEMENTS,
3039 &random_placement_method, RANDOM_USE_PERCENTAGE,
3040 " ", "percentage", "use percentage for random elements"
3043 -1, ED_LEVEL_SETTINGS_YPOS(0),
3044 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3045 RADIO_NR_RANDOM_ELEMENTS,
3046 &random_placement_method, RANDOM_USE_QUANTITY,
3047 " ", "quantity", "use quantity for random elements"
3055 int gadget_id_align;
3057 char *text_above, *text_left, *text_right, *infotext;
3058 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3060 // ---------- level and editor settings -------------------------------------
3063 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3064 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3065 &level.auto_count_gems,
3067 "automatically count gems needed", "set counter to number of gems"
3070 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3071 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3072 &level.rate_time_over_score,
3074 "rate time/steps used over score", "sort high scores by playing time/steps"
3077 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3078 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3079 &levelset_use_levelset_artwork,
3081 "use current custom artwork", "use custom artwork of this level set"
3084 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3085 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3086 &levelset_copy_level_template,
3088 "copy current level template", "copy level template of this level set"
3091 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3092 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3093 &random_placement_background_restricted,
3095 "restrict random placement to:", "set random placement restriction"
3098 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3099 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3100 &setup.editor.use_template_for_new_levels,
3101 "Template for new levels and CE/GE:", NULL,
3102 "use template for new levels", "use template for level properties"
3105 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3106 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3107 &level.use_custom_template,
3109 "use template for custom elements", "use template for custom properties"
3112 // ---------- element settings: configure (various elements) ----------------
3115 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3116 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3117 &stick_element_properties_window,
3119 "stick this screen to edit content","stick this screen to edit content"
3122 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3123 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3124 &level.em_slippery_gems,
3126 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3129 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3130 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3131 &level.em_explodes_by_fire,
3133 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3136 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3137 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3138 &level.use_spring_bug,
3140 "use spring pushing bug", "use odd spring pushing behaviour"
3143 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3144 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3145 &level.use_time_orb_bug,
3147 "use time orb bug", "use odd time orb behaviour"
3150 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3151 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3152 &level.use_life_bugs,
3154 "use buggy element behaviour", "use odd (historic) element behaviour"
3157 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3158 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3161 "create single random element", "only create one element from content"
3164 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3165 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3166 &level.ball_active_initial,
3168 "magic ball initially activated", "activate magic ball after level start"
3171 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3172 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3173 &level.grow_into_diggable,
3175 "can grow into anything diggable", "grow into more than just sand"
3178 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3179 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3180 &level.sb_fields_needed,
3182 "all fields need to be filled", "require all SB fields to be solved"
3185 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3186 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3187 &level.sb_objects_needed,
3189 "all objects need to be placed", "require all SB objects to be solved"
3192 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3193 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3194 &level.auto_exit_sokoban,
3196 "exit level if all tasks solved", "automatically finish Sokoban levels"
3199 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3200 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3201 &level.solved_by_one_player,
3203 "only one player must enter exit", "level solved by first player in exit"
3206 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3207 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3208 &level.finish_dig_collect,
3210 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3213 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3214 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3215 &level.keep_walkable_ce,
3217 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3220 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3221 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3222 &level.continuous_snapping,
3224 "continuous snapping", "use snapping without releasing key"
3227 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3228 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3229 &level.block_snap_field,
3231 "block snapped field when snapping", "use snapping delay to show animation"
3234 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3235 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3236 &level.block_last_field,
3238 "block last field when moving", "player blocks last field when moving"
3241 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3242 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3243 &level.sp_block_last_field,
3245 "block last field when moving", "player blocks last field when moving"
3248 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3249 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3250 &level.instant_relocation,
3252 "no scrolling when relocating", "player gets relocated without delay"
3255 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3256 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3257 &level.shifted_relocation,
3259 "no centering when relocating", "level not centered after relocation"
3262 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3263 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3264 &level.lazy_relocation,
3266 "only redraw off-screen relocation","no redraw if relocation target visible"
3269 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3270 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3271 &level.use_start_element[0],
3273 "use level start element:", "start level at this element's position"
3276 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3277 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3278 &level.use_artwork_element[0],
3280 "use artwork from element:", "use player artwork from other element"
3283 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3284 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3285 &level.use_explosion_element[0],
3287 "use explosion from element:", "use explosion properties from element"
3290 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3291 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3292 &level.initial_player_gravity[0],
3294 "use initial gravity", "set initial player gravity"
3297 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3298 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3299 &level.use_initial_inventory[0],
3301 "use initial inventory:", "use collected elements on level start"
3304 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3305 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3306 &level.can_pass_to_walkable,
3308 "can pass to walkable element", "player can pass to empty or walkable"
3311 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3312 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3313 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3315 "can fall into acid (with gravity)","player can fall into acid pool"
3318 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3319 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3320 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3322 "can move into acid", "element can move into acid pool"
3325 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3326 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3327 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3329 "deadly when colliding with", "element is deadly when hitting player"
3332 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3333 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3334 &level.envelope[0].autowrap,
3336 "auto-wrap", "automatically wrap envelope text"
3339 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3340 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3341 &level.envelope[0].centered,
3343 "centered", "automatically center envelope text"
3346 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3347 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3348 &level.mm_laser_red,
3349 "choose color components for laser:", NULL,
3350 "red", "use red color components in laser"
3353 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3354 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3355 &level.mm_laser_green,
3357 "green", "use green color components in laser"
3360 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3361 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3362 &level.mm_laser_blue,
3364 "blue", "use blue color components in laser"
3367 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3368 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3369 &level.df_laser_red,
3370 "choose color components for laser:", NULL,
3371 "red", "use red color components in laser"
3374 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3375 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3376 &level.df_laser_green,
3378 "green", "use green color components in laser"
3381 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3382 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3383 &level.df_laser_blue,
3385 "blue", "use blue color components in laser"
3388 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3389 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3390 &level.rotate_mm_ball_content,
3392 "randomly rotate created content", "randomly rotate newly created content"
3395 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3396 GADGET_ID_EXPLODE_MM_BALL, GADGET_ID_NONE,
3397 &level.explode_mm_ball,
3399 "explode ball instead of melting", "use explosion to release ball content"
3402 // ---------- element settings: configure 1 (custom elements) ---------------
3405 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3406 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3407 &custom_element.use_gfx_element,
3409 "use graphic of element:", "use existing element graphic"
3412 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3413 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3414 &level.use_custom_template,
3416 "use template", "use template for custom properties"
3419 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3420 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3421 &custom_element_properties[EP_ACCESSIBLE],
3423 NULL, "player can walk to or pass this field"
3426 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3427 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3428 &custom_element_properties[EP_GRAVITY_REACHABLE],
3430 "reachable despite gravity", "player can walk/dig despite gravity"
3433 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3434 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3435 &custom_element.use_last_ce_value,
3437 "use last CE value after change", "use last CE value after change"
3440 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3441 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3442 &custom_element_properties[EP_WALK_TO_OBJECT],
3444 NULL, "player can dig/collect/push element"
3447 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3448 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3449 &custom_element_properties[EP_INDESTRUCTIBLE],
3451 "indestructible", "element is indestructible"
3454 // ---------- element settings: configure 2 (custom elements) ---------------
3457 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3458 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3459 &custom_element_properties[EP_CAN_MOVE],
3461 NULL, "element can move with some pattern"
3464 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3465 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3466 &custom_element_properties[EP_CAN_FALL],
3468 "can fall", "element can fall down"
3471 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3472 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3473 &custom_element_properties[EP_CAN_SMASH],
3475 NULL, "element can smash other elements"
3478 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3479 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3480 &custom_element_properties[EP_SLIPPERY],
3482 NULL, "other elements can fall down from it"
3485 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3486 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3487 &custom_element_properties[EP_DEADLY],
3489 NULL, "element can kill the player"
3492 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3493 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3494 &custom_element_properties[EP_CAN_EXPLODE],
3496 NULL, "element can explode"
3499 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3500 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3501 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3503 "by fire", "element can explode by fire/explosion"
3506 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3507 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3508 &custom_element_properties[EP_EXPLODES_SMASHED],
3510 "smashed", "element can explode when smashed"
3513 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3514 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3515 &custom_element_properties[EP_EXPLODES_IMPACT],
3517 "impact", "element can explode on impact"
3520 // ---------- element settings: advanced (custom elements) ------------------
3523 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3524 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3525 &custom_element_change.can_change,
3527 "element changes to:", "change element on specified condition"
3530 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3531 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3532 &custom_element_change_events[CE_DELAY],
3534 NULL, "element changes after delay"
3537 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3538 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3539 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3541 NULL, "element changes by direct action"
3544 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3545 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3546 &custom_element_change_events[CE_BY_OTHER_ACTION],
3548 NULL, "element changes by other element"
3551 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3552 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3553 &custom_element_change.explode,
3555 "explode instead of change", "element explodes instead of change"
3558 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3559 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3560 &custom_element_change.use_target_content,
3562 "use extended change target:", "element changes to more elements"
3565 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3566 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3567 &custom_element_change.only_if_complete,
3569 "replace all or nothing", "only replace when all can be changed"
3572 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3573 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3574 &custom_element_change.use_random_replace,
3576 NULL, "use percentage for random replace"
3579 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3580 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3581 &custom_element_change.has_action,
3583 NULL, "execute action on specified condition"
3590 int xoffset, yoffset;
3592 int gadget_id_align;
3594 int area_xsize, area_ysize;
3595 char *text_left, *text_right, *text_above, *text_below, *infotext;
3596 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3598 // ---------- level playfield content ---------------------------------------
3603 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3605 -1, -1, // these values are not constant, but can change at runtime
3606 NULL, NULL, NULL, NULL, NULL
3609 // ---------- yam yam content -----------------------------------------------
3612 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3613 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3614 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3615 &level.yamyam_content[0].e[0][0], 3, 3,
3616 NULL, NULL, NULL, "1", NULL
3619 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3620 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3621 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3622 &level.yamyam_content[1].e[0][0], 3, 3,
3623 NULL, NULL, NULL, "2", NULL
3626 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3627 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3628 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3629 &level.yamyam_content[2].e[0][0], 3, 3,
3630 NULL, NULL, NULL, "3", NULL
3633 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3634 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3635 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3636 &level.yamyam_content[3].e[0][0], 3, 3,
3637 NULL, NULL, NULL, "4", NULL
3640 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3641 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3642 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3643 &level.yamyam_content[4].e[0][0], 3, 3,
3644 NULL, NULL, NULL, "5", NULL
3647 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3648 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3649 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3650 &level.yamyam_content[5].e[0][0], 3, 3,
3651 NULL, NULL, NULL, "6", NULL
3654 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3655 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3656 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3657 &level.yamyam_content[6].e[0][0], 3, 3,
3658 NULL, NULL, NULL, "7", NULL
3661 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3662 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3663 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3664 &level.yamyam_content[7].e[0][0], 3, 3,
3665 NULL, NULL, NULL, "8", NULL
3668 // ---------- magic ball content --------------------------------------------
3671 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3672 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3673 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3674 &level.ball_content[0].e[0][0], 3, 3,
3675 NULL, NULL, NULL, "1", NULL
3678 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3679 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3680 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3681 &level.ball_content[1].e[0][0], 3, 3,
3682 NULL, NULL, NULL, "2", NULL
3685 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3686 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3687 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3688 &level.ball_content[2].e[0][0], 3, 3,
3689 NULL, NULL, NULL, "3", NULL
3692 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3693 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3694 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3695 &level.ball_content[3].e[0][0], 3, 3,
3696 NULL, NULL, NULL, "4", NULL
3699 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3700 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3701 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3702 &level.ball_content[4].e[0][0], 3, 3,
3703 NULL, NULL, NULL, "5", NULL
3706 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3707 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3708 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3709 &level.ball_content[5].e[0][0], 3, 3,
3710 NULL, NULL, NULL, "6", NULL
3713 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3714 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3715 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3716 &level.ball_content[6].e[0][0], 3, 3,
3717 NULL, NULL, NULL, "7", NULL
3720 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3721 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3722 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3723 &level.ball_content[7].e[0][0], 3, 3,
3724 NULL, NULL, NULL, "8", NULL
3727 // ---------- android content -----------------------------------------------
3730 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
3731 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3732 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3733 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3734 NULL, NULL, "elements:", NULL, "elements android can clone"
3737 // ---------- amoeba content ------------------------------------------------
3740 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3741 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3742 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3743 &level.amoeba_content, 1, 1,
3744 "content:", NULL, NULL, NULL, "amoeba content"
3747 // ---------- level start element -------------------------------------------
3750 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3751 0, ED_AREA_1X1_SETTINGS_YOFF,
3752 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3753 &level.start_element[0], 1, 1,
3754 NULL, NULL, NULL, NULL, "level start element"
3757 // ---------- player artwork element ----------------------------------------
3760 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3761 0, ED_AREA_1X1_SETTINGS_YOFF,
3762 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3763 &level.artwork_element[0], 1, 1,
3764 NULL, NULL, NULL, NULL, "element for player artwork"
3767 // ---------- player explosion element --------------------------------------
3770 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
3771 0, ED_AREA_1X1_SETTINGS_YOFF,
3772 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3773 &level.explosion_element[0], 1, 1,
3774 NULL, NULL, NULL, NULL, "element for player explosion"
3777 // ---------- player initial inventory --------------------------------------
3780 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3781 0, ED_AREA_1X1_SETTINGS_YOFF,
3782 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3783 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3784 NULL, NULL, NULL, NULL, "content for initial inventory"
3787 // ---------- gray ball content -----------------------------------------
3790 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3791 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3792 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
3793 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
3794 "content:", NULL, NULL, NULL, "content for gray ball"
3797 // ---------- element settings: configure 1 (custom elements) ---------------
3799 // ---------- custom graphic ------------------------------------------------
3802 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3803 0, ED_AREA_1X1_SETTINGS_YOFF,
3804 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3805 &custom_element.gfx_element_initial, 1, 1,
3806 NULL, NULL, NULL, NULL, "custom graphic element"
3809 // ---------- element settings: configure 2 (custom elements) ---------------
3811 // ---------- custom content (when exploding) -------------------------------
3814 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
3815 0, ED_AREA_3X3_SETTINGS_YOFF,
3816 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
3817 &custom_element.content.e[0][0], 3, 3,
3818 "content:", NULL, NULL, NULL, NULL
3821 // ---------- custom enter and leave element (when moving) ------------------
3824 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3825 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3826 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3827 &custom_element.move_enter_element, 1, 1,
3828 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
3831 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3832 0, ED_AREA_1X1_SETTINGS_YOFF,
3833 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3834 &custom_element.move_leave_element, 1, 1,
3835 NULL, NULL, NULL, NULL, "element that will be left behind"
3838 // ---------- element settings: advanced (custom elements) ------------------
3840 // ---------- custom change target ------------------------------------------
3843 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3844 0, ED_AREA_1X1_SETTINGS_YOFF,
3845 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3846 &custom_element_change.target_element, 1, 1,
3847 NULL, "after/when:", NULL, NULL, "new target element after change"
3850 // ---------- custom change content (extended change target) ----------------
3853 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3854 0, ED_AREA_3X3_SETTINGS_YOFF,
3855 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
3856 &custom_element_change.target_content.e[0][0], 3, 3,
3857 NULL, NULL, NULL, NULL, "new extended elements after change"
3860 // ---------- custom change trigger (element causing change) ----------------
3863 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3864 0, ED_AREA_1X1_SETTINGS_YOFF,
3865 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3866 &custom_element_change.initial_trigger_element, 1, 1,
3867 NULL, NULL, NULL, NULL, "other element triggering change"
3870 // ---------- custom change action (element used for action) ----------------
3873 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3874 0, ED_AREA_1X1_SETTINGS_YOFF,
3875 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3876 &custom_element_change.action_element, 1, 1,
3877 NULL, NULL, NULL, NULL, "element used as action parameter"
3880 // ---------- group element content -----------------------------------------
3883 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3884 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3885 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3886 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3887 "content:", NULL, NULL, NULL, NULL
3890 // ---------- random background (for random painting) -----------------------
3893 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
3894 0, ED_AREA_1X1_LSETTINGS_YOFF,
3895 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3896 &random_placement_background_element, 1, 1,
3897 NULL, NULL, NULL, NULL, "random placement background"
3902 // ----------------------------------------------------------------------------
3903 // some internally used variables
3904 // ----------------------------------------------------------------------------
3906 // maximal size of level editor drawing area
3907 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3909 // actual size of level editor drawing area
3910 static int ed_fieldx, ed_fieldy;
3912 // actual position of level editor drawing area in level playfield
3913 static int level_xpos = -1, level_ypos = -1;
3915 // actual tile size used to display playfield drawing area
3916 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3917 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
3919 #define IN_ED_FIELD(x, y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3921 // drawing elements on the three mouse buttons
3922 static int new_element1 = EL_WALL;
3923 static int new_element2 = EL_EMPTY;
3924 static int new_element3 = EL_SAND;
3926 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3927 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3928 (button) == 2 ? new_element2 : \
3929 (button) == 3 ? new_element3 : EL_EMPTY)
3931 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
3933 static int use_permanent_palette = TRUE;
3935 #define PX (use_permanent_palette ? DX : SX)
3936 #define PY (use_permanent_palette ? DY : SY)
3937 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
3938 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
3940 // forward declaration for internal use
3941 static void CopyBrushToCursor(int, int);
3942 static void DeleteBrushFromCursor(void);
3943 static void ModifyEditorCounterValue(int, int);
3944 static void ModifyEditorCounterLimits(int, int, int);
3945 static void ModifyEditorSelectboxValue(int, int);
3946 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3947 static void ModifyEditorDrawingArea(int, int, int);
3948 static void ModifyEditorElementList(void);
3949 static void AdjustElementListScrollbar(void);
3950 static void RedrawDrawingElements(void);
3951 static void DrawDrawingWindowExt(boolean);
3952 static void DrawDrawingWindow(void);
3953 static void DrawLevelConfigWindow(void);
3954 static void DrawPropertiesWindow(void);
3955 static void DrawPaletteWindow(void);
3956 static void UpdateCustomElementGraphicGadgets(void);
3957 static boolean checkPropertiesConfig(int);
3958 static void SetAutomaticNumberOfGemsNeeded(void);
3959 static void ClearEditorGadgetInfoText(void);
3960 static void CopyLevelToUndoBuffer(int);
3961 static void HandleDrawingAreas(struct GadgetInfo *);
3962 static void HandleCounterButtons(struct GadgetInfo *);
3963 static void HandleTextInputGadgets(struct GadgetInfo *);
3964 static void HandleTextAreaGadgets(struct GadgetInfo *);
3965 static void HandleSelectboxGadgets(struct GadgetInfo *);
3966 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3967 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3968 static void HandleRadiobuttons(struct GadgetInfo *);
3969 static void HandleCheckbuttons(struct GadgetInfo *);
3970 static void HandleControlButtons(struct GadgetInfo *);
3971 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3972 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3973 static boolean AskToCopyAndModifyLevelTemplate(void);
3974 static boolean getDrawModeHiRes(void);
3975 static int getTabulatorBarWidth(void);
3976 static int getTabulatorBarHeight(void);
3977 static Pixel getTabulatorBarColor(void);
3978 static int numHiresTiles(int);
3980 static int num_editor_gadgets = 0; // dynamically determined
3982 static struct GadgetInfo **level_editor_gadget = NULL;
3983 static int *right_gadget_border = NULL;
3985 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3986 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3987 static boolean draw_with_brush = FALSE;
3988 static int properties_element = 0;
3990 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3991 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3992 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3993 static int undo_buffer_position = 0;
3994 static int undo_buffer_steps = 0;
3995 static int redo_buffer_steps = 0;
3997 static int edit_mode;
3998 static int edit_mode_levelconfig;
3999 static int edit_mode_properties;
4001 static int element_shift = 0;
4003 static int editor_el_players[] =
4010 static int *editor_el_players_ptr = editor_el_players;
4011 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4013 static int editor_hl_boulderdash[] =
4015 EL_INTERNAL_CASCADE_BD_ACTIVE,
4021 static int editor_el_boulderdash[] =
4030 EL_BD_EXPANDABLE_WALL,
4038 EL_BD_BUTTERFLY_LEFT,
4040 EL_BD_BUTTERFLY_RIGHT,
4041 EL_BD_FIREFLY_RIGHT,
4044 EL_BD_BUTTERFLY_DOWN,
4048 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4049 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4050 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4051 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4053 static int editor_hl_boulderdash_native[] =
4055 EL_INTERNAL_CASCADE_BD_NATIVE_ACTIVE,
4061 static int editor_el_boulderdash_native[] =
4078 EL_BD_BUTTERFLY_LEFT,
4080 EL_BD_BUTTERFLY_RIGHT,
4081 EL_BD_FIREFLY_RIGHT,
4084 EL_BD_BUTTERFLY_DOWN,
4089 EL_BD_BUTTERFLY_2_UP,
4093 EL_BD_BUTTERFLY_2_LEFT,
4094 EL_BD_FIREFLY_2_LEFT,
4095 EL_BD_BUTTERFLY_2_RIGHT,
4096 EL_BD_FIREFLY_2_RIGHT,
4099 EL_BD_BUTTERFLY_2_DOWN,
4100 EL_BD_FIREFLY_2_DOWN,
4108 EL_BD_DRAGONFLY_LEFT,
4109 EL_BD_STONEFLY_LEFT,
4110 EL_BD_DRAGONFLY_RIGHT,
4111 EL_BD_STONEFLY_RIGHT,
4114 EL_BD_DRAGONFLY_DOWN,
4115 EL_BD_STONEFLY_DOWN,
4138 EL_BD_SAND_SLOPED_UP_LEFT,
4139 EL_BD_SAND_SLOPED_UP_RIGHT,
4140 EL_BD_WALL_SLOPED_UP_LEFT,
4141 EL_BD_WALL_SLOPED_UP_RIGHT,
4143 EL_BD_SAND_SLOPED_DOWN_LEFT,
4144 EL_BD_SAND_SLOPED_DOWN_RIGHT,
4145 EL_BD_WALL_SLOPED_DOWN_LEFT,
4146 EL_BD_WALL_SLOPED_DOWN_RIGHT,
4148 EL_BD_FLYING_DIAMOND,
4150 EL_BD_STEELWALL_SLOPED_UP_LEFT,
4151 EL_BD_STEELWALL_SLOPED_UP_RIGHT,
4155 EL_BD_STEELWALL_SLOPED_DOWN_LEFT,
4156 EL_BD_STEELWALL_SLOPED_DOWN_RIGHT,
4159 EL_BD_WALL_NON_SLOPED,
4165 EL_BD_INVISIBLE_EXIT_CLOSED,
4166 EL_BD_INVISIBLE_EXIT_OPEN,
4169 EL_BD_STEELWALL_EXPLODABLE,
4170 EL_BD_STEELWALL_DIGGABLE,
4171 EL_BD_WALL_DIGGABLE,
4173 EL_BD_EXPANDABLE_WALL_HORIZONTAL,
4174 EL_BD_EXPANDABLE_WALL_VERTICAL,
4175 EL_BD_EXPANDABLE_WALL_ANY,
4176 EL_BD_CREATURE_SWITCH,
4178 EL_BD_EXPANDABLE_STEELWALL_HORIZONTAL,
4179 EL_BD_EXPANDABLE_STEELWALL_VERTICAL,
4180 EL_BD_EXPANDABLE_STEELWALL_ANY,
4181 EL_BD_EXPANDABLE_WALL_SWITCH_HORIZONTAL,
4183 EL_BD_BITER_SWITCH_1,
4184 EL_BD_REPLICATOR_SWITCH,
4185 EL_BD_CONVEYOR_SWITCH,
4186 EL_BD_CONVEYOR_DIR_SWITCH_RIGHT,
4195 EL_BD_DIAMOND_GLUED,
4198 EL_BD_TRAPPED_DIAMOND,
4218 EL_BD_GRAVITY_SWITCH,
4219 EL_BD_PNEUMATIC_HAMMER,
4226 EL_BD_BLADDER_SPENDER,
4228 EL_BD_CONVEYOR_LEFT,
4229 EL_BD_CONVEYOR_RIGHT,
4244 EL_BD_PLAYER_WITH_BOMB,
4246 EL_BD_PLAYER_STIRRING,
4248 static int *editor_hl_boulderdash_native_ptr = editor_hl_boulderdash_native;
4249 static int *editor_el_boulderdash_native_ptr = editor_el_boulderdash_native;
4250 static int num_editor_hl_boulderdash_native = ARRAY_SIZE(editor_hl_boulderdash_native);
4251 static int num_editor_el_boulderdash_native = ARRAY_SIZE(editor_el_boulderdash_native);
4253 static int editor_hl_emerald_mine[] =
4255 EL_INTERNAL_CASCADE_EM_ACTIVE,
4261 static int editor_el_emerald_mine[] =
4279 EL_EM_DYNAMITE_ACTIVE,
4298 EL_ACID_POOL_TOPLEFT,
4300 EL_ACID_POOL_TOPRIGHT,
4303 EL_ACID_POOL_BOTTOMLEFT,
4304 EL_ACID_POOL_BOTTOM,
4305 EL_ACID_POOL_BOTTOMRIGHT,
4323 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4324 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4325 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4326 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4328 static int editor_hl_emerald_mine_club[] =
4330 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4336 static int editor_el_emerald_mine_club[] =
4363 EL_EMC_WALL_SLIPPERY_1,
4364 EL_EMC_WALL_SLIPPERY_2,
4365 EL_EMC_WALL_SLIPPERY_3,
4366 EL_EMC_WALL_SLIPPERY_4,
4389 EL_EMC_MAGIC_BALL_SWITCH,
4396 EL_EMC_SPRING_BUMPER,
4400 EL_BALLOON_SWITCH_UP,
4401 EL_BALLOON_SWITCH_ANY,
4404 EL_BALLOON_SWITCH_LEFT,
4406 EL_BALLOON_SWITCH_RIGHT,
4410 EL_BALLOON_SWITCH_DOWN,
4411 EL_BALLOON_SWITCH_NONE,
4413 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4414 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4415 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4416 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4418 static int editor_hl_rnd[] =
4420 EL_INTERNAL_CASCADE_RND_ACTIVE,
4426 static int editor_el_rnd[] =
4429 EL_DYNAMITE_ACTIVE, // RND
4463 EL_WALL_EMERALD_YELLOW,
4464 EL_WALL_EMERALD_RED,
4465 EL_WALL_EMERALD_PURPLE,
4483 EL_DYNABOMB_INCREASE_NUMBER,
4484 EL_DYNABOMB_INCREASE_SIZE,
4485 EL_DYNABOMB_INCREASE_POWER,
4505 EL_INVISIBLE_STEELWALL,
4509 EL_EXPANDABLE_WALL_HORIZONTAL,
4510 EL_EXPANDABLE_WALL_VERTICAL,
4511 EL_EXPANDABLE_WALL_ANY,
4513 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4514 static int *editor_el_rnd_ptr = editor_el_rnd;
4515 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4516 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4518 static int editor_hl_sokoban[] =
4520 EL_INTERNAL_CASCADE_SB_ACTIVE,
4526 static int editor_el_sokoban[] =
4529 EL_SOKOBAN_FIELD_EMPTY,
4530 EL_SOKOBAN_FIELD_FULL,
4531 EL_SOKOBAN_FIELD_PLAYER,
4533 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4534 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4535 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4536 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4538 static int editor_hl_supaplex[] =
4540 EL_INTERNAL_CASCADE_SP_ACTIVE,
4546 static int editor_el_supaplex[] =
4564 EL_SP_PORT_HORIZONTAL,
4565 EL_SP_PORT_VERTICAL,
4573 EL_SP_GRAVITY_PORT_LEFT,
4574 EL_SP_GRAVITY_PORT_RIGHT,
4575 EL_SP_GRAVITY_PORT_UP,
4576 EL_SP_GRAVITY_PORT_DOWN,
4578 EL_SP_GRAVITY_ON_PORT_LEFT,
4579 EL_SP_GRAVITY_ON_PORT_RIGHT,
4580 EL_SP_GRAVITY_ON_PORT_UP,
4581 EL_SP_GRAVITY_ON_PORT_DOWN,
4583 EL_SP_GRAVITY_OFF_PORT_LEFT,
4584 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4585 EL_SP_GRAVITY_OFF_PORT_UP,
4586 EL_SP_GRAVITY_OFF_PORT_DOWN,
4588 EL_SP_HARDWARE_GRAY,
4589 EL_SP_HARDWARE_GREEN,
4590 EL_SP_HARDWARE_BLUE,
4593 EL_SP_HARDWARE_BASE_1,
4594 EL_SP_HARDWARE_BASE_2,
4595 EL_SP_HARDWARE_BASE_3,
4596 EL_SP_HARDWARE_BASE_4,
4598 EL_SP_HARDWARE_BASE_5,
4599 EL_SP_HARDWARE_BASE_6,
4600 EL_SP_HARDWARE_YELLOW,
4608 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4609 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4610 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4611 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4613 static int editor_hl_diamond_caves[] =
4615 EL_INTERNAL_CASCADE_DC_ACTIVE,
4621 static int editor_el_diamond_caves[] =
4623 EL_EM_STEEL_EXIT_CLOSED, // DC2
4624 EL_EM_STEEL_EXIT_OPEN, // DC2
4625 EL_WALL_EMERALD, // DC2
4626 EL_WALL_DIAMOND, // DC2
4633 EL_CONVEYOR_BELT_1_LEFT,
4634 EL_CONVEYOR_BELT_1_MIDDLE,
4635 EL_CONVEYOR_BELT_1_RIGHT,
4636 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4638 EL_CONVEYOR_BELT_2_LEFT,
4639 EL_CONVEYOR_BELT_2_MIDDLE,
4640 EL_CONVEYOR_BELT_2_RIGHT,
4641 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4643 EL_CONVEYOR_BELT_3_LEFT,
4644 EL_CONVEYOR_BELT_3_MIDDLE,
4645 EL_CONVEYOR_BELT_3_RIGHT,
4646 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4648 EL_CONVEYOR_BELT_4_LEFT,
4649 EL_CONVEYOR_BELT_4_MIDDLE,
4650 EL_CONVEYOR_BELT_4_RIGHT,
4651 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4653 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4654 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4655 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4656 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4658 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4659 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4660 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4661 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4666 EL_DC_TIMEGATE_SWITCH,
4668 EL_SWITCHGATE_CLOSED,
4670 EL_SWITCHGATE_SWITCH_UP,
4671 EL_SWITCHGATE_SWITCH_DOWN,
4674 EL_LIGHT_SWITCH_ACTIVE,
4675 EL_DC_SWITCHGATE_SWITCH_UP,
4676 EL_DC_SWITCHGATE_SWITCH_DOWN,
4678 EL_STEEL_EXIT_CLOSED,
4680 EL_STEELWALL_SLIPPERY,
4683 EL_QUICKSAND_FAST_EMPTY,
4684 EL_QUICKSAND_FAST_FULL,
4698 EL_SIGN_RADIOACTIVITY,
4704 EL_SIGN_ENTRY_FORBIDDEN,
4705 EL_SIGN_EMERGENCY_EXIT,
4730 EL_DC_STEELWALL_2_SINGLE,
4731 EL_DC_STEELWALL_2_TOP,
4732 EL_SIGN_EXCLAMATION,
4735 EL_DC_STEELWALL_2_LEFT,
4736 EL_DC_STEELWALL_2_MIDDLE,
4737 EL_DC_STEELWALL_2_HORIZONTAL,
4738 EL_DC_STEELWALL_2_RIGHT,
4740 EL_DC_STEELWALL_1_TOPLEFT,
4741 EL_DC_STEELWALL_2_VERTICAL,
4742 EL_DC_STEELWALL_1_TOPRIGHT,
4745 EL_DC_STEELWALL_1_VERTICAL,
4746 EL_DC_STEELWALL_2_BOTTOM,
4748 EL_DC_GATE_WHITE_GRAY,
4750 EL_DC_STEELWALL_1_BOTTOMLEFT,
4751 EL_DC_STEELWALL_1_HORIZONTAL,
4752 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4753 EL_DC_GATE_FAKE_GRAY,
4755 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4756 EL_DC_STEELWALL_1_BOTTOM,
4757 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
4758 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
4760 EL_DC_STEELWALL_1_RIGHT,
4762 EL_DC_STEELWALL_1_LEFT,
4763 EL_EXPANDABLE_STEELWALL_VERTICAL,
4765 EL_DC_STEELWALL_1_TOPRIGHT_2,
4766 EL_DC_STEELWALL_1_TOP,
4767 EL_DC_STEELWALL_1_TOPLEFT_2,
4768 EL_EXPANDABLE_STEELWALL_ANY,
4770 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
4771 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
4772 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
4773 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
4775 static int editor_hl_dx_boulderdash[] =
4777 EL_INTERNAL_CASCADE_DX_ACTIVE,
4783 static int editor_el_dx_boulderdash[] =
4787 EL_TUBE_HORIZONTAL_DOWN,
4791 EL_TUBE_VERTICAL_RIGHT,
4793 EL_TUBE_VERTICAL_LEFT,
4797 EL_TUBE_HORIZONTAL_UP,
4805 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
4806 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
4807 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
4808 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
4810 static int editor_hl_mirror_magic[] =
4812 EL_INTERNAL_CASCADE_MM_ACTIVE,
4818 static int editor_el_mirror_magic[] =
4820 EL_MM_MCDUFFIN_RIGHT,
4822 EL_MM_MCDUFFIN_LEFT,
4823 EL_MM_MCDUFFIN_DOWN,
4826 EL_MM_MIRROR_FIXED_START,
4827 EL_MM_POLARIZER_START,
4828 EL_MM_POLARIZER_CROSS_START,
4830 EL_MM_TELEPORTER_RED_START,
4831 EL_MM_TELEPORTER_YELLOW_START,
4832 EL_MM_TELEPORTER_GREEN_START,
4833 EL_MM_TELEPORTER_BLUE_START,
4846 EL_MM_LIGHTBULB_ACTIVE,
4860 EL_MM_STEEL_GRID_FIXED_1,
4861 EL_MM_STEEL_GRID_FIXED_2,
4862 EL_MM_STEEL_GRID_FIXED_3,
4863 EL_MM_STEEL_GRID_FIXED_4,
4865 EL_MM_WOODEN_GRID_FIXED_1,
4866 EL_MM_WOODEN_GRID_FIXED_2,
4867 EL_MM_WOODEN_GRID_FIXED_3,
4868 EL_MM_WOODEN_GRID_FIXED_4,
4875 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
4876 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
4877 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
4878 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
4880 static int editor_hl_deflektor[] =
4882 EL_INTERNAL_CASCADE_DF_ACTIVE,
4888 static int editor_el_deflektor[] =
4895 EL_DF_RECEIVER_RIGHT,
4897 EL_DF_RECEIVER_LEFT,
4898 EL_DF_RECEIVER_DOWN,
4901 EL_DF_MIRROR_ROTATING_START,
4902 EL_DF_MIRROR_FIXED_START,
4905 EL_DF_FIBRE_OPTIC_RED_1,
4906 EL_DF_FIBRE_OPTIC_YELLOW_1,
4907 EL_DF_FIBRE_OPTIC_GREEN_1,
4908 EL_DF_FIBRE_OPTIC_BLUE_1,
4910 EL_DF_STEEL_GRID_FIXED_START,
4911 EL_DF_STEEL_GRID_ROTATING_START,
4912 EL_DF_WOODEN_GRID_FIXED_START,
4913 EL_DF_WOODEN_GRID_ROTATING_START,
4925 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
4926 static int *editor_el_deflektor_ptr = editor_el_deflektor;
4927 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
4928 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
4930 static int editor_hl_chars[] =
4932 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
4938 static int editor_el_chars[] =
5020 EL_CHAR(CHAR_BYTE_COPYRIGHT),
5021 EL_CHAR(CHAR_BYTE_UMLAUT_A),
5022 EL_CHAR(CHAR_BYTE_UMLAUT_O),
5023 EL_CHAR(CHAR_BYTE_UMLAUT_U),
5025 EL_CHAR(CHAR_BYTE_DEGREE),
5026 EL_CHAR(CHAR_BYTE_REGISTERED),
5027 EL_CHAR(FONT_ASCII_CURSOR),
5028 EL_CHAR(FONT_ASCII_BUTTON),
5030 EL_CHAR(FONT_ASCII_UP),
5031 EL_CHAR(FONT_ASCII_DOWN),
5035 static int *editor_hl_chars_ptr = editor_hl_chars;
5036 static int *editor_el_chars_ptr = editor_el_chars;
5037 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
5038 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
5040 static int editor_hl_steel_chars[] =
5042 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
5048 static int editor_el_steel_chars[] =
5058 EL_STEEL_CHAR('\''),
5125 EL_STEEL_CHAR('\\'),
5130 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
5131 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
5132 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
5133 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
5135 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
5136 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
5137 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
5138 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
5140 EL_STEEL_CHAR(FONT_ASCII_UP),
5141 EL_STEEL_CHAR(FONT_ASCII_DOWN),
5145 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
5146 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
5147 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
5148 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
5150 static int editor_hl_custom[] =
5152 EL_INTERNAL_CASCADE_CE_ACTIVE,
5158 static int editor_el_custom[] =
5160 EL_CUSTOM_START + 0,
5161 EL_CUSTOM_START + 1,
5162 EL_CUSTOM_START + 2,
5163 EL_CUSTOM_START + 3,
5165 EL_CUSTOM_START + 4,
5166 EL_CUSTOM_START + 5,
5167 EL_CUSTOM_START + 6,
5168 EL_CUSTOM_START + 7,
5170 EL_CUSTOM_START + 8,
5171 EL_CUSTOM_START + 9,
5172 EL_CUSTOM_START + 10,
5173 EL_CUSTOM_START + 11,
5175 EL_CUSTOM_START + 12,
5176 EL_CUSTOM_START + 13,
5177 EL_CUSTOM_START + 14,
5178 EL_CUSTOM_START + 15,
5180 EL_CUSTOM_START + 16,
5181 EL_CUSTOM_START + 17,
5182 EL_CUSTOM_START + 18,
5183 EL_CUSTOM_START + 19,
5185 EL_CUSTOM_START + 20,
5186 EL_CUSTOM_START + 21,
5187 EL_CUSTOM_START + 22,
5188 EL_CUSTOM_START + 23,
5190 EL_CUSTOM_START + 24,
5191 EL_CUSTOM_START + 25,
5192 EL_CUSTOM_START + 26,
5193 EL_CUSTOM_START + 27,
5195 EL_CUSTOM_START + 28,
5196 EL_CUSTOM_START + 29,
5197 EL_CUSTOM_START + 30,
5198 EL_CUSTOM_START + 31,
5200 EL_CUSTOM_START + 32,
5201 EL_CUSTOM_START + 33,
5202 EL_CUSTOM_START + 34,
5203 EL_CUSTOM_START + 35,
5205 EL_CUSTOM_START + 36,
5206 EL_CUSTOM_START + 37,
5207 EL_CUSTOM_START + 38,
5208 EL_CUSTOM_START + 39,
5210 EL_CUSTOM_START + 40,
5211 EL_CUSTOM_START + 41,
5212 EL_CUSTOM_START + 42,
5213 EL_CUSTOM_START + 43,
5215 EL_CUSTOM_START + 44,
5216 EL_CUSTOM_START + 45,
5217 EL_CUSTOM_START + 46,
5218 EL_CUSTOM_START + 47,
5220 EL_CUSTOM_START + 48,
5221 EL_CUSTOM_START + 49,
5222 EL_CUSTOM_START + 50,
5223 EL_CUSTOM_START + 51,
5225 EL_CUSTOM_START + 52,
5226 EL_CUSTOM_START + 53,
5227 EL_CUSTOM_START + 54,
5228 EL_CUSTOM_START + 55,
5230 EL_CUSTOM_START + 56,
5231 EL_CUSTOM_START + 57,
5232 EL_CUSTOM_START + 58,
5233 EL_CUSTOM_START + 59,
5235 EL_CUSTOM_START + 60,
5236 EL_CUSTOM_START + 61,
5237 EL_CUSTOM_START + 62,
5238 EL_CUSTOM_START + 63,
5240 EL_CUSTOM_START + 64,
5241 EL_CUSTOM_START + 65,
5242 EL_CUSTOM_START + 66,
5243 EL_CUSTOM_START + 67,
5245 EL_CUSTOM_START + 68,
5246 EL_CUSTOM_START + 69,
5247 EL_CUSTOM_START + 70,
5248 EL_CUSTOM_START + 71,
5250 EL_CUSTOM_START + 72,
5251 EL_CUSTOM_START + 73,
5252 EL_CUSTOM_START + 74,
5253 EL_CUSTOM_START + 75,
5255 EL_CUSTOM_START + 76,
5256 EL_CUSTOM_START + 77,
5257 EL_CUSTOM_START + 78,
5258 EL_CUSTOM_START + 79,
5260 EL_CUSTOM_START + 80,
5261 EL_CUSTOM_START + 81,
5262 EL_CUSTOM_START + 82,
5263 EL_CUSTOM_START + 83,
5265 EL_CUSTOM_START + 84,
5266 EL_CUSTOM_START + 85,
5267 EL_CUSTOM_START + 86,
5268 EL_CUSTOM_START + 87,
5270 EL_CUSTOM_START + 88,
5271 EL_CUSTOM_START + 89,
5272 EL_CUSTOM_START + 90,
5273 EL_CUSTOM_START + 91,
5275 EL_CUSTOM_START + 92,
5276 EL_CUSTOM_START + 93,
5277 EL_CUSTOM_START + 94,
5278 EL_CUSTOM_START + 95,
5280 EL_CUSTOM_START + 96,
5281 EL_CUSTOM_START + 97,
5282 EL_CUSTOM_START + 98,
5283 EL_CUSTOM_START + 99,
5285 EL_CUSTOM_START + 100,
5286 EL_CUSTOM_START + 101,
5287 EL_CUSTOM_START + 102,
5288 EL_CUSTOM_START + 103,
5290 EL_CUSTOM_START + 104,
5291 EL_CUSTOM_START + 105,
5292 EL_CUSTOM_START + 106,
5293 EL_CUSTOM_START + 107,
5295 EL_CUSTOM_START + 108,
5296 EL_CUSTOM_START + 109,
5297 EL_CUSTOM_START + 110,
5298 EL_CUSTOM_START + 111,
5300 EL_CUSTOM_START + 112,
5301 EL_CUSTOM_START + 113,
5302 EL_CUSTOM_START + 114,
5303 EL_CUSTOM_START + 115,
5305 EL_CUSTOM_START + 116,
5306 EL_CUSTOM_START + 117,
5307 EL_CUSTOM_START + 118,
5308 EL_CUSTOM_START + 119,
5310 EL_CUSTOM_START + 120,
5311 EL_CUSTOM_START + 121,
5312 EL_CUSTOM_START + 122,
5313 EL_CUSTOM_START + 123,
5315 EL_CUSTOM_START + 124,
5316 EL_CUSTOM_START + 125,
5317 EL_CUSTOM_START + 126,
5318 EL_CUSTOM_START + 127,
5320 EL_CUSTOM_START + 128,
5321 EL_CUSTOM_START + 129,
5322 EL_CUSTOM_START + 130,
5323 EL_CUSTOM_START + 131,
5325 EL_CUSTOM_START + 132,
5326 EL_CUSTOM_START + 133,
5327 EL_CUSTOM_START + 134,
5328 EL_CUSTOM_START + 135,
5330 EL_CUSTOM_START + 136,
5331 EL_CUSTOM_START + 137,
5332 EL_CUSTOM_START + 138,
5333 EL_CUSTOM_START + 139,
5335 EL_CUSTOM_START + 140,
5336 EL_CUSTOM_START + 141,
5337 EL_CUSTOM_START + 142,
5338 EL_CUSTOM_START + 143,
5340 EL_CUSTOM_START + 144,
5341 EL_CUSTOM_START + 145,
5342 EL_CUSTOM_START + 146,
5343 EL_CUSTOM_START + 147,
5345 EL_CUSTOM_START + 148,
5346 EL_CUSTOM_START + 149,
5347 EL_CUSTOM_START + 150,
5348 EL_CUSTOM_START + 151,
5350 EL_CUSTOM_START + 152,
5351 EL_CUSTOM_START + 153,
5352 EL_CUSTOM_START + 154,
5353 EL_CUSTOM_START + 155,
5355 EL_CUSTOM_START + 156,
5356 EL_CUSTOM_START + 157,
5357 EL_CUSTOM_START + 158,
5358 EL_CUSTOM_START + 159,
5360 EL_CUSTOM_START + 160,
5361 EL_CUSTOM_START + 161,
5362 EL_CUSTOM_START + 162,
5363 EL_CUSTOM_START + 163,
5365 EL_CUSTOM_START + 164,
5366 EL_CUSTOM_START + 165,
5367 EL_CUSTOM_START + 166,
5368 EL_CUSTOM_START + 167,
5370 EL_CUSTOM_START + 168,
5371 EL_CUSTOM_START + 169,
5372 EL_CUSTOM_START + 170,
5373 EL_CUSTOM_START + 171,
5375 EL_CUSTOM_START + 172,
5376 EL_CUSTOM_START + 173,
5377 EL_CUSTOM_START + 174,
5378 EL_CUSTOM_START + 175,
5380 EL_CUSTOM_START + 176,
5381 EL_CUSTOM_START + 177,
5382 EL_CUSTOM_START + 178,
5383 EL_CUSTOM_START + 179,
5385 EL_CUSTOM_START + 180,
5386 EL_CUSTOM_START + 181,
5387 EL_CUSTOM_START + 182,
5388 EL_CUSTOM_START + 183,
5390 EL_CUSTOM_START + 184,
5391 EL_CUSTOM_START + 185,
5392 EL_CUSTOM_START + 186,
5393 EL_CUSTOM_START + 187,
5395 EL_CUSTOM_START + 188,
5396 EL_CUSTOM_START + 189,
5397 EL_CUSTOM_START + 190,
5398 EL_CUSTOM_START + 191,
5400 EL_CUSTOM_START + 192,
5401 EL_CUSTOM_START + 193,
5402 EL_CUSTOM_START + 194,
5403 EL_CUSTOM_START + 195,
5405 EL_CUSTOM_START + 196,
5406 EL_CUSTOM_START + 197,
5407 EL_CUSTOM_START + 198,
5408 EL_CUSTOM_START + 199,
5410 EL_CUSTOM_START + 200,
5411 EL_CUSTOM_START + 201,
5412 EL_CUSTOM_START + 202,
5413 EL_CUSTOM_START + 203,
5415 EL_CUSTOM_START + 204,
5416 EL_CUSTOM_START + 205,
5417 EL_CUSTOM_START + 206,
5418 EL_CUSTOM_START + 207,
5420 EL_CUSTOM_START + 208,
5421 EL_CUSTOM_START + 209,
5422 EL_CUSTOM_START + 210,
5423 EL_CUSTOM_START + 211,
5425 EL_CUSTOM_START + 212,
5426 EL_CUSTOM_START + 213,
5427 EL_CUSTOM_START + 214,
5428 EL_CUSTOM_START + 215,
5430 EL_CUSTOM_START + 216,
5431 EL_CUSTOM_START + 217,
5432 EL_CUSTOM_START + 218,
5433 EL_CUSTOM_START + 219,
5435 EL_CUSTOM_START + 220,
5436 EL_CUSTOM_START + 221,
5437 EL_CUSTOM_START + 222,
5438 EL_CUSTOM_START + 223,
5440 EL_CUSTOM_START + 224,
5441 EL_CUSTOM_START + 225,
5442 EL_CUSTOM_START + 226,
5443 EL_CUSTOM_START + 227,
5445 EL_CUSTOM_START + 228,
5446 EL_CUSTOM_START + 229,
5447 EL_CUSTOM_START + 230,
5448 EL_CUSTOM_START + 231,
5450 EL_CUSTOM_START + 232,
5451 EL_CUSTOM_START + 233,
5452 EL_CUSTOM_START + 234,
5453 EL_CUSTOM_START + 235,
5455 EL_CUSTOM_START + 236,
5456 EL_CUSTOM_START + 237,
5457 EL_CUSTOM_START + 238,
5458 EL_CUSTOM_START + 239,
5460 EL_CUSTOM_START + 240,
5461 EL_CUSTOM_START + 241,
5462 EL_CUSTOM_START + 242,
5463 EL_CUSTOM_START + 243,
5465 EL_CUSTOM_START + 244,
5466 EL_CUSTOM_START + 245,
5467 EL_CUSTOM_START + 246,
5468 EL_CUSTOM_START + 247,
5470 EL_CUSTOM_START + 248,
5471 EL_CUSTOM_START + 249,
5472 EL_CUSTOM_START + 250,
5473 EL_CUSTOM_START + 251,
5475 EL_CUSTOM_START + 252,
5476 EL_CUSTOM_START + 253,
5477 EL_CUSTOM_START + 254,
5478 EL_CUSTOM_START + 255
5480 static int *editor_hl_custom_ptr = editor_hl_custom;
5481 static int *editor_el_custom_ptr = editor_el_custom;
5482 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5483 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5485 static int editor_hl_group[] =
5487 EL_INTERNAL_CASCADE_GE_ACTIVE,
5493 static int editor_el_group[] =
5507 EL_GROUP_START + 10,
5508 EL_GROUP_START + 11,
5510 EL_GROUP_START + 12,
5511 EL_GROUP_START + 13,
5512 EL_GROUP_START + 14,
5513 EL_GROUP_START + 15,
5515 EL_GROUP_START + 16,
5516 EL_GROUP_START + 17,
5517 EL_GROUP_START + 18,
5518 EL_GROUP_START + 19,
5520 EL_GROUP_START + 20,
5521 EL_GROUP_START + 21,
5522 EL_GROUP_START + 22,
5523 EL_GROUP_START + 23,
5525 EL_GROUP_START + 24,
5526 EL_GROUP_START + 25,
5527 EL_GROUP_START + 26,
5528 EL_GROUP_START + 27,
5530 EL_GROUP_START + 28,
5531 EL_GROUP_START + 29,
5532 EL_GROUP_START + 30,
5535 static int *editor_hl_group_ptr = editor_hl_group;
5536 static int *editor_el_group_ptr = editor_el_group;
5537 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5538 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5540 static int editor_hl_empty_space[] =
5542 EL_INTERNAL_CASCADE_ES_ACTIVE,
5548 static int editor_el_empty_space[] =
5570 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
5571 static int *editor_el_empty_space_ptr = editor_el_empty_space;
5572 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
5573 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
5575 static int editor_hl_reference[] =
5577 EL_INTERNAL_CASCADE_REF_ACTIVE,
5583 static int editor_el_reference[] =
5587 EL_TRIGGER_CE_VALUE,
5588 EL_TRIGGER_CE_SCORE,
5592 EL_CURRENT_CE_VALUE,
5593 EL_CURRENT_CE_SCORE,
5615 static int *editor_hl_reference_ptr = editor_hl_reference;
5616 static int *editor_el_reference_ptr = editor_el_reference;
5617 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5618 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5620 static int editor_hl_user_defined[] =
5622 EL_INTERNAL_CASCADE_USER_ACTIVE,
5628 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5629 static int *editor_el_user_defined_ptr = NULL;
5630 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5631 static int num_editor_el_user_defined = 0;
5633 static int editor_hl_dynamic[] =
5635 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5641 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5642 static int *editor_el_dynamic_ptr = NULL;
5643 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5644 static int num_editor_el_dynamic = 0;
5646 static int editor_hl_empty[] = { EL_EMPTY };
5647 static int *editor_el_empty = NULL; // dynamically allocated
5649 static int *editor_hl_empty_ptr = editor_hl_empty;
5650 static int *editor_el_empty_ptr = NULL;
5651 static int num_editor_hl_empty = 0;
5652 static int num_editor_el_empty = 0; // dynamically determined, if needed
5654 static boolean use_el_empty = FALSE;
5656 static int *editor_elements = NULL; // dynamically allocated
5657 static int num_editor_elements = 0; // dynamically determined
5659 static boolean setup_editor_cascade_never = FALSE;
5661 static boolean setup_editor_el_players = TRUE;
5662 static boolean setup_editor_el_boulderdash = TRUE;
5663 static boolean setup_editor_el_boulderdash_native = TRUE;
5664 static boolean setup_editor_el_emerald_mine = TRUE;
5665 static boolean setup_editor_el_emerald_mine_club = TRUE;
5666 static boolean setup_editor_el_more = TRUE;
5667 static boolean setup_editor_el_sokoban = TRUE;
5668 static boolean setup_editor_el_supaplex = TRUE;
5669 static boolean setup_editor_el_diamond_caves = TRUE;
5670 static boolean setup_editor_el_dx_boulderdash = TRUE;
5671 static boolean setup_editor_el_mirror_magic = TRUE;
5672 static boolean setup_editor_el_deflektor = TRUE;
5673 static boolean setup_editor_el_chars = TRUE;
5674 static boolean setup_editor_el_steel_chars = TRUE;
5675 static boolean setup_editor_el_custom = TRUE;
5676 static boolean setup_editor_el_user_defined = TRUE;
5677 static boolean setup_editor_el_dynamic = TRUE;
5679 static int editor_hl_unused[] = { EL_EMPTY };
5680 static int *editor_hl_unused_ptr = editor_hl_unused;
5681 static int num_editor_hl_unused = 0;
5685 boolean *setup_value;
5686 boolean *setup_cascade_value;
5688 int **headline_list;
5689 int *headline_list_size;
5692 int *element_list_size;
5694 boolean last_setup_value;
5696 editor_elements_info[] =
5699 &setup_editor_el_players,
5700 &setup_editor_cascade_never,
5701 &editor_hl_unused_ptr, &num_editor_hl_unused,
5702 &editor_el_players_ptr, &num_editor_el_players
5705 &setup_editor_el_boulderdash,
5706 &setup.editor_cascade.el_bd,
5707 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5708 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5711 &setup_editor_el_boulderdash_native,
5712 &setup.editor_cascade.el_bd_native,
5713 &editor_hl_boulderdash_native_ptr, &num_editor_hl_boulderdash_native,
5714 &editor_el_boulderdash_native_ptr, &num_editor_el_boulderdash_native
5717 &setup_editor_el_emerald_mine,
5718 &setup.editor_cascade.el_em,
5719 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5720 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5723 &setup_editor_el_emerald_mine_club,
5724 &setup.editor_cascade.el_emc,
5725 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5726 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5729 &setup_editor_el_more,
5730 &setup.editor_cascade.el_rnd,
5731 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5732 &editor_el_rnd_ptr, &num_editor_el_rnd
5735 &setup_editor_el_sokoban,
5736 &setup.editor_cascade.el_sb,
5737 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5738 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5741 &setup_editor_el_supaplex,
5742 &setup.editor_cascade.el_sp,
5743 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5744 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5747 &setup_editor_el_diamond_caves,
5748 &setup.editor_cascade.el_dc,
5749 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5750 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5753 &setup_editor_el_dx_boulderdash,
5754 &setup.editor_cascade.el_dx,
5755 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5756 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
5759 &setup_editor_el_mirror_magic,
5760 &setup.editor_cascade.el_mm,
5761 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
5762 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
5765 &setup_editor_el_deflektor,
5766 &setup.editor_cascade.el_df,
5767 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
5768 &editor_el_deflektor_ptr, &num_editor_el_deflektor
5771 &setup_editor_el_chars,
5772 &setup.editor_cascade.el_chars,
5773 &editor_hl_chars_ptr, &num_editor_hl_chars,
5774 &editor_el_chars_ptr, &num_editor_el_chars
5777 &setup_editor_el_steel_chars,
5778 &setup.editor_cascade.el_steel_chars,
5779 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
5780 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
5783 &setup_editor_el_custom,
5784 &setup.editor_cascade.el_ce,
5785 &editor_hl_custom_ptr, &num_editor_hl_custom,
5786 &editor_el_custom_ptr, &num_editor_el_custom
5789 &setup_editor_el_custom,
5790 &setup.editor_cascade.el_ge,
5791 &editor_hl_group_ptr, &num_editor_hl_group,
5792 &editor_el_group_ptr, &num_editor_el_group
5795 &setup_editor_el_custom,
5796 &setup.editor_cascade.el_es,
5797 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
5798 &editor_el_empty_space_ptr, &num_editor_el_empty_space
5801 &setup_editor_el_custom,
5802 &setup.editor_cascade.el_ref,
5803 &editor_hl_reference_ptr, &num_editor_hl_reference,
5804 &editor_el_reference_ptr, &num_editor_el_reference
5807 &setup_editor_el_user_defined,
5808 &setup.editor_cascade.el_user,
5809 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
5810 &editor_el_user_defined_ptr, &num_editor_el_user_defined
5813 &setup_editor_el_dynamic,
5814 &setup.editor_cascade.el_dynamic,
5815 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
5816 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
5821 &editor_hl_empty_ptr, &num_editor_hl_empty,
5822 &editor_el_empty_ptr, &num_editor_el_empty,
5832 static struct XY xy_directions[] =
5841 // ----------------------------------------------------------------------------
5843 // ----------------------------------------------------------------------------
5845 static int getMaxInfoTextLength(void)
5847 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
5850 static int getTextWidthForGadget(char *text)
5855 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
5858 static int getTextWidthForDrawingArea(char *text)
5863 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
5866 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
5868 return (gi->x + gi->width + getTextWidthForGadget(text));
5871 static char *getElementInfoText(int element)
5873 char *info_text = NULL;
5875 if (element < MAX_NUM_ELEMENTS)
5877 if (strlen(element_info[element].description) > 0)
5878 info_text = element_info[element].description;
5879 else if (element_info[element].custom_description != NULL)
5880 info_text = element_info[element].custom_description;
5881 else if (element_info[element].editor_description != NULL)
5882 info_text = element_info[element].editor_description;
5885 if (info_text == NULL)
5886 info_text = INFOTEXT_UNKNOWN_ELEMENT;
5891 static char *getElementDescriptionFilenameExt(char *basename)
5893 char *elements_subdir = ELEMENTS_DIRECTORY;
5894 static char *elements_subdir2 = NULL;
5895 static char *filename = NULL;
5897 if (elements_subdir2 == NULL)
5898 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
5900 checked_free(filename);
5902 // 1st try: look for element description in current level set directory
5903 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
5904 if (fileExists(filename))
5909 // 2nd try: look for element description in the game's base directory
5910 filename = getPath3(options.docs_directory, elements_subdir, basename);
5911 if (fileExists(filename))
5917 static char *getElementDescriptionFilename(int element)
5919 char basename[MAX_FILENAME_LEN];
5922 // 1st try: look for element description file for exactly this element
5923 sprintf(basename, "%s.txt", element_info[element].token_name);
5924 filename = getElementDescriptionFilenameExt(basename);
5925 if (filename != NULL)
5928 // 2nd try: look for element description file for this element's class
5929 sprintf(basename, "%s.txt", element_info[element].class_name);
5930 filename = getElementDescriptionFilenameExt(basename);
5931 if (filename != NULL)
5934 // 3rd try: look for generic fallback text file for any element
5935 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
5936 if (filename != NULL)
5942 static boolean suppressBorderElement(void)
5944 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
5945 lev_fieldx <= MAX_ED_FIELDX &&
5946 lev_fieldy <= MAX_ED_FIELDY);
5949 static void InitDynamicEditorElementList(int **elements, int *num_elements)
5951 boolean element_found[NUM_FILE_ELEMENTS];
5954 // initialize list of used elements to "not used"
5955 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5956 element_found[i] = FALSE;
5958 // find all elements used in current level
5959 for (y = 0; y < lev_fieldy; y++)
5961 for (x = 0; x < lev_fieldx; x++)
5963 if (Tile[x][y] >= NUM_FILE_ELEMENTS) // should never happen
5966 if (IS_MM_WALL(Tile[x][y]))
5967 element_found[map_mm_wall_element(Tile[x][y])] = TRUE;
5969 element_found[Tile[x][y]] = TRUE;
5975 // count number of elements used in current level
5976 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5977 if (element_found[i])
5980 // add space for up to 3 more elements for padding that may be needed
5983 // free memory for old list of elements, if needed
5984 checked_free(*elements);
5986 // allocate memory for new list of elements
5987 *elements = checked_malloc(*num_elements * sizeof(int));
5991 // add all elements used in current level (non-custom/group/empty elements)
5992 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5993 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) ||
5994 IS_GROUP_ELEMENT(i) ||
5995 IS_EMPTY_ELEMENT(i)))
5996 (*elements)[(*num_elements)++] = i;
5998 // add all elements used in current level (custom/group/empty elements)
5999 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
6000 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) ||
6001 IS_GROUP_ELEMENT(i) ||
6002 IS_EMPTY_ELEMENT(i)))
6003 (*elements)[(*num_elements)++] = i;
6005 while (*num_elements % 4) // pad with empty elements, if needed
6006 (*elements)[(*num_elements)++] = EL_EMPTY;
6009 static void ReinitializeElementList_EnableSections(void)
6011 // default: enable all element sections
6013 setup_editor_el_players = TRUE;
6014 setup_editor_el_boulderdash = TRUE;
6015 setup_editor_el_boulderdash_native = TRUE;
6016 setup_editor_el_emerald_mine = TRUE;
6017 setup_editor_el_emerald_mine_club = TRUE;
6018 setup_editor_el_more = TRUE;
6019 setup_editor_el_sokoban = TRUE;
6020 setup_editor_el_supaplex = TRUE;
6021 setup_editor_el_diamond_caves = TRUE;
6022 setup_editor_el_dx_boulderdash = TRUE;
6023 setup_editor_el_mirror_magic = TRUE;
6024 setup_editor_el_deflektor = TRUE;
6025 setup_editor_el_chars = TRUE;
6026 setup_editor_el_steel_chars = TRUE;
6028 setup_editor_el_custom = TRUE;
6029 setup_editor_el_user_defined = TRUE;
6030 setup_editor_el_dynamic = TRUE;
6032 // now disable all element sections not to be displayed
6034 if (!setup.editor.el_classic)
6036 setup_editor_el_players = FALSE;
6037 setup_editor_el_boulderdash = FALSE;
6038 setup_editor_el_boulderdash_native = FALSE;
6039 setup_editor_el_emerald_mine = FALSE;
6040 setup_editor_el_emerald_mine_club = FALSE;
6041 setup_editor_el_more = FALSE;
6042 setup_editor_el_sokoban = FALSE;
6043 setup_editor_el_supaplex = FALSE;
6044 setup_editor_el_diamond_caves = FALSE;
6045 setup_editor_el_dx_boulderdash = FALSE;
6046 setup_editor_el_mirror_magic = FALSE;
6047 setup_editor_el_deflektor = FALSE;
6048 setup_editor_el_chars = FALSE;
6049 setup_editor_el_steel_chars = FALSE;
6052 if (!setup.editor.el_custom)
6054 setup_editor_el_custom = FALSE;
6057 if (!setup.editor.el_user_defined)
6059 setup_editor_el_user_defined = FALSE;
6062 if (!setup.editor.el_dynamic)
6064 setup_editor_el_dynamic = FALSE;
6067 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
6069 setup_editor_el_boulderdash_native = FALSE;
6070 setup_editor_el_mirror_magic = FALSE;
6071 setup_editor_el_deflektor = FALSE;
6073 else if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
6075 setup_editor_el_players = FALSE;
6076 setup_editor_el_boulderdash = FALSE;
6077 setup_editor_el_emerald_mine = FALSE;
6078 setup_editor_el_emerald_mine_club = FALSE;
6079 setup_editor_el_more = FALSE;
6080 setup_editor_el_sokoban = FALSE;
6081 setup_editor_el_supaplex = FALSE;
6082 setup_editor_el_diamond_caves = FALSE;
6083 setup_editor_el_dx_boulderdash = FALSE;
6084 setup_editor_el_mirror_magic = FALSE;
6085 setup_editor_el_deflektor = FALSE;
6086 setup_editor_el_chars = FALSE;
6087 setup_editor_el_steel_chars = FALSE;
6089 setup_editor_el_custom = FALSE;
6091 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
6093 setup_editor_el_boulderdash = FALSE;
6094 setup_editor_el_boulderdash_native = FALSE;
6095 setup_editor_el_more = FALSE;
6096 setup_editor_el_sokoban = FALSE;
6097 setup_editor_el_supaplex = FALSE;
6098 setup_editor_el_diamond_caves = FALSE;
6099 setup_editor_el_dx_boulderdash = FALSE;
6100 setup_editor_el_mirror_magic = FALSE;
6101 setup_editor_el_deflektor = FALSE;
6102 setup_editor_el_steel_chars = FALSE;
6104 setup_editor_el_custom = FALSE;
6106 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
6108 setup_editor_el_players = FALSE;
6109 setup_editor_el_boulderdash = FALSE;
6110 setup_editor_el_boulderdash_native = FALSE;
6111 setup_editor_el_emerald_mine = FALSE;
6112 setup_editor_el_emerald_mine_club = FALSE;
6113 setup_editor_el_more = FALSE;
6114 setup_editor_el_sokoban = FALSE;
6115 setup_editor_el_diamond_caves = FALSE;
6116 setup_editor_el_dx_boulderdash = FALSE;
6117 setup_editor_el_mirror_magic = FALSE;
6118 setup_editor_el_deflektor = FALSE;
6119 setup_editor_el_chars = FALSE;
6120 setup_editor_el_steel_chars = FALSE;
6122 setup_editor_el_custom = FALSE;
6124 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
6126 setup_editor_el_players = FALSE;
6127 setup_editor_el_boulderdash = FALSE;
6128 setup_editor_el_boulderdash_native = FALSE;
6129 setup_editor_el_emerald_mine = FALSE;
6130 setup_editor_el_emerald_mine_club = FALSE;
6131 setup_editor_el_more = FALSE;
6132 setup_editor_el_sokoban = FALSE;
6133 setup_editor_el_supaplex = FALSE;
6134 setup_editor_el_diamond_caves = FALSE;
6135 setup_editor_el_dx_boulderdash = FALSE;
6136 setup_editor_el_steel_chars = FALSE;
6138 setup_editor_el_custom = FALSE;
6142 static void ReinitializeElementList(void)
6144 static boolean initialization_needed = TRUE;
6148 ReinitializeElementList_EnableSections();
6150 if (initialization_needed)
6152 LoadSetup_EditorCascade(); // load last editor cascade state
6154 // initialize editor cascade element from saved cascade state
6155 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6157 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
6158 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
6160 if (IS_EDITOR_CASCADE(*cascade_element))
6162 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
6163 EL_CASCADE_INACTIVE(*cascade_element));
6166 initialization_needed = FALSE;
6169 checked_free(editor_elements);
6171 // reload optional user defined element list for each invocation of editor
6172 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
6173 &num_editor_el_user_defined);
6175 // initialize dynamic level element list for each invocation of editor
6176 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
6177 &num_editor_el_dynamic);
6179 // initialize list of empty elements (used for padding, if needed)
6180 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6181 editor_el_empty[i] = EL_EMPTY;
6183 // do some sanity checks for each element from element list
6184 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6186 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6188 int element = (*editor_elements_info[i].element_list)[j];
6190 if (element >= NUM_FILE_ELEMENTS)
6191 Warn("editor element %d is runtime element", element);
6193 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
6194 Warn("no element description text for element %d", element);
6198 num_editor_elements = 0;
6199 use_el_empty = FALSE;
6201 // determine size of element list
6202 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6204 if (*editor_elements_info[i].setup_value)
6206 boolean found_inactive_cascade = FALSE;
6208 if (setup.editor.el_headlines)
6210 // required for correct padding of palette headline buttons
6211 if (*editor_elements_info[i].headline_list_size > 0)
6212 num_editor_elements += ED_ELEMENTLIST_COLS;
6214 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6216 int element = (*editor_elements_info[i].headline_list)[j];
6218 if (IS_EDITOR_CASCADE_INACTIVE(element))
6219 found_inactive_cascade = TRUE;
6223 if (found_inactive_cascade)
6226 // required for correct padding of palette element buttons
6227 int element_list_size = *editor_elements_info[i].element_list_size;
6229 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6230 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6232 num_editor_elements += element_buttons;
6236 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
6238 // offer at least as many elements as element buttons exist
6239 use_el_empty = TRUE;
6240 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
6242 num_editor_elements += num_editor_el_empty;
6246 num_editor_el_empty = 0;
6249 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
6251 // fill element list
6252 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6254 boolean found_inactive_cascade = FALSE;
6256 if (*editor_elements_info[i].setup_value)
6258 if (setup.editor.el_headlines)
6260 // required for correct padding of palette headline buttons
6261 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6262 ED_ELEMENTLIST_COLS : 0);
6264 for (j = 0; j < headline_size; j++)
6266 // use empty elements for padding of palette headline buttons
6267 int element = (j < *editor_elements_info[i].headline_list_size ?
6268 (*editor_elements_info[i].headline_list)[j] :
6269 editor_el_empty[0]);
6271 editor_elements[pos++] = element;
6273 if (IS_EDITOR_CASCADE_INACTIVE(element))
6274 found_inactive_cascade = TRUE;
6278 if (found_inactive_cascade)
6281 // required for correct padding of palette element buttons
6282 int element_list_size = *editor_elements_info[i].element_list_size;
6284 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6285 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6287 // copy all elements from element list
6288 for (j = 0; j < element_list_size; j++)
6289 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6291 // use empty elements for padding of palette element buttons
6292 for (j = 0; j < element_buttons - element_list_size; j++)
6293 editor_elements[pos++] = editor_el_empty[0];
6297 // (this function is also called before editor gadgets are initialized!)
6298 AdjustElementListScrollbar();
6301 void PrintEditorElementList(void)
6303 boolean *stop = &setup_editor_el_user_defined;
6306 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6308 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6310 if (IS_EDITOR_CASCADE(cascade_element))
6312 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6313 char *headline = element_info[cascade_element_show].editor_description;
6315 PrintLineWithPrefix("# ", "-", 77);
6316 Print("# %s\n", headline);
6317 PrintLineWithPrefix("# ", "-", 77);
6320 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6322 int element = (*editor_elements_info[i].headline_list)[j];
6324 if (IS_EDITOR_CASCADE(element))
6325 element = EL_CHAR_MINUS;
6327 Print("# %s\n", element_info[element].token_name);
6333 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6335 int element = (*editor_elements_info[i].element_list)[j];
6337 Print("# %s\n", element_info[element].token_name);
6345 static void ReinitializeElementListButtons(void)
6347 static boolean last_setup_value_headlines = FALSE;
6348 static boolean initialization_needed = TRUE;
6351 if (!initialization_needed) // check if editor element setup has changed
6353 if (last_setup_value_headlines != setup.editor.el_headlines)
6354 initialization_needed = TRUE;
6356 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6357 if (editor_elements_info[i].last_setup_value !=
6358 *editor_elements_info[i].setup_value)
6359 initialization_needed = TRUE;
6362 if (!initialization_needed)
6365 FreeLevelEditorGadgets();
6366 CreateLevelEditorGadgets();
6368 // store current setup values for next invocation of this function
6369 last_setup_value_headlines = setup.editor.el_headlines;
6370 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6371 editor_elements_info[i].last_setup_value =
6372 *editor_elements_info[i].setup_value;
6374 initialization_needed = FALSE;
6377 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6380 int border_graphic =
6381 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6382 struct GraphicInfo *g = &graphic_info[border_graphic];
6383 Bitmap *src_bitmap = g->bitmap;
6384 int src_x = g->src_x;
6385 int src_y = g->src_y;
6386 int border_size = g->border_size;
6387 int border_xpos = g->width - border_size;
6388 int border_ypos = g->height - border_size;
6389 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6392 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6393 border_size, border_size,
6394 dest_x - border_size, dest_y - border_size);
6395 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6396 border_size, border_size,
6397 dest_x + width, dest_y - border_size);
6398 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6399 border_size, border_size,
6400 dest_x - border_size, dest_y + height);
6401 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6402 border_size, border_size,
6403 dest_x + width, dest_y + height);
6405 for (i = 0; i < width / tilesize; i++)
6407 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6408 tilesize, border_size,
6409 dest_x + i * tilesize, dest_y - border_size);
6410 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6411 tilesize, border_size,
6412 dest_x + i * tilesize, dest_y + height);
6415 for (i = 0; i < height / tilesize; i++)
6417 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6418 border_size, tilesize,
6419 dest_x - border_size, dest_y + i * tilesize);
6420 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6421 border_size, tilesize,
6422 dest_x + width, dest_y + i * tilesize);
6425 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6428 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6430 int xsize_tile = MAX(ed_tilesize, xsize);
6431 int ysize_tile = MAX(ed_tilesize, ysize);
6432 int xsize_full = xsize + 1;
6433 int ysize_full = ysize + 1;
6434 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6435 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6436 Pixel line_color = getTabulatorBarColor();
6438 if (line_color == BLACK_PIXEL) // black => transparent
6441 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6442 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6443 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6446 static void DrawEditorLevelBorderLinesIfNeeded(void)
6448 int xsize = lev_fieldx * ed_tilesize;
6449 int ysize = lev_fieldy * ed_tilesize;
6450 int line_size = getTabulatorBarHeight();
6452 if (!suppressBorderElement())
6455 // draw little border line around editable level playfield
6458 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6461 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6463 if (xsize < SXSIZE && ysize < SYSIZE)
6464 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6467 static void DrawEditorElement(int x, int y, int element)
6469 DrawSizedElement(x, y, element, ed_tilesize);
6472 static void DrawEditorElementThruMask(int x, int y, int element)
6474 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6477 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6479 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6482 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6484 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6485 DrawEditorLevelBorderLinesIfNeeded();
6488 static void DrawDrawingArea(int id)
6490 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6493 int *value = drawingarea_info[id].value;
6494 int area_xsize = drawingarea_info[id].area_xsize;
6495 int area_ysize = drawingarea_info[id].area_ysize;
6496 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6498 for (x = 0; x < area_xsize; x++)
6499 for (y = 0; y < area_ysize; y++)
6500 DrawSizedGraphicExt(drawto,
6501 gi->x + x * tilesize,
6502 gi->y + y * tilesize,
6503 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6506 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6509 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6510 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6512 BlitBitmap(drawto, drawto,
6513 SX + (dx == -1 ? ed_tilesize : 0),
6514 SY + (dy == -1 ? ed_tilesize : 0),
6515 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6516 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6517 SX + (dx == +1 ? ed_tilesize : 0),
6518 SY + (dy == +1 ? ed_tilesize : 0));
6522 x = (dx == 1 ? 0 : ed_fieldx - 1);
6523 for (y = 0; y < ed_fieldy; y++)
6524 DrawEditorElementOrWall(x, y, from_x, from_y);
6528 y = (dy == 1 ? 0 : ed_fieldy - 1);
6529 for (x = 0; x < ed_fieldx; x++)
6530 DrawEditorElementOrWall(x, y, from_x, from_y);
6533 redraw_mask |= REDRAW_FIELD;
6537 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6540 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6543 static void CreateControlButtons(void)
6545 struct GadgetInfo *gi;
6548 // create toolbox buttons
6549 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6551 int id = controlbutton_info[i].gadget_id;
6552 int type = controlbutton_info[i].gadget_type;
6553 int graphic = controlbutton_info[i].graphic;
6554 struct XYTileSize *pos = controlbutton_info[i].pos;
6555 struct GraphicInfo *gd = &graphic_info[graphic];
6556 Bitmap *deco_bitmap = NULL;
6557 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6558 int tile_size = 0, deco_shift = 0;
6559 boolean deco_masked = FALSE;
6560 int gd_x1 = gd->src_x;
6561 int gd_y1 = gd->src_y;
6562 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6563 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6564 int gd_x1a = gd->src_x + gd->active_xoffset;
6565 int gd_y1a = gd->src_y + gd->active_yoffset;
6566 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6567 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6570 unsigned int event_mask;
6571 int radio_button_nr = RADIO_NR_NONE;
6572 boolean checked = FALSE;
6574 if (type == GD_TYPE_RADIO_BUTTON)
6576 event_mask = GD_EVENT_PRESSED;
6577 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6579 if (id == drawing_function)
6584 if (id == GADGET_ID_WRAP_LEFT ||
6585 id == GADGET_ID_WRAP_RIGHT ||
6586 id == GADGET_ID_WRAP_UP ||
6587 id == GADGET_ID_WRAP_DOWN)
6588 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6590 event_mask = GD_EVENT_RELEASED;
6593 if (id == GADGET_ID_PROPERTIES ||
6594 id == GADGET_ID_PALETTE)
6599 else if (id == GADGET_ID_ELEMENT_LEFT ||
6600 id == GADGET_ID_ELEMENT_MIDDLE ||
6601 id == GADGET_ID_ELEMENT_RIGHT)
6606 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6607 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6608 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6610 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6611 editor.button.element_left.tile_size :
6612 id == GADGET_ID_ELEMENT_MIDDLE ?
6613 editor.button.element_middle.tile_size :
6614 id == GADGET_ID_ELEMENT_RIGHT ?
6615 editor.button.element_right.tile_size : 0);
6617 // make sure that decoration does not overlap gadget border
6618 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6620 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6622 deco_xpos = (gd->width - tile_size) / 2;
6623 deco_ypos = (gd->height - tile_size) / 2;
6625 deco_masked = gd->draw_masked;
6633 gi = CreateGadget(GDI_CUSTOM_ID, id,
6634 GDI_CUSTOM_TYPE_ID, i,
6635 GDI_IMAGE_ID, graphic,
6636 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6639 GDI_WIDTH, gd->width,
6640 GDI_HEIGHT, gd->height,
6642 GDI_STATE, GD_BUTTON_UNPRESSED,
6643 GDI_RADIO_NR, radio_button_nr,
6644 GDI_CHECKED, checked,
6645 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6646 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6647 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6648 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6649 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6650 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6651 GDI_DECORATION_SIZE, tile_size, tile_size,
6652 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6653 GDI_DECORATION_MASKED, deco_masked,
6654 GDI_EVENT_MASK, event_mask,
6655 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6656 GDI_CALLBACK_ACTION, HandleControlButtons,
6660 Fail("cannot create gadget");
6662 level_editor_gadget[id] = gi;
6665 // these values are not constant, but can change at runtime
6666 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6667 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6668 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6669 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6670 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6671 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6672 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6673 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6674 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6675 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6676 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6677 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6679 // create buttons for scrolling of drawing area and element list
6680 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6682 int id = scrollbutton_info[i].gadget_id;
6683 int graphic = scrollbutton_info[i].graphic;
6684 struct GraphicInfo *gd = &graphic_info[graphic];
6685 Bitmap *gd_bitmap = gd->bitmap;
6686 int gd_x1 = gd->src_x;
6687 int gd_y1 = gd->src_y;
6688 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6689 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6690 int width = gd->width;
6691 int height = gd->height;
6692 int x = scrollbutton_pos[i].x;
6693 int y = scrollbutton_pos[i].y;
6694 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6696 if (id == GADGET_ID_SCROLL_LIST_UP ||
6697 id == GADGET_ID_SCROLL_LIST_DOWN)
6708 gi = CreateGadget(GDI_CUSTOM_ID, id,
6709 GDI_CUSTOM_TYPE_ID, i,
6710 GDI_IMAGE_ID, graphic,
6711 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6716 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6717 GDI_STATE, GD_BUTTON_UNPRESSED,
6718 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6719 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6720 GDI_EVENT_MASK, event_mask,
6721 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6722 GDI_CALLBACK_ACTION, HandleControlButtons,
6726 Fail("cannot create gadget");
6728 level_editor_gadget[id] = gi;
6731 // create buttons for element list
6732 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6734 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6735 int graphic = IMG_EDITOR_PALETTE_BUTTON;
6736 struct GraphicInfo *gd = &graphic_info[graphic];
6737 Bitmap *gd_bitmap = gd->bitmap;
6738 Bitmap *deco_bitmap;
6739 int deco_x, deco_y, deco_xpos, deco_ypos;
6740 int gd_x1 = gd->src_x;
6741 int gd_y1 = gd->src_y;
6742 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6743 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6744 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
6745 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
6746 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
6747 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
6748 int element = editor_elements[i];
6749 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
6750 unsigned int event_mask = GD_EVENT_RELEASED;
6752 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
6754 deco_xpos = (gd->width - tile_size) / 2;
6755 deco_ypos = (gd->height - tile_size) / 2;
6757 gi = CreateGadget(GDI_CUSTOM_ID, id,
6758 GDI_CUSTOM_TYPE_ID, i,
6759 GDI_IMAGE_ID, graphic,
6760 GDI_INFO_TEXT, getElementInfoText(element),
6763 GDI_WIDTH, gd->width,
6764 GDI_HEIGHT, gd->height,
6765 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6766 GDI_STATE, GD_BUTTON_UNPRESSED,
6767 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6768 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6769 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6770 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6771 GDI_DECORATION_SIZE, tile_size, tile_size,
6772 GDI_DECORATION_SHIFTING, 1, 1,
6773 GDI_EVENT_MASK, event_mask,
6774 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6775 GDI_CALLBACK_ACTION, HandleControlButtons,
6779 Fail("cannot create gadget");
6781 level_editor_gadget[id] = gi;
6785 static void CreateCounterButtons(void)
6787 int max_infotext_len = getMaxInfoTextLength();
6790 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
6793 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
6794 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
6796 // determine horizontal position to the right of specified gadget
6797 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6798 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
6799 ED_GADGET_TEXT_DISTANCE);
6801 // determine horizontal offset for leading text
6802 if (counterbutton_info[i].text_left != NULL)
6803 x += getTextWidthForGadget(counterbutton_info[i].text_left);
6805 for (j = 0; j < 2; j++)
6807 struct GadgetInfo *gi;
6809 counterbutton_info[i].gadget_id_down :
6810 counterbutton_info[i].gadget_id_up);
6812 struct GraphicInfo *gd;
6813 int gd_x1, gd_x2, gd_y1, gd_y2;
6814 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6815 char infotext[max_infotext_len + 1];
6817 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6820 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
6821 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
6823 event_mask |= GD_EVENT_RELEASED;
6827 x = DX + editor.button.prev_level.x;
6828 y = DY + editor.button.prev_level.y;
6832 x = DX + editor.button.next_level.x;
6833 y = DY + editor.button.next_level.y;
6839 IMG_EDITOR_COUNTER_DOWN :
6840 IMG_EDITOR_COUNTER_UP);
6843 gd = &graphic_info[graphic];
6847 gd_x2 = gd->src_x + gd->pressed_xoffset;
6848 gd_y2 = gd->src_y + gd->pressed_yoffset;
6850 sprintf(infotext, "%s counter value by 1, 5 or 10",
6851 (j == 0 ? "decrease" : "increase"));
6853 gi = CreateGadget(GDI_CUSTOM_ID, id,
6854 GDI_CUSTOM_TYPE_ID, i,
6855 GDI_IMAGE_ID, graphic,
6856 GDI_INFO_TEXT, infotext,
6859 GDI_WIDTH, gd->width,
6860 GDI_HEIGHT, gd->height,
6861 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6862 GDI_STATE, GD_BUTTON_UNPRESSED,
6863 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6864 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6865 GDI_EVENT_MASK, event_mask,
6866 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6867 GDI_CALLBACK_ACTION, HandleCounterButtons,
6871 Fail("cannot create gadget");
6873 level_editor_gadget[id] = gi;
6874 right_gadget_border[id] =
6875 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6877 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
6881 int font_type = FONT_INPUT_1;
6882 int font_type_active = FONT_INPUT_1_ACTIVE;
6884 id = counterbutton_info[i].gadget_id_text;
6886 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6888 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6890 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
6892 font_type = FONT_LEVEL_NUMBER;
6893 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
6895 x = DX + editor.input.level_number.x;
6896 y = DY + editor.input.level_number.y;
6900 graphic = IMG_EDITOR_COUNTER_INPUT;
6903 gd = &graphic_info[graphic];
6907 gd_x2 = gd->src_x + gd->active_xoffset;
6908 gd_y2 = gd->src_y + gd->active_yoffset;
6910 gi = CreateGadget(GDI_CUSTOM_ID, id,
6911 GDI_CUSTOM_TYPE_ID, i,
6912 GDI_IMAGE_ID, graphic,
6913 GDI_INFO_TEXT, "enter counter value",
6916 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
6917 GDI_NUMBER_VALUE, 0,
6918 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
6919 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
6920 GDI_TEXT_SIZE, 3, // minimal counter text size
6921 GDI_TEXT_FONT, font_type,
6922 GDI_TEXT_FONT_ACTIVE, font_type_active,
6923 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6924 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6925 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6926 GDI_DESIGN_WIDTH, gd->width,
6927 GDI_EVENT_MASK, event_mask,
6928 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6929 GDI_CALLBACK_ACTION, HandleCounterButtons,
6933 Fail("cannot create gadget");
6935 level_editor_gadget[id] = gi;
6936 right_gadget_border[id] =
6937 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6939 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
6945 static void CreateDrawingAreas(void)
6949 // these values are not constant, but can change at runtime
6950 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
6951 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
6953 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
6955 struct GadgetInfo *gi;
6956 int id = drawingarea_info[i].gadget_id;
6957 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
6958 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
6959 int area_xsize = drawingarea_info[i].area_xsize;
6960 int area_ysize = drawingarea_info[i].area_ysize;
6961 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
6962 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
6963 unsigned int event_mask =
6964 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
6965 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
6967 // determine horizontal position to the right of specified gadget
6968 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
6969 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
6970 ED_DRAWINGAREA_TEXT_DISTANCE);
6972 // determine horizontal offset for leading text
6973 if (drawingarea_info[i].text_left != NULL)
6974 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
6976 gi = CreateGadget(GDI_CUSTOM_ID, id,
6977 GDI_CUSTOM_TYPE_ID, i,
6980 GDI_TYPE, GD_TYPE_DRAWING_AREA,
6981 GDI_AREA_SIZE, area_xsize, area_ysize,
6982 GDI_ITEM_SIZE, item_size, item_size,
6983 GDI_EVENT_MASK, event_mask,
6984 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
6985 GDI_CALLBACK_ACTION, HandleDrawingAreas,
6989 Fail("cannot create gadget");
6991 level_editor_gadget[id] = gi;
6992 right_gadget_border[id] =
6993 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
6997 static void CreateTextInputGadgets(void)
6999 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
7000 int max_infotext_len = getMaxInfoTextLength();
7003 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
7005 int gd_x1 = gd->src_x;
7006 int gd_y1 = gd->src_y;
7007 int gd_x2 = gd->src_x + gd->active_xoffset;
7008 int gd_y2 = gd->src_y + gd->active_yoffset;
7009 struct GadgetInfo *gi;
7010 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7011 char infotext[MAX_OUTPUT_LINESIZE + 1];
7012 int id = textinput_info[i].gadget_id;
7015 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
7017 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
7018 int border_size = gd->border_size;
7019 int font_nr = FONT_INPUT_1;
7020 int font_height = getFontHeight(font_nr);
7021 int xoffset = element_border + TILEX + element_border + 3 * border_size;
7022 int yoffset = element_border + (TILEY - font_height) / 2;
7024 x = (editor.settings.element_name.x != -1 ?
7025 editor.settings.element_name.x :
7026 editor.settings.element_graphic.x + xoffset) - border_size;
7027 y = (editor.settings.element_name.y != -1 ?
7028 editor.settings.element_name.y :
7029 editor.settings.element_graphic.y + yoffset) - border_size;
7033 x = ED_SETTINGS_X(textinput_info[i].x);
7034 y = ED_SETTINGS_Y(textinput_info[i].y);
7037 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
7038 infotext[max_infotext_len] = '\0';
7040 gi = CreateGadget(GDI_CUSTOM_ID, id,
7041 GDI_CUSTOM_TYPE_ID, i,
7042 GDI_INFO_TEXT, infotext,
7045 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
7046 GDI_TEXT_VALUE, textinput_info[i].value,
7047 GDI_TEXT_SIZE, textinput_info[i].size,
7048 GDI_TEXT_FONT, FONT_INPUT_1,
7049 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7050 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7051 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7052 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7053 GDI_DESIGN_WIDTH, gd->width,
7054 GDI_EVENT_MASK, event_mask,
7055 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7056 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
7060 Fail("cannot create gadget");
7062 level_editor_gadget[id] = gi;
7066 static void CreateTextAreaGadgets(void)
7068 int max_infotext_len = getMaxInfoTextLength();
7071 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
7073 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
7074 int gd_x1 = gd->src_x;
7075 int gd_y1 = gd->src_y;
7076 int gd_x2 = gd->src_x + gd->active_xoffset;
7077 int gd_y2 = gd->src_y + gd->active_yoffset;
7078 struct GadgetInfo *gi;
7079 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
7080 char infotext[MAX_OUTPUT_LINESIZE + 1];
7081 int id = textarea_info[i].gadget_id;
7082 int area_xsize = textarea_info[i].xsize;
7083 int area_ysize = textarea_info[i].ysize;
7085 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
7086 infotext[max_infotext_len] = '\0';
7088 gi = CreateGadget(GDI_CUSTOM_ID, id,
7089 GDI_CUSTOM_TYPE_ID, i,
7090 GDI_INFO_TEXT, infotext,
7091 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
7092 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
7093 GDI_TYPE, GD_TYPE_TEXT_AREA,
7094 GDI_AREA_SIZE, area_xsize, area_ysize,
7095 GDI_TEXT_FONT, FONT_INPUT_1,
7096 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7097 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7098 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7099 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7100 GDI_DESIGN_WIDTH, gd->width,
7101 GDI_EVENT_MASK, event_mask,
7102 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7103 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
7107 Fail("cannot create gadget");
7109 level_editor_gadget[id] = gi;
7113 static void CreateSelectboxGadgets(void)
7115 int max_infotext_len = getMaxInfoTextLength();
7118 for (i = 0; i < ED_NUM_SELECTBOX; i++)
7120 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
7121 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
7122 int gd_x1 = gd->src_x;
7123 int gd_y1 = gd->src_y;
7124 int gd_x2 = gd->src_x + gd->active_xoffset;
7125 int gd_y2 = gd->src_y + gd->active_yoffset;
7126 int selectbox_button_xsize = gd2->width;
7127 struct GadgetInfo *gi;
7128 char infotext[MAX_OUTPUT_LINESIZE + 1];
7129 int id = selectbox_info[i].gadget_id;
7130 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
7131 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
7132 unsigned int event_mask =
7133 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
7135 if (selectbox_info[i].size == -1) // dynamically determine size
7137 // (we cannot use -1 for uninitialized values if we directly compare
7138 // with results from strlen(), because the '<' and '>' operation will
7139 // implicitely cast -1 to an unsigned integer value!)
7140 selectbox_info[i].size = 0;
7142 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
7143 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
7144 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
7146 selectbox_info[i].size++; // add one character empty space
7149 // determine horizontal position to the right of specified gadget
7150 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
7151 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
7152 ED_GADGET_TEXT_DISTANCE);
7154 // determine horizontal offset for leading text
7155 if (selectbox_info[i].text_left != NULL)
7156 x += getTextWidthForGadget(selectbox_info[i].text_left);
7158 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
7159 infotext[max_infotext_len] = '\0';
7161 gi = CreateGadget(GDI_CUSTOM_ID, id,
7162 GDI_CUSTOM_TYPE_ID, i,
7163 GDI_INFO_TEXT, infotext,
7166 GDI_TYPE, GD_TYPE_SELECTBOX,
7167 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
7168 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
7169 GDI_TEXT_SIZE, selectbox_info[i].size,
7170 GDI_TEXT_FONT, FONT_INPUT_1,
7171 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
7172 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
7173 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7174 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7175 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7176 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
7177 GDI_DESIGN_WIDTH, gd->width,
7178 GDI_EVENT_MASK, event_mask,
7179 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7180 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
7184 Fail("cannot create gadget");
7186 level_editor_gadget[id] = gi;
7187 right_gadget_border[id] =
7188 getRightGadgetBorder(gi, selectbox_info[i].text_right);
7192 static void CreateTextbuttonGadgets(void)
7194 int max_infotext_len = getMaxInfoTextLength();
7197 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
7199 int id = textbutton_info[i].gadget_id;
7201 ((id >= GADGET_ID_LEVELCONFIG_LEVEL && id <= GADGET_ID_LEVELCONFIG_EDITOR) ||
7202 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
7204 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
7205 int gadget_distance =
7206 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
7207 struct GraphicInfo *gd = &graphic_info[graphic];
7208 int gd_x1 = gd->src_x;
7209 int gd_y1 = gd->src_y;
7210 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7211 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7212 int gd_x1a = gd->src_x + gd->active_xoffset;
7213 int gd_y1a = gd->src_y + gd->active_yoffset;
7214 int border_xsize = gd->border_size + gd->draw_xoffset;
7215 int border_ysize = gd->border_size;
7216 struct GadgetInfo *gi;
7217 unsigned int event_mask = GD_EVENT_RELEASED;
7218 char infotext[MAX_OUTPUT_LINESIZE + 1];
7219 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
7220 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
7222 if (textbutton_info[i].size == -1) // dynamically determine size
7223 textbutton_info[i].size = strlen(textbutton_info[i].text);
7225 sprintf(infotext, "%s", textbutton_info[i].infotext);
7226 infotext[max_infotext_len] = '\0';
7228 // determine horizontal position to the right of specified gadget
7229 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7231 int gadget_id_align = textbutton_info[i].gadget_id_align;
7233 x = right_gadget_border[gadget_id_align] + gadget_distance;
7235 if (textbutton_info[i].y == -1)
7236 y = level_editor_gadget[gadget_id_align]->y;
7239 // determine horizontal offset for leading text
7240 if (textbutton_info[i].text_left != NULL)
7241 x += getTextWidthForGadget(textbutton_info[i].text_left);
7243 gi = CreateGadget(GDI_CUSTOM_ID, id,
7244 GDI_CUSTOM_TYPE_ID, i,
7245 GDI_IMAGE_ID, graphic,
7246 GDI_INFO_TEXT, infotext,
7249 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
7250 GDI_TEXT_VALUE, textbutton_info[i].text,
7251 GDI_TEXT_SIZE, textbutton_info[i].size,
7252 GDI_TEXT_FONT, FONT_INPUT_2,
7253 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
7254 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7255 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7256 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7257 GDI_BORDER_SIZE, border_xsize, border_ysize,
7258 GDI_DESIGN_WIDTH, gd->width,
7259 GDI_DECORATION_SHIFTING, 1, 1,
7260 GDI_EVENT_MASK, event_mask,
7261 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7262 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7266 Fail("cannot create gadget");
7268 level_editor_gadget[id] = gi;
7269 right_gadget_border[id] =
7270 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7274 static void CreateGraphicbuttonGadgets(void)
7276 struct GadgetInfo *gi;
7279 // create buttons for scrolling of drawing area and element list
7280 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7282 int id = graphicbutton_info[i].gadget_id;
7283 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7284 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7285 int graphic = graphicbutton_info[i].graphic;
7286 struct GraphicInfo *gd = &graphic_info[graphic];
7287 int gd_x1 = gd->src_x;
7288 int gd_y1 = gd->src_y;
7289 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7290 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7291 unsigned int event_mask = GD_EVENT_RELEASED;
7293 // determine horizontal position to the right of specified gadget
7294 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7295 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7296 ED_GADGET_TEXT_DISTANCE);
7298 // determine horizontal offset for leading text
7299 if (graphicbutton_info[i].text_left != NULL)
7300 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7302 gi = CreateGadget(GDI_CUSTOM_ID, id,
7303 GDI_CUSTOM_TYPE_ID, i,
7304 GDI_IMAGE_ID, graphic,
7305 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7308 GDI_WIDTH, gd->width,
7309 GDI_HEIGHT, gd->height,
7310 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7311 GDI_STATE, GD_BUTTON_UNPRESSED,
7312 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7313 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7314 GDI_EVENT_MASK, event_mask,
7315 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7316 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7320 Fail("cannot create gadget");
7322 level_editor_gadget[id] = gi;
7323 right_gadget_border[id] =
7324 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7328 static void CreateScrollbarGadgets(void)
7332 // these values are not constant, but can change at runtime
7333 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7334 SX + ED_SCROLL_HORIZONTAL_XPOS;
7335 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7336 SY + ED_SCROLL_HORIZONTAL_YPOS;
7337 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7338 ED_SCROLL_HORIZONTAL_XSIZE;
7339 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7340 ED_SCROLL_HORIZONTAL_YSIZE;
7341 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7342 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7343 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7344 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7346 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7347 SX + ED_SCROLL_VERTICAL_XPOS;
7348 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7349 SY + ED_SCROLL_VERTICAL_YPOS;
7350 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7351 ED_SCROLL_VERTICAL_XSIZE;
7352 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7353 ED_SCROLL_VERTICAL_YSIZE;
7354 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7355 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7356 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7357 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7359 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7360 PX + ED_SCROLL2_VERTICAL_XPOS;
7361 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7362 PY + ED_SCROLL2_VERTICAL_YPOS;
7363 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7364 ED_SCROLL2_VERTICAL_XSIZE;
7365 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7366 ED_SCROLL2_VERTICAL_YSIZE;
7367 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7368 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7369 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7370 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7372 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7374 int id = scrollbar_info[i].gadget_id;
7375 int graphic = scrollbar_info[i].graphic;
7376 struct GraphicInfo *gd = &graphic_info[graphic];
7377 int gd_x1 = gd->src_x;
7378 int gd_y1 = gd->src_y;
7379 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7380 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7381 struct GadgetInfo *gi;
7382 int items_max, items_visible, item_position;
7383 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7385 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7387 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7388 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7389 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7391 else // drawing area scrollbars
7393 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7395 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7396 items_visible = ed_fieldx;
7401 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7402 items_visible = ed_fieldy;
7407 gi = CreateGadget(GDI_CUSTOM_ID, id,
7408 GDI_CUSTOM_TYPE_ID, i,
7409 GDI_IMAGE_ID, graphic,
7410 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7411 GDI_X, scrollbar_pos[i].x,
7412 GDI_Y, scrollbar_pos[i].y,
7413 GDI_WIDTH, scrollbar_pos[i].width,
7414 GDI_HEIGHT, scrollbar_pos[i].height,
7415 GDI_TYPE, scrollbar_info[i].type,
7416 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7417 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7418 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7419 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7420 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7421 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7422 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7423 GDI_STATE, GD_BUTTON_UNPRESSED,
7424 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7425 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7426 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7427 GDI_EVENT_MASK, event_mask,
7428 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7429 GDI_CALLBACK_ACTION, HandleControlButtons,
7433 Fail("cannot create gadget");
7435 level_editor_gadget[id] = gi;
7439 static void CreateCheckbuttonGadgets(void)
7441 struct GadgetInfo *gi;
7444 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7446 int id = checkbutton_info[i].gadget_id;
7447 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7448 IMG_EDITOR_CHECKBOX);
7449 struct GraphicInfo *gd = &graphic_info[graphic];
7450 int gd_x1 = gd->src_x;
7451 int gd_y1 = gd->src_y;
7452 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7453 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7454 int gd_x1a = gd->src_x + gd->active_xoffset;
7455 int gd_y1a = gd->src_y + gd->active_yoffset;
7456 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7457 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7458 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7459 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7460 unsigned int event_mask = GD_EVENT_PRESSED;
7462 // determine horizontal position to the right of specified gadget
7463 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7464 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7465 ED_GADGET_TEXT_DISTANCE);
7467 // determine horizontal offset for leading text
7468 if (checkbutton_info[i].text_left != NULL)
7469 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7471 gi = CreateGadget(GDI_CUSTOM_ID, id,
7472 GDI_CUSTOM_TYPE_ID, i,
7473 GDI_IMAGE_ID, graphic,
7474 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7477 GDI_WIDTH, gd->width,
7478 GDI_HEIGHT, gd->height,
7479 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7480 GDI_CHECKED, *checkbutton_info[i].value,
7481 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7482 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7483 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7484 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7485 GDI_EVENT_MASK, event_mask,
7486 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7487 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7491 Fail("cannot create gadget");
7493 level_editor_gadget[id] = gi;
7494 right_gadget_border[id] =
7495 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7499 static void CreateRadiobuttonGadgets(void)
7501 int graphic = IMG_EDITOR_RADIOBUTTON;
7502 struct GraphicInfo *gd = &graphic_info[graphic];
7503 int gd_x1 = gd->src_x;
7504 int gd_y1 = gd->src_y;
7505 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7506 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7507 int gd_x1a = gd->src_x + gd->active_xoffset;
7508 int gd_y1a = gd->src_y + gd->active_yoffset;
7509 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7510 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7511 struct GadgetInfo *gi;
7514 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7516 int id = radiobutton_info[i].gadget_id;
7517 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7518 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7519 unsigned int event_mask = GD_EVENT_PRESSED;
7522 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7524 // determine horizontal position to the right of specified gadget
7525 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7526 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7527 ED_GADGET_TEXT_DISTANCE);
7529 // determine horizontal offset for leading text
7530 if (radiobutton_info[i].text_left != NULL)
7531 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7533 gi = CreateGadget(GDI_CUSTOM_ID, id,
7534 GDI_CUSTOM_TYPE_ID, i,
7535 GDI_IMAGE_ID, graphic,
7536 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7539 GDI_WIDTH, gd->width,
7540 GDI_HEIGHT, gd->height,
7541 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7542 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7543 GDI_CHECKED, checked,
7544 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7545 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7546 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7547 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7548 GDI_EVENT_MASK, event_mask,
7549 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7550 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7554 Fail("cannot create gadget");
7556 level_editor_gadget[id] = gi;
7557 right_gadget_border[id] =
7558 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7562 void CreateLevelEditorGadgets(void)
7564 // force EDITOR font inside level editor
7565 SetFontStatus(GAME_MODE_EDITOR);
7567 // these values are not constant, but can change at runtime
7568 ed_fieldx = MAX_ED_FIELDX - 1;
7569 ed_fieldy = MAX_ED_FIELDY - 1;
7571 num_editor_gadgets = NUM_EDITOR_GADGETS;
7573 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7575 level_editor_gadget =
7576 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7577 right_gadget_border =
7578 checked_calloc(num_editor_gadgets * sizeof(int));
7580 // set number of empty (padding) element buttons to maximum number of buttons
7581 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7583 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7584 editor_el_empty_ptr = editor_el_empty;
7586 use_permanent_palette = !editor.palette.show_as_separate_screen;
7588 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
7590 ReinitializeElementList();
7592 CreateControlButtons();
7593 CreateScrollbarGadgets();
7595 // order of function calls is important because of cross-references
7596 CreateCheckbuttonGadgets();
7597 CreateCounterButtons();
7598 CreateRadiobuttonGadgets();
7599 CreateTextInputGadgets();
7600 CreateTextAreaGadgets();
7601 CreateSelectboxGadgets();
7602 CreateGraphicbuttonGadgets();
7603 CreateTextbuttonGadgets();
7604 CreateDrawingAreas();
7609 void FreeLevelEditorGadgets(void)
7613 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
7615 for (i = 0; i < num_editor_gadgets; i++)
7617 FreeGadget(level_editor_gadget[i]);
7619 level_editor_gadget[i] = NULL;
7622 checked_free(level_editor_gadget);
7623 checked_free(right_gadget_border);
7625 checked_free(editor_el_empty);
7628 static void MapCounterButtons(int id)
7630 int font_nr = FONT_TEXT_1;
7631 int font_height = getFontHeight(font_nr);
7632 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7633 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7634 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7635 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7636 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7637 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7638 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7639 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7640 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7641 int yoffset = (gi_down->height - font_height) / 2;
7642 int x_left = gi_down->x - xoffset_left;
7643 int x_right; // set after gadget position was modified
7644 int y_above = gi_down->y - yoffset_above;
7646 int y; // set after gadget position was modified
7648 // counter limits must be changed first to prevent value truncation
7649 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7650 counterbutton_info[id].max_value);
7652 // right text position might have changed after setting position above
7653 x_right = gi_up->x + gi_up->width + xoffset_right;
7655 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7657 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
7658 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7659 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7661 ModifyGadget(gi_down, GDI_Y,
7662 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7663 ModifyGadget(gi_text, GDI_Y,
7664 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7665 ModifyGadget(gi_up, GDI_Y,
7666 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7669 // vertical position might have changed after setting position above
7670 y = gi_up->y + yoffset;
7672 if (counterbutton_info[id].text_above)
7673 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
7675 if (counterbutton_info[id].text_left)
7676 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7678 if (counterbutton_info[id].text_right)
7679 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7686 static void MapControlButtons(void)
7691 // map toolbox buttons (excluding special CE toolbox buttons)
7692 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7693 MapGadget(level_editor_gadget[i]);
7695 // map toolbox buttons (element properties buttons)
7696 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
7697 MapGadget(level_editor_gadget[i]);
7699 if (use_permanent_palette)
7701 // map buttons to select elements
7702 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7703 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
7704 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
7705 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
7706 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
7709 // map buttons to select level
7710 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
7711 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
7712 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
7713 MapCounterButtons(counter_id);
7716 static void MapDrawingArea(int id)
7718 int font_nr = FONT_TEXT_1;
7719 int font_height = getFontHeight(font_nr);
7720 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7721 int area_xsize = gi->drawing.area_xsize;
7722 int area_ysize = gi->drawing.area_ysize;
7723 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7724 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
7725 int x_left = gi->x - xoffset_left;
7726 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
7727 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
7728 int x_below = gi->x + (gi->width - xoffset_below) / 2;
7729 int y_side = gi->y + (gi->height - font_height) / 2;
7730 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
7731 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
7733 if (drawingarea_info[id].text_left)
7734 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
7736 if (drawingarea_info[id].text_right)
7737 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
7739 if (drawingarea_info[id].text_above)
7740 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
7742 if (drawingarea_info[id].text_below)
7743 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
7745 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
7747 DrawElementBorder(gi->x, gi->y,
7748 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
7749 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
7751 DrawDrawingArea(id);
7757 static void MapTextInputGadget(int id)
7759 int font_nr = FONT_TEXT_1;
7760 int font_height = getFontHeight(font_nr);
7761 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
7762 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7763 int x_above = ED_SETTINGS_X(textinput_info[id].x);
7764 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
7766 if (textinput_info[id].text_above)
7767 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
7769 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
7774 static void MapTextAreaGadget(int id)
7776 int font_nr = FONT_TEXT_1;
7777 int font_height = getFontHeight(font_nr);
7778 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7779 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7780 int x_above = ED_SETTINGS_X(textarea_info[id].x);
7781 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
7782 char *text_above = textarea_info[id].text_above;
7784 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
7785 text_above = textarea_info[id].text_above_cropped;
7788 DrawTextS(x_above, y_above, font_nr, text_above);
7790 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
7795 static void MapSelectboxGadget(int id)
7797 int font_nr = FONT_TEXT_1;
7798 int font_height = getFontHeight(font_nr);
7799 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
7800 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
7801 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7802 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7803 int yoffset = (gi->height - font_height) / 2;
7804 int x_left = gi->x - xoffset_left;
7805 int x_right = gi->x + gi->width + xoffset_right;
7806 int y_above = gi->y - yoffset_above;
7808 int y = gi->y + yoffset;
7810 if (selectbox_info[id].text_above)
7811 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
7813 if (selectbox_info[id].text_left)
7814 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
7816 if (selectbox_info[id].text_right)
7817 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
7819 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
7824 static void MapTextbuttonGadget(int id)
7826 int font_nr = FONT_TEXT_1;
7827 int font_height = getFontHeight(font_nr);
7828 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
7829 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
7830 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7831 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7832 int yoffset = (gi->height - font_height) / 2;
7833 int x_left = gi->x - xoffset_left;
7834 int x_right = gi->x + gi->width + xoffset_right;
7835 int y_above = gi->y - yoffset_above;
7837 int y = gi->y + yoffset;
7839 // only show button to delete change pages when more than minimum pages
7840 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
7841 custom_element.num_change_pages == MIN_CHANGE_PAGES)
7844 if (textbutton_info[id].text_above)
7845 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
7847 if (textbutton_info[id].text_left)
7848 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
7850 if (textbutton_info[id].text_right)
7851 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
7856 static void MapGraphicbuttonGadget(int id)
7858 int font_nr = FONT_TEXT_1;
7859 int font_height = getFontHeight(font_nr);
7860 struct GadgetInfo *gi = level_editor_gadget[graphicbutton_info[id].gadget_id];
7861 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
7862 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7863 int yoffset = (gi->height - font_height) / 2;
7864 int x_left = gi->x - xoffset_left;
7865 int x_right = gi->x + gi->width + xoffset_right;
7866 int y = gi->y + yoffset;
7868 if (graphicbutton_info[id].text_left)
7869 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
7871 if (graphicbutton_info[id].text_right)
7872 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
7877 static void MapRadiobuttonGadget(int id)
7879 int font_nr = FONT_TEXT_1;
7880 int font_height = getFontHeight(font_nr);
7881 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
7882 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7883 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7884 int yoffset = (gi->height - font_height) / 2;
7885 int x_left = gi->x - xoffset_left;
7886 int x_right = gi->x + gi->width + xoffset_right;
7887 int y = gi->y + yoffset;
7889 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
7891 if (radiobutton_info[id].text_left)
7892 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
7894 if (radiobutton_info[id].text_right)
7895 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
7897 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
7902 static void MapCheckbuttonGadget(int id)
7904 int font_nr = FONT_TEXT_1;
7905 int font_height = getFontHeight(font_nr);
7906 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
7907 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7908 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7909 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7910 int yoffset = (gi->height - font_height) / 2;
7911 int y_above = gi->y - yoffset_above;
7913 int x_left, x_right, y; // set after gadget position was modified
7915 // set position for gadgets with dynamically determined position
7916 if (checkbutton_info[id].x != -1) // do not change dynamic positions
7917 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x), GDI_END);
7918 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
7920 x_left = gi->x - xoffset_left;
7921 x_right = gi->x + gi->width + xoffset_right;
7922 y = gi->y + yoffset;
7924 if (checkbutton_info[id].text_above)
7925 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
7927 if (checkbutton_info[id].text_left)
7928 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
7930 if (checkbutton_info[id].text_right)
7931 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
7933 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
7938 static void MapMainDrawingArea(void)
7940 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
7941 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
7944 if (suppressBorderElement())
7946 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
7947 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
7950 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
7952 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
7953 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
7954 no_horizontal_scrollbar) ||
7955 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
7956 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
7957 no_vertical_scrollbar))
7960 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
7963 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
7965 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
7966 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
7969 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
7972 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
7975 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
7979 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
7981 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
7982 i == GADGET_ID_CUSTOM_COPY_TO ||
7983 i == GADGET_ID_CUSTOM_EXCHANGE ||
7984 i == GADGET_ID_CUSTOM_COPY ||
7985 i == GADGET_ID_CUSTOM_PASTE)
7988 MapGadget(level_editor_gadget[i]);
7990 UnmapGadget(level_editor_gadget[i]);
7995 static void MapLevelEditorToolboxCustomGadgets(void)
7997 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
8000 static void MapLevelEditorToolboxCustomGadgetsIfNeeded(void)
8002 if (IS_CUSTOM_ELEMENT(properties_element) ||
8003 IS_GROUP_ELEMENT(properties_element) ||
8004 IS_EMPTY_ELEMENT(properties_element))
8005 MapLevelEditorToolboxCustomGadgets();
8008 static void UnmapLevelEditorToolboxCustomGadgets(void)
8010 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
8013 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
8017 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
8019 if (i != GADGET_ID_SINGLE_ITEMS &&
8020 i != GADGET_ID_PICK_ELEMENT)
8022 struct GadgetInfo *gi = level_editor_gadget[i];
8030 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
8031 struct GraphicInfo *gd = &graphic_info[graphic];
8035 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
8036 gi->width, gi->height, gi->x, gi->y);
8038 redraw_mask |= REDRAW_DOOR_3;
8044 static void MapLevelEditorToolboxDrawingGadgets(void)
8046 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
8049 static void UnmapLevelEditorToolboxDrawingGadgets(void)
8051 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
8054 static void UnmapDrawingArea(int id)
8056 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
8059 static void UnmapLevelEditorFieldGadgets(void)
8063 for (i = 0; i < num_editor_gadgets; i++)
8064 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
8065 level_editor_gadget[i]->y))
8066 UnmapGadget(level_editor_gadget[i]);
8069 void UnmapLevelEditorGadgets(void)
8073 for (i = 0; i < num_editor_gadgets; i++)
8074 UnmapGadget(level_editor_gadget[i]);
8077 static void ResetUndoBuffer(void)
8079 undo_buffer_position = -1;
8080 undo_buffer_steps = -1;
8081 redo_buffer_steps = 0;
8083 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
8085 level.changed = FALSE;
8088 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
8090 if (remap_toolbox_gadgets)
8092 ModifyEditorElementList();
8093 RedrawDrawingElements();
8096 if (edit_mode == ED_MODE_LEVELCONFIG)
8097 DrawLevelConfigWindow();
8098 else if (edit_mode == ED_MODE_PROPERTIES)
8099 DrawPropertiesWindow();
8100 else if (edit_mode == ED_MODE_PALETTE)
8101 DrawPaletteWindow();
8102 else // edit_mode == ED_MODE_DRAWING
8103 DrawDrawingWindowExt(remap_toolbox_gadgets);
8106 static void DrawEditModeWindow(void)
8108 DrawEditModeWindowExt(TRUE);
8111 static void DrawEditModeWindow_PlayfieldOnly(void)
8113 DrawEditModeWindowExt(FALSE);
8116 static void ChangeEditModeWindow(int new_edit_mode)
8118 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
8120 DrawEditModeWindow();
8123 static boolean LevelChanged(void)
8125 boolean field_changed = FALSE;
8128 for (y = 0; y < lev_fieldy; y++)
8129 for (x = 0; x < lev_fieldx; x++)
8130 if (Tile[x][y] != level.field[x][y])
8131 field_changed = TRUE;
8133 return (level.changed || field_changed);
8136 static boolean PrepareSavingIntoPersonalLevelSet(void)
8138 static LevelDirTree *last_copied_leveldir = NULL;
8139 static LevelDirTree *last_written_leveldir = NULL;
8140 static int last_copied_level_nr = -1;
8141 static int last_written_level_nr = -1;
8142 LevelDirTree *leveldir_former = leveldir_current;
8143 int level_nr_former = level_nr;
8146 // remember last mod/save so that for current session, we write
8147 // back to the same personal copy, asking only about overwrite.
8148 if (leveldir_current == last_copied_leveldir &&
8149 level_nr == last_copied_level_nr)
8151 // "cd" to personal level set dir (as used when writing last copy)
8152 leveldir_current = last_written_leveldir;
8153 level_nr = last_written_level_nr;
8158 if (!Request("This level is read-only! "
8159 "Save into personal level set?", REQ_ASK))
8162 // "cd" to personal level set dir (for writing copy the first time)
8164 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
8166 // this may happen if "setup.internal.create_user_levelset" is FALSE
8167 // or if file "levelinfo.conf" is missing in personal user level set
8168 if (leveldir_current == NULL)
8170 Request("Cannot find personal level set?!", REQ_CONFIRM);
8172 leveldir_current = leveldir_former;
8177 // find unused level number
8178 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
8180 static char *level_filename = NULL;
8182 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
8184 if (!fileExists(level_filename))
8188 last_copied_leveldir = leveldir_former;
8189 last_copied_level_nr = level_nr_former;
8191 last_written_leveldir = leveldir_current;
8192 last_written_level_nr = level_nr = new_level_nr;
8197 static void ModifyLevelConfigForSavingIntoPersonalLevelSet(char *former_name)
8199 static char *filename_levelinfo = NULL, *mod_name = NULL;
8202 // annotate this copy-and-mod in personal levelinfo.conf
8203 setString(&filename_levelinfo,
8204 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
8206 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
8208 fprintf(file, "\n");
8209 fprintf(file, "# level %d was modified from:\n", level_nr);
8210 fprintf(file, "# - previous level set name: %s\n",
8212 fprintf(file, "# - level within previous set: %d \"%s\"\n",
8213 level.file_info.nr, level.name);
8214 fprintf(file, "# - previous author: %s\n",
8216 fprintf(file, "# - previous save date: ");
8218 if (level.creation_date.src == DATE_SRC_LEVELFILE)
8220 fprintf(file, "%04d-%02d-%02d\n",
8221 level.creation_date.year,
8222 level.creation_date.month,
8223 level.creation_date.day);
8227 fprintf(file, "not recorded\n");
8233 if (level_nr > leveldir_current->last_level)
8234 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
8236 // else: allow the save even if annotation failed
8238 // now... spray graffiti on the old level vital statistics
8239 // user can change these; just trying to set a good baseline
8241 // don't truncate names for fear of making offensive or silly:
8242 // long-named original author only recorded in levelinfo.conf.
8243 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
8244 if (!strEqual(level.author, leveldir_current->author))
8246 setString(&mod_name, getStringCat3(leveldir_current->author,
8247 " after ", level.author));
8249 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8250 setString(&mod_name,
8251 getStringCat2(leveldir_current->author, " (ed.)"));
8253 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8254 setString(&mod_name, leveldir_current->author);
8256 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
8258 // less worried about truncation here
8259 setString(&mod_name, getStringCat2("Mod: ", level.name));
8260 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
8264 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
8265 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8269 for (x = 0; x < lev_fieldx; x++)
8270 for (y = 0; y < lev_fieldy; y++)
8271 dst[x][y] = src[x][y];
8274 static int setSelectboxValue(int selectbox_id, int new_value)
8276 int new_index_value = 0;
8279 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8280 if (selectbox_info[selectbox_id].options[i].value == new_value)
8281 new_index_value = i;
8283 *selectbox_info[selectbox_id].value =
8284 selectbox_info[selectbox_id].options[new_index_value].value;
8286 return new_index_value;
8289 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8293 // change action mode and arg variables according to action type variable
8294 for (i = 0; action_arg_options[i].value != -1; i++)
8296 if (action_arg_options[i].value == custom_element_change.action_type)
8298 int mode = action_arg_options[i].mode;
8300 // only change if corresponding selectbox has changed
8301 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8302 action_arg_modes[mode])
8303 custom_element_change.action_mode = -1;
8305 // only change if corresponding selectbox has changed
8306 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8307 action_arg_options[i].options)
8308 custom_element_change.action_arg = -1;
8315 static void setSelectboxSpecialActionOptions(void)
8319 // change action mode and arg selectbox according to action type selectbox
8320 for (i = 0; action_arg_options[i].value != -1; i++)
8322 if (action_arg_options[i].value == custom_element_change.action_type)
8324 int mode = action_arg_options[i].mode;
8326 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8327 action_arg_modes[mode]);
8328 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8329 custom_element_change.action_mode);
8331 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8332 action_arg_options[i].options);
8333 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8334 custom_element_change.action_arg);
8340 static void copy_custom_element_settings(int element_from, int element_to)
8342 struct ElementInfo *ei_from = &element_info[element_from];
8343 struct ElementInfo *ei_to = &element_info[element_to];
8345 copyElementInfo(ei_from, ei_to);
8348 static void replace_custom_element_in_settings(int element_from,
8353 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8355 struct ElementInfo *ei = &element_info[i];
8357 for (y = 0; y < 3; y++)
8358 for (x = 0; x < 3; x++)
8359 if (ei->content.e[x][y] == element_from)
8360 ei->content.e[x][y] = element_to;
8362 for (j = 0; j < ei->num_change_pages; j++)
8364 struct ElementChangeInfo *change = &ei->change_page[j];
8366 if (change->target_element == element_from)
8367 change->target_element = element_to;
8369 if (change->initial_trigger_element == element_from)
8370 change->initial_trigger_element = element_to;
8372 if (change->action_element == element_from)
8373 change->action_element = element_to;
8375 for (y = 0; y < 3; y++)
8376 for (x = 0; x < 3; x++)
8377 if (change->target_content.e[x][y] == element_from)
8378 change->target_content.e[x][y] = element_to;
8381 if (ei->group != NULL) // group or internal
8382 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8383 if (ei->group->element[j] == element_from)
8384 ei->group->element[j] = element_to;
8388 static void replace_custom_element_in_playfield(int element_from,
8393 for (x = 0; x < lev_fieldx; x++)
8394 for (y = 0; y < lev_fieldy; y++)
8395 if (Tile[x][y] == element_from)
8396 Tile[x][y] = element_to;
8399 static boolean CopyCustomElement(int element_old, int element_new,
8402 int copy_mode_orig = copy_mode;
8404 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8406 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8407 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8408 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8410 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8412 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8413 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8414 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8416 level.changed = TRUE;
8418 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8420 Request("Please choose custom element!", REQ_CONFIRM);
8424 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8426 Request("Please choose group element!", REQ_CONFIRM);
8430 else if (IS_EMPTY_ELEMENT(element_old) && !IS_EMPTY_ELEMENT(element_new))
8432 Request("Please choose empty element!", REQ_CONFIRM);
8438 level.changed = TRUE;
8441 // when modifying custom/group element, ask for copying level template
8442 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8444 if (!AskToCopyAndModifyLevelTemplate())
8448 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8450 copy_custom_element_settings(element_new, element_old);
8452 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8454 copy_custom_element_settings(element_old, element_new);
8456 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8458 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8459 copy_custom_element_settings(element_new, element_old);
8460 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8462 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8463 replace_custom_element_in_settings(element_new, element_old);
8464 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8466 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8467 replace_custom_element_in_playfield(element_new, element_old);
8468 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8471 UpdateCustomElementGraphicGadgets();
8472 DrawPropertiesWindow();
8477 static void CopyCustomElementPropertiesToEditor(int element)
8480 int current_change_page = element_info[element].current_change_page;
8482 // dynamically (re)build selectbox for selecting change page
8483 for (i = 0; i < element_info[element].num_change_pages; i++)
8485 sprintf(options_change_page_strings[i], "%d", i + 1);
8487 options_change_page[i].value = i;
8488 options_change_page[i].text = options_change_page_strings[i];
8491 options_change_page[i].value = -1;
8492 options_change_page[i].text = NULL;
8494 // needed here to initialize combined element properties
8495 InitElementPropertiesEngine(level.game_version);
8497 element_info[element].change =
8498 &element_info[element].change_page[current_change_page];
8500 custom_element = element_info[element];
8501 custom_element_change = *element_info[element].change;
8503 // needed to initially set selectbox options for special action options
8504 setSelectboxSpecialActionOptions();
8506 // needed to initially set selectbox value variables to reliable defaults
8507 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8508 setSelectboxValue(i, *selectbox_info[i].value);
8510 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8511 custom_element_properties[i] = HAS_PROPERTY(element, i);
8513 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8514 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8516 // ---------- element settings: configure (custom elements) -----------------
8518 // set accessible layer selectbox help value
8519 custom_element.access_type =
8520 (IS_WALKABLE(element) ? EP_WALKABLE :
8521 IS_PASSABLE(element) ? EP_PASSABLE :
8522 custom_element.access_type);
8523 custom_element.access_layer =
8524 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8525 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8526 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8527 custom_element.access_layer);
8528 custom_element.access_protected =
8529 (IS_PROTECTED(element) ? 1 : 0);
8530 custom_element_properties[EP_ACCESSIBLE] =
8531 (IS_ACCESSIBLE_OVER(element) ||
8532 IS_ACCESSIBLE_INSIDE(element) ||
8533 IS_ACCESSIBLE_UNDER(element));
8535 // set walk-to-object action selectbox help value
8536 custom_element.walk_to_action =
8537 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8538 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8539 IS_DROPPABLE(element) ? EP_DROPPABLE :
8540 IS_THROWABLE(element) ? EP_THROWABLE :
8541 IS_PUSHABLE(element) ? EP_PUSHABLE :
8542 custom_element.walk_to_action);
8543 custom_element_properties[EP_WALK_TO_OBJECT] =
8544 (IS_DIGGABLE(element) ||
8545 IS_COLLECTIBLE_ONLY(element) ||
8546 IS_DROPPABLE(element) ||
8547 IS_THROWABLE(element) ||
8548 IS_PUSHABLE(element));
8550 // set smash targets selectbox help value
8551 custom_element.smash_targets =
8552 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8553 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8554 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8555 custom_element.smash_targets);
8556 custom_element_properties[EP_CAN_SMASH] =
8557 (CAN_SMASH_EVERYTHING(element) ||
8558 CAN_SMASH_ENEMIES(element) ||
8559 CAN_SMASH_PLAYER(element));
8561 // set deadliness selectbox help value
8562 custom_element.deadliness =
8563 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8564 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8565 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8566 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8567 custom_element.deadliness);
8568 custom_element_properties[EP_DEADLY] =
8569 (DONT_TOUCH(element) ||
8570 DONT_GET_HIT_BY(element) ||
8571 DONT_COLLIDE_WITH(element) ||
8572 DONT_RUN_INTO(element));
8574 // ---------- element settings: advanced (custom elements) ------------------
8576 // set "change by direct action" selectbox help value
8577 custom_element_change.direct_action =
8578 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
8579 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8580 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8581 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8582 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8583 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8584 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8585 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8586 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8587 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8588 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8589 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8590 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8591 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8592 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8593 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8594 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8595 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8596 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8597 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
8598 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
8599 custom_element_change.direct_action);
8601 // set "change by other element action" selectbox help value
8602 custom_element_change.other_action =
8603 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
8604 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8605 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8606 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8607 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8608 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8609 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8610 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8611 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8612 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8613 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8614 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
8615 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8616 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8617 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8618 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8619 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8620 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8621 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8622 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8623 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8624 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8625 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8626 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8627 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8628 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
8629 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
8630 custom_element_change.other_action);
8633 static void CopyGroupElementPropertiesToEditor(int element)
8635 group_element_info = *element_info[element].group;
8636 custom_element = element_info[element]; // needed for description
8639 static void CopyEmptyElementPropertiesToEditor(int element)
8641 custom_element = element_info[element];
8644 static void CopyClassicElementPropertiesToEditor(int element)
8646 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8647 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
8648 getMoveIntoAcidProperty(&level, element);
8650 if (MAYBE_DONT_COLLIDE_WITH(element))
8651 custom_element_properties[EP_DONT_COLLIDE_WITH] =
8652 getDontCollideWithProperty(&level, element);
8655 static void CopyElementPropertiesToEditor(int element)
8657 if (IS_CUSTOM_ELEMENT(element))
8658 CopyCustomElementPropertiesToEditor(element);
8659 else if (IS_GROUP_ELEMENT(element))
8660 CopyGroupElementPropertiesToEditor(element);
8661 else if (IS_EMPTY_ELEMENT(element))
8662 CopyEmptyElementPropertiesToEditor(element);
8664 CopyClassicElementPropertiesToEditor(element);
8667 static boolean AskToCopyAndModifyLevelTemplate(void)
8669 if (Request("Copy and modify settings from level template?", REQ_ASK))
8671 level.use_custom_template = FALSE;
8673 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
8674 GDI_CHECKED, FALSE, GDI_END);
8675 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
8676 GDI_CHECKED, FALSE, GDI_END);
8682 LoadLevelTemplate(-1); // this resets all element modifications ...
8684 DrawEditModeWindow(); // ... and copies them to 'custom_element'
8690 static void CopyCustomElementPropertiesToGame(int element)
8693 int access_type_and_layer;
8695 // mark that this custom element has been modified
8696 custom_element.modified_settings = TRUE;
8697 level.changed = TRUE;
8699 if (level.use_custom_template)
8700 AskToCopyAndModifyLevelTemplate();
8702 element_info[element] = custom_element;
8703 *element_info[element].change = custom_element_change;
8705 // ---------- element settings: configure (custom elements) -----------------
8707 // set accessible property from checkbox and selectbox
8708 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
8709 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
8710 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
8711 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
8712 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
8713 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
8714 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
8715 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
8716 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
8717 custom_element_properties[access_type_and_layer] =
8718 custom_element_properties[EP_ACCESSIBLE];
8719 custom_element_properties[EP_PROTECTED] =
8720 (custom_element.access_protected != 0 &&
8721 custom_element_properties[EP_ACCESSIBLE]);
8723 // set walk-to-object property from checkbox and selectbox
8724 custom_element_properties[EP_DIGGABLE] = FALSE;
8725 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
8726 custom_element_properties[EP_DROPPABLE] = FALSE;
8727 custom_element_properties[EP_THROWABLE] = FALSE;
8728 custom_element_properties[EP_PUSHABLE] = FALSE;
8729 custom_element_properties[custom_element.walk_to_action] =
8730 custom_element_properties[EP_WALK_TO_OBJECT];
8732 // set smash property from checkbox and selectbox
8733 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
8734 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
8735 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
8736 custom_element_properties[custom_element.smash_targets] =
8737 custom_element_properties[EP_CAN_SMASH];
8739 // set deadliness property from checkbox and selectbox
8740 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
8741 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
8742 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
8743 custom_element_properties[EP_DONT_TOUCH] = FALSE;
8744 custom_element_properties[custom_element.deadliness] =
8745 custom_element_properties[EP_DEADLY];
8747 // ---------- element settings: advanced (custom elements) ------------------
8749 // set player change event from checkbox and selectbox
8750 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
8751 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
8752 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
8753 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
8754 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
8755 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
8756 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
8757 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
8758 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
8759 custom_element_change_events[CE_SWITCHED] = FALSE;
8760 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
8761 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
8762 custom_element_change_events[CE_BLOCKED] = FALSE;
8763 custom_element_change_events[CE_IMPACT] = FALSE;
8764 custom_element_change_events[CE_SMASHED] = FALSE;
8765 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
8766 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
8767 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
8768 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
8769 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
8770 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
8771 custom_element_change_events[custom_element_change.direct_action] =
8772 custom_element_change_events[CE_BY_DIRECT_ACTION];
8774 // set other element action change event from checkbox and selectbox
8775 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
8776 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
8777 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
8778 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
8779 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
8780 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
8781 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
8782 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
8783 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
8784 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
8785 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
8786 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
8787 custom_element_change_events[CE_TOUCHING_X] = FALSE;
8788 custom_element_change_events[CE_HITTING_X] = FALSE;
8789 custom_element_change_events[CE_DIGGING_X] = FALSE;
8790 custom_element_change_events[CE_HIT_BY_X] = FALSE;
8791 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
8792 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
8793 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
8794 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
8795 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
8796 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
8797 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
8798 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
8799 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
8800 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
8801 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
8802 custom_element_change_events[custom_element_change.other_action] =
8803 custom_element_change_events[CE_BY_OTHER_ACTION];
8805 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8806 SET_PROPERTY(element, i, custom_element_properties[i]);
8808 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8809 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
8811 // copy change events also to special level editor variable
8812 custom_element = element_info[element];
8813 custom_element_change = *element_info[element].change;
8815 // needed here to restore runtime value "element_info[element].gfx_element"
8816 InitElementPropertiesGfxElement();
8819 static void CopyGroupElementPropertiesToGame(int element)
8821 // mark that this group element has been modified
8822 custom_element.modified_settings = TRUE;
8823 level.changed = TRUE;
8825 if (level.use_custom_template)
8826 AskToCopyAndModifyLevelTemplate();
8828 element_info[element] = custom_element;
8829 *element_info[element].group = group_element_info;
8831 // needed here to restore runtime value "element_info[element].gfx_element"
8832 InitElementPropertiesGfxElement();
8835 static void CopyEmptyElementPropertiesToGame(int element)
8837 // mark that this empty element has been modified
8838 custom_element.modified_settings = TRUE;
8839 level.changed = TRUE;
8841 if (level.use_custom_template)
8842 AskToCopyAndModifyLevelTemplate();
8844 element_info[element] = custom_element;
8846 // needed here to restore runtime value "element_info[element].gfx_element"
8847 InitElementPropertiesGfxElement();
8850 static void CopyClassicElementPropertiesToGame(int element)
8852 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8853 setMoveIntoAcidProperty(&level, element,
8854 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
8856 if (MAYBE_DONT_COLLIDE_WITH(element))
8857 setDontCollideWithProperty(&level, element,
8858 custom_element_properties[EP_DONT_COLLIDE_WITH]);
8861 static void CopyElementPropertiesToGame(int element)
8863 if (IS_CUSTOM_ELEMENT(element))
8864 CopyCustomElementPropertiesToGame(element);
8865 else if (IS_GROUP_ELEMENT(element))
8866 CopyGroupElementPropertiesToGame(element);
8867 else if (IS_EMPTY_ELEMENT(element))
8868 CopyEmptyElementPropertiesToGame(element);
8870 CopyClassicElementPropertiesToGame(element);
8874 static void CheckElementDescriptions(void)
8878 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8879 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
8880 Warn("no element description file for element '%s'", EL_NAME(i));
8884 static int getMaxEdFieldX(boolean has_scrollbar)
8886 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
8887 int sxsize = SXSIZE - scrollbar_width;
8888 int max_ed_fieldx = sxsize / ed_tilesize;
8890 return max_ed_fieldx;
8893 static int getMaxEdFieldY(boolean has_scrollbar)
8895 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
8896 INFOTEXT_YSIZE_FULL : 0);
8897 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
8898 int sysize = SYSIZE - scrollbar_height - infotext_height;
8899 int max_ed_fieldy = sysize / ed_tilesize;
8901 return max_ed_fieldy;
8904 static void InitZoomLevelSettings(int zoom_tilesize)
8906 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
8908 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
8910 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
8911 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
8913 // make sure that tile size is always a power of 2
8914 ed_tilesize = (1 << log_2(ed_tilesize));
8916 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8918 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
8919 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
8923 last_game_engine_type = level.game_engine_type;
8925 // limit zoom tilesize by upper and lower bound
8926 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
8928 // store zoom tilesize in auto setup file only if it was manually changed
8929 if (zoom_tilesize != -1)
8930 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
8932 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
8933 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
8936 static void InitDrawingElements(void)
8938 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
8940 if (level.game_engine_type == game_engine_type_last)
8943 if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
8945 new_element1 = EL_BD_WALL;
8946 new_element2 = EL_EMPTY;
8947 new_element3 = EL_BD_SAND;
8949 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
8951 new_element1 = EL_SP_CHIP_SINGLE;
8952 new_element2 = EL_EMPTY;
8953 new_element3 = EL_SP_BASE;
8955 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8957 new_element1 = EL_MM_MIRROR_START;
8958 new_element2 = EL_EMPTY;
8959 new_element3 = EL_MM_WOODEN_WALL;
8963 new_element1 = EL_WALL;
8964 new_element2 = EL_EMPTY;
8965 new_element3 = EL_SAND;
8968 game_engine_type_last = level.game_engine_type;
8971 static void InitLevelSetInfo(void)
8973 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
8974 "%s", leveldir_current->name);
8975 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
8976 "%s", leveldir_current->author);
8978 levelset_num_levels = leveldir_current->levels;
8980 levelset_use_levelset_artwork = FALSE;
8981 levelset_copy_level_template = FALSE;
8983 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
8986 static void ChangeEditorToLevelSet(char *levelset_subdir)
8988 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
8990 // the previous level set might have used custom artwork
8991 ReloadCustomArtwork(0);
8993 LoadLevelSetup_SeriesInfo();
8995 SaveLevelSetup_LastSeries();
8996 SaveLevelSetup_SeriesInfo();
9000 LoadLevel(level_nr);
9001 LoadScore(level_nr);
9006 static boolean useEditorDoorAnimation(void)
9008 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
9009 boolean door_1_viewport_unchanged =
9010 (vp_door_1->x == DX &&
9011 vp_door_1->y == DY &&
9012 vp_door_1->width == DXSIZE &&
9013 vp_door_1->height == DYSIZE);
9014 boolean door_1_contains_toolbox =
9017 EX + EXSIZE <= DX + DXSIZE &&
9018 EY + EYSIZE <= DY + DYSIZE);
9020 return (door_1_viewport_unchanged && door_1_contains_toolbox);
9023 static void DrawEditorDoorBackground(int graphic, int x, int y,
9024 int width, int height)
9026 struct GraphicInfo *g = &graphic_info[graphic];
9028 if (g->bitmap != NULL)
9029 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
9030 MIN(width, g->width), MIN(height, g->height), x, y);
9032 ClearRectangle(drawto, x, y, width, height);
9035 static void DrawEditorDoorContent(void)
9037 // needed for gadgets drawn on background (like palette scrollbar)
9038 SetDoorBackgroundImage(IMG_UNDEFINED);
9040 // copy default editor door content to main double buffer
9041 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
9044 DrawSpecialEditorDoor();
9046 // draw new control window
9047 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
9049 // draw all toolbox gadgets to editor doors
9050 MapControlButtons();
9052 // when returning from test game to properties page, redraw toolbox gadgets
9053 if (edit_mode == ED_MODE_PROPERTIES)
9055 UnmapLevelEditorToolboxDrawingGadgets();
9056 UnmapLevelEditorToolboxCustomGadgets();
9058 MapLevelEditorToolboxCustomGadgetsIfNeeded();
9061 // draw all palette gadgets to editor doors
9062 ModifyEditorElementList();
9063 RedrawDrawingElements();
9065 // copy actual editor door content to door double buffer for OpenDoor()
9066 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
9069 void DrawLevelEd(void)
9071 int fade_mask = REDRAW_FIELD;
9073 FadeSoundsAndMusic();
9076 fade_mask = REDRAW_ALL;
9080 // needed if different viewport properties defined for editor
9081 ChangeViewportPropertiesIfNeeded();
9085 InitZoomLevelSettings(-1);
9086 InitDrawingElements();
9090 CheckElementDescriptions();
9093 if (level_editor_test_game)
9095 CopyPlayfield(level.field, Tile);
9096 CopyPlayfield(TileBackup, level.field);
9098 level_editor_test_game = FALSE;
9102 edit_mode = ED_MODE_DRAWING;
9103 edit_mode_levelconfig = ED_MODE_LEVELCONFIG_LEVEL;
9104 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
9112 // redraw_mask |= REDRAW_ALL;
9114 FreeLevelEditorGadgets();
9115 CreateLevelEditorGadgets();
9117 ReinitializeElementList(); // update dynamic level element list
9118 ReinitializeElementListButtons(); // custom element may look different
9120 InitElementPropertiesGfxElement();
9124 DrawEditModeWindow_PlayfieldOnly();
9126 DrawMaskedBorder(fade_mask);
9128 // use door animation if door 1 viewport is unchanged and contains toolbox
9129 if (useEditorDoorAnimation())
9133 DrawEditorDoorContent();
9135 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
9139 DrawEditorDoorContent();
9144 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
9147 static void AdjustDrawingAreaGadgets(void)
9149 int ed_xsize = lev_fieldx + 2;
9150 int ed_ysize = lev_fieldy + 2;
9151 int max_ed_fieldx = MAX_ED_FIELDX;
9152 int max_ed_fieldy = MAX_ED_FIELDY;
9153 boolean horizontal_scrollbar_needed;
9154 boolean vertical_scrollbar_needed;
9155 int x, y, width, height;
9157 if (suppressBorderElement())
9159 ed_xsize = lev_fieldx;
9160 ed_ysize = lev_fieldy;
9163 // check if we need any scrollbars
9164 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9165 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9167 // check if we have a smaller editor field because of scrollbars
9168 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9169 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9171 // check again if we now need more scrollbars because of less space
9172 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
9173 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
9175 // check if editor field gets even smaller after adding new scrollbars
9176 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
9177 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
9179 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
9180 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
9182 x = SX + ed_fieldx * ed_tilesize;
9183 y = SY + ed_fieldy * ed_tilesize;
9185 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
9186 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
9188 // adjust drawing area gadget
9189 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
9190 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
9191 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
9194 // adjust horizontal scrollbar gadgets
9195 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
9198 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
9199 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
9202 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
9205 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
9208 // adjust vertical scrollbar gadgets
9209 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
9212 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
9214 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
9216 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
9219 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
9223 static void AdjustLevelScrollPosition(void)
9225 if (level_xpos < -1)
9227 if (level_xpos > lev_fieldx - ed_fieldx + 1)
9228 level_xpos = lev_fieldx - ed_fieldx + 1;
9229 if (lev_fieldx < ed_fieldx - 2)
9232 if (level_ypos < -1)
9234 if (level_ypos > lev_fieldy - ed_fieldy + 1)
9235 level_ypos = lev_fieldy - ed_fieldy + 1;
9236 if (lev_fieldy < ed_fieldy - 2)
9239 if (suppressBorderElement())
9246 static void AdjustEditorScrollbar(int id)
9248 struct GadgetInfo *gi = level_editor_gadget[id];
9249 int items_max, items_visible, item_position;
9251 if (id == GADGET_ID_SCROLL_HORIZONTAL)
9253 items_max = MAX(lev_fieldx + 2, ed_fieldx);
9254 items_visible = ed_fieldx;
9255 item_position = level_xpos + 1;
9259 items_max = MAX(lev_fieldy + 2, ed_fieldy);
9260 items_visible = ed_fieldy;
9261 item_position = level_ypos + 1;
9264 if (item_position > items_max - items_visible)
9265 item_position = items_max - items_visible;
9267 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9268 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9271 static void AdjustElementListScrollbar(void)
9273 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
9274 int items_max, items_visible, item_position;
9276 // correct position of element list scrollbar
9277 if (element_shift < 0)
9279 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9280 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9282 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
9283 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
9284 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
9286 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9287 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
9288 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9291 static void ModifyEditorCounterValue(int counter_id, int new_value)
9293 int *counter_value = counterbutton_info[counter_id].value;
9294 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9295 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9297 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9299 if (counter_value != NULL)
9300 *counter_value = gi->textinput.number_value;
9303 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9305 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9306 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9308 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9310 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9311 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9313 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9314 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9316 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9317 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9322 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9324 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9325 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9326 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9328 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9331 static void ModifyEditorSelectboxOptions(int selectbox_id,
9332 struct ValueTextInfo *options)
9334 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9335 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9337 selectbox_info[selectbox_id].options = options;
9339 // set index to zero -- list may be shorter now (correct later, if needed)
9340 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9341 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9344 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9346 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9347 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9349 drawingarea_info[drawingarea_id].area_xsize = xsize;
9350 drawingarea_info[drawingarea_id].area_ysize = ysize;
9352 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9355 static void ModifyEditorElementList(void)
9359 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9362 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9364 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9365 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9366 struct GadgetDesign *gd = &gi->deco.design;
9367 int element = editor_elements[element_shift + i];
9368 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9372 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9374 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9380 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9382 int graphic = el2edimg(element);
9383 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9389 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9392 static void ModifyDrawingElementButton(int element, int id)
9394 struct GadgetInfo *gi = level_editor_gadget[id];
9395 Bitmap *deco_bitmap;
9397 int tile_size = gi->deco.width;
9399 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9401 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9404 static void PickDrawingElement(int button, int element)
9409 struct XYTileSize *pos;
9411 } de, drawing_elements[] =
9413 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9414 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9415 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9418 if (button < 1 || button > 3)
9421 if (IS_MM_WALL(element))
9422 element = map_mm_wall_element(element);
9424 de = drawing_elements[button - 1];
9426 *de.new_element = element; // update global drawing element variable
9428 DrawDrawingElementGraphic(element, de.pos);
9429 ModifyDrawingElementButton(element, de.id);
9431 redraw_mask |= REDRAW_DOOR_1;
9434 static void RedrawDrawingElements(void)
9436 PickDrawingElement(1, new_element1);
9437 PickDrawingElement(2, new_element2);
9438 PickDrawingElement(3, new_element3);
9441 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9443 stick_element_properties_window = FALSE;
9445 SetMainBackgroundImage(IMG_UNDEFINED);
9448 UnmapLevelEditorFieldGadgets();
9450 AdjustDrawingAreaGadgets();
9451 AdjustLevelScrollPosition();
9452 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9453 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9455 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9457 MapMainDrawingArea();
9459 if (remap_toolbox_gadgets)
9461 UnmapLevelEditorToolboxCustomGadgets();
9462 MapLevelEditorToolboxDrawingGadgets();
9466 static void DrawDrawingWindow(void)
9468 DrawDrawingWindowExt(TRUE);
9471 static int getTabulatorBarWidth(void)
9473 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9474 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9476 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9479 static int getTabulatorBarHeight(void)
9481 return ED_TAB_BAR_HEIGHT;
9484 static Pixel getTabulatorBarColor(void)
9486 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9487 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9488 int gd_x = gd->x + gd_gi1->border.width / 2;
9489 int gd_y = gd->y + gd_gi1->height - 1;
9491 return GetPixel(gd->bitmap, gd_x, gd_y);
9494 static void DrawLevelConfigTabulatorGadgets(void)
9496 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9497 Pixel tab_color = getTabulatorBarColor();
9498 int id_first = ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST;
9499 int id_last = ED_TAB_BUTTON_ID_LEVELCONFIG_LAST;
9502 for (i = id_first; i <= id_last; i++)
9504 int gadget_id = textbutton_info[i].gadget_id;
9505 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9506 boolean active = (i != edit_mode_levelconfig);
9508 // draw background line below tabulator button
9509 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9511 // draw solid line below inactive tabulator buttons
9512 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9513 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9514 ED_GADGET_TINY_DISTANCE, tab_color);
9516 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9517 MapTextbuttonGadget(i);
9520 // draw little border line below tabulator buttons
9521 if (tab_color != BLACK_PIXEL) // black => transparent
9522 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9523 ED_GADGET_TINY_DISTANCE,
9524 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9527 static void DrawPropertiesTabulatorGadgets(void)
9529 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9530 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9531 int gd_x = gd->x + gd_gi1->border.width / 2;
9532 int gd_y = gd->y + gd_gi1->height - 1;
9533 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9534 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9535 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9538 // draw two config tabulators for player elements
9539 if (IS_PLAYER_ELEMENT(properties_element))
9540 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9542 // draw two config and one "change" tabulator for custom elements
9543 if (IS_CUSTOM_ELEMENT(properties_element))
9544 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9546 for (i = id_first; i <= id_last; i++)
9548 int gadget_id = textbutton_info[i].gadget_id;
9549 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9550 boolean active = (i != edit_mode_properties);
9552 // use "config 1" and "config 2" instead of "config" for players and CEs
9553 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9554 (IS_PLAYER_ELEMENT(properties_element) ||
9555 IS_CUSTOM_ELEMENT(properties_element)))
9558 // draw background line below tabulator button
9559 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9561 // draw solid line below inactive tabulator buttons
9562 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9563 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9564 ED_GADGET_TINY_DISTANCE, tab_color);
9566 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9567 MapTextbuttonGadget(i);
9570 // draw little border line below tabulator buttons
9571 if (tab_color != BLACK_PIXEL) // black => transparent
9572 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9573 ED_GADGET_TINY_DISTANCE,
9574 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9577 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9579 DrawText(SX + xpos, SY + ypos, text, font_nr);
9582 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9585 int font_width = getFontWidth(font_nr);
9586 int font_height = getFontHeight(font_nr);
9587 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9588 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9590 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9591 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9592 TRUE, FALSE, FALSE);
9595 static void DrawLevelConfigLevel(void)
9599 // draw counter gadgets
9600 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9601 MapCounterButtons(i);
9603 // draw checkbutton gadgets
9604 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9605 MapCheckbuttonGadget(i);
9607 // draw selectbox gadgets
9608 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9609 MapSelectboxGadget(i);
9611 // draw text input gadgets
9612 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9613 MapTextInputGadget(i);
9616 static char *getLevelSubdirFromSaveMode(int save_mode)
9618 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9619 return getNewUserLevelSubdir();
9621 return leveldir_current->subdir;
9624 static void DrawLevelConfigLevelSet_DirectoryInfo(void)
9626 char *directory_text = "Level set directory:";
9627 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9628 int font1_nr = FONT_TEXT_1;
9629 int font2_nr = FONT_TEXT_2;
9630 int font1_height = getFontHeight(font1_nr);
9631 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
9632 int x = ED_LEVEL_SETTINGS_X(0);
9633 int y = ED_LEVEL_SETTINGS_Y(6);
9635 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
9636 PrintInfoText(directory_name, font2_nr, x, y);
9639 static void DrawLevelConfigLevelSet(void)
9641 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
9642 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
9645 // draw counter gadgets
9646 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
9647 MapCounterButtons(i);
9649 // draw checkbutton gadgets
9650 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
9652 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
9653 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
9654 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
9657 MapCheckbuttonGadget(i);
9660 // draw selectbox gadgets
9661 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
9662 MapSelectboxGadget(i);
9664 // draw text input gadgets
9665 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
9666 MapTextInputGadget(i);
9668 // draw textbutton gadgets
9669 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
9672 DrawLevelConfigLevelSet_DirectoryInfo();
9675 static void DrawLevelConfigEditor(void)
9679 // draw counter gadgets
9680 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
9681 MapCounterButtons(i);
9683 // draw checkbutton gadgets
9684 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
9685 MapCheckbuttonGadget(i);
9687 // draw radiobutton gadgets
9688 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
9689 MapRadiobuttonGadget(i);
9691 // draw drawing area
9692 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
9694 // draw textbutton gadgets
9695 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
9698 static void DrawLevelConfigWindow(void)
9700 char *text = "Global Settings";
9701 int font_nr = FONT_TITLE_1;
9702 struct MenuPosInfo *pos = &editor.settings.headline;
9703 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
9704 int sy = SY + pos->y;
9706 stick_element_properties_window = FALSE;
9708 SetAutomaticNumberOfGemsNeeded();
9710 UnmapLevelEditorFieldGadgets();
9712 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9715 DrawText(sx, sy, text, font_nr);
9717 DrawLevelConfigTabulatorGadgets();
9719 if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVEL)
9720 DrawLevelConfigLevel();
9721 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVELSET)
9722 DrawLevelConfigLevelSet();
9723 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_EDITOR)
9724 DrawLevelConfigEditor();
9727 static void DrawCustomContentArea(void)
9729 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
9730 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9731 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
9732 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
9733 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
9734 int xoffset = ED_GADGET_SPACE_DISTANCE;
9736 // add distance for potential left text (without drawing area border)
9737 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
9739 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9741 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
9744 static void DrawCustomChangeContentArea(void)
9746 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
9747 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9748 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
9749 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
9750 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
9751 int xoffset = ED_GADGET_SPACE_DISTANCE;
9753 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9758 static void RemoveElementContentArea(int id, int font_height)
9760 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9762 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
9763 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
9764 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9765 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
9766 ED_GADGET_TEXT_DISTANCE + font_height);
9769 static void DrawYamYamContentAreas(void)
9771 int font_nr = FONT_TEXT_1;
9772 int font_height = getFontHeight(font_nr);
9773 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9774 int yoffset = (tilesize - font_height) / 2;
9775 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
9776 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
9779 // display counter to choose number of element content areas
9780 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
9782 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9784 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
9786 if (i < level.num_yamyam_contents)
9792 UnmapDrawingArea(id);
9794 // delete content areas in case of reducing number of them
9795 RemoveElementContentArea(id, font_height);
9799 DrawText(x, y + 0 * tilesize, "content", font_nr);
9800 DrawText(x, y + 1 * tilesize, "when", font_nr);
9801 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
9804 static void DrawMagicBallContentAreas(void)
9806 int font_nr = FONT_TEXT_1;
9807 int font_height = getFontHeight(font_nr);
9808 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9809 int yoffset = (tilesize - font_height) / 2;
9810 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
9811 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
9814 // display counter to choose number of element content areas
9815 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
9817 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9819 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
9821 if (i < level.num_ball_contents)
9827 UnmapDrawingArea(id);
9829 // delete content areas in case of reducing number of them
9830 RemoveElementContentArea(id, font_height);
9834 DrawText(x, y + 0 * tilesize, "generated", font_nr);
9835 DrawText(x, y + 1 * tilesize, "when", font_nr);
9836 DrawText(x, y + 2 * tilesize, "active", font_nr);
9839 static void DrawAndroidElementArea(void)
9841 int id = ED_DRAWING_ID_ANDROID_CONTENT;
9842 int num_elements = level.num_android_clone_elements;
9843 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9844 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9845 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9846 int xsize = MAX_ANDROID_ELEMENTS;
9849 // display counter to choose number of element areas
9850 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
9852 if (drawingarea_info[id].text_left != NULL)
9853 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9855 UnmapDrawingArea(id);
9857 ModifyEditorDrawingArea(id, num_elements, 1);
9859 // delete content areas in case of reducing number of them
9860 DrawBackground(sx, sy,
9861 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9862 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9867 static void DrawGroupElementArea(void)
9869 int id = ED_DRAWING_ID_GROUP_CONTENT;
9870 int num_elements = group_element_info.num_elements;
9871 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9872 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9873 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9874 int xsize = MAX_ELEMENTS_IN_GROUP;
9877 if (drawingarea_info[id].text_left != NULL)
9878 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9880 UnmapDrawingArea(id);
9882 ModifyEditorDrawingArea(id, num_elements, 1);
9884 // delete content areas in case of reducing number of them
9885 DrawBackground(sx, sy,
9886 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9887 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9892 static void DrawPlayerInitialInventoryArea(int element)
9894 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
9895 int player_nr = GET_PLAYER_NR(element);
9896 int num_elements = level.initial_inventory_size[player_nr];
9897 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9898 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9899 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9900 int xsize = MAX_INITIAL_INVENTORY_SIZE;
9903 // determine horizontal position to the right of specified gadget
9904 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
9905 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
9906 ED_DRAWINGAREA_TEXT_DISTANCE);
9908 // determine horizontal offset for leading text
9909 if (drawingarea_info[id].text_left != NULL)
9910 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9912 UnmapDrawingArea(id);
9914 ModifyEditorDrawingArea(id, num_elements, 1);
9916 // delete content areas in case of reducing number of them
9917 DrawBackground(sx, sy,
9918 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9919 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9924 static void DrawMMBallContentArea(void)
9926 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
9927 int num_elements = level.num_mm_ball_contents;
9928 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9929 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9930 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9931 int xsize = MAX_MM_BALL_CONTENTS;
9934 if (drawingarea_info[id].text_left != NULL)
9935 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9937 UnmapDrawingArea(id);
9939 ModifyEditorDrawingArea(id, num_elements, 1);
9941 // delete content areas in case of reducing number of them
9942 DrawBackground(sx, sy,
9943 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9944 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9949 static void DrawEnvelopeTextArea(int envelope_nr)
9951 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
9952 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
9956 DrawBackground(gi->x, gi->y,
9957 gi->textarea.crop_width, gi->textarea.crop_height);
9959 if (envelope_nr != -1)
9960 textarea_info[id].value = level.envelope[envelope_nr].text;
9962 ModifyGadget(gi, GDI_AREA_SIZE,
9963 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
9964 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
9967 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
9970 static void DrawPropertiesInfo(void)
9979 // configurable properties
9981 { EP_WALKABLE_OVER, "- player can walk over it" },
9982 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
9983 { EP_WALKABLE_UNDER, "- player can walk under it" },
9984 { EP_PASSABLE_OVER, "- player can pass over it" },
9985 { EP_PASSABLE_INSIDE, "- player can pass through it" },
9986 { EP_PASSABLE_UNDER, "- player can pass under it" },
9987 { EP_PROTECTED, "- player is protected by it" },
9989 { EP_DIGGABLE, "- can be digged away" },
9990 { EP_COLLECTIBLE, "- can be collected" },
9991 { EP_DROPPABLE, "- can be dropped after collecting" },
9992 { EP_THROWABLE, "- can be thrown after collecting" },
9993 { EP_PUSHABLE, "- can be pushed" },
9995 { EP_CAN_FALL, "- can fall" },
9996 { EP_CAN_MOVE, "- can move" },
9998 { EP_CAN_SMASH_PLAYER, "- can smash player" },
10000 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
10002 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
10004 { EP_SLIPPERY, "- slippery for falling elements" },
10005 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
10007 { EP_DONT_RUN_INTO, "- deadly when running into" },
10008 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
10009 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
10010 { EP_DONT_TOUCH, "- deadly when touching" },
10012 { EP_INDESTRUCTIBLE, "- indestructible" },
10014 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
10015 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
10016 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
10018 { EP_CAN_CHANGE, "- can change to other element" },
10020 // pre-defined properties
10021 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
10022 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
10023 { EP_SWITCHABLE, "- can be switched" },
10025 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
10030 char *filename = getElementDescriptionFilename(properties_element);
10031 char *num_elements_text = "In this level: ";
10032 char *num_similar_text = "Similar tiles: ";
10033 char *properties_text = "Standard properties: ";
10034 char *description_text = "Description:";
10035 char *no_description_text = "No description available.";
10036 char *none_text = "None";
10038 int num_elements_in_level = 0;
10039 int num_similar_in_level = 0;
10040 int num_hires_tiles_in_level = 0;
10041 int num_standard_properties = 0;
10042 int font1_nr = FONT_TEXT_1;
10043 int font2_nr = FONT_TEXT_2;
10044 int font1_width = getFontWidth(font1_nr);
10045 int font1_height = getFontHeight(font1_nr);
10046 int font2_height = getFontHeight(font2_nr);
10047 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
10048 int font2_yoffset = (font1_height - font2_height) / 2;
10049 int num_elements_text_len = strlen(num_elements_text) * font1_width;
10050 int num_similar_text_len = strlen(num_similar_text) * font1_width;
10051 int properties_text_len = strlen(properties_text) * font1_width;
10052 int xpos = ED_ELEMENT_SETTINGS_X(0);
10053 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10056 if (setup.editor.show_element_token)
10058 int font3_nr = FONT_TEXT_3;
10059 int font3_height = getFontHeight(font3_nr);
10061 DrawTextF(xpos, ypos, font3_nr,
10062 "[%s]", element_info[properties_element].token_name);
10064 ypos += 2 * font3_height;
10067 // ----- print number of elements / percentage of this element in level
10069 for (y = 0; y < lev_fieldy; y++)
10071 for (x = 0; x < lev_fieldx; x++)
10073 if (Tile[x][y] == properties_element)
10075 num_elements_in_level++;
10077 else if (IS_MM_WALL(Tile[x][y]) &&
10078 map_mm_wall_element(Tile[x][y]) == properties_element)
10080 num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
10085 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10087 DrawTextS(xpos, ypos, font1_nr, num_elements_text);
10089 if (num_hires_tiles_in_level > 0)
10090 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10091 "%d wall tiles", num_hires_tiles_in_level);
10092 else if (num_elements_in_level > 0)
10093 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10094 "%d (%.2f %%)", num_elements_in_level, percentage);
10096 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
10099 // ----- print number of similar elements / percentage of them in level
10101 for (y = 0; y < lev_fieldy; y++)
10103 for (x = 0; x < lev_fieldx; x++)
10105 if (strEqual(element_info[Tile[x][y]].class_name,
10106 element_info[properties_element].class_name))
10108 num_similar_in_level++;
10113 if (num_similar_in_level != num_elements_in_level)
10115 ypos += 1 * MAX(font1_height, font2_height);
10117 percentage = num_similar_in_level * 100.0 / (lev_fieldx * lev_fieldy);
10119 DrawTextS(xpos, ypos, font1_nr, num_similar_text);
10121 if (num_similar_in_level > 0)
10122 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10123 "%d (%.2f %%)", num_similar_in_level, percentage);
10125 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
10129 ypos += 2 * MAX(font1_height, font2_height);
10131 // ----- print standard properties of this element
10133 DrawTextS(xpos, ypos, font1_nr, properties_text);
10135 ypos += line1_height;
10137 for (i = 0; properties[i].value != -1; i++)
10139 if (!HAS_PROPERTY(properties_element, properties[i].value))
10142 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
10144 ypos += font2_height;
10146 num_standard_properties++;
10149 if (num_standard_properties == 0)
10151 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
10152 font2_nr, none_text);
10154 ypos -= (line1_height - font1_height);
10157 ypos += MAX(font1_height, font2_height);
10159 // ----- print special description of this element
10161 PrintInfoText(description_text, font1_nr, xpos, ypos);
10163 ypos += line1_height;
10165 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
10166 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
10169 #define TEXT_COLLECTING "Score for collecting"
10170 #define TEXT_SMASHING "Score for smashing"
10171 #define TEXT_SLURPING "Score for slurping robot"
10172 #define TEXT_CRACKING "Score for cracking"
10173 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
10174 #define TEXT_DURATION "Duration when activated"
10175 #define TEXT_DELAY_ON "Delay before activating"
10176 #define TEXT_DELAY_OFF "Delay before deactivating"
10177 #define TEXT_DELAY_CHANGING "Delay before changing"
10178 #define TEXT_DELAY_EXPLODING "Delay before exploding"
10179 #define TEXT_DELAY_MOVING "Delay before moving"
10180 #define TEXT_BALL_DELAY "Element generation delay"
10181 #define TEXT_MOVE_SPEED "Speed of android moving"
10182 #define TEXT_CLONE_SPEED "Speed of android cloning"
10183 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
10184 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
10185 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
10186 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
10187 #define TEXT_TIME_BONUS "Extra time to solve level"
10194 } elements_with_counter[] =
10196 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
10197 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
10198 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
10199 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
10200 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10201 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
10202 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
10203 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
10204 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
10205 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
10206 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
10207 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
10208 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10209 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10210 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
10211 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
10212 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
10213 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
10214 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
10215 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
10216 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10217 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10218 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10219 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10220 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10221 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10222 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
10223 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10224 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10225 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10226 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
10227 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10228 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10229 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
10230 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
10231 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
10232 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
10233 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
10234 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10235 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10236 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10237 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10238 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10239 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
10240 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10241 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10242 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE], TEXT_COLLECTING },
10243 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10244 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10245 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
10246 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
10247 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
10248 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10249 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10250 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10251 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10252 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10253 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10254 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10255 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10256 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
10257 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
10258 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
10259 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
10260 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
10261 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10262 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
10263 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
10264 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
10265 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10266 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10267 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10268 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10269 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10270 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10271 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10272 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10273 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10274 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10275 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10276 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10277 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10278 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
10280 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10281 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
10282 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
10283 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
10284 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
10285 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
10286 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
10287 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
10288 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
10289 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
10290 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
10291 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
10292 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
10293 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
10294 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
10295 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
10297 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
10298 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
10299 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
10300 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
10301 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
10302 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
10303 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
10304 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
10305 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
10306 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
10307 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
10308 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
10309 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_CHANGING },
10310 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10311 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10316 static boolean checkPropertiesConfig(int element)
10320 if (IS_GEM(element) ||
10321 IS_CUSTOM_ELEMENT(element) ||
10322 IS_GROUP_ELEMENT(element) ||
10323 IS_EMPTY_ELEMENT(element) ||
10324 IS_BALLOON_ELEMENT(element) ||
10325 IS_ENVELOPE(element) ||
10326 IS_MM_ENVELOPE(element) ||
10327 IS_MM_MCDUFFIN(element) ||
10328 IS_DF_LASER(element) ||
10329 IS_PLAYER_ELEMENT(element) ||
10330 HAS_EDITOR_CONTENT(element) ||
10331 CAN_GROW(element) ||
10332 COULD_MOVE_INTO_ACID(element) ||
10333 MAYBE_DONT_COLLIDE_WITH(element) ||
10334 element == EL_SOKOBAN_OBJECT ||
10335 element == EL_SOKOBAN_FIELD_EMPTY ||
10336 element == EL_SOKOBAN_FIELD_FULL)
10339 for (i = 0; elements_with_counter[i].element != -1; i++)
10340 if (elements_with_counter[i].element == element)
10346 static void SetAutomaticNumberOfGemsNeeded(void)
10350 if (!level.auto_count_gems)
10353 level.gems_needed = 0;
10355 for (x = 0; x < lev_fieldx; x++)
10357 for (y = 0; y < lev_fieldy; y++)
10359 int element = Tile[x][y];
10364 case EL_EMERALD_YELLOW:
10365 case EL_EMERALD_RED:
10366 case EL_EMERALD_PURPLE:
10367 case EL_BD_DIAMOND:
10368 case EL_WALL_EMERALD:
10369 case EL_WALL_EMERALD_YELLOW:
10370 case EL_WALL_EMERALD_RED:
10371 case EL_WALL_EMERALD_PURPLE:
10372 case EL_WALL_BD_DIAMOND:
10374 case EL_SP_INFOTRON:
10377 level.gems_needed++;
10381 case EL_WALL_DIAMOND:
10382 level.gems_needed += 3;
10386 case EL_WALL_PEARL:
10387 level.gems_needed += 5;
10391 case EL_WALL_CRYSTAL:
10392 level.gems_needed += 8;
10401 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10404 static void DrawPropertiesConfig(void)
10406 boolean draw_footer_line = FALSE;
10407 int max_num_element_counters = 4;
10408 int num_element_counters = 0;
10411 if (!checkPropertiesConfig(properties_element))
10413 int xpos = ED_ELEMENT_SETTINGS_X(0);
10414 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10416 PrintInfoText("No configuration options available.",
10417 FONT_TEXT_1, xpos, ypos);
10422 // check if there are elements where a value can be chosen for
10423 for (i = 0; elements_with_counter[i].element != -1; i++)
10425 if (elements_with_counter[i].element == properties_element)
10427 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10429 counterbutton_info[counter_id].y =
10430 ED_ELEMENT_SETTINGS_YPOS(
10431 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10432 (CAN_GROW(properties_element) ? 1 : 0) +
10433 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10434 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10435 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10436 num_element_counters);
10438 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10439 counterbutton_info[counter_id].text_right = elements_with_counter[i].text;
10441 if (properties_element == EL_GAME_OF_LIFE ||
10442 properties_element == EL_BIOMAZE)
10444 counterbutton_info[counter_id].min_value = 0; // min neighbours
10445 counterbutton_info[counter_id].max_value = 8; // max neighbours
10449 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10450 counterbutton_info[counter_id].min_value = MIN_SCORE;
10451 counterbutton_info[counter_id].max_value = MAX_SCORE;
10454 MapCounterButtons(counter_id);
10456 num_element_counters++;
10457 if (num_element_counters >= max_num_element_counters)
10462 if (HAS_EDITOR_CONTENT(properties_element))
10464 // draw stickybutton gadget
10465 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10467 if (IS_AMOEBOID(properties_element))
10468 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10469 else if (properties_element == EL_YAMYAM ||
10470 properties_element == EL_YAMYAM_LEFT ||
10471 properties_element == EL_YAMYAM_RIGHT ||
10472 properties_element == EL_YAMYAM_UP ||
10473 properties_element == EL_YAMYAM_DOWN)
10474 DrawYamYamContentAreas();
10475 else if (properties_element == EL_EMC_MAGIC_BALL)
10477 DrawMagicBallContentAreas();
10479 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10480 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10482 else if (properties_element == EL_EMC_ANDROID)
10483 DrawAndroidElementArea();
10484 else if (properties_element == EL_MM_GRAY_BALL)
10486 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
10487 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
10488 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
10489 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EXPLODE_MM_BALL);
10491 DrawMMBallContentArea();
10495 if (IS_PLAYER_ELEMENT(properties_element))
10497 int player_nr = GET_PLAYER_NR(properties_element);
10499 // these properties can be set for every player individually
10501 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10503 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
10504 &level.start_element[player_nr];
10505 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
10506 &level.artwork_element[player_nr];
10507 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
10508 &level.explosion_element[player_nr];
10510 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10511 &level.use_start_element[player_nr];
10512 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10513 &level.use_artwork_element[player_nr];
10514 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10515 &level.use_explosion_element[player_nr];
10516 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10517 &level.initial_player_gravity[player_nr];
10519 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10520 &level.initial_player_stepsize[player_nr];
10522 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
10523 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
10524 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
10525 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
10526 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
10527 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
10528 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
10529 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
10530 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
10531 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
10532 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
10533 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
10534 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
10535 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
10536 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
10538 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
10539 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
10540 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
10542 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
10544 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10546 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
10547 &level.initial_inventory_content[player_nr][0];
10549 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
10550 &level.initial_inventory_size[player_nr];
10552 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
10553 &level.use_initial_inventory[player_nr];
10555 // draw checkbutton gadgets
10556 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
10557 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
10558 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
10560 // draw counter gadgets
10561 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
10563 // draw drawing area gadgets
10564 DrawPlayerInitialInventoryArea(properties_element);
10568 if (IS_GEM(properties_element))
10569 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
10571 if (properties_element == EL_EM_DYNAMITE)
10572 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
10574 if (COULD_MOVE_INTO_ACID(properties_element) &&
10575 !IS_PLAYER_ELEMENT(properties_element) &&
10576 (!IS_CUSTOM_ELEMENT(properties_element) ||
10577 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
10579 // set position for checkbutton for "can move into acid"
10580 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
10581 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
10582 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
10583 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
10584 IS_BALLOON_ELEMENT(properties_element) ||
10585 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10587 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
10590 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
10591 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
10593 if (properties_element == EL_SPRING ||
10594 properties_element == EL_SPRING_LEFT ||
10595 properties_element == EL_SPRING_RIGHT)
10596 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
10598 if (properties_element == EL_TIME_ORB_FULL)
10599 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
10601 if (properties_element == EL_GAME_OF_LIFE ||
10602 properties_element == EL_BIOMAZE)
10603 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
10605 if (CAN_GROW(properties_element))
10607 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
10608 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10610 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
10613 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
10614 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
10616 if (properties_element == EL_SOKOBAN_OBJECT)
10617 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
10619 if (properties_element == EL_SOKOBAN_OBJECT ||
10620 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
10621 properties_element == EL_SOKOBAN_FIELD_FULL)
10623 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
10624 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
10627 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
10630 if (IS_BALLOON_ELEMENT(properties_element))
10631 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
10633 if (IS_ENVELOPE(properties_element) ||
10634 IS_MM_ENVELOPE(properties_element))
10636 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
10637 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
10638 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
10639 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
10640 int envelope_nr = ENVELOPE_NR(properties_element);
10642 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
10643 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
10645 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
10646 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
10648 // display counter to choose size of envelope text area
10649 MapCounterButtons(counter1_id);
10650 MapCounterButtons(counter2_id);
10652 // display checkbuttons to choose auto-wrap and alignment properties
10653 MapCheckbuttonGadget(button1_id);
10654 MapCheckbuttonGadget(button2_id);
10656 DrawEnvelopeTextArea(envelope_nr);
10659 if (IS_MM_MCDUFFIN(properties_element))
10661 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
10662 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
10663 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
10666 if (IS_DF_LASER(properties_element))
10668 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
10669 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
10670 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
10673 if (IS_CUSTOM_ELEMENT(properties_element))
10675 // draw stickybutton gadget
10676 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10678 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10680 // draw checkbutton gadgets
10681 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
10682 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
10683 MapCheckbuttonGadget(i);
10685 // draw counter gadgets
10686 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
10687 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
10688 MapCounterButtons(i);
10690 // draw selectbox gadgets
10691 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
10692 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
10693 MapSelectboxGadget(i);
10695 // draw textbutton gadgets
10696 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10698 // draw text input gadgets
10699 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10701 // draw drawing area gadgets
10702 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10704 draw_footer_line = TRUE;
10706 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10708 // draw checkbutton gadgets
10709 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
10710 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
10711 MapCheckbuttonGadget(i);
10713 // draw counter gadgets
10714 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
10715 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
10716 MapCounterButtons(i);
10718 // draw selectbox gadgets
10719 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
10720 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
10721 MapSelectboxGadget(i);
10723 // draw drawing area gadgets
10724 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
10725 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
10726 DrawCustomContentArea();
10729 else if (IS_GROUP_ELEMENT(properties_element))
10731 // draw stickybutton gadget
10732 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10734 // draw checkbutton gadgets
10735 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10736 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10738 // draw counter gadgets
10739 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
10741 // draw selectbox gadgets
10742 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
10744 // draw textbutton gadgets
10745 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10747 // draw drawing area gadgets
10748 DrawGroupElementArea();
10750 // draw text input gadgets
10751 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10753 // draw drawing area gadgets
10754 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10756 draw_footer_line = TRUE;
10758 else if (IS_EMPTY_ELEMENT(properties_element))
10760 // draw stickybutton gadget
10761 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10763 // draw checkbutton gadgets
10764 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10765 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10767 // draw textbutton gadgets
10768 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10770 // draw drawing area gadgets
10771 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10773 draw_footer_line = TRUE;
10776 // draw little footer border line above CE/GE use/save template gadgets
10777 if (draw_footer_line)
10779 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
10780 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
10781 int gd_x = gd->x + gd_gi1->border.width / 2;
10782 int gd_y = gd->y + gd_gi1->height - 1;
10783 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
10785 if (tab_color != BLACK_PIXEL) // black => transparent
10786 FillRectangle(drawto,
10787 SX + ED_ELEMENT_SETTINGS_X(0),
10788 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
10790 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10794 static void DrawPropertiesChangeDrawingAreas(void)
10796 if (IS_CUSTOM_ELEMENT(properties_element))
10798 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
10799 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
10800 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
10802 DrawCustomChangeContentArea();
10805 redraw_mask |= REDRAW_FIELD;
10808 static void DrawPropertiesChange(void)
10812 // needed to initially set selectbox options for special action options
10813 setSelectboxSpecialActionOptions();
10815 // draw stickybutton gadget
10816 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10818 // draw checkbutton gadgets
10819 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
10820 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
10821 MapCheckbuttonGadget(i);
10823 // draw counter gadgets
10824 for (i = ED_COUNTER_ID_CHANGE_FIRST;
10825 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
10826 MapCounterButtons(i);
10828 // draw selectbox gadgets
10829 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
10830 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
10831 MapSelectboxGadget(i);
10833 // draw textbutton gadgets
10834 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
10835 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
10836 MapTextbuttonGadget(i);
10838 // draw graphicbutton gadgets
10839 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
10840 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
10841 MapGraphicbuttonGadget(i);
10843 // draw drawing area gadgets
10844 DrawPropertiesChangeDrawingAreas();
10847 static void DrawEditorElementAnimation(int x, int y)
10849 int graphic = el2img(properties_element);
10850 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
10851 custom_element.ce_value_fixed_initial :
10852 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
10853 custom_element.collect_score_initial : FrameCounter);
10855 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
10858 static void DrawEditorElementName(int x, int y, int font_nr)
10860 char *element_name = getElementInfoText(properties_element);
10861 int font_width = getFontWidth(font_nr);
10862 int font_height = getFontHeight(font_nr);
10863 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
10864 int max_chars_per_line = max_text_width / font_width;
10866 if (strlen(element_name) <= max_chars_per_line)
10867 DrawTextS(x, y, font_nr, element_name);
10870 char buffer[max_chars_per_line + 1];
10871 int next_pos = max_chars_per_line;
10873 strncpy(buffer, element_name, max_chars_per_line);
10874 buffer[max_chars_per_line] = '\0';
10876 if (element_name[max_chars_per_line] == ' ')
10882 for (i = max_chars_per_line - 1; i >= 0; i--)
10883 if (buffer[i] == ' ')
10886 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
10893 DrawTextS(x, y - font_height / 2, font_nr, buffer);
10895 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
10896 buffer[max_chars_per_line] = '\0';
10898 DrawTextS(x, y + font_height / 2, font_nr, buffer);
10902 static void DrawPropertiesWindow(void)
10904 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
10905 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
10906 int border_size = gd->border_size;
10907 int font_nr = FONT_TEXT_1;
10908 int font_height = getFontHeight(font_nr);
10909 int xoffset = TILEX + element_border + 3 * border_size;
10910 int yoffset = (TILEY - font_height) / 2;
10911 int x1 = editor.settings.element_graphic.x + element_border;
10912 int y1 = editor.settings.element_graphic.y + element_border;
10913 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
10914 editor.settings.element_name.x);
10915 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
10916 editor.settings.element_name.y);
10917 char *text = "Element Settings";
10918 int font2_nr = FONT_TITLE_1;
10919 struct MenuPosInfo *pos = &editor.settings.headline;
10920 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
10921 int sy = SY + pos->y;
10923 stick_element_properties_window = FALSE;
10925 // make sure that previous properties edit mode exists for this element
10926 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
10927 !IS_CUSTOM_ELEMENT(properties_element))
10928 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
10930 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
10931 !IS_PLAYER_ELEMENT(properties_element) &&
10932 !IS_CUSTOM_ELEMENT(properties_element))
10933 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
10935 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
10936 (IS_PLAYER_ELEMENT(properties_element) ||
10937 IS_CUSTOM_ELEMENT(properties_element)))
10938 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
10940 CopyElementPropertiesToEditor(properties_element);
10942 UnmapLevelEditorFieldGadgets();
10943 UnmapLevelEditorToolboxDrawingGadgets();
10944 UnmapLevelEditorToolboxCustomGadgets();
10946 MapLevelEditorToolboxCustomGadgetsIfNeeded();
10948 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10951 DrawText(sx, sy, text, font2_nr);
10953 FrameCounter = 0; // restart animation frame counter
10955 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
10956 DrawEditorElementAnimation(SX + x1, SY + y1);
10957 DrawEditorElementName(x2, y2, font_nr);
10959 DrawPropertiesTabulatorGadgets();
10961 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
10962 DrawPropertiesInfo();
10963 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
10964 DrawPropertiesChange();
10965 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
10966 DrawPropertiesConfig();
10969 static void DrawPaletteWindow(void)
10973 UnmapLevelEditorFieldGadgets();
10975 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10978 // map buttons to select elements
10979 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
10980 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
10981 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
10982 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
10983 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
10986 static void UpdateCustomElementGraphicGadgets(void)
10990 InitElementPropertiesGfxElement();
10992 ModifyEditorElementList();
10993 RedrawDrawingElements();
10995 // force redraw of all mapped drawing area gadgets
10996 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
10998 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
11005 static int getOpenDirectionFromTube(int element)
11009 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
11010 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
11011 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
11012 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
11013 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
11014 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
11015 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
11016 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
11017 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
11018 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
11019 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
11025 static int getTubeFromOpenDirection(int direction)
11029 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
11030 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
11031 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
11032 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
11033 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
11034 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
11035 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
11036 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
11037 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
11038 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
11039 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
11041 // if only one direction, fall back to simple tube with that direction
11042 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
11043 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
11044 case (MV_UP): return EL_TUBE_VERTICAL;
11045 case (MV_DOWN): return EL_TUBE_VERTICAL;
11051 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
11053 int element_new = getTubeFromOpenDirection(direction);
11055 return (element_new != EL_EMPTY ? element_new : element_old);
11058 static int getOpenDirectionFromBelt(int element)
11060 int belt_dir = getBeltDirFromBeltElement(element);
11062 return (belt_dir == MV_LEFT ? MV_RIGHT :
11063 belt_dir == MV_RIGHT ? MV_LEFT :
11064 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
11067 static int getBeltFromNrAndOpenDirection(int nr, int direction)
11069 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
11070 direction == MV_RIGHT ? MV_LEFT :
11071 direction == MV_HORIZONTAL ? MV_NONE : direction);
11073 if (direction == MV_NONE)
11076 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
11079 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
11082 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
11084 return (element_new != EL_EMPTY ? element_new : element_old);
11087 static int getOpenDirectionFromPool(int element)
11091 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
11092 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
11093 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
11094 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
11095 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
11096 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
11102 static int getPoolFromOpenDirection(int direction)
11106 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
11107 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
11108 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
11109 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
11110 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
11111 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
11117 static int getPoolFromOpenDirectionExt(int direction, int help_element)
11119 int element = getPoolFromOpenDirection(direction);
11120 int help_direction = getOpenDirectionFromPool(help_element);
11122 if (element == EL_EMPTY)
11124 int help_direction_vertical = help_direction & MV_VERTICAL;
11126 element = getPoolFromOpenDirection(direction | help_direction_vertical);
11129 if (element == EL_EMPTY)
11131 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
11133 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
11139 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
11141 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
11143 return (element_new != EL_EMPTY ? element_new : element_old);
11146 static int getOpenDirectionFromPillar(int element)
11150 case EL_EMC_WALL_1: return (MV_DOWN);
11151 case EL_EMC_WALL_2: return (MV_VERTICAL);
11152 case EL_EMC_WALL_3: return (MV_UP);
11158 static int getPillarFromOpenDirection(int direction)
11162 case (MV_DOWN): return EL_EMC_WALL_1;
11163 case (MV_VERTICAL): return EL_EMC_WALL_2;
11164 case (MV_UP): return EL_EMC_WALL_3;
11170 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
11172 int element_new = getPillarFromOpenDirection(direction);
11174 return (element_new != EL_EMPTY ? element_new : element_old);
11177 static int getOpenDirectionFromSteel2(int element)
11181 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
11182 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
11183 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
11184 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
11185 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
11186 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
11187 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
11188 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
11194 static int getSteel2FromOpenDirection(int direction)
11198 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
11199 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
11200 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
11201 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
11202 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
11203 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
11204 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
11205 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
11211 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
11213 int element_new = getSteel2FromOpenDirection(direction);
11215 return (element_new != EL_EMPTY ? element_new : element_old);
11218 static int getOpenDirectionFromChip(int element)
11222 case EL_SP_CHIP_SINGLE: return (MV_NONE);
11223 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
11224 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
11225 case EL_SP_CHIP_TOP: return (MV_DOWN);
11226 case EL_SP_CHIP_BOTTOM: return (MV_UP);
11232 static int getChipFromOpenDirection(int direction)
11236 case (MV_NONE): return EL_SP_CHIP_SINGLE;
11237 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
11238 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
11239 case (MV_UP): return EL_SP_CHIP_BOTTOM;
11240 case (MV_DOWN): return EL_SP_CHIP_TOP;
11246 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
11248 int element_new = getChipFromOpenDirection(direction);
11250 return (element_new != EL_EMPTY ? element_new : element_old);
11253 static int getClosedTube(int x, int y)
11255 struct XY *xy = xy_directions;
11256 int element_old = IntelliDrawBuffer[x][y];
11257 int direction_old = getOpenDirectionFromTube(element_old);
11258 int direction_new = MV_NONE;
11261 for (i = 0; i < NUM_DIRECTIONS; i++)
11263 int xx = x + xy[i].x;
11264 int yy = y + xy[i].y;
11265 int dir = MV_DIR_FROM_BIT(i);
11266 int dir_opposite = MV_DIR_OPPOSITE(dir);
11268 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
11269 (direction_old & dir) &&
11270 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11271 direction_new |= dir;
11274 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
11277 static int getClosedBelt(int x, int y)
11279 struct XY *xy = xy_directions;
11280 int element_old = IntelliDrawBuffer[x][y];
11281 int nr = getBeltNrFromBeltElement(element_old);
11282 int direction_old = getOpenDirectionFromBelt(element_old);
11283 int direction_new = MV_NONE;
11286 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11288 int xx = x + xy[i].x;
11289 int yy = y + xy[i].y;
11290 int dir = MV_DIR_FROM_BIT(i);
11291 int dir_opposite = MV_DIR_OPPOSITE(dir);
11293 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
11294 (direction_old & dir) &&
11295 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11296 direction_new |= dir;
11299 return getBeltFromNrAndOpenDirection(nr, direction_new);
11302 static int getClosedPool(int x, int y)
11304 struct XY *xy = xy_directions;
11305 int element_old = IntelliDrawBuffer[x][y];
11306 int direction_old = getOpenDirectionFromPool(element_old);
11307 int direction_new = MV_NONE;
11310 for (i = 0; i < NUM_DIRECTIONS; i++)
11312 int xx = x + xy[i].x;
11313 int yy = y + xy[i].y;
11314 int dir = MV_DIR_FROM_BIT(i);
11315 int dir_opposite = MV_DIR_OPPOSITE(dir);
11317 if (IN_LEV_FIELD(xx, yy) &&
11318 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
11319 (direction_old & dir) &&
11320 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11321 direction_new |= dir;
11324 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
11327 static int getClosedPillar(int x, int y)
11329 struct XY *xy = xy_directions;
11330 int element_old = IntelliDrawBuffer[x][y];
11331 int direction_old = getOpenDirectionFromPillar(element_old);
11332 int direction_new = MV_NONE;
11335 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11337 int xx = x + xy[i].x;
11338 int yy = y + xy[i].y;
11339 int dir = MV_DIR_FROM_BIT(i);
11340 int dir_opposite = MV_DIR_OPPOSITE(dir);
11342 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11343 (direction_old & dir) &&
11344 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11345 direction_new |= dir;
11348 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11351 static int getClosedSteel2(int x, int y)
11353 struct XY *xy = xy_directions;
11354 int element_old = IntelliDrawBuffer[x][y];
11355 int direction_old = getOpenDirectionFromSteel2(element_old);
11356 int direction_new = MV_NONE;
11359 for (i = 0; i < NUM_DIRECTIONS; i++)
11361 int xx = x + xy[i].x;
11362 int yy = y + xy[i].y;
11363 int dir = MV_DIR_FROM_BIT(i);
11364 int dir_opposite = MV_DIR_OPPOSITE(dir);
11366 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11367 (direction_old & dir) &&
11368 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11369 direction_new |= dir;
11372 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11375 static int getClosedChip(int x, int y)
11377 struct XY *xy = xy_directions;
11378 int element_old = IntelliDrawBuffer[x][y];
11379 int direction_old = getOpenDirectionFromChip(element_old);
11380 int direction_new = MV_NONE;
11383 for (i = 0; i < NUM_DIRECTIONS; i++)
11385 int xx = x + xy[i].x;
11386 int yy = y + xy[i].y;
11387 int dir = MV_DIR_FROM_BIT(i);
11388 int dir_opposite = MV_DIR_OPPOSITE(dir);
11390 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11391 (direction_old & dir) &&
11392 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11393 direction_new |= dir;
11396 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11399 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11400 boolean change_level)
11402 int sx = x - level_xpos;
11403 int sy = y - level_ypos;
11404 int old_element = Tile[x][y];
11405 int new_element = element;
11406 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11407 boolean draw_masked = FALSE;
11409 if (IS_MM_WALL_EDITOR(element))
11411 element = map_mm_wall_element_editor(element) | new_bitmask;
11413 if (IS_MM_WALL(old_element))
11414 element |= MM_WALL_BITS(old_element);
11417 draw_masked = TRUE;
11419 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11421 int element_changed = old_element & ~new_bitmask;
11423 if (MM_WALL_BITS(element_changed) != 0)
11424 element = element_changed;
11427 IntelliDrawBuffer[x][y] = element;
11430 Tile[x][y] = element;
11432 if (IN_ED_FIELD(sx, sy))
11434 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11435 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11436 else if (draw_masked)
11437 DrawEditorElementThruMask(sx, sy, element);
11439 DrawEditorElement(sx, sy, element);
11443 static void SetElementSimple(int x, int y, int element, boolean change_level)
11445 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11448 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11449 int x2, int y2, int *element2,
11450 int (*close_function)(int, int),
11451 boolean change_level)
11453 // set neighbour elements to newly determined connections
11454 SetElementSimple(x1, y1, *element1, change_level);
11455 SetElementSimple(x2, y2, *element2, change_level);
11457 // remove all open connections of neighbour elements
11458 *element1 = close_function(x1, y1);
11459 *element2 = close_function(x2, y2);
11461 // set neighbour elements to new, minimized connections
11462 SetElementSimple(x1, y1, *element1, change_level);
11463 SetElementSimple(x2, y2, *element2, change_level);
11466 static void SetElementIntelliDraw(int x, int y, int dx, int dy, int new_element,
11467 boolean change_level, int button)
11469 struct XY *xy = xy_directions;
11470 static int last_x = -1;
11471 static int last_y = -1;
11473 if (new_element == EL_UNDEFINED)
11481 int old_element = IntelliDrawBuffer[x][y];
11483 if (IS_TUBE(new_element))
11485 int last_element_new = EL_UNDEFINED;
11486 int direction = MV_NONE;
11489 // if old element is of same kind, keep all existing directions
11490 if (IS_TUBE(old_element))
11491 direction |= getOpenDirectionFromTube(old_element);
11493 for (i = 0; i < NUM_DIRECTIONS; i++)
11495 int xx = x + xy[i].x;
11496 int yy = y + xy[i].y;
11498 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11499 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11501 int dir = MV_DIR_FROM_BIT(i);
11502 int dir_opposite = MV_DIR_OPPOSITE(dir);
11503 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11504 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11505 int last_direction_new = last_direction_old | dir_opposite;
11507 last_element_new = getTubeFromOpenDirection(last_direction_new);
11513 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
11515 if (last_element_new != EL_UNDEFINED)
11516 MergeAndCloseNeighbourElements(x, y, &new_element,
11517 last_x, last_y, &last_element_new,
11518 getClosedTube, change_level);
11520 else if (IS_BELT(new_element))
11522 int belt_nr = getBeltNrFromBeltElement(new_element);
11523 int last_element_new = EL_UNDEFINED;
11524 int direction = MV_NONE;
11527 // if old element is of same kind, keep all existing directions
11528 if (IS_BELT(old_element))
11529 direction |= getOpenDirectionFromBelt(old_element);
11531 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11533 int xx = x + xy[i].x;
11534 int yy = y + xy[i].y;
11536 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11537 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
11539 int dir = MV_DIR_FROM_BIT(i);
11540 int dir_opposite = MV_DIR_OPPOSITE(dir);
11541 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11542 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
11543 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
11544 int last_direction_new = last_direction_old | dir_opposite;
11546 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11547 last_direction_new);
11552 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
11554 if (last_element_new != EL_UNDEFINED)
11555 MergeAndCloseNeighbourElements(x, y, &new_element,
11556 last_x, last_y, &last_element_new,
11557 getClosedBelt, change_level);
11559 else if (IS_ACID_POOL_OR_ACID(new_element))
11561 int last_element_new = EL_UNDEFINED;
11562 int direction = MV_NONE;
11565 // if old element is of same kind, keep all existing directions
11566 if (IS_ACID_POOL_OR_ACID(old_element))
11567 direction |= getOpenDirectionFromPool(old_element);
11569 for (i = 0; i < NUM_DIRECTIONS; i++)
11571 int xx = x + xy[i].x;
11572 int yy = y + xy[i].y;
11574 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11575 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
11577 int dir = MV_DIR_FROM_BIT(i);
11578 int dir_opposite = MV_DIR_OPPOSITE(dir);
11579 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11580 int last_direction_old = getOpenDirectionFromPool(last_element_old);
11581 int last_direction_new = last_direction_old | dir_opposite;
11583 last_element_new = getPoolFromOpenDirection(last_direction_new);
11589 // special corrections needed for intuitively correct acid pool drawing
11590 if (last_element_new == EL_EMPTY)
11591 last_element_new = new_element;
11592 else if (last_element_new != EL_UNDEFINED)
11593 new_element = last_element_new;
11595 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
11597 if (last_element_new != EL_UNDEFINED)
11598 MergeAndCloseNeighbourElements(x, y, &new_element,
11599 last_x, last_y, &last_element_new,
11600 getClosedPool, change_level);
11602 else if (IS_EMC_PILLAR(new_element))
11604 int last_element_new = EL_UNDEFINED;
11605 int direction = MV_NONE;
11608 // if old element is of same kind, keep all existing directions
11609 if (IS_EMC_PILLAR(old_element))
11610 direction |= getOpenDirectionFromPillar(old_element);
11612 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11614 int xx = x + xy[i].x;
11615 int yy = y + xy[i].y;
11617 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11618 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
11620 int dir = MV_DIR_FROM_BIT(i);
11621 int dir_opposite = MV_DIR_OPPOSITE(dir);
11622 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11623 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
11624 int last_direction_new = last_direction_old | dir_opposite;
11626 last_element_new = getPillarFromOpenDirection(last_direction_new);
11632 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
11634 if (last_element_new != EL_UNDEFINED)
11635 MergeAndCloseNeighbourElements(x, y, &new_element,
11636 last_x, last_y, &last_element_new,
11637 getClosedPillar, change_level);
11639 else if (IS_DC_STEELWALL_2(new_element))
11641 int last_element_new = EL_UNDEFINED;
11642 int direction = MV_NONE;
11645 // if old element is of same kind, keep all existing directions
11646 if (IS_DC_STEELWALL_2(old_element))
11647 direction |= getOpenDirectionFromSteel2(old_element);
11649 for (i = 0; i < NUM_DIRECTIONS; i++)
11651 int xx = x + xy[i].x;
11652 int yy = y + xy[i].y;
11654 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11655 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
11657 int dir = MV_DIR_FROM_BIT(i);
11658 int dir_opposite = MV_DIR_OPPOSITE(dir);
11659 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11660 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
11661 int last_direction_new = last_direction_old | dir_opposite;
11663 last_element_new = getSteel2FromOpenDirection(last_direction_new);
11669 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
11671 if (last_element_new != EL_UNDEFINED)
11672 MergeAndCloseNeighbourElements(x, y, &new_element,
11673 last_x, last_y, &last_element_new,
11674 getClosedSteel2, change_level);
11676 else if (IS_SP_CHIP(new_element))
11678 int last_element_new = EL_UNDEFINED;
11679 int direction = MV_NONE;
11682 // (do not keep existing directions, regardless of kind of old element)
11684 for (i = 0; i < NUM_DIRECTIONS; i++)
11686 int xx = x + xy[i].x;
11687 int yy = y + xy[i].y;
11689 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11690 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
11692 int dir = MV_DIR_FROM_BIT(i);
11693 int dir_opposite = MV_DIR_OPPOSITE(dir);
11694 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11695 int last_direction_old = getOpenDirectionFromChip(last_element_old);
11696 int last_direction_new = last_direction_old | dir_opposite;
11698 if (last_direction_old == MV_NONE)
11700 last_element_new = getChipFromOpenDirection(last_direction_new);
11703 else if (last_direction_old & (dir | dir_opposite))
11705 direction |= MV_DIR_OPPOSITE(last_direction_old);
11709 direction |= MV_DIR_OPPOSITE(dir);
11714 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
11716 if (last_element_new != EL_UNDEFINED)
11717 MergeAndCloseNeighbourElements(x, y, &new_element,
11718 last_x, last_y, &last_element_new,
11719 getClosedChip, change_level);
11721 else if (IS_SP_HARDWARE_BASE(new_element))
11723 int nr = GetSimpleRandom(6);
11725 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
11726 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
11727 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
11728 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
11729 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
11731 else if (new_element == EL_SP_HARDWARE_GREEN ||
11732 new_element == EL_SP_HARDWARE_BLUE ||
11733 new_element == EL_SP_HARDWARE_RED)
11735 int nr = GetSimpleRandom(3);
11737 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
11738 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
11740 else if (IS_GROUP_ELEMENT(new_element))
11742 boolean connected_drawing = FALSE;
11745 for (i = 0; i < NUM_DIRECTIONS; i++)
11747 int xx = x + xy[i].x;
11748 int yy = y + xy[i].y;
11750 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11751 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
11752 connected_drawing = TRUE;
11755 if (!connected_drawing)
11756 ResolveGroupElement(new_element);
11758 new_element = GetElementFromGroupElement(new_element);
11760 else if (IS_BELT_SWITCH(old_element))
11762 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
11763 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
11765 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
11766 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
11768 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
11772 static int swappable_elements[][2] =
11774 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
11775 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
11776 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
11777 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
11778 { EL_EMERALD, EL_WALL_EMERALD },
11779 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
11780 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
11781 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
11782 { EL_DIAMOND, EL_WALL_DIAMOND },
11783 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
11784 { EL_GATE_1, EL_GATE_1_GRAY },
11785 { EL_GATE_2, EL_GATE_2_GRAY },
11786 { EL_GATE_3, EL_GATE_3_GRAY },
11787 { EL_GATE_4, EL_GATE_4_GRAY },
11788 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
11789 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
11790 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
11791 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
11792 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
11793 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
11794 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
11795 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
11796 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
11797 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
11798 { EL_LAMP, EL_LAMP_ACTIVE },
11799 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
11800 { EL_SP_BASE, EL_SP_BUGGY_BASE },
11801 { EL_PEARL, EL_WALL_PEARL },
11802 { EL_CRYSTAL, EL_WALL_CRYSTAL },
11803 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
11804 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
11805 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
11806 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
11807 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
11808 { EL_LANDMINE, EL_DC_LANDMINE },
11809 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
11810 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
11811 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
11812 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
11813 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
11814 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
11815 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
11816 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
11817 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
11821 static int rotatable_elements_4[][4] =
11831 EL_SPACESHIP_RIGHT,
11836 EL_BD_BUTTERFLY_UP,
11837 EL_BD_BUTTERFLY_RIGHT,
11838 EL_BD_BUTTERFLY_DOWN,
11839 EL_BD_BUTTERFLY_LEFT
11843 EL_BD_FIREFLY_RIGHT,
11844 EL_BD_FIREFLY_DOWN,
11872 EL_SP_GRAVITY_PORT_UP,
11873 EL_SP_GRAVITY_PORT_RIGHT,
11874 EL_SP_GRAVITY_PORT_DOWN,
11875 EL_SP_GRAVITY_PORT_LEFT
11878 EL_SP_GRAVITY_ON_PORT_UP,
11879 EL_SP_GRAVITY_ON_PORT_RIGHT,
11880 EL_SP_GRAVITY_ON_PORT_DOWN,
11881 EL_SP_GRAVITY_ON_PORT_LEFT
11884 EL_SP_GRAVITY_OFF_PORT_UP,
11885 EL_SP_GRAVITY_OFF_PORT_RIGHT,
11886 EL_SP_GRAVITY_OFF_PORT_DOWN,
11887 EL_SP_GRAVITY_OFF_PORT_LEFT
11896 EL_BALLOON_SWITCH_UP,
11897 EL_BALLOON_SWITCH_RIGHT,
11898 EL_BALLOON_SWITCH_DOWN,
11899 EL_BALLOON_SWITCH_LEFT
11903 EL_MM_MCDUFFIN_RIGHT,
11904 EL_MM_MCDUFFIN_DOWN,
11905 EL_MM_MCDUFFIN_LEFT
11908 EL_MM_MIRROR_FIXED_1,
11909 EL_MM_MIRROR_FIXED_4,
11910 EL_MM_MIRROR_FIXED_3,
11911 EL_MM_MIRROR_FIXED_2
11914 EL_MM_STEEL_GRID_FIXED_1,
11915 EL_MM_STEEL_GRID_FIXED_4,
11916 EL_MM_STEEL_GRID_FIXED_2,
11917 EL_MM_STEEL_GRID_FIXED_3
11920 EL_MM_WOODEN_GRID_FIXED_1,
11921 EL_MM_WOODEN_GRID_FIXED_4,
11922 EL_MM_WOODEN_GRID_FIXED_2,
11923 EL_MM_WOODEN_GRID_FIXED_3
11926 EL_MM_POLARIZER_CROSS_1,
11927 EL_MM_POLARIZER_CROSS_4,
11928 EL_MM_POLARIZER_CROSS_3,
11929 EL_MM_POLARIZER_CROSS_2
11933 EL_MM_PACMAN_RIGHT,
11945 EL_DF_RECEIVER_RIGHT,
11946 EL_DF_RECEIVER_DOWN,
11947 EL_DF_RECEIVER_LEFT
11960 static int rotatable_elements_8[][8] =
11963 EL_DF_STEEL_GRID_FIXED_1,
11964 EL_DF_STEEL_GRID_FIXED_8,
11965 EL_DF_STEEL_GRID_FIXED_7,
11966 EL_DF_STEEL_GRID_FIXED_6,
11967 EL_DF_STEEL_GRID_FIXED_5,
11968 EL_DF_STEEL_GRID_FIXED_4,
11969 EL_DF_STEEL_GRID_FIXED_3,
11970 EL_DF_STEEL_GRID_FIXED_2
11973 EL_DF_WOODEN_GRID_FIXED_1,
11974 EL_DF_WOODEN_GRID_FIXED_8,
11975 EL_DF_WOODEN_GRID_FIXED_7,
11976 EL_DF_WOODEN_GRID_FIXED_6,
11977 EL_DF_WOODEN_GRID_FIXED_5,
11978 EL_DF_WOODEN_GRID_FIXED_4,
11979 EL_DF_WOODEN_GRID_FIXED_3,
11980 EL_DF_WOODEN_GRID_FIXED_2
11983 EL_DF_STEEL_GRID_ROTATING_1,
11984 EL_DF_STEEL_GRID_ROTATING_8,
11985 EL_DF_STEEL_GRID_ROTATING_7,
11986 EL_DF_STEEL_GRID_ROTATING_6,
11987 EL_DF_STEEL_GRID_ROTATING_5,
11988 EL_DF_STEEL_GRID_ROTATING_4,
11989 EL_DF_STEEL_GRID_ROTATING_3,
11990 EL_DF_STEEL_GRID_ROTATING_2
11993 EL_DF_WOODEN_GRID_ROTATING_1,
11994 EL_DF_WOODEN_GRID_ROTATING_8,
11995 EL_DF_WOODEN_GRID_ROTATING_7,
11996 EL_DF_WOODEN_GRID_ROTATING_6,
11997 EL_DF_WOODEN_GRID_ROTATING_5,
11998 EL_DF_WOODEN_GRID_ROTATING_4,
11999 EL_DF_WOODEN_GRID_ROTATING_3,
12000 EL_DF_WOODEN_GRID_ROTATING_2
12007 static int rotatable_elements_16[][16] =
12028 EL_MM_TELEPORTER_5,
12029 EL_MM_TELEPORTER_4,
12030 EL_MM_TELEPORTER_3,
12031 EL_MM_TELEPORTER_2,
12032 EL_MM_TELEPORTER_1,
12033 EL_MM_TELEPORTER_16,
12034 EL_MM_TELEPORTER_15,
12035 EL_MM_TELEPORTER_14,
12036 EL_MM_TELEPORTER_13,
12037 EL_MM_TELEPORTER_12,
12038 EL_MM_TELEPORTER_11,
12039 EL_MM_TELEPORTER_10,
12040 EL_MM_TELEPORTER_9,
12041 EL_MM_TELEPORTER_8,
12042 EL_MM_TELEPORTER_7,
12046 EL_MM_TELEPORTER_RED_5,
12047 EL_MM_TELEPORTER_RED_4,
12048 EL_MM_TELEPORTER_RED_3,
12049 EL_MM_TELEPORTER_RED_2,
12050 EL_MM_TELEPORTER_RED_1,
12051 EL_MM_TELEPORTER_RED_16,
12052 EL_MM_TELEPORTER_RED_15,
12053 EL_MM_TELEPORTER_RED_14,
12054 EL_MM_TELEPORTER_RED_13,
12055 EL_MM_TELEPORTER_RED_12,
12056 EL_MM_TELEPORTER_RED_11,
12057 EL_MM_TELEPORTER_RED_10,
12058 EL_MM_TELEPORTER_RED_9,
12059 EL_MM_TELEPORTER_RED_8,
12060 EL_MM_TELEPORTER_RED_7,
12061 EL_MM_TELEPORTER_RED_6
12064 EL_MM_TELEPORTER_YELLOW_5,
12065 EL_MM_TELEPORTER_YELLOW_4,
12066 EL_MM_TELEPORTER_YELLOW_3,
12067 EL_MM_TELEPORTER_YELLOW_2,
12068 EL_MM_TELEPORTER_YELLOW_1,
12069 EL_MM_TELEPORTER_YELLOW_16,
12070 EL_MM_TELEPORTER_YELLOW_15,
12071 EL_MM_TELEPORTER_YELLOW_14,
12072 EL_MM_TELEPORTER_YELLOW_13,
12073 EL_MM_TELEPORTER_YELLOW_12,
12074 EL_MM_TELEPORTER_YELLOW_11,
12075 EL_MM_TELEPORTER_YELLOW_10,
12076 EL_MM_TELEPORTER_YELLOW_9,
12077 EL_MM_TELEPORTER_YELLOW_8,
12078 EL_MM_TELEPORTER_YELLOW_7,
12079 EL_MM_TELEPORTER_YELLOW_6
12082 EL_MM_TELEPORTER_GREEN_5,
12083 EL_MM_TELEPORTER_GREEN_4,
12084 EL_MM_TELEPORTER_GREEN_3,
12085 EL_MM_TELEPORTER_GREEN_2,
12086 EL_MM_TELEPORTER_GREEN_1,
12087 EL_MM_TELEPORTER_GREEN_16,
12088 EL_MM_TELEPORTER_GREEN_15,
12089 EL_MM_TELEPORTER_GREEN_14,
12090 EL_MM_TELEPORTER_GREEN_13,
12091 EL_MM_TELEPORTER_GREEN_12,
12092 EL_MM_TELEPORTER_GREEN_11,
12093 EL_MM_TELEPORTER_GREEN_10,
12094 EL_MM_TELEPORTER_GREEN_9,
12095 EL_MM_TELEPORTER_GREEN_8,
12096 EL_MM_TELEPORTER_GREEN_7,
12097 EL_MM_TELEPORTER_GREEN_6
12100 EL_MM_TELEPORTER_BLUE_5,
12101 EL_MM_TELEPORTER_BLUE_4,
12102 EL_MM_TELEPORTER_BLUE_3,
12103 EL_MM_TELEPORTER_BLUE_2,
12104 EL_MM_TELEPORTER_BLUE_1,
12105 EL_MM_TELEPORTER_BLUE_16,
12106 EL_MM_TELEPORTER_BLUE_15,
12107 EL_MM_TELEPORTER_BLUE_14,
12108 EL_MM_TELEPORTER_BLUE_13,
12109 EL_MM_TELEPORTER_BLUE_12,
12110 EL_MM_TELEPORTER_BLUE_11,
12111 EL_MM_TELEPORTER_BLUE_10,
12112 EL_MM_TELEPORTER_BLUE_9,
12113 EL_MM_TELEPORTER_BLUE_8,
12114 EL_MM_TELEPORTER_BLUE_7,
12115 EL_MM_TELEPORTER_BLUE_6
12119 EL_MM_POLARIZER_16,
12120 EL_MM_POLARIZER_15,
12121 EL_MM_POLARIZER_14,
12122 EL_MM_POLARIZER_13,
12123 EL_MM_POLARIZER_12,
12124 EL_MM_POLARIZER_11,
12125 EL_MM_POLARIZER_10,
12154 EL_DF_MIRROR_ROTATING_1,
12155 EL_DF_MIRROR_ROTATING_16,
12156 EL_DF_MIRROR_ROTATING_15,
12157 EL_DF_MIRROR_ROTATING_14,
12158 EL_DF_MIRROR_ROTATING_13,
12159 EL_DF_MIRROR_ROTATING_12,
12160 EL_DF_MIRROR_ROTATING_11,
12161 EL_DF_MIRROR_ROTATING_10,
12162 EL_DF_MIRROR_ROTATING_9,
12163 EL_DF_MIRROR_ROTATING_8,
12164 EL_DF_MIRROR_ROTATING_7,
12165 EL_DF_MIRROR_ROTATING_6,
12166 EL_DF_MIRROR_ROTATING_5,
12167 EL_DF_MIRROR_ROTATING_4,
12168 EL_DF_MIRROR_ROTATING_3,
12169 EL_DF_MIRROR_ROTATING_2
12172 EL_DF_MIRROR_FIXED_1,
12173 EL_DF_MIRROR_FIXED_16,
12174 EL_DF_MIRROR_FIXED_15,
12175 EL_DF_MIRROR_FIXED_14,
12176 EL_DF_MIRROR_FIXED_13,
12177 EL_DF_MIRROR_FIXED_12,
12178 EL_DF_MIRROR_FIXED_11,
12179 EL_DF_MIRROR_FIXED_10,
12180 EL_DF_MIRROR_FIXED_9,
12181 EL_DF_MIRROR_FIXED_8,
12182 EL_DF_MIRROR_FIXED_7,
12183 EL_DF_MIRROR_FIXED_6,
12184 EL_DF_MIRROR_FIXED_5,
12185 EL_DF_MIRROR_FIXED_4,
12186 EL_DF_MIRROR_FIXED_3,
12187 EL_DF_MIRROR_FIXED_2
12196 for (i = 0; swappable_elements[i][0] != -1; i++)
12198 int element1 = swappable_elements[i][0];
12199 int element2 = swappable_elements[i][1];
12201 if (old_element == element1 || old_element == element2)
12202 new_element = (old_element == element1 ? element2 : element1);
12205 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
12207 for (j = 0; j < 4; j++)
12209 int element = rotatable_elements_4[i][j];
12211 if (old_element == element)
12212 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
12213 button == 2 ? rotatable_elements_4[i][0] :
12214 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
12219 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
12221 for (j = 0; j < 8; j++)
12223 int element = rotatable_elements_8[i][j];
12225 if (old_element == element)
12226 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
12227 button == 2 ? rotatable_elements_8[i][0] :
12228 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
12233 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
12235 for (j = 0; j < 16; j++)
12237 int element = rotatable_elements_16[i][j];
12239 if (old_element == element)
12240 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
12241 button == 2 ? rotatable_elements_16[i][0] :
12242 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
12247 if (old_element != new_element)
12249 int max_infotext_len = getMaxInfoTextLength();
12250 char infotext[MAX_OUTPUT_LINESIZE + 1];
12252 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
12253 infotext[max_infotext_len] = '\0';
12255 ClearEditorGadgetInfoText();
12257 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
12262 if (IS_MM_WALL_EDITOR(new_element))
12263 SetElementSimpleExt(x, y, dx, dy, new_element, change_level);
12265 SetElementSimple(x, y, new_element, change_level);
12271 static void ResetIntelliDraw(void)
12275 for (x = 0; x < lev_fieldx; x++)
12276 for (y = 0; y < lev_fieldy; y++)
12277 IntelliDrawBuffer[x][y] = Tile[x][y];
12279 SetElementIntelliDraw(-1, -1, -1, -1, EL_UNDEFINED, FALSE, -1);
12282 static boolean draw_mode_hires = FALSE;
12284 static boolean isHiresTileElement(int element)
12286 return (IS_MM_WALL(element) || element == EL_EMPTY);
12289 static boolean isHiresDrawElement(int element)
12291 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
12294 static int numHiresTiles(int element)
12296 if (IS_MM_WALL(element))
12297 return get_number_of_bits(MM_WALL_BITS(element));
12302 static void SetDrawModeHiRes(int element)
12305 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12306 isHiresDrawElement(element));
12309 static boolean getDrawModeHiRes(void)
12311 return draw_mode_hires;
12314 static int getLoResScreenPos(int pos)
12316 return (getDrawModeHiRes() ? pos / 2 : pos);
12319 static int getLoResScreenMod(int pos)
12321 return (getDrawModeHiRes() ? pos % 2 : 0);
12324 static void SetElementExt(int x, int y, int dx, int dy, int element,
12325 boolean change_level, int button)
12328 SetElementSimple(x, y, Tile[x][y], change_level);
12329 else if (GetKeyModState() & KMOD_Shift)
12330 SetElementIntelliDraw(x, y, dx, dy, element, change_level, button);
12332 SetElementSimpleExt(x, y, dx, dy, element, change_level);
12335 static void SetElement(int x, int y, int element)
12337 SetElementExt(x, y, 0, 0, element, TRUE, -1);
12340 static void SetElementButton(int x, int y, int dx, int dy, int element,
12343 SetElementExt(x, y, dx, dy, element, TRUE, button);
12346 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
12348 int lx = getLoResScreenPos(sx2) + level_xpos;
12349 int ly = getLoResScreenPos(sy2) + level_ypos;
12350 int dx = getLoResScreenMod(sx2);
12351 int dy = getLoResScreenMod(sy2);
12353 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
12356 static void SetLevelElementHiRes(int lx2, int ly2, int element)
12363 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
12366 static int getLevelElementHiRes(int lx2, int ly2)
12372 int element = Tile[lx][ly];
12373 unsigned int bitmask = (dx + 1) << (dy * 2);
12375 if (IS_MM_WALL(element))
12377 if (element & bitmask)
12378 return map_mm_wall_element(element);
12386 static void DrawLineElement(int x, int y, int element, boolean change_level)
12388 SetElementHiRes(x, y, element, change_level);
12391 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12392 int element, boolean change_level)
12394 int xsize = ABS(to_x - from_x);
12395 int ysize = ABS(to_y - from_y);
12396 int dx = (to_x < from_x ? -1 : +1);
12397 int dy = (to_y < from_y ? -1 : +1);
12400 if (from_y == to_y) // horizontal line
12402 for (i = 0; i <= xsize; i++)
12403 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12405 else if (from_x == to_x) // vertical line
12407 for (i = 0; i <= ysize; i++)
12408 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12410 else // diagonal line
12412 if (ysize < xsize) // a < 1
12414 float a = (float)ysize / (float)xsize;
12416 for (i = 0; i <= xsize; i++)
12419 int y = dy * (int)(a * i + 0.5);
12421 DrawLineElement(from_x + x, from_y + y, element, change_level);
12426 float a = (float)xsize / (float)ysize;
12428 for (i = 0; i <= ysize; i++)
12430 int x = dx * (int)(a * i + 0.5);
12433 DrawLineElement(from_x + x, from_y + y, element, change_level);
12439 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12440 int element, boolean change_level)
12442 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12443 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12444 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12445 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12448 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12449 int element, boolean change_level)
12454 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12456 for (y = from_y; y <= to_y; y++)
12457 DrawLine(from_x, y, to_x, y, element, change_level);
12460 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12461 int element, boolean change_level)
12463 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12464 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12465 int len_x = ABS(to_x - from_x);
12466 int len_y = ABS(to_y - from_y);
12469 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
12471 // not optimal (some points get drawn twice) but simple,
12472 // and fast enough for the few points we are drawing
12474 for (x = 0; x <= radius; x++)
12476 int sx, sy, sx2, sy2, lx, ly;
12478 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
12480 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12481 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12482 sx = getLoResScreenPos(sx2);
12483 sy = getLoResScreenPos(sy2);
12484 lx = sx + level_xpos;
12485 ly = sy + level_ypos;
12487 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12488 DrawLineElement(sx2, sy2, element, change_level);
12491 for (y = 0; y <= radius; y++)
12493 int sx, sy, sx2, sy2, lx, ly;
12495 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
12497 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12498 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12499 sx = getLoResScreenPos(sx2);
12500 sy = getLoResScreenPos(sy2);
12501 lx = sx + level_xpos;
12502 ly = sy + level_ypos;
12504 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12505 DrawLineElement(sx2, sy2, element, change_level);
12509 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
12510 int element, boolean change_level)
12512 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12513 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12515 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12518 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
12520 #if DRAW_CIRCLES_BUTTON_AVAILABLE
12521 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
12522 int element, boolean change_level)
12524 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12525 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12526 int mirror_to_x2 = from_x - (to_x2 - from_x);
12527 int mirror_to_y2 = from_y - (to_y2 - from_y);
12529 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12530 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
12531 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
12532 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element, change_level);
12536 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
12538 int from_sx, from_sy;
12542 swap_numbers(&from_x, &to_x);
12545 swap_numbers(&from_y, &to_y);
12547 from_sx = SX + from_x * ed_tilesize;
12548 from_sy = SY + from_y * ed_tilesize;
12549 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
12550 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
12552 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12553 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12554 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12555 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12557 if (from_x == to_x && from_y == to_y)
12558 MarkTileDirty(from_x/2, from_y/2);
12560 redraw_mask |= REDRAW_FIELD;
12563 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
12564 int element, boolean change_level)
12566 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
12569 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
12570 int element, boolean change_level)
12572 if (element == -1 || change_level)
12573 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
12575 DrawAreaBorder(from_x, from_y, to_x, to_y);
12578 // values for CopyBrushExt()
12579 #define CB_AREA_TO_BRUSH 0
12580 #define CB_BRUSH_TO_CURSOR 1
12581 #define CB_BRUSH_TO_LEVEL 2
12582 #define CB_DELETE_OLD_CURSOR 3
12583 #define CB_DUMP_BRUSH 4
12584 #define CB_DUMP_BRUSH_SMALL 5
12585 #define CB_CLIPBOARD_TO_BRUSH 6
12586 #define CB_BRUSH_TO_CLIPBOARD 7
12587 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
12588 #define CB_UPDATE_BRUSH_POSITION 9
12589 #define CB_FLIP_BRUSH_X 10
12590 #define CB_FLIP_BRUSH_Y 11
12591 #define CB_FLIP_BRUSH_XY 12
12593 #define MAX_CB_PART_SIZE 10
12594 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
12595 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
12596 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
12597 MAX_CB_NUM_LINES * \
12600 static int getFlippedTileExt(int map[], int element)
12604 for (i = 0; map[i] != -1; i++)
12605 if (map[i] == element)
12606 return map[i ^ 1]; // get flipped element by flipping LSB of index
12611 static int getFlippedTileX(int element)
12615 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_RIGHT,
12616 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_RIGHT,
12617 EL_BUG_LEFT, EL_BUG_RIGHT,
12618 EL_SPACESHIP_LEFT, EL_SPACESHIP_RIGHT,
12619 EL_PACMAN_LEFT, EL_PACMAN_RIGHT,
12620 EL_ARROW_LEFT, EL_ARROW_RIGHT,
12621 EL_MOLE_LEFT, EL_MOLE_RIGHT,
12622 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_RIGHT,
12623 EL_YAMYAM_LEFT, EL_YAMYAM_RIGHT,
12624 EL_SP_PORT_LEFT, EL_SP_PORT_RIGHT,
12625 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_RIGHT,
12626 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_RIGHT,
12627 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_RIGHT,
12628 EL_CONVEYOR_BELT_1_LEFT, EL_CONVEYOR_BELT_1_RIGHT,
12629 EL_CONVEYOR_BELT_2_LEFT, EL_CONVEYOR_BELT_2_RIGHT,
12630 EL_CONVEYOR_BELT_3_LEFT, EL_CONVEYOR_BELT_3_RIGHT,
12631 EL_CONVEYOR_BELT_4_LEFT, EL_CONVEYOR_BELT_4_RIGHT,
12632 EL_SPRING_LEFT, EL_SPRING_RIGHT,
12633 EL_SP_CHIP_LEFT, EL_SP_CHIP_RIGHT,
12634 EL_TUBE_VERTICAL_LEFT, EL_TUBE_VERTICAL_RIGHT,
12635 EL_TUBE_LEFT_UP, EL_TUBE_RIGHT_UP,
12636 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_DOWN,
12637 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_RIGHT,
12638 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_TOPRIGHT,
12639 EL_DC_STEELWALL_1_BOTTOMLEFT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
12640 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_TOPRIGHT_2,
12641 EL_DC_STEELWALL_1_BOTTOMLEFT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
12642 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_RIGHT,
12643 EL_ACID_POOL_TOPLEFT, EL_ACID_POOL_TOPRIGHT,
12644 EL_ACID_POOL_BOTTOMLEFT, EL_ACID_POOL_BOTTOMRIGHT,
12649 return getFlippedTileExt(map, element);
12652 static int getFlippedTileY(int element)
12656 EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY_DOWN,
12657 EL_BD_FIREFLY_UP, EL_BD_FIREFLY_DOWN,
12658 EL_BUG_UP, EL_BUG_DOWN,
12659 EL_SPACESHIP_UP, EL_SPACESHIP_DOWN,
12660 EL_PACMAN_UP, EL_PACMAN_DOWN,
12661 EL_ARROW_UP, EL_ARROW_DOWN,
12662 EL_MOLE_UP, EL_MOLE_DOWN,
12663 EL_BALLOON_SWITCH_UP, EL_BALLOON_SWITCH_DOWN,
12664 EL_YAMYAM_UP, EL_YAMYAM_DOWN,
12665 EL_SP_PORT_UP, EL_SP_PORT_DOWN,
12666 EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN,
12667 EL_SP_GRAVITY_ON_PORT_UP, EL_SP_GRAVITY_ON_PORT_DOWN,
12668 EL_SP_GRAVITY_OFF_PORT_UP, EL_SP_GRAVITY_OFF_PORT_DOWN,
12669 EL_SP_CHIP_TOP, EL_SP_CHIP_BOTTOM,
12670 EL_TUBE_HORIZONTAL_UP, EL_TUBE_HORIZONTAL_DOWN,
12671 EL_TUBE_LEFT_UP, EL_TUBE_LEFT_DOWN,
12672 EL_TUBE_RIGHT_UP, EL_TUBE_RIGHT_DOWN,
12673 EL_DC_STEELWALL_1_TOP, EL_DC_STEELWALL_1_BOTTOM,
12674 EL_DC_STEELWALL_1_TOPLEFT, EL_DC_STEELWALL_1_BOTTOMLEFT,
12675 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMRIGHT,
12676 EL_DC_STEELWALL_1_TOPLEFT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
12677 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
12678 EL_DC_STEELWALL_2_TOP, EL_DC_STEELWALL_2_BOTTOM,
12679 EL_EMC_WALL_1, EL_EMC_WALL_3,
12684 return getFlippedTileExt(map, element);
12687 static int getFlippedTileXY(int element)
12691 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_UP,
12692 EL_BD_BUTTERFLY_RIGHT, EL_BD_BUTTERFLY_DOWN,
12693 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_UP,
12694 EL_BD_FIREFLY_RIGHT, EL_BD_FIREFLY_DOWN,
12695 EL_BUG_LEFT, EL_BUG_UP,
12696 EL_BUG_RIGHT, EL_BUG_DOWN,
12697 EL_SPACESHIP_LEFT, EL_SPACESHIP_UP,
12698 EL_SPACESHIP_RIGHT, EL_SPACESHIP_DOWN,
12699 EL_PACMAN_LEFT, EL_PACMAN_UP,
12700 EL_PACMAN_RIGHT, EL_PACMAN_DOWN,
12701 EL_ARROW_LEFT, EL_ARROW_UP,
12702 EL_ARROW_RIGHT, EL_ARROW_DOWN,
12703 EL_MOLE_LEFT, EL_MOLE_UP,
12704 EL_MOLE_RIGHT, EL_MOLE_DOWN,
12705 EL_BALLOON_SWITCH_LEFT, EL_BALLOON_SWITCH_UP,
12706 EL_BALLOON_SWITCH_RIGHT, EL_BALLOON_SWITCH_DOWN,
12707 EL_YAMYAM_LEFT, EL_YAMYAM_UP,
12708 EL_YAMYAM_RIGHT, EL_YAMYAM_DOWN,
12709 EL_SP_PORT_LEFT, EL_SP_PORT_UP,
12710 EL_SP_PORT_RIGHT, EL_SP_PORT_DOWN,
12711 EL_SP_GRAVITY_PORT_LEFT, EL_SP_GRAVITY_PORT_UP,
12712 EL_SP_GRAVITY_PORT_RIGHT, EL_SP_GRAVITY_PORT_DOWN,
12713 EL_SP_GRAVITY_ON_PORT_LEFT, EL_SP_GRAVITY_ON_PORT_UP,
12714 EL_SP_GRAVITY_ON_PORT_RIGHT, EL_SP_GRAVITY_ON_PORT_DOWN,
12715 EL_SP_GRAVITY_OFF_PORT_LEFT, EL_SP_GRAVITY_OFF_PORT_UP,
12716 EL_SP_GRAVITY_OFF_PORT_RIGHT, EL_SP_GRAVITY_OFF_PORT_DOWN,
12717 EL_SP_CHIP_LEFT, EL_SP_CHIP_TOP,
12718 EL_SP_CHIP_RIGHT, EL_SP_CHIP_BOTTOM,
12719 EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL,
12720 EL_TUBE_VERTICAL_LEFT, EL_TUBE_HORIZONTAL_UP,
12721 EL_TUBE_VERTICAL_RIGHT, EL_TUBE_HORIZONTAL_DOWN,
12722 EL_TUBE_LEFT_DOWN, EL_TUBE_RIGHT_UP,
12723 EL_DC_STEELWALL_1_LEFT, EL_DC_STEELWALL_1_TOP,
12724 EL_DC_STEELWALL_1_RIGHT, EL_DC_STEELWALL_1_BOTTOM,
12725 EL_DC_STEELWALL_1_HORIZONTAL, EL_DC_STEELWALL_1_VERTICAL,
12726 EL_DC_STEELWALL_1_TOPRIGHT, EL_DC_STEELWALL_1_BOTTOMLEFT,
12727 EL_DC_STEELWALL_1_TOPRIGHT_2, EL_DC_STEELWALL_1_BOTTOMLEFT_2,
12728 EL_DC_STEELWALL_2_LEFT, EL_DC_STEELWALL_2_TOP,
12729 EL_DC_STEELWALL_2_RIGHT, EL_DC_STEELWALL_2_BOTTOM,
12730 EL_DC_STEELWALL_2_HORIZONTAL, EL_DC_STEELWALL_2_VERTICAL,
12731 EL_EXPANDABLE_WALL_HORIZONTAL, EL_EXPANDABLE_WALL_VERTICAL,
12732 EL_EXPANDABLE_STEELWALL_HORIZONTAL, EL_EXPANDABLE_STEELWALL_VERTICAL,
12737 return getFlippedTileExt(map, element);
12740 static int getFlippedTile(int element, int mode)
12742 if (IS_MM_ELEMENT(element))
12744 // get MM game element
12745 element = map_element_RND_to_MM(element);
12747 // get flipped game element
12748 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX_MM(element) :
12749 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY_MM(element) :
12750 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY_MM(element) :
12753 // get RND game element again
12754 element = map_element_MM_to_RND(element);
12758 // get flipped game element
12759 element = (mode == CB_FLIP_BRUSH_X ? getFlippedTileX(element) :
12760 mode == CB_FLIP_BRUSH_Y ? getFlippedTileY(element) :
12761 mode == CB_FLIP_BRUSH_XY ? getFlippedTileXY(element) :
12768 static void SwapFlippedTiles(short *tile1, short *tile2, int mode)
12771 short tile1_flipped = getFlippedTile(*tile1, mode);
12772 short tile2_flipped = getFlippedTile(*tile2, mode);
12775 *tile1 = tile2_flipped;
12776 *tile2 = tile1_flipped;
12779 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
12781 DrawLineElement(sx, sy, element, change_level);
12784 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
12785 int button, int mode)
12787 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12788 static int brush_width, brush_height;
12789 static int last_cursor_x = -1, last_cursor_y = -1;
12790 static boolean delete_old_brush = FALSE;
12791 int new_element = BUTTON_ELEMENT(button);
12794 if (mode == CB_DUMP_BRUSH ||
12795 mode == CB_DUMP_BRUSH_SMALL ||
12796 mode == CB_BRUSH_TO_CLIPBOARD ||
12797 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12799 if (edit_mode != ED_MODE_DRAWING)
12802 char part[MAX_CB_PART_SIZE + 1] = "";
12803 char text[MAX_CB_TEXT_SIZE + 1] = "";
12804 int width = (draw_with_brush ? brush_width : lev_fieldx);
12805 int height = (draw_with_brush ? brush_height : lev_fieldy);
12806 char *format = "%s%03d";
12808 for (y = 0; y < height; y++)
12809 for (x = 0; x < width; x++)
12810 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
12813 for (y = 0; y < height; y++)
12815 for (x = 0; x < width; x++)
12817 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
12818 char *prefix = (mode == CB_DUMP_BRUSH ||
12819 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
12821 if (element >= NUM_FILE_ELEMENTS)
12822 element = EL_UNKNOWN;
12824 // copy brush to level sketch text buffer for the R'n'D forum:
12825 // - large tiles: `xxx or `xxxx (0x60 ASCII)
12826 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
12827 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
12828 strcat(text, part);
12831 strcat(text, "\n");
12834 if (mode == CB_BRUSH_TO_CLIPBOARD ||
12835 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12836 SDL_SetClipboardText(text);
12838 Print("%s", text); // print brush data to console and log file
12843 if (mode == CB_CLIPBOARD_TO_BRUSH)
12845 if (edit_mode != ED_MODE_DRAWING)
12848 if (!SDL_HasClipboardText())
12850 Request("Clipboard is empty!", REQ_CONFIRM);
12855 boolean copy_to_brush = (draw_with_brush ||
12856 drawing_function == GADGET_ID_GRAB_BRUSH);
12858 // this will delete the old brush, if already drawing with a brush
12860 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
12862 // initialization is required for "odd" (incomplete) clipboard content
12863 for (x = 0; x < MAX_LEV_FIELDX; x++)
12864 for (y = 0; y < MAX_LEV_FIELDY; y++)
12865 brush_buffer[x][y] = EL_EMPTY;
12872 char *clipboard_text = SDL_GetClipboardText();
12873 char *ptr = clipboard_text;
12874 boolean allow_new_row = FALSE;
12875 boolean stop = FALSE;
12877 while (*ptr && !stop)
12879 boolean prefix_found = FALSE;
12880 boolean start_new_row = FALSE;
12882 // level sketch element number prefixes (may be multi-byte characters)
12883 char *prefix_list[] = { "`", "¸" };
12886 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
12888 char *prefix = prefix_list[i];
12890 // check if string is large enough for prefix
12891 if (strlen(ptr) < strlen(prefix))
12898 // check if string starts with prefix
12899 if (strPrefix(ptr, prefix))
12901 ptr += strlen(prefix);
12903 prefix_found = TRUE;
12909 // check if prefix found and followed by (at least) three digits
12910 if (prefix_found &&
12911 strlen(ptr) >= 3 &&
12912 ptr[0] >= '0' && ptr[0] <= '9' &&
12913 ptr[1] >= '0' && ptr[1] <= '9' &&
12914 ptr[2] >= '0' && ptr[2] <= '9')
12916 int element = ((ptr[0] - '0') * 100 +
12917 (ptr[1] - '0') * 10 +
12922 // level sketch element number might consist of four digits
12923 if (ptr[0] >= '0' && ptr[0] <= '9')
12925 element = element * 10 + (ptr[0] - '0');
12929 // remap some (historic, now obsolete) elements
12930 element = getMappedElement(element);
12932 if (element >= NUM_FILE_ELEMENTS)
12933 element = EL_UNKNOWN;
12935 brush_buffer[x][y] = element;
12937 brush_width = MAX(x + 1, brush_width);
12938 brush_height = MAX(y + 1, brush_height);
12942 if (x >= MAX_LEV_FIELDX)
12943 start_new_row = TRUE;
12945 allow_new_row = TRUE;
12949 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
12950 start_new_row = TRUE;
12952 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
12960 if (y >= MAX_LEV_FIELDY)
12963 allow_new_row = FALSE;
12967 SDL_free(clipboard_text);
12969 if (brush_width == 0 || brush_height == 0)
12971 Request("No level sketch found in clipboard!", REQ_CONFIRM);
12978 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
12981 SDL_GetMouseState(&mx, &my);
12983 // if inside drawing area, activate and draw brush at last mouse position
12984 if (mx >= gi->x && mx < gi->x + gi->width &&
12985 my >= gi->y && my < gi->y + gi->height)
12986 CopyBrushToCursor(last_cursor_x, last_cursor_y);
12988 draw_with_brush = TRUE;
12994 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
12995 brush_width, brush_height);
12997 if (!Request(request, REQ_ASK))
13000 for (x = 0; x < MAX_LEV_FIELDX; x++)
13001 for (y = 0; y < MAX_LEV_FIELDY; y++)
13002 Tile[x][y] = brush_buffer[x][y];
13004 lev_fieldx = level.fieldx = brush_width;
13005 lev_fieldy = level.fieldy = brush_height;
13007 boolean use_bd_engine = TRUE;
13008 boolean use_em_engine = TRUE;
13009 boolean use_sp_engine = TRUE;
13010 boolean use_mm_engine = TRUE;
13012 for (x = 0; x < MAX_LEV_FIELDX; x++)
13014 for (y = 0; y < MAX_LEV_FIELDY; y++)
13016 int element = Tile[x][y];
13018 if (!IS_BD_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13019 use_bd_engine = FALSE;
13021 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
13022 use_em_engine = FALSE;
13024 if (!IS_SP_ELEMENT(element))
13025 use_sp_engine = FALSE;
13027 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
13028 use_mm_engine = FALSE;
13032 level.game_engine_type = (use_bd_engine ? GAME_ENGINE_TYPE_BD :
13033 use_em_engine ? GAME_ENGINE_TYPE_EM :
13034 use_sp_engine ? GAME_ENGINE_TYPE_SP :
13035 use_mm_engine ? GAME_ENGINE_TYPE_MM :
13036 GAME_ENGINE_TYPE_RND);
13038 // update element selection list
13039 ReinitializeElementList();
13040 ModifyEditorElementList();
13042 SetBorderElement();
13044 DrawEditModeWindow();
13045 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13051 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
13054 if (mode == CB_AREA_TO_BRUSH)
13056 int from_lx, from_ly;
13059 swap_numbers(&from_x, &to_x);
13062 swap_numbers(&from_y, &to_y);
13064 brush_width = to_x - from_x + 1;
13065 brush_height = to_y - from_y + 1;
13067 from_lx = from_x + level_xpos;
13068 from_ly = from_y + level_ypos;
13070 for (y = 0; y < brush_height; y++)
13072 for (x = 0; x < brush_width; x++)
13074 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
13077 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
13082 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13084 delete_old_brush = FALSE;
13086 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
13087 mode == CB_BRUSH_TO_LEVEL)
13089 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
13090 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
13091 int cursor_from_x = cursor_x - brush_width / 2;
13092 int cursor_from_y = cursor_y - brush_height / 2;
13093 int border_from_x = cursor_x, border_from_y = cursor_y;
13094 int border_to_x = cursor_x, border_to_y = cursor_y;
13096 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
13097 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13099 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
13100 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
13102 delete_old_brush = FALSE;
13107 for (y = 0; y < brush_height; y++)
13109 for (x = 0; x < brush_width; x++)
13111 int sx = cursor_from_x + x;
13112 int sy = cursor_from_y + y;
13113 int lx = sx + level_xpos;
13114 int ly = sy + level_ypos;
13115 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
13116 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
13117 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
13118 brush_buffer[x][y] : new_element);
13120 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
13122 if (sx < border_from_x)
13123 border_from_x = sx;
13124 else if (sx > border_to_x)
13126 if (sy < border_from_y)
13127 border_from_y = sy;
13128 else if (sy > border_to_y)
13131 DrawBrushElement(sx, sy, element, change_level);
13136 if (mode != CB_DELETE_OLD_CURSOR)
13137 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
13139 last_cursor_x = cursor_x;
13140 last_cursor_y = cursor_y;
13142 delete_old_brush = TRUE;
13144 else if (mode == CB_FLIP_BRUSH_X)
13146 for (y = 0; y < brush_height; y++)
13147 for (x = 0; x < (brush_width + 1) / 2; x++)
13148 SwapFlippedTiles(&brush_buffer[x][y],
13149 &brush_buffer[brush_width - x - 1][y], mode);
13151 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13153 else if (mode == CB_FLIP_BRUSH_Y)
13155 for (y = 0; y < (brush_height + 1) / 2; y++)
13156 for (x = 0; x < brush_width; x++)
13157 SwapFlippedTiles(&brush_buffer[x][y],
13158 &brush_buffer[x][brush_height - y - 1], mode);
13160 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13162 else if (mode == CB_FLIP_BRUSH_XY)
13164 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13166 for (y = 0; y < MAX(brush_width, brush_height); y++)
13167 for (x = 0; x <= y; x++)
13168 SwapFlippedTiles(&brush_buffer[x][y],
13169 &brush_buffer[y][x], mode);
13171 swap_numbers(&brush_width, &brush_height);
13173 CopyBrushExt(last_cursor_x, last_cursor_y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13176 if (mode == CB_UPDATE_BRUSH_POSITION)
13178 last_cursor_x = from_x;
13179 last_cursor_y = from_y;
13183 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
13186 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
13189 static void CopyBrushToLevel(int x, int y, int button)
13191 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
13194 static void CopyBrushToCursor(int x, int y)
13196 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
13199 static void UpdateBrushPosition(int x, int y)
13201 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
13204 static void DeleteBrushFromCursor(void)
13206 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
13209 static void FlipBrushX(void)
13211 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13214 static void FlipBrushY(void)
13216 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_Y);
13219 static void RotateBrush(void)
13221 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_XY);
13222 CopyBrushExt(0, 0, 0, 0, 0, CB_FLIP_BRUSH_X);
13225 void DumpBrush(void)
13227 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
13230 void DumpBrush_Small(void)
13232 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
13235 void CopyClipboardToBrush(void)
13237 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
13240 void CopyBrushToClipboard(void)
13242 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
13245 void CopyBrushToClipboard_Small(void)
13247 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
13250 void UndoLevelEditorOperation(void)
13252 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
13255 void RedoLevelEditorOperation(void)
13257 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
13260 static void FloodFill(int from_x, int from_y, int fill_element)
13262 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
13265 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
13267 int from_x = from_sx2 + 2 * level_xpos;
13268 int from_y = from_sy2 + 2 * level_ypos;
13269 int max_fillx = lev_fieldx * 2;
13270 int max_filly = lev_fieldy * 2;
13271 short Fill[max_fillx][max_filly];
13274 for (x = 0; x < max_fillx; x++)
13275 for (y = 0; y < max_filly; y++)
13276 Fill[x][y] = getLevelElementHiRes(x, y);
13278 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
13279 Fill, max_fillx, max_filly);
13281 for (x = 0; x < max_fillx; x++)
13282 for (y = 0; y < max_filly; y++)
13283 if (Fill[x][y] == fill_element)
13284 SetLevelElementHiRes(x, y, Fill[x][y]);
13287 // values for DrawLevelText() modes
13288 #define TEXT_INIT 0
13289 #define TEXT_SETCURSOR 1
13290 #define TEXT_WRITECHAR 2
13291 #define TEXT_BACKSPACE 3
13292 #define TEXT_NEWLINE 4
13294 #define TEXT_QUERY_TYPING 6
13296 static int DrawLevelText(int sx, int sy, char letter, int mode)
13298 static short delete_buffer[MAX_LEV_FIELDX];
13299 static int start_sx;
13300 static int last_sx, last_sy;
13301 static boolean typing = FALSE;
13302 int letter_element;
13303 int lx = 0, ly = 0;
13305 // map lower case letters to upper case and convert special characters
13306 if (letter >= 'a' && letter <= 'z')
13307 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
13308 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
13309 letter_element = EL_CHAR_AUMLAUT;
13310 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
13311 letter_element = EL_CHAR_OUMLAUT;
13312 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
13313 letter_element = EL_CHAR_UUMLAUT;
13314 else if (letter == '^')
13315 letter_element = EL_CHAR_COPYRIGHT;
13317 letter_element = EL_CHAR_ASCII0 + letter;
13319 if (mode != TEXT_INIT)
13324 if (mode != TEXT_SETCURSOR)
13330 lx = last_sx + level_xpos;
13331 ly = last_sy + level_ypos;
13338 DrawLevelText(0, 0, 0, TEXT_END);
13344 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
13347 case TEXT_SETCURSOR:
13348 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
13349 DrawAreaBorder(sx, sy, sx, sy);
13350 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
13351 ed_tilesize, ed_tilesize);
13356 case TEXT_WRITECHAR:
13357 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
13359 if (new_element1 >= EL_STEEL_CHAR_START &&
13360 new_element1 <= EL_STEEL_CHAR_END)
13361 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
13363 delete_buffer[sx - start_sx] = Tile[lx][ly];
13364 Tile[lx][ly] = letter_element;
13366 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
13367 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
13368 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13369 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13371 DrawLevelText(0, 0, 0, TEXT_END);
13373 level.changed = TRUE;
13377 case TEXT_BACKSPACE:
13380 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
13381 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
13382 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
13387 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
13388 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
13390 DrawLevelText(0, 0, 0, TEXT_END);
13394 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13395 DrawEditorElement(sx, sy, Tile[lx][ly]);
13400 case TEXT_QUERY_TYPING:
13410 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
13411 int element, boolean change_level)
13413 int lx = sx + level_xpos;
13414 int ly = sy + level_ypos;
13417 DrawEditorElement(sx, sy, Tile[lx][ly]);
13419 DrawAreaBorder(sx, sy, sx, sy);
13422 static void CheckLevelBorderElement(boolean redraw_playfield)
13424 int last_border_element = BorderElement;
13426 SetBorderElement();
13428 if (redraw_playfield && BorderElement != last_border_element)
13429 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13432 static void CopyLevelToUndoBuffer(int mode)
13434 static boolean accumulated_undo = FALSE;
13435 boolean new_undo_buffer_position = TRUE;
13438 if (undo_buffer_steps == 0)
13439 accumulated_undo = FALSE;
13443 case UNDO_IMMEDIATE:
13444 accumulated_undo = FALSE;
13447 case UNDO_ACCUMULATE:
13448 if (accumulated_undo)
13449 new_undo_buffer_position = FALSE;
13450 accumulated_undo = TRUE;
13457 if (new_undo_buffer_position)
13459 // advance position in undo buffer ring
13460 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13462 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
13463 undo_buffer_steps++;
13466 // always reset redo buffer when storing level change into undo buffer
13467 redo_buffer_steps = 0;
13469 for (x = 0; x < lev_fieldx; x++)
13470 for (y = 0; y < lev_fieldy; y++)
13471 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
13473 // check if drawing operation forces change of border style
13474 CheckLevelBorderElement(TRUE);
13476 level.changed = TRUE;
13479 static void RandomPlacement(int new_element)
13481 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
13482 int num_free_positions = 0;
13483 int num_percentage, num_elements;
13486 ResetIntelliDraw();
13488 // determine number of free positions for randomly placing the new element
13489 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
13491 free_position[x][y] =
13492 (random_placement_background_restricted ?
13493 Tile[x][y] == random_placement_background_element :
13494 Tile[x][y] != new_element);
13496 if (free_position[x][y])
13497 num_free_positions++;
13500 // determine number of new elements to place there
13501 num_percentage = num_free_positions * random_placement_value / 100;
13502 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
13503 num_percentage : random_placement_value);
13505 // if less free positions than elements to place, fill all these positions
13506 if (num_free_positions < num_elements)
13508 for (x = 0; x < lev_fieldx; x++)
13509 for (y = 0; y < lev_fieldy; y++)
13510 if (free_position[x][y])
13511 SetElement(x, y, new_element);
13515 while (num_elements > 0)
13517 x = GetSimpleRandom(lev_fieldx);
13518 y = GetSimpleRandom(lev_fieldy);
13520 // don't place element at the same position twice
13521 if (free_position[x][y])
13523 free_position[x][y] = FALSE;
13524 SetElement(x, y, new_element);
13530 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13531 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13534 static void WrapLevel(int dx, int dy)
13536 int wrap_dx = lev_fieldx - dx;
13537 int wrap_dy = lev_fieldy - dy;
13540 for (x = 0; x < lev_fieldx; x++)
13541 for (y = 0; y < lev_fieldy; y++)
13542 TileBackup[x][y] = Tile[x][y];
13544 for (x = 0; x < lev_fieldx; x++)
13545 for (y = 0; y < lev_fieldy; y++)
13547 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
13549 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13550 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
13553 static void DrawAreaElementHighlight(boolean highlighted,
13554 boolean highlighted_similar)
13556 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13563 for (x = 0; x < ed_fieldx; x++)
13565 for (y = 0; y < ed_fieldy; y++)
13567 boolean highlight = FALSE;
13568 int lx = x + level_xpos;
13569 int ly = y + level_ypos;
13571 if (!IN_LEV_FIELD(lx, ly))
13574 // check if element is the same
13575 if (Tile[lx][ly] == new_element1)
13578 // check if element is similar
13579 if (highlighted_similar &&
13580 strEqual(element_info[Tile[lx][ly]].class_name,
13581 element_info[new_element1].class_name))
13584 // check if element is matching MM style wall
13585 if (IS_MM_WALL(Tile[lx][ly]) &&
13586 map_mm_wall_element(Tile[lx][ly]) == new_element1)
13592 if (IS_MM_WALL(Tile[lx][ly]) && !highlighted_similar)
13596 for (i = 0; i < 4; i++)
13598 if (!(MM_WALL_BITS(Tile[lx][ly]) & (1 << i)))
13601 int xx = x * 2 + (i % 2);
13602 int yy = y * 2 + (i / 2);
13603 int sx = SX + xx * ed_tilesize / 2;
13604 int sy = SY + yy * ed_tilesize / 2;
13607 int to_sx = sx + ed_tilesize / 2 - 1;
13608 int to_sy = sy + ed_tilesize / 2 - 1;
13610 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13611 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13612 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13613 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13618 int sx = SX + x * ed_tilesize;
13619 int sy = SY + y * ed_tilesize;
13622 int to_sx = sx + ed_tilesize - 1;
13623 int to_sy = sy + ed_tilesize - 1;
13625 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13626 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13627 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13628 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13634 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
13636 char *template_filename_old = getLocalLevelTemplateFilename();
13637 char *template_filename_new =
13638 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
13640 if (copyFile(template_filename_old, template_filename_new) != 0)
13641 Request("Cannot copy level template!", REQ_CONFIRM);
13643 free(template_filename_new);
13646 static void HandleDrawingAreas(struct GadgetInfo *gi)
13648 static boolean started_inside_drawing_area = FALSE;
13649 static int last_sx = -1;
13650 static int last_sy = -1;
13651 static int last_sx2 = -1;
13652 static int last_sy2 = -1;
13653 int id = gi->custom_id;
13654 int type_id = gi->custom_type_id;
13655 boolean button_press_event;
13656 boolean button_release_event;
13657 boolean inside_drawing_area = !gi->event.off_borders;
13658 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
13659 int actual_drawing_function;
13660 int button = gi->event.button;
13661 int new_element = BUTTON_ELEMENT(button);
13662 int sx = gi->event.x, sy = gi->event.y;
13663 int min_sx = 0, min_sy = 0;
13664 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
13665 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
13666 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
13667 int sx2 = gi->event.mx / mini_item_xsize;
13668 int sy2 = gi->event.my / mini_item_ysize;
13671 int lx = 0, ly = 0;
13674 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
13675 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
13677 // make sure to stay inside drawing area boundaries
13678 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
13679 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
13683 int min_lx = 0, min_ly = 0;
13684 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
13686 // get positions inside level field
13687 lx = sx + level_xpos;
13688 ly = sy + level_ypos;
13690 if (!IN_LEV_FIELD(lx, ly))
13691 inside_drawing_area = FALSE;
13693 // make sure to stay inside level field boundaries
13694 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
13695 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
13697 // correct drawing area positions accordingly
13698 sx = lx - level_xpos;
13699 sy = ly - level_ypos;
13702 // also correct MM wall-sized (double) drawing area positions accordingly
13703 if (sx2 / 2 < sx || sx2 / 2 > sx)
13705 dx = (sx2 / 2 < sx ? 0 : 1);
13708 if (sy2 / 2 < sy || sy2 / 2 > sy)
13710 dy = (sy2 / 2 < sy ? 0 : 1);
13714 if (!button_press_event && !button_release_event)
13716 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
13717 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
13718 isHiresTileElement(old_element) &&
13719 isHiresDrawElement(new_element));
13721 // prevent handling events for every pixel position when moving mouse
13722 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
13723 (sx2 == last_sx2 && sy2 == last_sy2))
13732 if (button_press_event)
13733 started_inside_drawing_area = inside_drawing_area;
13735 if (!started_inside_drawing_area)
13738 if (!IS_VALID_BUTTON(button))
13741 // handle info callback for each invocation of action callback
13742 gi->callback_info(gi);
13744 // automatically switch to 'single item' drawing mode, if needed
13745 actual_drawing_function =
13746 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
13747 drawing_function : GADGET_ID_SINGLE_ITEMS);
13749 // clicking into drawing area with pressed Control key picks element
13750 if (GetKeyModState() & KMOD_Control)
13752 last_drawing_function = drawing_function;
13753 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
13756 if (GetKeyModState() & KMOD_Shift)
13758 if (button_press_event || button_release_event)
13759 ResetIntelliDraw();
13762 SetDrawModeHiRes(-1); // reset to normal draw mode
13764 switch (actual_drawing_function)
13766 case GADGET_ID_SINGLE_ITEMS:
13769 if (button_release_event)
13771 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13773 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
13774 !inside_drawing_area)
13775 DeleteBrushFromCursor();
13780 if (draw_with_brush)
13782 CopyBrushToLevel(sx, sy, button);
13786 SetDrawModeHiRes(new_element);
13788 if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
13790 // remove player at old position
13791 for (y = 0; y < lev_fieldy; y++)
13793 for (x = 0; x < lev_fieldx; x++)
13795 int old_element = Tile[x][y];
13797 if (IS_PLAYER_ELEMENT(old_element) &&
13798 IS_PLAYER_ELEMENT(new_element))
13800 int replaced_with_element =
13801 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
13802 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
13804 old_element == EL_SOKOBAN_FIELD_PLAYER &&
13805 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
13807 new_element == EL_SOKOBAN_FIELD_PLAYER &&
13808 old_element == EL_PLAYER_1 ? EL_EMPTY :
13810 new_element >= EL_PLAYER_1 &&
13811 new_element <= EL_PLAYER_4 &&
13812 new_element == old_element ? EL_EMPTY :
13816 SetElement(x, y, replaced_with_element);
13818 else if (IS_MM_MCDUFFIN(old_element) &&
13819 IS_MM_MCDUFFIN(new_element))
13821 // remove McDuffin at old position
13822 SetElement(x, y, EL_EMPTY);
13828 SetElementButton(lx, ly, dx, dy, new_element, button);
13831 else if (!button_release_event)
13833 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13835 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
13836 DrawMiniGraphicExt(drawto,
13837 gi->x + sx * MINI_TILEX,
13838 gi->y + sy * MINI_TILEY,
13839 el2edimg(new_element));
13841 DrawFixedGraphicExt(drawto,
13842 gi->x + sx * TILEX,
13843 gi->y + sy * TILEY,
13844 el2edimg(new_element), 0);
13846 if (id == GADGET_ID_CUSTOM_GRAPHIC)
13847 new_element = GFX_ELEMENT(new_element);
13849 drawingarea_info[type_id].value[pos] = new_element;
13851 CopyElementPropertiesToGame(properties_element);
13853 if (id == GADGET_ID_CUSTOM_GRAPHIC)
13855 UpdateCustomElementGraphicGadgets();
13857 FrameCounter = 0; // restart animation frame counter
13862 case GADGET_ID_CONNECTED_ITEMS:
13864 static int last_sx = -1;
13865 static int last_sy = -1;
13867 if (button_release_event)
13868 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13870 SetDrawModeHiRes(new_element);
13872 if (getDrawModeHiRes())
13878 if (!button_press_event)
13879 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
13886 case GADGET_ID_LINE:
13887 case GADGET_ID_ARC:
13888 case GADGET_ID_RECTANGLE:
13889 case GADGET_ID_FILLED_BOX:
13890 SetDrawModeHiRes(new_element);
13892 if (getDrawModeHiRes())
13898 case GADGET_ID_GRAB_BRUSH:
13899 case GADGET_ID_TEXT:
13901 static int last_sx = -1;
13902 static int last_sy = -1;
13903 static int start_sx = -1;
13904 static int start_sy = -1;
13905 void (*draw_func)(int, int, int, int, int, boolean);
13907 if (drawing_function == GADGET_ID_LINE)
13908 draw_func = DrawLine;
13909 else if (drawing_function == GADGET_ID_ARC)
13910 draw_func = DrawArc;
13911 else if (drawing_function == GADGET_ID_RECTANGLE)
13912 draw_func = DrawBox;
13913 else if (drawing_function == GADGET_ID_FILLED_BOX)
13914 draw_func = DrawFilledBox;
13915 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
13916 draw_func = SelectArea;
13917 else // (drawing_function == GADGET_ID_TEXT)
13918 draw_func = SetTextCursor;
13920 if (button_press_event)
13922 draw_func(sx, sy, sx, sy, new_element, FALSE);
13923 start_sx = last_sx = sx;
13924 start_sy = last_sy = sy;
13926 if (drawing_function == GADGET_ID_TEXT)
13927 DrawLevelText(0, 0, 0, TEXT_END);
13929 else if (button_release_event)
13931 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
13932 if (drawing_function == GADGET_ID_GRAB_BRUSH)
13934 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
13935 CopyBrushToCursor(sx, sy);
13936 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
13938 draw_with_brush = TRUE;
13940 else if (drawing_function == GADGET_ID_TEXT)
13941 DrawLevelText(sx, sy, 0, TEXT_INIT);
13943 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13945 else if (last_sx != sx || last_sy != sy)
13947 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
13948 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
13949 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
13950 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
13957 case GADGET_ID_FLOOD_FILL:
13958 if (button_press_event && Tile[lx][ly] != new_element)
13960 if (IS_MM_WALL_EDITOR(new_element))
13961 FloodFillWall_MM(sx2, sy2, new_element);
13963 FloodFill(lx, ly, new_element);
13965 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13966 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13970 case GADGET_ID_PICK_ELEMENT:
13971 if (button_release_event)
13972 ClickOnGadget(level_editor_gadget[last_drawing_function],
13974 else if (draw_level)
13975 PickDrawingElement(button, Tile[lx][ly]);
13978 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13980 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
13987 // do not mark level as modified for certain non-level-changing gadgets
13988 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
13989 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
13990 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
13991 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
13994 level.changed = TRUE;
13997 static void HandleCounterButtons(struct GadgetInfo *gi)
13999 int gadget_id = gi->custom_id;
14000 int counter_id = gi->custom_type_id;
14001 int button = gi->event.button;
14002 int *counter_value = counterbutton_info[counter_id].value;
14003 int step = BUTTON_STEPSIZE(button) *
14004 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
14006 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14008 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
14009 boolean released = (gi->event.type == GD_EVENT_RELEASED);
14010 boolean level_changed = LevelChanged();
14012 if ((level_changed && pressed) || (!level_changed && released))
14015 if (level_changed && !Request("Level has changed! Discard changes?",
14018 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14019 ModifyEditorCounterValue(counter_id, *counter_value);
14025 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
14026 *counter_value = gi->textinput.number_value;
14028 ModifyEditorCounterValue(counter_id, *counter_value + step);
14030 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
14032 int last_game_engine_type = level.game_engine_type;
14034 LoadLevel(level_nr);
14035 LoadScore(level_nr);
14037 SaveLevelSetup_SeriesInfo();
14042 DrawEditModeWindow();
14044 if (level.game_engine_type != last_game_engine_type)
14046 // update element selection list
14047 ReinitializeElementList();
14048 ModifyEditorElementList();
14054 switch (counter_id)
14056 case ED_COUNTER_ID_YAMYAM_CONTENT:
14057 DrawYamYamContentAreas();
14060 case ED_COUNTER_ID_BALL_CONTENT:
14061 DrawMagicBallContentAreas();
14064 case ED_COUNTER_ID_ANDROID_CONTENT:
14065 DrawAndroidElementArea();
14068 case ED_COUNTER_ID_GROUP_CONTENT:
14069 DrawGroupElementArea();
14070 CopyGroupElementPropertiesToGame(properties_element);
14073 case ED_COUNTER_ID_INVENTORY_SIZE:
14074 DrawPlayerInitialInventoryArea(properties_element);
14077 case ED_COUNTER_ID_MM_BALL_CONTENT:
14078 DrawMMBallContentArea();
14081 case ED_COUNTER_ID_ENVELOPE_XSIZE:
14082 case ED_COUNTER_ID_ENVELOPE_YSIZE:
14083 DrawEnvelopeTextArea(-1);
14086 case ED_COUNTER_ID_LEVEL_XSIZE:
14087 case ED_COUNTER_ID_LEVEL_YSIZE:
14088 lev_fieldx = level.fieldx;
14089 lev_fieldy = level.fieldy;
14091 // check if resizing of level results in change of border border
14092 SetBorderElement();
14100 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
14101 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
14102 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
14103 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
14104 CopyElementPropertiesToGame(properties_element);
14106 // do not mark level as modified for certain non-level-changing gadgets
14107 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
14108 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
14109 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
14110 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
14113 level.changed = TRUE;
14116 static void HandleTextInputGadgets(struct GadgetInfo *gi)
14118 int type_id = gi->custom_type_id;
14120 strcpy(textinput_info[type_id].value, gi->textinput.value);
14122 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
14124 CopyElementPropertiesToGame(properties_element);
14126 ModifyEditorElementList(); // update changed button info text
14129 // do not mark level as modified for certain non-level-changing gadgets
14130 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
14131 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
14134 level.changed = TRUE;
14137 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
14139 int type_id = gi->custom_type_id;
14141 strncpy(textarea_info[type_id].value, gi->textarea.value,
14142 MAX_ENVELOPE_TEXT_LEN);
14143 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
14145 level.changed = TRUE;
14148 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
14150 int type_id = gi->custom_type_id;
14151 int value_old = *selectbox_info[type_id].value;
14152 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
14154 *selectbox_info[type_id].value = value_new;
14156 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
14158 DrawLevelConfigWindow();
14160 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14162 element_info[properties_element].current_change_page = gi->selectbox.index;
14164 DrawPropertiesWindow();
14166 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
14167 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
14168 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
14169 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
14170 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
14172 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
14174 // when changing action type, also check action mode and action arg
14175 if (value_old != value_new)
14176 setSelectboxSpecialActionVariablesIfNeeded();
14178 DrawPropertiesChange();
14181 CopyElementPropertiesToGame(properties_element);
14183 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
14185 // update element selection list
14186 ReinitializeElementList();
14187 ModifyEditorElementList();
14190 // do not mark level as modified for certain non-level-changing gadgets
14191 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
14192 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
14195 level.changed = TRUE;
14198 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
14200 int type_id = gi->custom_type_id;
14203 if (type_id >= ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST &&
14204 type_id <= ED_TAB_BUTTON_ID_LEVELCONFIG_LAST)
14206 edit_mode_levelconfig = gi->custom_type_id;
14208 DrawLevelConfigWindow();
14210 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
14211 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
14213 edit_mode_properties = gi->custom_type_id;
14215 DrawPropertiesWindow();
14217 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
14218 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
14220 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
14222 // backup original "level.field" (needed to track playfield changes)
14223 CopyPlayfield(level.field, TileBackup);
14225 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
14226 CopyPlayfield(Tile, level.field);
14228 if (new_template ||
14229 Request("Save this template and kill the old?", REQ_ASK))
14230 SaveLevelTemplate();
14233 Request("Template saved!", REQ_CONFIRM);
14235 // restore original "level.field" (needed to track playfield changes)
14236 CopyPlayfield(TileBackup, level.field);
14238 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
14240 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
14242 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
14243 leveldir_current->readonly)
14245 Request("This level set is read-only!", REQ_CONFIRM);
14250 if (strEqual(levelset_name, ""))
14252 Request("Please enter level set title!", REQ_CONFIRM);
14257 if (strEqual(levelset_author, ""))
14259 Request("Please enter level set author!", REQ_CONFIRM);
14264 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
14266 if (UpdateUserLevelSet(levelset_subdir,
14269 levelset_num_levels))
14271 Request("Level set updated!", REQ_CONFIRM);
14275 Request("Updating level set failed!", REQ_CONFIRM);
14278 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
14280 if (level.changed && !Request("Level has changed! Discard changes?",
14284 if (CreateUserLevelSet(levelset_subdir,
14287 levelset_num_levels,
14288 levelset_use_levelset_artwork))
14290 if (levelset_copy_level_template)
14291 CopyLevelTemplateToUserLevelSet(levelset_subdir);
14293 Request("New level set created!", REQ_CONFIRM);
14295 AddUserLevelSetToLevelInfo(levelset_subdir);
14296 ChangeEditorToLevelSet(levelset_subdir);
14300 Request("Creating new level set failed!", REQ_CONFIRM);
14304 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
14305 custom_element.num_change_pages < MAX_CHANGE_PAGES)
14307 struct ElementInfo *ei = &element_info[properties_element];
14309 // when modifying custom element, ask for copying level template
14310 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14313 setElementChangePages(ei, ei->num_change_pages + 1);
14315 // set new change page to be new current change page
14316 ei->current_change_page = ei->num_change_pages - 1;
14317 ei->change = &ei->change_page[ei->current_change_page];
14319 setElementChangeInfoToDefaults(ei->change);
14321 DrawPropertiesWindow();
14323 level.changed = TRUE;
14325 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
14326 custom_element.num_change_pages > MIN_CHANGE_PAGES)
14328 struct ElementInfo *ei = &element_info[properties_element];
14330 // when modifying custom element, ask for copying level template
14331 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14334 // copy all change pages after change page to be deleted
14335 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
14336 ei->change_page[i] = ei->change_page[i + 1];
14338 setElementChangePages(ei, ei->num_change_pages - 1);
14340 DrawPropertiesWindow();
14342 level.changed = TRUE;
14346 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
14348 int type_id = gi->custom_type_id;
14350 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
14351 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
14353 struct ElementInfo *ei = &element_info[properties_element];
14354 int step = BUTTON_STEPSIZE(gi->event.button);
14356 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
14357 ei->current_change_page += step;
14359 if (ei->current_change_page < 0)
14360 ei->current_change_page = 0;
14361 else if (ei->current_change_page >= ei->num_change_pages)
14362 ei->current_change_page = ei->num_change_pages - 1;
14364 DrawPropertiesWindow();
14366 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
14367 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14369 struct ElementInfo *ei = &element_info[properties_element];
14370 int current_change_page = ei->current_change_page;
14372 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
14374 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
14375 ei->change_page[current_change_page];
14377 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
14379 // when modifying custom element, ask for copying level template
14380 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
14383 ei->change_page[current_change_page] =
14384 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
14386 level.changed = TRUE;
14389 DrawPropertiesWindow();
14393 static void HandleRadiobuttons(struct GadgetInfo *gi)
14395 int type_id = gi->custom_type_id;
14397 *radiobutton_info[type_id].value =
14398 radiobutton_info[type_id].checked_value;
14400 // do not mark level as modified for certain non-level-changing gadgets
14401 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
14402 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
14405 level.changed = TRUE;
14408 static void HandleCheckbuttons(struct GadgetInfo *gi)
14410 int type_id = gi->custom_type_id;
14412 *checkbutton_info[type_id].value ^= TRUE;
14414 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
14415 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
14416 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
14417 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
14418 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
14419 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
14420 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
14421 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
14423 CopyElementPropertiesToGame(properties_element);
14426 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
14428 UpdateCustomElementGraphicGadgets();
14430 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
14431 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
14433 boolean template_related_changes_found = FALSE;
14436 // check if any custom, group or empty elements have been changed
14437 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
14438 if ((IS_CUSTOM_ELEMENT(i) ||
14439 IS_GROUP_ELEMENT(i) ||
14440 IS_EMPTY_ELEMENT(i)) &&
14441 element_info[i].modified_settings)
14442 template_related_changes_found = TRUE;
14444 if (level.use_custom_template &&
14445 !fileExists(getGlobalLevelTemplateFilename()))
14447 Request("No level template found!", REQ_CONFIRM);
14449 level.use_custom_template = FALSE;
14451 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14456 if (level.use_custom_template &&
14457 template_related_changes_found &&
14458 !Request("Discard changes and use level template?", REQ_ASK))
14460 level.use_custom_template = FALSE;
14462 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
14467 if (!level.use_custom_template &&
14468 Request("Copy settings from level template?", REQ_ASK))
14473 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
14475 DrawEditModeWindow();
14477 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
14479 if (setup.editor.use_template_for_new_levels &&
14480 !fileExists(getGlobalLevelTemplateFilename()))
14482 Request("No level template found!", REQ_CONFIRM);
14487 if (setup.editor.use_template_for_new_levels &&
14489 !Request("Discard level and load template?", REQ_ASK))
14494 if (!setup.editor.use_template_for_new_levels &&
14496 !Request("Discard level and use empty level?", REQ_ASK))
14501 LoadLevel(level_nr);
14502 LoadScore(level_nr);
14507 DrawEditModeWindow();
14509 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
14511 SetAutomaticNumberOfGemsNeeded();
14514 // do not mark level as modified for certain non-level-changing gadgets
14515 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
14516 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
14517 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
14518 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
14519 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
14520 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
14523 level.changed = TRUE;
14526 static void HandleControlButtons(struct GadgetInfo *gi)
14528 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
14529 static int last_edit_mode = ED_MODE_DRAWING;
14530 static int last_custom_copy_mode = -1;
14531 static int last_button = 0;
14532 int id = gi->custom_id;
14533 int button = gi->event.button;
14534 int step = BUTTON_STEPSIZE(button);
14535 int new_element = BUTTON_ELEMENT(button);
14536 int last_properties_element = properties_element;
14539 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
14540 DrawLevelText(0, 0, 0, TEXT_END);
14542 if (id < ED_NUM_CTRL1_BUTTONS &&
14543 id != GADGET_ID_SINGLE_ITEMS &&
14544 id != GADGET_ID_PICK_ELEMENT &&
14545 edit_mode != ED_MODE_DRAWING &&
14546 drawing_function != GADGET_ID_PICK_ELEMENT &&
14547 !(GetKeyModState() & KMOD_Control))
14548 ChangeEditModeWindow(ED_MODE_DRAWING);
14550 // element copy mode active, but no element button pressed => deactivate
14551 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
14552 last_custom_copy_mode = -1;
14554 // when showing palette on element buttons, change element of button used
14555 if (editor.palette.show_on_element_buttons &&
14556 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
14558 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
14560 id = GADGET_ID_PALETTE;
14565 case GADGET_ID_SCROLL_LEFT:
14566 if (level_xpos >= 0)
14568 if (lev_fieldx < ed_fieldx - 2)
14571 level_xpos -= step;
14572 if (level_xpos < -1)
14575 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
14577 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14579 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14580 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14584 case GADGET_ID_SCROLL_RIGHT:
14585 if (level_xpos <= lev_fieldx - ed_fieldx)
14587 if (lev_fieldx < ed_fieldx - 2)
14590 level_xpos += step;
14591 if (level_xpos > lev_fieldx - ed_fieldx + 1)
14592 level_xpos = lev_fieldx - ed_fieldx + 1;
14594 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
14596 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14598 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14599 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14603 case GADGET_ID_SCROLL_UP:
14604 if (level_ypos >= 0)
14606 if (lev_fieldy < ed_fieldy - 2)
14609 level_ypos -= step;
14610 if (level_ypos < -1)
14613 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
14615 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14617 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
14618 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
14622 case GADGET_ID_SCROLL_DOWN:
14623 if (level_ypos <= lev_fieldy - ed_fieldy)
14625 if (lev_fieldy < ed_fieldy - 2)
14628 level_ypos += step;
14629 if (level_ypos > lev_fieldy - ed_fieldy + 1)
14630 level_ypos = lev_fieldy - ed_fieldy + 1;
14632 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
14634 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14636 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
14637 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
14641 case GADGET_ID_SCROLL_HORIZONTAL:
14642 level_xpos = gi->event.item_position - 1;
14644 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14649 case GADGET_ID_SCROLL_VERTICAL:
14650 level_ypos = gi->event.item_position - 1;
14652 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14657 case GADGET_ID_SCROLL_LIST_UP:
14658 case GADGET_ID_SCROLL_LIST_DOWN:
14659 case GADGET_ID_SCROLL_LIST_VERTICAL:
14660 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
14661 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
14664 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
14665 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
14667 if (element_shift < 0)
14669 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14670 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14672 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14673 GDI_SCROLLBAR_ITEM_POSITION,
14674 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14677 ModifyEditorElementList();
14681 case GADGET_ID_PROPERTIES:
14682 // always switch off element properties when they are already displayed
14683 last_properties_element = new_element;
14684 case GADGET_ID_ELEMENT_LEFT:
14685 case GADGET_ID_ELEMENT_MIDDLE:
14686 case GADGET_ID_ELEMENT_RIGHT:
14687 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
14688 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
14689 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
14692 if (edit_mode != ED_MODE_PROPERTIES)
14694 last_edit_mode = edit_mode;
14696 ChangeEditModeWindow(ED_MODE_PROPERTIES);
14698 last_level_drawing_function = drawing_function;
14699 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14702 else if (properties_element != last_properties_element)
14704 DrawEditModeWindow();
14708 ChangeEditModeWindow(ED_MODE_DRAWING);
14710 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
14715 case GADGET_ID_PALETTE:
14716 if (edit_mode != ED_MODE_PALETTE)
14718 last_edit_mode = edit_mode;
14720 ChangeEditModeWindow(ED_MODE_PALETTE);
14724 ChangeEditModeWindow(last_edit_mode);
14728 case GADGET_ID_WRAP_LEFT:
14729 WrapLevel(-step, 0);
14732 case GADGET_ID_WRAP_RIGHT:
14733 WrapLevel(step, 0);
14736 case GADGET_ID_WRAP_UP:
14737 WrapLevel(0, -step);
14740 case GADGET_ID_WRAP_DOWN:
14741 WrapLevel(0, step);
14744 case GADGET_ID_SINGLE_ITEMS:
14745 case GADGET_ID_CONNECTED_ITEMS:
14746 case GADGET_ID_LINE:
14747 case GADGET_ID_ARC:
14748 case GADGET_ID_TEXT:
14749 case GADGET_ID_RECTANGLE:
14750 case GADGET_ID_FILLED_BOX:
14751 case GADGET_ID_FLOOD_FILL:
14752 case GADGET_ID_GRAB_BRUSH:
14753 case GADGET_ID_PICK_ELEMENT:
14754 if (drawing_function != GADGET_ID_PICK_ELEMENT)
14755 last_drawing_function = drawing_function;
14756 drawing_function = id;
14757 draw_with_brush = FALSE;
14760 case GADGET_ID_RANDOM_PLACEMENT:
14761 RandomPlacement(new_element);
14764 case GADGET_ID_ZOOM:
14765 // zoom level editor tile size in or out (or reset to default size)
14766 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
14767 button == 2 ? ed_tilesize_default :
14768 button == 3 ? ed_tilesize / 2 : ed_tilesize);
14770 // when using touch device, cycle through all zoom tilesizes
14771 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
14772 ed_tilesize = MICRO_TILESIZE;
14774 // limit zoom level by upper and lower bound
14775 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
14777 InitZoomLevelSettings(ed_tilesize);
14779 if (edit_mode == ED_MODE_DRAWING)
14781 DrawDrawingWindow();
14783 // redraw zoom gadget info text
14784 PrintEditorGadgetInfoText(level_editor_gadget[id]);
14787 // save current editor zoom tilesize
14788 SaveSetup_AutoSetup();
14792 case GADGET_ID_CUSTOM_COPY_FROM:
14793 case GADGET_ID_CUSTOM_COPY_TO:
14794 case GADGET_ID_CUSTOM_EXCHANGE:
14795 last_custom_copy_mode = id;
14796 last_drawing_function = drawing_function;
14799 case GADGET_ID_CUSTOM_COPY:
14800 CopyCustomElement(properties_element, -1, id);
14803 case GADGET_ID_CUSTOM_PASTE:
14804 CopyCustomElement(-1, properties_element, id);
14807 case GADGET_ID_UNDO:
14808 if (button < 0) // keep button value (even if modifier keys are pressed)
14810 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
14813 if (button == 1 && undo_buffer_steps == 0)
14815 Request("Undo buffer empty!", REQ_CONFIRM);
14819 else if (button == 2)
14823 else if (button == 3 && redo_buffer_steps == 0)
14825 Request("Redo buffer empty!", REQ_CONFIRM);
14830 if (edit_mode != ED_MODE_DRAWING)
14831 ChangeEditModeWindow(ED_MODE_DRAWING);
14837 undo_buffer_position =
14838 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
14840 undo_buffer_steps--;
14841 redo_buffer_steps++;
14847 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
14849 undo_buffer_steps++;
14850 redo_buffer_steps--;
14853 for (x = 0; x < lev_fieldx; x++)
14854 for (y = 0; y < lev_fieldy; y++)
14855 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
14857 // check if undo operation forces change of border style
14858 CheckLevelBorderElement(FALSE);
14860 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14864 case GADGET_ID_CONF:
14865 if (edit_mode != ED_MODE_LEVELCONFIG)
14867 last_edit_mode = edit_mode;
14869 ChangeEditModeWindow(ED_MODE_LEVELCONFIG);
14873 ChangeEditModeWindow(ED_MODE_DRAWING);
14877 case GADGET_ID_CLEAR:
14878 if (edit_mode != ED_MODE_DRAWING)
14879 ChangeEditModeWindow(ED_MODE_DRAWING);
14881 for (x = 0; x < MAX_LEV_FIELDX; x++)
14882 for (y = 0; y < MAX_LEV_FIELDY; y++)
14883 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
14885 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
14887 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14890 case GADGET_ID_SAVE:
14892 // saving read-only levels into personal level set modifies global vars
14893 // "leveldir_current" and "level_nr"; restore them after saving level
14894 LevelDirTree *leveldir_former = leveldir_current;
14895 int level_nr_former = level_nr;
14896 char *level_filename;
14899 if (leveldir_current->readonly &&
14900 !PrepareSavingIntoPersonalLevelSet())
14903 level_filename = getDefaultLevelFilename(level_nr);
14904 new_level = !fileExists(level_filename);
14907 Request("Save this level and kill the old?", REQ_ASK))
14909 if (leveldir_former->readonly)
14910 ModifyLevelConfigForSavingIntoPersonalLevelSet(leveldir_former->name);
14912 SetAutomaticNumberOfGemsNeeded();
14914 CopyPlayfield(Tile, level.field);
14915 SaveLevel(level_nr);
14917 level.changed = FALSE;
14921 char level_saved_msg[64];
14923 if (leveldir_former->readonly)
14924 sprintf(level_saved_msg,
14925 "Level saved as level %d into personal level set!",
14928 strcpy(level_saved_msg, "Level saved!");
14930 Request(level_saved_msg, REQ_CONFIRM);
14934 // "cd" back to copied-from levelset (in case of saved read-only level)
14935 leveldir_current = leveldir_former;
14936 level_nr = level_nr_former;
14941 case GADGET_ID_TEST:
14942 if (LevelChanged())
14943 level.game_version = GAME_VERSION_ACTUAL;
14945 CopyPlayfield(level.field, TileBackup);
14946 CopyPlayfield(Tile, level.field);
14948 CopyNativeLevel_RND_to_Native(&level);
14950 UnmapLevelEditorGadgets();
14951 UndrawSpecialEditorDoor();
14953 CloseDoor(DOOR_CLOSE_ALL);
14955 // needed before playing if editor playfield area has different size
14956 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
14958 // redraw_mask = REDRAW_ALL;
14960 level_editor_test_game = TRUE;
14962 StartGameActions(FALSE, setup.autorecord, level.random_seed);
14966 case GADGET_ID_EXIT:
14967 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
14971 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
14972 id <= GADGET_ID_ELEMENTLIST_LAST)
14974 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
14976 new_element = editor_elements[element_position + element_shift];
14978 if (IS_EDITOR_CASCADE(new_element))
14982 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
14984 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
14985 boolean *cascade_value = editor_elements_info[i].setup_cascade_value;
14987 if (*cascade_element == new_element)
14989 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
14990 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
14992 // update element selection list
14993 ReinitializeElementList();
14994 ModifyEditorElementList();
14996 // update cascading gadget info text
14997 PrintEditorGadgetInfoText(level_editor_gadget[id]);
14999 // save current editor cascading state
15000 SaveSetup_EditorCascade();
15009 if (last_custom_copy_mode != -1)
15011 if (CopyCustomElement(properties_element, new_element,
15012 last_custom_copy_mode))
15014 ClickOnGadget(level_editor_gadget[last_drawing_function],
15017 last_custom_copy_mode = -1;
15023 // change element of button used to show palette
15024 if (editor.palette.show_on_element_buttons)
15025 button = last_button;
15027 PickDrawingElement(button, new_element);
15029 if (!stick_element_properties_window &&
15030 drawing_function != GADGET_ID_PICK_ELEMENT &&
15031 !(GetKeyModState() & KMOD_Control))
15033 properties_element = new_element;
15034 if (edit_mode == ED_MODE_PROPERTIES)
15035 DrawPropertiesWindow();
15038 if (drawing_function == GADGET_ID_PICK_ELEMENT)
15039 ClickOnGadget(level_editor_gadget[last_drawing_function],
15042 if (!use_permanent_palette)
15043 ChangeEditModeWindow(last_edit_mode);
15046 else if (gi->event.type == GD_EVENT_PRESSED)
15047 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
15048 else if (gi->event.type == GD_EVENT_RELEASED)
15049 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
15050 else if (gi->event.type == GD_EVENT_MOVING)
15051 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
15053 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
15059 void HandleLevelEditorKeyInput(Key key)
15061 char letter = getCharFromKey(key);
15063 if (drawing_function == GADGET_ID_TEXT &&
15064 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
15067 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
15068 else if (key == KSYM_Delete || key == KSYM_BackSpace)
15069 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
15070 else if (key == KSYM_Return)
15071 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
15072 else if (key == KSYM_Escape)
15073 DrawLevelText(0, 0, 0, TEXT_END);
15078 int id = GADGET_ID_NONE;
15079 int new_element_shift = element_shift;
15080 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
15081 int button = MB_LEFTBUTTON;
15087 id = GADGET_ID_SCROLL_LEFT;
15090 id = GADGET_ID_SCROLL_RIGHT;
15093 id = GADGET_ID_SCROLL_UP;
15096 id = GADGET_ID_SCROLL_DOWN;
15100 case KSYM_Page_Down:
15101 step *= (key == KSYM_Page_Up ? -1 : +1);
15102 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
15104 if (element_shift < 0)
15106 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15107 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15109 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15110 GDI_SCROLLBAR_ITEM_POSITION,
15111 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15113 ModifyEditorElementList();
15119 element_shift = (key == KSYM_Home ? 0 :
15120 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
15122 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15123 GDI_SCROLLBAR_ITEM_POSITION,
15124 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15126 ModifyEditorElementList();
15133 // this is needed to prevent interference with running "True X-Mouse"
15134 if (GetKeyModStateFromEvents() & KMOD_Control)
15137 // check for last or next editor cascade block in element list
15138 for (i = 0; i < num_editor_elements; i++)
15140 if ((key == KSYM_Insert && i == element_shift) ||
15141 (key == KSYM_Delete && new_element_shift > element_shift))
15144 // jump to next cascade block (or to start of element list)
15145 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
15146 new_element_shift = i;
15149 if (i < num_editor_elements)
15150 element_shift = new_element_shift;
15152 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
15153 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
15155 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
15156 GDI_SCROLLBAR_ITEM_POSITION,
15157 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
15159 ModifyEditorElementList();
15164 if (edit_mode == ED_MODE_DRAWING)
15165 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
15166 else if (edit_mode == ED_MODE_LEVELCONFIG)
15167 HandleControlButtons(level_editor_gadget[GADGET_ID_CONF]);
15168 else if (edit_mode == ED_MODE_PROPERTIES)
15169 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
15170 else if (edit_mode == ED_MODE_PALETTE)
15171 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
15172 else // should never happen
15173 ChangeEditModeWindow(ED_MODE_DRAWING);
15181 if (id != GADGET_ID_NONE)
15182 ClickOnGadget(level_editor_gadget[id], button);
15183 else if (letter == '1' || letter == '?')
15184 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
15185 else if (letter == '2')
15186 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
15187 else if (letter == '3')
15188 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
15189 else if (letter == '.')
15190 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
15191 else if (letter == 'U')
15192 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
15193 else if (letter == '-' || key == KSYM_KP_Subtract)
15194 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
15195 else if (letter == '0' || key == KSYM_KP_0)
15196 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
15197 else if (letter == '+' || key == KSYM_KP_Add ||
15198 letter == '=') // ("Shift-=" is "+" on US keyboards)
15199 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
15200 else if (key == KSYM_Return ||
15201 key == KSYM_space ||
15202 key == setup.shortcut.toggle_pause)
15203 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
15205 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
15206 if (letter && letter == controlbutton_info[i].shortcut)
15207 if (!anyTextGadgetActive())
15208 ClickOnGadget(level_editor_gadget[i], button);
15210 if (draw_with_brush)
15214 else if (letter == 'y')
15216 else if (letter == 'z')
15221 static void HandleLevelEditorIdle_Properties(void)
15223 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
15224 int x = editor.settings.element_graphic.x + element_border;
15225 int y = editor.settings.element_graphic.y + element_border;
15226 static DelayCounter action_delay = { 0 };
15229 action_delay.value = GameFrameDelay;
15231 if (!DelayReached(&action_delay))
15234 for (i = 0; i < ED_NUM_SELECTBOX; i++)
15236 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
15238 if (gi->mapped && gi->active && gi->selectbox.open)
15242 DrawEditorElementAnimation(SX + x, SY + y);
15244 redraw_mask |= REDRAW_FIELD;
15246 FrameCounter++; // increase animation frame counter
15249 static void HandleLevelEditorIdle_Drawing(void)
15251 static boolean last_highlighted = FALSE;
15252 static boolean last_highlighted_similar = FALSE;
15253 boolean highlighted = (GetKeyModState() & KMOD_Alt);
15254 boolean highlighted_similar = (GetKeyModState() & KMOD_Shift);
15256 if (highlighted != last_highlighted ||
15257 (highlighted && highlighted_similar != last_highlighted_similar))
15259 DrawAreaElementHighlight(highlighted, highlighted_similar);
15261 redraw_mask |= REDRAW_FIELD;
15264 last_highlighted = highlighted;
15265 last_highlighted_similar = highlighted_similar;
15268 void HandleLevelEditorIdle(void)
15270 if (edit_mode == ED_MODE_PROPERTIES)
15271 HandleLevelEditorIdle_Properties();
15272 else if (edit_mode == ED_MODE_DRAWING)
15273 HandleLevelEditorIdle_Drawing();
15276 static void ClearEditorGadgetInfoText(void)
15278 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
15281 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
15283 char infotext[MAX_OUTPUT_LINESIZE + 1];
15284 int max_infotext_len = getMaxInfoTextLength();
15286 if (gi == NULL || strlen(gi->info_text) == 0)
15289 strncpy(infotext, gi->info_text, max_infotext_len);
15290 infotext[max_infotext_len] = '\0';
15292 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
15294 int key = controlbutton_info[gi->custom_id].shortcut;
15298 char shortcut[MAX_OUTPUT_LINESIZE + 1];
15300 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
15301 sprintf(shortcut, " ('.' or '%c')", key);
15302 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
15303 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
15304 else if (gi->custom_id == GADGET_ID_TEST)
15305 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
15306 else if (gi->custom_id == GADGET_ID_UNDO)
15307 sprintf(shortcut, " ('%c/Shift-U')", key);
15308 else if (gi->custom_id == GADGET_ID_ZOOM)
15309 sprintf(shortcut, " ('%c', '0', '-')", key);
15311 sprintf(shortcut, " ('%s%c')",
15312 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
15314 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
15315 strcat(infotext, shortcut);
15319 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
15322 void HandleEditorGadgetInfoText(void *ptr)
15324 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
15326 if (game_status != GAME_MODE_EDITOR)
15329 ClearEditorGadgetInfoText();
15331 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
15334 // misuse this function to delete brush cursor, if needed
15335 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
15336 DeleteBrushFromCursor();
15338 PrintEditorGadgetInfoText(gi);
15341 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
15343 int id = gi->custom_id;
15344 int type_id = gi->custom_type_id;
15345 int sx = gi->event.x;
15346 int sy = gi->event.y;
15347 int lx = sx + level_xpos;
15348 int ly = sy + level_ypos;
15349 int min_sx = 0, min_sy = 0;
15350 int max_sx = gi->drawing.area_xsize - 1;
15351 int max_sy = gi->drawing.area_ysize - 1;
15352 int actual_drawing_function = drawing_function;
15353 int max_infotext_len = getMaxInfoTextLength();
15354 char infotext[MAX_OUTPUT_LINESIZE + 1];
15356 infotext[0] = '\0'; // start with empty info text
15358 // pressed Control key: simulate picking element
15359 if (GetKeyModState() & KMOD_Control)
15360 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
15362 ClearEditorGadgetInfoText();
15364 if (gi->event.type == GD_EVENT_INFO_LEAVING)
15367 // make sure to stay inside drawing area boundaries
15368 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
15369 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
15371 if (id == GADGET_ID_DRAWING_LEVEL)
15375 int min_lx = 0, min_ly = 0;
15376 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
15378 // get positions inside level field
15379 lx = sx + level_xpos;
15380 ly = sy + level_ypos;
15382 // make sure to stay inside level field boundaries
15383 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
15384 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
15386 // correct drawing area positions accordingly
15387 sx = lx - level_xpos;
15388 sy = ly - level_ypos;
15391 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15393 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
15395 static int start_lx = 0;
15396 static int start_ly = 0;
15399 if (gi->event.type == GD_EVENT_PRESSED)
15405 switch (actual_drawing_function)
15407 case GADGET_ID_SINGLE_ITEMS:
15408 text = "Drawing single items";
15410 case GADGET_ID_CONNECTED_ITEMS:
15411 text = "Drawing connected items";
15413 case GADGET_ID_LINE:
15414 text = "Drawing line";
15416 case GADGET_ID_ARC:
15417 text = "Drawing arc";
15419 case GADGET_ID_TEXT:
15420 text = "Setting text cursor";
15422 case GADGET_ID_RECTANGLE:
15423 text = "Drawing rectangle";
15425 case GADGET_ID_FILLED_BOX:
15426 text = "Drawing filled box";
15428 case GADGET_ID_FLOOD_FILL:
15429 text = "Flood fill";
15431 case GADGET_ID_GRAB_BRUSH:
15432 text = "Grabbing brush";
15434 case GADGET_ID_PICK_ELEMENT:
15435 text = "Picking element";
15439 text = "Drawing position";
15443 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15444 sprintf(infotext, "%s: %d, %d", text, lx, ly);
15446 sprintf(infotext, "%s: %d, %d", text,
15447 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
15449 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15450 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
15452 sprintf(infotext, "Level position: %d, %d", lx, ly);
15455 // misuse this function to draw brush cursor, if needed
15456 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
15458 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
15459 CopyBrushToCursor(sx, sy);
15461 DeleteBrushFromCursor();
15464 if (!draw_with_brush)
15465 UpdateBrushPosition(sx, sy);
15467 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
15469 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
15470 int element = drawingarea_info[type_id].value[pos];
15472 strncpy(infotext, getElementInfoText(element), max_infotext_len);
15476 if (id == GADGET_ID_CUSTOM_CONTENT)
15477 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
15478 else if (id == GADGET_ID_GROUP_CONTENT)
15479 sprintf(infotext, "group element position: %d", sx + 1);
15480 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
15481 id <= GADGET_ID_YAMYAM_CONTENT_7)
15482 sprintf(infotext, "content area %d position: %d, %d",
15483 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
15484 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
15485 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
15486 sprintf(infotext, "content area %d position: %d, %d",
15487 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
15488 else if (id == GADGET_ID_ANDROID_CONTENT)
15489 sprintf(infotext, "android element position: %d", sx + 1);
15490 else if (drawingarea_info[type_id].infotext != NULL)
15491 strcpy(infotext, drawingarea_info[type_id].infotext);
15494 infotext[max_infotext_len] = '\0';
15496 if (strlen(infotext) > 0)
15497 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
15500 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
15501 boolean quick_quit)
15503 if (!ask_if_level_has_changed ||
15505 Request("Level has changed! Exit without saving?",
15506 REQ_ASK | REQ_STAY_OPEN))
15508 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
15509 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
15511 // draw normal door
15512 UndrawSpecialEditorDoor();
15514 // use door animation if door 1 viewport is unchanged and contains toolbox
15515 if (useEditorDoorAnimation())
15516 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
15518 // close editor doors if viewport definition is the same as in main menu
15519 if (vp_door_1->x == DX &&
15520 vp_door_1->y == DY &&
15521 vp_door_1->width == DXSIZE &&
15522 vp_door_1->height == DYSIZE &&
15523 vp_door_2->x == VX &&
15524 vp_door_2->y == VY &&
15525 vp_door_2->width == VXSIZE &&
15526 vp_door_2->height == VYSIZE)
15527 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
15529 SetDoorState(DOOR_CLOSE_ALL);
15534 FadeSkipNextFadeIn();
15536 SetGameStatus(GAME_MODE_MAIN);
15542 if (!global.use_envelope_request)
15544 CloseDoor(DOOR_CLOSE_1);
15545 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);