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_LEVELINFO_LEVEL,
607 GADGET_ID_LEVELINFO_LEVELSET,
608 GADGET_ID_LEVELINFO_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_CUSTOM_INDESTRUCTIBLE,
691 GADGET_ID_CUSTOM_CAN_EXPLODE,
692 GADGET_ID_CUSTOM_EXPLODE_FIRE,
693 GADGET_ID_CUSTOM_EXPLODE_SMASH,
694 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
695 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
696 GADGET_ID_CUSTOM_DEADLY,
697 GADGET_ID_CUSTOM_CAN_MOVE,
698 GADGET_ID_CUSTOM_CAN_FALL,
699 GADGET_ID_CUSTOM_CAN_SMASH,
700 GADGET_ID_CUSTOM_SLIPPERY,
701 GADGET_ID_CUSTOM_ACCESSIBLE,
702 GADGET_ID_CUSTOM_GRAV_REACHABLE,
703 GADGET_ID_CUSTOM_USE_LAST_VALUE,
704 GADGET_ID_CUSTOM_USE_GRAPHIC,
705 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
706 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
707 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
708 GADGET_ID_CUSTOM_CAN_CHANGE,
709 GADGET_ID_CHANGE_USE_CONTENT,
710 GADGET_ID_CHANGE_USE_EXPLOSION,
711 GADGET_ID_CHANGE_ONLY_COMPLETE,
712 GADGET_ID_CHANGE_USE_RANDOM,
713 GADGET_ID_CHANGE_HAS_ACTION,
714 GADGET_ID_CHANGE_DELAY,
715 GADGET_ID_CHANGE_BY_DIRECT_ACT,
716 GADGET_ID_CHANGE_BY_OTHER_ACT,
718 NUM_STATIC_GADGET_IDS
721 // gadgets for buttons in element list (dynamic)
722 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
723 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
724 ED_NUM_ELEMENTLIST_BUTTONS - 1)
726 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
728 // radio button numbers
732 RADIO_NR_DRAWING_TOOLBOX,
733 RADIO_NR_RANDOM_ELEMENTS
736 // values for counter gadgets
739 ED_COUNTER_ID_SELECT_LEVEL,
740 ED_COUNTER_ID_LEVEL_XSIZE,
741 ED_COUNTER_ID_LEVEL_YSIZE,
742 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
743 ED_COUNTER_ID_LEVEL_TIMELIMIT,
744 ED_COUNTER_ID_LEVEL_TIMESCORE,
745 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
746 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
747 ED_COUNTER_ID_LEVEL_RANDOM,
748 ED_COUNTER_ID_ELEMENT_VALUE1,
749 ED_COUNTER_ID_ELEMENT_VALUE2,
750 ED_COUNTER_ID_ELEMENT_VALUE3,
751 ED_COUNTER_ID_ELEMENT_VALUE4,
752 ED_COUNTER_ID_YAMYAM_CONTENT,
753 ED_COUNTER_ID_BALL_CONTENT,
754 ED_COUNTER_ID_ANDROID_CONTENT,
755 ED_COUNTER_ID_ENVELOPE_XSIZE,
756 ED_COUNTER_ID_ENVELOPE_YSIZE,
757 ED_COUNTER_ID_INVENTORY_SIZE,
758 ED_COUNTER_ID_MM_BALL_CONTENT,
759 ED_COUNTER_ID_CUSTOM_SCORE,
760 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
761 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
762 ED_COUNTER_ID_CUSTOM_VALUE_RND,
763 ED_COUNTER_ID_PUSH_DELAY_FIX,
764 ED_COUNTER_ID_PUSH_DELAY_RND,
765 ED_COUNTER_ID_DROP_DELAY_FIX,
766 ED_COUNTER_ID_DROP_DELAY_RND,
767 ED_COUNTER_ID_MOVE_DELAY_FIX,
768 ED_COUNTER_ID_MOVE_DELAY_RND,
769 ED_COUNTER_ID_STEP_DELAY_FIX,
770 ED_COUNTER_ID_STEP_DELAY_RND,
771 ED_COUNTER_ID_EXPLOSION_DELAY,
772 ED_COUNTER_ID_IGNITION_DELAY,
773 ED_COUNTER_ID_GROUP_CONTENT,
774 ED_COUNTER_ID_CHANGE_DELAY_FIX,
775 ED_COUNTER_ID_CHANGE_DELAY_RND,
776 ED_COUNTER_ID_CHANGE_CONT_RND,
778 ED_NUM_COUNTERBUTTONS
781 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
782 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
783 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
784 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
785 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
786 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
788 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
789 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
790 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
791 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
792 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
793 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
795 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
796 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
798 // values for scrollbutton gadgets
801 ED_SCROLLBUTTON_ID_AREA_UP,
802 ED_SCROLLBUTTON_ID_AREA_DOWN,
803 ED_SCROLLBUTTON_ID_AREA_LEFT,
804 ED_SCROLLBUTTON_ID_AREA_RIGHT,
805 ED_SCROLLBUTTON_ID_LIST_UP,
806 ED_SCROLLBUTTON_ID_LIST_DOWN,
811 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
812 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
814 // values for scrollbar gadgets
817 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
818 ED_SCROLLBAR_ID_AREA_VERTICAL,
819 ED_SCROLLBAR_ID_LIST_VERTICAL,
824 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
825 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
827 // values for text input gadgets
830 ED_TEXTINPUT_ID_LEVEL_NAME,
831 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
832 ED_TEXTINPUT_ID_LEVELSET_NAME,
833 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
834 ED_TEXTINPUT_ID_ELEMENT_NAME,
839 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
840 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
842 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
843 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
845 // values for text area gadgets
848 ED_TEXTAREA_ID_ENVELOPE_INFO,
853 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
854 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
856 // values for selectbox gadgets
859 ED_SELECTBOX_ID_TIME_OR_STEPS,
860 ED_SELECTBOX_ID_TIME_SCORE_BASE,
861 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
862 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
863 ED_SELECTBOX_ID_WIND_DIRECTION,
864 ED_SELECTBOX_ID_PLAYER_SPEED,
865 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
866 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
867 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
868 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
869 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
870 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
871 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
872 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
873 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
874 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
875 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
876 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
877 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
878 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
879 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
880 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
881 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
882 ED_SELECTBOX_ID_CHANGE_SIDE,
883 ED_SELECTBOX_ID_CHANGE_PLAYER,
884 ED_SELECTBOX_ID_CHANGE_PAGE,
885 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
886 ED_SELECTBOX_ID_ACTION_TYPE,
887 ED_SELECTBOX_ID_ACTION_MODE,
888 ED_SELECTBOX_ID_ACTION_ARG,
889 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
890 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
895 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
896 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
898 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
899 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
901 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
902 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
903 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
904 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
905 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
906 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
908 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
909 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
911 // values for textbutton gadgets
914 ED_TEXTBUTTON_ID_LEVELINFO_LEVEL,
915 ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET,
916 ED_TEXTBUTTON_ID_LEVELINFO_EDITOR,
917 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
918 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
919 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
920 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
921 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
922 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
923 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
924 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
925 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
926 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
931 #define ED_TAB_BUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
932 #define ED_TAB_BUTTON_ID_LEVELINFO_LAST ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
934 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
935 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
937 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
938 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
940 // values for graphicbutton gadgets
943 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
944 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
945 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
946 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
948 ED_NUM_GRAPHICBUTTONS
951 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
952 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
954 // values for checkbutton gadgets
957 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
958 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
959 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
960 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
961 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
962 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
963 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
964 ED_CHECKBUTTON_ID_STICK_ELEMENT,
965 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
966 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
967 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
968 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
969 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
970 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
971 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
972 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
973 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
974 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
975 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
976 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
977 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
978 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
979 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
980 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
981 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
982 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
983 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
984 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
985 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
986 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
987 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
988 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
989 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
990 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
991 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
992 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
993 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
994 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
995 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
996 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
997 ED_CHECKBUTTON_ID_MM_LASER_RED,
998 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
999 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1000 ED_CHECKBUTTON_ID_DF_LASER_RED,
1001 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1002 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1003 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1004 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1005 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1006 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1007 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1008 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1009 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1010 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1011 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1012 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1013 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1014 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1015 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1016 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1017 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1018 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1019 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1020 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1021 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1022 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1023 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1024 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1025 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1026 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1027 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1032 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1033 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1035 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1036 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1038 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1039 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1041 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1042 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1043 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1044 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1045 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1046 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1048 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1049 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1051 // values for radiobutton gadgets
1054 ED_RADIOBUTTON_ID_PERCENTAGE,
1055 ED_RADIOBUTTON_ID_QUANTITY,
1060 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1061 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1063 // values for drawing area gadgets
1066 ED_DRAWING_ID_DRAWING_LEVEL,
1067 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1068 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1069 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1070 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1071 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1072 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1073 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1074 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1075 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1076 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1077 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1078 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1079 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1080 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1081 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1082 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1083 ED_DRAWING_ID_ANDROID_CONTENT,
1084 ED_DRAWING_ID_AMOEBA_CONTENT,
1085 ED_DRAWING_ID_START_ELEMENT,
1086 ED_DRAWING_ID_ARTWORK_ELEMENT,
1087 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1088 ED_DRAWING_ID_INVENTORY_CONTENT,
1089 ED_DRAWING_ID_MM_BALL_CONTENT,
1090 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1091 ED_DRAWING_ID_CUSTOM_CONTENT,
1092 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1093 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1094 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1095 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1096 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1097 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1098 ED_DRAWING_ID_GROUP_CONTENT,
1099 ED_DRAWING_ID_RANDOM_BACKGROUND,
1101 ED_NUM_DRAWING_AREAS
1104 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1105 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1108 // ----------------------------------------------------------------------------
1109 // some internally used definitions
1110 // ----------------------------------------------------------------------------
1112 // values for CopyLevelToUndoBuffer()
1113 #define UNDO_IMMEDIATE 0
1114 #define UNDO_ACCUMULATE 1
1116 // values for scrollbars
1117 #define ED_SCROLL_NO 0
1118 #define ED_SCROLL_LEFT 1
1119 #define ED_SCROLL_RIGHT 2
1120 #define ED_SCROLL_UP 4
1121 #define ED_SCROLL_DOWN 8
1123 // screens in the level editor
1124 #define ED_MODE_DRAWING 0
1125 #define ED_MODE_INFO 1
1126 #define ED_MODE_PROPERTIES 2
1127 #define ED_MODE_PALETTE 3
1129 // sub-screens in the global settings section
1130 #define ED_MODE_LEVELINFO_LEVEL ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
1131 #define ED_MODE_LEVELINFO_LEVELSET ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET
1132 #define ED_MODE_LEVELINFO_EDITOR ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
1134 // sub-screens in the element properties section
1135 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1136 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1137 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1138 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1139 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1141 // how many steps can be cancelled
1142 #define NUM_UNDO_STEPS (64 + 1)
1144 // values for elements with score for certain actions
1146 #define MAX_SCORE 999
1148 // values for elements with count for collecting
1149 #define MIN_COLLECT_COUNT 0
1150 #define MAX_COLLECT_COUNT 999
1152 // values for random placement
1153 #define RANDOM_USE_PERCENTAGE 0
1154 #define RANDOM_USE_QUANTITY 1
1156 // values for level set save mode
1157 #define LEVELSET_SAVE_MODE_UPDATE 0
1158 #define LEVELSET_SAVE_MODE_CREATE 1
1160 // default value for element tile size in drawing area
1161 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1162 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1165 // ----------------------------------------------------------------------------
1166 // some internally used data structure definitions
1167 // ----------------------------------------------------------------------------
1173 struct XYTileSize *pos;
1177 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1179 // note: some additional characters are already reserved for "cheat mode"
1180 // shortcuts (":XYZ" style) -- for details, see "events.c"
1182 // ---------- toolbox control buttons ---------------------------------------
1185 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1186 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1187 "draw single items", 's'
1190 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1191 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1192 "draw connected items", 'd'
1195 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1196 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1200 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1201 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1205 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1206 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1207 "draw outline rectangles", 'r'
1210 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1211 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1212 "draw filled rectangles", 'R'
1215 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1216 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1217 "wrap (rotate) level up", 0
1220 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1221 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1222 "enter text elements", 't'
1225 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1226 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1230 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1231 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1232 "wrap (rotate) level left", 0
1235 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1236 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1237 "zoom level tile size", '+'
1240 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1241 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1242 "wrap (rotate) level right", 0
1245 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1246 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1247 "random element placement", 0
1250 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1251 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1255 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1256 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1257 "wrap (rotate) level down", 0
1260 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1261 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1262 "pick drawing element", ','
1265 // ---------- level control buttons -----------------------------------------
1268 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1269 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1270 "undo/redo last operation", 'u'
1273 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_INFO,
1274 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1275 "properties of level", 'I'
1278 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1279 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1283 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1284 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1288 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1289 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1293 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1294 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1295 "exit level editor", 'E'
1298 // ---------- CE and GE control buttons -------------------------------------
1301 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1302 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1303 "copy settings from other element", 0
1306 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1307 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1308 "copy settings to other element", 0
1311 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1312 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1313 "exchange element with other element", 0
1316 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1317 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1318 "copy settings from this element", 0
1321 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1322 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1323 "paste settings to this element", 0
1326 // ---------- palette control buttons ---------------------------------------
1329 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1330 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1331 "properties of drawing element", 'p'
1334 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1335 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1336 "properties of drawing element 1", '1'
1339 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1340 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1341 "properties of drawing element 2", '2'
1344 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1345 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1346 "properties of drawing element 3", '3'
1349 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1350 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1351 "show list of elements", 'e'
1355 static int random_placement_value = 10;
1356 static int random_placement_method = RANDOM_USE_QUANTITY;
1357 static int random_placement_background_element = EL_SAND;
1358 static boolean random_placement_background_restricted = FALSE;
1359 static boolean stick_element_properties_window = FALSE;
1360 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1361 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1362 static struct ElementChangeInfo custom_element_change;
1363 static struct ElementGroupInfo group_element_info;
1364 static struct ElementInfo custom_element;
1366 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1367 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1368 static int levelset_num_levels = 100;
1369 static boolean levelset_use_levelset_artwork = FALSE;
1370 static boolean levelset_copy_level_template = FALSE;
1371 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1376 int min_value, max_value;
1377 int gadget_id_down, gadget_id_up;
1379 int gadget_id_align;
1381 char *text_above, *text_left, *text_right;
1382 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1384 // ---------- current level number ------------------------------------------
1387 -1, -1, // these values are not constant, but can change at runtime
1389 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1390 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1395 // ---------- level and editor settings -------------------------------------
1398 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1399 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1400 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1401 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1403 "playfield size:", NULL, "width",
1406 -1, ED_LEVEL_SETTINGS_YPOS(4),
1407 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1408 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1409 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1411 NULL, " ", "height",
1414 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1416 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1417 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1419 NULL, "number of gems to collect:", NULL
1422 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1424 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1425 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1427 "time or step limit to solve level:", NULL, NULL
1430 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1432 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1433 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1434 &level.score[SC_TIME_BONUS],
1435 "score for time or steps left:", NULL, NULL
1438 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1440 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1441 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1443 NULL, "random seed:", "(0 => random)"
1446 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1448 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1449 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1450 &levelset_num_levels,
1451 "number of levels:", NULL, NULL,
1454 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1456 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1457 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1458 &random_placement_value,
1459 "random element placement:", NULL, "in"
1462 // ---------- element settings: configure (various elements) ----------------
1465 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1466 MIN_SCORE, MAX_SCORE,
1467 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1468 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1469 NULL, // will be set when used
1473 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1474 MIN_SCORE, MAX_SCORE,
1475 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1476 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1477 NULL, // will be set when used
1481 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1482 MIN_SCORE, MAX_SCORE,
1483 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1484 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1485 NULL, // will be set when used
1489 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1490 MIN_SCORE, MAX_SCORE,
1491 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1492 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1493 NULL, // will be set when used
1497 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1498 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1499 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1500 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1501 &level.num_yamyam_contents,
1502 NULL, NULL, "number of content areas"
1505 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1506 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1507 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1508 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1509 &level.num_ball_contents,
1510 NULL, NULL, "number of content areas"
1513 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1514 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1515 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1516 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1517 &level.num_android_clone_elements,
1518 NULL, NULL, "number of clonable elements"
1521 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1522 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1523 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1524 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1525 NULL, // will be set when used
1526 NULL, NULL, "width",
1529 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1530 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1531 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1532 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1533 NULL, // will be set when used
1534 NULL, " ", "height",
1537 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1538 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1539 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1540 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1541 &level.initial_inventory_size[0],
1542 NULL, NULL, "number of inventory elements"
1545 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1546 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1547 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1548 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1549 &level.num_mm_ball_contents,
1550 NULL, NULL, "number of content elements"
1553 // ---------- element settings: configure 1 (custom elements) ---------------
1556 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1557 MIN_SCORE, MAX_SCORE,
1558 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1559 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1560 &custom_element.collect_score_initial,
1561 NULL, "CE score", " "
1564 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1565 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1566 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1567 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1568 &custom_element.collect_count_initial,
1569 NULL, "CE count", NULL
1572 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1574 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1575 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1576 &custom_element.ce_value_fixed_initial,
1577 NULL, "CE value", NULL
1580 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1582 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1583 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1584 &custom_element.ce_value_random_initial,
1585 NULL, "+random", NULL
1588 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1590 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1591 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1592 &custom_element.push_delay_fixed,
1593 NULL, "push delay", NULL
1596 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1598 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1599 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1600 &custom_element.push_delay_random,
1601 NULL, "+random", NULL
1604 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1606 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1607 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1608 &custom_element.drop_delay_fixed,
1609 NULL, "drop delay", NULL
1612 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1614 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1615 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1616 &custom_element.drop_delay_random,
1617 NULL, "+random", NULL
1620 // ---------- element settings: configure 2 (custom elements) ---------------
1623 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1625 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1626 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1627 &custom_element.move_delay_fixed,
1628 NULL, "move delay", NULL
1631 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1633 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1634 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1635 &custom_element.move_delay_random,
1636 NULL, "+random", NULL
1639 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1641 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1642 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1643 &custom_element.step_delay_fixed,
1644 NULL, "step delay", NULL
1647 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1649 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1650 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1651 &custom_element.step_delay_random,
1652 NULL, "+random", NULL
1655 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1657 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1658 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1659 &custom_element.explosion_delay,
1660 NULL, "explosion delay", NULL
1663 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1665 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1666 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1667 &custom_element.ignition_delay,
1668 NULL, "ignition delay", "(by fire)"
1671 // ---------- element settings: configure (group elements) ------------------
1674 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1675 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1676 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1677 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1678 &group_element_info.num_elements,
1679 NULL, NULL, "number of elements in group"
1682 // ---------- element settings: advanced (custom elements) ------------------
1685 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1687 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1688 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1689 &custom_element_change.delay_fixed,
1690 NULL, "CE delay", NULL,
1693 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1695 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1696 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1697 &custom_element_change.delay_random,
1698 NULL, "+random", NULL
1701 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1703 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1704 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1705 &custom_element_change.random_percentage,
1706 NULL, "use random replace:", "%"
1716 char *text_above, *infotext;
1717 } textinput_info[ED_NUM_TEXTINPUT] =
1720 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1721 GADGET_ID_LEVEL_NAME,
1724 "Title:", "Title for this level"
1727 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1728 GADGET_ID_LEVEL_AUTHOR,
1729 MAX_LEVEL_AUTHOR_LEN,
1731 "Author:", "Author for this level"
1734 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1735 GADGET_ID_LEVELSET_NAME,
1738 "Title:", "Title for this or new level set"
1741 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1742 GADGET_ID_LEVELSET_AUTHOR,
1743 MAX_LEVEL_AUTHOR_LEN,
1745 "Author:", "Author for this or new level set"
1748 -1, -1, // these values are not constant, but can change at runtime
1749 GADGET_ID_ELEMENT_NAME,
1750 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1751 custom_element.description,
1752 NULL, "Element name"
1762 char *text_above, *text_above_cropped, *infotext;
1763 } textarea_info[ED_NUM_TEXTAREAS] =
1766 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1767 GADGET_ID_ENVELOPE_INFO,
1768 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1770 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1774 static struct ValueTextInfo options_time_or_steps[] =
1782 static struct ValueTextInfo options_time_score_base[] =
1784 { 1, "per second/step" },
1785 { 10, "per 10 seconds/steps" },
1790 static struct ValueTextInfo options_game_engine_type[] =
1792 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1793 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1794 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1795 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1800 static struct ValueTextInfo options_levelset_save_mode[] =
1802 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1803 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1808 static struct ValueTextInfo options_wind_direction[] =
1810 { MV_START_NONE, "none" },
1811 { MV_START_LEFT, "left" },
1812 { MV_START_RIGHT, "right" },
1813 { MV_START_UP, "up" },
1814 { MV_START_DOWN, "down" },
1819 static struct ValueTextInfo options_player_speed[] =
1826 { 16, "very fast" },
1827 { 32, "ultrafast" },
1832 static struct ValueTextInfo options_access_type[] =
1834 { EP_WALKABLE, "walkable" },
1835 { EP_PASSABLE, "passable" },
1840 static struct ValueTextInfo options_access_layer[] =
1842 { EP_ACCESSIBLE_OVER, "over" },
1843 { EP_ACCESSIBLE_INSIDE, "inside" },
1844 { EP_ACCESSIBLE_UNDER, "under" },
1849 static struct ValueTextInfo options_access_protected[] =
1851 { 0, "unprotected" },
1857 static struct ValueTextInfo options_access_direction[] =
1859 { MV_NO_DIRECTION, "no direction" },
1860 { MV_LEFT, "left" },
1861 { MV_RIGHT, "right" },
1863 { MV_DOWN, "down" },
1864 { MV_LEFT | MV_UP, "left + up" },
1865 { MV_LEFT | MV_DOWN, "left + down" },
1866 { MV_RIGHT | MV_UP, "right + up" },
1867 { MV_RIGHT | MV_DOWN, "right + down" },
1868 { MV_HORIZONTAL, "horizontal" },
1869 { MV_VERTICAL, "vertical" },
1870 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1871 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1872 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1873 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1874 { MV_ALL_DIRECTIONS, "all directions" },
1879 static struct ValueTextInfo options_walk_to_action[] =
1881 { EP_DIGGABLE, "diggable" },
1882 { EP_COLLECTIBLE_ONLY, "collectible" },
1883 { EP_DROPPABLE, "collectible & droppable" },
1884 { EP_THROWABLE, "collectible & throwable" },
1885 { EP_PUSHABLE, "pushable" },
1890 static struct ValueTextInfo options_move_pattern[] =
1892 { MV_LEFT, "left" },
1893 { MV_RIGHT, "right" },
1895 { MV_DOWN, "down" },
1896 { MV_HORIZONTAL, "horizontal" },
1897 { MV_VERTICAL, "vertical" },
1898 { MV_ALL_DIRECTIONS, "all directions" },
1899 { MV_WIND_DIRECTION, "wind direction" },
1900 { MV_TOWARDS_PLAYER, "towards player" },
1901 { MV_AWAY_FROM_PLAYER, "away from player" },
1902 { MV_ALONG_LEFT_SIDE, "along left side" },
1903 { MV_ALONG_RIGHT_SIDE, "along right side" },
1904 { MV_TURNING_LEFT, "turning left" },
1905 { MV_TURNING_RIGHT, "turning right" },
1906 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1907 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1908 { MV_TURNING_RANDOM, "turning random" },
1909 { MV_MAZE_RUNNER, "maze runner style" },
1910 { MV_MAZE_HUNTER, "maze hunter style" },
1911 { MV_WHEN_PUSHED, "when pushed" },
1912 { MV_WHEN_DROPPED, "when dropped/thrown" },
1917 static struct ValueTextInfo options_move_direction[] =
1919 { MV_START_AUTOMATIC, "automatic" },
1920 { MV_START_LEFT, "left" },
1921 { MV_START_RIGHT, "right" },
1922 { MV_START_UP, "up" },
1923 { MV_START_DOWN, "down" },
1924 { MV_START_RANDOM, "random" },
1925 { MV_START_PREVIOUS, "previous" },
1930 static struct ValueTextInfo options_move_stepsize[] =
1932 { 0, "not moving" },
1937 { 16, "very fast" },
1938 { 32, "even faster" },
1943 static struct ValueTextInfo options_move_leave_type[] =
1945 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1946 { LEAVE_TYPE_LIMITED, "change it to" },
1951 static struct ValueTextInfo options_smash_targets[] =
1953 { EP_CAN_SMASH_PLAYER, "player" },
1955 { EP_CAN_SMASH_ENEMIES, "enemies" },
1957 { EP_CAN_SMASH_EVERYTHING, "everything" },
1962 static struct ValueTextInfo options_slippery_type[] =
1964 { SLIPPERY_ANY_RANDOM, "random" },
1965 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1966 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1967 { SLIPPERY_ONLY_LEFT, "only left" },
1968 { SLIPPERY_ONLY_RIGHT, "only right" },
1973 static struct ValueTextInfo options_deadliness[] =
1975 { EP_DONT_RUN_INTO, "running into" },
1976 { EP_DONT_COLLIDE_WITH, "colliding with" },
1977 { EP_DONT_GET_HIT_BY, "getting hit by" },
1978 { EP_DONT_TOUCH, "touching" },
1983 static struct ValueTextInfo options_explosion_type[] =
1985 { EXPLODES_3X3, "3x3" },
1986 { EXPLODES_CROSS, "3+3" },
1987 { EXPLODES_1X1, "1x1" },
1992 static struct ValueTextInfo options_time_units[] =
1995 { FRAMES_PER_SECOND, "seconds" },
2000 static struct ValueTextInfo options_change_direct_action[] =
2002 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2003 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2004 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2005 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2006 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2007 { CE_ENTERED_BY_PLAYER, "entered by player" },
2008 { CE_LEFT_BY_PLAYER, "left by player" },
2009 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2010 { CE_SWITCHED, "switched" },
2011 { CE_HITTING_SOMETHING, "hitting something" },
2012 { CE_HIT_BY_SOMETHING, "hit by something" },
2014 { CE_BLOCKED, "blocked" },
2016 { CE_IMPACT, "impact (on something)" },
2017 { CE_SMASHED, "smashed (from above)" },
2019 { CE_VALUE_CHANGES, "CE value changes" },
2020 { CE_SCORE_CHANGES, "CE score changes" },
2022 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2023 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2024 { CE_UNDEFINED, " " },
2025 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2026 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2027 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2028 { CE_UNDEFINED, " " },
2029 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2030 { CE_NEXT_TO_PLAYER, "next to player" },
2035 static struct ValueTextInfo options_change_other_action[] =
2037 { CE_PLAYER_TOUCHES_X, "player touches" },
2038 { CE_PLAYER_PRESSES_X, "player presses" },
2039 { CE_PLAYER_SWITCHES_X, "player switches" },
2040 { CE_PLAYER_SNAPS_X, "player snaps" },
2041 { CE_PLAYER_PUSHES_X, "player pushes" },
2042 { CE_PLAYER_ENTERS_X, "player enters" },
2043 { CE_PLAYER_LEAVES_X, "player leaves" },
2044 { CE_PLAYER_DIGS_X, "player digs" },
2045 { CE_PLAYER_COLLECTS_X, "player collects" },
2046 { CE_PLAYER_DROPS_X, "player drops/throws" },
2047 { CE_TOUCHING_X, "touching" },
2048 { CE_HITTING_X, "hitting" },
2049 { CE_DIGGING_X, "digging" },
2050 { CE_HIT_BY_X, "hit by" },
2051 { CE_SWITCH_OF_X, "switch of" },
2052 { CE_CHANGE_OF_X, "change by page of" },
2053 { CE_EXPLOSION_OF_X, "explosion of" },
2054 { CE_MOVE_OF_X, "move of" },
2055 { CE_CREATION_OF_X, "creation of" },
2056 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2057 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2058 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2059 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2060 { CE_UNDEFINED, " " },
2061 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2062 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2063 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2064 { CE_UNDEFINED, " " },
2065 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2066 { CE_PLAYER_NEXT_TO_X, "player next to" },
2067 { CE_NEXT_TO_X, "next to" },
2072 static struct ValueTextInfo options_change_trigger_side[] =
2074 { CH_SIDE_LEFT, "left" },
2075 { CH_SIDE_RIGHT, "right" },
2076 { CH_SIDE_TOP, "top" },
2077 { CH_SIDE_BOTTOM, "bottom" },
2078 { CH_SIDE_LEFT_RIGHT, "left/right" },
2079 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2080 { CH_SIDE_ANY, "any" },
2085 static struct ValueTextInfo options_change_trigger_player[] =
2087 { CH_PLAYER_1, "1" },
2088 { CH_PLAYER_2, "2" },
2089 { CH_PLAYER_3, "3" },
2090 { CH_PLAYER_4, "4" },
2091 { CH_PLAYER_ANY, "any" },
2096 static struct ValueTextInfo options_change_trigger_page[] =
2107 { (1u << 9), "10" },
2108 { (1u << 10), "11" },
2109 { (1u << 11), "12" },
2110 { (1u << 12), "13" },
2111 { (1u << 13), "14" },
2112 { (1u << 14), "15" },
2113 { (1u << 15), "16" },
2114 { (1u << 16), "17" },
2115 { (1u << 17), "18" },
2116 { (1u << 18), "19" },
2117 { (1u << 19), "20" },
2118 { (1u << 20), "21" },
2119 { (1u << 21), "22" },
2120 { (1u << 22), "23" },
2121 { (1u << 23), "24" },
2122 { (1u << 24), "25" },
2123 { (1u << 25), "26" },
2124 { (1u << 26), "27" },
2125 { (1u << 27), "28" },
2126 { (1u << 28), "29" },
2127 { (1u << 29), "30" },
2128 { (1u << 30), "31" },
2129 { (1u << 31), "32" },
2130 { CH_PAGE_ANY, "any" },
2135 static struct ValueTextInfo options_change_replace_when[] =
2137 { CP_WHEN_EMPTY, "empty" },
2138 { CP_WHEN_WALKABLE, "walkable" },
2139 { CP_WHEN_DIGGABLE, "diggable" },
2140 { CP_WHEN_COLLECTIBLE, "collectible" },
2141 { CP_WHEN_REMOVABLE, "removable" },
2142 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2147 static struct ValueTextInfo options_action_type[] =
2149 { CA_NO_ACTION, "no action" },
2150 { CA_UNDEFINED, " " },
2151 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2152 { CA_RESTART_LEVEL, "restart level" },
2153 { CA_SHOW_ENVELOPE, "show envelope" },
2154 { CA_SET_LEVEL_TIME, "set time" },
2155 { CA_SET_LEVEL_SCORE, "set score" },
2156 { CA_SET_LEVEL_GEMS, "set gems" },
2157 { CA_SET_LEVEL_WIND, "set wind dir." },
2158 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2159 { CA_UNDEFINED, " " },
2160 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2161 { CA_MOVE_PLAYER, "move player" },
2162 { CA_MOVE_PLAYER_NEW, "move player new" },
2163 { CA_EXIT_PLAYER, "exit player" },
2164 { CA_KILL_PLAYER, "kill player" },
2165 { CA_SET_PLAYER_KEYS, "set keys" },
2166 { CA_SET_PLAYER_SPEED, "set speed" },
2167 { CA_SET_PLAYER_SHIELD, "set shield" },
2168 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2169 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2170 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2171 { CA_UNDEFINED, " " },
2172 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2173 { CA_SET_CE_VALUE, "set CE value" },
2174 { CA_SET_CE_SCORE, "set CE score" },
2175 { CA_SET_CE_ARTWORK, "set CE artwork" },
2176 { CA_UNDEFINED, " " },
2177 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2178 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2183 static struct ValueTextInfo options_action_mode_none[] =
2185 { CA_MODE_UNDEFINED, " " },
2190 static struct ValueTextInfo options_action_mode_assign[] =
2192 { CA_MODE_SET, "=" },
2197 static struct ValueTextInfo options_action_mode_add_remove[] =
2199 { CA_MODE_ADD, "+" },
2200 { CA_MODE_SUBTRACT, "-" },
2205 static struct ValueTextInfo options_action_mode_calculate[] =
2207 { CA_MODE_SET, "=" },
2208 { CA_MODE_ADD, "+" },
2209 { CA_MODE_SUBTRACT, "-" },
2210 { CA_MODE_MULTIPLY, "*" },
2211 { CA_MODE_DIVIDE, "/" },
2212 { CA_MODE_MODULO, "%" },
2217 static struct ValueTextInfo options_action_arg_none[] =
2219 { CA_ARG_UNDEFINED, " " },
2224 static struct ValueTextInfo options_action_arg_player[] =
2226 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2227 { CA_ARG_PLAYER_1, "1" },
2228 { CA_ARG_PLAYER_2, "2" },
2229 { CA_ARG_PLAYER_3, "3" },
2230 { CA_ARG_PLAYER_4, "4" },
2231 { CA_ARG_PLAYER_ANY, "any" },
2232 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2233 { CA_ARG_PLAYER_ACTION, "action ->" },
2238 static struct ValueTextInfo options_action_arg_number[] =
2240 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2247 { CA_ARG_10, "10" },
2248 { CA_ARG_100, "100" },
2249 { CA_ARG_1000, "1000" },
2250 { CA_ARG_UNDEFINED, " " },
2251 { CA_ARG_NUMBER_MIN, "min" },
2252 { CA_ARG_NUMBER_MAX, "max" },
2253 { CA_ARG_UNDEFINED, " " },
2254 { CA_ARG_NUMBER_RESET, "reset" },
2255 { CA_ARG_UNDEFINED, " " },
2256 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2257 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2258 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2259 { CA_ARG_UNDEFINED, " " },
2260 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2261 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2262 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2263 { CA_ARG_UNDEFINED, " " },
2264 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2265 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2266 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2267 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2268 { CA_ARG_UNDEFINED, " " },
2269 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2270 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2271 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2272 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2277 static struct ValueTextInfo options_action_arg_value[] =
2279 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2286 { CA_ARG_10, "10" },
2287 { CA_ARG_100, "100" },
2288 { CA_ARG_1000, "1000" },
2289 { CA_ARG_UNDEFINED, " " },
2290 { CA_ARG_NUMBER_MIN, "min" },
2291 { CA_ARG_NUMBER_MAX, "max" },
2292 { CA_ARG_UNDEFINED, " " },
2293 { CA_ARG_NUMBER_RESET, "reset" },
2294 { CA_ARG_UNDEFINED, " " },
2295 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2296 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2297 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2298 { CA_ARG_UNDEFINED, " " },
2299 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2300 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2301 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2302 { CA_ARG_UNDEFINED, " " },
2303 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2304 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2305 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2306 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2307 { CA_ARG_UNDEFINED, " " },
2308 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2309 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2310 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2311 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2312 { CA_ARG_UNDEFINED, " " },
2313 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2314 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2315 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2316 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2321 static struct ValueTextInfo options_action_arg_envelope[] =
2323 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2328 { CA_ARG_UNDEFINED, " " },
2329 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2330 { CA_ARG_ELEMENT_TARGET, "target" },
2331 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2332 { CA_ARG_ELEMENT_ACTION, "action ->" },
2337 static struct ValueTextInfo options_action_arg_key[] =
2339 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2348 { CA_ARG_UNDEFINED, " " },
2349 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2350 { CA_ARG_ELEMENT_TARGET, "target" },
2351 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2352 { CA_ARG_ELEMENT_ACTION, "action ->" },
2357 static struct ValueTextInfo options_action_arg_speed[] =
2359 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2360 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2361 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2362 { CA_ARG_SPEED_SLOW, "slow" },
2363 { CA_ARG_SPEED_NORMAL, "normal" },
2364 { CA_ARG_SPEED_FAST, "fast" },
2365 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2366 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2367 { CA_ARG_UNDEFINED, " " },
2368 { CA_ARG_SPEED_SLOWER, "slower" },
2369 { CA_ARG_SPEED_FASTER, "faster" },
2370 { CA_ARG_UNDEFINED, " " },
2371 { CA_ARG_SPEED_RESET, "reset" },
2376 static struct ValueTextInfo options_action_arg_shield[] =
2378 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2379 { CA_ARG_SHIELD_OFF, "off" },
2380 { CA_ARG_SHIELD_NORMAL, "normal" },
2381 { CA_ARG_SHIELD_DEADLY, "deadly" },
2386 static struct ValueTextInfo options_action_arg_artwork[] =
2388 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2389 { CA_ARG_ELEMENT_TARGET, "target" },
2390 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2391 { CA_ARG_ELEMENT_ACTION, "action ->" },
2392 { CA_ARG_UNDEFINED, " " },
2393 { CA_ARG_ELEMENT_RESET, "reset" },
2398 static struct ValueTextInfo options_action_arg_gravity[] =
2400 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2401 { CA_ARG_GRAVITY_ON, "on" },
2402 { CA_ARG_GRAVITY_OFF, "off" },
2403 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2408 static struct ValueTextInfo options_action_arg_direction[] =
2410 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2411 { CA_ARG_DIRECTION_NONE, "none" },
2412 { CA_ARG_DIRECTION_LEFT, "left" },
2413 { CA_ARG_DIRECTION_RIGHT, "right" },
2414 { CA_ARG_DIRECTION_UP, "up" },
2415 { CA_ARG_DIRECTION_DOWN, "down" },
2416 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2417 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2422 static struct ValueTextInfo options_action_arg_scan_mode[] =
2424 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2425 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2426 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2431 static struct ValueTextInfo options_action_arg_inventory[] =
2433 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2434 { CA_ARG_ELEMENT_TARGET, "+ target" },
2435 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2436 { CA_ARG_ELEMENT_ACTION, "+ action" },
2437 { CA_ARG_UNDEFINED, " " },
2438 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2439 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2440 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2441 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2442 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2443 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2444 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2445 { CA_ARG_UNDEFINED, " " },
2446 { CA_ARG_INVENTORY_RESET, "reset" },
2451 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2452 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2457 static struct ValueTextInfo options_group_choice_mode[] =
2459 { ANIM_RANDOM, "random" },
2460 { ANIM_LOOP, "loop" },
2461 { ANIM_LINEAR, "linear" },
2462 { ANIM_PINGPONG, "pingpong" },
2463 { ANIM_PINGPONG2, "pingpong 2" },
2468 static struct ValueTextInfo *action_arg_modes[] =
2470 options_action_mode_none,
2471 options_action_mode_assign,
2472 options_action_mode_add_remove,
2473 options_action_mode_calculate,
2480 struct ValueTextInfo *options;
2482 action_arg_options[] =
2484 { CA_NO_ACTION, 0, options_action_arg_none, },
2485 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2486 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2487 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2488 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2489 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2490 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2491 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2492 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2493 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2494 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2495 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2496 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2497 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2498 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2499 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2500 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2501 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2502 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2503 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2504 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2505 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2514 int gadget_id_align;
2515 int size; // char size of selectbox or '-1' (dynamically determined)
2516 struct ValueTextInfo *options;
2518 char *text_above, *text_left, *text_right, *infotext;
2519 } selectbox_info[ED_NUM_SELECTBOX] =
2521 // ---------- level and editor settings -------------------------------------
2524 -1, ED_LEVEL_SETTINGS_YPOS(8),
2525 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2527 options_time_or_steps,
2528 &level.use_step_counter,
2529 NULL, NULL, "(0 => no limit)", "time or step limit"
2532 -1, ED_LEVEL_SETTINGS_YPOS(10),
2533 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2535 options_time_score_base,
2536 &level.time_score_base,
2537 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2540 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2541 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2543 options_game_engine_type,
2544 &level.game_engine_type,
2545 NULL, "game engine:", NULL, "game engine"
2548 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2549 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2551 options_levelset_save_mode,
2552 &levelset_save_mode,
2553 "Action:", NULL, NULL, "action when saving level set"
2556 // ---------- element settings: configure (several elements) ----------------
2559 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2560 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2562 options_wind_direction,
2563 &level.wind_direction_initial,
2564 NULL, "initial wind direction:", NULL, "initial wind direction"
2567 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2568 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2570 options_player_speed,
2571 &level.initial_player_stepsize[0],
2572 NULL, "initial player speed:", NULL, "initial player speed"
2575 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2576 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2578 options_group_choice_mode,
2579 &level.mm_ball_choice_mode,
2580 NULL, "choice type:", NULL, "type of content choice"
2583 // ---------- element settings: configure 1 (custom elements) ---------------
2586 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2587 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2589 options_access_type,
2590 &custom_element.access_type,
2591 NULL, NULL, NULL, "type of access to this field"
2594 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2595 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2597 options_access_layer,
2598 &custom_element.access_layer,
2599 NULL, NULL, NULL, "layer of access for this field"
2602 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2603 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2605 options_access_protected,
2606 &custom_element.access_protected,
2607 NULL, NULL, NULL, "protected access for this field"
2610 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2611 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2613 options_access_direction,
2614 &custom_element.access_direction,
2615 NULL, "from", NULL, "access direction for this field"
2618 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2619 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2621 options_walk_to_action,
2622 &custom_element.walk_to_action,
2623 NULL, NULL, NULL, "diggable/collectible/pushable"
2626 // ---------- element settings: configure 2 (custom elements) ---------------
2629 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2630 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2632 options_move_pattern,
2633 &custom_element.move_pattern,
2634 NULL, "can move", NULL, "element move pattern"
2637 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2638 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2640 options_move_direction,
2641 &custom_element.move_direction_initial,
2642 NULL, "starts moving", NULL, "initial element move direction"
2645 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2646 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2648 options_move_stepsize,
2649 &custom_element.move_stepsize,
2650 NULL, "move/fall speed", NULL, "speed of element movement"
2653 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2654 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2656 options_move_leave_type,
2657 &custom_element.move_leave_type,
2658 // left text with leading spaces to place gadget next to "can dig" gadget
2659 // (needed because drawing area gadgets created after selectbox gadgets)
2660 // NULL, "can dig: can", ":", "leave behind or change element"
2661 NULL, " can", ":", "leave behind or change element"
2664 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2665 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2667 options_smash_targets,
2668 &custom_element.smash_targets,
2669 NULL, "can smash", NULL, "elements that can be smashed"
2672 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2673 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2675 options_slippery_type,
2676 &custom_element.slippery_type,
2677 NULL, "slippery", NULL, "where other elements fall down"
2680 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2681 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2684 &custom_element.deadliness,
2685 NULL, "deadly when", NULL, "deadliness of element"
2688 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2689 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2691 options_explosion_type,
2692 &custom_element.explosion_type,
2693 NULL, "can explode", NULL, "explosion type"
2696 // ---------- element settings: advanced (custom elements) ------------------
2699 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2700 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2703 &custom_element_change.delay_frames,
2704 NULL, "delay time given in", NULL, "delay time units for change"
2707 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2708 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2710 options_change_direct_action,
2711 &custom_element_change.direct_action,
2712 NULL, NULL, NULL, "type of direct action"
2715 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2716 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2718 options_change_other_action,
2719 &custom_element_change.other_action,
2720 NULL, NULL, "element:", "type of other element action"
2723 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2724 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2726 options_change_trigger_side,
2727 &custom_element_change.trigger_side,
2728 NULL, "at", "side", "element side triggering change"
2731 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2732 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2734 options_change_trigger_player,
2735 &custom_element_change.trigger_player,
2736 NULL, "player:", " ", "player that causes change"
2739 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2740 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2742 options_change_trigger_page,
2743 &custom_element_change.trigger_page,
2744 NULL, "page:", NULL, "change page that causes change"
2747 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2748 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2750 options_change_replace_when,
2751 &custom_element_change.replace_when,
2752 NULL, "replace when", NULL, "which elements can be replaced"
2755 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2756 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2758 options_action_type,
2759 &custom_element_change.action_type,
2760 NULL, NULL, NULL, "action on specified condition"
2763 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2764 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2766 options_action_mode_none,
2767 &custom_element_change.action_mode,
2768 NULL, NULL, NULL, "action operator"
2771 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2772 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2774 options_action_arg_none,
2775 &custom_element_change.action_arg,
2776 NULL, NULL, NULL, "action parameter"
2779 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2780 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2782 options_change_page,
2783 &custom_element.current_change_page,
2784 NULL, NULL, NULL, "element change page"
2787 // ---------- element settings: configure (group elements) ------------------
2790 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2791 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2793 options_group_choice_mode,
2794 &group_element_info.choice_mode,
2795 NULL, "choice type:", NULL, "type of group element choice"
2803 int gadget_id_align;
2806 char *text_above, *text_left, *text_right, *infotext;
2807 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2809 // ---------- level and editor settings (tabs) ------------------------------
2812 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2813 GADGET_ID_LEVELINFO_LEVEL, GADGET_ID_NONE,
2815 NULL, NULL, NULL, "Configure level properties"
2819 GADGET_ID_LEVELINFO_LEVELSET, GADGET_ID_LEVELINFO_LEVEL,
2821 NULL, NULL, NULL, "Update this or create new level set"
2825 GADGET_ID_LEVELINFO_EDITOR, GADGET_ID_LEVELINFO_LEVELSET,
2827 NULL, NULL, NULL, "Configure editor properties"
2830 // ---------- element settings (tabs) ---------------------------------------
2833 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2834 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2836 NULL, NULL, NULL, "Show information about element"
2840 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2842 NULL, NULL, NULL, "Configure element properties"
2846 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2848 NULL, NULL, NULL, "Configure element properties, part 1"
2852 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2854 NULL, NULL, NULL, "Configure element properties, part 2"
2858 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2860 NULL, NULL, NULL, "Configure custom element change pages"
2863 // ---------- level and editor settings (buttons) ---------------------------
2866 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2867 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
2869 NULL, NULL, NULL, "Update or create level set"
2872 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2873 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2875 NULL, NULL, "this level as level template",
2876 "Save current settings as new template"
2879 // ---------- element settings (buttons) ------------------------------------
2883 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2885 NULL, " ", "As Template",
2886 "Save current settings as new template"
2890 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2892 NULL, NULL, NULL, "Add new change page"
2896 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2898 NULL, NULL, NULL, "Delete current change page"
2907 int gadget_id_align;
2908 char *text_left, *text_right, *infotext;
2909 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2912 IMG_EDITOR_COUNTER_DOWN,
2913 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2914 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2915 NULL, NULL, "select previous change page"
2918 IMG_EDITOR_COUNTER_UP,
2919 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2920 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2921 NULL, "change page", "select next change page"
2924 IMG_GFX_EDITOR_BUTTON_CP_COPY,
2925 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2926 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2927 " ", NULL, "copy settings from this change page"
2930 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
2931 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2932 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2933 NULL, NULL, "paste settings to this change page"
2940 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2947 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2950 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2951 GADGET_ID_SCROLL_UP,
2952 "scroll level editing area up"
2955 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2956 GADGET_ID_SCROLL_DOWN,
2957 "scroll level editing area down"
2960 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2961 GADGET_ID_SCROLL_LEFT,
2962 "scroll level editing area left"
2965 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2966 GADGET_ID_SCROLL_RIGHT,
2967 "scroll level editing area right"
2970 IMG_EDITOR_PALETTE_SCROLL_UP,
2971 GADGET_ID_SCROLL_LIST_UP,
2972 "scroll element list up ('Page Up')"
2975 IMG_EDITOR_PALETTE_SCROLL_DOWN,
2976 GADGET_ID_SCROLL_LIST_DOWN,
2977 "scroll element list down ('Page Down')"
2985 int wheel_x, wheel_y;
2986 int wheel_width, wheel_height;
2987 } scrollbar_pos[ED_NUM_SCROLLBARS];
2995 } scrollbar_info[ED_NUM_SCROLLBARS] =
2998 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2999 GD_TYPE_SCROLLBAR_HORIZONTAL,
3000 GADGET_ID_SCROLL_HORIZONTAL,
3001 "scroll level editing area horizontally"
3004 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3005 GD_TYPE_SCROLLBAR_VERTICAL,
3006 GADGET_ID_SCROLL_VERTICAL,
3007 "scroll level editing area vertically"
3010 IMG_EDITOR_PALETTE_SCROLLBAR,
3011 GD_TYPE_SCROLLBAR_VERTICAL,
3012 GADGET_ID_SCROLL_LIST_VERTICAL,
3013 "scroll element list vertically"
3022 int gadget_id_align;
3023 int radio_button_nr;
3026 char *text_left, *text_right, *infotext;
3027 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3030 -1, ED_LEVEL_SETTINGS_YPOS(0),
3031 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3032 RADIO_NR_RANDOM_ELEMENTS,
3033 &random_placement_method, RANDOM_USE_PERCENTAGE,
3034 " ", "percentage", "use percentage for random elements"
3037 -1, ED_LEVEL_SETTINGS_YPOS(0),
3038 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3039 RADIO_NR_RANDOM_ELEMENTS,
3040 &random_placement_method, RANDOM_USE_QUANTITY,
3041 " ", "quantity", "use quantity for random elements"
3049 int gadget_id_align;
3051 char *text_above, *text_left, *text_right, *infotext;
3052 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3054 // ---------- level and editor settings -------------------------------------
3057 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3058 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3059 &level.auto_count_gems,
3061 "automatically count gems needed", "set counter to number of gems"
3064 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3065 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3066 &level.rate_time_over_score,
3068 "rate time/steps used over score", "sort high scores by playing time/steps"
3071 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3072 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3073 &levelset_use_levelset_artwork,
3075 "use current custom artwork", "use custom artwork of this level set"
3078 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3079 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3080 &levelset_copy_level_template,
3082 "copy current level template", "copy level template of this level set"
3085 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3086 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3087 &random_placement_background_restricted,
3089 "restrict random placement to:", "set random placement restriction"
3092 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3093 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3094 &setup.editor.use_template_for_new_levels,
3095 "Template for new levels and CE/GE:", NULL,
3096 "use template for new levels", "use template for level properties"
3099 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3100 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3101 &level.use_custom_template,
3103 "use template for custom elements", "use template for custom properties"
3106 // ---------- element settings: configure (various elements) ----------------
3109 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3110 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3111 &stick_element_properties_window,
3113 "stick this screen to edit content","stick this screen to edit content"
3116 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3117 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3118 &level.em_slippery_gems,
3120 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3123 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3124 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3125 &level.em_explodes_by_fire,
3127 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3130 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3131 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3132 &level.use_spring_bug,
3134 "use spring pushing bug", "use odd spring pushing behaviour"
3137 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3138 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3139 &level.use_time_orb_bug,
3141 "use time orb bug", "use odd time orb behaviour"
3144 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3145 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3146 &level.use_life_bugs,
3148 "use buggy element behaviour", "use odd (historic) element behaviour"
3151 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3152 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3155 "create single random element", "only create one element from content"
3158 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3159 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3160 &level.ball_active_initial,
3162 "magic ball initially activated", "activate magic ball after level start"
3165 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3166 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3167 &level.grow_into_diggable,
3169 "can grow into anything diggable", "grow into more than just sand"
3172 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3173 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3174 &level.sb_fields_needed,
3176 "all fields need to be filled", "require all SB fields to be solved"
3179 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3180 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3181 &level.sb_objects_needed,
3183 "all objects need to be placed", "require all SB objects to be solved"
3186 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3187 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3188 &level.auto_exit_sokoban,
3190 "exit level if all tasks solved", "automatically finish Sokoban levels"
3193 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3194 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3195 &level.solved_by_one_player,
3197 "only one player must enter exit", "level solved by first player in exit"
3200 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3201 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3202 &level.finish_dig_collect,
3204 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3207 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3208 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3209 &level.keep_walkable_ce,
3211 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3214 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3215 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3216 &level.continuous_snapping,
3218 "continuous snapping", "use snapping without releasing key"
3221 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3222 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3223 &level.block_snap_field,
3225 "block snapped field when snapping", "use snapping delay to show animation"
3228 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3229 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3230 &level.block_last_field,
3232 "block last field when moving", "player blocks last field when moving"
3235 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3236 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3237 &level.sp_block_last_field,
3239 "block last field when moving", "player blocks last field when moving"
3242 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3243 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3244 &level.instant_relocation,
3246 "no scrolling when relocating", "player gets relocated without delay"
3249 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3250 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3251 &level.shifted_relocation,
3253 "no centering when relocating", "level not centered after relocation"
3256 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3257 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3258 &level.lazy_relocation,
3260 "only redraw off-screen relocation","no redraw if relocation target visible"
3263 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3264 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3265 &level.use_start_element[0],
3267 "use level start element:", "start level at this element's position"
3270 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3271 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3272 &level.use_artwork_element[0],
3274 "use artwork from element:", "use player artwork from other element"
3277 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3278 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3279 &level.use_explosion_element[0],
3281 "use explosion from element:", "use explosion properties from element"
3284 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3285 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3286 &level.initial_player_gravity[0],
3288 "use initial gravity", "set initial player gravity"
3291 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3292 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3293 &level.use_initial_inventory[0],
3295 "use initial inventory:", "use collected elements on level start"
3298 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3299 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3300 &level.can_pass_to_walkable,
3302 "can pass to walkable element", "player can pass to empty or walkable"
3305 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3306 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3307 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3309 "can fall into acid (with gravity)","player can fall into acid pool"
3312 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3313 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3314 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3316 "can move into acid", "element can move into acid pool"
3319 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3320 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3321 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3323 "deadly when colliding with", "element is deadly when hitting player"
3326 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3327 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3328 &level.envelope[0].autowrap,
3330 "auto-wrap", "automatically wrap envelope text"
3333 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3334 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3335 &level.envelope[0].centered,
3337 "centered", "automatically center envelope text"
3340 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3341 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3342 &level.mm_laser_red,
3343 "choose color components for laser:", NULL,
3344 "red", "use red color components in laser"
3347 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3348 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3349 &level.mm_laser_green,
3351 "green", "use green color components in laser"
3354 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3355 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3356 &level.mm_laser_blue,
3358 "blue", "use blue color components in laser"
3361 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3362 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3363 &level.df_laser_red,
3364 "choose color components for laser:", NULL,
3365 "red", "use red color components in laser"
3368 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3369 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3370 &level.df_laser_green,
3372 "green", "use green color components in laser"
3375 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3376 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3377 &level.df_laser_blue,
3379 "blue", "use blue color components in laser"
3382 // ---------- element settings: configure 1 (custom elements) ---------------
3385 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3386 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3387 &custom_element.use_gfx_element,
3389 "use graphic of element:", "use existing element graphic"
3392 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3393 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3394 &level.use_custom_template,
3396 "use template", "use template for custom properties"
3399 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3400 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3401 &custom_element_properties[EP_ACCESSIBLE],
3403 NULL, "player can walk to or pass this field"
3406 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3407 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3408 &custom_element_properties[EP_GRAVITY_REACHABLE],
3410 "reachable despite gravity", "player can walk/dig despite gravity"
3413 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3414 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3415 &custom_element.use_last_ce_value,
3417 "use last CE value after change", "use last CE value after change"
3420 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3421 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3422 &custom_element_properties[EP_WALK_TO_OBJECT],
3424 NULL, "player can dig/collect/push element"
3427 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3428 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3429 &custom_element_properties[EP_INDESTRUCTIBLE],
3431 "indestructible", "element is indestructible"
3434 // ---------- element settings: configure 2 (custom elements) ---------------
3437 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3438 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3439 &custom_element_properties[EP_CAN_MOVE],
3441 NULL, "element can move with some pattern"
3444 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3445 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3446 &custom_element_properties[EP_CAN_FALL],
3448 "can fall", "element can fall down"
3451 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3452 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3453 &custom_element_properties[EP_CAN_SMASH],
3455 NULL, "element can smash other elements"
3458 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3459 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3460 &custom_element_properties[EP_SLIPPERY],
3462 NULL, "other elements can fall down from it"
3465 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3466 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3467 &custom_element_properties[EP_DEADLY],
3469 NULL, "element can kill the player"
3472 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3473 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3474 &custom_element_properties[EP_CAN_EXPLODE],
3476 NULL, "element can explode"
3479 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3480 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3481 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3483 "by fire", "element can explode by fire/explosion"
3486 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3487 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3488 &custom_element_properties[EP_EXPLODES_SMASHED],
3490 "smashed", "element can explode when smashed"
3493 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3494 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3495 &custom_element_properties[EP_EXPLODES_IMPACT],
3497 "impact", "element can explode on impact"
3500 // ---------- element settings: advanced (custom elements) ------------------
3503 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3504 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3505 &custom_element_change.can_change,
3507 "element changes to:", "change element on specified condition"
3510 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3511 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3512 &custom_element_change_events[CE_DELAY],
3514 NULL, "element changes after delay"
3517 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3518 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3519 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3521 NULL, "element changes by direct action"
3524 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3525 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3526 &custom_element_change_events[CE_BY_OTHER_ACTION],
3528 NULL, "element changes by other element"
3531 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3532 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3533 &custom_element_change.explode,
3535 "explode instead of change", "element explodes instead of change"
3538 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3539 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3540 &custom_element_change.use_target_content,
3542 "use extended change target:", "element changes to more elements"
3545 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3546 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3547 &custom_element_change.only_if_complete,
3549 "replace all or nothing", "only replace when all can be changed"
3552 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3553 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3554 &custom_element_change.use_random_replace,
3556 NULL, "use percentage for random replace"
3559 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3560 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3561 &custom_element_change.has_action,
3563 NULL, "execute action on specified condition"
3570 int xoffset, yoffset;
3572 int gadget_id_align;
3574 int area_xsize, area_ysize;
3575 char *text_left, *text_right, *text_above, *text_below, *infotext;
3576 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3578 // ---------- level playfield content ---------------------------------------
3583 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3585 -1, -1, // these values are not constant, but can change at runtime
3586 NULL, NULL, NULL, NULL, NULL
3589 // ---------- yam yam content -----------------------------------------------
3592 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3593 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3594 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3595 &level.yamyam_content[0].e[0][0], 3, 3,
3596 NULL, NULL, NULL, "1", NULL
3599 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3600 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3601 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3602 &level.yamyam_content[1].e[0][0], 3, 3,
3603 NULL, NULL, NULL, "2", NULL
3606 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3607 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3608 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3609 &level.yamyam_content[2].e[0][0], 3, 3,
3610 NULL, NULL, NULL, "3", NULL
3613 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3614 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3615 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3616 &level.yamyam_content[3].e[0][0], 3, 3,
3617 NULL, NULL, NULL, "4", NULL
3620 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3621 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3622 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3623 &level.yamyam_content[4].e[0][0], 3, 3,
3624 NULL, NULL, NULL, "5", NULL
3627 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3628 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3629 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3630 &level.yamyam_content[5].e[0][0], 3, 3,
3631 NULL, NULL, NULL, "6", NULL
3634 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3635 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3636 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3637 &level.yamyam_content[6].e[0][0], 3, 3,
3638 NULL, NULL, NULL, "7", NULL
3641 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3642 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3643 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3644 &level.yamyam_content[7].e[0][0], 3, 3,
3645 NULL, NULL, NULL, "8", NULL
3648 // ---------- magic ball content --------------------------------------------
3651 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3652 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3653 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3654 &level.ball_content[0].e[0][0], 3, 3,
3655 NULL, NULL, NULL, "1", NULL
3658 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3659 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3660 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3661 &level.ball_content[1].e[0][0], 3, 3,
3662 NULL, NULL, NULL, "2", NULL
3665 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3666 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3667 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3668 &level.ball_content[2].e[0][0], 3, 3,
3669 NULL, NULL, NULL, "3", NULL
3672 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3673 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3674 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3675 &level.ball_content[3].e[0][0], 3, 3,
3676 NULL, NULL, NULL, "4", NULL
3679 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3680 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3681 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3682 &level.ball_content[4].e[0][0], 3, 3,
3683 NULL, NULL, NULL, "5", NULL
3686 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3687 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3688 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3689 &level.ball_content[5].e[0][0], 3, 3,
3690 NULL, NULL, NULL, "6", NULL
3693 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3694 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3695 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3696 &level.ball_content[6].e[0][0], 3, 3,
3697 NULL, NULL, NULL, "7", NULL
3700 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3701 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3702 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3703 &level.ball_content[7].e[0][0], 3, 3,
3704 NULL, NULL, NULL, "8", NULL
3707 // ---------- android content -----------------------------------------------
3710 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
3711 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3712 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3713 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3714 NULL, NULL, "elements:", NULL, "elements android can clone"
3717 // ---------- amoeba content ------------------------------------------------
3720 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3721 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3722 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3723 &level.amoeba_content, 1, 1,
3724 "content:", NULL, NULL, NULL, "amoeba content"
3727 // ---------- level start element -------------------------------------------
3730 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3731 0, ED_AREA_1X1_SETTINGS_YOFF,
3732 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3733 &level.start_element[0], 1, 1,
3734 NULL, NULL, NULL, NULL, "level start element"
3737 // ---------- player artwork element ----------------------------------------
3740 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3741 0, ED_AREA_1X1_SETTINGS_YOFF,
3742 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3743 &level.artwork_element[0], 1, 1,
3744 NULL, NULL, NULL, NULL, "element for player artwork"
3747 // ---------- player explosion element --------------------------------------
3750 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
3751 0, ED_AREA_1X1_SETTINGS_YOFF,
3752 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3753 &level.explosion_element[0], 1, 1,
3754 NULL, NULL, NULL, NULL, "element for player explosion"
3757 // ---------- player initial inventory --------------------------------------
3760 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3761 0, ED_AREA_1X1_SETTINGS_YOFF,
3762 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3763 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3764 NULL, NULL, NULL, NULL, "content for initial inventory"
3767 // ---------- gray ball content -----------------------------------------
3770 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3771 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3772 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
3773 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
3774 "content:", NULL, NULL, NULL, "content for gray ball"
3777 // ---------- element settings: configure 1 (custom elements) ---------------
3779 // ---------- custom graphic ------------------------------------------------
3782 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3783 0, ED_AREA_1X1_SETTINGS_YOFF,
3784 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3785 &custom_element.gfx_element_initial,1, 1,
3786 NULL, NULL, NULL, NULL, "custom graphic element"
3789 // ---------- element settings: configure 2 (custom elements) ---------------
3791 // ---------- custom content (when exploding) -------------------------------
3794 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
3795 0, ED_AREA_3X3_SETTINGS_YOFF,
3796 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
3797 &custom_element.content.e[0][0], 3, 3,
3798 "content:", NULL, NULL, NULL, NULL
3801 // ---------- custom enter and leave element (when moving) ------------------
3804 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3805 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3806 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3807 &custom_element.move_enter_element, 1, 1,
3808 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
3811 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3812 0, ED_AREA_1X1_SETTINGS_YOFF,
3813 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3814 &custom_element.move_leave_element, 1, 1,
3815 NULL, NULL, NULL, NULL, "element that will be left behind"
3818 // ---------- element settings: advanced (custom elements) ------------------
3820 // ---------- custom change target ------------------------------------------
3823 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3824 0, ED_AREA_1X1_SETTINGS_YOFF,
3825 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3826 &custom_element_change.target_element, 1, 1,
3827 NULL, "after/when:", NULL, NULL, "new target element after change"
3830 // ---------- custom change content (extended change target) ----------------
3833 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3834 0, ED_AREA_3X3_SETTINGS_YOFF,
3835 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
3836 &custom_element_change.target_content.e[0][0], 3, 3,
3837 NULL, NULL, NULL, NULL, "new extended elements after change"
3840 // ---------- custom change trigger (element causing change) ----------------
3843 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3844 0, ED_AREA_1X1_SETTINGS_YOFF,
3845 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3846 &custom_element_change.initial_trigger_element, 1, 1,
3847 NULL, NULL, NULL, NULL, "other element triggering change"
3850 // ---------- custom change action (element used for action) ----------------
3853 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3854 0, ED_AREA_1X1_SETTINGS_YOFF,
3855 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3856 &custom_element_change.action_element, 1, 1,
3857 NULL, NULL, NULL, NULL, "element used as action parameter"
3860 // ---------- group element content -----------------------------------------
3863 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3864 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3865 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3866 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3867 "content:", NULL, NULL, NULL, NULL
3870 // ---------- random background (for random painting) -----------------------
3873 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
3874 0, ED_AREA_1X1_LSETTINGS_YOFF,
3875 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3876 &random_placement_background_element, 1, 1,
3877 NULL, NULL, NULL, NULL, "random placement background"
3882 // ----------------------------------------------------------------------------
3883 // some internally used variables
3884 // ----------------------------------------------------------------------------
3886 // maximal size of level editor drawing area
3887 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3889 // actual size of level editor drawing area
3890 static int ed_fieldx, ed_fieldy;
3892 // actual position of level editor drawing area in level playfield
3893 static int level_xpos = -1, level_ypos = -1;
3895 // actual tile size used to display playfield drawing area
3896 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3897 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
3899 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3901 // drawing elements on the three mouse buttons
3902 static int new_element1 = EL_WALL;
3903 static int new_element2 = EL_EMPTY;
3904 static int new_element3 = EL_SAND;
3906 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3907 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3908 (button) == 2 ? new_element2 : \
3909 (button) == 3 ? new_element3 : EL_EMPTY)
3911 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
3913 static int use_permanent_palette = TRUE;
3915 #define PX (use_permanent_palette ? DX : SX)
3916 #define PY (use_permanent_palette ? DY : SY)
3917 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
3918 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
3920 // forward declaration for internal use
3921 static void CopyBrushToCursor(int, int);
3922 static void DeleteBrushFromCursor(void);
3923 static void ModifyEditorCounterValue(int, int);
3924 static void ModifyEditorCounterLimits(int, int, int);
3925 static void ModifyEditorSelectboxValue(int, int);
3926 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3927 static void ModifyEditorDrawingArea(int, int, int);
3928 static void ModifyEditorElementList(void);
3929 static void AdjustElementListScrollbar(void);
3930 static void RedrawDrawingElements(void);
3931 static void DrawDrawingWindowExt(boolean);
3932 static void DrawDrawingWindow(void);
3933 static void DrawLevelInfoWindow(void);
3934 static void DrawPropertiesWindow(void);
3935 static void DrawPaletteWindow(void);
3936 static void UpdateCustomElementGraphicGadgets(void);
3937 static boolean checkPropertiesConfig(int);
3938 static void SetAutomaticNumberOfGemsNeeded(void);
3939 static void ClearEditorGadgetInfoText(void);
3940 static void CopyLevelToUndoBuffer(int);
3941 static void HandleDrawingAreas(struct GadgetInfo *);
3942 static void HandleCounterButtons(struct GadgetInfo *);
3943 static void HandleTextInputGadgets(struct GadgetInfo *);
3944 static void HandleTextAreaGadgets(struct GadgetInfo *);
3945 static void HandleSelectboxGadgets(struct GadgetInfo *);
3946 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3947 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3948 static void HandleRadiobuttons(struct GadgetInfo *);
3949 static void HandleCheckbuttons(struct GadgetInfo *);
3950 static void HandleControlButtons(struct GadgetInfo *);
3951 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3952 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3953 static boolean AskToCopyAndModifyLevelTemplate(void);
3954 static boolean getDrawModeHiRes(void);
3955 static int getTabulatorBarWidth(void);
3956 static int getTabulatorBarHeight(void);
3957 static Pixel getTabulatorBarColor(void);
3959 static int num_editor_gadgets = 0; // dynamically determined
3961 static struct GadgetInfo **level_editor_gadget = NULL;
3962 static int *right_gadget_border = NULL;
3964 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3965 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3966 static boolean draw_with_brush = FALSE;
3967 static int properties_element = 0;
3969 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3970 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3971 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3972 static int undo_buffer_position = 0;
3973 static int undo_buffer_steps = 0;
3974 static int redo_buffer_steps = 0;
3976 static int edit_mode;
3977 static int edit_mode_levelinfo;
3978 static int edit_mode_properties;
3980 static int element_shift = 0;
3982 static int editor_el_players[] =
3989 static int *editor_el_players_ptr = editor_el_players;
3990 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
3992 static int editor_hl_boulderdash[] =
3994 EL_INTERNAL_CASCADE_BD_ACTIVE,
4000 static int editor_el_boulderdash[] =
4009 EL_BD_EXPANDABLE_WALL,
4017 EL_BD_BUTTERFLY_LEFT,
4019 EL_BD_BUTTERFLY_RIGHT,
4020 EL_BD_FIREFLY_RIGHT,
4023 EL_BD_BUTTERFLY_DOWN,
4027 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4028 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4029 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4030 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4032 static int editor_hl_emerald_mine[] =
4034 EL_INTERNAL_CASCADE_EM_ACTIVE,
4040 static int editor_el_emerald_mine[] =
4058 EL_EM_DYNAMITE_ACTIVE,
4077 EL_ACID_POOL_TOPLEFT,
4079 EL_ACID_POOL_TOPRIGHT,
4082 EL_ACID_POOL_BOTTOMLEFT,
4083 EL_ACID_POOL_BOTTOM,
4084 EL_ACID_POOL_BOTTOMRIGHT,
4102 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4103 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4104 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4105 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4107 static int editor_hl_emerald_mine_club[] =
4109 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4115 static int editor_el_emerald_mine_club[] =
4142 EL_EMC_WALL_SLIPPERY_1,
4143 EL_EMC_WALL_SLIPPERY_2,
4144 EL_EMC_WALL_SLIPPERY_3,
4145 EL_EMC_WALL_SLIPPERY_4,
4168 EL_EMC_MAGIC_BALL_SWITCH,
4175 EL_EMC_SPRING_BUMPER,
4179 EL_BALLOON_SWITCH_UP,
4180 EL_BALLOON_SWITCH_ANY,
4183 EL_BALLOON_SWITCH_LEFT,
4185 EL_BALLOON_SWITCH_RIGHT,
4189 EL_BALLOON_SWITCH_DOWN,
4190 EL_BALLOON_SWITCH_NONE,
4192 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4193 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4194 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4195 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4197 static int editor_hl_rnd[] =
4199 EL_INTERNAL_CASCADE_RND_ACTIVE,
4205 static int editor_el_rnd[] =
4208 EL_DYNAMITE_ACTIVE, // RND
4242 EL_WALL_EMERALD_YELLOW,
4243 EL_WALL_EMERALD_RED,
4244 EL_WALL_EMERALD_PURPLE,
4262 EL_DYNABOMB_INCREASE_NUMBER,
4263 EL_DYNABOMB_INCREASE_SIZE,
4264 EL_DYNABOMB_INCREASE_POWER,
4284 EL_INVISIBLE_STEELWALL,
4288 EL_EXPANDABLE_WALL_HORIZONTAL,
4289 EL_EXPANDABLE_WALL_VERTICAL,
4290 EL_EXPANDABLE_WALL_ANY,
4292 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4293 static int *editor_el_rnd_ptr = editor_el_rnd;
4294 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4295 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4297 static int editor_hl_sokoban[] =
4299 EL_INTERNAL_CASCADE_SB_ACTIVE,
4305 static int editor_el_sokoban[] =
4308 EL_SOKOBAN_FIELD_EMPTY,
4309 EL_SOKOBAN_FIELD_FULL,
4310 EL_SOKOBAN_FIELD_PLAYER,
4312 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4313 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4314 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4315 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4317 static int editor_hl_supaplex[] =
4319 EL_INTERNAL_CASCADE_SP_ACTIVE,
4325 static int editor_el_supaplex[] =
4343 EL_SP_PORT_HORIZONTAL,
4344 EL_SP_PORT_VERTICAL,
4352 EL_SP_GRAVITY_PORT_LEFT,
4353 EL_SP_GRAVITY_PORT_RIGHT,
4354 EL_SP_GRAVITY_PORT_UP,
4355 EL_SP_GRAVITY_PORT_DOWN,
4357 EL_SP_GRAVITY_ON_PORT_LEFT,
4358 EL_SP_GRAVITY_ON_PORT_RIGHT,
4359 EL_SP_GRAVITY_ON_PORT_UP,
4360 EL_SP_GRAVITY_ON_PORT_DOWN,
4362 EL_SP_GRAVITY_OFF_PORT_LEFT,
4363 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4364 EL_SP_GRAVITY_OFF_PORT_UP,
4365 EL_SP_GRAVITY_OFF_PORT_DOWN,
4367 EL_SP_HARDWARE_GRAY,
4368 EL_SP_HARDWARE_GREEN,
4369 EL_SP_HARDWARE_BLUE,
4372 EL_SP_HARDWARE_BASE_1,
4373 EL_SP_HARDWARE_BASE_2,
4374 EL_SP_HARDWARE_BASE_3,
4375 EL_SP_HARDWARE_BASE_4,
4377 EL_SP_HARDWARE_BASE_5,
4378 EL_SP_HARDWARE_BASE_6,
4379 EL_SP_HARDWARE_YELLOW,
4387 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4388 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4389 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4390 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4392 static int editor_hl_diamond_caves[] =
4394 EL_INTERNAL_CASCADE_DC_ACTIVE,
4400 static int editor_el_diamond_caves[] =
4402 EL_EM_STEEL_EXIT_CLOSED, // DC2
4403 EL_EM_STEEL_EXIT_OPEN, // DC2
4404 EL_WALL_EMERALD, // DC2
4405 EL_WALL_DIAMOND, // DC2
4412 EL_CONVEYOR_BELT_1_LEFT,
4413 EL_CONVEYOR_BELT_1_MIDDLE,
4414 EL_CONVEYOR_BELT_1_RIGHT,
4415 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4417 EL_CONVEYOR_BELT_2_LEFT,
4418 EL_CONVEYOR_BELT_2_MIDDLE,
4419 EL_CONVEYOR_BELT_2_RIGHT,
4420 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4422 EL_CONVEYOR_BELT_3_LEFT,
4423 EL_CONVEYOR_BELT_3_MIDDLE,
4424 EL_CONVEYOR_BELT_3_RIGHT,
4425 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4427 EL_CONVEYOR_BELT_4_LEFT,
4428 EL_CONVEYOR_BELT_4_MIDDLE,
4429 EL_CONVEYOR_BELT_4_RIGHT,
4430 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4432 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4433 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4434 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4435 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4437 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4438 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4439 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4440 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4445 EL_DC_TIMEGATE_SWITCH,
4447 EL_SWITCHGATE_CLOSED,
4449 EL_SWITCHGATE_SWITCH_UP,
4450 EL_SWITCHGATE_SWITCH_DOWN,
4453 EL_LIGHT_SWITCH_ACTIVE,
4454 EL_DC_SWITCHGATE_SWITCH_UP,
4455 EL_DC_SWITCHGATE_SWITCH_DOWN,
4457 EL_STEEL_EXIT_CLOSED,
4459 EL_STEELWALL_SLIPPERY,
4462 EL_QUICKSAND_FAST_EMPTY,
4463 EL_QUICKSAND_FAST_FULL,
4477 EL_SIGN_RADIOACTIVITY,
4483 EL_SIGN_ENTRY_FORBIDDEN,
4484 EL_SIGN_EMERGENCY_EXIT,
4509 EL_DC_STEELWALL_2_SINGLE,
4510 EL_DC_STEELWALL_2_TOP,
4511 EL_SIGN_EXCLAMATION,
4514 EL_DC_STEELWALL_2_LEFT,
4515 EL_DC_STEELWALL_2_MIDDLE,
4516 EL_DC_STEELWALL_2_HORIZONTAL,
4517 EL_DC_STEELWALL_2_RIGHT,
4519 EL_DC_STEELWALL_1_TOPLEFT,
4520 EL_DC_STEELWALL_2_VERTICAL,
4521 EL_DC_STEELWALL_1_TOPRIGHT,
4524 EL_DC_STEELWALL_1_VERTICAL,
4525 EL_DC_STEELWALL_2_BOTTOM,
4527 EL_DC_GATE_WHITE_GRAY,
4529 EL_DC_STEELWALL_1_BOTTOMLEFT,
4530 EL_DC_STEELWALL_1_HORIZONTAL,
4531 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4532 EL_DC_GATE_FAKE_GRAY,
4534 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4535 EL_DC_STEELWALL_1_BOTTOM,
4536 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
4537 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
4539 EL_DC_STEELWALL_1_RIGHT,
4541 EL_DC_STEELWALL_1_LEFT,
4542 EL_EXPANDABLE_STEELWALL_VERTICAL,
4544 EL_DC_STEELWALL_1_TOPRIGHT_2,
4545 EL_DC_STEELWALL_1_TOP,
4546 EL_DC_STEELWALL_1_TOPLEFT_2,
4547 EL_EXPANDABLE_STEELWALL_ANY,
4549 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
4550 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
4551 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
4552 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
4554 static int editor_hl_dx_boulderdash[] =
4556 EL_INTERNAL_CASCADE_DX_ACTIVE,
4562 static int editor_el_dx_boulderdash[] =
4566 EL_TUBE_HORIZONTAL_DOWN,
4570 EL_TUBE_VERTICAL_RIGHT,
4572 EL_TUBE_VERTICAL_LEFT,
4576 EL_TUBE_HORIZONTAL_UP,
4584 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
4585 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
4586 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
4587 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
4589 static int editor_hl_mirror_magic[] =
4591 EL_INTERNAL_CASCADE_MM_ACTIVE,
4597 static int editor_el_mirror_magic[] =
4599 EL_MM_MCDUFFIN_RIGHT,
4601 EL_MM_MCDUFFIN_LEFT,
4602 EL_MM_MCDUFFIN_DOWN,
4605 EL_MM_MIRROR_FIXED_START,
4606 EL_MM_POLARIZER_START,
4607 EL_MM_POLARIZER_CROSS_START,
4609 EL_MM_TELEPORTER_RED_START,
4610 EL_MM_TELEPORTER_YELLOW_START,
4611 EL_MM_TELEPORTER_GREEN_START,
4612 EL_MM_TELEPORTER_BLUE_START,
4625 EL_MM_LIGHTBULB_ACTIVE,
4639 EL_MM_STEEL_GRID_FIXED_1,
4640 EL_MM_STEEL_GRID_FIXED_2,
4641 EL_MM_STEEL_GRID_FIXED_3,
4642 EL_MM_STEEL_GRID_FIXED_4,
4644 EL_MM_WOODEN_GRID_FIXED_1,
4645 EL_MM_WOODEN_GRID_FIXED_2,
4646 EL_MM_WOODEN_GRID_FIXED_3,
4647 EL_MM_WOODEN_GRID_FIXED_4,
4654 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
4655 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
4656 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
4657 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
4659 static int editor_hl_deflektor[] =
4661 EL_INTERNAL_CASCADE_DF_ACTIVE,
4667 static int editor_el_deflektor[] =
4674 EL_DF_RECEIVER_RIGHT,
4676 EL_DF_RECEIVER_LEFT,
4677 EL_DF_RECEIVER_DOWN,
4680 EL_DF_MIRROR_ROTATING_START,
4684 EL_DF_FIBRE_OPTIC_RED_1,
4685 EL_DF_FIBRE_OPTIC_YELLOW_1,
4686 EL_DF_FIBRE_OPTIC_GREEN_1,
4687 EL_DF_FIBRE_OPTIC_BLUE_1,
4689 EL_DF_STEEL_GRID_FIXED_START,
4690 EL_DF_STEEL_GRID_ROTATING_START,
4691 EL_DF_WOODEN_GRID_FIXED_START,
4692 EL_DF_WOODEN_GRID_ROTATING_START,
4699 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
4700 static int *editor_el_deflektor_ptr = editor_el_deflektor;
4701 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
4702 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
4704 static int editor_hl_chars[] =
4706 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
4712 static int editor_el_chars[] =
4794 EL_CHAR(CHAR_BYTE_COPYRIGHT),
4795 EL_CHAR(CHAR_BYTE_UMLAUT_A),
4796 EL_CHAR(CHAR_BYTE_UMLAUT_O),
4797 EL_CHAR(CHAR_BYTE_UMLAUT_U),
4799 EL_CHAR(CHAR_BYTE_DEGREE),
4800 EL_CHAR(CHAR_BYTE_REGISTERED),
4801 EL_CHAR(FONT_ASCII_CURSOR),
4802 EL_CHAR(FONT_ASCII_BUTTON),
4804 EL_CHAR(FONT_ASCII_UP),
4805 EL_CHAR(FONT_ASCII_DOWN),
4809 static int *editor_hl_chars_ptr = editor_hl_chars;
4810 static int *editor_el_chars_ptr = editor_el_chars;
4811 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
4812 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
4814 static int editor_hl_steel_chars[] =
4816 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
4822 static int editor_el_steel_chars[] =
4832 EL_STEEL_CHAR('\''),
4899 EL_STEEL_CHAR('\\'),
4904 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
4905 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
4906 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
4907 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
4909 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
4910 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
4911 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4912 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4914 EL_STEEL_CHAR(FONT_ASCII_UP),
4915 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4919 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4920 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4921 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
4922 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
4924 static int editor_hl_custom[] =
4926 EL_INTERNAL_CASCADE_CE_ACTIVE,
4932 static int editor_el_custom[] =
4934 EL_CUSTOM_START + 0,
4935 EL_CUSTOM_START + 1,
4936 EL_CUSTOM_START + 2,
4937 EL_CUSTOM_START + 3,
4939 EL_CUSTOM_START + 4,
4940 EL_CUSTOM_START + 5,
4941 EL_CUSTOM_START + 6,
4942 EL_CUSTOM_START + 7,
4944 EL_CUSTOM_START + 8,
4945 EL_CUSTOM_START + 9,
4946 EL_CUSTOM_START + 10,
4947 EL_CUSTOM_START + 11,
4949 EL_CUSTOM_START + 12,
4950 EL_CUSTOM_START + 13,
4951 EL_CUSTOM_START + 14,
4952 EL_CUSTOM_START + 15,
4954 EL_CUSTOM_START + 16,
4955 EL_CUSTOM_START + 17,
4956 EL_CUSTOM_START + 18,
4957 EL_CUSTOM_START + 19,
4959 EL_CUSTOM_START + 20,
4960 EL_CUSTOM_START + 21,
4961 EL_CUSTOM_START + 22,
4962 EL_CUSTOM_START + 23,
4964 EL_CUSTOM_START + 24,
4965 EL_CUSTOM_START + 25,
4966 EL_CUSTOM_START + 26,
4967 EL_CUSTOM_START + 27,
4969 EL_CUSTOM_START + 28,
4970 EL_CUSTOM_START + 29,
4971 EL_CUSTOM_START + 30,
4972 EL_CUSTOM_START + 31,
4974 EL_CUSTOM_START + 32,
4975 EL_CUSTOM_START + 33,
4976 EL_CUSTOM_START + 34,
4977 EL_CUSTOM_START + 35,
4979 EL_CUSTOM_START + 36,
4980 EL_CUSTOM_START + 37,
4981 EL_CUSTOM_START + 38,
4982 EL_CUSTOM_START + 39,
4984 EL_CUSTOM_START + 40,
4985 EL_CUSTOM_START + 41,
4986 EL_CUSTOM_START + 42,
4987 EL_CUSTOM_START + 43,
4989 EL_CUSTOM_START + 44,
4990 EL_CUSTOM_START + 45,
4991 EL_CUSTOM_START + 46,
4992 EL_CUSTOM_START + 47,
4994 EL_CUSTOM_START + 48,
4995 EL_CUSTOM_START + 49,
4996 EL_CUSTOM_START + 50,
4997 EL_CUSTOM_START + 51,
4999 EL_CUSTOM_START + 52,
5000 EL_CUSTOM_START + 53,
5001 EL_CUSTOM_START + 54,
5002 EL_CUSTOM_START + 55,
5004 EL_CUSTOM_START + 56,
5005 EL_CUSTOM_START + 57,
5006 EL_CUSTOM_START + 58,
5007 EL_CUSTOM_START + 59,
5009 EL_CUSTOM_START + 60,
5010 EL_CUSTOM_START + 61,
5011 EL_CUSTOM_START + 62,
5012 EL_CUSTOM_START + 63,
5014 EL_CUSTOM_START + 64,
5015 EL_CUSTOM_START + 65,
5016 EL_CUSTOM_START + 66,
5017 EL_CUSTOM_START + 67,
5019 EL_CUSTOM_START + 68,
5020 EL_CUSTOM_START + 69,
5021 EL_CUSTOM_START + 70,
5022 EL_CUSTOM_START + 71,
5024 EL_CUSTOM_START + 72,
5025 EL_CUSTOM_START + 73,
5026 EL_CUSTOM_START + 74,
5027 EL_CUSTOM_START + 75,
5029 EL_CUSTOM_START + 76,
5030 EL_CUSTOM_START + 77,
5031 EL_CUSTOM_START + 78,
5032 EL_CUSTOM_START + 79,
5034 EL_CUSTOM_START + 80,
5035 EL_CUSTOM_START + 81,
5036 EL_CUSTOM_START + 82,
5037 EL_CUSTOM_START + 83,
5039 EL_CUSTOM_START + 84,
5040 EL_CUSTOM_START + 85,
5041 EL_CUSTOM_START + 86,
5042 EL_CUSTOM_START + 87,
5044 EL_CUSTOM_START + 88,
5045 EL_CUSTOM_START + 89,
5046 EL_CUSTOM_START + 90,
5047 EL_CUSTOM_START + 91,
5049 EL_CUSTOM_START + 92,
5050 EL_CUSTOM_START + 93,
5051 EL_CUSTOM_START + 94,
5052 EL_CUSTOM_START + 95,
5054 EL_CUSTOM_START + 96,
5055 EL_CUSTOM_START + 97,
5056 EL_CUSTOM_START + 98,
5057 EL_CUSTOM_START + 99,
5059 EL_CUSTOM_START + 100,
5060 EL_CUSTOM_START + 101,
5061 EL_CUSTOM_START + 102,
5062 EL_CUSTOM_START + 103,
5064 EL_CUSTOM_START + 104,
5065 EL_CUSTOM_START + 105,
5066 EL_CUSTOM_START + 106,
5067 EL_CUSTOM_START + 107,
5069 EL_CUSTOM_START + 108,
5070 EL_CUSTOM_START + 109,
5071 EL_CUSTOM_START + 110,
5072 EL_CUSTOM_START + 111,
5074 EL_CUSTOM_START + 112,
5075 EL_CUSTOM_START + 113,
5076 EL_CUSTOM_START + 114,
5077 EL_CUSTOM_START + 115,
5079 EL_CUSTOM_START + 116,
5080 EL_CUSTOM_START + 117,
5081 EL_CUSTOM_START + 118,
5082 EL_CUSTOM_START + 119,
5084 EL_CUSTOM_START + 120,
5085 EL_CUSTOM_START + 121,
5086 EL_CUSTOM_START + 122,
5087 EL_CUSTOM_START + 123,
5089 EL_CUSTOM_START + 124,
5090 EL_CUSTOM_START + 125,
5091 EL_CUSTOM_START + 126,
5092 EL_CUSTOM_START + 127,
5094 EL_CUSTOM_START + 128,
5095 EL_CUSTOM_START + 129,
5096 EL_CUSTOM_START + 130,
5097 EL_CUSTOM_START + 131,
5099 EL_CUSTOM_START + 132,
5100 EL_CUSTOM_START + 133,
5101 EL_CUSTOM_START + 134,
5102 EL_CUSTOM_START + 135,
5104 EL_CUSTOM_START + 136,
5105 EL_CUSTOM_START + 137,
5106 EL_CUSTOM_START + 138,
5107 EL_CUSTOM_START + 139,
5109 EL_CUSTOM_START + 140,
5110 EL_CUSTOM_START + 141,
5111 EL_CUSTOM_START + 142,
5112 EL_CUSTOM_START + 143,
5114 EL_CUSTOM_START + 144,
5115 EL_CUSTOM_START + 145,
5116 EL_CUSTOM_START + 146,
5117 EL_CUSTOM_START + 147,
5119 EL_CUSTOM_START + 148,
5120 EL_CUSTOM_START + 149,
5121 EL_CUSTOM_START + 150,
5122 EL_CUSTOM_START + 151,
5124 EL_CUSTOM_START + 152,
5125 EL_CUSTOM_START + 153,
5126 EL_CUSTOM_START + 154,
5127 EL_CUSTOM_START + 155,
5129 EL_CUSTOM_START + 156,
5130 EL_CUSTOM_START + 157,
5131 EL_CUSTOM_START + 158,
5132 EL_CUSTOM_START + 159,
5134 EL_CUSTOM_START + 160,
5135 EL_CUSTOM_START + 161,
5136 EL_CUSTOM_START + 162,
5137 EL_CUSTOM_START + 163,
5139 EL_CUSTOM_START + 164,
5140 EL_CUSTOM_START + 165,
5141 EL_CUSTOM_START + 166,
5142 EL_CUSTOM_START + 167,
5144 EL_CUSTOM_START + 168,
5145 EL_CUSTOM_START + 169,
5146 EL_CUSTOM_START + 170,
5147 EL_CUSTOM_START + 171,
5149 EL_CUSTOM_START + 172,
5150 EL_CUSTOM_START + 173,
5151 EL_CUSTOM_START + 174,
5152 EL_CUSTOM_START + 175,
5154 EL_CUSTOM_START + 176,
5155 EL_CUSTOM_START + 177,
5156 EL_CUSTOM_START + 178,
5157 EL_CUSTOM_START + 179,
5159 EL_CUSTOM_START + 180,
5160 EL_CUSTOM_START + 181,
5161 EL_CUSTOM_START + 182,
5162 EL_CUSTOM_START + 183,
5164 EL_CUSTOM_START + 184,
5165 EL_CUSTOM_START + 185,
5166 EL_CUSTOM_START + 186,
5167 EL_CUSTOM_START + 187,
5169 EL_CUSTOM_START + 188,
5170 EL_CUSTOM_START + 189,
5171 EL_CUSTOM_START + 190,
5172 EL_CUSTOM_START + 191,
5174 EL_CUSTOM_START + 192,
5175 EL_CUSTOM_START + 193,
5176 EL_CUSTOM_START + 194,
5177 EL_CUSTOM_START + 195,
5179 EL_CUSTOM_START + 196,
5180 EL_CUSTOM_START + 197,
5181 EL_CUSTOM_START + 198,
5182 EL_CUSTOM_START + 199,
5184 EL_CUSTOM_START + 200,
5185 EL_CUSTOM_START + 201,
5186 EL_CUSTOM_START + 202,
5187 EL_CUSTOM_START + 203,
5189 EL_CUSTOM_START + 204,
5190 EL_CUSTOM_START + 205,
5191 EL_CUSTOM_START + 206,
5192 EL_CUSTOM_START + 207,
5194 EL_CUSTOM_START + 208,
5195 EL_CUSTOM_START + 209,
5196 EL_CUSTOM_START + 210,
5197 EL_CUSTOM_START + 211,
5199 EL_CUSTOM_START + 212,
5200 EL_CUSTOM_START + 213,
5201 EL_CUSTOM_START + 214,
5202 EL_CUSTOM_START + 215,
5204 EL_CUSTOM_START + 216,
5205 EL_CUSTOM_START + 217,
5206 EL_CUSTOM_START + 218,
5207 EL_CUSTOM_START + 219,
5209 EL_CUSTOM_START + 220,
5210 EL_CUSTOM_START + 221,
5211 EL_CUSTOM_START + 222,
5212 EL_CUSTOM_START + 223,
5214 EL_CUSTOM_START + 224,
5215 EL_CUSTOM_START + 225,
5216 EL_CUSTOM_START + 226,
5217 EL_CUSTOM_START + 227,
5219 EL_CUSTOM_START + 228,
5220 EL_CUSTOM_START + 229,
5221 EL_CUSTOM_START + 230,
5222 EL_CUSTOM_START + 231,
5224 EL_CUSTOM_START + 232,
5225 EL_CUSTOM_START + 233,
5226 EL_CUSTOM_START + 234,
5227 EL_CUSTOM_START + 235,
5229 EL_CUSTOM_START + 236,
5230 EL_CUSTOM_START + 237,
5231 EL_CUSTOM_START + 238,
5232 EL_CUSTOM_START + 239,
5234 EL_CUSTOM_START + 240,
5235 EL_CUSTOM_START + 241,
5236 EL_CUSTOM_START + 242,
5237 EL_CUSTOM_START + 243,
5239 EL_CUSTOM_START + 244,
5240 EL_CUSTOM_START + 245,
5241 EL_CUSTOM_START + 246,
5242 EL_CUSTOM_START + 247,
5244 EL_CUSTOM_START + 248,
5245 EL_CUSTOM_START + 249,
5246 EL_CUSTOM_START + 250,
5247 EL_CUSTOM_START + 251,
5249 EL_CUSTOM_START + 252,
5250 EL_CUSTOM_START + 253,
5251 EL_CUSTOM_START + 254,
5252 EL_CUSTOM_START + 255
5254 static int *editor_hl_custom_ptr = editor_hl_custom;
5255 static int *editor_el_custom_ptr = editor_el_custom;
5256 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5257 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5259 static int editor_hl_group[] =
5261 EL_INTERNAL_CASCADE_GE_ACTIVE,
5267 static int editor_el_group[] =
5281 EL_GROUP_START + 10,
5282 EL_GROUP_START + 11,
5284 EL_GROUP_START + 12,
5285 EL_GROUP_START + 13,
5286 EL_GROUP_START + 14,
5287 EL_GROUP_START + 15,
5289 EL_GROUP_START + 16,
5290 EL_GROUP_START + 17,
5291 EL_GROUP_START + 18,
5292 EL_GROUP_START + 19,
5294 EL_GROUP_START + 20,
5295 EL_GROUP_START + 21,
5296 EL_GROUP_START + 22,
5297 EL_GROUP_START + 23,
5299 EL_GROUP_START + 24,
5300 EL_GROUP_START + 25,
5301 EL_GROUP_START + 26,
5302 EL_GROUP_START + 27,
5304 EL_GROUP_START + 28,
5305 EL_GROUP_START + 29,
5306 EL_GROUP_START + 30,
5309 static int *editor_hl_group_ptr = editor_hl_group;
5310 static int *editor_el_group_ptr = editor_el_group;
5311 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5312 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5314 static int editor_hl_empty_space[] =
5316 EL_INTERNAL_CASCADE_ES_ACTIVE,
5322 static int editor_el_empty_space[] =
5344 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
5345 static int *editor_el_empty_space_ptr = editor_el_empty_space;
5346 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
5347 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
5349 static int editor_hl_reference[] =
5351 EL_INTERNAL_CASCADE_REF_ACTIVE,
5357 static int editor_el_reference[] =
5361 EL_TRIGGER_CE_VALUE,
5362 EL_TRIGGER_CE_SCORE,
5366 EL_CURRENT_CE_VALUE,
5367 EL_CURRENT_CE_SCORE,
5389 static int *editor_hl_reference_ptr = editor_hl_reference;
5390 static int *editor_el_reference_ptr = editor_el_reference;
5391 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5392 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5394 static int editor_hl_user_defined[] =
5396 EL_INTERNAL_CASCADE_USER_ACTIVE,
5402 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5403 static int *editor_el_user_defined_ptr = NULL;
5404 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5405 static int num_editor_el_user_defined = 0;
5407 static int editor_hl_dynamic[] =
5409 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5415 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5416 static int *editor_el_dynamic_ptr = NULL;
5417 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5418 static int num_editor_el_dynamic = 0;
5420 static int editor_hl_empty[] = { EL_EMPTY };
5421 static int *editor_el_empty = NULL; // dynamically allocated
5423 static int *editor_hl_empty_ptr = editor_hl_empty;
5424 static int *editor_el_empty_ptr = NULL;
5425 static int num_editor_hl_empty = 0;
5426 static int num_editor_el_empty = 0; // dynamically determined, if needed
5428 static boolean use_el_empty = FALSE;
5430 static int *editor_elements = NULL; // dynamically allocated
5431 static int num_editor_elements = 0; // dynamically determined
5433 static boolean setup_editor_cascade_never = FALSE;
5435 static boolean setup_editor_el_players = TRUE;
5436 static boolean setup_editor_el_boulderdash = TRUE;
5437 static boolean setup_editor_el_emerald_mine = TRUE;
5438 static boolean setup_editor_el_emerald_mine_club = TRUE;
5439 static boolean setup_editor_el_more = TRUE;
5440 static boolean setup_editor_el_sokoban = TRUE;
5441 static boolean setup_editor_el_supaplex = TRUE;
5442 static boolean setup_editor_el_diamond_caves = TRUE;
5443 static boolean setup_editor_el_dx_boulderdash = TRUE;
5444 static boolean setup_editor_el_mirror_magic = TRUE;
5445 static boolean setup_editor_el_deflektor = TRUE;
5446 static boolean setup_editor_el_chars = TRUE;
5447 static boolean setup_editor_el_steel_chars = TRUE;
5448 static boolean setup_editor_el_custom = TRUE;
5449 static boolean setup_editor_el_user_defined = TRUE;
5450 static boolean setup_editor_el_dynamic = TRUE;
5452 static int editor_hl_unused[] = { EL_EMPTY };
5453 static int *editor_hl_unused_ptr = editor_hl_unused;
5454 static int num_editor_hl_unused = 0;
5458 boolean *setup_value;
5459 boolean *setup_cascade_value;
5461 int **headline_list;
5462 int *headline_list_size;
5465 int *element_list_size;
5467 boolean last_setup_value;
5469 editor_elements_info[] =
5472 &setup_editor_el_players,
5473 &setup_editor_cascade_never,
5474 &editor_hl_unused_ptr, &num_editor_hl_unused,
5475 &editor_el_players_ptr, &num_editor_el_players
5478 &setup_editor_el_boulderdash,
5479 &setup.editor_cascade.el_bd,
5480 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5481 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5484 &setup_editor_el_emerald_mine,
5485 &setup.editor_cascade.el_em,
5486 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5487 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5490 &setup_editor_el_emerald_mine_club,
5491 &setup.editor_cascade.el_emc,
5492 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5493 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5496 &setup_editor_el_more,
5497 &setup.editor_cascade.el_rnd,
5498 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5499 &editor_el_rnd_ptr, &num_editor_el_rnd
5502 &setup_editor_el_sokoban,
5503 &setup.editor_cascade.el_sb,
5504 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5505 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5508 &setup_editor_el_supaplex,
5509 &setup.editor_cascade.el_sp,
5510 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5511 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5514 &setup_editor_el_diamond_caves,
5515 &setup.editor_cascade.el_dc,
5516 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5517 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5520 &setup_editor_el_dx_boulderdash,
5521 &setup.editor_cascade.el_dx,
5522 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5523 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
5526 &setup_editor_el_mirror_magic,
5527 &setup.editor_cascade.el_mm,
5528 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
5529 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
5532 &setup_editor_el_deflektor,
5533 &setup.editor_cascade.el_df,
5534 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
5535 &editor_el_deflektor_ptr, &num_editor_el_deflektor
5538 &setup_editor_el_chars,
5539 &setup.editor_cascade.el_chars,
5540 &editor_hl_chars_ptr, &num_editor_hl_chars,
5541 &editor_el_chars_ptr, &num_editor_el_chars
5544 &setup_editor_el_steel_chars,
5545 &setup.editor_cascade.el_steel_chars,
5546 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
5547 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
5550 &setup_editor_el_custom,
5551 &setup.editor_cascade.el_ce,
5552 &editor_hl_custom_ptr, &num_editor_hl_custom,
5553 &editor_el_custom_ptr, &num_editor_el_custom
5556 &setup_editor_el_custom,
5557 &setup.editor_cascade.el_ge,
5558 &editor_hl_group_ptr, &num_editor_hl_group,
5559 &editor_el_group_ptr, &num_editor_el_group
5562 &setup_editor_el_custom,
5563 &setup.editor_cascade.el_es,
5564 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
5565 &editor_el_empty_space_ptr, &num_editor_el_empty_space
5568 &setup_editor_el_custom,
5569 &setup.editor_cascade.el_ref,
5570 &editor_hl_reference_ptr, &num_editor_hl_reference,
5571 &editor_el_reference_ptr, &num_editor_el_reference
5574 &setup_editor_el_user_defined,
5575 &setup.editor_cascade.el_user,
5576 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
5577 &editor_el_user_defined_ptr, &num_editor_el_user_defined
5580 &setup_editor_el_dynamic,
5581 &setup.editor_cascade.el_dynamic,
5582 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
5583 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
5588 &editor_hl_empty_ptr, &num_editor_hl_empty,
5589 &editor_el_empty_ptr, &num_editor_el_empty,
5599 static struct XY xy_directions[] =
5608 // ----------------------------------------------------------------------------
5610 // ----------------------------------------------------------------------------
5612 static int getMaxInfoTextLength(void)
5614 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
5617 static int getTextWidthForGadget(char *text)
5622 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
5625 static int getTextWidthForDrawingArea(char *text)
5630 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
5633 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
5635 return (gi->x + gi->width + getTextWidthForGadget(text));
5638 static char *getElementInfoText(int element)
5640 char *info_text = NULL;
5642 if (element < MAX_NUM_ELEMENTS)
5644 if (strlen(element_info[element].description) > 0)
5645 info_text = element_info[element].description;
5646 else if (element_info[element].custom_description != NULL)
5647 info_text = element_info[element].custom_description;
5648 else if (element_info[element].editor_description != NULL)
5649 info_text = element_info[element].editor_description;
5652 if (info_text == NULL)
5653 info_text = INFOTEXT_UNKNOWN_ELEMENT;
5658 static char *getElementDescriptionFilenameExt(char *basename)
5660 char *elements_subdir = ELEMENTS_DIRECTORY;
5661 static char *elements_subdir2 = NULL;
5662 static char *filename = NULL;
5664 if (elements_subdir2 == NULL)
5665 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
5667 checked_free(filename);
5669 // 1st try: look for element description in current level set directory
5670 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
5671 if (fileExists(filename))
5676 // 2nd try: look for element description in the game's base directory
5677 filename = getPath3(options.docs_directory, elements_subdir, basename);
5678 if (fileExists(filename))
5684 static char *getElementDescriptionFilename(int element)
5686 char basename[MAX_FILENAME_LEN];
5689 // 1st try: look for element description file for exactly this element
5690 sprintf(basename, "%s.txt", element_info[element].token_name);
5691 filename = getElementDescriptionFilenameExt(basename);
5692 if (filename != NULL)
5695 // 2nd try: look for element description file for this element's class
5696 sprintf(basename, "%s.txt", element_info[element].class_name);
5697 filename = getElementDescriptionFilenameExt(basename);
5698 if (filename != NULL)
5701 // 3rd try: look for generic fallback text file for any element
5702 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
5703 if (filename != NULL)
5709 static boolean suppressBorderElement(void)
5711 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
5712 lev_fieldx <= MAX_ED_FIELDX &&
5713 lev_fieldy <= MAX_ED_FIELDY);
5716 static void InitDynamicEditorElementList(int **elements, int *num_elements)
5718 boolean element_found[NUM_FILE_ELEMENTS];
5721 // initialize list of used elements to "not used"
5722 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5723 element_found[i] = FALSE;
5725 // find all elements used in current level
5726 for (y = 0; y < lev_fieldy; y++)
5727 for (x = 0; x < lev_fieldx; x++)
5728 if (Tile[x][y] < NUM_FILE_ELEMENTS) // should always be true
5729 element_found[Tile[x][y]] = TRUE;
5733 // count number of elements used in current level
5734 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5735 if (element_found[i])
5738 // add space for up to 3 more elements for padding that may be needed
5741 // free memory for old list of elements, if needed
5742 checked_free(*elements);
5744 // allocate memory for new list of elements
5745 *elements = checked_malloc(*num_elements * sizeof(int));
5749 // add all elements used in current level (non-custom/group elements)
5750 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5751 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5752 (*elements)[(*num_elements)++] = i;
5754 // add all elements used in current level (custom/group elements)
5755 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5756 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5757 (*elements)[(*num_elements)++] = i;
5759 while (*num_elements % 4) // pad with empty elements, if needed
5760 (*elements)[(*num_elements)++] = EL_EMPTY;
5763 static void ReinitializeElementList_EnableSections(void)
5765 // default: enable all element sections
5767 setup_editor_el_players = TRUE;
5768 setup_editor_el_boulderdash = TRUE;
5769 setup_editor_el_emerald_mine = TRUE;
5770 setup_editor_el_emerald_mine_club = TRUE;
5771 setup_editor_el_more = TRUE;
5772 setup_editor_el_sokoban = TRUE;
5773 setup_editor_el_supaplex = TRUE;
5774 setup_editor_el_diamond_caves = TRUE;
5775 setup_editor_el_dx_boulderdash = TRUE;
5776 setup_editor_el_mirror_magic = TRUE;
5777 setup_editor_el_deflektor = TRUE;
5778 setup_editor_el_chars = TRUE;
5779 setup_editor_el_steel_chars = TRUE;
5781 setup_editor_el_custom = TRUE;
5782 setup_editor_el_user_defined = TRUE;
5783 setup_editor_el_dynamic = TRUE;
5785 // now disable all element sections not to be displayed
5787 if (!setup.editor.el_classic)
5789 setup_editor_el_players = FALSE;
5790 setup_editor_el_boulderdash = FALSE;
5791 setup_editor_el_emerald_mine = FALSE;
5792 setup_editor_el_emerald_mine_club = FALSE;
5793 setup_editor_el_more = FALSE;
5794 setup_editor_el_sokoban = FALSE;
5795 setup_editor_el_supaplex = FALSE;
5796 setup_editor_el_diamond_caves = FALSE;
5797 setup_editor_el_dx_boulderdash = FALSE;
5798 setup_editor_el_mirror_magic = FALSE;
5799 setup_editor_el_deflektor = FALSE;
5800 setup_editor_el_chars = FALSE;
5801 setup_editor_el_steel_chars = FALSE;
5804 if (!setup.editor.el_custom)
5806 setup_editor_el_custom = FALSE;
5809 if (!setup.editor.el_user_defined)
5811 setup_editor_el_user_defined = FALSE;
5814 if (!setup.editor.el_dynamic)
5816 setup_editor_el_dynamic = FALSE;
5819 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
5821 setup_editor_el_mirror_magic = FALSE;
5822 setup_editor_el_deflektor = FALSE;
5824 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
5826 setup_editor_el_boulderdash = FALSE;
5827 setup_editor_el_more = FALSE;
5828 setup_editor_el_sokoban = FALSE;
5829 setup_editor_el_supaplex = FALSE;
5830 setup_editor_el_diamond_caves = FALSE;
5831 setup_editor_el_dx_boulderdash = FALSE;
5832 setup_editor_el_mirror_magic = FALSE;
5833 setup_editor_el_deflektor = FALSE;
5834 setup_editor_el_steel_chars = FALSE;
5836 setup_editor_el_custom = FALSE;
5838 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
5840 setup_editor_el_players = FALSE;
5841 setup_editor_el_boulderdash = FALSE;
5842 setup_editor_el_emerald_mine = FALSE;
5843 setup_editor_el_emerald_mine_club = FALSE;
5844 setup_editor_el_more = FALSE;
5845 setup_editor_el_sokoban = FALSE;
5846 setup_editor_el_diamond_caves = FALSE;
5847 setup_editor_el_dx_boulderdash = FALSE;
5848 setup_editor_el_mirror_magic = FALSE;
5849 setup_editor_el_deflektor = FALSE;
5850 setup_editor_el_chars = FALSE;
5851 setup_editor_el_steel_chars = FALSE;
5853 setup_editor_el_custom = FALSE;
5855 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
5857 setup_editor_el_players = FALSE;
5858 setup_editor_el_boulderdash = FALSE;
5859 setup_editor_el_emerald_mine = FALSE;
5860 setup_editor_el_emerald_mine_club = FALSE;
5861 setup_editor_el_more = FALSE;
5862 setup_editor_el_sokoban = FALSE;
5863 setup_editor_el_supaplex = FALSE;
5864 setup_editor_el_diamond_caves = FALSE;
5865 setup_editor_el_dx_boulderdash = FALSE;
5866 setup_editor_el_steel_chars = FALSE;
5868 setup_editor_el_custom = FALSE;
5872 static void ReinitializeElementList(void)
5874 static boolean initialization_needed = TRUE;
5878 ReinitializeElementList_EnableSections();
5880 if (initialization_needed)
5882 LoadSetup_EditorCascade(); // load last editor cascade state
5884 // initialize editor cascade element from saved cascade state
5885 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5887 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
5888 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
5890 if (IS_EDITOR_CASCADE(*cascade_element))
5892 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
5893 EL_CASCADE_INACTIVE(*cascade_element));
5896 initialization_needed = FALSE;
5899 checked_free(editor_elements);
5901 // reload optional user defined element list for each invocation of editor
5902 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
5903 &num_editor_el_user_defined);
5905 // initialize dynamic level element list for each invocation of editor
5906 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
5907 &num_editor_el_dynamic);
5909 // initialize list of empty elements (used for padding, if needed)
5910 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5911 editor_el_empty[i] = EL_EMPTY;
5913 // do some sanity checks for each element from element list
5914 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5916 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5918 int element = (*editor_elements_info[i].element_list)[j];
5920 if (element >= NUM_FILE_ELEMENTS)
5921 Warn("editor element %d is runtime element", element);
5923 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
5924 Warn("no element description text for element %d", element);
5928 num_editor_elements = 0;
5929 use_el_empty = FALSE;
5931 // determine size of element list
5932 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5934 if (*editor_elements_info[i].setup_value)
5936 boolean found_inactive_cascade = FALSE;
5938 if (setup.editor.el_headlines)
5940 // required for correct padding of palette headline buttons
5941 if (*editor_elements_info[i].headline_list_size > 0)
5942 num_editor_elements += ED_ELEMENTLIST_COLS;
5944 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5946 int element = (*editor_elements_info[i].headline_list)[j];
5948 if (IS_EDITOR_CASCADE_INACTIVE(element))
5949 found_inactive_cascade = TRUE;
5953 if (found_inactive_cascade)
5956 // required for correct padding of palette element buttons
5957 int element_list_size = *editor_elements_info[i].element_list_size;
5959 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
5960 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
5962 num_editor_elements += element_buttons;
5966 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
5968 // offer at least as many elements as element buttons exist
5969 use_el_empty = TRUE;
5970 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
5972 num_editor_elements += num_editor_el_empty;
5976 num_editor_el_empty = 0;
5979 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
5981 // fill element list
5982 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5984 boolean found_inactive_cascade = FALSE;
5986 if (*editor_elements_info[i].setup_value)
5988 if (setup.editor.el_headlines)
5990 // required for correct padding of palette headline buttons
5991 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
5992 ED_ELEMENTLIST_COLS : 0);
5994 for (j = 0; j < headline_size; j++)
5996 // use empty elements for padding of palette headline buttons
5997 int element = (j < *editor_elements_info[i].headline_list_size ?
5998 (*editor_elements_info[i].headline_list)[j] :
5999 editor_el_empty[0]);
6001 editor_elements[pos++] = element;
6003 if (IS_EDITOR_CASCADE_INACTIVE(element))
6004 found_inactive_cascade = TRUE;
6008 if (found_inactive_cascade)
6011 // required for correct padding of palette element buttons
6012 int element_list_size = *editor_elements_info[i].element_list_size;
6014 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6015 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6017 // copy all elements from element list
6018 for (j = 0; j < element_list_size; j++)
6019 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6021 // use empty elements for padding of palette element buttons
6022 for (j = 0; j < element_buttons - element_list_size; j++)
6023 editor_elements[pos++] = editor_el_empty[0];
6027 // (this function is also called before editor gadgets are initialized!)
6028 AdjustElementListScrollbar();
6031 void PrintEditorElementList(void)
6033 boolean *stop = &setup_editor_el_user_defined;
6036 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6038 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6040 if (IS_EDITOR_CASCADE(cascade_element))
6042 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6043 char *headline = element_info[cascade_element_show].editor_description;
6045 PrintLineWithPrefix("# ", "-", 77);
6046 Print("# %s\n", headline);
6047 PrintLineWithPrefix("# ", "-", 77);
6050 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6052 int element = (*editor_elements_info[i].headline_list)[j];
6054 if (IS_EDITOR_CASCADE(element))
6055 element = EL_CHAR_MINUS;
6057 Print("# %s\n", element_info[element].token_name);
6063 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6065 int element = (*editor_elements_info[i].element_list)[j];
6067 Print("# %s\n", element_info[element].token_name);
6075 static void ReinitializeElementListButtons(void)
6077 static boolean last_setup_value_headlines = FALSE;
6078 static boolean initialization_needed = TRUE;
6081 if (!initialization_needed) // check if editor element setup has changed
6083 if (last_setup_value_headlines != setup.editor.el_headlines)
6084 initialization_needed = TRUE;
6086 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6087 if (editor_elements_info[i].last_setup_value !=
6088 *editor_elements_info[i].setup_value)
6089 initialization_needed = TRUE;
6092 if (!initialization_needed)
6095 FreeLevelEditorGadgets();
6096 CreateLevelEditorGadgets();
6098 // store current setup values for next invocation of this function
6099 last_setup_value_headlines = setup.editor.el_headlines;
6100 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6101 editor_elements_info[i].last_setup_value =
6102 *editor_elements_info[i].setup_value;
6104 initialization_needed = FALSE;
6107 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6110 int border_graphic =
6111 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6112 struct GraphicInfo *g = &graphic_info[border_graphic];
6113 Bitmap *src_bitmap = g->bitmap;
6114 int src_x = g->src_x;
6115 int src_y = g->src_y;
6116 int border_size = g->border_size;
6117 int border_xpos = g->width - border_size;
6118 int border_ypos = g->height - border_size;
6119 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6122 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6123 border_size, border_size,
6124 dest_x - border_size, dest_y - border_size);
6125 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6126 border_size, border_size,
6127 dest_x + width, dest_y - border_size);
6128 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6129 border_size, border_size,
6130 dest_x - border_size, dest_y + height);
6131 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6132 border_size, border_size,
6133 dest_x + width, dest_y + height);
6135 for (i = 0; i < width / tilesize; i++)
6137 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6138 tilesize, border_size,
6139 dest_x + i * tilesize, dest_y - border_size);
6140 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6141 tilesize, border_size,
6142 dest_x + i * tilesize, dest_y + height);
6145 for (i = 0; i < height / tilesize; i++)
6147 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6148 border_size, tilesize,
6149 dest_x - border_size, dest_y + i * tilesize);
6150 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6151 border_size, tilesize,
6152 dest_x + width, dest_y + i * tilesize);
6155 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6158 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6160 int xsize_tile = MAX(ed_tilesize, xsize);
6161 int ysize_tile = MAX(ed_tilesize, ysize);
6162 int xsize_full = xsize + 1;
6163 int ysize_full = ysize + 1;
6164 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6165 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6166 Pixel line_color = getTabulatorBarColor();
6168 if (line_color == BLACK_PIXEL) // black => transparent
6171 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6172 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6173 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6176 static void DrawEditorLevelBorderLinesIfNeeded(void)
6178 int xsize = lev_fieldx * ed_tilesize;
6179 int ysize = lev_fieldy * ed_tilesize;
6180 int line_size = getTabulatorBarHeight();
6182 if (!suppressBorderElement())
6185 // draw little border line around editable level playfield
6188 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6191 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6193 if (xsize < SXSIZE && ysize < SYSIZE)
6194 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6197 static void DrawEditorElement(int x, int y, int element)
6199 DrawSizedElement(x, y, element, ed_tilesize);
6202 static void DrawEditorElementThruMask(int x, int y, int element)
6204 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6207 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6209 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6212 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6214 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6215 DrawEditorLevelBorderLinesIfNeeded();
6218 static void DrawDrawingArea(int id)
6220 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6223 int *value = drawingarea_info[id].value;
6224 int area_xsize = drawingarea_info[id].area_xsize;
6225 int area_ysize = drawingarea_info[id].area_ysize;
6226 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6228 for (x = 0; x < area_xsize; x++)
6229 for (y = 0; y < area_ysize; y++)
6230 DrawSizedGraphicExt(drawto,
6231 gi->x + x * tilesize,
6232 gi->y + y * tilesize,
6233 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6236 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6239 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6240 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6242 BlitBitmap(drawto, drawto,
6243 SX + (dx == -1 ? ed_tilesize : 0),
6244 SY + (dy == -1 ? ed_tilesize : 0),
6245 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6246 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6247 SX + (dx == +1 ? ed_tilesize : 0),
6248 SY + (dy == +1 ? ed_tilesize : 0));
6252 x = (dx == 1 ? 0 : ed_fieldx - 1);
6253 for (y = 0; y < ed_fieldy; y++)
6254 DrawEditorElementOrWall(x, y, from_x, from_y);
6258 y = (dy == 1 ? 0 : ed_fieldy - 1);
6259 for (x = 0; x < ed_fieldx; x++)
6260 DrawEditorElementOrWall(x, y, from_x, from_y);
6263 redraw_mask |= REDRAW_FIELD;
6267 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6270 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6273 static void CreateControlButtons(void)
6275 struct GadgetInfo *gi;
6278 // create toolbox buttons
6279 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6281 int id = controlbutton_info[i].gadget_id;
6282 int type = controlbutton_info[i].gadget_type;
6283 int graphic = controlbutton_info[i].graphic;
6284 struct XYTileSize *pos = controlbutton_info[i].pos;
6285 struct GraphicInfo *gd = &graphic_info[graphic];
6286 Bitmap *deco_bitmap = NULL;
6287 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6288 int tile_size = 0, deco_shift = 0;
6289 boolean deco_masked = FALSE;
6290 int gd_x1 = gd->src_x;
6291 int gd_y1 = gd->src_y;
6292 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6293 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6294 int gd_x1a = gd->src_x + gd->active_xoffset;
6295 int gd_y1a = gd->src_y + gd->active_yoffset;
6296 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6297 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6300 unsigned int event_mask;
6301 int radio_button_nr = RADIO_NR_NONE;
6302 boolean checked = FALSE;
6304 if (type == GD_TYPE_RADIO_BUTTON)
6306 event_mask = GD_EVENT_PRESSED;
6307 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6309 if (id == drawing_function)
6314 if (id == GADGET_ID_WRAP_LEFT ||
6315 id == GADGET_ID_WRAP_RIGHT ||
6316 id == GADGET_ID_WRAP_UP ||
6317 id == GADGET_ID_WRAP_DOWN)
6318 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6320 event_mask = GD_EVENT_RELEASED;
6323 if (id == GADGET_ID_PROPERTIES ||
6324 id == GADGET_ID_PALETTE)
6329 else if (id == GADGET_ID_ELEMENT_LEFT ||
6330 id == GADGET_ID_ELEMENT_MIDDLE ||
6331 id == GADGET_ID_ELEMENT_RIGHT)
6336 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6337 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6338 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6340 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6341 editor.button.element_left.tile_size :
6342 id == GADGET_ID_ELEMENT_MIDDLE ?
6343 editor.button.element_middle.tile_size :
6344 id == GADGET_ID_ELEMENT_RIGHT ?
6345 editor.button.element_right.tile_size : 0);
6347 // make sure that decoration does not overlap gadget border
6348 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6350 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6352 deco_xpos = (gd->width - tile_size) / 2;
6353 deco_ypos = (gd->height - tile_size) / 2;
6355 deco_masked = gd->draw_masked;
6363 gi = CreateGadget(GDI_CUSTOM_ID, id,
6364 GDI_CUSTOM_TYPE_ID, i,
6365 GDI_IMAGE_ID, graphic,
6366 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6369 GDI_WIDTH, gd->width,
6370 GDI_HEIGHT, gd->height,
6372 GDI_STATE, GD_BUTTON_UNPRESSED,
6373 GDI_RADIO_NR, radio_button_nr,
6374 GDI_CHECKED, checked,
6375 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6376 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6377 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6378 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6379 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6380 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6381 GDI_DECORATION_SIZE, tile_size, tile_size,
6382 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6383 GDI_DECORATION_MASKED, deco_masked,
6384 GDI_EVENT_MASK, event_mask,
6385 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6386 GDI_CALLBACK_ACTION, HandleControlButtons,
6390 Fail("cannot create gadget");
6392 level_editor_gadget[id] = gi;
6395 // these values are not constant, but can change at runtime
6396 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6397 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6398 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6399 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6400 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6401 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6402 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6403 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6404 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6405 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6406 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6407 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6409 // create buttons for scrolling of drawing area and element list
6410 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6412 int id = scrollbutton_info[i].gadget_id;
6413 int graphic = scrollbutton_info[i].graphic;
6414 struct GraphicInfo *gd = &graphic_info[graphic];
6415 Bitmap *gd_bitmap = gd->bitmap;
6416 int gd_x1 = gd->src_x;
6417 int gd_y1 = gd->src_y;
6418 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6419 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6420 int width = gd->width;
6421 int height = gd->height;
6422 int x = scrollbutton_pos[i].x;
6423 int y = scrollbutton_pos[i].y;
6424 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6426 if (id == GADGET_ID_SCROLL_LIST_UP ||
6427 id == GADGET_ID_SCROLL_LIST_DOWN)
6438 gi = CreateGadget(GDI_CUSTOM_ID, id,
6439 GDI_CUSTOM_TYPE_ID, i,
6440 GDI_IMAGE_ID, graphic,
6441 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6446 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6447 GDI_STATE, GD_BUTTON_UNPRESSED,
6448 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6449 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6450 GDI_EVENT_MASK, event_mask,
6451 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6452 GDI_CALLBACK_ACTION, HandleControlButtons,
6456 Fail("cannot create gadget");
6458 level_editor_gadget[id] = gi;
6461 // create buttons for element list
6462 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6464 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6465 int graphic = IMG_EDITOR_PALETTE_BUTTON;
6466 struct GraphicInfo *gd = &graphic_info[graphic];
6467 Bitmap *gd_bitmap = gd->bitmap;
6468 Bitmap *deco_bitmap;
6469 int deco_x, deco_y, deco_xpos, deco_ypos;
6470 int gd_x1 = gd->src_x;
6471 int gd_y1 = gd->src_y;
6472 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6473 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6474 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
6475 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
6476 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
6477 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
6478 int element = editor_elements[i];
6479 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
6480 unsigned int event_mask = GD_EVENT_RELEASED;
6482 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
6484 deco_xpos = (gd->width - tile_size) / 2;
6485 deco_ypos = (gd->height - tile_size) / 2;
6487 gi = CreateGadget(GDI_CUSTOM_ID, id,
6488 GDI_CUSTOM_TYPE_ID, i,
6489 GDI_IMAGE_ID, graphic,
6490 GDI_INFO_TEXT, getElementInfoText(element),
6493 GDI_WIDTH, gd->width,
6494 GDI_HEIGHT, gd->height,
6495 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6496 GDI_STATE, GD_BUTTON_UNPRESSED,
6497 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6498 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6499 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6500 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6501 GDI_DECORATION_SIZE, tile_size, tile_size,
6502 GDI_DECORATION_SHIFTING, 1, 1,
6503 GDI_EVENT_MASK, event_mask,
6504 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6505 GDI_CALLBACK_ACTION, HandleControlButtons,
6509 Fail("cannot create gadget");
6511 level_editor_gadget[id] = gi;
6515 static void CreateCounterButtons(void)
6517 int max_infotext_len = getMaxInfoTextLength();
6520 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
6523 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
6524 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
6526 // determine horizontal position to the right of specified gadget
6527 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6528 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
6529 ED_GADGET_TEXT_DISTANCE);
6531 // determine horizontal offset for leading text
6532 if (counterbutton_info[i].text_left != NULL)
6533 x += getTextWidthForGadget(counterbutton_info[i].text_left);
6535 for (j = 0; j < 2; j++)
6537 struct GadgetInfo *gi;
6539 counterbutton_info[i].gadget_id_down :
6540 counterbutton_info[i].gadget_id_up);
6542 struct GraphicInfo *gd;
6543 int gd_x1, gd_x2, gd_y1, gd_y2;
6544 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6545 char infotext[max_infotext_len + 1];
6547 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6550 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
6551 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
6553 event_mask |= GD_EVENT_RELEASED;
6557 x = DX + editor.button.prev_level.x;
6558 y = DY + editor.button.prev_level.y;
6562 x = DX + editor.button.next_level.x;
6563 y = DY + editor.button.next_level.y;
6569 IMG_EDITOR_COUNTER_DOWN :
6570 IMG_EDITOR_COUNTER_UP);
6573 gd = &graphic_info[graphic];
6577 gd_x2 = gd->src_x + gd->pressed_xoffset;
6578 gd_y2 = gd->src_y + gd->pressed_yoffset;
6580 sprintf(infotext, "%s counter value by 1, 5 or 10",
6581 (j == 0 ? "decrease" : "increase"));
6583 gi = CreateGadget(GDI_CUSTOM_ID, id,
6584 GDI_CUSTOM_TYPE_ID, i,
6585 GDI_IMAGE_ID, graphic,
6586 GDI_INFO_TEXT, infotext,
6589 GDI_WIDTH, gd->width,
6590 GDI_HEIGHT, gd->height,
6591 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6592 GDI_STATE, GD_BUTTON_UNPRESSED,
6593 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6594 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6595 GDI_EVENT_MASK, event_mask,
6596 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6597 GDI_CALLBACK_ACTION, HandleCounterButtons,
6601 Fail("cannot create gadget");
6603 level_editor_gadget[id] = gi;
6604 right_gadget_border[id] =
6605 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6607 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
6611 int font_type = FONT_INPUT_1;
6612 int font_type_active = FONT_INPUT_1_ACTIVE;
6614 id = counterbutton_info[i].gadget_id_text;
6616 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6618 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6620 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
6622 font_type = FONT_LEVEL_NUMBER;
6623 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
6625 x = DX + editor.input.level_number.x;
6626 y = DY + editor.input.level_number.y;
6630 graphic = IMG_EDITOR_COUNTER_INPUT;
6633 gd = &graphic_info[graphic];
6637 gd_x2 = gd->src_x + gd->active_xoffset;
6638 gd_y2 = gd->src_y + gd->active_yoffset;
6640 gi = CreateGadget(GDI_CUSTOM_ID, id,
6641 GDI_CUSTOM_TYPE_ID, i,
6642 GDI_IMAGE_ID, graphic,
6643 GDI_INFO_TEXT, "enter counter value",
6646 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
6647 GDI_NUMBER_VALUE, 0,
6648 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
6649 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
6650 GDI_TEXT_SIZE, 3, // minimal counter text size
6651 GDI_TEXT_FONT, font_type,
6652 GDI_TEXT_FONT_ACTIVE, font_type_active,
6653 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6654 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6655 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6656 GDI_DESIGN_WIDTH, gd->width,
6657 GDI_EVENT_MASK, event_mask,
6658 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6659 GDI_CALLBACK_ACTION, HandleCounterButtons,
6663 Fail("cannot create gadget");
6665 level_editor_gadget[id] = gi;
6666 right_gadget_border[id] =
6667 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6669 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
6675 static void CreateDrawingAreas(void)
6679 // these values are not constant, but can change at runtime
6680 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
6681 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
6683 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
6685 struct GadgetInfo *gi;
6686 int id = drawingarea_info[i].gadget_id;
6687 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
6688 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
6689 int area_xsize = drawingarea_info[i].area_xsize;
6690 int area_ysize = drawingarea_info[i].area_ysize;
6691 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
6692 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
6693 unsigned int event_mask =
6694 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
6695 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
6697 // determine horizontal position to the right of specified gadget
6698 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
6699 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
6700 ED_DRAWINGAREA_TEXT_DISTANCE);
6702 // determine horizontal offset for leading text
6703 if (drawingarea_info[i].text_left != NULL)
6704 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
6706 gi = CreateGadget(GDI_CUSTOM_ID, id,
6707 GDI_CUSTOM_TYPE_ID, i,
6710 GDI_TYPE, GD_TYPE_DRAWING_AREA,
6711 GDI_AREA_SIZE, area_xsize, area_ysize,
6712 GDI_ITEM_SIZE, item_size, item_size,
6713 GDI_EVENT_MASK, event_mask,
6714 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
6715 GDI_CALLBACK_ACTION, HandleDrawingAreas,
6719 Fail("cannot create gadget");
6721 level_editor_gadget[id] = gi;
6722 right_gadget_border[id] =
6723 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
6727 static void CreateTextInputGadgets(void)
6729 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
6730 int max_infotext_len = getMaxInfoTextLength();
6733 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
6735 int gd_x1 = gd->src_x;
6736 int gd_y1 = gd->src_y;
6737 int gd_x2 = gd->src_x + gd->active_xoffset;
6738 int gd_y2 = gd->src_y + gd->active_yoffset;
6739 struct GadgetInfo *gi;
6740 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6741 char infotext[MAX_OUTPUT_LINESIZE + 1];
6742 int id = textinput_info[i].gadget_id;
6745 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
6747 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
6748 int border_size = gd->border_size;
6749 int font_nr = FONT_INPUT_1;
6750 int font_height = getFontHeight(font_nr);
6751 int xoffset = element_border + TILEX + element_border + 3 * border_size;
6752 int yoffset = element_border + (TILEY - font_height) / 2;
6754 x = (editor.settings.element_name.x != -1 ?
6755 editor.settings.element_name.x :
6756 editor.settings.element_graphic.x + xoffset) - border_size;
6757 y = (editor.settings.element_name.y != -1 ?
6758 editor.settings.element_name.y :
6759 editor.settings.element_graphic.y + yoffset) - border_size;
6763 x = ED_SETTINGS_X(textinput_info[i].x);
6764 y = ED_SETTINGS_Y(textinput_info[i].y);
6767 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
6768 infotext[max_infotext_len] = '\0';
6770 gi = CreateGadget(GDI_CUSTOM_ID, id,
6771 GDI_CUSTOM_TYPE_ID, i,
6772 GDI_INFO_TEXT, infotext,
6775 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
6776 GDI_TEXT_VALUE, textinput_info[i].value,
6777 GDI_TEXT_SIZE, textinput_info[i].size,
6778 GDI_TEXT_FONT, FONT_INPUT_1,
6779 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6780 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6781 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6782 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6783 GDI_DESIGN_WIDTH, gd->width,
6784 GDI_EVENT_MASK, event_mask,
6785 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6786 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
6790 Fail("cannot create gadget");
6792 level_editor_gadget[id] = gi;
6796 static void CreateTextAreaGadgets(void)
6798 int max_infotext_len = getMaxInfoTextLength();
6801 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
6803 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
6804 int gd_x1 = gd->src_x;
6805 int gd_y1 = gd->src_y;
6806 int gd_x2 = gd->src_x + gd->active_xoffset;
6807 int gd_y2 = gd->src_y + gd->active_yoffset;
6808 struct GadgetInfo *gi;
6809 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
6810 char infotext[MAX_OUTPUT_LINESIZE + 1];
6811 int id = textarea_info[i].gadget_id;
6812 int area_xsize = textarea_info[i].xsize;
6813 int area_ysize = textarea_info[i].ysize;
6815 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
6816 infotext[max_infotext_len] = '\0';
6818 gi = CreateGadget(GDI_CUSTOM_ID, id,
6819 GDI_CUSTOM_TYPE_ID, i,
6820 GDI_INFO_TEXT, infotext,
6821 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
6822 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
6823 GDI_TYPE, GD_TYPE_TEXT_AREA,
6824 GDI_AREA_SIZE, area_xsize, area_ysize,
6825 GDI_TEXT_FONT, FONT_INPUT_1,
6826 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6827 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6828 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6829 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6830 GDI_DESIGN_WIDTH, gd->width,
6831 GDI_EVENT_MASK, event_mask,
6832 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6833 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
6837 Fail("cannot create gadget");
6839 level_editor_gadget[id] = gi;
6843 static void CreateSelectboxGadgets(void)
6845 int max_infotext_len = getMaxInfoTextLength();
6848 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6850 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
6851 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
6852 int gd_x1 = gd->src_x;
6853 int gd_y1 = gd->src_y;
6854 int gd_x2 = gd->src_x + gd->active_xoffset;
6855 int gd_y2 = gd->src_y + gd->active_yoffset;
6856 int selectbox_button_xsize = gd2->width;
6857 struct GadgetInfo *gi;
6858 char infotext[MAX_OUTPUT_LINESIZE + 1];
6859 int id = selectbox_info[i].gadget_id;
6860 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
6861 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
6862 unsigned int event_mask =
6863 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6865 if (selectbox_info[i].size == -1) // dynamically determine size
6867 // (we cannot use -1 for uninitialized values if we directly compare
6868 // with results from strlen(), because the '<' and '>' operation will
6869 // implicitely cast -1 to an unsigned integer value!)
6870 selectbox_info[i].size = 0;
6872 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
6873 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
6874 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
6876 selectbox_info[i].size++; // add one character empty space
6879 // determine horizontal position to the right of specified gadget
6880 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
6881 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
6882 ED_GADGET_TEXT_DISTANCE);
6884 // determine horizontal offset for leading text
6885 if (selectbox_info[i].text_left != NULL)
6886 x += getTextWidthForGadget(selectbox_info[i].text_left);
6888 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
6889 infotext[max_infotext_len] = '\0';
6891 gi = CreateGadget(GDI_CUSTOM_ID, id,
6892 GDI_CUSTOM_TYPE_ID, i,
6893 GDI_INFO_TEXT, infotext,
6896 GDI_TYPE, GD_TYPE_SELECTBOX,
6897 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
6898 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
6899 GDI_TEXT_SIZE, selectbox_info[i].size,
6900 GDI_TEXT_FONT, FONT_INPUT_1,
6901 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6902 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
6903 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6904 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6905 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6906 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
6907 GDI_DESIGN_WIDTH, gd->width,
6908 GDI_EVENT_MASK, event_mask,
6909 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6910 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
6914 Fail("cannot create gadget");
6916 level_editor_gadget[id] = gi;
6917 right_gadget_border[id] =
6918 getRightGadgetBorder(gi, selectbox_info[i].text_right);
6922 static void CreateTextbuttonGadgets(void)
6924 int max_infotext_len = getMaxInfoTextLength();
6927 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
6929 int id = textbutton_info[i].gadget_id;
6931 ((id >= GADGET_ID_LEVELINFO_LEVEL && id <= GADGET_ID_LEVELINFO_EDITOR) ||
6932 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
6934 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
6935 int gadget_distance =
6936 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
6937 struct GraphicInfo *gd = &graphic_info[graphic];
6938 int gd_x1 = gd->src_x;
6939 int gd_y1 = gd->src_y;
6940 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6941 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6942 int gd_x1a = gd->src_x + gd->active_xoffset;
6943 int gd_y1a = gd->src_y + gd->active_yoffset;
6944 int border_xsize = gd->border_size + gd->draw_xoffset;
6945 int border_ysize = gd->border_size;
6946 struct GadgetInfo *gi;
6947 unsigned int event_mask = GD_EVENT_RELEASED;
6948 char infotext[MAX_OUTPUT_LINESIZE + 1];
6949 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
6950 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
6952 if (textbutton_info[i].size == -1) // dynamically determine size
6953 textbutton_info[i].size = strlen(textbutton_info[i].text);
6955 sprintf(infotext, "%s", textbutton_info[i].infotext);
6956 infotext[max_infotext_len] = '\0';
6958 // determine horizontal position to the right of specified gadget
6959 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6961 int gadget_id_align = textbutton_info[i].gadget_id_align;
6963 x = right_gadget_border[gadget_id_align] + gadget_distance;
6965 if (textbutton_info[i].y == -1)
6966 y = level_editor_gadget[gadget_id_align]->y;
6969 // determine horizontal offset for leading text
6970 if (textbutton_info[i].text_left != NULL)
6971 x += getTextWidthForGadget(textbutton_info[i].text_left);
6973 gi = CreateGadget(GDI_CUSTOM_ID, id,
6974 GDI_CUSTOM_TYPE_ID, i,
6975 GDI_IMAGE_ID, graphic,
6976 GDI_INFO_TEXT, infotext,
6979 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
6980 GDI_TEXT_VALUE, textbutton_info[i].text,
6981 GDI_TEXT_SIZE, textbutton_info[i].size,
6982 GDI_TEXT_FONT, FONT_INPUT_2,
6983 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
6984 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6985 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6986 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6987 GDI_BORDER_SIZE, border_xsize, border_ysize,
6988 GDI_DESIGN_WIDTH, gd->width,
6989 GDI_DECORATION_SHIFTING, 1, 1,
6990 GDI_EVENT_MASK, event_mask,
6991 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6992 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
6996 Fail("cannot create gadget");
6998 level_editor_gadget[id] = gi;
6999 right_gadget_border[id] =
7000 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7004 static void CreateGraphicbuttonGadgets(void)
7006 struct GadgetInfo *gi;
7009 // create buttons for scrolling of drawing area and element list
7010 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7012 int id = graphicbutton_info[i].gadget_id;
7013 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7014 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7015 int graphic = graphicbutton_info[i].graphic;
7016 struct GraphicInfo *gd = &graphic_info[graphic];
7017 int gd_x1 = gd->src_x;
7018 int gd_y1 = gd->src_y;
7019 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7020 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7021 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7023 // determine horizontal position to the right of specified gadget
7024 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7025 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7026 ED_GADGET_TEXT_DISTANCE);
7028 // determine horizontal offset for leading text
7029 if (graphicbutton_info[i].text_left != NULL)
7030 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7032 gi = CreateGadget(GDI_CUSTOM_ID, id,
7033 GDI_CUSTOM_TYPE_ID, i,
7034 GDI_IMAGE_ID, graphic,
7035 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7038 GDI_WIDTH, gd->width,
7039 GDI_HEIGHT, gd->height,
7040 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7041 GDI_STATE, GD_BUTTON_UNPRESSED,
7042 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7043 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7044 GDI_EVENT_MASK, event_mask,
7045 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7046 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7050 Fail("cannot create gadget");
7052 level_editor_gadget[id] = gi;
7053 right_gadget_border[id] =
7054 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7058 static void CreateScrollbarGadgets(void)
7062 // these values are not constant, but can change at runtime
7063 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7064 SX + ED_SCROLL_HORIZONTAL_XPOS;
7065 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7066 SY + ED_SCROLL_HORIZONTAL_YPOS;
7067 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7068 ED_SCROLL_HORIZONTAL_XSIZE;
7069 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7070 ED_SCROLL_HORIZONTAL_YSIZE;
7071 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7072 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7073 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7074 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7076 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7077 SX + ED_SCROLL_VERTICAL_XPOS;
7078 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7079 SY + ED_SCROLL_VERTICAL_YPOS;
7080 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7081 ED_SCROLL_VERTICAL_XSIZE;
7082 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7083 ED_SCROLL_VERTICAL_YSIZE;
7084 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7085 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7086 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7087 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7089 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7090 PX + ED_SCROLL2_VERTICAL_XPOS;
7091 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7092 PY + ED_SCROLL2_VERTICAL_YPOS;
7093 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7094 ED_SCROLL2_VERTICAL_XSIZE;
7095 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7096 ED_SCROLL2_VERTICAL_YSIZE;
7097 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7098 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7099 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7100 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7102 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7104 int id = scrollbar_info[i].gadget_id;
7105 int graphic = scrollbar_info[i].graphic;
7106 struct GraphicInfo *gd = &graphic_info[graphic];
7107 int gd_x1 = gd->src_x;
7108 int gd_y1 = gd->src_y;
7109 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7110 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7111 struct GadgetInfo *gi;
7112 int items_max, items_visible, item_position;
7113 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7115 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7117 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7118 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7119 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7121 else // drawing area scrollbars
7123 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7125 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7126 items_visible = ed_fieldx;
7131 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7132 items_visible = ed_fieldy;
7137 gi = CreateGadget(GDI_CUSTOM_ID, id,
7138 GDI_CUSTOM_TYPE_ID, i,
7139 GDI_IMAGE_ID, graphic,
7140 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7141 GDI_X, scrollbar_pos[i].x,
7142 GDI_Y, scrollbar_pos[i].y,
7143 GDI_WIDTH, scrollbar_pos[i].width,
7144 GDI_HEIGHT, scrollbar_pos[i].height,
7145 GDI_TYPE, scrollbar_info[i].type,
7146 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7147 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7148 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7149 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7150 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7151 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7152 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7153 GDI_STATE, GD_BUTTON_UNPRESSED,
7154 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7155 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7156 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7157 GDI_EVENT_MASK, event_mask,
7158 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7159 GDI_CALLBACK_ACTION, HandleControlButtons,
7163 Fail("cannot create gadget");
7165 level_editor_gadget[id] = gi;
7169 static void CreateCheckbuttonGadgets(void)
7171 struct GadgetInfo *gi;
7174 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7176 int id = checkbutton_info[i].gadget_id;
7177 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7178 IMG_EDITOR_CHECKBOX);
7179 struct GraphicInfo *gd = &graphic_info[graphic];
7180 int gd_x1 = gd->src_x;
7181 int gd_y1 = gd->src_y;
7182 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7183 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7184 int gd_x1a = gd->src_x + gd->active_xoffset;
7185 int gd_y1a = gd->src_y + gd->active_yoffset;
7186 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7187 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7188 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7189 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7190 unsigned int event_mask = GD_EVENT_PRESSED;
7192 // determine horizontal position to the right of specified gadget
7193 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7194 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7195 ED_GADGET_TEXT_DISTANCE);
7197 // determine horizontal offset for leading text
7198 if (checkbutton_info[i].text_left != NULL)
7199 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7201 gi = CreateGadget(GDI_CUSTOM_ID, id,
7202 GDI_CUSTOM_TYPE_ID, i,
7203 GDI_IMAGE_ID, graphic,
7204 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7207 GDI_WIDTH, gd->width,
7208 GDI_HEIGHT, gd->height,
7209 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7210 GDI_CHECKED, *checkbutton_info[i].value,
7211 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7212 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7213 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7214 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7215 GDI_EVENT_MASK, event_mask,
7216 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7217 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7221 Fail("cannot create gadget");
7223 level_editor_gadget[id] = gi;
7224 right_gadget_border[id] =
7225 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7229 static void CreateRadiobuttonGadgets(void)
7231 int graphic = IMG_EDITOR_RADIOBUTTON;
7232 struct GraphicInfo *gd = &graphic_info[graphic];
7233 int gd_x1 = gd->src_x;
7234 int gd_y1 = gd->src_y;
7235 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7236 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7237 int gd_x1a = gd->src_x + gd->active_xoffset;
7238 int gd_y1a = gd->src_y + gd->active_yoffset;
7239 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7240 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7241 struct GadgetInfo *gi;
7244 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7246 int id = radiobutton_info[i].gadget_id;
7247 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7248 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7249 unsigned int event_mask = GD_EVENT_PRESSED;
7252 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7254 // determine horizontal position to the right of specified gadget
7255 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7256 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7257 ED_GADGET_TEXT_DISTANCE);
7259 // determine horizontal offset for leading text
7260 if (radiobutton_info[i].text_left != NULL)
7261 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7263 gi = CreateGadget(GDI_CUSTOM_ID, id,
7264 GDI_CUSTOM_TYPE_ID, i,
7265 GDI_IMAGE_ID, graphic,
7266 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7269 GDI_WIDTH, gd->width,
7270 GDI_HEIGHT, gd->height,
7271 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7272 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7273 GDI_CHECKED, checked,
7274 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7275 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7276 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7277 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7278 GDI_EVENT_MASK, event_mask,
7279 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7280 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7284 Fail("cannot create gadget");
7286 level_editor_gadget[id] = gi;
7287 right_gadget_border[id] =
7288 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7292 void CreateLevelEditorGadgets(void)
7294 // force EDITOR font inside level editor
7295 SetFontStatus(GAME_MODE_EDITOR);
7297 // these values are not constant, but can change at runtime
7298 ed_fieldx = MAX_ED_FIELDX - 1;
7299 ed_fieldy = MAX_ED_FIELDY - 1;
7301 num_editor_gadgets = NUM_EDITOR_GADGETS;
7303 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7305 level_editor_gadget =
7306 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7307 right_gadget_border =
7308 checked_calloc(num_editor_gadgets * sizeof(int));
7310 // set number of empty (padding) element buttons to maximum number of buttons
7311 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7313 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7314 editor_el_empty_ptr = editor_el_empty;
7316 use_permanent_palette = !editor.palette.show_as_separate_screen;
7318 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
7320 ReinitializeElementList();
7322 CreateControlButtons();
7323 CreateScrollbarGadgets();
7325 // order of function calls is important because of cross-references
7326 CreateCheckbuttonGadgets();
7327 CreateCounterButtons();
7328 CreateRadiobuttonGadgets();
7329 CreateTextInputGadgets();
7330 CreateTextAreaGadgets();
7331 CreateSelectboxGadgets();
7332 CreateGraphicbuttonGadgets();
7333 CreateTextbuttonGadgets();
7334 CreateDrawingAreas();
7339 void FreeLevelEditorGadgets(void)
7343 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
7345 for (i = 0; i < num_editor_gadgets; i++)
7347 FreeGadget(level_editor_gadget[i]);
7349 level_editor_gadget[i] = NULL;
7352 checked_free(level_editor_gadget);
7353 checked_free(right_gadget_border);
7355 checked_free(editor_el_empty);
7358 static void MapCounterButtons(int id)
7360 int font_nr = FONT_TEXT_1;
7361 int font_height = getFontHeight(font_nr);
7362 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7363 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7364 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7365 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7366 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7367 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7368 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7369 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7370 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7371 int yoffset = (gi_down->height - font_height) / 2;
7372 int x_left = gi_down->x - xoffset_left;
7373 int x_right; // set after gadget position was modified
7374 int y_above = gi_down->y - yoffset_above;
7376 int y; // set after gadget position was modified
7378 // counter limits must be changed first to prevent value truncation
7379 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7380 counterbutton_info[id].max_value);
7382 // right text position might have changed after setting position above
7383 x_right = gi_up->x + gi_up->width + xoffset_right;
7385 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7387 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
7388 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7389 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7391 ModifyGadget(gi_down, GDI_Y,
7392 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7393 ModifyGadget(gi_text, GDI_Y,
7394 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7395 ModifyGadget(gi_up, GDI_Y,
7396 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7399 // vertical position might have changed after setting position above
7400 y = gi_up->y + yoffset;
7402 if (counterbutton_info[id].text_above)
7403 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
7405 if (counterbutton_info[id].text_left)
7406 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7408 if (counterbutton_info[id].text_right)
7409 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7416 static void MapControlButtons(void)
7421 // map toolbox buttons (excluding special CE toolbox buttons)
7422 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7423 MapGadget(level_editor_gadget[i]);
7425 // map toolbox buttons (element properties buttons)
7426 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
7427 MapGadget(level_editor_gadget[i]);
7429 if (use_permanent_palette)
7431 // map buttons to select elements
7432 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7433 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
7434 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
7435 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
7436 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
7439 // map buttons to select level
7440 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
7441 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
7442 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
7443 MapCounterButtons(counter_id);
7446 static void MapDrawingArea(int id)
7448 int font_nr = FONT_TEXT_1;
7449 int font_height = getFontHeight(font_nr);
7450 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7451 int area_xsize = gi->drawing.area_xsize;
7452 int area_ysize = gi->drawing.area_ysize;
7453 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7454 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
7455 int x_left = gi->x - xoffset_left;
7456 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
7457 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
7458 int x_below = gi->x + (gi->width - xoffset_below) / 2;
7459 int y_side = gi->y + (gi->height - font_height) / 2;
7460 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
7461 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
7463 if (drawingarea_info[id].text_left)
7464 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
7466 if (drawingarea_info[id].text_right)
7467 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
7469 if (drawingarea_info[id].text_above)
7470 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
7472 if (drawingarea_info[id].text_below)
7473 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
7475 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
7477 DrawElementBorder(gi->x, gi->y,
7478 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
7479 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
7481 DrawDrawingArea(id);
7487 static void MapTextInputGadget(int id)
7489 int font_nr = FONT_TEXT_1;
7490 int font_height = getFontHeight(font_nr);
7491 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
7492 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7493 int x_above = ED_SETTINGS_X(textinput_info[id].x);
7494 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
7496 if (textinput_info[id].text_above)
7497 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
7499 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
7504 static void MapTextAreaGadget(int id)
7506 int font_nr = FONT_TEXT_1;
7507 int font_height = getFontHeight(font_nr);
7508 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7509 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7510 int x_above = ED_SETTINGS_X(textarea_info[id].x);
7511 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
7512 char *text_above = textarea_info[id].text_above;
7514 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
7515 text_above = textarea_info[id].text_above_cropped;
7518 DrawTextS(x_above, y_above, font_nr, text_above);
7520 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
7525 static void MapSelectboxGadget(int id)
7527 int font_nr = FONT_TEXT_1;
7528 int font_height = getFontHeight(font_nr);
7529 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
7530 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
7531 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7532 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7533 int yoffset = (gi->height - font_height) / 2;
7534 int x_left = gi->x - xoffset_left;
7535 int x_right = gi->x + gi->width + xoffset_right;
7536 int y_above = gi->y - yoffset_above;
7538 int y = gi->y + yoffset;
7540 if (selectbox_info[id].text_above)
7541 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
7543 if (selectbox_info[id].text_left)
7544 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
7546 if (selectbox_info[id].text_right)
7547 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
7549 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
7554 static void MapTextbuttonGadget(int id)
7556 int font_nr = FONT_TEXT_1;
7557 int font_height = getFontHeight(font_nr);
7558 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
7559 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
7560 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7561 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7562 int yoffset = (gi->height - font_height) / 2;
7563 int x_left = gi->x - xoffset_left;
7564 int x_right = gi->x + gi->width + xoffset_right;
7565 int y_above = gi->y - yoffset_above;
7567 int y = gi->y + yoffset;
7569 // only show button to delete change pages when more than minimum pages
7570 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
7571 custom_element.num_change_pages == MIN_CHANGE_PAGES)
7574 if (textbutton_info[id].text_above)
7575 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
7577 if (textbutton_info[id].text_left)
7578 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
7580 if (textbutton_info[id].text_right)
7581 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
7586 static void MapGraphicbuttonGadget(int id)
7588 int font_nr = FONT_TEXT_1;
7589 int font_height = getFontHeight(font_nr);
7590 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
7591 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
7592 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7593 int yoffset = (gi->height - font_height) / 2;
7594 int x_left = gi->x - xoffset_left;
7595 int x_right = gi->x + gi->width + xoffset_right;
7596 int y = gi->y + yoffset;
7598 if (graphicbutton_info[id].text_left)
7599 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
7601 if (graphicbutton_info[id].text_right)
7602 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
7607 static void MapRadiobuttonGadget(int id)
7609 int font_nr = FONT_TEXT_1;
7610 int font_height = getFontHeight(font_nr);
7611 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
7612 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7613 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7614 int yoffset = (gi->height - font_height) / 2;
7615 int x_left = gi->x - xoffset_left;
7616 int x_right = gi->x + gi->width + xoffset_right;
7617 int y = gi->y + yoffset;
7619 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
7621 if (radiobutton_info[id].text_left)
7622 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
7624 if (radiobutton_info[id].text_right)
7625 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
7627 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
7632 static void MapCheckbuttonGadget(int id)
7634 int font_nr = FONT_TEXT_1;
7635 int font_height = getFontHeight(font_nr);
7636 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
7637 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7638 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7639 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7640 int yoffset = (gi->height - font_height) / 2;
7641 int y_above = gi->y - yoffset_above;
7643 int x_left, x_right, y; // set after gadget position was modified
7645 // set position for gadgets with dynamically determined position
7646 if (checkbutton_info[id].x != -1) // do not change dynamic positions
7647 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x),GDI_END);
7648 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
7650 x_left = gi->x - xoffset_left;
7651 x_right = gi->x + gi->width + xoffset_right;
7652 y = gi->y + yoffset;
7654 if (checkbutton_info[id].text_above)
7655 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
7657 if (checkbutton_info[id].text_left)
7658 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
7660 if (checkbutton_info[id].text_right)
7661 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
7663 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
7668 static void MapMainDrawingArea(void)
7670 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
7671 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
7674 if (suppressBorderElement())
7676 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
7677 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
7680 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
7682 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
7683 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
7684 no_horizontal_scrollbar) ||
7685 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
7686 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
7687 no_vertical_scrollbar))
7690 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
7693 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
7695 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
7696 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
7699 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
7702 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
7705 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
7709 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
7711 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
7712 i == GADGET_ID_CUSTOM_COPY_TO ||
7713 i == GADGET_ID_CUSTOM_EXCHANGE ||
7714 i == GADGET_ID_CUSTOM_COPY ||
7715 i == GADGET_ID_CUSTOM_PASTE)
7718 MapGadget(level_editor_gadget[i]);
7720 UnmapGadget(level_editor_gadget[i]);
7725 static void MapLevelEditorToolboxCustomGadgets(void)
7727 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
7730 static void UnmapLevelEditorToolboxCustomGadgets(void)
7732 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
7735 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
7739 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
7741 if (i != GADGET_ID_SINGLE_ITEMS &&
7742 i != GADGET_ID_PICK_ELEMENT)
7744 struct GadgetInfo *gi = level_editor_gadget[i];
7752 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
7753 struct GraphicInfo *gd = &graphic_info[graphic];
7757 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
7758 gi->width, gi->height, gi->x, gi->y);
7760 redraw_mask |= REDRAW_DOOR_3;
7766 static void MapLevelEditorToolboxDrawingGadgets(void)
7768 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
7771 static void UnmapLevelEditorToolboxDrawingGadgets(void)
7773 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
7776 static void UnmapDrawingArea(int id)
7778 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
7781 static void UnmapLevelEditorFieldGadgets(void)
7785 for (i = 0; i < num_editor_gadgets; i++)
7786 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
7787 level_editor_gadget[i]->y))
7788 UnmapGadget(level_editor_gadget[i]);
7791 void UnmapLevelEditorGadgets(void)
7795 for (i = 0; i < num_editor_gadgets; i++)
7796 UnmapGadget(level_editor_gadget[i]);
7799 static void ResetUndoBuffer(void)
7801 undo_buffer_position = -1;
7802 undo_buffer_steps = -1;
7803 redo_buffer_steps = 0;
7805 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7807 level.changed = FALSE;
7810 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
7812 if (remap_toolbox_gadgets)
7814 ModifyEditorElementList();
7815 RedrawDrawingElements();
7818 if (edit_mode == ED_MODE_INFO)
7819 DrawLevelInfoWindow();
7820 else if (edit_mode == ED_MODE_PROPERTIES)
7821 DrawPropertiesWindow();
7822 else if (edit_mode == ED_MODE_PALETTE)
7823 DrawPaletteWindow();
7824 else // edit_mode == ED_MODE_DRAWING
7825 DrawDrawingWindowExt(remap_toolbox_gadgets);
7828 static void DrawEditModeWindow(void)
7830 DrawEditModeWindowExt(TRUE);
7833 static void DrawEditModeWindow_PlayfieldOnly(void)
7835 DrawEditModeWindowExt(FALSE);
7838 static void ChangeEditModeWindow(int new_edit_mode)
7840 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
7842 DrawEditModeWindow();
7845 static boolean LevelChanged(void)
7847 boolean field_changed = FALSE;
7850 for (y = 0; y < lev_fieldy; y++)
7851 for (x = 0; x < lev_fieldx; x++)
7852 if (Tile[x][y] != level.field[x][y])
7853 field_changed = TRUE;
7855 return (level.changed || field_changed);
7858 static boolean PrepareSavingIntoPersonalLevelSet(void)
7860 static LevelDirTree *last_copied_leveldir = NULL;
7861 static LevelDirTree *last_written_leveldir = NULL;
7862 static int last_copied_level_nr = -1;
7863 static int last_written_level_nr = -1;
7864 LevelDirTree *leveldir_former = leveldir_current;
7865 int level_nr_former = level_nr;
7868 // remember last mod/save so that for current session, we write
7869 // back to the same personal copy, asking only about overwrite.
7870 if (leveldir_current == last_copied_leveldir &&
7871 level_nr == last_copied_level_nr)
7873 // "cd" to personal level set dir (as used when writing last copy)
7874 leveldir_current = last_written_leveldir;
7875 level_nr = last_written_level_nr;
7880 if (!Request("This level is read-only! "
7881 "Save into personal level set?", REQ_ASK))
7884 // "cd" to personal level set dir (for writing copy the first time)
7886 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
7888 // this may happen if "setup.internal.create_user_levelset" is FALSE
7889 // or if file "levelinfo.conf" is missing in personal user level set
7890 if (leveldir_current == NULL)
7892 Request("Cannot find personal level set?!", REQ_CONFIRM);
7894 leveldir_current = leveldir_former;
7899 // find unused level number
7900 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
7902 static char *level_filename = NULL;
7904 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
7906 if (!fileExists(level_filename))
7910 last_copied_leveldir = leveldir_former;
7911 last_copied_level_nr = level_nr_former;
7913 last_written_leveldir = leveldir_current;
7914 last_written_level_nr = level_nr = new_level_nr;
7919 static void ModifyLevelInfoForSavingIntoPersonalLevelSet(char *former_name)
7921 static char *filename_levelinfo = NULL, *mod_name = NULL;
7924 // annotate this copy-and-mod in personal levelinfo.conf
7925 setString(&filename_levelinfo,
7926 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
7928 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
7930 fprintf(file, "\n");
7931 fprintf(file, "# level %d was modified from:\n", level_nr);
7932 fprintf(file, "# - previous level set name: %s\n",
7934 fprintf(file, "# - level within previous set: %d \"%s\"\n",
7935 level.file_info.nr, level.name);
7936 fprintf(file, "# - previous author: %s\n",
7938 fprintf(file, "# - previous save date: ");
7940 if (level.creation_date.src == DATE_SRC_LEVELFILE)
7942 fprintf(file, "%04d-%02d-%02d\n",
7943 level.creation_date.year,
7944 level.creation_date.month,
7945 level.creation_date.day);
7949 fprintf(file, "not recorded\n");
7955 if (level_nr > leveldir_current->last_level)
7956 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
7958 // else: allow the save even if annotation failed
7960 // now... spray graffiti on the old level vital statistics
7961 // user can change these; just trying to set a good baseline
7963 // don't truncate names for fear of making offensive or silly:
7964 // long-named original author only recorded in levelinfo.conf.
7965 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
7966 if (!strEqual(level.author, leveldir_current->author))
7968 setString(&mod_name, getStringCat3(leveldir_current->author,
7969 " after ", level.author));
7971 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7972 setString(&mod_name,
7973 getStringCat2(leveldir_current->author, " (ed.)"));
7975 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7976 setString(&mod_name, leveldir_current->author);
7978 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
7980 // less worried about truncation here
7981 setString(&mod_name, getStringCat2("Mod: ", level.name));
7982 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
7986 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
7987 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
7991 for (x = 0; x < lev_fieldx; x++)
7992 for (y = 0; y < lev_fieldy; y++)
7993 dst[x][y] = src[x][y];
7996 static int setSelectboxValue(int selectbox_id, int new_value)
7998 int new_index_value = 0;
8001 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8002 if (selectbox_info[selectbox_id].options[i].value == new_value)
8003 new_index_value = i;
8005 *selectbox_info[selectbox_id].value =
8006 selectbox_info[selectbox_id].options[new_index_value].value;
8008 return new_index_value;
8011 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8015 // change action mode and arg variables according to action type variable
8016 for (i = 0; action_arg_options[i].value != -1; i++)
8018 if (action_arg_options[i].value == custom_element_change.action_type)
8020 int mode = action_arg_options[i].mode;
8022 // only change if corresponding selectbox has changed
8023 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8024 action_arg_modes[mode])
8025 custom_element_change.action_mode = -1;
8027 // only change if corresponding selectbox has changed
8028 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8029 action_arg_options[i].options)
8030 custom_element_change.action_arg = -1;
8037 static void setSelectboxSpecialActionOptions(void)
8041 // change action mode and arg selectbox according to action type selectbox
8042 for (i = 0; action_arg_options[i].value != -1; i++)
8044 if (action_arg_options[i].value == custom_element_change.action_type)
8046 int mode = action_arg_options[i].mode;
8048 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8049 action_arg_modes[mode]);
8050 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8051 custom_element_change.action_mode);
8053 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8054 action_arg_options[i].options);
8055 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8056 custom_element_change.action_arg);
8062 static void copy_custom_element_settings(int element_from, int element_to)
8064 struct ElementInfo *ei_from = &element_info[element_from];
8065 struct ElementInfo *ei_to = &element_info[element_to];
8067 copyElementInfo(ei_from, ei_to);
8070 static void replace_custom_element_in_settings(int element_from,
8075 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8077 struct ElementInfo *ei = &element_info[i];
8079 for (y = 0; y < 3; y++)
8080 for (x = 0; x < 3; x++)
8081 if (ei->content.e[x][y] == element_from)
8082 ei->content.e[x][y] = element_to;
8084 for (j = 0; j < ei->num_change_pages; j++)
8086 struct ElementChangeInfo *change = &ei->change_page[j];
8088 if (change->target_element == element_from)
8089 change->target_element = element_to;
8091 if (change->initial_trigger_element == element_from)
8092 change->initial_trigger_element = element_to;
8094 if (change->action_element == element_from)
8095 change->action_element = element_to;
8097 for (y = 0; y < 3; y++)
8098 for (x = 0; x < 3; x++)
8099 if (change->target_content.e[x][y] == element_from)
8100 change->target_content.e[x][y] = element_to;
8103 if (ei->group != NULL) // group or internal
8104 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8105 if (ei->group->element[j] == element_from)
8106 ei->group->element[j] = element_to;
8110 static void replace_custom_element_in_playfield(int element_from,
8115 for (x = 0; x < lev_fieldx; x++)
8116 for (y = 0; y < lev_fieldy; y++)
8117 if (Tile[x][y] == element_from)
8118 Tile[x][y] = element_to;
8121 static boolean CopyCustomElement(int element_old, int element_new,
8124 int copy_mode_orig = copy_mode;
8126 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8128 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8129 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8130 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8132 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8134 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8135 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8136 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8138 level.changed = TRUE;
8140 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8142 Request("Please choose custom element!", REQ_CONFIRM);
8146 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8148 Request("Please choose group element!", REQ_CONFIRM);
8154 level.changed = TRUE;
8157 // when modifying custom/group element, ask for copying level template
8158 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8160 if (!AskToCopyAndModifyLevelTemplate())
8164 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8166 copy_custom_element_settings(element_new, element_old);
8168 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8170 copy_custom_element_settings(element_old, element_new);
8172 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8174 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8175 copy_custom_element_settings(element_new, element_old);
8176 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8178 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8179 replace_custom_element_in_settings(element_new, element_old);
8180 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8182 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8183 replace_custom_element_in_playfield(element_new, element_old);
8184 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8187 UpdateCustomElementGraphicGadgets();
8188 DrawPropertiesWindow();
8193 static void CopyCustomElementPropertiesToEditor(int element)
8196 int current_change_page = element_info[element].current_change_page;
8198 // dynamically (re)build selectbox for selecting change page
8199 for (i = 0; i < element_info[element].num_change_pages; i++)
8201 sprintf(options_change_page_strings[i], "%d", i + 1);
8203 options_change_page[i].value = i;
8204 options_change_page[i].text = options_change_page_strings[i];
8207 options_change_page[i].value = -1;
8208 options_change_page[i].text = NULL;
8210 // needed here to initialize combined element properties
8211 InitElementPropertiesEngine(level.game_version);
8213 element_info[element].change =
8214 &element_info[element].change_page[current_change_page];
8216 custom_element = element_info[element];
8217 custom_element_change = *element_info[element].change;
8219 // needed to initially set selectbox options for special action options
8220 setSelectboxSpecialActionOptions();
8222 // needed to initially set selectbox value variables to reliable defaults
8223 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8224 setSelectboxValue(i, *selectbox_info[i].value);
8226 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8227 custom_element_properties[i] = HAS_PROPERTY(element, i);
8229 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8230 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8232 // ---------- element settings: configure (custom elements) -----------------
8234 // set accessible layer selectbox help value
8235 custom_element.access_type =
8236 (IS_WALKABLE(element) ? EP_WALKABLE :
8237 IS_PASSABLE(element) ? EP_PASSABLE :
8238 custom_element.access_type);
8239 custom_element.access_layer =
8240 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8241 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8242 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8243 custom_element.access_layer);
8244 custom_element.access_protected =
8245 (IS_PROTECTED(element) ? 1 : 0);
8246 custom_element_properties[EP_ACCESSIBLE] =
8247 (IS_ACCESSIBLE_OVER(element) ||
8248 IS_ACCESSIBLE_INSIDE(element) ||
8249 IS_ACCESSIBLE_UNDER(element));
8251 // set walk-to-object action selectbox help value
8252 custom_element.walk_to_action =
8253 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8254 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8255 IS_DROPPABLE(element) ? EP_DROPPABLE :
8256 IS_THROWABLE(element) ? EP_THROWABLE :
8257 IS_PUSHABLE(element) ? EP_PUSHABLE :
8258 custom_element.walk_to_action);
8259 custom_element_properties[EP_WALK_TO_OBJECT] =
8260 (IS_DIGGABLE(element) ||
8261 IS_COLLECTIBLE_ONLY(element) ||
8262 IS_DROPPABLE(element) ||
8263 IS_THROWABLE(element) ||
8264 IS_PUSHABLE(element));
8266 // set smash targets selectbox help value
8267 custom_element.smash_targets =
8268 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8269 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8270 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8271 custom_element.smash_targets);
8272 custom_element_properties[EP_CAN_SMASH] =
8273 (CAN_SMASH_EVERYTHING(element) ||
8274 CAN_SMASH_ENEMIES(element) ||
8275 CAN_SMASH_PLAYER(element));
8277 // set deadliness selectbox help value
8278 custom_element.deadliness =
8279 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8280 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8281 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8282 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8283 custom_element.deadliness);
8284 custom_element_properties[EP_DEADLY] =
8285 (DONT_TOUCH(element) ||
8286 DONT_GET_HIT_BY(element) ||
8287 DONT_COLLIDE_WITH(element) ||
8288 DONT_RUN_INTO(element));
8290 // ---------- element settings: advanced (custom elements) ------------------
8292 // set "change by direct action" selectbox help value
8293 custom_element_change.direct_action =
8294 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
8295 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8296 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8297 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8298 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8299 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8300 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8301 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8302 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8303 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8304 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8305 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8306 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8307 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8308 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8309 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8310 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8311 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8312 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8313 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
8314 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
8315 custom_element_change.direct_action);
8317 // set "change by other element action" selectbox help value
8318 custom_element_change.other_action =
8319 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
8320 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8321 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8322 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8323 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8324 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8325 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8326 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8327 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8328 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8329 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8330 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
8331 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8332 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8333 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8334 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8335 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8336 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8337 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8338 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8339 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8340 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8341 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8342 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8343 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8344 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
8345 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
8346 custom_element_change.other_action);
8349 static void CopyGroupElementPropertiesToEditor(int element)
8351 group_element_info = *element_info[element].group;
8352 custom_element = element_info[element]; // needed for description
8355 static void CopyEmptyElementPropertiesToEditor(int element)
8357 custom_element = element_info[element];
8360 static void CopyClassicElementPropertiesToEditor(int element)
8362 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8363 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
8364 getMoveIntoAcidProperty(&level, element);
8366 if (MAYBE_DONT_COLLIDE_WITH(element))
8367 custom_element_properties[EP_DONT_COLLIDE_WITH] =
8368 getDontCollideWithProperty(&level, element);
8371 static void CopyElementPropertiesToEditor(int element)
8373 if (IS_CUSTOM_ELEMENT(element))
8374 CopyCustomElementPropertiesToEditor(element);
8375 else if (IS_GROUP_ELEMENT(element))
8376 CopyGroupElementPropertiesToEditor(element);
8377 else if (IS_EMPTY_ELEMENT(element))
8378 CopyEmptyElementPropertiesToEditor(element);
8380 CopyClassicElementPropertiesToEditor(element);
8383 static boolean AskToCopyAndModifyLevelTemplate(void)
8385 if (Request("Copy and modify settings from level template?", REQ_ASK))
8387 level.use_custom_template = FALSE;
8389 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
8390 GDI_CHECKED, FALSE, GDI_END);
8391 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
8392 GDI_CHECKED, FALSE, GDI_END);
8398 LoadLevelTemplate(-1); // this resets all element modifications ...
8400 DrawEditModeWindow(); // ... and copies them to 'custom_element'
8406 static void CopyCustomElementPropertiesToGame(int element)
8409 int access_type_and_layer;
8411 // mark that this custom element has been modified
8412 custom_element.modified_settings = TRUE;
8413 level.changed = TRUE;
8415 if (level.use_custom_template)
8416 AskToCopyAndModifyLevelTemplate();
8418 element_info[element] = custom_element;
8419 *element_info[element].change = custom_element_change;
8421 // ---------- element settings: configure (custom elements) -----------------
8423 // set accessible property from checkbox and selectbox
8424 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
8425 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
8426 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
8427 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
8428 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
8429 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
8430 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
8431 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
8432 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
8433 custom_element_properties[access_type_and_layer] =
8434 custom_element_properties[EP_ACCESSIBLE];
8435 custom_element_properties[EP_PROTECTED] =
8436 (custom_element.access_protected != 0 &&
8437 custom_element_properties[EP_ACCESSIBLE]);
8439 // set walk-to-object property from checkbox and selectbox
8440 custom_element_properties[EP_DIGGABLE] = FALSE;
8441 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
8442 custom_element_properties[EP_DROPPABLE] = FALSE;
8443 custom_element_properties[EP_THROWABLE] = FALSE;
8444 custom_element_properties[EP_PUSHABLE] = FALSE;
8445 custom_element_properties[custom_element.walk_to_action] =
8446 custom_element_properties[EP_WALK_TO_OBJECT];
8448 // set smash property from checkbox and selectbox
8449 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
8450 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
8451 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
8452 custom_element_properties[custom_element.smash_targets] =
8453 custom_element_properties[EP_CAN_SMASH];
8455 // set deadliness property from checkbox and selectbox
8456 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
8457 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
8458 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
8459 custom_element_properties[EP_DONT_TOUCH] = FALSE;
8460 custom_element_properties[custom_element.deadliness] =
8461 custom_element_properties[EP_DEADLY];
8463 // ---------- element settings: advanced (custom elements) ------------------
8465 // set player change event from checkbox and selectbox
8466 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
8467 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
8468 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
8469 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
8470 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
8471 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
8472 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
8473 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
8474 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
8475 custom_element_change_events[CE_SWITCHED] = FALSE;
8476 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
8477 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
8478 custom_element_change_events[CE_BLOCKED] = FALSE;
8479 custom_element_change_events[CE_IMPACT] = FALSE;
8480 custom_element_change_events[CE_SMASHED] = FALSE;
8481 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
8482 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
8483 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
8484 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
8485 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
8486 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
8487 custom_element_change_events[custom_element_change.direct_action] =
8488 custom_element_change_events[CE_BY_DIRECT_ACTION];
8490 // set other element action change event from checkbox and selectbox
8491 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
8492 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
8493 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
8494 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
8495 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
8496 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
8497 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
8498 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
8499 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
8500 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
8501 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
8502 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
8503 custom_element_change_events[CE_TOUCHING_X] = FALSE;
8504 custom_element_change_events[CE_HITTING_X] = FALSE;
8505 custom_element_change_events[CE_DIGGING_X] = FALSE;
8506 custom_element_change_events[CE_HIT_BY_X] = FALSE;
8507 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
8508 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
8509 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
8510 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
8511 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
8512 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
8513 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
8514 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
8515 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
8516 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
8517 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
8518 custom_element_change_events[custom_element_change.other_action] =
8519 custom_element_change_events[CE_BY_OTHER_ACTION];
8521 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8522 SET_PROPERTY(element, i, custom_element_properties[i]);
8524 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8525 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
8527 // copy change events also to special level editor variable
8528 custom_element = element_info[element];
8529 custom_element_change = *element_info[element].change;
8531 // needed here to restore runtime value "element_info[element].gfx_element"
8532 InitElementPropertiesGfxElement();
8535 static void CopyGroupElementPropertiesToGame(int element)
8537 // mark that this group element has been modified
8538 custom_element.modified_settings = TRUE;
8539 level.changed = TRUE;
8541 if (level.use_custom_template)
8542 AskToCopyAndModifyLevelTemplate();
8544 element_info[element] = custom_element;
8545 *element_info[element].group = group_element_info;
8547 // needed here to restore runtime value "element_info[element].gfx_element"
8548 InitElementPropertiesGfxElement();
8551 static void CopyEmptyElementPropertiesToGame(int element)
8553 // mark that this empty element has been modified
8554 custom_element.modified_settings = TRUE;
8555 level.changed = TRUE;
8557 if (level.use_custom_template)
8558 AskToCopyAndModifyLevelTemplate();
8560 element_info[element] = custom_element;
8562 // needed here to restore runtime value "element_info[element].gfx_element"
8563 InitElementPropertiesGfxElement();
8566 static void CopyClassicElementPropertiesToGame(int element)
8568 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8569 setMoveIntoAcidProperty(&level, element,
8570 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
8572 if (MAYBE_DONT_COLLIDE_WITH(element))
8573 setDontCollideWithProperty(&level, element,
8574 custom_element_properties[EP_DONT_COLLIDE_WITH]);
8577 static void CopyElementPropertiesToGame(int element)
8579 if (IS_CUSTOM_ELEMENT(element))
8580 CopyCustomElementPropertiesToGame(element);
8581 else if (IS_GROUP_ELEMENT(element))
8582 CopyGroupElementPropertiesToGame(element);
8583 else if (IS_EMPTY_ELEMENT(element))
8584 CopyEmptyElementPropertiesToGame(element);
8586 CopyClassicElementPropertiesToGame(element);
8590 static void CheckElementDescriptions(void)
8594 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8595 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
8596 Warn("no element description file for element '%s'", EL_NAME(i));
8600 static int getMaxEdFieldX(boolean has_scrollbar)
8602 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
8603 int sxsize = SXSIZE - scrollbar_width;
8604 int max_ed_fieldx = sxsize / ed_tilesize;
8606 return max_ed_fieldx;
8609 static int getMaxEdFieldY(boolean has_scrollbar)
8611 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
8612 INFOTEXT_YSIZE_FULL : 0);
8613 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
8614 int sysize = SYSIZE - scrollbar_height - infotext_height;
8615 int max_ed_fieldy = sysize / ed_tilesize;
8617 return max_ed_fieldy;
8620 static void InitZoomLevelSettings(int zoom_tilesize)
8622 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
8624 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
8626 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
8627 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
8629 // make sure that tile size is always a power of 2
8630 ed_tilesize = (1 << log_2(ed_tilesize));
8632 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8634 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
8635 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
8639 last_game_engine_type = level.game_engine_type;
8641 // limit zoom tilesize by upper and lower bound
8642 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
8644 // store zoom tilesize in auto setup file only if it was manually changed
8645 if (zoom_tilesize != -1)
8646 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
8648 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
8649 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
8652 static void InitDrawingElements(void)
8654 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
8656 if (level.game_engine_type == game_engine_type_last)
8659 if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
8661 new_element1 = EL_SP_CHIP_SINGLE;
8662 new_element2 = EL_EMPTY;
8663 new_element3 = EL_SP_BASE;
8665 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8667 new_element1 = EL_MM_MIRROR_START;
8668 new_element2 = EL_EMPTY;
8669 new_element3 = EL_MM_WOODEN_WALL;
8673 new_element1 = EL_WALL;
8674 new_element2 = EL_EMPTY;
8675 new_element3 = EL_SAND;
8678 game_engine_type_last = level.game_engine_type;
8681 static void InitLevelSetInfo(void)
8683 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
8684 "%s", leveldir_current->name);
8685 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
8686 "%s", leveldir_current->author);
8688 levelset_num_levels = leveldir_current->levels;
8690 levelset_use_levelset_artwork = FALSE;
8691 levelset_copy_level_template = FALSE;
8693 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
8696 static void ChangeEditorToLevelSet(char *levelset_subdir)
8698 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
8700 // the previous level set might have used custom artwork
8701 ReloadCustomArtwork(0);
8703 LoadLevelSetup_SeriesInfo();
8705 SaveLevelSetup_LastSeries();
8706 SaveLevelSetup_SeriesInfo();
8710 LoadLevel(level_nr);
8711 LoadScore(level_nr);
8716 static boolean useEditorDoorAnimation(void)
8718 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
8719 boolean door_1_viewport_unchanged =
8720 (vp_door_1->x == DX &&
8721 vp_door_1->y == DY &&
8722 vp_door_1->width == DXSIZE &&
8723 vp_door_1->height == DYSIZE);
8724 boolean door_1_contains_toolbox =
8727 EX + EXSIZE <= DX + DXSIZE &&
8728 EY + EYSIZE <= DY + DYSIZE);
8730 return (door_1_viewport_unchanged && door_1_contains_toolbox);
8733 static void DrawEditorDoorBackground(int graphic, int x, int y,
8734 int width, int height)
8736 struct GraphicInfo *g = &graphic_info[graphic];
8738 if (g->bitmap != NULL)
8739 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
8740 MIN(width, g->width), MIN(height, g->height), x, y);
8742 ClearRectangle(drawto, x, y, width, height);
8745 static void DrawEditorDoorContent(void)
8747 // needed for gadgets drawn on background (like palette scrollbar)
8748 SetDoorBackgroundImage(IMG_UNDEFINED);
8750 // copy default editor door content to main double buffer
8751 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
8754 DrawSpecialEditorDoor();
8756 // draw new control window
8757 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
8759 // draw all toolbox gadgets to editor doors
8760 MapControlButtons();
8762 // draw all palette gadgets to editor doors
8763 ModifyEditorElementList();
8764 RedrawDrawingElements();
8766 // copy actual editor door content to door double buffer for OpenDoor()
8767 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
8770 void DrawLevelEd(void)
8772 int fade_mask = REDRAW_FIELD;
8774 FadeSoundsAndMusic();
8777 fade_mask = REDRAW_ALL;
8781 // needed if different viewport properties defined for editor
8782 ChangeViewportPropertiesIfNeeded();
8786 InitZoomLevelSettings(-1);
8787 InitDrawingElements();
8791 CheckElementDescriptions();
8794 if (level_editor_test_game)
8796 CopyPlayfield(level.field, Tile);
8797 CopyPlayfield(TileBackup, level.field);
8799 level_editor_test_game = FALSE;
8803 edit_mode = ED_MODE_DRAWING;
8804 edit_mode_levelinfo = ED_MODE_LEVELINFO_LEVEL;
8805 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
8813 // redraw_mask |= REDRAW_ALL;
8815 FreeLevelEditorGadgets();
8816 CreateLevelEditorGadgets();
8818 ReinitializeElementList(); // update dynamic level element list
8819 ReinitializeElementListButtons(); // custom element may look different
8821 InitElementPropertiesGfxElement();
8825 DrawEditModeWindow_PlayfieldOnly();
8827 DrawMaskedBorder(fade_mask);
8829 // use door animation if door 1 viewport is unchanged and contains toolbox
8830 if (useEditorDoorAnimation())
8834 DrawEditorDoorContent();
8836 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
8840 DrawEditorDoorContent();
8845 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
8848 static void AdjustDrawingAreaGadgets(void)
8850 int ed_xsize = lev_fieldx + 2;
8851 int ed_ysize = lev_fieldy + 2;
8852 int max_ed_fieldx = MAX_ED_FIELDX;
8853 int max_ed_fieldy = MAX_ED_FIELDY;
8854 boolean horizontal_scrollbar_needed;
8855 boolean vertical_scrollbar_needed;
8856 int x, y, width, height;
8858 if (suppressBorderElement())
8860 ed_xsize = max_ed_fieldx;
8861 ed_ysize = max_ed_fieldy;
8864 // check if we need any scrollbars
8865 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8866 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8868 // check if we have a smaller editor field because of scrollbars
8869 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8870 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8872 // check again if we now need more scrollbars because of less space
8873 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8874 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8876 // check if editor field gets even smaller after adding new scrollbars
8877 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8878 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8880 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
8881 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
8883 x = SX + ed_fieldx * ed_tilesize;
8884 y = SY + ed_fieldy * ed_tilesize;
8886 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
8887 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
8889 // adjust drawing area gadget
8890 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
8891 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
8892 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
8895 // adjust horizontal scrollbar gadgets
8896 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
8899 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
8900 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
8903 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8906 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
8909 // adjust vertical scrollbar gadgets
8910 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
8913 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
8915 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
8917 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8920 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
8924 static void AdjustLevelScrollPosition(void)
8926 if (level_xpos < -1)
8928 if (level_xpos > lev_fieldx - ed_fieldx + 1)
8929 level_xpos = lev_fieldx - ed_fieldx + 1;
8930 if (lev_fieldx < ed_fieldx - 2)
8933 if (level_ypos < -1)
8935 if (level_ypos > lev_fieldy - ed_fieldy + 1)
8936 level_ypos = lev_fieldy - ed_fieldy + 1;
8937 if (lev_fieldy < ed_fieldy - 2)
8940 if (suppressBorderElement())
8947 static void AdjustEditorScrollbar(int id)
8949 struct GadgetInfo *gi = level_editor_gadget[id];
8950 int items_max, items_visible, item_position;
8952 if (id == GADGET_ID_SCROLL_HORIZONTAL)
8954 items_max = MAX(lev_fieldx + 2, ed_fieldx);
8955 items_visible = ed_fieldx;
8956 item_position = level_xpos + 1;
8960 items_max = MAX(lev_fieldy + 2, ed_fieldy);
8961 items_visible = ed_fieldy;
8962 item_position = level_ypos + 1;
8965 if (item_position > items_max - items_visible)
8966 item_position = items_max - items_visible;
8968 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8969 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8972 static void AdjustElementListScrollbar(void)
8974 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
8975 int items_max, items_visible, item_position;
8977 // correct position of element list scrollbar
8978 if (element_shift < 0)
8980 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
8981 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
8983 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
8984 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
8985 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
8987 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8988 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
8989 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8992 static void ModifyEditorCounterValue(int counter_id, int new_value)
8994 int *counter_value = counterbutton_info[counter_id].value;
8995 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8996 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8998 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9000 if (counter_value != NULL)
9001 *counter_value = gi->textinput.number_value;
9004 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9006 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9007 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9009 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9011 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9012 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9014 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9015 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9017 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9018 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9023 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9025 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9026 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9027 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9029 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9032 static void ModifyEditorSelectboxOptions(int selectbox_id,
9033 struct ValueTextInfo *options)
9035 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9036 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9038 selectbox_info[selectbox_id].options = options;
9040 // set index to zero -- list may be shorter now (correct later, if needed)
9041 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9042 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9045 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9047 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9048 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9050 drawingarea_info[drawingarea_id].area_xsize = xsize;
9051 drawingarea_info[drawingarea_id].area_ysize = ysize;
9053 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9056 static void ModifyEditorElementList(void)
9060 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9063 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9065 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9066 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9067 struct GadgetDesign *gd = &gi->deco.design;
9068 int element = editor_elements[element_shift + i];
9069 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9073 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9075 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9081 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9083 int graphic = el2edimg(element);
9084 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9090 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9093 static void ModifyDrawingElementButton(int element, int id)
9095 struct GadgetInfo *gi = level_editor_gadget[id];
9096 Bitmap *deco_bitmap;
9098 int tile_size = gi->deco.width;
9100 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9102 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9105 static void PickDrawingElement(int button, int element)
9110 struct XYTileSize *pos;
9112 } de, drawing_elements[] =
9114 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9115 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9116 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9119 if (button < 1 || button > 3)
9122 if (IS_MM_WALL(element))
9123 element = map_mm_wall_element(element);
9125 de = drawing_elements[button - 1];
9127 *de.new_element = element; // update global drawing element variable
9129 DrawDrawingElementGraphic(element, de.pos);
9130 ModifyDrawingElementButton(element, de.id);
9132 redraw_mask |= REDRAW_DOOR_1;
9135 static void RedrawDrawingElements(void)
9137 PickDrawingElement(1, new_element1);
9138 PickDrawingElement(2, new_element2);
9139 PickDrawingElement(3, new_element3);
9142 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9144 stick_element_properties_window = FALSE;
9146 SetMainBackgroundImage(IMG_UNDEFINED);
9149 UnmapLevelEditorFieldGadgets();
9151 AdjustDrawingAreaGadgets();
9152 AdjustLevelScrollPosition();
9153 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9154 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9156 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9158 MapMainDrawingArea();
9160 if (remap_toolbox_gadgets)
9162 UnmapLevelEditorToolboxCustomGadgets();
9163 MapLevelEditorToolboxDrawingGadgets();
9167 static void DrawDrawingWindow(void)
9169 DrawDrawingWindowExt(TRUE);
9172 static int getTabulatorBarWidth(void)
9174 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9175 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9177 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9180 static int getTabulatorBarHeight(void)
9182 return ED_TAB_BAR_HEIGHT;
9185 static Pixel getTabulatorBarColor(void)
9187 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
9188 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9189 int gd_x = gd->x + gd_gi1->border.width / 2;
9190 int gd_y = gd->y + gd_gi1->height - 1;
9192 return GetPixel(gd->bitmap, gd_x, gd_y);
9195 static void DrawLevelInfoTabulatorGadgets(void)
9197 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
9198 Pixel tab_color = getTabulatorBarColor();
9199 int id_first = ED_TAB_BUTTON_ID_LEVELINFO_FIRST;
9200 int id_last = ED_TAB_BUTTON_ID_LEVELINFO_LAST;
9203 for (i = id_first; i <= id_last; i++)
9205 int gadget_id = textbutton_info[i].gadget_id;
9206 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9207 boolean active = (i != edit_mode_levelinfo);
9209 // draw background line below tabulator button
9210 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9212 // draw solid line below inactive tabulator buttons
9213 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9214 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9215 ED_GADGET_TINY_DISTANCE, tab_color);
9217 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9218 MapTextbuttonGadget(i);
9221 // draw little border line below tabulator buttons
9222 if (tab_color != BLACK_PIXEL) // black => transparent
9223 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9224 ED_GADGET_TINY_DISTANCE,
9225 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9228 static void DrawPropertiesTabulatorGadgets(void)
9230 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9231 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9232 int gd_x = gd->x + gd_gi1->border.width / 2;
9233 int gd_y = gd->y + gd_gi1->height - 1;
9234 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9235 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9236 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9239 // draw two config tabulators for player elements
9240 if (IS_PLAYER_ELEMENT(properties_element))
9241 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9243 // draw two config and one "change" tabulator for custom elements
9244 if (IS_CUSTOM_ELEMENT(properties_element))
9245 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9247 for (i = id_first; i <= id_last; i++)
9249 int gadget_id = textbutton_info[i].gadget_id;
9250 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9251 boolean active = (i != edit_mode_properties);
9253 // use "config 1" and "config 2" instead of "config" for players and CEs
9254 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9255 (IS_PLAYER_ELEMENT(properties_element) ||
9256 IS_CUSTOM_ELEMENT(properties_element)))
9259 // draw background line below tabulator button
9260 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9262 // draw solid line below inactive tabulator buttons
9263 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9264 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9265 ED_GADGET_TINY_DISTANCE, tab_color);
9267 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9268 MapTextbuttonGadget(i);
9271 // draw little border line below tabulator buttons
9272 if (tab_color != BLACK_PIXEL) // black => transparent
9273 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9274 ED_GADGET_TINY_DISTANCE,
9275 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9278 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9280 DrawText(SX + xpos, SY + ypos, text, font_nr);
9283 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9286 int font_width = getFontWidth(font_nr);
9287 int font_height = getFontHeight(font_nr);
9288 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9289 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9291 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9292 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9293 TRUE, FALSE, FALSE);
9296 static void DrawLevelInfoLevel(void)
9300 // draw counter gadgets
9301 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9302 MapCounterButtons(i);
9304 // draw checkbutton gadgets
9305 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9306 MapCheckbuttonGadget(i);
9308 // draw selectbox gadgets
9309 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9310 MapSelectboxGadget(i);
9312 // draw text input gadgets
9313 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9314 MapTextInputGadget(i);
9317 static char *getLevelSubdirFromSaveMode(int save_mode)
9319 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9320 return getNewUserLevelSubdir();
9322 return leveldir_current->subdir;
9325 static void DrawLevelInfoLevelSet_DirectoryInfo(void)
9327 char *directory_text = "Level set directory:";
9328 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9329 int font1_nr = FONT_TEXT_1;
9330 int font2_nr = FONT_TEXT_2;
9331 int font1_height = getFontHeight(font1_nr);
9332 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
9333 int x = ED_LEVEL_SETTINGS_X(0);
9334 int y = ED_LEVEL_SETTINGS_Y(6);
9336 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
9337 PrintInfoText(directory_name, font2_nr, x, y);
9340 static void DrawLevelInfoLevelSet(void)
9342 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
9343 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
9346 // draw counter gadgets
9347 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
9348 MapCounterButtons(i);
9350 // draw checkbutton gadgets
9351 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
9353 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
9354 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
9355 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
9358 MapCheckbuttonGadget(i);
9361 // draw selectbox gadgets
9362 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
9363 MapSelectboxGadget(i);
9365 // draw text input gadgets
9366 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
9367 MapTextInputGadget(i);
9369 // draw textbutton gadgets
9370 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
9373 DrawLevelInfoLevelSet_DirectoryInfo();
9376 static void DrawLevelInfoEditor(void)
9380 // draw counter gadgets
9381 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
9382 MapCounterButtons(i);
9384 // draw checkbutton gadgets
9385 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
9386 MapCheckbuttonGadget(i);
9388 // draw radiobutton gadgets
9389 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
9390 MapRadiobuttonGadget(i);
9392 // draw drawing area
9393 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
9395 // draw textbutton gadgets
9396 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
9399 static void DrawLevelInfoWindow(void)
9401 char *text = "Global Settings";
9402 int font_nr = FONT_TITLE_1;
9403 struct MenuPosInfo *pos = &editor.settings.headline;
9404 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
9405 int sy = SY + pos->y;
9407 stick_element_properties_window = FALSE;
9409 SetAutomaticNumberOfGemsNeeded();
9411 UnmapLevelEditorFieldGadgets();
9413 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9416 DrawText(sx, sy, text, font_nr);
9418 DrawLevelInfoTabulatorGadgets();
9420 if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVEL)
9421 DrawLevelInfoLevel();
9422 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVELSET)
9423 DrawLevelInfoLevelSet();
9424 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_EDITOR)
9425 DrawLevelInfoEditor();
9428 static void DrawCustomContentArea(void)
9430 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
9431 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9432 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
9433 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
9434 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
9435 int xoffset = ED_GADGET_SPACE_DISTANCE;
9437 // add distance for potential left text (without drawing area border)
9438 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
9440 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9442 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
9445 static void DrawCustomChangeContentArea(void)
9447 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
9448 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9449 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
9450 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
9451 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
9452 int xoffset = ED_GADGET_SPACE_DISTANCE;
9454 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9459 static void RemoveElementContentArea(int id, int font_height)
9461 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9463 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
9464 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
9465 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9466 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
9467 ED_GADGET_TEXT_DISTANCE + font_height);
9470 static void DrawYamYamContentAreas(void)
9472 int font_nr = FONT_TEXT_1;
9473 int font_height = getFontHeight(font_nr);
9474 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9475 int yoffset = (tilesize - font_height) / 2;
9476 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
9477 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
9480 // display counter to choose number of element content areas
9481 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
9483 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9485 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
9487 if (i < level.num_yamyam_contents)
9493 UnmapDrawingArea(id);
9495 // delete content areas in case of reducing number of them
9496 RemoveElementContentArea(id, font_height);
9500 DrawText(x, y + 0 * tilesize, "content", font_nr);
9501 DrawText(x, y + 1 * tilesize, "when", font_nr);
9502 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
9505 static void DrawMagicBallContentAreas(void)
9507 int font_nr = FONT_TEXT_1;
9508 int font_height = getFontHeight(font_nr);
9509 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9510 int yoffset = (tilesize - font_height) / 2;
9511 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
9512 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
9515 // display counter to choose number of element content areas
9516 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
9518 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9520 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
9522 if (i < level.num_ball_contents)
9528 UnmapDrawingArea(id);
9530 // delete content areas in case of reducing number of them
9531 RemoveElementContentArea(id, font_height);
9535 DrawText(x, y + 0 * tilesize, "generated", font_nr);
9536 DrawText(x, y + 1 * tilesize, "when", font_nr);
9537 DrawText(x, y + 2 * tilesize, "active", font_nr);
9540 static void DrawAndroidElementArea(void)
9542 int id = ED_DRAWING_ID_ANDROID_CONTENT;
9543 int num_elements = level.num_android_clone_elements;
9544 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9545 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9546 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9547 int xsize = MAX_ANDROID_ELEMENTS;
9550 // display counter to choose number of element areas
9551 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
9553 if (drawingarea_info[id].text_left != NULL)
9554 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9556 UnmapDrawingArea(id);
9558 ModifyEditorDrawingArea(id, num_elements, 1);
9560 // delete content areas in case of reducing number of them
9561 DrawBackground(sx, sy,
9562 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9563 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9568 static void DrawGroupElementArea(void)
9570 int id = ED_DRAWING_ID_GROUP_CONTENT;
9571 int num_elements = group_element_info.num_elements;
9572 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9573 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9574 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9575 int xsize = MAX_ELEMENTS_IN_GROUP;
9578 if (drawingarea_info[id].text_left != NULL)
9579 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9581 UnmapDrawingArea(id);
9583 ModifyEditorDrawingArea(id, num_elements, 1);
9585 // delete content areas in case of reducing number of them
9586 DrawBackground(sx, sy,
9587 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9588 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9593 static void DrawPlayerInitialInventoryArea(int element)
9595 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
9596 int player_nr = GET_PLAYER_NR(element);
9597 int num_elements = level.initial_inventory_size[player_nr];
9598 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9599 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9600 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9601 int xsize = MAX_INITIAL_INVENTORY_SIZE;
9604 // determine horizontal position to the right of specified gadget
9605 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
9606 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
9607 ED_DRAWINGAREA_TEXT_DISTANCE);
9609 // determine horizontal offset for leading text
9610 if (drawingarea_info[id].text_left != NULL)
9611 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9613 UnmapDrawingArea(id);
9615 ModifyEditorDrawingArea(id, num_elements, 1);
9617 // delete content areas in case of reducing number of them
9618 DrawBackground(sx, sy,
9619 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9620 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9625 static void DrawMMBallContentArea(void)
9627 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
9628 int num_elements = level.num_mm_ball_contents;
9629 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9630 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9631 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9632 int xsize = MAX_MM_BALL_CONTENTS;
9635 if (drawingarea_info[id].text_left != NULL)
9636 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9638 UnmapDrawingArea(id);
9640 ModifyEditorDrawingArea(id, num_elements, 1);
9642 // delete content areas in case of reducing number of them
9643 DrawBackground(sx, sy,
9644 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9645 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9650 static void DrawEnvelopeTextArea(int envelope_nr)
9652 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
9653 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
9657 DrawBackground(gi->x, gi->y,
9658 gi->textarea.crop_width, gi->textarea.crop_height);
9660 if (envelope_nr != -1)
9661 textarea_info[id].value = level.envelope[envelope_nr].text;
9663 ModifyGadget(gi, GDI_AREA_SIZE,
9664 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
9665 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
9668 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
9671 static void DrawPropertiesInfo(void)
9680 // configurable properties
9682 { EP_WALKABLE_OVER, "- player can walk over it" },
9683 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
9684 { EP_WALKABLE_UNDER, "- player can walk under it" },
9685 { EP_PASSABLE_OVER, "- player can pass over it" },
9686 { EP_PASSABLE_INSIDE, "- player can pass through it" },
9687 { EP_PASSABLE_UNDER, "- player can pass under it" },
9688 { EP_PROTECTED, "- player is protected by it" },
9690 { EP_DIGGABLE, "- can be digged away" },
9691 { EP_COLLECTIBLE, "- can be collected" },
9692 { EP_DROPPABLE, "- can be dropped after collecting" },
9693 { EP_THROWABLE, "- can be thrown after collecting" },
9694 { EP_PUSHABLE, "- can be pushed" },
9696 { EP_CAN_FALL, "- can fall" },
9697 { EP_CAN_MOVE, "- can move" },
9699 { EP_CAN_SMASH_PLAYER, "- can smash player" },
9701 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
9703 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
9705 { EP_SLIPPERY, "- slippery for falling elements" },
9706 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
9708 { EP_DONT_RUN_INTO, "- deadly when running into" },
9709 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
9710 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
9711 { EP_DONT_TOUCH, "- deadly when touching" },
9713 { EP_INDESTRUCTIBLE, "- indestructible" },
9715 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
9716 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
9717 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
9719 { EP_CAN_CHANGE, "- can change to other element" },
9721 // pre-defined properties
9722 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
9723 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
9724 { EP_SWITCHABLE, "- can be switched" },
9726 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
9731 char *filename = getElementDescriptionFilename(properties_element);
9732 char *percentage_text = "In this level: ";
9733 char *properties_text = "Standard properties: ";
9734 char *description_text = "Description:";
9735 char *no_description_text = "No description available.";
9736 char *none_text = "None";
9738 int num_elements_in_level;
9739 int num_standard_properties = 0;
9740 int font1_nr = FONT_TEXT_1;
9741 int font2_nr = FONT_TEXT_2;
9742 int font1_width = getFontWidth(font1_nr);
9743 int font1_height = getFontHeight(font1_nr);
9744 int font2_height = getFontHeight(font2_nr);
9745 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
9746 int font2_yoffset = (font1_height - font2_height) / 2;
9747 int percentage_text_len = strlen(percentage_text) * font1_width;
9748 int properties_text_len = strlen(properties_text) * font1_width;
9749 int xpos = ED_ELEMENT_SETTINGS_X(0);
9750 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9753 if (setup.editor.show_element_token)
9755 int font3_nr = FONT_TEXT_3;
9756 int font3_height = getFontHeight(font3_nr);
9758 DrawTextF(xpos, ypos, font3_nr,
9759 "[%s]", element_info[properties_element].token_name);
9761 ypos += 2 * font3_height;
9764 // ----- print number of elements / percentage of this element in level
9766 num_elements_in_level = 0;
9767 for (y = 0; y < lev_fieldy; y++)
9768 for (x = 0; x < lev_fieldx; x++)
9769 if (Tile[x][y] == properties_element)
9770 num_elements_in_level++;
9771 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
9773 DrawTextS(xpos, ypos, font1_nr, percentage_text);
9775 if (num_elements_in_level > 0)
9776 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9777 "%d (%.2f %%)", num_elements_in_level, percentage);
9779 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9782 ypos += 2 * MAX(font1_height, font2_height);
9784 // ----- print standard properties of this element
9786 DrawTextS(xpos, ypos, font1_nr, properties_text);
9788 ypos += line1_height;
9790 for (i = 0; properties[i].value != -1; i++)
9792 if (!HAS_PROPERTY(properties_element, properties[i].value))
9795 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
9797 ypos += font2_height;
9799 num_standard_properties++;
9802 if (num_standard_properties == 0)
9804 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
9805 font2_nr, none_text);
9807 ypos -= (line1_height - font1_height);
9810 ypos += MAX(font1_height, font2_height);
9812 // ----- print special description of this element
9814 PrintInfoText(description_text, font1_nr, xpos, ypos);
9816 ypos += line1_height;
9818 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
9819 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
9822 #define TEXT_COLLECTING "Score for collecting"
9823 #define TEXT_SMASHING "Score for smashing"
9824 #define TEXT_SLURPING "Score for slurping robot"
9825 #define TEXT_CRACKING "Score for cracking"
9826 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
9827 #define TEXT_DURATION "Duration when activated"
9828 #define TEXT_DELAY_ON "Delay before activating"
9829 #define TEXT_DELAY_OFF "Delay before deactivating"
9830 #define TEXT_DELAY_EXPLODING "Delay before exploding"
9831 #define TEXT_DELAY_MOVING "Delay before moving"
9832 #define TEXT_BALL_DELAY "Element generation delay"
9833 #define TEXT_MOVE_SPEED "Speed of android moving"
9834 #define TEXT_CLONE_SPEED "Speed of android cloning"
9835 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
9836 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
9837 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
9838 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
9839 #define TEXT_TIME_BONUS "Extra time to solve level"
9846 } elements_with_counter[] =
9848 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
9849 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
9850 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
9851 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
9852 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9853 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
9854 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
9855 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
9856 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
9857 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
9858 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
9859 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
9860 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9861 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9862 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
9863 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
9864 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
9865 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9866 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9867 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
9868 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9869 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9870 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9871 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9872 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9873 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9874 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
9875 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9876 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9877 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9878 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9879 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9880 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9881 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9882 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
9883 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
9884 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9885 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
9886 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9887 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9888 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9889 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9890 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9891 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
9892 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9893 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9894 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
9895 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9896 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9897 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
9898 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
9899 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
9900 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9901 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9902 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9903 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9904 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9905 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9906 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9907 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9908 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
9909 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
9910 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
9911 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
9912 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
9913 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9914 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
9915 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
9916 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
9917 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9918 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9919 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9920 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9921 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9922 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9923 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9924 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9925 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9926 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9927 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9928 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9929 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9930 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
9932 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
9933 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
9934 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
9935 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
9936 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
9937 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
9938 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
9939 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
9940 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
9941 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
9942 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
9943 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
9944 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
9945 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
9946 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
9947 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
9949 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
9950 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
9951 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
9952 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
9953 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
9954 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
9955 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
9956 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
9957 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
9958 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
9959 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
9960 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
9961 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_ON },
9962 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9963 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9968 static boolean checkPropertiesConfig(int element)
9972 if (IS_GEM(element) ||
9973 IS_CUSTOM_ELEMENT(element) ||
9974 IS_GROUP_ELEMENT(element) ||
9975 IS_EMPTY_ELEMENT(element) ||
9976 IS_BALLOON_ELEMENT(element) ||
9977 IS_ENVELOPE(element) ||
9978 IS_MM_ENVELOPE(element) ||
9979 IS_MM_MCDUFFIN(element) ||
9980 IS_DF_LASER(element) ||
9981 IS_PLAYER_ELEMENT(element) ||
9982 HAS_EDITOR_CONTENT(element) ||
9983 CAN_GROW(element) ||
9984 COULD_MOVE_INTO_ACID(element) ||
9985 MAYBE_DONT_COLLIDE_WITH(element) ||
9986 element == EL_SOKOBAN_OBJECT ||
9987 element == EL_SOKOBAN_FIELD_EMPTY ||
9988 element == EL_SOKOBAN_FIELD_FULL)
9991 for (i = 0; elements_with_counter[i].element != -1; i++)
9992 if (elements_with_counter[i].element == element)
9998 static void SetAutomaticNumberOfGemsNeeded(void)
10002 if (!level.auto_count_gems)
10005 level.gems_needed = 0;
10007 for (x = 0; x < lev_fieldx; x++)
10009 for (y = 0; y < lev_fieldy; y++)
10011 int element = Tile[x][y];
10016 case EL_EMERALD_YELLOW:
10017 case EL_EMERALD_RED:
10018 case EL_EMERALD_PURPLE:
10019 case EL_BD_DIAMOND:
10020 case EL_WALL_EMERALD:
10021 case EL_WALL_EMERALD_YELLOW:
10022 case EL_WALL_EMERALD_RED:
10023 case EL_WALL_EMERALD_PURPLE:
10024 case EL_WALL_BD_DIAMOND:
10026 case EL_SP_INFOTRON:
10029 level.gems_needed++;
10033 case EL_WALL_DIAMOND:
10034 level.gems_needed += 3;
10038 case EL_WALL_PEARL:
10039 level.gems_needed += 5;
10043 case EL_WALL_CRYSTAL:
10044 level.gems_needed += 8;
10053 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10056 static void DrawPropertiesConfig(void)
10058 boolean draw_footer_line = FALSE;
10059 int max_num_element_counters = 4;
10060 int num_element_counters = 0;
10063 if (!checkPropertiesConfig(properties_element))
10065 int xpos = ED_ELEMENT_SETTINGS_X(0);
10066 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10068 PrintInfoText("No configuration options available.",
10069 FONT_TEXT_1, xpos, ypos);
10074 // check if there are elements where a value can be chosen for
10075 for (i = 0; elements_with_counter[i].element != -1; i++)
10077 if (elements_with_counter[i].element == properties_element)
10079 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10081 counterbutton_info[counter_id].y =
10082 ED_ELEMENT_SETTINGS_YPOS(
10083 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10084 (CAN_GROW(properties_element) ? 1 : 0) +
10085 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10086 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10087 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10088 num_element_counters);
10090 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10091 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
10093 if (properties_element == EL_GAME_OF_LIFE ||
10094 properties_element == EL_BIOMAZE)
10096 counterbutton_info[counter_id].min_value = 0; // min neighbours
10097 counterbutton_info[counter_id].max_value = 8; // max neighbours
10101 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10102 counterbutton_info[counter_id].min_value = MIN_SCORE;
10103 counterbutton_info[counter_id].max_value = MAX_SCORE;
10106 MapCounterButtons(counter_id);
10108 num_element_counters++;
10109 if (num_element_counters >= max_num_element_counters)
10114 if (HAS_EDITOR_CONTENT(properties_element))
10116 // draw stickybutton gadget
10117 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10119 if (IS_AMOEBOID(properties_element))
10120 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10121 else if (properties_element == EL_YAMYAM ||
10122 properties_element == EL_YAMYAM_LEFT ||
10123 properties_element == EL_YAMYAM_RIGHT ||
10124 properties_element == EL_YAMYAM_UP ||
10125 properties_element == EL_YAMYAM_DOWN)
10126 DrawYamYamContentAreas();
10127 else if (properties_element == EL_EMC_MAGIC_BALL)
10129 DrawMagicBallContentAreas();
10131 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10132 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10134 else if (properties_element == EL_EMC_ANDROID)
10135 DrawAndroidElementArea();
10136 else if (properties_element == EL_MM_GRAY_BALL)
10138 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
10139 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
10141 DrawMMBallContentArea();
10145 if (IS_PLAYER_ELEMENT(properties_element))
10147 int player_nr = GET_PLAYER_NR(properties_element);
10149 // these properties can be set for every player individually
10151 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10153 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
10154 &level.start_element[player_nr];
10155 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
10156 &level.artwork_element[player_nr];
10157 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
10158 &level.explosion_element[player_nr];
10160 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10161 &level.use_start_element[player_nr];
10162 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10163 &level.use_artwork_element[player_nr];
10164 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10165 &level.use_explosion_element[player_nr];
10166 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10167 &level.initial_player_gravity[player_nr];
10169 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10170 &level.initial_player_stepsize[player_nr];
10172 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
10173 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
10174 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
10175 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
10176 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
10177 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
10178 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
10179 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
10180 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
10181 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
10182 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
10183 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
10184 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
10185 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
10186 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
10188 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
10189 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
10190 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
10192 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
10194 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10196 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
10197 &level.initial_inventory_content[player_nr][0];
10199 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
10200 &level.initial_inventory_size[player_nr];
10202 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
10203 &level.use_initial_inventory[player_nr];
10205 // draw checkbutton gadgets
10206 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
10207 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
10208 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
10210 // draw counter gadgets
10211 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
10213 // draw drawing area gadgets
10214 DrawPlayerInitialInventoryArea(properties_element);
10218 if (IS_GEM(properties_element))
10219 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
10221 if (properties_element == EL_EM_DYNAMITE)
10222 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
10224 if (COULD_MOVE_INTO_ACID(properties_element) &&
10225 !IS_PLAYER_ELEMENT(properties_element) &&
10226 (!IS_CUSTOM_ELEMENT(properties_element) ||
10227 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
10229 // set position for checkbutton for "can move into acid"
10230 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
10231 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
10232 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
10233 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
10234 IS_BALLOON_ELEMENT(properties_element) ||
10235 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10237 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
10240 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
10241 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
10243 if (properties_element == EL_SPRING ||
10244 properties_element == EL_SPRING_LEFT ||
10245 properties_element == EL_SPRING_RIGHT)
10246 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
10248 if (properties_element == EL_TIME_ORB_FULL)
10249 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
10251 if (properties_element == EL_GAME_OF_LIFE ||
10252 properties_element == EL_BIOMAZE)
10253 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
10255 if (CAN_GROW(properties_element))
10257 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
10258 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10260 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
10263 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
10264 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
10266 if (properties_element == EL_SOKOBAN_OBJECT)
10267 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
10269 if (properties_element == EL_SOKOBAN_OBJECT ||
10270 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
10271 properties_element == EL_SOKOBAN_FIELD_FULL)
10273 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
10274 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
10277 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
10280 if (IS_BALLOON_ELEMENT(properties_element))
10281 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
10283 if (IS_ENVELOPE(properties_element) ||
10284 IS_MM_ENVELOPE(properties_element))
10286 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
10287 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
10288 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
10289 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
10290 int envelope_nr = ENVELOPE_NR(properties_element);
10292 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
10293 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
10295 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
10296 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
10298 // display counter to choose size of envelope text area
10299 MapCounterButtons(counter1_id);
10300 MapCounterButtons(counter2_id);
10302 // display checkbuttons to choose auto-wrap and alignment properties
10303 MapCheckbuttonGadget(button1_id);
10304 MapCheckbuttonGadget(button2_id);
10306 DrawEnvelopeTextArea(envelope_nr);
10309 if (IS_MM_MCDUFFIN(properties_element))
10311 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
10312 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
10313 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
10316 if (IS_DF_LASER(properties_element))
10318 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
10319 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
10320 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
10323 if (IS_CUSTOM_ELEMENT(properties_element))
10325 // draw stickybutton gadget
10326 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10328 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10330 // draw checkbutton gadgets
10331 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
10332 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
10333 MapCheckbuttonGadget(i);
10335 // draw counter gadgets
10336 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
10337 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
10338 MapCounterButtons(i);
10340 // draw selectbox gadgets
10341 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
10342 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
10343 MapSelectboxGadget(i);
10345 // draw textbutton gadgets
10346 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10348 // draw text input gadgets
10349 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10351 // draw drawing area gadgets
10352 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10354 draw_footer_line = TRUE;
10356 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10358 // draw checkbutton gadgets
10359 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
10360 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
10361 MapCheckbuttonGadget(i);
10363 // draw counter gadgets
10364 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
10365 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
10366 MapCounterButtons(i);
10368 // draw selectbox gadgets
10369 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
10370 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
10371 MapSelectboxGadget(i);
10373 // draw drawing area gadgets
10374 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
10375 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
10376 DrawCustomContentArea();
10379 else if (IS_GROUP_ELEMENT(properties_element))
10381 // draw stickybutton gadget
10382 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10384 // draw checkbutton gadgets
10385 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10386 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10388 // draw counter gadgets
10389 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
10391 // draw selectbox gadgets
10392 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
10394 // draw textbutton gadgets
10395 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10397 // draw drawing area gadgets
10398 DrawGroupElementArea();
10400 // draw text input gadgets
10401 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10403 // draw drawing area gadgets
10404 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10406 draw_footer_line = TRUE;
10408 else if (IS_EMPTY_ELEMENT(properties_element))
10410 // draw stickybutton gadget
10411 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10413 // draw checkbutton gadgets
10414 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10415 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10417 // draw textbutton gadgets
10418 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10420 // draw drawing area gadgets
10421 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10423 draw_footer_line = TRUE;
10426 // draw little footer border line above CE/GE use/save template gadgets
10427 if (draw_footer_line)
10429 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
10430 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
10431 int gd_x = gd->x + gd_gi1->border.width / 2;
10432 int gd_y = gd->y + gd_gi1->height - 1;
10433 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
10435 if (tab_color != BLACK_PIXEL) // black => transparent
10436 FillRectangle(drawto,
10437 SX + ED_ELEMENT_SETTINGS_X(0),
10438 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
10440 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10444 static void DrawPropertiesChangeDrawingAreas(void)
10446 if (IS_CUSTOM_ELEMENT(properties_element))
10448 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
10449 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
10450 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
10452 DrawCustomChangeContentArea();
10455 redraw_mask |= REDRAW_FIELD;
10458 static void DrawPropertiesChange(void)
10462 // needed to initially set selectbox options for special action options
10463 setSelectboxSpecialActionOptions();
10465 // draw stickybutton gadget
10466 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10468 // draw checkbutton gadgets
10469 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
10470 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
10471 MapCheckbuttonGadget(i);
10473 // draw counter gadgets
10474 for (i = ED_COUNTER_ID_CHANGE_FIRST;
10475 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
10476 MapCounterButtons(i);
10478 // draw selectbox gadgets
10479 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
10480 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
10481 MapSelectboxGadget(i);
10483 // draw textbutton gadgets
10484 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
10485 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
10486 MapTextbuttonGadget(i);
10488 // draw graphicbutton gadgets
10489 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
10490 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
10491 MapGraphicbuttonGadget(i);
10493 // draw drawing area gadgets
10494 DrawPropertiesChangeDrawingAreas();
10497 static void DrawEditorElementAnimation(int x, int y)
10499 int graphic = el2img(properties_element);
10500 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
10501 custom_element.ce_value_fixed_initial :
10502 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
10503 custom_element.collect_score_initial : FrameCounter);
10505 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
10508 static void DrawEditorElementName(int x, int y, int font_nr)
10510 char *element_name = getElementInfoText(properties_element);
10511 int font_width = getFontWidth(font_nr);
10512 int font_height = getFontHeight(font_nr);
10513 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
10514 int max_chars_per_line = max_text_width / font_width;
10516 if (strlen(element_name) <= max_chars_per_line)
10517 DrawTextS(x, y, font_nr, element_name);
10520 char buffer[max_chars_per_line + 1];
10521 int next_pos = max_chars_per_line;
10523 strncpy(buffer, element_name, max_chars_per_line);
10524 buffer[max_chars_per_line] = '\0';
10526 if (element_name[max_chars_per_line] == ' ')
10532 for (i = max_chars_per_line - 1; i >= 0; i--)
10533 if (buffer[i] == ' ')
10536 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
10543 DrawTextS(x, y - font_height / 2, font_nr, buffer);
10545 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
10546 buffer[max_chars_per_line] = '\0';
10548 DrawTextS(x, y + font_height / 2, font_nr, buffer);
10552 static void DrawPropertiesWindow(void)
10554 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
10555 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
10556 int border_size = gd->border_size;
10557 int font_nr = FONT_TEXT_1;
10558 int font_height = getFontHeight(font_nr);
10559 int xoffset = TILEX + element_border + 3 * border_size;
10560 int yoffset = (TILEY - font_height) / 2;
10561 int x1 = editor.settings.element_graphic.x + element_border;
10562 int y1 = editor.settings.element_graphic.y + element_border;
10563 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
10564 editor.settings.element_name.x);
10565 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
10566 editor.settings.element_name.y);
10567 char *text = "Element Settings";
10568 int font2_nr = FONT_TITLE_1;
10569 struct MenuPosInfo *pos = &editor.settings.headline;
10570 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
10571 int sy = SY + pos->y;
10573 stick_element_properties_window = FALSE;
10575 // make sure that previous properties edit mode exists for this element
10576 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
10577 !IS_CUSTOM_ELEMENT(properties_element))
10578 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
10580 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
10581 !IS_PLAYER_ELEMENT(properties_element) &&
10582 !IS_CUSTOM_ELEMENT(properties_element))
10583 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
10585 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
10586 (IS_PLAYER_ELEMENT(properties_element) ||
10587 IS_CUSTOM_ELEMENT(properties_element)))
10588 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
10590 CopyElementPropertiesToEditor(properties_element);
10592 UnmapLevelEditorFieldGadgets();
10593 UnmapLevelEditorToolboxDrawingGadgets();
10594 UnmapLevelEditorToolboxCustomGadgets();
10596 if (IS_CUSTOM_ELEMENT(properties_element) ||
10597 IS_GROUP_ELEMENT(properties_element))
10598 MapLevelEditorToolboxCustomGadgets();
10600 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10603 DrawText(sx, sy, text, font2_nr);
10605 FrameCounter = 0; // restart animation frame counter
10607 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
10608 DrawEditorElementAnimation(SX + x1, SY + y1);
10609 DrawEditorElementName(x2, y2, font_nr);
10611 DrawPropertiesTabulatorGadgets();
10613 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
10614 DrawPropertiesInfo();
10615 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
10616 DrawPropertiesChange();
10617 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
10618 DrawPropertiesConfig();
10621 static void DrawPaletteWindow(void)
10625 UnmapLevelEditorFieldGadgets();
10627 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10630 // map buttons to select elements
10631 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
10632 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
10633 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
10634 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
10635 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
10638 static void UpdateCustomElementGraphicGadgets(void)
10642 InitElementPropertiesGfxElement();
10644 ModifyEditorElementList();
10645 RedrawDrawingElements();
10647 // force redraw of all mapped drawing area gadgets
10648 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
10650 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
10657 static int getOpenDirectionFromTube(int element)
10661 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
10662 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
10663 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
10664 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
10665 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
10666 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
10667 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
10668 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
10669 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
10670 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
10671 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
10677 static int getTubeFromOpenDirection(int direction)
10681 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
10682 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
10683 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
10684 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
10685 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
10686 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
10687 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
10688 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
10689 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
10690 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
10691 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
10693 // if only one direction, fall back to simple tube with that direction
10694 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
10695 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
10696 case (MV_UP): return EL_TUBE_VERTICAL;
10697 case (MV_DOWN): return EL_TUBE_VERTICAL;
10703 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
10705 int element_new = getTubeFromOpenDirection(direction);
10707 return (element_new != EL_EMPTY ? element_new : element_old);
10710 static int getOpenDirectionFromBelt(int element)
10712 int belt_dir = getBeltDirFromBeltElement(element);
10714 return (belt_dir == MV_LEFT ? MV_RIGHT :
10715 belt_dir == MV_RIGHT ? MV_LEFT :
10716 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
10719 static int getBeltFromNrAndOpenDirection(int nr, int direction)
10721 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
10722 direction == MV_RIGHT ? MV_LEFT :
10723 direction == MV_HORIZONTAL ? MV_NONE : direction);
10725 if (direction == MV_NONE)
10728 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
10731 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
10734 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
10736 return (element_new != EL_EMPTY ? element_new : element_old);
10739 static int getOpenDirectionFromPool(int element)
10743 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
10744 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
10745 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
10746 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
10747 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
10748 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
10754 static int getPoolFromOpenDirection(int direction)
10758 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
10759 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
10760 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
10761 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
10762 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
10763 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
10769 static int getPoolFromOpenDirectionExt(int direction, int help_element)
10771 int element = getPoolFromOpenDirection(direction);
10772 int help_direction = getOpenDirectionFromPool(help_element);
10774 if (element == EL_EMPTY)
10776 int help_direction_vertical = help_direction & MV_VERTICAL;
10778 element = getPoolFromOpenDirection(direction | help_direction_vertical);
10781 if (element == EL_EMPTY)
10783 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
10785 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
10791 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
10793 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
10795 return (element_new != EL_EMPTY ? element_new : element_old);
10798 static int getOpenDirectionFromPillar(int element)
10802 case EL_EMC_WALL_1: return (MV_DOWN);
10803 case EL_EMC_WALL_2: return (MV_VERTICAL);
10804 case EL_EMC_WALL_3: return (MV_UP);
10810 static int getPillarFromOpenDirection(int direction)
10814 case (MV_DOWN): return EL_EMC_WALL_1;
10815 case (MV_VERTICAL): return EL_EMC_WALL_2;
10816 case (MV_UP): return EL_EMC_WALL_3;
10822 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
10824 int element_new = getPillarFromOpenDirection(direction);
10826 return (element_new != EL_EMPTY ? element_new : element_old);
10829 static int getOpenDirectionFromSteel2(int element)
10833 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
10834 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
10835 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
10836 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
10837 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
10838 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
10839 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
10840 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
10846 static int getSteel2FromOpenDirection(int direction)
10850 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
10851 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
10852 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
10853 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
10854 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
10855 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
10856 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
10857 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
10863 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
10865 int element_new = getSteel2FromOpenDirection(direction);
10867 return (element_new != EL_EMPTY ? element_new : element_old);
10870 static int getOpenDirectionFromChip(int element)
10874 case EL_SP_CHIP_SINGLE: return (MV_NONE);
10875 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
10876 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
10877 case EL_SP_CHIP_TOP: return (MV_DOWN);
10878 case EL_SP_CHIP_BOTTOM: return (MV_UP);
10884 static int getChipFromOpenDirection(int direction)
10888 case (MV_NONE): return EL_SP_CHIP_SINGLE;
10889 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
10890 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
10891 case (MV_UP): return EL_SP_CHIP_BOTTOM;
10892 case (MV_DOWN): return EL_SP_CHIP_TOP;
10898 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
10900 int element_new = getChipFromOpenDirection(direction);
10902 return (element_new != EL_EMPTY ? element_new : element_old);
10905 static int getClosedTube(int x, int y)
10907 struct XY *xy = xy_directions;
10908 int element_old = IntelliDrawBuffer[x][y];
10909 int direction_old = getOpenDirectionFromTube(element_old);
10910 int direction_new = MV_NONE;
10913 for (i = 0; i < NUM_DIRECTIONS; i++)
10915 int xx = x + xy[i].x;
10916 int yy = y + xy[i].y;
10917 int dir = MV_DIR_FROM_BIT(i);
10918 int dir_opposite = MV_DIR_OPPOSITE(dir);
10920 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
10921 (direction_old & dir) &&
10922 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10923 direction_new |= dir;
10926 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
10929 static int getClosedBelt(int x, int y)
10931 struct XY *xy = xy_directions;
10932 int element_old = IntelliDrawBuffer[x][y];
10933 int nr = getBeltNrFromBeltElement(element_old);
10934 int direction_old = getOpenDirectionFromBelt(element_old);
10935 int direction_new = MV_NONE;
10938 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10940 int xx = x + xy[i].x;
10941 int yy = y + xy[i].y;
10942 int dir = MV_DIR_FROM_BIT(i);
10943 int dir_opposite = MV_DIR_OPPOSITE(dir);
10945 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
10946 (direction_old & dir) &&
10947 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10948 direction_new |= dir;
10951 return getBeltFromNrAndOpenDirection(nr, direction_new);
10954 static int getClosedPool(int x, int y)
10956 struct XY *xy = xy_directions;
10957 int element_old = IntelliDrawBuffer[x][y];
10958 int direction_old = getOpenDirectionFromPool(element_old);
10959 int direction_new = MV_NONE;
10962 for (i = 0; i < NUM_DIRECTIONS; i++)
10964 int xx = x + xy[i].x;
10965 int yy = y + xy[i].y;
10966 int dir = MV_DIR_FROM_BIT(i);
10967 int dir_opposite = MV_DIR_OPPOSITE(dir);
10969 if (IN_LEV_FIELD(xx, yy) &&
10970 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
10971 (direction_old & dir) &&
10972 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10973 direction_new |= dir;
10976 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
10979 static int getClosedPillar(int x, int y)
10981 struct XY *xy = xy_directions;
10982 int element_old = IntelliDrawBuffer[x][y];
10983 int direction_old = getOpenDirectionFromPillar(element_old);
10984 int direction_new = MV_NONE;
10987 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
10989 int xx = x + xy[i].x;
10990 int yy = y + xy[i].y;
10991 int dir = MV_DIR_FROM_BIT(i);
10992 int dir_opposite = MV_DIR_OPPOSITE(dir);
10994 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
10995 (direction_old & dir) &&
10996 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10997 direction_new |= dir;
11000 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11003 static int getClosedSteel2(int x, int y)
11005 struct XY *xy = xy_directions;
11006 int element_old = IntelliDrawBuffer[x][y];
11007 int direction_old = getOpenDirectionFromSteel2(element_old);
11008 int direction_new = MV_NONE;
11011 for (i = 0; i < NUM_DIRECTIONS; i++)
11013 int xx = x + xy[i].x;
11014 int yy = y + xy[i].y;
11015 int dir = MV_DIR_FROM_BIT(i);
11016 int dir_opposite = MV_DIR_OPPOSITE(dir);
11018 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11019 (direction_old & dir) &&
11020 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11021 direction_new |= dir;
11024 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11027 static int getClosedChip(int x, int y)
11029 struct XY *xy = xy_directions;
11030 int element_old = IntelliDrawBuffer[x][y];
11031 int direction_old = getOpenDirectionFromChip(element_old);
11032 int direction_new = MV_NONE;
11035 for (i = 0; i < NUM_DIRECTIONS; i++)
11037 int xx = x + xy[i].x;
11038 int yy = y + xy[i].y;
11039 int dir = MV_DIR_FROM_BIT(i);
11040 int dir_opposite = MV_DIR_OPPOSITE(dir);
11042 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11043 (direction_old & dir) &&
11044 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11045 direction_new |= dir;
11048 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11051 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11052 boolean change_level)
11054 int sx = x - level_xpos;
11055 int sy = y - level_ypos;
11056 int old_element = Tile[x][y];
11057 int new_element = element;
11058 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11059 boolean draw_masked = FALSE;
11061 if (IS_MM_WALL_EDITOR(element))
11063 element = map_mm_wall_element_editor(element) | new_bitmask;
11065 if (IS_MM_WALL(old_element))
11066 element |= MM_WALL_BITS(old_element);
11069 draw_masked = TRUE;
11071 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11073 int element_changed = old_element & ~new_bitmask;
11075 if (MM_WALL_BITS(element_changed) != 0)
11076 element = element_changed;
11079 IntelliDrawBuffer[x][y] = element;
11082 Tile[x][y] = element;
11084 if (IN_ED_FIELD(sx, sy))
11086 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11087 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11088 else if (draw_masked)
11089 DrawEditorElementThruMask(sx, sy, element);
11091 DrawEditorElement(sx, sy, element);
11095 static void SetElementSimple(int x, int y, int element, boolean change_level)
11097 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11100 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11101 int x2, int y2, int *element2,
11102 int (*close_function)(int, int),
11103 boolean change_level)
11105 // set neighbour elements to newly determined connections
11106 SetElementSimple(x1, y1, *element1, change_level);
11107 SetElementSimple(x2, y2, *element2, change_level);
11109 // remove all open connections of neighbour elements
11110 *element1 = close_function(x1, y1);
11111 *element2 = close_function(x2, y2);
11113 // set neighbour elements to new, minimized connections
11114 SetElementSimple(x1, y1, *element1, change_level);
11115 SetElementSimple(x2, y2, *element2, change_level);
11118 static void SetElementIntelliDraw(int x, int y, int new_element,
11119 boolean change_level, int button)
11121 struct XY *xy = xy_directions;
11122 static int last_x = -1;
11123 static int last_y = -1;
11125 if (new_element == EL_UNDEFINED)
11133 int old_element = IntelliDrawBuffer[x][y];
11135 if (IS_TUBE(new_element))
11137 int last_element_new = EL_UNDEFINED;
11138 int direction = MV_NONE;
11141 // if old element is of same kind, keep all existing directions
11142 if (IS_TUBE(old_element))
11143 direction |= getOpenDirectionFromTube(old_element);
11145 for (i = 0; i < NUM_DIRECTIONS; i++)
11147 int xx = x + xy[i].x;
11148 int yy = y + xy[i].y;
11150 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11151 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11153 int dir = MV_DIR_FROM_BIT(i);
11154 int dir_opposite = MV_DIR_OPPOSITE(dir);
11155 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11156 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11157 int last_direction_new = last_direction_old | dir_opposite;
11159 last_element_new = getTubeFromOpenDirection(last_direction_new);
11165 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
11167 if (last_element_new != EL_UNDEFINED)
11168 MergeAndCloseNeighbourElements(x, y, &new_element,
11169 last_x, last_y, &last_element_new,
11170 getClosedTube, change_level);
11172 else if (IS_BELT(new_element))
11174 int belt_nr = getBeltNrFromBeltElement(new_element);
11175 int last_element_new = EL_UNDEFINED;
11176 int direction = MV_NONE;
11179 // if old element is of same kind, keep all existing directions
11180 if (IS_BELT(old_element))
11181 direction |= getOpenDirectionFromBelt(old_element);
11183 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11185 int xx = x + xy[i].x;
11186 int yy = y + xy[i].y;
11188 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11189 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
11191 int dir = MV_DIR_FROM_BIT(i);
11192 int dir_opposite = MV_DIR_OPPOSITE(dir);
11193 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11194 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
11195 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
11196 int last_direction_new = last_direction_old | dir_opposite;
11198 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11199 last_direction_new);
11204 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
11206 if (last_element_new != EL_UNDEFINED)
11207 MergeAndCloseNeighbourElements(x, y, &new_element,
11208 last_x, last_y, &last_element_new,
11209 getClosedBelt, change_level);
11211 else if (IS_ACID_POOL_OR_ACID(new_element))
11213 int last_element_new = EL_UNDEFINED;
11214 int direction = MV_NONE;
11217 // if old element is of same kind, keep all existing directions
11218 if (IS_ACID_POOL_OR_ACID(old_element))
11219 direction |= getOpenDirectionFromPool(old_element);
11221 for (i = 0; i < NUM_DIRECTIONS; i++)
11223 int xx = x + xy[i].x;
11224 int yy = y + xy[i].y;
11226 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11227 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
11229 int dir = MV_DIR_FROM_BIT(i);
11230 int dir_opposite = MV_DIR_OPPOSITE(dir);
11231 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11232 int last_direction_old = getOpenDirectionFromPool(last_element_old);
11233 int last_direction_new = last_direction_old | dir_opposite;
11235 last_element_new = getPoolFromOpenDirection(last_direction_new);
11241 // special corrections needed for intuitively correct acid pool drawing
11242 if (last_element_new == EL_EMPTY)
11243 last_element_new = new_element;
11244 else if (last_element_new != EL_UNDEFINED)
11245 new_element = last_element_new;
11247 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
11249 if (last_element_new != EL_UNDEFINED)
11250 MergeAndCloseNeighbourElements(x, y, &new_element,
11251 last_x, last_y, &last_element_new,
11252 getClosedPool, change_level);
11254 else if (IS_EMC_PILLAR(new_element))
11256 int last_element_new = EL_UNDEFINED;
11257 int direction = MV_NONE;
11260 // if old element is of same kind, keep all existing directions
11261 if (IS_EMC_PILLAR(old_element))
11262 direction |= getOpenDirectionFromPillar(old_element);
11264 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11266 int xx = x + xy[i].x;
11267 int yy = y + xy[i].y;
11269 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11270 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
11272 int dir = MV_DIR_FROM_BIT(i);
11273 int dir_opposite = MV_DIR_OPPOSITE(dir);
11274 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11275 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
11276 int last_direction_new = last_direction_old | dir_opposite;
11278 last_element_new = getPillarFromOpenDirection(last_direction_new);
11284 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
11286 if (last_element_new != EL_UNDEFINED)
11287 MergeAndCloseNeighbourElements(x, y, &new_element,
11288 last_x, last_y, &last_element_new,
11289 getClosedPillar, change_level);
11291 else if (IS_DC_STEELWALL_2(new_element))
11293 int last_element_new = EL_UNDEFINED;
11294 int direction = MV_NONE;
11297 // if old element is of same kind, keep all existing directions
11298 if (IS_DC_STEELWALL_2(old_element))
11299 direction |= getOpenDirectionFromSteel2(old_element);
11301 for (i = 0; i < NUM_DIRECTIONS; i++)
11303 int xx = x + xy[i].x;
11304 int yy = y + xy[i].y;
11306 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11307 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
11309 int dir = MV_DIR_FROM_BIT(i);
11310 int dir_opposite = MV_DIR_OPPOSITE(dir);
11311 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11312 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
11313 int last_direction_new = last_direction_old | dir_opposite;
11315 last_element_new = getSteel2FromOpenDirection(last_direction_new);
11321 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
11323 if (last_element_new != EL_UNDEFINED)
11324 MergeAndCloseNeighbourElements(x, y, &new_element,
11325 last_x, last_y, &last_element_new,
11326 getClosedSteel2, change_level);
11328 else if (IS_SP_CHIP(new_element))
11330 int last_element_new = EL_UNDEFINED;
11331 int direction = MV_NONE;
11334 // (do not keep existing directions, regardless of kind of old element)
11336 for (i = 0; i < NUM_DIRECTIONS; i++)
11338 int xx = x + xy[i].x;
11339 int yy = y + xy[i].y;
11341 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11342 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
11344 int dir = MV_DIR_FROM_BIT(i);
11345 int dir_opposite = MV_DIR_OPPOSITE(dir);
11346 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11347 int last_direction_old = getOpenDirectionFromChip(last_element_old);
11348 int last_direction_new = last_direction_old | dir_opposite;
11350 if (last_direction_old == MV_NONE)
11352 last_element_new = getChipFromOpenDirection(last_direction_new);
11355 else if (last_direction_old & (dir | dir_opposite))
11357 direction |= MV_DIR_OPPOSITE(last_direction_old);
11361 direction |= MV_DIR_OPPOSITE(dir);
11366 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
11368 if (last_element_new != EL_UNDEFINED)
11369 MergeAndCloseNeighbourElements(x, y, &new_element,
11370 last_x, last_y, &last_element_new,
11371 getClosedChip, change_level);
11373 else if (IS_SP_HARDWARE_BASE(new_element))
11375 int nr = GetSimpleRandom(6);
11377 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
11378 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
11379 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
11380 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
11381 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
11383 else if (new_element == EL_SP_HARDWARE_GREEN ||
11384 new_element == EL_SP_HARDWARE_BLUE ||
11385 new_element == EL_SP_HARDWARE_RED)
11387 int nr = GetSimpleRandom(3);
11389 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
11390 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
11392 else if (IS_GROUP_ELEMENT(new_element))
11394 boolean connected_drawing = FALSE;
11397 for (i = 0; i < NUM_DIRECTIONS; i++)
11399 int xx = x + xy[i].x;
11400 int yy = y + xy[i].y;
11402 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11403 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
11404 connected_drawing = TRUE;
11407 if (!connected_drawing)
11408 ResolveGroupElement(new_element);
11410 new_element = GetElementFromGroupElement(new_element);
11412 else if (IS_BELT_SWITCH(old_element))
11414 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
11415 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
11417 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
11418 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
11420 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
11424 static int swappable_elements[][2] =
11426 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
11427 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
11428 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
11429 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
11430 { EL_EMERALD, EL_WALL_EMERALD },
11431 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
11432 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
11433 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
11434 { EL_DIAMOND, EL_WALL_DIAMOND },
11435 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
11436 { EL_GATE_1, EL_GATE_1_GRAY },
11437 { EL_GATE_2, EL_GATE_2_GRAY },
11438 { EL_GATE_3, EL_GATE_3_GRAY },
11439 { EL_GATE_4, EL_GATE_4_GRAY },
11440 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
11441 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
11442 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
11443 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
11444 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
11445 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
11446 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
11447 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
11448 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
11449 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
11450 { EL_LAMP, EL_LAMP_ACTIVE },
11451 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
11452 { EL_SP_BASE, EL_SP_BUGGY_BASE },
11453 { EL_PEARL, EL_WALL_PEARL },
11454 { EL_CRYSTAL, EL_WALL_CRYSTAL },
11455 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
11456 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
11457 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
11458 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
11459 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
11460 { EL_LANDMINE, EL_DC_LANDMINE },
11461 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
11462 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
11463 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
11464 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
11465 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
11466 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
11467 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
11468 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
11469 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
11473 static int rotatable_elements_4[][4] =
11483 EL_SPACESHIP_RIGHT,
11488 EL_BD_BUTTERFLY_UP,
11489 EL_BD_BUTTERFLY_RIGHT,
11490 EL_BD_BUTTERFLY_DOWN,
11491 EL_BD_BUTTERFLY_LEFT
11495 EL_BD_FIREFLY_RIGHT,
11496 EL_BD_FIREFLY_DOWN,
11524 EL_SP_GRAVITY_PORT_UP,
11525 EL_SP_GRAVITY_PORT_RIGHT,
11526 EL_SP_GRAVITY_PORT_DOWN,
11527 EL_SP_GRAVITY_PORT_LEFT
11530 EL_SP_GRAVITY_ON_PORT_UP,
11531 EL_SP_GRAVITY_ON_PORT_RIGHT,
11532 EL_SP_GRAVITY_ON_PORT_DOWN,
11533 EL_SP_GRAVITY_ON_PORT_LEFT
11536 EL_SP_GRAVITY_OFF_PORT_UP,
11537 EL_SP_GRAVITY_OFF_PORT_RIGHT,
11538 EL_SP_GRAVITY_OFF_PORT_DOWN,
11539 EL_SP_GRAVITY_OFF_PORT_LEFT
11548 EL_BALLOON_SWITCH_UP,
11549 EL_BALLOON_SWITCH_RIGHT,
11550 EL_BALLOON_SWITCH_DOWN,
11551 EL_BALLOON_SWITCH_LEFT
11555 EL_MM_MCDUFFIN_RIGHT,
11556 EL_MM_MCDUFFIN_DOWN,
11557 EL_MM_MCDUFFIN_LEFT
11560 EL_MM_MIRROR_FIXED_1,
11561 EL_MM_MIRROR_FIXED_4,
11562 EL_MM_MIRROR_FIXED_3,
11563 EL_MM_MIRROR_FIXED_2
11566 EL_MM_STEEL_GRID_FIXED_1,
11567 EL_MM_STEEL_GRID_FIXED_4,
11568 EL_MM_STEEL_GRID_FIXED_2,
11569 EL_MM_STEEL_GRID_FIXED_3
11572 EL_MM_WOODEN_GRID_FIXED_1,
11573 EL_MM_WOODEN_GRID_FIXED_4,
11574 EL_MM_WOODEN_GRID_FIXED_2,
11575 EL_MM_WOODEN_GRID_FIXED_3
11578 EL_MM_POLARIZER_CROSS_1,
11579 EL_MM_POLARIZER_CROSS_4,
11580 EL_MM_POLARIZER_CROSS_3,
11581 EL_MM_POLARIZER_CROSS_2
11585 EL_MM_PACMAN_RIGHT,
11597 EL_DF_RECEIVER_RIGHT,
11598 EL_DF_RECEIVER_DOWN,
11599 EL_DF_RECEIVER_LEFT
11606 static int rotatable_elements_8[][8] =
11609 EL_DF_STEEL_GRID_FIXED_1,
11610 EL_DF_STEEL_GRID_FIXED_8,
11611 EL_DF_STEEL_GRID_FIXED_7,
11612 EL_DF_STEEL_GRID_FIXED_6,
11613 EL_DF_STEEL_GRID_FIXED_5,
11614 EL_DF_STEEL_GRID_FIXED_4,
11615 EL_DF_STEEL_GRID_FIXED_3,
11616 EL_DF_STEEL_GRID_FIXED_2
11619 EL_DF_WOODEN_GRID_FIXED_1,
11620 EL_DF_WOODEN_GRID_FIXED_8,
11621 EL_DF_WOODEN_GRID_FIXED_7,
11622 EL_DF_WOODEN_GRID_FIXED_6,
11623 EL_DF_WOODEN_GRID_FIXED_5,
11624 EL_DF_WOODEN_GRID_FIXED_4,
11625 EL_DF_WOODEN_GRID_FIXED_3,
11626 EL_DF_WOODEN_GRID_FIXED_2
11629 EL_DF_STEEL_GRID_ROTATING_1,
11630 EL_DF_STEEL_GRID_ROTATING_8,
11631 EL_DF_STEEL_GRID_ROTATING_7,
11632 EL_DF_STEEL_GRID_ROTATING_6,
11633 EL_DF_STEEL_GRID_ROTATING_5,
11634 EL_DF_STEEL_GRID_ROTATING_4,
11635 EL_DF_STEEL_GRID_ROTATING_3,
11636 EL_DF_STEEL_GRID_ROTATING_2
11639 EL_DF_WOODEN_GRID_ROTATING_1,
11640 EL_DF_WOODEN_GRID_ROTATING_8,
11641 EL_DF_WOODEN_GRID_ROTATING_7,
11642 EL_DF_WOODEN_GRID_ROTATING_6,
11643 EL_DF_WOODEN_GRID_ROTATING_5,
11644 EL_DF_WOODEN_GRID_ROTATING_4,
11645 EL_DF_WOODEN_GRID_ROTATING_3,
11646 EL_DF_WOODEN_GRID_ROTATING_2
11653 static int rotatable_elements_16[][16] =
11674 EL_MM_TELEPORTER_5,
11675 EL_MM_TELEPORTER_4,
11676 EL_MM_TELEPORTER_3,
11677 EL_MM_TELEPORTER_2,
11678 EL_MM_TELEPORTER_1,
11679 EL_MM_TELEPORTER_16,
11680 EL_MM_TELEPORTER_15,
11681 EL_MM_TELEPORTER_14,
11682 EL_MM_TELEPORTER_13,
11683 EL_MM_TELEPORTER_12,
11684 EL_MM_TELEPORTER_11,
11685 EL_MM_TELEPORTER_10,
11686 EL_MM_TELEPORTER_9,
11687 EL_MM_TELEPORTER_8,
11688 EL_MM_TELEPORTER_7,
11692 EL_MM_TELEPORTER_RED_5,
11693 EL_MM_TELEPORTER_RED_4,
11694 EL_MM_TELEPORTER_RED_3,
11695 EL_MM_TELEPORTER_RED_2,
11696 EL_MM_TELEPORTER_RED_1,
11697 EL_MM_TELEPORTER_RED_16,
11698 EL_MM_TELEPORTER_RED_15,
11699 EL_MM_TELEPORTER_RED_14,
11700 EL_MM_TELEPORTER_RED_13,
11701 EL_MM_TELEPORTER_RED_12,
11702 EL_MM_TELEPORTER_RED_11,
11703 EL_MM_TELEPORTER_RED_10,
11704 EL_MM_TELEPORTER_RED_9,
11705 EL_MM_TELEPORTER_RED_8,
11706 EL_MM_TELEPORTER_RED_7,
11707 EL_MM_TELEPORTER_RED_6
11710 EL_MM_TELEPORTER_YELLOW_5,
11711 EL_MM_TELEPORTER_YELLOW_4,
11712 EL_MM_TELEPORTER_YELLOW_3,
11713 EL_MM_TELEPORTER_YELLOW_2,
11714 EL_MM_TELEPORTER_YELLOW_1,
11715 EL_MM_TELEPORTER_YELLOW_16,
11716 EL_MM_TELEPORTER_YELLOW_15,
11717 EL_MM_TELEPORTER_YELLOW_14,
11718 EL_MM_TELEPORTER_YELLOW_13,
11719 EL_MM_TELEPORTER_YELLOW_12,
11720 EL_MM_TELEPORTER_YELLOW_11,
11721 EL_MM_TELEPORTER_YELLOW_10,
11722 EL_MM_TELEPORTER_YELLOW_9,
11723 EL_MM_TELEPORTER_YELLOW_8,
11724 EL_MM_TELEPORTER_YELLOW_7,
11725 EL_MM_TELEPORTER_YELLOW_6
11728 EL_MM_TELEPORTER_GREEN_5,
11729 EL_MM_TELEPORTER_GREEN_4,
11730 EL_MM_TELEPORTER_GREEN_3,
11731 EL_MM_TELEPORTER_GREEN_2,
11732 EL_MM_TELEPORTER_GREEN_1,
11733 EL_MM_TELEPORTER_GREEN_16,
11734 EL_MM_TELEPORTER_GREEN_15,
11735 EL_MM_TELEPORTER_GREEN_14,
11736 EL_MM_TELEPORTER_GREEN_13,
11737 EL_MM_TELEPORTER_GREEN_12,
11738 EL_MM_TELEPORTER_GREEN_11,
11739 EL_MM_TELEPORTER_GREEN_10,
11740 EL_MM_TELEPORTER_GREEN_9,
11741 EL_MM_TELEPORTER_GREEN_8,
11742 EL_MM_TELEPORTER_GREEN_7,
11743 EL_MM_TELEPORTER_GREEN_6
11746 EL_MM_TELEPORTER_BLUE_5,
11747 EL_MM_TELEPORTER_BLUE_4,
11748 EL_MM_TELEPORTER_BLUE_3,
11749 EL_MM_TELEPORTER_BLUE_2,
11750 EL_MM_TELEPORTER_BLUE_1,
11751 EL_MM_TELEPORTER_BLUE_16,
11752 EL_MM_TELEPORTER_BLUE_15,
11753 EL_MM_TELEPORTER_BLUE_14,
11754 EL_MM_TELEPORTER_BLUE_13,
11755 EL_MM_TELEPORTER_BLUE_12,
11756 EL_MM_TELEPORTER_BLUE_11,
11757 EL_MM_TELEPORTER_BLUE_10,
11758 EL_MM_TELEPORTER_BLUE_9,
11759 EL_MM_TELEPORTER_BLUE_8,
11760 EL_MM_TELEPORTER_BLUE_7,
11761 EL_MM_TELEPORTER_BLUE_6
11765 EL_MM_POLARIZER_16,
11766 EL_MM_POLARIZER_15,
11767 EL_MM_POLARIZER_14,
11768 EL_MM_POLARIZER_13,
11769 EL_MM_POLARIZER_12,
11770 EL_MM_POLARIZER_11,
11771 EL_MM_POLARIZER_10,
11800 EL_DF_MIRROR_ROTATING_1,
11801 EL_DF_MIRROR_ROTATING_16,
11802 EL_DF_MIRROR_ROTATING_15,
11803 EL_DF_MIRROR_ROTATING_14,
11804 EL_DF_MIRROR_ROTATING_13,
11805 EL_DF_MIRROR_ROTATING_12,
11806 EL_DF_MIRROR_ROTATING_11,
11807 EL_DF_MIRROR_ROTATING_10,
11808 EL_DF_MIRROR_ROTATING_9,
11809 EL_DF_MIRROR_ROTATING_8,
11810 EL_DF_MIRROR_ROTATING_7,
11811 EL_DF_MIRROR_ROTATING_6,
11812 EL_DF_MIRROR_ROTATING_5,
11813 EL_DF_MIRROR_ROTATING_4,
11814 EL_DF_MIRROR_ROTATING_3,
11815 EL_DF_MIRROR_ROTATING_2
11824 for (i = 0; swappable_elements[i][0] != -1; i++)
11826 int element1 = swappable_elements[i][0];
11827 int element2 = swappable_elements[i][1];
11829 if (old_element == element1 || old_element == element2)
11830 new_element = (old_element == element1 ? element2 : element1);
11833 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
11835 for (j = 0; j < 4; j++)
11837 int element = rotatable_elements_4[i][j];
11839 if (old_element == element)
11840 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
11841 button == 2 ? rotatable_elements_4[i][0] :
11842 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
11847 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
11849 for (j = 0; j < 8; j++)
11851 int element = rotatable_elements_8[i][j];
11853 if (old_element == element)
11854 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
11855 button == 2 ? rotatable_elements_8[i][0] :
11856 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
11861 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
11863 for (j = 0; j < 16; j++)
11865 int element = rotatable_elements_16[i][j];
11867 if (old_element == element)
11868 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
11869 button == 2 ? rotatable_elements_16[i][0] :
11870 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
11875 if (old_element != new_element)
11877 int max_infotext_len = getMaxInfoTextLength();
11878 char infotext[MAX_OUTPUT_LINESIZE + 1];
11880 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
11881 infotext[max_infotext_len] = '\0';
11883 ClearEditorGadgetInfoText();
11885 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
11890 SetElementSimple(x, y, new_element, change_level);
11896 static void ResetIntelliDraw(void)
11900 for (x = 0; x < lev_fieldx; x++)
11901 for (y = 0; y < lev_fieldy; y++)
11902 IntelliDrawBuffer[x][y] = Tile[x][y];
11904 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
11907 static boolean draw_mode_hires = FALSE;
11909 static boolean isHiresTileElement(int element)
11911 return (IS_MM_WALL(element) || element == EL_EMPTY);
11914 static boolean isHiresDrawElement(int element)
11916 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
11919 static void SetDrawModeHiRes(int element)
11922 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
11923 isHiresDrawElement(element));
11926 static boolean getDrawModeHiRes(void)
11928 return draw_mode_hires;
11931 static int getLoResScreenPos(int pos)
11933 return (getDrawModeHiRes() ? pos / 2 : pos);
11936 static int getLoResScreenMod(int pos)
11938 return (getDrawModeHiRes() ? pos % 2 : 0);
11941 static void SetElementExt(int x, int y, int dx, int dy, int element,
11942 boolean change_level, int button)
11945 SetElementSimple(x, y, Tile[x][y], change_level);
11946 else if (GetKeyModState() & KMOD_Shift && !IS_MM_WALL_EDITOR(element))
11947 SetElementIntelliDraw(x, y, element, change_level, button);
11949 SetElementSimpleExt(x, y, dx, dy, element, change_level);
11952 static void SetElement(int x, int y, int element)
11954 SetElementExt(x, y, 0, 0, element, TRUE, -1);
11957 static void SetElementButton(int x, int y, int dx, int dy, int element,
11960 SetElementExt(x, y, dx, dy, element, TRUE, button);
11963 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
11965 int lx = getLoResScreenPos(sx2) + level_xpos;
11966 int ly = getLoResScreenPos(sy2) + level_ypos;
11967 int dx = getLoResScreenMod(sx2);
11968 int dy = getLoResScreenMod(sy2);
11970 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
11973 static void SetLevelElementHiRes(int lx2, int ly2, int element)
11980 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
11983 static int getLevelElementHiRes(int lx2, int ly2)
11989 int element = Tile[lx][ly];
11990 unsigned int bitmask = (dx + 1) << (dy * 2);
11992 if (IS_MM_WALL(element))
11994 if (element & bitmask)
11995 return map_mm_wall_element(element);
12003 static void DrawLineElement(int x, int y, int element, boolean change_level)
12005 SetElementHiRes(x, y, element, change_level);
12008 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12009 int element, boolean change_level)
12011 int xsize = ABS(to_x - from_x);
12012 int ysize = ABS(to_y - from_y);
12013 int dx = (to_x < from_x ? -1 : +1);
12014 int dy = (to_y < from_y ? -1 : +1);
12017 if (from_y == to_y) // horizontal line
12019 for (i = 0; i <= xsize; i++)
12020 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12022 else if (from_x == to_x) // vertical line
12024 for (i = 0; i <= ysize; i++)
12025 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12027 else // diagonal line
12029 if (ysize < xsize) // a < 1
12031 float a = (float)ysize / (float)xsize;
12033 for (i = 0; i <= xsize; i++)
12036 int y = dy * (int)(a * i + 0.5);
12038 DrawLineElement(from_x + x, from_y + y, element, change_level);
12043 float a = (float)xsize / (float)ysize;
12045 for (i = 0; i <= ysize; i++)
12047 int x = dx * (int)(a * i + 0.5);
12050 DrawLineElement(from_x + x, from_y + y, element, change_level);
12056 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12057 int element, boolean change_level)
12059 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12060 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12061 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12062 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12065 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12066 int element, boolean change_level)
12071 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12073 for (y = from_y; y <= to_y; y++)
12074 DrawLine(from_x, y, to_x, y, element, change_level);
12077 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12078 int element, boolean change_level)
12080 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12081 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12082 int len_x = ABS(to_x - from_x);
12083 int len_y = ABS(to_y - from_y);
12086 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
12088 // not optimal (some points get drawn twice) but simple,
12089 // and fast enough for the few points we are drawing
12091 for (x = 0; x <= radius; x++)
12093 int sx, sy, sx2, sy2, lx, ly;
12095 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
12097 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12098 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12099 sx = getLoResScreenPos(sx2);
12100 sy = getLoResScreenPos(sy2);
12101 lx = sx + level_xpos;
12102 ly = sy + level_ypos;
12104 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12105 DrawLineElement(sx2, sy2, element, change_level);
12108 for (y = 0; y <= radius; y++)
12110 int sx, sy, sx2, sy2, lx, ly;
12112 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
12114 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12115 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12116 sx = getLoResScreenPos(sx2);
12117 sy = getLoResScreenPos(sy2);
12118 lx = sx + level_xpos;
12119 ly = sy + level_ypos;
12121 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12122 DrawLineElement(sx2, sy2, element, change_level);
12126 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
12127 int element, boolean change_level)
12129 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12130 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12132 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12135 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
12137 #if DRAW_CIRCLES_BUTTON_AVAILABLE
12138 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
12139 int element, boolean change_level)
12141 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12142 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12143 int mirror_to_x2 = from_x - (to_x2 - from_x);
12144 int mirror_to_y2 = from_y - (to_y2 - from_y);
12146 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12147 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
12148 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
12149 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
12153 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
12155 int from_sx, from_sy;
12159 swap_numbers(&from_x, &to_x);
12162 swap_numbers(&from_y, &to_y);
12164 from_sx = SX + from_x * ed_tilesize;
12165 from_sy = SY + from_y * ed_tilesize;
12166 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
12167 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
12169 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12170 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12171 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12172 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12174 if (from_x == to_x && from_y == to_y)
12175 MarkTileDirty(from_x/2, from_y/2);
12177 redraw_mask |= REDRAW_FIELD;
12180 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
12181 int element, boolean change_level)
12183 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
12186 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
12187 int element, boolean change_level)
12189 if (element == -1 || change_level)
12190 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
12192 DrawAreaBorder(from_x, from_y, to_x, to_y);
12195 // values for CopyBrushExt()
12196 #define CB_AREA_TO_BRUSH 0
12197 #define CB_BRUSH_TO_CURSOR 1
12198 #define CB_BRUSH_TO_LEVEL 2
12199 #define CB_DELETE_OLD_CURSOR 3
12200 #define CB_DUMP_BRUSH 4
12201 #define CB_DUMP_BRUSH_SMALL 5
12202 #define CB_CLIPBOARD_TO_BRUSH 6
12203 #define CB_BRUSH_TO_CLIPBOARD 7
12204 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
12205 #define CB_UPDATE_BRUSH_POSITION 9
12207 #define MAX_CB_PART_SIZE 10
12208 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
12209 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
12210 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
12211 MAX_CB_NUM_LINES * \
12214 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
12216 DrawLineElement(sx, sy, element, change_level);
12219 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
12220 int button, int mode)
12222 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12223 static int brush_width, brush_height;
12224 static int last_cursor_x = -1, last_cursor_y = -1;
12225 static boolean delete_old_brush = FALSE;
12226 int new_element = BUTTON_ELEMENT(button);
12229 if (mode == CB_DUMP_BRUSH ||
12230 mode == CB_DUMP_BRUSH_SMALL ||
12231 mode == CB_BRUSH_TO_CLIPBOARD ||
12232 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12234 if (edit_mode != ED_MODE_DRAWING)
12237 char part[MAX_CB_PART_SIZE + 1] = "";
12238 char text[MAX_CB_TEXT_SIZE + 1] = "";
12239 int width = (draw_with_brush ? brush_width : lev_fieldx);
12240 int height = (draw_with_brush ? brush_height : lev_fieldy);
12241 char *format = "%s%03d";
12243 for (y = 0; y < height; y++)
12244 for (x = 0; x < width; x++)
12245 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
12248 for (y = 0; y < height; y++)
12250 for (x = 0; x < width; x++)
12252 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
12253 char *prefix = (mode == CB_DUMP_BRUSH ||
12254 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
12256 if (element >= NUM_FILE_ELEMENTS)
12257 element = EL_UNKNOWN;
12259 // copy brush to level sketch text buffer for the R'n'D forum:
12260 // - large tiles: `xxx or `xxxx (0x60 ASCII)
12261 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
12262 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
12263 strcat(text, part);
12266 strcat(text, "\n");
12269 if (mode == CB_BRUSH_TO_CLIPBOARD ||
12270 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12271 SDL_SetClipboardText(text);
12273 Print("%s", text); // print brush data to console and log file
12278 if (mode == CB_CLIPBOARD_TO_BRUSH)
12280 if (edit_mode != ED_MODE_DRAWING)
12283 if (!SDL_HasClipboardText())
12285 Request("Clipboard is empty!", REQ_CONFIRM);
12290 boolean copy_to_brush = (draw_with_brush ||
12291 drawing_function == GADGET_ID_GRAB_BRUSH);
12293 // this will delete the old brush, if already drawing with a brush
12295 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
12297 // initialization is required for "odd" (incomplete) clipboard content
12298 for (x = 0; x < MAX_LEV_FIELDX; x++)
12299 for (y = 0; y < MAX_LEV_FIELDY; y++)
12300 brush_buffer[x][y] = EL_EMPTY;
12307 char *clipboard_text = SDL_GetClipboardText();
12308 char *ptr = clipboard_text;
12309 boolean allow_new_row = FALSE;
12310 boolean stop = FALSE;
12312 while (*ptr && !stop)
12314 boolean prefix_found = FALSE;
12315 boolean start_new_row = FALSE;
12317 // level sketch element number prefixes (may be multi-byte characters)
12318 char *prefix_list[] = { "`", "¸" };
12321 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
12323 char *prefix = prefix_list[i];
12325 // check if string is large enough for prefix
12326 if (strlen(ptr) < strlen(prefix))
12333 // check if string starts with prefix
12334 if (strPrefix(ptr, prefix))
12336 ptr += strlen(prefix);
12338 prefix_found = TRUE;
12344 // check if prefix found and followed by (at least) three digits
12345 if (prefix_found &&
12346 strlen(ptr) >= 3 &&
12347 ptr[0] >= '0' && ptr[0] <= '9' &&
12348 ptr[1] >= '0' && ptr[1] <= '9' &&
12349 ptr[2] >= '0' && ptr[2] <= '9')
12351 int element = ((ptr[0] - '0') * 100 +
12352 (ptr[1] - '0') * 10 +
12357 // level sketch element number might consist of four digits
12358 if (ptr[0] >= '0' && ptr[0] <= '9')
12360 element = element * 10 + (ptr[0] - '0');
12364 // remap some (historic, now obsolete) elements
12365 element = getMappedElement(element);
12367 if (element >= NUM_FILE_ELEMENTS)
12368 element = EL_UNKNOWN;
12370 brush_buffer[x][y] = element;
12372 brush_width = MAX(x + 1, brush_width);
12373 brush_height = MAX(y + 1, brush_height);
12377 if (x >= MAX_LEV_FIELDX)
12378 start_new_row = TRUE;
12380 allow_new_row = TRUE;
12384 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
12385 start_new_row = TRUE;
12387 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
12395 if (y >= MAX_LEV_FIELDY)
12398 allow_new_row = FALSE;
12402 SDL_free(clipboard_text);
12404 if (brush_width == 0 || brush_height == 0)
12406 Request("No level sketch found in clipboard!", REQ_CONFIRM);
12413 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
12416 SDL_GetMouseState(&mx, &my);
12418 // if inside drawing area, activate and draw brush at last mouse position
12419 if (mx >= gi->x && mx < gi->x + gi->width &&
12420 my >= gi->y && my < gi->y + gi->height)
12421 CopyBrushToCursor(last_cursor_x, last_cursor_y);
12423 draw_with_brush = TRUE;
12429 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
12430 brush_width, brush_height);
12432 if (!Request(request, REQ_ASK))
12435 for (x = 0; x < MAX_LEV_FIELDX; x++)
12436 for (y = 0; y < MAX_LEV_FIELDY; y++)
12437 Tile[x][y] = brush_buffer[x][y];
12439 lev_fieldx = level.fieldx = brush_width;
12440 lev_fieldy = level.fieldy = brush_height;
12442 boolean use_em_engine = TRUE;
12443 boolean use_sp_engine = TRUE;
12444 boolean use_mm_engine = TRUE;
12446 for (x = 0; x < MAX_LEV_FIELDX; x++)
12448 for (y = 0; y < MAX_LEV_FIELDY; y++)
12450 int element = Tile[x][y];
12452 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
12453 use_em_engine = FALSE;
12455 if (!IS_SP_ELEMENT(element))
12456 use_sp_engine = FALSE;
12458 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
12459 use_mm_engine = FALSE;
12463 level.game_engine_type = (use_em_engine ? GAME_ENGINE_TYPE_EM :
12464 use_sp_engine ? GAME_ENGINE_TYPE_SP :
12465 use_mm_engine ? GAME_ENGINE_TYPE_MM :
12466 GAME_ENGINE_TYPE_RND);
12468 // update element selection list
12469 ReinitializeElementList();
12470 ModifyEditorElementList();
12472 SetBorderElement();
12474 DrawEditModeWindow();
12475 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12481 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
12484 if (mode == CB_AREA_TO_BRUSH)
12486 int from_lx, from_ly;
12489 swap_numbers(&from_x, &to_x);
12492 swap_numbers(&from_y, &to_y);
12494 brush_width = to_x - from_x + 1;
12495 brush_height = to_y - from_y + 1;
12497 from_lx = from_x + level_xpos;
12498 from_ly = from_y + level_ypos;
12500 for (y = 0; y < brush_height; y++)
12502 for (x = 0; x < brush_width; x++)
12504 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
12507 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
12512 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12514 delete_old_brush = FALSE;
12516 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
12517 mode == CB_BRUSH_TO_LEVEL)
12519 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
12520 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
12521 int cursor_from_x = cursor_x - brush_width / 2;
12522 int cursor_from_y = cursor_y - brush_height / 2;
12523 int border_from_x = cursor_x, border_from_y = cursor_y;
12524 int border_to_x = cursor_x, border_to_y = cursor_y;
12526 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
12527 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12529 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
12530 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
12532 delete_old_brush = FALSE;
12537 for (y = 0; y < brush_height; y++)
12539 for (x = 0; x < brush_width; x++)
12541 int sx = cursor_from_x + x;
12542 int sy = cursor_from_y + y;
12543 int lx = sx + level_xpos;
12544 int ly = sy + level_ypos;
12545 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
12546 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
12547 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
12548 brush_buffer[x][y] : new_element);
12550 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12552 if (sx < border_from_x)
12553 border_from_x = sx;
12554 else if (sx > border_to_x)
12556 if (sy < border_from_y)
12557 border_from_y = sy;
12558 else if (sy > border_to_y)
12561 DrawBrushElement(sx, sy, element, change_level);
12566 if (mode != CB_DELETE_OLD_CURSOR)
12567 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
12569 last_cursor_x = cursor_x;
12570 last_cursor_y = cursor_y;
12572 delete_old_brush = TRUE;
12575 if (mode == CB_UPDATE_BRUSH_POSITION)
12577 last_cursor_x = from_x;
12578 last_cursor_y = from_y;
12582 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
12585 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
12588 static void CopyBrushToLevel(int x, int y, int button)
12590 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
12593 static void CopyBrushToCursor(int x, int y)
12595 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
12598 static void UpdateBrushPosition(int x, int y)
12600 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
12603 static void DeleteBrushFromCursor(void)
12605 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12608 void DumpBrush(void)
12610 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
12613 void DumpBrush_Small(void)
12615 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
12618 void CopyClipboardToBrush(void)
12620 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
12623 void CopyBrushToClipboard(void)
12625 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
12628 void CopyBrushToClipboard_Small(void)
12630 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
12633 void UndoLevelEditorOperation(void)
12635 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
12638 void RedoLevelEditorOperation(void)
12640 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
12643 static void FloodFill(int from_x, int from_y, int fill_element)
12645 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
12648 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
12650 int from_x = from_sx2 + 2 * level_xpos;
12651 int from_y = from_sy2 + 2 * level_ypos;
12652 int max_fillx = lev_fieldx * 2;
12653 int max_filly = lev_fieldy * 2;
12654 short Fill[max_fillx][max_filly];
12657 for (x = 0; x < max_fillx; x++)
12658 for (y = 0; y < max_filly; y++)
12659 Fill[x][y] = getLevelElementHiRes(x, y);
12661 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
12662 Fill, max_fillx, max_filly);
12664 for (x = 0; x < max_fillx; x++)
12665 for (y = 0; y < max_filly; y++)
12666 if (Fill[x][y] == fill_element)
12667 SetLevelElementHiRes(x, y, Fill[x][y]);
12670 // values for DrawLevelText() modes
12671 #define TEXT_INIT 0
12672 #define TEXT_SETCURSOR 1
12673 #define TEXT_WRITECHAR 2
12674 #define TEXT_BACKSPACE 3
12675 #define TEXT_NEWLINE 4
12677 #define TEXT_QUERY_TYPING 6
12679 static int DrawLevelText(int sx, int sy, char letter, int mode)
12681 static short delete_buffer[MAX_LEV_FIELDX];
12682 static int start_sx;
12683 static int last_sx, last_sy;
12684 static boolean typing = FALSE;
12685 int letter_element;
12686 int lx = 0, ly = 0;
12688 // map lower case letters to upper case and convert special characters
12689 if (letter >= 'a' && letter <= 'z')
12690 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
12691 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
12692 letter_element = EL_CHAR_AUMLAUT;
12693 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
12694 letter_element = EL_CHAR_OUMLAUT;
12695 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
12696 letter_element = EL_CHAR_UUMLAUT;
12697 else if (letter == '^')
12698 letter_element = EL_CHAR_COPYRIGHT;
12700 letter_element = EL_CHAR_ASCII0 + letter;
12702 if (mode != TEXT_INIT)
12707 if (mode != TEXT_SETCURSOR)
12713 lx = last_sx + level_xpos;
12714 ly = last_sy + level_ypos;
12721 DrawLevelText(0, 0, 0, TEXT_END);
12727 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
12730 case TEXT_SETCURSOR:
12731 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
12732 DrawAreaBorder(sx, sy, sx, sy);
12733 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
12734 ed_tilesize, ed_tilesize);
12739 case TEXT_WRITECHAR:
12740 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
12742 if (new_element1 >= EL_STEEL_CHAR_START &&
12743 new_element1 <= EL_STEEL_CHAR_END)
12744 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
12746 delete_buffer[sx - start_sx] = Tile[lx][ly];
12747 Tile[lx][ly] = letter_element;
12749 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
12750 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
12751 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12752 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12754 DrawLevelText(0, 0, 0, TEXT_END);
12756 level.changed = TRUE;
12760 case TEXT_BACKSPACE:
12763 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
12764 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
12765 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
12770 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12771 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12773 DrawLevelText(0, 0, 0, TEXT_END);
12777 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12778 DrawEditorElement(sx, sy, Tile[lx][ly]);
12783 case TEXT_QUERY_TYPING:
12793 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
12794 int element, boolean change_level)
12796 int lx = sx + level_xpos;
12797 int ly = sy + level_ypos;
12800 DrawEditorElement(sx, sy, Tile[lx][ly]);
12802 DrawAreaBorder(sx, sy, sx, sy);
12805 static void CheckLevelBorderElement(boolean redraw_playfield)
12807 int last_border_element = BorderElement;
12809 SetBorderElement();
12811 if (redraw_playfield && BorderElement != last_border_element)
12812 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12815 static void CopyLevelToUndoBuffer(int mode)
12817 static boolean accumulated_undo = FALSE;
12818 boolean new_undo_buffer_position = TRUE;
12821 if (undo_buffer_steps == 0)
12822 accumulated_undo = FALSE;
12826 case UNDO_IMMEDIATE:
12827 accumulated_undo = FALSE;
12830 case UNDO_ACCUMULATE:
12831 if (accumulated_undo)
12832 new_undo_buffer_position = FALSE;
12833 accumulated_undo = TRUE;
12840 if (new_undo_buffer_position)
12842 // advance position in undo buffer ring
12843 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
12845 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
12846 undo_buffer_steps++;
12849 // always reset redo buffer when storing level change into undo buffer
12850 redo_buffer_steps = 0;
12852 for (x = 0; x < lev_fieldx; x++)
12853 for (y = 0; y < lev_fieldy; y++)
12854 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
12856 // check if drawing operation forces change of border style
12857 CheckLevelBorderElement(TRUE);
12859 level.changed = TRUE;
12862 static void RandomPlacement(int new_element)
12864 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12865 int num_free_positions = 0;
12866 int num_percentage, num_elements;
12869 ResetIntelliDraw();
12871 // determine number of free positions for randomly placing the new element
12872 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
12874 free_position[x][y] =
12875 (random_placement_background_restricted ?
12876 Tile[x][y] == random_placement_background_element :
12877 Tile[x][y] != new_element);
12879 if (free_position[x][y])
12880 num_free_positions++;
12883 // determine number of new elements to place there
12884 num_percentage = num_free_positions * random_placement_value / 100;
12885 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
12886 num_percentage : random_placement_value);
12888 // if less free positions than elements to place, fill all these positions
12889 if (num_free_positions < num_elements)
12891 for (x = 0; x < lev_fieldx; x++)
12892 for (y = 0; y < lev_fieldy; y++)
12893 if (free_position[x][y])
12894 SetElement(x, y, new_element);
12898 while (num_elements > 0)
12900 x = GetSimpleRandom(lev_fieldx);
12901 y = GetSimpleRandom(lev_fieldy);
12903 // don't place element at the same position twice
12904 if (free_position[x][y])
12906 free_position[x][y] = FALSE;
12907 SetElement(x, y, new_element);
12913 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12914 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12917 static void WrapLevel(int dx, int dy)
12919 int wrap_dx = lev_fieldx - dx;
12920 int wrap_dy = lev_fieldy - dy;
12923 for (x = 0; x < lev_fieldx; x++)
12924 for (y = 0; y < lev_fieldy; y++)
12925 TileBackup[x][y] = Tile[x][y];
12927 for (x = 0; x < lev_fieldx; x++)
12928 for (y = 0; y < lev_fieldy; y++)
12930 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
12932 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12933 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
12936 static void DrawAreaElementHighlight(boolean highlighted)
12938 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12945 for (x = 0; x < ed_fieldx; x++)
12947 for (y = 0; y < ed_fieldy; y++)
12949 int lx = x + level_xpos;
12950 int ly = y + level_ypos;
12952 if (!IN_LEV_FIELD(lx, ly))
12955 if (Tile[lx][ly] != new_element1)
12958 int sx = SX + x * ed_tilesize;
12959 int sy = SY + y * ed_tilesize;
12962 int to_sx = sx + ed_tilesize - 1;
12963 int to_sy = sy + ed_tilesize - 1;
12965 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12966 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12967 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12968 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12973 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
12975 char *template_filename_old = getLocalLevelTemplateFilename();
12976 char *template_filename_new =
12977 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
12979 if (copyFile(template_filename_old, template_filename_new) != 0)
12980 Request("Cannot copy level template!", REQ_CONFIRM);
12982 free(template_filename_new);
12985 static void HandleDrawingAreas(struct GadgetInfo *gi)
12987 static boolean started_inside_drawing_area = FALSE;
12988 int id = gi->custom_id;
12989 int type_id = gi->custom_type_id;
12990 boolean button_press_event;
12991 boolean button_release_event;
12992 boolean inside_drawing_area = !gi->event.off_borders;
12993 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
12994 int actual_drawing_function;
12995 int button = gi->event.button;
12996 int new_element = BUTTON_ELEMENT(button);
12997 int sx = gi->event.x, sy = gi->event.y;
12998 int min_sx = 0, min_sy = 0;
12999 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
13000 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
13001 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
13002 int sx2 = gi->event.mx / mini_item_xsize;
13003 int sy2 = gi->event.my / mini_item_ysize;
13006 int lx = 0, ly = 0;
13009 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
13010 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
13012 // make sure to stay inside drawing area boundaries
13013 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
13014 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
13018 int min_lx = 0, min_ly = 0;
13019 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
13021 // get positions inside level field
13022 lx = sx + level_xpos;
13023 ly = sy + level_ypos;
13025 if (!IN_LEV_FIELD(lx, ly))
13026 inside_drawing_area = FALSE;
13028 // make sure to stay inside level field boundaries
13029 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
13030 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
13032 // correct drawing area positions accordingly
13033 sx = lx - level_xpos;
13034 sy = ly - level_ypos;
13037 // also correct MM wall-sized (double) drawing area positions accordingly
13038 if (sx2 / 2 < sx || sx2 / 2 > sx)
13040 dx = (sx2 / 2 < sx ? 0 : 1);
13043 if (sy2 / 2 < sy || sy2 / 2 > sy)
13045 dy = (sy2 / 2 < sy ? 0 : 1);
13049 if (!button_press_event && !button_release_event)
13051 static int last_sx = -1;
13052 static int last_sy = -1;
13053 static int last_sx2 = -1;
13054 static int last_sy2 = -1;
13055 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
13056 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
13057 isHiresTileElement(old_element) &&
13058 isHiresDrawElement(new_element));
13060 // prevent handling events for every pixel position when moving mouse
13061 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
13062 (sx2 == last_sx2 && sy2 == last_sy2))
13071 if (button_press_event)
13072 started_inside_drawing_area = inside_drawing_area;
13074 if (!started_inside_drawing_area)
13077 if (!IS_VALID_BUTTON(button))
13080 // handle info callback for each invocation of action callback
13081 gi->callback_info(gi);
13083 // automatically switch to 'single item' drawing mode, if needed
13084 actual_drawing_function =
13085 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
13086 drawing_function : GADGET_ID_SINGLE_ITEMS);
13088 // clicking into drawing area with pressed Control key picks element
13089 if (GetKeyModState() & KMOD_Control)
13091 last_drawing_function = drawing_function;
13092 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
13095 if (GetKeyModState() & KMOD_Shift)
13097 if (button_press_event || button_release_event)
13098 ResetIntelliDraw();
13101 SetDrawModeHiRes(-1); // reset to normal draw mode
13103 switch (actual_drawing_function)
13105 case GADGET_ID_SINGLE_ITEMS:
13108 if (button_release_event)
13110 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13112 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
13113 !inside_drawing_area)
13114 DeleteBrushFromCursor();
13119 if (draw_with_brush)
13121 CopyBrushToLevel(sx, sy, button);
13125 SetDrawModeHiRes(new_element);
13127 if (IS_PLAYER_ELEMENT(new_element))
13129 // remove player at old position
13130 for (y = 0; y < lev_fieldy; y++)
13132 for (x = 0; x < lev_fieldx; x++)
13134 int old_element = Tile[x][y];
13136 if (IS_PLAYER_ELEMENT(old_element))
13138 int replaced_with_element =
13139 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
13140 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
13142 old_element == EL_SOKOBAN_FIELD_PLAYER &&
13143 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
13145 new_element == EL_SOKOBAN_FIELD_PLAYER &&
13146 old_element == EL_PLAYER_1 ? EL_EMPTY :
13148 new_element >= EL_PLAYER_1 &&
13149 new_element <= EL_PLAYER_4 &&
13150 new_element == old_element ? EL_EMPTY :
13154 SetElement(x, y, replaced_with_element);
13160 SetElementButton(lx, ly, dx, dy, new_element, button);
13163 else if (!button_release_event)
13165 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13167 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
13168 DrawMiniGraphicExt(drawto,
13169 gi->x + sx * MINI_TILEX,
13170 gi->y + sy * MINI_TILEY,
13171 el2edimg(new_element));
13173 DrawFixedGraphicExt(drawto,
13174 gi->x + sx * TILEX,
13175 gi->y + sy * TILEY,
13176 el2edimg(new_element), 0);
13178 if (id == GADGET_ID_CUSTOM_GRAPHIC)
13179 new_element = GFX_ELEMENT(new_element);
13181 drawingarea_info[type_id].value[pos] = new_element;
13183 CopyElementPropertiesToGame(properties_element);
13185 if (id == GADGET_ID_CUSTOM_GRAPHIC)
13187 UpdateCustomElementGraphicGadgets();
13189 FrameCounter = 0; // restart animation frame counter
13194 case GADGET_ID_CONNECTED_ITEMS:
13196 static int last_sx = -1;
13197 static int last_sy = -1;
13199 if (button_release_event)
13200 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13202 SetDrawModeHiRes(new_element);
13204 if (getDrawModeHiRes())
13210 if (!button_press_event)
13211 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
13218 case GADGET_ID_LINE:
13219 case GADGET_ID_ARC:
13220 case GADGET_ID_RECTANGLE:
13221 case GADGET_ID_FILLED_BOX:
13222 SetDrawModeHiRes(new_element);
13224 if (getDrawModeHiRes())
13230 case GADGET_ID_GRAB_BRUSH:
13231 case GADGET_ID_TEXT:
13233 static int last_sx = -1;
13234 static int last_sy = -1;
13235 static int start_sx = -1;
13236 static int start_sy = -1;
13237 void (*draw_func)(int, int, int, int, int, boolean);
13239 if (drawing_function == GADGET_ID_LINE)
13240 draw_func = DrawLine;
13241 else if (drawing_function == GADGET_ID_ARC)
13242 draw_func = DrawArc;
13243 else if (drawing_function == GADGET_ID_RECTANGLE)
13244 draw_func = DrawBox;
13245 else if (drawing_function == GADGET_ID_FILLED_BOX)
13246 draw_func = DrawFilledBox;
13247 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
13248 draw_func = SelectArea;
13249 else // (drawing_function == GADGET_ID_TEXT)
13250 draw_func = SetTextCursor;
13252 if (button_press_event)
13254 draw_func(sx, sy, sx, sy, new_element, FALSE);
13255 start_sx = last_sx = sx;
13256 start_sy = last_sy = sy;
13258 if (drawing_function == GADGET_ID_TEXT)
13259 DrawLevelText(0, 0, 0, TEXT_END);
13261 else if (button_release_event)
13263 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
13264 if (drawing_function == GADGET_ID_GRAB_BRUSH)
13266 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
13267 CopyBrushToCursor(sx, sy);
13268 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
13270 draw_with_brush = TRUE;
13272 else if (drawing_function == GADGET_ID_TEXT)
13273 DrawLevelText(sx, sy, 0, TEXT_INIT);
13275 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13277 else if (last_sx != sx || last_sy != sy)
13279 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
13280 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
13281 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
13282 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
13289 case GADGET_ID_FLOOD_FILL:
13290 if (button_press_event && Tile[lx][ly] != new_element)
13292 if (IS_MM_WALL_EDITOR(new_element))
13293 FloodFillWall_MM(sx2, sy2, new_element);
13295 FloodFill(lx, ly, new_element);
13297 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13298 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13302 case GADGET_ID_PICK_ELEMENT:
13303 if (button_release_event)
13304 ClickOnGadget(level_editor_gadget[last_drawing_function],
13306 else if (draw_level)
13307 PickDrawingElement(button, Tile[lx][ly]);
13310 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13312 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
13319 // do not mark level as modified for certain non-level-changing gadgets
13320 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
13321 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
13322 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
13323 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
13326 level.changed = TRUE;
13329 static void HandleCounterButtons(struct GadgetInfo *gi)
13331 int gadget_id = gi->custom_id;
13332 int counter_id = gi->custom_type_id;
13333 int button = gi->event.button;
13334 int *counter_value = counterbutton_info[counter_id].value;
13335 int step = BUTTON_STEPSIZE(button) *
13336 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
13338 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
13340 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
13341 boolean released = (gi->event.type == GD_EVENT_RELEASED);
13342 boolean level_changed = LevelChanged();
13344 if ((level_changed && pressed) || (!level_changed && released))
13347 if (level_changed && !Request("Level has changed! Discard changes?",
13350 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
13351 ModifyEditorCounterValue(counter_id, *counter_value);
13357 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
13358 *counter_value = gi->textinput.number_value;
13360 ModifyEditorCounterValue(counter_id, *counter_value + step);
13362 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
13364 int last_game_engine_type = level.game_engine_type;
13366 LoadLevel(level_nr);
13367 LoadScore(level_nr);
13369 SaveLevelSetup_SeriesInfo();
13374 DrawEditModeWindow();
13376 if (level.game_engine_type != last_game_engine_type)
13378 // update element selection list
13379 ReinitializeElementList();
13380 ModifyEditorElementList();
13386 switch (counter_id)
13388 case ED_COUNTER_ID_YAMYAM_CONTENT:
13389 DrawYamYamContentAreas();
13392 case ED_COUNTER_ID_BALL_CONTENT:
13393 DrawMagicBallContentAreas();
13396 case ED_COUNTER_ID_ANDROID_CONTENT:
13397 DrawAndroidElementArea();
13400 case ED_COUNTER_ID_GROUP_CONTENT:
13401 DrawGroupElementArea();
13402 CopyGroupElementPropertiesToGame(properties_element);
13405 case ED_COUNTER_ID_INVENTORY_SIZE:
13406 DrawPlayerInitialInventoryArea(properties_element);
13409 case ED_COUNTER_ID_MM_BALL_CONTENT:
13410 DrawMMBallContentArea();
13413 case ED_COUNTER_ID_ENVELOPE_XSIZE:
13414 case ED_COUNTER_ID_ENVELOPE_YSIZE:
13415 DrawEnvelopeTextArea(-1);
13418 case ED_COUNTER_ID_LEVEL_XSIZE:
13419 case ED_COUNTER_ID_LEVEL_YSIZE:
13420 lev_fieldx = level.fieldx;
13421 lev_fieldy = level.fieldy;
13423 // check if resizing of level results in change of border border
13424 SetBorderElement();
13432 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
13433 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
13434 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
13435 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
13436 CopyElementPropertiesToGame(properties_element);
13438 // do not mark level as modified for certain non-level-changing gadgets
13439 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
13440 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
13441 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
13442 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
13445 level.changed = TRUE;
13448 static void HandleTextInputGadgets(struct GadgetInfo *gi)
13450 int type_id = gi->custom_type_id;
13452 strcpy(textinput_info[type_id].value, gi->textinput.value);
13454 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
13456 CopyElementPropertiesToGame(properties_element);
13458 ModifyEditorElementList(); // update changed button info text
13461 // do not mark level as modified for certain non-level-changing gadgets
13462 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
13463 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
13466 level.changed = TRUE;
13469 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
13471 int type_id = gi->custom_type_id;
13473 strncpy(textarea_info[type_id].value, gi->textarea.value,
13474 MAX_ENVELOPE_TEXT_LEN);
13475 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
13477 level.changed = TRUE;
13480 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
13482 int type_id = gi->custom_type_id;
13483 int value_old = *selectbox_info[type_id].value;
13484 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
13486 *selectbox_info[type_id].value = value_new;
13488 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
13490 DrawLevelInfoWindow();
13492 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
13494 element_info[properties_element].current_change_page = gi->selectbox.index;
13496 DrawPropertiesWindow();
13498 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
13499 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
13500 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
13501 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
13502 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
13504 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
13506 // when changing action type, also check action mode and action arg
13507 if (value_old != value_new)
13508 setSelectboxSpecialActionVariablesIfNeeded();
13510 DrawPropertiesChange();
13513 CopyElementPropertiesToGame(properties_element);
13515 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
13517 // update element selection list
13518 ReinitializeElementList();
13519 ModifyEditorElementList();
13522 // do not mark level as modified for certain non-level-changing gadgets
13523 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
13524 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
13527 level.changed = TRUE;
13530 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
13532 int type_id = gi->custom_type_id;
13535 if (type_id >= ED_TAB_BUTTON_ID_LEVELINFO_FIRST &&
13536 type_id <= ED_TAB_BUTTON_ID_LEVELINFO_LAST)
13538 edit_mode_levelinfo = gi->custom_type_id;
13540 DrawLevelInfoWindow();
13542 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
13543 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
13545 edit_mode_properties = gi->custom_type_id;
13547 DrawPropertiesWindow();
13549 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
13550 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
13552 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
13554 // backup original "level.field" (needed to track playfield changes)
13555 CopyPlayfield(level.field, TileBackup);
13557 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
13558 CopyPlayfield(Tile, level.field);
13560 if (new_template ||
13561 Request("Save this template and kill the old?", REQ_ASK))
13562 SaveLevelTemplate();
13565 Request("Template saved!", REQ_CONFIRM);
13567 // restore original "level.field" (needed to track playfield changes)
13568 CopyPlayfield(TileBackup, level.field);
13570 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
13572 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
13574 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
13575 leveldir_current->readonly)
13577 Request("This level set is read-only!", REQ_CONFIRM);
13582 if (strEqual(levelset_name, ""))
13584 Request("Please enter level set title!", REQ_CONFIRM);
13589 if (strEqual(levelset_author, ""))
13591 Request("Please enter level set author!", REQ_CONFIRM);
13596 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
13598 if (UpdateUserLevelSet(levelset_subdir,
13601 levelset_num_levels))
13603 Request("Level set updated!", REQ_CONFIRM);
13607 Request("Updating level set failed!", REQ_CONFIRM);
13610 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
13612 if (level.changed && !Request("Level has changed! Discard changes?",
13616 if (CreateUserLevelSet(levelset_subdir,
13619 levelset_num_levels,
13620 levelset_use_levelset_artwork))
13622 if (levelset_copy_level_template)
13623 CopyLevelTemplateToUserLevelSet(levelset_subdir);
13625 Request("New level set created!", REQ_CONFIRM);
13627 AddUserLevelSetToLevelInfo(levelset_subdir);
13628 ChangeEditorToLevelSet(levelset_subdir);
13632 Request("Creating new level set failed!", REQ_CONFIRM);
13636 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
13637 custom_element.num_change_pages < MAX_CHANGE_PAGES)
13639 struct ElementInfo *ei = &element_info[properties_element];
13641 // when modifying custom element, ask for copying level template
13642 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13645 setElementChangePages(ei, ei->num_change_pages + 1);
13647 // set new change page to be new current change page
13648 ei->current_change_page = ei->num_change_pages - 1;
13649 ei->change = &ei->change_page[ei->current_change_page];
13651 setElementChangeInfoToDefaults(ei->change);
13653 DrawPropertiesWindow();
13655 level.changed = TRUE;
13657 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
13658 custom_element.num_change_pages > MIN_CHANGE_PAGES)
13660 struct ElementInfo *ei = &element_info[properties_element];
13662 // when modifying custom element, ask for copying level template
13663 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13666 // copy all change pages after change page to be deleted
13667 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
13668 ei->change_page[i] = ei->change_page[i + 1];
13670 setElementChangePages(ei, ei->num_change_pages - 1);
13672 DrawPropertiesWindow();
13674 level.changed = TRUE;
13678 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
13680 int type_id = gi->custom_type_id;
13682 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
13683 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
13685 struct ElementInfo *ei = &element_info[properties_element];
13686 int step = BUTTON_STEPSIZE(gi->event.button);
13688 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
13689 ei->current_change_page += step;
13691 if (ei->current_change_page < 0)
13692 ei->current_change_page = 0;
13693 else if (ei->current_change_page >= ei->num_change_pages)
13694 ei->current_change_page = ei->num_change_pages - 1;
13696 DrawPropertiesWindow();
13698 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
13699 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13701 struct ElementInfo *ei = &element_info[properties_element];
13702 int current_change_page = ei->current_change_page;
13704 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
13706 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
13707 ei->change_page[current_change_page];
13709 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13711 // when modifying custom element, ask for copying level template
13712 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13715 ei->change_page[current_change_page] =
13716 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
13718 level.changed = TRUE;
13721 DrawPropertiesWindow();
13725 static void HandleRadiobuttons(struct GadgetInfo *gi)
13727 int type_id = gi->custom_type_id;
13729 *radiobutton_info[type_id].value =
13730 radiobutton_info[type_id].checked_value;
13732 // do not mark level as modified for certain non-level-changing gadgets
13733 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
13734 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
13737 level.changed = TRUE;
13740 static void HandleCheckbuttons(struct GadgetInfo *gi)
13742 int type_id = gi->custom_type_id;
13744 *checkbutton_info[type_id].value ^= TRUE;
13746 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
13747 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
13748 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
13749 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
13750 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
13751 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
13752 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
13753 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
13755 CopyElementPropertiesToGame(properties_element);
13758 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
13760 UpdateCustomElementGraphicGadgets();
13762 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
13763 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
13765 boolean template_related_changes_found = FALSE;
13768 // check if any custom, group or empty elements have been changed
13769 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
13770 if ((IS_CUSTOM_ELEMENT(i) ||
13771 IS_GROUP_ELEMENT(i) ||
13772 IS_EMPTY_ELEMENT(i)) &&
13773 element_info[i].modified_settings)
13774 template_related_changes_found = TRUE;
13776 if (level.use_custom_template &&
13777 !fileExists(getGlobalLevelTemplateFilename()))
13779 Request("No level template found!", REQ_CONFIRM);
13781 level.use_custom_template = FALSE;
13783 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13788 if (level.use_custom_template &&
13789 template_related_changes_found &&
13790 !Request("Discard changes and use level template?", REQ_ASK))
13792 level.use_custom_template = FALSE;
13794 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13799 if (!level.use_custom_template &&
13800 Request("Copy settings from level template?", REQ_ASK))
13805 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
13807 DrawEditModeWindow();
13809 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
13811 if (setup.editor.use_template_for_new_levels &&
13812 !fileExists(getGlobalLevelTemplateFilename()))
13814 Request("No level template found!", REQ_CONFIRM);
13819 if (setup.editor.use_template_for_new_levels &&
13821 !Request("Discard level and load template?", REQ_ASK))
13826 if (!setup.editor.use_template_for_new_levels &&
13828 !Request("Discard level and use empty level?", REQ_ASK))
13833 LoadLevel(level_nr);
13834 LoadScore(level_nr);
13839 DrawEditModeWindow();
13841 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
13843 SetAutomaticNumberOfGemsNeeded();
13846 // do not mark level as modified for certain non-level-changing gadgets
13847 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
13848 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
13849 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
13850 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
13851 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
13852 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
13855 level.changed = TRUE;
13858 static void HandleControlButtons(struct GadgetInfo *gi)
13860 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
13861 static int last_edit_mode = ED_MODE_DRAWING;
13862 static int last_custom_copy_mode = -1;
13863 static int last_button = 0;
13864 int id = gi->custom_id;
13865 int button = gi->event.button;
13866 int step = BUTTON_STEPSIZE(button);
13867 int new_element = BUTTON_ELEMENT(button);
13868 int last_properties_element = properties_element;
13871 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
13872 DrawLevelText(0, 0, 0, TEXT_END);
13874 if (id < ED_NUM_CTRL1_BUTTONS &&
13875 id != GADGET_ID_SINGLE_ITEMS &&
13876 id != GADGET_ID_PICK_ELEMENT &&
13877 edit_mode != ED_MODE_DRAWING &&
13878 drawing_function != GADGET_ID_PICK_ELEMENT &&
13879 !(GetKeyModState() & KMOD_Control))
13880 ChangeEditModeWindow(ED_MODE_DRAWING);
13882 // element copy mode active, but no element button pressed => deactivate
13883 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
13884 last_custom_copy_mode = -1;
13886 // when showing palette on element buttons, change element of button used
13887 if (editor.palette.show_on_element_buttons &&
13888 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
13890 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
13892 id = GADGET_ID_PALETTE;
13897 case GADGET_ID_SCROLL_LEFT:
13898 if (level_xpos >= 0)
13900 if (lev_fieldx < ed_fieldx - 2)
13903 level_xpos -= step;
13904 if (level_xpos < -1)
13907 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
13909 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13911 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
13912 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
13916 case GADGET_ID_SCROLL_RIGHT:
13917 if (level_xpos <= lev_fieldx - ed_fieldx)
13919 if (lev_fieldx < ed_fieldx - 2)
13922 level_xpos += step;
13923 if (level_xpos > lev_fieldx - ed_fieldx + 1)
13924 level_xpos = lev_fieldx - ed_fieldx + 1;
13926 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
13928 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13930 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
13931 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
13935 case GADGET_ID_SCROLL_UP:
13936 if (level_ypos >= 0)
13938 if (lev_fieldy < ed_fieldy - 2)
13941 level_ypos -= step;
13942 if (level_ypos < -1)
13945 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
13947 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13949 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13950 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13954 case GADGET_ID_SCROLL_DOWN:
13955 if (level_ypos <= lev_fieldy - ed_fieldy)
13957 if (lev_fieldy < ed_fieldy - 2)
13960 level_ypos += step;
13961 if (level_ypos > lev_fieldy - ed_fieldy + 1)
13962 level_ypos = lev_fieldy - ed_fieldy + 1;
13964 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
13966 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13968 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13969 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13973 case GADGET_ID_SCROLL_HORIZONTAL:
13974 level_xpos = gi->event.item_position - 1;
13976 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13981 case GADGET_ID_SCROLL_VERTICAL:
13982 level_ypos = gi->event.item_position - 1;
13984 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13989 case GADGET_ID_SCROLL_LIST_UP:
13990 case GADGET_ID_SCROLL_LIST_DOWN:
13991 case GADGET_ID_SCROLL_LIST_VERTICAL:
13992 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
13993 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
13996 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
13997 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
13999 if (element_shift < 0)
14001 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14002 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14004 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14005 GDI_SCROLLBAR_ITEM_POSITION,
14006 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14009 ModifyEditorElementList();
14013 case GADGET_ID_PROPERTIES:
14014 // always switch off element properties when they are already displayed
14015 last_properties_element = new_element;
14016 case GADGET_ID_ELEMENT_LEFT:
14017 case GADGET_ID_ELEMENT_MIDDLE:
14018 case GADGET_ID_ELEMENT_RIGHT:
14019 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
14020 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
14021 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
14024 if (edit_mode != ED_MODE_PROPERTIES)
14026 last_edit_mode = edit_mode;
14028 ChangeEditModeWindow(ED_MODE_PROPERTIES);
14030 last_level_drawing_function = drawing_function;
14031 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14034 else if (properties_element != last_properties_element)
14036 DrawEditModeWindow();
14040 ChangeEditModeWindow(ED_MODE_DRAWING);
14042 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
14047 case GADGET_ID_PALETTE:
14048 if (edit_mode != ED_MODE_PALETTE)
14050 last_edit_mode = edit_mode;
14052 ChangeEditModeWindow(ED_MODE_PALETTE);
14056 ChangeEditModeWindow(last_edit_mode);
14060 case GADGET_ID_WRAP_LEFT:
14061 WrapLevel(-step, 0);
14064 case GADGET_ID_WRAP_RIGHT:
14065 WrapLevel(step, 0);
14068 case GADGET_ID_WRAP_UP:
14069 WrapLevel(0, -step);
14072 case GADGET_ID_WRAP_DOWN:
14073 WrapLevel(0, step);
14076 case GADGET_ID_SINGLE_ITEMS:
14077 case GADGET_ID_CONNECTED_ITEMS:
14078 case GADGET_ID_LINE:
14079 case GADGET_ID_ARC:
14080 case GADGET_ID_TEXT:
14081 case GADGET_ID_RECTANGLE:
14082 case GADGET_ID_FILLED_BOX:
14083 case GADGET_ID_FLOOD_FILL:
14084 case GADGET_ID_GRAB_BRUSH:
14085 case GADGET_ID_PICK_ELEMENT:
14086 if (drawing_function != GADGET_ID_PICK_ELEMENT)
14087 last_drawing_function = drawing_function;
14088 drawing_function = id;
14089 draw_with_brush = FALSE;
14092 case GADGET_ID_RANDOM_PLACEMENT:
14093 RandomPlacement(new_element);
14096 case GADGET_ID_ZOOM:
14097 // zoom level editor tile size in or out (or reset to default size)
14098 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
14099 button == 2 ? ed_tilesize_default :
14100 button == 3 ? ed_tilesize / 2 : ed_tilesize);
14102 // when using touch device, cycle through all zoom tilesizes
14103 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
14104 ed_tilesize = MICRO_TILESIZE;
14106 // limit zoom level by upper and lower bound
14107 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
14109 InitZoomLevelSettings(ed_tilesize);
14111 if (edit_mode == ED_MODE_DRAWING)
14113 DrawDrawingWindow();
14115 // redraw zoom gadget info text
14116 PrintEditorGadgetInfoText(level_editor_gadget[id]);
14119 // save current editor zoom tilesize
14120 SaveSetup_AutoSetup();
14124 case GADGET_ID_CUSTOM_COPY_FROM:
14125 case GADGET_ID_CUSTOM_COPY_TO:
14126 case GADGET_ID_CUSTOM_EXCHANGE:
14127 last_custom_copy_mode = id;
14128 last_drawing_function = drawing_function;
14131 case GADGET_ID_CUSTOM_COPY:
14132 CopyCustomElement(properties_element, -1, id);
14135 case GADGET_ID_CUSTOM_PASTE:
14136 CopyCustomElement(-1, properties_element, id);
14139 case GADGET_ID_UNDO:
14140 if (button < 0) // keep button value (even if modifier keys are pressed)
14142 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
14145 if (button == 1 && undo_buffer_steps == 0)
14147 Request("Undo buffer empty!", REQ_CONFIRM);
14151 else if (button == 2)
14155 else if (button == 3 && redo_buffer_steps == 0)
14157 Request("Redo buffer empty!", REQ_CONFIRM);
14162 if (edit_mode != ED_MODE_DRAWING)
14163 ChangeEditModeWindow(ED_MODE_DRAWING);
14169 undo_buffer_position =
14170 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
14172 undo_buffer_steps--;
14173 redo_buffer_steps++;
14179 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
14181 undo_buffer_steps++;
14182 redo_buffer_steps--;
14185 for (x = 0; x < lev_fieldx; x++)
14186 for (y = 0; y < lev_fieldy; y++)
14187 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
14189 // check if undo operation forces change of border style
14190 CheckLevelBorderElement(FALSE);
14192 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14196 case GADGET_ID_INFO:
14197 if (edit_mode != ED_MODE_INFO)
14199 last_edit_mode = edit_mode;
14201 ChangeEditModeWindow(ED_MODE_INFO);
14205 ChangeEditModeWindow(ED_MODE_DRAWING);
14209 case GADGET_ID_CLEAR:
14210 if (edit_mode != ED_MODE_DRAWING)
14211 ChangeEditModeWindow(ED_MODE_DRAWING);
14213 for (x = 0; x < MAX_LEV_FIELDX; x++)
14214 for (y = 0; y < MAX_LEV_FIELDY; y++)
14215 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
14217 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
14219 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14222 case GADGET_ID_SAVE:
14224 // saving read-only levels into personal level set modifies global vars
14225 // "leveldir_current" and "level_nr"; restore them after saving level
14226 LevelDirTree *leveldir_former = leveldir_current;
14227 int level_nr_former = level_nr;
14228 char *level_filename;
14231 if (leveldir_current->readonly &&
14232 !PrepareSavingIntoPersonalLevelSet())
14235 level_filename = getDefaultLevelFilename(level_nr);
14236 new_level = !fileExists(level_filename);
14239 Request("Save this level and kill the old?", REQ_ASK))
14241 if (leveldir_former->readonly)
14242 ModifyLevelInfoForSavingIntoPersonalLevelSet(leveldir_former->name);
14244 SetAutomaticNumberOfGemsNeeded();
14246 CopyPlayfield(Tile, level.field);
14247 SaveLevel(level_nr);
14249 level.changed = FALSE;
14253 char level_saved_msg[64];
14255 if (leveldir_former->readonly)
14256 sprintf(level_saved_msg,
14257 "Level saved as level %d into personal level set!",
14260 strcpy(level_saved_msg, "Level saved!");
14262 Request(level_saved_msg, REQ_CONFIRM);
14266 // "cd" back to copied-from levelset (in case of saved read-only level)
14267 leveldir_current = leveldir_former;
14268 level_nr = level_nr_former;
14273 case GADGET_ID_TEST:
14274 if (LevelChanged())
14275 level.game_version = GAME_VERSION_ACTUAL;
14277 CopyPlayfield(level.field, TileBackup);
14278 CopyPlayfield(Tile, level.field);
14280 CopyNativeLevel_RND_to_Native(&level);
14282 UnmapLevelEditorGadgets();
14283 UndrawSpecialEditorDoor();
14285 CloseDoor(DOOR_CLOSE_ALL);
14287 // needed before playing if editor playfield area has different size
14288 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
14290 // redraw_mask = REDRAW_ALL;
14292 level_editor_test_game = TRUE;
14294 StartGameActions(FALSE, setup.autorecord, level.random_seed);
14298 case GADGET_ID_EXIT:
14299 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
14303 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
14304 id <= GADGET_ID_ELEMENTLIST_LAST)
14306 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
14308 new_element = editor_elements[element_position + element_shift];
14310 if (IS_EDITOR_CASCADE(new_element))
14314 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
14316 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
14317 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
14319 if (*cascade_element == new_element)
14321 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
14322 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
14324 // update element selection list
14325 ReinitializeElementList();
14326 ModifyEditorElementList();
14328 // update cascading gadget info text
14329 PrintEditorGadgetInfoText(level_editor_gadget[id]);
14331 // save current editor cascading state
14332 SaveSetup_EditorCascade();
14341 if (last_custom_copy_mode != -1)
14343 if (CopyCustomElement(properties_element, new_element,
14344 last_custom_copy_mode))
14346 ClickOnGadget(level_editor_gadget[last_drawing_function],
14349 last_custom_copy_mode = -1;
14355 // change element of button used to show palette
14356 if (editor.palette.show_on_element_buttons)
14357 button = last_button;
14359 PickDrawingElement(button, new_element);
14361 if (!stick_element_properties_window &&
14362 drawing_function != GADGET_ID_PICK_ELEMENT &&
14363 !(GetKeyModState() & KMOD_Control))
14365 properties_element = new_element;
14366 if (edit_mode == ED_MODE_PROPERTIES)
14367 DrawPropertiesWindow();
14370 if (drawing_function == GADGET_ID_PICK_ELEMENT)
14371 ClickOnGadget(level_editor_gadget[last_drawing_function],
14374 if (!use_permanent_palette)
14375 ChangeEditModeWindow(last_edit_mode);
14378 else if (gi->event.type == GD_EVENT_PRESSED)
14379 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
14380 else if (gi->event.type == GD_EVENT_RELEASED)
14381 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
14382 else if (gi->event.type == GD_EVENT_MOVING)
14383 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
14385 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
14391 void HandleLevelEditorKeyInput(Key key)
14393 char letter = getCharFromKey(key);
14395 if (drawing_function == GADGET_ID_TEXT &&
14396 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
14399 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
14400 else if (key == KSYM_Delete || key == KSYM_BackSpace)
14401 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
14402 else if (key == KSYM_Return)
14403 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
14404 else if (key == KSYM_Escape)
14405 DrawLevelText(0, 0, 0, TEXT_END);
14410 int id = GADGET_ID_NONE;
14411 int new_element_shift = element_shift;
14412 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
14413 int button = MB_LEFTBUTTON;
14419 id = GADGET_ID_SCROLL_LEFT;
14422 id = GADGET_ID_SCROLL_RIGHT;
14425 id = GADGET_ID_SCROLL_UP;
14428 id = GADGET_ID_SCROLL_DOWN;
14432 case KSYM_Page_Down:
14433 step *= (key == KSYM_Page_Up ? -1 : +1);
14434 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
14436 if (element_shift < 0)
14438 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14439 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14441 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14442 GDI_SCROLLBAR_ITEM_POSITION,
14443 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14445 ModifyEditorElementList();
14451 element_shift = (key == KSYM_Home ? 0 :
14452 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
14454 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14455 GDI_SCROLLBAR_ITEM_POSITION,
14456 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14458 ModifyEditorElementList();
14465 // this is needed to prevent interference with running "True X-Mouse"
14466 if (GetKeyModStateFromEvents() & KMOD_Control)
14469 // check for last or next editor cascade block in element list
14470 for (i = 0; i < num_editor_elements; i++)
14472 if ((key == KSYM_Insert && i == element_shift) ||
14473 (key == KSYM_Delete && new_element_shift > element_shift))
14476 // jump to next cascade block (or to start of element list)
14477 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
14478 new_element_shift = i;
14481 if (i < num_editor_elements)
14482 element_shift = new_element_shift;
14484 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14485 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14487 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14488 GDI_SCROLLBAR_ITEM_POSITION,
14489 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14491 ModifyEditorElementList();
14496 if (edit_mode == ED_MODE_DRAWING)
14497 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
14498 else if (edit_mode == ED_MODE_INFO)
14499 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
14500 else if (edit_mode == ED_MODE_PROPERTIES)
14501 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
14502 else if (edit_mode == ED_MODE_PALETTE)
14503 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
14504 else // should never happen
14505 ChangeEditModeWindow(ED_MODE_DRAWING);
14513 if (id != GADGET_ID_NONE)
14514 ClickOnGadget(level_editor_gadget[id], button);
14515 else if (letter == '1' || letter == '?')
14516 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
14517 else if (letter == '2')
14518 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
14519 else if (letter == '3')
14520 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
14521 else if (letter == '.')
14522 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
14523 else if (letter == 'U')
14524 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
14525 else if (letter == '-' || key == KSYM_KP_Subtract)
14526 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
14527 else if (letter == '0' || key == KSYM_KP_0)
14528 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
14529 else if (letter == '+' || key == KSYM_KP_Add ||
14530 letter == '=') // ("Shift-=" is "+" on US keyboards)
14531 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
14532 else if (key == KSYM_Return ||
14533 key == KSYM_space ||
14534 key == setup.shortcut.toggle_pause)
14535 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
14537 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
14538 if (letter && letter == controlbutton_info[i].shortcut)
14539 if (!anyTextGadgetActive())
14540 ClickOnGadget(level_editor_gadget[i], button);
14543 static void HandleLevelEditorIdle_Properties(void)
14545 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
14546 int x = editor.settings.element_graphic.x + element_border;
14547 int y = editor.settings.element_graphic.y + element_border;
14548 static DelayCounter action_delay = { 0 };
14551 action_delay.value = GameFrameDelay;
14553 if (!DelayReached(&action_delay))
14556 for (i = 0; i < ED_NUM_SELECTBOX; i++)
14558 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
14560 if (gi->mapped && gi->active && gi->selectbox.open)
14564 DrawEditorElementAnimation(SX + x, SY + y);
14566 redraw_mask |= REDRAW_FIELD;
14568 FrameCounter++; // increase animation frame counter
14571 static void HandleLevelEditorIdle_Drawing(void)
14573 static boolean last_highlighted = FALSE;
14574 boolean highlighted = (GetKeyModState() & KMOD_Alt);
14576 if (highlighted != last_highlighted)
14578 DrawAreaElementHighlight(highlighted);
14580 last_highlighted = highlighted;
14582 redraw_mask |= REDRAW_FIELD;
14586 void HandleLevelEditorIdle(void)
14588 if (edit_mode == ED_MODE_PROPERTIES)
14589 HandleLevelEditorIdle_Properties();
14590 else if (edit_mode == ED_MODE_DRAWING)
14591 HandleLevelEditorIdle_Drawing();
14594 static void ClearEditorGadgetInfoText(void)
14596 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
14599 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
14601 char infotext[MAX_OUTPUT_LINESIZE + 1];
14602 int max_infotext_len = getMaxInfoTextLength();
14604 if (gi == NULL || strlen(gi->info_text) == 0)
14607 strncpy(infotext, gi->info_text, max_infotext_len);
14608 infotext[max_infotext_len] = '\0';
14610 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
14612 int key = controlbutton_info[gi->custom_id].shortcut;
14616 char shortcut[MAX_OUTPUT_LINESIZE + 1];
14618 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
14619 sprintf(shortcut, " ('.' or '%c')", key);
14620 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
14621 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
14622 else if (gi->custom_id == GADGET_ID_TEST)
14623 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
14624 else if (gi->custom_id == GADGET_ID_UNDO)
14625 sprintf(shortcut, " ('%c/Shift-U')", key);
14626 else if (gi->custom_id == GADGET_ID_ZOOM)
14627 sprintf(shortcut, " ('%c', '0', '-')", key);
14629 sprintf(shortcut, " ('%s%c')",
14630 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
14632 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
14633 strcat(infotext, shortcut);
14637 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
14640 void HandleEditorGadgetInfoText(void *ptr)
14642 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
14644 if (game_status != GAME_MODE_EDITOR)
14647 ClearEditorGadgetInfoText();
14649 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
14652 // misuse this function to delete brush cursor, if needed
14653 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
14654 DeleteBrushFromCursor();
14656 PrintEditorGadgetInfoText(gi);
14659 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
14661 int id = gi->custom_id;
14662 int type_id = gi->custom_type_id;
14663 int sx = gi->event.x;
14664 int sy = gi->event.y;
14665 int lx = sx + level_xpos;
14666 int ly = sy + level_ypos;
14667 int min_sx = 0, min_sy = 0;
14668 int max_sx = gi->drawing.area_xsize - 1;
14669 int max_sy = gi->drawing.area_ysize - 1;
14670 int actual_drawing_function = drawing_function;
14671 int max_infotext_len = getMaxInfoTextLength();
14672 char infotext[MAX_OUTPUT_LINESIZE + 1];
14674 infotext[0] = '\0'; // start with empty info text
14676 // pressed Control key: simulate picking element
14677 if (GetKeyModState() & KMOD_Control)
14678 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14680 ClearEditorGadgetInfoText();
14682 if (gi->event.type == GD_EVENT_INFO_LEAVING)
14685 // make sure to stay inside drawing area boundaries
14686 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14687 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14689 if (id == GADGET_ID_DRAWING_LEVEL)
14693 int min_lx = 0, min_ly = 0;
14694 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14696 // get positions inside level field
14697 lx = sx + level_xpos;
14698 ly = sy + level_ypos;
14700 // make sure to stay inside level field boundaries
14701 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14702 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14704 // correct drawing area positions accordingly
14705 sx = lx - level_xpos;
14706 sy = ly - level_ypos;
14709 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
14711 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
14713 static int start_lx = 0;
14714 static int start_ly = 0;
14717 if (gi->event.type == GD_EVENT_PRESSED)
14723 switch (actual_drawing_function)
14725 case GADGET_ID_SINGLE_ITEMS:
14726 text = "Drawing single items";
14728 case GADGET_ID_CONNECTED_ITEMS:
14729 text = "Drawing connected items";
14731 case GADGET_ID_LINE:
14732 text = "Drawing line";
14734 case GADGET_ID_ARC:
14735 text = "Drawing arc";
14737 case GADGET_ID_TEXT:
14738 text = "Setting text cursor";
14740 case GADGET_ID_RECTANGLE:
14741 text = "Drawing rectangle";
14743 case GADGET_ID_FILLED_BOX:
14744 text = "Drawing filled box";
14746 case GADGET_ID_FLOOD_FILL:
14747 text = "Flood fill";
14749 case GADGET_ID_GRAB_BRUSH:
14750 text = "Grabbing brush";
14752 case GADGET_ID_PICK_ELEMENT:
14753 text = "Picking element";
14757 text = "Drawing position";
14761 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14762 sprintf(infotext, "%s: %d, %d", text, lx, ly);
14764 sprintf(infotext, "%s: %d, %d", text,
14765 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
14767 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14768 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
14770 sprintf(infotext, "Level position: %d, %d", lx, ly);
14773 // misuse this function to draw brush cursor, if needed
14774 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
14776 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
14777 CopyBrushToCursor(sx, sy);
14779 DeleteBrushFromCursor();
14782 if (!draw_with_brush)
14783 UpdateBrushPosition(sx, sy);
14785 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14787 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14788 int element = drawingarea_info[type_id].value[pos];
14790 strncpy(infotext, getElementInfoText(element), max_infotext_len);
14794 if (id == GADGET_ID_CUSTOM_CONTENT)
14795 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
14796 else if (id == GADGET_ID_GROUP_CONTENT)
14797 sprintf(infotext, "group element position: %d", sx + 1);
14798 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
14799 id <= GADGET_ID_YAMYAM_CONTENT_7)
14800 sprintf(infotext, "content area %d position: %d, %d",
14801 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
14802 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
14803 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
14804 sprintf(infotext, "content area %d position: %d, %d",
14805 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
14806 else if (id == GADGET_ID_ANDROID_CONTENT)
14807 sprintf(infotext, "android element position: %d", sx + 1);
14808 else if (drawingarea_info[type_id].infotext != NULL)
14809 strcpy(infotext, drawingarea_info[type_id].infotext);
14812 infotext[max_infotext_len] = '\0';
14814 if (strlen(infotext) > 0)
14815 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
14818 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
14819 boolean quick_quit)
14821 if (!ask_if_level_has_changed ||
14823 Request("Level has changed! Exit without saving?",
14824 REQ_ASK | REQ_STAY_OPEN))
14826 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
14827 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
14829 // draw normal door
14830 UndrawSpecialEditorDoor();
14832 // use door animation if door 1 viewport is unchanged and contains toolbox
14833 if (useEditorDoorAnimation())
14834 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
14836 // close editor doors if viewport definition is the same as in main menu
14837 if (vp_door_1->x == DX &&
14838 vp_door_1->y == DY &&
14839 vp_door_1->width == DXSIZE &&
14840 vp_door_1->height == DYSIZE &&
14841 vp_door_2->x == VX &&
14842 vp_door_2->y == VY &&
14843 vp_door_2->width == VXSIZE &&
14844 vp_door_2->height == VYSIZE)
14845 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
14847 SetDoorState(DOOR_CLOSE_2);
14852 FadeSkipNextFadeIn();
14854 SetGameStatus(GAME_MODE_MAIN);
14860 if (!global.use_envelope_request)
14862 CloseDoor(DOOR_CLOSE_1);
14863 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);