1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
14 #include "libgame/libgame.h"
25 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
28 // ----------------------------------------------------------------------------
29 // screen and artwork graphic pixel position definitions
30 // ----------------------------------------------------------------------------
32 // values for the control window
33 #define ED_CTRL1_BUTTONS_HORIZ 4 // toolbox
34 #define ED_CTRL1_BUTTONS_VERT 4
35 #define ED_CTRL2_BUTTONS_HORIZ 3 // level
36 #define ED_CTRL2_BUTTONS_VERT 2
37 #define ED_CTRL3_BUTTONS_HORIZ 3 // CE and GE
38 #define ED_CTRL3_BUTTONS_VERT 1
39 #define ED_CTRL4_BUTTONS_HORIZ 2 // CE and GE
40 #define ED_CTRL4_BUTTONS_VERT 1
41 #define ED_CTRL5_BUTTONS_HORIZ 1 // properties
42 #define ED_CTRL5_BUTTONS_VERT 1
43 #define ED_CTRL6_BUTTONS_HORIZ 3 // properties
44 #define ED_CTRL6_BUTTONS_VERT 1
45 #define ED_CTRL7_BUTTONS_HORIZ 1 // palette
46 #define ED_CTRL7_BUTTONS_VERT 1
48 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
49 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
50 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
51 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
52 #define ED_NUM_CTRL5_BUTTONS (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT)
53 #define ED_NUM_CTRL6_BUTTONS (ED_CTRL6_BUTTONS_HORIZ * ED_CTRL6_BUTTONS_VERT)
54 #define ED_NUM_CTRL7_BUTTONS (ED_CTRL7_BUTTONS_HORIZ * ED_CTRL7_BUTTONS_VERT)
55 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
56 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
57 #define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS)
58 #define ED_NUM_CTRL1_5_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS)
59 #define ED_NUM_CTRL1_6_BUTTONS (ED_NUM_CTRL1_5_BUTTONS + ED_NUM_CTRL6_BUTTONS)
60 #define ED_NUM_CTRL1_7_BUTTONS (ED_NUM_CTRL1_6_BUTTONS + ED_NUM_CTRL7_BUTTONS)
61 #define ED_NUM_CTRL_BUTTONS ED_NUM_CTRL1_7_BUTTONS
63 // values for the element list
64 #define ED_ELEMENTLIST_XPOS (editor.palette.x)
65 #define ED_ELEMENTLIST_YPOS (editor.palette.y)
66 #define ED_ELEMENTLIST_XSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
67 #define ED_ELEMENTLIST_YSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
68 #define ED_ELEMENTLIST_COLS MAX(1, editor.palette.cols)
69 #define ED_ELEMENTLIST_ROWS MAX(1, editor.palette.rows)
70 #define ED_ELEMENTLIST_BUTTONS_HORIZ (ED_ELEMENTLIST_COLS)
71 #define ED_ELEMENTLIST_BUTTONS_VERT (ED_ELEMENTLIST_ROWS)
72 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
73 ED_ELEMENTLIST_BUTTONS_VERT)
76 #define ED_GADGET_NORMAL_DISTANCE (editor.gadget.normal_spacing)
77 #define ED_GADGET_SMALL_DISTANCE (editor.gadget.small_spacing)
78 #define ED_GADGET_TINY_DISTANCE (editor.gadget.tiny_spacing)
79 #define ED_GADGET_LINE_DISTANCE (editor.gadget.line_spacing)
80 #define ED_GADGET_TEXT_DISTANCE (editor.gadget.text_spacing)
81 #define ED_TAB_BAR_HEIGHT (editor.gadget.separator_line.height)
82 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
83 ED_DRAWINGAREA_BORDER_SIZE)
84 #define ED_GADGET_SPACE_DISTANCE (getFontWidth(FONT_TEXT_1))
86 // values for drawingarea gadgets
87 #define IMG_BORDER_1 IMG_EDITOR_ELEMENT_BORDER
88 #define IMG_BORDER_2 IMG_EDITOR_ELEMENT_BORDER_INPUT
89 #define ED_ELEMENT_BORDER (graphic_info[IMG_BORDER_1].border_size)
90 #define ED_DRAWINGAREA_BORDER_SIZE (graphic_info[IMG_BORDER_2].border_size)
91 #define ED_DRAWINGAREA_TILE_SIZE (editor.drawingarea.tile_size)
93 // values for checkbutton gadgets
94 #define ED_CHECKBUTTON_XSIZE (graphic_info[IMG_EDITOR_CHECKBOX].width)
95 #define ED_CHECKBUTTON_YSIZE (graphic_info[IMG_EDITOR_CHECKBOX].height)
97 #define ED_TABBUTTON_XSIZE (graphic_info[IMG_EDITOR_TABBUTTON].width)
98 #define ED_TABBUTTON_YSIZE (graphic_info[IMG_EDITOR_TABBUTTON].height)
100 #define ED_SETTINGS_LEVEL_TABS_X (editor.settings.tabs.x)
101 #define ED_SETTINGS_LEVEL_TABS_Y (editor.settings.tabs.y)
102 #define ED_SETTINGS_ELEMENT_TABS_X (editor.settings.tabs.x)
103 #define ED_SETTINGS_ELEMENT_TABS_Y (editor.settings.tabs.y + \
104 editor.settings.tabs.yoffset2)
106 #define ED_SETTINGS_TABS_XOFFSET (editor.settings.tabs.draw_xoffset)
107 #define ED_SETTINGS_TABS_YOFFSET (editor.settings.tabs.draw_yoffset)
109 #define ED_LEVEL_TABS_XSTART (ED_SETTINGS_LEVEL_TABS_X)
110 #define ED_LEVEL_TABS_YSTART (ED_SETTINGS_LEVEL_TABS_Y)
111 #define ED_LEVEL_SETTINGS_XSTART (ED_SETTINGS_LEVEL_TABS_X + \
112 ED_SETTINGS_TABS_XOFFSET)
113 #define ED_LEVEL_SETTINGS_YSTART (ED_SETTINGS_LEVEL_TABS_Y + \
114 ED_TABBUTTON_YSIZE + \
115 ED_GADGET_TINY_DISTANCE + \
116 ED_TAB_BAR_HEIGHT + \
117 ED_SETTINGS_TABS_YOFFSET + \
118 getFontHeight(FONT_TEXT_1) + \
119 ED_GADGET_TEXT_DISTANCE)
120 #define ED_ELEMENT_TABS_XSTART (ED_SETTINGS_ELEMENT_TABS_X)
121 #define ED_ELEMENT_TABS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y)
122 #define ED_ELEMENT_SETTINGS_XSTART (ED_SETTINGS_ELEMENT_TABS_X + \
123 ED_SETTINGS_TABS_XOFFSET)
124 #define ED_ELEMENT_SETTINGS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y + \
125 ED_TABBUTTON_YSIZE + \
126 ED_GADGET_TINY_DISTANCE + \
127 ED_TAB_BAR_HEIGHT + \
128 ED_SETTINGS_TABS_YOFFSET)
130 #define ED_SETTINGS_XOFFSET (ED_CHECKBUTTON_XSIZE + \
131 ED_GADGET_TEXT_DISTANCE)
132 #define ED_SETTINGS_YOFFSET (ED_CHECKBUTTON_YSIZE + \
133 ED_GADGET_LINE_DISTANCE)
135 #define ED_POS_RANGE (10000)
136 #define ED_POS_LEVEL_TABS_FIRST (1 * ED_POS_RANGE)
137 #define ED_POS_LEVEL_TABS_LAST (2 * ED_POS_RANGE - 1)
138 #define ED_POS_LEVEL_SETTINGS_FIRST (2 * ED_POS_RANGE)
139 #define ED_POS_LEVEL_SETTINGS_LAST (3 * ED_POS_RANGE - 1)
140 #define ED_POS_ELEMENT_TABS_FIRST (3 * ED_POS_RANGE)
141 #define ED_POS_ELEMENT_TABS_LAST (4 * ED_POS_RANGE - 1)
142 #define ED_POS_ELEMENT_SETTINGS_FIRST (4 * ED_POS_RANGE)
143 #define ED_POS_ELEMENT_SETTINGS_LAST (5 * ED_POS_RANGE - 1)
145 #define ED_LEVEL_TABS_XPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
146 #define ED_LEVEL_TABS_YPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
148 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
149 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
151 #define ED_ELEMENT_TABS_XPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
152 #define ED_ELEMENT_TABS_YPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
154 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
155 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
157 #define IS_POS_LEVEL_TABS(n) ((n) >= ED_POS_LEVEL_TABS_FIRST && \
158 (n) <= ED_POS_LEVEL_TABS_LAST)
159 #define IS_POS_LEVEL_SETTINGS(n) ((n) >= ED_POS_LEVEL_SETTINGS_FIRST && \
160 (n) <= ED_POS_LEVEL_SETTINGS_LAST)
161 #define IS_POS_ELEMENT_TABS(n) ((n) >= ED_POS_ELEMENT_TABS_FIRST && \
162 (n) <= ED_POS_ELEMENT_TABS_LAST)
163 #define IS_POS_ELEMENT_SETTINGS(n) ((n) >= ED_POS_ELEMENT_SETTINGS_FIRST && \
164 (n) <= ED_POS_ELEMENT_SETTINGS_LAST)
166 #define ED_LEVEL_TABS_LINE(n) ((n) - ED_POS_LEVEL_TABS_FIRST)
167 #define ED_LEVEL_SETTINGS_LINE(n) ((n) - ED_POS_LEVEL_SETTINGS_FIRST)
168 #define ED_ELEMENT_TABS_LINE(n) ((n) - ED_POS_ELEMENT_TABS_FIRST)
169 #define ED_ELEMENT_SETTINGS_LINE(n) ((n) - ED_POS_ELEMENT_SETTINGS_FIRST)
171 #define ED_LEVEL_TABS_X(n) (ED_LEVEL_TABS_XSTART + \
172 (n) * ED_SETTINGS_TABS_XOFFSET)
173 #define ED_LEVEL_TABS_Y(n) (ED_LEVEL_TABS_YSTART + \
174 (n) * ED_SETTINGS_TABS_YOFFSET)
176 #define ED_LEVEL_SETTINGS_X(n) (ED_LEVEL_SETTINGS_XSTART + \
177 (n) * ED_SETTINGS_XOFFSET)
178 #define ED_LEVEL_SETTINGS_Y(n) (ED_LEVEL_SETTINGS_YSTART + \
179 (n) * ED_SETTINGS_YOFFSET)
181 #define ED_ELEMENT_TABS_X(n) (ED_ELEMENT_TABS_XSTART + \
182 (n) * ED_SETTINGS_TABS_XOFFSET)
183 #define ED_ELEMENT_TABS_Y(n) (ED_ELEMENT_TABS_YSTART + \
184 (n) * ED_SETTINGS_TABS_YOFFSET)
186 #define ED_ELEMENT_SETTINGS_X(n) (ED_ELEMENT_SETTINGS_XSTART + \
187 (n) * ED_SETTINGS_XOFFSET)
188 #define ED_ELEMENT_SETTINGS_Y(n) (ED_ELEMENT_SETTINGS_YSTART + \
189 (n) * ED_SETTINGS_YOFFSET)
191 #define ED_POS_TO_LEVEL_TABS_X(n) \
192 (ED_LEVEL_TABS_X(ED_LEVEL_TABS_LINE(n)))
193 #define ED_POS_TO_LEVEL_TABS_Y(n) \
194 (ED_LEVEL_TABS_Y(ED_LEVEL_TABS_LINE(n)))
196 #define ED_POS_TO_LEVEL_SETTINGS_X(n) \
197 (ED_LEVEL_SETTINGS_X(ED_LEVEL_SETTINGS_LINE(n)))
198 #define ED_POS_TO_LEVEL_SETTINGS_Y(n) \
199 (ED_LEVEL_SETTINGS_Y(ED_LEVEL_SETTINGS_LINE(n)))
201 #define ED_POS_TO_ELEMENT_TABS_X(n) \
202 (ED_ELEMENT_TABS_X(ED_ELEMENT_TABS_LINE(n)))
203 #define ED_POS_TO_ELEMENT_TABS_Y(n) \
204 (ED_ELEMENT_TABS_Y(ED_ELEMENT_TABS_LINE(n)))
206 #define ED_POS_TO_ELEMENT_SETTINGS_X(n) \
207 (ED_ELEMENT_SETTINGS_X(ED_ELEMENT_SETTINGS_LINE(n)))
208 #define ED_POS_TO_ELEMENT_SETTINGS_Y(n) \
209 (ED_ELEMENT_SETTINGS_Y(ED_ELEMENT_SETTINGS_LINE(n)))
211 #define ED_SETTINGS_X(n) (IS_POS_LEVEL_TABS(n) ? \
212 ED_POS_TO_LEVEL_TABS_X(n) : \
213 IS_POS_LEVEL_SETTINGS(n) ? \
214 ED_POS_TO_LEVEL_SETTINGS_X(n) : \
215 IS_POS_ELEMENT_TABS(n) ? \
216 ED_POS_TO_ELEMENT_TABS_X(n) : \
217 IS_POS_ELEMENT_SETTINGS(n) ? \
218 ED_POS_TO_ELEMENT_SETTINGS_X(n) : (n))
219 #define ED_SETTINGS_Y(n) (IS_POS_LEVEL_TABS(n) ? \
220 ED_POS_TO_LEVEL_TABS_Y(n) : \
221 IS_POS_LEVEL_SETTINGS(n) ? \
222 ED_POS_TO_LEVEL_SETTINGS_Y(n) : \
223 IS_POS_ELEMENT_TABS(n) ? \
224 ED_POS_TO_ELEMENT_TABS_Y(n) : \
225 IS_POS_ELEMENT_SETTINGS(n) ? \
226 ED_POS_TO_ELEMENT_SETTINGS_Y(n) : (n))
228 #define ED_SETTINGS_XOFF(n) (5 * ((n) % 4) * \
229 ED_DRAWINGAREA_TILE_SIZE)
230 #define ED_SETTINGS_YOFF(n) (5 * ((n) / 4) * \
231 ED_DRAWINGAREA_TILE_SIZE)
233 #define ED_AREA_XOFFSET_1(n) ((n) != 0 ? \
234 ED_DRAWINGAREA_BORDER_SIZE : 0)
235 #define ED_AREA_YOFFSET_1(n) ((n) != 0 ? \
236 (ED_CHECKBUTTON_YSIZE - \
237 ED_DRAWINGAREA_TILE_SIZE) / 2 : 0)
239 #define ED_AREA_XOFFSET_2(n) (0)
240 #define ED_AREA_YOFFSET_2(n) ((n) == 3 ? \
241 ((n) - 1) * ED_DRAWINGAREA_TILE_SIZE / 2 : 0)
243 #define ED_AREA_SETTINGS_X(i) (ED_SETTINGS_X((i).x) + \
244 ED_SETTINGS_XOFF((i).xoffset) + \
245 ED_AREA_XOFFSET_1((i).x) - \
246 ED_AREA_XOFFSET_2((i).area_xsize))
247 #define ED_AREA_SETTINGS_Y(i) (ED_SETTINGS_Y((i).y) + \
248 ED_SETTINGS_YOFF((i).yoffset) + \
249 ED_AREA_YOFFSET_1((i).y) - \
250 ED_AREA_YOFFSET_2((i).area_ysize))
252 // values for element content drawing areas
253 #define ED_AREA_1X1_LSETTINGS_XPOS(n) ED_LEVEL_SETTINGS_XPOS(n)
254 #define ED_AREA_1X1_LSETTINGS_YPOS(n) ED_LEVEL_SETTINGS_YPOS(n)
255 #define ED_AREA_1X1_LSETTINGS_XOFF (0)
256 #define ED_AREA_1X1_LSETTINGS_YOFF (0)
258 #define ED_AREA_1X1_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
259 #define ED_AREA_1X1_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
260 #define ED_AREA_1X1_SETTINGS_XOFF (0)
261 #define ED_AREA_1X1_SETTINGS_YOFF (0)
263 #define ED_AREA_3X3_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
264 #define ED_AREA_3X3_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
265 #define ED_AREA_3X3_SETTINGS_XOFF (0)
266 #define ED_AREA_3X3_SETTINGS_YOFF (0)
269 #define ED_AREA_ELEMENT_CONTENT_XOFF(n) (n)
270 #define ED_AREA_ELEMENT_CONTENT_YOFF(n) (n)
273 #define ED_XPOS_YAM 0
274 #define ED_YPOS_YAM 5
275 #define ED_AREA_YAMYAM_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_YAM)
276 #define ED_AREA_YAMYAM_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_YAM)
277 #define ED_AREA_YAMYAM_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
278 #define ED_AREA_YAMYAM_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
279 #define ED_AREA_YAMYAM_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_YAM) + \
281 #define ED_AREA_YAMYAM_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_YAM) + \
282 ED_SETTINGS_YOFF(n) + \
283 ED_AREA_YOFFSET_1(ED_YPOS_YAM) - \
284 ED_AREA_YOFFSET_2(3))
286 // magic ball content
287 #define ED_XPOS_BALL 0
288 #define ED_YPOS_BALL 6
289 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_BALL)
290 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_BALL)
291 #define ED_AREA_MAGIC_BALL_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
292 #define ED_AREA_MAGIC_BALL_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
293 #define ED_AREA_MAGIC_BALL_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_BALL) + \
295 #define ED_AREA_MAGIC_BALL_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_BALL) + \
296 ED_SETTINGS_YOFF(n) + \
297 ED_AREA_YOFFSET_1(ED_YPOS_BALL) - \
298 ED_AREA_YOFFSET_2(3))
300 // values for scrolling gadgets for drawing area
301 #define ED_SCROLLBUTTON_XSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].width)
302 #define ED_SCROLLBUTTON_YSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].height)
304 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
305 #define ED_SCROLL_UP_YPOS (0)
306 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
307 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
308 #define ED_SCROLL_LEFT_XPOS (0)
309 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
310 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
311 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
312 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
313 ED_SCROLLBUTTON_XSIZE)
314 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
315 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
316 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
317 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
318 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
319 ED_SCROLLBUTTON_YSIZE)
320 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
321 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
323 // values for scrolling gadgets for element list
324 #define ED_SCROLLBUTTON2_XSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
325 #define ED_SCROLLBUTTON2_YSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
327 #define ED_SCROLL2_UP_XPOS (ED_ELEMENTLIST_XPOS + \
328 ED_ELEMENTLIST_BUTTONS_HORIZ * \
329 ED_ELEMENTLIST_XSIZE)
330 #define ED_SCROLL2_UP_YPOS ED_ELEMENTLIST_YPOS
331 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
332 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
333 ED_ELEMENTLIST_BUTTONS_VERT * \
334 ED_ELEMENTLIST_YSIZE - \
335 ED_SCROLLBUTTON2_YSIZE)
336 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
337 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
338 ED_SCROLLBUTTON2_YSIZE)
339 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
340 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
341 ED_ELEMENTLIST_YSIZE - \
342 2 * ED_SCROLLBUTTON2_YSIZE)
344 // values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText()
345 #define INFOTEXT_FONT FONT_TEXT_2
346 #define INFOTEXT_XSIZE SXSIZE
347 #define INFOTEXT_YSIZE getFontHeight(INFOTEXT_FONT)
348 #define INFOTEXT_YSIZE_FULL (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE)
349 #define INFOTEXT_X (editor.settings.tooltip.x)
350 #define INFOTEXT_Y (editor.settings.tooltip.y)
351 #define INFOTEXT_XY_REDEFINED (INFOTEXT_X != -1 || INFOTEXT_Y != -1)
352 #define INFOTEXT_XPOS SX + (INFOTEXT_XY_REDEFINED ? INFOTEXT_X : 0)
353 #define INFOTEXT_YPOS SY + (INFOTEXT_XY_REDEFINED ? INFOTEXT_Y : \
354 SYSIZE - INFOTEXT_YSIZE)
357 // ----------------------------------------------------------------------------
358 // editor gadget definitions
359 // ----------------------------------------------------------------------------
365 // drawing toolbox buttons
367 GADGET_ID_SINGLE_ITEMS,
368 GADGET_ID_CONNECTED_ITEMS,
372 GADGET_ID_FILLED_BOX,
375 GADGET_ID_FLOOD_FILL,
378 GADGET_ID_WRAP_RIGHT,
379 GADGET_ID_RANDOM_PLACEMENT,
380 GADGET_ID_GRAB_BRUSH,
382 GADGET_ID_PICK_ELEMENT,
391 GADGET_ID_CUSTOM_COPY_FROM,
392 GADGET_ID_CUSTOM_COPY_TO,
393 GADGET_ID_CUSTOM_EXCHANGE,
394 GADGET_ID_CUSTOM_COPY,
395 GADGET_ID_CUSTOM_PASTE,
397 GADGET_ID_PROPERTIES,
398 GADGET_ID_ELEMENT_LEFT,
399 GADGET_ID_ELEMENT_MIDDLE,
400 GADGET_ID_ELEMENT_RIGHT,
403 // counter gadget identifiers
405 GADGET_ID_SELECT_LEVEL_DOWN,
406 GADGET_ID_SELECT_LEVEL_TEXT,
407 GADGET_ID_SELECT_LEVEL_UP,
408 GADGET_ID_LEVEL_XSIZE_DOWN,
409 GADGET_ID_LEVEL_XSIZE_TEXT,
410 GADGET_ID_LEVEL_XSIZE_UP,
411 GADGET_ID_LEVEL_YSIZE_DOWN,
412 GADGET_ID_LEVEL_YSIZE_TEXT,
413 GADGET_ID_LEVEL_YSIZE_UP,
414 GADGET_ID_LEVEL_RANDOM_DOWN,
415 GADGET_ID_LEVEL_RANDOM_TEXT,
416 GADGET_ID_LEVEL_RANDOM_UP,
417 GADGET_ID_LEVEL_GEMSLIMIT_DOWN,
418 GADGET_ID_LEVEL_GEMSLIMIT_TEXT,
419 GADGET_ID_LEVEL_GEMSLIMIT_UP,
420 GADGET_ID_LEVEL_TIMELIMIT_DOWN,
421 GADGET_ID_LEVEL_TIMELIMIT_TEXT,
422 GADGET_ID_LEVEL_TIMELIMIT_UP,
423 GADGET_ID_LEVEL_TIMESCORE_DOWN,
424 GADGET_ID_LEVEL_TIMESCORE_TEXT,
425 GADGET_ID_LEVEL_TIMESCORE_UP,
426 GADGET_ID_LEVEL_RANDOM_SEED_DOWN,
427 GADGET_ID_LEVEL_RANDOM_SEED_TEXT,
428 GADGET_ID_LEVEL_RANDOM_SEED_UP,
429 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN,
430 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT,
431 GADGET_ID_LEVELSET_NUM_LEVELS_UP,
432 GADGET_ID_ELEMENT_VALUE1_DOWN,
433 GADGET_ID_ELEMENT_VALUE1_TEXT,
434 GADGET_ID_ELEMENT_VALUE1_UP,
435 GADGET_ID_ELEMENT_VALUE2_DOWN,
436 GADGET_ID_ELEMENT_VALUE2_TEXT,
437 GADGET_ID_ELEMENT_VALUE2_UP,
438 GADGET_ID_ELEMENT_VALUE3_DOWN,
439 GADGET_ID_ELEMENT_VALUE3_TEXT,
440 GADGET_ID_ELEMENT_VALUE3_UP,
441 GADGET_ID_ELEMENT_VALUE4_DOWN,
442 GADGET_ID_ELEMENT_VALUE4_TEXT,
443 GADGET_ID_ELEMENT_VALUE4_UP,
444 GADGET_ID_YAMYAM_CONTENT_DOWN,
445 GADGET_ID_YAMYAM_CONTENT_TEXT,
446 GADGET_ID_YAMYAM_CONTENT_UP,
447 GADGET_ID_BALL_CONTENT_DOWN,
448 GADGET_ID_BALL_CONTENT_TEXT,
449 GADGET_ID_BALL_CONTENT_UP,
450 GADGET_ID_ANDROID_CONTENT_DOWN,
451 GADGET_ID_ANDROID_CONTENT_TEXT,
452 GADGET_ID_ANDROID_CONTENT_UP,
453 GADGET_ID_ENVELOPE_XSIZE_DOWN,
454 GADGET_ID_ENVELOPE_XSIZE_TEXT,
455 GADGET_ID_ENVELOPE_XSIZE_UP,
456 GADGET_ID_ENVELOPE_YSIZE_DOWN,
457 GADGET_ID_ENVELOPE_YSIZE_TEXT,
458 GADGET_ID_ENVELOPE_YSIZE_UP,
459 GADGET_ID_INVENTORY_SIZE_DOWN,
460 GADGET_ID_INVENTORY_SIZE_TEXT,
461 GADGET_ID_INVENTORY_SIZE_UP,
462 GADGET_ID_CUSTOM_SCORE_DOWN,
463 GADGET_ID_CUSTOM_SCORE_TEXT,
464 GADGET_ID_CUSTOM_SCORE_UP,
465 GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
466 GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
467 GADGET_ID_CUSTOM_GEMCOUNT_UP,
468 GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
469 GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
470 GADGET_ID_CUSTOM_VALUE_FIX_UP,
471 GADGET_ID_CUSTOM_VALUE_RND_DOWN,
472 GADGET_ID_CUSTOM_VALUE_RND_TEXT,
473 GADGET_ID_CUSTOM_VALUE_RND_UP,
474 GADGET_ID_PUSH_DELAY_FIX_DOWN,
475 GADGET_ID_PUSH_DELAY_FIX_TEXT,
476 GADGET_ID_PUSH_DELAY_FIX_UP,
477 GADGET_ID_PUSH_DELAY_RND_DOWN,
478 GADGET_ID_PUSH_DELAY_RND_TEXT,
479 GADGET_ID_PUSH_DELAY_RND_UP,
480 GADGET_ID_DROP_DELAY_FIX_DOWN,
481 GADGET_ID_DROP_DELAY_FIX_TEXT,
482 GADGET_ID_DROP_DELAY_FIX_UP,
483 GADGET_ID_DROP_DELAY_RND_DOWN,
484 GADGET_ID_DROP_DELAY_RND_TEXT,
485 GADGET_ID_DROP_DELAY_RND_UP,
486 GADGET_ID_MOVE_DELAY_FIX_DOWN,
487 GADGET_ID_MOVE_DELAY_FIX_TEXT,
488 GADGET_ID_MOVE_DELAY_FIX_UP,
489 GADGET_ID_MOVE_DELAY_RND_DOWN,
490 GADGET_ID_MOVE_DELAY_RND_TEXT,
491 GADGET_ID_MOVE_DELAY_RND_UP,
492 GADGET_ID_STEP_DELAY_FIX_DOWN,
493 GADGET_ID_STEP_DELAY_FIX_TEXT,
494 GADGET_ID_STEP_DELAY_FIX_UP,
495 GADGET_ID_STEP_DELAY_RND_DOWN,
496 GADGET_ID_STEP_DELAY_RND_TEXT,
497 GADGET_ID_STEP_DELAY_RND_UP,
498 GADGET_ID_EXPLOSION_DELAY_DOWN,
499 GADGET_ID_EXPLOSION_DELAY_TEXT,
500 GADGET_ID_EXPLOSION_DELAY_UP,
501 GADGET_ID_IGNITION_DELAY_DOWN,
502 GADGET_ID_IGNITION_DELAY_TEXT,
503 GADGET_ID_IGNITION_DELAY_UP,
504 GADGET_ID_CHANGE_DELAY_FIX_DOWN,
505 GADGET_ID_CHANGE_DELAY_FIX_TEXT,
506 GADGET_ID_CHANGE_DELAY_FIX_UP,
507 GADGET_ID_CHANGE_DELAY_RND_DOWN,
508 GADGET_ID_CHANGE_DELAY_RND_TEXT,
509 GADGET_ID_CHANGE_DELAY_RND_UP,
510 GADGET_ID_CHANGE_CONT_RND_DOWN,
511 GADGET_ID_CHANGE_CONT_RND_TEXT,
512 GADGET_ID_CHANGE_CONT_RND_UP,
513 GADGET_ID_GROUP_CONTENT_DOWN,
514 GADGET_ID_GROUP_CONTENT_TEXT,
515 GADGET_ID_GROUP_CONTENT_UP,
517 // drawing area identifiers
519 GADGET_ID_DRAWING_LEVEL,
520 GADGET_ID_YAMYAM_CONTENT_0,
521 GADGET_ID_YAMYAM_CONTENT_1,
522 GADGET_ID_YAMYAM_CONTENT_2,
523 GADGET_ID_YAMYAM_CONTENT_3,
524 GADGET_ID_YAMYAM_CONTENT_4,
525 GADGET_ID_YAMYAM_CONTENT_5,
526 GADGET_ID_YAMYAM_CONTENT_6,
527 GADGET_ID_YAMYAM_CONTENT_7,
528 GADGET_ID_MAGIC_BALL_CONTENT_0,
529 GADGET_ID_MAGIC_BALL_CONTENT_1,
530 GADGET_ID_MAGIC_BALL_CONTENT_2,
531 GADGET_ID_MAGIC_BALL_CONTENT_3,
532 GADGET_ID_MAGIC_BALL_CONTENT_4,
533 GADGET_ID_MAGIC_BALL_CONTENT_5,
534 GADGET_ID_MAGIC_BALL_CONTENT_6,
535 GADGET_ID_MAGIC_BALL_CONTENT_7,
536 GADGET_ID_ANDROID_CONTENT,
537 GADGET_ID_AMOEBA_CONTENT,
538 GADGET_ID_START_ELEMENT,
539 GADGET_ID_ARTWORK_ELEMENT,
540 GADGET_ID_EXPLOSION_ELEMENT,
541 GADGET_ID_INVENTORY_CONTENT,
542 GADGET_ID_CUSTOM_GRAPHIC,
543 GADGET_ID_CUSTOM_CONTENT,
544 GADGET_ID_CUSTOM_MOVE_ENTER,
545 GADGET_ID_CUSTOM_MOVE_LEAVE,
546 GADGET_ID_CUSTOM_CHANGE_TARGET,
547 GADGET_ID_CUSTOM_CHANGE_CONTENT,
548 GADGET_ID_CUSTOM_CHANGE_TRIGGER,
549 GADGET_ID_CUSTOM_CHANGE_ACTION,
550 GADGET_ID_GROUP_CONTENT,
551 GADGET_ID_RANDOM_BACKGROUND,
553 // text input identifiers
555 GADGET_ID_LEVEL_NAME,
556 GADGET_ID_LEVEL_AUTHOR,
557 GADGET_ID_LEVELSET_NAME,
558 GADGET_ID_LEVELSET_AUTHOR,
559 GADGET_ID_ELEMENT_NAME,
561 // text area identifiers
563 GADGET_ID_ENVELOPE_INFO,
565 // selectbox identifiers
567 GADGET_ID_TIME_OR_STEPS,
568 GADGET_ID_TIME_SCORE_BASE,
569 GADGET_ID_GAME_ENGINE_TYPE,
570 GADGET_ID_LEVELSET_SAVE_MODE,
571 GADGET_ID_WIND_DIRECTION,
572 GADGET_ID_PLAYER_SPEED,
573 GADGET_ID_CUSTOM_WALK_TO_ACTION,
574 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
575 GADGET_ID_CUSTOM_DEADLINESS,
576 GADGET_ID_CUSTOM_MOVE_PATTERN,
577 GADGET_ID_CUSTOM_MOVE_DIRECTION,
578 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
579 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
580 GADGET_ID_CUSTOM_SMASH_TARGETS,
581 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
582 GADGET_ID_CUSTOM_ACCESS_TYPE,
583 GADGET_ID_CUSTOM_ACCESS_LAYER,
584 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
585 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
586 GADGET_ID_CHANGE_TIME_UNITS,
587 GADGET_ID_CHANGE_DIRECT_ACTION,
588 GADGET_ID_CHANGE_OTHER_ACTION,
589 GADGET_ID_CHANGE_SIDE,
590 GADGET_ID_CHANGE_PLAYER,
591 GADGET_ID_CHANGE_PAGE,
592 GADGET_ID_CHANGE_REPLACE_WHEN,
593 GADGET_ID_ACTION_TYPE,
594 GADGET_ID_ACTION_MODE,
595 GADGET_ID_ACTION_ARG,
596 GADGET_ID_SELECT_CHANGE_PAGE,
597 GADGET_ID_GROUP_CHOICE_MODE,
599 // textbutton identifiers
601 GADGET_ID_LEVELINFO_LEVEL,
602 GADGET_ID_LEVELINFO_LEVELSET,
603 GADGET_ID_LEVELINFO_EDITOR,
604 GADGET_ID_PROPERTIES_INFO,
605 GADGET_ID_PROPERTIES_CONFIG,
606 GADGET_ID_PROPERTIES_CONFIG_1,
607 GADGET_ID_PROPERTIES_CONFIG_2,
608 GADGET_ID_PROPERTIES_CHANGE,
609 GADGET_ID_SAVE_AS_TEMPLATE_1,
610 GADGET_ID_SAVE_AS_TEMPLATE_2,
611 GADGET_ID_SAVE_LEVELSET,
612 GADGET_ID_ADD_CHANGE_PAGE,
613 GADGET_ID_DEL_CHANGE_PAGE,
615 // graphicbutton identifiers
617 GADGET_ID_PREV_CHANGE_PAGE,
618 GADGET_ID_NEXT_CHANGE_PAGE,
619 GADGET_ID_COPY_CHANGE_PAGE,
620 GADGET_ID_PASTE_CHANGE_PAGE,
622 // gadgets for scrolling of drawing area
625 GADGET_ID_SCROLL_DOWN,
626 GADGET_ID_SCROLL_LEFT,
627 GADGET_ID_SCROLL_RIGHT,
628 GADGET_ID_SCROLL_HORIZONTAL,
629 GADGET_ID_SCROLL_VERTICAL,
631 // gadgets for scrolling element list
633 GADGET_ID_SCROLL_LIST_UP,
634 GADGET_ID_SCROLL_LIST_DOWN,
635 GADGET_ID_SCROLL_LIST_VERTICAL,
637 // checkbuttons/radiobuttons for level/element properties
639 GADGET_ID_AUTO_COUNT_GEMS,
640 GADGET_ID_RATE_TIME_OVER_SCORE,
641 GADGET_ID_USE_LEVELSET_ARTWORK,
642 GADGET_ID_COPY_LEVEL_TEMPLATE,
643 GADGET_ID_RANDOM_PERCENTAGE,
644 GADGET_ID_RANDOM_QUANTITY,
645 GADGET_ID_RANDOM_RESTRICTED,
646 GADGET_ID_STICK_ELEMENT,
647 GADGET_ID_EM_SLIPPERY_GEMS,
648 GADGET_ID_EM_EXPLODES_BY_FIRE,
649 GADGET_ID_USE_SPRING_BUG,
650 GADGET_ID_USE_TIME_ORB_BUG,
651 GADGET_ID_USE_LIFE_BUGS,
652 GADGET_ID_RANDOM_BALL_CONTENT,
653 GADGET_ID_INITIAL_BALL_ACTIVE,
654 GADGET_ID_GROW_INTO_DIGGABLE,
655 GADGET_ID_SB_FIELDS_NEEDED,
656 GADGET_ID_SB_OBJECTS_NEEDED,
657 GADGET_ID_AUTO_EXIT_SOKOBAN,
658 GADGET_ID_SOLVED_BY_ONE_PLAYER,
659 GADGET_ID_FINISH_DIG_COLLECT,
660 GADGET_ID_CONTINUOUS_SNAPPING,
661 GADGET_ID_BLOCK_SNAP_FIELD,
662 GADGET_ID_BLOCK_LAST_FIELD,
663 GADGET_ID_SP_BLOCK_LAST_FIELD,
664 GADGET_ID_INSTANT_RELOCATION,
665 GADGET_ID_SHIFTED_RELOCATION,
666 GADGET_ID_LAZY_RELOCATION,
667 GADGET_ID_USE_START_ELEMENT,
668 GADGET_ID_USE_ARTWORK_ELEMENT,
669 GADGET_ID_USE_EXPLOSION_ELEMENT,
670 GADGET_ID_INITIAL_GRAVITY,
671 GADGET_ID_USE_INITIAL_INVENTORY,
672 GADGET_ID_CAN_PASS_TO_WALKABLE,
673 GADGET_ID_CAN_FALL_INTO_ACID,
674 GADGET_ID_CAN_MOVE_INTO_ACID,
675 GADGET_ID_DONT_COLLIDE_WITH,
676 GADGET_ID_ENVELOPE_AUTOWRAP,
677 GADGET_ID_ENVELOPE_CENTERED,
678 GADGET_ID_MM_LASER_RED,
679 GADGET_ID_MM_LASER_GREEN,
680 GADGET_ID_MM_LASER_BLUE,
681 GADGET_ID_DF_LASER_RED,
682 GADGET_ID_DF_LASER_GREEN,
683 GADGET_ID_DF_LASER_BLUE,
684 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
685 GADGET_ID_CUSTOM_CAN_EXPLODE,
686 GADGET_ID_CUSTOM_EXPLODE_FIRE,
687 GADGET_ID_CUSTOM_EXPLODE_SMASH,
688 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
689 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
690 GADGET_ID_CUSTOM_DEADLY,
691 GADGET_ID_CUSTOM_CAN_MOVE,
692 GADGET_ID_CUSTOM_CAN_FALL,
693 GADGET_ID_CUSTOM_CAN_SMASH,
694 GADGET_ID_CUSTOM_SLIPPERY,
695 GADGET_ID_CUSTOM_ACCESSIBLE,
696 GADGET_ID_CUSTOM_GRAV_REACHABLE,
697 GADGET_ID_CUSTOM_USE_LAST_VALUE,
698 GADGET_ID_CUSTOM_USE_GRAPHIC,
699 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
700 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
701 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
702 GADGET_ID_CUSTOM_CAN_CHANGE,
703 GADGET_ID_CHANGE_USE_CONTENT,
704 GADGET_ID_CHANGE_USE_EXPLOSION,
705 GADGET_ID_CHANGE_ONLY_COMPLETE,
706 GADGET_ID_CHANGE_USE_RANDOM,
707 GADGET_ID_CHANGE_HAS_ACTION,
708 GADGET_ID_CHANGE_DELAY,
709 GADGET_ID_CHANGE_BY_DIRECT_ACT,
710 GADGET_ID_CHANGE_BY_OTHER_ACT,
712 NUM_STATIC_GADGET_IDS
715 // gadgets for buttons in element list (dynamic)
716 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
717 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
718 ED_NUM_ELEMENTLIST_BUTTONS - 1)
720 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
722 // radio button numbers
726 RADIO_NR_DRAWING_TOOLBOX,
727 RADIO_NR_RANDOM_ELEMENTS
730 // values for counter gadgets
733 ED_COUNTER_ID_SELECT_LEVEL,
734 ED_COUNTER_ID_LEVEL_XSIZE,
735 ED_COUNTER_ID_LEVEL_YSIZE,
736 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
737 ED_COUNTER_ID_LEVEL_TIMELIMIT,
738 ED_COUNTER_ID_LEVEL_TIMESCORE,
739 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
740 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
741 ED_COUNTER_ID_LEVEL_RANDOM,
742 ED_COUNTER_ID_ELEMENT_VALUE1,
743 ED_COUNTER_ID_ELEMENT_VALUE2,
744 ED_COUNTER_ID_ELEMENT_VALUE3,
745 ED_COUNTER_ID_ELEMENT_VALUE4,
746 ED_COUNTER_ID_YAMYAM_CONTENT,
747 ED_COUNTER_ID_BALL_CONTENT,
748 ED_COUNTER_ID_ANDROID_CONTENT,
749 ED_COUNTER_ID_ENVELOPE_XSIZE,
750 ED_COUNTER_ID_ENVELOPE_YSIZE,
751 ED_COUNTER_ID_INVENTORY_SIZE,
752 ED_COUNTER_ID_CUSTOM_SCORE,
753 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
754 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
755 ED_COUNTER_ID_CUSTOM_VALUE_RND,
756 ED_COUNTER_ID_PUSH_DELAY_FIX,
757 ED_COUNTER_ID_PUSH_DELAY_RND,
758 ED_COUNTER_ID_DROP_DELAY_FIX,
759 ED_COUNTER_ID_DROP_DELAY_RND,
760 ED_COUNTER_ID_MOVE_DELAY_FIX,
761 ED_COUNTER_ID_MOVE_DELAY_RND,
762 ED_COUNTER_ID_STEP_DELAY_FIX,
763 ED_COUNTER_ID_STEP_DELAY_RND,
764 ED_COUNTER_ID_EXPLOSION_DELAY,
765 ED_COUNTER_ID_IGNITION_DELAY,
766 ED_COUNTER_ID_GROUP_CONTENT,
767 ED_COUNTER_ID_CHANGE_DELAY_FIX,
768 ED_COUNTER_ID_CHANGE_DELAY_RND,
769 ED_COUNTER_ID_CHANGE_CONT_RND,
771 ED_NUM_COUNTERBUTTONS
774 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
775 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
776 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
777 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
778 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
779 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
781 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
782 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
783 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
784 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
785 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
786 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
788 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
789 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
791 // values for scrollbutton gadgets
794 ED_SCROLLBUTTON_ID_AREA_UP,
795 ED_SCROLLBUTTON_ID_AREA_DOWN,
796 ED_SCROLLBUTTON_ID_AREA_LEFT,
797 ED_SCROLLBUTTON_ID_AREA_RIGHT,
798 ED_SCROLLBUTTON_ID_LIST_UP,
799 ED_SCROLLBUTTON_ID_LIST_DOWN,
804 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
805 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
807 // values for scrollbar gadgets
810 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
811 ED_SCROLLBAR_ID_AREA_VERTICAL,
812 ED_SCROLLBAR_ID_LIST_VERTICAL,
817 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
818 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
820 // values for text input gadgets
823 ED_TEXTINPUT_ID_LEVEL_NAME,
824 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
825 ED_TEXTINPUT_ID_LEVELSET_NAME,
826 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
827 ED_TEXTINPUT_ID_ELEMENT_NAME,
832 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
833 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
835 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
836 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
838 // values for text area gadgets
841 ED_TEXTAREA_ID_ENVELOPE_INFO,
846 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
847 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
849 // values for selectbox gadgets
852 ED_SELECTBOX_ID_TIME_OR_STEPS,
853 ED_SELECTBOX_ID_TIME_SCORE_BASE,
854 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
855 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
856 ED_SELECTBOX_ID_WIND_DIRECTION,
857 ED_SELECTBOX_ID_PLAYER_SPEED,
858 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
859 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
860 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
861 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
862 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
863 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
864 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
865 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
866 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
867 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
868 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
869 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
870 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
871 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
872 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
873 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
874 ED_SELECTBOX_ID_CHANGE_SIDE,
875 ED_SELECTBOX_ID_CHANGE_PLAYER,
876 ED_SELECTBOX_ID_CHANGE_PAGE,
877 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
878 ED_SELECTBOX_ID_ACTION_TYPE,
879 ED_SELECTBOX_ID_ACTION_MODE,
880 ED_SELECTBOX_ID_ACTION_ARG,
881 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
882 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
887 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
888 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
890 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
891 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
893 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
894 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
895 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
896 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
897 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
898 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
900 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
901 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
903 // values for textbutton gadgets
906 ED_TEXTBUTTON_ID_LEVELINFO_LEVEL,
907 ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET,
908 ED_TEXTBUTTON_ID_LEVELINFO_EDITOR,
909 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
910 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
911 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
912 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
913 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
914 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
915 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
916 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
917 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
918 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
923 #define ED_TAB_BUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
924 #define ED_TAB_BUTTON_ID_LEVELINFO_LAST ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
926 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
927 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
929 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
930 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
932 // values for graphicbutton gadgets
935 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
936 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
937 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
938 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
940 ED_NUM_GRAPHICBUTTONS
943 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
944 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
946 // values for checkbutton gadgets
949 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
950 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
951 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
952 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
953 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
954 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
955 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
956 ED_CHECKBUTTON_ID_STICK_ELEMENT,
957 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
958 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
959 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
960 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
961 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
962 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
963 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
964 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
965 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
966 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
967 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
968 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
969 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
970 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
971 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
972 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
973 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
974 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
975 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
976 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
977 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
978 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
979 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
980 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
981 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
982 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
983 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
984 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
985 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
986 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
987 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
988 ED_CHECKBUTTON_ID_MM_LASER_RED,
989 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
990 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
991 ED_CHECKBUTTON_ID_DF_LASER_RED,
992 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
993 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
994 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
995 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
996 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
997 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
998 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
999 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1000 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1001 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1002 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1003 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1004 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1005 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1006 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1007 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1008 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1009 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1010 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1011 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1012 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1013 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1014 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1015 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1016 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1017 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1018 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1023 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1024 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1026 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1027 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1029 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1030 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1032 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1033 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1034 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1035 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1036 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1037 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1039 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1040 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1042 // values for radiobutton gadgets
1045 ED_RADIOBUTTON_ID_PERCENTAGE,
1046 ED_RADIOBUTTON_ID_QUANTITY,
1051 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1052 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1054 // values for drawing area gadgets
1057 ED_DRAWING_ID_DRAWING_LEVEL,
1058 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1059 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1060 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1061 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1062 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1063 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1064 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1065 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1066 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1067 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1068 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1069 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1070 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1071 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1072 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1073 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1074 ED_DRAWING_ID_ANDROID_CONTENT,
1075 ED_DRAWING_ID_AMOEBA_CONTENT,
1076 ED_DRAWING_ID_START_ELEMENT,
1077 ED_DRAWING_ID_ARTWORK_ELEMENT,
1078 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1079 ED_DRAWING_ID_INVENTORY_CONTENT,
1080 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1081 ED_DRAWING_ID_CUSTOM_CONTENT,
1082 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1083 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1084 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1085 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1086 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1087 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1088 ED_DRAWING_ID_GROUP_CONTENT,
1089 ED_DRAWING_ID_RANDOM_BACKGROUND,
1091 ED_NUM_DRAWING_AREAS
1094 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1095 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1098 // ----------------------------------------------------------------------------
1099 // some internally used definitions
1100 // ----------------------------------------------------------------------------
1102 // values for CopyLevelToUndoBuffer()
1103 #define UNDO_IMMEDIATE 0
1104 #define UNDO_ACCUMULATE 1
1106 // values for scrollbars
1107 #define ED_SCROLL_NO 0
1108 #define ED_SCROLL_LEFT 1
1109 #define ED_SCROLL_RIGHT 2
1110 #define ED_SCROLL_UP 4
1111 #define ED_SCROLL_DOWN 8
1113 // screens in the level editor
1114 #define ED_MODE_DRAWING 0
1115 #define ED_MODE_INFO 1
1116 #define ED_MODE_PROPERTIES 2
1117 #define ED_MODE_PALETTE 3
1119 // sub-screens in the global settings section
1120 #define ED_MODE_LEVELINFO_LEVEL ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
1121 #define ED_MODE_LEVELINFO_LEVELSET ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET
1122 #define ED_MODE_LEVELINFO_EDITOR ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
1124 // sub-screens in the element properties section
1125 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1126 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1127 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1128 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1129 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1131 // how many steps can be cancelled
1132 #define NUM_UNDO_STEPS (64 + 1)
1134 // values for elements with score for certain actions
1136 #define MAX_SCORE 999
1138 // values for elements with count for collecting
1139 #define MIN_COLLECT_COUNT 0
1140 #define MAX_COLLECT_COUNT 999
1142 // values for random placement
1143 #define RANDOM_USE_PERCENTAGE 0
1144 #define RANDOM_USE_QUANTITY 1
1146 // values for level set save mode
1147 #define LEVELSET_SAVE_MODE_UPDATE 0
1148 #define LEVELSET_SAVE_MODE_CREATE 1
1150 // default value for element tile size in drawing area
1151 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1152 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1155 // ----------------------------------------------------------------------------
1156 // some internally used data structure definitions
1157 // ----------------------------------------------------------------------------
1163 struct XYTileSize *pos;
1167 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1169 // note: some additional characters are already reserved for "cheat mode"
1170 // shortcuts (":XYZ" style) -- for details, see "events.c"
1172 // ---------- toolbox control buttons ---------------------------------------
1175 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1176 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1177 "draw single items", 's'
1180 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1181 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1182 "draw connected items", 'd'
1185 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1186 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1190 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1191 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1195 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1196 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1197 "draw outline rectangles", 'r'
1200 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1201 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1202 "draw filled rectangles", 'R'
1205 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1206 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1207 "wrap (rotate) level up", 0
1210 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1211 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1212 "enter text elements", 't'
1215 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1216 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1220 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1221 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1222 "wrap (rotate) level left", 0
1225 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1226 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1227 "zoom level tile size", '+'
1230 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1231 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1232 "wrap (rotate) level right", 0
1235 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1236 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1237 "random element placement", 0
1240 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1241 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1245 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1246 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1247 "wrap (rotate) level down", 0
1250 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1251 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1252 "pick drawing element", ','
1255 // ---------- level control buttons -----------------------------------------
1258 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1259 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1260 "undo/redo last operation", 'u'
1263 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_INFO,
1264 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1265 "properties of level", 'I'
1268 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1269 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1273 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1274 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1278 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1279 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1283 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1284 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1285 "exit level editor", 'E'
1288 // ---------- CE and GE control buttons -------------------------------------
1291 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1292 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1293 "copy settings from other element", 0
1296 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1297 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1298 "copy settings to other element", 0
1301 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1302 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1303 "exchange element with other element", 0
1306 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1307 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1308 "copy settings from this element", 0
1311 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1312 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1313 "paste settings to this element", 0
1316 // ---------- palette control buttons ---------------------------------------
1319 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1320 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1321 "properties of drawing element", 'p'
1324 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1325 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1326 "properties of drawing element 1", '1'
1329 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1330 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1331 "properties of drawing element 2", '2'
1334 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1335 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1336 "properties of drawing element 3", '3'
1339 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1340 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1341 "show list of elements", 'e'
1345 static int random_placement_value = 10;
1346 static int random_placement_method = RANDOM_USE_QUANTITY;
1347 static int random_placement_background_element = EL_SAND;
1348 static boolean random_placement_background_restricted = FALSE;
1349 static boolean stick_element_properties_window = FALSE;
1350 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1351 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1352 static struct ElementChangeInfo custom_element_change;
1353 static struct ElementGroupInfo group_element_info;
1354 static struct ElementInfo custom_element;
1356 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1357 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1358 static int levelset_num_levels = 100;
1359 static boolean levelset_use_levelset_artwork = FALSE;
1360 static boolean levelset_copy_level_template = FALSE;
1361 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1366 int min_value, max_value;
1367 int gadget_id_down, gadget_id_up;
1369 int gadget_id_align;
1371 char *text_above, *text_left, *text_right;
1372 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1374 // ---------- current level number ------------------------------------------
1377 -1, -1, // these values are not constant, but can change at runtime
1379 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1380 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1385 // ---------- level and editor settings -------------------------------------
1388 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1389 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1390 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1391 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1393 "playfield size:", NULL, "width",
1396 -1, ED_LEVEL_SETTINGS_YPOS(4),
1397 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1398 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1399 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1401 NULL, " ", "height",
1404 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1406 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1407 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1409 NULL, "number of gems to collect:", NULL
1412 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1414 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1415 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1417 "time or step limit to solve level:", NULL, NULL
1420 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1422 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1423 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1424 &level.score[SC_TIME_BONUS],
1425 "score for time or steps left:", NULL, NULL
1428 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1430 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1431 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1433 NULL, "random seed:", "(0 => random)"
1436 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1438 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1439 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1440 &levelset_num_levels,
1441 "number of levels:", NULL, NULL,
1444 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1446 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1447 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1448 &random_placement_value,
1449 "random element placement:", NULL, "in"
1452 // ---------- element settings: configure (various elements) ----------------
1455 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1456 MIN_SCORE, MAX_SCORE,
1457 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1458 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1459 NULL, // will be set when used
1463 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1464 MIN_SCORE, MAX_SCORE,
1465 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1466 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1467 NULL, // will be set when used
1471 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1472 MIN_SCORE, MAX_SCORE,
1473 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1474 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1475 NULL, // will be set when used
1479 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1480 MIN_SCORE, MAX_SCORE,
1481 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1482 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1483 NULL, // will be set when used
1487 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1488 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1489 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1490 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1491 &level.num_yamyam_contents,
1492 NULL, NULL, "number of content areas"
1495 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1496 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1497 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1498 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1499 &level.num_ball_contents,
1500 NULL, NULL, "number of content areas"
1503 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1504 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1505 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1506 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1507 &level.num_android_clone_elements,
1508 NULL, NULL, "number of clonable elements"
1511 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1512 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1513 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1514 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1515 NULL, // will be set when used
1516 NULL, NULL, "width",
1519 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1520 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1521 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1522 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1523 NULL, // will be set when used
1524 NULL, " ", "height",
1527 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1528 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1529 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1530 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1531 &level.initial_inventory_size[0],
1532 NULL, NULL, "number of inventory elements"
1535 // ---------- element settings: configure 1 (custom elements) ---------------
1538 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1539 MIN_SCORE, MAX_SCORE,
1540 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1541 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1542 &custom_element.collect_score_initial,
1543 NULL, "CE score", " "
1546 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1547 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1548 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1549 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1550 &custom_element.collect_count_initial,
1551 NULL, "CE count", NULL
1554 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1556 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1557 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1558 &custom_element.ce_value_fixed_initial,
1559 NULL, "CE value", NULL
1562 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1564 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1565 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1566 &custom_element.ce_value_random_initial,
1567 NULL, "+random", NULL
1570 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1572 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1573 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1574 &custom_element.push_delay_fixed,
1575 NULL, "push delay", NULL
1578 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1580 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1581 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1582 &custom_element.push_delay_random,
1583 NULL, "+random", NULL
1586 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1588 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1589 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1590 &custom_element.drop_delay_fixed,
1591 NULL, "drop delay", NULL
1594 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1596 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1597 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1598 &custom_element.drop_delay_random,
1599 NULL, "+random", NULL
1602 // ---------- element settings: configure 2 (custom elements) ---------------
1605 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1607 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1608 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1609 &custom_element.move_delay_fixed,
1610 NULL, "move delay", NULL
1613 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1615 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1616 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1617 &custom_element.move_delay_random,
1618 NULL, "+random", NULL
1621 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1623 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1624 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1625 &custom_element.step_delay_fixed,
1626 NULL, "step delay", NULL
1629 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1631 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1632 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1633 &custom_element.step_delay_random,
1634 NULL, "+random", NULL
1637 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1639 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1640 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1641 &custom_element.explosion_delay,
1642 NULL, "explosion delay", NULL
1645 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1647 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1648 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1649 &custom_element.ignition_delay,
1650 NULL, "ignition delay", "(by fire)"
1653 // ---------- element settings: configure (group elements) ------------------
1656 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1657 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1658 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1659 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1660 &group_element_info.num_elements,
1661 NULL, NULL, "number of elements in group"
1664 // ---------- element settings: advanced (custom elements) ------------------
1667 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1669 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1670 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1671 &custom_element_change.delay_fixed,
1672 NULL, "CE delay", NULL,
1675 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1677 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1678 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1679 &custom_element_change.delay_random,
1680 NULL, "+random", NULL
1683 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1685 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1686 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1687 &custom_element_change.random_percentage,
1688 NULL, "use random replace:", "%"
1698 char *text_above, *infotext;
1699 } textinput_info[ED_NUM_TEXTINPUT] =
1702 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1703 GADGET_ID_LEVEL_NAME,
1706 "Title:", "Title for this level"
1709 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1710 GADGET_ID_LEVEL_AUTHOR,
1711 MAX_LEVEL_AUTHOR_LEN,
1713 "Author:", "Author for this level"
1716 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1717 GADGET_ID_LEVELSET_NAME,
1720 "Title:", "Title for this or new level set"
1723 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1724 GADGET_ID_LEVELSET_AUTHOR,
1725 MAX_LEVEL_AUTHOR_LEN,
1727 "Author:", "Author for this or new level set"
1730 -1, -1, // these values are not constant, but can change at runtime
1731 GADGET_ID_ELEMENT_NAME,
1732 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1733 custom_element.description,
1734 NULL, "Element name"
1744 char *text_above, *infotext;
1745 } textarea_info[ED_NUM_TEXTAREAS] =
1748 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1749 GADGET_ID_ENVELOPE_INFO,
1750 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1752 "Envelope Content:", "Envelope Content"
1756 static struct ValueTextInfo options_time_or_steps[] =
1764 static struct ValueTextInfo options_time_score_base[] =
1766 { 1, "per second/step" },
1767 { 10, "per 10 seconds/steps" },
1772 static struct ValueTextInfo options_game_engine_type[] =
1774 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1775 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1776 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1777 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1782 static struct ValueTextInfo options_levelset_save_mode[] =
1784 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1785 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1790 static struct ValueTextInfo options_wind_direction[] =
1792 { MV_START_NONE, "none" },
1793 { MV_START_LEFT, "left" },
1794 { MV_START_RIGHT, "right" },
1795 { MV_START_UP, "up" },
1796 { MV_START_DOWN, "down" },
1801 static struct ValueTextInfo options_player_speed[] =
1808 { 16, "very fast" },
1809 { 32, "ultrafast" },
1814 static struct ValueTextInfo options_access_type[] =
1816 { EP_WALKABLE, "walkable" },
1817 { EP_PASSABLE, "passable" },
1822 static struct ValueTextInfo options_access_layer[] =
1824 { EP_ACCESSIBLE_OVER, "over" },
1825 { EP_ACCESSIBLE_INSIDE, "inside" },
1826 { EP_ACCESSIBLE_UNDER, "under" },
1831 static struct ValueTextInfo options_access_protected[] =
1833 { 0, "unprotected" },
1839 static struct ValueTextInfo options_access_direction[] =
1841 { MV_NO_DIRECTION, "no direction" },
1842 { MV_LEFT, "left" },
1843 { MV_RIGHT, "right" },
1845 { MV_DOWN, "down" },
1846 { MV_LEFT | MV_UP, "left + up" },
1847 { MV_LEFT | MV_DOWN, "left + down" },
1848 { MV_RIGHT | MV_UP, "right + up" },
1849 { MV_RIGHT | MV_DOWN, "right + down" },
1850 { MV_HORIZONTAL, "horizontal" },
1851 { MV_VERTICAL, "vertical" },
1852 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1853 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1854 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1855 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1856 { MV_ALL_DIRECTIONS, "all directions" },
1861 static struct ValueTextInfo options_walk_to_action[] =
1863 { EP_DIGGABLE, "diggable" },
1864 { EP_COLLECTIBLE_ONLY, "collectible" },
1865 { EP_DROPPABLE, "collectible & droppable" },
1866 { EP_THROWABLE, "collectible & throwable" },
1867 { EP_PUSHABLE, "pushable" },
1872 static struct ValueTextInfo options_move_pattern[] =
1874 { MV_LEFT, "left" },
1875 { MV_RIGHT, "right" },
1877 { MV_DOWN, "down" },
1878 { MV_HORIZONTAL, "horizontal" },
1879 { MV_VERTICAL, "vertical" },
1880 { MV_ALL_DIRECTIONS, "all directions" },
1881 { MV_WIND_DIRECTION, "wind direction" },
1882 { MV_TOWARDS_PLAYER, "towards player" },
1883 { MV_AWAY_FROM_PLAYER, "away from player" },
1884 { MV_ALONG_LEFT_SIDE, "along left side" },
1885 { MV_ALONG_RIGHT_SIDE, "along right side" },
1886 { MV_TURNING_LEFT, "turning left" },
1887 { MV_TURNING_RIGHT, "turning right" },
1888 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1889 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1890 { MV_TURNING_RANDOM, "turning random" },
1891 { MV_MAZE_RUNNER, "maze runner style" },
1892 { MV_MAZE_HUNTER, "maze hunter style" },
1893 { MV_WHEN_PUSHED, "when pushed" },
1894 { MV_WHEN_DROPPED, "when dropped/thrown" },
1899 static struct ValueTextInfo options_move_direction[] =
1901 { MV_START_AUTOMATIC, "automatic" },
1902 { MV_START_LEFT, "left" },
1903 { MV_START_RIGHT, "right" },
1904 { MV_START_UP, "up" },
1905 { MV_START_DOWN, "down" },
1906 { MV_START_RANDOM, "random" },
1907 { MV_START_PREVIOUS, "previous" },
1912 static struct ValueTextInfo options_move_stepsize[] =
1914 { 0, "not moving" },
1919 { 16, "very fast" },
1920 { 32, "even faster" },
1925 static struct ValueTextInfo options_move_leave_type[] =
1927 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1928 { LEAVE_TYPE_LIMITED, "change it to" },
1933 static struct ValueTextInfo options_smash_targets[] =
1935 { EP_CAN_SMASH_PLAYER, "player" },
1937 { EP_CAN_SMASH_ENEMIES, "enemies" },
1939 { EP_CAN_SMASH_EVERYTHING, "everything" },
1944 static struct ValueTextInfo options_slippery_type[] =
1946 { SLIPPERY_ANY_RANDOM, "random" },
1947 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1948 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1949 { SLIPPERY_ONLY_LEFT, "only left" },
1950 { SLIPPERY_ONLY_RIGHT, "only right" },
1955 static struct ValueTextInfo options_deadliness[] =
1957 { EP_DONT_RUN_INTO, "running into" },
1958 { EP_DONT_COLLIDE_WITH, "colliding with" },
1959 { EP_DONT_GET_HIT_BY, "getting hit by" },
1960 { EP_DONT_TOUCH, "touching" },
1965 static struct ValueTextInfo options_explosion_type[] =
1967 { EXPLODES_3X3, "3x3" },
1968 { EXPLODES_CROSS, "3+3" },
1969 { EXPLODES_1X1, "1x1" },
1974 static struct ValueTextInfo options_time_units[] =
1977 { FRAMES_PER_SECOND, "seconds" },
1982 static struct ValueTextInfo options_change_direct_action[] =
1984 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1985 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1986 { CE_SWITCHED_BY_PLAYER, "switched by player" },
1987 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
1988 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1989 { CE_ENTERED_BY_PLAYER, "entered by player" },
1990 { CE_LEFT_BY_PLAYER, "left by player" },
1991 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1992 { CE_SWITCHED, "switched" },
1993 { CE_HITTING_SOMETHING, "hitting something" },
1994 { CE_HIT_BY_SOMETHING, "hit by something" },
1996 { CE_BLOCKED, "blocked" },
1998 { CE_IMPACT, "impact (on something)" },
1999 { CE_SMASHED, "smashed (from above)" },
2001 { CE_VALUE_CHANGES, "CE value changes" },
2002 { CE_SCORE_CHANGES, "CE score changes" },
2004 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2005 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2006 { CE_UNDEFINED, " " },
2007 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2008 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2009 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2014 static struct ValueTextInfo options_change_other_action[] =
2016 { CE_PLAYER_TOUCHES_X, "player touches" },
2017 { CE_PLAYER_PRESSES_X, "player presses" },
2018 { CE_PLAYER_SWITCHES_X, "player switches" },
2019 { CE_PLAYER_SNAPS_X, "player snaps" },
2020 { CE_PLAYER_PUSHES_X, "player pushes" },
2021 { CE_PLAYER_ENTERS_X, "player enters" },
2022 { CE_PLAYER_LEAVES_X, "player leaves" },
2023 { CE_PLAYER_DIGS_X, "player digs" },
2024 { CE_PLAYER_COLLECTS_X, "player collects" },
2025 { CE_PLAYER_DROPS_X, "player drops/throws" },
2026 { CE_TOUCHING_X, "touching" },
2027 { CE_HITTING_X, "hitting" },
2028 { CE_DIGGING_X, "digging" },
2029 { CE_HIT_BY_X, "hit by" },
2030 { CE_SWITCH_OF_X, "switch of" },
2031 { CE_CHANGE_OF_X, "change by page of" },
2032 { CE_EXPLOSION_OF_X, "explosion of" },
2033 { CE_MOVE_OF_X, "move of" },
2034 { CE_CREATION_OF_X, "creation of" },
2035 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2036 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2037 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2038 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2039 { CE_UNDEFINED, " " },
2040 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2041 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2042 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2047 static struct ValueTextInfo options_change_trigger_side[] =
2049 { CH_SIDE_LEFT, "left" },
2050 { CH_SIDE_RIGHT, "right" },
2051 { CH_SIDE_TOP, "top" },
2052 { CH_SIDE_BOTTOM, "bottom" },
2053 { CH_SIDE_LEFT_RIGHT, "left/right" },
2054 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2055 { CH_SIDE_ANY, "any" },
2060 static struct ValueTextInfo options_change_trigger_player[] =
2062 { CH_PLAYER_1, "1" },
2063 { CH_PLAYER_2, "2" },
2064 { CH_PLAYER_3, "3" },
2065 { CH_PLAYER_4, "4" },
2066 { CH_PLAYER_ANY, "any" },
2071 static struct ValueTextInfo options_change_trigger_page[] =
2083 { (1 << 10), "11" },
2084 { (1 << 11), "12" },
2085 { (1 << 12), "13" },
2086 { (1 << 13), "14" },
2087 { (1 << 14), "15" },
2088 { (1 << 15), "16" },
2089 { (1 << 16), "17" },
2090 { (1 << 17), "18" },
2091 { (1 << 18), "19" },
2092 { (1 << 19), "20" },
2093 { (1 << 20), "21" },
2094 { (1 << 21), "22" },
2095 { (1 << 22), "23" },
2096 { (1 << 23), "24" },
2097 { (1 << 24), "25" },
2098 { (1 << 25), "26" },
2099 { (1 << 26), "27" },
2100 { (1 << 27), "28" },
2101 { (1 << 28), "29" },
2102 { (1 << 29), "30" },
2103 { (1 << 30), "31" },
2104 { (1 << 31), "32" },
2105 { CH_PAGE_ANY, "any" },
2110 static struct ValueTextInfo options_change_replace_when[] =
2112 { CP_WHEN_EMPTY, "empty" },
2113 { CP_WHEN_WALKABLE, "walkable" },
2114 { CP_WHEN_DIGGABLE, "diggable" },
2115 { CP_WHEN_COLLECTIBLE, "collectible" },
2116 { CP_WHEN_REMOVABLE, "removable" },
2117 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2122 static struct ValueTextInfo options_action_type[] =
2124 { CA_NO_ACTION, "no action" },
2125 { CA_UNDEFINED, " " },
2126 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2127 { CA_RESTART_LEVEL, "restart level" },
2128 { CA_SHOW_ENVELOPE, "show envelope" },
2129 { CA_SET_LEVEL_TIME, "set time" },
2130 { CA_SET_LEVEL_SCORE, "set score" },
2131 { CA_SET_LEVEL_GEMS, "set gems" },
2132 { CA_SET_LEVEL_WIND, "set wind dir." },
2133 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2134 { CA_UNDEFINED, " " },
2135 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2136 { CA_MOVE_PLAYER, "move player" },
2137 { CA_MOVE_PLAYER_NEW, "move player new" },
2138 { CA_EXIT_PLAYER, "exit player" },
2139 { CA_KILL_PLAYER, "kill player" },
2140 { CA_SET_PLAYER_KEYS, "set keys" },
2141 { CA_SET_PLAYER_SPEED, "set speed" },
2142 { CA_SET_PLAYER_SHIELD, "set shield" },
2143 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2144 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2145 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2146 { CA_UNDEFINED, " " },
2147 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2148 { CA_SET_CE_VALUE, "set CE value" },
2149 { CA_SET_CE_SCORE, "set CE score" },
2150 { CA_SET_CE_ARTWORK, "set CE artwork" },
2151 { CA_UNDEFINED, " " },
2152 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2153 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2158 static struct ValueTextInfo options_action_mode_none[] =
2160 { CA_MODE_UNDEFINED, " " },
2165 static struct ValueTextInfo options_action_mode_assign[] =
2167 { CA_MODE_SET, "=" },
2172 static struct ValueTextInfo options_action_mode_add_remove[] =
2174 { CA_MODE_ADD, "+" },
2175 { CA_MODE_SUBTRACT, "-" },
2180 static struct ValueTextInfo options_action_mode_calculate[] =
2182 { CA_MODE_SET, "=" },
2183 { CA_MODE_ADD, "+" },
2184 { CA_MODE_SUBTRACT, "-" },
2185 { CA_MODE_MULTIPLY, "*" },
2186 { CA_MODE_DIVIDE, "/" },
2187 { CA_MODE_MODULO, "%" },
2192 static struct ValueTextInfo options_action_arg_none[] =
2194 { CA_ARG_UNDEFINED, " " },
2199 static struct ValueTextInfo options_action_arg_player[] =
2201 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2202 { CA_ARG_PLAYER_1, "1" },
2203 { CA_ARG_PLAYER_2, "2" },
2204 { CA_ARG_PLAYER_3, "3" },
2205 { CA_ARG_PLAYER_4, "4" },
2206 { CA_ARG_PLAYER_ANY, "any" },
2207 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2208 { CA_ARG_PLAYER_ACTION, "action ->" },
2213 static struct ValueTextInfo options_action_arg_number[] =
2215 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2222 { CA_ARG_10, "10" },
2223 { CA_ARG_100, "100" },
2224 { CA_ARG_1000, "1000" },
2225 { CA_ARG_UNDEFINED, " " },
2226 { CA_ARG_NUMBER_MIN, "min" },
2227 { CA_ARG_NUMBER_MAX, "max" },
2228 { CA_ARG_UNDEFINED, " " },
2229 { CA_ARG_NUMBER_RESET, "reset" },
2230 { CA_ARG_UNDEFINED, " " },
2231 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2232 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2233 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2234 { CA_ARG_UNDEFINED, " " },
2235 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2236 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2237 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2238 { CA_ARG_UNDEFINED, " " },
2239 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2240 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2241 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2242 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2243 { CA_ARG_UNDEFINED, " " },
2244 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2245 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2246 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2247 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2252 static struct ValueTextInfo options_action_arg_value[] =
2254 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2261 { CA_ARG_10, "10" },
2262 { CA_ARG_100, "100" },
2263 { CA_ARG_1000, "1000" },
2264 { CA_ARG_UNDEFINED, " " },
2265 { CA_ARG_NUMBER_MIN, "min" },
2266 { CA_ARG_NUMBER_MAX, "max" },
2267 { CA_ARG_UNDEFINED, " " },
2268 { CA_ARG_NUMBER_RESET, "reset" },
2269 { CA_ARG_UNDEFINED, " " },
2270 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2271 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2272 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2273 { CA_ARG_UNDEFINED, " " },
2274 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2275 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2276 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2277 { CA_ARG_UNDEFINED, " " },
2278 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2279 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2280 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2281 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2282 { CA_ARG_UNDEFINED, " " },
2283 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2284 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2285 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2286 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2287 { CA_ARG_UNDEFINED, " " },
2288 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2289 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2290 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2291 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2296 static struct ValueTextInfo options_action_arg_envelope[] =
2298 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2303 { CA_ARG_UNDEFINED, " " },
2304 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2305 { CA_ARG_ELEMENT_TARGET, "target" },
2306 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2307 { CA_ARG_ELEMENT_ACTION, "action ->" },
2312 static struct ValueTextInfo options_action_arg_key[] =
2314 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2323 { CA_ARG_UNDEFINED, " " },
2324 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2325 { CA_ARG_ELEMENT_TARGET, "target" },
2326 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2327 { CA_ARG_ELEMENT_ACTION, "action ->" },
2332 static struct ValueTextInfo options_action_arg_speed[] =
2334 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2335 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2336 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2337 { CA_ARG_SPEED_SLOW, "slow" },
2338 { CA_ARG_SPEED_NORMAL, "normal" },
2339 { CA_ARG_SPEED_FAST, "fast" },
2340 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2341 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2342 { CA_ARG_UNDEFINED, " " },
2343 { CA_ARG_SPEED_SLOWER, "slower" },
2344 { CA_ARG_SPEED_FASTER, "faster" },
2345 { CA_ARG_UNDEFINED, " " },
2346 { CA_ARG_SPEED_RESET, "reset" },
2351 static struct ValueTextInfo options_action_arg_shield[] =
2353 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2354 { CA_ARG_SHIELD_OFF, "off" },
2355 { CA_ARG_SHIELD_NORMAL, "normal" },
2356 { CA_ARG_SHIELD_DEADLY, "deadly" },
2361 static struct ValueTextInfo options_action_arg_artwork[] =
2363 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2364 { CA_ARG_ELEMENT_TARGET, "target" },
2365 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2366 { CA_ARG_ELEMENT_ACTION, "action ->" },
2367 { CA_ARG_UNDEFINED, " " },
2368 { CA_ARG_ELEMENT_RESET, "reset" },
2373 static struct ValueTextInfo options_action_arg_gravity[] =
2375 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2376 { CA_ARG_GRAVITY_ON, "on" },
2377 { CA_ARG_GRAVITY_OFF, "off" },
2378 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2383 static struct ValueTextInfo options_action_arg_direction[] =
2385 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2386 { CA_ARG_DIRECTION_NONE, "none" },
2387 { CA_ARG_DIRECTION_LEFT, "left" },
2388 { CA_ARG_DIRECTION_RIGHT, "right" },
2389 { CA_ARG_DIRECTION_UP, "up" },
2390 { CA_ARG_DIRECTION_DOWN, "down" },
2391 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2392 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2397 static struct ValueTextInfo options_action_arg_scan_mode[] =
2399 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2400 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2401 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2406 static struct ValueTextInfo options_action_arg_inventory[] =
2408 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2409 { CA_ARG_ELEMENT_TARGET, "+ target" },
2410 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2411 { CA_ARG_ELEMENT_ACTION, "+ action" },
2412 { CA_ARG_UNDEFINED, " " },
2413 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2414 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2415 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2416 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2417 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2418 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2419 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2420 { CA_ARG_UNDEFINED, " " },
2421 { CA_ARG_INVENTORY_RESET, "reset" },
2426 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2427 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2432 static struct ValueTextInfo options_group_choice_mode[] =
2434 { ANIM_RANDOM, "random" },
2435 { ANIM_LOOP, "loop" },
2436 { ANIM_LINEAR, "linear" },
2437 { ANIM_PINGPONG, "pingpong" },
2438 { ANIM_PINGPONG2, "pingpong 2" },
2443 static struct ValueTextInfo *action_arg_modes[] =
2445 options_action_mode_none,
2446 options_action_mode_assign,
2447 options_action_mode_add_remove,
2448 options_action_mode_calculate,
2455 struct ValueTextInfo *options;
2457 action_arg_options[] =
2459 { CA_NO_ACTION, 0, options_action_arg_none, },
2460 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2461 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2462 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2463 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2464 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2465 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2466 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2467 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2468 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2469 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2470 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2471 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2472 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2473 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2474 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2475 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2476 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2477 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2478 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2479 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2480 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2489 int gadget_id_align;
2490 int size; // char size of selectbox or '-1' (dynamically determined)
2491 struct ValueTextInfo *options;
2493 char *text_above, *text_left, *text_right, *infotext;
2494 } selectbox_info[ED_NUM_SELECTBOX] =
2496 // ---------- level and editor settings -------------------------------------
2499 -1, ED_LEVEL_SETTINGS_YPOS(8),
2500 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2502 options_time_or_steps,
2503 &level.use_step_counter,
2504 NULL, NULL, "(0 => no limit)", "time or step limit"
2507 -1, ED_LEVEL_SETTINGS_YPOS(10),
2508 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2510 options_time_score_base,
2511 &level.time_score_base,
2512 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2515 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2516 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2518 options_game_engine_type,
2519 &level.game_engine_type,
2520 NULL, "game engine:", NULL, "game engine"
2523 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2524 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2526 options_levelset_save_mode,
2527 &levelset_save_mode,
2528 "Action:", NULL, NULL, "action when saving level set"
2531 // ---------- element settings: configure (several elements) ----------------
2534 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2535 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2537 options_wind_direction,
2538 &level.wind_direction_initial,
2539 NULL, "initial wind direction:", NULL, "initial wind direction"
2542 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2543 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2545 options_player_speed,
2546 &level.initial_player_stepsize[0],
2547 NULL, "initial player speed:", NULL, "initial player speed"
2550 // ---------- element settings: configure 1 (custom elements) ---------------
2553 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2554 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2556 options_access_type,
2557 &custom_element.access_type,
2558 NULL, NULL, NULL, "type of access to this field"
2561 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2562 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2564 options_access_layer,
2565 &custom_element.access_layer,
2566 NULL, NULL, NULL, "layer of access for this field"
2569 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2570 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2572 options_access_protected,
2573 &custom_element.access_protected,
2574 NULL, NULL, NULL, "protected access for this field"
2577 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2578 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2580 options_access_direction,
2581 &custom_element.access_direction,
2582 NULL, "from", NULL, "access direction for this field"
2585 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2586 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2588 options_walk_to_action,
2589 &custom_element.walk_to_action,
2590 NULL, NULL, NULL, "diggable/collectible/pushable"
2593 // ---------- element settings: configure 2 (custom elements) ---------------
2596 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2597 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2599 options_move_pattern,
2600 &custom_element.move_pattern,
2601 NULL, "can move", NULL, "element move pattern"
2604 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2605 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2607 options_move_direction,
2608 &custom_element.move_direction_initial,
2609 NULL, "starts moving", NULL, "initial element move direction"
2612 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2613 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2615 options_move_stepsize,
2616 &custom_element.move_stepsize,
2617 NULL, "move/fall speed", NULL, "speed of element movement"
2620 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2621 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2623 options_move_leave_type,
2624 &custom_element.move_leave_type,
2625 // left text with leading spaces to place gadget next to "can dig" gadget
2626 // (needed because drawing area gadgets created after selectbox gadgets)
2627 // NULL, "can dig: can", ":", "leave behind or change element"
2628 NULL, " can", ":", "leave behind or change element"
2631 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2632 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2634 options_smash_targets,
2635 &custom_element.smash_targets,
2636 NULL, "can smash", NULL, "elements that can be smashed"
2639 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2640 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2642 options_slippery_type,
2643 &custom_element.slippery_type,
2644 NULL, "slippery", NULL, "where other elements fall down"
2647 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2648 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2651 &custom_element.deadliness,
2652 NULL, "deadly when", NULL, "deadliness of element"
2655 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2656 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2658 options_explosion_type,
2659 &custom_element.explosion_type,
2660 NULL, "can explode", NULL, "explosion type"
2663 // ---------- element settings: advanced (custom elements) ------------------
2666 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2667 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2670 &custom_element_change.delay_frames,
2671 NULL, "delay time given in", NULL, "delay time units for change"
2674 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2675 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2677 options_change_direct_action,
2678 &custom_element_change.direct_action,
2679 NULL, NULL, NULL, "type of direct action"
2682 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2683 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2685 options_change_other_action,
2686 &custom_element_change.other_action,
2687 NULL, NULL, "element:", "type of other element action"
2690 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2691 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2693 options_change_trigger_side,
2694 &custom_element_change.trigger_side,
2695 NULL, "at", "side", "element side triggering change"
2698 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2699 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2701 options_change_trigger_player,
2702 &custom_element_change.trigger_player,
2703 NULL, "player:", " ", "player that causes change"
2706 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2707 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2709 options_change_trigger_page,
2710 &custom_element_change.trigger_page,
2711 NULL, "page:", NULL, "change page that causes change"
2714 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2715 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2717 options_change_replace_when,
2718 &custom_element_change.replace_when,
2719 NULL, "replace when", NULL, "which elements can be replaced"
2722 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2723 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2725 options_action_type,
2726 &custom_element_change.action_type,
2727 NULL, NULL, NULL, "action on specified condition"
2730 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2731 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2733 options_action_mode_none,
2734 &custom_element_change.action_mode,
2735 NULL, NULL, NULL, "action operator"
2738 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2739 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2741 options_action_arg_none,
2742 &custom_element_change.action_arg,
2743 NULL, NULL, NULL, "action parameter"
2746 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2747 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2749 options_change_page,
2750 &custom_element.current_change_page,
2751 NULL, NULL, NULL, "element change page"
2754 // ---------- element settings: configure (group elements) ------------------
2757 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2758 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2760 options_group_choice_mode,
2761 &group_element_info.choice_mode,
2762 NULL, "choice type:", NULL, "type of group element choice"
2770 int gadget_id_align;
2773 char *text_above, *text_left, *text_right, *infotext;
2774 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2776 // ---------- level and editor settings (tabs) ------------------------------
2779 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2780 GADGET_ID_LEVELINFO_LEVEL, GADGET_ID_NONE,
2782 NULL, NULL, NULL, "Configure level properties"
2786 GADGET_ID_LEVELINFO_LEVELSET, GADGET_ID_LEVELINFO_LEVEL,
2788 NULL, NULL, NULL, "Update this or create new level set"
2792 GADGET_ID_LEVELINFO_EDITOR, GADGET_ID_LEVELINFO_LEVELSET,
2794 NULL, NULL, NULL, "Configure editor properties"
2797 // ---------- element settings (tabs) ---------------------------------------
2800 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2801 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2803 NULL, NULL, NULL, "Show information about element"
2807 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2809 NULL, NULL, NULL, "Configure element properties"
2813 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2815 NULL, NULL, NULL, "Configure element properties, part 1"
2819 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2821 NULL, NULL, NULL, "Configure element properties, part 2"
2825 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2827 NULL, NULL, NULL, "Configure custom element change pages"
2830 // ---------- level and editor settings (buttons) ---------------------------
2833 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2834 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
2836 NULL, NULL, NULL, "Update or create level set"
2839 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2840 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2842 NULL, NULL, "this level as level template",
2843 "Save current settings as new template"
2846 // ---------- element settings (buttons) ------------------------------------
2850 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2852 NULL, " ", "As Template",
2853 "Save current settings as new template"
2857 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2859 NULL, NULL, NULL, "Add new change page"
2863 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2865 NULL, NULL, NULL, "Delete current change page"
2874 int gadget_id_align;
2875 char *text_left, *text_right, *infotext;
2876 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2879 IMG_EDITOR_COUNTER_DOWN,
2880 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2881 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2882 NULL, NULL, "select previous change page"
2885 IMG_EDITOR_COUNTER_UP,
2886 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2887 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2888 NULL, "change page", "select next change page"
2891 IMG_GFX_EDITOR_BUTTON_CP_COPY,
2892 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2893 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2894 " ", NULL, "copy settings from this change page"
2897 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
2898 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2899 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2900 NULL, NULL, "paste settings to this change page"
2907 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2914 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2917 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2918 GADGET_ID_SCROLL_UP,
2919 "scroll level editing area up"
2922 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2923 GADGET_ID_SCROLL_DOWN,
2924 "scroll level editing area down"
2927 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2928 GADGET_ID_SCROLL_LEFT,
2929 "scroll level editing area left"
2932 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2933 GADGET_ID_SCROLL_RIGHT,
2934 "scroll level editing area right"
2937 IMG_EDITOR_PALETTE_SCROLL_UP,
2938 GADGET_ID_SCROLL_LIST_UP,
2939 "scroll element list up ('Page Up')"
2942 IMG_EDITOR_PALETTE_SCROLL_DOWN,
2943 GADGET_ID_SCROLL_LIST_DOWN,
2944 "scroll element list down ('Page Down')"
2952 int wheel_x, wheel_y;
2953 int wheel_width, wheel_height;
2954 } scrollbar_pos[ED_NUM_SCROLLBARS];
2962 } scrollbar_info[ED_NUM_SCROLLBARS] =
2965 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2966 GD_TYPE_SCROLLBAR_HORIZONTAL,
2967 GADGET_ID_SCROLL_HORIZONTAL,
2968 "scroll level editing area horizontally"
2971 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2972 GD_TYPE_SCROLLBAR_VERTICAL,
2973 GADGET_ID_SCROLL_VERTICAL,
2974 "scroll level editing area vertically"
2977 IMG_EDITOR_PALETTE_SCROLLBAR,
2978 GD_TYPE_SCROLLBAR_VERTICAL,
2979 GADGET_ID_SCROLL_LIST_VERTICAL,
2980 "scroll element list vertically"
2989 int gadget_id_align;
2990 int radio_button_nr;
2993 char *text_left, *text_right, *infotext;
2994 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
2997 -1, ED_LEVEL_SETTINGS_YPOS(0),
2998 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
2999 RADIO_NR_RANDOM_ELEMENTS,
3000 &random_placement_method, RANDOM_USE_PERCENTAGE,
3001 " ", "percentage", "use percentage for random elements"
3004 -1, ED_LEVEL_SETTINGS_YPOS(0),
3005 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3006 RADIO_NR_RANDOM_ELEMENTS,
3007 &random_placement_method, RANDOM_USE_QUANTITY,
3008 " ", "quantity", "use quantity for random elements"
3016 int gadget_id_align;
3018 char *text_above, *text_left, *text_right, *infotext;
3019 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3021 // ---------- level and editor settings -------------------------------------
3024 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3025 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3026 &level.auto_count_gems,
3028 "automatically count gems needed", "set counter to number of gems"
3031 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3032 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3033 &level.rate_time_over_score,
3035 "rate time/steps used over score", "sort high scores by playing time/steps"
3038 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3039 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3040 &levelset_use_levelset_artwork,
3042 "use current custom artwork", "use custom artwork of this level set"
3045 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3046 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3047 &levelset_copy_level_template,
3049 "copy current level template", "copy level template of this level set"
3052 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3053 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3054 &random_placement_background_restricted,
3056 "restrict random placement to:", "set random placement restriction"
3059 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3060 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3061 &setup.editor.use_template_for_new_levels,
3062 "Template for new levels and CE/GE:", NULL,
3063 "use template for new levels", "use template for level properties"
3066 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3067 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3068 &level.use_custom_template,
3070 "use template for custom elements", "use template for custom properties"
3073 // ---------- element settings: configure (various elements) ----------------
3076 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3077 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3078 &stick_element_properties_window,
3080 "stick this screen to edit content","stick this screen to edit content"
3083 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3084 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3085 &level.em_slippery_gems,
3087 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3090 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3091 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3092 &level.em_explodes_by_fire,
3094 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3097 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3098 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3099 &level.use_spring_bug,
3101 "use spring pushing bug", "use odd spring pushing behaviour"
3104 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3105 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3106 &level.use_time_orb_bug,
3108 "use time orb bug", "use odd time orb behaviour"
3111 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3112 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3113 &level.use_life_bugs,
3115 "use buggy element behaviour", "use odd (historic) element behaviour"
3118 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3119 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3122 "create single random element", "only create one element from content"
3125 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3126 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3127 &level.ball_active_initial,
3129 "magic ball initially activated", "activate magic ball after level start"
3132 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3133 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3134 &level.grow_into_diggable,
3136 "can grow into anything diggable", "grow into more than just sand"
3139 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3140 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3141 &level.sb_fields_needed,
3143 "all fields need to be filled", "require all SB fields to be solved"
3146 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3147 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3148 &level.sb_objects_needed,
3150 "all objects need to be placed", "require all SB objects to be solved"
3153 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3154 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3155 &level.auto_exit_sokoban,
3157 "exit level if all tasks solved", "automatically finish Sokoban levels"
3160 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3161 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3162 &level.solved_by_one_player,
3164 "only one player must enter exit", "level solved by first player in exit"
3167 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3168 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3169 &level.finish_dig_collect,
3171 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3174 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3175 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3176 &level.continuous_snapping,
3178 "continuous snapping", "use snapping without releasing key"
3181 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3182 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3183 &level.block_snap_field,
3185 "block snapped field when snapping", "use snapping delay to show animation"
3188 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3189 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3190 &level.block_last_field,
3192 "block last field when moving", "player blocks last field when moving"
3195 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3196 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3197 &level.sp_block_last_field,
3199 "block last field when moving", "player blocks last field when moving"
3202 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3203 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3204 &level.instant_relocation,
3206 "no scrolling when relocating", "player gets relocated without delay"
3209 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3210 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3211 &level.shifted_relocation,
3213 "no centering when relocating", "level not centered after relocation"
3216 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3217 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3218 &level.lazy_relocation,
3220 "only redraw off-screen relocation","no redraw if relocation target visible"
3223 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3224 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3225 &level.use_start_element[0],
3227 "use level start element:", "start level at this element's position"
3230 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3231 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3232 &level.use_artwork_element[0],
3234 "use artwork from element:", "use player artwork from other element"
3237 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3238 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3239 &level.use_explosion_element[0],
3241 "use explosion from element:", "use explosion properties from element"
3244 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3245 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3246 &level.initial_player_gravity[0],
3248 "use initial gravity", "set initial player gravity"
3251 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3252 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3253 &level.use_initial_inventory[0],
3255 "use initial inventory:", "use collected elements on level start"
3258 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3259 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3260 &level.can_pass_to_walkable,
3262 "can pass to walkable element", "player can pass to empty or walkable"
3265 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3266 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3267 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3269 "can fall into acid (with gravity)","player can fall into acid pool"
3272 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3273 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3274 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3276 "can move into acid", "element can move into acid pool"
3279 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3280 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3281 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3283 "deadly when colliding with", "element is deadly when hitting player"
3286 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3287 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3288 &level.envelope[0].autowrap,
3290 "auto-wrap", "automatically wrap envelope text"
3293 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3294 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3295 &level.envelope[0].centered,
3297 "centered", "automatically center envelope text"
3300 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3301 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3302 &level.mm_laser_red,
3303 "choose color components for laser:", NULL,
3304 "red", "use red color components in laser"
3307 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3308 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3309 &level.mm_laser_green,
3311 "green", "use green color components in laser"
3314 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3315 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3316 &level.mm_laser_blue,
3318 "blue", "use blue color components in laser"
3321 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3322 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3323 &level.df_laser_red,
3324 "choose color components for laser:", NULL,
3325 "red", "use red color components in laser"
3328 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3329 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3330 &level.df_laser_green,
3332 "green", "use green color components in laser"
3335 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3336 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3337 &level.df_laser_blue,
3339 "blue", "use blue color components in laser"
3342 // ---------- element settings: configure 1 (custom elements) ---------------
3345 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3346 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3347 &custom_element.use_gfx_element,
3349 "use graphic of element:", "use existing element graphic"
3352 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3353 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3354 &level.use_custom_template,
3356 "use template", "use template for custom properties"
3359 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3360 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3361 &custom_element_properties[EP_ACCESSIBLE],
3363 NULL, "player can walk to or pass this field"
3366 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3367 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3368 &custom_element_properties[EP_GRAVITY_REACHABLE],
3370 "reachable despite gravity", "player can walk/dig despite gravity"
3373 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3374 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3375 &custom_element.use_last_ce_value,
3377 "use last CE value after change", "use last CE value after change"
3380 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3381 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3382 &custom_element_properties[EP_WALK_TO_OBJECT],
3384 NULL, "player can dig/collect/push element"
3387 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3388 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3389 &custom_element_properties[EP_INDESTRUCTIBLE],
3391 "indestructible", "element is indestructible"
3394 // ---------- element settings: configure 2 (custom elements) ---------------
3397 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3398 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3399 &custom_element_properties[EP_CAN_MOVE],
3401 NULL, "element can move with some pattern"
3404 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3405 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3406 &custom_element_properties[EP_CAN_FALL],
3408 "can fall", "element can fall down"
3411 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3412 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3413 &custom_element_properties[EP_CAN_SMASH],
3415 NULL, "element can smash other elements"
3418 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3419 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3420 &custom_element_properties[EP_SLIPPERY],
3422 NULL, "other elements can fall down from it"
3425 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3426 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3427 &custom_element_properties[EP_DEADLY],
3429 NULL, "element can kill the player"
3432 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3433 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3434 &custom_element_properties[EP_CAN_EXPLODE],
3436 NULL, "element can explode"
3439 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3440 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3441 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3443 "by fire", "element can explode by fire/explosion"
3446 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3447 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3448 &custom_element_properties[EP_EXPLODES_SMASHED],
3450 "smashed", "element can explode when smashed"
3453 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3454 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3455 &custom_element_properties[EP_EXPLODES_IMPACT],
3457 "impact", "element can explode on impact"
3460 // ---------- element settings: advanced (custom elements) ------------------
3463 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3464 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3465 &custom_element_change.can_change,
3467 "element changes to:", "change element on specified condition"
3470 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3471 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3472 &custom_element_change_events[CE_DELAY],
3474 NULL, "element changes after delay"
3477 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3478 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3479 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3481 NULL, "element changes by direct action"
3484 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3485 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3486 &custom_element_change_events[CE_BY_OTHER_ACTION],
3488 NULL, "element changes by other element"
3491 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3492 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3493 &custom_element_change.explode,
3495 "explode instead of change", "element explodes instead of change"
3498 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3499 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3500 &custom_element_change.use_target_content,
3502 "use extended change target:", "element changes to more elements"
3505 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3506 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3507 &custom_element_change.only_if_complete,
3509 "replace all or nothing", "only replace when all can be changed"
3512 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3513 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3514 &custom_element_change.use_random_replace,
3516 NULL, "use percentage for random replace"
3519 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3520 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3521 &custom_element_change.has_action,
3523 NULL, "execute action on specified condition"
3530 int xoffset, yoffset;
3532 int gadget_id_align;
3534 int area_xsize, area_ysize;
3535 char *text_left, *text_right, *text_above, *text_below, *infotext;
3536 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3538 // ---------- level playfield content ---------------------------------------
3543 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3545 -1, -1, // these values are not constant, but can change at runtime
3546 NULL, NULL, NULL, NULL, NULL
3549 // ---------- yam yam content -----------------------------------------------
3552 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3553 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3554 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3555 &level.yamyam_content[0].e[0][0], 3, 3,
3556 NULL, NULL, NULL, "1", NULL
3559 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3560 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3561 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3562 &level.yamyam_content[1].e[0][0], 3, 3,
3563 NULL, NULL, NULL, "2", NULL
3566 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3567 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3568 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3569 &level.yamyam_content[2].e[0][0], 3, 3,
3570 NULL, NULL, NULL, "3", NULL
3573 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3574 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3575 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3576 &level.yamyam_content[3].e[0][0], 3, 3,
3577 NULL, NULL, NULL, "4", NULL
3580 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3581 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3582 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3583 &level.yamyam_content[4].e[0][0], 3, 3,
3584 NULL, NULL, NULL, "5", NULL
3587 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3588 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3589 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3590 &level.yamyam_content[5].e[0][0], 3, 3,
3591 NULL, NULL, NULL, "6", NULL
3594 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3595 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3596 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3597 &level.yamyam_content[6].e[0][0], 3, 3,
3598 NULL, NULL, NULL, "7", NULL
3601 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3602 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3603 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3604 &level.yamyam_content[7].e[0][0], 3, 3,
3605 NULL, NULL, NULL, "8", NULL
3608 // ---------- magic ball content --------------------------------------------
3611 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3612 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3613 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3614 &level.ball_content[0].e[0][0], 3, 3,
3615 NULL, NULL, NULL, "1", NULL
3618 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3619 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3620 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3621 &level.ball_content[1].e[0][0], 3, 3,
3622 NULL, NULL, NULL, "2", NULL
3625 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3626 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3627 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3628 &level.ball_content[2].e[0][0], 3, 3,
3629 NULL, NULL, NULL, "3", NULL
3632 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3633 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3634 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3635 &level.ball_content[3].e[0][0], 3, 3,
3636 NULL, NULL, NULL, "4", NULL
3639 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3640 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3641 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3642 &level.ball_content[4].e[0][0], 3, 3,
3643 NULL, NULL, NULL, "5", NULL
3646 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3647 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3648 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3649 &level.ball_content[5].e[0][0], 3, 3,
3650 NULL, NULL, NULL, "6", NULL
3653 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3654 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3655 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3656 &level.ball_content[6].e[0][0], 3, 3,
3657 NULL, NULL, NULL, "7", NULL
3660 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3661 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3662 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3663 &level.ball_content[7].e[0][0], 3, 3,
3664 NULL, NULL, NULL, "8", NULL
3667 // ---------- android content -----------------------------------------------
3670 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
3671 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3672 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3673 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3674 NULL, NULL, "elements:", NULL, "elements android can clone"
3677 // ---------- amoeba content ------------------------------------------------
3680 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3681 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3682 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3683 &level.amoeba_content, 1, 1,
3684 "content:", NULL, NULL, NULL, "amoeba content"
3687 // ---------- level start element -------------------------------------------
3690 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3691 0, ED_AREA_1X1_SETTINGS_YOFF,
3692 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3693 &level.start_element[0], 1, 1,
3694 NULL, NULL, NULL, NULL, "level start element"
3697 // ---------- player artwork element ----------------------------------------
3700 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3701 0, ED_AREA_1X1_SETTINGS_YOFF,
3702 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3703 &level.artwork_element[0], 1, 1,
3704 NULL, NULL, NULL, NULL, "element for player artwork"
3707 // ---------- player explosion element --------------------------------------
3710 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
3711 0, ED_AREA_1X1_SETTINGS_YOFF,
3712 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3713 &level.explosion_element[0], 1, 1,
3714 NULL, NULL, NULL, NULL, "element for player explosion"
3717 // ---------- player initial inventory --------------------------------------
3720 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3721 0, ED_AREA_1X1_SETTINGS_YOFF,
3722 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3723 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3724 NULL, NULL, NULL, NULL, "content for initial inventory"
3727 // ---------- element settings: configure 1 (custom elements) ---------------
3729 // ---------- custom graphic ------------------------------------------------
3732 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3733 0, ED_AREA_1X1_SETTINGS_YOFF,
3734 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3735 &custom_element.gfx_element_initial,1, 1,
3736 NULL, NULL, NULL, NULL, "custom graphic element"
3739 // ---------- element settings: configure 2 (custom elements) ---------------
3741 // ---------- custom content (when exploding) -------------------------------
3744 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
3745 0, ED_AREA_3X3_SETTINGS_YOFF,
3746 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
3747 &custom_element.content.e[0][0], 3, 3,
3748 "content:", NULL, NULL, NULL, NULL
3751 // ---------- custom enter and leave element (when moving) ------------------
3754 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3755 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3756 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3757 &custom_element.move_enter_element, 1, 1,
3758 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
3761 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3762 0, ED_AREA_1X1_SETTINGS_YOFF,
3763 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3764 &custom_element.move_leave_element, 1, 1,
3765 NULL, NULL, NULL, NULL, "element that will be left behind"
3768 // ---------- element settings: advanced (custom elements) ------------------
3770 // ---------- custom change target ------------------------------------------
3773 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3774 0, ED_AREA_1X1_SETTINGS_YOFF,
3775 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3776 &custom_element_change.target_element, 1, 1,
3777 NULL, "after/when:", NULL, NULL, "new target element after change"
3780 // ---------- custom change content (extended change target) ----------------
3783 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3784 0, ED_AREA_3X3_SETTINGS_YOFF,
3785 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
3786 &custom_element_change.target_content.e[0][0], 3, 3,
3787 NULL, NULL, NULL, NULL, "new extended elements after change"
3790 // ---------- custom change trigger (element causing change) ----------------
3793 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3794 0, ED_AREA_1X1_SETTINGS_YOFF,
3795 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3796 &custom_element_change.initial_trigger_element, 1, 1,
3797 NULL, NULL, NULL, NULL, "other element triggering change"
3800 // ---------- custom change action (element used for action) ----------------
3803 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3804 0, ED_AREA_1X1_SETTINGS_YOFF,
3805 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3806 &custom_element_change.action_element, 1, 1,
3807 NULL, NULL, NULL, NULL, "element used as action parameter"
3810 // ---------- group element content -----------------------------------------
3813 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3814 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3815 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3816 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3817 "content:", NULL, NULL, NULL, NULL
3820 // ---------- random background (for random painting) -----------------------
3823 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
3824 0, ED_AREA_1X1_LSETTINGS_YOFF,
3825 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3826 &random_placement_background_element, 1, 1,
3827 NULL, NULL, NULL, NULL, "random placement background"
3832 // ----------------------------------------------------------------------------
3833 // some internally used variables
3834 // ----------------------------------------------------------------------------
3836 // maximal size of level editor drawing area
3837 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3839 // actual size of level editor drawing area
3840 static int ed_fieldx, ed_fieldy;
3842 // actual position of level editor drawing area in level playfield
3843 static int level_xpos = -1, level_ypos = -1;
3845 // actual tile size used to display playfield drawing area
3846 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3847 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
3849 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3851 // drawing elements on the three mouse buttons
3852 static int new_element1 = EL_WALL;
3853 static int new_element2 = EL_EMPTY;
3854 static int new_element3 = EL_SAND;
3856 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3857 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3858 (button) == 2 ? new_element2 : \
3859 (button) == 3 ? new_element3 : EL_EMPTY)
3861 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
3863 static int use_permanent_palette = TRUE;
3865 #define PX (use_permanent_palette ? DX : SX)
3866 #define PY (use_permanent_palette ? DY : SY)
3867 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
3868 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
3870 // forward declaration for internal use
3871 static void CopyBrushToCursor(int, int);
3872 static void DeleteBrushFromCursor(void);
3873 static void ModifyEditorCounterValue(int, int);
3874 static void ModifyEditorCounterLimits(int, int, int);
3875 static void ModifyEditorSelectboxValue(int, int);
3876 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3877 static void ModifyEditorDrawingArea(int, int, int);
3878 static void ModifyEditorElementList(void);
3879 static void AdjustElementListScrollbar(void);
3880 static void RedrawDrawingElements(void);
3881 static void DrawDrawingWindowExt(boolean);
3882 static void DrawDrawingWindow(void);
3883 static void DrawLevelInfoWindow(void);
3884 static void DrawPropertiesWindow(void);
3885 static void DrawPaletteWindow(void);
3886 static void UpdateCustomElementGraphicGadgets(void);
3887 static boolean checkPropertiesConfig(int);
3888 static void SetAutomaticNumberOfGemsNeeded(void);
3889 static void ClearEditorGadgetInfoText(void);
3890 static void CopyLevelToUndoBuffer(int);
3891 static void HandleDrawingAreas(struct GadgetInfo *);
3892 static void HandleCounterButtons(struct GadgetInfo *);
3893 static void HandleTextInputGadgets(struct GadgetInfo *);
3894 static void HandleTextAreaGadgets(struct GadgetInfo *);
3895 static void HandleSelectboxGadgets(struct GadgetInfo *);
3896 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3897 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3898 static void HandleRadiobuttons(struct GadgetInfo *);
3899 static void HandleCheckbuttons(struct GadgetInfo *);
3900 static void HandleControlButtons(struct GadgetInfo *);
3901 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3902 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3903 static boolean AskToCopyAndModifyLevelTemplate(void);
3904 static boolean getDrawModeHiRes(void);
3905 static int getTabulatorBarWidth(void);
3906 static int getTabulatorBarHeight(void);
3907 static Pixel getTabulatorBarColor(void);
3909 static int num_editor_gadgets = 0; // dynamically determined
3911 static struct GadgetInfo **level_editor_gadget = NULL;
3912 static int *right_gadget_border = NULL;
3914 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3915 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3916 static boolean draw_with_brush = FALSE;
3917 static int properties_element = 0;
3919 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3920 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3921 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3922 static int undo_buffer_position = 0;
3923 static int undo_buffer_steps = 0;
3924 static int redo_buffer_steps = 0;
3926 static int edit_mode;
3927 static int edit_mode_levelinfo;
3928 static int edit_mode_properties;
3930 static int element_shift = 0;
3932 static int editor_el_players[] =
3939 static int *editor_el_players_ptr = editor_el_players;
3940 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
3942 static int editor_hl_boulderdash[] =
3944 EL_INTERNAL_CASCADE_BD_ACTIVE,
3950 static int editor_el_boulderdash[] =
3959 EL_BD_EXPANDABLE_WALL,
3967 EL_BD_BUTTERFLY_LEFT,
3969 EL_BD_BUTTERFLY_RIGHT,
3970 EL_BD_FIREFLY_RIGHT,
3973 EL_BD_BUTTERFLY_DOWN,
3977 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3978 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3979 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
3980 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
3982 static int editor_hl_emerald_mine[] =
3984 EL_INTERNAL_CASCADE_EM_ACTIVE,
3990 static int editor_el_emerald_mine[] =
4008 EL_EM_DYNAMITE_ACTIVE,
4027 EL_ACID_POOL_TOPLEFT,
4029 EL_ACID_POOL_TOPRIGHT,
4032 EL_ACID_POOL_BOTTOMLEFT,
4033 EL_ACID_POOL_BOTTOM,
4034 EL_ACID_POOL_BOTTOMRIGHT,
4052 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4053 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4054 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4055 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4057 static int editor_hl_emerald_mine_club[] =
4059 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4065 static int editor_el_emerald_mine_club[] =
4092 EL_EMC_WALL_SLIPPERY_1,
4093 EL_EMC_WALL_SLIPPERY_2,
4094 EL_EMC_WALL_SLIPPERY_3,
4095 EL_EMC_WALL_SLIPPERY_4,
4118 EL_EMC_MAGIC_BALL_SWITCH,
4125 EL_EMC_SPRING_BUMPER,
4129 EL_BALLOON_SWITCH_UP,
4130 EL_BALLOON_SWITCH_ANY,
4133 EL_BALLOON_SWITCH_LEFT,
4135 EL_BALLOON_SWITCH_RIGHT,
4139 EL_BALLOON_SWITCH_DOWN,
4140 EL_BALLOON_SWITCH_NONE,
4142 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4143 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4144 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4145 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4147 static int editor_hl_rnd[] =
4149 EL_INTERNAL_CASCADE_RND_ACTIVE,
4155 static int editor_el_rnd[] =
4158 EL_DYNAMITE_ACTIVE, // RND
4192 EL_WALL_EMERALD_YELLOW,
4193 EL_WALL_EMERALD_RED,
4194 EL_WALL_EMERALD_PURPLE,
4212 EL_DYNABOMB_INCREASE_NUMBER,
4213 EL_DYNABOMB_INCREASE_SIZE,
4214 EL_DYNABOMB_INCREASE_POWER,
4234 EL_INVISIBLE_STEELWALL,
4238 EL_EXPANDABLE_WALL_HORIZONTAL,
4239 EL_EXPANDABLE_WALL_VERTICAL,
4240 EL_EXPANDABLE_WALL_ANY,
4242 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4243 static int *editor_el_rnd_ptr = editor_el_rnd;
4244 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4245 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4247 static int editor_hl_sokoban[] =
4249 EL_INTERNAL_CASCADE_SB_ACTIVE,
4255 static int editor_el_sokoban[] =
4258 EL_SOKOBAN_FIELD_EMPTY,
4259 EL_SOKOBAN_FIELD_FULL,
4260 EL_SOKOBAN_FIELD_PLAYER,
4262 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4263 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4264 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4265 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4267 static int editor_hl_supaplex[] =
4269 EL_INTERNAL_CASCADE_SP_ACTIVE,
4275 static int editor_el_supaplex[] =
4293 EL_SP_PORT_HORIZONTAL,
4294 EL_SP_PORT_VERTICAL,
4302 EL_SP_GRAVITY_PORT_LEFT,
4303 EL_SP_GRAVITY_PORT_RIGHT,
4304 EL_SP_GRAVITY_PORT_UP,
4305 EL_SP_GRAVITY_PORT_DOWN,
4307 EL_SP_GRAVITY_ON_PORT_LEFT,
4308 EL_SP_GRAVITY_ON_PORT_RIGHT,
4309 EL_SP_GRAVITY_ON_PORT_UP,
4310 EL_SP_GRAVITY_ON_PORT_DOWN,
4312 EL_SP_GRAVITY_OFF_PORT_LEFT,
4313 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4314 EL_SP_GRAVITY_OFF_PORT_UP,
4315 EL_SP_GRAVITY_OFF_PORT_DOWN,
4317 EL_SP_HARDWARE_GRAY,
4318 EL_SP_HARDWARE_GREEN,
4319 EL_SP_HARDWARE_BLUE,
4322 EL_SP_HARDWARE_BASE_1,
4323 EL_SP_HARDWARE_BASE_2,
4324 EL_SP_HARDWARE_BASE_3,
4325 EL_SP_HARDWARE_BASE_4,
4327 EL_SP_HARDWARE_BASE_5,
4328 EL_SP_HARDWARE_BASE_6,
4329 EL_SP_HARDWARE_YELLOW,
4337 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4338 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4339 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4340 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4342 static int editor_hl_diamond_caves[] =
4344 EL_INTERNAL_CASCADE_DC_ACTIVE,
4350 static int editor_el_diamond_caves[] =
4352 EL_EM_STEEL_EXIT_CLOSED, // DC2
4353 EL_EM_STEEL_EXIT_OPEN, // DC2
4354 EL_WALL_EMERALD, // DC2
4355 EL_WALL_DIAMOND, // DC2
4362 EL_CONVEYOR_BELT_1_LEFT,
4363 EL_CONVEYOR_BELT_1_MIDDLE,
4364 EL_CONVEYOR_BELT_1_RIGHT,
4365 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4367 EL_CONVEYOR_BELT_2_LEFT,
4368 EL_CONVEYOR_BELT_2_MIDDLE,
4369 EL_CONVEYOR_BELT_2_RIGHT,
4370 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4372 EL_CONVEYOR_BELT_3_LEFT,
4373 EL_CONVEYOR_BELT_3_MIDDLE,
4374 EL_CONVEYOR_BELT_3_RIGHT,
4375 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4377 EL_CONVEYOR_BELT_4_LEFT,
4378 EL_CONVEYOR_BELT_4_MIDDLE,
4379 EL_CONVEYOR_BELT_4_RIGHT,
4380 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4382 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4383 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4384 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4385 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4387 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4388 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4389 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4390 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4395 EL_DC_TIMEGATE_SWITCH,
4397 EL_SWITCHGATE_CLOSED,
4399 EL_SWITCHGATE_SWITCH_UP,
4400 EL_SWITCHGATE_SWITCH_DOWN,
4403 EL_LIGHT_SWITCH_ACTIVE,
4404 EL_DC_SWITCHGATE_SWITCH_UP,
4405 EL_DC_SWITCHGATE_SWITCH_DOWN,
4407 EL_STEEL_EXIT_CLOSED,
4409 EL_STEELWALL_SLIPPERY,
4412 EL_QUICKSAND_FAST_EMPTY,
4413 EL_QUICKSAND_FAST_FULL,
4427 EL_SIGN_RADIOACTIVITY,
4433 EL_SIGN_ENTRY_FORBIDDEN,
4434 EL_SIGN_EMERGENCY_EXIT,
4459 EL_DC_STEELWALL_2_SINGLE,
4460 EL_DC_STEELWALL_2_TOP,
4461 EL_SIGN_EXCLAMATION,
4464 EL_DC_STEELWALL_2_LEFT,
4465 EL_DC_STEELWALL_2_MIDDLE,
4466 EL_DC_STEELWALL_2_HORIZONTAL,
4467 EL_DC_STEELWALL_2_RIGHT,
4469 EL_DC_STEELWALL_1_TOPLEFT,
4470 EL_DC_STEELWALL_2_VERTICAL,
4471 EL_DC_STEELWALL_1_TOPRIGHT,
4474 EL_DC_STEELWALL_1_VERTICAL,
4475 EL_DC_STEELWALL_2_BOTTOM,
4477 EL_DC_GATE_WHITE_GRAY,
4479 EL_DC_STEELWALL_1_BOTTOMLEFT,
4480 EL_DC_STEELWALL_1_HORIZONTAL,
4481 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4482 EL_DC_GATE_FAKE_GRAY,
4484 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4485 EL_DC_STEELWALL_1_BOTTOM,
4486 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
4487 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
4489 EL_DC_STEELWALL_1_RIGHT,
4491 EL_DC_STEELWALL_1_LEFT,
4492 EL_EXPANDABLE_STEELWALL_VERTICAL,
4494 EL_DC_STEELWALL_1_TOPRIGHT_2,
4495 EL_DC_STEELWALL_1_TOP,
4496 EL_DC_STEELWALL_1_TOPLEFT_2,
4497 EL_EXPANDABLE_STEELWALL_ANY,
4499 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
4500 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
4501 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
4502 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
4504 static int editor_hl_dx_boulderdash[] =
4506 EL_INTERNAL_CASCADE_DX_ACTIVE,
4512 static int editor_el_dx_boulderdash[] =
4516 EL_TUBE_HORIZONTAL_DOWN,
4520 EL_TUBE_VERTICAL_RIGHT,
4522 EL_TUBE_VERTICAL_LEFT,
4526 EL_TUBE_HORIZONTAL_UP,
4534 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
4535 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
4536 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
4537 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
4539 static int editor_hl_mirror_magic[] =
4541 EL_INTERNAL_CASCADE_MM_ACTIVE,
4547 static int editor_el_mirror_magic[] =
4549 EL_MM_MCDUFFIN_RIGHT,
4551 EL_MM_MCDUFFIN_LEFT,
4552 EL_MM_MCDUFFIN_DOWN,
4555 EL_MM_MIRROR_FIXED_START,
4556 EL_MM_POLARIZER_START,
4557 EL_MM_POLARIZER_CROSS_START,
4559 EL_MM_TELEPORTER_RED_START,
4560 EL_MM_TELEPORTER_YELLOW_START,
4561 EL_MM_TELEPORTER_GREEN_START,
4562 EL_MM_TELEPORTER_BLUE_START,
4575 EL_MM_LIGHTBULB_ACTIVE,
4589 EL_MM_STEEL_GRID_FIXED_1,
4590 EL_MM_STEEL_GRID_FIXED_2,
4591 EL_MM_STEEL_GRID_FIXED_3,
4592 EL_MM_STEEL_GRID_FIXED_4,
4594 EL_MM_WOODEN_GRID_FIXED_1,
4595 EL_MM_WOODEN_GRID_FIXED_2,
4596 EL_MM_WOODEN_GRID_FIXED_3,
4597 EL_MM_WOODEN_GRID_FIXED_4
4599 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
4600 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
4601 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
4602 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
4604 static int editor_hl_deflektor[] =
4606 EL_INTERNAL_CASCADE_DF_ACTIVE,
4612 static int editor_el_deflektor[] =
4619 EL_DF_RECEIVER_RIGHT,
4621 EL_DF_RECEIVER_LEFT,
4622 EL_DF_RECEIVER_DOWN,
4625 EL_DF_MIRROR_ROTATING_START,
4629 EL_DF_FIBRE_OPTIC_RED_1,
4630 EL_DF_FIBRE_OPTIC_YELLOW_1,
4631 EL_DF_FIBRE_OPTIC_GREEN_1,
4632 EL_DF_FIBRE_OPTIC_BLUE_1,
4634 EL_DF_STEEL_GRID_FIXED_START,
4635 EL_DF_STEEL_GRID_ROTATING_START,
4636 EL_DF_WOODEN_GRID_FIXED_START,
4637 EL_DF_WOODEN_GRID_ROTATING_START,
4644 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
4645 static int *editor_el_deflektor_ptr = editor_el_deflektor;
4646 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
4647 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
4649 static int editor_hl_chars[] =
4651 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
4657 static int editor_el_chars[] =
4739 EL_CHAR(CHAR_BYTE_COPYRIGHT),
4740 EL_CHAR(CHAR_BYTE_UMLAUT_A),
4741 EL_CHAR(CHAR_BYTE_UMLAUT_O),
4742 EL_CHAR(CHAR_BYTE_UMLAUT_U),
4744 EL_CHAR(CHAR_BYTE_DEGREE),
4745 EL_CHAR(CHAR_BYTE_REGISTERED),
4746 EL_CHAR(FONT_ASCII_CURSOR),
4747 EL_CHAR(FONT_ASCII_BUTTON),
4749 EL_CHAR(FONT_ASCII_UP),
4750 EL_CHAR(FONT_ASCII_DOWN),
4754 static int *editor_hl_chars_ptr = editor_hl_chars;
4755 static int *editor_el_chars_ptr = editor_el_chars;
4756 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
4757 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
4759 static int editor_hl_steel_chars[] =
4761 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
4767 static int editor_el_steel_chars[] =
4777 EL_STEEL_CHAR('\''),
4844 EL_STEEL_CHAR('\\'),
4849 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
4850 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
4851 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
4852 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
4854 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
4855 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
4856 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4857 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4859 EL_STEEL_CHAR(FONT_ASCII_UP),
4860 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4864 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4865 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4866 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
4867 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
4869 static int editor_hl_custom[] =
4871 EL_INTERNAL_CASCADE_CE_ACTIVE,
4877 static int editor_el_custom[] =
4879 EL_CUSTOM_START + 0,
4880 EL_CUSTOM_START + 1,
4881 EL_CUSTOM_START + 2,
4882 EL_CUSTOM_START + 3,
4884 EL_CUSTOM_START + 4,
4885 EL_CUSTOM_START + 5,
4886 EL_CUSTOM_START + 6,
4887 EL_CUSTOM_START + 7,
4889 EL_CUSTOM_START + 8,
4890 EL_CUSTOM_START + 9,
4891 EL_CUSTOM_START + 10,
4892 EL_CUSTOM_START + 11,
4894 EL_CUSTOM_START + 12,
4895 EL_CUSTOM_START + 13,
4896 EL_CUSTOM_START + 14,
4897 EL_CUSTOM_START + 15,
4899 EL_CUSTOM_START + 16,
4900 EL_CUSTOM_START + 17,
4901 EL_CUSTOM_START + 18,
4902 EL_CUSTOM_START + 19,
4904 EL_CUSTOM_START + 20,
4905 EL_CUSTOM_START + 21,
4906 EL_CUSTOM_START + 22,
4907 EL_CUSTOM_START + 23,
4909 EL_CUSTOM_START + 24,
4910 EL_CUSTOM_START + 25,
4911 EL_CUSTOM_START + 26,
4912 EL_CUSTOM_START + 27,
4914 EL_CUSTOM_START + 28,
4915 EL_CUSTOM_START + 29,
4916 EL_CUSTOM_START + 30,
4917 EL_CUSTOM_START + 31,
4919 EL_CUSTOM_START + 32,
4920 EL_CUSTOM_START + 33,
4921 EL_CUSTOM_START + 34,
4922 EL_CUSTOM_START + 35,
4924 EL_CUSTOM_START + 36,
4925 EL_CUSTOM_START + 37,
4926 EL_CUSTOM_START + 38,
4927 EL_CUSTOM_START + 39,
4929 EL_CUSTOM_START + 40,
4930 EL_CUSTOM_START + 41,
4931 EL_CUSTOM_START + 42,
4932 EL_CUSTOM_START + 43,
4934 EL_CUSTOM_START + 44,
4935 EL_CUSTOM_START + 45,
4936 EL_CUSTOM_START + 46,
4937 EL_CUSTOM_START + 47,
4939 EL_CUSTOM_START + 48,
4940 EL_CUSTOM_START + 49,
4941 EL_CUSTOM_START + 50,
4942 EL_CUSTOM_START + 51,
4944 EL_CUSTOM_START + 52,
4945 EL_CUSTOM_START + 53,
4946 EL_CUSTOM_START + 54,
4947 EL_CUSTOM_START + 55,
4949 EL_CUSTOM_START + 56,
4950 EL_CUSTOM_START + 57,
4951 EL_CUSTOM_START + 58,
4952 EL_CUSTOM_START + 59,
4954 EL_CUSTOM_START + 60,
4955 EL_CUSTOM_START + 61,
4956 EL_CUSTOM_START + 62,
4957 EL_CUSTOM_START + 63,
4959 EL_CUSTOM_START + 64,
4960 EL_CUSTOM_START + 65,
4961 EL_CUSTOM_START + 66,
4962 EL_CUSTOM_START + 67,
4964 EL_CUSTOM_START + 68,
4965 EL_CUSTOM_START + 69,
4966 EL_CUSTOM_START + 70,
4967 EL_CUSTOM_START + 71,
4969 EL_CUSTOM_START + 72,
4970 EL_CUSTOM_START + 73,
4971 EL_CUSTOM_START + 74,
4972 EL_CUSTOM_START + 75,
4974 EL_CUSTOM_START + 76,
4975 EL_CUSTOM_START + 77,
4976 EL_CUSTOM_START + 78,
4977 EL_CUSTOM_START + 79,
4979 EL_CUSTOM_START + 80,
4980 EL_CUSTOM_START + 81,
4981 EL_CUSTOM_START + 82,
4982 EL_CUSTOM_START + 83,
4984 EL_CUSTOM_START + 84,
4985 EL_CUSTOM_START + 85,
4986 EL_CUSTOM_START + 86,
4987 EL_CUSTOM_START + 87,
4989 EL_CUSTOM_START + 88,
4990 EL_CUSTOM_START + 89,
4991 EL_CUSTOM_START + 90,
4992 EL_CUSTOM_START + 91,
4994 EL_CUSTOM_START + 92,
4995 EL_CUSTOM_START + 93,
4996 EL_CUSTOM_START + 94,
4997 EL_CUSTOM_START + 95,
4999 EL_CUSTOM_START + 96,
5000 EL_CUSTOM_START + 97,
5001 EL_CUSTOM_START + 98,
5002 EL_CUSTOM_START + 99,
5004 EL_CUSTOM_START + 100,
5005 EL_CUSTOM_START + 101,
5006 EL_CUSTOM_START + 102,
5007 EL_CUSTOM_START + 103,
5009 EL_CUSTOM_START + 104,
5010 EL_CUSTOM_START + 105,
5011 EL_CUSTOM_START + 106,
5012 EL_CUSTOM_START + 107,
5014 EL_CUSTOM_START + 108,
5015 EL_CUSTOM_START + 109,
5016 EL_CUSTOM_START + 110,
5017 EL_CUSTOM_START + 111,
5019 EL_CUSTOM_START + 112,
5020 EL_CUSTOM_START + 113,
5021 EL_CUSTOM_START + 114,
5022 EL_CUSTOM_START + 115,
5024 EL_CUSTOM_START + 116,
5025 EL_CUSTOM_START + 117,
5026 EL_CUSTOM_START + 118,
5027 EL_CUSTOM_START + 119,
5029 EL_CUSTOM_START + 120,
5030 EL_CUSTOM_START + 121,
5031 EL_CUSTOM_START + 122,
5032 EL_CUSTOM_START + 123,
5034 EL_CUSTOM_START + 124,
5035 EL_CUSTOM_START + 125,
5036 EL_CUSTOM_START + 126,
5037 EL_CUSTOM_START + 127,
5039 EL_CUSTOM_START + 128,
5040 EL_CUSTOM_START + 129,
5041 EL_CUSTOM_START + 130,
5042 EL_CUSTOM_START + 131,
5044 EL_CUSTOM_START + 132,
5045 EL_CUSTOM_START + 133,
5046 EL_CUSTOM_START + 134,
5047 EL_CUSTOM_START + 135,
5049 EL_CUSTOM_START + 136,
5050 EL_CUSTOM_START + 137,
5051 EL_CUSTOM_START + 138,
5052 EL_CUSTOM_START + 139,
5054 EL_CUSTOM_START + 140,
5055 EL_CUSTOM_START + 141,
5056 EL_CUSTOM_START + 142,
5057 EL_CUSTOM_START + 143,
5059 EL_CUSTOM_START + 144,
5060 EL_CUSTOM_START + 145,
5061 EL_CUSTOM_START + 146,
5062 EL_CUSTOM_START + 147,
5064 EL_CUSTOM_START + 148,
5065 EL_CUSTOM_START + 149,
5066 EL_CUSTOM_START + 150,
5067 EL_CUSTOM_START + 151,
5069 EL_CUSTOM_START + 152,
5070 EL_CUSTOM_START + 153,
5071 EL_CUSTOM_START + 154,
5072 EL_CUSTOM_START + 155,
5074 EL_CUSTOM_START + 156,
5075 EL_CUSTOM_START + 157,
5076 EL_CUSTOM_START + 158,
5077 EL_CUSTOM_START + 159,
5079 EL_CUSTOM_START + 160,
5080 EL_CUSTOM_START + 161,
5081 EL_CUSTOM_START + 162,
5082 EL_CUSTOM_START + 163,
5084 EL_CUSTOM_START + 164,
5085 EL_CUSTOM_START + 165,
5086 EL_CUSTOM_START + 166,
5087 EL_CUSTOM_START + 167,
5089 EL_CUSTOM_START + 168,
5090 EL_CUSTOM_START + 169,
5091 EL_CUSTOM_START + 170,
5092 EL_CUSTOM_START + 171,
5094 EL_CUSTOM_START + 172,
5095 EL_CUSTOM_START + 173,
5096 EL_CUSTOM_START + 174,
5097 EL_CUSTOM_START + 175,
5099 EL_CUSTOM_START + 176,
5100 EL_CUSTOM_START + 177,
5101 EL_CUSTOM_START + 178,
5102 EL_CUSTOM_START + 179,
5104 EL_CUSTOM_START + 180,
5105 EL_CUSTOM_START + 181,
5106 EL_CUSTOM_START + 182,
5107 EL_CUSTOM_START + 183,
5109 EL_CUSTOM_START + 184,
5110 EL_CUSTOM_START + 185,
5111 EL_CUSTOM_START + 186,
5112 EL_CUSTOM_START + 187,
5114 EL_CUSTOM_START + 188,
5115 EL_CUSTOM_START + 189,
5116 EL_CUSTOM_START + 190,
5117 EL_CUSTOM_START + 191,
5119 EL_CUSTOM_START + 192,
5120 EL_CUSTOM_START + 193,
5121 EL_CUSTOM_START + 194,
5122 EL_CUSTOM_START + 195,
5124 EL_CUSTOM_START + 196,
5125 EL_CUSTOM_START + 197,
5126 EL_CUSTOM_START + 198,
5127 EL_CUSTOM_START + 199,
5129 EL_CUSTOM_START + 200,
5130 EL_CUSTOM_START + 201,
5131 EL_CUSTOM_START + 202,
5132 EL_CUSTOM_START + 203,
5134 EL_CUSTOM_START + 204,
5135 EL_CUSTOM_START + 205,
5136 EL_CUSTOM_START + 206,
5137 EL_CUSTOM_START + 207,
5139 EL_CUSTOM_START + 208,
5140 EL_CUSTOM_START + 209,
5141 EL_CUSTOM_START + 210,
5142 EL_CUSTOM_START + 211,
5144 EL_CUSTOM_START + 212,
5145 EL_CUSTOM_START + 213,
5146 EL_CUSTOM_START + 214,
5147 EL_CUSTOM_START + 215,
5149 EL_CUSTOM_START + 216,
5150 EL_CUSTOM_START + 217,
5151 EL_CUSTOM_START + 218,
5152 EL_CUSTOM_START + 219,
5154 EL_CUSTOM_START + 220,
5155 EL_CUSTOM_START + 221,
5156 EL_CUSTOM_START + 222,
5157 EL_CUSTOM_START + 223,
5159 EL_CUSTOM_START + 224,
5160 EL_CUSTOM_START + 225,
5161 EL_CUSTOM_START + 226,
5162 EL_CUSTOM_START + 227,
5164 EL_CUSTOM_START + 228,
5165 EL_CUSTOM_START + 229,
5166 EL_CUSTOM_START + 230,
5167 EL_CUSTOM_START + 231,
5169 EL_CUSTOM_START + 232,
5170 EL_CUSTOM_START + 233,
5171 EL_CUSTOM_START + 234,
5172 EL_CUSTOM_START + 235,
5174 EL_CUSTOM_START + 236,
5175 EL_CUSTOM_START + 237,
5176 EL_CUSTOM_START + 238,
5177 EL_CUSTOM_START + 239,
5179 EL_CUSTOM_START + 240,
5180 EL_CUSTOM_START + 241,
5181 EL_CUSTOM_START + 242,
5182 EL_CUSTOM_START + 243,
5184 EL_CUSTOM_START + 244,
5185 EL_CUSTOM_START + 245,
5186 EL_CUSTOM_START + 246,
5187 EL_CUSTOM_START + 247,
5189 EL_CUSTOM_START + 248,
5190 EL_CUSTOM_START + 249,
5191 EL_CUSTOM_START + 250,
5192 EL_CUSTOM_START + 251,
5194 EL_CUSTOM_START + 252,
5195 EL_CUSTOM_START + 253,
5196 EL_CUSTOM_START + 254,
5197 EL_CUSTOM_START + 255
5199 static int *editor_hl_custom_ptr = editor_hl_custom;
5200 static int *editor_el_custom_ptr = editor_el_custom;
5201 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5202 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5204 static int editor_hl_group[] =
5206 EL_INTERNAL_CASCADE_GE_ACTIVE,
5212 static int editor_el_group[] =
5226 EL_GROUP_START + 10,
5227 EL_GROUP_START + 11,
5229 EL_GROUP_START + 12,
5230 EL_GROUP_START + 13,
5231 EL_GROUP_START + 14,
5232 EL_GROUP_START + 15,
5234 EL_GROUP_START + 16,
5235 EL_GROUP_START + 17,
5236 EL_GROUP_START + 18,
5237 EL_GROUP_START + 19,
5239 EL_GROUP_START + 20,
5240 EL_GROUP_START + 21,
5241 EL_GROUP_START + 22,
5242 EL_GROUP_START + 23,
5244 EL_GROUP_START + 24,
5245 EL_GROUP_START + 25,
5246 EL_GROUP_START + 26,
5247 EL_GROUP_START + 27,
5249 EL_GROUP_START + 28,
5250 EL_GROUP_START + 29,
5251 EL_GROUP_START + 30,
5254 static int *editor_hl_group_ptr = editor_hl_group;
5255 static int *editor_el_group_ptr = editor_el_group;
5256 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5257 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5259 static int editor_hl_reference[] =
5261 EL_INTERNAL_CASCADE_REF_ACTIVE,
5267 static int editor_el_reference[] =
5271 EL_TRIGGER_CE_VALUE,
5272 EL_TRIGGER_CE_SCORE,
5276 EL_CURRENT_CE_VALUE,
5277 EL_CURRENT_CE_SCORE,
5299 static int *editor_hl_reference_ptr = editor_hl_reference;
5300 static int *editor_el_reference_ptr = editor_el_reference;
5301 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5302 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5304 static int editor_hl_user_defined[] =
5306 EL_INTERNAL_CASCADE_USER_ACTIVE,
5312 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5313 static int *editor_el_user_defined_ptr = NULL;
5314 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5315 static int num_editor_el_user_defined = 0;
5317 static int editor_hl_dynamic[] =
5319 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5325 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5326 static int *editor_el_dynamic_ptr = NULL;
5327 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5328 static int num_editor_el_dynamic = 0;
5330 static int editor_hl_empty[] = { EL_EMPTY };
5331 static int *editor_el_empty = NULL; // dynamically allocated
5333 static int *editor_hl_empty_ptr = editor_hl_empty;
5334 static int *editor_el_empty_ptr = NULL;
5335 static int num_editor_hl_empty = 0;
5336 static int num_editor_el_empty = 0; // dynamically determined, if needed
5338 static boolean use_el_empty = FALSE;
5340 static int *editor_elements = NULL; // dynamically allocated
5341 static int num_editor_elements = 0; // dynamically determined
5343 static boolean setup_editor_cascade_never = FALSE;
5345 static boolean setup_editor_el_players = TRUE;
5346 static boolean setup_editor_el_boulderdash = TRUE;
5347 static boolean setup_editor_el_emerald_mine = TRUE;
5348 static boolean setup_editor_el_emerald_mine_club = TRUE;
5349 static boolean setup_editor_el_more = TRUE;
5350 static boolean setup_editor_el_sokoban = TRUE;
5351 static boolean setup_editor_el_supaplex = TRUE;
5352 static boolean setup_editor_el_diamond_caves = TRUE;
5353 static boolean setup_editor_el_dx_boulderdash = TRUE;
5354 static boolean setup_editor_el_mirror_magic = TRUE;
5355 static boolean setup_editor_el_deflektor = TRUE;
5356 static boolean setup_editor_el_chars = TRUE;
5357 static boolean setup_editor_el_steel_chars = TRUE;
5358 static boolean setup_editor_el_custom = TRUE;
5359 static boolean setup_editor_el_user_defined = TRUE;
5360 static boolean setup_editor_el_dynamic = TRUE;
5362 static int editor_hl_unused[] = { EL_EMPTY };
5363 static int *editor_hl_unused_ptr = editor_hl_unused;
5364 static int num_editor_hl_unused = 0;
5368 boolean *setup_value;
5369 boolean *setup_cascade_value;
5371 int **headline_list;
5372 int *headline_list_size;
5375 int *element_list_size;
5377 boolean last_setup_value;
5379 editor_elements_info[] =
5382 &setup_editor_el_players,
5383 &setup_editor_cascade_never,
5384 &editor_hl_unused_ptr, &num_editor_hl_unused,
5385 &editor_el_players_ptr, &num_editor_el_players
5388 &setup_editor_el_boulderdash,
5389 &setup.editor_cascade.el_bd,
5390 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5391 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5394 &setup_editor_el_emerald_mine,
5395 &setup.editor_cascade.el_em,
5396 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5397 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5400 &setup_editor_el_emerald_mine_club,
5401 &setup.editor_cascade.el_emc,
5402 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5403 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5406 &setup_editor_el_more,
5407 &setup.editor_cascade.el_rnd,
5408 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5409 &editor_el_rnd_ptr, &num_editor_el_rnd
5412 &setup_editor_el_sokoban,
5413 &setup.editor_cascade.el_sb,
5414 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5415 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5418 &setup_editor_el_supaplex,
5419 &setup.editor_cascade.el_sp,
5420 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5421 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5424 &setup_editor_el_diamond_caves,
5425 &setup.editor_cascade.el_dc,
5426 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5427 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5430 &setup_editor_el_dx_boulderdash,
5431 &setup.editor_cascade.el_dx,
5432 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5433 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
5436 &setup_editor_el_mirror_magic,
5437 &setup.editor_cascade.el_mm,
5438 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
5439 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
5442 &setup_editor_el_deflektor,
5443 &setup.editor_cascade.el_df,
5444 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
5445 &editor_el_deflektor_ptr, &num_editor_el_deflektor
5448 &setup_editor_el_chars,
5449 &setup.editor_cascade.el_chars,
5450 &editor_hl_chars_ptr, &num_editor_hl_chars,
5451 &editor_el_chars_ptr, &num_editor_el_chars
5454 &setup_editor_el_steel_chars,
5455 &setup.editor_cascade.el_steel_chars,
5456 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
5457 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
5460 &setup_editor_el_custom,
5461 &setup.editor_cascade.el_ce,
5462 &editor_hl_custom_ptr, &num_editor_hl_custom,
5463 &editor_el_custom_ptr, &num_editor_el_custom
5466 &setup_editor_el_custom,
5467 &setup.editor_cascade.el_ge,
5468 &editor_hl_group_ptr, &num_editor_hl_group,
5469 &editor_el_group_ptr, &num_editor_el_group
5472 &setup_editor_el_custom,
5473 &setup.editor_cascade.el_ref,
5474 &editor_hl_reference_ptr, &num_editor_hl_reference,
5475 &editor_el_reference_ptr, &num_editor_el_reference
5478 &setup_editor_el_user_defined,
5479 &setup.editor_cascade.el_user,
5480 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
5481 &editor_el_user_defined_ptr, &num_editor_el_user_defined
5484 &setup_editor_el_dynamic,
5485 &setup.editor_cascade.el_dynamic,
5486 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
5487 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
5492 &editor_hl_empty_ptr, &num_editor_hl_empty,
5493 &editor_el_empty_ptr, &num_editor_el_empty,
5504 // ----------------------------------------------------------------------------
5506 // ----------------------------------------------------------------------------
5508 static int getMaxInfoTextLength(void)
5510 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
5513 static int getTextWidthForGadget(char *text)
5518 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
5521 static int getTextWidthForDrawingArea(char *text)
5526 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
5529 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
5531 return (gi->x + gi->width + getTextWidthForGadget(text));
5534 static char *getElementInfoText(int element)
5536 char *info_text = NULL;
5538 if (element < MAX_NUM_ELEMENTS)
5540 if (strlen(element_info[element].description) > 0)
5541 info_text = element_info[element].description;
5542 else if (element_info[element].custom_description != NULL)
5543 info_text = element_info[element].custom_description;
5544 else if (element_info[element].editor_description != NULL)
5545 info_text = element_info[element].editor_description;
5548 if (info_text == NULL)
5549 info_text = INFOTEXT_UNKNOWN_ELEMENT;
5554 static char *getElementDescriptionFilenameExt(char *basename)
5556 char *elements_subdir = "elements";
5557 static char *elements_subdir2 = NULL;
5558 static char *filename = NULL;
5560 if (elements_subdir2 == NULL)
5561 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
5563 checked_free(filename);
5565 // 1st try: look for element description in current level set directory
5566 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
5567 if (fileExists(filename))
5572 // 2nd try: look for element description in the game's base directory
5573 filename = getPath3(options.docs_directory, elements_subdir, basename);
5574 if (fileExists(filename))
5580 static char *getElementDescriptionFilename(int element)
5582 char basename[MAX_FILENAME_LEN];
5585 // 1st try: look for element description file for exactly this element
5586 sprintf(basename, "%s.txt", element_info[element].token_name);
5587 filename = getElementDescriptionFilenameExt(basename);
5588 if (filename != NULL)
5591 // 2nd try: look for element description file for this element's class
5592 sprintf(basename, "%s.txt", element_info[element].class_name);
5593 filename = getElementDescriptionFilenameExt(basename);
5594 if (filename != NULL)
5600 static boolean suppressBorderElement(void)
5602 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
5603 lev_fieldx <= MAX_ED_FIELDX &&
5604 lev_fieldy <= MAX_ED_FIELDY);
5607 static void InitDynamicEditorElementList(int **elements, int *num_elements)
5609 boolean element_found[NUM_FILE_ELEMENTS];
5612 // initialize list of used elements to "not used"
5613 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5614 element_found[i] = FALSE;
5616 // find all elements used in current level
5617 for (y = 0; y < lev_fieldy; y++)
5618 for (x = 0; x < lev_fieldx; x++)
5619 if (Tile[x][y] < NUM_FILE_ELEMENTS) // should always be true
5620 element_found[Tile[x][y]] = TRUE;
5624 // count number of elements used in current level
5625 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5626 if (element_found[i])
5629 // add space for up to 3 more elements for padding that may be needed
5632 // free memory for old list of elements, if needed
5633 checked_free(*elements);
5635 // allocate memory for new list of elements
5636 *elements = checked_malloc(*num_elements * sizeof(int));
5640 // add all elements used in current level (non-custom/group elements)
5641 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5642 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5643 (*elements)[(*num_elements)++] = i;
5645 // add all elements used in current level (custom/group elements)
5646 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5647 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5648 (*elements)[(*num_elements)++] = i;
5650 while (*num_elements % 4) // pad with empty elements, if needed
5651 (*elements)[(*num_elements)++] = EL_EMPTY;
5654 static void ReinitializeElementList_EnableSections(void)
5656 // default: enable all element sections
5658 setup_editor_el_players = TRUE;
5659 setup_editor_el_boulderdash = TRUE;
5660 setup_editor_el_emerald_mine = TRUE;
5661 setup_editor_el_emerald_mine_club = TRUE;
5662 setup_editor_el_more = TRUE;
5663 setup_editor_el_sokoban = TRUE;
5664 setup_editor_el_supaplex = TRUE;
5665 setup_editor_el_diamond_caves = TRUE;
5666 setup_editor_el_dx_boulderdash = TRUE;
5667 setup_editor_el_mirror_magic = TRUE;
5668 setup_editor_el_deflektor = TRUE;
5669 setup_editor_el_chars = TRUE;
5670 setup_editor_el_steel_chars = TRUE;
5672 setup_editor_el_custom = TRUE;
5673 setup_editor_el_user_defined = TRUE;
5674 setup_editor_el_dynamic = TRUE;
5676 // now disable all element sections not to be displayed
5678 if (!setup.editor.el_classic)
5680 setup_editor_el_players = FALSE;
5681 setup_editor_el_boulderdash = FALSE;
5682 setup_editor_el_emerald_mine = FALSE;
5683 setup_editor_el_emerald_mine_club = FALSE;
5684 setup_editor_el_more = FALSE;
5685 setup_editor_el_sokoban = FALSE;
5686 setup_editor_el_supaplex = FALSE;
5687 setup_editor_el_diamond_caves = FALSE;
5688 setup_editor_el_dx_boulderdash = FALSE;
5689 setup_editor_el_mirror_magic = FALSE;
5690 setup_editor_el_deflektor = FALSE;
5691 setup_editor_el_chars = FALSE;
5692 setup_editor_el_steel_chars = FALSE;
5695 if (!setup.editor.el_custom)
5697 setup_editor_el_custom = FALSE;
5700 if (!setup.editor.el_user_defined)
5702 setup_editor_el_user_defined = FALSE;
5705 if (!setup.editor.el_dynamic)
5707 setup_editor_el_dynamic = FALSE;
5710 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
5712 setup_editor_el_mirror_magic = FALSE;
5713 setup_editor_el_deflektor = FALSE;
5715 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
5717 setup_editor_el_boulderdash = FALSE;
5718 setup_editor_el_more = FALSE;
5719 setup_editor_el_sokoban = FALSE;
5720 setup_editor_el_supaplex = FALSE;
5721 setup_editor_el_diamond_caves = FALSE;
5722 setup_editor_el_dx_boulderdash = FALSE;
5723 setup_editor_el_mirror_magic = FALSE;
5724 setup_editor_el_deflektor = FALSE;
5725 setup_editor_el_steel_chars = FALSE;
5727 setup_editor_el_custom = FALSE;
5729 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
5731 setup_editor_el_players = FALSE;
5732 setup_editor_el_boulderdash = FALSE;
5733 setup_editor_el_emerald_mine = FALSE;
5734 setup_editor_el_emerald_mine_club = FALSE;
5735 setup_editor_el_more = FALSE;
5736 setup_editor_el_sokoban = FALSE;
5737 setup_editor_el_diamond_caves = FALSE;
5738 setup_editor_el_dx_boulderdash = FALSE;
5739 setup_editor_el_mirror_magic = FALSE;
5740 setup_editor_el_deflektor = FALSE;
5741 setup_editor_el_chars = FALSE;
5742 setup_editor_el_steel_chars = FALSE;
5744 setup_editor_el_custom = FALSE;
5746 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
5748 setup_editor_el_players = FALSE;
5749 setup_editor_el_boulderdash = FALSE;
5750 setup_editor_el_emerald_mine = FALSE;
5751 setup_editor_el_emerald_mine_club = FALSE;
5752 setup_editor_el_more = FALSE;
5753 setup_editor_el_sokoban = FALSE;
5754 setup_editor_el_supaplex = FALSE;
5755 setup_editor_el_diamond_caves = FALSE;
5756 setup_editor_el_dx_boulderdash = FALSE;
5757 setup_editor_el_steel_chars = FALSE;
5759 setup_editor_el_custom = FALSE;
5763 static void ReinitializeElementList(void)
5765 static boolean initialization_needed = TRUE;
5769 ReinitializeElementList_EnableSections();
5771 if (initialization_needed)
5773 LoadSetup_EditorCascade(); // load last editor cascade state
5775 // initialize editor cascade element from saved cascade state
5776 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5778 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
5779 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
5781 if (IS_EDITOR_CASCADE(*cascade_element))
5783 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
5784 EL_CASCADE_INACTIVE(*cascade_element));
5787 initialization_needed = FALSE;
5790 checked_free(editor_elements);
5792 // reload optional user defined element list for each invocation of editor
5793 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
5794 &num_editor_el_user_defined);
5796 // initialize dynamic level element list for each invocation of editor
5797 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
5798 &num_editor_el_dynamic);
5800 // initialize list of empty elements (used for padding, if needed)
5801 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5802 editor_el_empty[i] = EL_EMPTY;
5804 // do some sanity checks for each element from element list
5805 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5807 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5809 int element = (*editor_elements_info[i].element_list)[j];
5811 if (element >= NUM_FILE_ELEMENTS)
5812 Warn("editor element %d is runtime element", element);
5814 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
5815 Warn("no element description text for element %d", element);
5819 num_editor_elements = 0;
5820 use_el_empty = FALSE;
5822 // determine size of element list
5823 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5825 boolean found_inactive_cascade = FALSE;
5827 if (*editor_elements_info[i].setup_value)
5829 if (setup.editor.el_headlines)
5831 // required for correct padding of palette headline buttons
5832 if (*editor_elements_info[i].headline_list_size > 0)
5833 num_editor_elements += ED_ELEMENTLIST_COLS;
5835 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5837 int element = (*editor_elements_info[i].headline_list)[j];
5839 if (IS_EDITOR_CASCADE_INACTIVE(element))
5840 found_inactive_cascade = TRUE;
5844 if (found_inactive_cascade)
5847 // required for correct padding of palette element buttons
5848 int element_list_size = *editor_elements_info[i].element_list_size;
5850 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
5851 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
5853 num_editor_elements += element_buttons;
5857 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
5859 // offer at least as many elements as element buttons exist
5860 use_el_empty = TRUE;
5861 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
5863 num_editor_elements += num_editor_el_empty;
5867 num_editor_el_empty = 0;
5870 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
5872 // fill element list
5873 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5875 boolean found_inactive_cascade = FALSE;
5877 if (*editor_elements_info[i].setup_value)
5879 if (setup.editor.el_headlines)
5881 // required for correct padding of palette headline buttons
5882 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
5883 ED_ELEMENTLIST_COLS : 0);
5885 for (j = 0; j < headline_size; j++)
5887 // use empty elements for padding of palette headline buttons
5888 int element = (j < *editor_elements_info[i].headline_list_size ?
5889 (*editor_elements_info[i].headline_list)[j] :
5890 editor_el_empty[0]);
5892 editor_elements[pos++] = element;
5894 if (IS_EDITOR_CASCADE_INACTIVE(element))
5895 found_inactive_cascade = TRUE;
5899 if (found_inactive_cascade)
5902 // required for correct padding of palette element buttons
5903 int element_list_size = *editor_elements_info[i].element_list_size;
5905 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
5906 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
5908 // copy all elements from element list
5909 for (j = 0; j < element_list_size; j++)
5910 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
5912 // use empty elements for padding of palette element buttons
5913 for (j = 0; j < element_buttons - element_list_size; j++)
5914 editor_elements[pos++] = editor_el_empty[0];
5918 // (this function is also called before editor gadgets are initialized!)
5919 AdjustElementListScrollbar();
5922 void PrintEditorElementList(void)
5924 boolean *stop = &setup_editor_el_user_defined;
5927 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
5929 int cascade_element = (*editor_elements_info[i].headline_list)[0];
5931 if (IS_EDITOR_CASCADE(cascade_element))
5933 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
5934 char *headline = element_info[cascade_element_show].editor_description;
5936 PrintLineWithPrefix("# ", "-", 77);
5937 Print("# %s\n", headline);
5938 PrintLineWithPrefix("# ", "-", 77);
5941 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5943 int element = (*editor_elements_info[i].headline_list)[j];
5945 if (IS_EDITOR_CASCADE(element))
5946 element = EL_CHAR_MINUS;
5948 Print("# %s\n", element_info[element].token_name);
5954 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5956 int element = (*editor_elements_info[i].element_list)[j];
5958 Print("# %s\n", element_info[element].token_name);
5966 static void ReinitializeElementListButtons(void)
5968 static boolean last_setup_value_headlines = FALSE;
5969 static boolean initialization_needed = TRUE;
5972 if (!initialization_needed) // check if editor element setup has changed
5974 if (last_setup_value_headlines != setup.editor.el_headlines)
5975 initialization_needed = TRUE;
5977 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5978 if (editor_elements_info[i].last_setup_value !=
5979 *editor_elements_info[i].setup_value)
5980 initialization_needed = TRUE;
5983 if (!initialization_needed)
5986 FreeLevelEditorGadgets();
5987 CreateLevelEditorGadgets();
5989 // store current setup values for next invocation of this function
5990 last_setup_value_headlines = setup.editor.el_headlines;
5991 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5992 editor_elements_info[i].last_setup_value =
5993 *editor_elements_info[i].setup_value;
5995 initialization_needed = FALSE;
5998 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6001 int border_graphic =
6002 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6003 struct GraphicInfo *g = &graphic_info[border_graphic];
6004 Bitmap *src_bitmap = g->bitmap;
6005 int src_x = g->src_x;
6006 int src_y = g->src_y;
6007 int border_size = g->border_size;
6008 int border_xpos = g->width - border_size;
6009 int border_ypos = g->height - border_size;
6010 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6013 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6014 border_size, border_size,
6015 dest_x - border_size, dest_y - border_size);
6016 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6017 border_size, border_size,
6018 dest_x + width, dest_y - border_size);
6019 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6020 border_size, border_size,
6021 dest_x - border_size, dest_y + height);
6022 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6023 border_size, border_size,
6024 dest_x + width, dest_y + height);
6026 for (i = 0; i < width / tilesize; i++)
6028 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6029 tilesize, border_size,
6030 dest_x + i * tilesize, dest_y - border_size);
6031 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6032 tilesize, border_size,
6033 dest_x + i * tilesize, dest_y + height);
6036 for (i = 0; i < height / tilesize; i++)
6038 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6039 border_size, tilesize,
6040 dest_x - border_size, dest_y + i * tilesize);
6041 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6042 border_size, tilesize,
6043 dest_x + width, dest_y + i * tilesize);
6046 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6049 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6051 int xsize_tile = MAX(ed_tilesize, xsize);
6052 int ysize_tile = MAX(ed_tilesize, ysize);
6053 int xsize_full = xsize + 1;
6054 int ysize_full = ysize + 1;
6055 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6056 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6057 Pixel line_color = getTabulatorBarColor();
6059 if (line_color == BLACK_PIXEL) // black => transparent
6062 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6063 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6064 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6067 static void DrawEditorLevelBorderLinesIfNeeded(void)
6069 int xsize = lev_fieldx * ed_tilesize;
6070 int ysize = lev_fieldy * ed_tilesize;
6071 int line_size = getTabulatorBarHeight();
6073 if (!suppressBorderElement())
6076 // draw little border line around editable level playfield
6079 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6082 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6084 if (xsize < SXSIZE && ysize < SYSIZE)
6085 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6088 static void DrawEditorElement(int x, int y, int element)
6090 DrawSizedElement(x, y, element, ed_tilesize);
6093 static void DrawEditorElementThruMask(int x, int y, int element)
6095 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6098 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6100 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6103 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6105 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6106 DrawEditorLevelBorderLinesIfNeeded();
6109 static void DrawDrawingArea(int id)
6111 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6114 int *value = drawingarea_info[id].value;
6115 int area_xsize = drawingarea_info[id].area_xsize;
6116 int area_ysize = drawingarea_info[id].area_ysize;
6117 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6119 for (x = 0; x < area_xsize; x++)
6120 for (y = 0; y < area_ysize; y++)
6121 DrawSizedGraphicExt(drawto,
6122 gi->x + x * tilesize,
6123 gi->y + y * tilesize,
6124 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6127 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6130 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6131 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6133 BlitBitmap(drawto, drawto,
6134 SX + (dx == -1 ? ed_tilesize : 0),
6135 SY + (dy == -1 ? ed_tilesize : 0),
6136 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6137 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6138 SX + (dx == +1 ? ed_tilesize : 0),
6139 SY + (dy == +1 ? ed_tilesize : 0));
6143 x = (dx == 1 ? 0 : ed_fieldx - 1);
6144 for (y = 0; y < ed_fieldy; y++)
6145 DrawEditorElementOrWall(x, y, from_x, from_y);
6149 y = (dy == 1 ? 0 : ed_fieldy - 1);
6150 for (x = 0; x < ed_fieldx; x++)
6151 DrawEditorElementOrWall(x, y, from_x, from_y);
6154 redraw_mask |= REDRAW_FIELD;
6158 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6161 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6164 static void CreateControlButtons(void)
6166 struct GadgetInfo *gi;
6169 // create toolbox buttons
6170 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6172 int id = controlbutton_info[i].gadget_id;
6173 int type = controlbutton_info[i].gadget_type;
6174 int graphic = controlbutton_info[i].graphic;
6175 struct XYTileSize *pos = controlbutton_info[i].pos;
6176 struct GraphicInfo *gd = &graphic_info[graphic];
6177 Bitmap *deco_bitmap = NULL;
6178 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6179 int tile_size = 0, deco_shift = 0;
6180 boolean deco_masked = FALSE;
6181 int gd_x1 = gd->src_x;
6182 int gd_y1 = gd->src_y;
6183 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6184 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6185 int gd_x1a = gd->src_x + gd->active_xoffset;
6186 int gd_y1a = gd->src_y + gd->active_yoffset;
6187 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6188 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6191 unsigned int event_mask;
6192 int radio_button_nr = RADIO_NR_NONE;
6193 boolean checked = FALSE;
6195 if (type == GD_TYPE_RADIO_BUTTON)
6197 event_mask = GD_EVENT_PRESSED;
6198 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6200 if (id == drawing_function)
6205 if (id == GADGET_ID_WRAP_LEFT ||
6206 id == GADGET_ID_WRAP_RIGHT ||
6207 id == GADGET_ID_WRAP_UP ||
6208 id == GADGET_ID_WRAP_DOWN)
6209 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6211 event_mask = GD_EVENT_RELEASED;
6214 if (id == GADGET_ID_PROPERTIES ||
6215 id == GADGET_ID_PALETTE)
6220 else if (id == GADGET_ID_ELEMENT_LEFT ||
6221 id == GADGET_ID_ELEMENT_MIDDLE ||
6222 id == GADGET_ID_ELEMENT_RIGHT)
6227 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6228 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6229 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6231 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6232 editor.button.element_left.tile_size :
6233 id == GADGET_ID_ELEMENT_MIDDLE ?
6234 editor.button.element_middle.tile_size :
6235 id == GADGET_ID_ELEMENT_RIGHT ?
6236 editor.button.element_right.tile_size : 0);
6238 // make sure that decoration does not overlap gadget border
6239 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6241 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6243 deco_xpos = (gd->width - tile_size) / 2;
6244 deco_ypos = (gd->height - tile_size) / 2;
6246 deco_masked = gd->draw_masked;
6254 gi = CreateGadget(GDI_CUSTOM_ID, id,
6255 GDI_CUSTOM_TYPE_ID, i,
6256 GDI_IMAGE_ID, graphic,
6257 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6260 GDI_WIDTH, gd->width,
6261 GDI_HEIGHT, gd->height,
6263 GDI_STATE, GD_BUTTON_UNPRESSED,
6264 GDI_RADIO_NR, radio_button_nr,
6265 GDI_CHECKED, checked,
6266 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6267 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6268 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6269 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6270 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6271 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6272 GDI_DECORATION_SIZE, tile_size, tile_size,
6273 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6274 GDI_DECORATION_MASKED, deco_masked,
6275 GDI_EVENT_MASK, event_mask,
6276 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6277 GDI_CALLBACK_ACTION, HandleControlButtons,
6281 Fail("cannot create gadget");
6283 level_editor_gadget[id] = gi;
6286 // these values are not constant, but can change at runtime
6287 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6288 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6289 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6290 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6291 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6292 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6293 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6294 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6295 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6296 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6297 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6298 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6300 // create buttons for scrolling of drawing area and element list
6301 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6303 int id = scrollbutton_info[i].gadget_id;
6304 int graphic = scrollbutton_info[i].graphic;
6305 struct GraphicInfo *gd = &graphic_info[graphic];
6306 Bitmap *gd_bitmap = gd->bitmap;
6307 int gd_x1 = gd->src_x;
6308 int gd_y1 = gd->src_y;
6309 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6310 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6311 int width = gd->width;
6312 int height = gd->height;
6313 int x = scrollbutton_pos[i].x;
6314 int y = scrollbutton_pos[i].y;
6315 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6317 if (id == GADGET_ID_SCROLL_LIST_UP ||
6318 id == GADGET_ID_SCROLL_LIST_DOWN)
6329 gi = CreateGadget(GDI_CUSTOM_ID, id,
6330 GDI_CUSTOM_TYPE_ID, i,
6331 GDI_IMAGE_ID, graphic,
6332 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6337 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6338 GDI_STATE, GD_BUTTON_UNPRESSED,
6339 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6340 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6341 GDI_EVENT_MASK, event_mask,
6342 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6343 GDI_CALLBACK_ACTION, HandleControlButtons,
6347 Fail("cannot create gadget");
6349 level_editor_gadget[id] = gi;
6352 // create buttons for element list
6353 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6355 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6356 int graphic = IMG_EDITOR_PALETTE_BUTTON;
6357 struct GraphicInfo *gd = &graphic_info[graphic];
6358 Bitmap *gd_bitmap = gd->bitmap;
6359 Bitmap *deco_bitmap;
6360 int deco_x, deco_y, deco_xpos, deco_ypos;
6361 int gd_x1 = gd->src_x;
6362 int gd_y1 = gd->src_y;
6363 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6364 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6365 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
6366 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
6367 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
6368 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
6369 int element = editor_elements[i];
6370 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
6371 unsigned int event_mask = GD_EVENT_RELEASED;
6373 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
6375 deco_xpos = (gd->width - tile_size) / 2;
6376 deco_ypos = (gd->height - tile_size) / 2;
6378 gi = CreateGadget(GDI_CUSTOM_ID, id,
6379 GDI_CUSTOM_TYPE_ID, i,
6380 GDI_IMAGE_ID, graphic,
6381 GDI_INFO_TEXT, getElementInfoText(element),
6384 GDI_WIDTH, gd->width,
6385 GDI_HEIGHT, gd->height,
6386 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6387 GDI_STATE, GD_BUTTON_UNPRESSED,
6388 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6389 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6390 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6391 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6392 GDI_DECORATION_SIZE, tile_size, tile_size,
6393 GDI_DECORATION_SHIFTING, 1, 1,
6394 GDI_EVENT_MASK, event_mask,
6395 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6396 GDI_CALLBACK_ACTION, HandleControlButtons,
6400 Fail("cannot create gadget");
6402 level_editor_gadget[id] = gi;
6406 static void CreateCounterButtons(void)
6408 int max_infotext_len = getMaxInfoTextLength();
6411 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
6414 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
6415 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
6417 // determine horizontal position to the right of specified gadget
6418 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6419 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
6420 ED_GADGET_TEXT_DISTANCE);
6422 // determine horizontal offset for leading text
6423 if (counterbutton_info[i].text_left != NULL)
6424 x += getTextWidthForGadget(counterbutton_info[i].text_left);
6426 for (j = 0; j < 2; j++)
6428 struct GadgetInfo *gi;
6430 counterbutton_info[i].gadget_id_down :
6431 counterbutton_info[i].gadget_id_up);
6433 struct GraphicInfo *gd;
6434 int gd_x1, gd_x2, gd_y1, gd_y2;
6435 unsigned int event_mask;
6436 char infotext[max_infotext_len + 1];
6438 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6440 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6443 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
6444 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
6446 event_mask |= GD_EVENT_RELEASED;
6450 x = DX + editor.button.prev_level.x;
6451 y = DY + editor.button.prev_level.y;
6455 x = DX + editor.button.next_level.x;
6456 y = DY + editor.button.next_level.y;
6462 IMG_EDITOR_COUNTER_DOWN :
6463 IMG_EDITOR_COUNTER_UP);
6466 gd = &graphic_info[graphic];
6470 gd_x2 = gd->src_x + gd->pressed_xoffset;
6471 gd_y2 = gd->src_y + gd->pressed_yoffset;
6473 sprintf(infotext, "%s counter value by 1, 5 or 10",
6474 (j == 0 ? "decrease" : "increase"));
6476 gi = CreateGadget(GDI_CUSTOM_ID, id,
6477 GDI_CUSTOM_TYPE_ID, i,
6478 GDI_IMAGE_ID, graphic,
6479 GDI_INFO_TEXT, infotext,
6482 GDI_WIDTH, gd->width,
6483 GDI_HEIGHT, gd->height,
6484 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6485 GDI_STATE, GD_BUTTON_UNPRESSED,
6486 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6487 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6488 GDI_EVENT_MASK, event_mask,
6489 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6490 GDI_CALLBACK_ACTION, HandleCounterButtons,
6494 Fail("cannot create gadget");
6496 level_editor_gadget[id] = gi;
6497 right_gadget_border[id] =
6498 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6500 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
6504 int font_type = FONT_INPUT_1;
6505 int font_type_active = FONT_INPUT_1_ACTIVE;
6507 id = counterbutton_info[i].gadget_id_text;
6509 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6511 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6513 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
6515 font_type = FONT_LEVEL_NUMBER;
6516 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
6518 x = DX + editor.input.level_number.x;
6519 y = DY + editor.input.level_number.y;
6523 graphic = IMG_EDITOR_COUNTER_INPUT;
6526 gd = &graphic_info[graphic];
6530 gd_x2 = gd->src_x + gd->active_xoffset;
6531 gd_y2 = gd->src_y + gd->active_yoffset;
6533 gi = CreateGadget(GDI_CUSTOM_ID, id,
6534 GDI_CUSTOM_TYPE_ID, i,
6535 GDI_IMAGE_ID, graphic,
6536 GDI_INFO_TEXT, "enter counter value",
6539 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
6540 GDI_NUMBER_VALUE, 0,
6541 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
6542 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
6543 GDI_TEXT_SIZE, 3, // minimal counter text size
6544 GDI_TEXT_FONT, font_type,
6545 GDI_TEXT_FONT_ACTIVE, font_type_active,
6546 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6547 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6548 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6549 GDI_DESIGN_WIDTH, gd->width,
6550 GDI_EVENT_MASK, event_mask,
6551 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6552 GDI_CALLBACK_ACTION, HandleCounterButtons,
6556 Fail("cannot create gadget");
6558 level_editor_gadget[id] = gi;
6559 right_gadget_border[id] =
6560 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6562 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
6568 static void CreateDrawingAreas(void)
6572 // these values are not constant, but can change at runtime
6573 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
6574 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
6576 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
6578 struct GadgetInfo *gi;
6579 unsigned int event_mask;
6580 int id = drawingarea_info[i].gadget_id;
6581 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
6582 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
6583 int area_xsize = drawingarea_info[i].area_xsize;
6584 int area_ysize = drawingarea_info[i].area_ysize;
6585 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
6586 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
6589 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
6590 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
6592 // determine horizontal position to the right of specified gadget
6593 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
6594 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
6595 ED_DRAWINGAREA_TEXT_DISTANCE);
6597 // determine horizontal offset for leading text
6598 if (drawingarea_info[i].text_left != NULL)
6599 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
6601 gi = CreateGadget(GDI_CUSTOM_ID, id,
6602 GDI_CUSTOM_TYPE_ID, i,
6605 GDI_TYPE, GD_TYPE_DRAWING_AREA,
6606 GDI_AREA_SIZE, area_xsize, area_ysize,
6607 GDI_ITEM_SIZE, item_size, item_size,
6608 GDI_EVENT_MASK, event_mask,
6609 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
6610 GDI_CALLBACK_ACTION, HandleDrawingAreas,
6614 Fail("cannot create gadget");
6616 level_editor_gadget[id] = gi;
6617 right_gadget_border[id] =
6618 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
6622 static void CreateTextInputGadgets(void)
6624 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
6625 int max_infotext_len = getMaxInfoTextLength();
6628 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
6630 int gd_x1 = gd->src_x;
6631 int gd_y1 = gd->src_y;
6632 int gd_x2 = gd->src_x + gd->active_xoffset;
6633 int gd_y2 = gd->src_y + gd->active_yoffset;
6634 struct GadgetInfo *gi;
6635 unsigned int event_mask;
6636 char infotext[MAX_OUTPUT_LINESIZE + 1];
6637 int id = textinput_info[i].gadget_id;
6640 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
6642 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
6643 int border_size = gd->border_size;
6644 int font_nr = FONT_INPUT_1;
6645 int font_height = getFontHeight(font_nr);
6646 int xoffset = element_border + TILEX + element_border + 3 * border_size;
6647 int yoffset = element_border + (TILEY - font_height) / 2;
6649 x = (editor.settings.element_name.x != -1 ?
6650 editor.settings.element_name.x :
6651 editor.settings.element_graphic.x + xoffset) - border_size;
6652 y = (editor.settings.element_name.y != -1 ?
6653 editor.settings.element_name.y :
6654 editor.settings.element_graphic.y + yoffset) - border_size;
6658 x = ED_SETTINGS_X(textinput_info[i].x);
6659 y = ED_SETTINGS_Y(textinput_info[i].y);
6662 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6664 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
6665 infotext[max_infotext_len] = '\0';
6667 gi = CreateGadget(GDI_CUSTOM_ID, id,
6668 GDI_CUSTOM_TYPE_ID, i,
6669 GDI_INFO_TEXT, infotext,
6672 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
6673 GDI_TEXT_VALUE, textinput_info[i].value,
6674 GDI_TEXT_SIZE, textinput_info[i].size,
6675 GDI_TEXT_FONT, FONT_INPUT_1,
6676 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6677 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6678 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6679 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6680 GDI_DESIGN_WIDTH, gd->width,
6681 GDI_EVENT_MASK, event_mask,
6682 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6683 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
6687 Fail("cannot create gadget");
6689 level_editor_gadget[id] = gi;
6693 static void CreateTextAreaGadgets(void)
6695 int max_infotext_len = getMaxInfoTextLength();
6698 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
6700 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
6701 int gd_x1 = gd->src_x;
6702 int gd_y1 = gd->src_y;
6703 int gd_x2 = gd->src_x + gd->active_xoffset;
6704 int gd_y2 = gd->src_y + gd->active_yoffset;
6705 struct GadgetInfo *gi;
6706 unsigned int event_mask;
6707 char infotext[MAX_OUTPUT_LINESIZE + 1];
6708 int id = textarea_info[i].gadget_id;
6709 int area_xsize = textarea_info[i].xsize;
6710 int area_ysize = textarea_info[i].ysize;
6712 event_mask = GD_EVENT_TEXT_LEAVING;
6714 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
6715 infotext[max_infotext_len] = '\0';
6717 gi = CreateGadget(GDI_CUSTOM_ID, id,
6718 GDI_CUSTOM_TYPE_ID, i,
6719 GDI_INFO_TEXT, infotext,
6720 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
6721 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
6722 GDI_TYPE, GD_TYPE_TEXT_AREA,
6723 GDI_AREA_SIZE, area_xsize, area_ysize,
6724 GDI_TEXT_FONT, FONT_INPUT_1,
6725 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6726 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6727 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6728 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6729 GDI_DESIGN_WIDTH, gd->width,
6730 GDI_EVENT_MASK, event_mask,
6731 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6732 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
6736 Fail("cannot create gadget");
6738 level_editor_gadget[id] = gi;
6742 static void CreateSelectboxGadgets(void)
6744 int max_infotext_len = getMaxInfoTextLength();
6747 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6749 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
6750 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
6751 int gd_x1 = gd->src_x;
6752 int gd_y1 = gd->src_y;
6753 int gd_x2 = gd->src_x + gd->active_xoffset;
6754 int gd_y2 = gd->src_y + gd->active_yoffset;
6755 int selectbox_button_xsize = gd2->width;
6756 struct GadgetInfo *gi;
6757 unsigned int event_mask;
6758 char infotext[MAX_OUTPUT_LINESIZE + 1];
6759 int id = selectbox_info[i].gadget_id;
6760 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
6761 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
6763 if (selectbox_info[i].size == -1) // dynamically determine size
6765 // (we cannot use -1 for uninitialized values if we directly compare
6766 // with results from strlen(), because the '<' and '>' operation will
6767 // implicitely cast -1 to an unsigned integer value!)
6768 selectbox_info[i].size = 0;
6770 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
6771 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
6772 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
6774 selectbox_info[i].size++; // add one character empty space
6777 event_mask = GD_EVENT_RELEASED |
6778 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6780 // determine horizontal position to the right of specified gadget
6781 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
6782 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
6783 ED_GADGET_TEXT_DISTANCE);
6785 // determine horizontal offset for leading text
6786 if (selectbox_info[i].text_left != NULL)
6787 x += getTextWidthForGadget(selectbox_info[i].text_left);
6789 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
6790 infotext[max_infotext_len] = '\0';
6792 gi = CreateGadget(GDI_CUSTOM_ID, id,
6793 GDI_CUSTOM_TYPE_ID, i,
6794 GDI_INFO_TEXT, infotext,
6797 GDI_TYPE, GD_TYPE_SELECTBOX,
6798 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
6799 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
6800 GDI_TEXT_SIZE, selectbox_info[i].size,
6801 GDI_TEXT_FONT, FONT_INPUT_1,
6802 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6803 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
6804 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6805 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6806 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6807 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
6808 GDI_DESIGN_WIDTH, gd->width,
6809 GDI_EVENT_MASK, event_mask,
6810 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6811 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
6815 Fail("cannot create gadget");
6817 level_editor_gadget[id] = gi;
6818 right_gadget_border[id] =
6819 getRightGadgetBorder(gi, selectbox_info[i].text_right);
6823 static void CreateTextbuttonGadgets(void)
6825 int max_infotext_len = getMaxInfoTextLength();
6828 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
6830 int id = textbutton_info[i].gadget_id;
6832 ((id >= GADGET_ID_LEVELINFO_LEVEL && id <= GADGET_ID_LEVELINFO_EDITOR) ||
6833 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
6835 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
6836 int gadget_distance =
6837 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
6838 struct GraphicInfo *gd = &graphic_info[graphic];
6839 int gd_x1 = gd->src_x;
6840 int gd_y1 = gd->src_y;
6841 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6842 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6843 int gd_x1a = gd->src_x + gd->active_xoffset;
6844 int gd_y1a = gd->src_y + gd->active_yoffset;
6845 int border_xsize = gd->border_size + gd->draw_xoffset;
6846 int border_ysize = gd->border_size;
6847 struct GadgetInfo *gi;
6848 unsigned int event_mask;
6849 char infotext[MAX_OUTPUT_LINESIZE + 1];
6850 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
6851 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
6853 if (textbutton_info[i].size == -1) // dynamically determine size
6854 textbutton_info[i].size = strlen(textbutton_info[i].text);
6856 event_mask = GD_EVENT_RELEASED;
6858 sprintf(infotext, "%s", textbutton_info[i].infotext);
6859 infotext[max_infotext_len] = '\0';
6861 // determine horizontal position to the right of specified gadget
6862 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6864 int gadget_id_align = textbutton_info[i].gadget_id_align;
6866 x = right_gadget_border[gadget_id_align] + gadget_distance;
6868 if (textbutton_info[i].y == -1)
6869 y = level_editor_gadget[gadget_id_align]->y;
6872 // determine horizontal offset for leading text
6873 if (textbutton_info[i].text_left != NULL)
6874 x += getTextWidthForGadget(textbutton_info[i].text_left);
6876 gi = CreateGadget(GDI_CUSTOM_ID, id,
6877 GDI_CUSTOM_TYPE_ID, i,
6878 GDI_IMAGE_ID, graphic,
6879 GDI_INFO_TEXT, infotext,
6882 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
6883 GDI_TEXT_VALUE, textbutton_info[i].text,
6884 GDI_TEXT_SIZE, textbutton_info[i].size,
6885 GDI_TEXT_FONT, FONT_INPUT_2,
6886 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
6887 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6888 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6889 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6890 GDI_BORDER_SIZE, border_xsize, border_ysize,
6891 GDI_DESIGN_WIDTH, gd->width,
6892 GDI_DECORATION_SHIFTING, 1, 1,
6893 GDI_EVENT_MASK, event_mask,
6894 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6895 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
6899 Fail("cannot create gadget");
6901 level_editor_gadget[id] = gi;
6902 right_gadget_border[id] =
6903 getRightGadgetBorder(gi, textbutton_info[i].text_right);
6907 static void CreateGraphicbuttonGadgets(void)
6909 struct GadgetInfo *gi;
6910 unsigned int event_mask;
6913 // create buttons for scrolling of drawing area and element list
6914 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
6916 int id = graphicbutton_info[i].gadget_id;
6917 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
6918 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
6919 int graphic = graphicbutton_info[i].graphic;
6920 struct GraphicInfo *gd = &graphic_info[graphic];
6921 int gd_x1 = gd->src_x;
6922 int gd_y1 = gd->src_y;
6923 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6924 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6926 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6928 // determine horizontal position to the right of specified gadget
6929 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6930 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
6931 ED_GADGET_TEXT_DISTANCE);
6933 // determine horizontal offset for leading text
6934 if (graphicbutton_info[i].text_left != NULL)
6935 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
6937 gi = CreateGadget(GDI_CUSTOM_ID, id,
6938 GDI_CUSTOM_TYPE_ID, i,
6939 GDI_IMAGE_ID, graphic,
6940 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
6943 GDI_WIDTH, gd->width,
6944 GDI_HEIGHT, gd->height,
6945 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6946 GDI_STATE, GD_BUTTON_UNPRESSED,
6947 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6948 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6949 GDI_EVENT_MASK, event_mask,
6950 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6951 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
6955 Fail("cannot create gadget");
6957 level_editor_gadget[id] = gi;
6958 right_gadget_border[id] =
6959 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
6963 static void CreateScrollbarGadgets(void)
6967 // these values are not constant, but can change at runtime
6968 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
6969 SX + ED_SCROLL_HORIZONTAL_XPOS;
6970 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
6971 SY + ED_SCROLL_HORIZONTAL_YPOS;
6972 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
6973 ED_SCROLL_HORIZONTAL_XSIZE;
6974 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
6975 ED_SCROLL_HORIZONTAL_YSIZE;
6976 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
6977 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
6978 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
6979 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
6981 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
6982 SX + ED_SCROLL_VERTICAL_XPOS;
6983 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
6984 SY + ED_SCROLL_VERTICAL_YPOS;
6985 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
6986 ED_SCROLL_VERTICAL_XSIZE;
6987 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
6988 ED_SCROLL_VERTICAL_YSIZE;
6989 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
6990 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
6991 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
6992 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
6994 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
6995 PX + ED_SCROLL2_VERTICAL_XPOS;
6996 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
6997 PY + ED_SCROLL2_VERTICAL_YPOS;
6998 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
6999 ED_SCROLL2_VERTICAL_XSIZE;
7000 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7001 ED_SCROLL2_VERTICAL_YSIZE;
7002 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7003 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7004 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7005 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7007 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7009 int id = scrollbar_info[i].gadget_id;
7010 int graphic = scrollbar_info[i].graphic;
7011 struct GraphicInfo *gd = &graphic_info[graphic];
7012 int gd_x1 = gd->src_x;
7013 int gd_y1 = gd->src_y;
7014 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7015 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7016 struct GadgetInfo *gi;
7017 int items_max, items_visible, item_position;
7018 unsigned int event_mask;
7020 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7022 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7023 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7024 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7026 else // drawing area scrollbars
7028 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7030 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7031 items_visible = ed_fieldx;
7036 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7037 items_visible = ed_fieldy;
7042 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7044 gi = CreateGadget(GDI_CUSTOM_ID, id,
7045 GDI_CUSTOM_TYPE_ID, i,
7046 GDI_IMAGE_ID, graphic,
7047 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7048 GDI_X, scrollbar_pos[i].x,
7049 GDI_Y, scrollbar_pos[i].y,
7050 GDI_WIDTH, scrollbar_pos[i].width,
7051 GDI_HEIGHT, scrollbar_pos[i].height,
7052 GDI_TYPE, scrollbar_info[i].type,
7053 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7054 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7055 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7056 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7057 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7058 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7059 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7060 GDI_STATE, GD_BUTTON_UNPRESSED,
7061 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7062 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7063 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7064 GDI_EVENT_MASK, event_mask,
7065 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7066 GDI_CALLBACK_ACTION, HandleControlButtons,
7070 Fail("cannot create gadget");
7072 level_editor_gadget[id] = gi;
7076 static void CreateCheckbuttonGadgets(void)
7078 struct GadgetInfo *gi;
7079 unsigned int event_mask;
7082 event_mask = GD_EVENT_PRESSED;
7084 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7086 int id = checkbutton_info[i].gadget_id;
7087 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7088 IMG_EDITOR_CHECKBOX);
7089 struct GraphicInfo *gd = &graphic_info[graphic];
7090 int gd_x1 = gd->src_x;
7091 int gd_y1 = gd->src_y;
7092 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7093 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7094 int gd_x1a = gd->src_x + gd->active_xoffset;
7095 int gd_y1a = gd->src_y + gd->active_yoffset;
7096 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7097 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7098 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7099 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7101 // determine horizontal position to the right of specified gadget
7102 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7103 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7104 ED_GADGET_TEXT_DISTANCE);
7106 // determine horizontal offset for leading text
7107 if (checkbutton_info[i].text_left != NULL)
7108 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7110 gi = CreateGadget(GDI_CUSTOM_ID, id,
7111 GDI_CUSTOM_TYPE_ID, i,
7112 GDI_IMAGE_ID, graphic,
7113 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7116 GDI_WIDTH, gd->width,
7117 GDI_HEIGHT, gd->height,
7118 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7119 GDI_CHECKED, *checkbutton_info[i].value,
7120 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7121 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7122 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7123 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7124 GDI_EVENT_MASK, event_mask,
7125 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7126 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7130 Fail("cannot create gadget");
7132 level_editor_gadget[id] = gi;
7133 right_gadget_border[id] =
7134 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7138 static void CreateRadiobuttonGadgets(void)
7140 int graphic = IMG_EDITOR_RADIOBUTTON;
7141 struct GraphicInfo *gd = &graphic_info[graphic];
7142 int gd_x1 = gd->src_x;
7143 int gd_y1 = gd->src_y;
7144 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7145 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7146 int gd_x1a = gd->src_x + gd->active_xoffset;
7147 int gd_y1a = gd->src_y + gd->active_yoffset;
7148 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7149 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7150 struct GadgetInfo *gi;
7151 unsigned int event_mask;
7154 event_mask = GD_EVENT_PRESSED;
7156 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7158 int id = radiobutton_info[i].gadget_id;
7159 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7160 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7163 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7165 // determine horizontal position to the right of specified gadget
7166 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7167 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7168 ED_GADGET_TEXT_DISTANCE);
7170 // determine horizontal offset for leading text
7171 if (radiobutton_info[i].text_left != NULL)
7172 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7174 gi = CreateGadget(GDI_CUSTOM_ID, id,
7175 GDI_CUSTOM_TYPE_ID, i,
7176 GDI_IMAGE_ID, graphic,
7177 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7180 GDI_WIDTH, gd->width,
7181 GDI_HEIGHT, gd->height,
7182 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7183 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7184 GDI_CHECKED, checked,
7185 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7186 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7187 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7188 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7189 GDI_EVENT_MASK, event_mask,
7190 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7191 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7195 Fail("cannot create gadget");
7197 level_editor_gadget[id] = gi;
7198 right_gadget_border[id] =
7199 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7203 void CreateLevelEditorGadgets(void)
7205 // force EDITOR font inside level editor
7206 SetFontStatus(GAME_MODE_EDITOR);
7208 // these values are not constant, but can change at runtime
7209 ed_fieldx = MAX_ED_FIELDX - 1;
7210 ed_fieldy = MAX_ED_FIELDY - 1;
7212 num_editor_gadgets = NUM_EDITOR_GADGETS;
7214 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7216 level_editor_gadget =
7217 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7218 right_gadget_border =
7219 checked_calloc(num_editor_gadgets * sizeof(int));
7221 // set number of empty (padding) element buttons to maximum number of buttons
7222 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7224 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7225 editor_el_empty_ptr = editor_el_empty;
7227 use_permanent_palette = !editor.palette.show_as_separate_screen;
7229 ReinitializeElementList();
7231 CreateControlButtons();
7232 CreateScrollbarGadgets();
7234 // order of function calls is important because of cross-references
7235 CreateCheckbuttonGadgets();
7236 CreateCounterButtons();
7237 CreateRadiobuttonGadgets();
7238 CreateTextInputGadgets();
7239 CreateTextAreaGadgets();
7240 CreateSelectboxGadgets();
7241 CreateGraphicbuttonGadgets();
7242 CreateTextbuttonGadgets();
7243 CreateDrawingAreas();
7248 void FreeLevelEditorGadgets(void)
7252 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
7254 for (i = 0; i < num_editor_gadgets; i++)
7256 FreeGadget(level_editor_gadget[i]);
7258 level_editor_gadget[i] = NULL;
7261 checked_free(level_editor_gadget);
7262 checked_free(right_gadget_border);
7264 checked_free(editor_el_empty);
7267 static void MapCounterButtons(int id)
7269 int font_nr = FONT_TEXT_1;
7270 int font_height = getFontHeight(font_nr);
7271 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7272 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7273 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7274 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7275 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7276 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7277 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7278 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7279 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7280 int yoffset = (gi_down->height - font_height) / 2;
7281 int x_left = gi_down->x - xoffset_left;
7282 int x_right; // set after gadget position was modified
7283 int y_above = gi_down->y - yoffset_above;
7285 int y; // set after gadget position was modified
7287 // counter limits must be changed first to prevent value truncation
7288 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7289 counterbutton_info[id].max_value);
7291 // right text position might have changed after setting position above
7292 x_right = gi_up->x + gi_up->width + xoffset_right;
7294 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7296 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
7297 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7298 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7300 ModifyGadget(gi_down, GDI_Y,
7301 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7302 ModifyGadget(gi_text, GDI_Y,
7303 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7304 ModifyGadget(gi_up, GDI_Y,
7305 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7308 // vertical position might have changed after setting position above
7309 y = gi_up->y + yoffset;
7311 if (counterbutton_info[id].text_above)
7312 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
7314 if (counterbutton_info[id].text_left)
7315 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7317 if (counterbutton_info[id].text_right)
7318 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7325 static void MapControlButtons(void)
7330 // map toolbox buttons (excluding special CE toolbox buttons)
7331 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7332 MapGadget(level_editor_gadget[i]);
7334 // map toolbox buttons (element properties buttons)
7335 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
7336 MapGadget(level_editor_gadget[i]);
7338 if (use_permanent_palette)
7340 // map buttons to select elements
7341 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7342 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
7343 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
7344 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
7345 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
7348 // map buttons to select level
7349 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
7350 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
7351 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
7352 MapCounterButtons(counter_id);
7355 static void MapDrawingArea(int id)
7357 int font_nr = FONT_TEXT_1;
7358 int font_height = getFontHeight(font_nr);
7359 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7360 int area_xsize = gi->drawing.area_xsize;
7361 int area_ysize = gi->drawing.area_ysize;
7362 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7363 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
7364 int x_left = gi->x - xoffset_left;
7365 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
7366 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
7367 int x_below = gi->x + (gi->width - xoffset_below) / 2;
7368 int y_side = gi->y + (gi->height - font_height) / 2;
7369 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
7370 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
7372 if (drawingarea_info[id].text_left)
7373 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
7375 if (drawingarea_info[id].text_right)
7376 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
7378 if (drawingarea_info[id].text_above)
7379 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
7381 if (drawingarea_info[id].text_below)
7382 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
7384 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
7386 DrawElementBorder(gi->x, gi->y,
7387 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
7388 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
7390 DrawDrawingArea(id);
7396 static void MapTextInputGadget(int id)
7398 int font_nr = FONT_TEXT_1;
7399 int font_height = getFontHeight(font_nr);
7400 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
7401 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7402 int x_above = ED_SETTINGS_X(textinput_info[id].x);
7403 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
7405 if (textinput_info[id].text_above)
7406 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
7408 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
7413 static void MapTextAreaGadget(int id)
7415 int font_nr = FONT_TEXT_1;
7416 int font_height = getFontHeight(font_nr);
7417 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7418 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7419 int x_above = ED_SETTINGS_X(textarea_info[id].x);
7420 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
7422 if (textarea_info[id].text_above)
7423 DrawTextS(x_above, y_above, font_nr, textarea_info[id].text_above);
7425 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
7430 static void MapSelectboxGadget(int id)
7432 int font_nr = FONT_TEXT_1;
7433 int font_height = getFontHeight(font_nr);
7434 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
7435 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
7436 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7437 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7438 int yoffset = (gi->height - font_height) / 2;
7439 int x_left = gi->x - xoffset_left;
7440 int x_right = gi->x + gi->width + xoffset_right;
7441 int y_above = gi->y - yoffset_above;
7443 int y = gi->y + yoffset;
7445 if (selectbox_info[id].text_above)
7446 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
7448 if (selectbox_info[id].text_left)
7449 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
7451 if (selectbox_info[id].text_right)
7452 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
7454 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
7459 static void MapTextbuttonGadget(int id)
7461 int font_nr = FONT_TEXT_1;
7462 int font_height = getFontHeight(font_nr);
7463 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
7464 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
7465 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7466 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7467 int yoffset = (gi->height - font_height) / 2;
7468 int x_left = gi->x - xoffset_left;
7469 int x_right = gi->x + gi->width + xoffset_right;
7470 int y_above = gi->y - yoffset_above;
7472 int y = gi->y + yoffset;
7474 // only show button to delete change pages when more than minimum pages
7475 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
7476 custom_element.num_change_pages == MIN_CHANGE_PAGES)
7479 if (textbutton_info[id].text_above)
7480 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
7482 if (textbutton_info[id].text_left)
7483 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
7485 if (textbutton_info[id].text_right)
7486 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
7491 static void MapGraphicbuttonGadget(int id)
7493 int font_nr = FONT_TEXT_1;
7494 int font_height = getFontHeight(font_nr);
7495 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
7496 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
7497 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7498 int yoffset = (gi->height - font_height) / 2;
7499 int x_left = gi->x - xoffset_left;
7500 int x_right = gi->x + gi->width + xoffset_right;
7501 int y = gi->y + yoffset;
7503 if (graphicbutton_info[id].text_left)
7504 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
7506 if (graphicbutton_info[id].text_right)
7507 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
7512 static void MapRadiobuttonGadget(int id)
7514 int font_nr = FONT_TEXT_1;
7515 int font_height = getFontHeight(font_nr);
7516 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
7517 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7518 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7519 int yoffset = (gi->height - font_height) / 2;
7520 int x_left = gi->x - xoffset_left;
7521 int x_right = gi->x + gi->width + xoffset_right;
7522 int y = gi->y + yoffset;
7524 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
7526 if (radiobutton_info[id].text_left)
7527 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
7529 if (radiobutton_info[id].text_right)
7530 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
7532 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
7537 static void MapCheckbuttonGadget(int id)
7539 int font_nr = FONT_TEXT_1;
7540 int font_height = getFontHeight(font_nr);
7541 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
7542 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7543 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7544 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7545 int yoffset = (gi->height - font_height) / 2;
7546 int y_above = gi->y - yoffset_above;
7548 int x_left, x_right, y; // set after gadget position was modified
7550 // set position for gadgets with dynamically determined position
7551 if (checkbutton_info[id].x != -1) // do not change dynamic positions
7552 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x),GDI_END);
7553 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
7555 x_left = gi->x - xoffset_left;
7556 x_right = gi->x + gi->width + xoffset_right;
7557 y = gi->y + yoffset;
7559 if (checkbutton_info[id].text_above)
7560 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
7562 if (checkbutton_info[id].text_left)
7563 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
7565 if (checkbutton_info[id].text_right)
7566 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
7568 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
7573 static void MapMainDrawingArea(void)
7575 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
7576 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
7579 if (suppressBorderElement())
7581 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
7582 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
7585 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
7587 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
7588 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
7589 no_horizontal_scrollbar) ||
7590 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
7591 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
7592 no_vertical_scrollbar))
7595 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
7598 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
7600 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
7601 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
7604 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
7607 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
7610 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
7614 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
7616 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
7617 i == GADGET_ID_CUSTOM_COPY_TO ||
7618 i == GADGET_ID_CUSTOM_EXCHANGE ||
7619 i == GADGET_ID_CUSTOM_COPY ||
7620 i == GADGET_ID_CUSTOM_PASTE)
7623 MapGadget(level_editor_gadget[i]);
7625 UnmapGadget(level_editor_gadget[i]);
7630 static void MapLevelEditorToolboxCustomGadgets(void)
7632 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
7635 static void UnmapLevelEditorToolboxCustomGadgets(void)
7637 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
7640 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
7644 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
7646 if (i != GADGET_ID_SINGLE_ITEMS &&
7647 i != GADGET_ID_PICK_ELEMENT)
7649 struct GadgetInfo *gi = level_editor_gadget[i];
7657 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
7658 struct GraphicInfo *gd = &graphic_info[graphic];
7662 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
7663 gi->width, gi->height, gi->x, gi->y);
7665 redraw_mask |= REDRAW_DOOR_3;
7671 static void MapLevelEditorToolboxDrawingGadgets(void)
7673 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
7676 static void UnmapLevelEditorToolboxDrawingGadgets(void)
7678 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
7681 static void UnmapDrawingArea(int id)
7683 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
7686 static void UnmapLevelEditorFieldGadgets(void)
7690 for (i = 0; i < num_editor_gadgets; i++)
7691 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
7692 level_editor_gadget[i]->y))
7693 UnmapGadget(level_editor_gadget[i]);
7696 void UnmapLevelEditorGadgets(void)
7700 for (i = 0; i < num_editor_gadgets; i++)
7701 UnmapGadget(level_editor_gadget[i]);
7704 static void ResetUndoBuffer(void)
7706 undo_buffer_position = -1;
7707 undo_buffer_steps = -1;
7708 redo_buffer_steps = 0;
7710 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7712 level.changed = FALSE;
7715 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
7717 if (remap_toolbox_gadgets)
7719 ModifyEditorElementList();
7720 RedrawDrawingElements();
7723 if (edit_mode == ED_MODE_INFO)
7724 DrawLevelInfoWindow();
7725 else if (edit_mode == ED_MODE_PROPERTIES)
7726 DrawPropertiesWindow();
7727 else if (edit_mode == ED_MODE_PALETTE)
7728 DrawPaletteWindow();
7729 else // edit_mode == ED_MODE_DRAWING
7730 DrawDrawingWindowExt(remap_toolbox_gadgets);
7733 static void DrawEditModeWindow(void)
7735 DrawEditModeWindowExt(TRUE);
7738 static void DrawEditModeWindow_PlayfieldOnly(void)
7740 DrawEditModeWindowExt(FALSE);
7743 static void ChangeEditModeWindow(int new_edit_mode)
7745 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
7747 DrawEditModeWindow();
7750 static boolean LevelChanged(void)
7752 boolean field_changed = FALSE;
7755 for (y = 0; y < lev_fieldy; y++)
7756 for (x = 0; x < lev_fieldx; x++)
7757 if (Tile[x][y] != level.field[x][y])
7758 field_changed = TRUE;
7760 return (level.changed || field_changed);
7763 static boolean PrepareSavingIntoPersonalLevelSet(void)
7765 static LevelDirTree *last_copied_leveldir = NULL;
7766 static LevelDirTree *last_written_leveldir = NULL;
7767 static int last_copied_level_nr = -1;
7768 static int last_written_level_nr = -1;
7769 LevelDirTree *leveldir_former = leveldir_current;
7770 int level_nr_former = level_nr;
7773 // remember last mod/save so that for current session, we write
7774 // back to the same personal copy, asking only about overwrite.
7775 if (leveldir_current == last_copied_leveldir &&
7776 level_nr == last_copied_level_nr)
7778 // "cd" to personal level set dir (as used when writing last copy)
7779 leveldir_current = last_written_leveldir;
7780 level_nr = last_written_level_nr;
7785 if (!Request("This level is read-only! "
7786 "Save into personal level set?", REQ_ASK))
7789 // "cd" to personal level set dir (for writing copy the first time)
7791 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
7793 // this may happen if "setup.internal.create_user_levelset" is FALSE
7794 // or if file "levelinfo.conf" is missing in personal user level set
7795 if (leveldir_current == NULL)
7797 Request("Cannot find personal level set?!", REQ_CONFIRM);
7799 leveldir_current = leveldir_former;
7804 // find unused level number
7805 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
7807 static char *level_filename = NULL;
7809 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
7811 if (!fileExists(level_filename))
7815 last_copied_leveldir = leveldir_former;
7816 last_copied_level_nr = level_nr_former;
7818 last_written_leveldir = leveldir_current;
7819 last_written_level_nr = level_nr = new_level_nr;
7824 static void ModifyLevelInfoForSavingIntoPersonalLevelSet(char *former_name)
7826 static char *filename_levelinfo = NULL, *mod_name = NULL;
7829 // annotate this copy-and-mod in personal levelinfo.conf
7830 setString(&filename_levelinfo,
7831 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
7833 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
7835 fprintf(file, "\n");
7836 fprintf(file, "# level %d was modified from:\n", level_nr);
7837 fprintf(file, "# - previous level set name: %s\n",
7839 fprintf(file, "# - level within previous set: %d \"%s\"\n",
7840 level.file_info.nr, level.name);
7841 fprintf(file, "# - previous author: %s\n",
7843 fprintf(file, "# - previous save date: ");
7845 if (level.creation_date.src == DATE_SRC_LEVELFILE)
7847 fprintf(file, "%04d-%02d-%02d\n",
7848 level.creation_date.year,
7849 level.creation_date.month,
7850 level.creation_date.day);
7854 fprintf(file, "not recorded\n");
7860 if (level_nr > leveldir_current->last_level)
7861 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
7863 // else: allow the save even if annotation failed
7865 // now... spray graffiti on the old level vital statistics
7866 // user can change these; just trying to set a good baseline
7868 // don't truncate names for fear of making offensive or silly:
7869 // long-named original author only recorded in levelinfo.conf.
7870 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
7871 if (!strEqual(level.author, leveldir_current->author))
7873 setString(&mod_name, getStringCat3(leveldir_current->author,
7874 " after ", level.author));
7876 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7877 setString(&mod_name,
7878 getStringCat2(leveldir_current->author, " (ed.)"));
7880 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7881 setString(&mod_name, leveldir_current->author);
7883 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
7885 // less worried about truncation here
7886 setString(&mod_name, getStringCat2("Mod: ", level.name));
7887 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
7891 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
7892 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
7896 for (x = 0; x < lev_fieldx; x++)
7897 for (y = 0; y < lev_fieldy; y++)
7898 dst[x][y] = src[x][y];
7901 static int setSelectboxValue(int selectbox_id, int new_value)
7903 int new_index_value = 0;
7906 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
7907 if (selectbox_info[selectbox_id].options[i].value == new_value)
7908 new_index_value = i;
7910 *selectbox_info[selectbox_id].value =
7911 selectbox_info[selectbox_id].options[new_index_value].value;
7913 return new_index_value;
7916 static void setSelectboxSpecialActionVariablesIfNeeded(void)
7920 // change action mode and arg variables according to action type variable
7921 for (i = 0; action_arg_options[i].value != -1; i++)
7923 if (action_arg_options[i].value == custom_element_change.action_type)
7925 int mode = action_arg_options[i].mode;
7927 // only change if corresponding selectbox has changed
7928 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
7929 action_arg_modes[mode])
7930 custom_element_change.action_mode = -1;
7932 // only change if corresponding selectbox has changed
7933 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
7934 action_arg_options[i].options)
7935 custom_element_change.action_arg = -1;
7942 static void setSelectboxSpecialActionOptions(void)
7946 // change action mode and arg selectbox according to action type selectbox
7947 for (i = 0; action_arg_options[i].value != -1; i++)
7949 if (action_arg_options[i].value == custom_element_change.action_type)
7951 int mode = action_arg_options[i].mode;
7953 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
7954 action_arg_modes[mode]);
7955 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
7956 custom_element_change.action_mode);
7958 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
7959 action_arg_options[i].options);
7960 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
7961 custom_element_change.action_arg);
7967 static void copy_custom_element_settings(int element_from, int element_to)
7969 struct ElementInfo *ei_from = &element_info[element_from];
7970 struct ElementInfo *ei_to = &element_info[element_to];
7972 copyElementInfo(ei_from, ei_to);
7975 static void replace_custom_element_in_settings(int element_from,
7980 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
7982 struct ElementInfo *ei = &element_info[i];
7984 for (y = 0; y < 3; y++)
7985 for (x = 0; x < 3; x++)
7986 if (ei->content.e[x][y] == element_from)
7987 ei->content.e[x][y] = element_to;
7989 for (j = 0; j < ei->num_change_pages; j++)
7991 struct ElementChangeInfo *change = &ei->change_page[j];
7993 if (change->target_element == element_from)
7994 change->target_element = element_to;
7996 if (change->initial_trigger_element == element_from)
7997 change->initial_trigger_element = element_to;
7999 if (change->action_element == element_from)
8000 change->action_element = element_to;
8002 for (y = 0; y < 3; y++)
8003 for (x = 0; x < 3; x++)
8004 if (change->target_content.e[x][y] == element_from)
8005 change->target_content.e[x][y] = element_to;
8008 if (ei->group != NULL) // group or internal
8009 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8010 if (ei->group->element[j] == element_from)
8011 ei->group->element[j] = element_to;
8015 static void replace_custom_element_in_playfield(int element_from,
8020 for (x = 0; x < lev_fieldx; x++)
8021 for (y = 0; y < lev_fieldy; y++)
8022 if (Tile[x][y] == element_from)
8023 Tile[x][y] = element_to;
8026 static boolean CopyCustomElement(int element_old, int element_new,
8029 int copy_mode_orig = copy_mode;
8031 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8033 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8034 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8035 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8037 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8039 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8040 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8041 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8043 level.changed = TRUE;
8045 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8047 Request("Please choose custom element!", REQ_CONFIRM);
8051 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8053 Request("Please choose group element!", REQ_CONFIRM);
8059 level.changed = TRUE;
8062 // when modifying custom/group element, ask for copying level template
8063 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8065 if (!AskToCopyAndModifyLevelTemplate())
8069 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8071 copy_custom_element_settings(element_new, element_old);
8073 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8075 copy_custom_element_settings(element_old, element_new);
8077 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8079 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8080 copy_custom_element_settings(element_new, element_old);
8081 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8083 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8084 replace_custom_element_in_settings(element_new, element_old);
8085 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8087 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8088 replace_custom_element_in_playfield(element_new, element_old);
8089 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8092 UpdateCustomElementGraphicGadgets();
8093 DrawPropertiesWindow();
8098 static void CopyCustomElementPropertiesToEditor(int element)
8101 int current_change_page = element_info[element].current_change_page;
8103 // dynamically (re)build selectbox for selecting change page
8104 for (i = 0; i < element_info[element].num_change_pages; i++)
8106 sprintf(options_change_page_strings[i], "%d", i + 1);
8108 options_change_page[i].value = i;
8109 options_change_page[i].text = options_change_page_strings[i];
8112 options_change_page[i].value = -1;
8113 options_change_page[i].text = NULL;
8115 // needed here to initialize combined element properties
8116 InitElementPropertiesEngine(level.game_version);
8118 element_info[element].change =
8119 &element_info[element].change_page[current_change_page];
8121 custom_element = element_info[element];
8122 custom_element_change = *element_info[element].change;
8124 // needed to initially set selectbox options for special action options
8125 setSelectboxSpecialActionOptions();
8127 // needed to initially set selectbox value variables to reliable defaults
8128 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8129 setSelectboxValue(i, *selectbox_info[i].value);
8131 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8132 custom_element_properties[i] = HAS_PROPERTY(element, i);
8134 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8135 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8137 // ---------- element settings: configure (custom elements) -----------------
8139 // set accessible layer selectbox help value
8140 custom_element.access_type =
8141 (IS_WALKABLE(element) ? EP_WALKABLE :
8142 IS_PASSABLE(element) ? EP_PASSABLE :
8143 custom_element.access_type);
8144 custom_element.access_layer =
8145 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8146 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8147 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8148 custom_element.access_layer);
8149 custom_element.access_protected =
8150 (IS_PROTECTED(element) ? 1 : 0);
8151 custom_element_properties[EP_ACCESSIBLE] =
8152 (IS_ACCESSIBLE_OVER(element) ||
8153 IS_ACCESSIBLE_INSIDE(element) ||
8154 IS_ACCESSIBLE_UNDER(element));
8156 // set walk-to-object action selectbox help value
8157 custom_element.walk_to_action =
8158 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8159 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8160 IS_DROPPABLE(element) ? EP_DROPPABLE :
8161 IS_THROWABLE(element) ? EP_THROWABLE :
8162 IS_PUSHABLE(element) ? EP_PUSHABLE :
8163 custom_element.walk_to_action);
8164 custom_element_properties[EP_WALK_TO_OBJECT] =
8165 (IS_DIGGABLE(element) ||
8166 IS_COLLECTIBLE_ONLY(element) ||
8167 IS_DROPPABLE(element) ||
8168 IS_THROWABLE(element) ||
8169 IS_PUSHABLE(element));
8171 // set smash targets selectbox help value
8172 custom_element.smash_targets =
8173 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8174 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8175 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8176 custom_element.smash_targets);
8177 custom_element_properties[EP_CAN_SMASH] =
8178 (CAN_SMASH_EVERYTHING(element) ||
8179 CAN_SMASH_ENEMIES(element) ||
8180 CAN_SMASH_PLAYER(element));
8182 // set deadliness selectbox help value
8183 custom_element.deadliness =
8184 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8185 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8186 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8187 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8188 custom_element.deadliness);
8189 custom_element_properties[EP_DEADLY] =
8190 (DONT_TOUCH(element) ||
8191 DONT_GET_HIT_BY(element) ||
8192 DONT_COLLIDE_WITH(element) ||
8193 DONT_RUN_INTO(element));
8195 // ---------- element settings: advanced (custom elements) ------------------
8197 // set "change by direct action" selectbox help value
8198 custom_element_change.direct_action =
8199 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8200 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8201 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8202 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8203 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8204 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8205 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8206 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8207 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8208 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8209 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8210 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8211 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8212 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8213 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8214 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8215 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8216 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8217 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
8218 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
8219 custom_element_change.direct_action);
8221 // set "change by other element action" selectbox help value
8222 custom_element_change.other_action =
8223 (HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8224 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8225 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8226 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8227 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8228 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8229 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8230 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8231 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8232 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8233 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8234 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8235 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8236 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8237 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8238 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8239 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8240 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8241 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8242 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8243 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8244 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8245 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8246 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
8247 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
8248 custom_element_change.other_action);
8251 static void CopyGroupElementPropertiesToEditor(int element)
8253 group_element_info = *element_info[element].group;
8254 custom_element = element_info[element]; // needed for description
8257 static void CopyClassicElementPropertiesToEditor(int element)
8259 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
8260 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
8261 getMoveIntoAcidProperty(&level, element);
8263 if (MAYBE_DONT_COLLIDE_WITH(element))
8264 custom_element_properties[EP_DONT_COLLIDE_WITH] =
8265 getDontCollideWithProperty(&level, element);
8268 static void CopyElementPropertiesToEditor(int element)
8270 if (IS_CUSTOM_ELEMENT(element))
8271 CopyCustomElementPropertiesToEditor(element);
8272 else if (IS_GROUP_ELEMENT(element))
8273 CopyGroupElementPropertiesToEditor(element);
8275 CopyClassicElementPropertiesToEditor(element);
8278 static boolean AskToCopyAndModifyLevelTemplate(void)
8280 if (Request("Copy and modify settings from level template?", REQ_ASK))
8282 level.use_custom_template = FALSE;
8284 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
8285 GDI_CHECKED, FALSE, GDI_END);
8286 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
8287 GDI_CHECKED, FALSE, GDI_END);
8293 LoadLevelTemplate(-1); // this resets all element modifications ...
8295 DrawEditModeWindow(); // ... and copies them to 'custom_element'
8301 static void CopyCustomElementPropertiesToGame(int element)
8304 int access_type_and_layer;
8306 // mark that this custom element has been modified
8307 custom_element.modified_settings = TRUE;
8308 level.changed = TRUE;
8310 if (level.use_custom_template)
8311 AskToCopyAndModifyLevelTemplate();
8313 element_info[element] = custom_element;
8314 *element_info[element].change = custom_element_change;
8316 // ---------- element settings: configure (custom elements) -----------------
8318 // set accessible property from checkbox and selectbox
8319 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
8320 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
8321 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
8322 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
8323 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
8324 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
8325 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
8326 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
8327 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
8328 custom_element_properties[access_type_and_layer] =
8329 custom_element_properties[EP_ACCESSIBLE];
8330 custom_element_properties[EP_PROTECTED] =
8331 (custom_element.access_protected != 0 &&
8332 custom_element_properties[EP_ACCESSIBLE]);
8334 // set walk-to-object property from checkbox and selectbox
8335 custom_element_properties[EP_DIGGABLE] = FALSE;
8336 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
8337 custom_element_properties[EP_DROPPABLE] = FALSE;
8338 custom_element_properties[EP_THROWABLE] = FALSE;
8339 custom_element_properties[EP_PUSHABLE] = FALSE;
8340 custom_element_properties[custom_element.walk_to_action] =
8341 custom_element_properties[EP_WALK_TO_OBJECT];
8343 // set smash property from checkbox and selectbox
8344 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
8345 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
8346 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
8347 custom_element_properties[custom_element.smash_targets] =
8348 custom_element_properties[EP_CAN_SMASH];
8350 // set deadliness property from checkbox and selectbox
8351 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
8352 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
8353 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
8354 custom_element_properties[EP_DONT_TOUCH] = FALSE;
8355 custom_element_properties[custom_element.deadliness] =
8356 custom_element_properties[EP_DEADLY];
8358 // ---------- element settings: advanced (custom elements) ------------------
8360 // set player change event from checkbox and selectbox
8361 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
8362 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
8363 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
8364 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
8365 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
8366 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
8367 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
8368 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
8369 custom_element_change_events[CE_SWITCHED] = FALSE;
8370 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
8371 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
8372 custom_element_change_events[CE_BLOCKED] = FALSE;
8373 custom_element_change_events[CE_IMPACT] = FALSE;
8374 custom_element_change_events[CE_SMASHED] = FALSE;
8375 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
8376 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
8377 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
8378 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
8379 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
8380 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
8381 custom_element_change_events[custom_element_change.direct_action] =
8382 custom_element_change_events[CE_BY_DIRECT_ACTION];
8384 // set other element action change event from checkbox and selectbox
8385 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
8386 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
8387 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
8388 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
8389 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
8390 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
8391 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
8392 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
8393 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
8394 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
8395 custom_element_change_events[CE_TOUCHING_X] = FALSE;
8396 custom_element_change_events[CE_HITTING_X] = FALSE;
8397 custom_element_change_events[CE_DIGGING_X] = FALSE;
8398 custom_element_change_events[CE_HIT_BY_X] = FALSE;
8399 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
8400 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
8401 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
8402 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
8403 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
8404 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
8405 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
8406 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
8407 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
8408 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
8409 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
8410 custom_element_change_events[custom_element_change.other_action] =
8411 custom_element_change_events[CE_BY_OTHER_ACTION];
8413 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8414 SET_PROPERTY(element, i, custom_element_properties[i]);
8416 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8417 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
8419 // copy change events also to special level editor variable
8420 custom_element = element_info[element];
8421 custom_element_change = *element_info[element].change;
8423 // needed here to restore runtime value "element_info[element].gfx_element"
8424 InitElementPropertiesGfxElement();
8427 static void CopyGroupElementPropertiesToGame(int element)
8429 // mark that this group element has been modified
8430 custom_element.modified_settings = TRUE;
8431 level.changed = TRUE;
8433 if (level.use_custom_template)
8434 AskToCopyAndModifyLevelTemplate();
8436 element_info[element] = custom_element;
8437 *element_info[element].group = group_element_info;
8439 // needed here to restore runtime value "element_info[element].gfx_element"
8440 InitElementPropertiesGfxElement();
8443 static void CopyClassicElementPropertiesToGame(int element)
8445 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
8446 setMoveIntoAcidProperty(&level, element,
8447 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
8449 if (MAYBE_DONT_COLLIDE_WITH(element))
8450 setDontCollideWithProperty(&level, element,
8451 custom_element_properties[EP_DONT_COLLIDE_WITH]);
8454 static void CopyElementPropertiesToGame(int element)
8456 if (IS_CUSTOM_ELEMENT(element))
8457 CopyCustomElementPropertiesToGame(element);
8458 else if (IS_GROUP_ELEMENT(element))
8459 CopyGroupElementPropertiesToGame(element);
8461 CopyClassicElementPropertiesToGame(element);
8465 static void CheckElementDescriptions(void)
8469 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8470 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
8471 Warn("no element description file for element '%s'", EL_NAME(i));
8475 static int getMaxEdFieldX(boolean has_scrollbar)
8477 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
8478 int sxsize = SXSIZE - scrollbar_width;
8479 int max_ed_fieldx = sxsize / ed_tilesize;
8481 return max_ed_fieldx;
8484 static int getMaxEdFieldY(boolean has_scrollbar)
8486 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
8487 INFOTEXT_YSIZE_FULL : 0);
8488 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
8489 int sysize = SYSIZE - scrollbar_height - infotext_height;
8490 int max_ed_fieldy = sysize / ed_tilesize;
8492 return max_ed_fieldy;
8495 static void InitZoomLevelSettings(int zoom_tilesize)
8497 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
8499 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
8501 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
8502 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
8504 // make sure that tile size is always a power of 2
8505 ed_tilesize = (1 << log_2(ed_tilesize));
8507 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8509 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
8510 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
8514 last_game_engine_type = level.game_engine_type;
8516 // limit zoom tilesize by upper and lower bound
8517 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
8519 // store zoom tilesize in auto setup file only if it was manually changed
8520 if (zoom_tilesize != -1)
8521 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
8523 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
8524 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
8527 static void InitDrawingElements(void)
8529 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
8531 if (level.game_engine_type == game_engine_type_last)
8534 if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
8536 new_element1 = EL_SP_CHIP_SINGLE;
8537 new_element2 = EL_EMPTY;
8538 new_element3 = EL_SP_BASE;
8540 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8542 new_element1 = EL_MM_MIRROR_START;
8543 new_element2 = EL_EMPTY;
8544 new_element3 = EL_MM_WOODEN_WALL;
8548 new_element1 = EL_WALL;
8549 new_element2 = EL_EMPTY;
8550 new_element3 = EL_SAND;
8553 game_engine_type_last = level.game_engine_type;
8556 static void InitLevelSetInfo(void)
8558 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
8559 "%s", leveldir_current->name);
8560 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
8561 "%s", leveldir_current->author);
8563 levelset_num_levels = leveldir_current->levels;
8565 levelset_use_levelset_artwork = FALSE;
8566 levelset_copy_level_template = FALSE;
8568 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
8571 static void ChangeEditorToLevelSet(char *levelset_subdir)
8573 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
8575 // the previous level set might have used custom artwork
8576 ReloadCustomArtwork(0);
8578 LoadLevelSetup_SeriesInfo();
8580 SaveLevelSetup_LastSeries();
8581 SaveLevelSetup_SeriesInfo();
8585 LoadLevel(level_nr);
8586 LoadScore(level_nr);
8591 static boolean useEditorDoorAnimation(void)
8593 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
8594 boolean door_1_viewport_unchanged =
8595 (vp_door_1->x == DX &&
8596 vp_door_1->y == DY &&
8597 vp_door_1->width == DXSIZE &&
8598 vp_door_1->height == DYSIZE);
8599 boolean door_1_contains_toolbox =
8602 EX + EXSIZE <= DX + DXSIZE &&
8603 EY + EYSIZE <= DY + DYSIZE);
8605 return (door_1_viewport_unchanged && door_1_contains_toolbox);
8608 static void DrawEditorDoorBackground(int graphic, int x, int y,
8609 int width, int height)
8611 struct GraphicInfo *g = &graphic_info[graphic];
8613 if (g->bitmap != NULL)
8614 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
8615 MIN(width, g->width), MIN(height, g->height), x, y);
8617 ClearRectangle(drawto, x, y, width, height);
8620 static void DrawEditorDoorContent(void)
8622 // needed for gadgets drawn on background (like palette scrollbar)
8623 SetDoorBackgroundImage(IMG_UNDEFINED);
8625 // copy default editor door content to main double buffer
8626 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
8629 DrawSpecialEditorDoor();
8631 // draw new control window
8632 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
8634 // draw all toolbox gadgets to editor doors
8635 MapControlButtons();
8637 // draw all palette gadgets to editor doors
8638 ModifyEditorElementList();
8639 RedrawDrawingElements();
8641 // copy actual editor door content to door double buffer for OpenDoor()
8642 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
8645 void DrawLevelEd(void)
8647 int fade_mask = REDRAW_FIELD;
8649 FadeSoundsAndMusic();
8652 fade_mask = REDRAW_ALL;
8656 // needed if different viewport properties defined for editor
8657 ChangeViewportPropertiesIfNeeded();
8661 InitZoomLevelSettings(-1);
8662 InitDrawingElements();
8666 CheckElementDescriptions();
8669 if (level_editor_test_game)
8671 CopyPlayfield(level.field, Tile);
8672 CopyPlayfield(TileBackup, level.field);
8674 level_editor_test_game = FALSE;
8678 edit_mode = ED_MODE_DRAWING;
8679 edit_mode_levelinfo = ED_MODE_LEVELINFO_LEVEL;
8680 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
8688 // redraw_mask |= REDRAW_ALL;
8690 FreeLevelEditorGadgets();
8691 CreateLevelEditorGadgets();
8693 ReinitializeElementList(); // update dynamic level element list
8694 ReinitializeElementListButtons(); // custom element may look different
8696 InitElementPropertiesGfxElement();
8700 DrawEditModeWindow_PlayfieldOnly();
8702 DrawMaskedBorder(fade_mask);
8704 // use door animation if door 1 viewport is unchanged and contains toolbox
8705 if (useEditorDoorAnimation())
8709 DrawEditorDoorContent();
8711 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
8715 DrawEditorDoorContent();
8720 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
8723 static void AdjustDrawingAreaGadgets(void)
8725 int ed_xsize = lev_fieldx + 2;
8726 int ed_ysize = lev_fieldy + 2;
8727 int max_ed_fieldx = MAX_ED_FIELDX;
8728 int max_ed_fieldy = MAX_ED_FIELDY;
8729 boolean horizontal_scrollbar_needed;
8730 boolean vertical_scrollbar_needed;
8731 int x, y, width, height;
8733 if (suppressBorderElement())
8735 ed_xsize = max_ed_fieldx;
8736 ed_ysize = max_ed_fieldy;
8739 // check if we need any scrollbars
8740 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8741 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8743 // check if we have a smaller editor field because of scrollbars
8744 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8745 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8747 // check again if we now need more scrollbars because of less space
8748 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8749 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8751 // check if editor field gets even smaller after adding new scrollbars
8752 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8753 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8755 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
8756 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
8758 x = SX + ed_fieldx * ed_tilesize;
8759 y = SY + ed_fieldy * ed_tilesize;
8761 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
8762 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
8764 // adjust drawing area gadget
8765 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
8766 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
8767 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
8770 // adjust horizontal scrollbar gadgets
8771 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
8774 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
8775 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
8778 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8781 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
8784 // adjust vertical scrollbar gadgets
8785 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
8788 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
8790 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
8792 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8795 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
8799 static void AdjustLevelScrollPosition(void)
8801 if (level_xpos < -1)
8803 if (level_xpos > lev_fieldx - ed_fieldx + 1)
8804 level_xpos = lev_fieldx - ed_fieldx + 1;
8805 if (lev_fieldx < ed_fieldx - 2)
8808 if (level_ypos < -1)
8810 if (level_ypos > lev_fieldy - ed_fieldy + 1)
8811 level_ypos = lev_fieldy - ed_fieldy + 1;
8812 if (lev_fieldy < ed_fieldy - 2)
8815 if (suppressBorderElement())
8822 static void AdjustEditorScrollbar(int id)
8824 struct GadgetInfo *gi = level_editor_gadget[id];
8825 int items_max, items_visible, item_position;
8827 if (id == GADGET_ID_SCROLL_HORIZONTAL)
8829 items_max = MAX(lev_fieldx + 2, ed_fieldx);
8830 items_visible = ed_fieldx;
8831 item_position = level_xpos + 1;
8835 items_max = MAX(lev_fieldy + 2, ed_fieldy);
8836 items_visible = ed_fieldy;
8837 item_position = level_ypos + 1;
8840 if (item_position > items_max - items_visible)
8841 item_position = items_max - items_visible;
8843 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8844 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8847 static void AdjustElementListScrollbar(void)
8849 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
8850 int items_max, items_visible, item_position;
8852 // correct position of element list scrollbar
8853 if (element_shift < 0)
8855 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
8856 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
8858 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
8859 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
8860 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
8862 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8863 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
8864 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8867 static void ModifyEditorCounterValue(int counter_id, int new_value)
8869 int *counter_value = counterbutton_info[counter_id].value;
8870 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8871 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8873 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
8875 if (counter_value != NULL)
8876 *counter_value = gi->textinput.number_value;
8879 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
8881 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8882 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8884 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
8886 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
8887 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
8889 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
8890 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8892 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
8893 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
8898 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
8900 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8901 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8902 int new_index_value = setSelectboxValue(selectbox_id, new_value);
8904 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
8907 static void ModifyEditorSelectboxOptions(int selectbox_id,
8908 struct ValueTextInfo *options)
8910 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8911 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8913 selectbox_info[selectbox_id].options = options;
8915 // set index to zero -- list may be shorter now (correct later, if needed)
8916 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
8917 GDI_SELECTBOX_OPTIONS, options, GDI_END);
8920 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
8922 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
8923 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8925 drawingarea_info[drawingarea_id].area_xsize = xsize;
8926 drawingarea_info[drawingarea_id].area_ysize = ysize;
8928 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
8931 static void ModifyEditorElementList(void)
8935 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
8938 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8940 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
8941 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8942 struct GadgetDesign *gd = &gi->deco.design;
8943 int element = editor_elements[element_shift + i];
8944 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
8948 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
8950 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
8956 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
8958 int graphic = el2edimg(element);
8959 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
8965 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
8968 static void ModifyDrawingElementButton(int element, int id)
8970 struct GadgetInfo *gi = level_editor_gadget[id];
8971 Bitmap *deco_bitmap;
8973 int tile_size = gi->deco.width;
8975 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
8977 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
8980 static void PickDrawingElement(int button, int element)
8985 struct XYTileSize *pos;
8987 } de, drawing_elements[] =
8989 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
8990 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
8991 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
8994 if (button < 1 || button > 3)
8997 if (IS_MM_WALL(element))
8998 element = map_mm_wall_element(element);
9000 de = drawing_elements[button - 1];
9002 *de.new_element = element; // update global drawing element variable
9004 DrawDrawingElementGraphic(element, de.pos);
9005 ModifyDrawingElementButton(element, de.id);
9007 redraw_mask |= REDRAW_DOOR_1;
9010 static void RedrawDrawingElements(void)
9012 PickDrawingElement(1, new_element1);
9013 PickDrawingElement(2, new_element2);
9014 PickDrawingElement(3, new_element3);
9017 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9019 stick_element_properties_window = FALSE;
9021 SetMainBackgroundImage(IMG_UNDEFINED);
9024 UnmapLevelEditorFieldGadgets();
9026 AdjustDrawingAreaGadgets();
9027 AdjustLevelScrollPosition();
9028 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9029 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9031 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9033 MapMainDrawingArea();
9035 if (remap_toolbox_gadgets)
9037 UnmapLevelEditorToolboxCustomGadgets();
9038 MapLevelEditorToolboxDrawingGadgets();
9042 static void DrawDrawingWindow(void)
9044 DrawDrawingWindowExt(TRUE);
9047 static int getTabulatorBarWidth(void)
9049 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9050 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9052 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9055 static int getTabulatorBarHeight(void)
9057 return ED_TAB_BAR_HEIGHT;
9060 static Pixel getTabulatorBarColor(void)
9062 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
9063 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9064 int gd_x = gd->x + gd_gi1->border.width / 2;
9065 int gd_y = gd->y + gd_gi1->height - 1;
9067 return GetPixel(gd->bitmap, gd_x, gd_y);
9070 static void DrawLevelInfoTabulatorGadgets(void)
9072 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
9073 Pixel tab_color = getTabulatorBarColor();
9074 int id_first = ED_TAB_BUTTON_ID_LEVELINFO_FIRST;
9075 int id_last = ED_TAB_BUTTON_ID_LEVELINFO_LAST;
9078 for (i = id_first; i <= id_last; i++)
9080 int gadget_id = textbutton_info[i].gadget_id;
9081 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9082 boolean active = (i != edit_mode_levelinfo);
9084 // draw background line below tabulator button
9085 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9087 // draw solid line below inactive tabulator buttons
9088 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9089 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9090 ED_GADGET_TINY_DISTANCE, tab_color);
9092 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9093 MapTextbuttonGadget(i);
9096 // draw little border line below tabulator buttons
9097 if (tab_color != BLACK_PIXEL) // black => transparent
9098 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9099 ED_GADGET_TINY_DISTANCE,
9100 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9103 static void DrawPropertiesTabulatorGadgets(void)
9105 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9106 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9107 int gd_x = gd->x + gd_gi1->border.width / 2;
9108 int gd_y = gd->y + gd_gi1->height - 1;
9109 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9110 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9111 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9114 // draw two config tabulators for player elements
9115 if (ELEM_IS_PLAYER(properties_element))
9116 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9118 // draw two config and one "change" tabulator for custom elements
9119 if (IS_CUSTOM_ELEMENT(properties_element))
9120 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9122 for (i = id_first; i <= id_last; i++)
9124 int gadget_id = textbutton_info[i].gadget_id;
9125 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9126 boolean active = (i != edit_mode_properties);
9128 // use "config 1" and "config 2" instead of "config" for players and CEs
9129 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9130 (ELEM_IS_PLAYER(properties_element) ||
9131 IS_CUSTOM_ELEMENT(properties_element)))
9134 // draw background line below tabulator button
9135 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9137 // draw solid line below inactive tabulator buttons
9138 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9139 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9140 ED_GADGET_TINY_DISTANCE, tab_color);
9142 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9143 MapTextbuttonGadget(i);
9146 // draw little border line below tabulator buttons
9147 if (tab_color != BLACK_PIXEL) // black => transparent
9148 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9149 ED_GADGET_TINY_DISTANCE,
9150 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9153 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9155 DrawText(SX + xpos, SY + ypos, text, font_nr);
9158 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9161 int font_width = getFontWidth(font_nr);
9162 int font_height = getFontHeight(font_nr);
9163 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9164 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9166 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9167 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9168 TRUE, FALSE, FALSE);
9171 static void DrawLevelInfoLevel(void)
9175 // draw counter gadgets
9176 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9177 MapCounterButtons(i);
9179 // draw checkbutton gadgets
9180 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9181 MapCheckbuttonGadget(i);
9183 // draw selectbox gadgets
9184 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9185 MapSelectboxGadget(i);
9187 // draw text input gadgets
9188 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9189 MapTextInputGadget(i);
9192 static char *getLevelSubdirFromSaveMode(int save_mode)
9194 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9195 return getNewUserLevelSubdir();
9197 return leveldir_current->subdir;
9200 static void DrawLevelInfoLevelSet_DirectoryInfo(void)
9202 char *directory_text = "Level set directory:";
9203 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9204 int font1_nr = FONT_TEXT_1;
9205 int font2_nr = FONT_TEXT_2;
9206 int font1_height = getFontHeight(font1_nr);
9207 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
9208 int x = ED_LEVEL_SETTINGS_X(0);
9209 int y = ED_LEVEL_SETTINGS_Y(6);
9211 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
9212 PrintInfoText(directory_name, font2_nr, x, y);
9215 static void DrawLevelInfoLevelSet(void)
9217 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
9218 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
9221 // draw counter gadgets
9222 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
9223 MapCounterButtons(i);
9225 // draw checkbutton gadgets
9226 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
9228 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
9229 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
9230 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
9233 MapCheckbuttonGadget(i);
9236 // draw selectbox gadgets
9237 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
9238 MapSelectboxGadget(i);
9240 // draw text input gadgets
9241 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
9242 MapTextInputGadget(i);
9244 // draw textbutton gadgets
9245 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
9248 DrawLevelInfoLevelSet_DirectoryInfo();
9251 static void DrawLevelInfoEditor(void)
9255 // draw counter gadgets
9256 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
9257 MapCounterButtons(i);
9259 // draw checkbutton gadgets
9260 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
9261 MapCheckbuttonGadget(i);
9263 // draw radiobutton gadgets
9264 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
9265 MapRadiobuttonGadget(i);
9267 // draw drawing area
9268 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
9270 // draw textbutton gadgets
9271 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
9274 static void DrawLevelInfoWindow(void)
9276 char *text = "Global Settings";
9277 int font_nr = FONT_TITLE_1;
9278 struct MenuPosInfo *pos = &editor.settings.headline;
9279 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
9280 int sy = SY + pos->y;
9282 stick_element_properties_window = FALSE;
9284 SetAutomaticNumberOfGemsNeeded();
9286 UnmapLevelEditorFieldGadgets();
9288 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9291 DrawText(sx, sy, text, font_nr);
9293 DrawLevelInfoTabulatorGadgets();
9295 if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVEL)
9296 DrawLevelInfoLevel();
9297 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVELSET)
9298 DrawLevelInfoLevelSet();
9299 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_EDITOR)
9300 DrawLevelInfoEditor();
9303 static void DrawCustomContentArea(void)
9305 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
9306 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9307 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
9308 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
9309 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
9310 int xoffset = ED_GADGET_SPACE_DISTANCE;
9312 // add distance for potential left text (without drawing area border)
9313 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
9315 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9317 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
9320 static void DrawCustomChangeContentArea(void)
9322 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
9323 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9324 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
9325 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
9326 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
9327 int xoffset = ED_GADGET_SPACE_DISTANCE;
9329 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9334 static void RemoveElementContentArea(int id, int font_height)
9336 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9338 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
9339 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
9340 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9341 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
9342 ED_GADGET_TEXT_DISTANCE + font_height);
9345 static void DrawYamYamContentAreas(void)
9347 int font_nr = FONT_TEXT_1;
9348 int font_height = getFontHeight(font_nr);
9349 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9350 int yoffset = (tilesize - font_height) / 2;
9351 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
9352 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
9355 // display counter to choose number of element content areas
9356 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
9358 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9360 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
9362 if (i < level.num_yamyam_contents)
9368 UnmapDrawingArea(id);
9370 // delete content areas in case of reducing number of them
9371 RemoveElementContentArea(id, font_height);
9375 DrawText(x, y + 0 * tilesize, "content", font_nr);
9376 DrawText(x, y + 1 * tilesize, "when", font_nr);
9377 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
9380 static void DrawMagicBallContentAreas(void)
9382 int font_nr = FONT_TEXT_1;
9383 int font_height = getFontHeight(font_nr);
9384 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9385 int yoffset = (tilesize - font_height) / 2;
9386 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
9387 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
9390 // display counter to choose number of element content areas
9391 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
9393 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9395 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
9397 if (i < level.num_ball_contents)
9403 UnmapDrawingArea(id);
9405 // delete content areas in case of reducing number of them
9406 RemoveElementContentArea(id, font_height);
9410 DrawText(x, y + 0 * tilesize, "generated", font_nr);
9411 DrawText(x, y + 1 * tilesize, "when", font_nr);
9412 DrawText(x, y + 2 * tilesize, "active", font_nr);
9415 static void DrawAndroidElementArea(int element)
9417 int id = ED_DRAWING_ID_ANDROID_CONTENT;
9418 int num_elements = level.num_android_clone_elements;
9419 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9420 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9421 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9422 int xsize = MAX_ANDROID_ELEMENTS;
9425 // display counter to choose number of element areas
9426 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
9428 if (drawingarea_info[id].text_left != NULL)
9429 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9431 UnmapDrawingArea(id);
9433 ModifyEditorDrawingArea(id, num_elements, 1);
9435 // delete content areas in case of reducing number of them
9436 DrawBackground(sx, sy,
9437 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9438 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9443 static void DrawGroupElementArea(int element)
9445 int id = ED_DRAWING_ID_GROUP_CONTENT;
9446 int num_elements = group_element_info.num_elements;
9447 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9448 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9449 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9450 int xsize = MAX_ELEMENTS_IN_GROUP;
9453 if (drawingarea_info[id].text_left != NULL)
9454 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9456 UnmapDrawingArea(id);
9458 ModifyEditorDrawingArea(id, num_elements, 1);
9460 // delete content areas in case of reducing number of them
9461 DrawBackground(sx, sy,
9462 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9463 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9468 static void DrawPlayerInitialInventoryArea(int element)
9470 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
9471 int player_nr = GET_PLAYER_NR(element);
9472 int num_elements = level.initial_inventory_size[player_nr];
9473 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9474 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9475 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9476 int xsize = MAX_INITIAL_INVENTORY_SIZE;
9479 // determine horizontal position to the right of specified gadget
9480 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
9481 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
9482 ED_DRAWINGAREA_TEXT_DISTANCE);
9484 // determine horizontal offset for leading text
9485 if (drawingarea_info[id].text_left != NULL)
9486 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9488 UnmapDrawingArea(id);
9490 ModifyEditorDrawingArea(id, num_elements, 1);
9492 // delete content areas in case of reducing number of them
9493 DrawBackground(sx, sy,
9494 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9495 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9500 static void DrawEnvelopeTextArea(int envelope_nr)
9502 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
9503 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
9506 DrawBackground(gi->x, gi->y, gi->width, gi->height);
9508 if (envelope_nr != -1)
9509 textarea_info[id].value = level.envelope[envelope_nr].text;
9511 ModifyGadget(gi, GDI_AREA_SIZE,
9512 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
9513 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
9516 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
9519 static void DrawPropertiesInfo(void)
9528 // configurable properties
9530 { EP_WALKABLE_OVER, "- player can walk over it" },
9531 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
9532 { EP_WALKABLE_UNDER, "- player can walk under it" },
9533 { EP_PASSABLE_OVER, "- player can pass over it" },
9534 { EP_PASSABLE_INSIDE, "- player can pass through it" },
9535 { EP_PASSABLE_UNDER, "- player can pass under it" },
9536 { EP_PROTECTED, "- player is protected by it" },
9538 { EP_DIGGABLE, "- can be digged away" },
9539 { EP_COLLECTIBLE, "- can be collected" },
9540 { EP_DROPPABLE, "- can be dropped after collecting" },
9541 { EP_THROWABLE, "- can be thrown after collecting" },
9542 { EP_PUSHABLE, "- can be pushed" },
9544 { EP_CAN_FALL, "- can fall" },
9545 { EP_CAN_MOVE, "- can move" },
9547 { EP_CAN_SMASH_PLAYER, "- can smash player" },
9549 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
9551 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
9553 { EP_SLIPPERY, "- slippery for falling elements" },
9554 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
9556 { EP_DONT_RUN_INTO, "- deadly when running into" },
9557 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
9558 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
9559 { EP_DONT_TOUCH, "- deadly when touching" },
9561 { EP_INDESTRUCTIBLE, "- indestructible" },
9563 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
9564 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
9565 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
9567 { EP_CAN_CHANGE, "- can change to other element" },
9569 // pre-defined properties
9570 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
9571 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
9572 { EP_SWITCHABLE, "- can be switched" },
9574 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
9579 char *filename = getElementDescriptionFilename(properties_element);
9580 char *percentage_text = "In this level: ";
9581 char *properties_text = "Standard properties: ";
9582 char *description_text = "Description:";
9583 char *no_description_text = "No description available.";
9584 char *none_text = "None";
9586 int num_elements_in_level;
9587 int num_standard_properties = 0;
9588 int font1_nr = FONT_TEXT_1;
9589 int font2_nr = FONT_TEXT_2;
9590 int font1_width = getFontWidth(font1_nr);
9591 int font1_height = getFontHeight(font1_nr);
9592 int font2_height = getFontHeight(font2_nr);
9593 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
9594 int font2_yoffset = (font1_height - font2_height) / 2;
9595 int percentage_text_len = strlen(percentage_text) * font1_width;
9596 int properties_text_len = strlen(properties_text) * font1_width;
9597 int xpos = ED_ELEMENT_SETTINGS_X(0);
9598 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9601 if (setup.editor.show_element_token)
9603 int font3_nr = FONT_TEXT_3;
9604 int font3_height = getFontHeight(font3_nr);
9606 DrawTextF(xpos, ypos, font3_nr,
9607 "[%s]", element_info[properties_element].token_name);
9609 ypos += 2 * font3_height;
9612 // ----- print number of elements / percentage of this element in level
9614 num_elements_in_level = 0;
9615 for (y = 0; y < lev_fieldy; y++)
9616 for (x = 0; x < lev_fieldx; x++)
9617 if (Tile[x][y] == properties_element)
9618 num_elements_in_level++;
9619 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
9621 DrawTextS(xpos, ypos, font1_nr, percentage_text);
9623 if (num_elements_in_level > 0)
9624 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9625 "%d (%.2f %%)", num_elements_in_level, percentage);
9627 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9630 ypos += 2 * MAX(font1_height, font2_height);
9632 // ----- print standard properties of this element
9634 DrawTextS(xpos, ypos, font1_nr, properties_text);
9636 ypos += line1_height;
9638 for (i = 0; properties[i].value != -1; i++)
9640 if (!HAS_PROPERTY(properties_element, properties[i].value))
9643 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
9645 ypos += font2_height;
9647 num_standard_properties++;
9650 if (num_standard_properties == 0)
9652 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
9653 font2_nr, none_text);
9655 ypos -= (line1_height - font1_height);
9658 ypos += MAX(font1_height, font2_height);
9660 // ----- print special description of this element
9662 PrintInfoText(description_text, font1_nr, xpos, ypos);
9664 ypos += line1_height;
9666 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
9667 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
9670 #define TEXT_COLLECTING "Score for collecting"
9671 #define TEXT_SMASHING "Score for smashing"
9672 #define TEXT_SLURPING "Score for slurping robot"
9673 #define TEXT_CRACKING "Score for cracking"
9674 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
9675 #define TEXT_DURATION "Duration when activated"
9676 #define TEXT_DELAY_ON "Delay before activating"
9677 #define TEXT_DELAY_OFF "Delay before deactivating"
9678 #define TEXT_DELAY_EXPLODING "Delay before exploding"
9679 #define TEXT_DELAY_MOVING "Delay before moving"
9680 #define TEXT_BALL_DELAY "Element generation delay"
9681 #define TEXT_MOVE_SPEED "Speed of android moving"
9682 #define TEXT_CLONE_SPEED "Speed of android cloning"
9683 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
9684 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
9685 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
9686 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
9687 #define TEXT_TIME_BONUS "Extra time to solve level"
9694 } elements_with_counter[] =
9696 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
9697 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
9698 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
9699 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
9700 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9701 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
9702 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
9703 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
9704 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
9705 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
9706 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
9707 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
9708 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9709 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9710 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
9711 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
9712 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
9713 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9714 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9715 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
9716 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9717 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9718 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9719 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9720 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9721 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9722 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
9723 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9724 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9725 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9726 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9727 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9728 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9729 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9730 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
9731 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
9732 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9733 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
9734 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9735 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9736 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9737 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9738 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9739 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
9740 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9741 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9742 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
9743 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9744 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9745 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
9746 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
9747 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
9748 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9749 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9750 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9751 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9752 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9753 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9754 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9755 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9756 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
9757 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
9758 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
9759 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
9760 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
9761 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9762 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
9763 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
9764 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
9765 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9766 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9767 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9768 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9769 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9770 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9771 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9772 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9773 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9774 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9775 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9776 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9777 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9778 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
9780 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
9781 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
9782 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
9783 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
9784 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
9785 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
9786 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
9787 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
9788 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
9789 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
9790 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
9791 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
9792 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
9793 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
9794 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
9795 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
9797 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
9798 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
9799 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
9800 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
9801 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
9802 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
9803 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
9804 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
9805 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
9806 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
9807 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
9808 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
9809 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_ON },
9810 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9811 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9816 static boolean checkPropertiesConfig(int element)
9820 if (IS_GEM(element) ||
9821 IS_CUSTOM_ELEMENT(element) ||
9822 IS_GROUP_ELEMENT(element) ||
9823 IS_BALLOON_ELEMENT(element) ||
9824 IS_ENVELOPE(element) ||
9825 IS_MM_MCDUFFIN(element) ||
9826 IS_DF_LASER(element) ||
9827 ELEM_IS_PLAYER(element) ||
9828 HAS_EDITOR_CONTENT(element) ||
9829 CAN_GROW(element) ||
9830 COULD_MOVE_INTO_ACID(element) ||
9831 MAYBE_DONT_COLLIDE_WITH(element) ||
9832 element == EL_SOKOBAN_OBJECT ||
9833 element == EL_SOKOBAN_FIELD_EMPTY ||
9834 element == EL_SOKOBAN_FIELD_FULL)
9837 for (i = 0; elements_with_counter[i].element != -1; i++)
9838 if (elements_with_counter[i].element == element)
9844 static void SetAutomaticNumberOfGemsNeeded(void)
9848 if (!level.auto_count_gems)
9851 level.gems_needed = 0;
9853 for (x = 0; x < lev_fieldx; x++)
9855 for (y = 0; y < lev_fieldy; y++)
9857 int element = Tile[x][y];
9862 case EL_EMERALD_YELLOW:
9863 case EL_EMERALD_RED:
9864 case EL_EMERALD_PURPLE:
9866 case EL_WALL_EMERALD:
9867 case EL_WALL_EMERALD_YELLOW:
9868 case EL_WALL_EMERALD_RED:
9869 case EL_WALL_EMERALD_PURPLE:
9870 case EL_WALL_BD_DIAMOND:
9872 case EL_SP_INFOTRON:
9875 level.gems_needed++;
9879 case EL_WALL_DIAMOND:
9880 level.gems_needed += 3;
9885 level.gems_needed += 5;
9889 case EL_WALL_CRYSTAL:
9890 level.gems_needed += 8;
9899 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
9902 static void DrawPropertiesConfig(void)
9904 boolean draw_footer_line = FALSE;
9905 int max_num_element_counters = 4;
9906 int num_element_counters = 0;
9909 if (!checkPropertiesConfig(properties_element))
9911 int xpos = ED_ELEMENT_SETTINGS_X(0);
9912 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9914 PrintInfoText("No configuration options available.",
9915 FONT_TEXT_1, xpos, ypos);
9920 // check if there are elements where a value can be chosen for
9921 for (i = 0; elements_with_counter[i].element != -1; i++)
9923 if (elements_with_counter[i].element == properties_element)
9925 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
9927 counterbutton_info[counter_id].y =
9928 ED_ELEMENT_SETTINGS_YPOS(
9929 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
9930 (CAN_GROW(properties_element) ? 1 : 0) +
9931 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
9932 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
9933 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
9934 num_element_counters);
9936 counterbutton_info[counter_id].value = elements_with_counter[i].value;
9937 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
9939 if (properties_element == EL_GAME_OF_LIFE ||
9940 properties_element == EL_BIOMAZE)
9942 counterbutton_info[counter_id].min_value = 0; // min neighbours
9943 counterbutton_info[counter_id].max_value = 8; // max neighbours
9947 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
9948 counterbutton_info[counter_id].min_value = MIN_SCORE;
9949 counterbutton_info[counter_id].max_value = MAX_SCORE;
9952 MapCounterButtons(counter_id);
9954 num_element_counters++;
9955 if (num_element_counters >= max_num_element_counters)
9960 if (HAS_EDITOR_CONTENT(properties_element))
9962 // draw stickybutton gadget
9963 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9965 if (IS_AMOEBOID(properties_element))
9966 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
9967 else if (properties_element == EL_YAMYAM ||
9968 properties_element == EL_YAMYAM_LEFT ||
9969 properties_element == EL_YAMYAM_RIGHT ||
9970 properties_element == EL_YAMYAM_UP ||
9971 properties_element == EL_YAMYAM_DOWN)
9972 DrawYamYamContentAreas();
9973 else if (properties_element == EL_EMC_MAGIC_BALL)
9975 DrawMagicBallContentAreas();
9977 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
9978 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
9980 else if (properties_element == EL_EMC_ANDROID)
9981 DrawAndroidElementArea(properties_element);
9984 if (ELEM_IS_PLAYER(properties_element))
9986 int player_nr = GET_PLAYER_NR(properties_element);
9988 // these properties can be set for every player individually
9990 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
9992 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
9993 &level.start_element[player_nr];
9994 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
9995 &level.artwork_element[player_nr];
9996 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
9997 &level.explosion_element[player_nr];
9999 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10000 &level.use_start_element[player_nr];
10001 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10002 &level.use_artwork_element[player_nr];
10003 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10004 &level.use_explosion_element[player_nr];
10005 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10006 &level.initial_player_gravity[player_nr];
10008 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10009 &level.initial_player_stepsize[player_nr];
10011 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
10012 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
10013 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
10014 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
10015 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
10016 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
10017 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
10018 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
10019 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
10020 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
10021 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
10022 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
10023 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
10024 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
10025 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
10027 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
10028 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
10029 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
10031 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
10033 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10035 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
10036 &level.initial_inventory_content[player_nr][0];
10038 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
10039 &level.initial_inventory_size[player_nr];
10041 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
10042 &level.use_initial_inventory[player_nr];
10044 // draw checkbutton gadgets
10045 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
10046 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
10048 // draw counter gadgets
10049 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
10051 // draw drawing area gadgets
10052 DrawPlayerInitialInventoryArea(properties_element);
10056 if (IS_GEM(properties_element))
10057 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
10059 if (properties_element == EL_EM_DYNAMITE)
10060 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
10062 if (COULD_MOVE_INTO_ACID(properties_element) &&
10063 !ELEM_IS_PLAYER(properties_element) &&
10064 (!IS_CUSTOM_ELEMENT(properties_element) ||
10065 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
10067 // set position for checkbutton for "can move into acid"
10068 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
10069 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
10070 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
10071 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
10072 IS_BALLOON_ELEMENT(properties_element) ||
10073 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10075 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
10078 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
10079 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
10081 if (properties_element == EL_SPRING ||
10082 properties_element == EL_SPRING_LEFT ||
10083 properties_element == EL_SPRING_RIGHT)
10084 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
10086 if (properties_element == EL_TIME_ORB_FULL)
10087 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
10089 if (properties_element == EL_GAME_OF_LIFE ||
10090 properties_element == EL_BIOMAZE)
10091 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
10093 if (CAN_GROW(properties_element))
10095 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
10096 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10098 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
10101 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
10102 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
10104 if (properties_element == EL_SOKOBAN_OBJECT)
10105 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
10107 if (properties_element == EL_SOKOBAN_OBJECT ||
10108 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
10109 properties_element == EL_SOKOBAN_FIELD_FULL)
10111 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
10112 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
10115 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
10118 if (IS_BALLOON_ELEMENT(properties_element))
10119 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
10121 if (IS_ENVELOPE(properties_element))
10123 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
10124 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
10125 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
10126 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
10127 int envelope_nr = properties_element - EL_ENVELOPE_1;
10129 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
10130 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
10132 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
10133 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
10135 // display counter to choose size of envelope text area
10136 MapCounterButtons(counter1_id);
10137 MapCounterButtons(counter2_id);
10139 // display checkbuttons to choose auto-wrap and alignment properties
10140 MapCheckbuttonGadget(button1_id);
10141 MapCheckbuttonGadget(button2_id);
10143 DrawEnvelopeTextArea(envelope_nr);
10146 if (IS_MM_MCDUFFIN(properties_element))
10148 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
10149 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
10150 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
10153 if (IS_DF_LASER(properties_element))
10155 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
10156 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
10157 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
10160 if (IS_CUSTOM_ELEMENT(properties_element))
10162 // draw stickybutton gadget
10163 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10165 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10167 // draw checkbutton gadgets
10168 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
10169 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
10170 MapCheckbuttonGadget(i);
10172 // draw counter gadgets
10173 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
10174 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
10175 MapCounterButtons(i);
10177 // draw selectbox gadgets
10178 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
10179 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
10180 MapSelectboxGadget(i);
10182 // draw textbutton gadgets
10183 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10185 // draw text input gadgets
10186 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10188 // draw drawing area gadgets
10189 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10191 draw_footer_line = TRUE;
10193 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10195 // draw checkbutton gadgets
10196 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
10197 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
10198 MapCheckbuttonGadget(i);
10200 // draw counter gadgets
10201 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
10202 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
10203 MapCounterButtons(i);
10205 // draw selectbox gadgets
10206 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
10207 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
10208 MapSelectboxGadget(i);
10210 // draw drawing area gadgets
10211 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
10212 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
10213 DrawCustomContentArea();
10216 else if (IS_GROUP_ELEMENT(properties_element))
10218 // draw stickybutton gadget
10219 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10221 // draw checkbutton gadgets
10222 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10223 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10225 // draw counter gadgets
10226 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
10228 // draw selectbox gadgets
10229 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
10231 // draw textbutton gadgets
10232 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10234 // draw drawing area gadgets
10235 DrawGroupElementArea(properties_element);
10237 // draw text input gadgets
10238 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10240 // draw drawing area gadgets
10241 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10243 draw_footer_line = TRUE;
10246 // draw little footer border line above CE/GE use/save template gadgets
10247 if (draw_footer_line)
10249 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
10250 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
10251 int gd_x = gd->x + gd_gi1->border.width / 2;
10252 int gd_y = gd->y + gd_gi1->height - 1;
10253 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
10255 if (tab_color != BLACK_PIXEL) // black => transparent
10256 FillRectangle(drawto,
10257 SX + ED_ELEMENT_SETTINGS_X(0),
10258 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
10260 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10264 static void DrawPropertiesChangeDrawingAreas(void)
10266 if (IS_CUSTOM_ELEMENT(properties_element))
10268 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
10269 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
10270 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
10272 DrawCustomChangeContentArea();
10275 redraw_mask |= REDRAW_FIELD;
10278 static void DrawPropertiesChange(void)
10282 // needed to initially set selectbox options for special action options
10283 setSelectboxSpecialActionOptions();
10285 // draw stickybutton gadget
10286 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10288 // draw checkbutton gadgets
10289 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
10290 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
10291 MapCheckbuttonGadget(i);
10293 // draw counter gadgets
10294 for (i = ED_COUNTER_ID_CHANGE_FIRST;
10295 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
10296 MapCounterButtons(i);
10298 // draw selectbox gadgets
10299 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
10300 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
10301 MapSelectboxGadget(i);
10303 // draw textbutton gadgets
10304 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
10305 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
10306 MapTextbuttonGadget(i);
10308 // draw graphicbutton gadgets
10309 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
10310 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
10311 MapGraphicbuttonGadget(i);
10313 // draw drawing area gadgets
10314 DrawPropertiesChangeDrawingAreas();
10317 static void DrawEditorElementAnimation(int x, int y)
10319 int graphic = el2img(properties_element);
10320 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
10321 custom_element.ce_value_fixed_initial :
10322 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
10323 custom_element.collect_score_initial : FrameCounter);
10325 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
10328 static void DrawEditorElementName(int x, int y, int font_nr)
10330 char *element_name = getElementInfoText(properties_element);
10331 int font_width = getFontWidth(font_nr);
10332 int font_height = getFontHeight(font_nr);
10333 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
10334 int max_chars_per_line = max_text_width / font_width;
10335 char buffer[max_chars_per_line + 1];
10337 if (strlen(element_name) <= max_chars_per_line)
10338 DrawTextS(x, y, font_nr, element_name);
10341 int next_pos = max_chars_per_line;
10343 strncpy(buffer, element_name, max_chars_per_line);
10344 buffer[max_chars_per_line] = '\0';
10346 if (element_name[max_chars_per_line] == ' ')
10352 for (i = max_chars_per_line - 1; i >= 0; i--)
10353 if (buffer[i] == ' ')
10356 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
10363 DrawTextS(x, y - font_height / 2, font_nr, buffer);
10365 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
10366 buffer[max_chars_per_line] = '\0';
10368 DrawTextS(x, y + font_height / 2, font_nr, buffer);
10372 static void DrawPropertiesWindow(void)
10374 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
10375 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
10376 int border_size = gd->border_size;
10377 int font_nr = FONT_TEXT_1;
10378 int font_height = getFontHeight(font_nr);
10379 int xoffset = TILEX + element_border + 3 * border_size;
10380 int yoffset = (TILEY - font_height) / 2;
10381 int x1 = editor.settings.element_graphic.x + element_border;
10382 int y1 = editor.settings.element_graphic.y + element_border;
10383 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
10384 editor.settings.element_name.x);
10385 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
10386 editor.settings.element_name.y);
10387 char *text = "Element Settings";
10388 int font2_nr = FONT_TITLE_1;
10389 struct MenuPosInfo *pos = &editor.settings.headline;
10390 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
10391 int sy = SY + pos->y;
10393 stick_element_properties_window = FALSE;
10395 // make sure that previous properties edit mode exists for this element
10396 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
10397 !IS_CUSTOM_ELEMENT(properties_element))
10398 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
10400 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
10401 !ELEM_IS_PLAYER(properties_element) &&
10402 !IS_CUSTOM_ELEMENT(properties_element))
10403 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
10405 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
10406 (ELEM_IS_PLAYER(properties_element) ||
10407 IS_CUSTOM_ELEMENT(properties_element)))
10408 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
10410 CopyElementPropertiesToEditor(properties_element);
10412 UnmapLevelEditorFieldGadgets();
10413 UnmapLevelEditorToolboxDrawingGadgets();
10414 UnmapLevelEditorToolboxCustomGadgets();
10416 if (IS_CUSTOM_ELEMENT(properties_element) ||
10417 IS_GROUP_ELEMENT(properties_element))
10418 MapLevelEditorToolboxCustomGadgets();
10420 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10423 DrawText(sx, sy, text, font2_nr);
10425 FrameCounter = 0; // restart animation frame counter
10427 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
10428 DrawEditorElementAnimation(SX + x1, SY + y1);
10429 DrawEditorElementName(x2, y2, font_nr);
10431 DrawPropertiesTabulatorGadgets();
10433 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
10434 DrawPropertiesInfo();
10435 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
10436 DrawPropertiesChange();
10437 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
10438 DrawPropertiesConfig();
10441 static void DrawPaletteWindow(void)
10445 UnmapLevelEditorFieldGadgets();
10447 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10450 // map buttons to select elements
10451 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
10452 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
10453 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
10454 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
10455 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
10458 static void UpdateCustomElementGraphicGadgets(void)
10462 InitElementPropertiesGfxElement();
10464 ModifyEditorElementList();
10465 RedrawDrawingElements();
10467 // force redraw of all mapped drawing area gadgets
10468 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
10470 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
10477 static int getOpenDirectionFromTube(int element)
10481 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
10482 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
10483 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
10484 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
10485 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
10486 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
10487 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
10488 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
10489 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
10490 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
10491 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
10497 static int getTubeFromOpenDirection(int direction)
10501 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
10502 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
10503 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
10504 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
10505 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
10506 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
10507 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
10508 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
10509 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
10510 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
10511 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
10513 // if only one direction, fall back to simple tube with that direction
10514 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
10515 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
10516 case (MV_UP): return EL_TUBE_VERTICAL;
10517 case (MV_DOWN): return EL_TUBE_VERTICAL;
10523 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
10525 int element_new = getTubeFromOpenDirection(direction);
10527 return (element_new != EL_EMPTY ? element_new : element_old);
10530 static int getOpenDirectionFromBelt(int element)
10532 int belt_dir = getBeltDirFromBeltElement(element);
10534 return (belt_dir == MV_LEFT ? MV_RIGHT :
10535 belt_dir == MV_RIGHT ? MV_LEFT :
10536 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
10539 static int getBeltFromNrAndOpenDirection(int nr, int direction)
10541 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
10542 direction == MV_RIGHT ? MV_LEFT :
10543 direction == MV_HORIZONTAL ? MV_NONE : direction);
10545 if (direction == MV_NONE)
10548 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
10551 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
10554 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
10556 return (element_new != EL_EMPTY ? element_new : element_old);
10559 static int getOpenDirectionFromPool(int element)
10563 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
10564 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
10565 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
10566 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
10567 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
10568 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
10574 static int getPoolFromOpenDirection(int direction)
10578 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
10579 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
10580 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
10581 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
10582 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
10583 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
10589 static int getPoolFromOpenDirectionExt(int direction, int help_element)
10591 int element = getPoolFromOpenDirection(direction);
10592 int help_direction = getOpenDirectionFromPool(help_element);
10594 if (element == EL_EMPTY)
10596 int help_direction_vertical = help_direction & MV_VERTICAL;
10598 element = getPoolFromOpenDirection(direction | help_direction_vertical);
10601 if (element == EL_EMPTY)
10603 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
10605 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
10611 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
10613 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
10615 return (element_new != EL_EMPTY ? element_new : element_old);
10618 static int getOpenDirectionFromPillar(int element)
10622 case EL_EMC_WALL_1: return (MV_DOWN);
10623 case EL_EMC_WALL_2: return (MV_VERTICAL);
10624 case EL_EMC_WALL_3: return (MV_UP);
10630 static int getPillarFromOpenDirection(int direction)
10634 case (MV_DOWN): return EL_EMC_WALL_1;
10635 case (MV_VERTICAL): return EL_EMC_WALL_2;
10636 case (MV_UP): return EL_EMC_WALL_3;
10642 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
10644 int element_new = getPillarFromOpenDirection(direction);
10646 return (element_new != EL_EMPTY ? element_new : element_old);
10649 static int getOpenDirectionFromSteel2(int element)
10653 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
10654 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
10655 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
10656 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
10657 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
10658 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
10659 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
10660 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
10666 static int getSteel2FromOpenDirection(int direction)
10670 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
10671 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
10672 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
10673 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
10674 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
10675 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
10676 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
10677 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
10683 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
10685 int element_new = getSteel2FromOpenDirection(direction);
10687 return (element_new != EL_EMPTY ? element_new : element_old);
10690 static int getOpenDirectionFromChip(int element)
10694 case EL_SP_CHIP_SINGLE: return (MV_NONE);
10695 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
10696 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
10697 case EL_SP_CHIP_TOP: return (MV_DOWN);
10698 case EL_SP_CHIP_BOTTOM: return (MV_UP);
10704 static int getChipFromOpenDirection(int direction)
10708 case (MV_NONE): return EL_SP_CHIP_SINGLE;
10709 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
10710 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
10711 case (MV_UP): return EL_SP_CHIP_BOTTOM;
10712 case (MV_DOWN): return EL_SP_CHIP_TOP;
10718 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
10720 int element_new = getChipFromOpenDirection(direction);
10722 return (element_new != EL_EMPTY ? element_new : element_old);
10725 static int getClosedTube(int x, int y)
10727 static int xy[4][2] =
10734 int element_old = IntelliDrawBuffer[x][y];
10735 int direction_old = getOpenDirectionFromTube(element_old);
10736 int direction_new = MV_NONE;
10739 for (i = 0; i < NUM_DIRECTIONS; i++)
10741 int xx = x + xy[i][0];
10742 int yy = y + xy[i][1];
10743 int dir = MV_DIR_FROM_BIT(i);
10744 int dir_opposite = MV_DIR_OPPOSITE(dir);
10746 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
10747 (direction_old & dir) &&
10748 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10749 direction_new |= dir;
10752 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
10755 static int getClosedBelt(int x, int y)
10757 static int xy[4][2] =
10764 int element_old = IntelliDrawBuffer[x][y];
10765 int nr = getBeltNrFromBeltElement(element_old);
10766 int direction_old = getOpenDirectionFromBelt(element_old);
10767 int direction_new = MV_NONE;
10770 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10772 int xx = x + xy[i][0];
10773 int yy = y + xy[i][1];
10774 int dir = MV_DIR_FROM_BIT(i);
10775 int dir_opposite = MV_DIR_OPPOSITE(dir);
10777 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
10778 (direction_old & dir) &&
10779 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10780 direction_new |= dir;
10783 return getBeltFromNrAndOpenDirection(nr, direction_new);
10786 static int getClosedPool(int x, int y)
10788 static int xy[4][2] =
10795 int element_old = IntelliDrawBuffer[x][y];
10796 int direction_old = getOpenDirectionFromPool(element_old);
10797 int direction_new = MV_NONE;
10800 for (i = 0; i < NUM_DIRECTIONS; i++)
10802 int xx = x + xy[i][0];
10803 int yy = y + xy[i][1];
10804 int dir = MV_DIR_FROM_BIT(i);
10805 int dir_opposite = MV_DIR_OPPOSITE(dir);
10807 if (IN_LEV_FIELD(xx, yy) &&
10808 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
10809 (direction_old & dir) &&
10810 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10811 direction_new |= dir;
10814 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
10817 static int getClosedPillar(int x, int y)
10819 static int xy[4][2] =
10826 int element_old = IntelliDrawBuffer[x][y];
10827 int direction_old = getOpenDirectionFromPillar(element_old);
10828 int direction_new = MV_NONE;
10831 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
10833 int xx = x + xy[i][0];
10834 int yy = y + xy[i][1];
10835 int dir = MV_DIR_FROM_BIT(i);
10836 int dir_opposite = MV_DIR_OPPOSITE(dir);
10838 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
10839 (direction_old & dir) &&
10840 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10841 direction_new |= dir;
10844 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
10847 static int getClosedSteel2(int x, int y)
10849 static int xy[4][2] =
10856 int element_old = IntelliDrawBuffer[x][y];
10857 int direction_old = getOpenDirectionFromSteel2(element_old);
10858 int direction_new = MV_NONE;
10861 for (i = 0; i < NUM_DIRECTIONS; i++)
10863 int xx = x + xy[i][0];
10864 int yy = y + xy[i][1];
10865 int dir = MV_DIR_FROM_BIT(i);
10866 int dir_opposite = MV_DIR_OPPOSITE(dir);
10868 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
10869 (direction_old & dir) &&
10870 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10871 direction_new |= dir;
10874 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
10877 static int getClosedChip(int x, int y)
10879 static int xy[4][2] =
10886 int element_old = IntelliDrawBuffer[x][y];
10887 int direction_old = getOpenDirectionFromChip(element_old);
10888 int direction_new = MV_NONE;
10891 for (i = 0; i < NUM_DIRECTIONS; i++)
10893 int xx = x + xy[i][0];
10894 int yy = y + xy[i][1];
10895 int dir = MV_DIR_FROM_BIT(i);
10896 int dir_opposite = MV_DIR_OPPOSITE(dir);
10898 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
10899 (direction_old & dir) &&
10900 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10901 direction_new |= dir;
10904 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
10907 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
10908 boolean change_level)
10910 int sx = x - level_xpos;
10911 int sy = y - level_ypos;
10912 int old_element = Tile[x][y];
10913 int new_element = element;
10914 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
10915 boolean draw_masked = FALSE;
10917 if (IS_MM_WALL_EDITOR(element))
10919 element = map_mm_wall_element_editor(element) | new_bitmask;
10921 if (IS_MM_WALL(old_element))
10922 element |= MM_WALL_BITS(old_element);
10925 draw_masked = TRUE;
10927 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
10929 int element_changed = old_element & ~new_bitmask;
10931 if (MM_WALL_BITS(element_changed) != 0)
10932 element = element_changed;
10935 IntelliDrawBuffer[x][y] = element;
10938 Tile[x][y] = element;
10940 if (IN_ED_FIELD(sx, sy))
10942 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
10943 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
10944 else if (draw_masked)
10945 DrawEditorElementThruMask(sx, sy, element);
10947 DrawEditorElement(sx, sy, element);
10951 static void SetElementSimple(int x, int y, int element, boolean change_level)
10953 SetElementSimpleExt(x, y, 0, 0, element, change_level);
10956 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
10957 int x2, int y2, int *element2,
10958 int (*close_function)(int, int),
10959 boolean change_level)
10961 // set neighbour elements to newly determined connections
10962 SetElementSimple(x1, y1, *element1, change_level);
10963 SetElementSimple(x2, y2, *element2, change_level);
10965 // remove all open connections of neighbour elements
10966 *element1 = close_function(x1, y1);
10967 *element2 = close_function(x2, y2);
10969 // set neighbour elements to new, minimized connections
10970 SetElementSimple(x1, y1, *element1, change_level);
10971 SetElementSimple(x2, y2, *element2, change_level);
10974 static void SetElementIntelliDraw(int x, int y, int new_element,
10975 boolean change_level, int button)
10977 static int xy[4][2] =
10984 static int last_x = -1;
10985 static int last_y = -1;
10987 if (new_element == EL_UNDEFINED)
10995 int old_element = IntelliDrawBuffer[x][y];
10997 if (IS_TUBE(new_element))
10999 int last_element_new = EL_UNDEFINED;
11000 int direction = MV_NONE;
11003 // if old element is of same kind, keep all existing directions
11004 if (IS_TUBE(old_element))
11005 direction |= getOpenDirectionFromTube(old_element);
11007 for (i = 0; i < NUM_DIRECTIONS; i++)
11009 int xx = x + xy[i][0];
11010 int yy = y + xy[i][1];
11012 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11013 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11015 int dir = MV_DIR_FROM_BIT(i);
11016 int dir_opposite = MV_DIR_OPPOSITE(dir);
11017 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11018 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11019 int last_direction_new = last_direction_old | dir_opposite;
11021 last_element_new = getTubeFromOpenDirection(last_direction_new);
11027 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
11029 if (last_element_new != EL_UNDEFINED)
11030 MergeAndCloseNeighbourElements(x, y, &new_element,
11031 last_x, last_y, &last_element_new,
11032 getClosedTube, change_level);
11034 else if (IS_BELT(new_element))
11036 int belt_nr = getBeltNrFromBeltElement(new_element);
11037 int last_element_new = EL_UNDEFINED;
11038 int direction = MV_NONE;
11041 // if old element is of same kind, keep all existing directions
11042 if (IS_BELT(old_element))
11043 direction |= getOpenDirectionFromBelt(old_element);
11045 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11047 int xx = x + xy[i][0];
11048 int yy = y + xy[i][1];
11050 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11051 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
11053 int dir = MV_DIR_FROM_BIT(i);
11054 int dir_opposite = MV_DIR_OPPOSITE(dir);
11055 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11056 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
11057 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
11058 int last_direction_new = last_direction_old | dir_opposite;
11060 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11061 last_direction_new);
11066 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
11068 if (last_element_new != EL_UNDEFINED)
11069 MergeAndCloseNeighbourElements(x, y, &new_element,
11070 last_x, last_y, &last_element_new,
11071 getClosedBelt, change_level);
11073 else if (IS_ACID_POOL_OR_ACID(new_element))
11075 int last_element_new = EL_UNDEFINED;
11076 int direction = MV_NONE;
11079 // if old element is of same kind, keep all existing directions
11080 if (IS_ACID_POOL_OR_ACID(old_element))
11081 direction |= getOpenDirectionFromPool(old_element);
11083 for (i = 0; i < NUM_DIRECTIONS; i++)
11085 int xx = x + xy[i][0];
11086 int yy = y + xy[i][1];
11088 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11089 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
11091 int dir = MV_DIR_FROM_BIT(i);
11092 int dir_opposite = MV_DIR_OPPOSITE(dir);
11093 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11094 int last_direction_old = getOpenDirectionFromPool(last_element_old);
11095 int last_direction_new = last_direction_old | dir_opposite;
11097 last_element_new = getPoolFromOpenDirection(last_direction_new);
11103 // special corrections needed for intuitively correct acid pool drawing
11104 if (last_element_new == EL_EMPTY)
11105 last_element_new = new_element;
11106 else if (last_element_new != EL_UNDEFINED)
11107 new_element = last_element_new;
11109 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
11111 if (last_element_new != EL_UNDEFINED)
11112 MergeAndCloseNeighbourElements(x, y, &new_element,
11113 last_x, last_y, &last_element_new,
11114 getClosedPool, change_level);
11116 else if (IS_EMC_PILLAR(new_element))
11118 int last_element_new = EL_UNDEFINED;
11119 int direction = MV_NONE;
11122 // if old element is of same kind, keep all existing directions
11123 if (IS_EMC_PILLAR(old_element))
11124 direction |= getOpenDirectionFromPillar(old_element);
11126 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11128 int xx = x + xy[i][0];
11129 int yy = y + xy[i][1];
11131 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11132 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
11134 int dir = MV_DIR_FROM_BIT(i);
11135 int dir_opposite = MV_DIR_OPPOSITE(dir);
11136 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11137 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
11138 int last_direction_new = last_direction_old | dir_opposite;
11140 last_element_new = getPillarFromOpenDirection(last_direction_new);
11146 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
11148 if (last_element_new != EL_UNDEFINED)
11149 MergeAndCloseNeighbourElements(x, y, &new_element,
11150 last_x, last_y, &last_element_new,
11151 getClosedPillar, change_level);
11153 else if (IS_DC_STEELWALL_2(new_element))
11155 int last_element_new = EL_UNDEFINED;
11156 int direction = MV_NONE;
11159 // if old element is of same kind, keep all existing directions
11160 if (IS_DC_STEELWALL_2(old_element))
11161 direction |= getOpenDirectionFromSteel2(old_element);
11163 for (i = 0; i < NUM_DIRECTIONS; i++)
11165 int xx = x + xy[i][0];
11166 int yy = y + xy[i][1];
11168 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11169 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
11171 int dir = MV_DIR_FROM_BIT(i);
11172 int dir_opposite = MV_DIR_OPPOSITE(dir);
11173 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11174 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
11175 int last_direction_new = last_direction_old | dir_opposite;
11177 last_element_new = getSteel2FromOpenDirection(last_direction_new);
11183 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
11185 if (last_element_new != EL_UNDEFINED)
11186 MergeAndCloseNeighbourElements(x, y, &new_element,
11187 last_x, last_y, &last_element_new,
11188 getClosedSteel2, change_level);
11190 else if (IS_SP_CHIP(new_element))
11192 int last_element_new = EL_UNDEFINED;
11193 int direction = MV_NONE;
11196 // (do not keep existing directions, regardless of kind of old element)
11198 for (i = 0; i < NUM_DIRECTIONS; i++)
11200 int xx = x + xy[i][0];
11201 int yy = y + xy[i][1];
11203 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11204 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
11206 int dir = MV_DIR_FROM_BIT(i);
11207 int dir_opposite = MV_DIR_OPPOSITE(dir);
11208 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11209 int last_direction_old = getOpenDirectionFromChip(last_element_old);
11210 int last_direction_new = last_direction_old | dir_opposite;
11212 if (last_direction_old == MV_NONE)
11214 last_element_new = getChipFromOpenDirection(last_direction_new);
11217 else if (last_direction_old & (dir | dir_opposite))
11219 direction |= MV_DIR_OPPOSITE(last_direction_old);
11223 direction |= MV_DIR_OPPOSITE(dir);
11228 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
11230 if (last_element_new != EL_UNDEFINED)
11231 MergeAndCloseNeighbourElements(x, y, &new_element,
11232 last_x, last_y, &last_element_new,
11233 getClosedChip, change_level);
11235 else if (IS_SP_HARDWARE_BASE(new_element))
11237 int nr = GetSimpleRandom(6);
11239 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
11240 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
11241 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
11242 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
11243 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
11245 else if (new_element == EL_SP_HARDWARE_GREEN ||
11246 new_element == EL_SP_HARDWARE_BLUE ||
11247 new_element == EL_SP_HARDWARE_RED)
11249 int nr = GetSimpleRandom(3);
11251 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
11252 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
11254 else if (IS_GROUP_ELEMENT(new_element))
11256 boolean connected_drawing = FALSE;
11259 for (i = 0; i < NUM_DIRECTIONS; i++)
11261 int xx = x + xy[i][0];
11262 int yy = y + xy[i][1];
11264 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11265 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
11266 connected_drawing = TRUE;
11269 if (!connected_drawing)
11270 ResolveGroupElement(new_element);
11272 new_element = GetElementFromGroupElement(new_element);
11274 else if (IS_BELT_SWITCH(old_element))
11276 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
11277 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
11279 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
11280 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
11282 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
11286 static int swappable_elements[][2] =
11288 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
11289 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
11290 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
11291 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
11292 { EL_EMERALD, EL_WALL_EMERALD },
11293 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
11294 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
11295 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
11296 { EL_DIAMOND, EL_WALL_DIAMOND },
11297 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
11298 { EL_GATE_1, EL_GATE_1_GRAY },
11299 { EL_GATE_2, EL_GATE_2_GRAY },
11300 { EL_GATE_3, EL_GATE_3_GRAY },
11301 { EL_GATE_4, EL_GATE_4_GRAY },
11302 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
11303 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
11304 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
11305 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
11306 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
11307 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
11308 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
11309 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
11310 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
11311 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
11312 { EL_LAMP, EL_LAMP_ACTIVE },
11313 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
11314 { EL_SP_BASE, EL_SP_BUGGY_BASE },
11315 { EL_PEARL, EL_WALL_PEARL },
11316 { EL_CRYSTAL, EL_WALL_CRYSTAL },
11317 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
11318 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
11319 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
11320 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
11321 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
11322 { EL_LANDMINE, EL_DC_LANDMINE },
11323 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
11324 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
11325 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
11326 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
11327 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
11328 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
11329 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
11330 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
11331 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
11335 static int rotatable_elements_4[][4] =
11345 EL_SPACESHIP_RIGHT,
11350 EL_BD_BUTTERFLY_UP,
11351 EL_BD_BUTTERFLY_RIGHT,
11352 EL_BD_BUTTERFLY_DOWN,
11353 EL_BD_BUTTERFLY_LEFT
11357 EL_BD_FIREFLY_RIGHT,
11358 EL_BD_FIREFLY_DOWN,
11386 EL_SP_GRAVITY_PORT_UP,
11387 EL_SP_GRAVITY_PORT_RIGHT,
11388 EL_SP_GRAVITY_PORT_DOWN,
11389 EL_SP_GRAVITY_PORT_LEFT
11392 EL_SP_GRAVITY_ON_PORT_UP,
11393 EL_SP_GRAVITY_ON_PORT_RIGHT,
11394 EL_SP_GRAVITY_ON_PORT_DOWN,
11395 EL_SP_GRAVITY_ON_PORT_LEFT
11398 EL_SP_GRAVITY_OFF_PORT_UP,
11399 EL_SP_GRAVITY_OFF_PORT_RIGHT,
11400 EL_SP_GRAVITY_OFF_PORT_DOWN,
11401 EL_SP_GRAVITY_OFF_PORT_LEFT
11410 EL_BALLOON_SWITCH_UP,
11411 EL_BALLOON_SWITCH_RIGHT,
11412 EL_BALLOON_SWITCH_DOWN,
11413 EL_BALLOON_SWITCH_LEFT
11417 EL_MM_MCDUFFIN_RIGHT,
11418 EL_MM_MCDUFFIN_DOWN,
11419 EL_MM_MCDUFFIN_LEFT
11422 EL_MM_MIRROR_FIXED_1,
11423 EL_MM_MIRROR_FIXED_4,
11424 EL_MM_MIRROR_FIXED_3,
11425 EL_MM_MIRROR_FIXED_2
11428 EL_MM_STEEL_GRID_FIXED_1,
11429 EL_MM_STEEL_GRID_FIXED_4,
11430 EL_MM_STEEL_GRID_FIXED_2,
11431 EL_MM_STEEL_GRID_FIXED_3
11434 EL_MM_WOODEN_GRID_FIXED_1,
11435 EL_MM_WOODEN_GRID_FIXED_4,
11436 EL_MM_WOODEN_GRID_FIXED_2,
11437 EL_MM_WOODEN_GRID_FIXED_3
11440 EL_MM_POLARIZER_CROSS_1,
11441 EL_MM_POLARIZER_CROSS_4,
11442 EL_MM_POLARIZER_CROSS_3,
11443 EL_MM_POLARIZER_CROSS_2
11447 EL_MM_PACMAN_RIGHT,
11459 EL_DF_RECEIVER_RIGHT,
11460 EL_DF_RECEIVER_DOWN,
11461 EL_DF_RECEIVER_LEFT
11468 static int rotatable_elements_8[][8] =
11471 EL_DF_STEEL_GRID_FIXED_1,
11472 EL_DF_STEEL_GRID_FIXED_8,
11473 EL_DF_STEEL_GRID_FIXED_7,
11474 EL_DF_STEEL_GRID_FIXED_6,
11475 EL_DF_STEEL_GRID_FIXED_5,
11476 EL_DF_STEEL_GRID_FIXED_4,
11477 EL_DF_STEEL_GRID_FIXED_3,
11478 EL_DF_STEEL_GRID_FIXED_2
11481 EL_DF_WOODEN_GRID_FIXED_1,
11482 EL_DF_WOODEN_GRID_FIXED_8,
11483 EL_DF_WOODEN_GRID_FIXED_7,
11484 EL_DF_WOODEN_GRID_FIXED_6,
11485 EL_DF_WOODEN_GRID_FIXED_5,
11486 EL_DF_WOODEN_GRID_FIXED_4,
11487 EL_DF_WOODEN_GRID_FIXED_3,
11488 EL_DF_WOODEN_GRID_FIXED_2
11491 EL_DF_STEEL_GRID_ROTATING_1,
11492 EL_DF_STEEL_GRID_ROTATING_8,
11493 EL_DF_STEEL_GRID_ROTATING_7,
11494 EL_DF_STEEL_GRID_ROTATING_6,
11495 EL_DF_STEEL_GRID_ROTATING_5,
11496 EL_DF_STEEL_GRID_ROTATING_4,
11497 EL_DF_STEEL_GRID_ROTATING_3,
11498 EL_DF_STEEL_GRID_ROTATING_2
11501 EL_DF_WOODEN_GRID_ROTATING_1,
11502 EL_DF_WOODEN_GRID_ROTATING_8,
11503 EL_DF_WOODEN_GRID_ROTATING_7,
11504 EL_DF_WOODEN_GRID_ROTATING_6,
11505 EL_DF_WOODEN_GRID_ROTATING_5,
11506 EL_DF_WOODEN_GRID_ROTATING_4,
11507 EL_DF_WOODEN_GRID_ROTATING_3,
11508 EL_DF_WOODEN_GRID_ROTATING_2
11515 static int rotatable_elements_16[][16] =
11536 EL_MM_TELEPORTER_5,
11537 EL_MM_TELEPORTER_4,
11538 EL_MM_TELEPORTER_3,
11539 EL_MM_TELEPORTER_2,
11540 EL_MM_TELEPORTER_1,
11541 EL_MM_TELEPORTER_16,
11542 EL_MM_TELEPORTER_15,
11543 EL_MM_TELEPORTER_14,
11544 EL_MM_TELEPORTER_13,
11545 EL_MM_TELEPORTER_12,
11546 EL_MM_TELEPORTER_11,
11547 EL_MM_TELEPORTER_10,
11548 EL_MM_TELEPORTER_9,
11549 EL_MM_TELEPORTER_8,
11550 EL_MM_TELEPORTER_7,
11554 EL_MM_TELEPORTER_RED_5,
11555 EL_MM_TELEPORTER_RED_4,
11556 EL_MM_TELEPORTER_RED_3,
11557 EL_MM_TELEPORTER_RED_2,
11558 EL_MM_TELEPORTER_RED_1,
11559 EL_MM_TELEPORTER_RED_16,
11560 EL_MM_TELEPORTER_RED_15,
11561 EL_MM_TELEPORTER_RED_14,
11562 EL_MM_TELEPORTER_RED_13,
11563 EL_MM_TELEPORTER_RED_12,
11564 EL_MM_TELEPORTER_RED_11,
11565 EL_MM_TELEPORTER_RED_10,
11566 EL_MM_TELEPORTER_RED_9,
11567 EL_MM_TELEPORTER_RED_8,
11568 EL_MM_TELEPORTER_RED_7,
11569 EL_MM_TELEPORTER_RED_6
11572 EL_MM_TELEPORTER_YELLOW_5,
11573 EL_MM_TELEPORTER_YELLOW_4,
11574 EL_MM_TELEPORTER_YELLOW_3,
11575 EL_MM_TELEPORTER_YELLOW_2,
11576 EL_MM_TELEPORTER_YELLOW_1,
11577 EL_MM_TELEPORTER_YELLOW_16,
11578 EL_MM_TELEPORTER_YELLOW_15,
11579 EL_MM_TELEPORTER_YELLOW_14,
11580 EL_MM_TELEPORTER_YELLOW_13,
11581 EL_MM_TELEPORTER_YELLOW_12,
11582 EL_MM_TELEPORTER_YELLOW_11,
11583 EL_MM_TELEPORTER_YELLOW_10,
11584 EL_MM_TELEPORTER_YELLOW_9,
11585 EL_MM_TELEPORTER_YELLOW_8,
11586 EL_MM_TELEPORTER_YELLOW_7,
11587 EL_MM_TELEPORTER_YELLOW_6
11590 EL_MM_TELEPORTER_GREEN_5,
11591 EL_MM_TELEPORTER_GREEN_4,
11592 EL_MM_TELEPORTER_GREEN_3,
11593 EL_MM_TELEPORTER_GREEN_2,
11594 EL_MM_TELEPORTER_GREEN_1,
11595 EL_MM_TELEPORTER_GREEN_16,
11596 EL_MM_TELEPORTER_GREEN_15,
11597 EL_MM_TELEPORTER_GREEN_14,
11598 EL_MM_TELEPORTER_GREEN_13,
11599 EL_MM_TELEPORTER_GREEN_12,
11600 EL_MM_TELEPORTER_GREEN_11,
11601 EL_MM_TELEPORTER_GREEN_10,
11602 EL_MM_TELEPORTER_GREEN_9,
11603 EL_MM_TELEPORTER_GREEN_8,
11604 EL_MM_TELEPORTER_GREEN_7,
11605 EL_MM_TELEPORTER_GREEN_6
11608 EL_MM_TELEPORTER_BLUE_5,
11609 EL_MM_TELEPORTER_BLUE_4,
11610 EL_MM_TELEPORTER_BLUE_3,
11611 EL_MM_TELEPORTER_BLUE_2,
11612 EL_MM_TELEPORTER_BLUE_1,
11613 EL_MM_TELEPORTER_BLUE_16,
11614 EL_MM_TELEPORTER_BLUE_15,
11615 EL_MM_TELEPORTER_BLUE_14,
11616 EL_MM_TELEPORTER_BLUE_13,
11617 EL_MM_TELEPORTER_BLUE_12,
11618 EL_MM_TELEPORTER_BLUE_11,
11619 EL_MM_TELEPORTER_BLUE_10,
11620 EL_MM_TELEPORTER_BLUE_9,
11621 EL_MM_TELEPORTER_BLUE_8,
11622 EL_MM_TELEPORTER_BLUE_7,
11623 EL_MM_TELEPORTER_BLUE_6
11627 EL_MM_POLARIZER_16,
11628 EL_MM_POLARIZER_15,
11629 EL_MM_POLARIZER_14,
11630 EL_MM_POLARIZER_13,
11631 EL_MM_POLARIZER_12,
11632 EL_MM_POLARIZER_11,
11633 EL_MM_POLARIZER_10,
11662 EL_DF_MIRROR_ROTATING_1,
11663 EL_DF_MIRROR_ROTATING_16,
11664 EL_DF_MIRROR_ROTATING_15,
11665 EL_DF_MIRROR_ROTATING_14,
11666 EL_DF_MIRROR_ROTATING_13,
11667 EL_DF_MIRROR_ROTATING_12,
11668 EL_DF_MIRROR_ROTATING_11,
11669 EL_DF_MIRROR_ROTATING_10,
11670 EL_DF_MIRROR_ROTATING_9,
11671 EL_DF_MIRROR_ROTATING_8,
11672 EL_DF_MIRROR_ROTATING_7,
11673 EL_DF_MIRROR_ROTATING_6,
11674 EL_DF_MIRROR_ROTATING_5,
11675 EL_DF_MIRROR_ROTATING_4,
11676 EL_DF_MIRROR_ROTATING_3,
11677 EL_DF_MIRROR_ROTATING_2
11686 for (i = 0; swappable_elements[i][0] != -1; i++)
11688 int element1 = swappable_elements[i][0];
11689 int element2 = swappable_elements[i][1];
11691 if (old_element == element1 || old_element == element2)
11692 new_element = (old_element == element1 ? element2 : element1);
11695 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
11697 for (j = 0; j < 4; j++)
11699 int element = rotatable_elements_4[i][j];
11701 if (old_element == element)
11702 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
11703 button == 2 ? rotatable_elements_4[i][0] :
11704 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
11709 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
11711 for (j = 0; j < 8; j++)
11713 int element = rotatable_elements_8[i][j];
11715 if (old_element == element)
11716 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
11717 button == 2 ? rotatable_elements_8[i][0] :
11718 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
11723 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
11725 for (j = 0; j < 16; j++)
11727 int element = rotatable_elements_16[i][j];
11729 if (old_element == element)
11730 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
11731 button == 2 ? rotatable_elements_16[i][0] :
11732 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
11737 if (old_element != new_element)
11739 int max_infotext_len = getMaxInfoTextLength();
11740 char infotext[MAX_OUTPUT_LINESIZE + 1];
11742 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
11743 infotext[max_infotext_len] = '\0';
11745 ClearEditorGadgetInfoText();
11747 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
11752 SetElementSimple(x, y, new_element, change_level);
11758 static void ResetIntelliDraw(void)
11762 for (x = 0; x < lev_fieldx; x++)
11763 for (y = 0; y < lev_fieldy; y++)
11764 IntelliDrawBuffer[x][y] = Tile[x][y];
11766 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
11769 static boolean draw_mode_hires = FALSE;
11771 static boolean isHiresTileElement(int element)
11773 return (IS_MM_WALL(element) || element == EL_EMPTY);
11776 static boolean isHiresDrawElement(int element)
11778 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
11781 static void SetDrawModeHiRes(int element)
11784 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
11785 isHiresDrawElement(element));
11788 static boolean getDrawModeHiRes(void)
11790 return draw_mode_hires;
11793 static int getLoResScreenPos(int pos)
11795 return (getDrawModeHiRes() ? pos / 2 : pos);
11798 static int getLoResScreenMod(int pos)
11800 return (getDrawModeHiRes() ? pos % 2 : 0);
11803 static void SetElementExt(int x, int y, int dx, int dy, int element,
11804 boolean change_level, int button)
11807 SetElementSimple(x, y, Tile[x][y], change_level);
11808 else if (GetKeyModState() & KMOD_Shift && !IS_MM_WALL_EDITOR(element))
11809 SetElementIntelliDraw(x, y, element, change_level, button);
11811 SetElementSimpleExt(x, y, dx, dy, element, change_level);
11814 static void SetElement(int x, int y, int element)
11816 SetElementExt(x, y, 0, 0, element, TRUE, -1);
11819 static void SetElementButton(int x, int y, int dx, int dy, int element,
11822 SetElementExt(x, y, dx, dy, element, TRUE, button);
11825 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
11827 int lx = getLoResScreenPos(sx2) + level_xpos;
11828 int ly = getLoResScreenPos(sy2) + level_ypos;
11829 int dx = getLoResScreenMod(sx2);
11830 int dy = getLoResScreenMod(sy2);
11832 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
11835 static void SetLevelElementHiRes(int lx2, int ly2, int element)
11842 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
11845 static int getLevelElementHiRes(int lx2, int ly2)
11851 int element = Tile[lx][ly];
11852 unsigned int bitmask = (dx + 1) << (dy * 2);
11854 if (IS_MM_WALL(element))
11856 if (element & bitmask)
11857 return map_mm_wall_element(element);
11865 static void DrawLineElement(int x, int y, int element, boolean change_level)
11867 SetElementHiRes(x, y, element, change_level);
11870 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
11871 int element, boolean change_level)
11873 int xsize = ABS(to_x - from_x);
11874 int ysize = ABS(to_y - from_y);
11875 int dx = (to_x < from_x ? -1 : +1);
11876 int dy = (to_y < from_y ? -1 : +1);
11879 if (from_y == to_y) // horizontal line
11881 for (i = 0; i <= xsize; i++)
11882 DrawLineElement(from_x + i * dx, from_y, element, change_level);
11884 else if (from_x == to_x) // vertical line
11886 for (i = 0; i <= ysize; i++)
11887 DrawLineElement(from_x, from_y + i * dy, element, change_level);
11889 else // diagonal line
11891 if (ysize < xsize) // a < 1
11893 float a = (float)ysize / (float)xsize;
11895 for (i = 0; i <= xsize; i++)
11898 int y = dy * (int)(a * i + 0.5);
11900 DrawLineElement(from_x + x, from_y + y, element, change_level);
11905 float a = (float)xsize / (float)ysize;
11907 for (i = 0; i <= ysize; i++)
11909 int x = dx * (int)(a * i + 0.5);
11912 DrawLineElement(from_x + x, from_y + y, element, change_level);
11918 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
11919 int element, boolean change_level)
11921 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
11922 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
11923 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
11924 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
11927 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
11928 int element, boolean change_level)
11933 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
11935 for (y = from_y; y <= to_y; y++)
11936 DrawLine(from_x, y, to_x, y, element, change_level);
11939 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
11940 int element, boolean change_level)
11942 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
11943 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
11944 int len_x = ABS(to_x - from_x);
11945 int len_y = ABS(to_y - from_y);
11948 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
11950 // not optimal (some points get drawn twice) but simple,
11951 // and fast enough for the few points we are drawing
11953 for (x = 0; x <= radius; x++)
11955 int sx, sy, sx2, sy2, lx, ly;
11957 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
11959 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
11960 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
11961 sx = getLoResScreenPos(sx2);
11962 sy = getLoResScreenPos(sy2);
11963 lx = sx + level_xpos;
11964 ly = sy + level_ypos;
11966 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11967 DrawLineElement(sx2, sy2, element, change_level);
11970 for (y = 0; y <= radius; y++)
11972 int sx, sy, sx2, sy2, lx, ly;
11974 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
11976 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
11977 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
11978 sx = getLoResScreenPos(sx2);
11979 sy = getLoResScreenPos(sy2);
11980 lx = sx + level_xpos;
11981 ly = sy + level_ypos;
11983 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11984 DrawLineElement(sx2, sy2, element, change_level);
11988 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
11989 int element, boolean change_level)
11991 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
11992 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
11994 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
11997 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
11999 #if DRAW_CIRCLES_BUTTON_AVAILABLE
12000 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
12001 int element, boolean change_level)
12003 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12004 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12005 int mirror_to_x2 = from_x - (to_x2 - from_x);
12006 int mirror_to_y2 = from_y - (to_y2 - from_y);
12008 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12009 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
12010 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
12011 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
12015 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
12017 int from_sx, from_sy;
12021 swap_numbers(&from_x, &to_x);
12024 swap_numbers(&from_y, &to_y);
12026 from_sx = SX + from_x * ed_tilesize;
12027 from_sy = SY + from_y * ed_tilesize;
12028 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
12029 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
12031 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12032 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12033 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12034 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12036 if (from_x == to_x && from_y == to_y)
12037 MarkTileDirty(from_x/2, from_y/2);
12039 redraw_mask |= REDRAW_FIELD;
12042 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
12043 int element, boolean change_level)
12045 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
12048 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
12049 int element, boolean change_level)
12051 if (element == -1 || change_level)
12052 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
12054 DrawAreaBorder(from_x, from_y, to_x, to_y);
12057 // values for CopyBrushExt()
12058 #define CB_AREA_TO_BRUSH 0
12059 #define CB_BRUSH_TO_CURSOR 1
12060 #define CB_BRUSH_TO_LEVEL 2
12061 #define CB_DELETE_OLD_CURSOR 3
12062 #define CB_DUMP_BRUSH 4
12063 #define CB_DUMP_BRUSH_SMALL 5
12064 #define CB_CLIPBOARD_TO_BRUSH 6
12065 #define CB_BRUSH_TO_CLIPBOARD 7
12066 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
12067 #define CB_UPDATE_BRUSH_POSITION 9
12069 #define MAX_CB_PART_SIZE 10
12070 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
12071 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
12072 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
12073 MAX_CB_NUM_LINES * \
12076 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
12078 DrawLineElement(sx, sy, element, change_level);
12081 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
12082 int button, int mode)
12084 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12085 static int brush_width, brush_height;
12086 static int last_cursor_x = -1, last_cursor_y = -1;
12087 static boolean delete_old_brush = FALSE;
12088 int new_element = BUTTON_ELEMENT(button);
12091 if (mode == CB_DUMP_BRUSH ||
12092 mode == CB_DUMP_BRUSH_SMALL ||
12093 mode == CB_BRUSH_TO_CLIPBOARD ||
12094 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12096 if (edit_mode != ED_MODE_DRAWING)
12099 char part[MAX_CB_PART_SIZE + 1] = "";
12100 char text[MAX_CB_TEXT_SIZE + 1] = "";
12101 int width = (draw_with_brush ? brush_width : lev_fieldx);
12102 int height = (draw_with_brush ? brush_height : lev_fieldy);
12103 char *format = "%s%03d";
12105 for (y = 0; y < height; y++)
12106 for (x = 0; x < width; x++)
12107 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
12110 for (y = 0; y < height; y++)
12112 for (x = 0; x < width; x++)
12114 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
12115 char *prefix = (mode == CB_DUMP_BRUSH ||
12116 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
12118 if (element >= NUM_FILE_ELEMENTS)
12119 element = EL_UNKNOWN;
12121 // copy brush to level sketch text buffer for the R'n'D forum:
12122 // - large tiles: `xxx or `xxxx (0x60 ASCII)
12123 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
12124 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
12125 strcat(text, part);
12128 strcat(text, "\n");
12131 if (mode == CB_BRUSH_TO_CLIPBOARD ||
12132 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12133 SDL_SetClipboardText(text);
12135 Print("%s", text); // print brush data to console and log file
12140 if (mode == CB_CLIPBOARD_TO_BRUSH)
12142 if (edit_mode != ED_MODE_DRAWING)
12145 if (!SDL_HasClipboardText())
12147 Request("Clipboard is empty!", REQ_CONFIRM);
12152 boolean copy_to_brush = (draw_with_brush ||
12153 drawing_function == GADGET_ID_GRAB_BRUSH);
12155 // this will delete the old brush, if already drawing with a brush
12157 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
12159 // initialization is required for "odd" (incomplete) clipboard content
12160 for (x = 0; x < MAX_LEV_FIELDX; x++)
12161 for (y = 0; y < MAX_LEV_FIELDY; y++)
12162 brush_buffer[x][y] = EL_EMPTY;
12169 char *clipboard_text = SDL_GetClipboardText();
12170 char *ptr = clipboard_text;
12171 boolean allow_new_row = FALSE;
12172 boolean stop = FALSE;
12174 while (*ptr && !stop)
12176 boolean prefix_found = FALSE;
12177 boolean start_new_row = FALSE;
12179 // level sketch element number prefixes (may be multi-byte characters)
12180 char *prefix_list[] = { "`", "¸" };
12183 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
12185 char *prefix = prefix_list[i];
12187 // check if string is large enough for prefix
12188 if (strlen(ptr) < strlen(prefix))
12195 // check if string starts with prefix
12196 if (strPrefix(ptr, prefix))
12198 ptr += strlen(prefix);
12200 prefix_found = TRUE;
12206 // check if prefix found and followed by (at least) three digits
12207 if (prefix_found &&
12208 strlen(ptr) >= 3 &&
12209 ptr[0] >= '0' && ptr[0] <= '9' &&
12210 ptr[1] >= '0' && ptr[1] <= '9' &&
12211 ptr[2] >= '0' && ptr[2] <= '9')
12213 int element = ((ptr[0] - '0') * 100 +
12214 (ptr[1] - '0') * 10 +
12219 // level sketch element number might consist of four digits
12220 if (ptr[0] >= '0' && ptr[0] <= '9')
12222 element = element * 10 + (ptr[0] - '0');
12226 // remap some (historic, now obsolete) elements
12227 element = getMappedElement(element);
12229 if (element >= NUM_FILE_ELEMENTS)
12230 element = EL_UNKNOWN;
12232 brush_buffer[x][y] = element;
12234 brush_width = MAX(x + 1, brush_width);
12235 brush_height = MAX(y + 1, brush_height);
12239 if (x >= MAX_LEV_FIELDX)
12240 start_new_row = TRUE;
12242 allow_new_row = TRUE;
12246 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
12247 start_new_row = TRUE;
12249 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
12257 if (y >= MAX_LEV_FIELDY)
12260 allow_new_row = FALSE;
12264 SDL_free(clipboard_text);
12266 if (brush_width == 0 || brush_height == 0)
12268 Request("No level sketch found in clipboard!", REQ_CONFIRM);
12275 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
12278 SDL_GetMouseState(&mx, &my);
12280 // if inside drawing area, activate and draw brush at last mouse position
12281 if (mx >= gi->x && mx < gi->x + gi->width &&
12282 my >= gi->y && my < gi->y + gi->height)
12283 CopyBrushToCursor(last_cursor_x, last_cursor_y);
12285 draw_with_brush = TRUE;
12291 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
12292 brush_width, brush_height);
12294 if (!Request(request, REQ_ASK))
12297 for (x = 0; x < MAX_LEV_FIELDX; x++)
12298 for (y = 0; y < MAX_LEV_FIELDY; y++)
12299 Tile[x][y] = brush_buffer[x][y];
12301 lev_fieldx = level.fieldx = brush_width;
12302 lev_fieldy = level.fieldy = brush_height;
12304 boolean use_em_engine = TRUE;
12305 boolean use_sp_engine = TRUE;
12306 boolean use_mm_engine = TRUE;
12308 for (x = 0; x < MAX_LEV_FIELDX; x++)
12310 for (y = 0; y < MAX_LEV_FIELDY; y++)
12312 int element = Tile[x][y];
12314 if (!IS_EM_ELEMENT(element) && !ELEM_IS_PLAYER(element))
12315 use_em_engine = FALSE;
12317 if (!IS_SP_ELEMENT(element))
12318 use_sp_engine = FALSE;
12320 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
12321 use_mm_engine = FALSE;
12325 level.game_engine_type = (use_em_engine ? GAME_ENGINE_TYPE_EM :
12326 use_sp_engine ? GAME_ENGINE_TYPE_SP :
12327 use_mm_engine ? GAME_ENGINE_TYPE_MM :
12328 GAME_ENGINE_TYPE_RND);
12330 // update element selection list
12331 ReinitializeElementList();
12332 ModifyEditorElementList();
12334 SetBorderElement();
12336 DrawEditModeWindow();
12337 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12343 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
12346 if (mode == CB_AREA_TO_BRUSH)
12348 int from_lx, from_ly;
12351 swap_numbers(&from_x, &to_x);
12354 swap_numbers(&from_y, &to_y);
12356 brush_width = to_x - from_x + 1;
12357 brush_height = to_y - from_y + 1;
12359 from_lx = from_x + level_xpos;
12360 from_ly = from_y + level_ypos;
12362 for (y = 0; y < brush_height; y++)
12364 for (x = 0; x < brush_width; x++)
12366 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
12369 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
12374 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12376 delete_old_brush = FALSE;
12378 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
12379 mode == CB_BRUSH_TO_LEVEL)
12381 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
12382 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
12383 int cursor_from_x = cursor_x - brush_width / 2;
12384 int cursor_from_y = cursor_y - brush_height / 2;
12385 int border_from_x = cursor_x, border_from_y = cursor_y;
12386 int border_to_x = cursor_x, border_to_y = cursor_y;
12388 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
12389 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12391 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
12392 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
12394 delete_old_brush = FALSE;
12399 for (y = 0; y < brush_height; y++)
12401 for (x = 0; x < brush_width; x++)
12403 int sx = cursor_from_x + x;
12404 int sy = cursor_from_y + y;
12405 int lx = sx + level_xpos;
12406 int ly = sy + level_ypos;
12407 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
12408 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
12409 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
12410 brush_buffer[x][y] : new_element);
12412 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12414 if (sx < border_from_x)
12415 border_from_x = sx;
12416 else if (sx > border_to_x)
12418 if (sy < border_from_y)
12419 border_from_y = sy;
12420 else if (sy > border_to_y)
12423 DrawBrushElement(sx, sy, element, change_level);
12428 if (mode != CB_DELETE_OLD_CURSOR)
12429 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
12431 last_cursor_x = cursor_x;
12432 last_cursor_y = cursor_y;
12434 delete_old_brush = TRUE;
12437 if (mode == CB_UPDATE_BRUSH_POSITION)
12439 last_cursor_x = from_x;
12440 last_cursor_y = from_y;
12444 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
12447 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
12450 static void CopyBrushToLevel(int x, int y, int button)
12452 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
12455 static void CopyBrushToCursor(int x, int y)
12457 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
12460 static void UpdateBrushPosition(int x, int y)
12462 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
12465 static void DeleteBrushFromCursor(void)
12467 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12470 void DumpBrush(void)
12472 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
12475 void DumpBrush_Small(void)
12477 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
12480 void CopyClipboardToBrush(void)
12482 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
12485 void CopyBrushToClipboard(void)
12487 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
12490 void CopyBrushToClipboard_Small(void)
12492 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
12495 void UndoLevelEditorOperation(void)
12497 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
12500 void RedoLevelEditorOperation(void)
12502 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
12505 static void FloodFill(int from_x, int from_y, int fill_element)
12507 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
12510 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
12512 int from_x = from_sx2 + 2 * level_xpos;
12513 int from_y = from_sy2 + 2 * level_ypos;
12514 int max_fillx = lev_fieldx * 2;
12515 int max_filly = lev_fieldy * 2;
12516 short Fill[max_fillx][max_filly];
12519 for (x = 0; x < max_fillx; x++)
12520 for (y = 0; y < max_filly; y++)
12521 Fill[x][y] = getLevelElementHiRes(x, y);
12523 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
12524 Fill, max_fillx, max_filly);
12526 for (x = 0; x < max_fillx; x++)
12527 for (y = 0; y < max_filly; y++)
12528 if (Fill[x][y] == fill_element)
12529 SetLevelElementHiRes(x, y, Fill[x][y]);
12532 // values for DrawLevelText() modes
12533 #define TEXT_INIT 0
12534 #define TEXT_SETCURSOR 1
12535 #define TEXT_WRITECHAR 2
12536 #define TEXT_BACKSPACE 3
12537 #define TEXT_NEWLINE 4
12539 #define TEXT_QUERY_TYPING 6
12541 static int DrawLevelText(int sx, int sy, char letter, int mode)
12543 static short delete_buffer[MAX_LEV_FIELDX];
12544 static int start_sx;
12545 static int last_sx, last_sy;
12546 static boolean typing = FALSE;
12547 int letter_element = EL_CHAR_ASCII0 + letter;
12548 int lx = 0, ly = 0;
12550 // map lower case letters to upper case and convert special characters
12551 if (letter >= 'a' && letter <= 'z')
12552 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
12553 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
12554 letter_element = EL_CHAR_AUMLAUT;
12555 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
12556 letter_element = EL_CHAR_OUMLAUT;
12557 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
12558 letter_element = EL_CHAR_UUMLAUT;
12559 else if (letter == '^')
12560 letter_element = EL_CHAR_COPYRIGHT;
12562 letter_element = EL_CHAR_ASCII0 + letter;
12564 if (mode != TEXT_INIT)
12569 if (mode != TEXT_SETCURSOR)
12575 lx = last_sx + level_xpos;
12576 ly = last_sy + level_ypos;
12583 DrawLevelText(0, 0, 0, TEXT_END);
12589 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
12592 case TEXT_SETCURSOR:
12593 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
12594 DrawAreaBorder(sx, sy, sx, sy);
12595 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
12596 ed_tilesize, ed_tilesize);
12601 case TEXT_WRITECHAR:
12602 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
12604 if (new_element1 >= EL_STEEL_CHAR_START &&
12605 new_element1 <= EL_STEEL_CHAR_END)
12606 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
12608 delete_buffer[sx - start_sx] = Tile[lx][ly];
12609 Tile[lx][ly] = letter_element;
12611 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
12612 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
12613 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12614 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12616 DrawLevelText(0, 0, 0, TEXT_END);
12618 level.changed = TRUE;
12622 case TEXT_BACKSPACE:
12625 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
12626 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
12627 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
12632 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12633 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12635 DrawLevelText(0, 0, 0, TEXT_END);
12639 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12640 DrawEditorElement(sx, sy, Tile[lx][ly]);
12645 case TEXT_QUERY_TYPING:
12655 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
12656 int element, boolean change_level)
12658 int lx = sx + level_xpos;
12659 int ly = sy + level_ypos;
12662 DrawEditorElement(sx, sy, Tile[lx][ly]);
12664 DrawAreaBorder(sx, sy, sx, sy);
12667 static void CheckLevelBorderElement(boolean redraw_playfield)
12669 int last_border_element = BorderElement;
12671 SetBorderElement();
12673 if (redraw_playfield && BorderElement != last_border_element)
12674 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12677 static void CopyLevelToUndoBuffer(int mode)
12679 static boolean accumulated_undo = FALSE;
12680 boolean new_undo_buffer_position = TRUE;
12683 if (undo_buffer_steps == 0)
12684 accumulated_undo = FALSE;
12688 case UNDO_IMMEDIATE:
12689 accumulated_undo = FALSE;
12692 case UNDO_ACCUMULATE:
12693 if (accumulated_undo)
12694 new_undo_buffer_position = FALSE;
12695 accumulated_undo = TRUE;
12702 if (new_undo_buffer_position)
12704 // advance position in undo buffer ring
12705 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
12707 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
12708 undo_buffer_steps++;
12711 // always reset redo buffer when storing level change into undo buffer
12712 redo_buffer_steps = 0;
12714 for (x = 0; x < lev_fieldx; x++)
12715 for (y = 0; y < lev_fieldy; y++)
12716 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
12718 // check if drawing operation forces change of border style
12719 CheckLevelBorderElement(TRUE);
12721 level.changed = TRUE;
12724 static void RandomPlacement(int new_element)
12726 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12727 int num_free_positions = 0;
12728 int num_percentage, num_elements;
12731 ResetIntelliDraw();
12733 // determine number of free positions for randomly placing the new element
12734 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
12736 free_position[x][y] =
12737 (random_placement_background_restricted ?
12738 Tile[x][y] == random_placement_background_element :
12739 Tile[x][y] != new_element);
12741 if (free_position[x][y])
12742 num_free_positions++;
12745 // determine number of new elements to place there
12746 num_percentage = num_free_positions * random_placement_value / 100;
12747 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
12748 num_percentage : random_placement_value);
12750 // if less free positions than elements to place, fill all these positions
12751 if (num_free_positions < num_elements)
12753 for (x = 0; x < lev_fieldx; x++)
12754 for (y = 0; y < lev_fieldy; y++)
12755 if (free_position[x][y])
12756 SetElement(x, y, new_element);
12760 while (num_elements > 0)
12762 x = GetSimpleRandom(lev_fieldx);
12763 y = GetSimpleRandom(lev_fieldy);
12765 // don't place element at the same position twice
12766 if (free_position[x][y])
12768 free_position[x][y] = FALSE;
12769 SetElement(x, y, new_element);
12775 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12776 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12779 static void WrapLevel(int dx, int dy)
12781 int wrap_dx = lev_fieldx - dx;
12782 int wrap_dy = lev_fieldy - dy;
12785 for (x = 0; x < lev_fieldx; x++)
12786 for (y = 0; y < lev_fieldy; y++)
12787 TileBackup[x][y] = Tile[x][y];
12789 for (x = 0; x < lev_fieldx; x++)
12790 for (y = 0; y < lev_fieldy; y++)
12792 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
12794 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12795 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
12798 static void DrawAreaElementHighlight(boolean highlighted)
12800 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12807 for (x = 0; x < ed_fieldx; x++)
12809 for (y = 0; y < ed_fieldy; y++)
12811 int lx = x + level_xpos;
12812 int ly = y + level_ypos;
12814 if (!IN_LEV_FIELD(lx, ly))
12817 if (Tile[lx][ly] != new_element1)
12820 int sx = SX + x * ed_tilesize;
12821 int sy = SY + y * ed_tilesize;
12824 int to_sx = sx + ed_tilesize - 1;
12825 int to_sy = sy + ed_tilesize - 1;
12827 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12828 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12829 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12830 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12835 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
12837 char *template_filename_old = getLocalLevelTemplateFilename();
12838 char *template_filename_new =
12839 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
12841 if (copyFile(template_filename_old, template_filename_new) != 0)
12842 Request("Cannot copy level template!", REQ_CONFIRM);
12844 free(template_filename_new);
12847 static void HandleDrawingAreas(struct GadgetInfo *gi)
12849 static boolean started_inside_drawing_area = FALSE;
12850 static int last_sx = -1, last_sy = -1;
12851 static int last_sx2 = -1, last_sy2 = -1;
12852 int id = gi->custom_id;
12853 int type_id = gi->custom_type_id;
12854 boolean button_press_event;
12855 boolean button_release_event;
12856 boolean inside_drawing_area = !gi->event.off_borders;
12857 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
12858 int actual_drawing_function;
12859 int button = gi->event.button;
12860 int new_element = BUTTON_ELEMENT(button);
12861 int sx = gi->event.x, sy = gi->event.y;
12862 int min_sx = 0, min_sy = 0;
12863 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
12864 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
12865 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
12866 int sx2 = gi->event.mx / mini_item_xsize;
12867 int sy2 = gi->event.my / mini_item_ysize;
12870 int lx = 0, ly = 0;
12871 int min_lx = 0, min_ly = 0;
12872 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
12875 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
12876 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
12878 // make sure to stay inside drawing area boundaries
12879 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
12880 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
12884 // get positions inside level field
12885 lx = sx + level_xpos;
12886 ly = sy + level_ypos;
12888 if (!IN_LEV_FIELD(lx, ly))
12889 inside_drawing_area = FALSE;
12891 // make sure to stay inside level field boundaries
12892 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
12893 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
12895 // correct drawing area positions accordingly
12896 sx = lx - level_xpos;
12897 sy = ly - level_ypos;
12900 // also correct MM wall-sized (double) drawing area positions accordingly
12901 if (sx2 / 2 < sx || sx2 / 2 > sx)
12903 dx = (sx2 / 2 < sx ? 0 : 1);
12906 if (sy2 / 2 < sy || sy2 / 2 > sy)
12908 dy = (sy2 / 2 < sy ? 0 : 1);
12912 if (button_release_event)
12919 else if (!button_press_event)
12921 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
12922 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12923 isHiresTileElement(old_element) &&
12924 isHiresDrawElement(new_element));
12926 // prevent handling events for every pixel position when moving mouse
12927 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
12928 (sx2 == last_sx2 && sy2 == last_sy2))
12937 if (button_press_event)
12938 started_inside_drawing_area = inside_drawing_area;
12940 if (!started_inside_drawing_area)
12943 if (!IS_VALID_BUTTON(button))
12946 if (!button && !button_release_event)
12949 // handle info callback for each invocation of action callback
12950 gi->callback_info(gi);
12952 // automatically switch to 'single item' drawing mode, if needed
12953 actual_drawing_function =
12954 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
12955 drawing_function : GADGET_ID_SINGLE_ITEMS);
12957 // clicking into drawing area with pressed Control key picks element
12958 if (GetKeyModState() & KMOD_Control)
12960 last_drawing_function = drawing_function;
12961 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
12964 if (GetKeyModState() & KMOD_Shift)
12966 if (button_press_event || button_release_event)
12967 ResetIntelliDraw();
12970 SetDrawModeHiRes(-1); // reset to normal draw mode
12972 switch (actual_drawing_function)
12974 case GADGET_ID_SINGLE_ITEMS:
12977 if (button_release_event)
12979 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12981 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
12982 !inside_drawing_area)
12983 DeleteBrushFromCursor();
12986 if (!button || button_release_event)
12989 if (draw_with_brush)
12991 CopyBrushToLevel(sx, sy, button);
12995 SetDrawModeHiRes(new_element);
12997 if (ELEM_IS_PLAYER(new_element))
12999 // remove player at old position
13000 for (y = 0; y < lev_fieldy; y++)
13002 for (x = 0; x < lev_fieldx; x++)
13004 int old_element = Tile[x][y];
13006 if (ELEM_IS_PLAYER(old_element))
13008 int replaced_with_element =
13009 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
13010 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
13012 old_element == EL_SOKOBAN_FIELD_PLAYER &&
13013 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
13015 new_element == EL_SOKOBAN_FIELD_PLAYER &&
13016 old_element == EL_PLAYER_1 ? EL_EMPTY :
13018 new_element >= EL_PLAYER_1 &&
13019 new_element <= EL_PLAYER_4 &&
13020 new_element == old_element ? EL_EMPTY :
13024 SetElement(x, y, replaced_with_element);
13030 SetElementButton(lx, ly, dx, dy, new_element, button);
13033 else if (!button_release_event)
13035 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13037 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
13038 DrawMiniGraphicExt(drawto,
13039 gi->x + sx * MINI_TILEX,
13040 gi->y + sy * MINI_TILEY,
13041 el2edimg(new_element));
13043 DrawFixedGraphicExt(drawto,
13044 gi->x + sx * TILEX,
13045 gi->y + sy * TILEY,
13046 el2edimg(new_element), 0);
13048 if (id == GADGET_ID_CUSTOM_GRAPHIC)
13049 new_element = GFX_ELEMENT(new_element);
13051 drawingarea_info[type_id].value[pos] = new_element;
13053 CopyElementPropertiesToGame(properties_element);
13055 if (id == GADGET_ID_CUSTOM_GRAPHIC)
13057 UpdateCustomElementGraphicGadgets();
13059 FrameCounter = 0; // restart animation frame counter
13064 case GADGET_ID_CONNECTED_ITEMS:
13066 static int last_sx = -1;
13067 static int last_sy = -1;
13069 if (button_release_event)
13070 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13074 SetDrawModeHiRes(new_element);
13076 if (getDrawModeHiRes())
13082 if (!button_press_event)
13083 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
13091 case GADGET_ID_LINE:
13092 case GADGET_ID_ARC:
13093 case GADGET_ID_RECTANGLE:
13094 case GADGET_ID_FILLED_BOX:
13095 SetDrawModeHiRes(new_element);
13097 if (getDrawModeHiRes())
13103 case GADGET_ID_GRAB_BRUSH:
13104 case GADGET_ID_TEXT:
13106 static int last_sx = -1;
13107 static int last_sy = -1;
13108 static int start_sx = -1;
13109 static int start_sy = -1;
13110 void (*draw_func)(int, int, int, int, int, boolean);
13112 if (drawing_function == GADGET_ID_LINE)
13113 draw_func = DrawLine;
13114 else if (drawing_function == GADGET_ID_ARC)
13115 draw_func = DrawArc;
13116 else if (drawing_function == GADGET_ID_RECTANGLE)
13117 draw_func = DrawBox;
13118 else if (drawing_function == GADGET_ID_FILLED_BOX)
13119 draw_func = DrawFilledBox;
13120 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
13121 draw_func = SelectArea;
13122 else // (drawing_function == GADGET_ID_TEXT)
13123 draw_func = SetTextCursor;
13125 if (button_press_event)
13127 draw_func(sx, sy, sx, sy, new_element, FALSE);
13128 start_sx = last_sx = sx;
13129 start_sy = last_sy = sy;
13131 if (drawing_function == GADGET_ID_TEXT)
13132 DrawLevelText(0, 0, 0, TEXT_END);
13134 else if (button_release_event)
13136 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
13137 if (drawing_function == GADGET_ID_GRAB_BRUSH)
13139 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
13140 CopyBrushToCursor(sx, sy);
13141 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
13143 draw_with_brush = TRUE;
13145 else if (drawing_function == GADGET_ID_TEXT)
13146 DrawLevelText(sx, sy, 0, TEXT_INIT);
13148 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13150 else if (last_sx != sx || last_sy != sy)
13152 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
13153 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
13154 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
13155 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
13162 case GADGET_ID_FLOOD_FILL:
13163 if (button_press_event && Tile[lx][ly] != new_element)
13165 if (IS_MM_WALL_EDITOR(new_element))
13166 FloodFillWall_MM(sx2, sy2, new_element);
13168 FloodFill(lx, ly, new_element);
13170 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13171 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13175 case GADGET_ID_PICK_ELEMENT:
13176 if (button_release_event)
13177 ClickOnGadget(level_editor_gadget[last_drawing_function],
13179 else if (draw_level)
13180 PickDrawingElement(button, Tile[lx][ly]);
13183 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13185 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
13192 // do not mark level as modified for certain non-level-changing gadgets
13193 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
13194 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
13195 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
13196 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
13199 level.changed = TRUE;
13202 static void HandleCounterButtons(struct GadgetInfo *gi)
13204 int gadget_id = gi->custom_id;
13205 int counter_id = gi->custom_type_id;
13206 int button = gi->event.button;
13207 int *counter_value = counterbutton_info[counter_id].value;
13208 int step = BUTTON_STEPSIZE(button) *
13209 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
13211 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
13213 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
13214 boolean released = (gi->event.type == GD_EVENT_RELEASED);
13215 boolean level_changed = LevelChanged();
13217 if ((level_changed && pressed) || (!level_changed && released))
13220 if (level_changed && !Request("Level has changed! Discard changes?",
13223 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
13224 ModifyEditorCounterValue(counter_id, *counter_value);
13230 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
13231 *counter_value = gi->textinput.number_value;
13233 ModifyEditorCounterValue(counter_id, *counter_value + step);
13235 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
13237 int last_game_engine_type = level.game_engine_type;
13239 LoadLevel(level_nr);
13240 LoadScore(level_nr);
13242 SaveLevelSetup_SeriesInfo();
13247 DrawEditModeWindow();
13249 if (level.game_engine_type != last_game_engine_type)
13251 // update element selection list
13252 ReinitializeElementList();
13253 ModifyEditorElementList();
13259 switch (counter_id)
13261 case ED_COUNTER_ID_YAMYAM_CONTENT:
13262 DrawYamYamContentAreas();
13265 case ED_COUNTER_ID_BALL_CONTENT:
13266 DrawMagicBallContentAreas();
13269 case ED_COUNTER_ID_ANDROID_CONTENT:
13270 DrawAndroidElementArea(properties_element);
13273 case ED_COUNTER_ID_GROUP_CONTENT:
13274 DrawGroupElementArea(properties_element);
13275 CopyGroupElementPropertiesToGame(properties_element);
13278 case ED_COUNTER_ID_INVENTORY_SIZE:
13279 DrawPlayerInitialInventoryArea(properties_element);
13282 case ED_COUNTER_ID_ENVELOPE_XSIZE:
13283 case ED_COUNTER_ID_ENVELOPE_YSIZE:
13284 DrawEnvelopeTextArea(-1);
13287 case ED_COUNTER_ID_LEVEL_XSIZE:
13288 case ED_COUNTER_ID_LEVEL_YSIZE:
13289 lev_fieldx = level.fieldx;
13290 lev_fieldy = level.fieldy;
13292 // check if resizing of level results in change of border border
13293 SetBorderElement();
13301 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
13302 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
13303 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
13304 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
13305 CopyElementPropertiesToGame(properties_element);
13307 // do not mark level as modified for certain non-level-changing gadgets
13308 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
13309 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
13310 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
13311 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
13314 level.changed = TRUE;
13317 static void HandleTextInputGadgets(struct GadgetInfo *gi)
13319 int type_id = gi->custom_type_id;
13321 strcpy(textinput_info[type_id].value, gi->textinput.value);
13323 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
13325 CopyElementPropertiesToGame(properties_element);
13327 ModifyEditorElementList(); // update changed button info text
13330 // do not mark level as modified for certain non-level-changing gadgets
13331 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
13332 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
13335 level.changed = TRUE;
13338 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
13340 int type_id = gi->custom_type_id;
13342 strncpy(textarea_info[type_id].value, gi->textarea.value,
13343 MAX_ENVELOPE_TEXT_LEN);
13344 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
13346 level.changed = TRUE;
13349 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
13351 int type_id = gi->custom_type_id;
13352 int value_old = *selectbox_info[type_id].value;
13353 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
13355 *selectbox_info[type_id].value = value_new;
13357 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
13359 DrawLevelInfoWindow();
13361 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
13363 element_info[properties_element].current_change_page = gi->selectbox.index;
13365 DrawPropertiesWindow();
13367 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
13368 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
13369 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
13370 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
13371 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
13373 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
13375 // when changing action type, also check action mode and action arg
13376 if (value_old != value_new)
13377 setSelectboxSpecialActionVariablesIfNeeded();
13379 DrawPropertiesChange();
13382 CopyElementPropertiesToGame(properties_element);
13384 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
13386 // update element selection list
13387 ReinitializeElementList();
13388 ModifyEditorElementList();
13391 // do not mark level as modified for certain non-level-changing gadgets
13392 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
13393 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
13396 level.changed = TRUE;
13399 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
13401 int type_id = gi->custom_type_id;
13404 if (type_id >= ED_TAB_BUTTON_ID_LEVELINFO_FIRST &&
13405 type_id <= ED_TAB_BUTTON_ID_LEVELINFO_LAST)
13407 edit_mode_levelinfo = gi->custom_type_id;
13409 DrawLevelInfoWindow();
13411 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
13412 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
13414 edit_mode_properties = gi->custom_type_id;
13416 DrawPropertiesWindow();
13418 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
13419 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
13421 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
13423 // backup original "level.field" (needed to track playfield changes)
13424 CopyPlayfield(level.field, TileBackup);
13426 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
13427 CopyPlayfield(Tile, level.field);
13429 if (new_template ||
13430 Request("Save this template and kill the old?", REQ_ASK))
13431 SaveLevelTemplate();
13434 Request("Template saved!", REQ_CONFIRM);
13436 // restore original "level.field" (needed to track playfield changes)
13437 CopyPlayfield(TileBackup, level.field);
13439 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
13441 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
13443 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
13444 leveldir_current->readonly)
13446 Request("This level set is read-only!", REQ_CONFIRM);
13451 if (strEqual(levelset_name, ""))
13453 Request("Please enter level set title!", REQ_CONFIRM);
13458 if (strEqual(levelset_author, ""))
13460 Request("Please enter level set author!", REQ_CONFIRM);
13465 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
13467 if (UpdateUserLevelSet(levelset_subdir,
13470 levelset_num_levels))
13472 Request("Level set updated!", REQ_CONFIRM);
13476 Request("Updating level set failed!", REQ_CONFIRM);
13479 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
13481 if (level.changed && !Request("Level has changed! Discard changes?",
13485 if (CreateUserLevelSet(levelset_subdir,
13488 levelset_num_levels,
13489 levelset_use_levelset_artwork))
13491 if (levelset_copy_level_template)
13492 CopyLevelTemplateToUserLevelSet(levelset_subdir);
13494 Request("New level set created!", REQ_CONFIRM);
13496 AddUserLevelSetToLevelInfo(levelset_subdir);
13497 ChangeEditorToLevelSet(levelset_subdir);
13501 Request("Creating new level set failed!", REQ_CONFIRM);
13505 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
13506 custom_element.num_change_pages < MAX_CHANGE_PAGES)
13508 struct ElementInfo *ei = &element_info[properties_element];
13510 // when modifying custom element, ask for copying level template
13511 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13514 setElementChangePages(ei, ei->num_change_pages + 1);
13516 // set new change page to be new current change page
13517 ei->current_change_page = ei->num_change_pages - 1;
13518 ei->change = &ei->change_page[ei->current_change_page];
13520 setElementChangeInfoToDefaults(ei->change);
13522 DrawPropertiesWindow();
13524 level.changed = TRUE;
13526 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
13527 custom_element.num_change_pages > MIN_CHANGE_PAGES)
13529 struct ElementInfo *ei = &element_info[properties_element];
13531 // when modifying custom element, ask for copying level template
13532 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13535 // copy all change pages after change page to be deleted
13536 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
13537 ei->change_page[i] = ei->change_page[i + 1];
13539 setElementChangePages(ei, ei->num_change_pages - 1);
13541 DrawPropertiesWindow();
13543 level.changed = TRUE;
13547 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
13549 int type_id = gi->custom_type_id;
13551 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
13552 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
13554 struct ElementInfo *ei = &element_info[properties_element];
13555 int step = BUTTON_STEPSIZE(gi->event.button);
13557 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
13558 ei->current_change_page += step;
13560 if (ei->current_change_page < 0)
13561 ei->current_change_page = 0;
13562 else if (ei->current_change_page >= ei->num_change_pages)
13563 ei->current_change_page = ei->num_change_pages - 1;
13565 DrawPropertiesWindow();
13567 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
13568 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13570 struct ElementInfo *ei = &element_info[properties_element];
13571 int current_change_page = ei->current_change_page;
13573 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
13575 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
13576 ei->change_page[current_change_page];
13578 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13580 // when modifying custom element, ask for copying level template
13581 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13584 ei->change_page[current_change_page] =
13585 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
13587 level.changed = TRUE;
13590 DrawPropertiesWindow();
13594 static void HandleRadiobuttons(struct GadgetInfo *gi)
13596 int type_id = gi->custom_type_id;
13598 *radiobutton_info[type_id].value =
13599 radiobutton_info[type_id].checked_value;
13601 // do not mark level as modified for certain non-level-changing gadgets
13602 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
13603 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
13606 level.changed = TRUE;
13609 static void HandleCheckbuttons(struct GadgetInfo *gi)
13611 int type_id = gi->custom_type_id;
13613 *checkbutton_info[type_id].value ^= TRUE;
13615 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
13616 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
13617 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
13618 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
13619 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
13620 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
13621 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
13622 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
13624 CopyElementPropertiesToGame(properties_element);
13627 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
13629 UpdateCustomElementGraphicGadgets();
13631 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
13632 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
13634 boolean template_related_changes_found = FALSE;
13637 // check if any custom or group elements have been changed
13638 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
13639 if ((IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)) &&
13640 element_info[i].modified_settings)
13641 template_related_changes_found = TRUE;
13643 if (level.use_custom_template &&
13644 !fileExists(getGlobalLevelTemplateFilename()))
13646 Request("No level template found!", REQ_CONFIRM);
13648 level.use_custom_template = FALSE;
13650 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13655 if (level.use_custom_template &&
13656 template_related_changes_found &&
13657 !Request("Discard changes and use level template?", REQ_ASK))
13659 level.use_custom_template = FALSE;
13661 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13666 if (!level.use_custom_template &&
13667 Request("Copy settings from level template?", REQ_ASK))
13672 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
13674 DrawEditModeWindow();
13676 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
13678 if (setup.editor.use_template_for_new_levels &&
13679 !fileExists(getGlobalLevelTemplateFilename()))
13681 Request("No level template found!", REQ_CONFIRM);
13686 if (setup.editor.use_template_for_new_levels &&
13688 !Request("Discard level and load template?", REQ_ASK))
13693 if (!setup.editor.use_template_for_new_levels &&
13695 !Request("Discard level and use empty level?", REQ_ASK))
13700 LoadLevel(level_nr);
13701 LoadScore(level_nr);
13706 DrawEditModeWindow();
13708 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
13710 SetAutomaticNumberOfGemsNeeded();
13713 // do not mark level as modified for certain non-level-changing gadgets
13714 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
13715 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
13716 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
13717 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
13718 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
13719 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
13722 level.changed = TRUE;
13725 static void HandleControlButtons(struct GadgetInfo *gi)
13727 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
13728 static int last_edit_mode = ED_MODE_DRAWING;
13729 static int last_custom_copy_mode = -1;
13730 static int last_button = 0;
13731 int id = gi->custom_id;
13732 int button = gi->event.button;
13733 int step = BUTTON_STEPSIZE(button);
13734 int new_element = BUTTON_ELEMENT(button);
13735 int last_properties_element = properties_element;
13738 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
13739 DrawLevelText(0, 0, 0, TEXT_END);
13741 if (id < ED_NUM_CTRL1_BUTTONS &&
13742 id != GADGET_ID_SINGLE_ITEMS &&
13743 id != GADGET_ID_PICK_ELEMENT &&
13744 edit_mode != ED_MODE_DRAWING &&
13745 drawing_function != GADGET_ID_PICK_ELEMENT &&
13746 !(GetKeyModState() & KMOD_Control))
13747 ChangeEditModeWindow(ED_MODE_DRAWING);
13749 // element copy mode active, but no element button pressed => deactivate
13750 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
13751 last_custom_copy_mode = -1;
13753 // when showing palette on element buttons, change element of button used
13754 if (editor.palette.show_on_element_buttons &&
13755 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
13757 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
13759 id = GADGET_ID_PALETTE;
13764 case GADGET_ID_SCROLL_LEFT:
13765 if (level_xpos >= 0)
13767 if (lev_fieldx < ed_fieldx - 2)
13770 level_xpos -= step;
13771 if (level_xpos < -1)
13774 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
13776 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13778 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
13779 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
13783 case GADGET_ID_SCROLL_RIGHT:
13784 if (level_xpos <= lev_fieldx - ed_fieldx)
13786 if (lev_fieldx < ed_fieldx - 2)
13789 level_xpos += step;
13790 if (level_xpos > lev_fieldx - ed_fieldx + 1)
13791 level_xpos = lev_fieldx - ed_fieldx + 1;
13793 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
13795 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13797 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
13798 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
13802 case GADGET_ID_SCROLL_UP:
13803 if (level_ypos >= 0)
13805 if (lev_fieldy < ed_fieldy - 2)
13808 level_ypos -= step;
13809 if (level_ypos < -1)
13812 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
13814 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13816 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13817 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13821 case GADGET_ID_SCROLL_DOWN:
13822 if (level_ypos <= lev_fieldy - ed_fieldy)
13824 if (lev_fieldy < ed_fieldy - 2)
13827 level_ypos += step;
13828 if (level_ypos > lev_fieldy - ed_fieldy + 1)
13829 level_ypos = lev_fieldy - ed_fieldy + 1;
13831 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
13833 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13835 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13836 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13840 case GADGET_ID_SCROLL_HORIZONTAL:
13841 level_xpos = gi->event.item_position - 1;
13843 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13848 case GADGET_ID_SCROLL_VERTICAL:
13849 level_ypos = gi->event.item_position - 1;
13851 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13856 case GADGET_ID_SCROLL_LIST_UP:
13857 case GADGET_ID_SCROLL_LIST_DOWN:
13858 case GADGET_ID_SCROLL_LIST_VERTICAL:
13859 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
13860 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
13863 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
13864 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
13866 if (element_shift < 0)
13868 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
13869 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
13871 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13872 GDI_SCROLLBAR_ITEM_POSITION,
13873 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13876 ModifyEditorElementList();
13880 case GADGET_ID_PROPERTIES:
13881 // always switch off element properties when they are already displayed
13882 last_properties_element = new_element;
13883 case GADGET_ID_ELEMENT_LEFT:
13884 case GADGET_ID_ELEMENT_MIDDLE:
13885 case GADGET_ID_ELEMENT_RIGHT:
13886 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
13887 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
13888 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
13891 if (edit_mode != ED_MODE_PROPERTIES)
13893 last_edit_mode = edit_mode;
13895 ChangeEditModeWindow(ED_MODE_PROPERTIES);
13897 last_level_drawing_function = drawing_function;
13898 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
13901 else if (properties_element != last_properties_element)
13903 DrawEditModeWindow();
13907 ChangeEditModeWindow(ED_MODE_DRAWING);
13909 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
13914 case GADGET_ID_PALETTE:
13915 if (edit_mode != ED_MODE_PALETTE)
13917 last_edit_mode = edit_mode;
13919 ChangeEditModeWindow(ED_MODE_PALETTE);
13923 ChangeEditModeWindow(last_edit_mode);
13927 case GADGET_ID_WRAP_LEFT:
13928 WrapLevel(-step, 0);
13931 case GADGET_ID_WRAP_RIGHT:
13932 WrapLevel(step, 0);
13935 case GADGET_ID_WRAP_UP:
13936 WrapLevel(0, -step);
13939 case GADGET_ID_WRAP_DOWN:
13940 WrapLevel(0, step);
13943 case GADGET_ID_SINGLE_ITEMS:
13944 case GADGET_ID_CONNECTED_ITEMS:
13945 case GADGET_ID_LINE:
13946 case GADGET_ID_ARC:
13947 case GADGET_ID_TEXT:
13948 case GADGET_ID_RECTANGLE:
13949 case GADGET_ID_FILLED_BOX:
13950 case GADGET_ID_FLOOD_FILL:
13951 case GADGET_ID_GRAB_BRUSH:
13952 case GADGET_ID_PICK_ELEMENT:
13953 if (drawing_function != GADGET_ID_PICK_ELEMENT)
13954 last_drawing_function = drawing_function;
13955 drawing_function = id;
13956 draw_with_brush = FALSE;
13959 case GADGET_ID_RANDOM_PLACEMENT:
13960 RandomPlacement(new_element);
13963 case GADGET_ID_ZOOM:
13964 // zoom level editor tile size in or out (or reset to default size)
13965 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
13966 button == 2 ? ed_tilesize_default :
13967 button == 3 ? ed_tilesize / 2 : ed_tilesize);
13969 // when using touch device, cycle through all zoom tilesizes
13970 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
13971 ed_tilesize = MICRO_TILESIZE;
13973 // limit zoom level by upper and lower bound
13974 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
13976 InitZoomLevelSettings(ed_tilesize);
13978 if (edit_mode == ED_MODE_DRAWING)
13980 DrawDrawingWindow();
13982 // redraw zoom gadget info text
13983 PrintEditorGadgetInfoText(level_editor_gadget[id]);
13986 // save current editor zoom tilesize
13987 SaveSetup_AutoSetup();
13991 case GADGET_ID_CUSTOM_COPY_FROM:
13992 case GADGET_ID_CUSTOM_COPY_TO:
13993 case GADGET_ID_CUSTOM_EXCHANGE:
13994 last_custom_copy_mode = id;
13995 last_drawing_function = drawing_function;
13998 case GADGET_ID_CUSTOM_COPY:
13999 CopyCustomElement(properties_element, -1, id);
14002 case GADGET_ID_CUSTOM_PASTE:
14003 CopyCustomElement(-1, properties_element, id);
14006 case GADGET_ID_UNDO:
14007 if (button < 0) // keep button value (even if modifier keys are pressed)
14009 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
14012 if (button == 1 && undo_buffer_steps == 0)
14014 Request("Undo buffer empty!", REQ_CONFIRM);
14018 else if (button == 2)
14022 else if (button == 3 && redo_buffer_steps == 0)
14024 Request("Redo buffer empty!", REQ_CONFIRM);
14029 if (edit_mode != ED_MODE_DRAWING)
14030 ChangeEditModeWindow(ED_MODE_DRAWING);
14036 undo_buffer_position =
14037 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
14039 undo_buffer_steps--;
14040 redo_buffer_steps++;
14046 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
14048 undo_buffer_steps++;
14049 redo_buffer_steps--;
14052 for (x = 0; x < lev_fieldx; x++)
14053 for (y = 0; y < lev_fieldy; y++)
14054 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
14056 // check if undo operation forces change of border style
14057 CheckLevelBorderElement(FALSE);
14059 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14063 case GADGET_ID_INFO:
14064 if (edit_mode != ED_MODE_INFO)
14066 last_edit_mode = edit_mode;
14068 ChangeEditModeWindow(ED_MODE_INFO);
14072 ChangeEditModeWindow(ED_MODE_DRAWING);
14076 case GADGET_ID_CLEAR:
14077 if (edit_mode != ED_MODE_DRAWING)
14078 ChangeEditModeWindow(ED_MODE_DRAWING);
14080 for (x = 0; x < MAX_LEV_FIELDX; x++)
14081 for (y = 0; y < MAX_LEV_FIELDY; y++)
14082 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
14084 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
14086 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14089 case GADGET_ID_SAVE:
14091 // saving read-only levels into personal level set modifies global vars
14092 // "leveldir_current" and "level_nr"; restore them after saving level
14093 LevelDirTree *leveldir_former = leveldir_current;
14094 int level_nr_former = level_nr;
14095 char *level_filename;
14098 if (leveldir_current->readonly &&
14099 !PrepareSavingIntoPersonalLevelSet())
14102 level_filename = getDefaultLevelFilename(level_nr);
14103 new_level = !fileExists(level_filename);
14106 Request("Save this level and kill the old?", REQ_ASK))
14108 if (leveldir_former->readonly)
14109 ModifyLevelInfoForSavingIntoPersonalLevelSet(leveldir_former->name);
14111 SetAutomaticNumberOfGemsNeeded();
14113 CopyPlayfield(Tile, level.field);
14114 SaveLevel(level_nr);
14116 level.changed = FALSE;
14120 char level_saved_msg[64];
14122 if (leveldir_former->readonly)
14123 sprintf(level_saved_msg,
14124 "Level saved as level %d into personal level set!",
14127 strcpy(level_saved_msg, "Level saved!");
14129 Request(level_saved_msg, REQ_CONFIRM);
14133 // "cd" back to copied-from levelset (in case of saved read-only level)
14134 leveldir_current = leveldir_former;
14135 level_nr = level_nr_former;
14140 case GADGET_ID_TEST:
14141 if (LevelChanged())
14142 level.game_version = GAME_VERSION_ACTUAL;
14144 CopyPlayfield(level.field, TileBackup);
14145 CopyPlayfield(Tile, level.field);
14147 CopyNativeLevel_RND_to_Native(&level);
14149 UnmapLevelEditorGadgets();
14150 UndrawSpecialEditorDoor();
14152 CloseDoor(DOOR_CLOSE_ALL);
14154 // needed before playing if editor playfield area has different size
14155 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
14157 // redraw_mask = REDRAW_ALL;
14159 level_editor_test_game = TRUE;
14161 StartGameActions(FALSE, setup.autorecord, level.random_seed);
14165 case GADGET_ID_EXIT:
14166 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
14170 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
14171 id <= GADGET_ID_ELEMENTLIST_LAST)
14173 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
14174 int new_element = editor_elements[element_position + element_shift];
14176 if (IS_EDITOR_CASCADE(new_element))
14180 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
14182 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
14183 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
14185 if (*cascade_element == new_element)
14187 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
14188 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
14190 // update element selection list
14191 ReinitializeElementList();
14192 ModifyEditorElementList();
14194 // update cascading gadget info text
14195 PrintEditorGadgetInfoText(level_editor_gadget[id]);
14197 // save current editor cascading state
14198 SaveSetup_EditorCascade();
14207 if (last_custom_copy_mode != -1)
14209 if (CopyCustomElement(properties_element, new_element,
14210 last_custom_copy_mode))
14212 ClickOnGadget(level_editor_gadget[last_drawing_function],
14215 last_custom_copy_mode = -1;
14221 // change element of button used to show palette
14222 if (editor.palette.show_on_element_buttons)
14223 button = last_button;
14225 PickDrawingElement(button, new_element);
14227 if (!stick_element_properties_window &&
14228 drawing_function != GADGET_ID_PICK_ELEMENT &&
14229 !(GetKeyModState() & KMOD_Control))
14231 properties_element = new_element;
14232 if (edit_mode == ED_MODE_PROPERTIES)
14233 DrawPropertiesWindow();
14236 if (drawing_function == GADGET_ID_PICK_ELEMENT)
14237 ClickOnGadget(level_editor_gadget[last_drawing_function],
14240 if (!use_permanent_palette)
14241 ChangeEditModeWindow(last_edit_mode);
14244 else if (gi->event.type == GD_EVENT_PRESSED)
14245 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
14246 else if (gi->event.type == GD_EVENT_RELEASED)
14247 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
14248 else if (gi->event.type == GD_EVENT_MOVING)
14249 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
14251 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
14257 void HandleLevelEditorKeyInput(Key key)
14259 char letter = getCharFromKey(key);
14261 if (drawing_function == GADGET_ID_TEXT &&
14262 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
14265 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
14266 else if (key == KSYM_Delete || key == KSYM_BackSpace)
14267 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
14268 else if (key == KSYM_Return)
14269 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
14270 else if (key == KSYM_Escape)
14271 DrawLevelText(0, 0, 0, TEXT_END);
14276 int id = GADGET_ID_NONE;
14277 int new_element_shift = element_shift;
14278 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
14279 int button = MB_LEFTBUTTON;
14285 id = GADGET_ID_SCROLL_LEFT;
14288 id = GADGET_ID_SCROLL_RIGHT;
14291 id = GADGET_ID_SCROLL_UP;
14294 id = GADGET_ID_SCROLL_DOWN;
14298 case KSYM_Page_Down:
14299 step *= (key == KSYM_Page_Up ? -1 : +1);
14300 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
14302 if (element_shift < 0)
14304 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14305 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14307 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14308 GDI_SCROLLBAR_ITEM_POSITION,
14309 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14311 ModifyEditorElementList();
14317 element_shift = (key == KSYM_Home ? 0 :
14318 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
14320 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14321 GDI_SCROLLBAR_ITEM_POSITION,
14322 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14324 ModifyEditorElementList();
14331 // this is needed to prevent interference with running "True X-Mouse"
14332 if (GetKeyModStateFromEvents() & KMOD_Control)
14335 // check for last or next editor cascade block in element list
14336 for (i = 0; i < num_editor_elements; i++)
14338 if ((key == KSYM_Insert && i == element_shift) ||
14339 (key == KSYM_Delete && new_element_shift > element_shift))
14342 // jump to next cascade block (or to start of element list)
14343 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
14344 new_element_shift = i;
14347 if (i < num_editor_elements)
14348 element_shift = new_element_shift;
14350 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14351 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14353 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14354 GDI_SCROLLBAR_ITEM_POSITION,
14355 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14357 ModifyEditorElementList();
14362 if (edit_mode == ED_MODE_DRAWING)
14363 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
14364 else if (edit_mode == ED_MODE_INFO)
14365 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
14366 else if (edit_mode == ED_MODE_PROPERTIES)
14367 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
14368 else if (edit_mode == ED_MODE_PALETTE)
14369 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
14370 else // should never happen
14371 ChangeEditModeWindow(ED_MODE_DRAWING);
14379 if (id != GADGET_ID_NONE)
14380 ClickOnGadget(level_editor_gadget[id], button);
14381 else if (letter == '1' || letter == '?')
14382 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
14383 else if (letter == '2')
14384 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
14385 else if (letter == '3')
14386 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
14387 else if (letter == '.')
14388 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
14389 else if (letter == 'U')
14390 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
14391 else if (letter == '-' || key == KSYM_KP_Subtract)
14392 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
14393 else if (letter == '0' || key == KSYM_KP_0)
14394 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
14395 else if (letter == '+' || key == KSYM_KP_Add ||
14396 letter == '=') // ("Shift-=" is "+" on US keyboards)
14397 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
14398 else if (key == KSYM_Return ||
14399 key == KSYM_space ||
14400 key == setup.shortcut.toggle_pause)
14401 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
14403 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
14404 if (letter && letter == controlbutton_info[i].shortcut)
14405 if (!anyTextGadgetActive())
14406 ClickOnGadget(level_editor_gadget[i], button);
14409 static void HandleLevelEditorIdle_Properties(void)
14411 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
14412 int x = editor.settings.element_graphic.x + element_border;
14413 int y = editor.settings.element_graphic.y + element_border;
14414 static unsigned int action_delay = 0;
14415 unsigned int action_delay_value = GameFrameDelay;
14418 if (!DelayReached(&action_delay, action_delay_value))
14421 for (i = 0; i < ED_NUM_SELECTBOX; i++)
14423 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
14425 if (gi->mapped && gi->active && gi->selectbox.open)
14429 DrawEditorElementAnimation(SX + x, SY + y);
14431 redraw_mask |= REDRAW_FIELD;
14433 FrameCounter++; // increase animation frame counter
14436 static void HandleLevelEditorIdle_Drawing(void)
14438 static boolean last_highlighted = FALSE;
14439 boolean highlighted = (GetKeyModState() & KMOD_Alt);
14441 if (highlighted != last_highlighted)
14443 DrawAreaElementHighlight(highlighted);
14445 last_highlighted = highlighted;
14447 redraw_mask |= REDRAW_FIELD;
14451 void HandleLevelEditorIdle(void)
14453 if (edit_mode == ED_MODE_PROPERTIES)
14454 HandleLevelEditorIdle_Properties();
14455 else if (edit_mode == ED_MODE_DRAWING)
14456 HandleLevelEditorIdle_Drawing();
14459 static void ClearEditorGadgetInfoText(void)
14461 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
14464 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
14466 char infotext[MAX_OUTPUT_LINESIZE + 1];
14467 char shortcut[MAX_OUTPUT_LINESIZE + 1];
14468 int max_infotext_len = getMaxInfoTextLength();
14470 if (gi == NULL || strlen(gi->info_text) == 0)
14473 strncpy(infotext, gi->info_text, max_infotext_len);
14474 infotext[max_infotext_len] = '\0';
14476 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
14478 int key = controlbutton_info[gi->custom_id].shortcut;
14482 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
14483 sprintf(shortcut, " ('.' or '%c')", key);
14484 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
14485 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
14486 else if (gi->custom_id == GADGET_ID_TEST)
14487 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
14488 else if (gi->custom_id == GADGET_ID_UNDO)
14489 sprintf(shortcut, " ('%c/Shift-U')", key);
14490 else if (gi->custom_id == GADGET_ID_ZOOM)
14491 sprintf(shortcut, " ('%c', '0', '-')", key);
14493 sprintf(shortcut, " ('%s%c')",
14494 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
14496 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
14497 strcat(infotext, shortcut);
14501 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
14504 void HandleEditorGadgetInfoText(void *ptr)
14506 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
14508 if (game_status != GAME_MODE_EDITOR)
14511 ClearEditorGadgetInfoText();
14513 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
14516 // misuse this function to delete brush cursor, if needed
14517 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
14518 DeleteBrushFromCursor();
14520 PrintEditorGadgetInfoText(gi);
14523 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
14525 static int start_lx, start_ly;
14526 int id = gi->custom_id;
14527 int type_id = gi->custom_type_id;
14528 int sx = gi->event.x;
14529 int sy = gi->event.y;
14530 int lx = sx + level_xpos;
14531 int ly = sy + level_ypos;
14532 int min_sx = 0, min_sy = 0;
14533 int max_sx = gi->drawing.area_xsize - 1;
14534 int max_sy = gi->drawing.area_ysize - 1;
14535 int actual_drawing_function = drawing_function;
14536 int max_infotext_len = getMaxInfoTextLength();
14537 char infotext[MAX_OUTPUT_LINESIZE + 1];
14540 infotext[0] = '\0'; // start with empty info text
14542 // pressed Control key: simulate picking element
14543 if (GetKeyModState() & KMOD_Control)
14544 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14546 ClearEditorGadgetInfoText();
14548 if (gi->event.type == GD_EVENT_INFO_LEAVING)
14551 // make sure to stay inside drawing area boundaries
14552 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14553 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14555 if (id == GADGET_ID_DRAWING_LEVEL)
14559 int min_lx = 0, min_ly = 0;
14560 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14562 // get positions inside level field
14563 lx = sx + level_xpos;
14564 ly = sy + level_ypos;
14566 // make sure to stay inside level field boundaries
14567 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14568 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14570 // correct drawing area positions accordingly
14571 sx = lx - level_xpos;
14572 sy = ly - level_ypos;
14575 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
14577 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
14579 if (gi->event.type == GD_EVENT_PRESSED)
14585 switch (actual_drawing_function)
14587 case GADGET_ID_SINGLE_ITEMS:
14588 text = "Drawing single items";
14590 case GADGET_ID_CONNECTED_ITEMS:
14591 text = "Drawing connected items";
14593 case GADGET_ID_LINE:
14594 text = "Drawing line";
14596 case GADGET_ID_ARC:
14597 text = "Drawing arc";
14599 case GADGET_ID_TEXT:
14600 text = "Setting text cursor";
14602 case GADGET_ID_RECTANGLE:
14603 text = "Drawing rectangle";
14605 case GADGET_ID_FILLED_BOX:
14606 text = "Drawing filled box";
14608 case GADGET_ID_FLOOD_FILL:
14609 text = "Flood fill";
14611 case GADGET_ID_GRAB_BRUSH:
14612 text = "Grabbing brush";
14614 case GADGET_ID_PICK_ELEMENT:
14615 text = "Picking element";
14619 text = "Drawing position";
14623 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14624 sprintf(infotext, "%s: %d, %d", text, lx, ly);
14626 sprintf(infotext, "%s: %d, %d", text,
14627 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
14629 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14630 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
14632 sprintf(infotext, "Level position: %d, %d", lx, ly);
14635 // misuse this function to draw brush cursor, if needed
14636 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
14638 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
14639 CopyBrushToCursor(sx, sy);
14641 DeleteBrushFromCursor();
14644 if (!draw_with_brush)
14645 UpdateBrushPosition(sx, sy);
14647 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14649 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14650 int element = drawingarea_info[type_id].value[pos];
14652 strncpy(infotext, getElementInfoText(element), max_infotext_len);
14656 if (id == GADGET_ID_CUSTOM_CONTENT)
14657 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
14658 else if (id == GADGET_ID_GROUP_CONTENT)
14659 sprintf(infotext, "group element position: %d", sx + 1);
14660 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
14661 id <= GADGET_ID_YAMYAM_CONTENT_7)
14662 sprintf(infotext, "content area %d position: %d, %d",
14663 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
14664 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
14665 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
14666 sprintf(infotext, "content area %d position: %d, %d",
14667 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
14668 else if (id == GADGET_ID_ANDROID_CONTENT)
14669 sprintf(infotext, "android element position: %d", sx + 1);
14670 else if (drawingarea_info[type_id].infotext != NULL)
14671 strcpy(infotext, drawingarea_info[type_id].infotext);
14674 infotext[max_infotext_len] = '\0';
14676 if (strlen(infotext) > 0)
14677 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
14680 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
14681 boolean quick_quit)
14683 if (!ask_if_level_has_changed ||
14685 Request("Level has changed! Exit without saving?",
14686 REQ_ASK | REQ_STAY_OPEN))
14688 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
14689 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
14691 // draw normal door
14692 UndrawSpecialEditorDoor();
14694 // use door animation if door 1 viewport is unchanged and contains toolbox
14695 if (useEditorDoorAnimation())
14696 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
14698 // close editor doors if viewport definition is the same as in main menu
14699 if (vp_door_1->x == DX &&
14700 vp_door_1->y == DY &&
14701 vp_door_1->width == DXSIZE &&
14702 vp_door_1->height == DYSIZE &&
14703 vp_door_2->x == VX &&
14704 vp_door_2->y == VY &&
14705 vp_door_2->width == VXSIZE &&
14706 vp_door_2->height == VYSIZE)
14707 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
14709 SetDoorState(DOOR_CLOSE_2);
14714 FadeSkipNextFadeIn();
14716 SetGameStatus(GAME_MODE_MAIN);
14722 if (!global.use_envelope_request)
14724 CloseDoor(DOOR_CLOSE_1);
14725 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);