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_KEEP_WALKABLE_CE,
661 GADGET_ID_CONTINUOUS_SNAPPING,
662 GADGET_ID_BLOCK_SNAP_FIELD,
663 GADGET_ID_BLOCK_LAST_FIELD,
664 GADGET_ID_SP_BLOCK_LAST_FIELD,
665 GADGET_ID_INSTANT_RELOCATION,
666 GADGET_ID_SHIFTED_RELOCATION,
667 GADGET_ID_LAZY_RELOCATION,
668 GADGET_ID_USE_START_ELEMENT,
669 GADGET_ID_USE_ARTWORK_ELEMENT,
670 GADGET_ID_USE_EXPLOSION_ELEMENT,
671 GADGET_ID_INITIAL_GRAVITY,
672 GADGET_ID_USE_INITIAL_INVENTORY,
673 GADGET_ID_CAN_PASS_TO_WALKABLE,
674 GADGET_ID_CAN_FALL_INTO_ACID,
675 GADGET_ID_CAN_MOVE_INTO_ACID,
676 GADGET_ID_DONT_COLLIDE_WITH,
677 GADGET_ID_ENVELOPE_AUTOWRAP,
678 GADGET_ID_ENVELOPE_CENTERED,
679 GADGET_ID_MM_LASER_RED,
680 GADGET_ID_MM_LASER_GREEN,
681 GADGET_ID_MM_LASER_BLUE,
682 GADGET_ID_DF_LASER_RED,
683 GADGET_ID_DF_LASER_GREEN,
684 GADGET_ID_DF_LASER_BLUE,
685 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
686 GADGET_ID_CUSTOM_CAN_EXPLODE,
687 GADGET_ID_CUSTOM_EXPLODE_FIRE,
688 GADGET_ID_CUSTOM_EXPLODE_SMASH,
689 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
690 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
691 GADGET_ID_CUSTOM_DEADLY,
692 GADGET_ID_CUSTOM_CAN_MOVE,
693 GADGET_ID_CUSTOM_CAN_FALL,
694 GADGET_ID_CUSTOM_CAN_SMASH,
695 GADGET_ID_CUSTOM_SLIPPERY,
696 GADGET_ID_CUSTOM_ACCESSIBLE,
697 GADGET_ID_CUSTOM_GRAV_REACHABLE,
698 GADGET_ID_CUSTOM_USE_LAST_VALUE,
699 GADGET_ID_CUSTOM_USE_GRAPHIC,
700 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
701 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
702 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
703 GADGET_ID_CUSTOM_CAN_CHANGE,
704 GADGET_ID_CHANGE_USE_CONTENT,
705 GADGET_ID_CHANGE_USE_EXPLOSION,
706 GADGET_ID_CHANGE_ONLY_COMPLETE,
707 GADGET_ID_CHANGE_USE_RANDOM,
708 GADGET_ID_CHANGE_HAS_ACTION,
709 GADGET_ID_CHANGE_DELAY,
710 GADGET_ID_CHANGE_BY_DIRECT_ACT,
711 GADGET_ID_CHANGE_BY_OTHER_ACT,
713 NUM_STATIC_GADGET_IDS
716 // gadgets for buttons in element list (dynamic)
717 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
718 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
719 ED_NUM_ELEMENTLIST_BUTTONS - 1)
721 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
723 // radio button numbers
727 RADIO_NR_DRAWING_TOOLBOX,
728 RADIO_NR_RANDOM_ELEMENTS
731 // values for counter gadgets
734 ED_COUNTER_ID_SELECT_LEVEL,
735 ED_COUNTER_ID_LEVEL_XSIZE,
736 ED_COUNTER_ID_LEVEL_YSIZE,
737 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
738 ED_COUNTER_ID_LEVEL_TIMELIMIT,
739 ED_COUNTER_ID_LEVEL_TIMESCORE,
740 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
741 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
742 ED_COUNTER_ID_LEVEL_RANDOM,
743 ED_COUNTER_ID_ELEMENT_VALUE1,
744 ED_COUNTER_ID_ELEMENT_VALUE2,
745 ED_COUNTER_ID_ELEMENT_VALUE3,
746 ED_COUNTER_ID_ELEMENT_VALUE4,
747 ED_COUNTER_ID_YAMYAM_CONTENT,
748 ED_COUNTER_ID_BALL_CONTENT,
749 ED_COUNTER_ID_ANDROID_CONTENT,
750 ED_COUNTER_ID_ENVELOPE_XSIZE,
751 ED_COUNTER_ID_ENVELOPE_YSIZE,
752 ED_COUNTER_ID_INVENTORY_SIZE,
753 ED_COUNTER_ID_CUSTOM_SCORE,
754 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
755 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
756 ED_COUNTER_ID_CUSTOM_VALUE_RND,
757 ED_COUNTER_ID_PUSH_DELAY_FIX,
758 ED_COUNTER_ID_PUSH_DELAY_RND,
759 ED_COUNTER_ID_DROP_DELAY_FIX,
760 ED_COUNTER_ID_DROP_DELAY_RND,
761 ED_COUNTER_ID_MOVE_DELAY_FIX,
762 ED_COUNTER_ID_MOVE_DELAY_RND,
763 ED_COUNTER_ID_STEP_DELAY_FIX,
764 ED_COUNTER_ID_STEP_DELAY_RND,
765 ED_COUNTER_ID_EXPLOSION_DELAY,
766 ED_COUNTER_ID_IGNITION_DELAY,
767 ED_COUNTER_ID_GROUP_CONTENT,
768 ED_COUNTER_ID_CHANGE_DELAY_FIX,
769 ED_COUNTER_ID_CHANGE_DELAY_RND,
770 ED_COUNTER_ID_CHANGE_CONT_RND,
772 ED_NUM_COUNTERBUTTONS
775 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
776 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
777 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
778 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
779 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
780 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
782 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
783 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
784 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
785 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
786 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
787 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
789 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
790 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
792 // values for scrollbutton gadgets
795 ED_SCROLLBUTTON_ID_AREA_UP,
796 ED_SCROLLBUTTON_ID_AREA_DOWN,
797 ED_SCROLLBUTTON_ID_AREA_LEFT,
798 ED_SCROLLBUTTON_ID_AREA_RIGHT,
799 ED_SCROLLBUTTON_ID_LIST_UP,
800 ED_SCROLLBUTTON_ID_LIST_DOWN,
805 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
806 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
808 // values for scrollbar gadgets
811 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
812 ED_SCROLLBAR_ID_AREA_VERTICAL,
813 ED_SCROLLBAR_ID_LIST_VERTICAL,
818 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
819 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
821 // values for text input gadgets
824 ED_TEXTINPUT_ID_LEVEL_NAME,
825 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
826 ED_TEXTINPUT_ID_LEVELSET_NAME,
827 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
828 ED_TEXTINPUT_ID_ELEMENT_NAME,
833 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
834 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
836 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
837 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
839 // values for text area gadgets
842 ED_TEXTAREA_ID_ENVELOPE_INFO,
847 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
848 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
850 // values for selectbox gadgets
853 ED_SELECTBOX_ID_TIME_OR_STEPS,
854 ED_SELECTBOX_ID_TIME_SCORE_BASE,
855 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
856 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
857 ED_SELECTBOX_ID_WIND_DIRECTION,
858 ED_SELECTBOX_ID_PLAYER_SPEED,
859 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
860 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
861 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
862 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
863 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
864 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
865 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
866 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
867 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
868 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
869 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
870 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
871 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
872 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
873 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
874 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
875 ED_SELECTBOX_ID_CHANGE_SIDE,
876 ED_SELECTBOX_ID_CHANGE_PLAYER,
877 ED_SELECTBOX_ID_CHANGE_PAGE,
878 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
879 ED_SELECTBOX_ID_ACTION_TYPE,
880 ED_SELECTBOX_ID_ACTION_MODE,
881 ED_SELECTBOX_ID_ACTION_ARG,
882 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
883 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
888 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
889 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
891 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
892 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
894 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
895 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
896 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
897 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
898 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
899 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
901 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
902 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
904 // values for textbutton gadgets
907 ED_TEXTBUTTON_ID_LEVELINFO_LEVEL,
908 ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET,
909 ED_TEXTBUTTON_ID_LEVELINFO_EDITOR,
910 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
911 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
912 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
913 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
914 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
915 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
916 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
917 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
918 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
919 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
924 #define ED_TAB_BUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
925 #define ED_TAB_BUTTON_ID_LEVELINFO_LAST ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
927 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
928 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
930 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
931 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
933 // values for graphicbutton gadgets
936 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
937 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
938 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
939 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
941 ED_NUM_GRAPHICBUTTONS
944 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
945 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
947 // values for checkbutton gadgets
950 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
951 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
952 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
953 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
954 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
955 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
956 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
957 ED_CHECKBUTTON_ID_STICK_ELEMENT,
958 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
959 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
960 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
961 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
962 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
963 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
964 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
965 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
966 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
967 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
968 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
969 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
970 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
971 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
972 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
973 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
974 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
975 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
976 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
977 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
978 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
979 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
980 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
981 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
982 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
983 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
984 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
985 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
986 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
987 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
988 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
989 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
990 ED_CHECKBUTTON_ID_MM_LASER_RED,
991 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
992 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
993 ED_CHECKBUTTON_ID_DF_LASER_RED,
994 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
995 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
996 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
997 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
998 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
999 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1000 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1001 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1002 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1003 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1004 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1005 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1006 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1007 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1008 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1009 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1010 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1011 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1012 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1013 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1014 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1015 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1016 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1017 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1018 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1019 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1020 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1025 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1026 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1028 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1029 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1031 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1032 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1034 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1035 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1036 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1037 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1038 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1039 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1041 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1042 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1044 // values for radiobutton gadgets
1047 ED_RADIOBUTTON_ID_PERCENTAGE,
1048 ED_RADIOBUTTON_ID_QUANTITY,
1053 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1054 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1056 // values for drawing area gadgets
1059 ED_DRAWING_ID_DRAWING_LEVEL,
1060 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1061 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1062 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1063 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1064 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1065 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1066 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1067 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1068 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1069 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1070 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1071 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1072 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1073 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1074 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1075 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1076 ED_DRAWING_ID_ANDROID_CONTENT,
1077 ED_DRAWING_ID_AMOEBA_CONTENT,
1078 ED_DRAWING_ID_START_ELEMENT,
1079 ED_DRAWING_ID_ARTWORK_ELEMENT,
1080 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1081 ED_DRAWING_ID_INVENTORY_CONTENT,
1082 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1083 ED_DRAWING_ID_CUSTOM_CONTENT,
1084 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1085 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1086 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1087 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1088 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1089 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1090 ED_DRAWING_ID_GROUP_CONTENT,
1091 ED_DRAWING_ID_RANDOM_BACKGROUND,
1093 ED_NUM_DRAWING_AREAS
1096 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1097 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1100 // ----------------------------------------------------------------------------
1101 // some internally used definitions
1102 // ----------------------------------------------------------------------------
1104 // values for CopyLevelToUndoBuffer()
1105 #define UNDO_IMMEDIATE 0
1106 #define UNDO_ACCUMULATE 1
1108 // values for scrollbars
1109 #define ED_SCROLL_NO 0
1110 #define ED_SCROLL_LEFT 1
1111 #define ED_SCROLL_RIGHT 2
1112 #define ED_SCROLL_UP 4
1113 #define ED_SCROLL_DOWN 8
1115 // screens in the level editor
1116 #define ED_MODE_DRAWING 0
1117 #define ED_MODE_INFO 1
1118 #define ED_MODE_PROPERTIES 2
1119 #define ED_MODE_PALETTE 3
1121 // sub-screens in the global settings section
1122 #define ED_MODE_LEVELINFO_LEVEL ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
1123 #define ED_MODE_LEVELINFO_LEVELSET ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET
1124 #define ED_MODE_LEVELINFO_EDITOR ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
1126 // sub-screens in the element properties section
1127 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1128 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1129 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1130 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1131 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1133 // how many steps can be cancelled
1134 #define NUM_UNDO_STEPS (64 + 1)
1136 // values for elements with score for certain actions
1138 #define MAX_SCORE 999
1140 // values for elements with count for collecting
1141 #define MIN_COLLECT_COUNT 0
1142 #define MAX_COLLECT_COUNT 999
1144 // values for random placement
1145 #define RANDOM_USE_PERCENTAGE 0
1146 #define RANDOM_USE_QUANTITY 1
1148 // values for level set save mode
1149 #define LEVELSET_SAVE_MODE_UPDATE 0
1150 #define LEVELSET_SAVE_MODE_CREATE 1
1152 // default value for element tile size in drawing area
1153 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1154 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1157 // ----------------------------------------------------------------------------
1158 // some internally used data structure definitions
1159 // ----------------------------------------------------------------------------
1165 struct XYTileSize *pos;
1169 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1171 // note: some additional characters are already reserved for "cheat mode"
1172 // shortcuts (":XYZ" style) -- for details, see "events.c"
1174 // ---------- toolbox control buttons ---------------------------------------
1177 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1178 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1179 "draw single items", 's'
1182 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1183 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1184 "draw connected items", 'd'
1187 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1188 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1192 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1193 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1197 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1198 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1199 "draw outline rectangles", 'r'
1202 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1203 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1204 "draw filled rectangles", 'R'
1207 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1208 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1209 "wrap (rotate) level up", 0
1212 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1213 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1214 "enter text elements", 't'
1217 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1218 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1222 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1223 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1224 "wrap (rotate) level left", 0
1227 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1228 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1229 "zoom level tile size", '+'
1232 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1233 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1234 "wrap (rotate) level right", 0
1237 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1238 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1239 "random element placement", 0
1242 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1243 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1247 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1248 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1249 "wrap (rotate) level down", 0
1252 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1253 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1254 "pick drawing element", ','
1257 // ---------- level control buttons -----------------------------------------
1260 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1261 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1262 "undo/redo last operation", 'u'
1265 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_INFO,
1266 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1267 "properties of level", 'I'
1270 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1271 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1275 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1276 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1280 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1281 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1285 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1286 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1287 "exit level editor", 'E'
1290 // ---------- CE and GE control buttons -------------------------------------
1293 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1294 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1295 "copy settings from other element", 0
1298 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1299 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1300 "copy settings to other element", 0
1303 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1304 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1305 "exchange element with other element", 0
1308 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1309 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1310 "copy settings from this element", 0
1313 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1314 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1315 "paste settings to this element", 0
1318 // ---------- palette control buttons ---------------------------------------
1321 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1322 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1323 "properties of drawing element", 'p'
1326 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1327 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1328 "properties of drawing element 1", '1'
1331 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1332 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1333 "properties of drawing element 2", '2'
1336 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1337 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1338 "properties of drawing element 3", '3'
1341 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1342 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1343 "show list of elements", 'e'
1347 static int random_placement_value = 10;
1348 static int random_placement_method = RANDOM_USE_QUANTITY;
1349 static int random_placement_background_element = EL_SAND;
1350 static boolean random_placement_background_restricted = FALSE;
1351 static boolean stick_element_properties_window = FALSE;
1352 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1353 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1354 static struct ElementChangeInfo custom_element_change;
1355 static struct ElementGroupInfo group_element_info;
1356 static struct ElementInfo custom_element;
1358 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1359 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1360 static int levelset_num_levels = 100;
1361 static boolean levelset_use_levelset_artwork = FALSE;
1362 static boolean levelset_copy_level_template = FALSE;
1363 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1368 int min_value, max_value;
1369 int gadget_id_down, gadget_id_up;
1371 int gadget_id_align;
1373 char *text_above, *text_left, *text_right;
1374 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1376 // ---------- current level number ------------------------------------------
1379 -1, -1, // these values are not constant, but can change at runtime
1381 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1382 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1387 // ---------- level and editor settings -------------------------------------
1390 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1391 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1392 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1393 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1395 "playfield size:", NULL, "width",
1398 -1, ED_LEVEL_SETTINGS_YPOS(4),
1399 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1400 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1401 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1403 NULL, " ", "height",
1406 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1408 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1409 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1411 NULL, "number of gems to collect:", NULL
1414 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1416 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1417 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1419 "time or step limit to solve level:", NULL, NULL
1422 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1424 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1425 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1426 &level.score[SC_TIME_BONUS],
1427 "score for time or steps left:", NULL, NULL
1430 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1432 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1433 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1435 NULL, "random seed:", "(0 => random)"
1438 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1440 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1441 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1442 &levelset_num_levels,
1443 "number of levels:", NULL, NULL,
1446 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1448 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1449 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1450 &random_placement_value,
1451 "random element placement:", NULL, "in"
1454 // ---------- element settings: configure (various elements) ----------------
1457 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1458 MIN_SCORE, MAX_SCORE,
1459 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1460 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1461 NULL, // will be set when used
1465 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1466 MIN_SCORE, MAX_SCORE,
1467 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1468 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1469 NULL, // will be set when used
1473 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1474 MIN_SCORE, MAX_SCORE,
1475 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1476 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1477 NULL, // will be set when used
1481 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1482 MIN_SCORE, MAX_SCORE,
1483 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1484 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1485 NULL, // will be set when used
1489 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1490 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1491 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1492 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1493 &level.num_yamyam_contents,
1494 NULL, NULL, "number of content areas"
1497 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1498 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1499 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1500 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1501 &level.num_ball_contents,
1502 NULL, NULL, "number of content areas"
1505 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1506 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1507 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1508 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1509 &level.num_android_clone_elements,
1510 NULL, NULL, "number of clonable elements"
1513 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1514 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1515 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1516 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1517 NULL, // will be set when used
1518 NULL, NULL, "width",
1521 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1522 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1523 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1524 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1525 NULL, // will be set when used
1526 NULL, " ", "height",
1529 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1530 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1531 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1532 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1533 &level.initial_inventory_size[0],
1534 NULL, NULL, "number of inventory elements"
1537 // ---------- element settings: configure 1 (custom elements) ---------------
1540 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1541 MIN_SCORE, MAX_SCORE,
1542 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1543 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1544 &custom_element.collect_score_initial,
1545 NULL, "CE score", " "
1548 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1549 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1550 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1551 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1552 &custom_element.collect_count_initial,
1553 NULL, "CE count", NULL
1556 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1558 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1559 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1560 &custom_element.ce_value_fixed_initial,
1561 NULL, "CE value", NULL
1564 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1566 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1567 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1568 &custom_element.ce_value_random_initial,
1569 NULL, "+random", NULL
1572 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1574 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1575 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1576 &custom_element.push_delay_fixed,
1577 NULL, "push delay", NULL
1580 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1582 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1583 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1584 &custom_element.push_delay_random,
1585 NULL, "+random", NULL
1588 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1590 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1591 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1592 &custom_element.drop_delay_fixed,
1593 NULL, "drop delay", NULL
1596 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1598 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1599 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1600 &custom_element.drop_delay_random,
1601 NULL, "+random", NULL
1604 // ---------- element settings: configure 2 (custom elements) ---------------
1607 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1609 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1610 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1611 &custom_element.move_delay_fixed,
1612 NULL, "move delay", NULL
1615 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1617 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1618 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1619 &custom_element.move_delay_random,
1620 NULL, "+random", NULL
1623 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1625 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1626 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1627 &custom_element.step_delay_fixed,
1628 NULL, "step delay", NULL
1631 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1633 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1634 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1635 &custom_element.step_delay_random,
1636 NULL, "+random", NULL
1639 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1641 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1642 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1643 &custom_element.explosion_delay,
1644 NULL, "explosion delay", NULL
1647 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1649 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1650 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1651 &custom_element.ignition_delay,
1652 NULL, "ignition delay", "(by fire)"
1655 // ---------- element settings: configure (group elements) ------------------
1658 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1659 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1660 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1661 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1662 &group_element_info.num_elements,
1663 NULL, NULL, "number of elements in group"
1666 // ---------- element settings: advanced (custom elements) ------------------
1669 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1671 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1672 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1673 &custom_element_change.delay_fixed,
1674 NULL, "CE delay", NULL,
1677 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1679 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1680 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1681 &custom_element_change.delay_random,
1682 NULL, "+random", NULL
1685 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1687 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1688 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1689 &custom_element_change.random_percentage,
1690 NULL, "use random replace:", "%"
1700 char *text_above, *infotext;
1701 } textinput_info[ED_NUM_TEXTINPUT] =
1704 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1705 GADGET_ID_LEVEL_NAME,
1708 "Title:", "Title for this level"
1711 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1712 GADGET_ID_LEVEL_AUTHOR,
1713 MAX_LEVEL_AUTHOR_LEN,
1715 "Author:", "Author for this level"
1718 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1719 GADGET_ID_LEVELSET_NAME,
1722 "Title:", "Title for this or new level set"
1725 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1726 GADGET_ID_LEVELSET_AUTHOR,
1727 MAX_LEVEL_AUTHOR_LEN,
1729 "Author:", "Author for this or new level set"
1732 -1, -1, // these values are not constant, but can change at runtime
1733 GADGET_ID_ELEMENT_NAME,
1734 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1735 custom_element.description,
1736 NULL, "Element name"
1746 char *text_above, *infotext;
1747 } textarea_info[ED_NUM_TEXTAREAS] =
1750 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1751 GADGET_ID_ENVELOPE_INFO,
1752 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1754 "Envelope Content:", "Envelope Content"
1758 static struct ValueTextInfo options_time_or_steps[] =
1766 static struct ValueTextInfo options_time_score_base[] =
1768 { 1, "per second/step" },
1769 { 10, "per 10 seconds/steps" },
1774 static struct ValueTextInfo options_game_engine_type[] =
1776 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1777 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1778 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1779 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1784 static struct ValueTextInfo options_levelset_save_mode[] =
1786 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1787 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1792 static struct ValueTextInfo options_wind_direction[] =
1794 { MV_START_NONE, "none" },
1795 { MV_START_LEFT, "left" },
1796 { MV_START_RIGHT, "right" },
1797 { MV_START_UP, "up" },
1798 { MV_START_DOWN, "down" },
1803 static struct ValueTextInfo options_player_speed[] =
1810 { 16, "very fast" },
1811 { 32, "ultrafast" },
1816 static struct ValueTextInfo options_access_type[] =
1818 { EP_WALKABLE, "walkable" },
1819 { EP_PASSABLE, "passable" },
1824 static struct ValueTextInfo options_access_layer[] =
1826 { EP_ACCESSIBLE_OVER, "over" },
1827 { EP_ACCESSIBLE_INSIDE, "inside" },
1828 { EP_ACCESSIBLE_UNDER, "under" },
1833 static struct ValueTextInfo options_access_protected[] =
1835 { 0, "unprotected" },
1841 static struct ValueTextInfo options_access_direction[] =
1843 { MV_NO_DIRECTION, "no direction" },
1844 { MV_LEFT, "left" },
1845 { MV_RIGHT, "right" },
1847 { MV_DOWN, "down" },
1848 { MV_LEFT | MV_UP, "left + up" },
1849 { MV_LEFT | MV_DOWN, "left + down" },
1850 { MV_RIGHT | MV_UP, "right + up" },
1851 { MV_RIGHT | MV_DOWN, "right + down" },
1852 { MV_HORIZONTAL, "horizontal" },
1853 { MV_VERTICAL, "vertical" },
1854 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1855 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1856 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1857 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1858 { MV_ALL_DIRECTIONS, "all directions" },
1863 static struct ValueTextInfo options_walk_to_action[] =
1865 { EP_DIGGABLE, "diggable" },
1866 { EP_COLLECTIBLE_ONLY, "collectible" },
1867 { EP_DROPPABLE, "collectible & droppable" },
1868 { EP_THROWABLE, "collectible & throwable" },
1869 { EP_PUSHABLE, "pushable" },
1874 static struct ValueTextInfo options_move_pattern[] =
1876 { MV_LEFT, "left" },
1877 { MV_RIGHT, "right" },
1879 { MV_DOWN, "down" },
1880 { MV_HORIZONTAL, "horizontal" },
1881 { MV_VERTICAL, "vertical" },
1882 { MV_ALL_DIRECTIONS, "all directions" },
1883 { MV_WIND_DIRECTION, "wind direction" },
1884 { MV_TOWARDS_PLAYER, "towards player" },
1885 { MV_AWAY_FROM_PLAYER, "away from player" },
1886 { MV_ALONG_LEFT_SIDE, "along left side" },
1887 { MV_ALONG_RIGHT_SIDE, "along right side" },
1888 { MV_TURNING_LEFT, "turning left" },
1889 { MV_TURNING_RIGHT, "turning right" },
1890 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1891 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1892 { MV_TURNING_RANDOM, "turning random" },
1893 { MV_MAZE_RUNNER, "maze runner style" },
1894 { MV_MAZE_HUNTER, "maze hunter style" },
1895 { MV_WHEN_PUSHED, "when pushed" },
1896 { MV_WHEN_DROPPED, "when dropped/thrown" },
1901 static struct ValueTextInfo options_move_direction[] =
1903 { MV_START_AUTOMATIC, "automatic" },
1904 { MV_START_LEFT, "left" },
1905 { MV_START_RIGHT, "right" },
1906 { MV_START_UP, "up" },
1907 { MV_START_DOWN, "down" },
1908 { MV_START_RANDOM, "random" },
1909 { MV_START_PREVIOUS, "previous" },
1914 static struct ValueTextInfo options_move_stepsize[] =
1916 { 0, "not moving" },
1921 { 16, "very fast" },
1922 { 32, "even faster" },
1927 static struct ValueTextInfo options_move_leave_type[] =
1929 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1930 { LEAVE_TYPE_LIMITED, "change it to" },
1935 static struct ValueTextInfo options_smash_targets[] =
1937 { EP_CAN_SMASH_PLAYER, "player" },
1939 { EP_CAN_SMASH_ENEMIES, "enemies" },
1941 { EP_CAN_SMASH_EVERYTHING, "everything" },
1946 static struct ValueTextInfo options_slippery_type[] =
1948 { SLIPPERY_ANY_RANDOM, "random" },
1949 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1950 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1951 { SLIPPERY_ONLY_LEFT, "only left" },
1952 { SLIPPERY_ONLY_RIGHT, "only right" },
1957 static struct ValueTextInfo options_deadliness[] =
1959 { EP_DONT_RUN_INTO, "running into" },
1960 { EP_DONT_COLLIDE_WITH, "colliding with" },
1961 { EP_DONT_GET_HIT_BY, "getting hit by" },
1962 { EP_DONT_TOUCH, "touching" },
1967 static struct ValueTextInfo options_explosion_type[] =
1969 { EXPLODES_3X3, "3x3" },
1970 { EXPLODES_CROSS, "3+3" },
1971 { EXPLODES_1X1, "1x1" },
1976 static struct ValueTextInfo options_time_units[] =
1979 { FRAMES_PER_SECOND, "seconds" },
1984 static struct ValueTextInfo options_change_direct_action[] =
1986 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1987 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1988 { CE_SWITCHED_BY_PLAYER, "switched by player" },
1989 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
1990 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1991 { CE_ENTERED_BY_PLAYER, "entered by player" },
1992 { CE_LEFT_BY_PLAYER, "left by player" },
1993 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1994 { CE_SWITCHED, "switched" },
1995 { CE_HITTING_SOMETHING, "hitting something" },
1996 { CE_HIT_BY_SOMETHING, "hit by something" },
1998 { CE_BLOCKED, "blocked" },
2000 { CE_IMPACT, "impact (on something)" },
2001 { CE_SMASHED, "smashed (from above)" },
2003 { CE_VALUE_CHANGES, "CE value changes" },
2004 { CE_SCORE_CHANGES, "CE score changes" },
2006 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2007 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2008 { CE_UNDEFINED, " " },
2009 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2010 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2011 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2012 { CE_UNDEFINED, " " },
2013 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2014 { CE_NEXT_TO_PLAYER, "next to player" },
2019 static struct ValueTextInfo options_change_other_action[] =
2021 { CE_PLAYER_TOUCHES_X, "player touches" },
2022 { CE_PLAYER_PRESSES_X, "player presses" },
2023 { CE_PLAYER_SWITCHES_X, "player switches" },
2024 { CE_PLAYER_SNAPS_X, "player snaps" },
2025 { CE_PLAYER_PUSHES_X, "player pushes" },
2026 { CE_PLAYER_ENTERS_X, "player enters" },
2027 { CE_PLAYER_LEAVES_X, "player leaves" },
2028 { CE_PLAYER_DIGS_X, "player digs" },
2029 { CE_PLAYER_COLLECTS_X, "player collects" },
2030 { CE_PLAYER_DROPS_X, "player drops/throws" },
2031 { CE_TOUCHING_X, "touching" },
2032 { CE_HITTING_X, "hitting" },
2033 { CE_DIGGING_X, "digging" },
2034 { CE_HIT_BY_X, "hit by" },
2035 { CE_SWITCH_OF_X, "switch of" },
2036 { CE_CHANGE_OF_X, "change by page of" },
2037 { CE_EXPLOSION_OF_X, "explosion of" },
2038 { CE_MOVE_OF_X, "move of" },
2039 { CE_CREATION_OF_X, "creation of" },
2040 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2041 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2042 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2043 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2044 { CE_UNDEFINED, " " },
2045 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2046 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2047 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2048 { CE_UNDEFINED, " " },
2049 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2050 { CE_PLAYER_NEXT_TO_X, "player next to" },
2051 { CE_NEXT_TO_X, "next to" },
2056 static struct ValueTextInfo options_change_trigger_side[] =
2058 { CH_SIDE_LEFT, "left" },
2059 { CH_SIDE_RIGHT, "right" },
2060 { CH_SIDE_TOP, "top" },
2061 { CH_SIDE_BOTTOM, "bottom" },
2062 { CH_SIDE_LEFT_RIGHT, "left/right" },
2063 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2064 { CH_SIDE_ANY, "any" },
2069 static struct ValueTextInfo options_change_trigger_player[] =
2071 { CH_PLAYER_1, "1" },
2072 { CH_PLAYER_2, "2" },
2073 { CH_PLAYER_3, "3" },
2074 { CH_PLAYER_4, "4" },
2075 { CH_PLAYER_ANY, "any" },
2080 static struct ValueTextInfo options_change_trigger_page[] =
2092 { (1 << 10), "11" },
2093 { (1 << 11), "12" },
2094 { (1 << 12), "13" },
2095 { (1 << 13), "14" },
2096 { (1 << 14), "15" },
2097 { (1 << 15), "16" },
2098 { (1 << 16), "17" },
2099 { (1 << 17), "18" },
2100 { (1 << 18), "19" },
2101 { (1 << 19), "20" },
2102 { (1 << 20), "21" },
2103 { (1 << 21), "22" },
2104 { (1 << 22), "23" },
2105 { (1 << 23), "24" },
2106 { (1 << 24), "25" },
2107 { (1 << 25), "26" },
2108 { (1 << 26), "27" },
2109 { (1 << 27), "28" },
2110 { (1 << 28), "29" },
2111 { (1 << 29), "30" },
2112 { (1 << 30), "31" },
2113 { (1 << 31), "32" },
2114 { CH_PAGE_ANY, "any" },
2119 static struct ValueTextInfo options_change_replace_when[] =
2121 { CP_WHEN_EMPTY, "empty" },
2122 { CP_WHEN_WALKABLE, "walkable" },
2123 { CP_WHEN_DIGGABLE, "diggable" },
2124 { CP_WHEN_COLLECTIBLE, "collectible" },
2125 { CP_WHEN_REMOVABLE, "removable" },
2126 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2131 static struct ValueTextInfo options_action_type[] =
2133 { CA_NO_ACTION, "no action" },
2134 { CA_UNDEFINED, " " },
2135 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2136 { CA_RESTART_LEVEL, "restart level" },
2137 { CA_SHOW_ENVELOPE, "show envelope" },
2138 { CA_SET_LEVEL_TIME, "set time" },
2139 { CA_SET_LEVEL_SCORE, "set score" },
2140 { CA_SET_LEVEL_GEMS, "set gems" },
2141 { CA_SET_LEVEL_WIND, "set wind dir." },
2142 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2143 { CA_UNDEFINED, " " },
2144 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2145 { CA_MOVE_PLAYER, "move player" },
2146 { CA_MOVE_PLAYER_NEW, "move player new" },
2147 { CA_EXIT_PLAYER, "exit player" },
2148 { CA_KILL_PLAYER, "kill player" },
2149 { CA_SET_PLAYER_KEYS, "set keys" },
2150 { CA_SET_PLAYER_SPEED, "set speed" },
2151 { CA_SET_PLAYER_SHIELD, "set shield" },
2152 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2153 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2154 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2155 { CA_UNDEFINED, " " },
2156 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2157 { CA_SET_CE_VALUE, "set CE value" },
2158 { CA_SET_CE_SCORE, "set CE score" },
2159 { CA_SET_CE_ARTWORK, "set CE artwork" },
2160 { CA_UNDEFINED, " " },
2161 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2162 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2167 static struct ValueTextInfo options_action_mode_none[] =
2169 { CA_MODE_UNDEFINED, " " },
2174 static struct ValueTextInfo options_action_mode_assign[] =
2176 { CA_MODE_SET, "=" },
2181 static struct ValueTextInfo options_action_mode_add_remove[] =
2183 { CA_MODE_ADD, "+" },
2184 { CA_MODE_SUBTRACT, "-" },
2189 static struct ValueTextInfo options_action_mode_calculate[] =
2191 { CA_MODE_SET, "=" },
2192 { CA_MODE_ADD, "+" },
2193 { CA_MODE_SUBTRACT, "-" },
2194 { CA_MODE_MULTIPLY, "*" },
2195 { CA_MODE_DIVIDE, "/" },
2196 { CA_MODE_MODULO, "%" },
2201 static struct ValueTextInfo options_action_arg_none[] =
2203 { CA_ARG_UNDEFINED, " " },
2208 static struct ValueTextInfo options_action_arg_player[] =
2210 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2211 { CA_ARG_PLAYER_1, "1" },
2212 { CA_ARG_PLAYER_2, "2" },
2213 { CA_ARG_PLAYER_3, "3" },
2214 { CA_ARG_PLAYER_4, "4" },
2215 { CA_ARG_PLAYER_ANY, "any" },
2216 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2217 { CA_ARG_PLAYER_ACTION, "action ->" },
2222 static struct ValueTextInfo options_action_arg_number[] =
2224 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2231 { CA_ARG_10, "10" },
2232 { CA_ARG_100, "100" },
2233 { CA_ARG_1000, "1000" },
2234 { CA_ARG_UNDEFINED, " " },
2235 { CA_ARG_NUMBER_MIN, "min" },
2236 { CA_ARG_NUMBER_MAX, "max" },
2237 { CA_ARG_UNDEFINED, " " },
2238 { CA_ARG_NUMBER_RESET, "reset" },
2239 { CA_ARG_UNDEFINED, " " },
2240 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2241 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2242 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2243 { CA_ARG_UNDEFINED, " " },
2244 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2245 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2246 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2247 { CA_ARG_UNDEFINED, " " },
2248 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2249 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2250 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2251 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2252 { CA_ARG_UNDEFINED, " " },
2253 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2254 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2255 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2256 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2261 static struct ValueTextInfo options_action_arg_value[] =
2263 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2270 { CA_ARG_10, "10" },
2271 { CA_ARG_100, "100" },
2272 { CA_ARG_1000, "1000" },
2273 { CA_ARG_UNDEFINED, " " },
2274 { CA_ARG_NUMBER_MIN, "min" },
2275 { CA_ARG_NUMBER_MAX, "max" },
2276 { CA_ARG_UNDEFINED, " " },
2277 { CA_ARG_NUMBER_RESET, "reset" },
2278 { CA_ARG_UNDEFINED, " " },
2279 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2280 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2281 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2282 { CA_ARG_UNDEFINED, " " },
2283 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2284 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2285 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2286 { CA_ARG_UNDEFINED, " " },
2287 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2288 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2289 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2290 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2291 { CA_ARG_UNDEFINED, " " },
2292 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2293 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2294 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2295 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2296 { CA_ARG_UNDEFINED, " " },
2297 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2298 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2299 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2300 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2305 static struct ValueTextInfo options_action_arg_envelope[] =
2307 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2312 { CA_ARG_UNDEFINED, " " },
2313 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2314 { CA_ARG_ELEMENT_TARGET, "target" },
2315 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2316 { CA_ARG_ELEMENT_ACTION, "action ->" },
2321 static struct ValueTextInfo options_action_arg_key[] =
2323 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2332 { CA_ARG_UNDEFINED, " " },
2333 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2334 { CA_ARG_ELEMENT_TARGET, "target" },
2335 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2336 { CA_ARG_ELEMENT_ACTION, "action ->" },
2341 static struct ValueTextInfo options_action_arg_speed[] =
2343 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2344 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2345 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2346 { CA_ARG_SPEED_SLOW, "slow" },
2347 { CA_ARG_SPEED_NORMAL, "normal" },
2348 { CA_ARG_SPEED_FAST, "fast" },
2349 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2350 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2351 { CA_ARG_UNDEFINED, " " },
2352 { CA_ARG_SPEED_SLOWER, "slower" },
2353 { CA_ARG_SPEED_FASTER, "faster" },
2354 { CA_ARG_UNDEFINED, " " },
2355 { CA_ARG_SPEED_RESET, "reset" },
2360 static struct ValueTextInfo options_action_arg_shield[] =
2362 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2363 { CA_ARG_SHIELD_OFF, "off" },
2364 { CA_ARG_SHIELD_NORMAL, "normal" },
2365 { CA_ARG_SHIELD_DEADLY, "deadly" },
2370 static struct ValueTextInfo options_action_arg_artwork[] =
2372 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2373 { CA_ARG_ELEMENT_TARGET, "target" },
2374 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2375 { CA_ARG_ELEMENT_ACTION, "action ->" },
2376 { CA_ARG_UNDEFINED, " " },
2377 { CA_ARG_ELEMENT_RESET, "reset" },
2382 static struct ValueTextInfo options_action_arg_gravity[] =
2384 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2385 { CA_ARG_GRAVITY_ON, "on" },
2386 { CA_ARG_GRAVITY_OFF, "off" },
2387 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2392 static struct ValueTextInfo options_action_arg_direction[] =
2394 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2395 { CA_ARG_DIRECTION_NONE, "none" },
2396 { CA_ARG_DIRECTION_LEFT, "left" },
2397 { CA_ARG_DIRECTION_RIGHT, "right" },
2398 { CA_ARG_DIRECTION_UP, "up" },
2399 { CA_ARG_DIRECTION_DOWN, "down" },
2400 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2401 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2406 static struct ValueTextInfo options_action_arg_scan_mode[] =
2408 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2409 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2410 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2415 static struct ValueTextInfo options_action_arg_inventory[] =
2417 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2418 { CA_ARG_ELEMENT_TARGET, "+ target" },
2419 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2420 { CA_ARG_ELEMENT_ACTION, "+ action" },
2421 { CA_ARG_UNDEFINED, " " },
2422 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2423 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2424 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2425 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2426 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2427 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2428 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2429 { CA_ARG_UNDEFINED, " " },
2430 { CA_ARG_INVENTORY_RESET, "reset" },
2435 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2436 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2441 static struct ValueTextInfo options_group_choice_mode[] =
2443 { ANIM_RANDOM, "random" },
2444 { ANIM_LOOP, "loop" },
2445 { ANIM_LINEAR, "linear" },
2446 { ANIM_PINGPONG, "pingpong" },
2447 { ANIM_PINGPONG2, "pingpong 2" },
2452 static struct ValueTextInfo *action_arg_modes[] =
2454 options_action_mode_none,
2455 options_action_mode_assign,
2456 options_action_mode_add_remove,
2457 options_action_mode_calculate,
2464 struct ValueTextInfo *options;
2466 action_arg_options[] =
2468 { CA_NO_ACTION, 0, options_action_arg_none, },
2469 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2470 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2471 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2472 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2473 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2474 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2475 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2476 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2477 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2478 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2479 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2480 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2481 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2482 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2483 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2484 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2485 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2486 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2487 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2488 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2489 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2498 int gadget_id_align;
2499 int size; // char size of selectbox or '-1' (dynamically determined)
2500 struct ValueTextInfo *options;
2502 char *text_above, *text_left, *text_right, *infotext;
2503 } selectbox_info[ED_NUM_SELECTBOX] =
2505 // ---------- level and editor settings -------------------------------------
2508 -1, ED_LEVEL_SETTINGS_YPOS(8),
2509 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2511 options_time_or_steps,
2512 &level.use_step_counter,
2513 NULL, NULL, "(0 => no limit)", "time or step limit"
2516 -1, ED_LEVEL_SETTINGS_YPOS(10),
2517 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2519 options_time_score_base,
2520 &level.time_score_base,
2521 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2524 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2525 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2527 options_game_engine_type,
2528 &level.game_engine_type,
2529 NULL, "game engine:", NULL, "game engine"
2532 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2533 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2535 options_levelset_save_mode,
2536 &levelset_save_mode,
2537 "Action:", NULL, NULL, "action when saving level set"
2540 // ---------- element settings: configure (several elements) ----------------
2543 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2544 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2546 options_wind_direction,
2547 &level.wind_direction_initial,
2548 NULL, "initial wind direction:", NULL, "initial wind direction"
2551 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2552 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2554 options_player_speed,
2555 &level.initial_player_stepsize[0],
2556 NULL, "initial player speed:", NULL, "initial player speed"
2559 // ---------- element settings: configure 1 (custom elements) ---------------
2562 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2563 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2565 options_access_type,
2566 &custom_element.access_type,
2567 NULL, NULL, NULL, "type of access to this field"
2570 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2571 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2573 options_access_layer,
2574 &custom_element.access_layer,
2575 NULL, NULL, NULL, "layer of access for this field"
2578 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2579 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2581 options_access_protected,
2582 &custom_element.access_protected,
2583 NULL, NULL, NULL, "protected access for this field"
2586 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2587 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2589 options_access_direction,
2590 &custom_element.access_direction,
2591 NULL, "from", NULL, "access direction for this field"
2594 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2595 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2597 options_walk_to_action,
2598 &custom_element.walk_to_action,
2599 NULL, NULL, NULL, "diggable/collectible/pushable"
2602 // ---------- element settings: configure 2 (custom elements) ---------------
2605 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2606 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2608 options_move_pattern,
2609 &custom_element.move_pattern,
2610 NULL, "can move", NULL, "element move pattern"
2613 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2614 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2616 options_move_direction,
2617 &custom_element.move_direction_initial,
2618 NULL, "starts moving", NULL, "initial element move direction"
2621 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2622 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2624 options_move_stepsize,
2625 &custom_element.move_stepsize,
2626 NULL, "move/fall speed", NULL, "speed of element movement"
2629 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2630 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2632 options_move_leave_type,
2633 &custom_element.move_leave_type,
2634 // left text with leading spaces to place gadget next to "can dig" gadget
2635 // (needed because drawing area gadgets created after selectbox gadgets)
2636 // NULL, "can dig: can", ":", "leave behind or change element"
2637 NULL, " can", ":", "leave behind or change element"
2640 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2641 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2643 options_smash_targets,
2644 &custom_element.smash_targets,
2645 NULL, "can smash", NULL, "elements that can be smashed"
2648 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2649 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2651 options_slippery_type,
2652 &custom_element.slippery_type,
2653 NULL, "slippery", NULL, "where other elements fall down"
2656 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2657 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2660 &custom_element.deadliness,
2661 NULL, "deadly when", NULL, "deadliness of element"
2664 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2665 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2667 options_explosion_type,
2668 &custom_element.explosion_type,
2669 NULL, "can explode", NULL, "explosion type"
2672 // ---------- element settings: advanced (custom elements) ------------------
2675 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2676 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2679 &custom_element_change.delay_frames,
2680 NULL, "delay time given in", NULL, "delay time units for change"
2683 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2684 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2686 options_change_direct_action,
2687 &custom_element_change.direct_action,
2688 NULL, NULL, NULL, "type of direct action"
2691 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2692 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2694 options_change_other_action,
2695 &custom_element_change.other_action,
2696 NULL, NULL, "element:", "type of other element action"
2699 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2700 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2702 options_change_trigger_side,
2703 &custom_element_change.trigger_side,
2704 NULL, "at", "side", "element side triggering change"
2707 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2708 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2710 options_change_trigger_player,
2711 &custom_element_change.trigger_player,
2712 NULL, "player:", " ", "player that causes change"
2715 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2716 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2718 options_change_trigger_page,
2719 &custom_element_change.trigger_page,
2720 NULL, "page:", NULL, "change page that causes change"
2723 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2724 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2726 options_change_replace_when,
2727 &custom_element_change.replace_when,
2728 NULL, "replace when", NULL, "which elements can be replaced"
2731 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2732 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2734 options_action_type,
2735 &custom_element_change.action_type,
2736 NULL, NULL, NULL, "action on specified condition"
2739 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2740 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2742 options_action_mode_none,
2743 &custom_element_change.action_mode,
2744 NULL, NULL, NULL, "action operator"
2747 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2748 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2750 options_action_arg_none,
2751 &custom_element_change.action_arg,
2752 NULL, NULL, NULL, "action parameter"
2755 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2756 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2758 options_change_page,
2759 &custom_element.current_change_page,
2760 NULL, NULL, NULL, "element change page"
2763 // ---------- element settings: configure (group elements) ------------------
2766 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2767 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2769 options_group_choice_mode,
2770 &group_element_info.choice_mode,
2771 NULL, "choice type:", NULL, "type of group element choice"
2779 int gadget_id_align;
2782 char *text_above, *text_left, *text_right, *infotext;
2783 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2785 // ---------- level and editor settings (tabs) ------------------------------
2788 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2789 GADGET_ID_LEVELINFO_LEVEL, GADGET_ID_NONE,
2791 NULL, NULL, NULL, "Configure level properties"
2795 GADGET_ID_LEVELINFO_LEVELSET, GADGET_ID_LEVELINFO_LEVEL,
2797 NULL, NULL, NULL, "Update this or create new level set"
2801 GADGET_ID_LEVELINFO_EDITOR, GADGET_ID_LEVELINFO_LEVELSET,
2803 NULL, NULL, NULL, "Configure editor properties"
2806 // ---------- element settings (tabs) ---------------------------------------
2809 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2810 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2812 NULL, NULL, NULL, "Show information about element"
2816 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2818 NULL, NULL, NULL, "Configure element properties"
2822 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2824 NULL, NULL, NULL, "Configure element properties, part 1"
2828 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2830 NULL, NULL, NULL, "Configure element properties, part 2"
2834 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2836 NULL, NULL, NULL, "Configure custom element change pages"
2839 // ---------- level and editor settings (buttons) ---------------------------
2842 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2843 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
2845 NULL, NULL, NULL, "Update or create level set"
2848 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2849 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2851 NULL, NULL, "this level as level template",
2852 "Save current settings as new template"
2855 // ---------- element settings (buttons) ------------------------------------
2859 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2861 NULL, " ", "As Template",
2862 "Save current settings as new template"
2866 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2868 NULL, NULL, NULL, "Add new change page"
2872 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2874 NULL, NULL, NULL, "Delete current change page"
2883 int gadget_id_align;
2884 char *text_left, *text_right, *infotext;
2885 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2888 IMG_EDITOR_COUNTER_DOWN,
2889 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2890 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2891 NULL, NULL, "select previous change page"
2894 IMG_EDITOR_COUNTER_UP,
2895 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2896 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2897 NULL, "change page", "select next change page"
2900 IMG_GFX_EDITOR_BUTTON_CP_COPY,
2901 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2902 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2903 " ", NULL, "copy settings from this change page"
2906 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
2907 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2908 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2909 NULL, NULL, "paste settings to this change page"
2916 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2923 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2926 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2927 GADGET_ID_SCROLL_UP,
2928 "scroll level editing area up"
2931 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2932 GADGET_ID_SCROLL_DOWN,
2933 "scroll level editing area down"
2936 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2937 GADGET_ID_SCROLL_LEFT,
2938 "scroll level editing area left"
2941 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2942 GADGET_ID_SCROLL_RIGHT,
2943 "scroll level editing area right"
2946 IMG_EDITOR_PALETTE_SCROLL_UP,
2947 GADGET_ID_SCROLL_LIST_UP,
2948 "scroll element list up ('Page Up')"
2951 IMG_EDITOR_PALETTE_SCROLL_DOWN,
2952 GADGET_ID_SCROLL_LIST_DOWN,
2953 "scroll element list down ('Page Down')"
2961 int wheel_x, wheel_y;
2962 int wheel_width, wheel_height;
2963 } scrollbar_pos[ED_NUM_SCROLLBARS];
2971 } scrollbar_info[ED_NUM_SCROLLBARS] =
2974 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2975 GD_TYPE_SCROLLBAR_HORIZONTAL,
2976 GADGET_ID_SCROLL_HORIZONTAL,
2977 "scroll level editing area horizontally"
2980 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2981 GD_TYPE_SCROLLBAR_VERTICAL,
2982 GADGET_ID_SCROLL_VERTICAL,
2983 "scroll level editing area vertically"
2986 IMG_EDITOR_PALETTE_SCROLLBAR,
2987 GD_TYPE_SCROLLBAR_VERTICAL,
2988 GADGET_ID_SCROLL_LIST_VERTICAL,
2989 "scroll element list vertically"
2998 int gadget_id_align;
2999 int radio_button_nr;
3002 char *text_left, *text_right, *infotext;
3003 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3006 -1, ED_LEVEL_SETTINGS_YPOS(0),
3007 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3008 RADIO_NR_RANDOM_ELEMENTS,
3009 &random_placement_method, RANDOM_USE_PERCENTAGE,
3010 " ", "percentage", "use percentage for random elements"
3013 -1, ED_LEVEL_SETTINGS_YPOS(0),
3014 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3015 RADIO_NR_RANDOM_ELEMENTS,
3016 &random_placement_method, RANDOM_USE_QUANTITY,
3017 " ", "quantity", "use quantity for random elements"
3025 int gadget_id_align;
3027 char *text_above, *text_left, *text_right, *infotext;
3028 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3030 // ---------- level and editor settings -------------------------------------
3033 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3034 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3035 &level.auto_count_gems,
3037 "automatically count gems needed", "set counter to number of gems"
3040 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3041 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3042 &level.rate_time_over_score,
3044 "rate time/steps used over score", "sort high scores by playing time/steps"
3047 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3048 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3049 &levelset_use_levelset_artwork,
3051 "use current custom artwork", "use custom artwork of this level set"
3054 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3055 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3056 &levelset_copy_level_template,
3058 "copy current level template", "copy level template of this level set"
3061 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3062 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3063 &random_placement_background_restricted,
3065 "restrict random placement to:", "set random placement restriction"
3068 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3069 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3070 &setup.editor.use_template_for_new_levels,
3071 "Template for new levels and CE/GE:", NULL,
3072 "use template for new levels", "use template for level properties"
3075 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3076 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3077 &level.use_custom_template,
3079 "use template for custom elements", "use template for custom properties"
3082 // ---------- element settings: configure (various elements) ----------------
3085 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3086 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3087 &stick_element_properties_window,
3089 "stick this screen to edit content","stick this screen to edit content"
3092 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3093 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3094 &level.em_slippery_gems,
3096 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3099 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3100 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3101 &level.em_explodes_by_fire,
3103 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3106 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3107 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3108 &level.use_spring_bug,
3110 "use spring pushing bug", "use odd spring pushing behaviour"
3113 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3114 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3115 &level.use_time_orb_bug,
3117 "use time orb bug", "use odd time orb behaviour"
3120 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3121 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3122 &level.use_life_bugs,
3124 "use buggy element behaviour", "use odd (historic) element behaviour"
3127 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3128 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3131 "create single random element", "only create one element from content"
3134 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3135 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3136 &level.ball_active_initial,
3138 "magic ball initially activated", "activate magic ball after level start"
3141 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3142 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3143 &level.grow_into_diggable,
3145 "can grow into anything diggable", "grow into more than just sand"
3148 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3149 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3150 &level.sb_fields_needed,
3152 "all fields need to be filled", "require all SB fields to be solved"
3155 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3156 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3157 &level.sb_objects_needed,
3159 "all objects need to be placed", "require all SB objects to be solved"
3162 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3163 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3164 &level.auto_exit_sokoban,
3166 "exit level if all tasks solved", "automatically finish Sokoban levels"
3169 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3170 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3171 &level.solved_by_one_player,
3173 "only one player must enter exit", "level solved by first player in exit"
3176 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3177 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3178 &level.finish_dig_collect,
3180 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3183 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3184 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3185 &level.keep_walkable_ce,
3187 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3190 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3191 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3192 &level.continuous_snapping,
3194 "continuous snapping", "use snapping without releasing key"
3197 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3198 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3199 &level.block_snap_field,
3201 "block snapped field when snapping", "use snapping delay to show animation"
3204 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3205 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3206 &level.block_last_field,
3208 "block last field when moving", "player blocks last field when moving"
3211 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3212 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3213 &level.sp_block_last_field,
3215 "block last field when moving", "player blocks last field when moving"
3218 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3219 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3220 &level.instant_relocation,
3222 "no scrolling when relocating", "player gets relocated without delay"
3225 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3226 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3227 &level.shifted_relocation,
3229 "no centering when relocating", "level not centered after relocation"
3232 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3233 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3234 &level.lazy_relocation,
3236 "only redraw off-screen relocation","no redraw if relocation target visible"
3239 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3240 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3241 &level.use_start_element[0],
3243 "use level start element:", "start level at this element's position"
3246 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3247 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3248 &level.use_artwork_element[0],
3250 "use artwork from element:", "use player artwork from other element"
3253 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3254 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3255 &level.use_explosion_element[0],
3257 "use explosion from element:", "use explosion properties from element"
3260 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3261 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3262 &level.initial_player_gravity[0],
3264 "use initial gravity", "set initial player gravity"
3267 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3268 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3269 &level.use_initial_inventory[0],
3271 "use initial inventory:", "use collected elements on level start"
3274 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3275 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3276 &level.can_pass_to_walkable,
3278 "can pass to walkable element", "player can pass to empty or walkable"
3281 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3282 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3283 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3285 "can fall into acid (with gravity)","player can fall into acid pool"
3288 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3289 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3290 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3292 "can move into acid", "element can move into acid pool"
3295 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3296 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3297 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3299 "deadly when colliding with", "element is deadly when hitting player"
3302 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3303 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3304 &level.envelope[0].autowrap,
3306 "auto-wrap", "automatically wrap envelope text"
3309 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3310 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3311 &level.envelope[0].centered,
3313 "centered", "automatically center envelope text"
3316 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3317 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3318 &level.mm_laser_red,
3319 "choose color components for laser:", NULL,
3320 "red", "use red color components in laser"
3323 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3324 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3325 &level.mm_laser_green,
3327 "green", "use green color components in laser"
3330 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3331 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3332 &level.mm_laser_blue,
3334 "blue", "use blue color components in laser"
3337 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3338 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3339 &level.df_laser_red,
3340 "choose color components for laser:", NULL,
3341 "red", "use red color components in laser"
3344 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3345 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3346 &level.df_laser_green,
3348 "green", "use green color components in laser"
3351 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3352 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3353 &level.df_laser_blue,
3355 "blue", "use blue color components in laser"
3358 // ---------- element settings: configure 1 (custom elements) ---------------
3361 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3362 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3363 &custom_element.use_gfx_element,
3365 "use graphic of element:", "use existing element graphic"
3368 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3369 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3370 &level.use_custom_template,
3372 "use template", "use template for custom properties"
3375 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3376 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3377 &custom_element_properties[EP_ACCESSIBLE],
3379 NULL, "player can walk to or pass this field"
3382 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3383 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3384 &custom_element_properties[EP_GRAVITY_REACHABLE],
3386 "reachable despite gravity", "player can walk/dig despite gravity"
3389 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3390 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3391 &custom_element.use_last_ce_value,
3393 "use last CE value after change", "use last CE value after change"
3396 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3397 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3398 &custom_element_properties[EP_WALK_TO_OBJECT],
3400 NULL, "player can dig/collect/push element"
3403 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3404 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3405 &custom_element_properties[EP_INDESTRUCTIBLE],
3407 "indestructible", "element is indestructible"
3410 // ---------- element settings: configure 2 (custom elements) ---------------
3413 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3414 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3415 &custom_element_properties[EP_CAN_MOVE],
3417 NULL, "element can move with some pattern"
3420 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3421 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3422 &custom_element_properties[EP_CAN_FALL],
3424 "can fall", "element can fall down"
3427 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3428 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3429 &custom_element_properties[EP_CAN_SMASH],
3431 NULL, "element can smash other elements"
3434 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3435 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3436 &custom_element_properties[EP_SLIPPERY],
3438 NULL, "other elements can fall down from it"
3441 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3442 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3443 &custom_element_properties[EP_DEADLY],
3445 NULL, "element can kill the player"
3448 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3449 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3450 &custom_element_properties[EP_CAN_EXPLODE],
3452 NULL, "element can explode"
3455 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3456 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3457 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3459 "by fire", "element can explode by fire/explosion"
3462 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3463 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3464 &custom_element_properties[EP_EXPLODES_SMASHED],
3466 "smashed", "element can explode when smashed"
3469 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3470 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3471 &custom_element_properties[EP_EXPLODES_IMPACT],
3473 "impact", "element can explode on impact"
3476 // ---------- element settings: advanced (custom elements) ------------------
3479 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3480 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3481 &custom_element_change.can_change,
3483 "element changes to:", "change element on specified condition"
3486 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3487 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3488 &custom_element_change_events[CE_DELAY],
3490 NULL, "element changes after delay"
3493 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3494 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3495 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3497 NULL, "element changes by direct action"
3500 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3501 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3502 &custom_element_change_events[CE_BY_OTHER_ACTION],
3504 NULL, "element changes by other element"
3507 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3508 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3509 &custom_element_change.explode,
3511 "explode instead of change", "element explodes instead of change"
3514 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3515 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3516 &custom_element_change.use_target_content,
3518 "use extended change target:", "element changes to more elements"
3521 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3522 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3523 &custom_element_change.only_if_complete,
3525 "replace all or nothing", "only replace when all can be changed"
3528 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3529 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3530 &custom_element_change.use_random_replace,
3532 NULL, "use percentage for random replace"
3535 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3536 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3537 &custom_element_change.has_action,
3539 NULL, "execute action on specified condition"
3546 int xoffset, yoffset;
3548 int gadget_id_align;
3550 int area_xsize, area_ysize;
3551 char *text_left, *text_right, *text_above, *text_below, *infotext;
3552 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3554 // ---------- level playfield content ---------------------------------------
3559 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3561 -1, -1, // these values are not constant, but can change at runtime
3562 NULL, NULL, NULL, NULL, NULL
3565 // ---------- yam yam content -----------------------------------------------
3568 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3569 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3570 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3571 &level.yamyam_content[0].e[0][0], 3, 3,
3572 NULL, NULL, NULL, "1", NULL
3575 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3576 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3577 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3578 &level.yamyam_content[1].e[0][0], 3, 3,
3579 NULL, NULL, NULL, "2", NULL
3582 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3583 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3584 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3585 &level.yamyam_content[2].e[0][0], 3, 3,
3586 NULL, NULL, NULL, "3", NULL
3589 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3590 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3591 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3592 &level.yamyam_content[3].e[0][0], 3, 3,
3593 NULL, NULL, NULL, "4", NULL
3596 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3597 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3598 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3599 &level.yamyam_content[4].e[0][0], 3, 3,
3600 NULL, NULL, NULL, "5", NULL
3603 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3604 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3605 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3606 &level.yamyam_content[5].e[0][0], 3, 3,
3607 NULL, NULL, NULL, "6", NULL
3610 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3611 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3612 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3613 &level.yamyam_content[6].e[0][0], 3, 3,
3614 NULL, NULL, NULL, "7", NULL
3617 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3618 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3619 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3620 &level.yamyam_content[7].e[0][0], 3, 3,
3621 NULL, NULL, NULL, "8", NULL
3624 // ---------- magic ball content --------------------------------------------
3627 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3628 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3629 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3630 &level.ball_content[0].e[0][0], 3, 3,
3631 NULL, NULL, NULL, "1", NULL
3634 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3635 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3636 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3637 &level.ball_content[1].e[0][0], 3, 3,
3638 NULL, NULL, NULL, "2", NULL
3641 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3642 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3643 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3644 &level.ball_content[2].e[0][0], 3, 3,
3645 NULL, NULL, NULL, "3", NULL
3648 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3649 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3650 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3651 &level.ball_content[3].e[0][0], 3, 3,
3652 NULL, NULL, NULL, "4", NULL
3655 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3656 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3657 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3658 &level.ball_content[4].e[0][0], 3, 3,
3659 NULL, NULL, NULL, "5", NULL
3662 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3663 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3664 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3665 &level.ball_content[5].e[0][0], 3, 3,
3666 NULL, NULL, NULL, "6", NULL
3669 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3670 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3671 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3672 &level.ball_content[6].e[0][0], 3, 3,
3673 NULL, NULL, NULL, "7", NULL
3676 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3677 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3678 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3679 &level.ball_content[7].e[0][0], 3, 3,
3680 NULL, NULL, NULL, "8", NULL
3683 // ---------- android content -----------------------------------------------
3686 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
3687 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3688 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3689 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3690 NULL, NULL, "elements:", NULL, "elements android can clone"
3693 // ---------- amoeba content ------------------------------------------------
3696 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3697 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3698 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3699 &level.amoeba_content, 1, 1,
3700 "content:", NULL, NULL, NULL, "amoeba content"
3703 // ---------- level start element -------------------------------------------
3706 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3707 0, ED_AREA_1X1_SETTINGS_YOFF,
3708 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3709 &level.start_element[0], 1, 1,
3710 NULL, NULL, NULL, NULL, "level start element"
3713 // ---------- player artwork element ----------------------------------------
3716 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3717 0, ED_AREA_1X1_SETTINGS_YOFF,
3718 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3719 &level.artwork_element[0], 1, 1,
3720 NULL, NULL, NULL, NULL, "element for player artwork"
3723 // ---------- player explosion element --------------------------------------
3726 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
3727 0, ED_AREA_1X1_SETTINGS_YOFF,
3728 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3729 &level.explosion_element[0], 1, 1,
3730 NULL, NULL, NULL, NULL, "element for player explosion"
3733 // ---------- player initial inventory --------------------------------------
3736 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3737 0, ED_AREA_1X1_SETTINGS_YOFF,
3738 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3739 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3740 NULL, NULL, NULL, NULL, "content for initial inventory"
3743 // ---------- element settings: configure 1 (custom elements) ---------------
3745 // ---------- custom graphic ------------------------------------------------
3748 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3749 0, ED_AREA_1X1_SETTINGS_YOFF,
3750 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3751 &custom_element.gfx_element_initial,1, 1,
3752 NULL, NULL, NULL, NULL, "custom graphic element"
3755 // ---------- element settings: configure 2 (custom elements) ---------------
3757 // ---------- custom content (when exploding) -------------------------------
3760 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
3761 0, ED_AREA_3X3_SETTINGS_YOFF,
3762 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
3763 &custom_element.content.e[0][0], 3, 3,
3764 "content:", NULL, NULL, NULL, NULL
3767 // ---------- custom enter and leave element (when moving) ------------------
3770 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3771 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3772 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3773 &custom_element.move_enter_element, 1, 1,
3774 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
3777 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3778 0, ED_AREA_1X1_SETTINGS_YOFF,
3779 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3780 &custom_element.move_leave_element, 1, 1,
3781 NULL, NULL, NULL, NULL, "element that will be left behind"
3784 // ---------- element settings: advanced (custom elements) ------------------
3786 // ---------- custom change target ------------------------------------------
3789 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3790 0, ED_AREA_1X1_SETTINGS_YOFF,
3791 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3792 &custom_element_change.target_element, 1, 1,
3793 NULL, "after/when:", NULL, NULL, "new target element after change"
3796 // ---------- custom change content (extended change target) ----------------
3799 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3800 0, ED_AREA_3X3_SETTINGS_YOFF,
3801 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
3802 &custom_element_change.target_content.e[0][0], 3, 3,
3803 NULL, NULL, NULL, NULL, "new extended elements after change"
3806 // ---------- custom change trigger (element causing change) ----------------
3809 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3810 0, ED_AREA_1X1_SETTINGS_YOFF,
3811 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3812 &custom_element_change.initial_trigger_element, 1, 1,
3813 NULL, NULL, NULL, NULL, "other element triggering change"
3816 // ---------- custom change action (element used for action) ----------------
3819 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3820 0, ED_AREA_1X1_SETTINGS_YOFF,
3821 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3822 &custom_element_change.action_element, 1, 1,
3823 NULL, NULL, NULL, NULL, "element used as action parameter"
3826 // ---------- group element content -----------------------------------------
3829 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3830 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3831 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3832 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3833 "content:", NULL, NULL, NULL, NULL
3836 // ---------- random background (for random painting) -----------------------
3839 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
3840 0, ED_AREA_1X1_LSETTINGS_YOFF,
3841 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3842 &random_placement_background_element, 1, 1,
3843 NULL, NULL, NULL, NULL, "random placement background"
3848 // ----------------------------------------------------------------------------
3849 // some internally used variables
3850 // ----------------------------------------------------------------------------
3852 // maximal size of level editor drawing area
3853 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3855 // actual size of level editor drawing area
3856 static int ed_fieldx, ed_fieldy;
3858 // actual position of level editor drawing area in level playfield
3859 static int level_xpos = -1, level_ypos = -1;
3861 // actual tile size used to display playfield drawing area
3862 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3863 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
3865 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3867 // drawing elements on the three mouse buttons
3868 static int new_element1 = EL_WALL;
3869 static int new_element2 = EL_EMPTY;
3870 static int new_element3 = EL_SAND;
3872 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3873 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3874 (button) == 2 ? new_element2 : \
3875 (button) == 3 ? new_element3 : EL_EMPTY)
3877 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
3879 static int use_permanent_palette = TRUE;
3881 #define PX (use_permanent_palette ? DX : SX)
3882 #define PY (use_permanent_palette ? DY : SY)
3883 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
3884 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
3886 // forward declaration for internal use
3887 static void CopyBrushToCursor(int, int);
3888 static void DeleteBrushFromCursor(void);
3889 static void ModifyEditorCounterValue(int, int);
3890 static void ModifyEditorCounterLimits(int, int, int);
3891 static void ModifyEditorSelectboxValue(int, int);
3892 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3893 static void ModifyEditorDrawingArea(int, int, int);
3894 static void ModifyEditorElementList(void);
3895 static void AdjustElementListScrollbar(void);
3896 static void RedrawDrawingElements(void);
3897 static void DrawDrawingWindowExt(boolean);
3898 static void DrawDrawingWindow(void);
3899 static void DrawLevelInfoWindow(void);
3900 static void DrawPropertiesWindow(void);
3901 static void DrawPaletteWindow(void);
3902 static void UpdateCustomElementGraphicGadgets(void);
3903 static boolean checkPropertiesConfig(int);
3904 static void SetAutomaticNumberOfGemsNeeded(void);
3905 static void ClearEditorGadgetInfoText(void);
3906 static void CopyLevelToUndoBuffer(int);
3907 static void HandleDrawingAreas(struct GadgetInfo *);
3908 static void HandleCounterButtons(struct GadgetInfo *);
3909 static void HandleTextInputGadgets(struct GadgetInfo *);
3910 static void HandleTextAreaGadgets(struct GadgetInfo *);
3911 static void HandleSelectboxGadgets(struct GadgetInfo *);
3912 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3913 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3914 static void HandleRadiobuttons(struct GadgetInfo *);
3915 static void HandleCheckbuttons(struct GadgetInfo *);
3916 static void HandleControlButtons(struct GadgetInfo *);
3917 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3918 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3919 static boolean AskToCopyAndModifyLevelTemplate(void);
3920 static boolean getDrawModeHiRes(void);
3921 static int getTabulatorBarWidth(void);
3922 static int getTabulatorBarHeight(void);
3923 static Pixel getTabulatorBarColor(void);
3925 static int num_editor_gadgets = 0; // dynamically determined
3927 static struct GadgetInfo **level_editor_gadget = NULL;
3928 static int *right_gadget_border = NULL;
3930 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3931 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3932 static boolean draw_with_brush = FALSE;
3933 static int properties_element = 0;
3935 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3936 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3937 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3938 static int undo_buffer_position = 0;
3939 static int undo_buffer_steps = 0;
3940 static int redo_buffer_steps = 0;
3942 static int edit_mode;
3943 static int edit_mode_levelinfo;
3944 static int edit_mode_properties;
3946 static int element_shift = 0;
3948 static int editor_el_players[] =
3955 static int *editor_el_players_ptr = editor_el_players;
3956 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
3958 static int editor_hl_boulderdash[] =
3960 EL_INTERNAL_CASCADE_BD_ACTIVE,
3966 static int editor_el_boulderdash[] =
3975 EL_BD_EXPANDABLE_WALL,
3983 EL_BD_BUTTERFLY_LEFT,
3985 EL_BD_BUTTERFLY_RIGHT,
3986 EL_BD_FIREFLY_RIGHT,
3989 EL_BD_BUTTERFLY_DOWN,
3993 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3994 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3995 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
3996 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
3998 static int editor_hl_emerald_mine[] =
4000 EL_INTERNAL_CASCADE_EM_ACTIVE,
4006 static int editor_el_emerald_mine[] =
4024 EL_EM_DYNAMITE_ACTIVE,
4043 EL_ACID_POOL_TOPLEFT,
4045 EL_ACID_POOL_TOPRIGHT,
4048 EL_ACID_POOL_BOTTOMLEFT,
4049 EL_ACID_POOL_BOTTOM,
4050 EL_ACID_POOL_BOTTOMRIGHT,
4068 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4069 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4070 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4071 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4073 static int editor_hl_emerald_mine_club[] =
4075 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4081 static int editor_el_emerald_mine_club[] =
4108 EL_EMC_WALL_SLIPPERY_1,
4109 EL_EMC_WALL_SLIPPERY_2,
4110 EL_EMC_WALL_SLIPPERY_3,
4111 EL_EMC_WALL_SLIPPERY_4,
4134 EL_EMC_MAGIC_BALL_SWITCH,
4141 EL_EMC_SPRING_BUMPER,
4145 EL_BALLOON_SWITCH_UP,
4146 EL_BALLOON_SWITCH_ANY,
4149 EL_BALLOON_SWITCH_LEFT,
4151 EL_BALLOON_SWITCH_RIGHT,
4155 EL_BALLOON_SWITCH_DOWN,
4156 EL_BALLOON_SWITCH_NONE,
4158 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4159 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4160 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4161 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4163 static int editor_hl_rnd[] =
4165 EL_INTERNAL_CASCADE_RND_ACTIVE,
4171 static int editor_el_rnd[] =
4174 EL_DYNAMITE_ACTIVE, // RND
4208 EL_WALL_EMERALD_YELLOW,
4209 EL_WALL_EMERALD_RED,
4210 EL_WALL_EMERALD_PURPLE,
4228 EL_DYNABOMB_INCREASE_NUMBER,
4229 EL_DYNABOMB_INCREASE_SIZE,
4230 EL_DYNABOMB_INCREASE_POWER,
4250 EL_INVISIBLE_STEELWALL,
4254 EL_EXPANDABLE_WALL_HORIZONTAL,
4255 EL_EXPANDABLE_WALL_VERTICAL,
4256 EL_EXPANDABLE_WALL_ANY,
4258 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4259 static int *editor_el_rnd_ptr = editor_el_rnd;
4260 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4261 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4263 static int editor_hl_sokoban[] =
4265 EL_INTERNAL_CASCADE_SB_ACTIVE,
4271 static int editor_el_sokoban[] =
4274 EL_SOKOBAN_FIELD_EMPTY,
4275 EL_SOKOBAN_FIELD_FULL,
4276 EL_SOKOBAN_FIELD_PLAYER,
4278 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4279 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4280 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4281 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4283 static int editor_hl_supaplex[] =
4285 EL_INTERNAL_CASCADE_SP_ACTIVE,
4291 static int editor_el_supaplex[] =
4309 EL_SP_PORT_HORIZONTAL,
4310 EL_SP_PORT_VERTICAL,
4318 EL_SP_GRAVITY_PORT_LEFT,
4319 EL_SP_GRAVITY_PORT_RIGHT,
4320 EL_SP_GRAVITY_PORT_UP,
4321 EL_SP_GRAVITY_PORT_DOWN,
4323 EL_SP_GRAVITY_ON_PORT_LEFT,
4324 EL_SP_GRAVITY_ON_PORT_RIGHT,
4325 EL_SP_GRAVITY_ON_PORT_UP,
4326 EL_SP_GRAVITY_ON_PORT_DOWN,
4328 EL_SP_GRAVITY_OFF_PORT_LEFT,
4329 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4330 EL_SP_GRAVITY_OFF_PORT_UP,
4331 EL_SP_GRAVITY_OFF_PORT_DOWN,
4333 EL_SP_HARDWARE_GRAY,
4334 EL_SP_HARDWARE_GREEN,
4335 EL_SP_HARDWARE_BLUE,
4338 EL_SP_HARDWARE_BASE_1,
4339 EL_SP_HARDWARE_BASE_2,
4340 EL_SP_HARDWARE_BASE_3,
4341 EL_SP_HARDWARE_BASE_4,
4343 EL_SP_HARDWARE_BASE_5,
4344 EL_SP_HARDWARE_BASE_6,
4345 EL_SP_HARDWARE_YELLOW,
4353 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4354 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4355 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4356 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4358 static int editor_hl_diamond_caves[] =
4360 EL_INTERNAL_CASCADE_DC_ACTIVE,
4366 static int editor_el_diamond_caves[] =
4368 EL_EM_STEEL_EXIT_CLOSED, // DC2
4369 EL_EM_STEEL_EXIT_OPEN, // DC2
4370 EL_WALL_EMERALD, // DC2
4371 EL_WALL_DIAMOND, // DC2
4378 EL_CONVEYOR_BELT_1_LEFT,
4379 EL_CONVEYOR_BELT_1_MIDDLE,
4380 EL_CONVEYOR_BELT_1_RIGHT,
4381 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4383 EL_CONVEYOR_BELT_2_LEFT,
4384 EL_CONVEYOR_BELT_2_MIDDLE,
4385 EL_CONVEYOR_BELT_2_RIGHT,
4386 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4388 EL_CONVEYOR_BELT_3_LEFT,
4389 EL_CONVEYOR_BELT_3_MIDDLE,
4390 EL_CONVEYOR_BELT_3_RIGHT,
4391 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4393 EL_CONVEYOR_BELT_4_LEFT,
4394 EL_CONVEYOR_BELT_4_MIDDLE,
4395 EL_CONVEYOR_BELT_4_RIGHT,
4396 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4398 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4399 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4400 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4401 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4403 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4404 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4405 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4406 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4411 EL_DC_TIMEGATE_SWITCH,
4413 EL_SWITCHGATE_CLOSED,
4415 EL_SWITCHGATE_SWITCH_UP,
4416 EL_SWITCHGATE_SWITCH_DOWN,
4419 EL_LIGHT_SWITCH_ACTIVE,
4420 EL_DC_SWITCHGATE_SWITCH_UP,
4421 EL_DC_SWITCHGATE_SWITCH_DOWN,
4423 EL_STEEL_EXIT_CLOSED,
4425 EL_STEELWALL_SLIPPERY,
4428 EL_QUICKSAND_FAST_EMPTY,
4429 EL_QUICKSAND_FAST_FULL,
4443 EL_SIGN_RADIOACTIVITY,
4449 EL_SIGN_ENTRY_FORBIDDEN,
4450 EL_SIGN_EMERGENCY_EXIT,
4475 EL_DC_STEELWALL_2_SINGLE,
4476 EL_DC_STEELWALL_2_TOP,
4477 EL_SIGN_EXCLAMATION,
4480 EL_DC_STEELWALL_2_LEFT,
4481 EL_DC_STEELWALL_2_MIDDLE,
4482 EL_DC_STEELWALL_2_HORIZONTAL,
4483 EL_DC_STEELWALL_2_RIGHT,
4485 EL_DC_STEELWALL_1_TOPLEFT,
4486 EL_DC_STEELWALL_2_VERTICAL,
4487 EL_DC_STEELWALL_1_TOPRIGHT,
4490 EL_DC_STEELWALL_1_VERTICAL,
4491 EL_DC_STEELWALL_2_BOTTOM,
4493 EL_DC_GATE_WHITE_GRAY,
4495 EL_DC_STEELWALL_1_BOTTOMLEFT,
4496 EL_DC_STEELWALL_1_HORIZONTAL,
4497 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4498 EL_DC_GATE_FAKE_GRAY,
4500 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4501 EL_DC_STEELWALL_1_BOTTOM,
4502 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
4503 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
4505 EL_DC_STEELWALL_1_RIGHT,
4507 EL_DC_STEELWALL_1_LEFT,
4508 EL_EXPANDABLE_STEELWALL_VERTICAL,
4510 EL_DC_STEELWALL_1_TOPRIGHT_2,
4511 EL_DC_STEELWALL_1_TOP,
4512 EL_DC_STEELWALL_1_TOPLEFT_2,
4513 EL_EXPANDABLE_STEELWALL_ANY,
4515 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
4516 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
4517 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
4518 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
4520 static int editor_hl_dx_boulderdash[] =
4522 EL_INTERNAL_CASCADE_DX_ACTIVE,
4528 static int editor_el_dx_boulderdash[] =
4532 EL_TUBE_HORIZONTAL_DOWN,
4536 EL_TUBE_VERTICAL_RIGHT,
4538 EL_TUBE_VERTICAL_LEFT,
4542 EL_TUBE_HORIZONTAL_UP,
4550 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
4551 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
4552 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
4553 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
4555 static int editor_hl_mirror_magic[] =
4557 EL_INTERNAL_CASCADE_MM_ACTIVE,
4563 static int editor_el_mirror_magic[] =
4565 EL_MM_MCDUFFIN_RIGHT,
4567 EL_MM_MCDUFFIN_LEFT,
4568 EL_MM_MCDUFFIN_DOWN,
4571 EL_MM_MIRROR_FIXED_START,
4572 EL_MM_POLARIZER_START,
4573 EL_MM_POLARIZER_CROSS_START,
4575 EL_MM_TELEPORTER_RED_START,
4576 EL_MM_TELEPORTER_YELLOW_START,
4577 EL_MM_TELEPORTER_GREEN_START,
4578 EL_MM_TELEPORTER_BLUE_START,
4591 EL_MM_LIGHTBULB_ACTIVE,
4605 EL_MM_STEEL_GRID_FIXED_1,
4606 EL_MM_STEEL_GRID_FIXED_2,
4607 EL_MM_STEEL_GRID_FIXED_3,
4608 EL_MM_STEEL_GRID_FIXED_4,
4610 EL_MM_WOODEN_GRID_FIXED_1,
4611 EL_MM_WOODEN_GRID_FIXED_2,
4612 EL_MM_WOODEN_GRID_FIXED_3,
4613 EL_MM_WOODEN_GRID_FIXED_4
4615 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
4616 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
4617 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
4618 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
4620 static int editor_hl_deflektor[] =
4622 EL_INTERNAL_CASCADE_DF_ACTIVE,
4628 static int editor_el_deflektor[] =
4635 EL_DF_RECEIVER_RIGHT,
4637 EL_DF_RECEIVER_LEFT,
4638 EL_DF_RECEIVER_DOWN,
4641 EL_DF_MIRROR_ROTATING_START,
4645 EL_DF_FIBRE_OPTIC_RED_1,
4646 EL_DF_FIBRE_OPTIC_YELLOW_1,
4647 EL_DF_FIBRE_OPTIC_GREEN_1,
4648 EL_DF_FIBRE_OPTIC_BLUE_1,
4650 EL_DF_STEEL_GRID_FIXED_START,
4651 EL_DF_STEEL_GRID_ROTATING_START,
4652 EL_DF_WOODEN_GRID_FIXED_START,
4653 EL_DF_WOODEN_GRID_ROTATING_START,
4660 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
4661 static int *editor_el_deflektor_ptr = editor_el_deflektor;
4662 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
4663 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
4665 static int editor_hl_chars[] =
4667 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
4673 static int editor_el_chars[] =
4755 EL_CHAR(CHAR_BYTE_COPYRIGHT),
4756 EL_CHAR(CHAR_BYTE_UMLAUT_A),
4757 EL_CHAR(CHAR_BYTE_UMLAUT_O),
4758 EL_CHAR(CHAR_BYTE_UMLAUT_U),
4760 EL_CHAR(CHAR_BYTE_DEGREE),
4761 EL_CHAR(CHAR_BYTE_REGISTERED),
4762 EL_CHAR(FONT_ASCII_CURSOR),
4763 EL_CHAR(FONT_ASCII_BUTTON),
4765 EL_CHAR(FONT_ASCII_UP),
4766 EL_CHAR(FONT_ASCII_DOWN),
4770 static int *editor_hl_chars_ptr = editor_hl_chars;
4771 static int *editor_el_chars_ptr = editor_el_chars;
4772 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
4773 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
4775 static int editor_hl_steel_chars[] =
4777 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
4783 static int editor_el_steel_chars[] =
4793 EL_STEEL_CHAR('\''),
4860 EL_STEEL_CHAR('\\'),
4865 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
4866 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
4867 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
4868 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
4870 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
4871 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
4872 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4873 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4875 EL_STEEL_CHAR(FONT_ASCII_UP),
4876 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4880 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4881 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4882 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
4883 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
4885 static int editor_hl_custom[] =
4887 EL_INTERNAL_CASCADE_CE_ACTIVE,
4893 static int editor_el_custom[] =
4895 EL_CUSTOM_START + 0,
4896 EL_CUSTOM_START + 1,
4897 EL_CUSTOM_START + 2,
4898 EL_CUSTOM_START + 3,
4900 EL_CUSTOM_START + 4,
4901 EL_CUSTOM_START + 5,
4902 EL_CUSTOM_START + 6,
4903 EL_CUSTOM_START + 7,
4905 EL_CUSTOM_START + 8,
4906 EL_CUSTOM_START + 9,
4907 EL_CUSTOM_START + 10,
4908 EL_CUSTOM_START + 11,
4910 EL_CUSTOM_START + 12,
4911 EL_CUSTOM_START + 13,
4912 EL_CUSTOM_START + 14,
4913 EL_CUSTOM_START + 15,
4915 EL_CUSTOM_START + 16,
4916 EL_CUSTOM_START + 17,
4917 EL_CUSTOM_START + 18,
4918 EL_CUSTOM_START + 19,
4920 EL_CUSTOM_START + 20,
4921 EL_CUSTOM_START + 21,
4922 EL_CUSTOM_START + 22,
4923 EL_CUSTOM_START + 23,
4925 EL_CUSTOM_START + 24,
4926 EL_CUSTOM_START + 25,
4927 EL_CUSTOM_START + 26,
4928 EL_CUSTOM_START + 27,
4930 EL_CUSTOM_START + 28,
4931 EL_CUSTOM_START + 29,
4932 EL_CUSTOM_START + 30,
4933 EL_CUSTOM_START + 31,
4935 EL_CUSTOM_START + 32,
4936 EL_CUSTOM_START + 33,
4937 EL_CUSTOM_START + 34,
4938 EL_CUSTOM_START + 35,
4940 EL_CUSTOM_START + 36,
4941 EL_CUSTOM_START + 37,
4942 EL_CUSTOM_START + 38,
4943 EL_CUSTOM_START + 39,
4945 EL_CUSTOM_START + 40,
4946 EL_CUSTOM_START + 41,
4947 EL_CUSTOM_START + 42,
4948 EL_CUSTOM_START + 43,
4950 EL_CUSTOM_START + 44,
4951 EL_CUSTOM_START + 45,
4952 EL_CUSTOM_START + 46,
4953 EL_CUSTOM_START + 47,
4955 EL_CUSTOM_START + 48,
4956 EL_CUSTOM_START + 49,
4957 EL_CUSTOM_START + 50,
4958 EL_CUSTOM_START + 51,
4960 EL_CUSTOM_START + 52,
4961 EL_CUSTOM_START + 53,
4962 EL_CUSTOM_START + 54,
4963 EL_CUSTOM_START + 55,
4965 EL_CUSTOM_START + 56,
4966 EL_CUSTOM_START + 57,
4967 EL_CUSTOM_START + 58,
4968 EL_CUSTOM_START + 59,
4970 EL_CUSTOM_START + 60,
4971 EL_CUSTOM_START + 61,
4972 EL_CUSTOM_START + 62,
4973 EL_CUSTOM_START + 63,
4975 EL_CUSTOM_START + 64,
4976 EL_CUSTOM_START + 65,
4977 EL_CUSTOM_START + 66,
4978 EL_CUSTOM_START + 67,
4980 EL_CUSTOM_START + 68,
4981 EL_CUSTOM_START + 69,
4982 EL_CUSTOM_START + 70,
4983 EL_CUSTOM_START + 71,
4985 EL_CUSTOM_START + 72,
4986 EL_CUSTOM_START + 73,
4987 EL_CUSTOM_START + 74,
4988 EL_CUSTOM_START + 75,
4990 EL_CUSTOM_START + 76,
4991 EL_CUSTOM_START + 77,
4992 EL_CUSTOM_START + 78,
4993 EL_CUSTOM_START + 79,
4995 EL_CUSTOM_START + 80,
4996 EL_CUSTOM_START + 81,
4997 EL_CUSTOM_START + 82,
4998 EL_CUSTOM_START + 83,
5000 EL_CUSTOM_START + 84,
5001 EL_CUSTOM_START + 85,
5002 EL_CUSTOM_START + 86,
5003 EL_CUSTOM_START + 87,
5005 EL_CUSTOM_START + 88,
5006 EL_CUSTOM_START + 89,
5007 EL_CUSTOM_START + 90,
5008 EL_CUSTOM_START + 91,
5010 EL_CUSTOM_START + 92,
5011 EL_CUSTOM_START + 93,
5012 EL_CUSTOM_START + 94,
5013 EL_CUSTOM_START + 95,
5015 EL_CUSTOM_START + 96,
5016 EL_CUSTOM_START + 97,
5017 EL_CUSTOM_START + 98,
5018 EL_CUSTOM_START + 99,
5020 EL_CUSTOM_START + 100,
5021 EL_CUSTOM_START + 101,
5022 EL_CUSTOM_START + 102,
5023 EL_CUSTOM_START + 103,
5025 EL_CUSTOM_START + 104,
5026 EL_CUSTOM_START + 105,
5027 EL_CUSTOM_START + 106,
5028 EL_CUSTOM_START + 107,
5030 EL_CUSTOM_START + 108,
5031 EL_CUSTOM_START + 109,
5032 EL_CUSTOM_START + 110,
5033 EL_CUSTOM_START + 111,
5035 EL_CUSTOM_START + 112,
5036 EL_CUSTOM_START + 113,
5037 EL_CUSTOM_START + 114,
5038 EL_CUSTOM_START + 115,
5040 EL_CUSTOM_START + 116,
5041 EL_CUSTOM_START + 117,
5042 EL_CUSTOM_START + 118,
5043 EL_CUSTOM_START + 119,
5045 EL_CUSTOM_START + 120,
5046 EL_CUSTOM_START + 121,
5047 EL_CUSTOM_START + 122,
5048 EL_CUSTOM_START + 123,
5050 EL_CUSTOM_START + 124,
5051 EL_CUSTOM_START + 125,
5052 EL_CUSTOM_START + 126,
5053 EL_CUSTOM_START + 127,
5055 EL_CUSTOM_START + 128,
5056 EL_CUSTOM_START + 129,
5057 EL_CUSTOM_START + 130,
5058 EL_CUSTOM_START + 131,
5060 EL_CUSTOM_START + 132,
5061 EL_CUSTOM_START + 133,
5062 EL_CUSTOM_START + 134,
5063 EL_CUSTOM_START + 135,
5065 EL_CUSTOM_START + 136,
5066 EL_CUSTOM_START + 137,
5067 EL_CUSTOM_START + 138,
5068 EL_CUSTOM_START + 139,
5070 EL_CUSTOM_START + 140,
5071 EL_CUSTOM_START + 141,
5072 EL_CUSTOM_START + 142,
5073 EL_CUSTOM_START + 143,
5075 EL_CUSTOM_START + 144,
5076 EL_CUSTOM_START + 145,
5077 EL_CUSTOM_START + 146,
5078 EL_CUSTOM_START + 147,
5080 EL_CUSTOM_START + 148,
5081 EL_CUSTOM_START + 149,
5082 EL_CUSTOM_START + 150,
5083 EL_CUSTOM_START + 151,
5085 EL_CUSTOM_START + 152,
5086 EL_CUSTOM_START + 153,
5087 EL_CUSTOM_START + 154,
5088 EL_CUSTOM_START + 155,
5090 EL_CUSTOM_START + 156,
5091 EL_CUSTOM_START + 157,
5092 EL_CUSTOM_START + 158,
5093 EL_CUSTOM_START + 159,
5095 EL_CUSTOM_START + 160,
5096 EL_CUSTOM_START + 161,
5097 EL_CUSTOM_START + 162,
5098 EL_CUSTOM_START + 163,
5100 EL_CUSTOM_START + 164,
5101 EL_CUSTOM_START + 165,
5102 EL_CUSTOM_START + 166,
5103 EL_CUSTOM_START + 167,
5105 EL_CUSTOM_START + 168,
5106 EL_CUSTOM_START + 169,
5107 EL_CUSTOM_START + 170,
5108 EL_CUSTOM_START + 171,
5110 EL_CUSTOM_START + 172,
5111 EL_CUSTOM_START + 173,
5112 EL_CUSTOM_START + 174,
5113 EL_CUSTOM_START + 175,
5115 EL_CUSTOM_START + 176,
5116 EL_CUSTOM_START + 177,
5117 EL_CUSTOM_START + 178,
5118 EL_CUSTOM_START + 179,
5120 EL_CUSTOM_START + 180,
5121 EL_CUSTOM_START + 181,
5122 EL_CUSTOM_START + 182,
5123 EL_CUSTOM_START + 183,
5125 EL_CUSTOM_START + 184,
5126 EL_CUSTOM_START + 185,
5127 EL_CUSTOM_START + 186,
5128 EL_CUSTOM_START + 187,
5130 EL_CUSTOM_START + 188,
5131 EL_CUSTOM_START + 189,
5132 EL_CUSTOM_START + 190,
5133 EL_CUSTOM_START + 191,
5135 EL_CUSTOM_START + 192,
5136 EL_CUSTOM_START + 193,
5137 EL_CUSTOM_START + 194,
5138 EL_CUSTOM_START + 195,
5140 EL_CUSTOM_START + 196,
5141 EL_CUSTOM_START + 197,
5142 EL_CUSTOM_START + 198,
5143 EL_CUSTOM_START + 199,
5145 EL_CUSTOM_START + 200,
5146 EL_CUSTOM_START + 201,
5147 EL_CUSTOM_START + 202,
5148 EL_CUSTOM_START + 203,
5150 EL_CUSTOM_START + 204,
5151 EL_CUSTOM_START + 205,
5152 EL_CUSTOM_START + 206,
5153 EL_CUSTOM_START + 207,
5155 EL_CUSTOM_START + 208,
5156 EL_CUSTOM_START + 209,
5157 EL_CUSTOM_START + 210,
5158 EL_CUSTOM_START + 211,
5160 EL_CUSTOM_START + 212,
5161 EL_CUSTOM_START + 213,
5162 EL_CUSTOM_START + 214,
5163 EL_CUSTOM_START + 215,
5165 EL_CUSTOM_START + 216,
5166 EL_CUSTOM_START + 217,
5167 EL_CUSTOM_START + 218,
5168 EL_CUSTOM_START + 219,
5170 EL_CUSTOM_START + 220,
5171 EL_CUSTOM_START + 221,
5172 EL_CUSTOM_START + 222,
5173 EL_CUSTOM_START + 223,
5175 EL_CUSTOM_START + 224,
5176 EL_CUSTOM_START + 225,
5177 EL_CUSTOM_START + 226,
5178 EL_CUSTOM_START + 227,
5180 EL_CUSTOM_START + 228,
5181 EL_CUSTOM_START + 229,
5182 EL_CUSTOM_START + 230,
5183 EL_CUSTOM_START + 231,
5185 EL_CUSTOM_START + 232,
5186 EL_CUSTOM_START + 233,
5187 EL_CUSTOM_START + 234,
5188 EL_CUSTOM_START + 235,
5190 EL_CUSTOM_START + 236,
5191 EL_CUSTOM_START + 237,
5192 EL_CUSTOM_START + 238,
5193 EL_CUSTOM_START + 239,
5195 EL_CUSTOM_START + 240,
5196 EL_CUSTOM_START + 241,
5197 EL_CUSTOM_START + 242,
5198 EL_CUSTOM_START + 243,
5200 EL_CUSTOM_START + 244,
5201 EL_CUSTOM_START + 245,
5202 EL_CUSTOM_START + 246,
5203 EL_CUSTOM_START + 247,
5205 EL_CUSTOM_START + 248,
5206 EL_CUSTOM_START + 249,
5207 EL_CUSTOM_START + 250,
5208 EL_CUSTOM_START + 251,
5210 EL_CUSTOM_START + 252,
5211 EL_CUSTOM_START + 253,
5212 EL_CUSTOM_START + 254,
5213 EL_CUSTOM_START + 255
5215 static int *editor_hl_custom_ptr = editor_hl_custom;
5216 static int *editor_el_custom_ptr = editor_el_custom;
5217 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5218 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5220 static int editor_hl_group[] =
5222 EL_INTERNAL_CASCADE_GE_ACTIVE,
5228 static int editor_el_group[] =
5242 EL_GROUP_START + 10,
5243 EL_GROUP_START + 11,
5245 EL_GROUP_START + 12,
5246 EL_GROUP_START + 13,
5247 EL_GROUP_START + 14,
5248 EL_GROUP_START + 15,
5250 EL_GROUP_START + 16,
5251 EL_GROUP_START + 17,
5252 EL_GROUP_START + 18,
5253 EL_GROUP_START + 19,
5255 EL_GROUP_START + 20,
5256 EL_GROUP_START + 21,
5257 EL_GROUP_START + 22,
5258 EL_GROUP_START + 23,
5260 EL_GROUP_START + 24,
5261 EL_GROUP_START + 25,
5262 EL_GROUP_START + 26,
5263 EL_GROUP_START + 27,
5265 EL_GROUP_START + 28,
5266 EL_GROUP_START + 29,
5267 EL_GROUP_START + 30,
5270 static int *editor_hl_group_ptr = editor_hl_group;
5271 static int *editor_el_group_ptr = editor_el_group;
5272 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5273 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5275 static int editor_hl_empty_space[] =
5277 EL_INTERNAL_CASCADE_ES_ACTIVE,
5283 static int editor_el_empty_space[] =
5305 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
5306 static int *editor_el_empty_space_ptr = editor_el_empty_space;
5307 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
5308 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
5310 static int editor_hl_reference[] =
5312 EL_INTERNAL_CASCADE_REF_ACTIVE,
5318 static int editor_el_reference[] =
5322 EL_TRIGGER_CE_VALUE,
5323 EL_TRIGGER_CE_SCORE,
5327 EL_CURRENT_CE_VALUE,
5328 EL_CURRENT_CE_SCORE,
5350 static int *editor_hl_reference_ptr = editor_hl_reference;
5351 static int *editor_el_reference_ptr = editor_el_reference;
5352 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5353 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5355 static int editor_hl_user_defined[] =
5357 EL_INTERNAL_CASCADE_USER_ACTIVE,
5363 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5364 static int *editor_el_user_defined_ptr = NULL;
5365 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5366 static int num_editor_el_user_defined = 0;
5368 static int editor_hl_dynamic[] =
5370 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5376 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5377 static int *editor_el_dynamic_ptr = NULL;
5378 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5379 static int num_editor_el_dynamic = 0;
5381 static int editor_hl_empty[] = { EL_EMPTY };
5382 static int *editor_el_empty = NULL; // dynamically allocated
5384 static int *editor_hl_empty_ptr = editor_hl_empty;
5385 static int *editor_el_empty_ptr = NULL;
5386 static int num_editor_hl_empty = 0;
5387 static int num_editor_el_empty = 0; // dynamically determined, if needed
5389 static boolean use_el_empty = FALSE;
5391 static int *editor_elements = NULL; // dynamically allocated
5392 static int num_editor_elements = 0; // dynamically determined
5394 static boolean setup_editor_cascade_never = FALSE;
5396 static boolean setup_editor_el_players = TRUE;
5397 static boolean setup_editor_el_boulderdash = TRUE;
5398 static boolean setup_editor_el_emerald_mine = TRUE;
5399 static boolean setup_editor_el_emerald_mine_club = TRUE;
5400 static boolean setup_editor_el_more = TRUE;
5401 static boolean setup_editor_el_sokoban = TRUE;
5402 static boolean setup_editor_el_supaplex = TRUE;
5403 static boolean setup_editor_el_diamond_caves = TRUE;
5404 static boolean setup_editor_el_dx_boulderdash = TRUE;
5405 static boolean setup_editor_el_mirror_magic = TRUE;
5406 static boolean setup_editor_el_deflektor = TRUE;
5407 static boolean setup_editor_el_chars = TRUE;
5408 static boolean setup_editor_el_steel_chars = TRUE;
5409 static boolean setup_editor_el_custom = TRUE;
5410 static boolean setup_editor_el_user_defined = TRUE;
5411 static boolean setup_editor_el_dynamic = TRUE;
5413 static int editor_hl_unused[] = { EL_EMPTY };
5414 static int *editor_hl_unused_ptr = editor_hl_unused;
5415 static int num_editor_hl_unused = 0;
5419 boolean *setup_value;
5420 boolean *setup_cascade_value;
5422 int **headline_list;
5423 int *headline_list_size;
5426 int *element_list_size;
5428 boolean last_setup_value;
5430 editor_elements_info[] =
5433 &setup_editor_el_players,
5434 &setup_editor_cascade_never,
5435 &editor_hl_unused_ptr, &num_editor_hl_unused,
5436 &editor_el_players_ptr, &num_editor_el_players
5439 &setup_editor_el_boulderdash,
5440 &setup.editor_cascade.el_bd,
5441 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5442 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5445 &setup_editor_el_emerald_mine,
5446 &setup.editor_cascade.el_em,
5447 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5448 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5451 &setup_editor_el_emerald_mine_club,
5452 &setup.editor_cascade.el_emc,
5453 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5454 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5457 &setup_editor_el_more,
5458 &setup.editor_cascade.el_rnd,
5459 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5460 &editor_el_rnd_ptr, &num_editor_el_rnd
5463 &setup_editor_el_sokoban,
5464 &setup.editor_cascade.el_sb,
5465 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5466 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5469 &setup_editor_el_supaplex,
5470 &setup.editor_cascade.el_sp,
5471 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5472 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5475 &setup_editor_el_diamond_caves,
5476 &setup.editor_cascade.el_dc,
5477 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5478 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5481 &setup_editor_el_dx_boulderdash,
5482 &setup.editor_cascade.el_dx,
5483 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5484 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
5487 &setup_editor_el_mirror_magic,
5488 &setup.editor_cascade.el_mm,
5489 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
5490 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
5493 &setup_editor_el_deflektor,
5494 &setup.editor_cascade.el_df,
5495 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
5496 &editor_el_deflektor_ptr, &num_editor_el_deflektor
5499 &setup_editor_el_chars,
5500 &setup.editor_cascade.el_chars,
5501 &editor_hl_chars_ptr, &num_editor_hl_chars,
5502 &editor_el_chars_ptr, &num_editor_el_chars
5505 &setup_editor_el_steel_chars,
5506 &setup.editor_cascade.el_steel_chars,
5507 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
5508 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
5511 &setup_editor_el_custom,
5512 &setup.editor_cascade.el_ce,
5513 &editor_hl_custom_ptr, &num_editor_hl_custom,
5514 &editor_el_custom_ptr, &num_editor_el_custom
5517 &setup_editor_el_custom,
5518 &setup.editor_cascade.el_ge,
5519 &editor_hl_group_ptr, &num_editor_hl_group,
5520 &editor_el_group_ptr, &num_editor_el_group
5523 &setup_editor_el_custom,
5524 &setup.editor_cascade.el_es,
5525 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
5526 &editor_el_empty_space_ptr, &num_editor_el_empty_space
5529 &setup_editor_el_custom,
5530 &setup.editor_cascade.el_ref,
5531 &editor_hl_reference_ptr, &num_editor_hl_reference,
5532 &editor_el_reference_ptr, &num_editor_el_reference
5535 &setup_editor_el_user_defined,
5536 &setup.editor_cascade.el_user,
5537 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
5538 &editor_el_user_defined_ptr, &num_editor_el_user_defined
5541 &setup_editor_el_dynamic,
5542 &setup.editor_cascade.el_dynamic,
5543 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
5544 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
5549 &editor_hl_empty_ptr, &num_editor_hl_empty,
5550 &editor_el_empty_ptr, &num_editor_el_empty,
5561 // ----------------------------------------------------------------------------
5563 // ----------------------------------------------------------------------------
5565 static int getMaxInfoTextLength(void)
5567 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
5570 static int getTextWidthForGadget(char *text)
5575 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
5578 static int getTextWidthForDrawingArea(char *text)
5583 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
5586 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
5588 return (gi->x + gi->width + getTextWidthForGadget(text));
5591 static char *getElementInfoText(int element)
5593 char *info_text = NULL;
5595 if (element < MAX_NUM_ELEMENTS)
5597 if (strlen(element_info[element].description) > 0)
5598 info_text = element_info[element].description;
5599 else if (element_info[element].custom_description != NULL)
5600 info_text = element_info[element].custom_description;
5601 else if (element_info[element].editor_description != NULL)
5602 info_text = element_info[element].editor_description;
5605 if (info_text == NULL)
5606 info_text = INFOTEXT_UNKNOWN_ELEMENT;
5611 static char *getElementDescriptionFilenameExt(char *basename)
5613 char *elements_subdir = ELEMENTS_DIRECTORY;
5614 static char *elements_subdir2 = NULL;
5615 static char *filename = NULL;
5617 if (elements_subdir2 == NULL)
5618 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
5620 checked_free(filename);
5622 // 1st try: look for element description in current level set directory
5623 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
5624 if (fileExists(filename))
5629 // 2nd try: look for element description in the game's base directory
5630 filename = getPath3(options.docs_directory, elements_subdir, basename);
5631 if (fileExists(filename))
5637 static char *getElementDescriptionFilename(int element)
5639 char basename[MAX_FILENAME_LEN];
5642 // 1st try: look for element description file for exactly this element
5643 sprintf(basename, "%s.txt", element_info[element].token_name);
5644 filename = getElementDescriptionFilenameExt(basename);
5645 if (filename != NULL)
5648 // 2nd try: look for element description file for this element's class
5649 sprintf(basename, "%s.txt", element_info[element].class_name);
5650 filename = getElementDescriptionFilenameExt(basename);
5651 if (filename != NULL)
5654 // 3rd try: look for generic fallback text file for any element
5655 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
5656 if (filename != NULL)
5662 static boolean suppressBorderElement(void)
5664 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
5665 lev_fieldx <= MAX_ED_FIELDX &&
5666 lev_fieldy <= MAX_ED_FIELDY);
5669 static void InitDynamicEditorElementList(int **elements, int *num_elements)
5671 boolean element_found[NUM_FILE_ELEMENTS];
5674 // initialize list of used elements to "not used"
5675 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5676 element_found[i] = FALSE;
5678 // find all elements used in current level
5679 for (y = 0; y < lev_fieldy; y++)
5680 for (x = 0; x < lev_fieldx; x++)
5681 if (Tile[x][y] < NUM_FILE_ELEMENTS) // should always be true
5682 element_found[Tile[x][y]] = TRUE;
5686 // count number of elements used in current level
5687 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5688 if (element_found[i])
5691 // add space for up to 3 more elements for padding that may be needed
5694 // free memory for old list of elements, if needed
5695 checked_free(*elements);
5697 // allocate memory for new list of elements
5698 *elements = checked_malloc(*num_elements * sizeof(int));
5702 // add all elements used in current level (non-custom/group elements)
5703 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5704 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5705 (*elements)[(*num_elements)++] = i;
5707 // add all elements used in current level (custom/group elements)
5708 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5709 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5710 (*elements)[(*num_elements)++] = i;
5712 while (*num_elements % 4) // pad with empty elements, if needed
5713 (*elements)[(*num_elements)++] = EL_EMPTY;
5716 static void ReinitializeElementList_EnableSections(void)
5718 // default: enable all element sections
5720 setup_editor_el_players = TRUE;
5721 setup_editor_el_boulderdash = TRUE;
5722 setup_editor_el_emerald_mine = TRUE;
5723 setup_editor_el_emerald_mine_club = TRUE;
5724 setup_editor_el_more = TRUE;
5725 setup_editor_el_sokoban = TRUE;
5726 setup_editor_el_supaplex = TRUE;
5727 setup_editor_el_diamond_caves = TRUE;
5728 setup_editor_el_dx_boulderdash = TRUE;
5729 setup_editor_el_mirror_magic = TRUE;
5730 setup_editor_el_deflektor = TRUE;
5731 setup_editor_el_chars = TRUE;
5732 setup_editor_el_steel_chars = TRUE;
5734 setup_editor_el_custom = TRUE;
5735 setup_editor_el_user_defined = TRUE;
5736 setup_editor_el_dynamic = TRUE;
5738 // now disable all element sections not to be displayed
5740 if (!setup.editor.el_classic)
5742 setup_editor_el_players = FALSE;
5743 setup_editor_el_boulderdash = FALSE;
5744 setup_editor_el_emerald_mine = FALSE;
5745 setup_editor_el_emerald_mine_club = FALSE;
5746 setup_editor_el_more = FALSE;
5747 setup_editor_el_sokoban = FALSE;
5748 setup_editor_el_supaplex = FALSE;
5749 setup_editor_el_diamond_caves = FALSE;
5750 setup_editor_el_dx_boulderdash = FALSE;
5751 setup_editor_el_mirror_magic = FALSE;
5752 setup_editor_el_deflektor = FALSE;
5753 setup_editor_el_chars = FALSE;
5754 setup_editor_el_steel_chars = FALSE;
5757 if (!setup.editor.el_custom)
5759 setup_editor_el_custom = FALSE;
5762 if (!setup.editor.el_user_defined)
5764 setup_editor_el_user_defined = FALSE;
5767 if (!setup.editor.el_dynamic)
5769 setup_editor_el_dynamic = FALSE;
5772 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
5774 setup_editor_el_mirror_magic = FALSE;
5775 setup_editor_el_deflektor = FALSE;
5777 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
5779 setup_editor_el_boulderdash = FALSE;
5780 setup_editor_el_more = FALSE;
5781 setup_editor_el_sokoban = FALSE;
5782 setup_editor_el_supaplex = FALSE;
5783 setup_editor_el_diamond_caves = FALSE;
5784 setup_editor_el_dx_boulderdash = FALSE;
5785 setup_editor_el_mirror_magic = FALSE;
5786 setup_editor_el_deflektor = FALSE;
5787 setup_editor_el_steel_chars = FALSE;
5789 setup_editor_el_custom = FALSE;
5791 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
5793 setup_editor_el_players = FALSE;
5794 setup_editor_el_boulderdash = FALSE;
5795 setup_editor_el_emerald_mine = FALSE;
5796 setup_editor_el_emerald_mine_club = FALSE;
5797 setup_editor_el_more = FALSE;
5798 setup_editor_el_sokoban = FALSE;
5799 setup_editor_el_diamond_caves = FALSE;
5800 setup_editor_el_dx_boulderdash = FALSE;
5801 setup_editor_el_mirror_magic = FALSE;
5802 setup_editor_el_deflektor = FALSE;
5803 setup_editor_el_chars = FALSE;
5804 setup_editor_el_steel_chars = FALSE;
5806 setup_editor_el_custom = FALSE;
5808 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
5810 setup_editor_el_players = FALSE;
5811 setup_editor_el_boulderdash = FALSE;
5812 setup_editor_el_emerald_mine = FALSE;
5813 setup_editor_el_emerald_mine_club = FALSE;
5814 setup_editor_el_more = FALSE;
5815 setup_editor_el_sokoban = FALSE;
5816 setup_editor_el_supaplex = FALSE;
5817 setup_editor_el_diamond_caves = FALSE;
5818 setup_editor_el_dx_boulderdash = FALSE;
5819 setup_editor_el_steel_chars = FALSE;
5821 setup_editor_el_custom = FALSE;
5825 static void ReinitializeElementList(void)
5827 static boolean initialization_needed = TRUE;
5831 ReinitializeElementList_EnableSections();
5833 if (initialization_needed)
5835 LoadSetup_EditorCascade(); // load last editor cascade state
5837 // initialize editor cascade element from saved cascade state
5838 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5840 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
5841 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
5843 if (IS_EDITOR_CASCADE(*cascade_element))
5845 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
5846 EL_CASCADE_INACTIVE(*cascade_element));
5849 initialization_needed = FALSE;
5852 checked_free(editor_elements);
5854 // reload optional user defined element list for each invocation of editor
5855 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
5856 &num_editor_el_user_defined);
5858 // initialize dynamic level element list for each invocation of editor
5859 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
5860 &num_editor_el_dynamic);
5862 // initialize list of empty elements (used for padding, if needed)
5863 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5864 editor_el_empty[i] = EL_EMPTY;
5866 // do some sanity checks for each element from element list
5867 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5869 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5871 int element = (*editor_elements_info[i].element_list)[j];
5873 if (element >= NUM_FILE_ELEMENTS)
5874 Warn("editor element %d is runtime element", element);
5876 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
5877 Warn("no element description text for element %d", element);
5881 num_editor_elements = 0;
5882 use_el_empty = FALSE;
5884 // determine size of element list
5885 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5887 boolean found_inactive_cascade = FALSE;
5889 if (*editor_elements_info[i].setup_value)
5891 if (setup.editor.el_headlines)
5893 // required for correct padding of palette headline buttons
5894 if (*editor_elements_info[i].headline_list_size > 0)
5895 num_editor_elements += ED_ELEMENTLIST_COLS;
5897 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5899 int element = (*editor_elements_info[i].headline_list)[j];
5901 if (IS_EDITOR_CASCADE_INACTIVE(element))
5902 found_inactive_cascade = TRUE;
5906 if (found_inactive_cascade)
5909 // required for correct padding of palette element buttons
5910 int element_list_size = *editor_elements_info[i].element_list_size;
5912 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
5913 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
5915 num_editor_elements += element_buttons;
5919 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
5921 // offer at least as many elements as element buttons exist
5922 use_el_empty = TRUE;
5923 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
5925 num_editor_elements += num_editor_el_empty;
5929 num_editor_el_empty = 0;
5932 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
5934 // fill element list
5935 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5937 boolean found_inactive_cascade = FALSE;
5939 if (*editor_elements_info[i].setup_value)
5941 if (setup.editor.el_headlines)
5943 // required for correct padding of palette headline buttons
5944 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
5945 ED_ELEMENTLIST_COLS : 0);
5947 for (j = 0; j < headline_size; j++)
5949 // use empty elements for padding of palette headline buttons
5950 int element = (j < *editor_elements_info[i].headline_list_size ?
5951 (*editor_elements_info[i].headline_list)[j] :
5952 editor_el_empty[0]);
5954 editor_elements[pos++] = element;
5956 if (IS_EDITOR_CASCADE_INACTIVE(element))
5957 found_inactive_cascade = TRUE;
5961 if (found_inactive_cascade)
5964 // required for correct padding of palette element buttons
5965 int element_list_size = *editor_elements_info[i].element_list_size;
5967 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
5968 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
5970 // copy all elements from element list
5971 for (j = 0; j < element_list_size; j++)
5972 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
5974 // use empty elements for padding of palette element buttons
5975 for (j = 0; j < element_buttons - element_list_size; j++)
5976 editor_elements[pos++] = editor_el_empty[0];
5980 // (this function is also called before editor gadgets are initialized!)
5981 AdjustElementListScrollbar();
5984 void PrintEditorElementList(void)
5986 boolean *stop = &setup_editor_el_user_defined;
5989 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
5991 int cascade_element = (*editor_elements_info[i].headline_list)[0];
5993 if (IS_EDITOR_CASCADE(cascade_element))
5995 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
5996 char *headline = element_info[cascade_element_show].editor_description;
5998 PrintLineWithPrefix("# ", "-", 77);
5999 Print("# %s\n", headline);
6000 PrintLineWithPrefix("# ", "-", 77);
6003 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6005 int element = (*editor_elements_info[i].headline_list)[j];
6007 if (IS_EDITOR_CASCADE(element))
6008 element = EL_CHAR_MINUS;
6010 Print("# %s\n", element_info[element].token_name);
6016 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6018 int element = (*editor_elements_info[i].element_list)[j];
6020 Print("# %s\n", element_info[element].token_name);
6028 static void ReinitializeElementListButtons(void)
6030 static boolean last_setup_value_headlines = FALSE;
6031 static boolean initialization_needed = TRUE;
6034 if (!initialization_needed) // check if editor element setup has changed
6036 if (last_setup_value_headlines != setup.editor.el_headlines)
6037 initialization_needed = TRUE;
6039 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6040 if (editor_elements_info[i].last_setup_value !=
6041 *editor_elements_info[i].setup_value)
6042 initialization_needed = TRUE;
6045 if (!initialization_needed)
6048 FreeLevelEditorGadgets();
6049 CreateLevelEditorGadgets();
6051 // store current setup values for next invocation of this function
6052 last_setup_value_headlines = setup.editor.el_headlines;
6053 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6054 editor_elements_info[i].last_setup_value =
6055 *editor_elements_info[i].setup_value;
6057 initialization_needed = FALSE;
6060 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6063 int border_graphic =
6064 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6065 struct GraphicInfo *g = &graphic_info[border_graphic];
6066 Bitmap *src_bitmap = g->bitmap;
6067 int src_x = g->src_x;
6068 int src_y = g->src_y;
6069 int border_size = g->border_size;
6070 int border_xpos = g->width - border_size;
6071 int border_ypos = g->height - border_size;
6072 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6075 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6076 border_size, border_size,
6077 dest_x - border_size, dest_y - border_size);
6078 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6079 border_size, border_size,
6080 dest_x + width, dest_y - border_size);
6081 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6082 border_size, border_size,
6083 dest_x - border_size, dest_y + height);
6084 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6085 border_size, border_size,
6086 dest_x + width, dest_y + height);
6088 for (i = 0; i < width / tilesize; i++)
6090 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6091 tilesize, border_size,
6092 dest_x + i * tilesize, dest_y - border_size);
6093 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6094 tilesize, border_size,
6095 dest_x + i * tilesize, dest_y + height);
6098 for (i = 0; i < height / tilesize; i++)
6100 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6101 border_size, tilesize,
6102 dest_x - border_size, dest_y + i * tilesize);
6103 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6104 border_size, tilesize,
6105 dest_x + width, dest_y + i * tilesize);
6108 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6111 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6113 int xsize_tile = MAX(ed_tilesize, xsize);
6114 int ysize_tile = MAX(ed_tilesize, ysize);
6115 int xsize_full = xsize + 1;
6116 int ysize_full = ysize + 1;
6117 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6118 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6119 Pixel line_color = getTabulatorBarColor();
6121 if (line_color == BLACK_PIXEL) // black => transparent
6124 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6125 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6126 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6129 static void DrawEditorLevelBorderLinesIfNeeded(void)
6131 int xsize = lev_fieldx * ed_tilesize;
6132 int ysize = lev_fieldy * ed_tilesize;
6133 int line_size = getTabulatorBarHeight();
6135 if (!suppressBorderElement())
6138 // draw little border line around editable level playfield
6141 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6144 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6146 if (xsize < SXSIZE && ysize < SYSIZE)
6147 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6150 static void DrawEditorElement(int x, int y, int element)
6152 DrawSizedElement(x, y, element, ed_tilesize);
6155 static void DrawEditorElementThruMask(int x, int y, int element)
6157 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6160 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6162 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6165 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6167 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6168 DrawEditorLevelBorderLinesIfNeeded();
6171 static void DrawDrawingArea(int id)
6173 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6176 int *value = drawingarea_info[id].value;
6177 int area_xsize = drawingarea_info[id].area_xsize;
6178 int area_ysize = drawingarea_info[id].area_ysize;
6179 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6181 for (x = 0; x < area_xsize; x++)
6182 for (y = 0; y < area_ysize; y++)
6183 DrawSizedGraphicExt(drawto,
6184 gi->x + x * tilesize,
6185 gi->y + y * tilesize,
6186 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6189 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6192 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6193 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6195 BlitBitmap(drawto, drawto,
6196 SX + (dx == -1 ? ed_tilesize : 0),
6197 SY + (dy == -1 ? ed_tilesize : 0),
6198 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6199 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6200 SX + (dx == +1 ? ed_tilesize : 0),
6201 SY + (dy == +1 ? ed_tilesize : 0));
6205 x = (dx == 1 ? 0 : ed_fieldx - 1);
6206 for (y = 0; y < ed_fieldy; y++)
6207 DrawEditorElementOrWall(x, y, from_x, from_y);
6211 y = (dy == 1 ? 0 : ed_fieldy - 1);
6212 for (x = 0; x < ed_fieldx; x++)
6213 DrawEditorElementOrWall(x, y, from_x, from_y);
6216 redraw_mask |= REDRAW_FIELD;
6220 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6223 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6226 static void CreateControlButtons(void)
6228 struct GadgetInfo *gi;
6231 // create toolbox buttons
6232 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6234 int id = controlbutton_info[i].gadget_id;
6235 int type = controlbutton_info[i].gadget_type;
6236 int graphic = controlbutton_info[i].graphic;
6237 struct XYTileSize *pos = controlbutton_info[i].pos;
6238 struct GraphicInfo *gd = &graphic_info[graphic];
6239 Bitmap *deco_bitmap = NULL;
6240 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6241 int tile_size = 0, deco_shift = 0;
6242 boolean deco_masked = FALSE;
6243 int gd_x1 = gd->src_x;
6244 int gd_y1 = gd->src_y;
6245 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6246 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6247 int gd_x1a = gd->src_x + gd->active_xoffset;
6248 int gd_y1a = gd->src_y + gd->active_yoffset;
6249 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6250 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6253 unsigned int event_mask;
6254 int radio_button_nr = RADIO_NR_NONE;
6255 boolean checked = FALSE;
6257 if (type == GD_TYPE_RADIO_BUTTON)
6259 event_mask = GD_EVENT_PRESSED;
6260 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6262 if (id == drawing_function)
6267 if (id == GADGET_ID_WRAP_LEFT ||
6268 id == GADGET_ID_WRAP_RIGHT ||
6269 id == GADGET_ID_WRAP_UP ||
6270 id == GADGET_ID_WRAP_DOWN)
6271 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6273 event_mask = GD_EVENT_RELEASED;
6276 if (id == GADGET_ID_PROPERTIES ||
6277 id == GADGET_ID_PALETTE)
6282 else if (id == GADGET_ID_ELEMENT_LEFT ||
6283 id == GADGET_ID_ELEMENT_MIDDLE ||
6284 id == GADGET_ID_ELEMENT_RIGHT)
6289 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6290 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6291 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6293 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6294 editor.button.element_left.tile_size :
6295 id == GADGET_ID_ELEMENT_MIDDLE ?
6296 editor.button.element_middle.tile_size :
6297 id == GADGET_ID_ELEMENT_RIGHT ?
6298 editor.button.element_right.tile_size : 0);
6300 // make sure that decoration does not overlap gadget border
6301 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6303 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6305 deco_xpos = (gd->width - tile_size) / 2;
6306 deco_ypos = (gd->height - tile_size) / 2;
6308 deco_masked = gd->draw_masked;
6316 gi = CreateGadget(GDI_CUSTOM_ID, id,
6317 GDI_CUSTOM_TYPE_ID, i,
6318 GDI_IMAGE_ID, graphic,
6319 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6322 GDI_WIDTH, gd->width,
6323 GDI_HEIGHT, gd->height,
6325 GDI_STATE, GD_BUTTON_UNPRESSED,
6326 GDI_RADIO_NR, radio_button_nr,
6327 GDI_CHECKED, checked,
6328 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6329 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6330 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6331 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6332 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6333 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6334 GDI_DECORATION_SIZE, tile_size, tile_size,
6335 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6336 GDI_DECORATION_MASKED, deco_masked,
6337 GDI_EVENT_MASK, event_mask,
6338 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6339 GDI_CALLBACK_ACTION, HandleControlButtons,
6343 Fail("cannot create gadget");
6345 level_editor_gadget[id] = gi;
6348 // these values are not constant, but can change at runtime
6349 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6350 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6351 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6352 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6353 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6354 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6355 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6356 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6357 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6358 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6359 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6360 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6362 // create buttons for scrolling of drawing area and element list
6363 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6365 int id = scrollbutton_info[i].gadget_id;
6366 int graphic = scrollbutton_info[i].graphic;
6367 struct GraphicInfo *gd = &graphic_info[graphic];
6368 Bitmap *gd_bitmap = gd->bitmap;
6369 int gd_x1 = gd->src_x;
6370 int gd_y1 = gd->src_y;
6371 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6372 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6373 int width = gd->width;
6374 int height = gd->height;
6375 int x = scrollbutton_pos[i].x;
6376 int y = scrollbutton_pos[i].y;
6377 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6379 if (id == GADGET_ID_SCROLL_LIST_UP ||
6380 id == GADGET_ID_SCROLL_LIST_DOWN)
6391 gi = CreateGadget(GDI_CUSTOM_ID, id,
6392 GDI_CUSTOM_TYPE_ID, i,
6393 GDI_IMAGE_ID, graphic,
6394 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6399 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6400 GDI_STATE, GD_BUTTON_UNPRESSED,
6401 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6402 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6403 GDI_EVENT_MASK, event_mask,
6404 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6405 GDI_CALLBACK_ACTION, HandleControlButtons,
6409 Fail("cannot create gadget");
6411 level_editor_gadget[id] = gi;
6414 // create buttons for element list
6415 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6417 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6418 int graphic = IMG_EDITOR_PALETTE_BUTTON;
6419 struct GraphicInfo *gd = &graphic_info[graphic];
6420 Bitmap *gd_bitmap = gd->bitmap;
6421 Bitmap *deco_bitmap;
6422 int deco_x, deco_y, deco_xpos, deco_ypos;
6423 int gd_x1 = gd->src_x;
6424 int gd_y1 = gd->src_y;
6425 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6426 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6427 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
6428 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
6429 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
6430 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
6431 int element = editor_elements[i];
6432 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
6433 unsigned int event_mask = GD_EVENT_RELEASED;
6435 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
6437 deco_xpos = (gd->width - tile_size) / 2;
6438 deco_ypos = (gd->height - tile_size) / 2;
6440 gi = CreateGadget(GDI_CUSTOM_ID, id,
6441 GDI_CUSTOM_TYPE_ID, i,
6442 GDI_IMAGE_ID, graphic,
6443 GDI_INFO_TEXT, getElementInfoText(element),
6446 GDI_WIDTH, gd->width,
6447 GDI_HEIGHT, gd->height,
6448 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6449 GDI_STATE, GD_BUTTON_UNPRESSED,
6450 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6451 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6452 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6453 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6454 GDI_DECORATION_SIZE, tile_size, tile_size,
6455 GDI_DECORATION_SHIFTING, 1, 1,
6456 GDI_EVENT_MASK, event_mask,
6457 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6458 GDI_CALLBACK_ACTION, HandleControlButtons,
6462 Fail("cannot create gadget");
6464 level_editor_gadget[id] = gi;
6468 static void CreateCounterButtons(void)
6470 int max_infotext_len = getMaxInfoTextLength();
6473 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
6476 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
6477 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
6479 // determine horizontal position to the right of specified gadget
6480 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6481 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
6482 ED_GADGET_TEXT_DISTANCE);
6484 // determine horizontal offset for leading text
6485 if (counterbutton_info[i].text_left != NULL)
6486 x += getTextWidthForGadget(counterbutton_info[i].text_left);
6488 for (j = 0; j < 2; j++)
6490 struct GadgetInfo *gi;
6492 counterbutton_info[i].gadget_id_down :
6493 counterbutton_info[i].gadget_id_up);
6495 struct GraphicInfo *gd;
6496 int gd_x1, gd_x2, gd_y1, gd_y2;
6497 unsigned int event_mask;
6498 char infotext[max_infotext_len + 1];
6500 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6502 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6505 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
6506 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
6508 event_mask |= GD_EVENT_RELEASED;
6512 x = DX + editor.button.prev_level.x;
6513 y = DY + editor.button.prev_level.y;
6517 x = DX + editor.button.next_level.x;
6518 y = DY + editor.button.next_level.y;
6524 IMG_EDITOR_COUNTER_DOWN :
6525 IMG_EDITOR_COUNTER_UP);
6528 gd = &graphic_info[graphic];
6532 gd_x2 = gd->src_x + gd->pressed_xoffset;
6533 gd_y2 = gd->src_y + gd->pressed_yoffset;
6535 sprintf(infotext, "%s counter value by 1, 5 or 10",
6536 (j == 0 ? "decrease" : "increase"));
6538 gi = CreateGadget(GDI_CUSTOM_ID, id,
6539 GDI_CUSTOM_TYPE_ID, i,
6540 GDI_IMAGE_ID, graphic,
6541 GDI_INFO_TEXT, infotext,
6544 GDI_WIDTH, gd->width,
6545 GDI_HEIGHT, gd->height,
6546 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6547 GDI_STATE, GD_BUTTON_UNPRESSED,
6548 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6549 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
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; // text count button
6566 int font_type = FONT_INPUT_1;
6567 int font_type_active = FONT_INPUT_1_ACTIVE;
6569 id = counterbutton_info[i].gadget_id_text;
6571 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6573 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6575 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
6577 font_type = FONT_LEVEL_NUMBER;
6578 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
6580 x = DX + editor.input.level_number.x;
6581 y = DY + editor.input.level_number.y;
6585 graphic = IMG_EDITOR_COUNTER_INPUT;
6588 gd = &graphic_info[graphic];
6592 gd_x2 = gd->src_x + gd->active_xoffset;
6593 gd_y2 = gd->src_y + gd->active_yoffset;
6595 gi = CreateGadget(GDI_CUSTOM_ID, id,
6596 GDI_CUSTOM_TYPE_ID, i,
6597 GDI_IMAGE_ID, graphic,
6598 GDI_INFO_TEXT, "enter counter value",
6601 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
6602 GDI_NUMBER_VALUE, 0,
6603 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
6604 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
6605 GDI_TEXT_SIZE, 3, // minimal counter text size
6606 GDI_TEXT_FONT, font_type,
6607 GDI_TEXT_FONT_ACTIVE, font_type_active,
6608 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6609 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6610 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6611 GDI_DESIGN_WIDTH, gd->width,
6612 GDI_EVENT_MASK, event_mask,
6613 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6614 GDI_CALLBACK_ACTION, HandleCounterButtons,
6618 Fail("cannot create gadget");
6620 level_editor_gadget[id] = gi;
6621 right_gadget_border[id] =
6622 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6624 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
6630 static void CreateDrawingAreas(void)
6634 // these values are not constant, but can change at runtime
6635 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
6636 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
6638 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
6640 struct GadgetInfo *gi;
6641 unsigned int event_mask;
6642 int id = drawingarea_info[i].gadget_id;
6643 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
6644 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
6645 int area_xsize = drawingarea_info[i].area_xsize;
6646 int area_ysize = drawingarea_info[i].area_ysize;
6647 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
6648 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
6651 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
6652 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
6654 // determine horizontal position to the right of specified gadget
6655 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
6656 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
6657 ED_DRAWINGAREA_TEXT_DISTANCE);
6659 // determine horizontal offset for leading text
6660 if (drawingarea_info[i].text_left != NULL)
6661 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
6663 gi = CreateGadget(GDI_CUSTOM_ID, id,
6664 GDI_CUSTOM_TYPE_ID, i,
6667 GDI_TYPE, GD_TYPE_DRAWING_AREA,
6668 GDI_AREA_SIZE, area_xsize, area_ysize,
6669 GDI_ITEM_SIZE, item_size, item_size,
6670 GDI_EVENT_MASK, event_mask,
6671 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
6672 GDI_CALLBACK_ACTION, HandleDrawingAreas,
6676 Fail("cannot create gadget");
6678 level_editor_gadget[id] = gi;
6679 right_gadget_border[id] =
6680 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
6684 static void CreateTextInputGadgets(void)
6686 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
6687 int max_infotext_len = getMaxInfoTextLength();
6690 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
6692 int gd_x1 = gd->src_x;
6693 int gd_y1 = gd->src_y;
6694 int gd_x2 = gd->src_x + gd->active_xoffset;
6695 int gd_y2 = gd->src_y + gd->active_yoffset;
6696 struct GadgetInfo *gi;
6697 unsigned int event_mask;
6698 char infotext[MAX_OUTPUT_LINESIZE + 1];
6699 int id = textinput_info[i].gadget_id;
6702 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
6704 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
6705 int border_size = gd->border_size;
6706 int font_nr = FONT_INPUT_1;
6707 int font_height = getFontHeight(font_nr);
6708 int xoffset = element_border + TILEX + element_border + 3 * border_size;
6709 int yoffset = element_border + (TILEY - font_height) / 2;
6711 x = (editor.settings.element_name.x != -1 ?
6712 editor.settings.element_name.x :
6713 editor.settings.element_graphic.x + xoffset) - border_size;
6714 y = (editor.settings.element_name.y != -1 ?
6715 editor.settings.element_name.y :
6716 editor.settings.element_graphic.y + yoffset) - border_size;
6720 x = ED_SETTINGS_X(textinput_info[i].x);
6721 y = ED_SETTINGS_Y(textinput_info[i].y);
6724 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6726 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
6727 infotext[max_infotext_len] = '\0';
6729 gi = CreateGadget(GDI_CUSTOM_ID, id,
6730 GDI_CUSTOM_TYPE_ID, i,
6731 GDI_INFO_TEXT, infotext,
6734 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
6735 GDI_TEXT_VALUE, textinput_info[i].value,
6736 GDI_TEXT_SIZE, textinput_info[i].size,
6737 GDI_TEXT_FONT, FONT_INPUT_1,
6738 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6739 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6740 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6741 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6742 GDI_DESIGN_WIDTH, gd->width,
6743 GDI_EVENT_MASK, event_mask,
6744 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6745 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
6749 Fail("cannot create gadget");
6751 level_editor_gadget[id] = gi;
6755 static void CreateTextAreaGadgets(void)
6757 int max_infotext_len = getMaxInfoTextLength();
6760 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
6762 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
6763 int gd_x1 = gd->src_x;
6764 int gd_y1 = gd->src_y;
6765 int gd_x2 = gd->src_x + gd->active_xoffset;
6766 int gd_y2 = gd->src_y + gd->active_yoffset;
6767 struct GadgetInfo *gi;
6768 unsigned int event_mask;
6769 char infotext[MAX_OUTPUT_LINESIZE + 1];
6770 int id = textarea_info[i].gadget_id;
6771 int area_xsize = textarea_info[i].xsize;
6772 int area_ysize = textarea_info[i].ysize;
6774 event_mask = GD_EVENT_TEXT_LEAVING;
6776 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
6777 infotext[max_infotext_len] = '\0';
6779 gi = CreateGadget(GDI_CUSTOM_ID, id,
6780 GDI_CUSTOM_TYPE_ID, i,
6781 GDI_INFO_TEXT, infotext,
6782 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
6783 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
6784 GDI_TYPE, GD_TYPE_TEXT_AREA,
6785 GDI_AREA_SIZE, area_xsize, area_ysize,
6786 GDI_TEXT_FONT, FONT_INPUT_1,
6787 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6788 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6789 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6790 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6791 GDI_DESIGN_WIDTH, gd->width,
6792 GDI_EVENT_MASK, event_mask,
6793 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6794 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
6798 Fail("cannot create gadget");
6800 level_editor_gadget[id] = gi;
6804 static void CreateSelectboxGadgets(void)
6806 int max_infotext_len = getMaxInfoTextLength();
6809 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6811 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
6812 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
6813 int gd_x1 = gd->src_x;
6814 int gd_y1 = gd->src_y;
6815 int gd_x2 = gd->src_x + gd->active_xoffset;
6816 int gd_y2 = gd->src_y + gd->active_yoffset;
6817 int selectbox_button_xsize = gd2->width;
6818 struct GadgetInfo *gi;
6819 unsigned int event_mask;
6820 char infotext[MAX_OUTPUT_LINESIZE + 1];
6821 int id = selectbox_info[i].gadget_id;
6822 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
6823 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
6825 if (selectbox_info[i].size == -1) // dynamically determine size
6827 // (we cannot use -1 for uninitialized values if we directly compare
6828 // with results from strlen(), because the '<' and '>' operation will
6829 // implicitely cast -1 to an unsigned integer value!)
6830 selectbox_info[i].size = 0;
6832 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
6833 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
6834 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
6836 selectbox_info[i].size++; // add one character empty space
6839 event_mask = GD_EVENT_RELEASED |
6840 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6842 // determine horizontal position to the right of specified gadget
6843 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
6844 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
6845 ED_GADGET_TEXT_DISTANCE);
6847 // determine horizontal offset for leading text
6848 if (selectbox_info[i].text_left != NULL)
6849 x += getTextWidthForGadget(selectbox_info[i].text_left);
6851 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
6852 infotext[max_infotext_len] = '\0';
6854 gi = CreateGadget(GDI_CUSTOM_ID, id,
6855 GDI_CUSTOM_TYPE_ID, i,
6856 GDI_INFO_TEXT, infotext,
6859 GDI_TYPE, GD_TYPE_SELECTBOX,
6860 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
6861 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
6862 GDI_TEXT_SIZE, selectbox_info[i].size,
6863 GDI_TEXT_FONT, FONT_INPUT_1,
6864 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6865 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
6866 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6867 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6868 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6869 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
6870 GDI_DESIGN_WIDTH, gd->width,
6871 GDI_EVENT_MASK, event_mask,
6872 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6873 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
6877 Fail("cannot create gadget");
6879 level_editor_gadget[id] = gi;
6880 right_gadget_border[id] =
6881 getRightGadgetBorder(gi, selectbox_info[i].text_right);
6885 static void CreateTextbuttonGadgets(void)
6887 int max_infotext_len = getMaxInfoTextLength();
6890 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
6892 int id = textbutton_info[i].gadget_id;
6894 ((id >= GADGET_ID_LEVELINFO_LEVEL && id <= GADGET_ID_LEVELINFO_EDITOR) ||
6895 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
6897 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
6898 int gadget_distance =
6899 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
6900 struct GraphicInfo *gd = &graphic_info[graphic];
6901 int gd_x1 = gd->src_x;
6902 int gd_y1 = gd->src_y;
6903 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6904 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6905 int gd_x1a = gd->src_x + gd->active_xoffset;
6906 int gd_y1a = gd->src_y + gd->active_yoffset;
6907 int border_xsize = gd->border_size + gd->draw_xoffset;
6908 int border_ysize = gd->border_size;
6909 struct GadgetInfo *gi;
6910 unsigned int event_mask;
6911 char infotext[MAX_OUTPUT_LINESIZE + 1];
6912 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
6913 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
6915 if (textbutton_info[i].size == -1) // dynamically determine size
6916 textbutton_info[i].size = strlen(textbutton_info[i].text);
6918 event_mask = GD_EVENT_RELEASED;
6920 sprintf(infotext, "%s", textbutton_info[i].infotext);
6921 infotext[max_infotext_len] = '\0';
6923 // determine horizontal position to the right of specified gadget
6924 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6926 int gadget_id_align = textbutton_info[i].gadget_id_align;
6928 x = right_gadget_border[gadget_id_align] + gadget_distance;
6930 if (textbutton_info[i].y == -1)
6931 y = level_editor_gadget[gadget_id_align]->y;
6934 // determine horizontal offset for leading text
6935 if (textbutton_info[i].text_left != NULL)
6936 x += getTextWidthForGadget(textbutton_info[i].text_left);
6938 gi = CreateGadget(GDI_CUSTOM_ID, id,
6939 GDI_CUSTOM_TYPE_ID, i,
6940 GDI_IMAGE_ID, graphic,
6941 GDI_INFO_TEXT, infotext,
6944 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
6945 GDI_TEXT_VALUE, textbutton_info[i].text,
6946 GDI_TEXT_SIZE, textbutton_info[i].size,
6947 GDI_TEXT_FONT, FONT_INPUT_2,
6948 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
6949 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6950 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6951 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6952 GDI_BORDER_SIZE, border_xsize, border_ysize,
6953 GDI_DESIGN_WIDTH, gd->width,
6954 GDI_DECORATION_SHIFTING, 1, 1,
6955 GDI_EVENT_MASK, event_mask,
6956 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6957 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
6961 Fail("cannot create gadget");
6963 level_editor_gadget[id] = gi;
6964 right_gadget_border[id] =
6965 getRightGadgetBorder(gi, textbutton_info[i].text_right);
6969 static void CreateGraphicbuttonGadgets(void)
6971 struct GadgetInfo *gi;
6972 unsigned int event_mask;
6975 // create buttons for scrolling of drawing area and element list
6976 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
6978 int id = graphicbutton_info[i].gadget_id;
6979 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
6980 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
6981 int graphic = graphicbutton_info[i].graphic;
6982 struct GraphicInfo *gd = &graphic_info[graphic];
6983 int gd_x1 = gd->src_x;
6984 int gd_y1 = gd->src_y;
6985 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6986 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6988 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6990 // determine horizontal position to the right of specified gadget
6991 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6992 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
6993 ED_GADGET_TEXT_DISTANCE);
6995 // determine horizontal offset for leading text
6996 if (graphicbutton_info[i].text_left != NULL)
6997 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
6999 gi = CreateGadget(GDI_CUSTOM_ID, id,
7000 GDI_CUSTOM_TYPE_ID, i,
7001 GDI_IMAGE_ID, graphic,
7002 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7005 GDI_WIDTH, gd->width,
7006 GDI_HEIGHT, gd->height,
7007 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7008 GDI_STATE, GD_BUTTON_UNPRESSED,
7009 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7010 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7011 GDI_EVENT_MASK, event_mask,
7012 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7013 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7017 Fail("cannot create gadget");
7019 level_editor_gadget[id] = gi;
7020 right_gadget_border[id] =
7021 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7025 static void CreateScrollbarGadgets(void)
7029 // these values are not constant, but can change at runtime
7030 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7031 SX + ED_SCROLL_HORIZONTAL_XPOS;
7032 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7033 SY + ED_SCROLL_HORIZONTAL_YPOS;
7034 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7035 ED_SCROLL_HORIZONTAL_XSIZE;
7036 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7037 ED_SCROLL_HORIZONTAL_YSIZE;
7038 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7039 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7040 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7041 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7043 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7044 SX + ED_SCROLL_VERTICAL_XPOS;
7045 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7046 SY + ED_SCROLL_VERTICAL_YPOS;
7047 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7048 ED_SCROLL_VERTICAL_XSIZE;
7049 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7050 ED_SCROLL_VERTICAL_YSIZE;
7051 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7052 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7053 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7054 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7056 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7057 PX + ED_SCROLL2_VERTICAL_XPOS;
7058 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7059 PY + ED_SCROLL2_VERTICAL_YPOS;
7060 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7061 ED_SCROLL2_VERTICAL_XSIZE;
7062 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7063 ED_SCROLL2_VERTICAL_YSIZE;
7064 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7065 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7066 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7067 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7069 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7071 int id = scrollbar_info[i].gadget_id;
7072 int graphic = scrollbar_info[i].graphic;
7073 struct GraphicInfo *gd = &graphic_info[graphic];
7074 int gd_x1 = gd->src_x;
7075 int gd_y1 = gd->src_y;
7076 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7077 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7078 struct GadgetInfo *gi;
7079 int items_max, items_visible, item_position;
7080 unsigned int event_mask;
7082 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7084 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7085 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7086 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7088 else // drawing area scrollbars
7090 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7092 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7093 items_visible = ed_fieldx;
7098 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7099 items_visible = ed_fieldy;
7104 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7106 gi = CreateGadget(GDI_CUSTOM_ID, id,
7107 GDI_CUSTOM_TYPE_ID, i,
7108 GDI_IMAGE_ID, graphic,
7109 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7110 GDI_X, scrollbar_pos[i].x,
7111 GDI_Y, scrollbar_pos[i].y,
7112 GDI_WIDTH, scrollbar_pos[i].width,
7113 GDI_HEIGHT, scrollbar_pos[i].height,
7114 GDI_TYPE, scrollbar_info[i].type,
7115 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7116 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7117 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7118 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7119 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7120 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7121 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7122 GDI_STATE, GD_BUTTON_UNPRESSED,
7123 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7124 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7125 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7126 GDI_EVENT_MASK, event_mask,
7127 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7128 GDI_CALLBACK_ACTION, HandleControlButtons,
7132 Fail("cannot create gadget");
7134 level_editor_gadget[id] = gi;
7138 static void CreateCheckbuttonGadgets(void)
7140 struct GadgetInfo *gi;
7141 unsigned int event_mask;
7144 event_mask = GD_EVENT_PRESSED;
7146 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7148 int id = checkbutton_info[i].gadget_id;
7149 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7150 IMG_EDITOR_CHECKBOX);
7151 struct GraphicInfo *gd = &graphic_info[graphic];
7152 int gd_x1 = gd->src_x;
7153 int gd_y1 = gd->src_y;
7154 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7155 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7156 int gd_x1a = gd->src_x + gd->active_xoffset;
7157 int gd_y1a = gd->src_y + gd->active_yoffset;
7158 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7159 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7160 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7161 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7163 // determine horizontal position to the right of specified gadget
7164 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7165 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7166 ED_GADGET_TEXT_DISTANCE);
7168 // determine horizontal offset for leading text
7169 if (checkbutton_info[i].text_left != NULL)
7170 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7172 gi = CreateGadget(GDI_CUSTOM_ID, id,
7173 GDI_CUSTOM_TYPE_ID, i,
7174 GDI_IMAGE_ID, graphic,
7175 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7178 GDI_WIDTH, gd->width,
7179 GDI_HEIGHT, gd->height,
7180 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7181 GDI_CHECKED, *checkbutton_info[i].value,
7182 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7183 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7184 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7185 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7186 GDI_EVENT_MASK, event_mask,
7187 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7188 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7192 Fail("cannot create gadget");
7194 level_editor_gadget[id] = gi;
7195 right_gadget_border[id] =
7196 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7200 static void CreateRadiobuttonGadgets(void)
7202 int graphic = IMG_EDITOR_RADIOBUTTON;
7203 struct GraphicInfo *gd = &graphic_info[graphic];
7204 int gd_x1 = gd->src_x;
7205 int gd_y1 = gd->src_y;
7206 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7207 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7208 int gd_x1a = gd->src_x + gd->active_xoffset;
7209 int gd_y1a = gd->src_y + gd->active_yoffset;
7210 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7211 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7212 struct GadgetInfo *gi;
7213 unsigned int event_mask;
7216 event_mask = GD_EVENT_PRESSED;
7218 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7220 int id = radiobutton_info[i].gadget_id;
7221 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7222 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7225 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7227 // determine horizontal position to the right of specified gadget
7228 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7229 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7230 ED_GADGET_TEXT_DISTANCE);
7232 // determine horizontal offset for leading text
7233 if (radiobutton_info[i].text_left != NULL)
7234 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7236 gi = CreateGadget(GDI_CUSTOM_ID, id,
7237 GDI_CUSTOM_TYPE_ID, i,
7238 GDI_IMAGE_ID, graphic,
7239 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7242 GDI_WIDTH, gd->width,
7243 GDI_HEIGHT, gd->height,
7244 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7245 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7246 GDI_CHECKED, checked,
7247 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7248 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7249 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7250 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7251 GDI_EVENT_MASK, event_mask,
7252 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7253 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7257 Fail("cannot create gadget");
7259 level_editor_gadget[id] = gi;
7260 right_gadget_border[id] =
7261 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7265 void CreateLevelEditorGadgets(void)
7267 // force EDITOR font inside level editor
7268 SetFontStatus(GAME_MODE_EDITOR);
7270 // these values are not constant, but can change at runtime
7271 ed_fieldx = MAX_ED_FIELDX - 1;
7272 ed_fieldy = MAX_ED_FIELDY - 1;
7274 num_editor_gadgets = NUM_EDITOR_GADGETS;
7276 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7278 level_editor_gadget =
7279 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7280 right_gadget_border =
7281 checked_calloc(num_editor_gadgets * sizeof(int));
7283 // set number of empty (padding) element buttons to maximum number of buttons
7284 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7286 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7287 editor_el_empty_ptr = editor_el_empty;
7289 use_permanent_palette = !editor.palette.show_as_separate_screen;
7291 ReinitializeElementList();
7293 CreateControlButtons();
7294 CreateScrollbarGadgets();
7296 // order of function calls is important because of cross-references
7297 CreateCheckbuttonGadgets();
7298 CreateCounterButtons();
7299 CreateRadiobuttonGadgets();
7300 CreateTextInputGadgets();
7301 CreateTextAreaGadgets();
7302 CreateSelectboxGadgets();
7303 CreateGraphicbuttonGadgets();
7304 CreateTextbuttonGadgets();
7305 CreateDrawingAreas();
7310 void FreeLevelEditorGadgets(void)
7314 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
7316 for (i = 0; i < num_editor_gadgets; i++)
7318 FreeGadget(level_editor_gadget[i]);
7320 level_editor_gadget[i] = NULL;
7323 checked_free(level_editor_gadget);
7324 checked_free(right_gadget_border);
7326 checked_free(editor_el_empty);
7329 static void MapCounterButtons(int id)
7331 int font_nr = FONT_TEXT_1;
7332 int font_height = getFontHeight(font_nr);
7333 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7334 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7335 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7336 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7337 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7338 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7339 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7340 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7341 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7342 int yoffset = (gi_down->height - font_height) / 2;
7343 int x_left = gi_down->x - xoffset_left;
7344 int x_right; // set after gadget position was modified
7345 int y_above = gi_down->y - yoffset_above;
7347 int y; // set after gadget position was modified
7349 // counter limits must be changed first to prevent value truncation
7350 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7351 counterbutton_info[id].max_value);
7353 // right text position might have changed after setting position above
7354 x_right = gi_up->x + gi_up->width + xoffset_right;
7356 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7358 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
7359 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7360 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7362 ModifyGadget(gi_down, GDI_Y,
7363 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7364 ModifyGadget(gi_text, GDI_Y,
7365 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7366 ModifyGadget(gi_up, GDI_Y,
7367 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7370 // vertical position might have changed after setting position above
7371 y = gi_up->y + yoffset;
7373 if (counterbutton_info[id].text_above)
7374 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
7376 if (counterbutton_info[id].text_left)
7377 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7379 if (counterbutton_info[id].text_right)
7380 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7387 static void MapControlButtons(void)
7392 // map toolbox buttons (excluding special CE toolbox buttons)
7393 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7394 MapGadget(level_editor_gadget[i]);
7396 // map toolbox buttons (element properties buttons)
7397 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
7398 MapGadget(level_editor_gadget[i]);
7400 if (use_permanent_palette)
7402 // map buttons to select elements
7403 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7404 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
7405 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
7406 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
7407 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
7410 // map buttons to select level
7411 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
7412 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
7413 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
7414 MapCounterButtons(counter_id);
7417 static void MapDrawingArea(int id)
7419 int font_nr = FONT_TEXT_1;
7420 int font_height = getFontHeight(font_nr);
7421 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7422 int area_xsize = gi->drawing.area_xsize;
7423 int area_ysize = gi->drawing.area_ysize;
7424 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7425 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
7426 int x_left = gi->x - xoffset_left;
7427 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
7428 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
7429 int x_below = gi->x + (gi->width - xoffset_below) / 2;
7430 int y_side = gi->y + (gi->height - font_height) / 2;
7431 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
7432 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
7434 if (drawingarea_info[id].text_left)
7435 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
7437 if (drawingarea_info[id].text_right)
7438 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
7440 if (drawingarea_info[id].text_above)
7441 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
7443 if (drawingarea_info[id].text_below)
7444 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
7446 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
7448 DrawElementBorder(gi->x, gi->y,
7449 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
7450 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
7452 DrawDrawingArea(id);
7458 static void MapTextInputGadget(int id)
7460 int font_nr = FONT_TEXT_1;
7461 int font_height = getFontHeight(font_nr);
7462 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
7463 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7464 int x_above = ED_SETTINGS_X(textinput_info[id].x);
7465 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
7467 if (textinput_info[id].text_above)
7468 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
7470 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
7475 static void MapTextAreaGadget(int id)
7477 int font_nr = FONT_TEXT_1;
7478 int font_height = getFontHeight(font_nr);
7479 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7480 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7481 int x_above = ED_SETTINGS_X(textarea_info[id].x);
7482 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
7484 if (textarea_info[id].text_above)
7485 DrawTextS(x_above, y_above, font_nr, textarea_info[id].text_above);
7487 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
7492 static void MapSelectboxGadget(int id)
7494 int font_nr = FONT_TEXT_1;
7495 int font_height = getFontHeight(font_nr);
7496 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
7497 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
7498 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7499 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7500 int yoffset = (gi->height - font_height) / 2;
7501 int x_left = gi->x - xoffset_left;
7502 int x_right = gi->x + gi->width + xoffset_right;
7503 int y_above = gi->y - yoffset_above;
7505 int y = gi->y + yoffset;
7507 if (selectbox_info[id].text_above)
7508 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
7510 if (selectbox_info[id].text_left)
7511 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
7513 if (selectbox_info[id].text_right)
7514 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
7516 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
7521 static void MapTextbuttonGadget(int id)
7523 int font_nr = FONT_TEXT_1;
7524 int font_height = getFontHeight(font_nr);
7525 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
7526 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
7527 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7528 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7529 int yoffset = (gi->height - font_height) / 2;
7530 int x_left = gi->x - xoffset_left;
7531 int x_right = gi->x + gi->width + xoffset_right;
7532 int y_above = gi->y - yoffset_above;
7534 int y = gi->y + yoffset;
7536 // only show button to delete change pages when more than minimum pages
7537 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
7538 custom_element.num_change_pages == MIN_CHANGE_PAGES)
7541 if (textbutton_info[id].text_above)
7542 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
7544 if (textbutton_info[id].text_left)
7545 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
7547 if (textbutton_info[id].text_right)
7548 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
7553 static void MapGraphicbuttonGadget(int id)
7555 int font_nr = FONT_TEXT_1;
7556 int font_height = getFontHeight(font_nr);
7557 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
7558 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
7559 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7560 int yoffset = (gi->height - font_height) / 2;
7561 int x_left = gi->x - xoffset_left;
7562 int x_right = gi->x + gi->width + xoffset_right;
7563 int y = gi->y + yoffset;
7565 if (graphicbutton_info[id].text_left)
7566 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
7568 if (graphicbutton_info[id].text_right)
7569 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
7574 static void MapRadiobuttonGadget(int id)
7576 int font_nr = FONT_TEXT_1;
7577 int font_height = getFontHeight(font_nr);
7578 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
7579 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7580 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7581 int yoffset = (gi->height - font_height) / 2;
7582 int x_left = gi->x - xoffset_left;
7583 int x_right = gi->x + gi->width + xoffset_right;
7584 int y = gi->y + yoffset;
7586 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
7588 if (radiobutton_info[id].text_left)
7589 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
7591 if (radiobutton_info[id].text_right)
7592 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
7594 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
7599 static void MapCheckbuttonGadget(int id)
7601 int font_nr = FONT_TEXT_1;
7602 int font_height = getFontHeight(font_nr);
7603 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
7604 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7605 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7606 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7607 int yoffset = (gi->height - font_height) / 2;
7608 int y_above = gi->y - yoffset_above;
7610 int x_left, x_right, y; // set after gadget position was modified
7612 // set position for gadgets with dynamically determined position
7613 if (checkbutton_info[id].x != -1) // do not change dynamic positions
7614 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x),GDI_END);
7615 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
7617 x_left = gi->x - xoffset_left;
7618 x_right = gi->x + gi->width + xoffset_right;
7619 y = gi->y + yoffset;
7621 if (checkbutton_info[id].text_above)
7622 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
7624 if (checkbutton_info[id].text_left)
7625 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
7627 if (checkbutton_info[id].text_right)
7628 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
7630 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
7635 static void MapMainDrawingArea(void)
7637 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
7638 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
7641 if (suppressBorderElement())
7643 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
7644 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
7647 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
7649 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
7650 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
7651 no_horizontal_scrollbar) ||
7652 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
7653 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
7654 no_vertical_scrollbar))
7657 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
7660 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
7662 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
7663 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
7666 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
7669 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
7672 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
7676 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
7678 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
7679 i == GADGET_ID_CUSTOM_COPY_TO ||
7680 i == GADGET_ID_CUSTOM_EXCHANGE ||
7681 i == GADGET_ID_CUSTOM_COPY ||
7682 i == GADGET_ID_CUSTOM_PASTE)
7685 MapGadget(level_editor_gadget[i]);
7687 UnmapGadget(level_editor_gadget[i]);
7692 static void MapLevelEditorToolboxCustomGadgets(void)
7694 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
7697 static void UnmapLevelEditorToolboxCustomGadgets(void)
7699 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
7702 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
7706 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
7708 if (i != GADGET_ID_SINGLE_ITEMS &&
7709 i != GADGET_ID_PICK_ELEMENT)
7711 struct GadgetInfo *gi = level_editor_gadget[i];
7719 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
7720 struct GraphicInfo *gd = &graphic_info[graphic];
7724 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
7725 gi->width, gi->height, gi->x, gi->y);
7727 redraw_mask |= REDRAW_DOOR_3;
7733 static void MapLevelEditorToolboxDrawingGadgets(void)
7735 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
7738 static void UnmapLevelEditorToolboxDrawingGadgets(void)
7740 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
7743 static void UnmapDrawingArea(int id)
7745 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
7748 static void UnmapLevelEditorFieldGadgets(void)
7752 for (i = 0; i < num_editor_gadgets; i++)
7753 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
7754 level_editor_gadget[i]->y))
7755 UnmapGadget(level_editor_gadget[i]);
7758 void UnmapLevelEditorGadgets(void)
7762 for (i = 0; i < num_editor_gadgets; i++)
7763 UnmapGadget(level_editor_gadget[i]);
7766 static void ResetUndoBuffer(void)
7768 undo_buffer_position = -1;
7769 undo_buffer_steps = -1;
7770 redo_buffer_steps = 0;
7772 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7774 level.changed = FALSE;
7777 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
7779 if (remap_toolbox_gadgets)
7781 ModifyEditorElementList();
7782 RedrawDrawingElements();
7785 if (edit_mode == ED_MODE_INFO)
7786 DrawLevelInfoWindow();
7787 else if (edit_mode == ED_MODE_PROPERTIES)
7788 DrawPropertiesWindow();
7789 else if (edit_mode == ED_MODE_PALETTE)
7790 DrawPaletteWindow();
7791 else // edit_mode == ED_MODE_DRAWING
7792 DrawDrawingWindowExt(remap_toolbox_gadgets);
7795 static void DrawEditModeWindow(void)
7797 DrawEditModeWindowExt(TRUE);
7800 static void DrawEditModeWindow_PlayfieldOnly(void)
7802 DrawEditModeWindowExt(FALSE);
7805 static void ChangeEditModeWindow(int new_edit_mode)
7807 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
7809 DrawEditModeWindow();
7812 static boolean LevelChanged(void)
7814 boolean field_changed = FALSE;
7817 for (y = 0; y < lev_fieldy; y++)
7818 for (x = 0; x < lev_fieldx; x++)
7819 if (Tile[x][y] != level.field[x][y])
7820 field_changed = TRUE;
7822 return (level.changed || field_changed);
7825 static boolean PrepareSavingIntoPersonalLevelSet(void)
7827 static LevelDirTree *last_copied_leveldir = NULL;
7828 static LevelDirTree *last_written_leveldir = NULL;
7829 static int last_copied_level_nr = -1;
7830 static int last_written_level_nr = -1;
7831 LevelDirTree *leveldir_former = leveldir_current;
7832 int level_nr_former = level_nr;
7835 // remember last mod/save so that for current session, we write
7836 // back to the same personal copy, asking only about overwrite.
7837 if (leveldir_current == last_copied_leveldir &&
7838 level_nr == last_copied_level_nr)
7840 // "cd" to personal level set dir (as used when writing last copy)
7841 leveldir_current = last_written_leveldir;
7842 level_nr = last_written_level_nr;
7847 if (!Request("This level is read-only! "
7848 "Save into personal level set?", REQ_ASK))
7851 // "cd" to personal level set dir (for writing copy the first time)
7853 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
7855 // this may happen if "setup.internal.create_user_levelset" is FALSE
7856 // or if file "levelinfo.conf" is missing in personal user level set
7857 if (leveldir_current == NULL)
7859 Request("Cannot find personal level set?!", REQ_CONFIRM);
7861 leveldir_current = leveldir_former;
7866 // find unused level number
7867 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
7869 static char *level_filename = NULL;
7871 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
7873 if (!fileExists(level_filename))
7877 last_copied_leveldir = leveldir_former;
7878 last_copied_level_nr = level_nr_former;
7880 last_written_leveldir = leveldir_current;
7881 last_written_level_nr = level_nr = new_level_nr;
7886 static void ModifyLevelInfoForSavingIntoPersonalLevelSet(char *former_name)
7888 static char *filename_levelinfo = NULL, *mod_name = NULL;
7891 // annotate this copy-and-mod in personal levelinfo.conf
7892 setString(&filename_levelinfo,
7893 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
7895 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
7897 fprintf(file, "\n");
7898 fprintf(file, "# level %d was modified from:\n", level_nr);
7899 fprintf(file, "# - previous level set name: %s\n",
7901 fprintf(file, "# - level within previous set: %d \"%s\"\n",
7902 level.file_info.nr, level.name);
7903 fprintf(file, "# - previous author: %s\n",
7905 fprintf(file, "# - previous save date: ");
7907 if (level.creation_date.src == DATE_SRC_LEVELFILE)
7909 fprintf(file, "%04d-%02d-%02d\n",
7910 level.creation_date.year,
7911 level.creation_date.month,
7912 level.creation_date.day);
7916 fprintf(file, "not recorded\n");
7922 if (level_nr > leveldir_current->last_level)
7923 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
7925 // else: allow the save even if annotation failed
7927 // now... spray graffiti on the old level vital statistics
7928 // user can change these; just trying to set a good baseline
7930 // don't truncate names for fear of making offensive or silly:
7931 // long-named original author only recorded in levelinfo.conf.
7932 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
7933 if (!strEqual(level.author, leveldir_current->author))
7935 setString(&mod_name, getStringCat3(leveldir_current->author,
7936 " after ", level.author));
7938 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7939 setString(&mod_name,
7940 getStringCat2(leveldir_current->author, " (ed.)"));
7942 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7943 setString(&mod_name, leveldir_current->author);
7945 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
7947 // less worried about truncation here
7948 setString(&mod_name, getStringCat2("Mod: ", level.name));
7949 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
7953 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
7954 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
7958 for (x = 0; x < lev_fieldx; x++)
7959 for (y = 0; y < lev_fieldy; y++)
7960 dst[x][y] = src[x][y];
7963 static int setSelectboxValue(int selectbox_id, int new_value)
7965 int new_index_value = 0;
7968 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
7969 if (selectbox_info[selectbox_id].options[i].value == new_value)
7970 new_index_value = i;
7972 *selectbox_info[selectbox_id].value =
7973 selectbox_info[selectbox_id].options[new_index_value].value;
7975 return new_index_value;
7978 static void setSelectboxSpecialActionVariablesIfNeeded(void)
7982 // change action mode and arg variables according to action type variable
7983 for (i = 0; action_arg_options[i].value != -1; i++)
7985 if (action_arg_options[i].value == custom_element_change.action_type)
7987 int mode = action_arg_options[i].mode;
7989 // only change if corresponding selectbox has changed
7990 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
7991 action_arg_modes[mode])
7992 custom_element_change.action_mode = -1;
7994 // only change if corresponding selectbox has changed
7995 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
7996 action_arg_options[i].options)
7997 custom_element_change.action_arg = -1;
8004 static void setSelectboxSpecialActionOptions(void)
8008 // change action mode and arg selectbox according to action type selectbox
8009 for (i = 0; action_arg_options[i].value != -1; i++)
8011 if (action_arg_options[i].value == custom_element_change.action_type)
8013 int mode = action_arg_options[i].mode;
8015 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8016 action_arg_modes[mode]);
8017 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8018 custom_element_change.action_mode);
8020 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8021 action_arg_options[i].options);
8022 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8023 custom_element_change.action_arg);
8029 static void copy_custom_element_settings(int element_from, int element_to)
8031 struct ElementInfo *ei_from = &element_info[element_from];
8032 struct ElementInfo *ei_to = &element_info[element_to];
8034 copyElementInfo(ei_from, ei_to);
8037 static void replace_custom_element_in_settings(int element_from,
8042 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8044 struct ElementInfo *ei = &element_info[i];
8046 for (y = 0; y < 3; y++)
8047 for (x = 0; x < 3; x++)
8048 if (ei->content.e[x][y] == element_from)
8049 ei->content.e[x][y] = element_to;
8051 for (j = 0; j < ei->num_change_pages; j++)
8053 struct ElementChangeInfo *change = &ei->change_page[j];
8055 if (change->target_element == element_from)
8056 change->target_element = element_to;
8058 if (change->initial_trigger_element == element_from)
8059 change->initial_trigger_element = element_to;
8061 if (change->action_element == element_from)
8062 change->action_element = element_to;
8064 for (y = 0; y < 3; y++)
8065 for (x = 0; x < 3; x++)
8066 if (change->target_content.e[x][y] == element_from)
8067 change->target_content.e[x][y] = element_to;
8070 if (ei->group != NULL) // group or internal
8071 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8072 if (ei->group->element[j] == element_from)
8073 ei->group->element[j] = element_to;
8077 static void replace_custom_element_in_playfield(int element_from,
8082 for (x = 0; x < lev_fieldx; x++)
8083 for (y = 0; y < lev_fieldy; y++)
8084 if (Tile[x][y] == element_from)
8085 Tile[x][y] = element_to;
8088 static boolean CopyCustomElement(int element_old, int element_new,
8091 int copy_mode_orig = copy_mode;
8093 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8095 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8096 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8097 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8099 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8101 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8102 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8103 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8105 level.changed = TRUE;
8107 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8109 Request("Please choose custom element!", REQ_CONFIRM);
8113 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8115 Request("Please choose group element!", REQ_CONFIRM);
8121 level.changed = TRUE;
8124 // when modifying custom/group element, ask for copying level template
8125 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8127 if (!AskToCopyAndModifyLevelTemplate())
8131 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8133 copy_custom_element_settings(element_new, element_old);
8135 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8137 copy_custom_element_settings(element_old, element_new);
8139 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8141 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8142 copy_custom_element_settings(element_new, element_old);
8143 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8145 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8146 replace_custom_element_in_settings(element_new, element_old);
8147 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8149 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8150 replace_custom_element_in_playfield(element_new, element_old);
8151 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8154 UpdateCustomElementGraphicGadgets();
8155 DrawPropertiesWindow();
8160 static void CopyCustomElementPropertiesToEditor(int element)
8163 int current_change_page = element_info[element].current_change_page;
8165 // dynamically (re)build selectbox for selecting change page
8166 for (i = 0; i < element_info[element].num_change_pages; i++)
8168 sprintf(options_change_page_strings[i], "%d", i + 1);
8170 options_change_page[i].value = i;
8171 options_change_page[i].text = options_change_page_strings[i];
8174 options_change_page[i].value = -1;
8175 options_change_page[i].text = NULL;
8177 // needed here to initialize combined element properties
8178 InitElementPropertiesEngine(level.game_version);
8180 element_info[element].change =
8181 &element_info[element].change_page[current_change_page];
8183 custom_element = element_info[element];
8184 custom_element_change = *element_info[element].change;
8186 // needed to initially set selectbox options for special action options
8187 setSelectboxSpecialActionOptions();
8189 // needed to initially set selectbox value variables to reliable defaults
8190 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8191 setSelectboxValue(i, *selectbox_info[i].value);
8193 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8194 custom_element_properties[i] = HAS_PROPERTY(element, i);
8196 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8197 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8199 // ---------- element settings: configure (custom elements) -----------------
8201 // set accessible layer selectbox help value
8202 custom_element.access_type =
8203 (IS_WALKABLE(element) ? EP_WALKABLE :
8204 IS_PASSABLE(element) ? EP_PASSABLE :
8205 custom_element.access_type);
8206 custom_element.access_layer =
8207 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8208 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8209 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8210 custom_element.access_layer);
8211 custom_element.access_protected =
8212 (IS_PROTECTED(element) ? 1 : 0);
8213 custom_element_properties[EP_ACCESSIBLE] =
8214 (IS_ACCESSIBLE_OVER(element) ||
8215 IS_ACCESSIBLE_INSIDE(element) ||
8216 IS_ACCESSIBLE_UNDER(element));
8218 // set walk-to-object action selectbox help value
8219 custom_element.walk_to_action =
8220 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8221 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8222 IS_DROPPABLE(element) ? EP_DROPPABLE :
8223 IS_THROWABLE(element) ? EP_THROWABLE :
8224 IS_PUSHABLE(element) ? EP_PUSHABLE :
8225 custom_element.walk_to_action);
8226 custom_element_properties[EP_WALK_TO_OBJECT] =
8227 (IS_DIGGABLE(element) ||
8228 IS_COLLECTIBLE_ONLY(element) ||
8229 IS_DROPPABLE(element) ||
8230 IS_THROWABLE(element) ||
8231 IS_PUSHABLE(element));
8233 // set smash targets selectbox help value
8234 custom_element.smash_targets =
8235 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8236 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8237 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8238 custom_element.smash_targets);
8239 custom_element_properties[EP_CAN_SMASH] =
8240 (CAN_SMASH_EVERYTHING(element) ||
8241 CAN_SMASH_ENEMIES(element) ||
8242 CAN_SMASH_PLAYER(element));
8244 // set deadliness selectbox help value
8245 custom_element.deadliness =
8246 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8247 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8248 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8249 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8250 custom_element.deadliness);
8251 custom_element_properties[EP_DEADLY] =
8252 (DONT_TOUCH(element) ||
8253 DONT_GET_HIT_BY(element) ||
8254 DONT_COLLIDE_WITH(element) ||
8255 DONT_RUN_INTO(element));
8257 // ---------- element settings: advanced (custom elements) ------------------
8259 // set "change by direct action" selectbox help value
8260 custom_element_change.direct_action =
8261 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
8262 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8263 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8264 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8265 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8266 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8267 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8268 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8269 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8270 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8271 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8272 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8273 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8274 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8275 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8276 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8277 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8278 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8279 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8280 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
8281 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
8282 custom_element_change.direct_action);
8284 // set "change by other element action" selectbox help value
8285 custom_element_change.other_action =
8286 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
8287 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8288 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8289 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8290 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8291 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8292 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8293 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8294 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8295 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8296 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8297 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
8298 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8299 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8300 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8301 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8302 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8303 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8304 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8305 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8306 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8307 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8308 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8309 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8310 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8311 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
8312 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
8313 custom_element_change.other_action);
8316 static void CopyGroupElementPropertiesToEditor(int element)
8318 group_element_info = *element_info[element].group;
8319 custom_element = element_info[element]; // needed for description
8322 static void CopyEmptyElementPropertiesToEditor(int element)
8324 custom_element = element_info[element];
8327 static void CopyClassicElementPropertiesToEditor(int element)
8329 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8330 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
8331 getMoveIntoAcidProperty(&level, element);
8333 if (MAYBE_DONT_COLLIDE_WITH(element))
8334 custom_element_properties[EP_DONT_COLLIDE_WITH] =
8335 getDontCollideWithProperty(&level, element);
8338 static void CopyElementPropertiesToEditor(int element)
8340 if (IS_CUSTOM_ELEMENT(element))
8341 CopyCustomElementPropertiesToEditor(element);
8342 else if (IS_GROUP_ELEMENT(element))
8343 CopyGroupElementPropertiesToEditor(element);
8344 else if (IS_EMPTY_ELEMENT(element))
8345 CopyEmptyElementPropertiesToEditor(element);
8347 CopyClassicElementPropertiesToEditor(element);
8350 static boolean AskToCopyAndModifyLevelTemplate(void)
8352 if (Request("Copy and modify settings from level template?", REQ_ASK))
8354 level.use_custom_template = FALSE;
8356 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
8357 GDI_CHECKED, FALSE, GDI_END);
8358 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
8359 GDI_CHECKED, FALSE, GDI_END);
8365 LoadLevelTemplate(-1); // this resets all element modifications ...
8367 DrawEditModeWindow(); // ... and copies them to 'custom_element'
8373 static void CopyCustomElementPropertiesToGame(int element)
8376 int access_type_and_layer;
8378 // mark that this custom element has been modified
8379 custom_element.modified_settings = TRUE;
8380 level.changed = TRUE;
8382 if (level.use_custom_template)
8383 AskToCopyAndModifyLevelTemplate();
8385 element_info[element] = custom_element;
8386 *element_info[element].change = custom_element_change;
8388 // ---------- element settings: configure (custom elements) -----------------
8390 // set accessible property from checkbox and selectbox
8391 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
8392 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
8393 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
8394 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
8395 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
8396 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
8397 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
8398 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
8399 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
8400 custom_element_properties[access_type_and_layer] =
8401 custom_element_properties[EP_ACCESSIBLE];
8402 custom_element_properties[EP_PROTECTED] =
8403 (custom_element.access_protected != 0 &&
8404 custom_element_properties[EP_ACCESSIBLE]);
8406 // set walk-to-object property from checkbox and selectbox
8407 custom_element_properties[EP_DIGGABLE] = FALSE;
8408 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
8409 custom_element_properties[EP_DROPPABLE] = FALSE;
8410 custom_element_properties[EP_THROWABLE] = FALSE;
8411 custom_element_properties[EP_PUSHABLE] = FALSE;
8412 custom_element_properties[custom_element.walk_to_action] =
8413 custom_element_properties[EP_WALK_TO_OBJECT];
8415 // set smash property from checkbox and selectbox
8416 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
8417 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
8418 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
8419 custom_element_properties[custom_element.smash_targets] =
8420 custom_element_properties[EP_CAN_SMASH];
8422 // set deadliness property from checkbox and selectbox
8423 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
8424 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
8425 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
8426 custom_element_properties[EP_DONT_TOUCH] = FALSE;
8427 custom_element_properties[custom_element.deadliness] =
8428 custom_element_properties[EP_DEADLY];
8430 // ---------- element settings: advanced (custom elements) ------------------
8432 // set player change event from checkbox and selectbox
8433 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
8434 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
8435 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
8436 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
8437 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
8438 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
8439 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
8440 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
8441 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
8442 custom_element_change_events[CE_SWITCHED] = FALSE;
8443 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
8444 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
8445 custom_element_change_events[CE_BLOCKED] = FALSE;
8446 custom_element_change_events[CE_IMPACT] = FALSE;
8447 custom_element_change_events[CE_SMASHED] = FALSE;
8448 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
8449 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
8450 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
8451 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
8452 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
8453 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
8454 custom_element_change_events[custom_element_change.direct_action] =
8455 custom_element_change_events[CE_BY_DIRECT_ACTION];
8457 // set other element action change event from checkbox and selectbox
8458 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
8459 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
8460 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
8461 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
8462 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
8463 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
8464 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
8465 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
8466 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
8467 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
8468 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
8469 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
8470 custom_element_change_events[CE_TOUCHING_X] = FALSE;
8471 custom_element_change_events[CE_HITTING_X] = FALSE;
8472 custom_element_change_events[CE_DIGGING_X] = FALSE;
8473 custom_element_change_events[CE_HIT_BY_X] = FALSE;
8474 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
8475 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
8476 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
8477 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
8478 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
8479 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
8480 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
8481 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
8482 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
8483 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
8484 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
8485 custom_element_change_events[custom_element_change.other_action] =
8486 custom_element_change_events[CE_BY_OTHER_ACTION];
8488 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8489 SET_PROPERTY(element, i, custom_element_properties[i]);
8491 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8492 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
8494 // copy change events also to special level editor variable
8495 custom_element = element_info[element];
8496 custom_element_change = *element_info[element].change;
8498 // needed here to restore runtime value "element_info[element].gfx_element"
8499 InitElementPropertiesGfxElement();
8502 static void CopyGroupElementPropertiesToGame(int element)
8504 // mark that this group element has been modified
8505 custom_element.modified_settings = TRUE;
8506 level.changed = TRUE;
8508 if (level.use_custom_template)
8509 AskToCopyAndModifyLevelTemplate();
8511 element_info[element] = custom_element;
8512 *element_info[element].group = group_element_info;
8514 // needed here to restore runtime value "element_info[element].gfx_element"
8515 InitElementPropertiesGfxElement();
8518 static void CopyEmptyElementPropertiesToGame(int element)
8520 // mark that this empty element has been modified
8521 custom_element.modified_settings = TRUE;
8522 level.changed = TRUE;
8524 if (level.use_custom_template)
8525 AskToCopyAndModifyLevelTemplate();
8527 element_info[element] = custom_element;
8529 // needed here to restore runtime value "element_info[element].gfx_element"
8530 InitElementPropertiesGfxElement();
8533 static void CopyClassicElementPropertiesToGame(int element)
8535 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8536 setMoveIntoAcidProperty(&level, element,
8537 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
8539 if (MAYBE_DONT_COLLIDE_WITH(element))
8540 setDontCollideWithProperty(&level, element,
8541 custom_element_properties[EP_DONT_COLLIDE_WITH]);
8544 static void CopyElementPropertiesToGame(int element)
8546 if (IS_CUSTOM_ELEMENT(element))
8547 CopyCustomElementPropertiesToGame(element);
8548 else if (IS_GROUP_ELEMENT(element))
8549 CopyGroupElementPropertiesToGame(element);
8550 else if (IS_EMPTY_ELEMENT(element))
8551 CopyEmptyElementPropertiesToGame(element);
8553 CopyClassicElementPropertiesToGame(element);
8557 static void CheckElementDescriptions(void)
8561 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8562 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
8563 Warn("no element description file for element '%s'", EL_NAME(i));
8567 static int getMaxEdFieldX(boolean has_scrollbar)
8569 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
8570 int sxsize = SXSIZE - scrollbar_width;
8571 int max_ed_fieldx = sxsize / ed_tilesize;
8573 return max_ed_fieldx;
8576 static int getMaxEdFieldY(boolean has_scrollbar)
8578 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
8579 INFOTEXT_YSIZE_FULL : 0);
8580 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
8581 int sysize = SYSIZE - scrollbar_height - infotext_height;
8582 int max_ed_fieldy = sysize / ed_tilesize;
8584 return max_ed_fieldy;
8587 static void InitZoomLevelSettings(int zoom_tilesize)
8589 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
8591 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
8593 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
8594 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
8596 // make sure that tile size is always a power of 2
8597 ed_tilesize = (1 << log_2(ed_tilesize));
8599 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8601 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
8602 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
8606 last_game_engine_type = level.game_engine_type;
8608 // limit zoom tilesize by upper and lower bound
8609 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
8611 // store zoom tilesize in auto setup file only if it was manually changed
8612 if (zoom_tilesize != -1)
8613 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
8615 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
8616 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
8619 static void InitDrawingElements(void)
8621 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
8623 if (level.game_engine_type == game_engine_type_last)
8626 if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
8628 new_element1 = EL_SP_CHIP_SINGLE;
8629 new_element2 = EL_EMPTY;
8630 new_element3 = EL_SP_BASE;
8632 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8634 new_element1 = EL_MM_MIRROR_START;
8635 new_element2 = EL_EMPTY;
8636 new_element3 = EL_MM_WOODEN_WALL;
8640 new_element1 = EL_WALL;
8641 new_element2 = EL_EMPTY;
8642 new_element3 = EL_SAND;
8645 game_engine_type_last = level.game_engine_type;
8648 static void InitLevelSetInfo(void)
8650 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
8651 "%s", leveldir_current->name);
8652 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
8653 "%s", leveldir_current->author);
8655 levelset_num_levels = leveldir_current->levels;
8657 levelset_use_levelset_artwork = FALSE;
8658 levelset_copy_level_template = FALSE;
8660 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
8663 static void ChangeEditorToLevelSet(char *levelset_subdir)
8665 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
8667 // the previous level set might have used custom artwork
8668 ReloadCustomArtwork(0);
8670 LoadLevelSetup_SeriesInfo();
8672 SaveLevelSetup_LastSeries();
8673 SaveLevelSetup_SeriesInfo();
8677 LoadLevel(level_nr);
8678 LoadScore(level_nr);
8683 static boolean useEditorDoorAnimation(void)
8685 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
8686 boolean door_1_viewport_unchanged =
8687 (vp_door_1->x == DX &&
8688 vp_door_1->y == DY &&
8689 vp_door_1->width == DXSIZE &&
8690 vp_door_1->height == DYSIZE);
8691 boolean door_1_contains_toolbox =
8694 EX + EXSIZE <= DX + DXSIZE &&
8695 EY + EYSIZE <= DY + DYSIZE);
8697 return (door_1_viewport_unchanged && door_1_contains_toolbox);
8700 static void DrawEditorDoorBackground(int graphic, int x, int y,
8701 int width, int height)
8703 struct GraphicInfo *g = &graphic_info[graphic];
8705 if (g->bitmap != NULL)
8706 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
8707 MIN(width, g->width), MIN(height, g->height), x, y);
8709 ClearRectangle(drawto, x, y, width, height);
8712 static void DrawEditorDoorContent(void)
8714 // needed for gadgets drawn on background (like palette scrollbar)
8715 SetDoorBackgroundImage(IMG_UNDEFINED);
8717 // copy default editor door content to main double buffer
8718 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
8721 DrawSpecialEditorDoor();
8723 // draw new control window
8724 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
8726 // draw all toolbox gadgets to editor doors
8727 MapControlButtons();
8729 // draw all palette gadgets to editor doors
8730 ModifyEditorElementList();
8731 RedrawDrawingElements();
8733 // copy actual editor door content to door double buffer for OpenDoor()
8734 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
8737 void DrawLevelEd(void)
8739 int fade_mask = REDRAW_FIELD;
8741 FadeSoundsAndMusic();
8744 fade_mask = REDRAW_ALL;
8748 // needed if different viewport properties defined for editor
8749 ChangeViewportPropertiesIfNeeded();
8753 InitZoomLevelSettings(-1);
8754 InitDrawingElements();
8758 CheckElementDescriptions();
8761 if (level_editor_test_game)
8763 CopyPlayfield(level.field, Tile);
8764 CopyPlayfield(TileBackup, level.field);
8766 level_editor_test_game = FALSE;
8770 edit_mode = ED_MODE_DRAWING;
8771 edit_mode_levelinfo = ED_MODE_LEVELINFO_LEVEL;
8772 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
8780 // redraw_mask |= REDRAW_ALL;
8782 FreeLevelEditorGadgets();
8783 CreateLevelEditorGadgets();
8785 ReinitializeElementList(); // update dynamic level element list
8786 ReinitializeElementListButtons(); // custom element may look different
8788 InitElementPropertiesGfxElement();
8792 DrawEditModeWindow_PlayfieldOnly();
8794 DrawMaskedBorder(fade_mask);
8796 // use door animation if door 1 viewport is unchanged and contains toolbox
8797 if (useEditorDoorAnimation())
8801 DrawEditorDoorContent();
8803 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
8807 DrawEditorDoorContent();
8812 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
8815 static void AdjustDrawingAreaGadgets(void)
8817 int ed_xsize = lev_fieldx + 2;
8818 int ed_ysize = lev_fieldy + 2;
8819 int max_ed_fieldx = MAX_ED_FIELDX;
8820 int max_ed_fieldy = MAX_ED_FIELDY;
8821 boolean horizontal_scrollbar_needed;
8822 boolean vertical_scrollbar_needed;
8823 int x, y, width, height;
8825 if (suppressBorderElement())
8827 ed_xsize = max_ed_fieldx;
8828 ed_ysize = max_ed_fieldy;
8831 // check if we need any scrollbars
8832 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8833 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8835 // check if we have a smaller editor field because of scrollbars
8836 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8837 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8839 // check again if we now need more scrollbars because of less space
8840 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8841 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8843 // check if editor field gets even smaller after adding new scrollbars
8844 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8845 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8847 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
8848 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
8850 x = SX + ed_fieldx * ed_tilesize;
8851 y = SY + ed_fieldy * ed_tilesize;
8853 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
8854 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
8856 // adjust drawing area gadget
8857 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
8858 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
8859 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
8862 // adjust horizontal scrollbar gadgets
8863 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
8866 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
8867 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
8870 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8873 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
8876 // adjust vertical scrollbar gadgets
8877 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
8880 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
8882 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
8884 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8887 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
8891 static void AdjustLevelScrollPosition(void)
8893 if (level_xpos < -1)
8895 if (level_xpos > lev_fieldx - ed_fieldx + 1)
8896 level_xpos = lev_fieldx - ed_fieldx + 1;
8897 if (lev_fieldx < ed_fieldx - 2)
8900 if (level_ypos < -1)
8902 if (level_ypos > lev_fieldy - ed_fieldy + 1)
8903 level_ypos = lev_fieldy - ed_fieldy + 1;
8904 if (lev_fieldy < ed_fieldy - 2)
8907 if (suppressBorderElement())
8914 static void AdjustEditorScrollbar(int id)
8916 struct GadgetInfo *gi = level_editor_gadget[id];
8917 int items_max, items_visible, item_position;
8919 if (id == GADGET_ID_SCROLL_HORIZONTAL)
8921 items_max = MAX(lev_fieldx + 2, ed_fieldx);
8922 items_visible = ed_fieldx;
8923 item_position = level_xpos + 1;
8927 items_max = MAX(lev_fieldy + 2, ed_fieldy);
8928 items_visible = ed_fieldy;
8929 item_position = level_ypos + 1;
8932 if (item_position > items_max - items_visible)
8933 item_position = items_max - items_visible;
8935 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8936 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8939 static void AdjustElementListScrollbar(void)
8941 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
8942 int items_max, items_visible, item_position;
8944 // correct position of element list scrollbar
8945 if (element_shift < 0)
8947 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
8948 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
8950 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
8951 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
8952 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
8954 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8955 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
8956 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8959 static void ModifyEditorCounterValue(int counter_id, int new_value)
8961 int *counter_value = counterbutton_info[counter_id].value;
8962 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8963 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8965 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
8967 if (counter_value != NULL)
8968 *counter_value = gi->textinput.number_value;
8971 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
8973 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8974 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8976 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
8978 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
8979 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
8981 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
8982 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8984 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
8985 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
8990 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
8992 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8993 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8994 int new_index_value = setSelectboxValue(selectbox_id, new_value);
8996 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
8999 static void ModifyEditorSelectboxOptions(int selectbox_id,
9000 struct ValueTextInfo *options)
9002 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9003 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9005 selectbox_info[selectbox_id].options = options;
9007 // set index to zero -- list may be shorter now (correct later, if needed)
9008 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9009 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9012 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9014 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9015 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9017 drawingarea_info[drawingarea_id].area_xsize = xsize;
9018 drawingarea_info[drawingarea_id].area_ysize = ysize;
9020 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9023 static void ModifyEditorElementList(void)
9027 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9030 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9032 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9033 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9034 struct GadgetDesign *gd = &gi->deco.design;
9035 int element = editor_elements[element_shift + i];
9036 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9040 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9042 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9048 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9050 int graphic = el2edimg(element);
9051 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9057 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9060 static void ModifyDrawingElementButton(int element, int id)
9062 struct GadgetInfo *gi = level_editor_gadget[id];
9063 Bitmap *deco_bitmap;
9065 int tile_size = gi->deco.width;
9067 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9069 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9072 static void PickDrawingElement(int button, int element)
9077 struct XYTileSize *pos;
9079 } de, drawing_elements[] =
9081 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9082 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9083 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9086 if (button < 1 || button > 3)
9089 if (IS_MM_WALL(element))
9090 element = map_mm_wall_element(element);
9092 de = drawing_elements[button - 1];
9094 *de.new_element = element; // update global drawing element variable
9096 DrawDrawingElementGraphic(element, de.pos);
9097 ModifyDrawingElementButton(element, de.id);
9099 redraw_mask |= REDRAW_DOOR_1;
9102 static void RedrawDrawingElements(void)
9104 PickDrawingElement(1, new_element1);
9105 PickDrawingElement(2, new_element2);
9106 PickDrawingElement(3, new_element3);
9109 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9111 stick_element_properties_window = FALSE;
9113 SetMainBackgroundImage(IMG_UNDEFINED);
9116 UnmapLevelEditorFieldGadgets();
9118 AdjustDrawingAreaGadgets();
9119 AdjustLevelScrollPosition();
9120 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9121 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9123 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9125 MapMainDrawingArea();
9127 if (remap_toolbox_gadgets)
9129 UnmapLevelEditorToolboxCustomGadgets();
9130 MapLevelEditorToolboxDrawingGadgets();
9134 static void DrawDrawingWindow(void)
9136 DrawDrawingWindowExt(TRUE);
9139 static int getTabulatorBarWidth(void)
9141 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9142 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9144 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9147 static int getTabulatorBarHeight(void)
9149 return ED_TAB_BAR_HEIGHT;
9152 static Pixel getTabulatorBarColor(void)
9154 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
9155 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9156 int gd_x = gd->x + gd_gi1->border.width / 2;
9157 int gd_y = gd->y + gd_gi1->height - 1;
9159 return GetPixel(gd->bitmap, gd_x, gd_y);
9162 static void DrawLevelInfoTabulatorGadgets(void)
9164 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
9165 Pixel tab_color = getTabulatorBarColor();
9166 int id_first = ED_TAB_BUTTON_ID_LEVELINFO_FIRST;
9167 int id_last = ED_TAB_BUTTON_ID_LEVELINFO_LAST;
9170 for (i = id_first; i <= id_last; i++)
9172 int gadget_id = textbutton_info[i].gadget_id;
9173 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9174 boolean active = (i != edit_mode_levelinfo);
9176 // draw background line below tabulator button
9177 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9179 // draw solid line below inactive tabulator buttons
9180 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9181 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9182 ED_GADGET_TINY_DISTANCE, tab_color);
9184 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9185 MapTextbuttonGadget(i);
9188 // draw little border line below tabulator buttons
9189 if (tab_color != BLACK_PIXEL) // black => transparent
9190 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9191 ED_GADGET_TINY_DISTANCE,
9192 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9195 static void DrawPropertiesTabulatorGadgets(void)
9197 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9198 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9199 int gd_x = gd->x + gd_gi1->border.width / 2;
9200 int gd_y = gd->y + gd_gi1->height - 1;
9201 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9202 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9203 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9206 // draw two config tabulators for player elements
9207 if (IS_PLAYER_ELEMENT(properties_element))
9208 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9210 // draw two config and one "change" tabulator for custom elements
9211 if (IS_CUSTOM_ELEMENT(properties_element))
9212 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9214 for (i = id_first; i <= id_last; i++)
9216 int gadget_id = textbutton_info[i].gadget_id;
9217 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9218 boolean active = (i != edit_mode_properties);
9220 // use "config 1" and "config 2" instead of "config" for players and CEs
9221 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9222 (IS_PLAYER_ELEMENT(properties_element) ||
9223 IS_CUSTOM_ELEMENT(properties_element)))
9226 // draw background line below tabulator button
9227 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9229 // draw solid line below inactive tabulator buttons
9230 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9231 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9232 ED_GADGET_TINY_DISTANCE, tab_color);
9234 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9235 MapTextbuttonGadget(i);
9238 // draw little border line below tabulator buttons
9239 if (tab_color != BLACK_PIXEL) // black => transparent
9240 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9241 ED_GADGET_TINY_DISTANCE,
9242 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9245 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9247 DrawText(SX + xpos, SY + ypos, text, font_nr);
9250 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9253 int font_width = getFontWidth(font_nr);
9254 int font_height = getFontHeight(font_nr);
9255 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9256 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9258 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9259 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9260 TRUE, FALSE, FALSE);
9263 static void DrawLevelInfoLevel(void)
9267 // draw counter gadgets
9268 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9269 MapCounterButtons(i);
9271 // draw checkbutton gadgets
9272 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9273 MapCheckbuttonGadget(i);
9275 // draw selectbox gadgets
9276 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9277 MapSelectboxGadget(i);
9279 // draw text input gadgets
9280 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9281 MapTextInputGadget(i);
9284 static char *getLevelSubdirFromSaveMode(int save_mode)
9286 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9287 return getNewUserLevelSubdir();
9289 return leveldir_current->subdir;
9292 static void DrawLevelInfoLevelSet_DirectoryInfo(void)
9294 char *directory_text = "Level set directory:";
9295 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9296 int font1_nr = FONT_TEXT_1;
9297 int font2_nr = FONT_TEXT_2;
9298 int font1_height = getFontHeight(font1_nr);
9299 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
9300 int x = ED_LEVEL_SETTINGS_X(0);
9301 int y = ED_LEVEL_SETTINGS_Y(6);
9303 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
9304 PrintInfoText(directory_name, font2_nr, x, y);
9307 static void DrawLevelInfoLevelSet(void)
9309 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
9310 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
9313 // draw counter gadgets
9314 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
9315 MapCounterButtons(i);
9317 // draw checkbutton gadgets
9318 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
9320 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
9321 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
9322 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
9325 MapCheckbuttonGadget(i);
9328 // draw selectbox gadgets
9329 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
9330 MapSelectboxGadget(i);
9332 // draw text input gadgets
9333 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
9334 MapTextInputGadget(i);
9336 // draw textbutton gadgets
9337 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
9340 DrawLevelInfoLevelSet_DirectoryInfo();
9343 static void DrawLevelInfoEditor(void)
9347 // draw counter gadgets
9348 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
9349 MapCounterButtons(i);
9351 // draw checkbutton gadgets
9352 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
9353 MapCheckbuttonGadget(i);
9355 // draw radiobutton gadgets
9356 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
9357 MapRadiobuttonGadget(i);
9359 // draw drawing area
9360 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
9362 // draw textbutton gadgets
9363 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
9366 static void DrawLevelInfoWindow(void)
9368 char *text = "Global Settings";
9369 int font_nr = FONT_TITLE_1;
9370 struct MenuPosInfo *pos = &editor.settings.headline;
9371 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
9372 int sy = SY + pos->y;
9374 stick_element_properties_window = FALSE;
9376 SetAutomaticNumberOfGemsNeeded();
9378 UnmapLevelEditorFieldGadgets();
9380 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9383 DrawText(sx, sy, text, font_nr);
9385 DrawLevelInfoTabulatorGadgets();
9387 if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVEL)
9388 DrawLevelInfoLevel();
9389 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVELSET)
9390 DrawLevelInfoLevelSet();
9391 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_EDITOR)
9392 DrawLevelInfoEditor();
9395 static void DrawCustomContentArea(void)
9397 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
9398 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9399 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
9400 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
9401 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
9402 int xoffset = ED_GADGET_SPACE_DISTANCE;
9404 // add distance for potential left text (without drawing area border)
9405 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
9407 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9409 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
9412 static void DrawCustomChangeContentArea(void)
9414 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
9415 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9416 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
9417 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
9418 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
9419 int xoffset = ED_GADGET_SPACE_DISTANCE;
9421 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9426 static void RemoveElementContentArea(int id, int font_height)
9428 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9430 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
9431 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
9432 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9433 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
9434 ED_GADGET_TEXT_DISTANCE + font_height);
9437 static void DrawYamYamContentAreas(void)
9439 int font_nr = FONT_TEXT_1;
9440 int font_height = getFontHeight(font_nr);
9441 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9442 int yoffset = (tilesize - font_height) / 2;
9443 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
9444 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
9447 // display counter to choose number of element content areas
9448 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
9450 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9452 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
9454 if (i < level.num_yamyam_contents)
9460 UnmapDrawingArea(id);
9462 // delete content areas in case of reducing number of them
9463 RemoveElementContentArea(id, font_height);
9467 DrawText(x, y + 0 * tilesize, "content", font_nr);
9468 DrawText(x, y + 1 * tilesize, "when", font_nr);
9469 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
9472 static void DrawMagicBallContentAreas(void)
9474 int font_nr = FONT_TEXT_1;
9475 int font_height = getFontHeight(font_nr);
9476 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9477 int yoffset = (tilesize - font_height) / 2;
9478 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
9479 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
9482 // display counter to choose number of element content areas
9483 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
9485 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9487 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
9489 if (i < level.num_ball_contents)
9495 UnmapDrawingArea(id);
9497 // delete content areas in case of reducing number of them
9498 RemoveElementContentArea(id, font_height);
9502 DrawText(x, y + 0 * tilesize, "generated", font_nr);
9503 DrawText(x, y + 1 * tilesize, "when", font_nr);
9504 DrawText(x, y + 2 * tilesize, "active", font_nr);
9507 static void DrawAndroidElementArea(int element)
9509 int id = ED_DRAWING_ID_ANDROID_CONTENT;
9510 int num_elements = level.num_android_clone_elements;
9511 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9512 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9513 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9514 int xsize = MAX_ANDROID_ELEMENTS;
9517 // display counter to choose number of element areas
9518 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
9520 if (drawingarea_info[id].text_left != NULL)
9521 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9523 UnmapDrawingArea(id);
9525 ModifyEditorDrawingArea(id, num_elements, 1);
9527 // delete content areas in case of reducing number of them
9528 DrawBackground(sx, sy,
9529 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9530 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9535 static void DrawGroupElementArea(int element)
9537 int id = ED_DRAWING_ID_GROUP_CONTENT;
9538 int num_elements = group_element_info.num_elements;
9539 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9540 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9541 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9542 int xsize = MAX_ELEMENTS_IN_GROUP;
9545 if (drawingarea_info[id].text_left != NULL)
9546 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9548 UnmapDrawingArea(id);
9550 ModifyEditorDrawingArea(id, num_elements, 1);
9552 // delete content areas in case of reducing number of them
9553 DrawBackground(sx, sy,
9554 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9555 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9560 static void DrawPlayerInitialInventoryArea(int element)
9562 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
9563 int player_nr = GET_PLAYER_NR(element);
9564 int num_elements = level.initial_inventory_size[player_nr];
9565 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9566 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9567 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9568 int xsize = MAX_INITIAL_INVENTORY_SIZE;
9571 // determine horizontal position to the right of specified gadget
9572 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
9573 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
9574 ED_DRAWINGAREA_TEXT_DISTANCE);
9576 // determine horizontal offset for leading text
9577 if (drawingarea_info[id].text_left != NULL)
9578 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9580 UnmapDrawingArea(id);
9582 ModifyEditorDrawingArea(id, num_elements, 1);
9584 // delete content areas in case of reducing number of them
9585 DrawBackground(sx, sy,
9586 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9587 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9592 static void DrawEnvelopeTextArea(int envelope_nr)
9594 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
9595 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
9598 DrawBackground(gi->x, gi->y, gi->width, gi->height);
9600 if (envelope_nr != -1)
9601 textarea_info[id].value = level.envelope[envelope_nr].text;
9603 ModifyGadget(gi, GDI_AREA_SIZE,
9604 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
9605 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
9608 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
9611 static void DrawPropertiesInfo(void)
9620 // configurable properties
9622 { EP_WALKABLE_OVER, "- player can walk over it" },
9623 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
9624 { EP_WALKABLE_UNDER, "- player can walk under it" },
9625 { EP_PASSABLE_OVER, "- player can pass over it" },
9626 { EP_PASSABLE_INSIDE, "- player can pass through it" },
9627 { EP_PASSABLE_UNDER, "- player can pass under it" },
9628 { EP_PROTECTED, "- player is protected by it" },
9630 { EP_DIGGABLE, "- can be digged away" },
9631 { EP_COLLECTIBLE, "- can be collected" },
9632 { EP_DROPPABLE, "- can be dropped after collecting" },
9633 { EP_THROWABLE, "- can be thrown after collecting" },
9634 { EP_PUSHABLE, "- can be pushed" },
9636 { EP_CAN_FALL, "- can fall" },
9637 { EP_CAN_MOVE, "- can move" },
9639 { EP_CAN_SMASH_PLAYER, "- can smash player" },
9641 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
9643 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
9645 { EP_SLIPPERY, "- slippery for falling elements" },
9646 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
9648 { EP_DONT_RUN_INTO, "- deadly when running into" },
9649 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
9650 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
9651 { EP_DONT_TOUCH, "- deadly when touching" },
9653 { EP_INDESTRUCTIBLE, "- indestructible" },
9655 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
9656 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
9657 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
9659 { EP_CAN_CHANGE, "- can change to other element" },
9661 // pre-defined properties
9662 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
9663 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
9664 { EP_SWITCHABLE, "- can be switched" },
9666 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
9671 char *filename = getElementDescriptionFilename(properties_element);
9672 char *percentage_text = "In this level: ";
9673 char *properties_text = "Standard properties: ";
9674 char *description_text = "Description:";
9675 char *no_description_text = "No description available.";
9676 char *none_text = "None";
9678 int num_elements_in_level;
9679 int num_standard_properties = 0;
9680 int font1_nr = FONT_TEXT_1;
9681 int font2_nr = FONT_TEXT_2;
9682 int font1_width = getFontWidth(font1_nr);
9683 int font1_height = getFontHeight(font1_nr);
9684 int font2_height = getFontHeight(font2_nr);
9685 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
9686 int font2_yoffset = (font1_height - font2_height) / 2;
9687 int percentage_text_len = strlen(percentage_text) * font1_width;
9688 int properties_text_len = strlen(properties_text) * font1_width;
9689 int xpos = ED_ELEMENT_SETTINGS_X(0);
9690 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9693 if (setup.editor.show_element_token)
9695 int font3_nr = FONT_TEXT_3;
9696 int font3_height = getFontHeight(font3_nr);
9698 DrawTextF(xpos, ypos, font3_nr,
9699 "[%s]", element_info[properties_element].token_name);
9701 ypos += 2 * font3_height;
9704 // ----- print number of elements / percentage of this element in level
9706 num_elements_in_level = 0;
9707 for (y = 0; y < lev_fieldy; y++)
9708 for (x = 0; x < lev_fieldx; x++)
9709 if (Tile[x][y] == properties_element)
9710 num_elements_in_level++;
9711 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
9713 DrawTextS(xpos, ypos, font1_nr, percentage_text);
9715 if (num_elements_in_level > 0)
9716 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9717 "%d (%.2f %%)", num_elements_in_level, percentage);
9719 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9722 ypos += 2 * MAX(font1_height, font2_height);
9724 // ----- print standard properties of this element
9726 DrawTextS(xpos, ypos, font1_nr, properties_text);
9728 ypos += line1_height;
9730 for (i = 0; properties[i].value != -1; i++)
9732 if (!HAS_PROPERTY(properties_element, properties[i].value))
9735 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
9737 ypos += font2_height;
9739 num_standard_properties++;
9742 if (num_standard_properties == 0)
9744 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
9745 font2_nr, none_text);
9747 ypos -= (line1_height - font1_height);
9750 ypos += MAX(font1_height, font2_height);
9752 // ----- print special description of this element
9754 PrintInfoText(description_text, font1_nr, xpos, ypos);
9756 ypos += line1_height;
9758 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
9759 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
9762 #define TEXT_COLLECTING "Score for collecting"
9763 #define TEXT_SMASHING "Score for smashing"
9764 #define TEXT_SLURPING "Score for slurping robot"
9765 #define TEXT_CRACKING "Score for cracking"
9766 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
9767 #define TEXT_DURATION "Duration when activated"
9768 #define TEXT_DELAY_ON "Delay before activating"
9769 #define TEXT_DELAY_OFF "Delay before deactivating"
9770 #define TEXT_DELAY_EXPLODING "Delay before exploding"
9771 #define TEXT_DELAY_MOVING "Delay before moving"
9772 #define TEXT_BALL_DELAY "Element generation delay"
9773 #define TEXT_MOVE_SPEED "Speed of android moving"
9774 #define TEXT_CLONE_SPEED "Speed of android cloning"
9775 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
9776 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
9777 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
9778 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
9779 #define TEXT_TIME_BONUS "Extra time to solve level"
9786 } elements_with_counter[] =
9788 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
9789 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
9790 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
9791 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
9792 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9793 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
9794 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
9795 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
9796 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
9797 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
9798 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
9799 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
9800 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9801 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9802 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
9803 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
9804 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
9805 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9806 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9807 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
9808 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9809 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9810 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9811 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9812 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9813 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9814 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
9815 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9816 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9817 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9818 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9819 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9820 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9821 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9822 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
9823 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
9824 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9825 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
9826 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9827 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9828 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9829 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9830 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9831 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
9832 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9833 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9834 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
9835 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9836 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9837 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
9838 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
9839 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
9840 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9841 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9842 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9843 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9844 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9845 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9846 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9847 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9848 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
9849 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
9850 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
9851 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
9852 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
9853 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9854 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
9855 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
9856 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
9857 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9858 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9859 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9860 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9861 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9862 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9863 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9864 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9865 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9866 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9867 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9868 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9869 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9870 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
9872 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
9873 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
9874 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
9875 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
9876 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
9877 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
9878 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
9879 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
9880 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
9881 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
9882 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
9883 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
9884 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
9885 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
9886 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
9887 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
9889 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
9890 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
9891 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
9892 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
9893 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
9894 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
9895 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
9896 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
9897 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
9898 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
9899 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
9900 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
9901 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_ON },
9902 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9903 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9908 static boolean checkPropertiesConfig(int element)
9912 if (IS_GEM(element) ||
9913 IS_CUSTOM_ELEMENT(element) ||
9914 IS_GROUP_ELEMENT(element) ||
9915 IS_EMPTY_ELEMENT(element) ||
9916 IS_BALLOON_ELEMENT(element) ||
9917 IS_ENVELOPE(element) ||
9918 IS_MM_MCDUFFIN(element) ||
9919 IS_DF_LASER(element) ||
9920 IS_PLAYER_ELEMENT(element) ||
9921 HAS_EDITOR_CONTENT(element) ||
9922 CAN_GROW(element) ||
9923 COULD_MOVE_INTO_ACID(element) ||
9924 MAYBE_DONT_COLLIDE_WITH(element) ||
9925 element == EL_SOKOBAN_OBJECT ||
9926 element == EL_SOKOBAN_FIELD_EMPTY ||
9927 element == EL_SOKOBAN_FIELD_FULL)
9930 for (i = 0; elements_with_counter[i].element != -1; i++)
9931 if (elements_with_counter[i].element == element)
9937 static void SetAutomaticNumberOfGemsNeeded(void)
9941 if (!level.auto_count_gems)
9944 level.gems_needed = 0;
9946 for (x = 0; x < lev_fieldx; x++)
9948 for (y = 0; y < lev_fieldy; y++)
9950 int element = Tile[x][y];
9955 case EL_EMERALD_YELLOW:
9956 case EL_EMERALD_RED:
9957 case EL_EMERALD_PURPLE:
9959 case EL_WALL_EMERALD:
9960 case EL_WALL_EMERALD_YELLOW:
9961 case EL_WALL_EMERALD_RED:
9962 case EL_WALL_EMERALD_PURPLE:
9963 case EL_WALL_BD_DIAMOND:
9965 case EL_SP_INFOTRON:
9968 level.gems_needed++;
9972 case EL_WALL_DIAMOND:
9973 level.gems_needed += 3;
9978 level.gems_needed += 5;
9982 case EL_WALL_CRYSTAL:
9983 level.gems_needed += 8;
9992 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
9995 static void DrawPropertiesConfig(void)
9997 boolean draw_footer_line = FALSE;
9998 int max_num_element_counters = 4;
9999 int num_element_counters = 0;
10002 if (!checkPropertiesConfig(properties_element))
10004 int xpos = ED_ELEMENT_SETTINGS_X(0);
10005 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10007 PrintInfoText("No configuration options available.",
10008 FONT_TEXT_1, xpos, ypos);
10013 // check if there are elements where a value can be chosen for
10014 for (i = 0; elements_with_counter[i].element != -1; i++)
10016 if (elements_with_counter[i].element == properties_element)
10018 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10020 counterbutton_info[counter_id].y =
10021 ED_ELEMENT_SETTINGS_YPOS(
10022 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10023 (CAN_GROW(properties_element) ? 1 : 0) +
10024 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10025 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10026 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10027 num_element_counters);
10029 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10030 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
10032 if (properties_element == EL_GAME_OF_LIFE ||
10033 properties_element == EL_BIOMAZE)
10035 counterbutton_info[counter_id].min_value = 0; // min neighbours
10036 counterbutton_info[counter_id].max_value = 8; // max neighbours
10040 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10041 counterbutton_info[counter_id].min_value = MIN_SCORE;
10042 counterbutton_info[counter_id].max_value = MAX_SCORE;
10045 MapCounterButtons(counter_id);
10047 num_element_counters++;
10048 if (num_element_counters >= max_num_element_counters)
10053 if (HAS_EDITOR_CONTENT(properties_element))
10055 // draw stickybutton gadget
10056 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10058 if (IS_AMOEBOID(properties_element))
10059 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10060 else if (properties_element == EL_YAMYAM ||
10061 properties_element == EL_YAMYAM_LEFT ||
10062 properties_element == EL_YAMYAM_RIGHT ||
10063 properties_element == EL_YAMYAM_UP ||
10064 properties_element == EL_YAMYAM_DOWN)
10065 DrawYamYamContentAreas();
10066 else if (properties_element == EL_EMC_MAGIC_BALL)
10068 DrawMagicBallContentAreas();
10070 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10071 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10073 else if (properties_element == EL_EMC_ANDROID)
10074 DrawAndroidElementArea(properties_element);
10077 if (IS_PLAYER_ELEMENT(properties_element))
10079 int player_nr = GET_PLAYER_NR(properties_element);
10081 // these properties can be set for every player individually
10083 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10085 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
10086 &level.start_element[player_nr];
10087 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
10088 &level.artwork_element[player_nr];
10089 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
10090 &level.explosion_element[player_nr];
10092 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10093 &level.use_start_element[player_nr];
10094 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10095 &level.use_artwork_element[player_nr];
10096 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10097 &level.use_explosion_element[player_nr];
10098 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10099 &level.initial_player_gravity[player_nr];
10101 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10102 &level.initial_player_stepsize[player_nr];
10104 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
10105 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
10106 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
10107 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
10108 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
10109 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
10110 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
10111 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
10112 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
10113 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
10114 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
10115 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
10116 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
10117 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
10118 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
10120 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
10121 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
10122 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
10124 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
10126 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10128 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
10129 &level.initial_inventory_content[player_nr][0];
10131 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
10132 &level.initial_inventory_size[player_nr];
10134 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
10135 &level.use_initial_inventory[player_nr];
10137 // draw checkbutton gadgets
10138 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
10139 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
10140 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
10142 // draw counter gadgets
10143 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
10145 // draw drawing area gadgets
10146 DrawPlayerInitialInventoryArea(properties_element);
10150 if (IS_GEM(properties_element))
10151 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
10153 if (properties_element == EL_EM_DYNAMITE)
10154 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
10156 if (COULD_MOVE_INTO_ACID(properties_element) &&
10157 !IS_PLAYER_ELEMENT(properties_element) &&
10158 (!IS_CUSTOM_ELEMENT(properties_element) ||
10159 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
10161 // set position for checkbutton for "can move into acid"
10162 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
10163 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
10164 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
10165 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
10166 IS_BALLOON_ELEMENT(properties_element) ||
10167 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10169 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
10172 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
10173 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
10175 if (properties_element == EL_SPRING ||
10176 properties_element == EL_SPRING_LEFT ||
10177 properties_element == EL_SPRING_RIGHT)
10178 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
10180 if (properties_element == EL_TIME_ORB_FULL)
10181 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
10183 if (properties_element == EL_GAME_OF_LIFE ||
10184 properties_element == EL_BIOMAZE)
10185 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
10187 if (CAN_GROW(properties_element))
10189 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
10190 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10192 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
10195 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
10196 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
10198 if (properties_element == EL_SOKOBAN_OBJECT)
10199 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
10201 if (properties_element == EL_SOKOBAN_OBJECT ||
10202 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
10203 properties_element == EL_SOKOBAN_FIELD_FULL)
10205 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
10206 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
10209 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
10212 if (IS_BALLOON_ELEMENT(properties_element))
10213 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
10215 if (IS_ENVELOPE(properties_element))
10217 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
10218 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
10219 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
10220 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
10221 int envelope_nr = properties_element - EL_ENVELOPE_1;
10223 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
10224 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
10226 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
10227 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
10229 // display counter to choose size of envelope text area
10230 MapCounterButtons(counter1_id);
10231 MapCounterButtons(counter2_id);
10233 // display checkbuttons to choose auto-wrap and alignment properties
10234 MapCheckbuttonGadget(button1_id);
10235 MapCheckbuttonGadget(button2_id);
10237 DrawEnvelopeTextArea(envelope_nr);
10240 if (IS_MM_MCDUFFIN(properties_element))
10242 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
10243 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
10244 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
10247 if (IS_DF_LASER(properties_element))
10249 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
10250 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
10251 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
10254 if (IS_CUSTOM_ELEMENT(properties_element))
10256 // draw stickybutton gadget
10257 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10259 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10261 // draw checkbutton gadgets
10262 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
10263 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
10264 MapCheckbuttonGadget(i);
10266 // draw counter gadgets
10267 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
10268 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
10269 MapCounterButtons(i);
10271 // draw selectbox gadgets
10272 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
10273 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
10274 MapSelectboxGadget(i);
10276 // draw textbutton gadgets
10277 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10279 // draw text input gadgets
10280 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10282 // draw drawing area gadgets
10283 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10285 draw_footer_line = TRUE;
10287 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10289 // draw checkbutton gadgets
10290 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
10291 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
10292 MapCheckbuttonGadget(i);
10294 // draw counter gadgets
10295 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
10296 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
10297 MapCounterButtons(i);
10299 // draw selectbox gadgets
10300 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
10301 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
10302 MapSelectboxGadget(i);
10304 // draw drawing area gadgets
10305 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
10306 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
10307 DrawCustomContentArea();
10310 else if (IS_GROUP_ELEMENT(properties_element))
10312 // draw stickybutton gadget
10313 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10315 // draw checkbutton gadgets
10316 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10317 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10319 // draw counter gadgets
10320 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
10322 // draw selectbox gadgets
10323 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
10325 // draw textbutton gadgets
10326 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10328 // draw drawing area gadgets
10329 DrawGroupElementArea(properties_element);
10331 // draw text input gadgets
10332 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10334 // draw drawing area gadgets
10335 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10337 draw_footer_line = TRUE;
10339 else if (IS_EMPTY_ELEMENT(properties_element))
10341 // draw stickybutton gadget
10342 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10344 // draw checkbutton gadgets
10345 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10346 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10348 // draw textbutton gadgets
10349 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10351 // draw drawing area gadgets
10352 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10354 draw_footer_line = TRUE;
10357 // draw little footer border line above CE/GE use/save template gadgets
10358 if (draw_footer_line)
10360 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
10361 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
10362 int gd_x = gd->x + gd_gi1->border.width / 2;
10363 int gd_y = gd->y + gd_gi1->height - 1;
10364 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
10366 if (tab_color != BLACK_PIXEL) // black => transparent
10367 FillRectangle(drawto,
10368 SX + ED_ELEMENT_SETTINGS_X(0),
10369 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
10371 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10375 static void DrawPropertiesChangeDrawingAreas(void)
10377 if (IS_CUSTOM_ELEMENT(properties_element))
10379 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
10380 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
10381 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
10383 DrawCustomChangeContentArea();
10386 redraw_mask |= REDRAW_FIELD;
10389 static void DrawPropertiesChange(void)
10393 // needed to initially set selectbox options for special action options
10394 setSelectboxSpecialActionOptions();
10396 // draw stickybutton gadget
10397 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10399 // draw checkbutton gadgets
10400 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
10401 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
10402 MapCheckbuttonGadget(i);
10404 // draw counter gadgets
10405 for (i = ED_COUNTER_ID_CHANGE_FIRST;
10406 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
10407 MapCounterButtons(i);
10409 // draw selectbox gadgets
10410 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
10411 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
10412 MapSelectboxGadget(i);
10414 // draw textbutton gadgets
10415 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
10416 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
10417 MapTextbuttonGadget(i);
10419 // draw graphicbutton gadgets
10420 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
10421 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
10422 MapGraphicbuttonGadget(i);
10424 // draw drawing area gadgets
10425 DrawPropertiesChangeDrawingAreas();
10428 static void DrawEditorElementAnimation(int x, int y)
10430 int graphic = el2img(properties_element);
10431 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
10432 custom_element.ce_value_fixed_initial :
10433 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
10434 custom_element.collect_score_initial : FrameCounter);
10436 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
10439 static void DrawEditorElementName(int x, int y, int font_nr)
10441 char *element_name = getElementInfoText(properties_element);
10442 int font_width = getFontWidth(font_nr);
10443 int font_height = getFontHeight(font_nr);
10444 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
10445 int max_chars_per_line = max_text_width / font_width;
10446 char buffer[max_chars_per_line + 1];
10448 if (strlen(element_name) <= max_chars_per_line)
10449 DrawTextS(x, y, font_nr, element_name);
10452 int next_pos = max_chars_per_line;
10454 strncpy(buffer, element_name, max_chars_per_line);
10455 buffer[max_chars_per_line] = '\0';
10457 if (element_name[max_chars_per_line] == ' ')
10463 for (i = max_chars_per_line - 1; i >= 0; i--)
10464 if (buffer[i] == ' ')
10467 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
10474 DrawTextS(x, y - font_height / 2, font_nr, buffer);
10476 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
10477 buffer[max_chars_per_line] = '\0';
10479 DrawTextS(x, y + font_height / 2, font_nr, buffer);
10483 static void DrawPropertiesWindow(void)
10485 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
10486 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
10487 int border_size = gd->border_size;
10488 int font_nr = FONT_TEXT_1;
10489 int font_height = getFontHeight(font_nr);
10490 int xoffset = TILEX + element_border + 3 * border_size;
10491 int yoffset = (TILEY - font_height) / 2;
10492 int x1 = editor.settings.element_graphic.x + element_border;
10493 int y1 = editor.settings.element_graphic.y + element_border;
10494 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
10495 editor.settings.element_name.x);
10496 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
10497 editor.settings.element_name.y);
10498 char *text = "Element Settings";
10499 int font2_nr = FONT_TITLE_1;
10500 struct MenuPosInfo *pos = &editor.settings.headline;
10501 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
10502 int sy = SY + pos->y;
10504 stick_element_properties_window = FALSE;
10506 // make sure that previous properties edit mode exists for this element
10507 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
10508 !IS_CUSTOM_ELEMENT(properties_element))
10509 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
10511 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
10512 !IS_PLAYER_ELEMENT(properties_element) &&
10513 !IS_CUSTOM_ELEMENT(properties_element))
10514 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
10516 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
10517 (IS_PLAYER_ELEMENT(properties_element) ||
10518 IS_CUSTOM_ELEMENT(properties_element)))
10519 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
10521 CopyElementPropertiesToEditor(properties_element);
10523 UnmapLevelEditorFieldGadgets();
10524 UnmapLevelEditorToolboxDrawingGadgets();
10525 UnmapLevelEditorToolboxCustomGadgets();
10527 if (IS_CUSTOM_ELEMENT(properties_element) ||
10528 IS_GROUP_ELEMENT(properties_element))
10529 MapLevelEditorToolboxCustomGadgets();
10531 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10534 DrawText(sx, sy, text, font2_nr);
10536 FrameCounter = 0; // restart animation frame counter
10538 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
10539 DrawEditorElementAnimation(SX + x1, SY + y1);
10540 DrawEditorElementName(x2, y2, font_nr);
10542 DrawPropertiesTabulatorGadgets();
10544 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
10545 DrawPropertiesInfo();
10546 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
10547 DrawPropertiesChange();
10548 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
10549 DrawPropertiesConfig();
10552 static void DrawPaletteWindow(void)
10556 UnmapLevelEditorFieldGadgets();
10558 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10561 // map buttons to select elements
10562 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
10563 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
10564 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
10565 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
10566 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
10569 static void UpdateCustomElementGraphicGadgets(void)
10573 InitElementPropertiesGfxElement();
10575 ModifyEditorElementList();
10576 RedrawDrawingElements();
10578 // force redraw of all mapped drawing area gadgets
10579 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
10581 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
10588 static int getOpenDirectionFromTube(int element)
10592 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
10593 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
10594 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
10595 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
10596 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
10597 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
10598 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
10599 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
10600 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
10601 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
10602 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
10608 static int getTubeFromOpenDirection(int direction)
10612 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
10613 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
10614 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
10615 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
10616 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
10617 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
10618 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
10619 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
10620 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
10621 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
10622 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
10624 // if only one direction, fall back to simple tube with that direction
10625 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
10626 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
10627 case (MV_UP): return EL_TUBE_VERTICAL;
10628 case (MV_DOWN): return EL_TUBE_VERTICAL;
10634 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
10636 int element_new = getTubeFromOpenDirection(direction);
10638 return (element_new != EL_EMPTY ? element_new : element_old);
10641 static int getOpenDirectionFromBelt(int element)
10643 int belt_dir = getBeltDirFromBeltElement(element);
10645 return (belt_dir == MV_LEFT ? MV_RIGHT :
10646 belt_dir == MV_RIGHT ? MV_LEFT :
10647 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
10650 static int getBeltFromNrAndOpenDirection(int nr, int direction)
10652 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
10653 direction == MV_RIGHT ? MV_LEFT :
10654 direction == MV_HORIZONTAL ? MV_NONE : direction);
10656 if (direction == MV_NONE)
10659 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
10662 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
10665 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
10667 return (element_new != EL_EMPTY ? element_new : element_old);
10670 static int getOpenDirectionFromPool(int element)
10674 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
10675 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
10676 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
10677 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
10678 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
10679 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
10685 static int getPoolFromOpenDirection(int direction)
10689 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
10690 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
10691 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
10692 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
10693 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
10694 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
10700 static int getPoolFromOpenDirectionExt(int direction, int help_element)
10702 int element = getPoolFromOpenDirection(direction);
10703 int help_direction = getOpenDirectionFromPool(help_element);
10705 if (element == EL_EMPTY)
10707 int help_direction_vertical = help_direction & MV_VERTICAL;
10709 element = getPoolFromOpenDirection(direction | help_direction_vertical);
10712 if (element == EL_EMPTY)
10714 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
10716 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
10722 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
10724 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
10726 return (element_new != EL_EMPTY ? element_new : element_old);
10729 static int getOpenDirectionFromPillar(int element)
10733 case EL_EMC_WALL_1: return (MV_DOWN);
10734 case EL_EMC_WALL_2: return (MV_VERTICAL);
10735 case EL_EMC_WALL_3: return (MV_UP);
10741 static int getPillarFromOpenDirection(int direction)
10745 case (MV_DOWN): return EL_EMC_WALL_1;
10746 case (MV_VERTICAL): return EL_EMC_WALL_2;
10747 case (MV_UP): return EL_EMC_WALL_3;
10753 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
10755 int element_new = getPillarFromOpenDirection(direction);
10757 return (element_new != EL_EMPTY ? element_new : element_old);
10760 static int getOpenDirectionFromSteel2(int element)
10764 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
10765 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
10766 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
10767 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
10768 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
10769 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
10770 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
10771 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
10777 static int getSteel2FromOpenDirection(int direction)
10781 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
10782 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
10783 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
10784 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
10785 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
10786 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
10787 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
10788 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
10794 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
10796 int element_new = getSteel2FromOpenDirection(direction);
10798 return (element_new != EL_EMPTY ? element_new : element_old);
10801 static int getOpenDirectionFromChip(int element)
10805 case EL_SP_CHIP_SINGLE: return (MV_NONE);
10806 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
10807 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
10808 case EL_SP_CHIP_TOP: return (MV_DOWN);
10809 case EL_SP_CHIP_BOTTOM: return (MV_UP);
10815 static int getChipFromOpenDirection(int direction)
10819 case (MV_NONE): return EL_SP_CHIP_SINGLE;
10820 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
10821 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
10822 case (MV_UP): return EL_SP_CHIP_BOTTOM;
10823 case (MV_DOWN): return EL_SP_CHIP_TOP;
10829 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
10831 int element_new = getChipFromOpenDirection(direction);
10833 return (element_new != EL_EMPTY ? element_new : element_old);
10836 static int getClosedTube(int x, int y)
10838 static int xy[4][2] =
10845 int element_old = IntelliDrawBuffer[x][y];
10846 int direction_old = getOpenDirectionFromTube(element_old);
10847 int direction_new = MV_NONE;
10850 for (i = 0; i < NUM_DIRECTIONS; i++)
10852 int xx = x + xy[i][0];
10853 int yy = y + xy[i][1];
10854 int dir = MV_DIR_FROM_BIT(i);
10855 int dir_opposite = MV_DIR_OPPOSITE(dir);
10857 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
10858 (direction_old & dir) &&
10859 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10860 direction_new |= dir;
10863 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
10866 static int getClosedBelt(int x, int y)
10868 static int xy[4][2] =
10875 int element_old = IntelliDrawBuffer[x][y];
10876 int nr = getBeltNrFromBeltElement(element_old);
10877 int direction_old = getOpenDirectionFromBelt(element_old);
10878 int direction_new = MV_NONE;
10881 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10883 int xx = x + xy[i][0];
10884 int yy = y + xy[i][1];
10885 int dir = MV_DIR_FROM_BIT(i);
10886 int dir_opposite = MV_DIR_OPPOSITE(dir);
10888 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
10889 (direction_old & dir) &&
10890 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10891 direction_new |= dir;
10894 return getBeltFromNrAndOpenDirection(nr, direction_new);
10897 static int getClosedPool(int x, int y)
10899 static int xy[4][2] =
10906 int element_old = IntelliDrawBuffer[x][y];
10907 int direction_old = getOpenDirectionFromPool(element_old);
10908 int direction_new = MV_NONE;
10911 for (i = 0; i < NUM_DIRECTIONS; i++)
10913 int xx = x + xy[i][0];
10914 int yy = y + xy[i][1];
10915 int dir = MV_DIR_FROM_BIT(i);
10916 int dir_opposite = MV_DIR_OPPOSITE(dir);
10918 if (IN_LEV_FIELD(xx, yy) &&
10919 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
10920 (direction_old & dir) &&
10921 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10922 direction_new |= dir;
10925 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
10928 static int getClosedPillar(int x, int y)
10930 static int xy[4][2] =
10937 int element_old = IntelliDrawBuffer[x][y];
10938 int direction_old = getOpenDirectionFromPillar(element_old);
10939 int direction_new = MV_NONE;
10942 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
10944 int xx = x + xy[i][0];
10945 int yy = y + xy[i][1];
10946 int dir = MV_DIR_FROM_BIT(i);
10947 int dir_opposite = MV_DIR_OPPOSITE(dir);
10949 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
10950 (direction_old & dir) &&
10951 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10952 direction_new |= dir;
10955 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
10958 static int getClosedSteel2(int x, int y)
10960 static int xy[4][2] =
10967 int element_old = IntelliDrawBuffer[x][y];
10968 int direction_old = getOpenDirectionFromSteel2(element_old);
10969 int direction_new = MV_NONE;
10972 for (i = 0; i < NUM_DIRECTIONS; i++)
10974 int xx = x + xy[i][0];
10975 int yy = y + xy[i][1];
10976 int dir = MV_DIR_FROM_BIT(i);
10977 int dir_opposite = MV_DIR_OPPOSITE(dir);
10979 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
10980 (direction_old & dir) &&
10981 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10982 direction_new |= dir;
10985 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
10988 static int getClosedChip(int x, int y)
10990 static int xy[4][2] =
10997 int element_old = IntelliDrawBuffer[x][y];
10998 int direction_old = getOpenDirectionFromChip(element_old);
10999 int direction_new = MV_NONE;
11002 for (i = 0; i < NUM_DIRECTIONS; i++)
11004 int xx = x + xy[i][0];
11005 int yy = y + xy[i][1];
11006 int dir = MV_DIR_FROM_BIT(i);
11007 int dir_opposite = MV_DIR_OPPOSITE(dir);
11009 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11010 (direction_old & dir) &&
11011 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11012 direction_new |= dir;
11015 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11018 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11019 boolean change_level)
11021 int sx = x - level_xpos;
11022 int sy = y - level_ypos;
11023 int old_element = Tile[x][y];
11024 int new_element = element;
11025 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11026 boolean draw_masked = FALSE;
11028 if (IS_MM_WALL_EDITOR(element))
11030 element = map_mm_wall_element_editor(element) | new_bitmask;
11032 if (IS_MM_WALL(old_element))
11033 element |= MM_WALL_BITS(old_element);
11036 draw_masked = TRUE;
11038 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11040 int element_changed = old_element & ~new_bitmask;
11042 if (MM_WALL_BITS(element_changed) != 0)
11043 element = element_changed;
11046 IntelliDrawBuffer[x][y] = element;
11049 Tile[x][y] = element;
11051 if (IN_ED_FIELD(sx, sy))
11053 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11054 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11055 else if (draw_masked)
11056 DrawEditorElementThruMask(sx, sy, element);
11058 DrawEditorElement(sx, sy, element);
11062 static void SetElementSimple(int x, int y, int element, boolean change_level)
11064 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11067 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11068 int x2, int y2, int *element2,
11069 int (*close_function)(int, int),
11070 boolean change_level)
11072 // set neighbour elements to newly determined connections
11073 SetElementSimple(x1, y1, *element1, change_level);
11074 SetElementSimple(x2, y2, *element2, change_level);
11076 // remove all open connections of neighbour elements
11077 *element1 = close_function(x1, y1);
11078 *element2 = close_function(x2, y2);
11080 // set neighbour elements to new, minimized connections
11081 SetElementSimple(x1, y1, *element1, change_level);
11082 SetElementSimple(x2, y2, *element2, change_level);
11085 static void SetElementIntelliDraw(int x, int y, int new_element,
11086 boolean change_level, int button)
11088 static int xy[4][2] =
11095 static int last_x = -1;
11096 static int last_y = -1;
11098 if (new_element == EL_UNDEFINED)
11106 int old_element = IntelliDrawBuffer[x][y];
11108 if (IS_TUBE(new_element))
11110 int last_element_new = EL_UNDEFINED;
11111 int direction = MV_NONE;
11114 // if old element is of same kind, keep all existing directions
11115 if (IS_TUBE(old_element))
11116 direction |= getOpenDirectionFromTube(old_element);
11118 for (i = 0; i < NUM_DIRECTIONS; i++)
11120 int xx = x + xy[i][0];
11121 int yy = y + xy[i][1];
11123 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11124 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11126 int dir = MV_DIR_FROM_BIT(i);
11127 int dir_opposite = MV_DIR_OPPOSITE(dir);
11128 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11129 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11130 int last_direction_new = last_direction_old | dir_opposite;
11132 last_element_new = getTubeFromOpenDirection(last_direction_new);
11138 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
11140 if (last_element_new != EL_UNDEFINED)
11141 MergeAndCloseNeighbourElements(x, y, &new_element,
11142 last_x, last_y, &last_element_new,
11143 getClosedTube, change_level);
11145 else if (IS_BELT(new_element))
11147 int belt_nr = getBeltNrFromBeltElement(new_element);
11148 int last_element_new = EL_UNDEFINED;
11149 int direction = MV_NONE;
11152 // if old element is of same kind, keep all existing directions
11153 if (IS_BELT(old_element))
11154 direction |= getOpenDirectionFromBelt(old_element);
11156 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11158 int xx = x + xy[i][0];
11159 int yy = y + xy[i][1];
11161 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11162 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
11164 int dir = MV_DIR_FROM_BIT(i);
11165 int dir_opposite = MV_DIR_OPPOSITE(dir);
11166 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11167 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
11168 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
11169 int last_direction_new = last_direction_old | dir_opposite;
11171 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11172 last_direction_new);
11177 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
11179 if (last_element_new != EL_UNDEFINED)
11180 MergeAndCloseNeighbourElements(x, y, &new_element,
11181 last_x, last_y, &last_element_new,
11182 getClosedBelt, change_level);
11184 else if (IS_ACID_POOL_OR_ACID(new_element))
11186 int last_element_new = EL_UNDEFINED;
11187 int direction = MV_NONE;
11190 // if old element is of same kind, keep all existing directions
11191 if (IS_ACID_POOL_OR_ACID(old_element))
11192 direction |= getOpenDirectionFromPool(old_element);
11194 for (i = 0; i < NUM_DIRECTIONS; i++)
11196 int xx = x + xy[i][0];
11197 int yy = y + xy[i][1];
11199 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11200 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
11202 int dir = MV_DIR_FROM_BIT(i);
11203 int dir_opposite = MV_DIR_OPPOSITE(dir);
11204 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11205 int last_direction_old = getOpenDirectionFromPool(last_element_old);
11206 int last_direction_new = last_direction_old | dir_opposite;
11208 last_element_new = getPoolFromOpenDirection(last_direction_new);
11214 // special corrections needed for intuitively correct acid pool drawing
11215 if (last_element_new == EL_EMPTY)
11216 last_element_new = new_element;
11217 else if (last_element_new != EL_UNDEFINED)
11218 new_element = last_element_new;
11220 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
11222 if (last_element_new != EL_UNDEFINED)
11223 MergeAndCloseNeighbourElements(x, y, &new_element,
11224 last_x, last_y, &last_element_new,
11225 getClosedPool, change_level);
11227 else if (IS_EMC_PILLAR(new_element))
11229 int last_element_new = EL_UNDEFINED;
11230 int direction = MV_NONE;
11233 // if old element is of same kind, keep all existing directions
11234 if (IS_EMC_PILLAR(old_element))
11235 direction |= getOpenDirectionFromPillar(old_element);
11237 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11239 int xx = x + xy[i][0];
11240 int yy = y + xy[i][1];
11242 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11243 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
11245 int dir = MV_DIR_FROM_BIT(i);
11246 int dir_opposite = MV_DIR_OPPOSITE(dir);
11247 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11248 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
11249 int last_direction_new = last_direction_old | dir_opposite;
11251 last_element_new = getPillarFromOpenDirection(last_direction_new);
11257 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
11259 if (last_element_new != EL_UNDEFINED)
11260 MergeAndCloseNeighbourElements(x, y, &new_element,
11261 last_x, last_y, &last_element_new,
11262 getClosedPillar, change_level);
11264 else if (IS_DC_STEELWALL_2(new_element))
11266 int last_element_new = EL_UNDEFINED;
11267 int direction = MV_NONE;
11270 // if old element is of same kind, keep all existing directions
11271 if (IS_DC_STEELWALL_2(old_element))
11272 direction |= getOpenDirectionFromSteel2(old_element);
11274 for (i = 0; i < NUM_DIRECTIONS; i++)
11276 int xx = x + xy[i][0];
11277 int yy = y + xy[i][1];
11279 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11280 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
11282 int dir = MV_DIR_FROM_BIT(i);
11283 int dir_opposite = MV_DIR_OPPOSITE(dir);
11284 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11285 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
11286 int last_direction_new = last_direction_old | dir_opposite;
11288 last_element_new = getSteel2FromOpenDirection(last_direction_new);
11294 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
11296 if (last_element_new != EL_UNDEFINED)
11297 MergeAndCloseNeighbourElements(x, y, &new_element,
11298 last_x, last_y, &last_element_new,
11299 getClosedSteel2, change_level);
11301 else if (IS_SP_CHIP(new_element))
11303 int last_element_new = EL_UNDEFINED;
11304 int direction = MV_NONE;
11307 // (do not keep existing directions, regardless of kind of old element)
11309 for (i = 0; i < NUM_DIRECTIONS; i++)
11311 int xx = x + xy[i][0];
11312 int yy = y + xy[i][1];
11314 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11315 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
11317 int dir = MV_DIR_FROM_BIT(i);
11318 int dir_opposite = MV_DIR_OPPOSITE(dir);
11319 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11320 int last_direction_old = getOpenDirectionFromChip(last_element_old);
11321 int last_direction_new = last_direction_old | dir_opposite;
11323 if (last_direction_old == MV_NONE)
11325 last_element_new = getChipFromOpenDirection(last_direction_new);
11328 else if (last_direction_old & (dir | dir_opposite))
11330 direction |= MV_DIR_OPPOSITE(last_direction_old);
11334 direction |= MV_DIR_OPPOSITE(dir);
11339 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
11341 if (last_element_new != EL_UNDEFINED)
11342 MergeAndCloseNeighbourElements(x, y, &new_element,
11343 last_x, last_y, &last_element_new,
11344 getClosedChip, change_level);
11346 else if (IS_SP_HARDWARE_BASE(new_element))
11348 int nr = GetSimpleRandom(6);
11350 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
11351 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
11352 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
11353 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
11354 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
11356 else if (new_element == EL_SP_HARDWARE_GREEN ||
11357 new_element == EL_SP_HARDWARE_BLUE ||
11358 new_element == EL_SP_HARDWARE_RED)
11360 int nr = GetSimpleRandom(3);
11362 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
11363 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
11365 else if (IS_GROUP_ELEMENT(new_element))
11367 boolean connected_drawing = FALSE;
11370 for (i = 0; i < NUM_DIRECTIONS; i++)
11372 int xx = x + xy[i][0];
11373 int yy = y + xy[i][1];
11375 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11376 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
11377 connected_drawing = TRUE;
11380 if (!connected_drawing)
11381 ResolveGroupElement(new_element);
11383 new_element = GetElementFromGroupElement(new_element);
11385 else if (IS_BELT_SWITCH(old_element))
11387 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
11388 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
11390 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
11391 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
11393 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
11397 static int swappable_elements[][2] =
11399 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
11400 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
11401 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
11402 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
11403 { EL_EMERALD, EL_WALL_EMERALD },
11404 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
11405 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
11406 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
11407 { EL_DIAMOND, EL_WALL_DIAMOND },
11408 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
11409 { EL_GATE_1, EL_GATE_1_GRAY },
11410 { EL_GATE_2, EL_GATE_2_GRAY },
11411 { EL_GATE_3, EL_GATE_3_GRAY },
11412 { EL_GATE_4, EL_GATE_4_GRAY },
11413 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
11414 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
11415 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
11416 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
11417 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
11418 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
11419 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
11420 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
11421 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
11422 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
11423 { EL_LAMP, EL_LAMP_ACTIVE },
11424 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
11425 { EL_SP_BASE, EL_SP_BUGGY_BASE },
11426 { EL_PEARL, EL_WALL_PEARL },
11427 { EL_CRYSTAL, EL_WALL_CRYSTAL },
11428 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
11429 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
11430 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
11431 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
11432 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
11433 { EL_LANDMINE, EL_DC_LANDMINE },
11434 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
11435 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
11436 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
11437 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
11438 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
11439 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
11440 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
11441 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
11442 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
11446 static int rotatable_elements_4[][4] =
11456 EL_SPACESHIP_RIGHT,
11461 EL_BD_BUTTERFLY_UP,
11462 EL_BD_BUTTERFLY_RIGHT,
11463 EL_BD_BUTTERFLY_DOWN,
11464 EL_BD_BUTTERFLY_LEFT
11468 EL_BD_FIREFLY_RIGHT,
11469 EL_BD_FIREFLY_DOWN,
11497 EL_SP_GRAVITY_PORT_UP,
11498 EL_SP_GRAVITY_PORT_RIGHT,
11499 EL_SP_GRAVITY_PORT_DOWN,
11500 EL_SP_GRAVITY_PORT_LEFT
11503 EL_SP_GRAVITY_ON_PORT_UP,
11504 EL_SP_GRAVITY_ON_PORT_RIGHT,
11505 EL_SP_GRAVITY_ON_PORT_DOWN,
11506 EL_SP_GRAVITY_ON_PORT_LEFT
11509 EL_SP_GRAVITY_OFF_PORT_UP,
11510 EL_SP_GRAVITY_OFF_PORT_RIGHT,
11511 EL_SP_GRAVITY_OFF_PORT_DOWN,
11512 EL_SP_GRAVITY_OFF_PORT_LEFT
11521 EL_BALLOON_SWITCH_UP,
11522 EL_BALLOON_SWITCH_RIGHT,
11523 EL_BALLOON_SWITCH_DOWN,
11524 EL_BALLOON_SWITCH_LEFT
11528 EL_MM_MCDUFFIN_RIGHT,
11529 EL_MM_MCDUFFIN_DOWN,
11530 EL_MM_MCDUFFIN_LEFT
11533 EL_MM_MIRROR_FIXED_1,
11534 EL_MM_MIRROR_FIXED_4,
11535 EL_MM_MIRROR_FIXED_3,
11536 EL_MM_MIRROR_FIXED_2
11539 EL_MM_STEEL_GRID_FIXED_1,
11540 EL_MM_STEEL_GRID_FIXED_4,
11541 EL_MM_STEEL_GRID_FIXED_2,
11542 EL_MM_STEEL_GRID_FIXED_3
11545 EL_MM_WOODEN_GRID_FIXED_1,
11546 EL_MM_WOODEN_GRID_FIXED_4,
11547 EL_MM_WOODEN_GRID_FIXED_2,
11548 EL_MM_WOODEN_GRID_FIXED_3
11551 EL_MM_POLARIZER_CROSS_1,
11552 EL_MM_POLARIZER_CROSS_4,
11553 EL_MM_POLARIZER_CROSS_3,
11554 EL_MM_POLARIZER_CROSS_2
11558 EL_MM_PACMAN_RIGHT,
11570 EL_DF_RECEIVER_RIGHT,
11571 EL_DF_RECEIVER_DOWN,
11572 EL_DF_RECEIVER_LEFT
11579 static int rotatable_elements_8[][8] =
11582 EL_DF_STEEL_GRID_FIXED_1,
11583 EL_DF_STEEL_GRID_FIXED_8,
11584 EL_DF_STEEL_GRID_FIXED_7,
11585 EL_DF_STEEL_GRID_FIXED_6,
11586 EL_DF_STEEL_GRID_FIXED_5,
11587 EL_DF_STEEL_GRID_FIXED_4,
11588 EL_DF_STEEL_GRID_FIXED_3,
11589 EL_DF_STEEL_GRID_FIXED_2
11592 EL_DF_WOODEN_GRID_FIXED_1,
11593 EL_DF_WOODEN_GRID_FIXED_8,
11594 EL_DF_WOODEN_GRID_FIXED_7,
11595 EL_DF_WOODEN_GRID_FIXED_6,
11596 EL_DF_WOODEN_GRID_FIXED_5,
11597 EL_DF_WOODEN_GRID_FIXED_4,
11598 EL_DF_WOODEN_GRID_FIXED_3,
11599 EL_DF_WOODEN_GRID_FIXED_2
11602 EL_DF_STEEL_GRID_ROTATING_1,
11603 EL_DF_STEEL_GRID_ROTATING_8,
11604 EL_DF_STEEL_GRID_ROTATING_7,
11605 EL_DF_STEEL_GRID_ROTATING_6,
11606 EL_DF_STEEL_GRID_ROTATING_5,
11607 EL_DF_STEEL_GRID_ROTATING_4,
11608 EL_DF_STEEL_GRID_ROTATING_3,
11609 EL_DF_STEEL_GRID_ROTATING_2
11612 EL_DF_WOODEN_GRID_ROTATING_1,
11613 EL_DF_WOODEN_GRID_ROTATING_8,
11614 EL_DF_WOODEN_GRID_ROTATING_7,
11615 EL_DF_WOODEN_GRID_ROTATING_6,
11616 EL_DF_WOODEN_GRID_ROTATING_5,
11617 EL_DF_WOODEN_GRID_ROTATING_4,
11618 EL_DF_WOODEN_GRID_ROTATING_3,
11619 EL_DF_WOODEN_GRID_ROTATING_2
11626 static int rotatable_elements_16[][16] =
11647 EL_MM_TELEPORTER_5,
11648 EL_MM_TELEPORTER_4,
11649 EL_MM_TELEPORTER_3,
11650 EL_MM_TELEPORTER_2,
11651 EL_MM_TELEPORTER_1,
11652 EL_MM_TELEPORTER_16,
11653 EL_MM_TELEPORTER_15,
11654 EL_MM_TELEPORTER_14,
11655 EL_MM_TELEPORTER_13,
11656 EL_MM_TELEPORTER_12,
11657 EL_MM_TELEPORTER_11,
11658 EL_MM_TELEPORTER_10,
11659 EL_MM_TELEPORTER_9,
11660 EL_MM_TELEPORTER_8,
11661 EL_MM_TELEPORTER_7,
11665 EL_MM_TELEPORTER_RED_5,
11666 EL_MM_TELEPORTER_RED_4,
11667 EL_MM_TELEPORTER_RED_3,
11668 EL_MM_TELEPORTER_RED_2,
11669 EL_MM_TELEPORTER_RED_1,
11670 EL_MM_TELEPORTER_RED_16,
11671 EL_MM_TELEPORTER_RED_15,
11672 EL_MM_TELEPORTER_RED_14,
11673 EL_MM_TELEPORTER_RED_13,
11674 EL_MM_TELEPORTER_RED_12,
11675 EL_MM_TELEPORTER_RED_11,
11676 EL_MM_TELEPORTER_RED_10,
11677 EL_MM_TELEPORTER_RED_9,
11678 EL_MM_TELEPORTER_RED_8,
11679 EL_MM_TELEPORTER_RED_7,
11680 EL_MM_TELEPORTER_RED_6
11683 EL_MM_TELEPORTER_YELLOW_5,
11684 EL_MM_TELEPORTER_YELLOW_4,
11685 EL_MM_TELEPORTER_YELLOW_3,
11686 EL_MM_TELEPORTER_YELLOW_2,
11687 EL_MM_TELEPORTER_YELLOW_1,
11688 EL_MM_TELEPORTER_YELLOW_16,
11689 EL_MM_TELEPORTER_YELLOW_15,
11690 EL_MM_TELEPORTER_YELLOW_14,
11691 EL_MM_TELEPORTER_YELLOW_13,
11692 EL_MM_TELEPORTER_YELLOW_12,
11693 EL_MM_TELEPORTER_YELLOW_11,
11694 EL_MM_TELEPORTER_YELLOW_10,
11695 EL_MM_TELEPORTER_YELLOW_9,
11696 EL_MM_TELEPORTER_YELLOW_8,
11697 EL_MM_TELEPORTER_YELLOW_7,
11698 EL_MM_TELEPORTER_YELLOW_6
11701 EL_MM_TELEPORTER_GREEN_5,
11702 EL_MM_TELEPORTER_GREEN_4,
11703 EL_MM_TELEPORTER_GREEN_3,
11704 EL_MM_TELEPORTER_GREEN_2,
11705 EL_MM_TELEPORTER_GREEN_1,
11706 EL_MM_TELEPORTER_GREEN_16,
11707 EL_MM_TELEPORTER_GREEN_15,
11708 EL_MM_TELEPORTER_GREEN_14,
11709 EL_MM_TELEPORTER_GREEN_13,
11710 EL_MM_TELEPORTER_GREEN_12,
11711 EL_MM_TELEPORTER_GREEN_11,
11712 EL_MM_TELEPORTER_GREEN_10,
11713 EL_MM_TELEPORTER_GREEN_9,
11714 EL_MM_TELEPORTER_GREEN_8,
11715 EL_MM_TELEPORTER_GREEN_7,
11716 EL_MM_TELEPORTER_GREEN_6
11719 EL_MM_TELEPORTER_BLUE_5,
11720 EL_MM_TELEPORTER_BLUE_4,
11721 EL_MM_TELEPORTER_BLUE_3,
11722 EL_MM_TELEPORTER_BLUE_2,
11723 EL_MM_TELEPORTER_BLUE_1,
11724 EL_MM_TELEPORTER_BLUE_16,
11725 EL_MM_TELEPORTER_BLUE_15,
11726 EL_MM_TELEPORTER_BLUE_14,
11727 EL_MM_TELEPORTER_BLUE_13,
11728 EL_MM_TELEPORTER_BLUE_12,
11729 EL_MM_TELEPORTER_BLUE_11,
11730 EL_MM_TELEPORTER_BLUE_10,
11731 EL_MM_TELEPORTER_BLUE_9,
11732 EL_MM_TELEPORTER_BLUE_8,
11733 EL_MM_TELEPORTER_BLUE_7,
11734 EL_MM_TELEPORTER_BLUE_6
11738 EL_MM_POLARIZER_16,
11739 EL_MM_POLARIZER_15,
11740 EL_MM_POLARIZER_14,
11741 EL_MM_POLARIZER_13,
11742 EL_MM_POLARIZER_12,
11743 EL_MM_POLARIZER_11,
11744 EL_MM_POLARIZER_10,
11773 EL_DF_MIRROR_ROTATING_1,
11774 EL_DF_MIRROR_ROTATING_16,
11775 EL_DF_MIRROR_ROTATING_15,
11776 EL_DF_MIRROR_ROTATING_14,
11777 EL_DF_MIRROR_ROTATING_13,
11778 EL_DF_MIRROR_ROTATING_12,
11779 EL_DF_MIRROR_ROTATING_11,
11780 EL_DF_MIRROR_ROTATING_10,
11781 EL_DF_MIRROR_ROTATING_9,
11782 EL_DF_MIRROR_ROTATING_8,
11783 EL_DF_MIRROR_ROTATING_7,
11784 EL_DF_MIRROR_ROTATING_6,
11785 EL_DF_MIRROR_ROTATING_5,
11786 EL_DF_MIRROR_ROTATING_4,
11787 EL_DF_MIRROR_ROTATING_3,
11788 EL_DF_MIRROR_ROTATING_2
11797 for (i = 0; swappable_elements[i][0] != -1; i++)
11799 int element1 = swappable_elements[i][0];
11800 int element2 = swappable_elements[i][1];
11802 if (old_element == element1 || old_element == element2)
11803 new_element = (old_element == element1 ? element2 : element1);
11806 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
11808 for (j = 0; j < 4; j++)
11810 int element = rotatable_elements_4[i][j];
11812 if (old_element == element)
11813 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
11814 button == 2 ? rotatable_elements_4[i][0] :
11815 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
11820 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
11822 for (j = 0; j < 8; j++)
11824 int element = rotatable_elements_8[i][j];
11826 if (old_element == element)
11827 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
11828 button == 2 ? rotatable_elements_8[i][0] :
11829 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
11834 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
11836 for (j = 0; j < 16; j++)
11838 int element = rotatable_elements_16[i][j];
11840 if (old_element == element)
11841 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
11842 button == 2 ? rotatable_elements_16[i][0] :
11843 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
11848 if (old_element != new_element)
11850 int max_infotext_len = getMaxInfoTextLength();
11851 char infotext[MAX_OUTPUT_LINESIZE + 1];
11853 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
11854 infotext[max_infotext_len] = '\0';
11856 ClearEditorGadgetInfoText();
11858 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
11863 SetElementSimple(x, y, new_element, change_level);
11869 static void ResetIntelliDraw(void)
11873 for (x = 0; x < lev_fieldx; x++)
11874 for (y = 0; y < lev_fieldy; y++)
11875 IntelliDrawBuffer[x][y] = Tile[x][y];
11877 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
11880 static boolean draw_mode_hires = FALSE;
11882 static boolean isHiresTileElement(int element)
11884 return (IS_MM_WALL(element) || element == EL_EMPTY);
11887 static boolean isHiresDrawElement(int element)
11889 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
11892 static void SetDrawModeHiRes(int element)
11895 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
11896 isHiresDrawElement(element));
11899 static boolean getDrawModeHiRes(void)
11901 return draw_mode_hires;
11904 static int getLoResScreenPos(int pos)
11906 return (getDrawModeHiRes() ? pos / 2 : pos);
11909 static int getLoResScreenMod(int pos)
11911 return (getDrawModeHiRes() ? pos % 2 : 0);
11914 static void SetElementExt(int x, int y, int dx, int dy, int element,
11915 boolean change_level, int button)
11918 SetElementSimple(x, y, Tile[x][y], change_level);
11919 else if (GetKeyModState() & KMOD_Shift && !IS_MM_WALL_EDITOR(element))
11920 SetElementIntelliDraw(x, y, element, change_level, button);
11922 SetElementSimpleExt(x, y, dx, dy, element, change_level);
11925 static void SetElement(int x, int y, int element)
11927 SetElementExt(x, y, 0, 0, element, TRUE, -1);
11930 static void SetElementButton(int x, int y, int dx, int dy, int element,
11933 SetElementExt(x, y, dx, dy, element, TRUE, button);
11936 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
11938 int lx = getLoResScreenPos(sx2) + level_xpos;
11939 int ly = getLoResScreenPos(sy2) + level_ypos;
11940 int dx = getLoResScreenMod(sx2);
11941 int dy = getLoResScreenMod(sy2);
11943 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
11946 static void SetLevelElementHiRes(int lx2, int ly2, int element)
11953 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
11956 static int getLevelElementHiRes(int lx2, int ly2)
11962 int element = Tile[lx][ly];
11963 unsigned int bitmask = (dx + 1) << (dy * 2);
11965 if (IS_MM_WALL(element))
11967 if (element & bitmask)
11968 return map_mm_wall_element(element);
11976 static void DrawLineElement(int x, int y, int element, boolean change_level)
11978 SetElementHiRes(x, y, element, change_level);
11981 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
11982 int element, boolean change_level)
11984 int xsize = ABS(to_x - from_x);
11985 int ysize = ABS(to_y - from_y);
11986 int dx = (to_x < from_x ? -1 : +1);
11987 int dy = (to_y < from_y ? -1 : +1);
11990 if (from_y == to_y) // horizontal line
11992 for (i = 0; i <= xsize; i++)
11993 DrawLineElement(from_x + i * dx, from_y, element, change_level);
11995 else if (from_x == to_x) // vertical line
11997 for (i = 0; i <= ysize; i++)
11998 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12000 else // diagonal line
12002 if (ysize < xsize) // a < 1
12004 float a = (float)ysize / (float)xsize;
12006 for (i = 0; i <= xsize; i++)
12009 int y = dy * (int)(a * i + 0.5);
12011 DrawLineElement(from_x + x, from_y + y, element, change_level);
12016 float a = (float)xsize / (float)ysize;
12018 for (i = 0; i <= ysize; i++)
12020 int x = dx * (int)(a * i + 0.5);
12023 DrawLineElement(from_x + x, from_y + y, element, change_level);
12029 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12030 int element, boolean change_level)
12032 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12033 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12034 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12035 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12038 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12039 int element, boolean change_level)
12044 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12046 for (y = from_y; y <= to_y; y++)
12047 DrawLine(from_x, y, to_x, y, element, change_level);
12050 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12051 int element, boolean change_level)
12053 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12054 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12055 int len_x = ABS(to_x - from_x);
12056 int len_y = ABS(to_y - from_y);
12059 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
12061 // not optimal (some points get drawn twice) but simple,
12062 // and fast enough for the few points we are drawing
12064 for (x = 0; x <= radius; x++)
12066 int sx, sy, sx2, sy2, lx, ly;
12068 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
12070 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12071 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12072 sx = getLoResScreenPos(sx2);
12073 sy = getLoResScreenPos(sy2);
12074 lx = sx + level_xpos;
12075 ly = sy + level_ypos;
12077 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12078 DrawLineElement(sx2, sy2, element, change_level);
12081 for (y = 0; y <= radius; y++)
12083 int sx, sy, sx2, sy2, lx, ly;
12085 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
12087 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12088 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12089 sx = getLoResScreenPos(sx2);
12090 sy = getLoResScreenPos(sy2);
12091 lx = sx + level_xpos;
12092 ly = sy + level_ypos;
12094 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12095 DrawLineElement(sx2, sy2, element, change_level);
12099 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
12100 int element, boolean change_level)
12102 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12103 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12105 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12108 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
12110 #if DRAW_CIRCLES_BUTTON_AVAILABLE
12111 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
12112 int element, boolean change_level)
12114 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12115 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12116 int mirror_to_x2 = from_x - (to_x2 - from_x);
12117 int mirror_to_y2 = from_y - (to_y2 - from_y);
12119 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12120 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
12121 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
12122 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
12126 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
12128 int from_sx, from_sy;
12132 swap_numbers(&from_x, &to_x);
12135 swap_numbers(&from_y, &to_y);
12137 from_sx = SX + from_x * ed_tilesize;
12138 from_sy = SY + from_y * ed_tilesize;
12139 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
12140 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
12142 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12143 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12144 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12145 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12147 if (from_x == to_x && from_y == to_y)
12148 MarkTileDirty(from_x/2, from_y/2);
12150 redraw_mask |= REDRAW_FIELD;
12153 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
12154 int element, boolean change_level)
12156 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
12159 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
12160 int element, boolean change_level)
12162 if (element == -1 || change_level)
12163 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
12165 DrawAreaBorder(from_x, from_y, to_x, to_y);
12168 // values for CopyBrushExt()
12169 #define CB_AREA_TO_BRUSH 0
12170 #define CB_BRUSH_TO_CURSOR 1
12171 #define CB_BRUSH_TO_LEVEL 2
12172 #define CB_DELETE_OLD_CURSOR 3
12173 #define CB_DUMP_BRUSH 4
12174 #define CB_DUMP_BRUSH_SMALL 5
12175 #define CB_CLIPBOARD_TO_BRUSH 6
12176 #define CB_BRUSH_TO_CLIPBOARD 7
12177 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
12178 #define CB_UPDATE_BRUSH_POSITION 9
12180 #define MAX_CB_PART_SIZE 10
12181 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
12182 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
12183 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
12184 MAX_CB_NUM_LINES * \
12187 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
12189 DrawLineElement(sx, sy, element, change_level);
12192 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
12193 int button, int mode)
12195 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12196 static int brush_width, brush_height;
12197 static int last_cursor_x = -1, last_cursor_y = -1;
12198 static boolean delete_old_brush = FALSE;
12199 int new_element = BUTTON_ELEMENT(button);
12202 if (mode == CB_DUMP_BRUSH ||
12203 mode == CB_DUMP_BRUSH_SMALL ||
12204 mode == CB_BRUSH_TO_CLIPBOARD ||
12205 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12207 if (edit_mode != ED_MODE_DRAWING)
12210 char part[MAX_CB_PART_SIZE + 1] = "";
12211 char text[MAX_CB_TEXT_SIZE + 1] = "";
12212 int width = (draw_with_brush ? brush_width : lev_fieldx);
12213 int height = (draw_with_brush ? brush_height : lev_fieldy);
12214 char *format = "%s%03d";
12216 for (y = 0; y < height; y++)
12217 for (x = 0; x < width; x++)
12218 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
12221 for (y = 0; y < height; y++)
12223 for (x = 0; x < width; x++)
12225 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
12226 char *prefix = (mode == CB_DUMP_BRUSH ||
12227 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
12229 if (element >= NUM_FILE_ELEMENTS)
12230 element = EL_UNKNOWN;
12232 // copy brush to level sketch text buffer for the R'n'D forum:
12233 // - large tiles: `xxx or `xxxx (0x60 ASCII)
12234 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
12235 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
12236 strcat(text, part);
12239 strcat(text, "\n");
12242 if (mode == CB_BRUSH_TO_CLIPBOARD ||
12243 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12244 SDL_SetClipboardText(text);
12246 Print("%s", text); // print brush data to console and log file
12251 if (mode == CB_CLIPBOARD_TO_BRUSH)
12253 if (edit_mode != ED_MODE_DRAWING)
12256 if (!SDL_HasClipboardText())
12258 Request("Clipboard is empty!", REQ_CONFIRM);
12263 boolean copy_to_brush = (draw_with_brush ||
12264 drawing_function == GADGET_ID_GRAB_BRUSH);
12266 // this will delete the old brush, if already drawing with a brush
12268 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
12270 // initialization is required for "odd" (incomplete) clipboard content
12271 for (x = 0; x < MAX_LEV_FIELDX; x++)
12272 for (y = 0; y < MAX_LEV_FIELDY; y++)
12273 brush_buffer[x][y] = EL_EMPTY;
12280 char *clipboard_text = SDL_GetClipboardText();
12281 char *ptr = clipboard_text;
12282 boolean allow_new_row = FALSE;
12283 boolean stop = FALSE;
12285 while (*ptr && !stop)
12287 boolean prefix_found = FALSE;
12288 boolean start_new_row = FALSE;
12290 // level sketch element number prefixes (may be multi-byte characters)
12291 char *prefix_list[] = { "`", "¸" };
12294 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
12296 char *prefix = prefix_list[i];
12298 // check if string is large enough for prefix
12299 if (strlen(ptr) < strlen(prefix))
12306 // check if string starts with prefix
12307 if (strPrefix(ptr, prefix))
12309 ptr += strlen(prefix);
12311 prefix_found = TRUE;
12317 // check if prefix found and followed by (at least) three digits
12318 if (prefix_found &&
12319 strlen(ptr) >= 3 &&
12320 ptr[0] >= '0' && ptr[0] <= '9' &&
12321 ptr[1] >= '0' && ptr[1] <= '9' &&
12322 ptr[2] >= '0' && ptr[2] <= '9')
12324 int element = ((ptr[0] - '0') * 100 +
12325 (ptr[1] - '0') * 10 +
12330 // level sketch element number might consist of four digits
12331 if (ptr[0] >= '0' && ptr[0] <= '9')
12333 element = element * 10 + (ptr[0] - '0');
12337 // remap some (historic, now obsolete) elements
12338 element = getMappedElement(element);
12340 if (element >= NUM_FILE_ELEMENTS)
12341 element = EL_UNKNOWN;
12343 brush_buffer[x][y] = element;
12345 brush_width = MAX(x + 1, brush_width);
12346 brush_height = MAX(y + 1, brush_height);
12350 if (x >= MAX_LEV_FIELDX)
12351 start_new_row = TRUE;
12353 allow_new_row = TRUE;
12357 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
12358 start_new_row = TRUE;
12360 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
12368 if (y >= MAX_LEV_FIELDY)
12371 allow_new_row = FALSE;
12375 SDL_free(clipboard_text);
12377 if (brush_width == 0 || brush_height == 0)
12379 Request("No level sketch found in clipboard!", REQ_CONFIRM);
12386 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
12389 SDL_GetMouseState(&mx, &my);
12391 // if inside drawing area, activate and draw brush at last mouse position
12392 if (mx >= gi->x && mx < gi->x + gi->width &&
12393 my >= gi->y && my < gi->y + gi->height)
12394 CopyBrushToCursor(last_cursor_x, last_cursor_y);
12396 draw_with_brush = TRUE;
12402 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
12403 brush_width, brush_height);
12405 if (!Request(request, REQ_ASK))
12408 for (x = 0; x < MAX_LEV_FIELDX; x++)
12409 for (y = 0; y < MAX_LEV_FIELDY; y++)
12410 Tile[x][y] = brush_buffer[x][y];
12412 lev_fieldx = level.fieldx = brush_width;
12413 lev_fieldy = level.fieldy = brush_height;
12415 boolean use_em_engine = TRUE;
12416 boolean use_sp_engine = TRUE;
12417 boolean use_mm_engine = TRUE;
12419 for (x = 0; x < MAX_LEV_FIELDX; x++)
12421 for (y = 0; y < MAX_LEV_FIELDY; y++)
12423 int element = Tile[x][y];
12425 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
12426 use_em_engine = FALSE;
12428 if (!IS_SP_ELEMENT(element))
12429 use_sp_engine = FALSE;
12431 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
12432 use_mm_engine = FALSE;
12436 level.game_engine_type = (use_em_engine ? GAME_ENGINE_TYPE_EM :
12437 use_sp_engine ? GAME_ENGINE_TYPE_SP :
12438 use_mm_engine ? GAME_ENGINE_TYPE_MM :
12439 GAME_ENGINE_TYPE_RND);
12441 // update element selection list
12442 ReinitializeElementList();
12443 ModifyEditorElementList();
12445 SetBorderElement();
12447 DrawEditModeWindow();
12448 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12454 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
12457 if (mode == CB_AREA_TO_BRUSH)
12459 int from_lx, from_ly;
12462 swap_numbers(&from_x, &to_x);
12465 swap_numbers(&from_y, &to_y);
12467 brush_width = to_x - from_x + 1;
12468 brush_height = to_y - from_y + 1;
12470 from_lx = from_x + level_xpos;
12471 from_ly = from_y + level_ypos;
12473 for (y = 0; y < brush_height; y++)
12475 for (x = 0; x < brush_width; x++)
12477 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
12480 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
12485 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12487 delete_old_brush = FALSE;
12489 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
12490 mode == CB_BRUSH_TO_LEVEL)
12492 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
12493 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
12494 int cursor_from_x = cursor_x - brush_width / 2;
12495 int cursor_from_y = cursor_y - brush_height / 2;
12496 int border_from_x = cursor_x, border_from_y = cursor_y;
12497 int border_to_x = cursor_x, border_to_y = cursor_y;
12499 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
12500 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12502 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
12503 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
12505 delete_old_brush = FALSE;
12510 for (y = 0; y < brush_height; y++)
12512 for (x = 0; x < brush_width; x++)
12514 int sx = cursor_from_x + x;
12515 int sy = cursor_from_y + y;
12516 int lx = sx + level_xpos;
12517 int ly = sy + level_ypos;
12518 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
12519 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
12520 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
12521 brush_buffer[x][y] : new_element);
12523 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12525 if (sx < border_from_x)
12526 border_from_x = sx;
12527 else if (sx > border_to_x)
12529 if (sy < border_from_y)
12530 border_from_y = sy;
12531 else if (sy > border_to_y)
12534 DrawBrushElement(sx, sy, element, change_level);
12539 if (mode != CB_DELETE_OLD_CURSOR)
12540 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
12542 last_cursor_x = cursor_x;
12543 last_cursor_y = cursor_y;
12545 delete_old_brush = TRUE;
12548 if (mode == CB_UPDATE_BRUSH_POSITION)
12550 last_cursor_x = from_x;
12551 last_cursor_y = from_y;
12555 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
12558 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
12561 static void CopyBrushToLevel(int x, int y, int button)
12563 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
12566 static void CopyBrushToCursor(int x, int y)
12568 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
12571 static void UpdateBrushPosition(int x, int y)
12573 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
12576 static void DeleteBrushFromCursor(void)
12578 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12581 void DumpBrush(void)
12583 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
12586 void DumpBrush_Small(void)
12588 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
12591 void CopyClipboardToBrush(void)
12593 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
12596 void CopyBrushToClipboard(void)
12598 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
12601 void CopyBrushToClipboard_Small(void)
12603 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
12606 void UndoLevelEditorOperation(void)
12608 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
12611 void RedoLevelEditorOperation(void)
12613 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
12616 static void FloodFill(int from_x, int from_y, int fill_element)
12618 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
12621 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
12623 int from_x = from_sx2 + 2 * level_xpos;
12624 int from_y = from_sy2 + 2 * level_ypos;
12625 int max_fillx = lev_fieldx * 2;
12626 int max_filly = lev_fieldy * 2;
12627 short Fill[max_fillx][max_filly];
12630 for (x = 0; x < max_fillx; x++)
12631 for (y = 0; y < max_filly; y++)
12632 Fill[x][y] = getLevelElementHiRes(x, y);
12634 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
12635 Fill, max_fillx, max_filly);
12637 for (x = 0; x < max_fillx; x++)
12638 for (y = 0; y < max_filly; y++)
12639 if (Fill[x][y] == fill_element)
12640 SetLevelElementHiRes(x, y, Fill[x][y]);
12643 // values for DrawLevelText() modes
12644 #define TEXT_INIT 0
12645 #define TEXT_SETCURSOR 1
12646 #define TEXT_WRITECHAR 2
12647 #define TEXT_BACKSPACE 3
12648 #define TEXT_NEWLINE 4
12650 #define TEXT_QUERY_TYPING 6
12652 static int DrawLevelText(int sx, int sy, char letter, int mode)
12654 static short delete_buffer[MAX_LEV_FIELDX];
12655 static int start_sx;
12656 static int last_sx, last_sy;
12657 static boolean typing = FALSE;
12658 int letter_element = EL_CHAR_ASCII0 + letter;
12659 int lx = 0, ly = 0;
12661 // map lower case letters to upper case and convert special characters
12662 if (letter >= 'a' && letter <= 'z')
12663 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
12664 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
12665 letter_element = EL_CHAR_AUMLAUT;
12666 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
12667 letter_element = EL_CHAR_OUMLAUT;
12668 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
12669 letter_element = EL_CHAR_UUMLAUT;
12670 else if (letter == '^')
12671 letter_element = EL_CHAR_COPYRIGHT;
12673 letter_element = EL_CHAR_ASCII0 + letter;
12675 if (mode != TEXT_INIT)
12680 if (mode != TEXT_SETCURSOR)
12686 lx = last_sx + level_xpos;
12687 ly = last_sy + level_ypos;
12694 DrawLevelText(0, 0, 0, TEXT_END);
12700 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
12703 case TEXT_SETCURSOR:
12704 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
12705 DrawAreaBorder(sx, sy, sx, sy);
12706 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
12707 ed_tilesize, ed_tilesize);
12712 case TEXT_WRITECHAR:
12713 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
12715 if (new_element1 >= EL_STEEL_CHAR_START &&
12716 new_element1 <= EL_STEEL_CHAR_END)
12717 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
12719 delete_buffer[sx - start_sx] = Tile[lx][ly];
12720 Tile[lx][ly] = letter_element;
12722 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
12723 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
12724 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12725 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12727 DrawLevelText(0, 0, 0, TEXT_END);
12729 level.changed = TRUE;
12733 case TEXT_BACKSPACE:
12736 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
12737 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
12738 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
12743 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12744 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12746 DrawLevelText(0, 0, 0, TEXT_END);
12750 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12751 DrawEditorElement(sx, sy, Tile[lx][ly]);
12756 case TEXT_QUERY_TYPING:
12766 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
12767 int element, boolean change_level)
12769 int lx = sx + level_xpos;
12770 int ly = sy + level_ypos;
12773 DrawEditorElement(sx, sy, Tile[lx][ly]);
12775 DrawAreaBorder(sx, sy, sx, sy);
12778 static void CheckLevelBorderElement(boolean redraw_playfield)
12780 int last_border_element = BorderElement;
12782 SetBorderElement();
12784 if (redraw_playfield && BorderElement != last_border_element)
12785 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12788 static void CopyLevelToUndoBuffer(int mode)
12790 static boolean accumulated_undo = FALSE;
12791 boolean new_undo_buffer_position = TRUE;
12794 if (undo_buffer_steps == 0)
12795 accumulated_undo = FALSE;
12799 case UNDO_IMMEDIATE:
12800 accumulated_undo = FALSE;
12803 case UNDO_ACCUMULATE:
12804 if (accumulated_undo)
12805 new_undo_buffer_position = FALSE;
12806 accumulated_undo = TRUE;
12813 if (new_undo_buffer_position)
12815 // advance position in undo buffer ring
12816 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
12818 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
12819 undo_buffer_steps++;
12822 // always reset redo buffer when storing level change into undo buffer
12823 redo_buffer_steps = 0;
12825 for (x = 0; x < lev_fieldx; x++)
12826 for (y = 0; y < lev_fieldy; y++)
12827 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
12829 // check if drawing operation forces change of border style
12830 CheckLevelBorderElement(TRUE);
12832 level.changed = TRUE;
12835 static void RandomPlacement(int new_element)
12837 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12838 int num_free_positions = 0;
12839 int num_percentage, num_elements;
12842 ResetIntelliDraw();
12844 // determine number of free positions for randomly placing the new element
12845 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
12847 free_position[x][y] =
12848 (random_placement_background_restricted ?
12849 Tile[x][y] == random_placement_background_element :
12850 Tile[x][y] != new_element);
12852 if (free_position[x][y])
12853 num_free_positions++;
12856 // determine number of new elements to place there
12857 num_percentage = num_free_positions * random_placement_value / 100;
12858 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
12859 num_percentage : random_placement_value);
12861 // if less free positions than elements to place, fill all these positions
12862 if (num_free_positions < num_elements)
12864 for (x = 0; x < lev_fieldx; x++)
12865 for (y = 0; y < lev_fieldy; y++)
12866 if (free_position[x][y])
12867 SetElement(x, y, new_element);
12871 while (num_elements > 0)
12873 x = GetSimpleRandom(lev_fieldx);
12874 y = GetSimpleRandom(lev_fieldy);
12876 // don't place element at the same position twice
12877 if (free_position[x][y])
12879 free_position[x][y] = FALSE;
12880 SetElement(x, y, new_element);
12886 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12887 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12890 static void WrapLevel(int dx, int dy)
12892 int wrap_dx = lev_fieldx - dx;
12893 int wrap_dy = lev_fieldy - dy;
12896 for (x = 0; x < lev_fieldx; x++)
12897 for (y = 0; y < lev_fieldy; y++)
12898 TileBackup[x][y] = Tile[x][y];
12900 for (x = 0; x < lev_fieldx; x++)
12901 for (y = 0; y < lev_fieldy; y++)
12903 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
12905 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12906 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
12909 static void DrawAreaElementHighlight(boolean highlighted)
12911 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12918 for (x = 0; x < ed_fieldx; x++)
12920 for (y = 0; y < ed_fieldy; y++)
12922 int lx = x + level_xpos;
12923 int ly = y + level_ypos;
12925 if (!IN_LEV_FIELD(lx, ly))
12928 if (Tile[lx][ly] != new_element1)
12931 int sx = SX + x * ed_tilesize;
12932 int sy = SY + y * ed_tilesize;
12935 int to_sx = sx + ed_tilesize - 1;
12936 int to_sy = sy + ed_tilesize - 1;
12938 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12939 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12940 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12941 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12946 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
12948 char *template_filename_old = getLocalLevelTemplateFilename();
12949 char *template_filename_new =
12950 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
12952 if (copyFile(template_filename_old, template_filename_new) != 0)
12953 Request("Cannot copy level template!", REQ_CONFIRM);
12955 free(template_filename_new);
12958 static void HandleDrawingAreas(struct GadgetInfo *gi)
12960 static boolean started_inside_drawing_area = FALSE;
12961 static int last_sx = -1, last_sy = -1;
12962 static int last_sx2 = -1, last_sy2 = -1;
12963 int id = gi->custom_id;
12964 int type_id = gi->custom_type_id;
12965 boolean button_press_event;
12966 boolean button_release_event;
12967 boolean inside_drawing_area = !gi->event.off_borders;
12968 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
12969 int actual_drawing_function;
12970 int button = gi->event.button;
12971 int new_element = BUTTON_ELEMENT(button);
12972 int sx = gi->event.x, sy = gi->event.y;
12973 int min_sx = 0, min_sy = 0;
12974 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
12975 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
12976 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
12977 int sx2 = gi->event.mx / mini_item_xsize;
12978 int sy2 = gi->event.my / mini_item_ysize;
12981 int lx = 0, ly = 0;
12982 int min_lx = 0, min_ly = 0;
12983 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
12986 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
12987 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
12989 // make sure to stay inside drawing area boundaries
12990 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
12991 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
12995 // get positions inside level field
12996 lx = sx + level_xpos;
12997 ly = sy + level_ypos;
12999 if (!IN_LEV_FIELD(lx, ly))
13000 inside_drawing_area = FALSE;
13002 // make sure to stay inside level field boundaries
13003 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
13004 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
13006 // correct drawing area positions accordingly
13007 sx = lx - level_xpos;
13008 sy = ly - level_ypos;
13011 // also correct MM wall-sized (double) drawing area positions accordingly
13012 if (sx2 / 2 < sx || sx2 / 2 > sx)
13014 dx = (sx2 / 2 < sx ? 0 : 1);
13017 if (sy2 / 2 < sy || sy2 / 2 > sy)
13019 dy = (sy2 / 2 < sy ? 0 : 1);
13023 if (button_release_event)
13030 else if (!button_press_event)
13032 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
13033 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
13034 isHiresTileElement(old_element) &&
13035 isHiresDrawElement(new_element));
13037 // prevent handling events for every pixel position when moving mouse
13038 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
13039 (sx2 == last_sx2 && sy2 == last_sy2))
13048 if (button_press_event)
13049 started_inside_drawing_area = inside_drawing_area;
13051 if (!started_inside_drawing_area)
13054 if (!IS_VALID_BUTTON(button))
13057 if (!button && !button_release_event)
13060 // handle info callback for each invocation of action callback
13061 gi->callback_info(gi);
13063 // automatically switch to 'single item' drawing mode, if needed
13064 actual_drawing_function =
13065 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
13066 drawing_function : GADGET_ID_SINGLE_ITEMS);
13068 // clicking into drawing area with pressed Control key picks element
13069 if (GetKeyModState() & KMOD_Control)
13071 last_drawing_function = drawing_function;
13072 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
13075 if (GetKeyModState() & KMOD_Shift)
13077 if (button_press_event || button_release_event)
13078 ResetIntelliDraw();
13081 SetDrawModeHiRes(-1); // reset to normal draw mode
13083 switch (actual_drawing_function)
13085 case GADGET_ID_SINGLE_ITEMS:
13088 if (button_release_event)
13090 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13092 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
13093 !inside_drawing_area)
13094 DeleteBrushFromCursor();
13097 if (!button || button_release_event)
13100 if (draw_with_brush)
13102 CopyBrushToLevel(sx, sy, button);
13106 SetDrawModeHiRes(new_element);
13108 if (IS_PLAYER_ELEMENT(new_element))
13110 // remove player at old position
13111 for (y = 0; y < lev_fieldy; y++)
13113 for (x = 0; x < lev_fieldx; x++)
13115 int old_element = Tile[x][y];
13117 if (IS_PLAYER_ELEMENT(old_element))
13119 int replaced_with_element =
13120 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
13121 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
13123 old_element == EL_SOKOBAN_FIELD_PLAYER &&
13124 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
13126 new_element == EL_SOKOBAN_FIELD_PLAYER &&
13127 old_element == EL_PLAYER_1 ? EL_EMPTY :
13129 new_element >= EL_PLAYER_1 &&
13130 new_element <= EL_PLAYER_4 &&
13131 new_element == old_element ? EL_EMPTY :
13135 SetElement(x, y, replaced_with_element);
13141 SetElementButton(lx, ly, dx, dy, new_element, button);
13144 else if (!button_release_event)
13146 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13148 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
13149 DrawMiniGraphicExt(drawto,
13150 gi->x + sx * MINI_TILEX,
13151 gi->y + sy * MINI_TILEY,
13152 el2edimg(new_element));
13154 DrawFixedGraphicExt(drawto,
13155 gi->x + sx * TILEX,
13156 gi->y + sy * TILEY,
13157 el2edimg(new_element), 0);
13159 if (id == GADGET_ID_CUSTOM_GRAPHIC)
13160 new_element = GFX_ELEMENT(new_element);
13162 drawingarea_info[type_id].value[pos] = new_element;
13164 CopyElementPropertiesToGame(properties_element);
13166 if (id == GADGET_ID_CUSTOM_GRAPHIC)
13168 UpdateCustomElementGraphicGadgets();
13170 FrameCounter = 0; // restart animation frame counter
13175 case GADGET_ID_CONNECTED_ITEMS:
13177 static int last_sx = -1;
13178 static int last_sy = -1;
13180 if (button_release_event)
13181 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13185 SetDrawModeHiRes(new_element);
13187 if (getDrawModeHiRes())
13193 if (!button_press_event)
13194 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
13202 case GADGET_ID_LINE:
13203 case GADGET_ID_ARC:
13204 case GADGET_ID_RECTANGLE:
13205 case GADGET_ID_FILLED_BOX:
13206 SetDrawModeHiRes(new_element);
13208 if (getDrawModeHiRes())
13214 case GADGET_ID_GRAB_BRUSH:
13215 case GADGET_ID_TEXT:
13217 static int last_sx = -1;
13218 static int last_sy = -1;
13219 static int start_sx = -1;
13220 static int start_sy = -1;
13221 void (*draw_func)(int, int, int, int, int, boolean);
13223 if (drawing_function == GADGET_ID_LINE)
13224 draw_func = DrawLine;
13225 else if (drawing_function == GADGET_ID_ARC)
13226 draw_func = DrawArc;
13227 else if (drawing_function == GADGET_ID_RECTANGLE)
13228 draw_func = DrawBox;
13229 else if (drawing_function == GADGET_ID_FILLED_BOX)
13230 draw_func = DrawFilledBox;
13231 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
13232 draw_func = SelectArea;
13233 else // (drawing_function == GADGET_ID_TEXT)
13234 draw_func = SetTextCursor;
13236 if (button_press_event)
13238 draw_func(sx, sy, sx, sy, new_element, FALSE);
13239 start_sx = last_sx = sx;
13240 start_sy = last_sy = sy;
13242 if (drawing_function == GADGET_ID_TEXT)
13243 DrawLevelText(0, 0, 0, TEXT_END);
13245 else if (button_release_event)
13247 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
13248 if (drawing_function == GADGET_ID_GRAB_BRUSH)
13250 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
13251 CopyBrushToCursor(sx, sy);
13252 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
13254 draw_with_brush = TRUE;
13256 else if (drawing_function == GADGET_ID_TEXT)
13257 DrawLevelText(sx, sy, 0, TEXT_INIT);
13259 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13261 else if (last_sx != sx || last_sy != sy)
13263 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
13264 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
13265 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
13266 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
13273 case GADGET_ID_FLOOD_FILL:
13274 if (button_press_event && Tile[lx][ly] != new_element)
13276 if (IS_MM_WALL_EDITOR(new_element))
13277 FloodFillWall_MM(sx2, sy2, new_element);
13279 FloodFill(lx, ly, new_element);
13281 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13282 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13286 case GADGET_ID_PICK_ELEMENT:
13287 if (button_release_event)
13288 ClickOnGadget(level_editor_gadget[last_drawing_function],
13290 else if (draw_level)
13291 PickDrawingElement(button, Tile[lx][ly]);
13294 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13296 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
13303 // do not mark level as modified for certain non-level-changing gadgets
13304 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
13305 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
13306 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
13307 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
13310 level.changed = TRUE;
13313 static void HandleCounterButtons(struct GadgetInfo *gi)
13315 int gadget_id = gi->custom_id;
13316 int counter_id = gi->custom_type_id;
13317 int button = gi->event.button;
13318 int *counter_value = counterbutton_info[counter_id].value;
13319 int step = BUTTON_STEPSIZE(button) *
13320 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
13322 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
13324 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
13325 boolean released = (gi->event.type == GD_EVENT_RELEASED);
13326 boolean level_changed = LevelChanged();
13328 if ((level_changed && pressed) || (!level_changed && released))
13331 if (level_changed && !Request("Level has changed! Discard changes?",
13334 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
13335 ModifyEditorCounterValue(counter_id, *counter_value);
13341 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
13342 *counter_value = gi->textinput.number_value;
13344 ModifyEditorCounterValue(counter_id, *counter_value + step);
13346 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
13348 int last_game_engine_type = level.game_engine_type;
13350 LoadLevel(level_nr);
13351 LoadScore(level_nr);
13353 SaveLevelSetup_SeriesInfo();
13358 DrawEditModeWindow();
13360 if (level.game_engine_type != last_game_engine_type)
13362 // update element selection list
13363 ReinitializeElementList();
13364 ModifyEditorElementList();
13370 switch (counter_id)
13372 case ED_COUNTER_ID_YAMYAM_CONTENT:
13373 DrawYamYamContentAreas();
13376 case ED_COUNTER_ID_BALL_CONTENT:
13377 DrawMagicBallContentAreas();
13380 case ED_COUNTER_ID_ANDROID_CONTENT:
13381 DrawAndroidElementArea(properties_element);
13384 case ED_COUNTER_ID_GROUP_CONTENT:
13385 DrawGroupElementArea(properties_element);
13386 CopyGroupElementPropertiesToGame(properties_element);
13389 case ED_COUNTER_ID_INVENTORY_SIZE:
13390 DrawPlayerInitialInventoryArea(properties_element);
13393 case ED_COUNTER_ID_ENVELOPE_XSIZE:
13394 case ED_COUNTER_ID_ENVELOPE_YSIZE:
13395 DrawEnvelopeTextArea(-1);
13398 case ED_COUNTER_ID_LEVEL_XSIZE:
13399 case ED_COUNTER_ID_LEVEL_YSIZE:
13400 lev_fieldx = level.fieldx;
13401 lev_fieldy = level.fieldy;
13403 // check if resizing of level results in change of border border
13404 SetBorderElement();
13412 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
13413 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
13414 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
13415 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
13416 CopyElementPropertiesToGame(properties_element);
13418 // do not mark level as modified for certain non-level-changing gadgets
13419 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
13420 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
13421 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
13422 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
13425 level.changed = TRUE;
13428 static void HandleTextInputGadgets(struct GadgetInfo *gi)
13430 int type_id = gi->custom_type_id;
13432 strcpy(textinput_info[type_id].value, gi->textinput.value);
13434 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
13436 CopyElementPropertiesToGame(properties_element);
13438 ModifyEditorElementList(); // update changed button info text
13441 // do not mark level as modified for certain non-level-changing gadgets
13442 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
13443 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
13446 level.changed = TRUE;
13449 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
13451 int type_id = gi->custom_type_id;
13453 strncpy(textarea_info[type_id].value, gi->textarea.value,
13454 MAX_ENVELOPE_TEXT_LEN);
13455 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
13457 level.changed = TRUE;
13460 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
13462 int type_id = gi->custom_type_id;
13463 int value_old = *selectbox_info[type_id].value;
13464 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
13466 *selectbox_info[type_id].value = value_new;
13468 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
13470 DrawLevelInfoWindow();
13472 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
13474 element_info[properties_element].current_change_page = gi->selectbox.index;
13476 DrawPropertiesWindow();
13478 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
13479 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
13480 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
13481 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
13482 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
13484 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
13486 // when changing action type, also check action mode and action arg
13487 if (value_old != value_new)
13488 setSelectboxSpecialActionVariablesIfNeeded();
13490 DrawPropertiesChange();
13493 CopyElementPropertiesToGame(properties_element);
13495 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
13497 // update element selection list
13498 ReinitializeElementList();
13499 ModifyEditorElementList();
13502 // do not mark level as modified for certain non-level-changing gadgets
13503 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
13504 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
13507 level.changed = TRUE;
13510 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
13512 int type_id = gi->custom_type_id;
13515 if (type_id >= ED_TAB_BUTTON_ID_LEVELINFO_FIRST &&
13516 type_id <= ED_TAB_BUTTON_ID_LEVELINFO_LAST)
13518 edit_mode_levelinfo = gi->custom_type_id;
13520 DrawLevelInfoWindow();
13522 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
13523 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
13525 edit_mode_properties = gi->custom_type_id;
13527 DrawPropertiesWindow();
13529 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
13530 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
13532 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
13534 // backup original "level.field" (needed to track playfield changes)
13535 CopyPlayfield(level.field, TileBackup);
13537 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
13538 CopyPlayfield(Tile, level.field);
13540 if (new_template ||
13541 Request("Save this template and kill the old?", REQ_ASK))
13542 SaveLevelTemplate();
13545 Request("Template saved!", REQ_CONFIRM);
13547 // restore original "level.field" (needed to track playfield changes)
13548 CopyPlayfield(TileBackup, level.field);
13550 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
13552 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
13554 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
13555 leveldir_current->readonly)
13557 Request("This level set is read-only!", REQ_CONFIRM);
13562 if (strEqual(levelset_name, ""))
13564 Request("Please enter level set title!", REQ_CONFIRM);
13569 if (strEqual(levelset_author, ""))
13571 Request("Please enter level set author!", REQ_CONFIRM);
13576 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
13578 if (UpdateUserLevelSet(levelset_subdir,
13581 levelset_num_levels))
13583 Request("Level set updated!", REQ_CONFIRM);
13587 Request("Updating level set failed!", REQ_CONFIRM);
13590 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
13592 if (level.changed && !Request("Level has changed! Discard changes?",
13596 if (CreateUserLevelSet(levelset_subdir,
13599 levelset_num_levels,
13600 levelset_use_levelset_artwork))
13602 if (levelset_copy_level_template)
13603 CopyLevelTemplateToUserLevelSet(levelset_subdir);
13605 Request("New level set created!", REQ_CONFIRM);
13607 AddUserLevelSetToLevelInfo(levelset_subdir);
13608 ChangeEditorToLevelSet(levelset_subdir);
13612 Request("Creating new level set failed!", REQ_CONFIRM);
13616 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
13617 custom_element.num_change_pages < MAX_CHANGE_PAGES)
13619 struct ElementInfo *ei = &element_info[properties_element];
13621 // when modifying custom element, ask for copying level template
13622 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13625 setElementChangePages(ei, ei->num_change_pages + 1);
13627 // set new change page to be new current change page
13628 ei->current_change_page = ei->num_change_pages - 1;
13629 ei->change = &ei->change_page[ei->current_change_page];
13631 setElementChangeInfoToDefaults(ei->change);
13633 DrawPropertiesWindow();
13635 level.changed = TRUE;
13637 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
13638 custom_element.num_change_pages > MIN_CHANGE_PAGES)
13640 struct ElementInfo *ei = &element_info[properties_element];
13642 // when modifying custom element, ask for copying level template
13643 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13646 // copy all change pages after change page to be deleted
13647 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
13648 ei->change_page[i] = ei->change_page[i + 1];
13650 setElementChangePages(ei, ei->num_change_pages - 1);
13652 DrawPropertiesWindow();
13654 level.changed = TRUE;
13658 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
13660 int type_id = gi->custom_type_id;
13662 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
13663 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
13665 struct ElementInfo *ei = &element_info[properties_element];
13666 int step = BUTTON_STEPSIZE(gi->event.button);
13668 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
13669 ei->current_change_page += step;
13671 if (ei->current_change_page < 0)
13672 ei->current_change_page = 0;
13673 else if (ei->current_change_page >= ei->num_change_pages)
13674 ei->current_change_page = ei->num_change_pages - 1;
13676 DrawPropertiesWindow();
13678 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
13679 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13681 struct ElementInfo *ei = &element_info[properties_element];
13682 int current_change_page = ei->current_change_page;
13684 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
13686 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
13687 ei->change_page[current_change_page];
13689 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13691 // when modifying custom element, ask for copying level template
13692 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13695 ei->change_page[current_change_page] =
13696 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
13698 level.changed = TRUE;
13701 DrawPropertiesWindow();
13705 static void HandleRadiobuttons(struct GadgetInfo *gi)
13707 int type_id = gi->custom_type_id;
13709 *radiobutton_info[type_id].value =
13710 radiobutton_info[type_id].checked_value;
13712 // do not mark level as modified for certain non-level-changing gadgets
13713 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
13714 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
13717 level.changed = TRUE;
13720 static void HandleCheckbuttons(struct GadgetInfo *gi)
13722 int type_id = gi->custom_type_id;
13724 *checkbutton_info[type_id].value ^= TRUE;
13726 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
13727 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
13728 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
13729 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
13730 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
13731 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
13732 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
13733 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
13735 CopyElementPropertiesToGame(properties_element);
13738 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
13740 UpdateCustomElementGraphicGadgets();
13742 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
13743 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
13745 boolean template_related_changes_found = FALSE;
13748 // check if any custom, group or empty elements have been changed
13749 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
13750 if ((IS_CUSTOM_ELEMENT(i) ||
13751 IS_GROUP_ELEMENT(i) ||
13752 IS_EMPTY_ELEMENT(i)) &&
13753 element_info[i].modified_settings)
13754 template_related_changes_found = TRUE;
13756 if (level.use_custom_template &&
13757 !fileExists(getGlobalLevelTemplateFilename()))
13759 Request("No level template found!", REQ_CONFIRM);
13761 level.use_custom_template = FALSE;
13763 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13768 if (level.use_custom_template &&
13769 template_related_changes_found &&
13770 !Request("Discard changes and use level template?", REQ_ASK))
13772 level.use_custom_template = FALSE;
13774 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13779 if (!level.use_custom_template &&
13780 Request("Copy settings from level template?", REQ_ASK))
13785 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
13787 DrawEditModeWindow();
13789 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
13791 if (setup.editor.use_template_for_new_levels &&
13792 !fileExists(getGlobalLevelTemplateFilename()))
13794 Request("No level template found!", REQ_CONFIRM);
13799 if (setup.editor.use_template_for_new_levels &&
13801 !Request("Discard level and load template?", REQ_ASK))
13806 if (!setup.editor.use_template_for_new_levels &&
13808 !Request("Discard level and use empty level?", REQ_ASK))
13813 LoadLevel(level_nr);
13814 LoadScore(level_nr);
13819 DrawEditModeWindow();
13821 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
13823 SetAutomaticNumberOfGemsNeeded();
13826 // do not mark level as modified for certain non-level-changing gadgets
13827 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
13828 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
13829 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
13830 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
13831 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
13832 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
13835 level.changed = TRUE;
13838 static void HandleControlButtons(struct GadgetInfo *gi)
13840 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
13841 static int last_edit_mode = ED_MODE_DRAWING;
13842 static int last_custom_copy_mode = -1;
13843 static int last_button = 0;
13844 int id = gi->custom_id;
13845 int button = gi->event.button;
13846 int step = BUTTON_STEPSIZE(button);
13847 int new_element = BUTTON_ELEMENT(button);
13848 int last_properties_element = properties_element;
13851 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
13852 DrawLevelText(0, 0, 0, TEXT_END);
13854 if (id < ED_NUM_CTRL1_BUTTONS &&
13855 id != GADGET_ID_SINGLE_ITEMS &&
13856 id != GADGET_ID_PICK_ELEMENT &&
13857 edit_mode != ED_MODE_DRAWING &&
13858 drawing_function != GADGET_ID_PICK_ELEMENT &&
13859 !(GetKeyModState() & KMOD_Control))
13860 ChangeEditModeWindow(ED_MODE_DRAWING);
13862 // element copy mode active, but no element button pressed => deactivate
13863 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
13864 last_custom_copy_mode = -1;
13866 // when showing palette on element buttons, change element of button used
13867 if (editor.palette.show_on_element_buttons &&
13868 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
13870 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
13872 id = GADGET_ID_PALETTE;
13877 case GADGET_ID_SCROLL_LEFT:
13878 if (level_xpos >= 0)
13880 if (lev_fieldx < ed_fieldx - 2)
13883 level_xpos -= step;
13884 if (level_xpos < -1)
13887 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
13889 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13891 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
13892 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
13896 case GADGET_ID_SCROLL_RIGHT:
13897 if (level_xpos <= lev_fieldx - ed_fieldx)
13899 if (lev_fieldx < ed_fieldx - 2)
13902 level_xpos += step;
13903 if (level_xpos > lev_fieldx - ed_fieldx + 1)
13904 level_xpos = lev_fieldx - ed_fieldx + 1;
13906 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
13908 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13910 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
13911 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
13915 case GADGET_ID_SCROLL_UP:
13916 if (level_ypos >= 0)
13918 if (lev_fieldy < ed_fieldy - 2)
13921 level_ypos -= step;
13922 if (level_ypos < -1)
13925 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
13927 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13929 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13930 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13934 case GADGET_ID_SCROLL_DOWN:
13935 if (level_ypos <= lev_fieldy - ed_fieldy)
13937 if (lev_fieldy < ed_fieldy - 2)
13940 level_ypos += step;
13941 if (level_ypos > lev_fieldy - ed_fieldy + 1)
13942 level_ypos = lev_fieldy - ed_fieldy + 1;
13944 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
13946 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13948 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13949 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13953 case GADGET_ID_SCROLL_HORIZONTAL:
13954 level_xpos = gi->event.item_position - 1;
13956 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13961 case GADGET_ID_SCROLL_VERTICAL:
13962 level_ypos = gi->event.item_position - 1;
13964 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13969 case GADGET_ID_SCROLL_LIST_UP:
13970 case GADGET_ID_SCROLL_LIST_DOWN:
13971 case GADGET_ID_SCROLL_LIST_VERTICAL:
13972 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
13973 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
13976 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
13977 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
13979 if (element_shift < 0)
13981 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
13982 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
13984 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13985 GDI_SCROLLBAR_ITEM_POSITION,
13986 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13989 ModifyEditorElementList();
13993 case GADGET_ID_PROPERTIES:
13994 // always switch off element properties when they are already displayed
13995 last_properties_element = new_element;
13996 case GADGET_ID_ELEMENT_LEFT:
13997 case GADGET_ID_ELEMENT_MIDDLE:
13998 case GADGET_ID_ELEMENT_RIGHT:
13999 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
14000 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
14001 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
14004 if (edit_mode != ED_MODE_PROPERTIES)
14006 last_edit_mode = edit_mode;
14008 ChangeEditModeWindow(ED_MODE_PROPERTIES);
14010 last_level_drawing_function = drawing_function;
14011 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14014 else if (properties_element != last_properties_element)
14016 DrawEditModeWindow();
14020 ChangeEditModeWindow(ED_MODE_DRAWING);
14022 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
14027 case GADGET_ID_PALETTE:
14028 if (edit_mode != ED_MODE_PALETTE)
14030 last_edit_mode = edit_mode;
14032 ChangeEditModeWindow(ED_MODE_PALETTE);
14036 ChangeEditModeWindow(last_edit_mode);
14040 case GADGET_ID_WRAP_LEFT:
14041 WrapLevel(-step, 0);
14044 case GADGET_ID_WRAP_RIGHT:
14045 WrapLevel(step, 0);
14048 case GADGET_ID_WRAP_UP:
14049 WrapLevel(0, -step);
14052 case GADGET_ID_WRAP_DOWN:
14053 WrapLevel(0, step);
14056 case GADGET_ID_SINGLE_ITEMS:
14057 case GADGET_ID_CONNECTED_ITEMS:
14058 case GADGET_ID_LINE:
14059 case GADGET_ID_ARC:
14060 case GADGET_ID_TEXT:
14061 case GADGET_ID_RECTANGLE:
14062 case GADGET_ID_FILLED_BOX:
14063 case GADGET_ID_FLOOD_FILL:
14064 case GADGET_ID_GRAB_BRUSH:
14065 case GADGET_ID_PICK_ELEMENT:
14066 if (drawing_function != GADGET_ID_PICK_ELEMENT)
14067 last_drawing_function = drawing_function;
14068 drawing_function = id;
14069 draw_with_brush = FALSE;
14072 case GADGET_ID_RANDOM_PLACEMENT:
14073 RandomPlacement(new_element);
14076 case GADGET_ID_ZOOM:
14077 // zoom level editor tile size in or out (or reset to default size)
14078 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
14079 button == 2 ? ed_tilesize_default :
14080 button == 3 ? ed_tilesize / 2 : ed_tilesize);
14082 // when using touch device, cycle through all zoom tilesizes
14083 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
14084 ed_tilesize = MICRO_TILESIZE;
14086 // limit zoom level by upper and lower bound
14087 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
14089 InitZoomLevelSettings(ed_tilesize);
14091 if (edit_mode == ED_MODE_DRAWING)
14093 DrawDrawingWindow();
14095 // redraw zoom gadget info text
14096 PrintEditorGadgetInfoText(level_editor_gadget[id]);
14099 // save current editor zoom tilesize
14100 SaveSetup_AutoSetup();
14104 case GADGET_ID_CUSTOM_COPY_FROM:
14105 case GADGET_ID_CUSTOM_COPY_TO:
14106 case GADGET_ID_CUSTOM_EXCHANGE:
14107 last_custom_copy_mode = id;
14108 last_drawing_function = drawing_function;
14111 case GADGET_ID_CUSTOM_COPY:
14112 CopyCustomElement(properties_element, -1, id);
14115 case GADGET_ID_CUSTOM_PASTE:
14116 CopyCustomElement(-1, properties_element, id);
14119 case GADGET_ID_UNDO:
14120 if (button < 0) // keep button value (even if modifier keys are pressed)
14122 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
14125 if (button == 1 && undo_buffer_steps == 0)
14127 Request("Undo buffer empty!", REQ_CONFIRM);
14131 else if (button == 2)
14135 else if (button == 3 && redo_buffer_steps == 0)
14137 Request("Redo buffer empty!", REQ_CONFIRM);
14142 if (edit_mode != ED_MODE_DRAWING)
14143 ChangeEditModeWindow(ED_MODE_DRAWING);
14149 undo_buffer_position =
14150 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
14152 undo_buffer_steps--;
14153 redo_buffer_steps++;
14159 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
14161 undo_buffer_steps++;
14162 redo_buffer_steps--;
14165 for (x = 0; x < lev_fieldx; x++)
14166 for (y = 0; y < lev_fieldy; y++)
14167 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
14169 // check if undo operation forces change of border style
14170 CheckLevelBorderElement(FALSE);
14172 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14176 case GADGET_ID_INFO:
14177 if (edit_mode != ED_MODE_INFO)
14179 last_edit_mode = edit_mode;
14181 ChangeEditModeWindow(ED_MODE_INFO);
14185 ChangeEditModeWindow(ED_MODE_DRAWING);
14189 case GADGET_ID_CLEAR:
14190 if (edit_mode != ED_MODE_DRAWING)
14191 ChangeEditModeWindow(ED_MODE_DRAWING);
14193 for (x = 0; x < MAX_LEV_FIELDX; x++)
14194 for (y = 0; y < MAX_LEV_FIELDY; y++)
14195 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
14197 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
14199 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14202 case GADGET_ID_SAVE:
14204 // saving read-only levels into personal level set modifies global vars
14205 // "leveldir_current" and "level_nr"; restore them after saving level
14206 LevelDirTree *leveldir_former = leveldir_current;
14207 int level_nr_former = level_nr;
14208 char *level_filename;
14211 if (leveldir_current->readonly &&
14212 !PrepareSavingIntoPersonalLevelSet())
14215 level_filename = getDefaultLevelFilename(level_nr);
14216 new_level = !fileExists(level_filename);
14219 Request("Save this level and kill the old?", REQ_ASK))
14221 if (leveldir_former->readonly)
14222 ModifyLevelInfoForSavingIntoPersonalLevelSet(leveldir_former->name);
14224 SetAutomaticNumberOfGemsNeeded();
14226 CopyPlayfield(Tile, level.field);
14227 SaveLevel(level_nr);
14229 level.changed = FALSE;
14233 char level_saved_msg[64];
14235 if (leveldir_former->readonly)
14236 sprintf(level_saved_msg,
14237 "Level saved as level %d into personal level set!",
14240 strcpy(level_saved_msg, "Level saved!");
14242 Request(level_saved_msg, REQ_CONFIRM);
14246 // "cd" back to copied-from levelset (in case of saved read-only level)
14247 leveldir_current = leveldir_former;
14248 level_nr = level_nr_former;
14253 case GADGET_ID_TEST:
14254 if (LevelChanged())
14255 level.game_version = GAME_VERSION_ACTUAL;
14257 CopyPlayfield(level.field, TileBackup);
14258 CopyPlayfield(Tile, level.field);
14260 CopyNativeLevel_RND_to_Native(&level);
14262 UnmapLevelEditorGadgets();
14263 UndrawSpecialEditorDoor();
14265 CloseDoor(DOOR_CLOSE_ALL);
14267 // needed before playing if editor playfield area has different size
14268 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
14270 // redraw_mask = REDRAW_ALL;
14272 level_editor_test_game = TRUE;
14274 StartGameActions(FALSE, setup.autorecord, level.random_seed);
14278 case GADGET_ID_EXIT:
14279 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
14283 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
14284 id <= GADGET_ID_ELEMENTLIST_LAST)
14286 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
14287 int new_element = editor_elements[element_position + element_shift];
14289 if (IS_EDITOR_CASCADE(new_element))
14293 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
14295 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
14296 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
14298 if (*cascade_element == new_element)
14300 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
14301 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
14303 // update element selection list
14304 ReinitializeElementList();
14305 ModifyEditorElementList();
14307 // update cascading gadget info text
14308 PrintEditorGadgetInfoText(level_editor_gadget[id]);
14310 // save current editor cascading state
14311 SaveSetup_EditorCascade();
14320 if (last_custom_copy_mode != -1)
14322 if (CopyCustomElement(properties_element, new_element,
14323 last_custom_copy_mode))
14325 ClickOnGadget(level_editor_gadget[last_drawing_function],
14328 last_custom_copy_mode = -1;
14334 // change element of button used to show palette
14335 if (editor.palette.show_on_element_buttons)
14336 button = last_button;
14338 PickDrawingElement(button, new_element);
14340 if (!stick_element_properties_window &&
14341 drawing_function != GADGET_ID_PICK_ELEMENT &&
14342 !(GetKeyModState() & KMOD_Control))
14344 properties_element = new_element;
14345 if (edit_mode == ED_MODE_PROPERTIES)
14346 DrawPropertiesWindow();
14349 if (drawing_function == GADGET_ID_PICK_ELEMENT)
14350 ClickOnGadget(level_editor_gadget[last_drawing_function],
14353 if (!use_permanent_palette)
14354 ChangeEditModeWindow(last_edit_mode);
14357 else if (gi->event.type == GD_EVENT_PRESSED)
14358 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
14359 else if (gi->event.type == GD_EVENT_RELEASED)
14360 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
14361 else if (gi->event.type == GD_EVENT_MOVING)
14362 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
14364 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
14370 void HandleLevelEditorKeyInput(Key key)
14372 char letter = getCharFromKey(key);
14374 if (drawing_function == GADGET_ID_TEXT &&
14375 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
14378 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
14379 else if (key == KSYM_Delete || key == KSYM_BackSpace)
14380 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
14381 else if (key == KSYM_Return)
14382 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
14383 else if (key == KSYM_Escape)
14384 DrawLevelText(0, 0, 0, TEXT_END);
14389 int id = GADGET_ID_NONE;
14390 int new_element_shift = element_shift;
14391 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
14392 int button = MB_LEFTBUTTON;
14398 id = GADGET_ID_SCROLL_LEFT;
14401 id = GADGET_ID_SCROLL_RIGHT;
14404 id = GADGET_ID_SCROLL_UP;
14407 id = GADGET_ID_SCROLL_DOWN;
14411 case KSYM_Page_Down:
14412 step *= (key == KSYM_Page_Up ? -1 : +1);
14413 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
14415 if (element_shift < 0)
14417 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14418 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14420 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14421 GDI_SCROLLBAR_ITEM_POSITION,
14422 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14424 ModifyEditorElementList();
14430 element_shift = (key == KSYM_Home ? 0 :
14431 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
14433 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14434 GDI_SCROLLBAR_ITEM_POSITION,
14435 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14437 ModifyEditorElementList();
14444 // this is needed to prevent interference with running "True X-Mouse"
14445 if (GetKeyModStateFromEvents() & KMOD_Control)
14448 // check for last or next editor cascade block in element list
14449 for (i = 0; i < num_editor_elements; i++)
14451 if ((key == KSYM_Insert && i == element_shift) ||
14452 (key == KSYM_Delete && new_element_shift > element_shift))
14455 // jump to next cascade block (or to start of element list)
14456 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
14457 new_element_shift = i;
14460 if (i < num_editor_elements)
14461 element_shift = new_element_shift;
14463 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14464 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14466 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14467 GDI_SCROLLBAR_ITEM_POSITION,
14468 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14470 ModifyEditorElementList();
14475 if (edit_mode == ED_MODE_DRAWING)
14476 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
14477 else if (edit_mode == ED_MODE_INFO)
14478 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
14479 else if (edit_mode == ED_MODE_PROPERTIES)
14480 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
14481 else if (edit_mode == ED_MODE_PALETTE)
14482 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
14483 else // should never happen
14484 ChangeEditModeWindow(ED_MODE_DRAWING);
14492 if (id != GADGET_ID_NONE)
14493 ClickOnGadget(level_editor_gadget[id], button);
14494 else if (letter == '1' || letter == '?')
14495 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
14496 else if (letter == '2')
14497 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
14498 else if (letter == '3')
14499 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
14500 else if (letter == '.')
14501 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
14502 else if (letter == 'U')
14503 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
14504 else if (letter == '-' || key == KSYM_KP_Subtract)
14505 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
14506 else if (letter == '0' || key == KSYM_KP_0)
14507 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
14508 else if (letter == '+' || key == KSYM_KP_Add ||
14509 letter == '=') // ("Shift-=" is "+" on US keyboards)
14510 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
14511 else if (key == KSYM_Return ||
14512 key == KSYM_space ||
14513 key == setup.shortcut.toggle_pause)
14514 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
14516 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
14517 if (letter && letter == controlbutton_info[i].shortcut)
14518 if (!anyTextGadgetActive())
14519 ClickOnGadget(level_editor_gadget[i], button);
14522 static void HandleLevelEditorIdle_Properties(void)
14524 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
14525 int x = editor.settings.element_graphic.x + element_border;
14526 int y = editor.settings.element_graphic.y + element_border;
14527 static unsigned int action_delay = 0;
14528 unsigned int action_delay_value = GameFrameDelay;
14531 if (!DelayReached(&action_delay, action_delay_value))
14534 for (i = 0; i < ED_NUM_SELECTBOX; i++)
14536 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
14538 if (gi->mapped && gi->active && gi->selectbox.open)
14542 DrawEditorElementAnimation(SX + x, SY + y);
14544 redraw_mask |= REDRAW_FIELD;
14546 FrameCounter++; // increase animation frame counter
14549 static void HandleLevelEditorIdle_Drawing(void)
14551 static boolean last_highlighted = FALSE;
14552 boolean highlighted = (GetKeyModState() & KMOD_Alt);
14554 if (highlighted != last_highlighted)
14556 DrawAreaElementHighlight(highlighted);
14558 last_highlighted = highlighted;
14560 redraw_mask |= REDRAW_FIELD;
14564 void HandleLevelEditorIdle(void)
14566 if (edit_mode == ED_MODE_PROPERTIES)
14567 HandleLevelEditorIdle_Properties();
14568 else if (edit_mode == ED_MODE_DRAWING)
14569 HandleLevelEditorIdle_Drawing();
14572 static void ClearEditorGadgetInfoText(void)
14574 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
14577 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
14579 char infotext[MAX_OUTPUT_LINESIZE + 1];
14580 char shortcut[MAX_OUTPUT_LINESIZE + 1];
14581 int max_infotext_len = getMaxInfoTextLength();
14583 if (gi == NULL || strlen(gi->info_text) == 0)
14586 strncpy(infotext, gi->info_text, max_infotext_len);
14587 infotext[max_infotext_len] = '\0';
14589 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
14591 int key = controlbutton_info[gi->custom_id].shortcut;
14595 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
14596 sprintf(shortcut, " ('.' or '%c')", key);
14597 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
14598 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
14599 else if (gi->custom_id == GADGET_ID_TEST)
14600 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
14601 else if (gi->custom_id == GADGET_ID_UNDO)
14602 sprintf(shortcut, " ('%c/Shift-U')", key);
14603 else if (gi->custom_id == GADGET_ID_ZOOM)
14604 sprintf(shortcut, " ('%c', '0', '-')", key);
14606 sprintf(shortcut, " ('%s%c')",
14607 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
14609 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
14610 strcat(infotext, shortcut);
14614 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
14617 void HandleEditorGadgetInfoText(void *ptr)
14619 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
14621 if (game_status != GAME_MODE_EDITOR)
14624 ClearEditorGadgetInfoText();
14626 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
14629 // misuse this function to delete brush cursor, if needed
14630 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
14631 DeleteBrushFromCursor();
14633 PrintEditorGadgetInfoText(gi);
14636 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
14638 static int start_lx, start_ly;
14639 int id = gi->custom_id;
14640 int type_id = gi->custom_type_id;
14641 int sx = gi->event.x;
14642 int sy = gi->event.y;
14643 int lx = sx + level_xpos;
14644 int ly = sy + level_ypos;
14645 int min_sx = 0, min_sy = 0;
14646 int max_sx = gi->drawing.area_xsize - 1;
14647 int max_sy = gi->drawing.area_ysize - 1;
14648 int actual_drawing_function = drawing_function;
14649 int max_infotext_len = getMaxInfoTextLength();
14650 char infotext[MAX_OUTPUT_LINESIZE + 1];
14653 infotext[0] = '\0'; // start with empty info text
14655 // pressed Control key: simulate picking element
14656 if (GetKeyModState() & KMOD_Control)
14657 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14659 ClearEditorGadgetInfoText();
14661 if (gi->event.type == GD_EVENT_INFO_LEAVING)
14664 // make sure to stay inside drawing area boundaries
14665 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14666 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14668 if (id == GADGET_ID_DRAWING_LEVEL)
14672 int min_lx = 0, min_ly = 0;
14673 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14675 // get positions inside level field
14676 lx = sx + level_xpos;
14677 ly = sy + level_ypos;
14679 // make sure to stay inside level field boundaries
14680 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14681 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14683 // correct drawing area positions accordingly
14684 sx = lx - level_xpos;
14685 sy = ly - level_ypos;
14688 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
14690 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
14692 if (gi->event.type == GD_EVENT_PRESSED)
14698 switch (actual_drawing_function)
14700 case GADGET_ID_SINGLE_ITEMS:
14701 text = "Drawing single items";
14703 case GADGET_ID_CONNECTED_ITEMS:
14704 text = "Drawing connected items";
14706 case GADGET_ID_LINE:
14707 text = "Drawing line";
14709 case GADGET_ID_ARC:
14710 text = "Drawing arc";
14712 case GADGET_ID_TEXT:
14713 text = "Setting text cursor";
14715 case GADGET_ID_RECTANGLE:
14716 text = "Drawing rectangle";
14718 case GADGET_ID_FILLED_BOX:
14719 text = "Drawing filled box";
14721 case GADGET_ID_FLOOD_FILL:
14722 text = "Flood fill";
14724 case GADGET_ID_GRAB_BRUSH:
14725 text = "Grabbing brush";
14727 case GADGET_ID_PICK_ELEMENT:
14728 text = "Picking element";
14732 text = "Drawing position";
14736 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14737 sprintf(infotext, "%s: %d, %d", text, lx, ly);
14739 sprintf(infotext, "%s: %d, %d", text,
14740 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
14742 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14743 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
14745 sprintf(infotext, "Level position: %d, %d", lx, ly);
14748 // misuse this function to draw brush cursor, if needed
14749 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
14751 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
14752 CopyBrushToCursor(sx, sy);
14754 DeleteBrushFromCursor();
14757 if (!draw_with_brush)
14758 UpdateBrushPosition(sx, sy);
14760 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14762 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14763 int element = drawingarea_info[type_id].value[pos];
14765 strncpy(infotext, getElementInfoText(element), max_infotext_len);
14769 if (id == GADGET_ID_CUSTOM_CONTENT)
14770 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
14771 else if (id == GADGET_ID_GROUP_CONTENT)
14772 sprintf(infotext, "group element position: %d", sx + 1);
14773 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
14774 id <= GADGET_ID_YAMYAM_CONTENT_7)
14775 sprintf(infotext, "content area %d position: %d, %d",
14776 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
14777 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
14778 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
14779 sprintf(infotext, "content area %d position: %d, %d",
14780 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
14781 else if (id == GADGET_ID_ANDROID_CONTENT)
14782 sprintf(infotext, "android element position: %d", sx + 1);
14783 else if (drawingarea_info[type_id].infotext != NULL)
14784 strcpy(infotext, drawingarea_info[type_id].infotext);
14787 infotext[max_infotext_len] = '\0';
14789 if (strlen(infotext) > 0)
14790 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
14793 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
14794 boolean quick_quit)
14796 if (!ask_if_level_has_changed ||
14798 Request("Level has changed! Exit without saving?",
14799 REQ_ASK | REQ_STAY_OPEN))
14801 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
14802 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
14804 // draw normal door
14805 UndrawSpecialEditorDoor();
14807 // use door animation if door 1 viewport is unchanged and contains toolbox
14808 if (useEditorDoorAnimation())
14809 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
14811 // close editor doors if viewport definition is the same as in main menu
14812 if (vp_door_1->x == DX &&
14813 vp_door_1->y == DY &&
14814 vp_door_1->width == DXSIZE &&
14815 vp_door_1->height == DYSIZE &&
14816 vp_door_2->x == VX &&
14817 vp_door_2->y == VY &&
14818 vp_door_2->width == VXSIZE &&
14819 vp_door_2->height == VYSIZE)
14820 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
14822 SetDoorState(DOOR_CLOSE_2);
14827 FadeSkipNextFadeIn();
14829 SetGameStatus(GAME_MODE_MAIN);
14835 if (!global.use_envelope_request)
14837 CloseDoor(DOOR_CLOSE_1);
14838 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);