1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // http://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_BUTTONS_HORIZ (editor.palette.cols)
69 #define ED_ELEMENTLIST_BUTTONS_VERT (editor.palette.rows)
70 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
71 ED_ELEMENTLIST_BUTTONS_VERT)
74 #define ED_GADGET_NORMAL_DISTANCE (editor.gadget.normal_spacing)
75 #define ED_GADGET_SMALL_DISTANCE (editor.gadget.small_spacing)
76 #define ED_GADGET_TINY_DISTANCE (editor.gadget.tiny_spacing)
77 #define ED_GADGET_LINE_DISTANCE (editor.gadget.line_spacing)
78 #define ED_GADGET_TEXT_DISTANCE (editor.gadget.text_spacing)
79 #define ED_TAB_BAR_HEIGHT (editor.gadget.separator_line.height)
80 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
81 ED_DRAWINGAREA_BORDER_SIZE)
82 #define ED_GADGET_SPACE_DISTANCE (getFontWidth(FONT_TEXT_1))
84 // values for drawingarea gadgets
85 #define IMG_BORDER_1 IMG_EDITOR_ELEMENT_BORDER
86 #define IMG_BORDER_2 IMG_EDITOR_ELEMENT_BORDER_INPUT
87 #define ED_ELEMENT_BORDER (graphic_info[IMG_BORDER_1].border_size)
88 #define ED_DRAWINGAREA_BORDER_SIZE (graphic_info[IMG_BORDER_2].border_size)
89 #define ED_DRAWINGAREA_TILE_SIZE (editor.drawingarea.tile_size)
91 // values for checkbutton gadgets
92 #define ED_CHECKBUTTON_XSIZE (graphic_info[IMG_EDITOR_CHECKBOX].width)
93 #define ED_CHECKBUTTON_YSIZE (graphic_info[IMG_EDITOR_CHECKBOX].height)
95 #define ED_TABBUTTON_XSIZE (graphic_info[IMG_EDITOR_TABBUTTON].width)
96 #define ED_TABBUTTON_YSIZE (graphic_info[IMG_EDITOR_TABBUTTON].height)
98 #define ED_SETTINGS_LEVEL_TABS_X (editor.settings.tabs.x)
99 #define ED_SETTINGS_LEVEL_TABS_Y (editor.settings.tabs.y)
100 #define ED_SETTINGS_ELEMENT_TABS_X (editor.settings.tabs.x)
101 #define ED_SETTINGS_ELEMENT_TABS_Y (editor.settings.tabs.y + \
102 editor.settings.tabs.yoffset2)
104 #define ED_SETTINGS_TABS_XOFFSET (editor.settings.tabs.draw_xoffset)
105 #define ED_SETTINGS_TABS_YOFFSET (editor.settings.tabs.draw_yoffset)
107 #define ED_LEVEL_TABS_XSTART (ED_SETTINGS_LEVEL_TABS_X)
108 #define ED_LEVEL_TABS_YSTART (ED_SETTINGS_LEVEL_TABS_Y)
109 #define ED_LEVEL_SETTINGS_XSTART (ED_SETTINGS_LEVEL_TABS_X + \
110 ED_SETTINGS_TABS_XOFFSET)
111 #define ED_LEVEL_SETTINGS_YSTART (ED_SETTINGS_LEVEL_TABS_Y + \
112 ED_TABBUTTON_YSIZE + \
113 ED_GADGET_TINY_DISTANCE + \
114 ED_TAB_BAR_HEIGHT + \
115 ED_SETTINGS_TABS_YOFFSET + \
116 getFontHeight(FONT_TEXT_1) + \
117 ED_GADGET_TEXT_DISTANCE)
118 #define ED_ELEMENT_TABS_XSTART (ED_SETTINGS_ELEMENT_TABS_X)
119 #define ED_ELEMENT_TABS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y)
120 #define ED_ELEMENT_SETTINGS_XSTART (ED_SETTINGS_ELEMENT_TABS_X + \
121 ED_SETTINGS_TABS_XOFFSET)
122 #define ED_ELEMENT_SETTINGS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y + \
123 ED_TABBUTTON_YSIZE + \
124 ED_GADGET_TINY_DISTANCE + \
125 ED_TAB_BAR_HEIGHT + \
126 ED_SETTINGS_TABS_YOFFSET)
128 #define ED_SETTINGS_XOFFSET (ED_CHECKBUTTON_XSIZE + \
129 ED_GADGET_TEXT_DISTANCE)
130 #define ED_SETTINGS_YOFFSET (ED_CHECKBUTTON_YSIZE + \
131 ED_GADGET_LINE_DISTANCE)
133 #define ED_POS_RANGE (10000)
134 #define ED_POS_LEVEL_TABS_FIRST (1 * ED_POS_RANGE)
135 #define ED_POS_LEVEL_TABS_LAST (2 * ED_POS_RANGE - 1)
136 #define ED_POS_LEVEL_SETTINGS_FIRST (2 * ED_POS_RANGE)
137 #define ED_POS_LEVEL_SETTINGS_LAST (3 * ED_POS_RANGE - 1)
138 #define ED_POS_ELEMENT_TABS_FIRST (3 * ED_POS_RANGE)
139 #define ED_POS_ELEMENT_TABS_LAST (4 * ED_POS_RANGE - 1)
140 #define ED_POS_ELEMENT_SETTINGS_FIRST (4 * ED_POS_RANGE)
141 #define ED_POS_ELEMENT_SETTINGS_LAST (5 * ED_POS_RANGE - 1)
143 #define ED_LEVEL_TABS_XPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
144 #define ED_LEVEL_TABS_YPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
146 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
147 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
149 #define ED_ELEMENT_TABS_XPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
150 #define ED_ELEMENT_TABS_YPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
152 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
153 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
155 #define IS_POS_LEVEL_TABS(n) ((n) >= ED_POS_LEVEL_TABS_FIRST && \
156 (n) <= ED_POS_LEVEL_TABS_LAST)
157 #define IS_POS_LEVEL_SETTINGS(n) ((n) >= ED_POS_LEVEL_SETTINGS_FIRST && \
158 (n) <= ED_POS_LEVEL_SETTINGS_LAST)
159 #define IS_POS_ELEMENT_TABS(n) ((n) >= ED_POS_ELEMENT_TABS_FIRST && \
160 (n) <= ED_POS_ELEMENT_TABS_LAST)
161 #define IS_POS_ELEMENT_SETTINGS(n) ((n) >= ED_POS_ELEMENT_SETTINGS_FIRST && \
162 (n) <= ED_POS_ELEMENT_SETTINGS_LAST)
164 #define ED_LEVEL_TABS_LINE(n) ((n) - ED_POS_LEVEL_TABS_FIRST)
165 #define ED_LEVEL_SETTINGS_LINE(n) ((n) - ED_POS_LEVEL_SETTINGS_FIRST)
166 #define ED_ELEMENT_TABS_LINE(n) ((n) - ED_POS_ELEMENT_TABS_FIRST)
167 #define ED_ELEMENT_SETTINGS_LINE(n) ((n) - ED_POS_ELEMENT_SETTINGS_FIRST)
169 #define ED_LEVEL_TABS_X(n) (ED_LEVEL_TABS_XSTART + \
170 (n) * ED_SETTINGS_TABS_XOFFSET)
171 #define ED_LEVEL_TABS_Y(n) (ED_LEVEL_TABS_YSTART + \
172 (n) * ED_SETTINGS_TABS_YOFFSET)
174 #define ED_LEVEL_SETTINGS_X(n) (ED_LEVEL_SETTINGS_XSTART + \
175 (n) * ED_SETTINGS_XOFFSET)
176 #define ED_LEVEL_SETTINGS_Y(n) (ED_LEVEL_SETTINGS_YSTART + \
177 (n) * ED_SETTINGS_YOFFSET)
179 #define ED_ELEMENT_TABS_X(n) (ED_ELEMENT_TABS_XSTART + \
180 (n) * ED_SETTINGS_TABS_XOFFSET)
181 #define ED_ELEMENT_TABS_Y(n) (ED_ELEMENT_TABS_YSTART + \
182 (n) * ED_SETTINGS_TABS_YOFFSET)
184 #define ED_ELEMENT_SETTINGS_X(n) (ED_ELEMENT_SETTINGS_XSTART + \
185 (n) * ED_SETTINGS_XOFFSET)
186 #define ED_ELEMENT_SETTINGS_Y(n) (ED_ELEMENT_SETTINGS_YSTART + \
187 (n) * ED_SETTINGS_YOFFSET)
189 #define ED_POS_TO_LEVEL_TABS_X(n) \
190 (ED_LEVEL_TABS_X(ED_LEVEL_TABS_LINE(n)))
191 #define ED_POS_TO_LEVEL_TABS_Y(n) \
192 (ED_LEVEL_TABS_Y(ED_LEVEL_TABS_LINE(n)))
194 #define ED_POS_TO_LEVEL_SETTINGS_X(n) \
195 (ED_LEVEL_SETTINGS_X(ED_LEVEL_SETTINGS_LINE(n)))
196 #define ED_POS_TO_LEVEL_SETTINGS_Y(n) \
197 (ED_LEVEL_SETTINGS_Y(ED_LEVEL_SETTINGS_LINE(n)))
199 #define ED_POS_TO_ELEMENT_TABS_X(n) \
200 (ED_ELEMENT_TABS_X(ED_ELEMENT_TABS_LINE(n)))
201 #define ED_POS_TO_ELEMENT_TABS_Y(n) \
202 (ED_ELEMENT_TABS_Y(ED_ELEMENT_TABS_LINE(n)))
204 #define ED_POS_TO_ELEMENT_SETTINGS_X(n) \
205 (ED_ELEMENT_SETTINGS_X(ED_ELEMENT_SETTINGS_LINE(n)))
206 #define ED_POS_TO_ELEMENT_SETTINGS_Y(n) \
207 (ED_ELEMENT_SETTINGS_Y(ED_ELEMENT_SETTINGS_LINE(n)))
209 #define ED_SETTINGS_X(n) (IS_POS_LEVEL_TABS(n) ? \
210 ED_POS_TO_LEVEL_TABS_X(n) : \
211 IS_POS_LEVEL_SETTINGS(n) ? \
212 ED_POS_TO_LEVEL_SETTINGS_X(n) : \
213 IS_POS_ELEMENT_TABS(n) ? \
214 ED_POS_TO_ELEMENT_TABS_X(n) : \
215 IS_POS_ELEMENT_SETTINGS(n) ? \
216 ED_POS_TO_ELEMENT_SETTINGS_X(n) : (n))
217 #define ED_SETTINGS_Y(n) (IS_POS_LEVEL_TABS(n) ? \
218 ED_POS_TO_LEVEL_TABS_Y(n) : \
219 IS_POS_LEVEL_SETTINGS(n) ? \
220 ED_POS_TO_LEVEL_SETTINGS_Y(n) : \
221 IS_POS_ELEMENT_TABS(n) ? \
222 ED_POS_TO_ELEMENT_TABS_Y(n) : \
223 IS_POS_ELEMENT_SETTINGS(n) ? \
224 ED_POS_TO_ELEMENT_SETTINGS_Y(n) : (n))
226 #define ED_SETTINGS_XOFF(n) (5 * ((n) % 4) * \
227 ED_DRAWINGAREA_TILE_SIZE)
228 #define ED_SETTINGS_YOFF(n) (5 * ((n) / 4) * \
229 ED_DRAWINGAREA_TILE_SIZE)
231 #define ED_AREA_XOFFSET_1(n) ((n) != 0 ? \
232 ED_DRAWINGAREA_BORDER_SIZE : 0)
233 #define ED_AREA_YOFFSET_1(n) ((n) != 0 ? \
234 (ED_CHECKBUTTON_YSIZE - \
235 ED_DRAWINGAREA_TILE_SIZE) / 2 : 0)
237 #define ED_AREA_XOFFSET_2(n) (0)
238 #define ED_AREA_YOFFSET_2(n) ((n) == 3 ? \
239 ((n) - 1) * ED_DRAWINGAREA_TILE_SIZE / 2 : 0)
241 #define ED_AREA_SETTINGS_X(i) (ED_SETTINGS_X((i).x) + \
242 ED_SETTINGS_XOFF((i).xoffset) + \
243 ED_AREA_XOFFSET_1((i).x) - \
244 ED_AREA_XOFFSET_2((i).area_xsize))
245 #define ED_AREA_SETTINGS_Y(i) (ED_SETTINGS_Y((i).y) + \
246 ED_SETTINGS_YOFF((i).yoffset) + \
247 ED_AREA_YOFFSET_1((i).y) - \
248 ED_AREA_YOFFSET_2((i).area_ysize))
250 // values for element content drawing areas
251 #define ED_AREA_1X1_LSETTINGS_XPOS(n) ED_LEVEL_SETTINGS_XPOS(n)
252 #define ED_AREA_1X1_LSETTINGS_YPOS(n) ED_LEVEL_SETTINGS_YPOS(n)
253 #define ED_AREA_1X1_LSETTINGS_XOFF (0)
254 #define ED_AREA_1X1_LSETTINGS_YOFF (0)
256 #define ED_AREA_1X1_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
257 #define ED_AREA_1X1_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
258 #define ED_AREA_1X1_SETTINGS_XOFF (0)
259 #define ED_AREA_1X1_SETTINGS_YOFF (0)
261 #define ED_AREA_3X3_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
262 #define ED_AREA_3X3_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
263 #define ED_AREA_3X3_SETTINGS_XOFF (0)
264 #define ED_AREA_3X3_SETTINGS_YOFF (0)
267 #define ED_AREA_ELEMENT_CONTENT_XOFF(n) (n)
268 #define ED_AREA_ELEMENT_CONTENT_YOFF(n) (n)
271 #define ED_XPOS_YAM 0
272 #define ED_YPOS_YAM 5
273 #define ED_AREA_YAMYAM_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_YAM)
274 #define ED_AREA_YAMYAM_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_YAM)
275 #define ED_AREA_YAMYAM_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
276 #define ED_AREA_YAMYAM_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
277 #define ED_AREA_YAMYAM_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_YAM) + \
279 #define ED_AREA_YAMYAM_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_YAM) + \
280 ED_SETTINGS_YOFF(n) + \
281 ED_AREA_YOFFSET_1(ED_YPOS_YAM) - \
282 ED_AREA_YOFFSET_2(3))
284 // magic ball content
285 #define ED_XPOS_BALL 0
286 #define ED_YPOS_BALL 6
287 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_BALL)
288 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_BALL)
289 #define ED_AREA_MAGIC_BALL_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
290 #define ED_AREA_MAGIC_BALL_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
291 #define ED_AREA_MAGIC_BALL_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_BALL) + \
293 #define ED_AREA_MAGIC_BALL_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_BALL) + \
294 ED_SETTINGS_YOFF(n) + \
295 ED_AREA_YOFFSET_1(ED_YPOS_BALL) - \
296 ED_AREA_YOFFSET_2(3))
298 // values for scrolling gadgets for drawing area
299 #define ED_SCROLLBUTTON_XSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].width)
300 #define ED_SCROLLBUTTON_YSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].height)
302 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
303 #define ED_SCROLL_UP_YPOS (0)
304 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
305 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
306 #define ED_SCROLL_LEFT_XPOS (0)
307 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
308 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
309 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
310 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
311 ED_SCROLLBUTTON_XSIZE)
312 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
313 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
314 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
315 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
316 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
317 ED_SCROLLBUTTON_YSIZE)
318 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
319 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
321 // values for scrolling gadgets for element list
322 #define ED_SCROLLBUTTON2_XSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
323 #define ED_SCROLLBUTTON2_YSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
325 #define ED_SCROLL2_UP_XPOS (ED_ELEMENTLIST_XPOS + \
326 ED_ELEMENTLIST_BUTTONS_HORIZ * \
327 ED_ELEMENTLIST_XSIZE)
328 #define ED_SCROLL2_UP_YPOS ED_ELEMENTLIST_YPOS
329 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
330 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
331 ED_ELEMENTLIST_BUTTONS_VERT * \
332 ED_ELEMENTLIST_YSIZE - \
333 ED_SCROLLBUTTON2_YSIZE)
334 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
335 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
336 ED_SCROLLBUTTON2_YSIZE)
337 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
338 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
339 ED_ELEMENTLIST_YSIZE - \
340 2 * ED_SCROLLBUTTON2_YSIZE)
342 // values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText()
343 #define INFOTEXT_FONT FONT_TEXT_2
344 #define INFOTEXT_XSIZE SXSIZE
345 #define INFOTEXT_YSIZE getFontHeight(INFOTEXT_FONT)
346 #define INFOTEXT_YSIZE_FULL (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE)
347 #define INFOTEXT_X (editor.settings.tooltip.x)
348 #define INFOTEXT_Y (editor.settings.tooltip.y)
349 #define INFOTEXT_XY_REDEFINED (INFOTEXT_X != -1 || INFOTEXT_Y != -1)
350 #define INFOTEXT_XPOS SX + (INFOTEXT_XY_REDEFINED ? INFOTEXT_X : 0)
351 #define INFOTEXT_YPOS SY + (INFOTEXT_XY_REDEFINED ? INFOTEXT_Y : \
352 SYSIZE - INFOTEXT_YSIZE)
355 // ----------------------------------------------------------------------------
356 // editor gadget definitions
357 // ----------------------------------------------------------------------------
363 // drawing toolbox buttons
365 GADGET_ID_SINGLE_ITEMS,
366 GADGET_ID_CONNECTED_ITEMS,
370 GADGET_ID_FILLED_BOX,
373 GADGET_ID_FLOOD_FILL,
376 GADGET_ID_WRAP_RIGHT,
377 GADGET_ID_RANDOM_PLACEMENT,
378 GADGET_ID_GRAB_BRUSH,
380 GADGET_ID_PICK_ELEMENT,
389 GADGET_ID_CUSTOM_COPY_FROM,
390 GADGET_ID_CUSTOM_COPY_TO,
391 GADGET_ID_CUSTOM_EXCHANGE,
392 GADGET_ID_CUSTOM_COPY,
393 GADGET_ID_CUSTOM_PASTE,
395 GADGET_ID_PROPERTIES,
396 GADGET_ID_ELEMENT_LEFT,
397 GADGET_ID_ELEMENT_MIDDLE,
398 GADGET_ID_ELEMENT_RIGHT,
401 // counter gadget identifiers
403 GADGET_ID_SELECT_LEVEL_DOWN,
404 GADGET_ID_SELECT_LEVEL_TEXT,
405 GADGET_ID_SELECT_LEVEL_UP,
406 GADGET_ID_LEVEL_XSIZE_DOWN,
407 GADGET_ID_LEVEL_XSIZE_TEXT,
408 GADGET_ID_LEVEL_XSIZE_UP,
409 GADGET_ID_LEVEL_YSIZE_DOWN,
410 GADGET_ID_LEVEL_YSIZE_TEXT,
411 GADGET_ID_LEVEL_YSIZE_UP,
412 GADGET_ID_LEVEL_RANDOM_DOWN,
413 GADGET_ID_LEVEL_RANDOM_TEXT,
414 GADGET_ID_LEVEL_RANDOM_UP,
415 GADGET_ID_LEVEL_GEMSLIMIT_DOWN,
416 GADGET_ID_LEVEL_GEMSLIMIT_TEXT,
417 GADGET_ID_LEVEL_GEMSLIMIT_UP,
418 GADGET_ID_LEVEL_TIMELIMIT_DOWN,
419 GADGET_ID_LEVEL_TIMELIMIT_TEXT,
420 GADGET_ID_LEVEL_TIMELIMIT_UP,
421 GADGET_ID_LEVEL_TIMESCORE_DOWN,
422 GADGET_ID_LEVEL_TIMESCORE_TEXT,
423 GADGET_ID_LEVEL_TIMESCORE_UP,
424 GADGET_ID_LEVEL_RANDOM_SEED_DOWN,
425 GADGET_ID_LEVEL_RANDOM_SEED_TEXT,
426 GADGET_ID_LEVEL_RANDOM_SEED_UP,
427 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN,
428 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT,
429 GADGET_ID_LEVELSET_NUM_LEVELS_UP,
430 GADGET_ID_ELEMENT_VALUE1_DOWN,
431 GADGET_ID_ELEMENT_VALUE1_TEXT,
432 GADGET_ID_ELEMENT_VALUE1_UP,
433 GADGET_ID_ELEMENT_VALUE2_DOWN,
434 GADGET_ID_ELEMENT_VALUE2_TEXT,
435 GADGET_ID_ELEMENT_VALUE2_UP,
436 GADGET_ID_ELEMENT_VALUE3_DOWN,
437 GADGET_ID_ELEMENT_VALUE3_TEXT,
438 GADGET_ID_ELEMENT_VALUE3_UP,
439 GADGET_ID_ELEMENT_VALUE4_DOWN,
440 GADGET_ID_ELEMENT_VALUE4_TEXT,
441 GADGET_ID_ELEMENT_VALUE4_UP,
442 GADGET_ID_YAMYAM_CONTENT_DOWN,
443 GADGET_ID_YAMYAM_CONTENT_TEXT,
444 GADGET_ID_YAMYAM_CONTENT_UP,
445 GADGET_ID_BALL_CONTENT_DOWN,
446 GADGET_ID_BALL_CONTENT_TEXT,
447 GADGET_ID_BALL_CONTENT_UP,
448 GADGET_ID_ANDROID_CONTENT_DOWN,
449 GADGET_ID_ANDROID_CONTENT_TEXT,
450 GADGET_ID_ANDROID_CONTENT_UP,
451 GADGET_ID_ENVELOPE_XSIZE_DOWN,
452 GADGET_ID_ENVELOPE_XSIZE_TEXT,
453 GADGET_ID_ENVELOPE_XSIZE_UP,
454 GADGET_ID_ENVELOPE_YSIZE_DOWN,
455 GADGET_ID_ENVELOPE_YSIZE_TEXT,
456 GADGET_ID_ENVELOPE_YSIZE_UP,
457 GADGET_ID_INVENTORY_SIZE_DOWN,
458 GADGET_ID_INVENTORY_SIZE_TEXT,
459 GADGET_ID_INVENTORY_SIZE_UP,
460 GADGET_ID_CUSTOM_SCORE_DOWN,
461 GADGET_ID_CUSTOM_SCORE_TEXT,
462 GADGET_ID_CUSTOM_SCORE_UP,
463 GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
464 GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
465 GADGET_ID_CUSTOM_GEMCOUNT_UP,
466 GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
467 GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
468 GADGET_ID_CUSTOM_VALUE_FIX_UP,
469 GADGET_ID_CUSTOM_VALUE_RND_DOWN,
470 GADGET_ID_CUSTOM_VALUE_RND_TEXT,
471 GADGET_ID_CUSTOM_VALUE_RND_UP,
472 GADGET_ID_PUSH_DELAY_FIX_DOWN,
473 GADGET_ID_PUSH_DELAY_FIX_TEXT,
474 GADGET_ID_PUSH_DELAY_FIX_UP,
475 GADGET_ID_PUSH_DELAY_RND_DOWN,
476 GADGET_ID_PUSH_DELAY_RND_TEXT,
477 GADGET_ID_PUSH_DELAY_RND_UP,
478 GADGET_ID_DROP_DELAY_FIX_DOWN,
479 GADGET_ID_DROP_DELAY_FIX_TEXT,
480 GADGET_ID_DROP_DELAY_FIX_UP,
481 GADGET_ID_DROP_DELAY_RND_DOWN,
482 GADGET_ID_DROP_DELAY_RND_TEXT,
483 GADGET_ID_DROP_DELAY_RND_UP,
484 GADGET_ID_MOVE_DELAY_FIX_DOWN,
485 GADGET_ID_MOVE_DELAY_FIX_TEXT,
486 GADGET_ID_MOVE_DELAY_FIX_UP,
487 GADGET_ID_MOVE_DELAY_RND_DOWN,
488 GADGET_ID_MOVE_DELAY_RND_TEXT,
489 GADGET_ID_MOVE_DELAY_RND_UP,
490 GADGET_ID_EXPLOSION_DELAY_DOWN,
491 GADGET_ID_EXPLOSION_DELAY_TEXT,
492 GADGET_ID_EXPLOSION_DELAY_UP,
493 GADGET_ID_IGNITION_DELAY_DOWN,
494 GADGET_ID_IGNITION_DELAY_TEXT,
495 GADGET_ID_IGNITION_DELAY_UP,
496 GADGET_ID_CHANGE_DELAY_FIX_DOWN,
497 GADGET_ID_CHANGE_DELAY_FIX_TEXT,
498 GADGET_ID_CHANGE_DELAY_FIX_UP,
499 GADGET_ID_CHANGE_DELAY_RND_DOWN,
500 GADGET_ID_CHANGE_DELAY_RND_TEXT,
501 GADGET_ID_CHANGE_DELAY_RND_UP,
502 GADGET_ID_CHANGE_CONT_RND_DOWN,
503 GADGET_ID_CHANGE_CONT_RND_TEXT,
504 GADGET_ID_CHANGE_CONT_RND_UP,
505 GADGET_ID_GROUP_CONTENT_DOWN,
506 GADGET_ID_GROUP_CONTENT_TEXT,
507 GADGET_ID_GROUP_CONTENT_UP,
509 // drawing area identifiers
511 GADGET_ID_DRAWING_LEVEL,
512 GADGET_ID_YAMYAM_CONTENT_0,
513 GADGET_ID_YAMYAM_CONTENT_1,
514 GADGET_ID_YAMYAM_CONTENT_2,
515 GADGET_ID_YAMYAM_CONTENT_3,
516 GADGET_ID_YAMYAM_CONTENT_4,
517 GADGET_ID_YAMYAM_CONTENT_5,
518 GADGET_ID_YAMYAM_CONTENT_6,
519 GADGET_ID_YAMYAM_CONTENT_7,
520 GADGET_ID_MAGIC_BALL_CONTENT_0,
521 GADGET_ID_MAGIC_BALL_CONTENT_1,
522 GADGET_ID_MAGIC_BALL_CONTENT_2,
523 GADGET_ID_MAGIC_BALL_CONTENT_3,
524 GADGET_ID_MAGIC_BALL_CONTENT_4,
525 GADGET_ID_MAGIC_BALL_CONTENT_5,
526 GADGET_ID_MAGIC_BALL_CONTENT_6,
527 GADGET_ID_MAGIC_BALL_CONTENT_7,
528 GADGET_ID_ANDROID_CONTENT,
529 GADGET_ID_AMOEBA_CONTENT,
530 GADGET_ID_START_ELEMENT,
531 GADGET_ID_ARTWORK_ELEMENT,
532 GADGET_ID_EXPLOSION_ELEMENT,
533 GADGET_ID_INVENTORY_CONTENT,
534 GADGET_ID_CUSTOM_GRAPHIC,
535 GADGET_ID_CUSTOM_CONTENT,
536 GADGET_ID_CUSTOM_MOVE_ENTER,
537 GADGET_ID_CUSTOM_MOVE_LEAVE,
538 GADGET_ID_CUSTOM_CHANGE_TARGET,
539 GADGET_ID_CUSTOM_CHANGE_CONTENT,
540 GADGET_ID_CUSTOM_CHANGE_TRIGGER,
541 GADGET_ID_CUSTOM_CHANGE_ACTION,
542 GADGET_ID_GROUP_CONTENT,
543 GADGET_ID_RANDOM_BACKGROUND,
545 // text input identifiers
547 GADGET_ID_LEVEL_NAME,
548 GADGET_ID_LEVEL_AUTHOR,
549 GADGET_ID_LEVELSET_NAME,
550 GADGET_ID_LEVELSET_AUTHOR,
551 GADGET_ID_ELEMENT_NAME,
553 // text area identifiers
555 GADGET_ID_ENVELOPE_INFO,
557 // selectbox identifiers
559 GADGET_ID_TIME_OR_STEPS,
560 GADGET_ID_GAME_ENGINE_TYPE,
561 GADGET_ID_LEVELSET_SAVE_MODE,
562 GADGET_ID_WIND_DIRECTION,
563 GADGET_ID_PLAYER_SPEED,
564 GADGET_ID_CUSTOM_WALK_TO_ACTION,
565 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
566 GADGET_ID_CUSTOM_DEADLINESS,
567 GADGET_ID_CUSTOM_MOVE_PATTERN,
568 GADGET_ID_CUSTOM_MOVE_DIRECTION,
569 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
570 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
571 GADGET_ID_CUSTOM_SMASH_TARGETS,
572 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
573 GADGET_ID_CUSTOM_ACCESS_TYPE,
574 GADGET_ID_CUSTOM_ACCESS_LAYER,
575 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
576 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
577 GADGET_ID_CHANGE_TIME_UNITS,
578 GADGET_ID_CHANGE_DIRECT_ACTION,
579 GADGET_ID_CHANGE_OTHER_ACTION,
580 GADGET_ID_CHANGE_SIDE,
581 GADGET_ID_CHANGE_PLAYER,
582 GADGET_ID_CHANGE_PAGE,
583 GADGET_ID_CHANGE_REPLACE_WHEN,
584 GADGET_ID_ACTION_TYPE,
585 GADGET_ID_ACTION_MODE,
586 GADGET_ID_ACTION_ARG,
587 GADGET_ID_SELECT_CHANGE_PAGE,
588 GADGET_ID_GROUP_CHOICE_MODE,
590 // textbutton identifiers
592 GADGET_ID_LEVELINFO_LEVEL,
593 GADGET_ID_LEVELINFO_LEVELSET,
594 GADGET_ID_LEVELINFO_EDITOR,
595 GADGET_ID_PROPERTIES_INFO,
596 GADGET_ID_PROPERTIES_CONFIG,
597 GADGET_ID_PROPERTIES_CONFIG_1,
598 GADGET_ID_PROPERTIES_CONFIG_2,
599 GADGET_ID_PROPERTIES_CHANGE,
600 GADGET_ID_SAVE_AS_TEMPLATE_1,
601 GADGET_ID_SAVE_AS_TEMPLATE_2,
602 GADGET_ID_SAVE_LEVELSET,
603 GADGET_ID_ADD_CHANGE_PAGE,
604 GADGET_ID_DEL_CHANGE_PAGE,
606 // graphicbutton identifiers
608 GADGET_ID_PREV_CHANGE_PAGE,
609 GADGET_ID_NEXT_CHANGE_PAGE,
610 GADGET_ID_COPY_CHANGE_PAGE,
611 GADGET_ID_PASTE_CHANGE_PAGE,
613 // gadgets for scrolling of drawing area
616 GADGET_ID_SCROLL_DOWN,
617 GADGET_ID_SCROLL_LEFT,
618 GADGET_ID_SCROLL_RIGHT,
619 GADGET_ID_SCROLL_HORIZONTAL,
620 GADGET_ID_SCROLL_VERTICAL,
622 // gadgets for scrolling element list
624 GADGET_ID_SCROLL_LIST_UP,
625 GADGET_ID_SCROLL_LIST_DOWN,
626 GADGET_ID_SCROLL_LIST_VERTICAL,
628 // checkbuttons/radiobuttons for level/element properties
630 GADGET_ID_AUTO_COUNT_GEMS,
631 GADGET_ID_USE_LEVELSET_ARTWORK,
632 GADGET_ID_COPY_LEVEL_TEMPLATE,
633 GADGET_ID_RANDOM_PERCENTAGE,
634 GADGET_ID_RANDOM_QUANTITY,
635 GADGET_ID_RANDOM_RESTRICTED,
636 GADGET_ID_STICK_ELEMENT,
637 GADGET_ID_EM_SLIPPERY_GEMS,
638 GADGET_ID_EM_EXPLODES_BY_FIRE,
639 GADGET_ID_USE_SPRING_BUG,
640 GADGET_ID_USE_TIME_ORB_BUG,
641 GADGET_ID_USE_LIFE_BUGS,
642 GADGET_ID_RANDOM_BALL_CONTENT,
643 GADGET_ID_INITIAL_BALL_STATE,
644 GADGET_ID_GROW_INTO_DIGGABLE,
645 GADGET_ID_SB_FIELDS_NEEDED,
646 GADGET_ID_SB_OBJECTS_NEEDED,
647 GADGET_ID_AUTO_EXIT_SOKOBAN,
648 GADGET_ID_SOLVED_BY_ONE_PLAYER,
649 GADGET_ID_CONTINUOUS_SNAPPING,
650 GADGET_ID_BLOCK_SNAP_FIELD,
651 GADGET_ID_BLOCK_LAST_FIELD,
652 GADGET_ID_SP_BLOCK_LAST_FIELD,
653 GADGET_ID_INSTANT_RELOCATION,
654 GADGET_ID_SHIFTED_RELOCATION,
655 GADGET_ID_LAZY_RELOCATION,
656 GADGET_ID_USE_START_ELEMENT,
657 GADGET_ID_USE_ARTWORK_ELEMENT,
658 GADGET_ID_USE_EXPLOSION_ELEMENT,
659 GADGET_ID_INITIAL_GRAVITY,
660 GADGET_ID_USE_INITIAL_INVENTORY,
661 GADGET_ID_CAN_PASS_TO_WALKABLE,
662 GADGET_ID_CAN_FALL_INTO_ACID,
663 GADGET_ID_CAN_MOVE_INTO_ACID,
664 GADGET_ID_DONT_COLLIDE_WITH,
665 GADGET_ID_ENVELOPE_AUTOWRAP,
666 GADGET_ID_ENVELOPE_CENTERED,
667 GADGET_ID_MM_LASER_RED,
668 GADGET_ID_MM_LASER_GREEN,
669 GADGET_ID_MM_LASER_BLUE,
670 GADGET_ID_DF_LASER_RED,
671 GADGET_ID_DF_LASER_GREEN,
672 GADGET_ID_DF_LASER_BLUE,
673 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
674 GADGET_ID_CUSTOM_CAN_EXPLODE,
675 GADGET_ID_CUSTOM_EXPLODE_FIRE,
676 GADGET_ID_CUSTOM_EXPLODE_SMASH,
677 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
678 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
679 GADGET_ID_CUSTOM_DEADLY,
680 GADGET_ID_CUSTOM_CAN_MOVE,
681 GADGET_ID_CUSTOM_CAN_FALL,
682 GADGET_ID_CUSTOM_CAN_SMASH,
683 GADGET_ID_CUSTOM_SLIPPERY,
684 GADGET_ID_CUSTOM_ACCESSIBLE,
685 GADGET_ID_CUSTOM_GRAV_REACHABLE,
686 GADGET_ID_CUSTOM_USE_LAST_VALUE,
687 GADGET_ID_CUSTOM_USE_GRAPHIC,
688 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
689 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
690 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
691 GADGET_ID_CUSTOM_CAN_CHANGE,
692 GADGET_ID_CHANGE_USE_CONTENT,
693 GADGET_ID_CHANGE_USE_EXPLOSION,
694 GADGET_ID_CHANGE_ONLY_COMPLETE,
695 GADGET_ID_CHANGE_USE_RANDOM,
696 GADGET_ID_CHANGE_HAS_ACTION,
697 GADGET_ID_CHANGE_DELAY,
698 GADGET_ID_CHANGE_BY_DIRECT_ACT,
699 GADGET_ID_CHANGE_BY_OTHER_ACT,
701 NUM_STATIC_GADGET_IDS
704 // gadgets for buttons in element list (dynamic)
705 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
706 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
707 ED_NUM_ELEMENTLIST_BUTTONS - 1)
709 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
711 // radio button numbers
715 RADIO_NR_DRAWING_TOOLBOX,
716 RADIO_NR_RANDOM_ELEMENTS
719 // values for counter gadgets
722 ED_COUNTER_ID_SELECT_LEVEL,
723 ED_COUNTER_ID_LEVEL_XSIZE,
724 ED_COUNTER_ID_LEVEL_YSIZE,
725 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
726 ED_COUNTER_ID_LEVEL_TIMELIMIT,
727 ED_COUNTER_ID_LEVEL_TIMESCORE,
728 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
729 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
730 ED_COUNTER_ID_LEVEL_RANDOM,
731 ED_COUNTER_ID_ELEMENT_VALUE1,
732 ED_COUNTER_ID_ELEMENT_VALUE2,
733 ED_COUNTER_ID_ELEMENT_VALUE3,
734 ED_COUNTER_ID_ELEMENT_VALUE4,
735 ED_COUNTER_ID_YAMYAM_CONTENT,
736 ED_COUNTER_ID_BALL_CONTENT,
737 ED_COUNTER_ID_ANDROID_CONTENT,
738 ED_COUNTER_ID_ENVELOPE_XSIZE,
739 ED_COUNTER_ID_ENVELOPE_YSIZE,
740 ED_COUNTER_ID_INVENTORY_SIZE,
741 ED_COUNTER_ID_CUSTOM_SCORE,
742 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
743 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
744 ED_COUNTER_ID_CUSTOM_VALUE_RND,
745 ED_COUNTER_ID_PUSH_DELAY_FIX,
746 ED_COUNTER_ID_PUSH_DELAY_RND,
747 ED_COUNTER_ID_DROP_DELAY_FIX,
748 ED_COUNTER_ID_DROP_DELAY_RND,
749 ED_COUNTER_ID_MOVE_DELAY_FIX,
750 ED_COUNTER_ID_MOVE_DELAY_RND,
751 ED_COUNTER_ID_EXPLOSION_DELAY,
752 ED_COUNTER_ID_IGNITION_DELAY,
753 ED_COUNTER_ID_GROUP_CONTENT,
754 ED_COUNTER_ID_CHANGE_DELAY_FIX,
755 ED_COUNTER_ID_CHANGE_DELAY_RND,
756 ED_COUNTER_ID_CHANGE_CONT_RND,
758 ED_NUM_COUNTERBUTTONS
761 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
762 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
763 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
764 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
765 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
766 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
768 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
769 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
770 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
771 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
772 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
773 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
775 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
776 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
778 // values for scrollbutton gadgets
781 ED_SCROLLBUTTON_ID_AREA_UP,
782 ED_SCROLLBUTTON_ID_AREA_DOWN,
783 ED_SCROLLBUTTON_ID_AREA_LEFT,
784 ED_SCROLLBUTTON_ID_AREA_RIGHT,
785 ED_SCROLLBUTTON_ID_LIST_UP,
786 ED_SCROLLBUTTON_ID_LIST_DOWN,
791 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
792 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
794 // values for scrollbar gadgets
797 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
798 ED_SCROLLBAR_ID_AREA_VERTICAL,
799 ED_SCROLLBAR_ID_LIST_VERTICAL,
804 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
805 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
807 // values for text input gadgets
810 ED_TEXTINPUT_ID_LEVEL_NAME,
811 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
812 ED_TEXTINPUT_ID_LEVELSET_NAME,
813 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
814 ED_TEXTINPUT_ID_ELEMENT_NAME,
819 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
820 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
822 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
823 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
825 // values for text area gadgets
828 ED_TEXTAREA_ID_ENVELOPE_INFO,
833 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
834 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
836 // values for selectbox gadgets
839 ED_SELECTBOX_ID_TIME_OR_STEPS,
840 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
841 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
842 ED_SELECTBOX_ID_WIND_DIRECTION,
843 ED_SELECTBOX_ID_PLAYER_SPEED,
844 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
845 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
846 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
847 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
848 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
849 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
850 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
851 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
852 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
853 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
854 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
855 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
856 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
857 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
858 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
859 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
860 ED_SELECTBOX_ID_CHANGE_SIDE,
861 ED_SELECTBOX_ID_CHANGE_PLAYER,
862 ED_SELECTBOX_ID_CHANGE_PAGE,
863 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
864 ED_SELECTBOX_ID_ACTION_TYPE,
865 ED_SELECTBOX_ID_ACTION_MODE,
866 ED_SELECTBOX_ID_ACTION_ARG,
867 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
868 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
873 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
874 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
876 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
877 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
879 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
880 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
881 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
882 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
883 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
884 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
886 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
887 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
889 // values for textbutton gadgets
892 ED_TEXTBUTTON_ID_LEVELINFO_LEVEL,
893 ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET,
894 ED_TEXTBUTTON_ID_LEVELINFO_EDITOR,
895 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
896 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
897 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
898 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
899 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
900 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
901 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
902 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
903 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
904 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
909 #define ED_TAB_BUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
910 #define ED_TAB_BUTTON_ID_LEVELINFO_LAST ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
912 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
913 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
915 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
916 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
918 // values for graphicbutton gadgets
921 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
922 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
923 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
924 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
926 ED_NUM_GRAPHICBUTTONS
929 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
930 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
932 // values for checkbutton gadgets
935 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
936 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
937 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
938 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
939 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
940 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
941 ED_CHECKBUTTON_ID_STICK_ELEMENT,
942 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
943 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
944 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
945 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
946 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
947 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
948 ED_CHECKBUTTON_ID_INITIAL_BALL_STATE,
949 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
950 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
951 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
952 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
953 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
954 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
955 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
956 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
957 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
958 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
959 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
960 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
961 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
962 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
963 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
964 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
965 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
966 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
967 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
968 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
969 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
970 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
971 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
972 ED_CHECKBUTTON_ID_MM_LASER_RED,
973 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
974 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
975 ED_CHECKBUTTON_ID_DF_LASER_RED,
976 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
977 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
978 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
979 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
980 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
981 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
982 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
983 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
984 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
985 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
986 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
987 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
988 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
989 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
990 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
991 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
992 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
993 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
994 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
995 ED_CHECKBUTTON_ID_CHANGE_DELAY,
996 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
997 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
998 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
999 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1000 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1001 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1002 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1007 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1008 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1010 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1011 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1013 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1014 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1016 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1017 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1018 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1019 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1020 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1021 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1023 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1024 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1026 // values for radiobutton gadgets
1029 ED_RADIOBUTTON_ID_PERCENTAGE,
1030 ED_RADIOBUTTON_ID_QUANTITY,
1035 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1036 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1038 // values for drawing area gadgets
1041 ED_DRAWING_ID_DRAWING_LEVEL,
1042 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1043 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1044 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1045 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1046 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1047 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1048 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1049 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1050 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1051 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1052 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1053 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1054 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1055 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1056 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1057 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1058 ED_DRAWING_ID_ANDROID_CONTENT,
1059 ED_DRAWING_ID_AMOEBA_CONTENT,
1060 ED_DRAWING_ID_START_ELEMENT,
1061 ED_DRAWING_ID_ARTWORK_ELEMENT,
1062 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1063 ED_DRAWING_ID_INVENTORY_CONTENT,
1064 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1065 ED_DRAWING_ID_CUSTOM_CONTENT,
1066 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1067 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1068 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1069 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1070 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1071 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1072 ED_DRAWING_ID_GROUP_CONTENT,
1073 ED_DRAWING_ID_RANDOM_BACKGROUND,
1075 ED_NUM_DRAWING_AREAS
1078 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1079 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1082 // ----------------------------------------------------------------------------
1083 // some internally used definitions
1084 // ----------------------------------------------------------------------------
1086 // values for CopyLevelToUndoBuffer()
1087 #define UNDO_IMMEDIATE 0
1088 #define UNDO_ACCUMULATE 1
1090 // values for scrollbars
1091 #define ED_SCROLL_NO 0
1092 #define ED_SCROLL_LEFT 1
1093 #define ED_SCROLL_RIGHT 2
1094 #define ED_SCROLL_UP 4
1095 #define ED_SCROLL_DOWN 8
1097 // screens in the level editor
1098 #define ED_MODE_DRAWING 0
1099 #define ED_MODE_INFO 1
1100 #define ED_MODE_PROPERTIES 2
1101 #define ED_MODE_PALETTE 3
1103 // sub-screens in the global settings section
1104 #define ED_MODE_LEVELINFO_LEVEL ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
1105 #define ED_MODE_LEVELINFO_LEVELSET ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET
1106 #define ED_MODE_LEVELINFO_EDITOR ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
1108 // sub-screens in the element properties section
1109 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1110 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1111 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1112 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1113 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1115 // how many steps can be cancelled
1116 #define NUM_UNDO_STEPS (64 + 1)
1118 // values for elements with score for certain actions
1120 #define MAX_SCORE 999
1122 // values for elements with count for collecting
1123 #define MIN_COLLECT_COUNT 0
1124 #define MAX_COLLECT_COUNT 999
1126 // values for random placement
1127 #define RANDOM_USE_PERCENTAGE 0
1128 #define RANDOM_USE_QUANTITY 1
1130 // values for level set save mode
1131 #define LEVELSET_SAVE_MODE_UPDATE 0
1132 #define LEVELSET_SAVE_MODE_CREATE 1
1134 // default value for element tile size in drawing area
1135 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1136 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1139 // ----------------------------------------------------------------------------
1140 // some internally used data structure definitions
1141 // ----------------------------------------------------------------------------
1147 struct XYTileSize *pos;
1151 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1153 // note: some additional characters are already reserved for "cheat mode"
1154 // shortcuts (":XYZ" style) -- for details, see "events.c"
1156 // ---------- toolbox control buttons ---------------------------------------
1159 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1160 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1161 "draw single items", 's'
1164 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1165 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1166 "draw connected items", 'd'
1169 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1170 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1174 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1175 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1179 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1180 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1181 "draw outline rectangles", 'r'
1184 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1185 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1186 "draw filled rectangles", 'R'
1189 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1190 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1191 "wrap (rotate) level up", 0
1194 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1195 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1196 "enter text elements", 't'
1199 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1200 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1204 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1205 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1206 "wrap (rotate) level left", 0
1209 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1210 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1211 "zoom level tile size", '+'
1214 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1215 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1216 "wrap (rotate) level right", 0
1219 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1220 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1221 "random element placement", 0
1224 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1225 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1229 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1230 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1231 "wrap (rotate) level down", 0
1234 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1235 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1236 "pick drawing element", ','
1239 // ---------- level control buttons -----------------------------------------
1242 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1243 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1244 "undo/redo last operation", 'u'
1247 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_INFO,
1248 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1249 "properties of level", 'I'
1252 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1253 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1257 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1258 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1262 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1263 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1267 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1268 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1269 "exit level editor", 'E'
1272 // ---------- CE and GE control buttons -------------------------------------
1275 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1276 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1277 "copy settings from other element", 0
1280 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1281 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1282 "copy settings to other element", 0
1285 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1286 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1287 "exchange element with other element", 0
1290 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1291 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1292 "copy settings from this element", 0
1295 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1296 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1297 "paste settings to this element", 0
1300 // ---------- palette control buttons ---------------------------------------
1303 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1304 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1305 "properties of drawing element", 'p'
1308 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1309 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1310 "properties of drawing element 1", '1'
1313 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1314 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1315 "properties of drawing element 2", '2'
1318 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1319 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1320 "properties of drawing element 3", '3'
1323 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1324 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1325 "show list of elements", 'e'
1329 static int random_placement_value = 10;
1330 static int random_placement_method = RANDOM_USE_QUANTITY;
1331 static int random_placement_background_element = EL_SAND;
1332 static boolean random_placement_background_restricted = FALSE;
1333 static boolean stick_element_properties_window = FALSE;
1334 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1335 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1336 static struct ElementChangeInfo custom_element_change;
1337 static struct ElementGroupInfo group_element_info;
1338 static struct ElementInfo custom_element;
1340 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1341 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1342 static int levelset_num_levels = 100;
1343 static boolean levelset_use_levelset_artwork = FALSE;
1344 static boolean levelset_copy_level_template = FALSE;
1345 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1350 int min_value, max_value;
1351 int gadget_id_down, gadget_id_up;
1353 int gadget_id_align;
1355 char *text_above, *text_left, *text_right;
1356 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1358 // ---------- current level number ------------------------------------------
1361 -1, -1, // these values are not constant, but can change at runtime
1363 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1364 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1369 // ---------- level and editor settings -------------------------------------
1372 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1373 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1374 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1375 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1377 "playfield size:", NULL, "width",
1380 -1, ED_LEVEL_SETTINGS_YPOS(4),
1381 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1382 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1383 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1385 NULL, " ", "height",
1388 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1390 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1391 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1393 NULL, "number of gems to collect:", NULL
1396 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1398 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1399 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1401 "time or step limit to solve level:", NULL, NULL
1404 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1406 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1407 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1408 &level.score[SC_TIME_BONUS],
1409 "score for each second/step left:", NULL, NULL
1412 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
1414 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1415 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1417 NULL, "random seed:", "(0 => random)"
1420 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1422 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1423 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1424 &levelset_num_levels,
1425 "number of levels:", NULL, NULL,
1428 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1430 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1431 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1432 &random_placement_value,
1433 "random element placement:", NULL, "in"
1436 // ---------- element settings: configure (various elements) ----------------
1439 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1440 MIN_SCORE, MAX_SCORE,
1441 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1442 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1443 NULL, // will be set when used
1447 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1448 MIN_SCORE, MAX_SCORE,
1449 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1450 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1451 NULL, // will be set when used
1455 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1456 MIN_SCORE, MAX_SCORE,
1457 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1458 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1459 NULL, // will be set when used
1463 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1464 MIN_SCORE, MAX_SCORE,
1465 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1466 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1467 NULL, // will be set when used
1471 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1472 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1473 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1474 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1475 &level.num_yamyam_contents,
1476 NULL, NULL, "number of content areas"
1479 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1480 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1481 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1482 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1483 &level.num_ball_contents,
1484 NULL, NULL, "number of content areas"
1487 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1488 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1489 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1490 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1491 &level.num_android_clone_elements,
1492 NULL, NULL, "number of clonable elements"
1495 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1496 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1497 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1498 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1499 NULL, // will be set when used
1500 NULL, NULL, "width",
1503 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1504 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1505 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1506 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1507 NULL, // will be set when used
1508 NULL, " ", "height",
1511 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1512 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1513 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1514 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1515 &level.initial_inventory_size[0],
1516 NULL, NULL, "number of inventory elements"
1519 // ---------- element settings: configure 1 (custom elements) ---------------
1522 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1523 MIN_SCORE, MAX_SCORE,
1524 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1525 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1526 &custom_element.collect_score_initial,
1527 NULL, "CE score", " "
1530 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1531 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1532 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1533 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1534 &custom_element.collect_count_initial,
1535 NULL, "CE count", NULL
1538 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1540 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1541 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1542 &custom_element.ce_value_fixed_initial,
1543 NULL, "CE value", NULL
1546 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1548 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1549 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1550 &custom_element.ce_value_random_initial,
1551 NULL, "+random", NULL
1554 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1556 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1557 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1558 &custom_element.push_delay_fixed,
1559 NULL, "push delay", NULL
1562 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1564 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1565 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1566 &custom_element.push_delay_random,
1567 NULL, "+random", NULL
1570 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1572 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1573 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1574 &custom_element.drop_delay_fixed,
1575 NULL, "drop delay", NULL
1578 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1580 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1581 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1582 &custom_element.drop_delay_random,
1583 NULL, "+random", NULL
1586 // ---------- element settings: configure 2 (custom elements) ---------------
1589 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1591 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1592 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1593 &custom_element.move_delay_fixed,
1594 NULL, "move delay", NULL
1597 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1599 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1600 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1601 &custom_element.move_delay_random,
1602 NULL, "+random", NULL
1605 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
1607 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1608 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1609 &custom_element.explosion_delay,
1610 NULL, "explosion delay", NULL
1613 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1615 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1616 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1617 &custom_element.ignition_delay,
1618 NULL, "ignition delay", "(by fire)"
1621 // ---------- element settings: configure (group elements) ------------------
1624 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1625 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1626 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1627 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1628 &group_element_info.num_elements,
1629 NULL, NULL, "number of elements in group"
1632 // ---------- element settings: advanced (custom elements) ------------------
1635 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1637 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1638 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1639 &custom_element_change.delay_fixed,
1640 NULL, "CE delay", NULL,
1643 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1645 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1646 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1647 &custom_element_change.delay_random,
1648 NULL, "+random", NULL
1651 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1653 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1654 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1655 &custom_element_change.random_percentage,
1656 NULL, "use random replace:", "%"
1666 char *text_above, *infotext;
1667 } textinput_info[ED_NUM_TEXTINPUT] =
1670 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1671 GADGET_ID_LEVEL_NAME,
1674 "Title:", "Title for this level"
1677 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1678 GADGET_ID_LEVEL_AUTHOR,
1679 MAX_LEVEL_AUTHOR_LEN,
1681 "Author:", "Author for this level"
1684 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1685 GADGET_ID_LEVELSET_NAME,
1688 "Title:", "Title for this or new level set"
1691 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1692 GADGET_ID_LEVELSET_AUTHOR,
1693 MAX_LEVEL_AUTHOR_LEN,
1695 "Author:", "Author for this or new level set"
1698 -1, -1, // these values are not constant, but can change at runtime
1699 GADGET_ID_ELEMENT_NAME,
1700 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1701 custom_element.description,
1702 NULL, "Element name"
1712 char *text_above, *infotext;
1713 } textarea_info[ED_NUM_TEXTAREAS] =
1716 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1717 GADGET_ID_ENVELOPE_INFO,
1718 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1720 "Envelope Content:", "Envelope Content"
1724 static struct ValueTextInfo options_time_or_steps[] =
1732 static struct ValueTextInfo options_game_engine_type[] =
1734 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1735 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1736 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1737 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1742 static struct ValueTextInfo options_levelset_save_mode[] =
1744 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1745 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1750 static struct ValueTextInfo options_wind_direction[] =
1752 { MV_START_NONE, "none" },
1753 { MV_START_LEFT, "left" },
1754 { MV_START_RIGHT, "right" },
1755 { MV_START_UP, "up" },
1756 { MV_START_DOWN, "down" },
1761 static struct ValueTextInfo options_player_speed[] =
1768 { 16, "very fast" },
1769 { 32, "ultrafast" },
1774 static struct ValueTextInfo options_access_type[] =
1776 { EP_WALKABLE, "walkable" },
1777 { EP_PASSABLE, "passable" },
1782 static struct ValueTextInfo options_access_layer[] =
1784 { EP_ACCESSIBLE_OVER, "over" },
1785 { EP_ACCESSIBLE_INSIDE, "inside" },
1786 { EP_ACCESSIBLE_UNDER, "under" },
1791 static struct ValueTextInfo options_access_protected[] =
1793 { 0, "unprotected" },
1799 static struct ValueTextInfo options_access_direction[] =
1801 { MV_NO_DIRECTION, "no direction" },
1802 { MV_LEFT, "left" },
1803 { MV_RIGHT, "right" },
1805 { MV_DOWN, "down" },
1806 { MV_LEFT | MV_UP, "left + up" },
1807 { MV_LEFT | MV_DOWN, "left + down" },
1808 { MV_RIGHT | MV_UP, "right + up" },
1809 { MV_RIGHT | MV_DOWN, "right + down" },
1810 { MV_HORIZONTAL, "horizontal" },
1811 { MV_VERTICAL, "vertical" },
1812 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1813 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1814 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1815 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1816 { MV_ALL_DIRECTIONS, "all directions" },
1821 static struct ValueTextInfo options_walk_to_action[] =
1823 { EP_DIGGABLE, "diggable" },
1824 { EP_COLLECTIBLE_ONLY, "collectible" },
1825 { EP_DROPPABLE, "collectible & droppable" },
1826 { EP_THROWABLE, "collectible & throwable" },
1827 { EP_PUSHABLE, "pushable" },
1832 static struct ValueTextInfo options_move_pattern[] =
1834 { MV_LEFT, "left" },
1835 { MV_RIGHT, "right" },
1837 { MV_DOWN, "down" },
1838 { MV_HORIZONTAL, "horizontal" },
1839 { MV_VERTICAL, "vertical" },
1840 { MV_ALL_DIRECTIONS, "all directions" },
1841 { MV_WIND_DIRECTION, "wind direction" },
1842 { MV_TOWARDS_PLAYER, "towards player" },
1843 { MV_AWAY_FROM_PLAYER, "away from player" },
1844 { MV_ALONG_LEFT_SIDE, "along left side" },
1845 { MV_ALONG_RIGHT_SIDE, "along right side" },
1846 { MV_TURNING_LEFT, "turning left" },
1847 { MV_TURNING_RIGHT, "turning right" },
1848 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1849 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1850 { MV_TURNING_RANDOM, "turning random" },
1851 { MV_MAZE_RUNNER, "maze runner style" },
1852 { MV_MAZE_HUNTER, "maze hunter style" },
1853 { MV_WHEN_PUSHED, "when pushed" },
1854 { MV_WHEN_DROPPED, "when dropped/thrown" },
1859 static struct ValueTextInfo options_move_direction[] =
1861 { MV_START_AUTOMATIC, "automatic" },
1862 { MV_START_LEFT, "left" },
1863 { MV_START_RIGHT, "right" },
1864 { MV_START_UP, "up" },
1865 { MV_START_DOWN, "down" },
1866 { MV_START_RANDOM, "random" },
1867 { MV_START_PREVIOUS, "previous" },
1872 static struct ValueTextInfo options_move_stepsize[] =
1874 { 0, "not moving" },
1879 { 16, "very fast" },
1880 { 32, "even faster" },
1885 static struct ValueTextInfo options_move_leave_type[] =
1887 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1888 { LEAVE_TYPE_LIMITED, "change it to" },
1893 static struct ValueTextInfo options_smash_targets[] =
1895 { EP_CAN_SMASH_PLAYER, "player" },
1897 { EP_CAN_SMASH_ENEMIES, "enemies" },
1899 { EP_CAN_SMASH_EVERYTHING, "everything" },
1904 static struct ValueTextInfo options_slippery_type[] =
1906 { SLIPPERY_ANY_RANDOM, "random" },
1907 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1908 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1909 { SLIPPERY_ONLY_LEFT, "only left" },
1910 { SLIPPERY_ONLY_RIGHT, "only right" },
1915 static struct ValueTextInfo options_deadliness[] =
1917 { EP_DONT_RUN_INTO, "running into" },
1918 { EP_DONT_COLLIDE_WITH, "colliding with" },
1919 { EP_DONT_GET_HIT_BY, "getting hit by" },
1920 { EP_DONT_TOUCH, "touching" },
1925 static struct ValueTextInfo options_explosion_type[] =
1927 { EXPLODES_3X3, "3x3" },
1928 { EXPLODES_CROSS, "3+3" },
1929 { EXPLODES_1X1, "1x1" },
1934 static struct ValueTextInfo options_time_units[] =
1937 { FRAMES_PER_SECOND, "seconds" },
1942 static struct ValueTextInfo options_change_direct_action[] =
1944 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1945 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1946 { CE_SWITCHED_BY_PLAYER, "switched by player" },
1947 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
1948 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1949 { CE_ENTERED_BY_PLAYER, "entered by player" },
1950 { CE_LEFT_BY_PLAYER, "left by player" },
1951 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1952 { CE_SWITCHED, "switched" },
1953 { CE_HITTING_SOMETHING, "hitting something" },
1954 { CE_HIT_BY_SOMETHING, "hit by something" },
1956 { CE_BLOCKED, "blocked" },
1958 { CE_IMPACT, "impact (on something)" },
1959 { CE_SMASHED, "smashed (from above)" },
1961 { CE_VALUE_CHANGES, "CE value changes" },
1962 { CE_SCORE_CHANGES, "CE score changes" },
1964 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
1965 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
1970 static struct ValueTextInfo options_change_other_action[] =
1972 { CE_PLAYER_TOUCHES_X, "player touches" },
1973 { CE_PLAYER_PRESSES_X, "player presses" },
1974 { CE_PLAYER_SWITCHES_X, "player switches" },
1975 { CE_PLAYER_SNAPS_X, "player snaps" },
1976 { CE_PLAYER_PUSHES_X, "player pushes" },
1977 { CE_PLAYER_ENTERS_X, "player enters" },
1978 { CE_PLAYER_LEAVES_X, "player leaves" },
1979 { CE_PLAYER_DIGS_X, "player digs" },
1980 { CE_PLAYER_COLLECTS_X, "player collects" },
1981 { CE_PLAYER_DROPS_X, "player drops/throws" },
1982 { CE_TOUCHING_X, "touching" },
1983 { CE_HITTING_X, "hitting" },
1984 { CE_DIGGING_X, "digging" },
1985 { CE_HIT_BY_X, "hit by" },
1986 { CE_SWITCH_OF_X, "switch of" },
1987 { CE_CHANGE_OF_X, "change by page of" },
1988 { CE_EXPLOSION_OF_X, "explosion of" },
1989 { CE_MOVE_OF_X, "move of" },
1990 { CE_CREATION_OF_X, "creation of" },
1991 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
1992 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
1993 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
1994 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
1999 static struct ValueTextInfo options_change_trigger_side[] =
2001 { CH_SIDE_LEFT, "left" },
2002 { CH_SIDE_RIGHT, "right" },
2003 { CH_SIDE_TOP, "top" },
2004 { CH_SIDE_BOTTOM, "bottom" },
2005 { CH_SIDE_LEFT_RIGHT, "left/right" },
2006 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2007 { CH_SIDE_ANY, "any" },
2012 static struct ValueTextInfo options_change_trigger_player[] =
2014 { CH_PLAYER_1, "1" },
2015 { CH_PLAYER_2, "2" },
2016 { CH_PLAYER_3, "3" },
2017 { CH_PLAYER_4, "4" },
2018 { CH_PLAYER_ANY, "any" },
2023 static struct ValueTextInfo options_change_trigger_page[] =
2035 { (1 << 10), "11" },
2036 { (1 << 11), "12" },
2037 { (1 << 12), "13" },
2038 { (1 << 13), "14" },
2039 { (1 << 14), "15" },
2040 { (1 << 15), "16" },
2041 { (1 << 16), "17" },
2042 { (1 << 17), "18" },
2043 { (1 << 18), "19" },
2044 { (1 << 19), "20" },
2045 { (1 << 20), "21" },
2046 { (1 << 21), "22" },
2047 { (1 << 22), "23" },
2048 { (1 << 23), "24" },
2049 { (1 << 24), "25" },
2050 { (1 << 25), "26" },
2051 { (1 << 26), "27" },
2052 { (1 << 27), "28" },
2053 { (1 << 28), "29" },
2054 { (1 << 29), "30" },
2055 { (1 << 30), "31" },
2056 { (1 << 31), "32" },
2057 { CH_PAGE_ANY, "any" },
2062 static struct ValueTextInfo options_change_replace_when[] =
2064 { CP_WHEN_EMPTY, "empty" },
2065 { CP_WHEN_WALKABLE, "walkable" },
2066 { CP_WHEN_DIGGABLE, "diggable" },
2067 { CP_WHEN_COLLECTIBLE, "collectible" },
2068 { CP_WHEN_REMOVABLE, "removable" },
2069 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2074 static struct ValueTextInfo options_action_type[] =
2076 { CA_NO_ACTION, "no action" },
2077 { CA_UNDEFINED, " " },
2078 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2079 { CA_RESTART_LEVEL, "restart level" },
2080 { CA_SHOW_ENVELOPE, "show envelope" },
2081 { CA_SET_LEVEL_TIME, "set time" },
2082 { CA_SET_LEVEL_SCORE, "set score" },
2083 { CA_SET_LEVEL_GEMS, "set gems" },
2084 { CA_SET_LEVEL_WIND, "set wind dir." },
2085 { CA_SET_LEVEL_RANDOM_SEED, "set rand. seed" },
2086 { CA_UNDEFINED, " " },
2087 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2088 { CA_MOVE_PLAYER, "move player" },
2089 { CA_EXIT_PLAYER, "exit player" },
2090 { CA_KILL_PLAYER, "kill player" },
2091 { CA_SET_PLAYER_KEYS, "set keys" },
2092 { CA_SET_PLAYER_SPEED, "set speed" },
2093 { CA_SET_PLAYER_SHIELD, "set shield" },
2094 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2095 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2096 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2097 { CA_UNDEFINED, " " },
2098 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2099 { CA_SET_CE_VALUE, "set CE value" },
2100 { CA_SET_CE_SCORE, "set CE score" },
2101 { CA_SET_CE_ARTWORK, "set CE artwork" },
2102 { CA_UNDEFINED, " " },
2103 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2104 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2109 static struct ValueTextInfo options_action_mode_none[] =
2111 { CA_MODE_UNDEFINED, " " },
2116 static struct ValueTextInfo options_action_mode_assign[] =
2118 { CA_MODE_SET, "=" },
2123 static struct ValueTextInfo options_action_mode_add_remove[] =
2125 { CA_MODE_ADD, "+" },
2126 { CA_MODE_SUBTRACT, "-" },
2131 static struct ValueTextInfo options_action_mode_calculate[] =
2133 { CA_MODE_SET, "=" },
2134 { CA_MODE_ADD, "+" },
2135 { CA_MODE_SUBTRACT, "-" },
2136 { CA_MODE_MULTIPLY, "*" },
2137 { CA_MODE_DIVIDE, "/" },
2138 { CA_MODE_MODULO, "%" },
2143 static struct ValueTextInfo options_action_arg_none[] =
2145 { CA_ARG_UNDEFINED, " " },
2150 static struct ValueTextInfo options_action_arg_player[] =
2152 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2153 { CA_ARG_PLAYER_1, "1" },
2154 { CA_ARG_PLAYER_2, "2" },
2155 { CA_ARG_PLAYER_3, "3" },
2156 { CA_ARG_PLAYER_4, "4" },
2157 { CA_ARG_PLAYER_ANY, "any" },
2158 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2159 { CA_ARG_PLAYER_ACTION, "action ->" },
2164 static struct ValueTextInfo options_action_arg_number[] =
2166 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2173 { CA_ARG_10, "10" },
2174 { CA_ARG_100, "100" },
2175 { CA_ARG_1000, "1000" },
2176 { CA_ARG_UNDEFINED, " " },
2177 { CA_ARG_NUMBER_MIN, "min" },
2178 { CA_ARG_NUMBER_MAX, "max" },
2179 { CA_ARG_UNDEFINED, " " },
2180 { CA_ARG_NUMBER_RESET, "reset" },
2181 { CA_ARG_UNDEFINED, " " },
2182 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2183 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2184 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2185 { CA_ARG_UNDEFINED, " " },
2186 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2187 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2188 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2189 { CA_ARG_UNDEFINED, " " },
2190 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2191 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2192 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2193 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2194 { CA_ARG_UNDEFINED, " " },
2195 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2196 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2197 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2198 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2203 static struct ValueTextInfo options_action_arg_value[] =
2205 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2212 { CA_ARG_10, "10" },
2213 { CA_ARG_100, "100" },
2214 { CA_ARG_1000, "1000" },
2215 { CA_ARG_UNDEFINED, " " },
2216 { CA_ARG_NUMBER_MIN, "min" },
2217 { CA_ARG_NUMBER_MAX, "max" },
2218 { CA_ARG_UNDEFINED, " " },
2219 { CA_ARG_NUMBER_RESET, "reset" },
2220 { CA_ARG_UNDEFINED, " " },
2221 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2222 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2223 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2224 { CA_ARG_UNDEFINED, " " },
2225 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2226 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2227 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2228 { CA_ARG_UNDEFINED, " " },
2229 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2230 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2231 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2232 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2233 { CA_ARG_UNDEFINED, " " },
2234 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2235 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2236 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2237 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2238 { CA_ARG_UNDEFINED, " " },
2239 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2240 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2241 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2242 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2247 static struct ValueTextInfo options_action_arg_envelope[] =
2249 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2254 { CA_ARG_UNDEFINED, " " },
2255 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2256 { CA_ARG_ELEMENT_TARGET, "target" },
2257 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2258 { CA_ARG_ELEMENT_ACTION, "action ->" },
2263 static struct ValueTextInfo options_action_arg_key[] =
2265 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2274 { CA_ARG_UNDEFINED, " " },
2275 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2276 { CA_ARG_ELEMENT_TARGET, "target" },
2277 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2278 { CA_ARG_ELEMENT_ACTION, "action ->" },
2283 static struct ValueTextInfo options_action_arg_speed[] =
2285 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2286 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2287 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2288 { CA_ARG_SPEED_SLOW, "slow" },
2289 { CA_ARG_SPEED_NORMAL, "normal" },
2290 { CA_ARG_SPEED_FAST, "fast" },
2291 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2292 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2293 { CA_ARG_UNDEFINED, " " },
2294 { CA_ARG_SPEED_SLOWER, "slower" },
2295 { CA_ARG_SPEED_FASTER, "faster" },
2296 { CA_ARG_UNDEFINED, " " },
2297 { CA_ARG_SPEED_RESET, "reset" },
2302 static struct ValueTextInfo options_action_arg_shield[] =
2304 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2305 { CA_ARG_SHIELD_OFF, "off" },
2306 { CA_ARG_SHIELD_NORMAL, "normal" },
2307 { CA_ARG_SHIELD_DEADLY, "deadly" },
2312 static struct ValueTextInfo options_action_arg_artwork[] =
2314 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2315 { CA_ARG_ELEMENT_TARGET, "target" },
2316 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2317 { CA_ARG_ELEMENT_ACTION, "action ->" },
2318 { CA_ARG_UNDEFINED, " " },
2319 { CA_ARG_ELEMENT_RESET, "reset" },
2324 static struct ValueTextInfo options_action_arg_gravity[] =
2326 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2327 { CA_ARG_GRAVITY_ON, "on" },
2328 { CA_ARG_GRAVITY_OFF, "off" },
2329 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2334 static struct ValueTextInfo options_action_arg_direction[] =
2336 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2337 { CA_ARG_DIRECTION_NONE, "none" },
2338 { CA_ARG_DIRECTION_LEFT, "left" },
2339 { CA_ARG_DIRECTION_RIGHT, "right" },
2340 { CA_ARG_DIRECTION_UP, "up" },
2341 { CA_ARG_DIRECTION_DOWN, "down" },
2342 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2343 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2348 static struct ValueTextInfo options_action_arg_scan_mode[] =
2350 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2351 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2352 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2357 static struct ValueTextInfo options_action_arg_inventory[] =
2359 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2360 { CA_ARG_ELEMENT_TARGET, "+ target" },
2361 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2362 { CA_ARG_ELEMENT_ACTION, "+ action" },
2363 { CA_ARG_UNDEFINED, " " },
2364 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2365 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2366 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2367 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2368 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2369 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2370 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2371 { CA_ARG_UNDEFINED, " " },
2372 { CA_ARG_INVENTORY_RESET, "reset" },
2377 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2378 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2383 static struct ValueTextInfo options_group_choice_mode[] =
2385 { ANIM_RANDOM, "random" },
2386 { ANIM_LOOP, "loop" },
2387 { ANIM_LINEAR, "linear" },
2388 { ANIM_PINGPONG, "pingpong" },
2389 { ANIM_PINGPONG2, "pingpong 2" },
2394 static struct ValueTextInfo *action_arg_modes[] =
2396 options_action_mode_none,
2397 options_action_mode_assign,
2398 options_action_mode_add_remove,
2399 options_action_mode_calculate,
2406 struct ValueTextInfo *options;
2408 action_arg_options[] =
2410 { CA_NO_ACTION, 0, options_action_arg_none, },
2411 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2412 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2413 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2414 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2415 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2416 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2417 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2418 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2419 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2420 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2421 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2422 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2423 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2424 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2425 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2426 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2427 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2428 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2429 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2430 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2439 int gadget_id_align;
2440 int size; // char size of selectbox or '-1' (dynamically determined)
2441 struct ValueTextInfo *options;
2443 char *text_above, *text_left, *text_right, *infotext;
2444 } selectbox_info[ED_NUM_SELECTBOX] =
2446 // ---------- level and editor settings -------------------------------------
2449 -1, ED_LEVEL_SETTINGS_YPOS(8),
2450 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2452 options_time_or_steps,
2453 &level.use_step_counter,
2454 NULL, NULL, "(0 => no limit)", "time or step limit"
2457 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
2458 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2460 options_game_engine_type,
2461 &level.game_engine_type,
2462 NULL, "game engine:", NULL, "game engine"
2465 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2466 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2468 options_levelset_save_mode,
2469 &levelset_save_mode,
2470 "Action:", NULL, NULL, "action when saving level set"
2473 // ---------- element settings: configure (several elements) ----------------
2476 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2477 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2479 options_wind_direction,
2480 &level.wind_direction_initial,
2481 NULL, "initial wind direction:", NULL, "initial wind direction"
2484 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2485 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2487 options_player_speed,
2488 &level.initial_player_stepsize[0],
2489 NULL, "initial player speed:", NULL, "initial player speed"
2492 // ---------- element settings: configure 1 (custom elements) ---------------
2495 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2496 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2498 options_access_type,
2499 &custom_element.access_type,
2500 NULL, NULL, NULL, "type of access to this field"
2503 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2504 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2506 options_access_layer,
2507 &custom_element.access_layer,
2508 NULL, NULL, NULL, "layer of access for this field"
2511 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2512 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2514 options_access_protected,
2515 &custom_element.access_protected,
2516 NULL, NULL, NULL, "protected access for this field"
2519 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2520 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2522 options_access_direction,
2523 &custom_element.access_direction,
2524 NULL, "from", NULL, "access direction for this field"
2527 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2528 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2530 options_walk_to_action,
2531 &custom_element.walk_to_action,
2532 NULL, NULL, NULL, "diggable/collectible/pushable"
2535 // ---------- element settings: configure 2 (custom elements) ---------------
2538 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2539 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2541 options_move_pattern,
2542 &custom_element.move_pattern,
2543 NULL, "can move", NULL, "element move pattern"
2546 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2547 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2549 options_move_direction,
2550 &custom_element.move_direction_initial,
2551 NULL, "starts moving", NULL, "initial element move direction"
2554 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2555 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2557 options_move_stepsize,
2558 &custom_element.move_stepsize,
2559 NULL, "move/fall speed", NULL, "speed of element movement"
2562 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2563 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2565 options_move_leave_type,
2566 &custom_element.move_leave_type,
2567 // left text with leading spaces to place gadget next to "can dig" gadget
2568 // (needed because drawing area gadgets created after selectbox gadgets)
2569 // NULL, "can dig: can", ":", "leave behind or change element"
2570 NULL, " can", ":", "leave behind or change element"
2573 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2574 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2576 options_smash_targets,
2577 &custom_element.smash_targets,
2578 NULL, "can smash", NULL, "elements that can be smashed"
2581 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2582 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2584 options_slippery_type,
2585 &custom_element.slippery_type,
2586 NULL, "slippery", NULL, "where other elements fall down"
2589 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2590 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2593 &custom_element.deadliness,
2594 NULL, "deadly when", NULL, "deadliness of element"
2597 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2598 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2600 options_explosion_type,
2601 &custom_element.explosion_type,
2602 NULL, "can explode", NULL, "explosion type"
2605 // ---------- element settings: advanced (custom elements) ------------------
2608 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2609 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2612 &custom_element_change.delay_frames,
2613 NULL, "delay time given in", NULL, "delay time units for change"
2616 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2617 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2619 options_change_direct_action,
2620 &custom_element_change.direct_action,
2621 NULL, NULL, NULL, "type of direct action"
2624 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2625 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2627 options_change_other_action,
2628 &custom_element_change.other_action,
2629 NULL, NULL, "element:", "type of other element action"
2632 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2633 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2635 options_change_trigger_side,
2636 &custom_element_change.trigger_side,
2637 NULL, "at", "side", "element side triggering change"
2640 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2641 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2643 options_change_trigger_player,
2644 &custom_element_change.trigger_player,
2645 NULL, "player:", " ", "player that causes change"
2648 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2649 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2651 options_change_trigger_page,
2652 &custom_element_change.trigger_page,
2653 NULL, "page:", NULL, "change page that causes change"
2656 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2657 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2659 options_change_replace_when,
2660 &custom_element_change.replace_when,
2661 NULL, "replace when", NULL, "which elements can be replaced"
2664 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2665 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2667 options_action_type,
2668 &custom_element_change.action_type,
2669 NULL, NULL, NULL, "action on specified condition"
2672 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2673 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2675 options_action_mode_none,
2676 &custom_element_change.action_mode,
2677 NULL, NULL, NULL, "action operator"
2680 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2681 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2683 options_action_arg_none,
2684 &custom_element_change.action_arg,
2685 NULL, NULL, NULL, "action parameter"
2688 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2689 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2691 options_change_page,
2692 &custom_element.current_change_page,
2693 NULL, NULL, NULL, "element change page"
2696 // ---------- element settings: configure (group elements) ------------------
2699 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2700 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2702 options_group_choice_mode,
2703 &group_element_info.choice_mode,
2704 NULL, "choice type:", NULL, "type of group element choice"
2712 int gadget_id_align;
2715 char *text_above, *text_left, *text_right, *infotext;
2716 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2718 // ---------- level and editor settings (tabs) ------------------------------
2721 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2722 GADGET_ID_LEVELINFO_LEVEL, GADGET_ID_NONE,
2724 NULL, NULL, NULL, "Configure level properties"
2728 GADGET_ID_LEVELINFO_LEVELSET, GADGET_ID_LEVELINFO_LEVEL,
2730 NULL, NULL, NULL, "Update this or create new level set"
2734 GADGET_ID_LEVELINFO_EDITOR, GADGET_ID_LEVELINFO_LEVELSET,
2736 NULL, NULL, NULL, "Configure editor properties"
2739 // ---------- element settings (tabs) ---------------------------------------
2742 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2743 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2745 NULL, NULL, NULL, "Show information about element"
2749 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2751 NULL, NULL, NULL, "Configure element properties"
2755 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2757 NULL, NULL, NULL, "Configure element properties, part 1"
2761 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2763 NULL, NULL, NULL, "Configure element properties, part 2"
2767 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2769 NULL, NULL, NULL, "Configure custom element change pages"
2772 // ---------- level and editor settings (buttons) ---------------------------
2775 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2776 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
2778 NULL, NULL, NULL, "Update or create level set"
2781 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2782 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2784 NULL, NULL, "this level as level template",
2785 "Save current settings as new template"
2788 // ---------- element settings (buttons) ------------------------------------
2792 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2794 NULL, " ", "As Template",
2795 "Save current settings as new template"
2799 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2801 NULL, NULL, NULL, "Add new change page"
2805 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2807 NULL, NULL, NULL, "Delete current change page"
2816 int gadget_id_align;
2817 char *text_left, *text_right, *infotext;
2818 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2821 IMG_EDITOR_COUNTER_DOWN,
2822 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2823 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2824 NULL, NULL, "select previous change page"
2827 IMG_EDITOR_COUNTER_UP,
2828 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2829 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2830 NULL, "change page", "select next change page"
2833 IMG_GFX_EDITOR_BUTTON_CP_COPY,
2834 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2835 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2836 " ", NULL, "copy settings from this change page"
2839 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
2840 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2841 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2842 NULL, NULL, "paste settings to this change page"
2849 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2856 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2859 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2860 GADGET_ID_SCROLL_UP,
2861 "scroll level editing area up"
2864 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2865 GADGET_ID_SCROLL_DOWN,
2866 "scroll level editing area down"
2869 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2870 GADGET_ID_SCROLL_LEFT,
2871 "scroll level editing area left"
2874 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2875 GADGET_ID_SCROLL_RIGHT,
2876 "scroll level editing area right"
2879 IMG_EDITOR_PALETTE_SCROLL_UP,
2880 GADGET_ID_SCROLL_LIST_UP,
2881 "scroll element list up ('Page Up')"
2884 IMG_EDITOR_PALETTE_SCROLL_DOWN,
2885 GADGET_ID_SCROLL_LIST_DOWN,
2886 "scroll element list down ('Page Down')"
2894 int wheel_x, wheel_y;
2895 int wheel_width, wheel_height;
2896 } scrollbar_pos[ED_NUM_SCROLLBARS];
2904 } scrollbar_info[ED_NUM_SCROLLBARS] =
2907 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2908 GD_TYPE_SCROLLBAR_HORIZONTAL,
2909 GADGET_ID_SCROLL_HORIZONTAL,
2910 "scroll level editing area horizontally"
2913 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2914 GD_TYPE_SCROLLBAR_VERTICAL,
2915 GADGET_ID_SCROLL_VERTICAL,
2916 "scroll level editing area vertically"
2919 IMG_EDITOR_PALETTE_SCROLLBAR,
2920 GD_TYPE_SCROLLBAR_VERTICAL,
2921 GADGET_ID_SCROLL_LIST_VERTICAL,
2922 "scroll element list vertically"
2931 int gadget_id_align;
2932 int radio_button_nr;
2935 char *text_left, *text_right, *infotext;
2936 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
2939 -1, ED_LEVEL_SETTINGS_YPOS(0),
2940 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
2941 RADIO_NR_RANDOM_ELEMENTS,
2942 &random_placement_method, RANDOM_USE_PERCENTAGE,
2943 " ", "percentage", "use percentage for random elements"
2946 -1, ED_LEVEL_SETTINGS_YPOS(0),
2947 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
2948 RADIO_NR_RANDOM_ELEMENTS,
2949 &random_placement_method, RANDOM_USE_QUANTITY,
2950 " ", "quantity", "use quantity for random elements"
2958 int gadget_id_align;
2960 char *text_above, *text_left, *text_right, *infotext;
2961 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
2963 // ---------- level and editor settings -------------------------------------
2966 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2967 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
2968 &level.auto_count_gems,
2970 "automatically count gems needed", "set counter to number of gems"
2973 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
2974 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
2975 &levelset_use_levelset_artwork,
2977 "use current custom artwork", "use custom artwork of this level set"
2980 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
2981 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
2982 &levelset_copy_level_template,
2984 "copy current level template", "copy level template of this level set"
2987 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
2988 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
2989 &random_placement_background_restricted,
2991 "restrict random placement to:", "set random placement restriction"
2994 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
2995 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
2996 &setup.editor.use_template_for_new_levels,
2997 "Template for new levels and CE/GE:", NULL,
2998 "use template for new levels", "use template for level properties"
3001 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3002 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3003 &level.use_custom_template,
3005 "use template for custom elements", "use template for custom properties"
3008 // ---------- element settings: configure (various elements) ----------------
3011 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3012 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3013 &stick_element_properties_window,
3015 "stick this screen to edit content","stick this screen to edit content"
3018 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3019 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3020 &level.em_slippery_gems,
3022 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3025 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3026 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3027 &level.em_explodes_by_fire,
3029 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3032 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3033 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3034 &level.use_spring_bug,
3036 "use spring pushing bug", "use odd spring pushing behaviour"
3039 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3040 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3041 &level.use_time_orb_bug,
3043 "use time orb bug", "use odd time orb behaviour"
3046 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3047 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3048 &level.use_life_bugs,
3050 "use buggy element behaviour", "use odd (historic) element behaviour"
3053 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3054 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3057 "create single random element", "only create one element from content"
3060 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3061 GADGET_ID_INITIAL_BALL_STATE, GADGET_ID_NONE,
3062 &level.ball_state_initial,
3064 "magic ball initially activated", "activate magic ball after level start"
3067 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3068 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3069 &level.grow_into_diggable,
3071 "can grow into anything diggable", "grow into more than just sand"
3074 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3075 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3076 &level.sb_fields_needed,
3078 "all fields need to be filled", "require all SB fields to be solved"
3081 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3082 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3083 &level.sb_objects_needed,
3085 "all objects need to be placed", "require all SB objects to be solved"
3088 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3089 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3090 &level.auto_exit_sokoban,
3092 "exit level if all tasks solved", "automatically finish Sokoban levels"
3095 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3096 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3097 &level.solved_by_one_player,
3099 "only one player must enter exit", "level solved by first player in exit"
3102 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3103 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3104 &level.continuous_snapping,
3106 "continuous snapping", "use snapping without releasing key"
3109 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3110 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3111 &level.block_snap_field,
3113 "block snapped field when snapping", "use snapping delay to show animation"
3116 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3117 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3118 &level.block_last_field,
3120 "block last field when moving", "player blocks last field when moving"
3123 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3124 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3125 &level.sp_block_last_field,
3127 "block last field when moving", "player blocks last field when moving"
3130 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3131 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3132 &level.instant_relocation,
3134 "no scrolling when relocating", "player gets relocated without delay"
3137 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3138 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3139 &level.shifted_relocation,
3141 "no centering when relocating", "level not centered after relocation"
3144 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3145 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3146 &level.lazy_relocation,
3148 "only redraw off-screen relocation","no redraw if relocation target visible"
3151 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3152 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3153 &level.use_start_element[0],
3155 "use level start element:", "start level at this element's position"
3158 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3159 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3160 &level.use_artwork_element[0],
3162 "use artwork from element:", "use player artwork from other element"
3165 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3166 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3167 &level.use_explosion_element[0],
3169 "use explosion from element:", "use explosion properties from element"
3172 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3173 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3174 &level.initial_player_gravity[0],
3176 "use initial gravity", "set initial player gravity"
3179 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3180 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3181 &level.use_initial_inventory[0],
3183 "use initial inventory:", "use collected elements on level start"
3186 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3187 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3188 &level.can_pass_to_walkable,
3190 "can pass to walkable element", "player can pass to empty or walkable"
3193 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3194 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3195 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3197 "can fall into acid (with gravity)","player can fall into acid pool"
3200 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3201 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3202 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3204 "can move into acid", "element can move into acid pool"
3207 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3208 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3209 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3211 "deadly when colliding with", "element is deadly when hitting player"
3214 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3215 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3216 &level.envelope[0].autowrap,
3218 "auto-wrap", "automatically wrap envelope text"
3221 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3222 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3223 &level.envelope[0].centered,
3225 "centered", "automatically center envelope text"
3228 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3229 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3230 &level.mm_laser_red,
3231 "choose color components for laser:", NULL,
3232 "red", "use red color components in laser"
3235 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3236 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3237 &level.mm_laser_green,
3239 "green", "use green color components in laser"
3242 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3243 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3244 &level.mm_laser_blue,
3246 "blue", "use blue color components in laser"
3249 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3250 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3251 &level.df_laser_red,
3252 "choose color components for laser:", NULL,
3253 "red", "use red color components in laser"
3256 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3257 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3258 &level.df_laser_green,
3260 "green", "use green color components in laser"
3263 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3264 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3265 &level.df_laser_blue,
3267 "blue", "use blue color components in laser"
3270 // ---------- element settings: configure 1 (custom elements) ---------------
3273 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3274 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3275 &custom_element.use_gfx_element,
3277 "use graphic of element:", "use existing element graphic"
3280 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3281 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3282 &level.use_custom_template,
3284 "use template", "use template for custom properties"
3287 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3288 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3289 &custom_element_properties[EP_ACCESSIBLE],
3291 NULL, "player can walk to or pass this field"
3294 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3295 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3296 &custom_element_properties[EP_GRAVITY_REACHABLE],
3298 "reachable despite gravity", "player can walk/dig despite gravity"
3301 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3302 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3303 &custom_element.use_last_ce_value,
3305 "use last CE value after change", "use last CE value after change"
3308 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3309 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3310 &custom_element_properties[EP_WALK_TO_OBJECT],
3312 NULL, "player can dig/collect/push element"
3315 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3316 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3317 &custom_element_properties[EP_INDESTRUCTIBLE],
3319 "indestructible", "element is indestructible"
3322 // ---------- element settings: configure 2 (custom elements) ---------------
3325 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3326 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3327 &custom_element_properties[EP_CAN_MOVE],
3329 NULL, "element can move with some pattern"
3332 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
3333 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3334 &custom_element_properties[EP_CAN_FALL],
3336 "can fall", "element can fall down"
3339 -1, ED_ELEMENT_SETTINGS_YPOS(7),
3340 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3341 &custom_element_properties[EP_CAN_SMASH],
3343 NULL, "element can smash other elements"
3346 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3347 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3348 &custom_element_properties[EP_SLIPPERY],
3350 NULL, "other elements can fall down from it"
3353 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3354 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3355 &custom_element_properties[EP_DEADLY],
3357 NULL, "element can kill the player"
3360 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3361 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3362 &custom_element_properties[EP_CAN_EXPLODE],
3364 NULL, "element can explode"
3367 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
3368 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3369 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3371 "by fire", "element can explode by fire/explosion"
3374 -1, ED_ELEMENT_SETTINGS_YPOS(11),
3375 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3376 &custom_element_properties[EP_EXPLODES_SMASHED],
3378 "smashed", "element can explode when smashed"
3381 -1, ED_ELEMENT_SETTINGS_YPOS(11),
3382 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3383 &custom_element_properties[EP_EXPLODES_IMPACT],
3385 "impact", "element can explode on impact"
3388 // ---------- element settings: advanced (custom elements) ------------------
3391 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3392 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3393 &custom_element_change.can_change,
3395 "element changes to:", "change element on specified condition"
3398 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3399 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3400 &custom_element_change_events[CE_DELAY],
3402 NULL, "element changes after delay"
3405 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3406 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3407 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3409 NULL, "element changes by direct action"
3412 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3413 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3414 &custom_element_change_events[CE_BY_OTHER_ACTION],
3416 NULL, "element changes by other element"
3419 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3420 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3421 &custom_element_change.explode,
3423 "explode instead of change", "element explodes instead of change"
3426 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3427 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3428 &custom_element_change.use_target_content,
3430 "use extended change target:", "element changes to more elements"
3433 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3434 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3435 &custom_element_change.only_if_complete,
3437 "replace all or nothing", "only replace when all can be changed"
3440 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3441 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3442 &custom_element_change.use_random_replace,
3444 NULL, "use percentage for random replace"
3447 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3448 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3449 &custom_element_change.has_action,
3451 NULL, "execute action on specified condition"
3458 int xoffset, yoffset;
3460 int gadget_id_align;
3462 int area_xsize, area_ysize;
3463 char *text_left, *text_right, *text_below, *infotext;
3464 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3466 // ---------- level playfield content ---------------------------------------
3471 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3473 -1, -1, // these values are not constant, but can change at runtime
3474 NULL, NULL, NULL, NULL
3477 // ---------- yam yam content -----------------------------------------------
3480 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3481 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3482 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3483 &level.yamyam_content[0].e[0][0], 3, 3,
3484 NULL, NULL, "1", NULL
3487 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3488 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3489 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3490 &level.yamyam_content[1].e[0][0], 3, 3,
3491 NULL, NULL, "2", NULL
3494 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3495 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3496 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3497 &level.yamyam_content[2].e[0][0], 3, 3,
3498 NULL, NULL, "3", NULL
3501 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3502 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3503 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3504 &level.yamyam_content[3].e[0][0], 3, 3,
3505 NULL, NULL, "4", NULL
3508 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3509 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3510 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3511 &level.yamyam_content[4].e[0][0], 3, 3,
3512 NULL, NULL, "5", NULL
3515 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3516 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3517 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3518 &level.yamyam_content[5].e[0][0], 3, 3,
3519 NULL, NULL, "6", NULL
3522 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3523 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3524 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3525 &level.yamyam_content[6].e[0][0], 3, 3,
3526 NULL, NULL, "7", NULL
3529 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3530 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3531 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3532 &level.yamyam_content[7].e[0][0], 3, 3,
3533 NULL, NULL, "8", NULL
3536 // ---------- magic ball content --------------------------------------------
3539 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3540 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3541 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3542 &level.ball_content[0].e[0][0], 3, 3,
3543 NULL, NULL, "1", NULL
3546 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3547 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3548 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3549 &level.ball_content[1].e[0][0], 3, 3,
3550 NULL, NULL, "2", NULL
3553 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3554 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3555 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3556 &level.ball_content[2].e[0][0], 3, 3,
3557 NULL, NULL, "3", NULL
3560 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3561 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3562 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3563 &level.ball_content[3].e[0][0], 3, 3,
3564 NULL, NULL, "4", NULL
3567 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3568 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3569 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3570 &level.ball_content[4].e[0][0], 3, 3,
3571 NULL, NULL, "5", NULL
3574 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3575 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3576 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3577 &level.ball_content[5].e[0][0], 3, 3,
3578 NULL, NULL, "6", NULL
3581 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3582 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3583 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3584 &level.ball_content[6].e[0][0], 3, 3,
3585 NULL, NULL, "7", NULL
3588 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3589 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3590 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3591 &level.ball_content[7].e[0][0], 3, 3,
3592 NULL, NULL, "8", NULL
3595 // ---------- android content -----------------------------------------------
3598 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(5),
3599 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3600 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3601 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3602 "elements:", NULL, NULL, "elements android can clone"
3605 // ---------- amoeba content ------------------------------------------------
3608 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3609 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3610 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3611 &level.amoeba_content, 1, 1,
3612 "content:", NULL, NULL, "amoeba content"
3615 // ---------- level start element -------------------------------------------
3618 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3619 0, ED_AREA_1X1_SETTINGS_YOFF,
3620 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3621 &level.start_element[0], 1, 1,
3622 NULL, NULL, NULL, "level start element"
3625 // ---------- player artwork element ----------------------------------------
3628 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3629 0, ED_AREA_1X1_SETTINGS_YOFF,
3630 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3631 &level.artwork_element[0], 1, 1,
3632 NULL, NULL, NULL, "element for player artwork"
3635 // ---------- player explosion element --------------------------------------
3638 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
3639 0, ED_AREA_1X1_SETTINGS_YOFF,
3640 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3641 &level.explosion_element[0], 1, 1,
3642 NULL, NULL, NULL, "element for player explosion"
3645 // ---------- player initial inventory --------------------------------------
3648 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3649 0, ED_AREA_1X1_SETTINGS_YOFF,
3650 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3651 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3652 NULL, NULL, NULL, "content for initial inventory"
3655 // ---------- element settings: configure 1 (custom elements) ---------------
3657 // ---------- custom graphic ------------------------------------------------
3660 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3661 0, ED_AREA_1X1_SETTINGS_YOFF,
3662 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3663 &custom_element.gfx_element_initial,1, 1,
3664 NULL, NULL, NULL, "custom graphic element"
3667 // ---------- element settings: configure 2 (custom elements) ---------------
3669 // ---------- custom content (when exploding) -------------------------------
3672 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
3673 0, ED_AREA_3X3_SETTINGS_YOFF,
3674 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
3675 &custom_element.content.e[0][0], 3, 3,
3676 "content:", NULL, NULL, NULL
3679 // ---------- custom enter and leave element (when moving) ------------------
3682 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3683 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3684 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3685 &custom_element.move_enter_element, 1, 1,
3686 "can dig:", " ", NULL, "element that can be digged/collected"
3689 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3690 0, ED_AREA_1X1_SETTINGS_YOFF,
3691 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3692 &custom_element.move_leave_element, 1, 1,
3693 NULL, NULL, NULL, "element that will be left behind"
3696 // ---------- element settings: advanced (custom elements) ------------------
3698 // ---------- custom change target ------------------------------------------
3701 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3702 0, ED_AREA_1X1_SETTINGS_YOFF,
3703 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3704 &custom_element_change.target_element, 1, 1,
3705 NULL, "after/when:", NULL, "new target element after change"
3708 // ---------- custom change content (extended change target) ----------------
3711 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3712 0, ED_AREA_3X3_SETTINGS_YOFF,
3713 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
3714 &custom_element_change.target_content.e[0][0], 3, 3,
3715 NULL, NULL, NULL, "new extended elements after change"
3718 // ---------- custom change trigger (element causing change) ----------------
3721 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3722 0, ED_AREA_1X1_SETTINGS_YOFF,
3723 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3724 &custom_element_change.initial_trigger_element, 1, 1,
3725 NULL, NULL, NULL, "other element triggering change"
3728 // ---------- custom change action (element used for action) ----------------
3731 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3732 0, ED_AREA_1X1_SETTINGS_YOFF,
3733 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3734 &custom_element_change.action_element, 1, 1,
3735 NULL, NULL, NULL, "element used as action parameter"
3738 // ---------- group element content -----------------------------------------
3741 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3742 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3743 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3744 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3745 "content:", NULL, NULL, NULL
3748 // ---------- random background (for random painting) -----------------------
3751 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
3752 0, ED_AREA_1X1_LSETTINGS_YOFF,
3753 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3754 &random_placement_background_element, 1, 1,
3755 NULL, NULL, NULL, "random placement background"
3760 // ----------------------------------------------------------------------------
3761 // some internally used variables
3762 // ----------------------------------------------------------------------------
3764 // maximal size of level editor drawing area
3765 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3767 // actual size of level editor drawing area
3768 static int ed_fieldx, ed_fieldy;
3770 // actual position of level editor drawing area in level playfield
3771 static int level_xpos = -1, level_ypos = -1;
3773 // actual tile size used to display playfield drawing area
3774 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3775 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
3777 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3779 // drawing elements on the three mouse buttons
3780 static int new_element1 = EL_WALL;
3781 static int new_element2 = EL_EMPTY;
3782 static int new_element3 = EL_SAND;
3784 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3785 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3786 (button) == 2 ? new_element2 : \
3787 (button) == 3 ? new_element3 : EL_EMPTY)
3789 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
3791 static int use_permanent_palette = TRUE;
3793 #define PX (use_permanent_palette ? DX : SX)
3794 #define PY (use_permanent_palette ? DY : SY)
3795 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
3796 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
3798 // forward declaration for internal use
3799 static void CopyBrushToCursor(int, int);
3800 static void DeleteBrushFromCursor(void);
3801 static void ModifyEditorCounterValue(int, int);
3802 static void ModifyEditorCounterLimits(int, int, int);
3803 static void ModifyEditorSelectboxValue(int, int);
3804 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3805 static void ModifyEditorDrawingArea(int, int, int);
3806 static void ModifyEditorElementList(void);
3807 static void AdjustElementListScrollbar(void);
3808 static void RedrawDrawingElements(void);
3809 static void DrawDrawingWindowExt(boolean);
3810 static void DrawDrawingWindow(void);
3811 static void DrawLevelInfoWindow(void);
3812 static void DrawPropertiesWindow(void);
3813 static void DrawPaletteWindow(void);
3814 static void UpdateCustomElementGraphicGadgets(void);
3815 static boolean checkPropertiesConfig(int);
3816 static void SetAutomaticNumberOfGemsNeeded(void);
3817 static void ClearEditorGadgetInfoText(void);
3818 static void CopyLevelToUndoBuffer(int);
3819 static void HandleDrawingAreas(struct GadgetInfo *);
3820 static void HandleCounterButtons(struct GadgetInfo *);
3821 static void HandleTextInputGadgets(struct GadgetInfo *);
3822 static void HandleTextAreaGadgets(struct GadgetInfo *);
3823 static void HandleSelectboxGadgets(struct GadgetInfo *);
3824 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3825 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3826 static void HandleRadiobuttons(struct GadgetInfo *);
3827 static void HandleCheckbuttons(struct GadgetInfo *);
3828 static void HandleControlButtons(struct GadgetInfo *);
3829 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3830 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3831 static boolean AskToCopyAndModifyLevelTemplate(void);
3832 static boolean getDrawModeHiRes(void);
3833 static int getTabulatorBarWidth(void);
3834 static int getTabulatorBarHeight(void);
3835 static Pixel getTabulatorBarColor(void);
3837 static int num_editor_gadgets = 0; // dynamically determined
3839 static struct GadgetInfo **level_editor_gadget = NULL;
3840 static int *right_gadget_border = NULL;
3842 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3843 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3844 static boolean draw_with_brush = FALSE;
3845 static int properties_element = 0;
3847 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3848 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3849 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3850 static int undo_buffer_position = 0;
3851 static int undo_buffer_steps = 0;
3852 static int redo_buffer_steps = 0;
3854 static int edit_mode;
3855 static int edit_mode_levelinfo;
3856 static int edit_mode_properties;
3858 static int element_shift = 0;
3860 static int editor_el_players[] =
3867 static int *editor_el_players_ptr = editor_el_players;
3868 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
3870 static int editor_hl_boulderdash[] =
3872 EL_INTERNAL_CASCADE_BD_ACTIVE,
3878 static int editor_el_boulderdash[] =
3887 EL_BD_EXPANDABLE_WALL,
3895 EL_BD_BUTTERFLY_LEFT,
3897 EL_BD_BUTTERFLY_RIGHT,
3898 EL_BD_FIREFLY_RIGHT,
3901 EL_BD_BUTTERFLY_DOWN,
3905 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3906 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3907 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
3908 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
3910 static int editor_hl_emerald_mine[] =
3912 EL_INTERNAL_CASCADE_EM_ACTIVE,
3918 static int editor_el_emerald_mine[] =
3936 EL_EM_DYNAMITE_ACTIVE,
3955 EL_ACID_POOL_TOPLEFT,
3957 EL_ACID_POOL_TOPRIGHT,
3960 EL_ACID_POOL_BOTTOMLEFT,
3961 EL_ACID_POOL_BOTTOM,
3962 EL_ACID_POOL_BOTTOMRIGHT,
3980 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
3981 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
3982 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
3983 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
3985 static int editor_hl_emerald_mine_club[] =
3987 EL_INTERNAL_CASCADE_EMC_ACTIVE,
3993 static int editor_el_emerald_mine_club[] =
4020 EL_EMC_WALL_SLIPPERY_1,
4021 EL_EMC_WALL_SLIPPERY_2,
4022 EL_EMC_WALL_SLIPPERY_3,
4023 EL_EMC_WALL_SLIPPERY_4,
4046 EL_EMC_MAGIC_BALL_SWITCH,
4048 EL_EMC_SPRING_BUMPER,
4057 EL_BALLOON_SWITCH_UP,
4058 EL_BALLOON_SWITCH_ANY,
4061 EL_BALLOON_SWITCH_LEFT,
4063 EL_BALLOON_SWITCH_RIGHT,
4067 EL_BALLOON_SWITCH_DOWN,
4068 EL_BALLOON_SWITCH_NONE,
4070 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4071 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4072 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4073 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4075 static int editor_hl_rnd[] =
4077 EL_INTERNAL_CASCADE_RND_ACTIVE,
4083 static int editor_el_rnd[] =
4086 EL_DYNAMITE_ACTIVE, // RND
4120 EL_WALL_EMERALD_YELLOW,
4121 EL_WALL_EMERALD_RED,
4122 EL_WALL_EMERALD_PURPLE,
4140 EL_DYNABOMB_INCREASE_NUMBER,
4141 EL_DYNABOMB_INCREASE_SIZE,
4142 EL_DYNABOMB_INCREASE_POWER,
4162 EL_INVISIBLE_STEELWALL,
4166 EL_EXPANDABLE_WALL_HORIZONTAL,
4167 EL_EXPANDABLE_WALL_VERTICAL,
4168 EL_EXPANDABLE_WALL_ANY,
4170 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4171 static int *editor_el_rnd_ptr = editor_el_rnd;
4172 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4173 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4175 static int editor_hl_sokoban[] =
4177 EL_INTERNAL_CASCADE_SB_ACTIVE,
4183 static int editor_el_sokoban[] =
4186 EL_SOKOBAN_FIELD_EMPTY,
4187 EL_SOKOBAN_FIELD_FULL,
4188 EL_SOKOBAN_FIELD_PLAYER,
4190 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4191 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4192 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4193 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4195 static int editor_hl_supaplex[] =
4197 EL_INTERNAL_CASCADE_SP_ACTIVE,
4203 static int editor_el_supaplex[] =
4221 EL_SP_PORT_HORIZONTAL,
4222 EL_SP_PORT_VERTICAL,
4230 EL_SP_GRAVITY_PORT_LEFT,
4231 EL_SP_GRAVITY_PORT_RIGHT,
4232 EL_SP_GRAVITY_PORT_UP,
4233 EL_SP_GRAVITY_PORT_DOWN,
4235 EL_SP_GRAVITY_ON_PORT_LEFT,
4236 EL_SP_GRAVITY_ON_PORT_RIGHT,
4237 EL_SP_GRAVITY_ON_PORT_UP,
4238 EL_SP_GRAVITY_ON_PORT_DOWN,
4240 EL_SP_GRAVITY_OFF_PORT_LEFT,
4241 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4242 EL_SP_GRAVITY_OFF_PORT_UP,
4243 EL_SP_GRAVITY_OFF_PORT_DOWN,
4245 EL_SP_HARDWARE_GRAY,
4246 EL_SP_HARDWARE_GREEN,
4247 EL_SP_HARDWARE_BLUE,
4250 EL_SP_HARDWARE_BASE_1,
4251 EL_SP_HARDWARE_BASE_2,
4252 EL_SP_HARDWARE_BASE_3,
4253 EL_SP_HARDWARE_BASE_4,
4255 EL_SP_HARDWARE_BASE_5,
4256 EL_SP_HARDWARE_BASE_6,
4257 EL_SP_HARDWARE_YELLOW,
4265 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4266 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4267 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4268 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4270 static int editor_hl_diamond_caves[] =
4272 EL_INTERNAL_CASCADE_DC_ACTIVE,
4278 static int editor_el_diamond_caves[] =
4280 EL_EM_STEEL_EXIT_CLOSED, // DC2
4281 EL_EM_STEEL_EXIT_OPEN, // DC2
4282 EL_WALL_EMERALD, // DC2
4283 EL_WALL_DIAMOND, // DC2
4290 EL_CONVEYOR_BELT_1_LEFT,
4291 EL_CONVEYOR_BELT_1_MIDDLE,
4292 EL_CONVEYOR_BELT_1_RIGHT,
4293 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4295 EL_CONVEYOR_BELT_2_LEFT,
4296 EL_CONVEYOR_BELT_2_MIDDLE,
4297 EL_CONVEYOR_BELT_2_RIGHT,
4298 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4300 EL_CONVEYOR_BELT_3_LEFT,
4301 EL_CONVEYOR_BELT_3_MIDDLE,
4302 EL_CONVEYOR_BELT_3_RIGHT,
4303 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4305 EL_CONVEYOR_BELT_4_LEFT,
4306 EL_CONVEYOR_BELT_4_MIDDLE,
4307 EL_CONVEYOR_BELT_4_RIGHT,
4308 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4310 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4311 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4312 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4313 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4315 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4316 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4317 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4318 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4323 EL_DC_TIMEGATE_SWITCH,
4325 EL_SWITCHGATE_CLOSED,
4327 EL_SWITCHGATE_SWITCH_UP,
4328 EL_SWITCHGATE_SWITCH_DOWN,
4331 EL_LIGHT_SWITCH_ACTIVE,
4332 EL_DC_SWITCHGATE_SWITCH_UP,
4333 EL_DC_SWITCHGATE_SWITCH_DOWN,
4335 EL_STEEL_EXIT_CLOSED,
4337 EL_STEELWALL_SLIPPERY,
4340 EL_QUICKSAND_FAST_EMPTY,
4341 EL_QUICKSAND_FAST_FULL,
4355 EL_SIGN_RADIOACTIVITY,
4361 EL_SIGN_ENTRY_FORBIDDEN,
4362 EL_SIGN_EMERGENCY_EXIT,
4387 EL_DC_STEELWALL_2_SINGLE,
4388 EL_DC_STEELWALL_2_TOP,
4389 EL_SIGN_EXCLAMATION,
4392 EL_DC_STEELWALL_2_LEFT,
4393 EL_DC_STEELWALL_2_MIDDLE,
4394 EL_DC_STEELWALL_2_HORIZONTAL,
4395 EL_DC_STEELWALL_2_RIGHT,
4397 EL_DC_STEELWALL_1_TOPLEFT,
4398 EL_DC_STEELWALL_2_VERTICAL,
4399 EL_DC_STEELWALL_1_TOPRIGHT,
4402 EL_DC_STEELWALL_1_VERTICAL,
4403 EL_DC_STEELWALL_2_BOTTOM,
4405 EL_DC_GATE_WHITE_GRAY,
4407 EL_DC_STEELWALL_1_BOTTOMLEFT,
4408 EL_DC_STEELWALL_1_HORIZONTAL,
4409 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4410 EL_DC_GATE_FAKE_GRAY,
4412 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4413 EL_DC_STEELWALL_1_BOTTOM,
4414 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
4415 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
4417 EL_DC_STEELWALL_1_RIGHT,
4419 EL_DC_STEELWALL_1_LEFT,
4420 EL_EXPANDABLE_STEELWALL_VERTICAL,
4422 EL_DC_STEELWALL_1_TOPRIGHT_2,
4423 EL_DC_STEELWALL_1_TOP,
4424 EL_DC_STEELWALL_1_TOPLEFT_2,
4425 EL_EXPANDABLE_STEELWALL_ANY,
4427 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
4428 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
4429 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
4430 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
4432 static int editor_hl_dx_boulderdash[] =
4434 EL_INTERNAL_CASCADE_DX_ACTIVE,
4440 static int editor_el_dx_boulderdash[] =
4444 EL_TUBE_HORIZONTAL_DOWN,
4448 EL_TUBE_VERTICAL_RIGHT,
4450 EL_TUBE_VERTICAL_LEFT,
4454 EL_TUBE_HORIZONTAL_UP,
4462 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
4463 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
4464 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
4465 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
4467 static int editor_hl_mirror_magic[] =
4469 EL_INTERNAL_CASCADE_MM_ACTIVE,
4475 static int editor_el_mirror_magic[] =
4477 EL_MM_MCDUFFIN_RIGHT,
4479 EL_MM_MCDUFFIN_LEFT,
4480 EL_MM_MCDUFFIN_DOWN,
4483 EL_MM_MIRROR_FIXED_START,
4484 EL_MM_POLARIZER_START,
4485 EL_MM_POLARIZER_CROSS_START,
4487 EL_MM_TELEPORTER_RED_START,
4488 EL_MM_TELEPORTER_YELLOW_START,
4489 EL_MM_TELEPORTER_GREEN_START,
4490 EL_MM_TELEPORTER_BLUE_START,
4503 EL_MM_LIGHTBULB_ACTIVE,
4517 EL_MM_STEEL_GRID_FIXED_1,
4518 EL_MM_STEEL_GRID_FIXED_2,
4519 EL_MM_STEEL_GRID_FIXED_3,
4520 EL_MM_STEEL_GRID_FIXED_4,
4522 EL_MM_WOODEN_GRID_FIXED_1,
4523 EL_MM_WOODEN_GRID_FIXED_2,
4524 EL_MM_WOODEN_GRID_FIXED_3,
4525 EL_MM_WOODEN_GRID_FIXED_4
4527 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
4528 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
4529 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
4530 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
4532 static int editor_hl_deflektor[] =
4534 EL_INTERNAL_CASCADE_DF_ACTIVE,
4540 static int editor_el_deflektor[] =
4547 EL_DF_RECEIVER_RIGHT,
4549 EL_DF_RECEIVER_LEFT,
4550 EL_DF_RECEIVER_DOWN,
4553 EL_DF_MIRROR_ROTATING_START,
4557 EL_DF_FIBRE_OPTIC_RED_1,
4558 EL_DF_FIBRE_OPTIC_YELLOW_1,
4559 EL_DF_FIBRE_OPTIC_GREEN_1,
4560 EL_DF_FIBRE_OPTIC_BLUE_1,
4562 EL_DF_STEEL_GRID_FIXED_START,
4563 EL_DF_STEEL_GRID_ROTATING_START,
4564 EL_DF_WOODEN_GRID_FIXED_START,
4565 EL_DF_WOODEN_GRID_ROTATING_START,
4572 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
4573 static int *editor_el_deflektor_ptr = editor_el_deflektor;
4574 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
4575 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
4577 static int editor_hl_chars[] =
4579 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
4585 static int editor_el_chars[] =
4667 EL_CHAR(CHAR_BYTE_COPYRIGHT),
4668 EL_CHAR(CHAR_BYTE_UMLAUT_A),
4669 EL_CHAR(CHAR_BYTE_UMLAUT_O),
4670 EL_CHAR(CHAR_BYTE_UMLAUT_U),
4672 EL_CHAR(CHAR_BYTE_DEGREE),
4673 EL_CHAR(CHAR_BYTE_REGISTERED),
4674 EL_CHAR(FONT_ASCII_CURSOR),
4675 EL_CHAR(FONT_ASCII_BUTTON),
4677 EL_CHAR(FONT_ASCII_UP),
4678 EL_CHAR(FONT_ASCII_DOWN),
4682 static int *editor_hl_chars_ptr = editor_hl_chars;
4683 static int *editor_el_chars_ptr = editor_el_chars;
4684 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
4685 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
4687 static int editor_hl_steel_chars[] =
4689 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
4695 static int editor_el_steel_chars[] =
4705 EL_STEEL_CHAR('\''),
4772 EL_STEEL_CHAR('\\'),
4777 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
4778 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
4779 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
4780 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
4782 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
4783 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
4784 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4785 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4787 EL_STEEL_CHAR(FONT_ASCII_UP),
4788 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4792 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4793 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4794 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
4795 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
4797 static int editor_hl_custom[] =
4799 EL_INTERNAL_CASCADE_CE_ACTIVE,
4805 static int editor_el_custom[] =
4807 EL_CUSTOM_START + 0,
4808 EL_CUSTOM_START + 1,
4809 EL_CUSTOM_START + 2,
4810 EL_CUSTOM_START + 3,
4812 EL_CUSTOM_START + 4,
4813 EL_CUSTOM_START + 5,
4814 EL_CUSTOM_START + 6,
4815 EL_CUSTOM_START + 7,
4817 EL_CUSTOM_START + 8,
4818 EL_CUSTOM_START + 9,
4819 EL_CUSTOM_START + 10,
4820 EL_CUSTOM_START + 11,
4822 EL_CUSTOM_START + 12,
4823 EL_CUSTOM_START + 13,
4824 EL_CUSTOM_START + 14,
4825 EL_CUSTOM_START + 15,
4827 EL_CUSTOM_START + 16,
4828 EL_CUSTOM_START + 17,
4829 EL_CUSTOM_START + 18,
4830 EL_CUSTOM_START + 19,
4832 EL_CUSTOM_START + 20,
4833 EL_CUSTOM_START + 21,
4834 EL_CUSTOM_START + 22,
4835 EL_CUSTOM_START + 23,
4837 EL_CUSTOM_START + 24,
4838 EL_CUSTOM_START + 25,
4839 EL_CUSTOM_START + 26,
4840 EL_CUSTOM_START + 27,
4842 EL_CUSTOM_START + 28,
4843 EL_CUSTOM_START + 29,
4844 EL_CUSTOM_START + 30,
4845 EL_CUSTOM_START + 31,
4847 EL_CUSTOM_START + 32,
4848 EL_CUSTOM_START + 33,
4849 EL_CUSTOM_START + 34,
4850 EL_CUSTOM_START + 35,
4852 EL_CUSTOM_START + 36,
4853 EL_CUSTOM_START + 37,
4854 EL_CUSTOM_START + 38,
4855 EL_CUSTOM_START + 39,
4857 EL_CUSTOM_START + 40,
4858 EL_CUSTOM_START + 41,
4859 EL_CUSTOM_START + 42,
4860 EL_CUSTOM_START + 43,
4862 EL_CUSTOM_START + 44,
4863 EL_CUSTOM_START + 45,
4864 EL_CUSTOM_START + 46,
4865 EL_CUSTOM_START + 47,
4867 EL_CUSTOM_START + 48,
4868 EL_CUSTOM_START + 49,
4869 EL_CUSTOM_START + 50,
4870 EL_CUSTOM_START + 51,
4872 EL_CUSTOM_START + 52,
4873 EL_CUSTOM_START + 53,
4874 EL_CUSTOM_START + 54,
4875 EL_CUSTOM_START + 55,
4877 EL_CUSTOM_START + 56,
4878 EL_CUSTOM_START + 57,
4879 EL_CUSTOM_START + 58,
4880 EL_CUSTOM_START + 59,
4882 EL_CUSTOM_START + 60,
4883 EL_CUSTOM_START + 61,
4884 EL_CUSTOM_START + 62,
4885 EL_CUSTOM_START + 63,
4887 EL_CUSTOM_START + 64,
4888 EL_CUSTOM_START + 65,
4889 EL_CUSTOM_START + 66,
4890 EL_CUSTOM_START + 67,
4892 EL_CUSTOM_START + 68,
4893 EL_CUSTOM_START + 69,
4894 EL_CUSTOM_START + 70,
4895 EL_CUSTOM_START + 71,
4897 EL_CUSTOM_START + 72,
4898 EL_CUSTOM_START + 73,
4899 EL_CUSTOM_START + 74,
4900 EL_CUSTOM_START + 75,
4902 EL_CUSTOM_START + 76,
4903 EL_CUSTOM_START + 77,
4904 EL_CUSTOM_START + 78,
4905 EL_CUSTOM_START + 79,
4907 EL_CUSTOM_START + 80,
4908 EL_CUSTOM_START + 81,
4909 EL_CUSTOM_START + 82,
4910 EL_CUSTOM_START + 83,
4912 EL_CUSTOM_START + 84,
4913 EL_CUSTOM_START + 85,
4914 EL_CUSTOM_START + 86,
4915 EL_CUSTOM_START + 87,
4917 EL_CUSTOM_START + 88,
4918 EL_CUSTOM_START + 89,
4919 EL_CUSTOM_START + 90,
4920 EL_CUSTOM_START + 91,
4922 EL_CUSTOM_START + 92,
4923 EL_CUSTOM_START + 93,
4924 EL_CUSTOM_START + 94,
4925 EL_CUSTOM_START + 95,
4927 EL_CUSTOM_START + 96,
4928 EL_CUSTOM_START + 97,
4929 EL_CUSTOM_START + 98,
4930 EL_CUSTOM_START + 99,
4932 EL_CUSTOM_START + 100,
4933 EL_CUSTOM_START + 101,
4934 EL_CUSTOM_START + 102,
4935 EL_CUSTOM_START + 103,
4937 EL_CUSTOM_START + 104,
4938 EL_CUSTOM_START + 105,
4939 EL_CUSTOM_START + 106,
4940 EL_CUSTOM_START + 107,
4942 EL_CUSTOM_START + 108,
4943 EL_CUSTOM_START + 109,
4944 EL_CUSTOM_START + 110,
4945 EL_CUSTOM_START + 111,
4947 EL_CUSTOM_START + 112,
4948 EL_CUSTOM_START + 113,
4949 EL_CUSTOM_START + 114,
4950 EL_CUSTOM_START + 115,
4952 EL_CUSTOM_START + 116,
4953 EL_CUSTOM_START + 117,
4954 EL_CUSTOM_START + 118,
4955 EL_CUSTOM_START + 119,
4957 EL_CUSTOM_START + 120,
4958 EL_CUSTOM_START + 121,
4959 EL_CUSTOM_START + 122,
4960 EL_CUSTOM_START + 123,
4962 EL_CUSTOM_START + 124,
4963 EL_CUSTOM_START + 125,
4964 EL_CUSTOM_START + 126,
4965 EL_CUSTOM_START + 127,
4967 EL_CUSTOM_START + 128,
4968 EL_CUSTOM_START + 129,
4969 EL_CUSTOM_START + 130,
4970 EL_CUSTOM_START + 131,
4972 EL_CUSTOM_START + 132,
4973 EL_CUSTOM_START + 133,
4974 EL_CUSTOM_START + 134,
4975 EL_CUSTOM_START + 135,
4977 EL_CUSTOM_START + 136,
4978 EL_CUSTOM_START + 137,
4979 EL_CUSTOM_START + 138,
4980 EL_CUSTOM_START + 139,
4982 EL_CUSTOM_START + 140,
4983 EL_CUSTOM_START + 141,
4984 EL_CUSTOM_START + 142,
4985 EL_CUSTOM_START + 143,
4987 EL_CUSTOM_START + 144,
4988 EL_CUSTOM_START + 145,
4989 EL_CUSTOM_START + 146,
4990 EL_CUSTOM_START + 147,
4992 EL_CUSTOM_START + 148,
4993 EL_CUSTOM_START + 149,
4994 EL_CUSTOM_START + 150,
4995 EL_CUSTOM_START + 151,
4997 EL_CUSTOM_START + 152,
4998 EL_CUSTOM_START + 153,
4999 EL_CUSTOM_START + 154,
5000 EL_CUSTOM_START + 155,
5002 EL_CUSTOM_START + 156,
5003 EL_CUSTOM_START + 157,
5004 EL_CUSTOM_START + 158,
5005 EL_CUSTOM_START + 159,
5007 EL_CUSTOM_START + 160,
5008 EL_CUSTOM_START + 161,
5009 EL_CUSTOM_START + 162,
5010 EL_CUSTOM_START + 163,
5012 EL_CUSTOM_START + 164,
5013 EL_CUSTOM_START + 165,
5014 EL_CUSTOM_START + 166,
5015 EL_CUSTOM_START + 167,
5017 EL_CUSTOM_START + 168,
5018 EL_CUSTOM_START + 169,
5019 EL_CUSTOM_START + 170,
5020 EL_CUSTOM_START + 171,
5022 EL_CUSTOM_START + 172,
5023 EL_CUSTOM_START + 173,
5024 EL_CUSTOM_START + 174,
5025 EL_CUSTOM_START + 175,
5027 EL_CUSTOM_START + 176,
5028 EL_CUSTOM_START + 177,
5029 EL_CUSTOM_START + 178,
5030 EL_CUSTOM_START + 179,
5032 EL_CUSTOM_START + 180,
5033 EL_CUSTOM_START + 181,
5034 EL_CUSTOM_START + 182,
5035 EL_CUSTOM_START + 183,
5037 EL_CUSTOM_START + 184,
5038 EL_CUSTOM_START + 185,
5039 EL_CUSTOM_START + 186,
5040 EL_CUSTOM_START + 187,
5042 EL_CUSTOM_START + 188,
5043 EL_CUSTOM_START + 189,
5044 EL_CUSTOM_START + 190,
5045 EL_CUSTOM_START + 191,
5047 EL_CUSTOM_START + 192,
5048 EL_CUSTOM_START + 193,
5049 EL_CUSTOM_START + 194,
5050 EL_CUSTOM_START + 195,
5052 EL_CUSTOM_START + 196,
5053 EL_CUSTOM_START + 197,
5054 EL_CUSTOM_START + 198,
5055 EL_CUSTOM_START + 199,
5057 EL_CUSTOM_START + 200,
5058 EL_CUSTOM_START + 201,
5059 EL_CUSTOM_START + 202,
5060 EL_CUSTOM_START + 203,
5062 EL_CUSTOM_START + 204,
5063 EL_CUSTOM_START + 205,
5064 EL_CUSTOM_START + 206,
5065 EL_CUSTOM_START + 207,
5067 EL_CUSTOM_START + 208,
5068 EL_CUSTOM_START + 209,
5069 EL_CUSTOM_START + 210,
5070 EL_CUSTOM_START + 211,
5072 EL_CUSTOM_START + 212,
5073 EL_CUSTOM_START + 213,
5074 EL_CUSTOM_START + 214,
5075 EL_CUSTOM_START + 215,
5077 EL_CUSTOM_START + 216,
5078 EL_CUSTOM_START + 217,
5079 EL_CUSTOM_START + 218,
5080 EL_CUSTOM_START + 219,
5082 EL_CUSTOM_START + 220,
5083 EL_CUSTOM_START + 221,
5084 EL_CUSTOM_START + 222,
5085 EL_CUSTOM_START + 223,
5087 EL_CUSTOM_START + 224,
5088 EL_CUSTOM_START + 225,
5089 EL_CUSTOM_START + 226,
5090 EL_CUSTOM_START + 227,
5092 EL_CUSTOM_START + 228,
5093 EL_CUSTOM_START + 229,
5094 EL_CUSTOM_START + 230,
5095 EL_CUSTOM_START + 231,
5097 EL_CUSTOM_START + 232,
5098 EL_CUSTOM_START + 233,
5099 EL_CUSTOM_START + 234,
5100 EL_CUSTOM_START + 235,
5102 EL_CUSTOM_START + 236,
5103 EL_CUSTOM_START + 237,
5104 EL_CUSTOM_START + 238,
5105 EL_CUSTOM_START + 239,
5107 EL_CUSTOM_START + 240,
5108 EL_CUSTOM_START + 241,
5109 EL_CUSTOM_START + 242,
5110 EL_CUSTOM_START + 243,
5112 EL_CUSTOM_START + 244,
5113 EL_CUSTOM_START + 245,
5114 EL_CUSTOM_START + 246,
5115 EL_CUSTOM_START + 247,
5117 EL_CUSTOM_START + 248,
5118 EL_CUSTOM_START + 249,
5119 EL_CUSTOM_START + 250,
5120 EL_CUSTOM_START + 251,
5122 EL_CUSTOM_START + 252,
5123 EL_CUSTOM_START + 253,
5124 EL_CUSTOM_START + 254,
5125 EL_CUSTOM_START + 255
5127 static int *editor_hl_custom_ptr = editor_hl_custom;
5128 static int *editor_el_custom_ptr = editor_el_custom;
5129 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5130 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5132 static int editor_hl_group[] =
5134 EL_INTERNAL_CASCADE_GE_ACTIVE,
5140 static int editor_el_group[] =
5154 EL_GROUP_START + 10,
5155 EL_GROUP_START + 11,
5157 EL_GROUP_START + 12,
5158 EL_GROUP_START + 13,
5159 EL_GROUP_START + 14,
5160 EL_GROUP_START + 15,
5162 EL_GROUP_START + 16,
5163 EL_GROUP_START + 17,
5164 EL_GROUP_START + 18,
5165 EL_GROUP_START + 19,
5167 EL_GROUP_START + 20,
5168 EL_GROUP_START + 21,
5169 EL_GROUP_START + 22,
5170 EL_GROUP_START + 23,
5172 EL_GROUP_START + 24,
5173 EL_GROUP_START + 25,
5174 EL_GROUP_START + 26,
5175 EL_GROUP_START + 27,
5177 EL_GROUP_START + 28,
5178 EL_GROUP_START + 29,
5179 EL_GROUP_START + 30,
5182 static int *editor_hl_group_ptr = editor_hl_group;
5183 static int *editor_el_group_ptr = editor_el_group;
5184 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5185 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5187 static int editor_hl_reference[] =
5189 EL_INTERNAL_CASCADE_REF_ACTIVE,
5195 static int editor_el_reference[] =
5199 EL_TRIGGER_CE_VALUE,
5200 EL_TRIGGER_CE_SCORE,
5204 EL_CURRENT_CE_VALUE,
5205 EL_CURRENT_CE_SCORE,
5227 static int *editor_hl_reference_ptr = editor_hl_reference;
5228 static int *editor_el_reference_ptr = editor_el_reference;
5229 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5230 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5232 static int editor_hl_user_defined[] =
5234 EL_INTERNAL_CASCADE_USER_ACTIVE,
5240 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5241 static int *editor_el_user_defined_ptr = NULL;
5242 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5243 static int num_editor_el_user_defined = 0;
5245 static int editor_hl_dynamic[] =
5247 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5253 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5254 static int *editor_el_dynamic_ptr = NULL;
5255 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5256 static int num_editor_el_dynamic = 0;
5258 static int editor_hl_empty[] = { EL_EMPTY };
5259 static int *editor_el_empty = NULL; // dynamically allocated
5261 static int *editor_hl_empty_ptr = editor_hl_empty;
5262 static int *editor_el_empty_ptr = NULL;
5263 static int num_editor_hl_empty = 0;
5264 static int num_editor_el_empty = 0; // dynamically determined, if needed
5266 static boolean use_el_empty = FALSE;
5268 static int *editor_elements = NULL; // dynamically allocated
5269 static int num_editor_elements = 0; // dynamically determined
5271 static boolean setup_editor_cascade_never = FALSE;
5273 static boolean setup_editor_el_players = TRUE;
5274 static boolean setup_editor_el_boulderdash = TRUE;
5275 static boolean setup_editor_el_emerald_mine = TRUE;
5276 static boolean setup_editor_el_emerald_mine_club = TRUE;
5277 static boolean setup_editor_el_more = TRUE;
5278 static boolean setup_editor_el_sokoban = TRUE;
5279 static boolean setup_editor_el_supaplex = TRUE;
5280 static boolean setup_editor_el_diamond_caves = TRUE;
5281 static boolean setup_editor_el_dx_boulderdash = TRUE;
5282 static boolean setup_editor_el_mirror_magic = TRUE;
5283 static boolean setup_editor_el_deflektor = TRUE;
5284 static boolean setup_editor_el_chars = TRUE;
5285 static boolean setup_editor_el_steel_chars = TRUE;
5286 static boolean setup_editor_el_custom = TRUE;
5287 static boolean setup_editor_el_user_defined = TRUE;
5288 static boolean setup_editor_el_dynamic = TRUE;
5290 static int editor_hl_unused[] = { EL_EMPTY };
5291 static int *editor_hl_unused_ptr = editor_hl_unused;
5292 static int num_editor_hl_unused = 0;
5296 boolean *setup_value;
5297 boolean *setup_cascade_value;
5299 int **headline_list;
5300 int *headline_list_size;
5303 int *element_list_size;
5305 boolean last_setup_value;
5307 editor_elements_info[] =
5310 &setup_editor_el_players,
5311 &setup_editor_cascade_never,
5312 &editor_hl_unused_ptr, &num_editor_hl_unused,
5313 &editor_el_players_ptr, &num_editor_el_players
5316 &setup_editor_el_boulderdash,
5317 &setup.editor_cascade.el_bd,
5318 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5319 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5322 &setup_editor_el_emerald_mine,
5323 &setup.editor_cascade.el_em,
5324 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5325 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5328 &setup_editor_el_emerald_mine_club,
5329 &setup.editor_cascade.el_emc,
5330 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5331 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5334 &setup_editor_el_more,
5335 &setup.editor_cascade.el_rnd,
5336 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5337 &editor_el_rnd_ptr, &num_editor_el_rnd
5340 &setup_editor_el_sokoban,
5341 &setup.editor_cascade.el_sb,
5342 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5343 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5346 &setup_editor_el_supaplex,
5347 &setup.editor_cascade.el_sp,
5348 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5349 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5352 &setup_editor_el_diamond_caves,
5353 &setup.editor_cascade.el_dc,
5354 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5355 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5358 &setup_editor_el_dx_boulderdash,
5359 &setup.editor_cascade.el_dx,
5360 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5361 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
5364 &setup_editor_el_mirror_magic,
5365 &setup.editor_cascade.el_mm,
5366 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
5367 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
5370 &setup_editor_el_deflektor,
5371 &setup.editor_cascade.el_df,
5372 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
5373 &editor_el_deflektor_ptr, &num_editor_el_deflektor
5376 &setup_editor_el_chars,
5377 &setup.editor_cascade.el_chars,
5378 &editor_hl_chars_ptr, &num_editor_hl_chars,
5379 &editor_el_chars_ptr, &num_editor_el_chars
5382 &setup_editor_el_steel_chars,
5383 &setup.editor_cascade.el_steel_chars,
5384 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
5385 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
5388 &setup_editor_el_custom,
5389 &setup.editor_cascade.el_ce,
5390 &editor_hl_custom_ptr, &num_editor_hl_custom,
5391 &editor_el_custom_ptr, &num_editor_el_custom
5394 &setup_editor_el_custom,
5395 &setup.editor_cascade.el_ge,
5396 &editor_hl_group_ptr, &num_editor_hl_group,
5397 &editor_el_group_ptr, &num_editor_el_group
5400 &setup_editor_el_custom,
5401 &setup.editor_cascade.el_ref,
5402 &editor_hl_reference_ptr, &num_editor_hl_reference,
5403 &editor_el_reference_ptr, &num_editor_el_reference
5406 &setup_editor_el_user_defined,
5407 &setup.editor_cascade.el_user,
5408 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
5409 &editor_el_user_defined_ptr, &num_editor_el_user_defined
5412 &setup_editor_el_dynamic,
5413 &setup.editor_cascade.el_dynamic,
5414 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
5415 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
5420 &editor_hl_empty_ptr, &num_editor_hl_empty,
5421 &editor_el_empty_ptr, &num_editor_el_empty,
5432 // ----------------------------------------------------------------------------
5434 // ----------------------------------------------------------------------------
5436 static int getMaxInfoTextLength(void)
5438 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
5441 static int getTextWidthForGadget(char *text)
5446 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
5449 static int getTextWidthForDrawingArea(char *text)
5454 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
5457 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
5459 return (gi->x + gi->width + getTextWidthForGadget(text));
5462 static char *getElementInfoText(int element)
5464 char *info_text = NULL;
5466 if (element < MAX_NUM_ELEMENTS)
5468 if (strlen(element_info[element].description) > 0)
5469 info_text = element_info[element].description;
5470 else if (element_info[element].custom_description != NULL)
5471 info_text = element_info[element].custom_description;
5472 else if (element_info[element].editor_description != NULL)
5473 info_text = element_info[element].editor_description;
5476 if (info_text == NULL)
5477 info_text = INFOTEXT_UNKNOWN_ELEMENT;
5482 static char *getElementDescriptionFilenameExt(char *basename)
5484 char *elements_subdir = "elements";
5485 static char *elements_subdir2 = NULL;
5486 static char *filename = NULL;
5488 if (elements_subdir2 == NULL)
5489 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
5491 checked_free(filename);
5493 // 1st try: look for element description in current level set directory
5494 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
5495 if (fileExists(filename))
5500 // 2nd try: look for element description in the game's base directory
5501 filename = getPath3(options.docs_directory, elements_subdir, basename);
5502 if (fileExists(filename))
5508 static char *getElementDescriptionFilename(int element)
5510 char basename[MAX_FILENAME_LEN];
5513 // 1st try: look for element description file for exactly this element
5514 sprintf(basename, "%s.txt", element_info[element].token_name);
5515 filename = getElementDescriptionFilenameExt(basename);
5516 if (filename != NULL)
5519 // 2nd try: look for element description file for this element's class
5520 sprintf(basename, "%s.txt", element_info[element].class_name);
5521 filename = getElementDescriptionFilenameExt(basename);
5522 if (filename != NULL)
5528 static boolean suppressBorderElement(void)
5530 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
5531 lev_fieldx <= MAX_ED_FIELDX &&
5532 lev_fieldy <= MAX_ED_FIELDY);
5535 static void InitDynamicEditorElementList(int **elements, int *num_elements)
5537 boolean element_found[NUM_FILE_ELEMENTS];
5540 // initialize list of used elements to "not used"
5541 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5542 element_found[i] = FALSE;
5544 // find all elements used in current level
5545 for (y = 0; y < lev_fieldy; y++)
5546 for (x = 0; x < lev_fieldx; x++)
5547 if (Feld[x][y] < NUM_FILE_ELEMENTS) // should always be true
5548 element_found[Feld[x][y]] = TRUE;
5552 // count number of elements used in current level
5553 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5554 if (element_found[i])
5557 // add space for up to 3 more elements for padding that may be needed
5560 // free memory for old list of elements, if needed
5561 checked_free(*elements);
5563 // allocate memory for new list of elements
5564 *elements = checked_malloc(*num_elements * sizeof(int));
5568 // add all elements used in current level (non-custom/group elements)
5569 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5570 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5571 (*elements)[(*num_elements)++] = i;
5573 // add all elements used in current level (custom/group elements)
5574 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5575 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5576 (*elements)[(*num_elements)++] = i;
5578 while (*num_elements % 4) // pad with empty elements, if needed
5579 (*elements)[(*num_elements)++] = EL_EMPTY;
5582 static void ReinitializeElementList_EnableSections(void)
5584 // default: enable all element sections
5586 setup_editor_el_players = TRUE;
5587 setup_editor_el_boulderdash = TRUE;
5588 setup_editor_el_emerald_mine = TRUE;
5589 setup_editor_el_emerald_mine_club = TRUE;
5590 setup_editor_el_more = TRUE;
5591 setup_editor_el_sokoban = TRUE;
5592 setup_editor_el_supaplex = TRUE;
5593 setup_editor_el_diamond_caves = TRUE;
5594 setup_editor_el_dx_boulderdash = TRUE;
5595 setup_editor_el_mirror_magic = TRUE;
5596 setup_editor_el_deflektor = TRUE;
5597 setup_editor_el_chars = TRUE;
5598 setup_editor_el_steel_chars = TRUE;
5600 setup_editor_el_custom = TRUE;
5601 setup_editor_el_user_defined = TRUE;
5602 setup_editor_el_dynamic = TRUE;
5604 // now disable all element sections not to be displayed
5606 if (!setup.editor.el_classic)
5608 setup_editor_el_players = FALSE;
5609 setup_editor_el_boulderdash = FALSE;
5610 setup_editor_el_emerald_mine = FALSE;
5611 setup_editor_el_emerald_mine_club = FALSE;
5612 setup_editor_el_more = FALSE;
5613 setup_editor_el_sokoban = FALSE;
5614 setup_editor_el_supaplex = FALSE;
5615 setup_editor_el_diamond_caves = FALSE;
5616 setup_editor_el_dx_boulderdash = FALSE;
5617 setup_editor_el_mirror_magic = FALSE;
5618 setup_editor_el_deflektor = FALSE;
5619 setup_editor_el_chars = FALSE;
5620 setup_editor_el_steel_chars = FALSE;
5623 if (!setup.editor.el_custom)
5625 setup_editor_el_custom = FALSE;
5628 if (!setup.editor.el_user_defined)
5630 setup_editor_el_user_defined = FALSE;
5633 if (!setup.editor.el_dynamic)
5635 setup_editor_el_dynamic = FALSE;
5638 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
5640 setup_editor_el_mirror_magic = FALSE;
5641 setup_editor_el_deflektor = FALSE;
5643 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
5645 setup_editor_el_boulderdash = FALSE;
5646 setup_editor_el_more = FALSE;
5647 setup_editor_el_sokoban = FALSE;
5648 setup_editor_el_supaplex = FALSE;
5649 setup_editor_el_diamond_caves = FALSE;
5650 setup_editor_el_dx_boulderdash = FALSE;
5651 setup_editor_el_mirror_magic = FALSE;
5652 setup_editor_el_deflektor = FALSE;
5653 setup_editor_el_steel_chars = FALSE;
5655 setup_editor_el_custom = FALSE;
5657 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
5659 setup_editor_el_players = FALSE;
5660 setup_editor_el_boulderdash = FALSE;
5661 setup_editor_el_emerald_mine = FALSE;
5662 setup_editor_el_emerald_mine_club = FALSE;
5663 setup_editor_el_more = FALSE;
5664 setup_editor_el_sokoban = FALSE;
5665 setup_editor_el_diamond_caves = FALSE;
5666 setup_editor_el_dx_boulderdash = FALSE;
5667 setup_editor_el_mirror_magic = FALSE;
5668 setup_editor_el_deflektor = FALSE;
5669 setup_editor_el_chars = FALSE;
5670 setup_editor_el_steel_chars = FALSE;
5672 setup_editor_el_custom = FALSE;
5674 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
5676 setup_editor_el_players = FALSE;
5677 setup_editor_el_boulderdash = FALSE;
5678 setup_editor_el_emerald_mine = FALSE;
5679 setup_editor_el_emerald_mine_club = FALSE;
5680 setup_editor_el_more = FALSE;
5681 setup_editor_el_sokoban = FALSE;
5682 setup_editor_el_supaplex = FALSE;
5683 setup_editor_el_diamond_caves = FALSE;
5684 setup_editor_el_dx_boulderdash = FALSE;
5685 setup_editor_el_steel_chars = FALSE;
5687 setup_editor_el_custom = FALSE;
5691 static void ReinitializeElementList(void)
5693 static boolean initialization_needed = TRUE;
5697 ReinitializeElementList_EnableSections();
5699 if (initialization_needed)
5701 LoadSetup_EditorCascade(); // load last editor cascade state
5703 // initialize editor cascade element from saved cascade state
5704 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5706 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
5707 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
5709 if (IS_EDITOR_CASCADE(*cascade_element))
5711 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
5712 EL_CASCADE_INACTIVE(*cascade_element));
5715 initialization_needed = FALSE;
5718 checked_free(editor_elements);
5720 // reload optional user defined element list for each invocation of editor
5721 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
5722 &num_editor_el_user_defined);
5724 // initialize dynamic level element list for each invocation of editor
5725 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
5726 &num_editor_el_dynamic);
5728 // initialize list of empty elements (used for padding, if needed)
5729 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5730 editor_el_empty[i] = EL_EMPTY;
5732 // do some sanity checks for each element from element list
5733 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5735 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5737 int element = (*editor_elements_info[i].element_list)[j];
5739 if (element >= NUM_FILE_ELEMENTS)
5740 Error(ERR_WARN, "editor element %d is runtime element", element);
5742 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
5743 Error(ERR_WARN, "no element description text for element %d", element);
5747 num_editor_elements = 0;
5748 use_el_empty = FALSE;
5750 // determine size of element list
5751 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5753 boolean found_inactive_cascade = FALSE;
5755 if (*editor_elements_info[i].setup_value)
5757 if (setup.editor.el_headlines)
5759 // required for correct padding of palette headline buttons
5760 if (*editor_elements_info[i].headline_list_size > 0)
5761 num_editor_elements += editor.palette.cols;
5763 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5765 int element = (*editor_elements_info[i].headline_list)[j];
5767 if (IS_EDITOR_CASCADE_INACTIVE(element))
5768 found_inactive_cascade = TRUE;
5772 if (found_inactive_cascade)
5775 // required for correct padding of palette element buttons
5776 int element_list_size = *editor_elements_info[i].element_list_size;
5778 (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
5779 int element_buttons = editor.palette.cols * element_rows;
5781 num_editor_elements += element_buttons;
5785 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
5787 // offer at least as many elements as element buttons exist
5788 use_el_empty = TRUE;
5789 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
5791 num_editor_elements += num_editor_el_empty;
5795 num_editor_el_empty = 0;
5798 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
5800 // fill element list
5801 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5803 boolean found_inactive_cascade = FALSE;
5805 if (*editor_elements_info[i].setup_value)
5807 if (setup.editor.el_headlines)
5809 // required for correct padding of palette headline buttons
5810 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
5811 editor.palette.cols : 0);
5813 for (j = 0; j < headline_size; j++)
5815 // use empty elements for padding of palette headline buttons
5816 int element = (j < *editor_elements_info[i].headline_list_size ?
5817 (*editor_elements_info[i].headline_list)[j] :
5818 editor_el_empty[0]);
5820 editor_elements[pos++] = element;
5822 if (IS_EDITOR_CASCADE_INACTIVE(element))
5823 found_inactive_cascade = TRUE;
5827 if (found_inactive_cascade)
5830 // required for correct padding of palette element buttons
5831 int element_list_size = *editor_elements_info[i].element_list_size;
5833 (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
5834 int element_buttons = editor.palette.cols * element_rows;
5836 // copy all elements from element list
5837 for (j = 0; j < element_list_size; j++)
5838 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
5840 // use empty elements for padding of palette element buttons
5841 for (j = 0; j < element_buttons - element_list_size; j++)
5842 editor_elements[pos++] = editor_el_empty[0];
5846 // (this function is also called before editor gadgets are initialized!)
5847 AdjustElementListScrollbar();
5850 void PrintEditorElementList(void)
5852 boolean *stop = &setup_editor_el_user_defined;
5855 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
5857 int cascade_element = (*editor_elements_info[i].headline_list)[0];
5859 if (IS_EDITOR_CASCADE(cascade_element))
5861 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
5862 char *headline = element_info[cascade_element_show].editor_description;
5864 PrintLineWithPrefix("# ", "-", 77);
5865 Print("# %s\n", headline);
5866 PrintLineWithPrefix("# ", "-", 77);
5869 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5871 int element = (*editor_elements_info[i].headline_list)[j];
5873 if (IS_EDITOR_CASCADE(element))
5874 element = EL_CHAR_MINUS;
5876 Print("# %s\n", element_info[element].token_name);
5882 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5884 int element = (*editor_elements_info[i].element_list)[j];
5886 Print("# %s\n", element_info[element].token_name);
5894 static void ReinitializeElementListButtons(void)
5896 static boolean last_setup_value_headlines = FALSE;
5897 static boolean initialization_needed = TRUE;
5900 if (!initialization_needed) // check if editor element setup has changed
5902 if (last_setup_value_headlines != setup.editor.el_headlines)
5903 initialization_needed = TRUE;
5905 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5906 if (editor_elements_info[i].last_setup_value !=
5907 *editor_elements_info[i].setup_value)
5908 initialization_needed = TRUE;
5911 if (!initialization_needed)
5914 FreeLevelEditorGadgets();
5915 CreateLevelEditorGadgets();
5917 // store current setup values for next invocation of this function
5918 last_setup_value_headlines = setup.editor.el_headlines;
5919 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5920 editor_elements_info[i].last_setup_value =
5921 *editor_elements_info[i].setup_value;
5923 initialization_needed = FALSE;
5926 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
5929 int border_graphic =
5930 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
5931 struct GraphicInfo *g = &graphic_info[border_graphic];
5932 Bitmap *src_bitmap = g->bitmap;
5933 int src_x = g->src_x;
5934 int src_y = g->src_y;
5935 int border_size = g->border_size;
5936 int border_xpos = g->width - border_size;
5937 int border_ypos = g->height - border_size;
5938 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
5941 BlitBitmap(src_bitmap, drawto, src_x, src_y,
5942 border_size, border_size,
5943 dest_x - border_size, dest_y - border_size);
5944 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
5945 border_size, border_size,
5946 dest_x + width, dest_y - border_size);
5947 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
5948 border_size, border_size,
5949 dest_x - border_size, dest_y + height);
5950 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
5951 border_size, border_size,
5952 dest_x + width, dest_y + height);
5954 for (i = 0; i < width / tilesize; i++)
5956 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
5957 tilesize, border_size,
5958 dest_x + i * tilesize, dest_y - border_size);
5959 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
5960 tilesize, border_size,
5961 dest_x + i * tilesize, dest_y + height);
5964 for (i = 0; i < height / tilesize; i++)
5966 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
5967 border_size, tilesize,
5968 dest_x - border_size, dest_y + i * tilesize);
5969 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
5970 border_size, tilesize,
5971 dest_x + width, dest_y + i * tilesize);
5974 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
5977 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
5979 int xsize_tile = MAX(ed_tilesize, xsize);
5980 int ysize_tile = MAX(ed_tilesize, ysize);
5981 int xsize_full = xsize + 1;
5982 int ysize_full = ysize + 1;
5983 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
5984 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
5985 Pixel line_color = getTabulatorBarColor();
5987 if (line_color == BLACK_PIXEL) // black => transparent
5990 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
5991 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
5992 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
5995 static void DrawEditorLevelBorderLinesIfNeeded(void)
5997 int xsize = lev_fieldx * ed_tilesize;
5998 int ysize = lev_fieldy * ed_tilesize;
5999 int line_size = getTabulatorBarHeight();
6001 if (!suppressBorderElement())
6004 // draw little border line around editable level playfield
6007 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6010 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6012 if (xsize < SXSIZE && ysize < SYSIZE)
6013 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6016 static void DrawEditorElement(int x, int y, int element)
6018 DrawSizedElement(x, y, element, ed_tilesize);
6021 static void DrawEditorElementThruMask(int x, int y, int element)
6023 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6026 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6028 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6031 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6033 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6034 DrawEditorLevelBorderLinesIfNeeded();
6037 static void DrawDrawingArea(int id)
6039 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6042 int *value = drawingarea_info[id].value;
6043 int area_xsize = drawingarea_info[id].area_xsize;
6044 int area_ysize = drawingarea_info[id].area_ysize;
6045 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6047 for (x = 0; x < area_xsize; x++)
6048 for (y = 0; y < area_ysize; y++)
6049 DrawSizedGraphicExt(drawto,
6050 gi->x + x * tilesize,
6051 gi->y + y * tilesize,
6052 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6055 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6058 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6059 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6061 BlitBitmap(drawto, drawto,
6062 SX + (dx == -1 ? ed_tilesize : 0),
6063 SY + (dy == -1 ? ed_tilesize : 0),
6064 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6065 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6066 SX + (dx == +1 ? ed_tilesize : 0),
6067 SY + (dy == +1 ? ed_tilesize : 0));
6071 x = (dx == 1 ? 0 : ed_fieldx - 1);
6072 for (y = 0; y < ed_fieldy; y++)
6073 DrawEditorElementOrWall(x, y, from_x, from_y);
6077 y = (dy == 1 ? 0 : ed_fieldy - 1);
6078 for (x = 0; x < ed_fieldx; x++)
6079 DrawEditorElementOrWall(x, y, from_x, from_y);
6082 redraw_mask |= REDRAW_FIELD;
6086 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6089 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6092 static void CreateControlButtons(void)
6094 struct GadgetInfo *gi;
6097 // create toolbox buttons
6098 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6100 int id = controlbutton_info[i].gadget_id;
6101 int type = controlbutton_info[i].gadget_type;
6102 int graphic = controlbutton_info[i].graphic;
6103 struct XYTileSize *pos = controlbutton_info[i].pos;
6104 struct GraphicInfo *gd = &graphic_info[graphic];
6105 Bitmap *deco_bitmap = NULL;
6106 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6107 int tile_size = 0, deco_shift = 0;
6108 boolean deco_masked = FALSE;
6109 int gd_x1 = gd->src_x;
6110 int gd_y1 = gd->src_y;
6111 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6112 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6113 int gd_x1a = gd->src_x + gd->active_xoffset;
6114 int gd_y1a = gd->src_y + gd->active_yoffset;
6115 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6116 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6119 unsigned int event_mask;
6120 int radio_button_nr = RADIO_NR_NONE;
6121 boolean checked = FALSE;
6123 if (type == GD_TYPE_RADIO_BUTTON)
6125 event_mask = GD_EVENT_PRESSED;
6126 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6128 if (id == drawing_function)
6133 if (id == GADGET_ID_WRAP_LEFT ||
6134 id == GADGET_ID_WRAP_RIGHT ||
6135 id == GADGET_ID_WRAP_UP ||
6136 id == GADGET_ID_WRAP_DOWN)
6137 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6139 event_mask = GD_EVENT_RELEASED;
6142 if (id == GADGET_ID_PROPERTIES ||
6143 id == GADGET_ID_PALETTE)
6148 else if (id == GADGET_ID_ELEMENT_LEFT ||
6149 id == GADGET_ID_ELEMENT_MIDDLE ||
6150 id == GADGET_ID_ELEMENT_RIGHT)
6155 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6156 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6157 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6159 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6160 editor.button.element_left.tile_size :
6161 id == GADGET_ID_ELEMENT_MIDDLE ?
6162 editor.button.element_middle.tile_size :
6163 id == GADGET_ID_ELEMENT_RIGHT ?
6164 editor.button.element_right.tile_size : 0);
6166 // make sure that decoration does not overlap gadget border
6167 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6169 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6171 deco_xpos = (gd->width - tile_size) / 2;
6172 deco_ypos = (gd->height - tile_size) / 2;
6174 deco_masked = gd->draw_masked;
6182 gi = CreateGadget(GDI_CUSTOM_ID, id,
6183 GDI_CUSTOM_TYPE_ID, i,
6184 GDI_IMAGE_ID, graphic,
6185 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6188 GDI_WIDTH, gd->width,
6189 GDI_HEIGHT, gd->height,
6191 GDI_STATE, GD_BUTTON_UNPRESSED,
6192 GDI_RADIO_NR, radio_button_nr,
6193 GDI_CHECKED, checked,
6194 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6195 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6196 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6197 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6198 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6199 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6200 GDI_DECORATION_SIZE, tile_size, tile_size,
6201 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6202 GDI_DECORATION_MASKED, deco_masked,
6203 GDI_EVENT_MASK, event_mask,
6204 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6205 GDI_CALLBACK_ACTION, HandleControlButtons,
6209 Error(ERR_EXIT, "cannot create gadget");
6211 level_editor_gadget[id] = gi;
6214 // these values are not constant, but can change at runtime
6215 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6216 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6217 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6218 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6219 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6220 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6221 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6222 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6223 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6224 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6225 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6226 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6228 // create buttons for scrolling of drawing area and element list
6229 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6231 int id = scrollbutton_info[i].gadget_id;
6232 int graphic = scrollbutton_info[i].graphic;
6233 struct GraphicInfo *gd = &graphic_info[graphic];
6234 Bitmap *gd_bitmap = gd->bitmap;
6235 int gd_x1 = gd->src_x;
6236 int gd_y1 = gd->src_y;
6237 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6238 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6239 int width = gd->width;
6240 int height = gd->height;
6241 int x = scrollbutton_pos[i].x;
6242 int y = scrollbutton_pos[i].y;
6243 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6245 if (id == GADGET_ID_SCROLL_LIST_UP ||
6246 id == GADGET_ID_SCROLL_LIST_DOWN)
6257 gi = CreateGadget(GDI_CUSTOM_ID, id,
6258 GDI_CUSTOM_TYPE_ID, i,
6259 GDI_IMAGE_ID, graphic,
6260 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6265 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6266 GDI_STATE, GD_BUTTON_UNPRESSED,
6267 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6268 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6269 GDI_EVENT_MASK, event_mask,
6270 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6271 GDI_CALLBACK_ACTION, HandleControlButtons,
6275 Error(ERR_EXIT, "cannot create gadget");
6277 level_editor_gadget[id] = gi;
6280 // create buttons for element list
6281 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6283 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6284 int graphic = IMG_EDITOR_PALETTE_BUTTON;
6285 struct GraphicInfo *gd = &graphic_info[graphic];
6286 Bitmap *gd_bitmap = gd->bitmap;
6287 Bitmap *deco_bitmap;
6288 int deco_x, deco_y, deco_xpos, deco_ypos;
6289 int gd_x1 = gd->src_x;
6290 int gd_y1 = gd->src_y;
6291 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6292 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6293 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
6294 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
6295 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
6296 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
6297 int element = editor_elements[i];
6298 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
6299 unsigned int event_mask = GD_EVENT_RELEASED;
6301 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
6303 deco_xpos = (gd->width - tile_size) / 2;
6304 deco_ypos = (gd->height - tile_size) / 2;
6306 gi = CreateGadget(GDI_CUSTOM_ID, id,
6307 GDI_CUSTOM_TYPE_ID, i,
6308 GDI_IMAGE_ID, graphic,
6309 GDI_INFO_TEXT, getElementInfoText(element),
6312 GDI_WIDTH, gd->width,
6313 GDI_HEIGHT, gd->height,
6314 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6315 GDI_STATE, GD_BUTTON_UNPRESSED,
6316 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6317 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6318 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6319 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6320 GDI_DECORATION_SIZE, tile_size, tile_size,
6321 GDI_DECORATION_SHIFTING, 1, 1,
6322 GDI_EVENT_MASK, event_mask,
6323 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6324 GDI_CALLBACK_ACTION, HandleControlButtons,
6328 Error(ERR_EXIT, "cannot create gadget");
6330 level_editor_gadget[id] = gi;
6334 static void CreateCounterButtons(void)
6336 int max_infotext_len = getMaxInfoTextLength();
6339 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
6342 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
6343 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
6345 // determine horizontal position to the right of specified gadget
6346 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6347 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
6348 ED_GADGET_TEXT_DISTANCE);
6350 // determine horizontal offset for leading text
6351 if (counterbutton_info[i].text_left != NULL)
6352 x += getTextWidthForGadget(counterbutton_info[i].text_left);
6354 for (j = 0; j < 2; j++)
6356 struct GadgetInfo *gi;
6358 counterbutton_info[i].gadget_id_down :
6359 counterbutton_info[i].gadget_id_up);
6361 struct GraphicInfo *gd;
6362 int gd_x1, gd_x2, gd_y1, gd_y2;
6363 unsigned int event_mask;
6364 char infotext[max_infotext_len + 1];
6366 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6368 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6371 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
6372 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
6374 event_mask |= GD_EVENT_RELEASED;
6378 x = DX + editor.button.prev_level.x;
6379 y = DY + editor.button.prev_level.y;
6383 x = DX + editor.button.next_level.x;
6384 y = DY + editor.button.next_level.y;
6390 IMG_EDITOR_COUNTER_DOWN :
6391 IMG_EDITOR_COUNTER_UP);
6394 gd = &graphic_info[graphic];
6398 gd_x2 = gd->src_x + gd->pressed_xoffset;
6399 gd_y2 = gd->src_y + gd->pressed_yoffset;
6401 sprintf(infotext, "%s counter value by 1, 5 or 10",
6402 (j == 0 ? "decrease" : "increase"));
6404 gi = CreateGadget(GDI_CUSTOM_ID, id,
6405 GDI_CUSTOM_TYPE_ID, i,
6406 GDI_IMAGE_ID, graphic,
6407 GDI_INFO_TEXT, infotext,
6410 GDI_WIDTH, gd->width,
6411 GDI_HEIGHT, gd->height,
6412 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6413 GDI_STATE, GD_BUTTON_UNPRESSED,
6414 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6415 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6416 GDI_EVENT_MASK, event_mask,
6417 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6418 GDI_CALLBACK_ACTION, HandleCounterButtons,
6422 Error(ERR_EXIT, "cannot create gadget");
6424 level_editor_gadget[id] = gi;
6425 right_gadget_border[id] =
6426 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6428 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
6432 int font_type = FONT_INPUT_1;
6433 int font_type_active = FONT_INPUT_1_ACTIVE;
6435 id = counterbutton_info[i].gadget_id_text;
6437 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6439 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6441 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
6443 font_type = FONT_LEVEL_NUMBER;
6444 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
6446 x = DX + editor.input.level_number.x;
6447 y = DY + editor.input.level_number.y;
6451 graphic = IMG_EDITOR_COUNTER_INPUT;
6454 gd = &graphic_info[graphic];
6458 gd_x2 = gd->src_x + gd->active_xoffset;
6459 gd_y2 = gd->src_y + gd->active_yoffset;
6461 gi = CreateGadget(GDI_CUSTOM_ID, id,
6462 GDI_CUSTOM_TYPE_ID, i,
6463 GDI_IMAGE_ID, graphic,
6464 GDI_INFO_TEXT, "enter counter value",
6467 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
6468 GDI_NUMBER_VALUE, 0,
6469 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
6470 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
6471 GDI_TEXT_SIZE, 3, // minimal counter text size
6472 GDI_TEXT_FONT, font_type,
6473 GDI_TEXT_FONT_ACTIVE, font_type_active,
6474 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6475 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6476 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6477 GDI_DESIGN_WIDTH, gd->width,
6478 GDI_EVENT_MASK, event_mask,
6479 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6480 GDI_CALLBACK_ACTION, HandleCounterButtons,
6484 Error(ERR_EXIT, "cannot create gadget");
6486 level_editor_gadget[id] = gi;
6487 right_gadget_border[id] =
6488 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6490 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
6496 static void CreateDrawingAreas(void)
6500 // these values are not constant, but can change at runtime
6501 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
6502 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
6504 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
6506 struct GadgetInfo *gi;
6507 unsigned int event_mask;
6508 int id = drawingarea_info[i].gadget_id;
6509 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
6510 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
6511 int area_xsize = drawingarea_info[i].area_xsize;
6512 int area_ysize = drawingarea_info[i].area_ysize;
6513 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
6514 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
6517 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
6518 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
6520 // determine horizontal position to the right of specified gadget
6521 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
6522 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
6523 ED_DRAWINGAREA_TEXT_DISTANCE);
6525 // determine horizontal offset for leading text
6526 if (drawingarea_info[i].text_left != NULL)
6527 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
6529 gi = CreateGadget(GDI_CUSTOM_ID, id,
6530 GDI_CUSTOM_TYPE_ID, i,
6533 GDI_TYPE, GD_TYPE_DRAWING_AREA,
6534 GDI_AREA_SIZE, area_xsize, area_ysize,
6535 GDI_ITEM_SIZE, item_size, item_size,
6536 GDI_EVENT_MASK, event_mask,
6537 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
6538 GDI_CALLBACK_ACTION, HandleDrawingAreas,
6542 Error(ERR_EXIT, "cannot create gadget");
6544 level_editor_gadget[id] = gi;
6545 right_gadget_border[id] =
6546 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
6550 static void CreateTextInputGadgets(void)
6552 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
6553 int max_infotext_len = getMaxInfoTextLength();
6556 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
6558 int gd_x1 = gd->src_x;
6559 int gd_y1 = gd->src_y;
6560 int gd_x2 = gd->src_x + gd->active_xoffset;
6561 int gd_y2 = gd->src_y + gd->active_yoffset;
6562 struct GadgetInfo *gi;
6563 unsigned int event_mask;
6564 char infotext[MAX_OUTPUT_LINESIZE + 1];
6565 int id = textinput_info[i].gadget_id;
6568 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
6570 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
6571 int border_size = gd->border_size;
6572 int font_nr = FONT_INPUT_1;
6573 int font_height = getFontHeight(font_nr);
6574 int xoffset = element_border + TILEX + element_border + 3 * border_size;
6575 int yoffset = element_border + (TILEY - font_height) / 2;
6577 x = (editor.settings.element_name.x != -1 ?
6578 editor.settings.element_name.x :
6579 editor.settings.element_graphic.x + xoffset) - border_size;
6580 y = (editor.settings.element_name.y != -1 ?
6581 editor.settings.element_name.y :
6582 editor.settings.element_graphic.y + yoffset) - border_size;
6586 x = ED_SETTINGS_X(textinput_info[i].x);
6587 y = ED_SETTINGS_Y(textinput_info[i].y);
6590 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6592 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
6593 infotext[max_infotext_len] = '\0';
6595 gi = CreateGadget(GDI_CUSTOM_ID, id,
6596 GDI_CUSTOM_TYPE_ID, i,
6597 GDI_INFO_TEXT, infotext,
6600 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
6601 GDI_TEXT_VALUE, textinput_info[i].value,
6602 GDI_TEXT_SIZE, textinput_info[i].size,
6603 GDI_TEXT_FONT, FONT_INPUT_1,
6604 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6605 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6606 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6607 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6608 GDI_DESIGN_WIDTH, gd->width,
6609 GDI_EVENT_MASK, event_mask,
6610 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6611 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
6615 Error(ERR_EXIT, "cannot create gadget");
6617 level_editor_gadget[id] = gi;
6621 static void CreateTextAreaGadgets(void)
6623 int max_infotext_len = getMaxInfoTextLength();
6626 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
6628 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
6629 int gd_x1 = gd->src_x;
6630 int gd_y1 = gd->src_y;
6631 int gd_x2 = gd->src_x + gd->active_xoffset;
6632 int gd_y2 = gd->src_y + gd->active_yoffset;
6633 struct GadgetInfo *gi;
6634 unsigned int event_mask;
6635 char infotext[MAX_OUTPUT_LINESIZE + 1];
6636 int id = textarea_info[i].gadget_id;
6637 int area_xsize = textarea_info[i].xsize;
6638 int area_ysize = textarea_info[i].ysize;
6640 event_mask = GD_EVENT_TEXT_LEAVING;
6642 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
6643 infotext[max_infotext_len] = '\0';
6645 gi = CreateGadget(GDI_CUSTOM_ID, id,
6646 GDI_CUSTOM_TYPE_ID, i,
6647 GDI_INFO_TEXT, infotext,
6648 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
6649 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
6650 GDI_TYPE, GD_TYPE_TEXT_AREA,
6651 GDI_AREA_SIZE, area_xsize, area_ysize,
6652 GDI_TEXT_FONT, FONT_INPUT_1,
6653 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6654 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6655 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6656 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6657 GDI_DESIGN_WIDTH, gd->width,
6658 GDI_EVENT_MASK, event_mask,
6659 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6660 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
6664 Error(ERR_EXIT, "cannot create gadget");
6666 level_editor_gadget[id] = gi;
6670 static void CreateSelectboxGadgets(void)
6672 int max_infotext_len = getMaxInfoTextLength();
6675 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6677 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
6678 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
6679 int gd_x1 = gd->src_x;
6680 int gd_y1 = gd->src_y;
6681 int gd_x2 = gd->src_x + gd->active_xoffset;
6682 int gd_y2 = gd->src_y + gd->active_yoffset;
6683 int selectbox_button_xsize = gd2->width;
6684 struct GadgetInfo *gi;
6685 unsigned int event_mask;
6686 char infotext[MAX_OUTPUT_LINESIZE + 1];
6687 int id = selectbox_info[i].gadget_id;
6688 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
6689 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
6691 if (selectbox_info[i].size == -1) // dynamically determine size
6693 // (we cannot use -1 for uninitialized values if we directly compare
6694 // with results from strlen(), because the '<' and '>' operation will
6695 // implicitely cast -1 to an unsigned integer value!)
6696 selectbox_info[i].size = 0;
6698 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
6699 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
6700 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
6702 selectbox_info[i].size++; // add one character empty space
6705 event_mask = GD_EVENT_RELEASED |
6706 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6708 // determine horizontal position to the right of specified gadget
6709 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
6710 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
6711 ED_GADGET_TEXT_DISTANCE);
6713 // determine horizontal offset for leading text
6714 if (selectbox_info[i].text_left != NULL)
6715 x += getTextWidthForGadget(selectbox_info[i].text_left);
6717 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
6718 infotext[max_infotext_len] = '\0';
6720 gi = CreateGadget(GDI_CUSTOM_ID, id,
6721 GDI_CUSTOM_TYPE_ID, i,
6722 GDI_INFO_TEXT, infotext,
6725 GDI_TYPE, GD_TYPE_SELECTBOX,
6726 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
6727 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
6728 GDI_TEXT_SIZE, selectbox_info[i].size,
6729 GDI_TEXT_FONT, FONT_INPUT_1,
6730 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6731 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
6732 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6733 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6734 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6735 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
6736 GDI_DESIGN_WIDTH, gd->width,
6737 GDI_EVENT_MASK, event_mask,
6738 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6739 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
6743 Error(ERR_EXIT, "cannot create gadget");
6745 level_editor_gadget[id] = gi;
6746 right_gadget_border[id] =
6747 getRightGadgetBorder(gi, selectbox_info[i].text_right);
6751 static void CreateTextbuttonGadgets(void)
6753 int max_infotext_len = getMaxInfoTextLength();
6756 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
6758 int id = textbutton_info[i].gadget_id;
6760 ((id >= GADGET_ID_LEVELINFO_LEVEL && id <= GADGET_ID_LEVELINFO_EDITOR) ||
6761 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
6763 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
6764 int gadget_distance =
6765 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
6766 struct GraphicInfo *gd = &graphic_info[graphic];
6767 int gd_x1 = gd->src_x;
6768 int gd_y1 = gd->src_y;
6769 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6770 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6771 int gd_x1a = gd->src_x + gd->active_xoffset;
6772 int gd_y1a = gd->src_y + gd->active_yoffset;
6773 int border_xsize = gd->border_size + gd->draw_xoffset;
6774 int border_ysize = gd->border_size;
6775 struct GadgetInfo *gi;
6776 unsigned int event_mask;
6777 char infotext[MAX_OUTPUT_LINESIZE + 1];
6778 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
6779 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
6781 if (textbutton_info[i].size == -1) // dynamically determine size
6782 textbutton_info[i].size = strlen(textbutton_info[i].text);
6784 event_mask = GD_EVENT_RELEASED;
6786 sprintf(infotext, "%s", textbutton_info[i].infotext);
6787 infotext[max_infotext_len] = '\0';
6789 // determine horizontal position to the right of specified gadget
6790 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6792 int gadget_id_align = textbutton_info[i].gadget_id_align;
6794 x = right_gadget_border[gadget_id_align] + gadget_distance;
6796 if (textbutton_info[i].y == -1)
6797 y = level_editor_gadget[gadget_id_align]->y;
6800 // determine horizontal offset for leading text
6801 if (textbutton_info[i].text_left != NULL)
6802 x += getTextWidthForGadget(textbutton_info[i].text_left);
6804 gi = CreateGadget(GDI_CUSTOM_ID, id,
6805 GDI_CUSTOM_TYPE_ID, i,
6806 GDI_IMAGE_ID, graphic,
6807 GDI_INFO_TEXT, infotext,
6810 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
6811 GDI_TEXT_VALUE, textbutton_info[i].text,
6812 GDI_TEXT_SIZE, textbutton_info[i].size,
6813 GDI_TEXT_FONT, FONT_INPUT_2,
6814 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
6815 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6816 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6817 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6818 GDI_BORDER_SIZE, border_xsize, border_ysize,
6819 GDI_DESIGN_WIDTH, gd->width,
6820 GDI_DECORATION_SHIFTING, 1, 1,
6821 GDI_EVENT_MASK, event_mask,
6822 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6823 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
6827 Error(ERR_EXIT, "cannot create gadget");
6829 level_editor_gadget[id] = gi;
6830 right_gadget_border[id] =
6831 getRightGadgetBorder(gi, textbutton_info[i].text_right);
6835 static void CreateGraphicbuttonGadgets(void)
6837 struct GadgetInfo *gi;
6838 unsigned int event_mask;
6841 // create buttons for scrolling of drawing area and element list
6842 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
6844 int id = graphicbutton_info[i].gadget_id;
6845 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
6846 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
6847 int graphic = graphicbutton_info[i].graphic;
6848 struct GraphicInfo *gd = &graphic_info[graphic];
6849 int gd_x1 = gd->src_x;
6850 int gd_y1 = gd->src_y;
6851 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6852 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6854 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6856 // determine horizontal position to the right of specified gadget
6857 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6858 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
6859 ED_GADGET_TEXT_DISTANCE);
6861 // determine horizontal offset for leading text
6862 if (graphicbutton_info[i].text_left != NULL)
6863 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
6865 gi = CreateGadget(GDI_CUSTOM_ID, id,
6866 GDI_CUSTOM_TYPE_ID, i,
6867 GDI_IMAGE_ID, graphic,
6868 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
6871 GDI_WIDTH, gd->width,
6872 GDI_HEIGHT, gd->height,
6873 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6874 GDI_STATE, GD_BUTTON_UNPRESSED,
6875 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6876 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6877 GDI_EVENT_MASK, event_mask,
6878 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6879 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
6883 Error(ERR_EXIT, "cannot create gadget");
6885 level_editor_gadget[id] = gi;
6886 right_gadget_border[id] =
6887 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
6891 static void CreateScrollbarGadgets(void)
6895 // these values are not constant, but can change at runtime
6896 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
6897 SX + ED_SCROLL_HORIZONTAL_XPOS;
6898 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
6899 SY + ED_SCROLL_HORIZONTAL_YPOS;
6900 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
6901 ED_SCROLL_HORIZONTAL_XSIZE;
6902 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
6903 ED_SCROLL_HORIZONTAL_YSIZE;
6904 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
6905 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
6906 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
6907 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
6909 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
6910 SX + ED_SCROLL_VERTICAL_XPOS;
6911 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
6912 SY + ED_SCROLL_VERTICAL_YPOS;
6913 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
6914 ED_SCROLL_VERTICAL_XSIZE;
6915 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
6916 ED_SCROLL_VERTICAL_YSIZE;
6917 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
6918 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
6919 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
6920 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
6922 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
6923 PX + ED_SCROLL2_VERTICAL_XPOS;
6924 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
6925 PY + ED_SCROLL2_VERTICAL_YPOS;
6926 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
6927 ED_SCROLL2_VERTICAL_XSIZE;
6928 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
6929 ED_SCROLL2_VERTICAL_YSIZE;
6930 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
6931 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
6932 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
6933 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
6935 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
6937 int id = scrollbar_info[i].gadget_id;
6938 int graphic = scrollbar_info[i].graphic;
6939 struct GraphicInfo *gd = &graphic_info[graphic];
6940 int gd_x1 = gd->src_x;
6941 int gd_y1 = gd->src_y;
6942 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6943 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6944 struct GadgetInfo *gi;
6945 int items_max, items_visible, item_position;
6946 unsigned int event_mask;
6948 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
6950 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
6951 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
6952 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
6954 else // drawing area scrollbars
6956 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
6958 items_max = MAX(lev_fieldx + 2, ed_fieldx);
6959 items_visible = ed_fieldx;
6964 items_max = MAX(lev_fieldy + 2, ed_fieldy);
6965 items_visible = ed_fieldy;
6970 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6972 gi = CreateGadget(GDI_CUSTOM_ID, id,
6973 GDI_CUSTOM_TYPE_ID, i,
6974 GDI_IMAGE_ID, graphic,
6975 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6976 GDI_X, scrollbar_pos[i].x,
6977 GDI_Y, scrollbar_pos[i].y,
6978 GDI_WIDTH, scrollbar_pos[i].width,
6979 GDI_HEIGHT, scrollbar_pos[i].height,
6980 GDI_TYPE, scrollbar_info[i].type,
6981 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6982 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6983 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6984 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
6985 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
6986 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
6987 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
6988 GDI_STATE, GD_BUTTON_UNPRESSED,
6989 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6990 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6991 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6992 GDI_EVENT_MASK, event_mask,
6993 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6994 GDI_CALLBACK_ACTION, HandleControlButtons,
6998 Error(ERR_EXIT, "cannot create gadget");
7000 level_editor_gadget[id] = gi;
7004 static void CreateCheckbuttonGadgets(void)
7006 struct GadgetInfo *gi;
7007 unsigned int event_mask;
7010 event_mask = GD_EVENT_PRESSED;
7012 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7014 int id = checkbutton_info[i].gadget_id;
7015 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7016 IMG_EDITOR_CHECKBOX);
7017 struct GraphicInfo *gd = &graphic_info[graphic];
7018 int gd_x1 = gd->src_x;
7019 int gd_y1 = gd->src_y;
7020 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7021 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7022 int gd_x1a = gd->src_x + gd->active_xoffset;
7023 int gd_y1a = gd->src_y + gd->active_yoffset;
7024 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7025 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7026 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7027 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7029 // determine horizontal position to the right of specified gadget
7030 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7031 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7032 ED_GADGET_TEXT_DISTANCE);
7034 // determine horizontal offset for leading text
7035 if (checkbutton_info[i].text_left != NULL)
7036 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7038 gi = CreateGadget(GDI_CUSTOM_ID, id,
7039 GDI_CUSTOM_TYPE_ID, i,
7040 GDI_IMAGE_ID, graphic,
7041 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7044 GDI_WIDTH, gd->width,
7045 GDI_HEIGHT, gd->height,
7046 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7047 GDI_CHECKED, *checkbutton_info[i].value,
7048 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7049 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7050 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7051 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7052 GDI_EVENT_MASK, event_mask,
7053 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7054 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7058 Error(ERR_EXIT, "cannot create gadget");
7060 level_editor_gadget[id] = gi;
7061 right_gadget_border[id] =
7062 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7066 static void CreateRadiobuttonGadgets(void)
7068 int graphic = IMG_EDITOR_RADIOBUTTON;
7069 struct GraphicInfo *gd = &graphic_info[graphic];
7070 int gd_x1 = gd->src_x;
7071 int gd_y1 = gd->src_y;
7072 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7073 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7074 int gd_x1a = gd->src_x + gd->active_xoffset;
7075 int gd_y1a = gd->src_y + gd->active_yoffset;
7076 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7077 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7078 struct GadgetInfo *gi;
7079 unsigned int event_mask;
7082 event_mask = GD_EVENT_PRESSED;
7084 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7086 int id = radiobutton_info[i].gadget_id;
7087 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7088 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7091 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7093 // determine horizontal position to the right of specified gadget
7094 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7095 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7096 ED_GADGET_TEXT_DISTANCE);
7098 // determine horizontal offset for leading text
7099 if (radiobutton_info[i].text_left != NULL)
7100 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7102 gi = CreateGadget(GDI_CUSTOM_ID, id,
7103 GDI_CUSTOM_TYPE_ID, i,
7104 GDI_IMAGE_ID, graphic,
7105 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7108 GDI_WIDTH, gd->width,
7109 GDI_HEIGHT, gd->height,
7110 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7111 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7112 GDI_CHECKED, checked,
7113 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7114 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7115 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7116 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7117 GDI_EVENT_MASK, event_mask,
7118 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7119 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7123 Error(ERR_EXIT, "cannot create gadget");
7125 level_editor_gadget[id] = gi;
7126 right_gadget_border[id] =
7127 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7131 void CreateLevelEditorGadgets(void)
7133 // force EDITOR font inside level editor
7134 SetFontStatus(GAME_MODE_EDITOR);
7136 // these values are not constant, but can change at runtime
7137 ed_fieldx = MAX_ED_FIELDX - 1;
7138 ed_fieldy = MAX_ED_FIELDY - 1;
7140 num_editor_gadgets = NUM_EDITOR_GADGETS;
7142 // printf("::: allocating %d gadgets ...\n", num_editor_gadgets);
7144 level_editor_gadget =
7145 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7146 right_gadget_border =
7147 checked_calloc(num_editor_gadgets * sizeof(int));
7149 // set number of empty (padding) element buttons to maximum number of buttons
7150 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7152 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7153 editor_el_empty_ptr = editor_el_empty;
7155 use_permanent_palette = !editor.palette.show_as_separate_screen;
7157 ReinitializeElementList();
7159 CreateControlButtons();
7160 CreateScrollbarGadgets();
7162 // order of function calls is important because of cross-references
7163 CreateCheckbuttonGadgets();
7164 CreateCounterButtons();
7165 CreateRadiobuttonGadgets();
7166 CreateTextInputGadgets();
7167 CreateTextAreaGadgets();
7168 CreateSelectboxGadgets();
7169 CreateGraphicbuttonGadgets();
7170 CreateTextbuttonGadgets();
7171 CreateDrawingAreas();
7176 void FreeLevelEditorGadgets(void)
7180 // printf("::: freeing %d gadgets ...\n", num_editor_gadgets);
7182 for (i = 0; i < num_editor_gadgets; i++)
7184 FreeGadget(level_editor_gadget[i]);
7186 level_editor_gadget[i] = NULL;
7189 checked_free(level_editor_gadget);
7190 checked_free(right_gadget_border);
7192 checked_free(editor_el_empty);
7195 static void MapCounterButtons(int id)
7197 int font_nr = FONT_TEXT_1;
7198 int font_height = getFontHeight(font_nr);
7199 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7200 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7201 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7202 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7203 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7204 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7205 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7206 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7207 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7208 int yoffset = (gi_down->height - font_height) / 2;
7209 int x_left = gi_down->x - xoffset_left;
7210 int x_right; // set after gadget position was modified
7211 int y_above = gi_down->y - yoffset_above;
7213 int y; // set after gadget position was modified
7215 // counter limits must be changed first to prevent value truncation
7216 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7217 counterbutton_info[id].max_value);
7219 // right text position might have changed after setting position above
7220 x_right = gi_up->x + gi_up->width + xoffset_right;
7222 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7224 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
7225 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7226 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7228 ModifyGadget(gi_down, GDI_Y,
7229 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7230 ModifyGadget(gi_text, GDI_Y,
7231 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7232 ModifyGadget(gi_up, GDI_Y,
7233 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7236 // vertical position might have changed after setting position above
7237 y = gi_up->y + yoffset;
7239 if (counterbutton_info[id].text_above)
7240 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
7242 if (counterbutton_info[id].text_left)
7243 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7245 if (counterbutton_info[id].text_right)
7246 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7253 static void MapControlButtons(void)
7258 // map toolbox buttons (excluding special CE toolbox buttons)
7259 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7260 MapGadget(level_editor_gadget[i]);
7262 // map toolbox buttons (element properties buttons)
7263 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
7264 MapGadget(level_editor_gadget[i]);
7266 if (use_permanent_palette)
7268 // map buttons to select elements
7269 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7270 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
7271 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
7272 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
7273 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
7276 // map buttons to select level
7277 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
7278 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
7279 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
7280 MapCounterButtons(counter_id);
7283 static void MapDrawingArea(int id)
7285 int font_nr = FONT_TEXT_1;
7286 int font_height = getFontHeight(font_nr);
7287 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7288 int area_xsize = gi->drawing.area_xsize;
7289 int area_ysize = gi->drawing.area_ysize;
7290 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7291 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
7292 int x_left = gi->x - xoffset_left;
7293 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
7294 int x_below = gi->x + (gi->width - xoffset_below) / 2;
7295 int y_side = gi->y + (gi->height - font_height) / 2;
7296 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
7298 if (drawingarea_info[id].text_left)
7299 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
7301 if (drawingarea_info[id].text_right)
7302 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
7304 if (drawingarea_info[id].text_below)
7305 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
7307 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
7309 DrawElementBorder(gi->x, gi->y,
7310 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
7311 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
7313 DrawDrawingArea(id);
7319 static void MapTextInputGadget(int id)
7321 int font_nr = FONT_TEXT_1;
7322 int font_height = getFontHeight(font_nr);
7323 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
7324 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7325 int x_above = ED_SETTINGS_X(textinput_info[id].x);
7326 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
7328 if (textinput_info[id].text_above)
7329 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
7331 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
7336 static void MapTextAreaGadget(int id)
7338 int font_nr = FONT_TEXT_1;
7339 int font_height = getFontHeight(font_nr);
7340 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7341 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7342 int x_above = ED_SETTINGS_X(textarea_info[id].x);
7343 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
7345 if (textarea_info[id].text_above)
7346 DrawTextS(x_above, y_above, font_nr, textarea_info[id].text_above);
7348 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
7353 static void MapSelectboxGadget(int id)
7355 int font_nr = FONT_TEXT_1;
7356 int font_height = getFontHeight(font_nr);
7357 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
7358 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
7359 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7360 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7361 int yoffset = (gi->height - font_height) / 2;
7362 int x_left = gi->x - xoffset_left;
7363 int x_right = gi->x + gi->width + xoffset_right;
7364 int y_above = gi->y - yoffset_above;
7366 int y = gi->y + yoffset;
7368 if (selectbox_info[id].text_above)
7369 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
7371 if (selectbox_info[id].text_left)
7372 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
7374 if (selectbox_info[id].text_right)
7375 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
7377 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
7382 static void MapTextbuttonGadget(int id)
7384 int font_nr = FONT_TEXT_1;
7385 int font_height = getFontHeight(font_nr);
7386 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
7387 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
7388 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7389 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7390 int yoffset = (gi->height - font_height) / 2;
7391 int x_left = gi->x - xoffset_left;
7392 int x_right = gi->x + gi->width + xoffset_right;
7393 int y_above = gi->y - yoffset_above;
7395 int y = gi->y + yoffset;
7397 // only show button to delete change pages when more than minimum pages
7398 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
7399 custom_element.num_change_pages == MIN_CHANGE_PAGES)
7402 if (textbutton_info[id].text_above)
7403 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
7405 if (textbutton_info[id].text_left)
7406 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
7408 if (textbutton_info[id].text_right)
7409 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
7414 static void MapGraphicbuttonGadget(int id)
7416 int font_nr = FONT_TEXT_1;
7417 int font_height = getFontHeight(font_nr);
7418 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
7419 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
7420 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7421 int yoffset = (gi->height - font_height) / 2;
7422 int x_left = gi->x - xoffset_left;
7423 int x_right = gi->x + gi->width + xoffset_right;
7424 int y = gi->y + yoffset;
7426 if (graphicbutton_info[id].text_left)
7427 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
7429 if (graphicbutton_info[id].text_right)
7430 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
7435 static void MapRadiobuttonGadget(int id)
7437 int font_nr = FONT_TEXT_1;
7438 int font_height = getFontHeight(font_nr);
7439 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
7440 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7441 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7442 int yoffset = (gi->height - font_height) / 2;
7443 int x_left = gi->x - xoffset_left;
7444 int x_right = gi->x + gi->width + xoffset_right;
7445 int y = gi->y + yoffset;
7447 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
7449 if (radiobutton_info[id].text_left)
7450 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
7452 if (radiobutton_info[id].text_right)
7453 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
7455 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
7460 static void MapCheckbuttonGadget(int id)
7462 int font_nr = FONT_TEXT_1;
7463 int font_height = getFontHeight(font_nr);
7464 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
7465 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7466 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7467 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7468 int yoffset = (gi->height - font_height) / 2;
7469 int y_above = gi->y - yoffset_above;
7471 int x_left, x_right, y; // set after gadget position was modified
7473 // set position for gadgets with dynamically determined position
7474 if (checkbutton_info[id].x != -1) // do not change dynamic positions
7475 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x),GDI_END);
7476 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
7478 x_left = gi->x - xoffset_left;
7479 x_right = gi->x + gi->width + xoffset_right;
7480 y = gi->y + yoffset;
7482 if (checkbutton_info[id].text_above)
7483 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
7485 if (checkbutton_info[id].text_left)
7486 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
7488 if (checkbutton_info[id].text_right)
7489 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
7491 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
7496 static void MapMainDrawingArea(void)
7498 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
7499 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
7502 if (suppressBorderElement())
7504 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
7505 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
7508 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
7510 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
7511 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
7512 no_horizontal_scrollbar) ||
7513 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
7514 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
7515 no_vertical_scrollbar))
7518 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
7521 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
7523 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
7524 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
7527 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
7530 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
7533 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
7537 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
7539 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
7540 i == GADGET_ID_CUSTOM_COPY_TO ||
7541 i == GADGET_ID_CUSTOM_EXCHANGE ||
7542 i == GADGET_ID_CUSTOM_COPY ||
7543 i == GADGET_ID_CUSTOM_PASTE)
7546 MapGadget(level_editor_gadget[i]);
7548 UnmapGadget(level_editor_gadget[i]);
7553 static void MapLevelEditorToolboxCustomGadgets(void)
7555 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
7558 static void UnmapLevelEditorToolboxCustomGadgets(void)
7560 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
7563 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
7567 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
7569 if (i != GADGET_ID_SINGLE_ITEMS &&
7570 i != GADGET_ID_PICK_ELEMENT)
7572 struct GadgetInfo *gi = level_editor_gadget[i];
7580 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
7581 struct GraphicInfo *gd = &graphic_info[graphic];
7585 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
7586 gi->width, gi->height, gi->x, gi->y);
7588 redraw_mask |= REDRAW_DOOR_3;
7594 static void MapLevelEditorToolboxDrawingGadgets(void)
7596 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
7599 static void UnmapLevelEditorToolboxDrawingGadgets(void)
7601 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
7604 static void UnmapDrawingArea(int id)
7606 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
7609 static void UnmapLevelEditorFieldGadgets(void)
7613 for (i = 0; i < num_editor_gadgets; i++)
7614 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
7615 level_editor_gadget[i]->y))
7616 UnmapGadget(level_editor_gadget[i]);
7619 void UnmapLevelEditorGadgets(void)
7623 for (i = 0; i < num_editor_gadgets; i++)
7624 UnmapGadget(level_editor_gadget[i]);
7627 static void ResetUndoBuffer(void)
7629 undo_buffer_position = -1;
7630 undo_buffer_steps = -1;
7631 redo_buffer_steps = 0;
7633 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7635 level.changed = FALSE;
7638 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
7640 if (remap_toolbox_gadgets)
7642 ModifyEditorElementList();
7643 RedrawDrawingElements();
7646 if (edit_mode == ED_MODE_INFO)
7647 DrawLevelInfoWindow();
7648 else if (edit_mode == ED_MODE_PROPERTIES)
7649 DrawPropertiesWindow();
7650 else if (edit_mode == ED_MODE_PALETTE)
7651 DrawPaletteWindow();
7652 else // edit_mode == ED_MODE_DRAWING
7653 DrawDrawingWindowExt(remap_toolbox_gadgets);
7656 static void DrawEditModeWindow(void)
7658 DrawEditModeWindowExt(TRUE);
7661 static void DrawEditModeWindow_PlayfieldOnly(void)
7663 DrawEditModeWindowExt(FALSE);
7666 static void ChangeEditModeWindow(int new_edit_mode)
7668 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
7670 DrawEditModeWindow();
7673 static boolean LevelChanged(void)
7675 boolean field_changed = FALSE;
7678 for (y = 0; y < lev_fieldy; y++)
7679 for (x = 0; x < lev_fieldx; x++)
7680 if (Feld[x][y] != level.field[x][y])
7681 field_changed = TRUE;
7683 return (level.changed || field_changed);
7686 static boolean PrepareSavingIntoPersonalLevelSet(void)
7688 static LevelDirTree *last_copied_leveldir = NULL;
7689 static LevelDirTree *last_written_leveldir = NULL;
7690 static int last_copied_level_nr = -1;
7691 static int last_written_level_nr = -1;
7692 LevelDirTree *leveldir_former = leveldir_current;
7693 int level_nr_former = level_nr;
7696 // remember last mod/save so that for current session, we write
7697 // back to the same personal copy, asking only about overwrite.
7698 if (leveldir_current == last_copied_leveldir &&
7699 level_nr == last_copied_level_nr)
7701 // "cd" to personal level set dir (as used when writing last copy)
7702 leveldir_current = last_written_leveldir;
7703 level_nr = last_written_level_nr;
7708 if (!Request("This level is read only! "
7709 "Save into personal level set?", REQ_ASK))
7712 // "cd" to personal level set dir (for writing copy the first time)
7714 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
7716 // find unused level number
7717 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
7719 static char *level_filename = NULL;
7721 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
7723 if (!fileExists(level_filename))
7727 last_copied_leveldir = leveldir_former;
7728 last_copied_level_nr = level_nr_former;
7730 last_written_leveldir = leveldir_current;
7731 last_written_level_nr = level_nr = new_level_nr;
7736 static void ModifyLevelInfoForSavingIntoPersonalLevelSet(char *former_name)
7738 static char *filename_levelinfo = NULL, *mod_name = NULL;
7741 // annotate this copy-and-mod in personal levelinfo.conf
7742 setString(&filename_levelinfo,
7743 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
7745 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
7747 fprintf(file, "\n");
7748 fprintf(file, "# level %d was modified from:\n", level_nr);
7749 fprintf(file, "# - previous level set name: %s\n",
7751 fprintf(file, "# - level within previous set: %d \"%s\"\n",
7752 level.file_info.nr, level.name);
7753 fprintf(file, "# - previous author: %s\n",
7755 fprintf(file, "# - previous save date: ");
7757 if (level.creation_date.src == DATE_SRC_LEVELFILE)
7759 fprintf(file, "%04d-%02d-%02d\n",
7760 level.creation_date.year,
7761 level.creation_date.month,
7762 level.creation_date.day);
7766 fprintf(file, "not recorded\n");
7772 if (level_nr > leveldir_current->last_level)
7773 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
7775 // else: allow the save even if annotation failed
7777 // now... spray graffiti on the old level vital statistics
7778 // user can change these; just trying to set a good baseline
7780 // don't truncate names for fear of making offensive or silly:
7781 // long-named original author only recorded in levelinfo.conf.
7782 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
7783 if (!strEqual(level.author, leveldir_current->author))
7785 setString(&mod_name, getStringCat3(leveldir_current->author,
7786 " after ", level.author));
7788 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7789 setString(&mod_name,
7790 getStringCat2(leveldir_current->author, " (ed.)"));
7792 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7793 setString(&mod_name, leveldir_current->author);
7795 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
7797 // less worried about truncation here
7798 setString(&mod_name, getStringCat2("Mod: ", level.name));
7799 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
7803 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
7804 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
7808 for (x = 0; x < lev_fieldx; x++)
7809 for (y = 0; y < lev_fieldy; y++)
7810 dst[x][y] = src[x][y];
7813 static int setSelectboxValue(int selectbox_id, int new_value)
7815 int new_index_value = 0;
7818 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
7819 if (selectbox_info[selectbox_id].options[i].value == new_value)
7820 new_index_value = i;
7822 *selectbox_info[selectbox_id].value =
7823 selectbox_info[selectbox_id].options[new_index_value].value;
7825 return new_index_value;
7828 static void setSelectboxSpecialActionVariablesIfNeeded(void)
7832 // change action mode and arg variables according to action type variable
7833 for (i = 0; action_arg_options[i].value != -1; i++)
7835 if (action_arg_options[i].value == custom_element_change.action_type)
7837 int mode = action_arg_options[i].mode;
7839 // only change if corresponding selectbox has changed
7840 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
7841 action_arg_modes[mode])
7842 custom_element_change.action_mode = -1;
7844 // only change if corresponding selectbox has changed
7845 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
7846 action_arg_options[i].options)
7847 custom_element_change.action_arg = -1;
7854 static void setSelectboxSpecialActionOptions(void)
7858 // change action mode and arg selectbox according to action type selectbox
7859 for (i = 0; action_arg_options[i].value != -1; i++)
7861 if (action_arg_options[i].value == custom_element_change.action_type)
7863 int mode = action_arg_options[i].mode;
7865 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
7866 action_arg_modes[mode]);
7867 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
7868 custom_element_change.action_mode);
7870 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
7871 action_arg_options[i].options);
7872 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
7873 custom_element_change.action_arg);
7879 static void copy_custom_element_settings(int element_from, int element_to)
7881 struct ElementInfo *ei_from = &element_info[element_from];
7882 struct ElementInfo *ei_to = &element_info[element_to];
7884 copyElementInfo(ei_from, ei_to);
7887 static void replace_custom_element_in_settings(int element_from,
7892 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
7894 struct ElementInfo *ei = &element_info[i];
7896 for (y = 0; y < 3; y++)
7897 for (x = 0; x < 3; x++)
7898 if (ei->content.e[x][y] == element_from)
7899 ei->content.e[x][y] = element_to;
7901 for (j = 0; j < ei->num_change_pages; j++)
7903 struct ElementChangeInfo *change = &ei->change_page[j];
7905 if (change->target_element == element_from)
7906 change->target_element = element_to;
7908 if (change->initial_trigger_element == element_from)
7909 change->initial_trigger_element = element_to;
7911 if (change->action_element == element_from)
7912 change->action_element = element_to;
7914 for (y = 0; y < 3; y++)
7915 for (x = 0; x < 3; x++)
7916 if (change->target_content.e[x][y] == element_from)
7917 change->target_content.e[x][y] = element_to;
7920 if (ei->group != NULL) // group or internal
7921 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
7922 if (ei->group->element[j] == element_from)
7923 ei->group->element[j] = element_to;
7927 static void replace_custom_element_in_playfield(int element_from,
7932 for (x = 0; x < lev_fieldx; x++)
7933 for (y = 0; y < lev_fieldy; y++)
7934 if (Feld[x][y] == element_from)
7935 Feld[x][y] = element_to;
7938 static boolean CopyCustomElement(int element_old, int element_new,
7941 int copy_mode_orig = copy_mode;
7943 if (copy_mode == GADGET_ID_CUSTOM_COPY)
7945 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
7946 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7947 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7949 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
7951 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
7952 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7953 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7955 level.changed = TRUE;
7957 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
7959 Request("Please choose custom element!", REQ_CONFIRM);
7963 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
7965 Request("Please choose group element!", REQ_CONFIRM);
7971 level.changed = TRUE;
7974 // when modifying custom/group element, ask for copying level template
7975 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
7977 if (!AskToCopyAndModifyLevelTemplate())
7981 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
7983 copy_custom_element_settings(element_new, element_old);
7985 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
7987 copy_custom_element_settings(element_old, element_new);
7989 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
7991 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
7992 copy_custom_element_settings(element_new, element_old);
7993 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
7995 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
7996 replace_custom_element_in_settings(element_new, element_old);
7997 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
7999 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8000 replace_custom_element_in_playfield(element_new, element_old);
8001 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8004 UpdateCustomElementGraphicGadgets();
8005 DrawPropertiesWindow();
8010 static void CopyCustomElementPropertiesToEditor(int element)
8013 int current_change_page = element_info[element].current_change_page;
8015 // dynamically (re)build selectbox for selecting change page
8016 for (i = 0; i < element_info[element].num_change_pages; i++)
8018 sprintf(options_change_page_strings[i], "%d", i + 1);
8020 options_change_page[i].value = i;
8021 options_change_page[i].text = options_change_page_strings[i];
8024 options_change_page[i].value = -1;
8025 options_change_page[i].text = NULL;
8027 // needed here to initialize combined element properties
8028 InitElementPropertiesEngine(level.game_version);
8030 element_info[element].change =
8031 &element_info[element].change_page[current_change_page];
8033 custom_element = element_info[element];
8034 custom_element_change = *element_info[element].change;
8036 // needed to initially set selectbox options for special action options
8037 setSelectboxSpecialActionOptions();
8039 // needed to initially set selectbox value variables to reliable defaults
8040 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8041 setSelectboxValue(i, *selectbox_info[i].value);
8043 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8044 custom_element_properties[i] = HAS_PROPERTY(element, i);
8046 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8047 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8049 // ---------- element settings: configure (custom elements) -----------------
8051 // set accessible layer selectbox help value
8052 custom_element.access_type =
8053 (IS_WALKABLE(element) ? EP_WALKABLE :
8054 IS_PASSABLE(element) ? EP_PASSABLE :
8055 custom_element.access_type);
8056 custom_element.access_layer =
8057 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8058 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8059 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8060 custom_element.access_layer);
8061 custom_element.access_protected =
8062 (IS_PROTECTED(element) ? 1 : 0);
8063 custom_element_properties[EP_ACCESSIBLE] =
8064 (IS_ACCESSIBLE_OVER(element) ||
8065 IS_ACCESSIBLE_INSIDE(element) ||
8066 IS_ACCESSIBLE_UNDER(element));
8068 // set walk-to-object action selectbox help value
8069 custom_element.walk_to_action =
8070 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8071 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8072 IS_DROPPABLE(element) ? EP_DROPPABLE :
8073 IS_THROWABLE(element) ? EP_THROWABLE :
8074 IS_PUSHABLE(element) ? EP_PUSHABLE :
8075 custom_element.walk_to_action);
8076 custom_element_properties[EP_WALK_TO_OBJECT] =
8077 (IS_DIGGABLE(element) ||
8078 IS_COLLECTIBLE_ONLY(element) ||
8079 IS_DROPPABLE(element) ||
8080 IS_THROWABLE(element) ||
8081 IS_PUSHABLE(element));
8083 // set smash targets selectbox help value
8084 custom_element.smash_targets =
8085 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8086 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8087 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8088 custom_element.smash_targets);
8089 custom_element_properties[EP_CAN_SMASH] =
8090 (CAN_SMASH_EVERYTHING(element) ||
8091 CAN_SMASH_ENEMIES(element) ||
8092 CAN_SMASH_PLAYER(element));
8094 // set deadliness selectbox help value
8095 custom_element.deadliness =
8096 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8097 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8098 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8099 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8100 custom_element.deadliness);
8101 custom_element_properties[EP_DEADLY] =
8102 (DONT_TOUCH(element) ||
8103 DONT_GET_HIT_BY(element) ||
8104 DONT_COLLIDE_WITH(element) ||
8105 DONT_RUN_INTO(element));
8107 // ---------- element settings: advanced (custom elements) ------------------
8109 // set "change by direct action" selectbox help value
8110 custom_element_change.direct_action =
8111 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8112 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8113 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8114 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8115 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8116 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8117 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8118 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8119 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8120 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8121 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8122 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8123 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8124 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8125 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8126 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8127 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8128 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8129 custom_element_change.direct_action);
8131 // set "change by other element action" selectbox help value
8132 custom_element_change.other_action =
8133 (HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8134 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8135 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8136 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8137 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8138 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8139 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8140 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8141 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8142 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8143 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8144 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8145 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8146 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8147 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8148 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8149 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8150 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8151 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8152 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8153 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8154 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8155 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8156 custom_element_change.other_action);
8159 static void CopyGroupElementPropertiesToEditor(int element)
8161 group_element_info = *element_info[element].group;
8162 custom_element = element_info[element]; // needed for description
8165 static void CopyClassicElementPropertiesToEditor(int element)
8167 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
8168 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
8169 getMoveIntoAcidProperty(&level, element);
8171 if (MAYBE_DONT_COLLIDE_WITH(element))
8172 custom_element_properties[EP_DONT_COLLIDE_WITH] =
8173 getDontCollideWithProperty(&level, element);
8176 static void CopyElementPropertiesToEditor(int element)
8178 if (IS_CUSTOM_ELEMENT(element))
8179 CopyCustomElementPropertiesToEditor(element);
8180 else if (IS_GROUP_ELEMENT(element))
8181 CopyGroupElementPropertiesToEditor(element);
8183 CopyClassicElementPropertiesToEditor(element);
8186 static boolean AskToCopyAndModifyLevelTemplate(void)
8188 if (Request("Copy and modify settings from level template?", REQ_ASK))
8190 level.use_custom_template = FALSE;
8192 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
8193 GDI_CHECKED, FALSE, GDI_END);
8194 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
8195 GDI_CHECKED, FALSE, GDI_END);
8201 LoadLevelTemplate(-1); // this resets all element modifications ...
8203 DrawEditModeWindow(); // ... and copies them to 'custom_element'
8209 static void CopyCustomElementPropertiesToGame(int element)
8212 int access_type_and_layer;
8214 // mark that this custom element has been modified
8215 custom_element.modified_settings = TRUE;
8216 level.changed = TRUE;
8218 if (level.use_custom_template)
8219 AskToCopyAndModifyLevelTemplate();
8221 element_info[element] = custom_element;
8222 *element_info[element].change = custom_element_change;
8224 // ---------- element settings: configure (custom elements) -----------------
8226 // set accessible property from checkbox and selectbox
8227 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
8228 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
8229 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
8230 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
8231 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
8232 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
8233 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
8234 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
8235 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
8236 custom_element_properties[access_type_and_layer] =
8237 custom_element_properties[EP_ACCESSIBLE];
8238 custom_element_properties[EP_PROTECTED] =
8239 (custom_element.access_protected != 0 &&
8240 custom_element_properties[EP_ACCESSIBLE]);
8242 // set walk-to-object property from checkbox and selectbox
8243 custom_element_properties[EP_DIGGABLE] = FALSE;
8244 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
8245 custom_element_properties[EP_DROPPABLE] = FALSE;
8246 custom_element_properties[EP_THROWABLE] = FALSE;
8247 custom_element_properties[EP_PUSHABLE] = FALSE;
8248 custom_element_properties[custom_element.walk_to_action] =
8249 custom_element_properties[EP_WALK_TO_OBJECT];
8251 // set smash property from checkbox and selectbox
8252 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
8253 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
8254 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
8255 custom_element_properties[custom_element.smash_targets] =
8256 custom_element_properties[EP_CAN_SMASH];
8258 // set deadliness property from checkbox and selectbox
8259 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
8260 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
8261 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
8262 custom_element_properties[EP_DONT_TOUCH] = FALSE;
8263 custom_element_properties[custom_element.deadliness] =
8264 custom_element_properties[EP_DEADLY];
8266 // ---------- element settings: advanced (custom elements) ------------------
8268 // set player change event from checkbox and selectbox
8269 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
8270 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
8271 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
8272 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
8273 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
8274 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
8275 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
8276 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
8277 custom_element_change_events[CE_SWITCHED] = FALSE;
8278 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
8279 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
8280 custom_element_change_events[CE_BLOCKED] = FALSE;
8281 custom_element_change_events[CE_IMPACT] = FALSE;
8282 custom_element_change_events[CE_SMASHED] = FALSE;
8283 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
8284 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
8285 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
8286 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
8287 custom_element_change_events[custom_element_change.direct_action] =
8288 custom_element_change_events[CE_BY_DIRECT_ACTION];
8290 // set other element action change event from checkbox and selectbox
8291 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
8292 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
8293 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
8294 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
8295 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
8296 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
8297 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
8298 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
8299 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
8300 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
8301 custom_element_change_events[CE_TOUCHING_X] = FALSE;
8302 custom_element_change_events[CE_HITTING_X] = FALSE;
8303 custom_element_change_events[CE_DIGGING_X] = FALSE;
8304 custom_element_change_events[CE_HIT_BY_X] = FALSE;
8305 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
8306 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
8307 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
8308 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
8309 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
8310 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
8311 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
8312 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
8313 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
8314 custom_element_change_events[custom_element_change.other_action] =
8315 custom_element_change_events[CE_BY_OTHER_ACTION];
8317 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8318 SET_PROPERTY(element, i, custom_element_properties[i]);
8320 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8321 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
8323 // copy change events also to special level editor variable
8324 custom_element = element_info[element];
8325 custom_element_change = *element_info[element].change;
8328 static void CopyGroupElementPropertiesToGame(int element)
8330 // mark that this group element has been modified
8331 custom_element.modified_settings = TRUE;
8332 level.changed = TRUE;
8334 if (level.use_custom_template)
8335 AskToCopyAndModifyLevelTemplate();
8337 element_info[element] = custom_element;
8338 *element_info[element].group = group_element_info;
8341 static void CopyClassicElementPropertiesToGame(int element)
8343 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
8344 setMoveIntoAcidProperty(&level, element,
8345 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
8347 if (MAYBE_DONT_COLLIDE_WITH(element))
8348 setDontCollideWithProperty(&level, element,
8349 custom_element_properties[EP_DONT_COLLIDE_WITH]);
8352 static void CopyElementPropertiesToGame(int element)
8354 if (IS_CUSTOM_ELEMENT(element))
8355 CopyCustomElementPropertiesToGame(element);
8356 else if (IS_GROUP_ELEMENT(element))
8357 CopyGroupElementPropertiesToGame(element);
8359 CopyClassicElementPropertiesToGame(element);
8363 static void CheckElementDescriptions(void)
8367 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8368 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
8369 Error(ERR_WARN, "no element description file for element '%s'",
8374 static int getMaxEdFieldX(boolean has_scrollbar)
8376 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
8377 int sxsize = SXSIZE - scrollbar_width;
8378 int max_ed_fieldx = sxsize / ed_tilesize;
8380 return max_ed_fieldx;
8383 static int getMaxEdFieldY(boolean has_scrollbar)
8385 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
8386 INFOTEXT_YSIZE_FULL : 0);
8387 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
8388 int sysize = SYSIZE - scrollbar_height - infotext_height;
8389 int max_ed_fieldy = sysize / ed_tilesize;
8391 return max_ed_fieldy;
8394 static void InitZoomLevelSettings(int zoom_tilesize)
8396 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
8398 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
8400 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
8401 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
8403 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8405 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
8406 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
8410 last_game_engine_type = level.game_engine_type;
8412 // limit zoom tilesize by upper and lower bound
8413 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
8415 // store zoom tilesize in auto setup file only if it was manually changed
8416 if (zoom_tilesize != -1)
8417 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
8419 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
8420 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
8423 static void InitDrawingElements(void)
8425 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
8427 if (level.game_engine_type == game_engine_type_last)
8430 if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
8432 new_element1 = EL_SP_CHIP_SINGLE;
8433 new_element2 = EL_EMPTY;
8434 new_element3 = EL_SP_BASE;
8436 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8438 new_element1 = EL_MM_MIRROR_START;
8439 new_element2 = EL_EMPTY;
8440 new_element3 = EL_MM_WOODEN_WALL;
8444 new_element1 = EL_WALL;
8445 new_element2 = EL_EMPTY;
8446 new_element3 = EL_SAND;
8449 game_engine_type_last = level.game_engine_type;
8452 static void InitLevelSetInfo(void)
8454 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
8455 "%s", leveldir_current->name);
8456 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
8457 "%s", leveldir_current->author);
8459 levelset_num_levels = leveldir_current->levels;
8461 levelset_use_levelset_artwork = FALSE;
8462 levelset_copy_level_template = FALSE;
8464 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
8467 static void ChangeEditorToLevelSet(char *levelset_subdir)
8469 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
8471 // the previous level set might have used custom artwork
8472 ReloadCustomArtwork(0);
8474 LoadLevelSetup_SeriesInfo();
8476 SaveLevelSetup_LastSeries();
8477 SaveLevelSetup_SeriesInfo();
8481 LoadLevel(level_nr);
8482 LoadScore(level_nr);
8487 static boolean useEditorDoorAnimation(void)
8489 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
8490 boolean door_1_viewport_unchanged =
8491 (vp_door_1->x == DX &&
8492 vp_door_1->y == DY &&
8493 vp_door_1->width == DXSIZE &&
8494 vp_door_1->height == DYSIZE);
8495 boolean door_1_contains_toolbox =
8498 EX + EXSIZE <= DX + DXSIZE &&
8499 EY + EYSIZE <= DY + DYSIZE);
8501 return (door_1_viewport_unchanged && door_1_contains_toolbox);
8504 static void DrawEditorDoorContent(void)
8506 // needed for gadgets drawn on background (like palette scrollbar)
8507 SetDoorBackgroundImage(IMG_UNDEFINED);
8509 // copy default editor door content to main double buffer
8510 BlitBitmap(graphic_info[IMG_BACKGROUND_PALETTE].bitmap, drawto,
8511 graphic_info[IMG_BACKGROUND_PALETTE].src_x,
8512 graphic_info[IMG_BACKGROUND_PALETTE].src_y,
8513 MIN(DXSIZE, graphic_info[IMG_BACKGROUND_PALETTE].width),
8514 MIN(DYSIZE, graphic_info[IMG_BACKGROUND_PALETTE].height),
8518 DrawSpecialEditorDoor();
8520 // draw new control window
8521 BlitBitmap(graphic_info[IMG_BACKGROUND_TOOLBOX].bitmap, drawto,
8522 graphic_info[IMG_BACKGROUND_TOOLBOX].src_x,
8523 graphic_info[IMG_BACKGROUND_TOOLBOX].src_y,
8524 MIN(EXSIZE, graphic_info[IMG_BACKGROUND_TOOLBOX].width),
8525 MIN(EYSIZE, graphic_info[IMG_BACKGROUND_TOOLBOX].height),
8528 // draw all toolbox gadgets to editor doors
8529 MapControlButtons();
8531 // draw all palette gadgets to editor doors
8532 ModifyEditorElementList();
8533 RedrawDrawingElements();
8535 // copy actual editor door content to door double buffer for OpenDoor()
8536 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
8539 void DrawLevelEd(void)
8541 int fade_mask = REDRAW_FIELD;
8543 FadeSoundsAndMusic();
8545 if (CheckIfGlobalBorderOrPlayfieldViewportHasChanged())
8546 fade_mask = REDRAW_ALL;
8550 // needed if different viewport properties defined for editor
8551 ChangeViewportPropertiesIfNeeded();
8555 InitZoomLevelSettings(-1);
8556 InitDrawingElements();
8560 CheckElementDescriptions();
8563 if (level_editor_test_game)
8565 CopyPlayfield(level.field, Feld);
8566 CopyPlayfield(FieldBackup, level.field);
8568 level_editor_test_game = FALSE;
8572 edit_mode = ED_MODE_DRAWING;
8573 edit_mode_levelinfo = ED_MODE_LEVELINFO_LEVEL;
8574 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
8582 // redraw_mask |= REDRAW_ALL;
8584 FreeLevelEditorGadgets();
8585 CreateLevelEditorGadgets();
8587 ReinitializeElementList(); // update dynamic level element list
8588 ReinitializeElementListButtons(); // custom element may look different
8590 InitElementPropertiesGfxElement();
8594 DrawEditModeWindow_PlayfieldOnly();
8596 DrawMaskedBorder(fade_mask);
8598 // use door animation if door 1 viewport is unchanged and contains toolbox
8599 if (useEditorDoorAnimation())
8603 DrawEditorDoorContent();
8605 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
8609 DrawEditorDoorContent();
8614 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
8617 static void AdjustDrawingAreaGadgets(void)
8619 int ed_xsize = lev_fieldx + 2;
8620 int ed_ysize = lev_fieldy + 2;
8621 int max_ed_fieldx = MAX_ED_FIELDX;
8622 int max_ed_fieldy = MAX_ED_FIELDY;
8623 boolean horizontal_scrollbar_needed;
8624 boolean vertical_scrollbar_needed;
8625 int x, y, width, height;
8627 if (suppressBorderElement())
8629 ed_xsize = max_ed_fieldx;
8630 ed_ysize = max_ed_fieldy;
8633 // check if we need any scrollbars
8634 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8635 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8637 // check if we have a smaller editor field because of scrollbars
8638 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8639 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8641 // check again if we now need more scrollbars because of less space
8642 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8643 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8645 // check if editor field gets even smaller after adding new scrollbars
8646 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8647 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8649 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
8650 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
8652 x = SX + ed_fieldx * ed_tilesize;
8653 y = SY + ed_fieldy * ed_tilesize;
8655 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
8656 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
8658 // adjust drawing area gadget
8659 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
8660 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
8661 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
8664 // adjust horizontal scrollbar gadgets
8665 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
8668 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
8669 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
8672 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8675 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
8678 // adjust vertical scrollbar gadgets
8679 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
8682 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
8684 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
8686 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8689 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
8693 static void AdjustLevelScrollPosition(void)
8695 if (level_xpos < -1)
8697 if (level_xpos > lev_fieldx - ed_fieldx + 1)
8698 level_xpos = lev_fieldx - ed_fieldx + 1;
8699 if (lev_fieldx < ed_fieldx - 2)
8702 if (level_ypos < -1)
8704 if (level_ypos > lev_fieldy - ed_fieldy + 1)
8705 level_ypos = lev_fieldy - ed_fieldy + 1;
8706 if (lev_fieldy < ed_fieldy - 2)
8709 if (suppressBorderElement())
8716 static void AdjustEditorScrollbar(int id)
8718 struct GadgetInfo *gi = level_editor_gadget[id];
8719 int items_max, items_visible, item_position;
8721 if (id == GADGET_ID_SCROLL_HORIZONTAL)
8723 items_max = MAX(lev_fieldx + 2, ed_fieldx);
8724 items_visible = ed_fieldx;
8725 item_position = level_xpos + 1;
8729 items_max = MAX(lev_fieldy + 2, ed_fieldy);
8730 items_visible = ed_fieldy;
8731 item_position = level_ypos + 1;
8734 if (item_position > items_max - items_visible)
8735 item_position = items_max - items_visible;
8737 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8738 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8741 static void AdjustElementListScrollbar(void)
8743 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
8744 int items_max, items_visible, item_position;
8746 // correct position of element list scrollbar
8747 if (element_shift < 0)
8749 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
8750 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
8752 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
8753 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
8754 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
8756 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8757 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
8758 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8761 static void ModifyEditorCounterValue(int counter_id, int new_value)
8763 int *counter_value = counterbutton_info[counter_id].value;
8764 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8765 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8767 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
8769 if (counter_value != NULL)
8770 *counter_value = gi->textinput.number_value;
8773 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
8775 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8776 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8778 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
8780 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
8781 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
8783 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
8784 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8786 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
8787 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
8792 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
8794 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8795 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8796 int new_index_value = setSelectboxValue(selectbox_id, new_value);
8798 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
8801 static void ModifyEditorSelectboxOptions(int selectbox_id,
8802 struct ValueTextInfo *options)
8804 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8805 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8807 selectbox_info[selectbox_id].options = options;
8809 // set index to zero -- list may be shorter now (correct later, if needed)
8810 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
8811 GDI_SELECTBOX_OPTIONS, options, GDI_END);
8814 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
8816 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
8817 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8819 drawingarea_info[drawingarea_id].area_xsize = xsize;
8820 drawingarea_info[drawingarea_id].area_ysize = ysize;
8822 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
8825 static void ModifyEditorElementList(void)
8829 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
8832 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8834 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
8835 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8836 struct GadgetDesign *gd = &gi->deco.design;
8837 int element = editor_elements[element_shift + i];
8838 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
8842 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
8844 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
8850 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
8852 int graphic = el2edimg(element);
8853 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
8859 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
8862 static void ModifyDrawingElementButton(int element, int id)
8864 struct GadgetInfo *gi = level_editor_gadget[id];
8865 Bitmap *deco_bitmap;
8867 int tile_size = gi->deco.width;
8869 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
8871 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
8874 static void PickDrawingElement(int button, int element)
8879 struct XYTileSize *pos;
8881 } de, drawing_elements[] =
8883 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
8884 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
8885 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
8888 if (button < 1 || button > 3)
8891 if (IS_MM_WALL(element))
8892 element = map_mm_wall_element(element);
8894 de = drawing_elements[button - 1];
8896 *de.new_element = element; // update global drawing element variable
8898 DrawDrawingElementGraphic(element, de.pos);
8899 ModifyDrawingElementButton(element, de.id);
8901 redraw_mask |= REDRAW_DOOR_1;
8904 static void RedrawDrawingElements(void)
8906 PickDrawingElement(1, new_element1);
8907 PickDrawingElement(2, new_element2);
8908 PickDrawingElement(3, new_element3);
8911 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
8913 stick_element_properties_window = FALSE;
8915 SetMainBackgroundImage(IMG_UNDEFINED);
8918 UnmapLevelEditorFieldGadgets();
8920 AdjustDrawingAreaGadgets();
8921 AdjustLevelScrollPosition();
8922 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
8923 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
8925 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8927 MapMainDrawingArea();
8929 if (remap_toolbox_gadgets)
8931 UnmapLevelEditorToolboxCustomGadgets();
8932 MapLevelEditorToolboxDrawingGadgets();
8936 static void DrawDrawingWindow(void)
8938 DrawDrawingWindowExt(TRUE);
8941 static int getTabulatorBarWidth(void)
8943 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
8944 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
8946 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
8949 static int getTabulatorBarHeight(void)
8951 return ED_TAB_BAR_HEIGHT;
8954 static Pixel getTabulatorBarColor(void)
8956 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
8957 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
8958 int gd_x = gd->x + gd_gi1->border.width / 2;
8959 int gd_y = gd->y + gd_gi1->height - 1;
8961 return GetPixel(gd->bitmap, gd_x, gd_y);
8964 static void DrawLevelInfoTabulatorGadgets(void)
8966 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
8967 Pixel tab_color = getTabulatorBarColor();
8968 int id_first = ED_TAB_BUTTON_ID_LEVELINFO_FIRST;
8969 int id_last = ED_TAB_BUTTON_ID_LEVELINFO_LAST;
8972 for (i = id_first; i <= id_last; i++)
8974 int gadget_id = textbutton_info[i].gadget_id;
8975 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8976 boolean active = (i != edit_mode_levelinfo);
8978 // draw background line below tabulator button
8979 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
8981 // draw solid line below inactive tabulator buttons
8982 if (!active && tab_color != BLACK_PIXEL) // black => transparent
8983 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
8984 ED_GADGET_TINY_DISTANCE, tab_color);
8986 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
8987 MapTextbuttonGadget(i);
8990 // draw little border line below tabulator buttons
8991 if (tab_color != BLACK_PIXEL) // black => transparent
8992 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
8993 ED_GADGET_TINY_DISTANCE,
8994 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
8997 static void DrawPropertiesTabulatorGadgets(void)
8999 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9000 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9001 int gd_x = gd->x + gd_gi1->border.width / 2;
9002 int gd_y = gd->y + gd_gi1->height - 1;
9003 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9004 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9005 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9008 // draw two config tabulators for player elements
9009 if (ELEM_IS_PLAYER(properties_element))
9010 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9012 // draw two config and one "change" tabulator for custom elements
9013 if (IS_CUSTOM_ELEMENT(properties_element))
9014 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9016 for (i = id_first; i <= id_last; i++)
9018 int gadget_id = textbutton_info[i].gadget_id;
9019 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9020 boolean active = (i != edit_mode_properties);
9022 // use "config 1" and "config 2" instead of "config" for players and CEs
9023 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9024 (ELEM_IS_PLAYER(properties_element) ||
9025 IS_CUSTOM_ELEMENT(properties_element)))
9028 // draw background line below tabulator button
9029 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9031 // draw solid line below inactive tabulator buttons
9032 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9033 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9034 ED_GADGET_TINY_DISTANCE, tab_color);
9036 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9037 MapTextbuttonGadget(i);
9040 // draw little border line below tabulator buttons
9041 if (tab_color != BLACK_PIXEL) // black => transparent
9042 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9043 ED_GADGET_TINY_DISTANCE,
9044 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9047 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9049 DrawText(SX + xpos, SY + ypos, text, font_nr);
9052 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9055 int font_width = getFontWidth(font_nr);
9056 int font_height = getFontHeight(font_nr);
9057 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9058 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9060 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9061 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9062 TRUE, FALSE, FALSE);
9065 static void DrawLevelInfoLevel(void)
9069 // draw counter gadgets
9070 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9071 MapCounterButtons(i);
9073 // draw checkbutton gadgets
9074 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9075 MapCheckbuttonGadget(i);
9077 // draw selectbox gadgets
9078 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9079 MapSelectboxGadget(i);
9081 // draw text input gadgets
9082 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9083 MapTextInputGadget(i);
9086 static char *getLevelSubdirFromSaveMode(int save_mode)
9088 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9089 return getNewUserLevelSubdir();
9091 return leveldir_current->subdir;
9094 static void DrawLevelInfoLevelSet_DirectoryInfo(void)
9096 char *directory_text = "Level set directory:";
9097 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9098 int font1_nr = FONT_TEXT_1;
9099 int font2_nr = FONT_TEXT_2;
9100 int font1_height = getFontHeight(font1_nr);
9101 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
9102 int x = ED_LEVEL_SETTINGS_X(0);
9103 int y = ED_LEVEL_SETTINGS_Y(6);
9105 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
9106 PrintInfoText(directory_name, font2_nr, x, y);
9109 static void DrawLevelInfoLevelSet(void)
9111 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
9112 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
9115 // draw counter gadgets
9116 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
9117 MapCounterButtons(i);
9119 // draw checkbutton gadgets
9120 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
9122 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
9123 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
9124 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
9127 MapCheckbuttonGadget(i);
9130 // draw selectbox gadgets
9131 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
9132 MapSelectboxGadget(i);
9134 // draw text input gadgets
9135 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
9136 MapTextInputGadget(i);
9138 // draw textbutton gadgets
9139 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
9142 DrawLevelInfoLevelSet_DirectoryInfo();
9145 static void DrawLevelInfoEditor(void)
9149 // draw counter gadgets
9150 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
9151 MapCounterButtons(i);
9153 // draw checkbutton gadgets
9154 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
9155 MapCheckbuttonGadget(i);
9157 // draw radiobutton gadgets
9158 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
9159 MapRadiobuttonGadget(i);
9161 // draw drawing area
9162 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
9164 // draw textbutton gadgets
9165 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
9168 static void DrawLevelInfoWindow(void)
9170 char *text = "Global Settings";
9171 int font_nr = FONT_TITLE_1;
9172 struct MenuPosInfo *pos = &editor.settings.headline;
9173 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
9174 int sy = SY + pos->y;
9176 stick_element_properties_window = FALSE;
9178 SetAutomaticNumberOfGemsNeeded();
9180 UnmapLevelEditorFieldGadgets();
9182 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9185 DrawText(sx, sy, text, font_nr);
9187 DrawLevelInfoTabulatorGadgets();
9189 if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVEL)
9190 DrawLevelInfoLevel();
9191 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVELSET)
9192 DrawLevelInfoLevelSet();
9193 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_EDITOR)
9194 DrawLevelInfoEditor();
9197 static void DrawCustomContentArea(void)
9199 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
9200 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9201 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
9202 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
9203 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
9204 int xoffset = ED_GADGET_SPACE_DISTANCE;
9206 // add distance for potential left text (without drawing area border)
9207 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
9209 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9211 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
9214 static void DrawCustomChangeContentArea(void)
9216 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
9217 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9218 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
9219 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
9220 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
9221 int xoffset = ED_GADGET_SPACE_DISTANCE;
9223 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9228 static void RemoveElementContentArea(int id, int font_height)
9230 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9232 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
9233 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
9234 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9235 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
9236 ED_GADGET_TEXT_DISTANCE + font_height);
9239 static void DrawYamYamContentAreas(void)
9241 int font_nr = FONT_TEXT_1;
9242 int font_height = getFontHeight(font_nr);
9243 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9244 int yoffset = (tilesize - font_height) / 2;
9245 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
9246 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
9249 // display counter to choose number of element content areas
9250 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
9252 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9254 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
9256 if (i < level.num_yamyam_contents)
9262 UnmapDrawingArea(id);
9264 // delete content areas in case of reducing number of them
9265 RemoveElementContentArea(id, font_height);
9269 DrawText(x, y + 0 * tilesize, "content", font_nr);
9270 DrawText(x, y + 1 * tilesize, "when", font_nr);
9271 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
9274 static void DrawMagicBallContentAreas(void)
9276 int font_nr = FONT_TEXT_1;
9277 int font_height = getFontHeight(font_nr);
9278 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9279 int yoffset = (tilesize - font_height) / 2;
9280 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
9281 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
9284 // display counter to choose number of element content areas
9285 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
9287 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9289 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
9291 if (i < level.num_ball_contents)
9297 UnmapDrawingArea(id);
9299 // delete content areas in case of reducing number of them
9300 RemoveElementContentArea(id, font_height);
9304 DrawText(x, y + 0 * tilesize, "generated", font_nr);
9305 DrawText(x, y + 1 * tilesize, "when", font_nr);
9306 DrawText(x, y + 2 * tilesize, "active", font_nr);
9309 static void DrawAndroidElementArea(int element)
9311 int id = ED_DRAWING_ID_ANDROID_CONTENT;
9312 int num_elements = level.num_android_clone_elements;
9313 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9314 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9315 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9316 int xsize = MAX_ANDROID_ELEMENTS;
9319 // display counter to choose number of element areas
9320 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
9322 if (drawingarea_info[id].text_left != NULL)
9323 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9325 UnmapDrawingArea(id);
9327 ModifyEditorDrawingArea(id, num_elements, 1);
9329 // delete content areas in case of reducing number of them
9330 DrawBackground(sx, sy,
9331 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9332 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9337 static void DrawGroupElementArea(int element)
9339 int id = ED_DRAWING_ID_GROUP_CONTENT;
9340 int num_elements = group_element_info.num_elements;
9341 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9342 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9343 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9344 int xsize = MAX_ELEMENTS_IN_GROUP;
9347 if (drawingarea_info[id].text_left != NULL)
9348 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9350 UnmapDrawingArea(id);
9352 ModifyEditorDrawingArea(id, num_elements, 1);
9354 // delete content areas in case of reducing number of them
9355 DrawBackground(sx, sy,
9356 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9357 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9362 static void DrawPlayerInitialInventoryArea(int element)
9364 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
9365 int player_nr = GET_PLAYER_NR(element);
9366 int num_elements = level.initial_inventory_size[player_nr];
9367 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9368 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9369 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9370 int xsize = MAX_INITIAL_INVENTORY_SIZE;
9373 // determine horizontal position to the right of specified gadget
9374 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
9375 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
9376 ED_DRAWINGAREA_TEXT_DISTANCE);
9378 // determine horizontal offset for leading text
9379 if (drawingarea_info[id].text_left != NULL)
9380 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9382 UnmapDrawingArea(id);
9384 ModifyEditorDrawingArea(id, num_elements, 1);
9386 // delete content areas in case of reducing number of them
9387 DrawBackground(sx, sy,
9388 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9389 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9394 static void DrawEnvelopeTextArea(int envelope_nr)
9396 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
9397 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
9400 DrawBackground(gi->x, gi->y, gi->width, gi->height);
9402 if (envelope_nr != -1)
9403 textarea_info[id].value = level.envelope[envelope_nr].text;
9405 ModifyGadget(gi, GDI_AREA_SIZE,
9406 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
9407 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
9410 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
9413 static void DrawPropertiesInfo(void)
9422 // configurable properties
9424 { EP_WALKABLE_OVER, "- player can walk over it" },
9425 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
9426 { EP_WALKABLE_UNDER, "- player can walk under it" },
9427 { EP_PASSABLE_OVER, "- player can pass over it" },
9428 { EP_PASSABLE_INSIDE, "- player can pass through it" },
9429 { EP_PASSABLE_UNDER, "- player can pass under it" },
9430 { EP_PROTECTED, "- player is protected by it" },
9432 { EP_DIGGABLE, "- can be digged away" },
9433 { EP_COLLECTIBLE, "- can be collected" },
9434 { EP_DROPPABLE, "- can be dropped after collecting" },
9435 { EP_THROWABLE, "- can be thrown after collecting" },
9436 { EP_PUSHABLE, "- can be pushed" },
9438 { EP_CAN_FALL, "- can fall" },
9439 { EP_CAN_MOVE, "- can move" },
9441 { EP_CAN_SMASH_PLAYER, "- can smash player" },
9443 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
9445 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
9447 { EP_SLIPPERY, "- slippery for falling elements" },
9448 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
9450 { EP_DONT_RUN_INTO, "- deadly when running into" },
9451 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
9452 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
9453 { EP_DONT_TOUCH, "- deadly when touching" },
9455 { EP_INDESTRUCTIBLE, "- indestructible" },
9457 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
9458 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
9459 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
9461 { EP_CAN_CHANGE, "- can change to other element" },
9463 // pre-defined properties
9464 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
9465 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
9466 { EP_SWITCHABLE, "- can be switched" },
9468 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
9473 char *filename = getElementDescriptionFilename(properties_element);
9474 char *percentage_text = "In this level: ";
9475 char *properties_text = "Standard properties: ";
9476 char *description_text = "Description:";
9477 char *no_description_text = "No description available.";
9478 char *none_text = "None";
9480 int num_elements_in_level;
9481 int num_standard_properties = 0;
9482 int font1_nr = FONT_TEXT_1;
9483 int font2_nr = FONT_TEXT_2;
9484 int font1_width = getFontWidth(font1_nr);
9485 int font1_height = getFontHeight(font1_nr);
9486 int font2_height = getFontHeight(font2_nr);
9487 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
9488 int font2_yoffset = (font1_height - font2_height) / 2;
9489 int percentage_text_len = strlen(percentage_text) * font1_width;
9490 int properties_text_len = strlen(properties_text) * font1_width;
9491 int xpos = ED_ELEMENT_SETTINGS_X(0);
9492 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9495 if (setup.editor.show_element_token)
9497 int font3_nr = FONT_TEXT_3;
9498 int font3_height = getFontHeight(font3_nr);
9500 DrawTextF(xpos, ypos, font3_nr,
9501 "[%s]", element_info[properties_element].token_name);
9503 ypos += 2 * font3_height;
9506 // ----- print number of elements / percentage of this element in level
9508 num_elements_in_level = 0;
9509 for (y = 0; y < lev_fieldy; y++)
9510 for (x = 0; x < lev_fieldx; x++)
9511 if (Feld[x][y] == properties_element)
9512 num_elements_in_level++;
9513 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
9515 DrawTextS(xpos, ypos, font1_nr, percentage_text);
9517 if (num_elements_in_level > 0)
9518 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9519 "%d (%.2f %%)", num_elements_in_level, percentage);
9521 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9524 ypos += 2 * MAX(font1_height, font2_height);
9526 // ----- print standard properties of this element
9528 DrawTextS(xpos, ypos, font1_nr, properties_text);
9530 ypos += line1_height;
9532 for (i = 0; properties[i].value != -1; i++)
9534 if (!HAS_PROPERTY(properties_element, properties[i].value))
9537 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
9539 ypos += font2_height;
9541 num_standard_properties++;
9544 if (num_standard_properties == 0)
9546 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
9547 font2_nr, none_text);
9549 ypos -= (line1_height - font1_height);
9552 ypos += MAX(font1_height, font2_height);
9554 // ----- print special description of this element
9556 PrintInfoText(description_text, font1_nr, xpos, ypos);
9558 ypos += line1_height;
9560 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
9561 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
9564 #define TEXT_COLLECTING "Score for collecting"
9565 #define TEXT_SMASHING "Score for smashing"
9566 #define TEXT_SLURPING "Score for slurping robot"
9567 #define TEXT_CRACKING "Score for cracking"
9568 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
9569 #define TEXT_DURATION "Duration when activated"
9570 #define TEXT_DELAY_ON "Delay before activating"
9571 #define TEXT_DELAY_OFF "Delay before deactivating"
9572 #define TEXT_DELAY_EXPLODING "Delay before exploding"
9573 #define TEXT_DELAY_MOVING "Delay before moving"
9574 #define TEXT_BALL_DELAY "Element generation delay"
9575 #define TEXT_MOVE_SPEED "Speed of android moving"
9576 #define TEXT_CLONE_SPEED "Speed of android cloning"
9577 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
9578 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
9579 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
9580 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
9581 #define TEXT_TIME_BONUS "Extra time to solve level"
9588 } elements_with_counter[] =
9590 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
9591 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
9592 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
9593 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
9594 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9595 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
9596 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
9597 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
9598 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
9599 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
9600 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
9601 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
9602 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9603 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9604 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
9605 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
9606 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
9607 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9608 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9609 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
9610 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9611 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9612 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9613 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9614 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9615 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9616 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
9617 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9618 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9619 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9620 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9621 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9622 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9623 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9624 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
9625 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
9626 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9627 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
9628 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9629 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9630 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9631 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9632 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9633 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
9634 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9635 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9636 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
9637 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9638 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9639 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
9640 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
9641 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
9642 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9643 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9644 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9645 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9646 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9647 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9648 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9649 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9650 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
9651 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
9652 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
9653 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
9654 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
9655 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9656 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
9657 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
9658 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
9659 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9660 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9661 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9662 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9663 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9664 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9665 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9666 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9667 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9668 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9669 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9670 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9671 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9672 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
9674 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
9675 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
9676 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
9677 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
9678 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
9679 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
9680 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
9681 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
9682 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
9683 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
9684 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
9685 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
9686 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
9687 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
9688 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
9689 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
9691 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
9692 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
9693 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
9694 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
9695 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
9696 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
9697 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
9698 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
9699 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
9700 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
9701 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_ON },
9702 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9703 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9708 static boolean checkPropertiesConfig(int element)
9712 if (IS_GEM(element) ||
9713 IS_CUSTOM_ELEMENT(element) ||
9714 IS_GROUP_ELEMENT(element) ||
9715 IS_BALLOON_ELEMENT(element) ||
9716 IS_ENVELOPE(element) ||
9717 IS_MM_MCDUFFIN(element) ||
9718 IS_DF_LASER(element) ||
9719 ELEM_IS_PLAYER(element) ||
9720 HAS_EDITOR_CONTENT(element) ||
9721 CAN_GROW(element) ||
9722 COULD_MOVE_INTO_ACID(element) ||
9723 MAYBE_DONT_COLLIDE_WITH(element) ||
9724 element == EL_SOKOBAN_OBJECT ||
9725 element == EL_SOKOBAN_FIELD_EMPTY ||
9726 element == EL_SOKOBAN_FIELD_FULL)
9729 for (i = 0; elements_with_counter[i].element != -1; i++)
9730 if (elements_with_counter[i].element == element)
9736 static void SetAutomaticNumberOfGemsNeeded(void)
9740 if (!level.auto_count_gems)
9743 level.gems_needed = 0;
9745 for (x = 0; x < lev_fieldx; x++)
9747 for (y = 0; y < lev_fieldy; y++)
9749 int element = Feld[x][y];
9751 if (IS_GEM(element) ||
9752 element == EL_MM_KETTLE ||
9753 element == EL_DF_CELL)
9754 level.gems_needed++;
9758 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
9761 static void DrawPropertiesConfig(void)
9763 boolean draw_footer_line = FALSE;
9764 int max_num_element_counters = 4;
9765 int num_element_counters = 0;
9768 if (!checkPropertiesConfig(properties_element))
9770 int xpos = ED_ELEMENT_SETTINGS_X(0);
9771 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9773 PrintInfoText("No configuration options available.",
9774 FONT_TEXT_1, xpos, ypos);
9779 // check if there are elements where a value can be chosen for
9780 for (i = 0; elements_with_counter[i].element != -1; i++)
9782 if (elements_with_counter[i].element == properties_element)
9784 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
9786 counterbutton_info[counter_id].y =
9787 ED_ELEMENT_SETTINGS_YPOS(
9788 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
9789 (CAN_GROW(properties_element) ? 1 : 0) +
9790 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
9791 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
9792 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
9793 num_element_counters);
9795 counterbutton_info[counter_id].value = elements_with_counter[i].value;
9796 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
9798 if (properties_element == EL_GAME_OF_LIFE ||
9799 properties_element == EL_BIOMAZE)
9801 counterbutton_info[counter_id].min_value = 0; // min neighbours
9802 counterbutton_info[counter_id].max_value = 8; // max neighbours
9806 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
9807 counterbutton_info[counter_id].min_value = MIN_SCORE;
9808 counterbutton_info[counter_id].max_value = MAX_SCORE;
9811 MapCounterButtons(counter_id);
9813 num_element_counters++;
9814 if (num_element_counters >= max_num_element_counters)
9819 if (HAS_EDITOR_CONTENT(properties_element))
9821 // draw stickybutton gadget
9822 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9824 if (IS_AMOEBOID(properties_element))
9825 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
9826 else if (properties_element == EL_YAMYAM ||
9827 properties_element == EL_YAMYAM_LEFT ||
9828 properties_element == EL_YAMYAM_RIGHT ||
9829 properties_element == EL_YAMYAM_UP ||
9830 properties_element == EL_YAMYAM_DOWN)
9831 DrawYamYamContentAreas();
9832 else if (properties_element == EL_EMC_MAGIC_BALL)
9834 DrawMagicBallContentAreas();
9836 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
9837 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_STATE);
9839 else if (properties_element == EL_EMC_ANDROID)
9840 DrawAndroidElementArea(properties_element);
9843 if (ELEM_IS_PLAYER(properties_element))
9845 int player_nr = GET_PLAYER_NR(properties_element);
9847 // these properties can be set for every player individually
9849 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
9851 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
9852 &level.start_element[player_nr];
9853 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
9854 &level.artwork_element[player_nr];
9855 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
9856 &level.explosion_element[player_nr];
9858 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
9859 &level.use_start_element[player_nr];
9860 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
9861 &level.use_artwork_element[player_nr];
9862 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
9863 &level.use_explosion_element[player_nr];
9864 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
9865 &level.initial_player_gravity[player_nr];
9867 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
9868 &level.initial_player_stepsize[player_nr];
9870 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
9871 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
9872 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
9873 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
9874 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
9875 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
9876 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
9877 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
9878 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
9879 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
9880 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
9881 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
9882 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
9883 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
9884 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
9886 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
9887 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
9888 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
9890 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
9892 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
9894 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
9895 &level.initial_inventory_content[player_nr][0];
9897 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
9898 &level.initial_inventory_size[player_nr];
9900 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
9901 &level.use_initial_inventory[player_nr];
9903 // draw checkbutton gadgets
9904 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
9906 // draw counter gadgets
9907 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
9909 // draw drawing area gadgets
9910 DrawPlayerInitialInventoryArea(properties_element);
9914 if (IS_GEM(properties_element))
9915 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
9917 if (properties_element == EL_EM_DYNAMITE)
9918 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
9920 if (COULD_MOVE_INTO_ACID(properties_element) &&
9921 !ELEM_IS_PLAYER(properties_element) &&
9922 (!IS_CUSTOM_ELEMENT(properties_element) ||
9923 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
9925 // set position for checkbutton for "can move into acid"
9926 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
9927 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
9928 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
9929 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 :
9930 IS_BALLOON_ELEMENT(properties_element) ||
9931 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
9933 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
9936 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
9937 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
9939 if (properties_element == EL_SPRING)
9940 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
9942 if (properties_element == EL_TIME_ORB_FULL)
9943 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
9945 if (properties_element == EL_GAME_OF_LIFE ||
9946 properties_element == EL_BIOMAZE)
9947 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
9949 if (CAN_GROW(properties_element))
9951 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
9952 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
9954 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
9957 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
9958 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
9960 if (properties_element == EL_SOKOBAN_OBJECT)
9961 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
9963 if (properties_element == EL_SOKOBAN_OBJECT ||
9964 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
9965 properties_element == EL_SOKOBAN_FIELD_FULL)
9967 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
9968 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
9971 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
9974 if (IS_BALLOON_ELEMENT(properties_element))
9975 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
9977 if (IS_ENVELOPE(properties_element))
9979 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
9980 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
9981 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
9982 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
9983 int envelope_nr = properties_element - EL_ENVELOPE_1;
9985 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
9986 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
9988 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
9989 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
9991 // display counter to choose size of envelope text area
9992 MapCounterButtons(counter1_id);
9993 MapCounterButtons(counter2_id);
9995 // display checkbuttons to choose auto-wrap and alignment properties
9996 MapCheckbuttonGadget(button1_id);
9997 MapCheckbuttonGadget(button2_id);
9999 DrawEnvelopeTextArea(envelope_nr);
10002 if (IS_MM_MCDUFFIN(properties_element))
10004 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
10005 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
10006 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
10009 if (IS_DF_LASER(properties_element))
10011 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
10012 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
10013 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
10016 if (IS_CUSTOM_ELEMENT(properties_element))
10018 // draw stickybutton gadget
10019 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10021 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10023 // draw checkbutton gadgets
10024 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
10025 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
10026 MapCheckbuttonGadget(i);
10028 // draw counter gadgets
10029 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
10030 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
10031 MapCounterButtons(i);
10033 // draw selectbox gadgets
10034 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
10035 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
10036 MapSelectboxGadget(i);
10038 // draw textbutton gadgets
10039 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10041 // draw text input gadgets
10042 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10044 // draw drawing area gadgets
10045 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10047 draw_footer_line = TRUE;
10049 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10051 // draw checkbutton gadgets
10052 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
10053 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
10054 MapCheckbuttonGadget(i);
10056 // draw counter gadgets
10057 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
10058 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
10059 MapCounterButtons(i);
10061 // draw selectbox gadgets
10062 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
10063 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
10064 MapSelectboxGadget(i);
10066 // draw drawing area gadgets
10067 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
10068 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
10069 DrawCustomContentArea();
10072 else if (IS_GROUP_ELEMENT(properties_element))
10074 // draw stickybutton gadget
10075 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10077 // draw checkbutton gadgets
10078 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10079 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10081 // draw counter gadgets
10082 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
10084 // draw selectbox gadgets
10085 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
10087 // draw textbutton gadgets
10088 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10090 // draw drawing area gadgets
10091 DrawGroupElementArea(properties_element);
10093 // draw text input gadgets
10094 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10096 // draw drawing area gadgets
10097 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10099 draw_footer_line = TRUE;
10102 // draw little footer border line above CE/GE use/save template gadgets
10103 if (draw_footer_line)
10105 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
10106 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
10107 int gd_x = gd->x + gd_gi1->border.width / 2;
10108 int gd_y = gd->y + gd_gi1->height - 1;
10109 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
10111 if (tab_color != BLACK_PIXEL) // black => transparent
10112 FillRectangle(drawto,
10113 SX + ED_ELEMENT_SETTINGS_X(0),
10114 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
10116 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10120 static void DrawPropertiesChangeDrawingAreas(void)
10122 if (IS_CUSTOM_ELEMENT(properties_element))
10124 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
10125 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
10126 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
10128 DrawCustomChangeContentArea();
10131 redraw_mask |= REDRAW_FIELD;
10134 static void DrawPropertiesChange(void)
10138 // needed to initially set selectbox options for special action options
10139 setSelectboxSpecialActionOptions();
10141 // draw stickybutton gadget
10142 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10144 // draw checkbutton gadgets
10145 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
10146 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
10147 MapCheckbuttonGadget(i);
10149 // draw counter gadgets
10150 for (i = ED_COUNTER_ID_CHANGE_FIRST;
10151 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
10152 MapCounterButtons(i);
10154 // draw selectbox gadgets
10155 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
10156 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
10157 MapSelectboxGadget(i);
10159 // draw textbutton gadgets
10160 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
10161 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
10162 MapTextbuttonGadget(i);
10164 // draw graphicbutton gadgets
10165 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
10166 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
10167 MapGraphicbuttonGadget(i);
10169 // draw drawing area gadgets
10170 DrawPropertiesChangeDrawingAreas();
10173 static void DrawEditorElementAnimation(int x, int y)
10175 int graphic = el2img(properties_element);
10176 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
10177 custom_element.ce_value_fixed_initial :
10178 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
10179 custom_element.collect_score_initial : FrameCounter);
10181 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
10184 static void DrawEditorElementName(int x, int y, int font_nr)
10186 char *element_name = getElementInfoText(properties_element);
10187 int font_width = getFontWidth(font_nr);
10188 int font_height = getFontHeight(font_nr);
10189 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
10190 int max_chars_per_line = max_text_width / font_width;
10191 char buffer[max_chars_per_line + 1];
10193 if (strlen(element_name) <= max_chars_per_line)
10194 DrawTextS(x, y, font_nr, element_name);
10197 int next_pos = max_chars_per_line;
10199 strncpy(buffer, element_name, max_chars_per_line);
10200 buffer[max_chars_per_line] = '\0';
10202 if (element_name[max_chars_per_line] == ' ')
10208 for (i = max_chars_per_line - 1; i >= 0; i--)
10209 if (buffer[i] == ' ')
10212 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
10219 DrawTextS(x, y - font_height / 2, font_nr, buffer);
10221 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
10222 buffer[max_chars_per_line] = '\0';
10224 DrawTextS(x, y + font_height / 2, font_nr, buffer);
10228 static void DrawPropertiesWindow(void)
10230 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
10231 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
10232 int border_size = gd->border_size;
10233 int font_nr = FONT_TEXT_1;
10234 int font_height = getFontHeight(font_nr);
10235 int xoffset = TILEX + element_border + 3 * border_size;
10236 int yoffset = (TILEY - font_height) / 2;
10237 int x1 = editor.settings.element_graphic.x + element_border;
10238 int y1 = editor.settings.element_graphic.y + element_border;
10239 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
10240 editor.settings.element_name.x);
10241 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
10242 editor.settings.element_name.y);
10243 char *text = "Element Settings";
10244 int font2_nr = FONT_TITLE_1;
10245 struct MenuPosInfo *pos = &editor.settings.headline;
10246 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
10247 int sy = SY + pos->y;
10249 stick_element_properties_window = FALSE;
10251 // make sure that previous properties edit mode exists for this element
10252 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
10253 !IS_CUSTOM_ELEMENT(properties_element))
10254 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
10256 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
10257 !ELEM_IS_PLAYER(properties_element) &&
10258 !IS_CUSTOM_ELEMENT(properties_element))
10259 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
10261 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
10262 (ELEM_IS_PLAYER(properties_element) ||
10263 IS_CUSTOM_ELEMENT(properties_element)))
10264 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
10266 CopyElementPropertiesToEditor(properties_element);
10268 UnmapLevelEditorFieldGadgets();
10269 UnmapLevelEditorToolboxDrawingGadgets();
10270 UnmapLevelEditorToolboxCustomGadgets();
10272 if (IS_CUSTOM_ELEMENT(properties_element) ||
10273 IS_GROUP_ELEMENT(properties_element))
10274 MapLevelEditorToolboxCustomGadgets();
10276 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10279 DrawText(sx, sy, text, font2_nr);
10281 FrameCounter = 0; // restart animation frame counter
10283 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
10284 DrawEditorElementAnimation(SX + x1, SY + y1);
10285 DrawEditorElementName(x2, y2, font_nr);
10287 DrawPropertiesTabulatorGadgets();
10289 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
10290 DrawPropertiesInfo();
10291 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
10292 DrawPropertiesChange();
10293 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
10294 DrawPropertiesConfig();
10297 static void DrawPaletteWindow(void)
10301 UnmapLevelEditorFieldGadgets();
10303 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10306 // map buttons to select elements
10307 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
10308 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
10309 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
10310 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
10311 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
10314 static void UpdateCustomElementGraphicGadgets(void)
10318 InitElementPropertiesGfxElement();
10320 ModifyEditorElementList();
10321 RedrawDrawingElements();
10323 // force redraw of all mapped drawing area gadgets
10324 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
10326 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
10333 static int getOpenDirectionFromTube(int element)
10337 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
10338 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
10339 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
10340 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
10341 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
10342 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
10343 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
10344 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
10345 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
10346 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
10347 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
10353 static int getTubeFromOpenDirection(int direction)
10357 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
10358 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
10359 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
10360 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
10361 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
10362 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
10363 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
10364 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
10365 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
10366 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
10367 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
10369 // if only one direction, fall back to simple tube with that direction
10370 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
10371 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
10372 case (MV_UP): return EL_TUBE_VERTICAL;
10373 case (MV_DOWN): return EL_TUBE_VERTICAL;
10379 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
10381 int element_new = getTubeFromOpenDirection(direction);
10383 return (element_new != EL_EMPTY ? element_new : element_old);
10386 static int getOpenDirectionFromBelt(int element)
10388 int belt_dir = getBeltDirFromBeltElement(element);
10390 return (belt_dir == MV_LEFT ? MV_RIGHT :
10391 belt_dir == MV_RIGHT ? MV_LEFT :
10392 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
10395 static int getBeltFromNrAndOpenDirection(int nr, int direction)
10397 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
10398 direction == MV_RIGHT ? MV_LEFT :
10399 direction == MV_HORIZONTAL ? MV_NONE : direction);
10401 if (direction == MV_NONE)
10404 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
10407 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
10410 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
10412 return (element_new != EL_EMPTY ? element_new : element_old);
10415 static int getOpenDirectionFromPool(int element)
10419 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
10420 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
10421 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
10422 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
10423 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
10424 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
10430 static int getPoolFromOpenDirection(int direction)
10434 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
10435 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
10436 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
10437 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
10438 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
10439 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
10445 static int getPoolFromOpenDirectionExt(int direction, int help_element)
10447 int element = getPoolFromOpenDirection(direction);
10448 int help_direction = getOpenDirectionFromPool(help_element);
10450 if (element == EL_EMPTY)
10452 int help_direction_vertical = help_direction & MV_VERTICAL;
10454 element = getPoolFromOpenDirection(direction | help_direction_vertical);
10457 if (element == EL_EMPTY)
10459 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
10461 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
10467 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
10469 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
10471 return (element_new != EL_EMPTY ? element_new : element_old);
10474 static int getOpenDirectionFromPillar(int element)
10478 case EL_EMC_WALL_1: return (MV_DOWN);
10479 case EL_EMC_WALL_2: return (MV_VERTICAL);
10480 case EL_EMC_WALL_3: return (MV_UP);
10486 static int getPillarFromOpenDirection(int direction)
10490 case (MV_DOWN): return EL_EMC_WALL_1;
10491 case (MV_VERTICAL): return EL_EMC_WALL_2;
10492 case (MV_UP): return EL_EMC_WALL_3;
10498 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
10500 int element_new = getPillarFromOpenDirection(direction);
10502 return (element_new != EL_EMPTY ? element_new : element_old);
10505 static int getOpenDirectionFromSteel2(int element)
10509 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
10510 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
10511 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
10512 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
10513 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
10514 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
10515 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
10516 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
10522 static int getSteel2FromOpenDirection(int direction)
10526 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
10527 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
10528 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
10529 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
10530 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
10531 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
10532 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
10533 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
10539 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
10541 int element_new = getSteel2FromOpenDirection(direction);
10543 return (element_new != EL_EMPTY ? element_new : element_old);
10546 static int getOpenDirectionFromChip(int element)
10550 case EL_SP_CHIP_SINGLE: return (MV_NONE);
10551 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
10552 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
10553 case EL_SP_CHIP_TOP: return (MV_DOWN);
10554 case EL_SP_CHIP_BOTTOM: return (MV_UP);
10560 static int getChipFromOpenDirection(int direction)
10564 case (MV_NONE): return EL_SP_CHIP_SINGLE;
10565 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
10566 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
10567 case (MV_UP): return EL_SP_CHIP_BOTTOM;
10568 case (MV_DOWN): return EL_SP_CHIP_TOP;
10574 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
10576 int element_new = getChipFromOpenDirection(direction);
10578 return (element_new != EL_EMPTY ? element_new : element_old);
10581 static int getClosedTube(int x, int y)
10583 static int xy[4][2] =
10590 int element_old = IntelliDrawBuffer[x][y];
10591 int direction_old = getOpenDirectionFromTube(element_old);
10592 int direction_new = MV_NONE;
10595 for (i = 0; i < NUM_DIRECTIONS; i++)
10597 int xx = x + xy[i][0];
10598 int yy = y + xy[i][1];
10599 int dir = MV_DIR_FROM_BIT(i);
10600 int dir_opposite = MV_DIR_OPPOSITE(dir);
10602 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
10603 (direction_old & dir) &&
10604 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10605 direction_new |= dir;
10608 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
10611 static int getClosedBelt(int x, int y)
10613 static int xy[4][2] =
10620 int element_old = IntelliDrawBuffer[x][y];
10621 int nr = getBeltNrFromBeltElement(element_old);
10622 int direction_old = getOpenDirectionFromBelt(element_old);
10623 int direction_new = MV_NONE;
10626 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10628 int xx = x + xy[i][0];
10629 int yy = y + xy[i][1];
10630 int dir = MV_DIR_FROM_BIT(i);
10631 int dir_opposite = MV_DIR_OPPOSITE(dir);
10633 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
10634 (direction_old & dir) &&
10635 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10636 direction_new |= dir;
10639 return getBeltFromNrAndOpenDirection(nr, direction_new);
10642 static int getClosedPool(int x, int y)
10644 static int xy[4][2] =
10651 int element_old = IntelliDrawBuffer[x][y];
10652 int direction_old = getOpenDirectionFromPool(element_old);
10653 int direction_new = MV_NONE;
10656 for (i = 0; i < NUM_DIRECTIONS; i++)
10658 int xx = x + xy[i][0];
10659 int yy = y + xy[i][1];
10660 int dir = MV_DIR_FROM_BIT(i);
10661 int dir_opposite = MV_DIR_OPPOSITE(dir);
10663 if (IN_LEV_FIELD(xx, yy) &&
10664 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
10665 (direction_old & dir) &&
10666 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10667 direction_new |= dir;
10670 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
10673 static int getClosedPillar(int x, int y)
10675 static int xy[4][2] =
10682 int element_old = IntelliDrawBuffer[x][y];
10683 int direction_old = getOpenDirectionFromPillar(element_old);
10684 int direction_new = MV_NONE;
10687 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
10689 int xx = x + xy[i][0];
10690 int yy = y + xy[i][1];
10691 int dir = MV_DIR_FROM_BIT(i);
10692 int dir_opposite = MV_DIR_OPPOSITE(dir);
10694 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
10695 (direction_old & dir) &&
10696 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10697 direction_new |= dir;
10700 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
10703 static int getClosedSteel2(int x, int y)
10705 static int xy[4][2] =
10712 int element_old = IntelliDrawBuffer[x][y];
10713 int direction_old = getOpenDirectionFromSteel2(element_old);
10714 int direction_new = MV_NONE;
10717 for (i = 0; i < NUM_DIRECTIONS; i++)
10719 int xx = x + xy[i][0];
10720 int yy = y + xy[i][1];
10721 int dir = MV_DIR_FROM_BIT(i);
10722 int dir_opposite = MV_DIR_OPPOSITE(dir);
10724 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
10725 (direction_old & dir) &&
10726 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10727 direction_new |= dir;
10730 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
10733 static int getClosedChip(int x, int y)
10735 static int xy[4][2] =
10742 int element_old = IntelliDrawBuffer[x][y];
10743 int direction_old = getOpenDirectionFromChip(element_old);
10744 int direction_new = MV_NONE;
10747 for (i = 0; i < NUM_DIRECTIONS; i++)
10749 int xx = x + xy[i][0];
10750 int yy = y + xy[i][1];
10751 int dir = MV_DIR_FROM_BIT(i);
10752 int dir_opposite = MV_DIR_OPPOSITE(dir);
10754 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
10755 (direction_old & dir) &&
10756 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10757 direction_new |= dir;
10760 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
10763 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
10764 boolean change_level)
10766 int sx = x - level_xpos;
10767 int sy = y - level_ypos;
10768 int old_element = Feld[x][y];
10769 int new_element = element;
10770 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
10771 boolean draw_masked = FALSE;
10773 if (IS_MM_WALL_EDITOR(element))
10775 element = map_mm_wall_element_editor(element) | new_bitmask;
10777 if (IS_MM_WALL(old_element))
10778 element |= MM_WALL_BITS(old_element);
10781 draw_masked = TRUE;
10783 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
10785 int element_changed = old_element & ~new_bitmask;
10787 if (MM_WALL_BITS(element_changed) != 0)
10788 element = element_changed;
10791 IntelliDrawBuffer[x][y] = element;
10794 Feld[x][y] = element;
10796 if (IN_ED_FIELD(sx, sy))
10798 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
10799 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
10800 else if (draw_masked)
10801 DrawEditorElementThruMask(sx, sy, element);
10803 DrawEditorElement(sx, sy, element);
10807 static void SetElementSimple(int x, int y, int element, boolean change_level)
10809 SetElementSimpleExt(x, y, 0, 0, element, change_level);
10812 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
10813 int x2, int y2, int *element2,
10814 int (*close_function)(int, int),
10815 boolean change_level)
10817 // set neighbour elements to newly determined connections
10818 SetElementSimple(x1, y1, *element1, change_level);
10819 SetElementSimple(x2, y2, *element2, change_level);
10821 // remove all open connections of neighbour elements
10822 *element1 = close_function(x1, y1);
10823 *element2 = close_function(x2, y2);
10825 // set neighbour elements to new, minimized connections
10826 SetElementSimple(x1, y1, *element1, change_level);
10827 SetElementSimple(x2, y2, *element2, change_level);
10830 static void SetElementIntelliDraw(int x, int y, int new_element,
10831 boolean change_level, int button)
10833 static int xy[4][2] =
10840 static int last_x = -1;
10841 static int last_y = -1;
10842 int old_element = IntelliDrawBuffer[x][y];
10844 if (new_element == EL_UNDEFINED)
10852 if (IS_TUBE(new_element))
10854 int last_element_new = EL_UNDEFINED;
10855 int direction = MV_NONE;
10858 // if old element is of same kind, keep all existing directions
10859 if (IS_TUBE(old_element))
10860 direction |= getOpenDirectionFromTube(old_element);
10862 for (i = 0; i < NUM_DIRECTIONS; i++)
10864 int xx = x + xy[i][0];
10865 int yy = y + xy[i][1];
10867 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10868 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
10870 int dir = MV_DIR_FROM_BIT(i);
10871 int dir_opposite = MV_DIR_OPPOSITE(dir);
10872 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10873 int last_direction_old = getOpenDirectionFromTube(last_element_old);
10874 int last_direction_new = last_direction_old | dir_opposite;
10876 last_element_new = getTubeFromOpenDirection(last_direction_new);
10882 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
10884 if (last_element_new != EL_UNDEFINED)
10885 MergeAndCloseNeighbourElements(x, y, &new_element,
10886 last_x, last_y, &last_element_new,
10887 getClosedTube, change_level);
10889 else if (IS_BELT(new_element))
10891 int belt_nr = getBeltNrFromBeltElement(new_element);
10892 int last_element_new = EL_UNDEFINED;
10893 int direction = MV_NONE;
10896 // if old element is of same kind, keep all existing directions
10897 if (IS_BELT(old_element))
10898 direction |= getOpenDirectionFromBelt(old_element);
10900 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10902 int xx = x + xy[i][0];
10903 int yy = y + xy[i][1];
10905 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10906 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
10908 int dir = MV_DIR_FROM_BIT(i);
10909 int dir_opposite = MV_DIR_OPPOSITE(dir);
10910 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10911 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
10912 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
10913 int last_direction_new = last_direction_old | dir_opposite;
10915 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
10916 last_direction_new);
10921 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
10923 if (last_element_new != EL_UNDEFINED)
10924 MergeAndCloseNeighbourElements(x, y, &new_element,
10925 last_x, last_y, &last_element_new,
10926 getClosedBelt, change_level);
10928 else if (IS_ACID_POOL_OR_ACID(new_element))
10930 int last_element_new = EL_UNDEFINED;
10931 int direction = MV_NONE;
10934 // if old element is of same kind, keep all existing directions
10935 if (IS_ACID_POOL_OR_ACID(old_element))
10936 direction |= getOpenDirectionFromPool(old_element);
10938 for (i = 0; i < NUM_DIRECTIONS; i++)
10940 int xx = x + xy[i][0];
10941 int yy = y + xy[i][1];
10943 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10944 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
10946 int dir = MV_DIR_FROM_BIT(i);
10947 int dir_opposite = MV_DIR_OPPOSITE(dir);
10948 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10949 int last_direction_old = getOpenDirectionFromPool(last_element_old);
10950 int last_direction_new = last_direction_old | dir_opposite;
10952 last_element_new = getPoolFromOpenDirection(last_direction_new);
10958 // special corrections needed for intuitively correct acid pool drawing
10959 if (last_element_new == EL_EMPTY)
10960 last_element_new = new_element;
10961 else if (last_element_new != EL_UNDEFINED)
10962 new_element = last_element_new;
10964 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
10966 if (last_element_new != EL_UNDEFINED)
10967 MergeAndCloseNeighbourElements(x, y, &new_element,
10968 last_x, last_y, &last_element_new,
10969 getClosedPool, change_level);
10971 else if (IS_EMC_PILLAR(new_element))
10973 int last_element_new = EL_UNDEFINED;
10974 int direction = MV_NONE;
10977 // if old element is of same kind, keep all existing directions
10978 if (IS_EMC_PILLAR(old_element))
10979 direction |= getOpenDirectionFromPillar(old_element);
10981 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
10983 int xx = x + xy[i][0];
10984 int yy = y + xy[i][1];
10986 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10987 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
10989 int dir = MV_DIR_FROM_BIT(i);
10990 int dir_opposite = MV_DIR_OPPOSITE(dir);
10991 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10992 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
10993 int last_direction_new = last_direction_old | dir_opposite;
10995 last_element_new = getPillarFromOpenDirection(last_direction_new);
11001 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
11003 if (last_element_new != EL_UNDEFINED)
11004 MergeAndCloseNeighbourElements(x, y, &new_element,
11005 last_x, last_y, &last_element_new,
11006 getClosedPillar, change_level);
11008 else if (IS_DC_STEELWALL_2(new_element))
11010 int last_element_new = EL_UNDEFINED;
11011 int direction = MV_NONE;
11014 // if old element is of same kind, keep all existing directions
11015 if (IS_DC_STEELWALL_2(old_element))
11016 direction |= getOpenDirectionFromSteel2(old_element);
11018 for (i = 0; i < NUM_DIRECTIONS; i++)
11020 int xx = x + xy[i][0];
11021 int yy = y + xy[i][1];
11023 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11024 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
11026 int dir = MV_DIR_FROM_BIT(i);
11027 int dir_opposite = MV_DIR_OPPOSITE(dir);
11028 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11029 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
11030 int last_direction_new = last_direction_old | dir_opposite;
11032 last_element_new = getSteel2FromOpenDirection(last_direction_new);
11038 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
11040 if (last_element_new != EL_UNDEFINED)
11041 MergeAndCloseNeighbourElements(x, y, &new_element,
11042 last_x, last_y, &last_element_new,
11043 getClosedSteel2, change_level);
11045 else if (IS_SP_CHIP(new_element))
11047 int last_element_new = EL_UNDEFINED;
11048 int direction = MV_NONE;
11051 // (do not keep existing directions, regardless of kind of old element)
11053 for (i = 0; i < NUM_DIRECTIONS; i++)
11055 int xx = x + xy[i][0];
11056 int yy = y + xy[i][1];
11058 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11059 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
11061 int dir = MV_DIR_FROM_BIT(i);
11062 int dir_opposite = MV_DIR_OPPOSITE(dir);
11063 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11064 int last_direction_old = getOpenDirectionFromChip(last_element_old);
11065 int last_direction_new = last_direction_old | dir_opposite;
11067 if (last_direction_old == MV_NONE)
11069 last_element_new = getChipFromOpenDirection(last_direction_new);
11072 else if (last_direction_old & (dir | dir_opposite))
11074 direction |= MV_DIR_OPPOSITE(last_direction_old);
11078 direction |= MV_DIR_OPPOSITE(dir);
11083 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
11085 if (last_element_new != EL_UNDEFINED)
11086 MergeAndCloseNeighbourElements(x, y, &new_element,
11087 last_x, last_y, &last_element_new,
11088 getClosedChip, change_level);
11090 else if (IS_SP_HARDWARE_BASE(new_element))
11092 int nr = GetSimpleRandom(6);
11094 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
11095 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
11096 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
11097 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
11098 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
11100 else if (new_element == EL_SP_HARDWARE_GREEN ||
11101 new_element == EL_SP_HARDWARE_BLUE ||
11102 new_element == EL_SP_HARDWARE_RED)
11104 int nr = GetSimpleRandom(3);
11106 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
11107 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
11109 else if (IS_GROUP_ELEMENT(new_element))
11111 boolean connected_drawing = FALSE;
11114 for (i = 0; i < NUM_DIRECTIONS; i++)
11116 int xx = x + xy[i][0];
11117 int yy = y + xy[i][1];
11119 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11120 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
11121 connected_drawing = TRUE;
11124 if (!connected_drawing)
11125 ResolveGroupElement(new_element);
11127 new_element = GetElementFromGroupElement(new_element);
11129 else if (IS_BELT_SWITCH(old_element))
11131 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
11132 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
11134 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
11135 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
11137 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
11141 static int swappable_elements[][2] =
11143 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
11144 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
11145 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
11146 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
11147 { EL_EMERALD, EL_WALL_EMERALD },
11148 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
11149 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
11150 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
11151 { EL_DIAMOND, EL_WALL_DIAMOND },
11152 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
11153 { EL_GATE_1, EL_GATE_1_GRAY },
11154 { EL_GATE_2, EL_GATE_2_GRAY },
11155 { EL_GATE_3, EL_GATE_3_GRAY },
11156 { EL_GATE_4, EL_GATE_4_GRAY },
11157 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
11158 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
11159 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
11160 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
11161 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
11162 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
11163 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
11164 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
11165 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
11166 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
11167 { EL_LAMP, EL_LAMP_ACTIVE },
11168 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
11169 { EL_SP_BASE, EL_SP_BUGGY_BASE },
11170 { EL_PEARL, EL_WALL_PEARL },
11171 { EL_CRYSTAL, EL_WALL_CRYSTAL },
11172 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
11173 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
11174 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
11175 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
11176 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
11177 { EL_LANDMINE, EL_DC_LANDMINE },
11178 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
11179 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
11180 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
11181 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
11182 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
11183 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
11184 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
11185 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
11186 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
11190 static int rotatable_elements_4[][4] =
11200 EL_SPACESHIP_RIGHT,
11205 EL_BD_BUTTERFLY_UP,
11206 EL_BD_BUTTERFLY_RIGHT,
11207 EL_BD_BUTTERFLY_DOWN,
11208 EL_BD_BUTTERFLY_LEFT
11212 EL_BD_FIREFLY_RIGHT,
11213 EL_BD_FIREFLY_DOWN,
11241 EL_SP_GRAVITY_PORT_UP,
11242 EL_SP_GRAVITY_PORT_RIGHT,
11243 EL_SP_GRAVITY_PORT_DOWN,
11244 EL_SP_GRAVITY_PORT_LEFT
11247 EL_SP_GRAVITY_ON_PORT_UP,
11248 EL_SP_GRAVITY_ON_PORT_RIGHT,
11249 EL_SP_GRAVITY_ON_PORT_DOWN,
11250 EL_SP_GRAVITY_ON_PORT_LEFT
11253 EL_SP_GRAVITY_OFF_PORT_UP,
11254 EL_SP_GRAVITY_OFF_PORT_RIGHT,
11255 EL_SP_GRAVITY_OFF_PORT_DOWN,
11256 EL_SP_GRAVITY_OFF_PORT_LEFT
11265 EL_BALLOON_SWITCH_UP,
11266 EL_BALLOON_SWITCH_RIGHT,
11267 EL_BALLOON_SWITCH_DOWN,
11268 EL_BALLOON_SWITCH_LEFT
11272 EL_MM_MCDUFFIN_RIGHT,
11273 EL_MM_MCDUFFIN_DOWN,
11274 EL_MM_MCDUFFIN_LEFT
11277 EL_MM_MIRROR_FIXED_1,
11278 EL_MM_MIRROR_FIXED_4,
11279 EL_MM_MIRROR_FIXED_3,
11280 EL_MM_MIRROR_FIXED_2
11283 EL_MM_STEEL_GRID_FIXED_1,
11284 EL_MM_STEEL_GRID_FIXED_4,
11285 EL_MM_STEEL_GRID_FIXED_2,
11286 EL_MM_STEEL_GRID_FIXED_3
11289 EL_MM_WOODEN_GRID_FIXED_1,
11290 EL_MM_WOODEN_GRID_FIXED_4,
11291 EL_MM_WOODEN_GRID_FIXED_2,
11292 EL_MM_WOODEN_GRID_FIXED_3
11295 EL_MM_POLARIZER_CROSS_1,
11296 EL_MM_POLARIZER_CROSS_4,
11297 EL_MM_POLARIZER_CROSS_3,
11298 EL_MM_POLARIZER_CROSS_2
11302 EL_MM_PACMAN_RIGHT,
11314 EL_DF_RECEIVER_RIGHT,
11315 EL_DF_RECEIVER_DOWN,
11316 EL_DF_RECEIVER_LEFT
11323 static int rotatable_elements_8[][8] =
11326 EL_DF_STEEL_GRID_FIXED_1,
11327 EL_DF_STEEL_GRID_FIXED_8,
11328 EL_DF_STEEL_GRID_FIXED_7,
11329 EL_DF_STEEL_GRID_FIXED_6,
11330 EL_DF_STEEL_GRID_FIXED_5,
11331 EL_DF_STEEL_GRID_FIXED_4,
11332 EL_DF_STEEL_GRID_FIXED_3,
11333 EL_DF_STEEL_GRID_FIXED_2
11336 EL_DF_WOODEN_GRID_FIXED_1,
11337 EL_DF_WOODEN_GRID_FIXED_8,
11338 EL_DF_WOODEN_GRID_FIXED_7,
11339 EL_DF_WOODEN_GRID_FIXED_6,
11340 EL_DF_WOODEN_GRID_FIXED_5,
11341 EL_DF_WOODEN_GRID_FIXED_4,
11342 EL_DF_WOODEN_GRID_FIXED_3,
11343 EL_DF_WOODEN_GRID_FIXED_2
11346 EL_DF_STEEL_GRID_ROTATING_1,
11347 EL_DF_STEEL_GRID_ROTATING_8,
11348 EL_DF_STEEL_GRID_ROTATING_7,
11349 EL_DF_STEEL_GRID_ROTATING_6,
11350 EL_DF_STEEL_GRID_ROTATING_5,
11351 EL_DF_STEEL_GRID_ROTATING_4,
11352 EL_DF_STEEL_GRID_ROTATING_3,
11353 EL_DF_STEEL_GRID_ROTATING_2
11356 EL_DF_WOODEN_GRID_ROTATING_1,
11357 EL_DF_WOODEN_GRID_ROTATING_8,
11358 EL_DF_WOODEN_GRID_ROTATING_7,
11359 EL_DF_WOODEN_GRID_ROTATING_6,
11360 EL_DF_WOODEN_GRID_ROTATING_5,
11361 EL_DF_WOODEN_GRID_ROTATING_4,
11362 EL_DF_WOODEN_GRID_ROTATING_3,
11363 EL_DF_WOODEN_GRID_ROTATING_2
11370 static int rotatable_elements_16[][16] =
11391 EL_MM_TELEPORTER_5,
11392 EL_MM_TELEPORTER_4,
11393 EL_MM_TELEPORTER_3,
11394 EL_MM_TELEPORTER_2,
11395 EL_MM_TELEPORTER_1,
11396 EL_MM_TELEPORTER_16,
11397 EL_MM_TELEPORTER_15,
11398 EL_MM_TELEPORTER_14,
11399 EL_MM_TELEPORTER_13,
11400 EL_MM_TELEPORTER_12,
11401 EL_MM_TELEPORTER_11,
11402 EL_MM_TELEPORTER_10,
11403 EL_MM_TELEPORTER_9,
11404 EL_MM_TELEPORTER_8,
11405 EL_MM_TELEPORTER_7,
11409 EL_MM_TELEPORTER_RED_5,
11410 EL_MM_TELEPORTER_RED_4,
11411 EL_MM_TELEPORTER_RED_3,
11412 EL_MM_TELEPORTER_RED_2,
11413 EL_MM_TELEPORTER_RED_1,
11414 EL_MM_TELEPORTER_RED_16,
11415 EL_MM_TELEPORTER_RED_15,
11416 EL_MM_TELEPORTER_RED_14,
11417 EL_MM_TELEPORTER_RED_13,
11418 EL_MM_TELEPORTER_RED_12,
11419 EL_MM_TELEPORTER_RED_11,
11420 EL_MM_TELEPORTER_RED_10,
11421 EL_MM_TELEPORTER_RED_9,
11422 EL_MM_TELEPORTER_RED_8,
11423 EL_MM_TELEPORTER_RED_7,
11424 EL_MM_TELEPORTER_RED_6
11427 EL_MM_TELEPORTER_YELLOW_5,
11428 EL_MM_TELEPORTER_YELLOW_4,
11429 EL_MM_TELEPORTER_YELLOW_3,
11430 EL_MM_TELEPORTER_YELLOW_2,
11431 EL_MM_TELEPORTER_YELLOW_1,
11432 EL_MM_TELEPORTER_YELLOW_16,
11433 EL_MM_TELEPORTER_YELLOW_15,
11434 EL_MM_TELEPORTER_YELLOW_14,
11435 EL_MM_TELEPORTER_YELLOW_13,
11436 EL_MM_TELEPORTER_YELLOW_12,
11437 EL_MM_TELEPORTER_YELLOW_11,
11438 EL_MM_TELEPORTER_YELLOW_10,
11439 EL_MM_TELEPORTER_YELLOW_9,
11440 EL_MM_TELEPORTER_YELLOW_8,
11441 EL_MM_TELEPORTER_YELLOW_7,
11442 EL_MM_TELEPORTER_YELLOW_6
11445 EL_MM_TELEPORTER_GREEN_5,
11446 EL_MM_TELEPORTER_GREEN_4,
11447 EL_MM_TELEPORTER_GREEN_3,
11448 EL_MM_TELEPORTER_GREEN_2,
11449 EL_MM_TELEPORTER_GREEN_1,
11450 EL_MM_TELEPORTER_GREEN_16,
11451 EL_MM_TELEPORTER_GREEN_15,
11452 EL_MM_TELEPORTER_GREEN_14,
11453 EL_MM_TELEPORTER_GREEN_13,
11454 EL_MM_TELEPORTER_GREEN_12,
11455 EL_MM_TELEPORTER_GREEN_11,
11456 EL_MM_TELEPORTER_GREEN_10,
11457 EL_MM_TELEPORTER_GREEN_9,
11458 EL_MM_TELEPORTER_GREEN_8,
11459 EL_MM_TELEPORTER_GREEN_7,
11460 EL_MM_TELEPORTER_GREEN_6
11463 EL_MM_TELEPORTER_BLUE_5,
11464 EL_MM_TELEPORTER_BLUE_4,
11465 EL_MM_TELEPORTER_BLUE_3,
11466 EL_MM_TELEPORTER_BLUE_2,
11467 EL_MM_TELEPORTER_BLUE_1,
11468 EL_MM_TELEPORTER_BLUE_16,
11469 EL_MM_TELEPORTER_BLUE_15,
11470 EL_MM_TELEPORTER_BLUE_14,
11471 EL_MM_TELEPORTER_BLUE_13,
11472 EL_MM_TELEPORTER_BLUE_12,
11473 EL_MM_TELEPORTER_BLUE_11,
11474 EL_MM_TELEPORTER_BLUE_10,
11475 EL_MM_TELEPORTER_BLUE_9,
11476 EL_MM_TELEPORTER_BLUE_8,
11477 EL_MM_TELEPORTER_BLUE_7,
11478 EL_MM_TELEPORTER_BLUE_6
11482 EL_MM_POLARIZER_16,
11483 EL_MM_POLARIZER_15,
11484 EL_MM_POLARIZER_14,
11485 EL_MM_POLARIZER_13,
11486 EL_MM_POLARIZER_12,
11487 EL_MM_POLARIZER_11,
11488 EL_MM_POLARIZER_10,
11517 EL_DF_MIRROR_ROTATING_1,
11518 EL_DF_MIRROR_ROTATING_16,
11519 EL_DF_MIRROR_ROTATING_15,
11520 EL_DF_MIRROR_ROTATING_14,
11521 EL_DF_MIRROR_ROTATING_13,
11522 EL_DF_MIRROR_ROTATING_12,
11523 EL_DF_MIRROR_ROTATING_11,
11524 EL_DF_MIRROR_ROTATING_10,
11525 EL_DF_MIRROR_ROTATING_9,
11526 EL_DF_MIRROR_ROTATING_8,
11527 EL_DF_MIRROR_ROTATING_7,
11528 EL_DF_MIRROR_ROTATING_6,
11529 EL_DF_MIRROR_ROTATING_5,
11530 EL_DF_MIRROR_ROTATING_4,
11531 EL_DF_MIRROR_ROTATING_3,
11532 EL_DF_MIRROR_ROTATING_2
11541 for (i = 0; swappable_elements[i][0] != -1; i++)
11543 int element1 = swappable_elements[i][0];
11544 int element2 = swappable_elements[i][1];
11546 if (old_element == element1 || old_element == element2)
11547 new_element = (old_element == element1 ? element2 : element1);
11550 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
11552 for (j = 0; j < 4; j++)
11554 int element = rotatable_elements_4[i][j];
11556 if (old_element == element)
11557 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
11558 button == 2 ? rotatable_elements_4[i][0] :
11559 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
11564 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
11566 for (j = 0; j < 8; j++)
11568 int element = rotatable_elements_8[i][j];
11570 if (old_element == element)
11571 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
11572 button == 2 ? rotatable_elements_8[i][0] :
11573 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
11578 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
11580 for (j = 0; j < 16; j++)
11582 int element = rotatable_elements_16[i][j];
11584 if (old_element == element)
11585 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
11586 button == 2 ? rotatable_elements_16[i][0] :
11587 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
11592 if (old_element != new_element)
11594 int max_infotext_len = getMaxInfoTextLength();
11595 char infotext[MAX_OUTPUT_LINESIZE + 1];
11597 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
11598 infotext[max_infotext_len] = '\0';
11600 ClearEditorGadgetInfoText();
11602 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
11607 SetElementSimple(x, y, new_element, change_level);
11613 static void ResetIntelliDraw(void)
11617 for (x = 0; x < lev_fieldx; x++)
11618 for (y = 0; y < lev_fieldy; y++)
11619 IntelliDrawBuffer[x][y] = Feld[x][y];
11621 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
11624 static boolean draw_mode_hires = FALSE;
11626 static void SetDrawModeHiRes(int element)
11629 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
11630 (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY));
11633 static boolean getDrawModeHiRes(void)
11635 return draw_mode_hires;
11638 static int getLoResScreenPos(int pos)
11640 return (getDrawModeHiRes() ? pos / 2 : pos);
11643 static int getLoResScreenMod(int pos)
11645 return (getDrawModeHiRes() ? pos % 2 : 0);
11648 static void SetElementExt(int x, int y, int dx, int dy, int element,
11649 boolean change_level, int button)
11652 SetElementSimple(x, y, Feld[x][y], change_level);
11653 else if (GetKeyModState() & KMOD_Shift && !IS_MM_WALL_EDITOR(element))
11654 SetElementIntelliDraw(x, y, element, change_level, button);
11656 SetElementSimpleExt(x, y, dx, dy, element, change_level);
11659 static void SetElement(int x, int y, int element)
11661 SetElementExt(x, y, 0, 0, element, TRUE, -1);
11664 static void SetElementButton(int x, int y, int dx, int dy, int element,
11667 SetElementExt(x, y, dx, dy, element, TRUE, button);
11670 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
11672 int lx = getLoResScreenPos(sx2) + level_xpos;
11673 int ly = getLoResScreenPos(sy2) + level_ypos;
11674 int dx = getLoResScreenMod(sx2);
11675 int dy = getLoResScreenMod(sy2);
11677 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
11680 static void SetLevelElementHiRes(int lx2, int ly2, int element)
11687 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
11690 static int getLevelElementHiRes(int lx2, int ly2)
11696 int element = Feld[lx][ly];
11697 unsigned int bitmask = (dx + 1) << (dy * 2);
11699 if (IS_MM_WALL(element))
11701 if (element & bitmask)
11702 return map_mm_wall_element(element);
11710 static void DrawLineElement(int x, int y, int element, boolean change_level)
11712 SetElementHiRes(x, y, element, change_level);
11715 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
11716 int element, boolean change_level)
11718 int xsize = ABS(to_x - from_x);
11719 int ysize = ABS(to_y - from_y);
11720 int dx = (to_x < from_x ? -1 : +1);
11721 int dy = (to_y < from_y ? -1 : +1);
11724 if (from_y == to_y) // horizontal line
11726 for (i = 0; i <= xsize; i++)
11727 DrawLineElement(from_x + i * dx, from_y, element, change_level);
11729 else if (from_x == to_x) // vertical line
11731 for (i = 0; i <= ysize; i++)
11732 DrawLineElement(from_x, from_y + i * dy, element, change_level);
11734 else // diagonal line
11736 if (ysize < xsize) // a < 1
11738 float a = (float)ysize / (float)xsize;
11740 for (i = 0; i <= xsize; i++)
11743 int y = dy * (int)(a * i + 0.5);
11745 DrawLineElement(from_x + x, from_y + y, element, change_level);
11750 float a = (float)xsize / (float)ysize;
11752 for (i = 0; i <= ysize; i++)
11754 int x = dx * (int)(a * i + 0.5);
11757 DrawLineElement(from_x + x, from_y + y, element, change_level);
11763 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
11764 int element, boolean change_level)
11766 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
11767 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
11768 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
11769 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
11772 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
11773 int element, boolean change_level)
11778 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
11780 for (y = from_y; y <= to_y; y++)
11781 DrawLine(from_x, y, to_x, y, element, change_level);
11784 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
11785 int element, boolean change_level)
11787 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
11788 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
11789 int len_x = ABS(to_x - from_x);
11790 int len_y = ABS(to_y - from_y);
11793 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
11795 // not optimal (some points get drawn twice) but simple,
11796 // and fast enough for the few points we are drawing
11798 for (x = 0; x <= radius; x++)
11800 int sx, sy, sx2, sy2, lx, ly;
11802 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
11804 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
11805 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
11806 sx = getLoResScreenPos(sx2);
11807 sy = getLoResScreenPos(sy2);
11808 lx = sx + level_xpos;
11809 ly = sy + level_ypos;
11811 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11812 DrawLineElement(sx2, sy2, element, change_level);
11815 for (y = 0; y <= radius; y++)
11817 int sx, sy, sx2, sy2, lx, ly;
11819 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
11821 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
11822 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
11823 sx = getLoResScreenPos(sx2);
11824 sy = getLoResScreenPos(sy2);
11825 lx = sx + level_xpos;
11826 ly = sy + level_ypos;
11828 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11829 DrawLineElement(sx2, sy2, element, change_level);
11833 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
11834 int element, boolean change_level)
11836 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
11837 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
11839 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
11842 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
11844 #if DRAW_CIRCLES_BUTTON_AVAILABLE
11845 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
11846 int element, boolean change_level)
11848 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
11849 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
11850 int mirror_to_x2 = from_x - (to_x2 - from_x);
11851 int mirror_to_y2 = from_y - (to_y2 - from_y);
11853 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
11854 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
11855 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
11856 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
11860 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
11862 int from_sx, from_sy;
11866 swap_numbers(&from_x, &to_x);
11869 swap_numbers(&from_y, &to_y);
11871 from_sx = SX + from_x * ed_tilesize;
11872 from_sy = SY + from_y * ed_tilesize;
11873 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
11874 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
11876 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
11877 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
11878 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
11879 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
11881 if (from_x == to_x && from_y == to_y)
11882 MarkTileDirty(from_x/2, from_y/2);
11884 redraw_mask |= REDRAW_FIELD;
11887 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
11888 int element, boolean change_level)
11890 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
11893 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
11894 int element, boolean change_level)
11896 if (element == -1 || change_level)
11897 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
11899 DrawAreaBorder(from_x, from_y, to_x, to_y);
11902 // values for CopyBrushExt()
11903 #define CB_AREA_TO_BRUSH 0
11904 #define CB_BRUSH_TO_CURSOR 1
11905 #define CB_BRUSH_TO_LEVEL 2
11906 #define CB_DELETE_OLD_CURSOR 3
11907 #define CB_DUMP_BRUSH 4
11908 #define CB_DUMP_BRUSH_SMALL 5
11909 #define CB_CLIPBOARD_TO_BRUSH 6
11910 #define CB_BRUSH_TO_CLIPBOARD 7
11911 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
11912 #define CB_UPDATE_BRUSH_POSITION 9
11914 #define MAX_CB_PART_SIZE 10
11915 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
11916 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
11917 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
11918 MAX_CB_NUM_LINES * \
11921 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
11923 DrawLineElement(sx, sy, element, change_level);
11926 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
11927 int button, int mode)
11929 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
11930 static int brush_width, brush_height;
11931 static int last_cursor_x = -1, last_cursor_y = -1;
11932 static boolean delete_old_brush = FALSE;
11933 int new_element = BUTTON_ELEMENT(button);
11936 if (mode == CB_DUMP_BRUSH ||
11937 mode == CB_DUMP_BRUSH_SMALL ||
11938 mode == CB_BRUSH_TO_CLIPBOARD ||
11939 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
11941 if (edit_mode != ED_MODE_DRAWING)
11944 char part[MAX_CB_PART_SIZE + 1] = "";
11945 char text[MAX_CB_TEXT_SIZE + 1] = "";
11946 int width = (draw_with_brush ? brush_width : lev_fieldx);
11947 int height = (draw_with_brush ? brush_height : lev_fieldy);
11949 for (y = 0; y < height; y++)
11951 for (x = 0; x < width; x++)
11953 int element = (draw_with_brush ? brush_buffer[x][y] : Feld[x][y]);
11954 int element_mapped = element;
11955 char *prefix = (mode == CB_DUMP_BRUSH ||
11956 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
11958 if (IS_CUSTOM_ELEMENT(element))
11959 element_mapped = EL_CUSTOM_START;
11960 else if (IS_GROUP_ELEMENT(element))
11961 element_mapped = EL_GROUP_START;
11962 else if (element >= NUM_FILE_ELEMENTS)
11963 element_mapped = EL_UNKNOWN;
11965 // copy brush to level sketch text buffer for the R'n'D forum:
11966 // - large tiles: `xxx (0x60 ASCII)
11967 // - small tiles: ¸xxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
11968 snprintf(part, MAX_CB_PART_SIZE + 1, "%s%03d", prefix, element_mapped);
11969 strcat(text, part);
11972 strcat(text, "\n");
11975 if (mode == CB_BRUSH_TO_CLIPBOARD ||
11976 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
11977 SDL_SetClipboardText(text);
11979 printf("%s", text);
11984 if (mode == CB_CLIPBOARD_TO_BRUSH)
11986 if (edit_mode != ED_MODE_DRAWING)
11989 if (!SDL_HasClipboardText())
11991 Request("Clipboard is empty!", REQ_CONFIRM);
11996 boolean copy_to_brush = (draw_with_brush ||
11997 drawing_function == GADGET_ID_GRAB_BRUSH);
11999 // this will delete the old brush, if already drawing with a brush
12001 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
12003 // initialization is required for "odd" (incomplete) clipboard content
12004 for (x = 0; x < MAX_LEV_FIELDX; x++)
12005 for (y = 0; y < MAX_LEV_FIELDY; y++)
12006 brush_buffer[x][y] = EL_EMPTY;
12013 char *clipboard_text = SDL_GetClipboardText();
12014 char *ptr = clipboard_text;
12015 boolean stop = FALSE;
12017 while (*ptr && !stop)
12019 boolean prefix_found = FALSE;
12021 // level sketch element number prefixes (may be multi-byte characters)
12022 char *prefix_list[] = { "`", "¸" };
12025 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
12027 char *prefix = prefix_list[i];
12029 // check if string is large enough for prefix
12030 if (strlen(ptr) < strlen(prefix))
12037 // check if string starts with prefix
12038 if (strPrefix(ptr, prefix))
12040 ptr += strlen(prefix);
12042 prefix_found = TRUE;
12048 // continue with next character if prefix not found
12051 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
12056 // continue with next character if prefix not found
12057 if (strlen(ptr) < 3)
12060 if (ptr[0] >= '0' && ptr[0] <= '9' &&
12061 ptr[1] >= '0' && ptr[1] <= '9' &&
12062 ptr[2] >= '0' && ptr[2] <= '9')
12064 int element = ((ptr[0] - '0') * 100 +
12065 (ptr[1] - '0') * 10 +
12070 if (element >= NUM_FILE_ELEMENTS)
12071 element = EL_UNKNOWN;
12073 brush_buffer[x][y] = element;
12075 brush_width = MAX(x + 1, brush_width);
12076 brush_height = MAX(y + 1, brush_height);
12080 if (x >= MAX_LEV_FIELDX || *ptr == '\n')
12085 if (y >= MAX_LEV_FIELDY)
12091 SDL_free(clipboard_text);
12093 if (brush_width == 0 || brush_height == 0)
12095 Request("No level sketch found in clipboard!", REQ_CONFIRM);
12102 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
12105 SDL_GetMouseState(&mx, &my);
12107 // if inside drawing area, activate and draw brush at last mouse position
12108 if (mx >= gi->x && mx < gi->x + gi->width &&
12109 my >= gi->y && my < gi->y + gi->height)
12110 CopyBrushToCursor(last_cursor_x, last_cursor_y);
12112 draw_with_brush = TRUE;
12118 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
12119 brush_width, brush_height);
12121 if (!Request(request, REQ_ASK))
12124 for (x = 0; x < MAX_LEV_FIELDX; x++)
12125 for (y = 0; y < MAX_LEV_FIELDY; y++)
12126 Feld[x][y] = brush_buffer[x][y];
12128 lev_fieldx = level.fieldx = brush_width;
12129 lev_fieldy = level.fieldy = brush_height;
12131 SetBorderElement();
12133 DrawEditModeWindow();
12134 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12140 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
12143 if (mode == CB_AREA_TO_BRUSH)
12145 int from_lx, from_ly;
12148 swap_numbers(&from_x, &to_x);
12151 swap_numbers(&from_y, &to_y);
12153 brush_width = to_x - from_x + 1;
12154 brush_height = to_y - from_y + 1;
12156 from_lx = from_x + level_xpos;
12157 from_ly = from_y + level_ypos;
12159 for (y = 0; y < brush_height; y++)
12161 for (x = 0; x < brush_width; x++)
12163 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
12166 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
12171 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12173 delete_old_brush = FALSE;
12175 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
12176 mode == CB_BRUSH_TO_LEVEL)
12178 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
12179 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
12180 int cursor_from_x = cursor_x - brush_width / 2;
12181 int cursor_from_y = cursor_y - brush_height / 2;
12182 int border_from_x = cursor_x, border_from_y = cursor_y;
12183 int border_to_x = cursor_x, border_to_y = cursor_y;
12185 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
12186 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12188 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
12189 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
12191 delete_old_brush = FALSE;
12196 for (y = 0; y < brush_height; y++)
12198 for (x = 0; x < brush_width; x++)
12200 int sx = cursor_from_x + x;
12201 int sy = cursor_from_y + y;
12202 int lx = sx + level_xpos;
12203 int ly = sy + level_ypos;
12204 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
12205 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
12206 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
12207 brush_buffer[x][y] : new_element);
12209 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12211 if (sx < border_from_x)
12212 border_from_x = sx;
12213 else if (sx > border_to_x)
12215 if (sy < border_from_y)
12216 border_from_y = sy;
12217 else if (sy > border_to_y)
12220 DrawBrushElement(sx, sy, element, change_level);
12225 if (mode != CB_DELETE_OLD_CURSOR)
12226 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
12228 last_cursor_x = cursor_x;
12229 last_cursor_y = cursor_y;
12231 delete_old_brush = TRUE;
12234 if (mode == CB_UPDATE_BRUSH_POSITION)
12236 last_cursor_x = from_x;
12237 last_cursor_y = from_y;
12241 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
12244 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
12247 static void CopyBrushToLevel(int x, int y, int button)
12249 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
12252 static void CopyBrushToCursor(int x, int y)
12254 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
12257 static void UpdateBrushPosition(int x, int y)
12259 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
12262 static void DeleteBrushFromCursor(void)
12264 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12267 void DumpBrush(void)
12269 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
12272 void DumpBrush_Small(void)
12274 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
12277 void CopyClipboardToBrush(void)
12279 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
12282 void CopyBrushToClipboard(void)
12284 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
12287 void CopyBrushToClipboard_Small(void)
12289 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
12292 static void FloodFill(int from_x, int from_y, int fill_element)
12294 FloodFillLevel(from_x, from_y, fill_element, Feld, lev_fieldx, lev_fieldy);
12297 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
12299 int from_x = from_sx2 + 2 * level_xpos;
12300 int from_y = from_sy2 + 2 * level_ypos;
12301 int max_fillx = lev_fieldx * 2;
12302 int max_filly = lev_fieldy * 2;
12303 short FillFeld[max_fillx][max_filly];
12306 for (x = 0; x < max_fillx; x++)
12307 for (y = 0; y < max_filly; y++)
12308 FillFeld[x][y] = getLevelElementHiRes(x, y);
12310 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
12311 FillFeld, max_fillx, max_filly);
12313 for (x = 0; x < max_fillx; x++)
12314 for (y = 0; y < max_filly; y++)
12315 if (FillFeld[x][y] == fill_element)
12316 SetLevelElementHiRes(x, y, FillFeld[x][y]);
12319 // values for DrawLevelText() modes
12320 #define TEXT_INIT 0
12321 #define TEXT_SETCURSOR 1
12322 #define TEXT_WRITECHAR 2
12323 #define TEXT_BACKSPACE 3
12324 #define TEXT_NEWLINE 4
12326 #define TEXT_QUERY_TYPING 6
12328 static int DrawLevelText(int sx, int sy, char letter, int mode)
12330 static short delete_buffer[MAX_LEV_FIELDX];
12331 static int start_sx;
12332 static int last_sx, last_sy;
12333 static boolean typing = FALSE;
12334 int letter_element = EL_CHAR_ASCII0 + letter;
12335 int lx = 0, ly = 0;
12337 // map lower case letters to upper case and convert special characters
12338 if (letter >= 'a' && letter <= 'z')
12339 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
12340 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
12341 letter_element = EL_CHAR_AUMLAUT;
12342 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
12343 letter_element = EL_CHAR_OUMLAUT;
12344 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
12345 letter_element = EL_CHAR_UUMLAUT;
12346 else if (letter == '^')
12347 letter_element = EL_CHAR_COPYRIGHT;
12349 letter_element = EL_CHAR_ASCII0 + letter;
12351 if (mode != TEXT_INIT)
12356 if (mode != TEXT_SETCURSOR)
12362 lx = last_sx + level_xpos;
12363 ly = last_sy + level_ypos;
12370 DrawLevelText(0, 0, 0, TEXT_END);
12376 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
12379 case TEXT_SETCURSOR:
12380 DrawEditorElement(last_sx, last_sy, Feld[lx][ly]);
12381 DrawAreaBorder(sx, sy, sx, sy);
12382 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
12383 ed_tilesize, ed_tilesize);
12388 case TEXT_WRITECHAR:
12389 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
12391 if (new_element1 >= EL_STEEL_CHAR_START &&
12392 new_element1 <= EL_STEEL_CHAR_END)
12393 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
12395 delete_buffer[sx - start_sx] = Feld[lx][ly];
12396 Feld[lx][ly] = letter_element;
12398 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
12399 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
12400 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12401 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12403 DrawLevelText(0, 0, 0, TEXT_END);
12405 level.changed = TRUE;
12409 case TEXT_BACKSPACE:
12412 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
12413 DrawEditorElement(sx - 1, sy, Feld[lx - 1][ly]);
12414 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
12419 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12420 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12422 DrawLevelText(0, 0, 0, TEXT_END);
12426 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12427 DrawEditorElement(sx, sy, Feld[lx][ly]);
12432 case TEXT_QUERY_TYPING:
12442 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
12443 int element, boolean change_level)
12445 int lx = sx + level_xpos;
12446 int ly = sy + level_ypos;
12449 DrawEditorElement(sx, sy, Feld[lx][ly]);
12451 DrawAreaBorder(sx, sy, sx, sy);
12454 static void CheckLevelBorderElement(boolean redraw_playfield)
12456 int last_border_element = BorderElement;
12458 SetBorderElement();
12460 if (redraw_playfield && BorderElement != last_border_element)
12461 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12464 static void CopyLevelToUndoBuffer(int mode)
12466 static boolean accumulated_undo = FALSE;
12467 boolean new_undo_buffer_position = TRUE;
12470 if (undo_buffer_steps == 0)
12471 accumulated_undo = FALSE;
12475 case UNDO_IMMEDIATE:
12476 accumulated_undo = FALSE;
12479 case UNDO_ACCUMULATE:
12480 if (accumulated_undo)
12481 new_undo_buffer_position = FALSE;
12482 accumulated_undo = TRUE;
12489 if (new_undo_buffer_position)
12491 // advance position in undo buffer ring
12492 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
12494 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
12495 undo_buffer_steps++;
12498 // always reset redo buffer when storing level change into undo buffer
12499 redo_buffer_steps = 0;
12501 for (x = 0; x < lev_fieldx; x++)
12502 for (y = 0; y < lev_fieldy; y++)
12503 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
12505 // check if drawing operation forces change of border style
12506 CheckLevelBorderElement(TRUE);
12508 level.changed = TRUE;
12511 static void RandomPlacement(int new_element)
12513 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12514 int num_free_positions = 0;
12515 int num_percentage, num_elements;
12518 ResetIntelliDraw();
12520 // determine number of free positions for randomly placing the new element
12521 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
12523 free_position[x][y] =
12524 (random_placement_background_restricted ?
12525 Feld[x][y] == random_placement_background_element :
12526 Feld[x][y] != new_element);
12528 if (free_position[x][y])
12529 num_free_positions++;
12532 // determine number of new elements to place there
12533 num_percentage = num_free_positions * random_placement_value / 100;
12534 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
12535 num_percentage : random_placement_value);
12537 // if less free positions than elements to place, fill all these positions
12538 if (num_free_positions < num_elements)
12540 for (x = 0; x < lev_fieldx; x++)
12541 for (y = 0; y < lev_fieldy; y++)
12542 if (free_position[x][y])
12543 SetElement(x, y, new_element);
12547 while (num_elements > 0)
12549 x = GetSimpleRandom(lev_fieldx);
12550 y = GetSimpleRandom(lev_fieldy);
12552 // don't place element at the same position twice
12553 if (free_position[x][y])
12555 free_position[x][y] = FALSE;
12556 SetElement(x, y, new_element);
12562 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12563 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12566 static void WrapLevel(int dx, int dy)
12568 int wrap_dx = lev_fieldx - dx;
12569 int wrap_dy = lev_fieldy - dy;
12572 for (x = 0; x < lev_fieldx; x++)
12573 for (y = 0; y < lev_fieldy; y++)
12574 FieldBackup[x][y] = Feld[x][y];
12576 for (x = 0; x < lev_fieldx; x++)
12577 for (y = 0; y < lev_fieldy; y++)
12579 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
12581 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12582 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
12585 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
12587 char *template_filename_old = getLocalLevelTemplateFilename();
12588 char *template_filename_new =
12589 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
12591 if (copyFile(template_filename_old, template_filename_new) != 0)
12592 Request("Cannot copy level template!", REQ_CONFIRM);
12594 free(template_filename_new);
12597 static void HandleDrawingAreas(struct GadgetInfo *gi)
12599 static boolean started_inside_drawing_area = FALSE;
12600 static int last_sx = -1, last_sy = -1;
12601 static int last_sx2 = -1, last_sy2 = -1;
12602 int id = gi->custom_id;
12603 int type_id = gi->custom_type_id;
12604 boolean button_press_event;
12605 boolean button_release_event;
12606 boolean inside_drawing_area = !gi->event.off_borders;
12607 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
12608 int actual_drawing_function;
12609 int button = gi->event.button;
12610 int new_element = BUTTON_ELEMENT(button);
12611 int sx = gi->event.x, sy = gi->event.y;
12612 int min_sx = 0, min_sy = 0;
12613 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
12614 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
12615 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
12616 int sx2 = gi->event.mx / mini_item_xsize;
12617 int sy2 = gi->event.my / mini_item_ysize;
12620 int lx = 0, ly = 0;
12621 int min_lx = 0, min_ly = 0;
12622 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
12625 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
12626 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
12628 // make sure to stay inside drawing area boundaries
12629 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
12630 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
12634 // get positions inside level field
12635 lx = sx + level_xpos;
12636 ly = sy + level_ypos;
12638 if (!IN_LEV_FIELD(lx, ly))
12639 inside_drawing_area = FALSE;
12641 // make sure to stay inside level field boundaries
12642 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
12643 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
12645 // correct drawing area positions accordingly
12646 sx = lx - level_xpos;
12647 sy = ly - level_ypos;
12650 // also correct MM wall-sized (double) drawing area positions accordingly
12651 if (sx2 / 2 < sx || sx2 / 2 > sx)
12653 dx = (sx2 / 2 < sx ? 0 : 1);
12656 if (sy2 / 2 < sy || sy2 / 2 > sy)
12658 dy = (sy2 / 2 < sy ? 0 : 1);
12662 if (button_release_event)
12669 else if (!button_press_event)
12671 // prevent handling events for every pixel position when moving mouse
12672 if ((sx == last_sx && sy == last_sy &&
12673 !IS_MM_WALL_EDITOR(new_element) && new_element != EL_EMPTY) ||
12674 (sx2 == last_sx2 && sy2 == last_sy2))
12683 if (button_press_event)
12684 started_inside_drawing_area = inside_drawing_area;
12686 if (!started_inside_drawing_area)
12689 if (!IS_VALID_BUTTON(button))
12692 if (!button && !button_release_event)
12695 // handle info callback for each invocation of action callback
12696 gi->callback_info(gi);
12698 // automatically switch to 'single item' drawing mode, if needed
12699 actual_drawing_function =
12700 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
12701 drawing_function : GADGET_ID_SINGLE_ITEMS);
12703 // clicking into drawing area with pressed Control key picks element
12704 if (GetKeyModState() & KMOD_Control)
12706 last_drawing_function = drawing_function;
12707 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
12710 if (GetKeyModState() & KMOD_Shift)
12712 if (button_press_event || button_release_event)
12713 ResetIntelliDraw();
12716 SetDrawModeHiRes(-1); // reset to normal draw mode
12718 switch (actual_drawing_function)
12720 case GADGET_ID_SINGLE_ITEMS:
12723 if (button_release_event)
12725 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12727 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
12728 !inside_drawing_area)
12729 DeleteBrushFromCursor();
12732 if (!button || button_release_event)
12735 if (draw_with_brush)
12737 CopyBrushToLevel(sx, sy, button);
12741 SetDrawModeHiRes(new_element);
12743 if (new_element == EL_PLAYER_1)
12745 // remove player at old position
12746 for (y = 0; y < lev_fieldy; y++)
12747 for (x = 0; x < lev_fieldx; x++)
12748 if (Feld[x][y] == EL_PLAYER_1)
12749 SetElement(x, y, EL_EMPTY);
12752 SetElementButton(lx, ly, dx, dy, new_element, button);
12755 else if (!button_release_event)
12757 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
12759 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
12760 DrawMiniGraphicExt(drawto,
12761 gi->x + sx * MINI_TILEX,
12762 gi->y + sy * MINI_TILEY,
12763 el2edimg(new_element));
12765 DrawFixedGraphicExt(drawto,
12766 gi->x + sx * TILEX,
12767 gi->y + sy * TILEY,
12768 el2edimg(new_element), 0);
12770 if (id == GADGET_ID_CUSTOM_GRAPHIC)
12771 new_element = GFX_ELEMENT(new_element);
12773 drawingarea_info[type_id].value[pos] = new_element;
12775 CopyElementPropertiesToGame(properties_element);
12777 if (id == GADGET_ID_CUSTOM_GRAPHIC)
12779 UpdateCustomElementGraphicGadgets();
12781 FrameCounter = 0; // restart animation frame counter
12786 case GADGET_ID_CONNECTED_ITEMS:
12788 static int last_sx = -1;
12789 static int last_sy = -1;
12791 if (button_release_event)
12792 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12796 SetDrawModeHiRes(new_element);
12798 if (getDrawModeHiRes())
12804 if (!button_press_event)
12805 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
12813 case GADGET_ID_LINE:
12814 case GADGET_ID_ARC:
12815 case GADGET_ID_RECTANGLE:
12816 case GADGET_ID_FILLED_BOX:
12817 SetDrawModeHiRes(new_element);
12819 if (getDrawModeHiRes())
12825 case GADGET_ID_GRAB_BRUSH:
12826 case GADGET_ID_TEXT:
12828 static int last_sx = -1;
12829 static int last_sy = -1;
12830 static int start_sx = -1;
12831 static int start_sy = -1;
12832 void (*draw_func)(int, int, int, int, int, boolean);
12834 if (drawing_function == GADGET_ID_LINE)
12835 draw_func = DrawLine;
12836 else if (drawing_function == GADGET_ID_ARC)
12837 draw_func = DrawArc;
12838 else if (drawing_function == GADGET_ID_RECTANGLE)
12839 draw_func = DrawBox;
12840 else if (drawing_function == GADGET_ID_FILLED_BOX)
12841 draw_func = DrawFilledBox;
12842 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
12843 draw_func = SelectArea;
12844 else // (drawing_function == GADGET_ID_TEXT)
12845 draw_func = SetTextCursor;
12847 if (button_press_event)
12849 draw_func(sx, sy, sx, sy, new_element, FALSE);
12850 start_sx = last_sx = sx;
12851 start_sy = last_sy = sy;
12853 if (drawing_function == GADGET_ID_TEXT)
12854 DrawLevelText(0, 0, 0, TEXT_END);
12856 else if (button_release_event)
12858 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
12859 if (drawing_function == GADGET_ID_GRAB_BRUSH)
12861 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
12862 CopyBrushToCursor(sx, sy);
12863 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
12865 draw_with_brush = TRUE;
12867 else if (drawing_function == GADGET_ID_TEXT)
12868 DrawLevelText(sx, sy, 0, TEXT_INIT);
12870 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12872 else if (last_sx != sx || last_sy != sy)
12874 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
12875 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
12876 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
12877 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
12884 case GADGET_ID_FLOOD_FILL:
12885 if (button_press_event && Feld[lx][ly] != new_element)
12887 if (IS_MM_WALL_EDITOR(new_element))
12888 FloodFillWall_MM(sx2, sy2, new_element);
12890 FloodFill(lx, ly, new_element);
12892 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12893 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12897 case GADGET_ID_PICK_ELEMENT:
12898 if (button_release_event)
12899 ClickOnGadget(level_editor_gadget[last_drawing_function],
12901 else if (draw_level)
12902 PickDrawingElement(button, Feld[lx][ly]);
12905 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
12907 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
12914 // do not mark level as modified for certain non-level-changing gadgets
12915 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
12916 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
12917 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
12918 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
12921 level.changed = TRUE;
12924 static void HandleCounterButtons(struct GadgetInfo *gi)
12926 int gadget_id = gi->custom_id;
12927 int counter_id = gi->custom_type_id;
12928 int button = gi->event.button;
12929 int *counter_value = counterbutton_info[counter_id].value;
12930 int step = BUTTON_STEPSIZE(button) *
12931 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
12933 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
12935 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
12936 boolean released = (gi->event.type == GD_EVENT_RELEASED);
12937 boolean level_changed = LevelChanged();
12939 if ((level_changed && pressed) || (!level_changed && released))
12942 if (level_changed && !Request("Level has changed! Discard changes?",
12945 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
12946 ModifyEditorCounterValue(counter_id, *counter_value);
12952 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
12953 *counter_value = gi->textinput.number_value;
12955 ModifyEditorCounterValue(counter_id, *counter_value + step);
12957 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
12959 int last_game_engine_type = level.game_engine_type;
12961 LoadLevel(level_nr);
12962 LoadScore(level_nr);
12964 SaveLevelSetup_SeriesInfo();
12969 DrawEditModeWindow();
12971 if (level.game_engine_type != last_game_engine_type)
12973 // update element selection list
12974 ReinitializeElementList();
12975 ModifyEditorElementList();
12981 switch (counter_id)
12983 case ED_COUNTER_ID_YAMYAM_CONTENT:
12984 DrawYamYamContentAreas();
12987 case ED_COUNTER_ID_BALL_CONTENT:
12988 DrawMagicBallContentAreas();
12991 case ED_COUNTER_ID_ANDROID_CONTENT:
12992 DrawAndroidElementArea(properties_element);
12995 case ED_COUNTER_ID_GROUP_CONTENT:
12996 DrawGroupElementArea(properties_element);
12997 CopyGroupElementPropertiesToGame(properties_element);
13000 case ED_COUNTER_ID_INVENTORY_SIZE:
13001 DrawPlayerInitialInventoryArea(properties_element);
13004 case ED_COUNTER_ID_ENVELOPE_XSIZE:
13005 case ED_COUNTER_ID_ENVELOPE_YSIZE:
13006 DrawEnvelopeTextArea(-1);
13009 case ED_COUNTER_ID_LEVEL_XSIZE:
13010 case ED_COUNTER_ID_LEVEL_YSIZE:
13011 lev_fieldx = level.fieldx;
13012 lev_fieldy = level.fieldy;
13014 // check if resizing of level results in change of border border
13015 SetBorderElement();
13023 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
13024 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
13025 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
13026 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
13027 CopyElementPropertiesToGame(properties_element);
13029 // do not mark level as modified for certain non-level-changing gadgets
13030 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
13031 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
13032 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
13033 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
13036 level.changed = TRUE;
13039 static void HandleTextInputGadgets(struct GadgetInfo *gi)
13041 int type_id = gi->custom_type_id;
13043 strcpy(textinput_info[type_id].value, gi->textinput.value);
13045 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
13047 CopyElementPropertiesToGame(properties_element);
13049 ModifyEditorElementList(); // update changed button info text
13052 // do not mark level as modified for certain non-level-changing gadgets
13053 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
13054 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
13057 level.changed = TRUE;
13060 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
13062 int type_id = gi->custom_type_id;
13064 strncpy(textarea_info[type_id].value, gi->textarea.value,
13065 MAX_ENVELOPE_TEXT_LEN);
13066 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
13068 level.changed = TRUE;
13071 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
13073 int type_id = gi->custom_type_id;
13074 int value_old = *selectbox_info[type_id].value;
13075 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
13077 *selectbox_info[type_id].value = value_new;
13079 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
13081 DrawLevelInfoWindow();
13083 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
13085 element_info[properties_element].current_change_page = gi->selectbox.index;
13087 DrawPropertiesWindow();
13089 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
13090 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
13091 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
13092 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
13093 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
13095 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
13097 // when changing action type, also check action mode and action arg
13098 if (value_old != value_new)
13099 setSelectboxSpecialActionVariablesIfNeeded();
13101 DrawPropertiesChange();
13104 CopyElementPropertiesToGame(properties_element);
13106 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
13108 // update element selection list
13109 ReinitializeElementList();
13110 ModifyEditorElementList();
13113 // do not mark level as modified for certain non-level-changing gadgets
13114 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
13115 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
13118 level.changed = TRUE;
13121 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
13123 int type_id = gi->custom_type_id;
13126 if (type_id >= ED_TAB_BUTTON_ID_LEVELINFO_FIRST &&
13127 type_id <= ED_TAB_BUTTON_ID_LEVELINFO_LAST)
13129 edit_mode_levelinfo = gi->custom_type_id;
13131 DrawLevelInfoWindow();
13133 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
13134 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
13136 edit_mode_properties = gi->custom_type_id;
13138 DrawPropertiesWindow();
13140 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
13141 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
13143 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
13145 // backup original "level.field" (needed to track playfield changes)
13146 CopyPlayfield(level.field, FieldBackup);
13148 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
13149 CopyPlayfield(Feld, level.field);
13151 if (new_template ||
13152 Request("Save this template and kill the old?", REQ_ASK))
13153 SaveLevelTemplate();
13156 Request("Template saved!", REQ_CONFIRM);
13158 // restore original "level.field" (needed to track playfield changes)
13159 CopyPlayfield(FieldBackup, level.field);
13161 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
13163 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
13165 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
13166 leveldir_current->readonly)
13168 Request("This level set is read only!", REQ_CONFIRM);
13173 if (strEqual(levelset_name, ""))
13175 Request("Please enter level set title!", REQ_CONFIRM);
13180 if (strEqual(levelset_author, ""))
13182 Request("Please enter level set author!", REQ_CONFIRM);
13187 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
13189 if (UpdateUserLevelSet(levelset_subdir,
13192 levelset_num_levels))
13194 Request("Level set updated!", REQ_CONFIRM);
13198 Request("Updating level set failed!", REQ_CONFIRM);
13201 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
13203 if (level.changed && !Request("Level has changed! Discard changes?",
13207 if (CreateUserLevelSet(levelset_subdir,
13210 levelset_num_levels,
13211 levelset_use_levelset_artwork))
13213 if (levelset_copy_level_template)
13214 CopyLevelTemplateToUserLevelSet(levelset_subdir);
13216 Request("New level set created!", REQ_CONFIRM);
13218 AddUserLevelSetToLevelInfo(levelset_subdir);
13219 ChangeEditorToLevelSet(levelset_subdir);
13223 Request("Creating new level set failed!", REQ_CONFIRM);
13227 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
13228 custom_element.num_change_pages < MAX_CHANGE_PAGES)
13230 struct ElementInfo *ei = &element_info[properties_element];
13232 // when modifying custom element, ask for copying level template
13233 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13236 setElementChangePages(ei, ei->num_change_pages + 1);
13238 // set new change page to be new current change page
13239 ei->current_change_page = ei->num_change_pages - 1;
13240 ei->change = &ei->change_page[ei->current_change_page];
13242 setElementChangeInfoToDefaults(ei->change);
13244 DrawPropertiesWindow();
13246 level.changed = TRUE;
13248 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
13249 custom_element.num_change_pages > MIN_CHANGE_PAGES)
13251 struct ElementInfo *ei = &element_info[properties_element];
13253 // when modifying custom element, ask for copying level template
13254 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13257 // copy all change pages after change page to be deleted
13258 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
13259 ei->change_page[i] = ei->change_page[i + 1];
13261 setElementChangePages(ei, ei->num_change_pages - 1);
13263 DrawPropertiesWindow();
13265 level.changed = TRUE;
13269 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
13271 int type_id = gi->custom_type_id;
13273 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
13274 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
13276 struct ElementInfo *ei = &element_info[properties_element];
13277 int step = BUTTON_STEPSIZE(gi->event.button);
13279 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
13280 ei->current_change_page += step;
13282 if (ei->current_change_page < 0)
13283 ei->current_change_page = 0;
13284 else if (ei->current_change_page >= ei->num_change_pages)
13285 ei->current_change_page = ei->num_change_pages - 1;
13287 DrawPropertiesWindow();
13289 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
13290 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13292 struct ElementInfo *ei = &element_info[properties_element];
13293 int current_change_page = ei->current_change_page;
13295 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
13297 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
13298 ei->change_page[current_change_page];
13300 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13302 // when modifying custom element, ask for copying level template
13303 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13306 ei->change_page[current_change_page] =
13307 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
13309 level.changed = TRUE;
13312 DrawPropertiesWindow();
13316 static void HandleRadiobuttons(struct GadgetInfo *gi)
13318 int type_id = gi->custom_type_id;
13320 *radiobutton_info[type_id].value =
13321 radiobutton_info[type_id].checked_value;
13323 // do not mark level as modified for certain non-level-changing gadgets
13324 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
13325 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
13328 level.changed = TRUE;
13331 static void HandleCheckbuttons(struct GadgetInfo *gi)
13333 int type_id = gi->custom_type_id;
13335 *checkbutton_info[type_id].value ^= TRUE;
13337 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
13338 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
13339 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
13340 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
13341 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
13342 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
13343 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
13344 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
13346 CopyElementPropertiesToGame(properties_element);
13349 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
13351 UpdateCustomElementGraphicGadgets();
13353 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
13354 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
13356 boolean template_related_changes_found = FALSE;
13359 // check if any custom or group elements have been changed
13360 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
13361 if ((IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)) &&
13362 element_info[i].modified_settings)
13363 template_related_changes_found = TRUE;
13365 if (level.use_custom_template &&
13366 !fileExists(getGlobalLevelTemplateFilename()))
13368 Request("No level template found!", REQ_CONFIRM);
13370 level.use_custom_template = FALSE;
13372 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13377 if (level.use_custom_template &&
13378 template_related_changes_found &&
13379 !Request("Discard changes and use level template?", REQ_ASK))
13381 level.use_custom_template = FALSE;
13383 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13388 if (!level.use_custom_template &&
13389 Request("Copy settings from level template?", REQ_ASK))
13394 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
13396 DrawEditModeWindow();
13398 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
13400 if (setup.editor.use_template_for_new_levels &&
13401 !fileExists(getGlobalLevelTemplateFilename()))
13403 Request("No level template found!", REQ_CONFIRM);
13408 if (setup.editor.use_template_for_new_levels &&
13410 !Request("Discard level and load template?", REQ_ASK))
13415 if (!setup.editor.use_template_for_new_levels &&
13417 !Request("Discard level and use empty level?", REQ_ASK))
13422 LoadLevel(level_nr);
13423 LoadScore(level_nr);
13428 DrawEditModeWindow();
13430 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
13432 SetAutomaticNumberOfGemsNeeded();
13435 // do not mark level as modified for certain non-level-changing gadgets
13436 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
13437 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
13438 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
13439 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
13440 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
13441 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
13444 level.changed = TRUE;
13447 static void HandleControlButtons(struct GadgetInfo *gi)
13449 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
13450 static int last_edit_mode = ED_MODE_DRAWING;
13451 static int last_custom_copy_mode = -1;
13452 static int last_button = 0;
13453 int id = gi->custom_id;
13454 int button = gi->event.button;
13455 int step = BUTTON_STEPSIZE(button);
13456 int new_element = BUTTON_ELEMENT(button);
13457 int last_properties_element = properties_element;
13460 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
13461 DrawLevelText(0, 0, 0, TEXT_END);
13463 if (id < ED_NUM_CTRL1_BUTTONS &&
13464 id != GADGET_ID_SINGLE_ITEMS &&
13465 id != GADGET_ID_PICK_ELEMENT &&
13466 edit_mode != ED_MODE_DRAWING &&
13467 drawing_function != GADGET_ID_PICK_ELEMENT &&
13468 !(GetKeyModState() & KMOD_Control))
13469 ChangeEditModeWindow(ED_MODE_DRAWING);
13471 // element copy mode active, but no element button pressed => deactivate
13472 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
13473 last_custom_copy_mode = -1;
13475 // when showing palette on element buttons, change element of button used
13476 if (editor.palette.show_on_element_buttons &&
13477 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
13479 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
13481 id = GADGET_ID_PALETTE;
13486 case GADGET_ID_SCROLL_LEFT:
13487 if (level_xpos >= 0)
13489 if (lev_fieldx < ed_fieldx - 2)
13492 level_xpos -= step;
13493 if (level_xpos < -1)
13496 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
13498 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13500 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
13501 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
13505 case GADGET_ID_SCROLL_RIGHT:
13506 if (level_xpos <= lev_fieldx - ed_fieldx)
13508 if (lev_fieldx < ed_fieldx - 2)
13511 level_xpos += step;
13512 if (level_xpos > lev_fieldx - ed_fieldx + 1)
13513 level_xpos = lev_fieldx - ed_fieldx + 1;
13515 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
13517 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13519 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
13520 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
13524 case GADGET_ID_SCROLL_UP:
13525 if (level_ypos >= 0)
13527 if (lev_fieldy < ed_fieldy - 2)
13530 level_ypos -= step;
13531 if (level_ypos < -1)
13534 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
13536 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13538 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13539 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13543 case GADGET_ID_SCROLL_DOWN:
13544 if (level_ypos <= lev_fieldy - ed_fieldy)
13546 if (lev_fieldy < ed_fieldy - 2)
13549 level_ypos += step;
13550 if (level_ypos > lev_fieldy - ed_fieldy + 1)
13551 level_ypos = lev_fieldy - ed_fieldy + 1;
13553 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
13555 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13557 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13558 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13562 case GADGET_ID_SCROLL_HORIZONTAL:
13563 level_xpos = gi->event.item_position - 1;
13565 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13570 case GADGET_ID_SCROLL_VERTICAL:
13571 level_ypos = gi->event.item_position - 1;
13573 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13578 case GADGET_ID_SCROLL_LIST_UP:
13579 case GADGET_ID_SCROLL_LIST_DOWN:
13580 case GADGET_ID_SCROLL_LIST_VERTICAL:
13581 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
13582 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
13585 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
13586 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
13588 if (element_shift < 0)
13590 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
13591 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
13593 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13594 GDI_SCROLLBAR_ITEM_POSITION,
13595 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13598 ModifyEditorElementList();
13602 case GADGET_ID_PROPERTIES:
13603 // always switch off element properties when they are already displayed
13604 last_properties_element = new_element;
13605 case GADGET_ID_ELEMENT_LEFT:
13606 case GADGET_ID_ELEMENT_MIDDLE:
13607 case GADGET_ID_ELEMENT_RIGHT:
13608 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
13609 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
13610 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
13613 if (edit_mode != ED_MODE_PROPERTIES)
13615 last_edit_mode = edit_mode;
13617 ChangeEditModeWindow(ED_MODE_PROPERTIES);
13619 last_level_drawing_function = drawing_function;
13620 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
13623 else if (properties_element != last_properties_element)
13625 DrawEditModeWindow();
13629 ChangeEditModeWindow(last_edit_mode);
13631 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
13636 case GADGET_ID_PALETTE:
13637 if (edit_mode != ED_MODE_PALETTE)
13639 last_edit_mode = edit_mode;
13641 ChangeEditModeWindow(ED_MODE_PALETTE);
13645 ChangeEditModeWindow(last_edit_mode);
13649 case GADGET_ID_WRAP_LEFT:
13650 WrapLevel(-step, 0);
13653 case GADGET_ID_WRAP_RIGHT:
13654 WrapLevel(step, 0);
13657 case GADGET_ID_WRAP_UP:
13658 WrapLevel(0, -step);
13661 case GADGET_ID_WRAP_DOWN:
13662 WrapLevel(0, step);
13665 case GADGET_ID_SINGLE_ITEMS:
13666 case GADGET_ID_CONNECTED_ITEMS:
13667 case GADGET_ID_LINE:
13668 case GADGET_ID_ARC:
13669 case GADGET_ID_TEXT:
13670 case GADGET_ID_RECTANGLE:
13671 case GADGET_ID_FILLED_BOX:
13672 case GADGET_ID_FLOOD_FILL:
13673 case GADGET_ID_GRAB_BRUSH:
13674 case GADGET_ID_PICK_ELEMENT:
13675 if (drawing_function != GADGET_ID_PICK_ELEMENT)
13676 last_drawing_function = drawing_function;
13677 drawing_function = id;
13678 draw_with_brush = FALSE;
13681 case GADGET_ID_RANDOM_PLACEMENT:
13682 RandomPlacement(new_element);
13685 case GADGET_ID_ZOOM:
13686 // zoom level editor tile size in or out (or reset to default size)
13687 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
13688 button == 2 ? ed_tilesize_default :
13689 button == 3 ? ed_tilesize / 2 : ed_tilesize);
13691 // limit zoom level by upper and lower bound
13692 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
13694 InitZoomLevelSettings(ed_tilesize);
13696 if (edit_mode == ED_MODE_DRAWING)
13698 DrawDrawingWindow();
13700 // redraw zoom gadget info text
13701 PrintEditorGadgetInfoText(level_editor_gadget[id]);
13704 // save current editor zoom tilesize
13705 SaveSetup_AutoSetup();
13709 case GADGET_ID_CUSTOM_COPY_FROM:
13710 case GADGET_ID_CUSTOM_COPY_TO:
13711 case GADGET_ID_CUSTOM_EXCHANGE:
13712 last_custom_copy_mode = id;
13713 last_drawing_function = drawing_function;
13716 case GADGET_ID_CUSTOM_COPY:
13717 CopyCustomElement(properties_element, -1, id);
13720 case GADGET_ID_CUSTOM_PASTE:
13721 CopyCustomElement(-1, properties_element, id);
13724 case GADGET_ID_UNDO:
13725 if (button == 1 && GetKeyModState() & (KMOD_Shift|KMOD_Control))
13728 if (button == 1 && undo_buffer_steps == 0)
13730 Request("Undo buffer empty!", REQ_CONFIRM);
13734 else if (button == 2)
13738 else if (button == 3 && redo_buffer_steps == 0)
13740 Request("Redo buffer empty!", REQ_CONFIRM);
13745 if (edit_mode != ED_MODE_DRAWING)
13746 ChangeEditModeWindow(ED_MODE_DRAWING);
13752 undo_buffer_position =
13753 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
13755 undo_buffer_steps--;
13756 redo_buffer_steps++;
13762 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13764 undo_buffer_steps++;
13765 redo_buffer_steps--;
13768 for (x = 0; x < lev_fieldx; x++)
13769 for (y = 0; y < lev_fieldy; y++)
13770 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
13772 // check if undo operation forces change of border style
13773 CheckLevelBorderElement(FALSE);
13775 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13779 case GADGET_ID_INFO:
13780 if (edit_mode != ED_MODE_INFO)
13782 last_edit_mode = edit_mode;
13784 ChangeEditModeWindow(ED_MODE_INFO);
13788 ChangeEditModeWindow(last_edit_mode);
13792 case GADGET_ID_CLEAR:
13793 if (edit_mode != ED_MODE_DRAWING)
13794 ChangeEditModeWindow(ED_MODE_DRAWING);
13796 for (x = 0; x < MAX_LEV_FIELDX; x++)
13797 for (y = 0; y < MAX_LEV_FIELDY; y++)
13798 Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
13800 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
13802 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13805 case GADGET_ID_SAVE:
13807 // saving read-only levels into personal level set modifies global vars
13808 // "leveldir_current" and "level_nr"; restore them after saving level
13809 LevelDirTree *leveldir_former = leveldir_current;
13810 int level_nr_former = level_nr;
13811 char *level_filename;
13814 if (leveldir_current->readonly &&
13815 !PrepareSavingIntoPersonalLevelSet())
13818 level_filename = getDefaultLevelFilename(level_nr);
13819 new_level = !fileExists(level_filename);
13822 Request("Save this level and kill the old?", REQ_ASK))
13824 if (leveldir_former->readonly)
13825 ModifyLevelInfoForSavingIntoPersonalLevelSet(leveldir_former->name);
13827 SetAutomaticNumberOfGemsNeeded();
13829 CopyPlayfield(Feld, level.field);
13830 SaveLevel(level_nr);
13832 level.changed = FALSE;
13836 char level_saved_msg[64];
13838 if (leveldir_former->readonly)
13839 sprintf(level_saved_msg,
13840 "Level saved as level %d into personal level set!",
13843 strcpy(level_saved_msg, "Level saved!");
13845 Request(level_saved_msg, REQ_CONFIRM);
13849 // "cd" back to copied-from levelset (in case of saved read-only level)
13850 leveldir_current = leveldir_former;
13851 level_nr = level_nr_former;
13856 case GADGET_ID_TEST:
13857 if (LevelChanged())
13858 level.game_version = GAME_VERSION_ACTUAL;
13860 CopyPlayfield(level.field, FieldBackup);
13861 CopyPlayfield(Feld, level.field);
13863 CopyNativeLevel_RND_to_Native(&level);
13865 UnmapLevelEditorGadgets();
13866 UndrawSpecialEditorDoor();
13868 CloseDoor(DOOR_CLOSE_ALL);
13870 // needed before playing if editor playfield area has different size
13871 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
13873 // redraw_mask = REDRAW_ALL;
13875 level_editor_test_game = TRUE;
13877 StartGameActions(FALSE, setup.autorecord, level.random_seed);
13881 case GADGET_ID_EXIT:
13882 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
13886 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
13887 id <= GADGET_ID_ELEMENTLIST_LAST)
13889 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
13890 int new_element = editor_elements[element_position + element_shift];
13892 if (IS_EDITOR_CASCADE(new_element))
13896 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
13898 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
13899 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
13901 if (*cascade_element == new_element)
13903 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
13904 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
13906 // update element selection list
13907 ReinitializeElementList();
13908 ModifyEditorElementList();
13910 // update cascading gadget info text
13911 PrintEditorGadgetInfoText(level_editor_gadget[id]);
13913 // save current editor cascading state
13914 SaveSetup_EditorCascade();
13923 if (last_custom_copy_mode != -1)
13925 if (CopyCustomElement(properties_element, new_element,
13926 last_custom_copy_mode))
13928 ClickOnGadget(level_editor_gadget[last_drawing_function],
13931 last_custom_copy_mode = -1;
13937 // change element of button used to show palette
13938 if (editor.palette.show_on_element_buttons)
13939 button = last_button;
13941 PickDrawingElement(button, new_element);
13943 if (!stick_element_properties_window &&
13944 drawing_function != GADGET_ID_PICK_ELEMENT &&
13945 !(GetKeyModState() & KMOD_Control))
13947 properties_element = new_element;
13948 if (edit_mode == ED_MODE_PROPERTIES)
13949 DrawPropertiesWindow();
13952 if (drawing_function == GADGET_ID_PICK_ELEMENT)
13953 ClickOnGadget(level_editor_gadget[last_drawing_function],
13956 if (!use_permanent_palette)
13957 ChangeEditModeWindow(last_edit_mode);
13960 else if (gi->event.type == GD_EVENT_PRESSED)
13961 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
13962 else if (gi->event.type == GD_EVENT_RELEASED)
13963 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
13964 else if (gi->event.type == GD_EVENT_MOVING)
13965 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
13967 printf("default: HandleControlButtons: ? (id == %d)\n", id);
13973 void HandleLevelEditorKeyInput(Key key)
13975 char letter = getCharFromKey(key);
13976 int button = MB_LEFTBUTTON;
13978 if (drawing_function == GADGET_ID_TEXT &&
13979 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
13982 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
13983 else if (key == KSYM_Delete || key == KSYM_BackSpace)
13984 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
13985 else if (key == KSYM_Return)
13986 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
13987 else if (key == KSYM_Escape)
13988 DrawLevelText(0, 0, 0, TEXT_END);
13990 else if (button_status == MB_RELEASED)
13992 int id = GADGET_ID_NONE;
13993 int new_element_shift = element_shift;
13994 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
14000 id = GADGET_ID_SCROLL_LEFT;
14003 id = GADGET_ID_SCROLL_RIGHT;
14006 id = GADGET_ID_SCROLL_UP;
14009 id = GADGET_ID_SCROLL_DOWN;
14013 case KSYM_Page_Down:
14014 step *= (key == KSYM_Page_Up ? -1 : +1);
14015 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
14017 if (element_shift < 0)
14019 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14020 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14022 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14023 GDI_SCROLLBAR_ITEM_POSITION,
14024 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14026 ModifyEditorElementList();
14032 element_shift = (key == KSYM_Home ? 0 :
14033 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
14035 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14036 GDI_SCROLLBAR_ITEM_POSITION,
14037 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14039 ModifyEditorElementList();
14046 // this is needed to prevent interference with running "True X-Mouse"
14047 if (GetKeyModStateFromEvents() & KMOD_Control)
14050 // check for last or next editor cascade block in element list
14051 for (i = 0; i < num_editor_elements; i++)
14053 if ((key == KSYM_Insert && i == element_shift) ||
14054 (key == KSYM_Delete && new_element_shift > element_shift))
14057 // jump to next cascade block (or to start of element list)
14058 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
14059 new_element_shift = i;
14062 if (i < num_editor_elements)
14063 element_shift = new_element_shift;
14065 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14066 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14068 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14069 GDI_SCROLLBAR_ITEM_POSITION,
14070 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14072 ModifyEditorElementList();
14077 if (edit_mode == ED_MODE_DRAWING)
14079 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
14081 else if (edit_mode == ED_MODE_INFO)
14083 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
14085 else if (edit_mode == ED_MODE_PROPERTIES)
14087 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
14089 else if (edit_mode == ED_MODE_PALETTE)
14091 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
14093 else // should never happen
14095 ChangeEditModeWindow(ED_MODE_DRAWING);
14104 if (id != GADGET_ID_NONE)
14105 ClickOnGadget(level_editor_gadget[id], button);
14106 else if (letter == '1' || letter == '?')
14107 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
14108 else if (letter == '2')
14109 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
14110 else if (letter == '3')
14111 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
14112 else if (letter == '.')
14113 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
14114 else if (letter == 'U')
14115 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
14116 else if (letter == '-' || key == KSYM_KP_Subtract)
14117 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
14118 else if (letter == '0' || key == KSYM_KP_0)
14119 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
14120 else if (letter == '+' || key == KSYM_KP_Add ||
14121 letter == '=') // ("Shift-=" is "+" on US keyboards)
14122 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
14123 else if (key == KSYM_Return ||
14124 key == KSYM_space ||
14125 key == setup.shortcut.toggle_pause)
14126 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
14128 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
14129 if (letter && letter == controlbutton_info[i].shortcut)
14130 if (!anyTextGadgetActive())
14131 ClickOnGadget(level_editor_gadget[i], button);
14135 void HandleLevelEditorIdle(void)
14137 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
14138 int x = editor.settings.element_graphic.x + element_border;
14139 int y = editor.settings.element_graphic.y + element_border;
14140 static unsigned int action_delay = 0;
14141 unsigned int action_delay_value = GameFrameDelay;
14144 if (edit_mode != ED_MODE_PROPERTIES)
14147 if (!DelayReached(&action_delay, action_delay_value))
14150 for (i = 0; i < ED_NUM_SELECTBOX; i++)
14152 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
14154 if (gi->mapped && gi->active && gi->selectbox.open)
14158 DrawEditorElementAnimation(SX + x, SY + y);
14160 redraw_mask |= REDRAW_FIELD;
14162 FrameCounter++; // increase animation frame counter
14165 static void ClearEditorGadgetInfoText(void)
14167 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
14170 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
14172 char infotext[MAX_OUTPUT_LINESIZE + 1];
14173 char shortcut[MAX_OUTPUT_LINESIZE + 1];
14174 int max_infotext_len = getMaxInfoTextLength();
14176 if (gi == NULL || strlen(gi->info_text) == 0)
14179 strncpy(infotext, gi->info_text, max_infotext_len);
14180 infotext[max_infotext_len] = '\0';
14182 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
14184 int key = controlbutton_info[gi->custom_id].shortcut;
14188 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
14189 sprintf(shortcut, " ('.' or '%c')", key);
14190 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
14191 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
14192 else if (gi->custom_id == GADGET_ID_TEST)
14193 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
14194 else if (gi->custom_id == GADGET_ID_UNDO)
14195 sprintf(shortcut, " ('%c/Shift-U')", key);
14196 else if (gi->custom_id == GADGET_ID_ZOOM)
14197 sprintf(shortcut, " ('%c', '0', '-')", key);
14199 sprintf(shortcut, " ('%s%c')",
14200 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
14202 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
14203 strcat(infotext, shortcut);
14207 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
14210 void HandleEditorGadgetInfoText(void *ptr)
14212 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
14214 if (game_status != GAME_MODE_EDITOR)
14217 ClearEditorGadgetInfoText();
14219 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
14222 // misuse this function to delete brush cursor, if needed
14223 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
14224 DeleteBrushFromCursor();
14226 PrintEditorGadgetInfoText(gi);
14229 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
14231 static int start_lx, start_ly;
14232 int id = gi->custom_id;
14233 int type_id = gi->custom_type_id;
14234 int sx = gi->event.x;
14235 int sy = gi->event.y;
14236 int lx = sx + level_xpos;
14237 int ly = sy + level_ypos;
14238 int min_sx = 0, min_sy = 0;
14239 int max_sx = gi->drawing.area_xsize - 1;
14240 int max_sy = gi->drawing.area_ysize - 1;
14241 int actual_drawing_function = drawing_function;
14242 int max_infotext_len = getMaxInfoTextLength();
14243 char infotext[MAX_OUTPUT_LINESIZE + 1];
14246 infotext[0] = '\0'; // start with empty info text
14248 // pressed Control key: simulate picking element
14249 if (GetKeyModState() & KMOD_Control)
14250 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14252 ClearEditorGadgetInfoText();
14254 if (gi->event.type == GD_EVENT_INFO_LEAVING)
14257 // make sure to stay inside drawing area boundaries
14258 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14259 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14261 if (id == GADGET_ID_DRAWING_LEVEL)
14265 int min_lx = 0, min_ly = 0;
14266 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14268 // get positions inside level field
14269 lx = sx + level_xpos;
14270 ly = sy + level_ypos;
14272 // make sure to stay inside level field boundaries
14273 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14274 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14276 // correct drawing area positions accordingly
14277 sx = lx - level_xpos;
14278 sy = ly - level_ypos;
14281 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
14283 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
14285 if (gi->event.type == GD_EVENT_PRESSED)
14291 switch (actual_drawing_function)
14293 case GADGET_ID_SINGLE_ITEMS:
14294 text = "Drawing single items";
14296 case GADGET_ID_CONNECTED_ITEMS:
14297 text = "Drawing connected items";
14299 case GADGET_ID_LINE:
14300 text = "Drawing line";
14302 case GADGET_ID_ARC:
14303 text = "Drawing arc";
14305 case GADGET_ID_TEXT:
14306 text = "Setting text cursor";
14308 case GADGET_ID_RECTANGLE:
14309 text = "Drawing rectangle";
14311 case GADGET_ID_FILLED_BOX:
14312 text = "Drawing filled box";
14314 case GADGET_ID_FLOOD_FILL:
14315 text = "Flood fill";
14317 case GADGET_ID_GRAB_BRUSH:
14318 text = "Grabbing brush";
14320 case GADGET_ID_PICK_ELEMENT:
14321 text = "Picking element";
14325 text = "Drawing position";
14329 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14330 sprintf(infotext, "%s: %d, %d", text, lx, ly);
14332 sprintf(infotext, "%s: %d, %d", text,
14333 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
14335 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14336 strncpy(infotext, getElementInfoText(Feld[lx][ly]), max_infotext_len);
14338 sprintf(infotext, "Level position: %d, %d", lx, ly);
14341 // misuse this function to draw brush cursor, if needed
14342 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
14344 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
14345 CopyBrushToCursor(sx, sy);
14347 DeleteBrushFromCursor();
14350 if (!draw_with_brush)
14351 UpdateBrushPosition(sx, sy);
14353 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14355 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14356 int element = drawingarea_info[type_id].value[pos];
14358 strncpy(infotext, getElementInfoText(element), max_infotext_len);
14362 if (id == GADGET_ID_CUSTOM_CONTENT)
14363 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
14364 else if (id == GADGET_ID_GROUP_CONTENT)
14365 sprintf(infotext, "group element position: %d", sx + 1);
14366 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
14367 id <= GADGET_ID_YAMYAM_CONTENT_7)
14368 sprintf(infotext, "content area %d position: %d, %d",
14369 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
14370 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
14371 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
14372 sprintf(infotext, "content area %d position: %d, %d",
14373 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
14374 else if (id == GADGET_ID_ANDROID_CONTENT)
14375 sprintf(infotext, "android element position: %d", sx + 1);
14376 else if (drawingarea_info[type_id].infotext != NULL)
14377 strcpy(infotext, drawingarea_info[type_id].infotext);
14380 infotext[max_infotext_len] = '\0';
14382 if (strlen(infotext) > 0)
14383 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
14386 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
14387 boolean quick_quit)
14389 if (!ask_if_level_has_changed ||
14391 Request("Level has changed! Exit without saving?",
14392 REQ_ASK | REQ_STAY_OPEN))
14394 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
14395 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
14397 // draw normal door
14398 UndrawSpecialEditorDoor();
14400 // use door animation if door 1 viewport is unchanged and contains toolbox
14401 if (useEditorDoorAnimation())
14402 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
14404 // close editor doors if viewport definition is the same as in main menu
14405 if (vp_door_1->x == DX &&
14406 vp_door_1->y == DY &&
14407 vp_door_1->width == DXSIZE &&
14408 vp_door_1->height == DYSIZE &&
14409 vp_door_2->x == VX &&
14410 vp_door_2->y == VY &&
14411 vp_door_2->width == VXSIZE &&
14412 vp_door_2->height == VYSIZE)
14413 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
14415 SetDoorState(DOOR_CLOSE_2);
14420 FadeSkipNextFadeIn();
14422 SetGameStatus(GAME_MODE_MAIN);
14428 if (!global.use_envelope_request)
14430 CloseDoor(DOOR_CLOSE_1);
14431 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);