1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
14 #include "libgame/libgame.h"
25 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
28 // ----------------------------------------------------------------------------
29 // screen and artwork graphic pixel position definitions
30 // ----------------------------------------------------------------------------
32 // values for the control window
33 #define ED_CTRL1_BUTTONS_HORIZ 4 // toolbox
34 #define ED_CTRL1_BUTTONS_VERT 4
35 #define ED_CTRL2_BUTTONS_HORIZ 3 // level
36 #define ED_CTRL2_BUTTONS_VERT 2
37 #define ED_CTRL3_BUTTONS_HORIZ 3 // CE and GE
38 #define ED_CTRL3_BUTTONS_VERT 1
39 #define ED_CTRL4_BUTTONS_HORIZ 2 // CE and GE
40 #define ED_CTRL4_BUTTONS_VERT 1
41 #define ED_CTRL5_BUTTONS_HORIZ 1 // properties
42 #define ED_CTRL5_BUTTONS_VERT 1
43 #define ED_CTRL6_BUTTONS_HORIZ 3 // properties
44 #define ED_CTRL6_BUTTONS_VERT 1
45 #define ED_CTRL7_BUTTONS_HORIZ 1 // palette
46 #define ED_CTRL7_BUTTONS_VERT 1
48 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
49 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
50 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
51 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
52 #define ED_NUM_CTRL5_BUTTONS (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT)
53 #define ED_NUM_CTRL6_BUTTONS (ED_CTRL6_BUTTONS_HORIZ * ED_CTRL6_BUTTONS_VERT)
54 #define ED_NUM_CTRL7_BUTTONS (ED_CTRL7_BUTTONS_HORIZ * ED_CTRL7_BUTTONS_VERT)
55 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
56 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
57 #define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS)
58 #define ED_NUM_CTRL1_5_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS)
59 #define ED_NUM_CTRL1_6_BUTTONS (ED_NUM_CTRL1_5_BUTTONS + ED_NUM_CTRL6_BUTTONS)
60 #define ED_NUM_CTRL1_7_BUTTONS (ED_NUM_CTRL1_6_BUTTONS + ED_NUM_CTRL7_BUTTONS)
61 #define ED_NUM_CTRL_BUTTONS ED_NUM_CTRL1_7_BUTTONS
63 // values for the element list
64 #define ED_ELEMENTLIST_XPOS (editor.palette.x)
65 #define ED_ELEMENTLIST_YPOS (editor.palette.y)
66 #define ED_ELEMENTLIST_XSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
67 #define ED_ELEMENTLIST_YSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
68 #define ED_ELEMENTLIST_COLS MAX(1, editor.palette.cols)
69 #define ED_ELEMENTLIST_ROWS MAX(1, editor.palette.rows)
70 #define ED_ELEMENTLIST_BUTTONS_HORIZ (ED_ELEMENTLIST_COLS)
71 #define ED_ELEMENTLIST_BUTTONS_VERT (ED_ELEMENTLIST_ROWS)
72 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
73 ED_ELEMENTLIST_BUTTONS_VERT)
76 #define ED_GADGET_NORMAL_DISTANCE (editor.gadget.normal_spacing)
77 #define ED_GADGET_SMALL_DISTANCE (editor.gadget.small_spacing)
78 #define ED_GADGET_TINY_DISTANCE (editor.gadget.tiny_spacing)
79 #define ED_GADGET_LINE_DISTANCE (editor.gadget.line_spacing)
80 #define ED_GADGET_TEXT_DISTANCE (editor.gadget.text_spacing)
81 #define ED_TAB_BAR_HEIGHT (editor.gadget.separator_line.height)
82 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
83 ED_DRAWINGAREA_BORDER_SIZE)
84 #define ED_GADGET_SPACE_DISTANCE (getFontWidth(FONT_TEXT_1))
86 // values for drawingarea gadgets
87 #define IMG_BORDER_1 IMG_EDITOR_ELEMENT_BORDER
88 #define IMG_BORDER_2 IMG_EDITOR_ELEMENT_BORDER_INPUT
89 #define ED_ELEMENT_BORDER (graphic_info[IMG_BORDER_1].border_size)
90 #define ED_DRAWINGAREA_BORDER_SIZE (graphic_info[IMG_BORDER_2].border_size)
91 #define ED_DRAWINGAREA_TILE_SIZE (editor.drawingarea.tile_size)
93 // values for checkbutton gadgets
94 #define ED_CHECKBUTTON_XSIZE (graphic_info[IMG_EDITOR_CHECKBOX].width)
95 #define ED_CHECKBUTTON_YSIZE (graphic_info[IMG_EDITOR_CHECKBOX].height)
97 #define ED_TABBUTTON_XSIZE (graphic_info[IMG_EDITOR_TABBUTTON].width)
98 #define ED_TABBUTTON_YSIZE (graphic_info[IMG_EDITOR_TABBUTTON].height)
100 #define ED_SETTINGS_LEVEL_TABS_X (editor.settings.tabs.x)
101 #define ED_SETTINGS_LEVEL_TABS_Y (editor.settings.tabs.y)
102 #define ED_SETTINGS_ELEMENT_TABS_X (editor.settings.tabs.x)
103 #define ED_SETTINGS_ELEMENT_TABS_Y (editor.settings.tabs.y + \
104 editor.settings.tabs.yoffset2)
106 #define ED_SETTINGS_TABS_XOFFSET (editor.settings.tabs.draw_xoffset)
107 #define ED_SETTINGS_TABS_YOFFSET (editor.settings.tabs.draw_yoffset)
109 #define ED_LEVEL_TABS_XSTART (ED_SETTINGS_LEVEL_TABS_X)
110 #define ED_LEVEL_TABS_YSTART (ED_SETTINGS_LEVEL_TABS_Y)
111 #define ED_LEVEL_SETTINGS_XSTART (ED_SETTINGS_LEVEL_TABS_X + \
112 ED_SETTINGS_TABS_XOFFSET)
113 #define ED_LEVEL_SETTINGS_YSTART (ED_SETTINGS_LEVEL_TABS_Y + \
114 ED_TABBUTTON_YSIZE + \
115 ED_GADGET_TINY_DISTANCE + \
116 ED_TAB_BAR_HEIGHT + \
117 ED_SETTINGS_TABS_YOFFSET + \
118 getFontHeight(FONT_TEXT_1) + \
119 ED_GADGET_TEXT_DISTANCE)
120 #define ED_ELEMENT_TABS_XSTART (ED_SETTINGS_ELEMENT_TABS_X)
121 #define ED_ELEMENT_TABS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y)
122 #define ED_ELEMENT_SETTINGS_XSTART (ED_SETTINGS_ELEMENT_TABS_X + \
123 ED_SETTINGS_TABS_XOFFSET)
124 #define ED_ELEMENT_SETTINGS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y + \
125 ED_TABBUTTON_YSIZE + \
126 ED_GADGET_TINY_DISTANCE + \
127 ED_TAB_BAR_HEIGHT + \
128 ED_SETTINGS_TABS_YOFFSET)
130 #define ED_SETTINGS_XOFFSET (ED_CHECKBUTTON_XSIZE + \
131 ED_GADGET_TEXT_DISTANCE)
132 #define ED_SETTINGS_YOFFSET (ED_CHECKBUTTON_YSIZE + \
133 ED_GADGET_LINE_DISTANCE)
135 #define ED_POS_RANGE (10000)
136 #define ED_POS_LEVEL_TABS_FIRST (1 * ED_POS_RANGE)
137 #define ED_POS_LEVEL_TABS_LAST (2 * ED_POS_RANGE - 1)
138 #define ED_POS_LEVEL_SETTINGS_FIRST (2 * ED_POS_RANGE)
139 #define ED_POS_LEVEL_SETTINGS_LAST (3 * ED_POS_RANGE - 1)
140 #define ED_POS_ELEMENT_TABS_FIRST (3 * ED_POS_RANGE)
141 #define ED_POS_ELEMENT_TABS_LAST (4 * ED_POS_RANGE - 1)
142 #define ED_POS_ELEMENT_SETTINGS_FIRST (4 * ED_POS_RANGE)
143 #define ED_POS_ELEMENT_SETTINGS_LAST (5 * ED_POS_RANGE - 1)
145 #define ED_LEVEL_TABS_XPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
146 #define ED_LEVEL_TABS_YPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
148 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
149 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
151 #define ED_ELEMENT_TABS_XPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
152 #define ED_ELEMENT_TABS_YPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
154 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
155 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
157 #define IS_POS_LEVEL_TABS(n) ((n) >= ED_POS_LEVEL_TABS_FIRST && \
158 (n) <= ED_POS_LEVEL_TABS_LAST)
159 #define IS_POS_LEVEL_SETTINGS(n) ((n) >= ED_POS_LEVEL_SETTINGS_FIRST && \
160 (n) <= ED_POS_LEVEL_SETTINGS_LAST)
161 #define IS_POS_ELEMENT_TABS(n) ((n) >= ED_POS_ELEMENT_TABS_FIRST && \
162 (n) <= ED_POS_ELEMENT_TABS_LAST)
163 #define IS_POS_ELEMENT_SETTINGS(n) ((n) >= ED_POS_ELEMENT_SETTINGS_FIRST && \
164 (n) <= ED_POS_ELEMENT_SETTINGS_LAST)
166 #define ED_LEVEL_TABS_LINE(n) ((n) - ED_POS_LEVEL_TABS_FIRST)
167 #define ED_LEVEL_SETTINGS_LINE(n) ((n) - ED_POS_LEVEL_SETTINGS_FIRST)
168 #define ED_ELEMENT_TABS_LINE(n) ((n) - ED_POS_ELEMENT_TABS_FIRST)
169 #define ED_ELEMENT_SETTINGS_LINE(n) ((n) - ED_POS_ELEMENT_SETTINGS_FIRST)
171 #define ED_LEVEL_TABS_X(n) (ED_LEVEL_TABS_XSTART + \
172 (n) * ED_SETTINGS_TABS_XOFFSET)
173 #define ED_LEVEL_TABS_Y(n) (ED_LEVEL_TABS_YSTART + \
174 (n) * ED_SETTINGS_TABS_YOFFSET)
176 #define ED_LEVEL_SETTINGS_X(n) (ED_LEVEL_SETTINGS_XSTART + \
177 (n) * ED_SETTINGS_XOFFSET)
178 #define ED_LEVEL_SETTINGS_Y(n) (ED_LEVEL_SETTINGS_YSTART + \
179 (n) * ED_SETTINGS_YOFFSET)
181 #define ED_ELEMENT_TABS_X(n) (ED_ELEMENT_TABS_XSTART + \
182 (n) * ED_SETTINGS_TABS_XOFFSET)
183 #define ED_ELEMENT_TABS_Y(n) (ED_ELEMENT_TABS_YSTART + \
184 (n) * ED_SETTINGS_TABS_YOFFSET)
186 #define ED_ELEMENT_SETTINGS_X(n) (ED_ELEMENT_SETTINGS_XSTART + \
187 (n) * ED_SETTINGS_XOFFSET)
188 #define ED_ELEMENT_SETTINGS_Y(n) (ED_ELEMENT_SETTINGS_YSTART + \
189 (n) * ED_SETTINGS_YOFFSET)
191 #define ED_POS_TO_LEVEL_TABS_X(n) \
192 (ED_LEVEL_TABS_X(ED_LEVEL_TABS_LINE(n)))
193 #define ED_POS_TO_LEVEL_TABS_Y(n) \
194 (ED_LEVEL_TABS_Y(ED_LEVEL_TABS_LINE(n)))
196 #define ED_POS_TO_LEVEL_SETTINGS_X(n) \
197 (ED_LEVEL_SETTINGS_X(ED_LEVEL_SETTINGS_LINE(n)))
198 #define ED_POS_TO_LEVEL_SETTINGS_Y(n) \
199 (ED_LEVEL_SETTINGS_Y(ED_LEVEL_SETTINGS_LINE(n)))
201 #define ED_POS_TO_ELEMENT_TABS_X(n) \
202 (ED_ELEMENT_TABS_X(ED_ELEMENT_TABS_LINE(n)))
203 #define ED_POS_TO_ELEMENT_TABS_Y(n) \
204 (ED_ELEMENT_TABS_Y(ED_ELEMENT_TABS_LINE(n)))
206 #define ED_POS_TO_ELEMENT_SETTINGS_X(n) \
207 (ED_ELEMENT_SETTINGS_X(ED_ELEMENT_SETTINGS_LINE(n)))
208 #define ED_POS_TO_ELEMENT_SETTINGS_Y(n) \
209 (ED_ELEMENT_SETTINGS_Y(ED_ELEMENT_SETTINGS_LINE(n)))
211 #define ED_SETTINGS_X(n) (IS_POS_LEVEL_TABS(n) ? \
212 ED_POS_TO_LEVEL_TABS_X(n) : \
213 IS_POS_LEVEL_SETTINGS(n) ? \
214 ED_POS_TO_LEVEL_SETTINGS_X(n) : \
215 IS_POS_ELEMENT_TABS(n) ? \
216 ED_POS_TO_ELEMENT_TABS_X(n) : \
217 IS_POS_ELEMENT_SETTINGS(n) ? \
218 ED_POS_TO_ELEMENT_SETTINGS_X(n) : (n))
219 #define ED_SETTINGS_Y(n) (IS_POS_LEVEL_TABS(n) ? \
220 ED_POS_TO_LEVEL_TABS_Y(n) : \
221 IS_POS_LEVEL_SETTINGS(n) ? \
222 ED_POS_TO_LEVEL_SETTINGS_Y(n) : \
223 IS_POS_ELEMENT_TABS(n) ? \
224 ED_POS_TO_ELEMENT_TABS_Y(n) : \
225 IS_POS_ELEMENT_SETTINGS(n) ? \
226 ED_POS_TO_ELEMENT_SETTINGS_Y(n) : (n))
228 #define ED_SETTINGS_XOFF(n) (5 * ((n) % 4) * \
229 ED_DRAWINGAREA_TILE_SIZE)
230 #define ED_SETTINGS_YOFF(n) (5 * ((n) / 4) * \
231 ED_DRAWINGAREA_TILE_SIZE)
233 #define ED_AREA_XOFFSET_1(n) ((n) != 0 ? \
234 ED_DRAWINGAREA_BORDER_SIZE : 0)
235 #define ED_AREA_YOFFSET_1(n) ((n) != 0 ? \
236 (ED_CHECKBUTTON_YSIZE - \
237 ED_DRAWINGAREA_TILE_SIZE) / 2 : 0)
239 #define ED_AREA_XOFFSET_2(n) (0)
240 #define ED_AREA_YOFFSET_2(n) ((n) == 3 ? \
241 ((n) - 1) * ED_DRAWINGAREA_TILE_SIZE / 2 : 0)
243 #define ED_AREA_SETTINGS_X(i) (ED_SETTINGS_X((i).x) + \
244 ED_SETTINGS_XOFF((i).xoffset) + \
245 ED_AREA_XOFFSET_1((i).x) - \
246 ED_AREA_XOFFSET_2((i).area_xsize))
247 #define ED_AREA_SETTINGS_Y(i) (ED_SETTINGS_Y((i).y) + \
248 ED_SETTINGS_YOFF((i).yoffset) + \
249 ED_AREA_YOFFSET_1((i).y) - \
250 ED_AREA_YOFFSET_2((i).area_ysize))
252 // values for element content drawing areas
253 #define ED_AREA_1X1_LSETTINGS_XPOS(n) ED_LEVEL_SETTINGS_XPOS(n)
254 #define ED_AREA_1X1_LSETTINGS_YPOS(n) ED_LEVEL_SETTINGS_YPOS(n)
255 #define ED_AREA_1X1_LSETTINGS_XOFF (0)
256 #define ED_AREA_1X1_LSETTINGS_YOFF (0)
258 #define ED_AREA_1X1_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
259 #define ED_AREA_1X1_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
260 #define ED_AREA_1X1_SETTINGS_XOFF (0)
261 #define ED_AREA_1X1_SETTINGS_YOFF (0)
263 #define ED_AREA_3X3_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
264 #define ED_AREA_3X3_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
265 #define ED_AREA_3X3_SETTINGS_XOFF (0)
266 #define ED_AREA_3X3_SETTINGS_YOFF (0)
269 #define ED_AREA_ELEMENT_CONTENT_XOFF(n) (n)
270 #define ED_AREA_ELEMENT_CONTENT_YOFF(n) (n)
273 #define ED_XPOS_YAM 0
274 #define ED_YPOS_YAM 5
275 #define ED_AREA_YAMYAM_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_YAM)
276 #define ED_AREA_YAMYAM_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_YAM)
277 #define ED_AREA_YAMYAM_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
278 #define ED_AREA_YAMYAM_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
279 #define ED_AREA_YAMYAM_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_YAM) + \
281 #define ED_AREA_YAMYAM_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_YAM) + \
282 ED_SETTINGS_YOFF(n) + \
283 ED_AREA_YOFFSET_1(ED_YPOS_YAM) - \
284 ED_AREA_YOFFSET_2(3))
286 // magic ball content
287 #define ED_XPOS_BALL 0
288 #define ED_YPOS_BALL 6
289 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_BALL)
290 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_BALL)
291 #define ED_AREA_MAGIC_BALL_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
292 #define ED_AREA_MAGIC_BALL_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
293 #define ED_AREA_MAGIC_BALL_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_BALL) + \
295 #define ED_AREA_MAGIC_BALL_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_BALL) + \
296 ED_SETTINGS_YOFF(n) + \
297 ED_AREA_YOFFSET_1(ED_YPOS_BALL) - \
298 ED_AREA_YOFFSET_2(3))
300 // values for scrolling gadgets for drawing area
301 #define ED_SCROLLBUTTON_XSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].width)
302 #define ED_SCROLLBUTTON_YSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].height)
304 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
305 #define ED_SCROLL_UP_YPOS (0)
306 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
307 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
308 #define ED_SCROLL_LEFT_XPOS (0)
309 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
310 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
311 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
312 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
313 ED_SCROLLBUTTON_XSIZE)
314 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
315 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
316 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
317 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
318 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
319 ED_SCROLLBUTTON_YSIZE)
320 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
321 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
323 // values for scrolling gadgets for element list
324 #define ED_SCROLLBUTTON2_XSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
325 #define ED_SCROLLBUTTON2_YSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
327 #define ED_SCROLL2_UP_XPOS (ED_ELEMENTLIST_XPOS + \
328 ED_ELEMENTLIST_BUTTONS_HORIZ * \
329 ED_ELEMENTLIST_XSIZE)
330 #define ED_SCROLL2_UP_YPOS ED_ELEMENTLIST_YPOS
331 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
332 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
333 ED_ELEMENTLIST_BUTTONS_VERT * \
334 ED_ELEMENTLIST_YSIZE - \
335 ED_SCROLLBUTTON2_YSIZE)
336 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
337 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
338 ED_SCROLLBUTTON2_YSIZE)
339 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
340 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
341 ED_ELEMENTLIST_YSIZE - \
342 2 * ED_SCROLLBUTTON2_YSIZE)
344 // values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText()
345 #define INFOTEXT_FONT FONT_TEXT_2
346 #define INFOTEXT_XSIZE SXSIZE
347 #define INFOTEXT_YSIZE getFontHeight(INFOTEXT_FONT)
348 #define INFOTEXT_YSIZE_FULL (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE)
349 #define INFOTEXT_X (editor.settings.tooltip.x)
350 #define INFOTEXT_Y (editor.settings.tooltip.y)
351 #define INFOTEXT_XY_REDEFINED (INFOTEXT_X != -1 || INFOTEXT_Y != -1)
352 #define INFOTEXT_XPOS SX + (INFOTEXT_XY_REDEFINED ? INFOTEXT_X : 0)
353 #define INFOTEXT_YPOS SY + (INFOTEXT_XY_REDEFINED ? INFOTEXT_Y : \
354 SYSIZE - INFOTEXT_YSIZE)
357 // ----------------------------------------------------------------------------
358 // editor gadget definitions
359 // ----------------------------------------------------------------------------
365 // drawing toolbox buttons
367 GADGET_ID_SINGLE_ITEMS,
368 GADGET_ID_CONNECTED_ITEMS,
372 GADGET_ID_FILLED_BOX,
375 GADGET_ID_FLOOD_FILL,
378 GADGET_ID_WRAP_RIGHT,
379 GADGET_ID_RANDOM_PLACEMENT,
380 GADGET_ID_GRAB_BRUSH,
382 GADGET_ID_PICK_ELEMENT,
391 GADGET_ID_CUSTOM_COPY_FROM,
392 GADGET_ID_CUSTOM_COPY_TO,
393 GADGET_ID_CUSTOM_EXCHANGE,
394 GADGET_ID_CUSTOM_COPY,
395 GADGET_ID_CUSTOM_PASTE,
397 GADGET_ID_PROPERTIES,
398 GADGET_ID_ELEMENT_LEFT,
399 GADGET_ID_ELEMENT_MIDDLE,
400 GADGET_ID_ELEMENT_RIGHT,
403 // counter gadget identifiers
405 GADGET_ID_SELECT_LEVEL_DOWN,
406 GADGET_ID_SELECT_LEVEL_TEXT,
407 GADGET_ID_SELECT_LEVEL_UP,
408 GADGET_ID_LEVEL_XSIZE_DOWN,
409 GADGET_ID_LEVEL_XSIZE_TEXT,
410 GADGET_ID_LEVEL_XSIZE_UP,
411 GADGET_ID_LEVEL_YSIZE_DOWN,
412 GADGET_ID_LEVEL_YSIZE_TEXT,
413 GADGET_ID_LEVEL_YSIZE_UP,
414 GADGET_ID_LEVEL_RANDOM_DOWN,
415 GADGET_ID_LEVEL_RANDOM_TEXT,
416 GADGET_ID_LEVEL_RANDOM_UP,
417 GADGET_ID_LEVEL_GEMSLIMIT_DOWN,
418 GADGET_ID_LEVEL_GEMSLIMIT_TEXT,
419 GADGET_ID_LEVEL_GEMSLIMIT_UP,
420 GADGET_ID_LEVEL_TIMELIMIT_DOWN,
421 GADGET_ID_LEVEL_TIMELIMIT_TEXT,
422 GADGET_ID_LEVEL_TIMELIMIT_UP,
423 GADGET_ID_LEVEL_TIMESCORE_DOWN,
424 GADGET_ID_LEVEL_TIMESCORE_TEXT,
425 GADGET_ID_LEVEL_TIMESCORE_UP,
426 GADGET_ID_LEVEL_RANDOM_SEED_DOWN,
427 GADGET_ID_LEVEL_RANDOM_SEED_TEXT,
428 GADGET_ID_LEVEL_RANDOM_SEED_UP,
429 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN,
430 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT,
431 GADGET_ID_LEVELSET_NUM_LEVELS_UP,
432 GADGET_ID_ELEMENT_VALUE1_DOWN,
433 GADGET_ID_ELEMENT_VALUE1_TEXT,
434 GADGET_ID_ELEMENT_VALUE1_UP,
435 GADGET_ID_ELEMENT_VALUE2_DOWN,
436 GADGET_ID_ELEMENT_VALUE2_TEXT,
437 GADGET_ID_ELEMENT_VALUE2_UP,
438 GADGET_ID_ELEMENT_VALUE3_DOWN,
439 GADGET_ID_ELEMENT_VALUE3_TEXT,
440 GADGET_ID_ELEMENT_VALUE3_UP,
441 GADGET_ID_ELEMENT_VALUE4_DOWN,
442 GADGET_ID_ELEMENT_VALUE4_TEXT,
443 GADGET_ID_ELEMENT_VALUE4_UP,
444 GADGET_ID_YAMYAM_CONTENT_DOWN,
445 GADGET_ID_YAMYAM_CONTENT_TEXT,
446 GADGET_ID_YAMYAM_CONTENT_UP,
447 GADGET_ID_BALL_CONTENT_DOWN,
448 GADGET_ID_BALL_CONTENT_TEXT,
449 GADGET_ID_BALL_CONTENT_UP,
450 GADGET_ID_ANDROID_CONTENT_DOWN,
451 GADGET_ID_ANDROID_CONTENT_TEXT,
452 GADGET_ID_ANDROID_CONTENT_UP,
453 GADGET_ID_ENVELOPE_XSIZE_DOWN,
454 GADGET_ID_ENVELOPE_XSIZE_TEXT,
455 GADGET_ID_ENVELOPE_XSIZE_UP,
456 GADGET_ID_ENVELOPE_YSIZE_DOWN,
457 GADGET_ID_ENVELOPE_YSIZE_TEXT,
458 GADGET_ID_ENVELOPE_YSIZE_UP,
459 GADGET_ID_INVENTORY_SIZE_DOWN,
460 GADGET_ID_INVENTORY_SIZE_TEXT,
461 GADGET_ID_INVENTORY_SIZE_UP,
462 GADGET_ID_MM_BALL_CONTENT_DOWN,
463 GADGET_ID_MM_BALL_CONTENT_TEXT,
464 GADGET_ID_MM_BALL_CONTENT_UP,
465 GADGET_ID_CUSTOM_SCORE_DOWN,
466 GADGET_ID_CUSTOM_SCORE_TEXT,
467 GADGET_ID_CUSTOM_SCORE_UP,
468 GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
469 GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
470 GADGET_ID_CUSTOM_GEMCOUNT_UP,
471 GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
472 GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
473 GADGET_ID_CUSTOM_VALUE_FIX_UP,
474 GADGET_ID_CUSTOM_VALUE_RND_DOWN,
475 GADGET_ID_CUSTOM_VALUE_RND_TEXT,
476 GADGET_ID_CUSTOM_VALUE_RND_UP,
477 GADGET_ID_PUSH_DELAY_FIX_DOWN,
478 GADGET_ID_PUSH_DELAY_FIX_TEXT,
479 GADGET_ID_PUSH_DELAY_FIX_UP,
480 GADGET_ID_PUSH_DELAY_RND_DOWN,
481 GADGET_ID_PUSH_DELAY_RND_TEXT,
482 GADGET_ID_PUSH_DELAY_RND_UP,
483 GADGET_ID_DROP_DELAY_FIX_DOWN,
484 GADGET_ID_DROP_DELAY_FIX_TEXT,
485 GADGET_ID_DROP_DELAY_FIX_UP,
486 GADGET_ID_DROP_DELAY_RND_DOWN,
487 GADGET_ID_DROP_DELAY_RND_TEXT,
488 GADGET_ID_DROP_DELAY_RND_UP,
489 GADGET_ID_MOVE_DELAY_FIX_DOWN,
490 GADGET_ID_MOVE_DELAY_FIX_TEXT,
491 GADGET_ID_MOVE_DELAY_FIX_UP,
492 GADGET_ID_MOVE_DELAY_RND_DOWN,
493 GADGET_ID_MOVE_DELAY_RND_TEXT,
494 GADGET_ID_MOVE_DELAY_RND_UP,
495 GADGET_ID_STEP_DELAY_FIX_DOWN,
496 GADGET_ID_STEP_DELAY_FIX_TEXT,
497 GADGET_ID_STEP_DELAY_FIX_UP,
498 GADGET_ID_STEP_DELAY_RND_DOWN,
499 GADGET_ID_STEP_DELAY_RND_TEXT,
500 GADGET_ID_STEP_DELAY_RND_UP,
501 GADGET_ID_EXPLOSION_DELAY_DOWN,
502 GADGET_ID_EXPLOSION_DELAY_TEXT,
503 GADGET_ID_EXPLOSION_DELAY_UP,
504 GADGET_ID_IGNITION_DELAY_DOWN,
505 GADGET_ID_IGNITION_DELAY_TEXT,
506 GADGET_ID_IGNITION_DELAY_UP,
507 GADGET_ID_CHANGE_DELAY_FIX_DOWN,
508 GADGET_ID_CHANGE_DELAY_FIX_TEXT,
509 GADGET_ID_CHANGE_DELAY_FIX_UP,
510 GADGET_ID_CHANGE_DELAY_RND_DOWN,
511 GADGET_ID_CHANGE_DELAY_RND_TEXT,
512 GADGET_ID_CHANGE_DELAY_RND_UP,
513 GADGET_ID_CHANGE_CONT_RND_DOWN,
514 GADGET_ID_CHANGE_CONT_RND_TEXT,
515 GADGET_ID_CHANGE_CONT_RND_UP,
516 GADGET_ID_GROUP_CONTENT_DOWN,
517 GADGET_ID_GROUP_CONTENT_TEXT,
518 GADGET_ID_GROUP_CONTENT_UP,
520 // drawing area identifiers
522 GADGET_ID_DRAWING_LEVEL,
523 GADGET_ID_YAMYAM_CONTENT_0,
524 GADGET_ID_YAMYAM_CONTENT_1,
525 GADGET_ID_YAMYAM_CONTENT_2,
526 GADGET_ID_YAMYAM_CONTENT_3,
527 GADGET_ID_YAMYAM_CONTENT_4,
528 GADGET_ID_YAMYAM_CONTENT_5,
529 GADGET_ID_YAMYAM_CONTENT_6,
530 GADGET_ID_YAMYAM_CONTENT_7,
531 GADGET_ID_MAGIC_BALL_CONTENT_0,
532 GADGET_ID_MAGIC_BALL_CONTENT_1,
533 GADGET_ID_MAGIC_BALL_CONTENT_2,
534 GADGET_ID_MAGIC_BALL_CONTENT_3,
535 GADGET_ID_MAGIC_BALL_CONTENT_4,
536 GADGET_ID_MAGIC_BALL_CONTENT_5,
537 GADGET_ID_MAGIC_BALL_CONTENT_6,
538 GADGET_ID_MAGIC_BALL_CONTENT_7,
539 GADGET_ID_ANDROID_CONTENT,
540 GADGET_ID_AMOEBA_CONTENT,
541 GADGET_ID_START_ELEMENT,
542 GADGET_ID_ARTWORK_ELEMENT,
543 GADGET_ID_EXPLOSION_ELEMENT,
544 GADGET_ID_INVENTORY_CONTENT,
545 GADGET_ID_MM_BALL_CONTENT,
546 GADGET_ID_CUSTOM_GRAPHIC,
547 GADGET_ID_CUSTOM_CONTENT,
548 GADGET_ID_CUSTOM_MOVE_ENTER,
549 GADGET_ID_CUSTOM_MOVE_LEAVE,
550 GADGET_ID_CUSTOM_CHANGE_TARGET,
551 GADGET_ID_CUSTOM_CHANGE_CONTENT,
552 GADGET_ID_CUSTOM_CHANGE_TRIGGER,
553 GADGET_ID_CUSTOM_CHANGE_ACTION,
554 GADGET_ID_GROUP_CONTENT,
555 GADGET_ID_RANDOM_BACKGROUND,
557 // text input identifiers
559 GADGET_ID_LEVEL_NAME,
560 GADGET_ID_LEVEL_AUTHOR,
561 GADGET_ID_LEVELSET_NAME,
562 GADGET_ID_LEVELSET_AUTHOR,
563 GADGET_ID_ELEMENT_NAME,
565 // text area identifiers
567 GADGET_ID_ENVELOPE_INFO,
569 // selectbox identifiers
571 GADGET_ID_TIME_OR_STEPS,
572 GADGET_ID_TIME_SCORE_BASE,
573 GADGET_ID_GAME_ENGINE_TYPE,
574 GADGET_ID_LEVELSET_SAVE_MODE,
575 GADGET_ID_WIND_DIRECTION,
576 GADGET_ID_PLAYER_SPEED,
577 GADGET_ID_MM_BALL_CHOICE_MODE,
578 GADGET_ID_CUSTOM_WALK_TO_ACTION,
579 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
580 GADGET_ID_CUSTOM_DEADLINESS,
581 GADGET_ID_CUSTOM_MOVE_PATTERN,
582 GADGET_ID_CUSTOM_MOVE_DIRECTION,
583 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
584 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
585 GADGET_ID_CUSTOM_SMASH_TARGETS,
586 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
587 GADGET_ID_CUSTOM_ACCESS_TYPE,
588 GADGET_ID_CUSTOM_ACCESS_LAYER,
589 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
590 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
591 GADGET_ID_CHANGE_TIME_UNITS,
592 GADGET_ID_CHANGE_DIRECT_ACTION,
593 GADGET_ID_CHANGE_OTHER_ACTION,
594 GADGET_ID_CHANGE_SIDE,
595 GADGET_ID_CHANGE_PLAYER,
596 GADGET_ID_CHANGE_PAGE,
597 GADGET_ID_CHANGE_REPLACE_WHEN,
598 GADGET_ID_ACTION_TYPE,
599 GADGET_ID_ACTION_MODE,
600 GADGET_ID_ACTION_ARG,
601 GADGET_ID_SELECT_CHANGE_PAGE,
602 GADGET_ID_GROUP_CHOICE_MODE,
604 // textbutton identifiers
606 GADGET_ID_LEVELCONFIG_LEVEL,
607 GADGET_ID_LEVELCONFIG_LEVELSET,
608 GADGET_ID_LEVELCONFIG_EDITOR,
609 GADGET_ID_PROPERTIES_INFO,
610 GADGET_ID_PROPERTIES_CONFIG,
611 GADGET_ID_PROPERTIES_CONFIG_1,
612 GADGET_ID_PROPERTIES_CONFIG_2,
613 GADGET_ID_PROPERTIES_CHANGE,
614 GADGET_ID_SAVE_AS_TEMPLATE_1,
615 GADGET_ID_SAVE_AS_TEMPLATE_2,
616 GADGET_ID_SAVE_LEVELSET,
617 GADGET_ID_ADD_CHANGE_PAGE,
618 GADGET_ID_DEL_CHANGE_PAGE,
620 // graphicbutton identifiers
622 GADGET_ID_PREV_CHANGE_PAGE,
623 GADGET_ID_NEXT_CHANGE_PAGE,
624 GADGET_ID_COPY_CHANGE_PAGE,
625 GADGET_ID_PASTE_CHANGE_PAGE,
627 // gadgets for scrolling of drawing area
630 GADGET_ID_SCROLL_DOWN,
631 GADGET_ID_SCROLL_LEFT,
632 GADGET_ID_SCROLL_RIGHT,
633 GADGET_ID_SCROLL_HORIZONTAL,
634 GADGET_ID_SCROLL_VERTICAL,
636 // gadgets for scrolling element list
638 GADGET_ID_SCROLL_LIST_UP,
639 GADGET_ID_SCROLL_LIST_DOWN,
640 GADGET_ID_SCROLL_LIST_VERTICAL,
642 // checkbuttons/radiobuttons for level/element properties
644 GADGET_ID_AUTO_COUNT_GEMS,
645 GADGET_ID_RATE_TIME_OVER_SCORE,
646 GADGET_ID_USE_LEVELSET_ARTWORK,
647 GADGET_ID_COPY_LEVEL_TEMPLATE,
648 GADGET_ID_RANDOM_PERCENTAGE,
649 GADGET_ID_RANDOM_QUANTITY,
650 GADGET_ID_RANDOM_RESTRICTED,
651 GADGET_ID_STICK_ELEMENT,
652 GADGET_ID_EM_SLIPPERY_GEMS,
653 GADGET_ID_EM_EXPLODES_BY_FIRE,
654 GADGET_ID_USE_SPRING_BUG,
655 GADGET_ID_USE_TIME_ORB_BUG,
656 GADGET_ID_USE_LIFE_BUGS,
657 GADGET_ID_RANDOM_BALL_CONTENT,
658 GADGET_ID_INITIAL_BALL_ACTIVE,
659 GADGET_ID_GROW_INTO_DIGGABLE,
660 GADGET_ID_SB_FIELDS_NEEDED,
661 GADGET_ID_SB_OBJECTS_NEEDED,
662 GADGET_ID_AUTO_EXIT_SOKOBAN,
663 GADGET_ID_SOLVED_BY_ONE_PLAYER,
664 GADGET_ID_FINISH_DIG_COLLECT,
665 GADGET_ID_KEEP_WALKABLE_CE,
666 GADGET_ID_CONTINUOUS_SNAPPING,
667 GADGET_ID_BLOCK_SNAP_FIELD,
668 GADGET_ID_BLOCK_LAST_FIELD,
669 GADGET_ID_SP_BLOCK_LAST_FIELD,
670 GADGET_ID_INSTANT_RELOCATION,
671 GADGET_ID_SHIFTED_RELOCATION,
672 GADGET_ID_LAZY_RELOCATION,
673 GADGET_ID_USE_START_ELEMENT,
674 GADGET_ID_USE_ARTWORK_ELEMENT,
675 GADGET_ID_USE_EXPLOSION_ELEMENT,
676 GADGET_ID_INITIAL_GRAVITY,
677 GADGET_ID_USE_INITIAL_INVENTORY,
678 GADGET_ID_CAN_PASS_TO_WALKABLE,
679 GADGET_ID_CAN_FALL_INTO_ACID,
680 GADGET_ID_CAN_MOVE_INTO_ACID,
681 GADGET_ID_DONT_COLLIDE_WITH,
682 GADGET_ID_ENVELOPE_AUTOWRAP,
683 GADGET_ID_ENVELOPE_CENTERED,
684 GADGET_ID_MM_LASER_RED,
685 GADGET_ID_MM_LASER_GREEN,
686 GADGET_ID_MM_LASER_BLUE,
687 GADGET_ID_DF_LASER_RED,
688 GADGET_ID_DF_LASER_GREEN,
689 GADGET_ID_DF_LASER_BLUE,
690 GADGET_ID_ROTATE_MM_BALL_CONTENT,
691 GADGET_ID_EXPLODE_MM_BALL,
692 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
693 GADGET_ID_CUSTOM_CAN_EXPLODE,
694 GADGET_ID_CUSTOM_EXPLODE_FIRE,
695 GADGET_ID_CUSTOM_EXPLODE_SMASH,
696 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
697 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
698 GADGET_ID_CUSTOM_DEADLY,
699 GADGET_ID_CUSTOM_CAN_MOVE,
700 GADGET_ID_CUSTOM_CAN_FALL,
701 GADGET_ID_CUSTOM_CAN_SMASH,
702 GADGET_ID_CUSTOM_SLIPPERY,
703 GADGET_ID_CUSTOM_ACCESSIBLE,
704 GADGET_ID_CUSTOM_GRAV_REACHABLE,
705 GADGET_ID_CUSTOM_USE_LAST_VALUE,
706 GADGET_ID_CUSTOM_USE_GRAPHIC,
707 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
708 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
709 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
710 GADGET_ID_CUSTOM_CAN_CHANGE,
711 GADGET_ID_CHANGE_USE_CONTENT,
712 GADGET_ID_CHANGE_USE_EXPLOSION,
713 GADGET_ID_CHANGE_ONLY_COMPLETE,
714 GADGET_ID_CHANGE_USE_RANDOM,
715 GADGET_ID_CHANGE_HAS_ACTION,
716 GADGET_ID_CHANGE_DELAY,
717 GADGET_ID_CHANGE_BY_DIRECT_ACT,
718 GADGET_ID_CHANGE_BY_OTHER_ACT,
720 NUM_STATIC_GADGET_IDS
723 // gadgets for buttons in element list (dynamic)
724 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
725 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
726 ED_NUM_ELEMENTLIST_BUTTONS - 1)
728 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
730 // radio button numbers
734 RADIO_NR_DRAWING_TOOLBOX,
735 RADIO_NR_RANDOM_ELEMENTS
738 // values for counter gadgets
741 ED_COUNTER_ID_SELECT_LEVEL,
742 ED_COUNTER_ID_LEVEL_XSIZE,
743 ED_COUNTER_ID_LEVEL_YSIZE,
744 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
745 ED_COUNTER_ID_LEVEL_TIMELIMIT,
746 ED_COUNTER_ID_LEVEL_TIMESCORE,
747 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
748 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
749 ED_COUNTER_ID_LEVEL_RANDOM,
750 ED_COUNTER_ID_ELEMENT_VALUE1,
751 ED_COUNTER_ID_ELEMENT_VALUE2,
752 ED_COUNTER_ID_ELEMENT_VALUE3,
753 ED_COUNTER_ID_ELEMENT_VALUE4,
754 ED_COUNTER_ID_YAMYAM_CONTENT,
755 ED_COUNTER_ID_BALL_CONTENT,
756 ED_COUNTER_ID_ANDROID_CONTENT,
757 ED_COUNTER_ID_ENVELOPE_XSIZE,
758 ED_COUNTER_ID_ENVELOPE_YSIZE,
759 ED_COUNTER_ID_INVENTORY_SIZE,
760 ED_COUNTER_ID_MM_BALL_CONTENT,
761 ED_COUNTER_ID_CUSTOM_SCORE,
762 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
763 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
764 ED_COUNTER_ID_CUSTOM_VALUE_RND,
765 ED_COUNTER_ID_PUSH_DELAY_FIX,
766 ED_COUNTER_ID_PUSH_DELAY_RND,
767 ED_COUNTER_ID_DROP_DELAY_FIX,
768 ED_COUNTER_ID_DROP_DELAY_RND,
769 ED_COUNTER_ID_MOVE_DELAY_FIX,
770 ED_COUNTER_ID_MOVE_DELAY_RND,
771 ED_COUNTER_ID_STEP_DELAY_FIX,
772 ED_COUNTER_ID_STEP_DELAY_RND,
773 ED_COUNTER_ID_EXPLOSION_DELAY,
774 ED_COUNTER_ID_IGNITION_DELAY,
775 ED_COUNTER_ID_GROUP_CONTENT,
776 ED_COUNTER_ID_CHANGE_DELAY_FIX,
777 ED_COUNTER_ID_CHANGE_DELAY_RND,
778 ED_COUNTER_ID_CHANGE_CONT_RND,
780 ED_NUM_COUNTERBUTTONS
783 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
784 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
785 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
786 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
787 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
788 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
790 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
791 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
792 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
793 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
794 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
795 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
797 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
798 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
800 // values for scrollbutton gadgets
803 ED_SCROLLBUTTON_ID_AREA_UP,
804 ED_SCROLLBUTTON_ID_AREA_DOWN,
805 ED_SCROLLBUTTON_ID_AREA_LEFT,
806 ED_SCROLLBUTTON_ID_AREA_RIGHT,
807 ED_SCROLLBUTTON_ID_LIST_UP,
808 ED_SCROLLBUTTON_ID_LIST_DOWN,
813 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
814 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
816 // values for scrollbar gadgets
819 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
820 ED_SCROLLBAR_ID_AREA_VERTICAL,
821 ED_SCROLLBAR_ID_LIST_VERTICAL,
826 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
827 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
829 // values for text input gadgets
832 ED_TEXTINPUT_ID_LEVEL_NAME,
833 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
834 ED_TEXTINPUT_ID_LEVELSET_NAME,
835 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
836 ED_TEXTINPUT_ID_ELEMENT_NAME,
841 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
842 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
844 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
845 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
847 // values for text area gadgets
850 ED_TEXTAREA_ID_ENVELOPE_INFO,
855 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
856 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
858 // values for selectbox gadgets
861 ED_SELECTBOX_ID_TIME_OR_STEPS,
862 ED_SELECTBOX_ID_TIME_SCORE_BASE,
863 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
864 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
865 ED_SELECTBOX_ID_WIND_DIRECTION,
866 ED_SELECTBOX_ID_PLAYER_SPEED,
867 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
868 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
869 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
870 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
871 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
872 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
873 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
874 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
875 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
876 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
877 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
878 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
879 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
880 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
881 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
882 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
883 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
884 ED_SELECTBOX_ID_CHANGE_SIDE,
885 ED_SELECTBOX_ID_CHANGE_PLAYER,
886 ED_SELECTBOX_ID_CHANGE_PAGE,
887 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
888 ED_SELECTBOX_ID_ACTION_TYPE,
889 ED_SELECTBOX_ID_ACTION_MODE,
890 ED_SELECTBOX_ID_ACTION_ARG,
891 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
892 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
897 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
898 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
900 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
901 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
903 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
904 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
905 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
906 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
907 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
908 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
910 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
911 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
913 // values for textbutton gadgets
916 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL,
917 ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET,
918 ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR,
919 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
920 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
921 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
922 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
923 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
924 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
925 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
926 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
927 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
928 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
933 #define ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
934 #define ED_TAB_BUTTON_ID_LEVELCONFIG_LAST ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
936 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
937 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
939 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
940 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
942 // values for graphicbutton gadgets
945 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
946 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
947 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
948 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
950 ED_NUM_GRAPHICBUTTONS
953 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
954 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
956 // values for checkbutton gadgets
959 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
960 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
961 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
962 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
963 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
964 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
965 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
966 ED_CHECKBUTTON_ID_STICK_ELEMENT,
967 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
968 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
969 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
970 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
971 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
972 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
973 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
974 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
975 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
976 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
977 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
978 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
979 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
980 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
981 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
982 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
983 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
984 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
985 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
986 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
987 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
988 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
989 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
990 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
991 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
992 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
993 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
994 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
995 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
996 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
997 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
998 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
999 ED_CHECKBUTTON_ID_MM_LASER_RED,
1000 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
1001 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1002 ED_CHECKBUTTON_ID_DF_LASER_RED,
1003 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1004 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1005 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
1006 ED_CHECKBUTTON_ID_EXPLODE_MM_BALL,
1007 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1008 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1009 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1010 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1011 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1012 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1013 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1014 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1015 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1016 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1017 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1018 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1019 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1020 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1021 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1022 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1023 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1024 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1025 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1026 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1027 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1028 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1029 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1030 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1031 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1036 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1037 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1039 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1040 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1042 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1043 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1045 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1046 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1047 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1048 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1049 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1050 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1052 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1053 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1055 // values for radiobutton gadgets
1058 ED_RADIOBUTTON_ID_PERCENTAGE,
1059 ED_RADIOBUTTON_ID_QUANTITY,
1064 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1065 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1067 // values for drawing area gadgets
1070 ED_DRAWING_ID_DRAWING_LEVEL,
1071 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1072 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1073 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1074 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1075 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1076 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1077 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1078 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1079 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1080 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1081 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1082 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1083 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1084 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1085 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1086 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1087 ED_DRAWING_ID_ANDROID_CONTENT,
1088 ED_DRAWING_ID_AMOEBA_CONTENT,
1089 ED_DRAWING_ID_START_ELEMENT,
1090 ED_DRAWING_ID_ARTWORK_ELEMENT,
1091 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1092 ED_DRAWING_ID_INVENTORY_CONTENT,
1093 ED_DRAWING_ID_MM_BALL_CONTENT,
1094 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1095 ED_DRAWING_ID_CUSTOM_CONTENT,
1096 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1097 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1098 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1099 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1100 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1101 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1102 ED_DRAWING_ID_GROUP_CONTENT,
1103 ED_DRAWING_ID_RANDOM_BACKGROUND,
1105 ED_NUM_DRAWING_AREAS
1108 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1109 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1112 // ----------------------------------------------------------------------------
1113 // some internally used definitions
1114 // ----------------------------------------------------------------------------
1116 // values for CopyLevelToUndoBuffer()
1117 #define UNDO_IMMEDIATE 0
1118 #define UNDO_ACCUMULATE 1
1120 // values for scrollbars
1121 #define ED_SCROLL_NO 0
1122 #define ED_SCROLL_LEFT 1
1123 #define ED_SCROLL_RIGHT 2
1124 #define ED_SCROLL_UP 4
1125 #define ED_SCROLL_DOWN 8
1127 // screens in the level editor
1128 #define ED_MODE_DRAWING 0
1129 #define ED_MODE_LEVELCONFIG 1
1130 #define ED_MODE_PROPERTIES 2
1131 #define ED_MODE_PALETTE 3
1133 // sub-screens in the global settings section
1134 #define ED_MODE_LEVELCONFIG_LEVEL ED_TEXTBUTTON_ID_LEVELCONFIG_LEVEL
1135 #define ED_MODE_LEVELCONFIG_LEVELSET ED_TEXTBUTTON_ID_LEVELCONFIG_LEVELSET
1136 #define ED_MODE_LEVELCONFIG_EDITOR ED_TEXTBUTTON_ID_LEVELCONFIG_EDITOR
1138 // sub-screens in the element properties section
1139 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1140 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1141 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1142 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1143 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1145 // how many steps can be cancelled
1146 #define NUM_UNDO_STEPS (64 + 1)
1148 // values for elements with score for certain actions
1150 #define MAX_SCORE 999
1152 // values for elements with count for collecting
1153 #define MIN_COLLECT_COUNT 0
1154 #define MAX_COLLECT_COUNT 999
1156 // values for random placement
1157 #define RANDOM_USE_PERCENTAGE 0
1158 #define RANDOM_USE_QUANTITY 1
1160 // values for level set save mode
1161 #define LEVELSET_SAVE_MODE_UPDATE 0
1162 #define LEVELSET_SAVE_MODE_CREATE 1
1164 // default value for element tile size in drawing area
1165 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1166 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1169 // ----------------------------------------------------------------------------
1170 // some internally used data structure definitions
1171 // ----------------------------------------------------------------------------
1177 struct XYTileSize *pos;
1181 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1183 // note: some additional characters are already reserved for "cheat mode"
1184 // shortcuts (":XYZ" style) -- for details, see "events.c"
1186 // ---------- toolbox control buttons ---------------------------------------
1189 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1190 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1191 "draw single items", 's'
1194 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1195 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1196 "draw connected items", 'd'
1199 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1200 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1204 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1205 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1209 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1210 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1211 "draw outline rectangles", 'r'
1214 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1215 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1216 "draw filled rectangles", 'R'
1219 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1220 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1221 "wrap (rotate) level up", 0
1224 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1225 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1226 "enter text elements", 't'
1229 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1230 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1234 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1235 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1236 "wrap (rotate) level left", 0
1239 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1240 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1241 "zoom level tile size", '+'
1244 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1245 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1246 "wrap (rotate) level right", 0
1249 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1250 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1251 "random element placement", 0
1254 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1255 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1259 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1260 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1261 "wrap (rotate) level down", 0
1264 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1265 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1266 "pick drawing element", ','
1269 // ---------- level control buttons -----------------------------------------
1272 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1273 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1274 "undo/redo last operation", 'u'
1277 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_CONF,
1278 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1279 "level and editor settings", 'I'
1282 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1283 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1287 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1288 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1292 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1293 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1297 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1298 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1299 "exit level editor", 'E'
1302 // ---------- CE and GE control buttons -------------------------------------
1305 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1306 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1307 "copy settings from other element", 0
1310 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1311 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1312 "copy settings to other element", 0
1315 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1316 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1317 "exchange element with other element", 0
1320 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1321 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1322 "copy settings from this element", 0
1325 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1326 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1327 "paste settings to this element", 0
1330 // ---------- palette control buttons ---------------------------------------
1333 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1334 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1335 "properties of drawing element", 'p'
1338 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1339 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1340 "properties of drawing element 1", '1'
1343 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1344 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1345 "properties of drawing element 2", '2'
1348 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1349 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1350 "properties of drawing element 3", '3'
1353 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1354 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1355 "show list of elements", 'e'
1359 static int random_placement_value = 10;
1360 static int random_placement_method = RANDOM_USE_QUANTITY;
1361 static int random_placement_background_element = EL_SAND;
1362 static boolean random_placement_background_restricted = FALSE;
1363 static boolean stick_element_properties_window = FALSE;
1364 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1365 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1366 static struct ElementChangeInfo custom_element_change;
1367 static struct ElementGroupInfo group_element_info;
1368 static struct ElementInfo custom_element;
1370 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1371 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1372 static int levelset_num_levels = 100;
1373 static boolean levelset_use_levelset_artwork = FALSE;
1374 static boolean levelset_copy_level_template = FALSE;
1375 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1380 int min_value, max_value;
1381 int gadget_id_down, gadget_id_up;
1383 int gadget_id_align;
1385 char *text_above, *text_left, *text_right;
1386 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1388 // ---------- current level number ------------------------------------------
1391 -1, -1, // these values are not constant, but can change at runtime
1393 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1394 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1399 // ---------- level and editor settings -------------------------------------
1402 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1403 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1404 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1405 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1407 "playfield size:", NULL, "width",
1410 -1, ED_LEVEL_SETTINGS_YPOS(4),
1411 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1412 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1413 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1415 NULL, " ", "height",
1418 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1420 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1421 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1423 NULL, "number of gems to collect:", NULL
1426 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1428 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1429 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1431 "time or step limit to solve level:", NULL, NULL
1434 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1436 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1437 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1438 &level.score[SC_TIME_BONUS],
1439 "score for time or steps left:", NULL, NULL
1442 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1444 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1445 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1447 NULL, "random seed:", "(0 => random)"
1450 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1452 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1453 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1454 &levelset_num_levels,
1455 "number of levels:", NULL, NULL,
1458 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1460 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1461 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1462 &random_placement_value,
1463 "random element placement:", NULL, "in"
1466 // ---------- element settings: configure (various elements) ----------------
1469 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1470 MIN_SCORE, MAX_SCORE,
1471 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1472 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1473 NULL, // will be set when used
1477 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1478 MIN_SCORE, MAX_SCORE,
1479 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1480 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1481 NULL, // will be set when used
1485 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1486 MIN_SCORE, MAX_SCORE,
1487 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1488 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1489 NULL, // will be set when used
1493 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1494 MIN_SCORE, MAX_SCORE,
1495 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1496 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1497 NULL, // will be set when used
1501 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1502 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1503 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1504 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1505 &level.num_yamyam_contents,
1506 NULL, NULL, "number of content areas"
1509 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1510 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1511 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1512 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1513 &level.num_ball_contents,
1514 NULL, NULL, "number of content areas"
1517 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1518 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1519 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1520 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1521 &level.num_android_clone_elements,
1522 NULL, NULL, "number of clonable elements"
1525 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1526 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1527 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1528 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1529 NULL, // will be set when used
1530 NULL, NULL, "width",
1533 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1534 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1535 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1536 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1537 NULL, // will be set when used
1538 NULL, " ", "height",
1541 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1542 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1543 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1544 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1545 &level.initial_inventory_size[0],
1546 NULL, NULL, "number of inventory elements"
1549 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1550 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1551 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1552 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1553 &level.num_mm_ball_contents,
1554 NULL, NULL, "number of content elements"
1557 // ---------- element settings: configure 1 (custom elements) ---------------
1560 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1561 MIN_SCORE, MAX_SCORE,
1562 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1563 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1564 &custom_element.collect_score_initial,
1565 NULL, "CE score", " "
1568 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1569 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1570 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1571 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1572 &custom_element.collect_count_initial,
1573 NULL, "CE count", NULL
1576 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1578 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1579 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1580 &custom_element.ce_value_fixed_initial,
1581 NULL, "CE value", NULL
1584 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1586 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1587 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1588 &custom_element.ce_value_random_initial,
1589 NULL, "+random", NULL
1592 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1594 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1595 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1596 &custom_element.push_delay_fixed,
1597 NULL, "push delay", NULL
1600 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1602 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1603 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1604 &custom_element.push_delay_random,
1605 NULL, "+random", NULL
1608 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1610 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1611 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1612 &custom_element.drop_delay_fixed,
1613 NULL, "drop delay", NULL
1616 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1618 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1619 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1620 &custom_element.drop_delay_random,
1621 NULL, "+random", NULL
1624 // ---------- element settings: configure 2 (custom elements) ---------------
1627 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1629 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1630 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1631 &custom_element.move_delay_fixed,
1632 NULL, "move delay", NULL
1635 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1637 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1638 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1639 &custom_element.move_delay_random,
1640 NULL, "+random", NULL
1643 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1645 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1646 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1647 &custom_element.step_delay_fixed,
1648 NULL, "step delay", NULL
1651 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1653 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1654 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1655 &custom_element.step_delay_random,
1656 NULL, "+random", NULL
1659 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1661 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1662 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1663 &custom_element.explosion_delay,
1664 NULL, "explosion delay", NULL
1667 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1669 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1670 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1671 &custom_element.ignition_delay,
1672 NULL, "ignition delay", "(by fire)"
1675 // ---------- element settings: configure (group elements) ------------------
1678 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1679 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1680 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1681 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1682 &group_element_info.num_elements,
1683 NULL, NULL, "number of elements in group"
1686 // ---------- element settings: advanced (custom elements) ------------------
1689 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1691 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1692 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1693 &custom_element_change.delay_fixed,
1694 NULL, "CE delay", NULL,
1697 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1699 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1700 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1701 &custom_element_change.delay_random,
1702 NULL, "+random", NULL
1705 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1707 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1708 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1709 &custom_element_change.random_percentage,
1710 NULL, "use random replace:", "%"
1720 char *text_above, *infotext;
1721 } textinput_info[ED_NUM_TEXTINPUT] =
1724 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1725 GADGET_ID_LEVEL_NAME,
1728 "Title:", "Title for this level"
1731 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1732 GADGET_ID_LEVEL_AUTHOR,
1733 MAX_LEVEL_AUTHOR_LEN,
1735 "Author:", "Author for this level"
1738 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1739 GADGET_ID_LEVELSET_NAME,
1742 "Title:", "Title for this or new level set"
1745 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1746 GADGET_ID_LEVELSET_AUTHOR,
1747 MAX_LEVEL_AUTHOR_LEN,
1749 "Author:", "Author for this or new level set"
1752 -1, -1, // these values are not constant, but can change at runtime
1753 GADGET_ID_ELEMENT_NAME,
1754 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1755 custom_element.description,
1756 NULL, "Element name"
1766 char *text_above, *text_above_cropped, *infotext;
1767 } textarea_info[ED_NUM_TEXTAREAS] =
1770 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1771 GADGET_ID_ENVELOPE_INFO,
1772 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1774 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1778 static struct ValueTextInfo options_time_or_steps[] =
1786 static struct ValueTextInfo options_time_score_base[] =
1788 { 1, "per second/step" },
1789 { 10, "per 10 seconds/steps" },
1794 static struct ValueTextInfo options_game_engine_type[] =
1796 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1797 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1798 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1799 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1804 static struct ValueTextInfo options_levelset_save_mode[] =
1806 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1807 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1812 static struct ValueTextInfo options_wind_direction[] =
1814 { MV_START_NONE, "none" },
1815 { MV_START_LEFT, "left" },
1816 { MV_START_RIGHT, "right" },
1817 { MV_START_UP, "up" },
1818 { MV_START_DOWN, "down" },
1823 static struct ValueTextInfo options_player_speed[] =
1830 { 16, "very fast" },
1831 { 32, "ultrafast" },
1836 static struct ValueTextInfo options_access_type[] =
1838 { EP_WALKABLE, "walkable" },
1839 { EP_PASSABLE, "passable" },
1844 static struct ValueTextInfo options_access_layer[] =
1846 { EP_ACCESSIBLE_OVER, "over" },
1847 { EP_ACCESSIBLE_INSIDE, "inside" },
1848 { EP_ACCESSIBLE_UNDER, "under" },
1853 static struct ValueTextInfo options_access_protected[] =
1855 { 0, "unprotected" },
1861 static struct ValueTextInfo options_access_direction[] =
1863 { MV_NO_DIRECTION, "no direction" },
1864 { MV_LEFT, "left" },
1865 { MV_RIGHT, "right" },
1867 { MV_DOWN, "down" },
1868 { MV_LEFT | MV_UP, "left + up" },
1869 { MV_LEFT | MV_DOWN, "left + down" },
1870 { MV_RIGHT | MV_UP, "right + up" },
1871 { MV_RIGHT | MV_DOWN, "right + down" },
1872 { MV_HORIZONTAL, "horizontal" },
1873 { MV_VERTICAL, "vertical" },
1874 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1875 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1876 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1877 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1878 { MV_ALL_DIRECTIONS, "all directions" },
1883 static struct ValueTextInfo options_walk_to_action[] =
1885 { EP_DIGGABLE, "diggable" },
1886 { EP_COLLECTIBLE_ONLY, "collectible" },
1887 { EP_DROPPABLE, "collectible & droppable" },
1888 { EP_THROWABLE, "collectible & throwable" },
1889 { EP_PUSHABLE, "pushable" },
1894 static struct ValueTextInfo options_move_pattern[] =
1896 { MV_LEFT, "left" },
1897 { MV_RIGHT, "right" },
1899 { MV_DOWN, "down" },
1900 { MV_HORIZONTAL, "horizontal" },
1901 { MV_VERTICAL, "vertical" },
1902 { MV_ALL_DIRECTIONS, "all directions" },
1903 { MV_WIND_DIRECTION, "wind direction" },
1904 { MV_TOWARDS_PLAYER, "towards player" },
1905 { MV_AWAY_FROM_PLAYER, "away from player" },
1906 { MV_ALONG_LEFT_SIDE, "along left side" },
1907 { MV_ALONG_RIGHT_SIDE, "along right side" },
1908 { MV_TURNING_LEFT, "turning left" },
1909 { MV_TURNING_RIGHT, "turning right" },
1910 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1911 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1912 { MV_TURNING_RANDOM, "turning random" },
1913 { MV_MAZE_RUNNER, "maze runner style" },
1914 { MV_MAZE_HUNTER, "maze hunter style" },
1915 { MV_WHEN_PUSHED, "when pushed" },
1916 { MV_WHEN_DROPPED, "when dropped/thrown" },
1921 static struct ValueTextInfo options_move_direction[] =
1923 { MV_START_AUTOMATIC, "automatic" },
1924 { MV_START_LEFT, "left" },
1925 { MV_START_RIGHT, "right" },
1926 { MV_START_UP, "up" },
1927 { MV_START_DOWN, "down" },
1928 { MV_START_RANDOM, "random" },
1929 { MV_START_PREVIOUS, "previous" },
1934 static struct ValueTextInfo options_move_stepsize[] =
1936 { 0, "not moving" },
1941 { 16, "very fast" },
1942 { 32, "even faster" },
1947 static struct ValueTextInfo options_move_leave_type[] =
1949 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1950 { LEAVE_TYPE_LIMITED, "change it to" },
1955 static struct ValueTextInfo options_smash_targets[] =
1957 { EP_CAN_SMASH_PLAYER, "player" },
1959 { EP_CAN_SMASH_ENEMIES, "enemies" },
1961 { EP_CAN_SMASH_EVERYTHING, "everything" },
1966 static struct ValueTextInfo options_slippery_type[] =
1968 { SLIPPERY_ANY_RANDOM, "random" },
1969 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1970 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1971 { SLIPPERY_ONLY_LEFT, "only left" },
1972 { SLIPPERY_ONLY_RIGHT, "only right" },
1977 static struct ValueTextInfo options_deadliness[] =
1979 { EP_DONT_RUN_INTO, "running into" },
1980 { EP_DONT_COLLIDE_WITH, "colliding with" },
1981 { EP_DONT_GET_HIT_BY, "getting hit by" },
1982 { EP_DONT_TOUCH, "touching" },
1987 static struct ValueTextInfo options_explosion_type[] =
1989 { EXPLODES_3X3, "3x3" },
1990 { EXPLODES_CROSS, "3+3" },
1991 { EXPLODES_1X1, "1x1" },
1996 static struct ValueTextInfo options_time_units[] =
1999 { FRAMES_PER_SECOND, "seconds" },
2004 static struct ValueTextInfo options_change_direct_action[] =
2006 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2007 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2008 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2009 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2010 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2011 { CE_ENTERED_BY_PLAYER, "entered by player" },
2012 { CE_LEFT_BY_PLAYER, "left by player" },
2013 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2014 { CE_SWITCHED, "switched" },
2015 { CE_HITTING_SOMETHING, "hitting something" },
2016 { CE_HIT_BY_SOMETHING, "hit by something" },
2018 { CE_BLOCKED, "blocked" },
2020 { CE_IMPACT, "impact (on something)" },
2021 { CE_SMASHED, "smashed (from above)" },
2023 { CE_VALUE_CHANGES, "CE value changes" },
2024 { CE_SCORE_CHANGES, "CE score changes" },
2026 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2027 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2028 { CE_UNDEFINED, " " },
2029 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2030 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2031 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2032 { CE_UNDEFINED, " " },
2033 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2034 { CE_NEXT_TO_PLAYER, "next to player" },
2039 static struct ValueTextInfo options_change_other_action[] =
2041 { CE_PLAYER_TOUCHES_X, "player touches" },
2042 { CE_PLAYER_PRESSES_X, "player presses" },
2043 { CE_PLAYER_SWITCHES_X, "player switches" },
2044 { CE_PLAYER_SNAPS_X, "player snaps" },
2045 { CE_PLAYER_PUSHES_X, "player pushes" },
2046 { CE_PLAYER_ENTERS_X, "player enters" },
2047 { CE_PLAYER_LEAVES_X, "player leaves" },
2048 { CE_PLAYER_DIGS_X, "player digs" },
2049 { CE_PLAYER_COLLECTS_X, "player collects" },
2050 { CE_PLAYER_DROPS_X, "player drops/throws" },
2051 { CE_TOUCHING_X, "touching" },
2052 { CE_HITTING_X, "hitting" },
2053 { CE_DIGGING_X, "digging" },
2054 { CE_HIT_BY_X, "hit by" },
2055 { CE_SWITCH_OF_X, "switch of" },
2056 { CE_CHANGE_OF_X, "change by page of" },
2057 { CE_EXPLOSION_OF_X, "explosion of" },
2058 { CE_MOVE_OF_X, "move of" },
2059 { CE_CREATION_OF_X, "creation of" },
2060 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2061 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2062 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2063 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2064 { CE_UNDEFINED, " " },
2065 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2066 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2067 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2068 { CE_UNDEFINED, " " },
2069 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2070 { CE_PLAYER_NEXT_TO_X, "player next to" },
2071 { CE_NEXT_TO_X, "next to" },
2076 static struct ValueTextInfo options_change_trigger_side[] =
2078 { CH_SIDE_LEFT, "left" },
2079 { CH_SIDE_RIGHT, "right" },
2080 { CH_SIDE_TOP, "top" },
2081 { CH_SIDE_BOTTOM, "bottom" },
2082 { CH_SIDE_LEFT_RIGHT, "left/right" },
2083 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2084 { CH_SIDE_ANY, "any" },
2089 static struct ValueTextInfo options_change_trigger_player[] =
2091 { CH_PLAYER_1, "1" },
2092 { CH_PLAYER_2, "2" },
2093 { CH_PLAYER_3, "3" },
2094 { CH_PLAYER_4, "4" },
2095 { CH_PLAYER_ANY, "any" },
2100 static struct ValueTextInfo options_change_trigger_page[] =
2111 { (1u << 9), "10" },
2112 { (1u << 10), "11" },
2113 { (1u << 11), "12" },
2114 { (1u << 12), "13" },
2115 { (1u << 13), "14" },
2116 { (1u << 14), "15" },
2117 { (1u << 15), "16" },
2118 { (1u << 16), "17" },
2119 { (1u << 17), "18" },
2120 { (1u << 18), "19" },
2121 { (1u << 19), "20" },
2122 { (1u << 20), "21" },
2123 { (1u << 21), "22" },
2124 { (1u << 22), "23" },
2125 { (1u << 23), "24" },
2126 { (1u << 24), "25" },
2127 { (1u << 25), "26" },
2128 { (1u << 26), "27" },
2129 { (1u << 27), "28" },
2130 { (1u << 28), "29" },
2131 { (1u << 29), "30" },
2132 { (1u << 30), "31" },
2133 { (1u << 31), "32" },
2134 { CH_PAGE_ANY, "any" },
2139 static struct ValueTextInfo options_change_replace_when[] =
2141 { CP_WHEN_EMPTY, "empty" },
2142 { CP_WHEN_WALKABLE, "walkable" },
2143 { CP_WHEN_DIGGABLE, "diggable" },
2144 { CP_WHEN_COLLECTIBLE, "collectible" },
2145 { CP_WHEN_REMOVABLE, "removable" },
2146 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2151 static struct ValueTextInfo options_action_type[] =
2153 { CA_NO_ACTION, "no action" },
2154 { CA_UNDEFINED, " " },
2155 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2156 { CA_RESTART_LEVEL, "restart level" },
2157 { CA_SHOW_ENVELOPE, "show envelope" },
2158 { CA_SET_LEVEL_TIME, "set time" },
2159 { CA_SET_LEVEL_SCORE, "set score" },
2160 { CA_SET_LEVEL_GEMS, "set gems" },
2161 { CA_SET_LEVEL_WIND, "set wind dir." },
2162 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2163 { CA_UNDEFINED, " " },
2164 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2165 { CA_MOVE_PLAYER, "move player" },
2166 { CA_MOVE_PLAYER_NEW, "move player new" },
2167 { CA_EXIT_PLAYER, "exit player" },
2168 { CA_KILL_PLAYER, "kill player" },
2169 { CA_SET_PLAYER_KEYS, "set keys" },
2170 { CA_SET_PLAYER_SPEED, "set speed" },
2171 { CA_SET_PLAYER_SHIELD, "set shield" },
2172 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2173 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2174 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2175 { CA_UNDEFINED, " " },
2176 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2177 { CA_SET_CE_VALUE, "set CE value" },
2178 { CA_SET_CE_SCORE, "set CE score" },
2179 { CA_SET_CE_ARTWORK, "set CE artwork" },
2180 { CA_UNDEFINED, " " },
2181 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2182 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2187 static struct ValueTextInfo options_action_mode_none[] =
2189 { CA_MODE_UNDEFINED, " " },
2194 static struct ValueTextInfo options_action_mode_assign[] =
2196 { CA_MODE_SET, "=" },
2201 static struct ValueTextInfo options_action_mode_add_remove[] =
2203 { CA_MODE_ADD, "+" },
2204 { CA_MODE_SUBTRACT, "-" },
2209 static struct ValueTextInfo options_action_mode_calculate[] =
2211 { CA_MODE_SET, "=" },
2212 { CA_MODE_ADD, "+" },
2213 { CA_MODE_SUBTRACT, "-" },
2214 { CA_MODE_MULTIPLY, "*" },
2215 { CA_MODE_DIVIDE, "/" },
2216 { CA_MODE_MODULO, "%" },
2221 static struct ValueTextInfo options_action_arg_none[] =
2223 { CA_ARG_UNDEFINED, " " },
2228 static struct ValueTextInfo options_action_arg_player[] =
2230 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2231 { CA_ARG_PLAYER_1, "1" },
2232 { CA_ARG_PLAYER_2, "2" },
2233 { CA_ARG_PLAYER_3, "3" },
2234 { CA_ARG_PLAYER_4, "4" },
2235 { CA_ARG_PLAYER_ANY, "any" },
2236 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2237 { CA_ARG_PLAYER_ACTION, "action ->" },
2242 static struct ValueTextInfo options_action_arg_number[] =
2244 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2251 { CA_ARG_10, "10" },
2252 { CA_ARG_100, "100" },
2253 { CA_ARG_1000, "1000" },
2254 { CA_ARG_UNDEFINED, " " },
2255 { CA_ARG_NUMBER_MIN, "min" },
2256 { CA_ARG_NUMBER_MAX, "max" },
2257 { CA_ARG_UNDEFINED, " " },
2258 { CA_ARG_NUMBER_RESET, "reset" },
2259 { CA_ARG_UNDEFINED, " " },
2260 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2261 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2262 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2263 { CA_ARG_UNDEFINED, " " },
2264 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2265 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2266 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2267 { CA_ARG_UNDEFINED, " " },
2268 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2269 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2270 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2271 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2272 { CA_ARG_UNDEFINED, " " },
2273 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2274 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2275 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2276 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2281 static struct ValueTextInfo options_action_arg_value[] =
2283 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2290 { CA_ARG_10, "10" },
2291 { CA_ARG_100, "100" },
2292 { CA_ARG_1000, "1000" },
2293 { CA_ARG_UNDEFINED, " " },
2294 { CA_ARG_NUMBER_MIN, "min" },
2295 { CA_ARG_NUMBER_MAX, "max" },
2296 { CA_ARG_UNDEFINED, " " },
2297 { CA_ARG_NUMBER_RESET, "reset" },
2298 { CA_ARG_UNDEFINED, " " },
2299 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2300 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2301 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2302 { CA_ARG_UNDEFINED, " " },
2303 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2304 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2305 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2306 { CA_ARG_UNDEFINED, " " },
2307 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2308 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2309 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2310 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2311 { CA_ARG_UNDEFINED, " " },
2312 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2313 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2314 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2315 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2316 { CA_ARG_UNDEFINED, " " },
2317 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2318 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2319 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2320 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2325 static struct ValueTextInfo options_action_arg_envelope[] =
2327 { 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_key[] =
2343 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2352 { CA_ARG_UNDEFINED, " " },
2353 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2354 { CA_ARG_ELEMENT_TARGET, "target" },
2355 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2356 { CA_ARG_ELEMENT_ACTION, "action ->" },
2361 static struct ValueTextInfo options_action_arg_speed[] =
2363 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2364 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2365 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2366 { CA_ARG_SPEED_SLOW, "slow" },
2367 { CA_ARG_SPEED_NORMAL, "normal" },
2368 { CA_ARG_SPEED_FAST, "fast" },
2369 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2370 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2371 { CA_ARG_UNDEFINED, " " },
2372 { CA_ARG_SPEED_SLOWER, "slower" },
2373 { CA_ARG_SPEED_FASTER, "faster" },
2374 { CA_ARG_UNDEFINED, " " },
2375 { CA_ARG_SPEED_RESET, "reset" },
2380 static struct ValueTextInfo options_action_arg_shield[] =
2382 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2383 { CA_ARG_SHIELD_OFF, "off" },
2384 { CA_ARG_SHIELD_NORMAL, "normal" },
2385 { CA_ARG_SHIELD_DEADLY, "deadly" },
2390 static struct ValueTextInfo options_action_arg_artwork[] =
2392 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2393 { CA_ARG_ELEMENT_TARGET, "target" },
2394 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2395 { CA_ARG_ELEMENT_ACTION, "action ->" },
2396 { CA_ARG_UNDEFINED, " " },
2397 { CA_ARG_ELEMENT_RESET, "reset" },
2402 static struct ValueTextInfo options_action_arg_gravity[] =
2404 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2405 { CA_ARG_GRAVITY_ON, "on" },
2406 { CA_ARG_GRAVITY_OFF, "off" },
2407 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2412 static struct ValueTextInfo options_action_arg_direction[] =
2414 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2415 { CA_ARG_DIRECTION_NONE, "none" },
2416 { CA_ARG_DIRECTION_LEFT, "left" },
2417 { CA_ARG_DIRECTION_RIGHT, "right" },
2418 { CA_ARG_DIRECTION_UP, "up" },
2419 { CA_ARG_DIRECTION_DOWN, "down" },
2420 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2421 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2426 static struct ValueTextInfo options_action_arg_scan_mode[] =
2428 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2429 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2430 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2435 static struct ValueTextInfo options_action_arg_inventory[] =
2437 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2438 { CA_ARG_ELEMENT_TARGET, "+ target" },
2439 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2440 { CA_ARG_ELEMENT_ACTION, "+ action" },
2441 { CA_ARG_UNDEFINED, " " },
2442 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2443 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2444 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2445 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2446 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2447 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2448 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2449 { CA_ARG_UNDEFINED, " " },
2450 { CA_ARG_INVENTORY_RESET, "reset" },
2455 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2456 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2461 static struct ValueTextInfo options_group_choice_mode[] =
2463 { ANIM_RANDOM, "random" },
2464 { ANIM_LOOP, "loop" },
2465 { ANIM_LINEAR, "linear" },
2466 { ANIM_PINGPONG, "pingpong" },
2467 { ANIM_PINGPONG2, "pingpong 2" },
2472 static struct ValueTextInfo *action_arg_modes[] =
2474 options_action_mode_none,
2475 options_action_mode_assign,
2476 options_action_mode_add_remove,
2477 options_action_mode_calculate,
2484 struct ValueTextInfo *options;
2486 action_arg_options[] =
2488 { CA_NO_ACTION, 0, options_action_arg_none, },
2489 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2490 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2491 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2492 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2493 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2494 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2495 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2496 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2497 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2498 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2499 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2500 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2501 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2502 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2503 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2504 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2505 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2506 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2507 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2508 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2509 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2518 int gadget_id_align;
2519 int size; // char size of selectbox or '-1' (dynamically determined)
2520 struct ValueTextInfo *options;
2522 char *text_above, *text_left, *text_right, *infotext;
2523 } selectbox_info[ED_NUM_SELECTBOX] =
2525 // ---------- level and editor settings -------------------------------------
2528 -1, ED_LEVEL_SETTINGS_YPOS(8),
2529 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2531 options_time_or_steps,
2532 &level.use_step_counter,
2533 NULL, NULL, "(0 => no limit)", "time or step limit"
2536 -1, ED_LEVEL_SETTINGS_YPOS(10),
2537 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2539 options_time_score_base,
2540 &level.time_score_base,
2541 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2544 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2545 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2547 options_game_engine_type,
2548 &level.game_engine_type,
2549 NULL, "game engine:", NULL, "game engine"
2552 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2553 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2555 options_levelset_save_mode,
2556 &levelset_save_mode,
2557 "Action:", NULL, NULL, "action when saving level set"
2560 // ---------- element settings: configure (several elements) ----------------
2563 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2564 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2566 options_wind_direction,
2567 &level.wind_direction_initial,
2568 NULL, "initial wind direction:", NULL, "initial wind direction"
2571 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2572 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2574 options_player_speed,
2575 &level.initial_player_stepsize[0],
2576 NULL, "initial player speed:", NULL, "initial player speed"
2579 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2580 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2582 options_group_choice_mode,
2583 &level.mm_ball_choice_mode,
2584 NULL, "choice type:", NULL, "type of content choice"
2587 // ---------- element settings: configure 1 (custom elements) ---------------
2590 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2591 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2593 options_access_type,
2594 &custom_element.access_type,
2595 NULL, NULL, NULL, "type of access to this field"
2598 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2599 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2601 options_access_layer,
2602 &custom_element.access_layer,
2603 NULL, NULL, NULL, "layer of access for this field"
2606 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2607 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2609 options_access_protected,
2610 &custom_element.access_protected,
2611 NULL, NULL, NULL, "protected access for this field"
2614 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2615 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2617 options_access_direction,
2618 &custom_element.access_direction,
2619 NULL, "from", NULL, "access direction for this field"
2622 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2623 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2625 options_walk_to_action,
2626 &custom_element.walk_to_action,
2627 NULL, NULL, NULL, "diggable/collectible/pushable"
2630 // ---------- element settings: configure 2 (custom elements) ---------------
2633 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2634 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2636 options_move_pattern,
2637 &custom_element.move_pattern,
2638 NULL, "can move", NULL, "element move pattern"
2641 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2642 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2644 options_move_direction,
2645 &custom_element.move_direction_initial,
2646 NULL, "starts moving", NULL, "initial element move direction"
2649 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2650 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2652 options_move_stepsize,
2653 &custom_element.move_stepsize,
2654 NULL, "move/fall speed", NULL, "speed of element movement"
2657 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2658 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2660 options_move_leave_type,
2661 &custom_element.move_leave_type,
2662 // left text with leading spaces to place gadget next to "can dig" gadget
2663 // (needed because drawing area gadgets created after selectbox gadgets)
2664 // NULL, "can dig: can", ":", "leave behind or change element"
2665 NULL, " can", ":", "leave behind or change element"
2668 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2669 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2671 options_smash_targets,
2672 &custom_element.smash_targets,
2673 NULL, "can smash", NULL, "elements that can be smashed"
2676 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2677 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2679 options_slippery_type,
2680 &custom_element.slippery_type,
2681 NULL, "slippery", NULL, "where other elements fall down"
2684 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2685 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2688 &custom_element.deadliness,
2689 NULL, "deadly when", NULL, "deadliness of element"
2692 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2693 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2695 options_explosion_type,
2696 &custom_element.explosion_type,
2697 NULL, "can explode", NULL, "explosion type"
2700 // ---------- element settings: advanced (custom elements) ------------------
2703 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2704 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2707 &custom_element_change.delay_frames,
2708 NULL, "delay time given in", NULL, "delay time units for change"
2711 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2712 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2714 options_change_direct_action,
2715 &custom_element_change.direct_action,
2716 NULL, NULL, NULL, "type of direct action"
2719 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2720 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2722 options_change_other_action,
2723 &custom_element_change.other_action,
2724 NULL, NULL, "element:", "type of other element action"
2727 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2728 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2730 options_change_trigger_side,
2731 &custom_element_change.trigger_side,
2732 NULL, "at", "side", "element side triggering change"
2735 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2736 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2738 options_change_trigger_player,
2739 &custom_element_change.trigger_player,
2740 NULL, "player:", " ", "player that causes change"
2743 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2744 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2746 options_change_trigger_page,
2747 &custom_element_change.trigger_page,
2748 NULL, "page:", NULL, "change page that causes change"
2751 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2752 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2754 options_change_replace_when,
2755 &custom_element_change.replace_when,
2756 NULL, "replace when", NULL, "which elements can be replaced"
2759 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2760 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2762 options_action_type,
2763 &custom_element_change.action_type,
2764 NULL, NULL, NULL, "action on specified condition"
2767 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2768 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2770 options_action_mode_none,
2771 &custom_element_change.action_mode,
2772 NULL, NULL, NULL, "action operator"
2775 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2776 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2778 options_action_arg_none,
2779 &custom_element_change.action_arg,
2780 NULL, NULL, NULL, "action parameter"
2783 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2784 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2786 options_change_page,
2787 &custom_element.current_change_page,
2788 NULL, NULL, NULL, "element change page"
2791 // ---------- element settings: configure (group elements) ------------------
2794 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2795 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2797 options_group_choice_mode,
2798 &group_element_info.choice_mode,
2799 NULL, "choice type:", NULL, "type of group element choice"
2807 int gadget_id_align;
2810 char *text_above, *text_left, *text_right, *infotext;
2811 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2813 // ---------- level and editor settings (tabs) ------------------------------
2816 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2817 GADGET_ID_LEVELCONFIG_LEVEL, GADGET_ID_NONE,
2819 NULL, NULL, NULL, "Configure level settings"
2823 GADGET_ID_LEVELCONFIG_LEVELSET, GADGET_ID_LEVELCONFIG_LEVEL,
2825 NULL, NULL, NULL, "Update this or create new level set"
2829 GADGET_ID_LEVELCONFIG_EDITOR, GADGET_ID_LEVELCONFIG_LEVELSET,
2831 NULL, NULL, NULL, "Configure editor settings"
2834 // ---------- element settings (tabs) ---------------------------------------
2837 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2838 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2840 NULL, NULL, NULL, "Show information about element"
2844 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2846 NULL, NULL, NULL, "Configure element properties"
2850 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2852 NULL, NULL, NULL, "Configure element properties, part 1"
2856 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2858 NULL, NULL, NULL, "Configure element properties, part 2"
2862 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2864 NULL, NULL, NULL, "Configure custom element change pages"
2867 // ---------- level and editor settings (buttons) ---------------------------
2870 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2871 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
2873 NULL, NULL, NULL, "Update or create level set"
2876 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2877 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2879 NULL, NULL, "this level as level template",
2880 "Save current settings as new template"
2883 // ---------- element settings (buttons) ------------------------------------
2887 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2889 NULL, " ", "As Template",
2890 "Save current settings as new template"
2894 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2896 NULL, NULL, NULL, "Add new change page"
2900 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2902 NULL, NULL, NULL, "Delete current change page"
2911 int gadget_id_align;
2912 char *text_left, *text_right, *infotext;
2913 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2916 IMG_EDITOR_COUNTER_DOWN,
2917 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2918 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2919 NULL, NULL, "select previous change page"
2922 IMG_EDITOR_COUNTER_UP,
2923 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2924 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2925 NULL, "change page", "select next change page"
2928 IMG_GFX_EDITOR_BUTTON_CP_COPY,
2929 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2930 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2931 " ", NULL, "copy settings from this change page"
2934 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
2935 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2936 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2937 NULL, NULL, "paste settings to this change page"
2944 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2951 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2954 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2955 GADGET_ID_SCROLL_UP,
2956 "scroll level editing area up"
2959 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2960 GADGET_ID_SCROLL_DOWN,
2961 "scroll level editing area down"
2964 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2965 GADGET_ID_SCROLL_LEFT,
2966 "scroll level editing area left"
2969 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2970 GADGET_ID_SCROLL_RIGHT,
2971 "scroll level editing area right"
2974 IMG_EDITOR_PALETTE_SCROLL_UP,
2975 GADGET_ID_SCROLL_LIST_UP,
2976 "scroll element list up ('Page Up')"
2979 IMG_EDITOR_PALETTE_SCROLL_DOWN,
2980 GADGET_ID_SCROLL_LIST_DOWN,
2981 "scroll element list down ('Page Down')"
2989 int wheel_x, wheel_y;
2990 int wheel_width, wheel_height;
2991 } scrollbar_pos[ED_NUM_SCROLLBARS];
2999 } scrollbar_info[ED_NUM_SCROLLBARS] =
3002 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3003 GD_TYPE_SCROLLBAR_HORIZONTAL,
3004 GADGET_ID_SCROLL_HORIZONTAL,
3005 "scroll level editing area horizontally"
3008 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3009 GD_TYPE_SCROLLBAR_VERTICAL,
3010 GADGET_ID_SCROLL_VERTICAL,
3011 "scroll level editing area vertically"
3014 IMG_EDITOR_PALETTE_SCROLLBAR,
3015 GD_TYPE_SCROLLBAR_VERTICAL,
3016 GADGET_ID_SCROLL_LIST_VERTICAL,
3017 "scroll element list vertically"
3026 int gadget_id_align;
3027 int radio_button_nr;
3030 char *text_left, *text_right, *infotext;
3031 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3034 -1, ED_LEVEL_SETTINGS_YPOS(0),
3035 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3036 RADIO_NR_RANDOM_ELEMENTS,
3037 &random_placement_method, RANDOM_USE_PERCENTAGE,
3038 " ", "percentage", "use percentage for random elements"
3041 -1, ED_LEVEL_SETTINGS_YPOS(0),
3042 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3043 RADIO_NR_RANDOM_ELEMENTS,
3044 &random_placement_method, RANDOM_USE_QUANTITY,
3045 " ", "quantity", "use quantity for random elements"
3053 int gadget_id_align;
3055 char *text_above, *text_left, *text_right, *infotext;
3056 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3058 // ---------- level and editor settings -------------------------------------
3061 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3062 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3063 &level.auto_count_gems,
3065 "automatically count gems needed", "set counter to number of gems"
3068 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3069 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3070 &level.rate_time_over_score,
3072 "rate time/steps used over score", "sort high scores by playing time/steps"
3075 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3076 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3077 &levelset_use_levelset_artwork,
3079 "use current custom artwork", "use custom artwork of this level set"
3082 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3083 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3084 &levelset_copy_level_template,
3086 "copy current level template", "copy level template of this level set"
3089 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3090 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3091 &random_placement_background_restricted,
3093 "restrict random placement to:", "set random placement restriction"
3096 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3097 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3098 &setup.editor.use_template_for_new_levels,
3099 "Template for new levels and CE/GE:", NULL,
3100 "use template for new levels", "use template for level properties"
3103 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3104 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3105 &level.use_custom_template,
3107 "use template for custom elements", "use template for custom properties"
3110 // ---------- element settings: configure (various elements) ----------------
3113 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3114 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3115 &stick_element_properties_window,
3117 "stick this screen to edit content","stick this screen to edit content"
3120 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3121 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3122 &level.em_slippery_gems,
3124 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3127 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3128 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3129 &level.em_explodes_by_fire,
3131 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3134 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3135 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3136 &level.use_spring_bug,
3138 "use spring pushing bug", "use odd spring pushing behaviour"
3141 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3142 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3143 &level.use_time_orb_bug,
3145 "use time orb bug", "use odd time orb behaviour"
3148 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3149 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3150 &level.use_life_bugs,
3152 "use buggy element behaviour", "use odd (historic) element behaviour"
3155 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3156 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3159 "create single random element", "only create one element from content"
3162 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3163 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3164 &level.ball_active_initial,
3166 "magic ball initially activated", "activate magic ball after level start"
3169 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3170 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3171 &level.grow_into_diggable,
3173 "can grow into anything diggable", "grow into more than just sand"
3176 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3177 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3178 &level.sb_fields_needed,
3180 "all fields need to be filled", "require all SB fields to be solved"
3183 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3184 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3185 &level.sb_objects_needed,
3187 "all objects need to be placed", "require all SB objects to be solved"
3190 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3191 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3192 &level.auto_exit_sokoban,
3194 "exit level if all tasks solved", "automatically finish Sokoban levels"
3197 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3198 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3199 &level.solved_by_one_player,
3201 "only one player must enter exit", "level solved by first player in exit"
3204 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3205 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3206 &level.finish_dig_collect,
3208 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3211 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3212 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3213 &level.keep_walkable_ce,
3215 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3218 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3219 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3220 &level.continuous_snapping,
3222 "continuous snapping", "use snapping without releasing key"
3225 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3226 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3227 &level.block_snap_field,
3229 "block snapped field when snapping", "use snapping delay to show animation"
3232 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3233 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3234 &level.block_last_field,
3236 "block last field when moving", "player blocks last field when moving"
3239 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3240 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3241 &level.sp_block_last_field,
3243 "block last field when moving", "player blocks last field when moving"
3246 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3247 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3248 &level.instant_relocation,
3250 "no scrolling when relocating", "player gets relocated without delay"
3253 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3254 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3255 &level.shifted_relocation,
3257 "no centering when relocating", "level not centered after relocation"
3260 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3261 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3262 &level.lazy_relocation,
3264 "only redraw off-screen relocation","no redraw if relocation target visible"
3267 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3268 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3269 &level.use_start_element[0],
3271 "use level start element:", "start level at this element's position"
3274 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3275 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3276 &level.use_artwork_element[0],
3278 "use artwork from element:", "use player artwork from other element"
3281 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3282 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3283 &level.use_explosion_element[0],
3285 "use explosion from element:", "use explosion properties from element"
3288 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3289 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3290 &level.initial_player_gravity[0],
3292 "use initial gravity", "set initial player gravity"
3295 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3296 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3297 &level.use_initial_inventory[0],
3299 "use initial inventory:", "use collected elements on level start"
3302 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3303 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3304 &level.can_pass_to_walkable,
3306 "can pass to walkable element", "player can pass to empty or walkable"
3309 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3310 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3311 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3313 "can fall into acid (with gravity)","player can fall into acid pool"
3316 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3317 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3318 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3320 "can move into acid", "element can move into acid pool"
3323 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3324 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3325 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3327 "deadly when colliding with", "element is deadly when hitting player"
3330 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3331 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3332 &level.envelope[0].autowrap,
3334 "auto-wrap", "automatically wrap envelope text"
3337 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3338 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3339 &level.envelope[0].centered,
3341 "centered", "automatically center envelope text"
3344 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3345 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3346 &level.mm_laser_red,
3347 "choose color components for laser:", NULL,
3348 "red", "use red color components in laser"
3351 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3352 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3353 &level.mm_laser_green,
3355 "green", "use green color components in laser"
3358 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3359 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3360 &level.mm_laser_blue,
3362 "blue", "use blue color components in laser"
3365 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3366 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3367 &level.df_laser_red,
3368 "choose color components for laser:", NULL,
3369 "red", "use red color components in laser"
3372 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3373 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3374 &level.df_laser_green,
3376 "green", "use green color components in laser"
3379 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3380 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3381 &level.df_laser_blue,
3383 "blue", "use blue color components in laser"
3386 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3387 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3388 &level.rotate_mm_ball_content,
3390 "randomly rotate created content", "randomly rotate newly created content"
3393 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3394 GADGET_ID_EXPLODE_MM_BALL, GADGET_ID_NONE,
3395 &level.explode_mm_ball,
3397 "explode ball instead of melting", "use explosion to release ball content"
3400 // ---------- element settings: configure 1 (custom elements) ---------------
3403 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3404 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3405 &custom_element.use_gfx_element,
3407 "use graphic of element:", "use existing element graphic"
3410 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3411 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3412 &level.use_custom_template,
3414 "use template", "use template for custom properties"
3417 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3418 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3419 &custom_element_properties[EP_ACCESSIBLE],
3421 NULL, "player can walk to or pass this field"
3424 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3425 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3426 &custom_element_properties[EP_GRAVITY_REACHABLE],
3428 "reachable despite gravity", "player can walk/dig despite gravity"
3431 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3432 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3433 &custom_element.use_last_ce_value,
3435 "use last CE value after change", "use last CE value after change"
3438 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3439 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3440 &custom_element_properties[EP_WALK_TO_OBJECT],
3442 NULL, "player can dig/collect/push element"
3445 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3446 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3447 &custom_element_properties[EP_INDESTRUCTIBLE],
3449 "indestructible", "element is indestructible"
3452 // ---------- element settings: configure 2 (custom elements) ---------------
3455 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3456 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3457 &custom_element_properties[EP_CAN_MOVE],
3459 NULL, "element can move with some pattern"
3462 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3463 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3464 &custom_element_properties[EP_CAN_FALL],
3466 "can fall", "element can fall down"
3469 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3470 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3471 &custom_element_properties[EP_CAN_SMASH],
3473 NULL, "element can smash other elements"
3476 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3477 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3478 &custom_element_properties[EP_SLIPPERY],
3480 NULL, "other elements can fall down from it"
3483 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3484 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3485 &custom_element_properties[EP_DEADLY],
3487 NULL, "element can kill the player"
3490 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3491 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3492 &custom_element_properties[EP_CAN_EXPLODE],
3494 NULL, "element can explode"
3497 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3498 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3499 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3501 "by fire", "element can explode by fire/explosion"
3504 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3505 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3506 &custom_element_properties[EP_EXPLODES_SMASHED],
3508 "smashed", "element can explode when smashed"
3511 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3512 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3513 &custom_element_properties[EP_EXPLODES_IMPACT],
3515 "impact", "element can explode on impact"
3518 // ---------- element settings: advanced (custom elements) ------------------
3521 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3522 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3523 &custom_element_change.can_change,
3525 "element changes to:", "change element on specified condition"
3528 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3529 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3530 &custom_element_change_events[CE_DELAY],
3532 NULL, "element changes after delay"
3535 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3536 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3537 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3539 NULL, "element changes by direct action"
3542 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3543 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3544 &custom_element_change_events[CE_BY_OTHER_ACTION],
3546 NULL, "element changes by other element"
3549 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3550 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3551 &custom_element_change.explode,
3553 "explode instead of change", "element explodes instead of change"
3556 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3557 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3558 &custom_element_change.use_target_content,
3560 "use extended change target:", "element changes to more elements"
3563 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3564 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3565 &custom_element_change.only_if_complete,
3567 "replace all or nothing", "only replace when all can be changed"
3570 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3571 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3572 &custom_element_change.use_random_replace,
3574 NULL, "use percentage for random replace"
3577 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3578 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3579 &custom_element_change.has_action,
3581 NULL, "execute action on specified condition"
3588 int xoffset, yoffset;
3590 int gadget_id_align;
3592 int area_xsize, area_ysize;
3593 char *text_left, *text_right, *text_above, *text_below, *infotext;
3594 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3596 // ---------- level playfield content ---------------------------------------
3601 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3603 -1, -1, // these values are not constant, but can change at runtime
3604 NULL, NULL, NULL, NULL, NULL
3607 // ---------- yam yam content -----------------------------------------------
3610 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3611 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3612 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3613 &level.yamyam_content[0].e[0][0], 3, 3,
3614 NULL, NULL, NULL, "1", NULL
3617 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3618 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3619 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3620 &level.yamyam_content[1].e[0][0], 3, 3,
3621 NULL, NULL, NULL, "2", NULL
3624 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3625 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3626 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3627 &level.yamyam_content[2].e[0][0], 3, 3,
3628 NULL, NULL, NULL, "3", NULL
3631 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3632 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3633 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3634 &level.yamyam_content[3].e[0][0], 3, 3,
3635 NULL, NULL, NULL, "4", NULL
3638 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3639 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3640 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3641 &level.yamyam_content[4].e[0][0], 3, 3,
3642 NULL, NULL, NULL, "5", NULL
3645 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3646 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3647 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3648 &level.yamyam_content[5].e[0][0], 3, 3,
3649 NULL, NULL, NULL, "6", NULL
3652 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3653 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3654 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3655 &level.yamyam_content[6].e[0][0], 3, 3,
3656 NULL, NULL, NULL, "7", NULL
3659 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3660 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3661 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3662 &level.yamyam_content[7].e[0][0], 3, 3,
3663 NULL, NULL, NULL, "8", NULL
3666 // ---------- magic ball content --------------------------------------------
3669 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3670 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3671 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3672 &level.ball_content[0].e[0][0], 3, 3,
3673 NULL, NULL, NULL, "1", NULL
3676 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3677 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3678 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3679 &level.ball_content[1].e[0][0], 3, 3,
3680 NULL, NULL, NULL, "2", NULL
3683 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3684 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3685 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3686 &level.ball_content[2].e[0][0], 3, 3,
3687 NULL, NULL, NULL, "3", NULL
3690 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3691 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3692 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3693 &level.ball_content[3].e[0][0], 3, 3,
3694 NULL, NULL, NULL, "4", NULL
3697 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3698 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3699 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3700 &level.ball_content[4].e[0][0], 3, 3,
3701 NULL, NULL, NULL, "5", NULL
3704 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3705 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3706 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3707 &level.ball_content[5].e[0][0], 3, 3,
3708 NULL, NULL, NULL, "6", NULL
3711 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3712 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3713 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3714 &level.ball_content[6].e[0][0], 3, 3,
3715 NULL, NULL, NULL, "7", NULL
3718 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3719 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3720 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3721 &level.ball_content[7].e[0][0], 3, 3,
3722 NULL, NULL, NULL, "8", NULL
3725 // ---------- android content -----------------------------------------------
3728 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
3729 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3730 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3731 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3732 NULL, NULL, "elements:", NULL, "elements android can clone"
3735 // ---------- amoeba content ------------------------------------------------
3738 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3739 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3740 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3741 &level.amoeba_content, 1, 1,
3742 "content:", NULL, NULL, NULL, "amoeba content"
3745 // ---------- level start element -------------------------------------------
3748 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3749 0, ED_AREA_1X1_SETTINGS_YOFF,
3750 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3751 &level.start_element[0], 1, 1,
3752 NULL, NULL, NULL, NULL, "level start element"
3755 // ---------- player artwork element ----------------------------------------
3758 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3759 0, ED_AREA_1X1_SETTINGS_YOFF,
3760 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3761 &level.artwork_element[0], 1, 1,
3762 NULL, NULL, NULL, NULL, "element for player artwork"
3765 // ---------- player explosion element --------------------------------------
3768 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
3769 0, ED_AREA_1X1_SETTINGS_YOFF,
3770 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3771 &level.explosion_element[0], 1, 1,
3772 NULL, NULL, NULL, NULL, "element for player explosion"
3775 // ---------- player initial inventory --------------------------------------
3778 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3779 0, ED_AREA_1X1_SETTINGS_YOFF,
3780 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3781 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3782 NULL, NULL, NULL, NULL, "content for initial inventory"
3785 // ---------- gray ball content -----------------------------------------
3788 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3789 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3790 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
3791 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
3792 "content:", NULL, NULL, NULL, "content for gray ball"
3795 // ---------- element settings: configure 1 (custom elements) ---------------
3797 // ---------- custom graphic ------------------------------------------------
3800 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3801 0, ED_AREA_1X1_SETTINGS_YOFF,
3802 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3803 &custom_element.gfx_element_initial, 1, 1,
3804 NULL, NULL, NULL, NULL, "custom graphic element"
3807 // ---------- element settings: configure 2 (custom elements) ---------------
3809 // ---------- custom content (when exploding) -------------------------------
3812 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
3813 0, ED_AREA_3X3_SETTINGS_YOFF,
3814 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
3815 &custom_element.content.e[0][0], 3, 3,
3816 "content:", NULL, NULL, NULL, NULL
3819 // ---------- custom enter and leave element (when moving) ------------------
3822 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3823 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3824 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3825 &custom_element.move_enter_element, 1, 1,
3826 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
3829 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3830 0, ED_AREA_1X1_SETTINGS_YOFF,
3831 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3832 &custom_element.move_leave_element, 1, 1,
3833 NULL, NULL, NULL, NULL, "element that will be left behind"
3836 // ---------- element settings: advanced (custom elements) ------------------
3838 // ---------- custom change target ------------------------------------------
3841 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3842 0, ED_AREA_1X1_SETTINGS_YOFF,
3843 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3844 &custom_element_change.target_element, 1, 1,
3845 NULL, "after/when:", NULL, NULL, "new target element after change"
3848 // ---------- custom change content (extended change target) ----------------
3851 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3852 0, ED_AREA_3X3_SETTINGS_YOFF,
3853 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
3854 &custom_element_change.target_content.e[0][0], 3, 3,
3855 NULL, NULL, NULL, NULL, "new extended elements after change"
3858 // ---------- custom change trigger (element causing change) ----------------
3861 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3862 0, ED_AREA_1X1_SETTINGS_YOFF,
3863 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3864 &custom_element_change.initial_trigger_element, 1, 1,
3865 NULL, NULL, NULL, NULL, "other element triggering change"
3868 // ---------- custom change action (element used for action) ----------------
3871 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3872 0, ED_AREA_1X1_SETTINGS_YOFF,
3873 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3874 &custom_element_change.action_element, 1, 1,
3875 NULL, NULL, NULL, NULL, "element used as action parameter"
3878 // ---------- group element content -----------------------------------------
3881 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3882 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3883 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3884 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3885 "content:", NULL, NULL, NULL, NULL
3888 // ---------- random background (for random painting) -----------------------
3891 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
3892 0, ED_AREA_1X1_LSETTINGS_YOFF,
3893 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3894 &random_placement_background_element, 1, 1,
3895 NULL, NULL, NULL, NULL, "random placement background"
3900 // ----------------------------------------------------------------------------
3901 // some internally used variables
3902 // ----------------------------------------------------------------------------
3904 // maximal size of level editor drawing area
3905 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3907 // actual size of level editor drawing area
3908 static int ed_fieldx, ed_fieldy;
3910 // actual position of level editor drawing area in level playfield
3911 static int level_xpos = -1, level_ypos = -1;
3913 // actual tile size used to display playfield drawing area
3914 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3915 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
3917 #define IN_ED_FIELD(x, y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3919 // drawing elements on the three mouse buttons
3920 static int new_element1 = EL_WALL;
3921 static int new_element2 = EL_EMPTY;
3922 static int new_element3 = EL_SAND;
3924 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3925 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3926 (button) == 2 ? new_element2 : \
3927 (button) == 3 ? new_element3 : EL_EMPTY)
3929 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
3931 static int use_permanent_palette = TRUE;
3933 #define PX (use_permanent_palette ? DX : SX)
3934 #define PY (use_permanent_palette ? DY : SY)
3935 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
3936 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
3938 // forward declaration for internal use
3939 static void CopyBrushToCursor(int, int);
3940 static void DeleteBrushFromCursor(void);
3941 static void ModifyEditorCounterValue(int, int);
3942 static void ModifyEditorCounterLimits(int, int, int);
3943 static void ModifyEditorSelectboxValue(int, int);
3944 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3945 static void ModifyEditorDrawingArea(int, int, int);
3946 static void ModifyEditorElementList(void);
3947 static void AdjustElementListScrollbar(void);
3948 static void RedrawDrawingElements(void);
3949 static void DrawDrawingWindowExt(boolean);
3950 static void DrawDrawingWindow(void);
3951 static void DrawLevelConfigWindow(void);
3952 static void DrawPropertiesWindow(void);
3953 static void DrawPaletteWindow(void);
3954 static void UpdateCustomElementGraphicGadgets(void);
3955 static boolean checkPropertiesConfig(int);
3956 static void SetAutomaticNumberOfGemsNeeded(void);
3957 static void ClearEditorGadgetInfoText(void);
3958 static void CopyLevelToUndoBuffer(int);
3959 static void HandleDrawingAreas(struct GadgetInfo *);
3960 static void HandleCounterButtons(struct GadgetInfo *);
3961 static void HandleTextInputGadgets(struct GadgetInfo *);
3962 static void HandleTextAreaGadgets(struct GadgetInfo *);
3963 static void HandleSelectboxGadgets(struct GadgetInfo *);
3964 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3965 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3966 static void HandleRadiobuttons(struct GadgetInfo *);
3967 static void HandleCheckbuttons(struct GadgetInfo *);
3968 static void HandleControlButtons(struct GadgetInfo *);
3969 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3970 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3971 static boolean AskToCopyAndModifyLevelTemplate(void);
3972 static boolean getDrawModeHiRes(void);
3973 static int getTabulatorBarWidth(void);
3974 static int getTabulatorBarHeight(void);
3975 static Pixel getTabulatorBarColor(void);
3976 static int numHiresTiles(int);
3978 static int num_editor_gadgets = 0; // dynamically determined
3980 static struct GadgetInfo **level_editor_gadget = NULL;
3981 static int *right_gadget_border = NULL;
3983 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3984 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3985 static boolean draw_with_brush = FALSE;
3986 static int properties_element = 0;
3988 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3989 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3990 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3991 static int undo_buffer_position = 0;
3992 static int undo_buffer_steps = 0;
3993 static int redo_buffer_steps = 0;
3995 static int edit_mode;
3996 static int edit_mode_levelconfig;
3997 static int edit_mode_properties;
3999 static int element_shift = 0;
4001 static int editor_el_players[] =
4008 static int *editor_el_players_ptr = editor_el_players;
4009 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4011 static int editor_hl_boulderdash[] =
4013 EL_INTERNAL_CASCADE_BD_ACTIVE,
4019 static int editor_el_boulderdash[] =
4028 EL_BD_EXPANDABLE_WALL,
4036 EL_BD_BUTTERFLY_LEFT,
4038 EL_BD_BUTTERFLY_RIGHT,
4039 EL_BD_FIREFLY_RIGHT,
4042 EL_BD_BUTTERFLY_DOWN,
4046 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4047 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4048 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4049 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4051 static int editor_hl_emerald_mine[] =
4053 EL_INTERNAL_CASCADE_EM_ACTIVE,
4059 static int editor_el_emerald_mine[] =
4077 EL_EM_DYNAMITE_ACTIVE,
4096 EL_ACID_POOL_TOPLEFT,
4098 EL_ACID_POOL_TOPRIGHT,
4101 EL_ACID_POOL_BOTTOMLEFT,
4102 EL_ACID_POOL_BOTTOM,
4103 EL_ACID_POOL_BOTTOMRIGHT,
4121 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4122 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4123 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4124 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4126 static int editor_hl_emerald_mine_club[] =
4128 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4134 static int editor_el_emerald_mine_club[] =
4161 EL_EMC_WALL_SLIPPERY_1,
4162 EL_EMC_WALL_SLIPPERY_2,
4163 EL_EMC_WALL_SLIPPERY_3,
4164 EL_EMC_WALL_SLIPPERY_4,
4187 EL_EMC_MAGIC_BALL_SWITCH,
4194 EL_EMC_SPRING_BUMPER,
4198 EL_BALLOON_SWITCH_UP,
4199 EL_BALLOON_SWITCH_ANY,
4202 EL_BALLOON_SWITCH_LEFT,
4204 EL_BALLOON_SWITCH_RIGHT,
4208 EL_BALLOON_SWITCH_DOWN,
4209 EL_BALLOON_SWITCH_NONE,
4211 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4212 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4213 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4214 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4216 static int editor_hl_rnd[] =
4218 EL_INTERNAL_CASCADE_RND_ACTIVE,
4224 static int editor_el_rnd[] =
4227 EL_DYNAMITE_ACTIVE, // RND
4261 EL_WALL_EMERALD_YELLOW,
4262 EL_WALL_EMERALD_RED,
4263 EL_WALL_EMERALD_PURPLE,
4281 EL_DYNABOMB_INCREASE_NUMBER,
4282 EL_DYNABOMB_INCREASE_SIZE,
4283 EL_DYNABOMB_INCREASE_POWER,
4303 EL_INVISIBLE_STEELWALL,
4307 EL_EXPANDABLE_WALL_HORIZONTAL,
4308 EL_EXPANDABLE_WALL_VERTICAL,
4309 EL_EXPANDABLE_WALL_ANY,
4311 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4312 static int *editor_el_rnd_ptr = editor_el_rnd;
4313 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4314 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4316 static int editor_hl_sokoban[] =
4318 EL_INTERNAL_CASCADE_SB_ACTIVE,
4324 static int editor_el_sokoban[] =
4327 EL_SOKOBAN_FIELD_EMPTY,
4328 EL_SOKOBAN_FIELD_FULL,
4329 EL_SOKOBAN_FIELD_PLAYER,
4331 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4332 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4333 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4334 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4336 static int editor_hl_supaplex[] =
4338 EL_INTERNAL_CASCADE_SP_ACTIVE,
4344 static int editor_el_supaplex[] =
4362 EL_SP_PORT_HORIZONTAL,
4363 EL_SP_PORT_VERTICAL,
4371 EL_SP_GRAVITY_PORT_LEFT,
4372 EL_SP_GRAVITY_PORT_RIGHT,
4373 EL_SP_GRAVITY_PORT_UP,
4374 EL_SP_GRAVITY_PORT_DOWN,
4376 EL_SP_GRAVITY_ON_PORT_LEFT,
4377 EL_SP_GRAVITY_ON_PORT_RIGHT,
4378 EL_SP_GRAVITY_ON_PORT_UP,
4379 EL_SP_GRAVITY_ON_PORT_DOWN,
4381 EL_SP_GRAVITY_OFF_PORT_LEFT,
4382 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4383 EL_SP_GRAVITY_OFF_PORT_UP,
4384 EL_SP_GRAVITY_OFF_PORT_DOWN,
4386 EL_SP_HARDWARE_GRAY,
4387 EL_SP_HARDWARE_GREEN,
4388 EL_SP_HARDWARE_BLUE,
4391 EL_SP_HARDWARE_BASE_1,
4392 EL_SP_HARDWARE_BASE_2,
4393 EL_SP_HARDWARE_BASE_3,
4394 EL_SP_HARDWARE_BASE_4,
4396 EL_SP_HARDWARE_BASE_5,
4397 EL_SP_HARDWARE_BASE_6,
4398 EL_SP_HARDWARE_YELLOW,
4406 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4407 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4408 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4409 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4411 static int editor_hl_diamond_caves[] =
4413 EL_INTERNAL_CASCADE_DC_ACTIVE,
4419 static int editor_el_diamond_caves[] =
4421 EL_EM_STEEL_EXIT_CLOSED, // DC2
4422 EL_EM_STEEL_EXIT_OPEN, // DC2
4423 EL_WALL_EMERALD, // DC2
4424 EL_WALL_DIAMOND, // DC2
4431 EL_CONVEYOR_BELT_1_LEFT,
4432 EL_CONVEYOR_BELT_1_MIDDLE,
4433 EL_CONVEYOR_BELT_1_RIGHT,
4434 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4436 EL_CONVEYOR_BELT_2_LEFT,
4437 EL_CONVEYOR_BELT_2_MIDDLE,
4438 EL_CONVEYOR_BELT_2_RIGHT,
4439 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4441 EL_CONVEYOR_BELT_3_LEFT,
4442 EL_CONVEYOR_BELT_3_MIDDLE,
4443 EL_CONVEYOR_BELT_3_RIGHT,
4444 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4446 EL_CONVEYOR_BELT_4_LEFT,
4447 EL_CONVEYOR_BELT_4_MIDDLE,
4448 EL_CONVEYOR_BELT_4_RIGHT,
4449 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4451 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4452 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4453 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4454 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4456 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4457 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4458 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4459 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4464 EL_DC_TIMEGATE_SWITCH,
4466 EL_SWITCHGATE_CLOSED,
4468 EL_SWITCHGATE_SWITCH_UP,
4469 EL_SWITCHGATE_SWITCH_DOWN,
4472 EL_LIGHT_SWITCH_ACTIVE,
4473 EL_DC_SWITCHGATE_SWITCH_UP,
4474 EL_DC_SWITCHGATE_SWITCH_DOWN,
4476 EL_STEEL_EXIT_CLOSED,
4478 EL_STEELWALL_SLIPPERY,
4481 EL_QUICKSAND_FAST_EMPTY,
4482 EL_QUICKSAND_FAST_FULL,
4496 EL_SIGN_RADIOACTIVITY,
4502 EL_SIGN_ENTRY_FORBIDDEN,
4503 EL_SIGN_EMERGENCY_EXIT,
4528 EL_DC_STEELWALL_2_SINGLE,
4529 EL_DC_STEELWALL_2_TOP,
4530 EL_SIGN_EXCLAMATION,
4533 EL_DC_STEELWALL_2_LEFT,
4534 EL_DC_STEELWALL_2_MIDDLE,
4535 EL_DC_STEELWALL_2_HORIZONTAL,
4536 EL_DC_STEELWALL_2_RIGHT,
4538 EL_DC_STEELWALL_1_TOPLEFT,
4539 EL_DC_STEELWALL_2_VERTICAL,
4540 EL_DC_STEELWALL_1_TOPRIGHT,
4543 EL_DC_STEELWALL_1_VERTICAL,
4544 EL_DC_STEELWALL_2_BOTTOM,
4546 EL_DC_GATE_WHITE_GRAY,
4548 EL_DC_STEELWALL_1_BOTTOMLEFT,
4549 EL_DC_STEELWALL_1_HORIZONTAL,
4550 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4551 EL_DC_GATE_FAKE_GRAY,
4553 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4554 EL_DC_STEELWALL_1_BOTTOM,
4555 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
4556 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
4558 EL_DC_STEELWALL_1_RIGHT,
4560 EL_DC_STEELWALL_1_LEFT,
4561 EL_EXPANDABLE_STEELWALL_VERTICAL,
4563 EL_DC_STEELWALL_1_TOPRIGHT_2,
4564 EL_DC_STEELWALL_1_TOP,
4565 EL_DC_STEELWALL_1_TOPLEFT_2,
4566 EL_EXPANDABLE_STEELWALL_ANY,
4568 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
4569 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
4570 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
4571 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
4573 static int editor_hl_dx_boulderdash[] =
4575 EL_INTERNAL_CASCADE_DX_ACTIVE,
4581 static int editor_el_dx_boulderdash[] =
4585 EL_TUBE_HORIZONTAL_DOWN,
4589 EL_TUBE_VERTICAL_RIGHT,
4591 EL_TUBE_VERTICAL_LEFT,
4595 EL_TUBE_HORIZONTAL_UP,
4603 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
4604 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
4605 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
4606 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
4608 static int editor_hl_mirror_magic[] =
4610 EL_INTERNAL_CASCADE_MM_ACTIVE,
4616 static int editor_el_mirror_magic[] =
4618 EL_MM_MCDUFFIN_RIGHT,
4620 EL_MM_MCDUFFIN_LEFT,
4621 EL_MM_MCDUFFIN_DOWN,
4624 EL_MM_MIRROR_FIXED_START,
4625 EL_MM_POLARIZER_START,
4626 EL_MM_POLARIZER_CROSS_START,
4628 EL_MM_TELEPORTER_RED_START,
4629 EL_MM_TELEPORTER_YELLOW_START,
4630 EL_MM_TELEPORTER_GREEN_START,
4631 EL_MM_TELEPORTER_BLUE_START,
4644 EL_MM_LIGHTBULB_ACTIVE,
4658 EL_MM_STEEL_GRID_FIXED_1,
4659 EL_MM_STEEL_GRID_FIXED_2,
4660 EL_MM_STEEL_GRID_FIXED_3,
4661 EL_MM_STEEL_GRID_FIXED_4,
4663 EL_MM_WOODEN_GRID_FIXED_1,
4664 EL_MM_WOODEN_GRID_FIXED_2,
4665 EL_MM_WOODEN_GRID_FIXED_3,
4666 EL_MM_WOODEN_GRID_FIXED_4,
4673 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
4674 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
4675 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
4676 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
4678 static int editor_hl_deflektor[] =
4680 EL_INTERNAL_CASCADE_DF_ACTIVE,
4686 static int editor_el_deflektor[] =
4693 EL_DF_RECEIVER_RIGHT,
4695 EL_DF_RECEIVER_LEFT,
4696 EL_DF_RECEIVER_DOWN,
4699 EL_DF_MIRROR_ROTATING_START,
4703 EL_DF_FIBRE_OPTIC_RED_1,
4704 EL_DF_FIBRE_OPTIC_YELLOW_1,
4705 EL_DF_FIBRE_OPTIC_GREEN_1,
4706 EL_DF_FIBRE_OPTIC_BLUE_1,
4708 EL_DF_STEEL_GRID_FIXED_START,
4709 EL_DF_STEEL_GRID_ROTATING_START,
4710 EL_DF_WOODEN_GRID_FIXED_START,
4711 EL_DF_WOODEN_GRID_ROTATING_START,
4718 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
4719 static int *editor_el_deflektor_ptr = editor_el_deflektor;
4720 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
4721 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
4723 static int editor_hl_chars[] =
4725 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
4731 static int editor_el_chars[] =
4813 EL_CHAR(CHAR_BYTE_COPYRIGHT),
4814 EL_CHAR(CHAR_BYTE_UMLAUT_A),
4815 EL_CHAR(CHAR_BYTE_UMLAUT_O),
4816 EL_CHAR(CHAR_BYTE_UMLAUT_U),
4818 EL_CHAR(CHAR_BYTE_DEGREE),
4819 EL_CHAR(CHAR_BYTE_REGISTERED),
4820 EL_CHAR(FONT_ASCII_CURSOR),
4821 EL_CHAR(FONT_ASCII_BUTTON),
4823 EL_CHAR(FONT_ASCII_UP),
4824 EL_CHAR(FONT_ASCII_DOWN),
4828 static int *editor_hl_chars_ptr = editor_hl_chars;
4829 static int *editor_el_chars_ptr = editor_el_chars;
4830 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
4831 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
4833 static int editor_hl_steel_chars[] =
4835 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
4841 static int editor_el_steel_chars[] =
4851 EL_STEEL_CHAR('\''),
4918 EL_STEEL_CHAR('\\'),
4923 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
4924 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
4925 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
4926 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
4928 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
4929 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
4930 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4931 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4933 EL_STEEL_CHAR(FONT_ASCII_UP),
4934 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4938 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4939 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4940 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
4941 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
4943 static int editor_hl_custom[] =
4945 EL_INTERNAL_CASCADE_CE_ACTIVE,
4951 static int editor_el_custom[] =
4953 EL_CUSTOM_START + 0,
4954 EL_CUSTOM_START + 1,
4955 EL_CUSTOM_START + 2,
4956 EL_CUSTOM_START + 3,
4958 EL_CUSTOM_START + 4,
4959 EL_CUSTOM_START + 5,
4960 EL_CUSTOM_START + 6,
4961 EL_CUSTOM_START + 7,
4963 EL_CUSTOM_START + 8,
4964 EL_CUSTOM_START + 9,
4965 EL_CUSTOM_START + 10,
4966 EL_CUSTOM_START + 11,
4968 EL_CUSTOM_START + 12,
4969 EL_CUSTOM_START + 13,
4970 EL_CUSTOM_START + 14,
4971 EL_CUSTOM_START + 15,
4973 EL_CUSTOM_START + 16,
4974 EL_CUSTOM_START + 17,
4975 EL_CUSTOM_START + 18,
4976 EL_CUSTOM_START + 19,
4978 EL_CUSTOM_START + 20,
4979 EL_CUSTOM_START + 21,
4980 EL_CUSTOM_START + 22,
4981 EL_CUSTOM_START + 23,
4983 EL_CUSTOM_START + 24,
4984 EL_CUSTOM_START + 25,
4985 EL_CUSTOM_START + 26,
4986 EL_CUSTOM_START + 27,
4988 EL_CUSTOM_START + 28,
4989 EL_CUSTOM_START + 29,
4990 EL_CUSTOM_START + 30,
4991 EL_CUSTOM_START + 31,
4993 EL_CUSTOM_START + 32,
4994 EL_CUSTOM_START + 33,
4995 EL_CUSTOM_START + 34,
4996 EL_CUSTOM_START + 35,
4998 EL_CUSTOM_START + 36,
4999 EL_CUSTOM_START + 37,
5000 EL_CUSTOM_START + 38,
5001 EL_CUSTOM_START + 39,
5003 EL_CUSTOM_START + 40,
5004 EL_CUSTOM_START + 41,
5005 EL_CUSTOM_START + 42,
5006 EL_CUSTOM_START + 43,
5008 EL_CUSTOM_START + 44,
5009 EL_CUSTOM_START + 45,
5010 EL_CUSTOM_START + 46,
5011 EL_CUSTOM_START + 47,
5013 EL_CUSTOM_START + 48,
5014 EL_CUSTOM_START + 49,
5015 EL_CUSTOM_START + 50,
5016 EL_CUSTOM_START + 51,
5018 EL_CUSTOM_START + 52,
5019 EL_CUSTOM_START + 53,
5020 EL_CUSTOM_START + 54,
5021 EL_CUSTOM_START + 55,
5023 EL_CUSTOM_START + 56,
5024 EL_CUSTOM_START + 57,
5025 EL_CUSTOM_START + 58,
5026 EL_CUSTOM_START + 59,
5028 EL_CUSTOM_START + 60,
5029 EL_CUSTOM_START + 61,
5030 EL_CUSTOM_START + 62,
5031 EL_CUSTOM_START + 63,
5033 EL_CUSTOM_START + 64,
5034 EL_CUSTOM_START + 65,
5035 EL_CUSTOM_START + 66,
5036 EL_CUSTOM_START + 67,
5038 EL_CUSTOM_START + 68,
5039 EL_CUSTOM_START + 69,
5040 EL_CUSTOM_START + 70,
5041 EL_CUSTOM_START + 71,
5043 EL_CUSTOM_START + 72,
5044 EL_CUSTOM_START + 73,
5045 EL_CUSTOM_START + 74,
5046 EL_CUSTOM_START + 75,
5048 EL_CUSTOM_START + 76,
5049 EL_CUSTOM_START + 77,
5050 EL_CUSTOM_START + 78,
5051 EL_CUSTOM_START + 79,
5053 EL_CUSTOM_START + 80,
5054 EL_CUSTOM_START + 81,
5055 EL_CUSTOM_START + 82,
5056 EL_CUSTOM_START + 83,
5058 EL_CUSTOM_START + 84,
5059 EL_CUSTOM_START + 85,
5060 EL_CUSTOM_START + 86,
5061 EL_CUSTOM_START + 87,
5063 EL_CUSTOM_START + 88,
5064 EL_CUSTOM_START + 89,
5065 EL_CUSTOM_START + 90,
5066 EL_CUSTOM_START + 91,
5068 EL_CUSTOM_START + 92,
5069 EL_CUSTOM_START + 93,
5070 EL_CUSTOM_START + 94,
5071 EL_CUSTOM_START + 95,
5073 EL_CUSTOM_START + 96,
5074 EL_CUSTOM_START + 97,
5075 EL_CUSTOM_START + 98,
5076 EL_CUSTOM_START + 99,
5078 EL_CUSTOM_START + 100,
5079 EL_CUSTOM_START + 101,
5080 EL_CUSTOM_START + 102,
5081 EL_CUSTOM_START + 103,
5083 EL_CUSTOM_START + 104,
5084 EL_CUSTOM_START + 105,
5085 EL_CUSTOM_START + 106,
5086 EL_CUSTOM_START + 107,
5088 EL_CUSTOM_START + 108,
5089 EL_CUSTOM_START + 109,
5090 EL_CUSTOM_START + 110,
5091 EL_CUSTOM_START + 111,
5093 EL_CUSTOM_START + 112,
5094 EL_CUSTOM_START + 113,
5095 EL_CUSTOM_START + 114,
5096 EL_CUSTOM_START + 115,
5098 EL_CUSTOM_START + 116,
5099 EL_CUSTOM_START + 117,
5100 EL_CUSTOM_START + 118,
5101 EL_CUSTOM_START + 119,
5103 EL_CUSTOM_START + 120,
5104 EL_CUSTOM_START + 121,
5105 EL_CUSTOM_START + 122,
5106 EL_CUSTOM_START + 123,
5108 EL_CUSTOM_START + 124,
5109 EL_CUSTOM_START + 125,
5110 EL_CUSTOM_START + 126,
5111 EL_CUSTOM_START + 127,
5113 EL_CUSTOM_START + 128,
5114 EL_CUSTOM_START + 129,
5115 EL_CUSTOM_START + 130,
5116 EL_CUSTOM_START + 131,
5118 EL_CUSTOM_START + 132,
5119 EL_CUSTOM_START + 133,
5120 EL_CUSTOM_START + 134,
5121 EL_CUSTOM_START + 135,
5123 EL_CUSTOM_START + 136,
5124 EL_CUSTOM_START + 137,
5125 EL_CUSTOM_START + 138,
5126 EL_CUSTOM_START + 139,
5128 EL_CUSTOM_START + 140,
5129 EL_CUSTOM_START + 141,
5130 EL_CUSTOM_START + 142,
5131 EL_CUSTOM_START + 143,
5133 EL_CUSTOM_START + 144,
5134 EL_CUSTOM_START + 145,
5135 EL_CUSTOM_START + 146,
5136 EL_CUSTOM_START + 147,
5138 EL_CUSTOM_START + 148,
5139 EL_CUSTOM_START + 149,
5140 EL_CUSTOM_START + 150,
5141 EL_CUSTOM_START + 151,
5143 EL_CUSTOM_START + 152,
5144 EL_CUSTOM_START + 153,
5145 EL_CUSTOM_START + 154,
5146 EL_CUSTOM_START + 155,
5148 EL_CUSTOM_START + 156,
5149 EL_CUSTOM_START + 157,
5150 EL_CUSTOM_START + 158,
5151 EL_CUSTOM_START + 159,
5153 EL_CUSTOM_START + 160,
5154 EL_CUSTOM_START + 161,
5155 EL_CUSTOM_START + 162,
5156 EL_CUSTOM_START + 163,
5158 EL_CUSTOM_START + 164,
5159 EL_CUSTOM_START + 165,
5160 EL_CUSTOM_START + 166,
5161 EL_CUSTOM_START + 167,
5163 EL_CUSTOM_START + 168,
5164 EL_CUSTOM_START + 169,
5165 EL_CUSTOM_START + 170,
5166 EL_CUSTOM_START + 171,
5168 EL_CUSTOM_START + 172,
5169 EL_CUSTOM_START + 173,
5170 EL_CUSTOM_START + 174,
5171 EL_CUSTOM_START + 175,
5173 EL_CUSTOM_START + 176,
5174 EL_CUSTOM_START + 177,
5175 EL_CUSTOM_START + 178,
5176 EL_CUSTOM_START + 179,
5178 EL_CUSTOM_START + 180,
5179 EL_CUSTOM_START + 181,
5180 EL_CUSTOM_START + 182,
5181 EL_CUSTOM_START + 183,
5183 EL_CUSTOM_START + 184,
5184 EL_CUSTOM_START + 185,
5185 EL_CUSTOM_START + 186,
5186 EL_CUSTOM_START + 187,
5188 EL_CUSTOM_START + 188,
5189 EL_CUSTOM_START + 189,
5190 EL_CUSTOM_START + 190,
5191 EL_CUSTOM_START + 191,
5193 EL_CUSTOM_START + 192,
5194 EL_CUSTOM_START + 193,
5195 EL_CUSTOM_START + 194,
5196 EL_CUSTOM_START + 195,
5198 EL_CUSTOM_START + 196,
5199 EL_CUSTOM_START + 197,
5200 EL_CUSTOM_START + 198,
5201 EL_CUSTOM_START + 199,
5203 EL_CUSTOM_START + 200,
5204 EL_CUSTOM_START + 201,
5205 EL_CUSTOM_START + 202,
5206 EL_CUSTOM_START + 203,
5208 EL_CUSTOM_START + 204,
5209 EL_CUSTOM_START + 205,
5210 EL_CUSTOM_START + 206,
5211 EL_CUSTOM_START + 207,
5213 EL_CUSTOM_START + 208,
5214 EL_CUSTOM_START + 209,
5215 EL_CUSTOM_START + 210,
5216 EL_CUSTOM_START + 211,
5218 EL_CUSTOM_START + 212,
5219 EL_CUSTOM_START + 213,
5220 EL_CUSTOM_START + 214,
5221 EL_CUSTOM_START + 215,
5223 EL_CUSTOM_START + 216,
5224 EL_CUSTOM_START + 217,
5225 EL_CUSTOM_START + 218,
5226 EL_CUSTOM_START + 219,
5228 EL_CUSTOM_START + 220,
5229 EL_CUSTOM_START + 221,
5230 EL_CUSTOM_START + 222,
5231 EL_CUSTOM_START + 223,
5233 EL_CUSTOM_START + 224,
5234 EL_CUSTOM_START + 225,
5235 EL_CUSTOM_START + 226,
5236 EL_CUSTOM_START + 227,
5238 EL_CUSTOM_START + 228,
5239 EL_CUSTOM_START + 229,
5240 EL_CUSTOM_START + 230,
5241 EL_CUSTOM_START + 231,
5243 EL_CUSTOM_START + 232,
5244 EL_CUSTOM_START + 233,
5245 EL_CUSTOM_START + 234,
5246 EL_CUSTOM_START + 235,
5248 EL_CUSTOM_START + 236,
5249 EL_CUSTOM_START + 237,
5250 EL_CUSTOM_START + 238,
5251 EL_CUSTOM_START + 239,
5253 EL_CUSTOM_START + 240,
5254 EL_CUSTOM_START + 241,
5255 EL_CUSTOM_START + 242,
5256 EL_CUSTOM_START + 243,
5258 EL_CUSTOM_START + 244,
5259 EL_CUSTOM_START + 245,
5260 EL_CUSTOM_START + 246,
5261 EL_CUSTOM_START + 247,
5263 EL_CUSTOM_START + 248,
5264 EL_CUSTOM_START + 249,
5265 EL_CUSTOM_START + 250,
5266 EL_CUSTOM_START + 251,
5268 EL_CUSTOM_START + 252,
5269 EL_CUSTOM_START + 253,
5270 EL_CUSTOM_START + 254,
5271 EL_CUSTOM_START + 255
5273 static int *editor_hl_custom_ptr = editor_hl_custom;
5274 static int *editor_el_custom_ptr = editor_el_custom;
5275 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5276 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5278 static int editor_hl_group[] =
5280 EL_INTERNAL_CASCADE_GE_ACTIVE,
5286 static int editor_el_group[] =
5300 EL_GROUP_START + 10,
5301 EL_GROUP_START + 11,
5303 EL_GROUP_START + 12,
5304 EL_GROUP_START + 13,
5305 EL_GROUP_START + 14,
5306 EL_GROUP_START + 15,
5308 EL_GROUP_START + 16,
5309 EL_GROUP_START + 17,
5310 EL_GROUP_START + 18,
5311 EL_GROUP_START + 19,
5313 EL_GROUP_START + 20,
5314 EL_GROUP_START + 21,
5315 EL_GROUP_START + 22,
5316 EL_GROUP_START + 23,
5318 EL_GROUP_START + 24,
5319 EL_GROUP_START + 25,
5320 EL_GROUP_START + 26,
5321 EL_GROUP_START + 27,
5323 EL_GROUP_START + 28,
5324 EL_GROUP_START + 29,
5325 EL_GROUP_START + 30,
5328 static int *editor_hl_group_ptr = editor_hl_group;
5329 static int *editor_el_group_ptr = editor_el_group;
5330 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5331 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5333 static int editor_hl_empty_space[] =
5335 EL_INTERNAL_CASCADE_ES_ACTIVE,
5341 static int editor_el_empty_space[] =
5363 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
5364 static int *editor_el_empty_space_ptr = editor_el_empty_space;
5365 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
5366 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
5368 static int editor_hl_reference[] =
5370 EL_INTERNAL_CASCADE_REF_ACTIVE,
5376 static int editor_el_reference[] =
5380 EL_TRIGGER_CE_VALUE,
5381 EL_TRIGGER_CE_SCORE,
5385 EL_CURRENT_CE_VALUE,
5386 EL_CURRENT_CE_SCORE,
5408 static int *editor_hl_reference_ptr = editor_hl_reference;
5409 static int *editor_el_reference_ptr = editor_el_reference;
5410 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5411 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5413 static int editor_hl_user_defined[] =
5415 EL_INTERNAL_CASCADE_USER_ACTIVE,
5421 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5422 static int *editor_el_user_defined_ptr = NULL;
5423 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5424 static int num_editor_el_user_defined = 0;
5426 static int editor_hl_dynamic[] =
5428 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5434 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5435 static int *editor_el_dynamic_ptr = NULL;
5436 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5437 static int num_editor_el_dynamic = 0;
5439 static int editor_hl_empty[] = { EL_EMPTY };
5440 static int *editor_el_empty = NULL; // dynamically allocated
5442 static int *editor_hl_empty_ptr = editor_hl_empty;
5443 static int *editor_el_empty_ptr = NULL;
5444 static int num_editor_hl_empty = 0;
5445 static int num_editor_el_empty = 0; // dynamically determined, if needed
5447 static boolean use_el_empty = FALSE;
5449 static int *editor_elements = NULL; // dynamically allocated
5450 static int num_editor_elements = 0; // dynamically determined
5452 static boolean setup_editor_cascade_never = FALSE;
5454 static boolean setup_editor_el_players = TRUE;
5455 static boolean setup_editor_el_boulderdash = TRUE;
5456 static boolean setup_editor_el_emerald_mine = TRUE;
5457 static boolean setup_editor_el_emerald_mine_club = TRUE;
5458 static boolean setup_editor_el_more = TRUE;
5459 static boolean setup_editor_el_sokoban = TRUE;
5460 static boolean setup_editor_el_supaplex = TRUE;
5461 static boolean setup_editor_el_diamond_caves = TRUE;
5462 static boolean setup_editor_el_dx_boulderdash = TRUE;
5463 static boolean setup_editor_el_mirror_magic = TRUE;
5464 static boolean setup_editor_el_deflektor = TRUE;
5465 static boolean setup_editor_el_chars = TRUE;
5466 static boolean setup_editor_el_steel_chars = TRUE;
5467 static boolean setup_editor_el_custom = TRUE;
5468 static boolean setup_editor_el_user_defined = TRUE;
5469 static boolean setup_editor_el_dynamic = TRUE;
5471 static int editor_hl_unused[] = { EL_EMPTY };
5472 static int *editor_hl_unused_ptr = editor_hl_unused;
5473 static int num_editor_hl_unused = 0;
5477 boolean *setup_value;
5478 boolean *setup_cascade_value;
5480 int **headline_list;
5481 int *headline_list_size;
5484 int *element_list_size;
5486 boolean last_setup_value;
5488 editor_elements_info[] =
5491 &setup_editor_el_players,
5492 &setup_editor_cascade_never,
5493 &editor_hl_unused_ptr, &num_editor_hl_unused,
5494 &editor_el_players_ptr, &num_editor_el_players
5497 &setup_editor_el_boulderdash,
5498 &setup.editor_cascade.el_bd,
5499 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5500 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5503 &setup_editor_el_emerald_mine,
5504 &setup.editor_cascade.el_em,
5505 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5506 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5509 &setup_editor_el_emerald_mine_club,
5510 &setup.editor_cascade.el_emc,
5511 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5512 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5515 &setup_editor_el_more,
5516 &setup.editor_cascade.el_rnd,
5517 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5518 &editor_el_rnd_ptr, &num_editor_el_rnd
5521 &setup_editor_el_sokoban,
5522 &setup.editor_cascade.el_sb,
5523 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5524 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5527 &setup_editor_el_supaplex,
5528 &setup.editor_cascade.el_sp,
5529 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5530 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5533 &setup_editor_el_diamond_caves,
5534 &setup.editor_cascade.el_dc,
5535 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5536 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5539 &setup_editor_el_dx_boulderdash,
5540 &setup.editor_cascade.el_dx,
5541 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5542 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
5545 &setup_editor_el_mirror_magic,
5546 &setup.editor_cascade.el_mm,
5547 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
5548 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
5551 &setup_editor_el_deflektor,
5552 &setup.editor_cascade.el_df,
5553 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
5554 &editor_el_deflektor_ptr, &num_editor_el_deflektor
5557 &setup_editor_el_chars,
5558 &setup.editor_cascade.el_chars,
5559 &editor_hl_chars_ptr, &num_editor_hl_chars,
5560 &editor_el_chars_ptr, &num_editor_el_chars
5563 &setup_editor_el_steel_chars,
5564 &setup.editor_cascade.el_steel_chars,
5565 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
5566 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
5569 &setup_editor_el_custom,
5570 &setup.editor_cascade.el_ce,
5571 &editor_hl_custom_ptr, &num_editor_hl_custom,
5572 &editor_el_custom_ptr, &num_editor_el_custom
5575 &setup_editor_el_custom,
5576 &setup.editor_cascade.el_ge,
5577 &editor_hl_group_ptr, &num_editor_hl_group,
5578 &editor_el_group_ptr, &num_editor_el_group
5581 &setup_editor_el_custom,
5582 &setup.editor_cascade.el_es,
5583 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
5584 &editor_el_empty_space_ptr, &num_editor_el_empty_space
5587 &setup_editor_el_custom,
5588 &setup.editor_cascade.el_ref,
5589 &editor_hl_reference_ptr, &num_editor_hl_reference,
5590 &editor_el_reference_ptr, &num_editor_el_reference
5593 &setup_editor_el_user_defined,
5594 &setup.editor_cascade.el_user,
5595 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
5596 &editor_el_user_defined_ptr, &num_editor_el_user_defined
5599 &setup_editor_el_dynamic,
5600 &setup.editor_cascade.el_dynamic,
5601 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
5602 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
5607 &editor_hl_empty_ptr, &num_editor_hl_empty,
5608 &editor_el_empty_ptr, &num_editor_el_empty,
5618 static struct XY xy_directions[] =
5627 // ----------------------------------------------------------------------------
5629 // ----------------------------------------------------------------------------
5631 static int getMaxInfoTextLength(void)
5633 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
5636 static int getTextWidthForGadget(char *text)
5641 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
5644 static int getTextWidthForDrawingArea(char *text)
5649 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
5652 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
5654 return (gi->x + gi->width + getTextWidthForGadget(text));
5657 static char *getElementInfoText(int element)
5659 char *info_text = NULL;
5661 if (element < MAX_NUM_ELEMENTS)
5663 if (strlen(element_info[element].description) > 0)
5664 info_text = element_info[element].description;
5665 else if (element_info[element].custom_description != NULL)
5666 info_text = element_info[element].custom_description;
5667 else if (element_info[element].editor_description != NULL)
5668 info_text = element_info[element].editor_description;
5671 if (info_text == NULL)
5672 info_text = INFOTEXT_UNKNOWN_ELEMENT;
5677 static char *getElementDescriptionFilenameExt(char *basename)
5679 char *elements_subdir = ELEMENTS_DIRECTORY;
5680 static char *elements_subdir2 = NULL;
5681 static char *filename = NULL;
5683 if (elements_subdir2 == NULL)
5684 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
5686 checked_free(filename);
5688 // 1st try: look for element description in current level set directory
5689 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
5690 if (fileExists(filename))
5695 // 2nd try: look for element description in the game's base directory
5696 filename = getPath3(options.docs_directory, elements_subdir, basename);
5697 if (fileExists(filename))
5703 static char *getElementDescriptionFilename(int element)
5705 char basename[MAX_FILENAME_LEN];
5708 // 1st try: look for element description file for exactly this element
5709 sprintf(basename, "%s.txt", element_info[element].token_name);
5710 filename = getElementDescriptionFilenameExt(basename);
5711 if (filename != NULL)
5714 // 2nd try: look for element description file for this element's class
5715 sprintf(basename, "%s.txt", element_info[element].class_name);
5716 filename = getElementDescriptionFilenameExt(basename);
5717 if (filename != NULL)
5720 // 3rd try: look for generic fallback text file for any element
5721 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
5722 if (filename != NULL)
5728 static boolean suppressBorderElement(void)
5730 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
5731 lev_fieldx <= MAX_ED_FIELDX &&
5732 lev_fieldy <= MAX_ED_FIELDY);
5735 static void InitDynamicEditorElementList(int **elements, int *num_elements)
5737 boolean element_found[NUM_FILE_ELEMENTS];
5740 // initialize list of used elements to "not used"
5741 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5742 element_found[i] = FALSE;
5744 // find all elements used in current level
5745 for (y = 0; y < lev_fieldy; y++)
5747 for (x = 0; x < lev_fieldx; x++)
5749 if (Tile[x][y] >= NUM_FILE_ELEMENTS) // should never happen
5752 if (IS_MM_WALL(Tile[x][y]))
5753 element_found[map_mm_wall_element(Tile[x][y])] = TRUE;
5755 element_found[Tile[x][y]] = TRUE;
5761 // count number of elements used in current level
5762 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5763 if (element_found[i])
5766 // add space for up to 3 more elements for padding that may be needed
5769 // free memory for old list of elements, if needed
5770 checked_free(*elements);
5772 // allocate memory for new list of elements
5773 *elements = checked_malloc(*num_elements * sizeof(int));
5777 // add all elements used in current level (non-custom/group/empty elements)
5778 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5779 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) ||
5780 IS_GROUP_ELEMENT(i) ||
5781 IS_EMPTY_ELEMENT(i)))
5782 (*elements)[(*num_elements)++] = i;
5784 // add all elements used in current level (custom/group/empty elements)
5785 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5786 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) ||
5787 IS_GROUP_ELEMENT(i) ||
5788 IS_EMPTY_ELEMENT(i)))
5789 (*elements)[(*num_elements)++] = i;
5791 while (*num_elements % 4) // pad with empty elements, if needed
5792 (*elements)[(*num_elements)++] = EL_EMPTY;
5795 static void ReinitializeElementList_EnableSections(void)
5797 // default: enable all element sections
5799 setup_editor_el_players = TRUE;
5800 setup_editor_el_boulderdash = TRUE;
5801 setup_editor_el_emerald_mine = TRUE;
5802 setup_editor_el_emerald_mine_club = TRUE;
5803 setup_editor_el_more = TRUE;
5804 setup_editor_el_sokoban = TRUE;
5805 setup_editor_el_supaplex = TRUE;
5806 setup_editor_el_diamond_caves = TRUE;
5807 setup_editor_el_dx_boulderdash = TRUE;
5808 setup_editor_el_mirror_magic = TRUE;
5809 setup_editor_el_deflektor = TRUE;
5810 setup_editor_el_chars = TRUE;
5811 setup_editor_el_steel_chars = TRUE;
5813 setup_editor_el_custom = TRUE;
5814 setup_editor_el_user_defined = TRUE;
5815 setup_editor_el_dynamic = TRUE;
5817 // now disable all element sections not to be displayed
5819 if (!setup.editor.el_classic)
5821 setup_editor_el_players = FALSE;
5822 setup_editor_el_boulderdash = FALSE;
5823 setup_editor_el_emerald_mine = FALSE;
5824 setup_editor_el_emerald_mine_club = FALSE;
5825 setup_editor_el_more = FALSE;
5826 setup_editor_el_sokoban = FALSE;
5827 setup_editor_el_supaplex = FALSE;
5828 setup_editor_el_diamond_caves = FALSE;
5829 setup_editor_el_dx_boulderdash = FALSE;
5830 setup_editor_el_mirror_magic = FALSE;
5831 setup_editor_el_deflektor = FALSE;
5832 setup_editor_el_chars = FALSE;
5833 setup_editor_el_steel_chars = FALSE;
5836 if (!setup.editor.el_custom)
5838 setup_editor_el_custom = FALSE;
5841 if (!setup.editor.el_user_defined)
5843 setup_editor_el_user_defined = FALSE;
5846 if (!setup.editor.el_dynamic)
5848 setup_editor_el_dynamic = FALSE;
5851 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
5853 setup_editor_el_mirror_magic = FALSE;
5854 setup_editor_el_deflektor = FALSE;
5856 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
5858 setup_editor_el_boulderdash = FALSE;
5859 setup_editor_el_more = FALSE;
5860 setup_editor_el_sokoban = FALSE;
5861 setup_editor_el_supaplex = FALSE;
5862 setup_editor_el_diamond_caves = FALSE;
5863 setup_editor_el_dx_boulderdash = FALSE;
5864 setup_editor_el_mirror_magic = FALSE;
5865 setup_editor_el_deflektor = FALSE;
5866 setup_editor_el_steel_chars = FALSE;
5868 setup_editor_el_custom = FALSE;
5870 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
5872 setup_editor_el_players = FALSE;
5873 setup_editor_el_boulderdash = FALSE;
5874 setup_editor_el_emerald_mine = FALSE;
5875 setup_editor_el_emerald_mine_club = FALSE;
5876 setup_editor_el_more = FALSE;
5877 setup_editor_el_sokoban = FALSE;
5878 setup_editor_el_diamond_caves = FALSE;
5879 setup_editor_el_dx_boulderdash = FALSE;
5880 setup_editor_el_mirror_magic = FALSE;
5881 setup_editor_el_deflektor = FALSE;
5882 setup_editor_el_chars = FALSE;
5883 setup_editor_el_steel_chars = FALSE;
5885 setup_editor_el_custom = FALSE;
5887 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
5889 setup_editor_el_players = FALSE;
5890 setup_editor_el_boulderdash = FALSE;
5891 setup_editor_el_emerald_mine = FALSE;
5892 setup_editor_el_emerald_mine_club = FALSE;
5893 setup_editor_el_more = FALSE;
5894 setup_editor_el_sokoban = FALSE;
5895 setup_editor_el_supaplex = FALSE;
5896 setup_editor_el_diamond_caves = FALSE;
5897 setup_editor_el_dx_boulderdash = FALSE;
5898 setup_editor_el_steel_chars = FALSE;
5900 setup_editor_el_custom = FALSE;
5904 static void ReinitializeElementList(void)
5906 static boolean initialization_needed = TRUE;
5910 ReinitializeElementList_EnableSections();
5912 if (initialization_needed)
5914 LoadSetup_EditorCascade(); // load last editor cascade state
5916 // initialize editor cascade element from saved cascade state
5917 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5919 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
5920 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
5922 if (IS_EDITOR_CASCADE(*cascade_element))
5924 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
5925 EL_CASCADE_INACTIVE(*cascade_element));
5928 initialization_needed = FALSE;
5931 checked_free(editor_elements);
5933 // reload optional user defined element list for each invocation of editor
5934 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
5935 &num_editor_el_user_defined);
5937 // initialize dynamic level element list for each invocation of editor
5938 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
5939 &num_editor_el_dynamic);
5941 // initialize list of empty elements (used for padding, if needed)
5942 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5943 editor_el_empty[i] = EL_EMPTY;
5945 // do some sanity checks for each element from element list
5946 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5948 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5950 int element = (*editor_elements_info[i].element_list)[j];
5952 if (element >= NUM_FILE_ELEMENTS)
5953 Warn("editor element %d is runtime element", element);
5955 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
5956 Warn("no element description text for element %d", element);
5960 num_editor_elements = 0;
5961 use_el_empty = FALSE;
5963 // determine size of element list
5964 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5966 if (*editor_elements_info[i].setup_value)
5968 boolean found_inactive_cascade = FALSE;
5970 if (setup.editor.el_headlines)
5972 // required for correct padding of palette headline buttons
5973 if (*editor_elements_info[i].headline_list_size > 0)
5974 num_editor_elements += ED_ELEMENTLIST_COLS;
5976 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5978 int element = (*editor_elements_info[i].headline_list)[j];
5980 if (IS_EDITOR_CASCADE_INACTIVE(element))
5981 found_inactive_cascade = TRUE;
5985 if (found_inactive_cascade)
5988 // required for correct padding of palette element buttons
5989 int element_list_size = *editor_elements_info[i].element_list_size;
5991 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
5992 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
5994 num_editor_elements += element_buttons;
5998 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
6000 // offer at least as many elements as element buttons exist
6001 use_el_empty = TRUE;
6002 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
6004 num_editor_elements += num_editor_el_empty;
6008 num_editor_el_empty = 0;
6011 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
6013 // fill element list
6014 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6016 boolean found_inactive_cascade = FALSE;
6018 if (*editor_elements_info[i].setup_value)
6020 if (setup.editor.el_headlines)
6022 // required for correct padding of palette headline buttons
6023 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6024 ED_ELEMENTLIST_COLS : 0);
6026 for (j = 0; j < headline_size; j++)
6028 // use empty elements for padding of palette headline buttons
6029 int element = (j < *editor_elements_info[i].headline_list_size ?
6030 (*editor_elements_info[i].headline_list)[j] :
6031 editor_el_empty[0]);
6033 editor_elements[pos++] = element;
6035 if (IS_EDITOR_CASCADE_INACTIVE(element))
6036 found_inactive_cascade = TRUE;
6040 if (found_inactive_cascade)
6043 // required for correct padding of palette element buttons
6044 int element_list_size = *editor_elements_info[i].element_list_size;
6046 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6047 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6049 // copy all elements from element list
6050 for (j = 0; j < element_list_size; j++)
6051 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6053 // use empty elements for padding of palette element buttons
6054 for (j = 0; j < element_buttons - element_list_size; j++)
6055 editor_elements[pos++] = editor_el_empty[0];
6059 // (this function is also called before editor gadgets are initialized!)
6060 AdjustElementListScrollbar();
6063 void PrintEditorElementList(void)
6065 boolean *stop = &setup_editor_el_user_defined;
6068 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6070 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6072 if (IS_EDITOR_CASCADE(cascade_element))
6074 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6075 char *headline = element_info[cascade_element_show].editor_description;
6077 PrintLineWithPrefix("# ", "-", 77);
6078 Print("# %s\n", headline);
6079 PrintLineWithPrefix("# ", "-", 77);
6082 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6084 int element = (*editor_elements_info[i].headline_list)[j];
6086 if (IS_EDITOR_CASCADE(element))
6087 element = EL_CHAR_MINUS;
6089 Print("# %s\n", element_info[element].token_name);
6095 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6097 int element = (*editor_elements_info[i].element_list)[j];
6099 Print("# %s\n", element_info[element].token_name);
6107 static void ReinitializeElementListButtons(void)
6109 static boolean last_setup_value_headlines = FALSE;
6110 static boolean initialization_needed = TRUE;
6113 if (!initialization_needed) // check if editor element setup has changed
6115 if (last_setup_value_headlines != setup.editor.el_headlines)
6116 initialization_needed = TRUE;
6118 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6119 if (editor_elements_info[i].last_setup_value !=
6120 *editor_elements_info[i].setup_value)
6121 initialization_needed = TRUE;
6124 if (!initialization_needed)
6127 FreeLevelEditorGadgets();
6128 CreateLevelEditorGadgets();
6130 // store current setup values for next invocation of this function
6131 last_setup_value_headlines = setup.editor.el_headlines;
6132 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6133 editor_elements_info[i].last_setup_value =
6134 *editor_elements_info[i].setup_value;
6136 initialization_needed = FALSE;
6139 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6142 int border_graphic =
6143 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6144 struct GraphicInfo *g = &graphic_info[border_graphic];
6145 Bitmap *src_bitmap = g->bitmap;
6146 int src_x = g->src_x;
6147 int src_y = g->src_y;
6148 int border_size = g->border_size;
6149 int border_xpos = g->width - border_size;
6150 int border_ypos = g->height - border_size;
6151 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6154 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6155 border_size, border_size,
6156 dest_x - border_size, dest_y - border_size);
6157 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6158 border_size, border_size,
6159 dest_x + width, dest_y - border_size);
6160 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6161 border_size, border_size,
6162 dest_x - border_size, dest_y + height);
6163 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6164 border_size, border_size,
6165 dest_x + width, dest_y + height);
6167 for (i = 0; i < width / tilesize; i++)
6169 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6170 tilesize, border_size,
6171 dest_x + i * tilesize, dest_y - border_size);
6172 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6173 tilesize, border_size,
6174 dest_x + i * tilesize, dest_y + height);
6177 for (i = 0; i < height / tilesize; i++)
6179 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6180 border_size, tilesize,
6181 dest_x - border_size, dest_y + i * tilesize);
6182 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6183 border_size, tilesize,
6184 dest_x + width, dest_y + i * tilesize);
6187 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6190 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6192 int xsize_tile = MAX(ed_tilesize, xsize);
6193 int ysize_tile = MAX(ed_tilesize, ysize);
6194 int xsize_full = xsize + 1;
6195 int ysize_full = ysize + 1;
6196 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6197 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6198 Pixel line_color = getTabulatorBarColor();
6200 if (line_color == BLACK_PIXEL) // black => transparent
6203 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6204 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6205 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6208 static void DrawEditorLevelBorderLinesIfNeeded(void)
6210 int xsize = lev_fieldx * ed_tilesize;
6211 int ysize = lev_fieldy * ed_tilesize;
6212 int line_size = getTabulatorBarHeight();
6214 if (!suppressBorderElement())
6217 // draw little border line around editable level playfield
6220 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6223 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6225 if (xsize < SXSIZE && ysize < SYSIZE)
6226 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6229 static void DrawEditorElement(int x, int y, int element)
6231 DrawSizedElement(x, y, element, ed_tilesize);
6234 static void DrawEditorElementThruMask(int x, int y, int element)
6236 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6239 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6241 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6244 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6246 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6247 DrawEditorLevelBorderLinesIfNeeded();
6250 static void DrawDrawingArea(int id)
6252 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6255 int *value = drawingarea_info[id].value;
6256 int area_xsize = drawingarea_info[id].area_xsize;
6257 int area_ysize = drawingarea_info[id].area_ysize;
6258 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6260 for (x = 0; x < area_xsize; x++)
6261 for (y = 0; y < area_ysize; y++)
6262 DrawSizedGraphicExt(drawto,
6263 gi->x + x * tilesize,
6264 gi->y + y * tilesize,
6265 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6268 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6271 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6272 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6274 BlitBitmap(drawto, drawto,
6275 SX + (dx == -1 ? ed_tilesize : 0),
6276 SY + (dy == -1 ? ed_tilesize : 0),
6277 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6278 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6279 SX + (dx == +1 ? ed_tilesize : 0),
6280 SY + (dy == +1 ? ed_tilesize : 0));
6284 x = (dx == 1 ? 0 : ed_fieldx - 1);
6285 for (y = 0; y < ed_fieldy; y++)
6286 DrawEditorElementOrWall(x, y, from_x, from_y);
6290 y = (dy == 1 ? 0 : ed_fieldy - 1);
6291 for (x = 0; x < ed_fieldx; x++)
6292 DrawEditorElementOrWall(x, y, from_x, from_y);
6295 redraw_mask |= REDRAW_FIELD;
6299 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6302 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6305 static void CreateControlButtons(void)
6307 struct GadgetInfo *gi;
6310 // create toolbox buttons
6311 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6313 int id = controlbutton_info[i].gadget_id;
6314 int type = controlbutton_info[i].gadget_type;
6315 int graphic = controlbutton_info[i].graphic;
6316 struct XYTileSize *pos = controlbutton_info[i].pos;
6317 struct GraphicInfo *gd = &graphic_info[graphic];
6318 Bitmap *deco_bitmap = NULL;
6319 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6320 int tile_size = 0, deco_shift = 0;
6321 boolean deco_masked = FALSE;
6322 int gd_x1 = gd->src_x;
6323 int gd_y1 = gd->src_y;
6324 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6325 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6326 int gd_x1a = gd->src_x + gd->active_xoffset;
6327 int gd_y1a = gd->src_y + gd->active_yoffset;
6328 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6329 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6332 unsigned int event_mask;
6333 int radio_button_nr = RADIO_NR_NONE;
6334 boolean checked = FALSE;
6336 if (type == GD_TYPE_RADIO_BUTTON)
6338 event_mask = GD_EVENT_PRESSED;
6339 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6341 if (id == drawing_function)
6346 if (id == GADGET_ID_WRAP_LEFT ||
6347 id == GADGET_ID_WRAP_RIGHT ||
6348 id == GADGET_ID_WRAP_UP ||
6349 id == GADGET_ID_WRAP_DOWN)
6350 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6352 event_mask = GD_EVENT_RELEASED;
6355 if (id == GADGET_ID_PROPERTIES ||
6356 id == GADGET_ID_PALETTE)
6361 else if (id == GADGET_ID_ELEMENT_LEFT ||
6362 id == GADGET_ID_ELEMENT_MIDDLE ||
6363 id == GADGET_ID_ELEMENT_RIGHT)
6368 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6369 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6370 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6372 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6373 editor.button.element_left.tile_size :
6374 id == GADGET_ID_ELEMENT_MIDDLE ?
6375 editor.button.element_middle.tile_size :
6376 id == GADGET_ID_ELEMENT_RIGHT ?
6377 editor.button.element_right.tile_size : 0);
6379 // make sure that decoration does not overlap gadget border
6380 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6382 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6384 deco_xpos = (gd->width - tile_size) / 2;
6385 deco_ypos = (gd->height - tile_size) / 2;
6387 deco_masked = gd->draw_masked;
6395 gi = CreateGadget(GDI_CUSTOM_ID, id,
6396 GDI_CUSTOM_TYPE_ID, i,
6397 GDI_IMAGE_ID, graphic,
6398 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6401 GDI_WIDTH, gd->width,
6402 GDI_HEIGHT, gd->height,
6404 GDI_STATE, GD_BUTTON_UNPRESSED,
6405 GDI_RADIO_NR, radio_button_nr,
6406 GDI_CHECKED, checked,
6407 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6408 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6409 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6410 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6411 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6412 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6413 GDI_DECORATION_SIZE, tile_size, tile_size,
6414 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6415 GDI_DECORATION_MASKED, deco_masked,
6416 GDI_EVENT_MASK, event_mask,
6417 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6418 GDI_CALLBACK_ACTION, HandleControlButtons,
6422 Fail("cannot create gadget");
6424 level_editor_gadget[id] = gi;
6427 // these values are not constant, but can change at runtime
6428 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6429 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6430 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6431 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6432 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6433 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6434 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6435 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6436 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6437 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6438 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6439 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6441 // create buttons for scrolling of drawing area and element list
6442 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6444 int id = scrollbutton_info[i].gadget_id;
6445 int graphic = scrollbutton_info[i].graphic;
6446 struct GraphicInfo *gd = &graphic_info[graphic];
6447 Bitmap *gd_bitmap = gd->bitmap;
6448 int gd_x1 = gd->src_x;
6449 int gd_y1 = gd->src_y;
6450 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6451 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6452 int width = gd->width;
6453 int height = gd->height;
6454 int x = scrollbutton_pos[i].x;
6455 int y = scrollbutton_pos[i].y;
6456 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6458 if (id == GADGET_ID_SCROLL_LIST_UP ||
6459 id == GADGET_ID_SCROLL_LIST_DOWN)
6470 gi = CreateGadget(GDI_CUSTOM_ID, id,
6471 GDI_CUSTOM_TYPE_ID, i,
6472 GDI_IMAGE_ID, graphic,
6473 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6478 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6479 GDI_STATE, GD_BUTTON_UNPRESSED,
6480 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6481 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6482 GDI_EVENT_MASK, event_mask,
6483 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6484 GDI_CALLBACK_ACTION, HandleControlButtons,
6488 Fail("cannot create gadget");
6490 level_editor_gadget[id] = gi;
6493 // create buttons for element list
6494 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6496 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6497 int graphic = IMG_EDITOR_PALETTE_BUTTON;
6498 struct GraphicInfo *gd = &graphic_info[graphic];
6499 Bitmap *gd_bitmap = gd->bitmap;
6500 Bitmap *deco_bitmap;
6501 int deco_x, deco_y, deco_xpos, deco_ypos;
6502 int gd_x1 = gd->src_x;
6503 int gd_y1 = gd->src_y;
6504 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6505 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6506 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
6507 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
6508 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
6509 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
6510 int element = editor_elements[i];
6511 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
6512 unsigned int event_mask = GD_EVENT_RELEASED;
6514 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
6516 deco_xpos = (gd->width - tile_size) / 2;
6517 deco_ypos = (gd->height - tile_size) / 2;
6519 gi = CreateGadget(GDI_CUSTOM_ID, id,
6520 GDI_CUSTOM_TYPE_ID, i,
6521 GDI_IMAGE_ID, graphic,
6522 GDI_INFO_TEXT, getElementInfoText(element),
6525 GDI_WIDTH, gd->width,
6526 GDI_HEIGHT, gd->height,
6527 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6528 GDI_STATE, GD_BUTTON_UNPRESSED,
6529 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6530 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6531 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6532 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6533 GDI_DECORATION_SIZE, tile_size, tile_size,
6534 GDI_DECORATION_SHIFTING, 1, 1,
6535 GDI_EVENT_MASK, event_mask,
6536 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6537 GDI_CALLBACK_ACTION, HandleControlButtons,
6541 Fail("cannot create gadget");
6543 level_editor_gadget[id] = gi;
6547 static void CreateCounterButtons(void)
6549 int max_infotext_len = getMaxInfoTextLength();
6552 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
6555 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
6556 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
6558 // determine horizontal position to the right of specified gadget
6559 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6560 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
6561 ED_GADGET_TEXT_DISTANCE);
6563 // determine horizontal offset for leading text
6564 if (counterbutton_info[i].text_left != NULL)
6565 x += getTextWidthForGadget(counterbutton_info[i].text_left);
6567 for (j = 0; j < 2; j++)
6569 struct GadgetInfo *gi;
6571 counterbutton_info[i].gadget_id_down :
6572 counterbutton_info[i].gadget_id_up);
6574 struct GraphicInfo *gd;
6575 int gd_x1, gd_x2, gd_y1, gd_y2;
6576 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6577 char infotext[max_infotext_len + 1];
6579 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6582 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
6583 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
6585 event_mask |= GD_EVENT_RELEASED;
6589 x = DX + editor.button.prev_level.x;
6590 y = DY + editor.button.prev_level.y;
6594 x = DX + editor.button.next_level.x;
6595 y = DY + editor.button.next_level.y;
6601 IMG_EDITOR_COUNTER_DOWN :
6602 IMG_EDITOR_COUNTER_UP);
6605 gd = &graphic_info[graphic];
6609 gd_x2 = gd->src_x + gd->pressed_xoffset;
6610 gd_y2 = gd->src_y + gd->pressed_yoffset;
6612 sprintf(infotext, "%s counter value by 1, 5 or 10",
6613 (j == 0 ? "decrease" : "increase"));
6615 gi = CreateGadget(GDI_CUSTOM_ID, id,
6616 GDI_CUSTOM_TYPE_ID, i,
6617 GDI_IMAGE_ID, graphic,
6618 GDI_INFO_TEXT, infotext,
6621 GDI_WIDTH, gd->width,
6622 GDI_HEIGHT, gd->height,
6623 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6624 GDI_STATE, GD_BUTTON_UNPRESSED,
6625 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6626 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6627 GDI_EVENT_MASK, event_mask,
6628 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6629 GDI_CALLBACK_ACTION, HandleCounterButtons,
6633 Fail("cannot create gadget");
6635 level_editor_gadget[id] = gi;
6636 right_gadget_border[id] =
6637 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6639 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
6643 int font_type = FONT_INPUT_1;
6644 int font_type_active = FONT_INPUT_1_ACTIVE;
6646 id = counterbutton_info[i].gadget_id_text;
6648 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6650 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6652 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
6654 font_type = FONT_LEVEL_NUMBER;
6655 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
6657 x = DX + editor.input.level_number.x;
6658 y = DY + editor.input.level_number.y;
6662 graphic = IMG_EDITOR_COUNTER_INPUT;
6665 gd = &graphic_info[graphic];
6669 gd_x2 = gd->src_x + gd->active_xoffset;
6670 gd_y2 = gd->src_y + gd->active_yoffset;
6672 gi = CreateGadget(GDI_CUSTOM_ID, id,
6673 GDI_CUSTOM_TYPE_ID, i,
6674 GDI_IMAGE_ID, graphic,
6675 GDI_INFO_TEXT, "enter counter value",
6678 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
6679 GDI_NUMBER_VALUE, 0,
6680 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
6681 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
6682 GDI_TEXT_SIZE, 3, // minimal counter text size
6683 GDI_TEXT_FONT, font_type,
6684 GDI_TEXT_FONT_ACTIVE, font_type_active,
6685 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6686 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6687 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6688 GDI_DESIGN_WIDTH, gd->width,
6689 GDI_EVENT_MASK, event_mask,
6690 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6691 GDI_CALLBACK_ACTION, HandleCounterButtons,
6695 Fail("cannot create gadget");
6697 level_editor_gadget[id] = gi;
6698 right_gadget_border[id] =
6699 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6701 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
6707 static void CreateDrawingAreas(void)
6711 // these values are not constant, but can change at runtime
6712 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
6713 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
6715 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
6717 struct GadgetInfo *gi;
6718 int id = drawingarea_info[i].gadget_id;
6719 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
6720 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
6721 int area_xsize = drawingarea_info[i].area_xsize;
6722 int area_ysize = drawingarea_info[i].area_ysize;
6723 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
6724 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
6725 unsigned int event_mask =
6726 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
6727 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
6729 // determine horizontal position to the right of specified gadget
6730 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
6731 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
6732 ED_DRAWINGAREA_TEXT_DISTANCE);
6734 // determine horizontal offset for leading text
6735 if (drawingarea_info[i].text_left != NULL)
6736 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
6738 gi = CreateGadget(GDI_CUSTOM_ID, id,
6739 GDI_CUSTOM_TYPE_ID, i,
6742 GDI_TYPE, GD_TYPE_DRAWING_AREA,
6743 GDI_AREA_SIZE, area_xsize, area_ysize,
6744 GDI_ITEM_SIZE, item_size, item_size,
6745 GDI_EVENT_MASK, event_mask,
6746 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
6747 GDI_CALLBACK_ACTION, HandleDrawingAreas,
6751 Fail("cannot create gadget");
6753 level_editor_gadget[id] = gi;
6754 right_gadget_border[id] =
6755 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
6759 static void CreateTextInputGadgets(void)
6761 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
6762 int max_infotext_len = getMaxInfoTextLength();
6765 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
6767 int gd_x1 = gd->src_x;
6768 int gd_y1 = gd->src_y;
6769 int gd_x2 = gd->src_x + gd->active_xoffset;
6770 int gd_y2 = gd->src_y + gd->active_yoffset;
6771 struct GadgetInfo *gi;
6772 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6773 char infotext[MAX_OUTPUT_LINESIZE + 1];
6774 int id = textinput_info[i].gadget_id;
6777 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
6779 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
6780 int border_size = gd->border_size;
6781 int font_nr = FONT_INPUT_1;
6782 int font_height = getFontHeight(font_nr);
6783 int xoffset = element_border + TILEX + element_border + 3 * border_size;
6784 int yoffset = element_border + (TILEY - font_height) / 2;
6786 x = (editor.settings.element_name.x != -1 ?
6787 editor.settings.element_name.x :
6788 editor.settings.element_graphic.x + xoffset) - border_size;
6789 y = (editor.settings.element_name.y != -1 ?
6790 editor.settings.element_name.y :
6791 editor.settings.element_graphic.y + yoffset) - border_size;
6795 x = ED_SETTINGS_X(textinput_info[i].x);
6796 y = ED_SETTINGS_Y(textinput_info[i].y);
6799 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
6800 infotext[max_infotext_len] = '\0';
6802 gi = CreateGadget(GDI_CUSTOM_ID, id,
6803 GDI_CUSTOM_TYPE_ID, i,
6804 GDI_INFO_TEXT, infotext,
6807 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
6808 GDI_TEXT_VALUE, textinput_info[i].value,
6809 GDI_TEXT_SIZE, textinput_info[i].size,
6810 GDI_TEXT_FONT, FONT_INPUT_1,
6811 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6812 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6813 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6814 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6815 GDI_DESIGN_WIDTH, gd->width,
6816 GDI_EVENT_MASK, event_mask,
6817 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6818 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
6822 Fail("cannot create gadget");
6824 level_editor_gadget[id] = gi;
6828 static void CreateTextAreaGadgets(void)
6830 int max_infotext_len = getMaxInfoTextLength();
6833 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
6835 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
6836 int gd_x1 = gd->src_x;
6837 int gd_y1 = gd->src_y;
6838 int gd_x2 = gd->src_x + gd->active_xoffset;
6839 int gd_y2 = gd->src_y + gd->active_yoffset;
6840 struct GadgetInfo *gi;
6841 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
6842 char infotext[MAX_OUTPUT_LINESIZE + 1];
6843 int id = textarea_info[i].gadget_id;
6844 int area_xsize = textarea_info[i].xsize;
6845 int area_ysize = textarea_info[i].ysize;
6847 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
6848 infotext[max_infotext_len] = '\0';
6850 gi = CreateGadget(GDI_CUSTOM_ID, id,
6851 GDI_CUSTOM_TYPE_ID, i,
6852 GDI_INFO_TEXT, infotext,
6853 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
6854 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
6855 GDI_TYPE, GD_TYPE_TEXT_AREA,
6856 GDI_AREA_SIZE, area_xsize, area_ysize,
6857 GDI_TEXT_FONT, FONT_INPUT_1,
6858 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6859 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6860 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6861 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6862 GDI_DESIGN_WIDTH, gd->width,
6863 GDI_EVENT_MASK, event_mask,
6864 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6865 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
6869 Fail("cannot create gadget");
6871 level_editor_gadget[id] = gi;
6875 static void CreateSelectboxGadgets(void)
6877 int max_infotext_len = getMaxInfoTextLength();
6880 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6882 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
6883 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
6884 int gd_x1 = gd->src_x;
6885 int gd_y1 = gd->src_y;
6886 int gd_x2 = gd->src_x + gd->active_xoffset;
6887 int gd_y2 = gd->src_y + gd->active_yoffset;
6888 int selectbox_button_xsize = gd2->width;
6889 struct GadgetInfo *gi;
6890 char infotext[MAX_OUTPUT_LINESIZE + 1];
6891 int id = selectbox_info[i].gadget_id;
6892 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
6893 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
6894 unsigned int event_mask =
6895 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6897 if (selectbox_info[i].size == -1) // dynamically determine size
6899 // (we cannot use -1 for uninitialized values if we directly compare
6900 // with results from strlen(), because the '<' and '>' operation will
6901 // implicitely cast -1 to an unsigned integer value!)
6902 selectbox_info[i].size = 0;
6904 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
6905 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
6906 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
6908 selectbox_info[i].size++; // add one character empty space
6911 // determine horizontal position to the right of specified gadget
6912 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
6913 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
6914 ED_GADGET_TEXT_DISTANCE);
6916 // determine horizontal offset for leading text
6917 if (selectbox_info[i].text_left != NULL)
6918 x += getTextWidthForGadget(selectbox_info[i].text_left);
6920 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
6921 infotext[max_infotext_len] = '\0';
6923 gi = CreateGadget(GDI_CUSTOM_ID, id,
6924 GDI_CUSTOM_TYPE_ID, i,
6925 GDI_INFO_TEXT, infotext,
6928 GDI_TYPE, GD_TYPE_SELECTBOX,
6929 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
6930 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
6931 GDI_TEXT_SIZE, selectbox_info[i].size,
6932 GDI_TEXT_FONT, FONT_INPUT_1,
6933 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6934 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
6935 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6936 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6937 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6938 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
6939 GDI_DESIGN_WIDTH, gd->width,
6940 GDI_EVENT_MASK, event_mask,
6941 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6942 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
6946 Fail("cannot create gadget");
6948 level_editor_gadget[id] = gi;
6949 right_gadget_border[id] =
6950 getRightGadgetBorder(gi, selectbox_info[i].text_right);
6954 static void CreateTextbuttonGadgets(void)
6956 int max_infotext_len = getMaxInfoTextLength();
6959 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
6961 int id = textbutton_info[i].gadget_id;
6963 ((id >= GADGET_ID_LEVELCONFIG_LEVEL && id <= GADGET_ID_LEVELCONFIG_EDITOR) ||
6964 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
6966 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
6967 int gadget_distance =
6968 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
6969 struct GraphicInfo *gd = &graphic_info[graphic];
6970 int gd_x1 = gd->src_x;
6971 int gd_y1 = gd->src_y;
6972 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6973 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6974 int gd_x1a = gd->src_x + gd->active_xoffset;
6975 int gd_y1a = gd->src_y + gd->active_yoffset;
6976 int border_xsize = gd->border_size + gd->draw_xoffset;
6977 int border_ysize = gd->border_size;
6978 struct GadgetInfo *gi;
6979 unsigned int event_mask = GD_EVENT_RELEASED;
6980 char infotext[MAX_OUTPUT_LINESIZE + 1];
6981 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
6982 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
6984 if (textbutton_info[i].size == -1) // dynamically determine size
6985 textbutton_info[i].size = strlen(textbutton_info[i].text);
6987 sprintf(infotext, "%s", textbutton_info[i].infotext);
6988 infotext[max_infotext_len] = '\0';
6990 // determine horizontal position to the right of specified gadget
6991 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6993 int gadget_id_align = textbutton_info[i].gadget_id_align;
6995 x = right_gadget_border[gadget_id_align] + gadget_distance;
6997 if (textbutton_info[i].y == -1)
6998 y = level_editor_gadget[gadget_id_align]->y;
7001 // determine horizontal offset for leading text
7002 if (textbutton_info[i].text_left != NULL)
7003 x += getTextWidthForGadget(textbutton_info[i].text_left);
7005 gi = CreateGadget(GDI_CUSTOM_ID, id,
7006 GDI_CUSTOM_TYPE_ID, i,
7007 GDI_IMAGE_ID, graphic,
7008 GDI_INFO_TEXT, infotext,
7011 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
7012 GDI_TEXT_VALUE, textbutton_info[i].text,
7013 GDI_TEXT_SIZE, textbutton_info[i].size,
7014 GDI_TEXT_FONT, FONT_INPUT_2,
7015 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
7016 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7017 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7018 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7019 GDI_BORDER_SIZE, border_xsize, border_ysize,
7020 GDI_DESIGN_WIDTH, gd->width,
7021 GDI_DECORATION_SHIFTING, 1, 1,
7022 GDI_EVENT_MASK, event_mask,
7023 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7024 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7028 Fail("cannot create gadget");
7030 level_editor_gadget[id] = gi;
7031 right_gadget_border[id] =
7032 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7036 static void CreateGraphicbuttonGadgets(void)
7038 struct GadgetInfo *gi;
7041 // create buttons for scrolling of drawing area and element list
7042 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7044 int id = graphicbutton_info[i].gadget_id;
7045 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7046 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7047 int graphic = graphicbutton_info[i].graphic;
7048 struct GraphicInfo *gd = &graphic_info[graphic];
7049 int gd_x1 = gd->src_x;
7050 int gd_y1 = gd->src_y;
7051 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7052 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7053 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7055 // determine horizontal position to the right of specified gadget
7056 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7057 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7058 ED_GADGET_TEXT_DISTANCE);
7060 // determine horizontal offset for leading text
7061 if (graphicbutton_info[i].text_left != NULL)
7062 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7064 gi = CreateGadget(GDI_CUSTOM_ID, id,
7065 GDI_CUSTOM_TYPE_ID, i,
7066 GDI_IMAGE_ID, graphic,
7067 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7070 GDI_WIDTH, gd->width,
7071 GDI_HEIGHT, gd->height,
7072 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7073 GDI_STATE, GD_BUTTON_UNPRESSED,
7074 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7075 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7076 GDI_EVENT_MASK, event_mask,
7077 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7078 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7082 Fail("cannot create gadget");
7084 level_editor_gadget[id] = gi;
7085 right_gadget_border[id] =
7086 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7090 static void CreateScrollbarGadgets(void)
7094 // these values are not constant, but can change at runtime
7095 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7096 SX + ED_SCROLL_HORIZONTAL_XPOS;
7097 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7098 SY + ED_SCROLL_HORIZONTAL_YPOS;
7099 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7100 ED_SCROLL_HORIZONTAL_XSIZE;
7101 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7102 ED_SCROLL_HORIZONTAL_YSIZE;
7103 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7104 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7105 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7106 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7108 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7109 SX + ED_SCROLL_VERTICAL_XPOS;
7110 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7111 SY + ED_SCROLL_VERTICAL_YPOS;
7112 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7113 ED_SCROLL_VERTICAL_XSIZE;
7114 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7115 ED_SCROLL_VERTICAL_YSIZE;
7116 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7117 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7118 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7119 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7121 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7122 PX + ED_SCROLL2_VERTICAL_XPOS;
7123 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7124 PY + ED_SCROLL2_VERTICAL_YPOS;
7125 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7126 ED_SCROLL2_VERTICAL_XSIZE;
7127 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7128 ED_SCROLL2_VERTICAL_YSIZE;
7129 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7130 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7131 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7132 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7134 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7136 int id = scrollbar_info[i].gadget_id;
7137 int graphic = scrollbar_info[i].graphic;
7138 struct GraphicInfo *gd = &graphic_info[graphic];
7139 int gd_x1 = gd->src_x;
7140 int gd_y1 = gd->src_y;
7141 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7142 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7143 struct GadgetInfo *gi;
7144 int items_max, items_visible, item_position;
7145 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7147 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7149 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7150 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7151 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7153 else // drawing area scrollbars
7155 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7157 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7158 items_visible = ed_fieldx;
7163 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7164 items_visible = ed_fieldy;
7169 gi = CreateGadget(GDI_CUSTOM_ID, id,
7170 GDI_CUSTOM_TYPE_ID, i,
7171 GDI_IMAGE_ID, graphic,
7172 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7173 GDI_X, scrollbar_pos[i].x,
7174 GDI_Y, scrollbar_pos[i].y,
7175 GDI_WIDTH, scrollbar_pos[i].width,
7176 GDI_HEIGHT, scrollbar_pos[i].height,
7177 GDI_TYPE, scrollbar_info[i].type,
7178 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7179 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7180 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7181 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7182 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7183 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7184 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7185 GDI_STATE, GD_BUTTON_UNPRESSED,
7186 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7187 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7188 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7189 GDI_EVENT_MASK, event_mask,
7190 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7191 GDI_CALLBACK_ACTION, HandleControlButtons,
7195 Fail("cannot create gadget");
7197 level_editor_gadget[id] = gi;
7201 static void CreateCheckbuttonGadgets(void)
7203 struct GadgetInfo *gi;
7206 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7208 int id = checkbutton_info[i].gadget_id;
7209 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7210 IMG_EDITOR_CHECKBOX);
7211 struct GraphicInfo *gd = &graphic_info[graphic];
7212 int gd_x1 = gd->src_x;
7213 int gd_y1 = gd->src_y;
7214 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7215 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7216 int gd_x1a = gd->src_x + gd->active_xoffset;
7217 int gd_y1a = gd->src_y + gd->active_yoffset;
7218 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7219 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7220 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7221 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7222 unsigned int event_mask = GD_EVENT_PRESSED;
7224 // determine horizontal position to the right of specified gadget
7225 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7226 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7227 ED_GADGET_TEXT_DISTANCE);
7229 // determine horizontal offset for leading text
7230 if (checkbutton_info[i].text_left != NULL)
7231 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7233 gi = CreateGadget(GDI_CUSTOM_ID, id,
7234 GDI_CUSTOM_TYPE_ID, i,
7235 GDI_IMAGE_ID, graphic,
7236 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7239 GDI_WIDTH, gd->width,
7240 GDI_HEIGHT, gd->height,
7241 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7242 GDI_CHECKED, *checkbutton_info[i].value,
7243 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7244 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7245 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7246 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7247 GDI_EVENT_MASK, event_mask,
7248 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7249 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7253 Fail("cannot create gadget");
7255 level_editor_gadget[id] = gi;
7256 right_gadget_border[id] =
7257 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7261 static void CreateRadiobuttonGadgets(void)
7263 int graphic = IMG_EDITOR_RADIOBUTTON;
7264 struct GraphicInfo *gd = &graphic_info[graphic];
7265 int gd_x1 = gd->src_x;
7266 int gd_y1 = gd->src_y;
7267 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7268 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7269 int gd_x1a = gd->src_x + gd->active_xoffset;
7270 int gd_y1a = gd->src_y + gd->active_yoffset;
7271 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7272 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7273 struct GadgetInfo *gi;
7276 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7278 int id = radiobutton_info[i].gadget_id;
7279 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7280 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7281 unsigned int event_mask = GD_EVENT_PRESSED;
7284 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7286 // determine horizontal position to the right of specified gadget
7287 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7288 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7289 ED_GADGET_TEXT_DISTANCE);
7291 // determine horizontal offset for leading text
7292 if (radiobutton_info[i].text_left != NULL)
7293 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7295 gi = CreateGadget(GDI_CUSTOM_ID, id,
7296 GDI_CUSTOM_TYPE_ID, i,
7297 GDI_IMAGE_ID, graphic,
7298 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7301 GDI_WIDTH, gd->width,
7302 GDI_HEIGHT, gd->height,
7303 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7304 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7305 GDI_CHECKED, checked,
7306 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7307 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7308 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7309 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7310 GDI_EVENT_MASK, event_mask,
7311 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7312 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7316 Fail("cannot create gadget");
7318 level_editor_gadget[id] = gi;
7319 right_gadget_border[id] =
7320 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7324 void CreateLevelEditorGadgets(void)
7326 // force EDITOR font inside level editor
7327 SetFontStatus(GAME_MODE_EDITOR);
7329 // these values are not constant, but can change at runtime
7330 ed_fieldx = MAX_ED_FIELDX - 1;
7331 ed_fieldy = MAX_ED_FIELDY - 1;
7333 num_editor_gadgets = NUM_EDITOR_GADGETS;
7335 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7337 level_editor_gadget =
7338 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7339 right_gadget_border =
7340 checked_calloc(num_editor_gadgets * sizeof(int));
7342 // set number of empty (padding) element buttons to maximum number of buttons
7343 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7345 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7346 editor_el_empty_ptr = editor_el_empty;
7348 use_permanent_palette = !editor.palette.show_as_separate_screen;
7350 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
7352 ReinitializeElementList();
7354 CreateControlButtons();
7355 CreateScrollbarGadgets();
7357 // order of function calls is important because of cross-references
7358 CreateCheckbuttonGadgets();
7359 CreateCounterButtons();
7360 CreateRadiobuttonGadgets();
7361 CreateTextInputGadgets();
7362 CreateTextAreaGadgets();
7363 CreateSelectboxGadgets();
7364 CreateGraphicbuttonGadgets();
7365 CreateTextbuttonGadgets();
7366 CreateDrawingAreas();
7371 void FreeLevelEditorGadgets(void)
7375 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
7377 for (i = 0; i < num_editor_gadgets; i++)
7379 FreeGadget(level_editor_gadget[i]);
7381 level_editor_gadget[i] = NULL;
7384 checked_free(level_editor_gadget);
7385 checked_free(right_gadget_border);
7387 checked_free(editor_el_empty);
7390 static void MapCounterButtons(int id)
7392 int font_nr = FONT_TEXT_1;
7393 int font_height = getFontHeight(font_nr);
7394 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7395 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7396 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7397 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7398 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7399 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7400 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7401 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7402 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7403 int yoffset = (gi_down->height - font_height) / 2;
7404 int x_left = gi_down->x - xoffset_left;
7405 int x_right; // set after gadget position was modified
7406 int y_above = gi_down->y - yoffset_above;
7408 int y; // set after gadget position was modified
7410 // counter limits must be changed first to prevent value truncation
7411 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7412 counterbutton_info[id].max_value);
7414 // right text position might have changed after setting position above
7415 x_right = gi_up->x + gi_up->width + xoffset_right;
7417 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7419 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
7420 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7421 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7423 ModifyGadget(gi_down, GDI_Y,
7424 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7425 ModifyGadget(gi_text, GDI_Y,
7426 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7427 ModifyGadget(gi_up, GDI_Y,
7428 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7431 // vertical position might have changed after setting position above
7432 y = gi_up->y + yoffset;
7434 if (counterbutton_info[id].text_above)
7435 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
7437 if (counterbutton_info[id].text_left)
7438 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7440 if (counterbutton_info[id].text_right)
7441 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7448 static void MapControlButtons(void)
7453 // map toolbox buttons (excluding special CE toolbox buttons)
7454 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7455 MapGadget(level_editor_gadget[i]);
7457 // map toolbox buttons (element properties buttons)
7458 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
7459 MapGadget(level_editor_gadget[i]);
7461 if (use_permanent_palette)
7463 // map buttons to select elements
7464 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7465 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
7466 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
7467 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
7468 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
7471 // map buttons to select level
7472 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
7473 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
7474 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
7475 MapCounterButtons(counter_id);
7478 static void MapDrawingArea(int id)
7480 int font_nr = FONT_TEXT_1;
7481 int font_height = getFontHeight(font_nr);
7482 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7483 int area_xsize = gi->drawing.area_xsize;
7484 int area_ysize = gi->drawing.area_ysize;
7485 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7486 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
7487 int x_left = gi->x - xoffset_left;
7488 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
7489 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
7490 int x_below = gi->x + (gi->width - xoffset_below) / 2;
7491 int y_side = gi->y + (gi->height - font_height) / 2;
7492 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
7493 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
7495 if (drawingarea_info[id].text_left)
7496 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
7498 if (drawingarea_info[id].text_right)
7499 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
7501 if (drawingarea_info[id].text_above)
7502 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
7504 if (drawingarea_info[id].text_below)
7505 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
7507 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
7509 DrawElementBorder(gi->x, gi->y,
7510 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
7511 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
7513 DrawDrawingArea(id);
7519 static void MapTextInputGadget(int id)
7521 int font_nr = FONT_TEXT_1;
7522 int font_height = getFontHeight(font_nr);
7523 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
7524 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7525 int x_above = ED_SETTINGS_X(textinput_info[id].x);
7526 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
7528 if (textinput_info[id].text_above)
7529 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
7531 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
7536 static void MapTextAreaGadget(int id)
7538 int font_nr = FONT_TEXT_1;
7539 int font_height = getFontHeight(font_nr);
7540 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7541 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7542 int x_above = ED_SETTINGS_X(textarea_info[id].x);
7543 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
7544 char *text_above = textarea_info[id].text_above;
7546 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
7547 text_above = textarea_info[id].text_above_cropped;
7550 DrawTextS(x_above, y_above, font_nr, text_above);
7552 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
7557 static void MapSelectboxGadget(int id)
7559 int font_nr = FONT_TEXT_1;
7560 int font_height = getFontHeight(font_nr);
7561 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
7562 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
7563 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7564 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7565 int yoffset = (gi->height - font_height) / 2;
7566 int x_left = gi->x - xoffset_left;
7567 int x_right = gi->x + gi->width + xoffset_right;
7568 int y_above = gi->y - yoffset_above;
7570 int y = gi->y + yoffset;
7572 if (selectbox_info[id].text_above)
7573 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
7575 if (selectbox_info[id].text_left)
7576 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
7578 if (selectbox_info[id].text_right)
7579 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
7581 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
7586 static void MapTextbuttonGadget(int id)
7588 int font_nr = FONT_TEXT_1;
7589 int font_height = getFontHeight(font_nr);
7590 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
7591 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
7592 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7593 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7594 int yoffset = (gi->height - font_height) / 2;
7595 int x_left = gi->x - xoffset_left;
7596 int x_right = gi->x + gi->width + xoffset_right;
7597 int y_above = gi->y - yoffset_above;
7599 int y = gi->y + yoffset;
7601 // only show button to delete change pages when more than minimum pages
7602 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
7603 custom_element.num_change_pages == MIN_CHANGE_PAGES)
7606 if (textbutton_info[id].text_above)
7607 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
7609 if (textbutton_info[id].text_left)
7610 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
7612 if (textbutton_info[id].text_right)
7613 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
7618 static void MapGraphicbuttonGadget(int id)
7620 int font_nr = FONT_TEXT_1;
7621 int font_height = getFontHeight(font_nr);
7622 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
7623 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
7624 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7625 int yoffset = (gi->height - font_height) / 2;
7626 int x_left = gi->x - xoffset_left;
7627 int x_right = gi->x + gi->width + xoffset_right;
7628 int y = gi->y + yoffset;
7630 if (graphicbutton_info[id].text_left)
7631 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
7633 if (graphicbutton_info[id].text_right)
7634 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
7639 static void MapRadiobuttonGadget(int id)
7641 int font_nr = FONT_TEXT_1;
7642 int font_height = getFontHeight(font_nr);
7643 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
7644 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7645 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7646 int yoffset = (gi->height - font_height) / 2;
7647 int x_left = gi->x - xoffset_left;
7648 int x_right = gi->x + gi->width + xoffset_right;
7649 int y = gi->y + yoffset;
7651 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
7653 if (radiobutton_info[id].text_left)
7654 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
7656 if (radiobutton_info[id].text_right)
7657 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
7659 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
7664 static void MapCheckbuttonGadget(int id)
7666 int font_nr = FONT_TEXT_1;
7667 int font_height = getFontHeight(font_nr);
7668 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
7669 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7670 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7671 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7672 int yoffset = (gi->height - font_height) / 2;
7673 int y_above = gi->y - yoffset_above;
7675 int x_left, x_right, y; // set after gadget position was modified
7677 // set position for gadgets with dynamically determined position
7678 if (checkbutton_info[id].x != -1) // do not change dynamic positions
7679 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x), GDI_END);
7680 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
7682 x_left = gi->x - xoffset_left;
7683 x_right = gi->x + gi->width + xoffset_right;
7684 y = gi->y + yoffset;
7686 if (checkbutton_info[id].text_above)
7687 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
7689 if (checkbutton_info[id].text_left)
7690 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
7692 if (checkbutton_info[id].text_right)
7693 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
7695 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
7700 static void MapMainDrawingArea(void)
7702 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
7703 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
7706 if (suppressBorderElement())
7708 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
7709 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
7712 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
7714 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
7715 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
7716 no_horizontal_scrollbar) ||
7717 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
7718 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
7719 no_vertical_scrollbar))
7722 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
7725 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
7727 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
7728 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
7731 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
7734 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
7737 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
7741 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
7743 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
7744 i == GADGET_ID_CUSTOM_COPY_TO ||
7745 i == GADGET_ID_CUSTOM_EXCHANGE ||
7746 i == GADGET_ID_CUSTOM_COPY ||
7747 i == GADGET_ID_CUSTOM_PASTE)
7750 MapGadget(level_editor_gadget[i]);
7752 UnmapGadget(level_editor_gadget[i]);
7757 static void MapLevelEditorToolboxCustomGadgets(void)
7759 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
7762 static void MapLevelEditorToolboxCustomGadgetsIfNeeded(void)
7764 if (IS_CUSTOM_ELEMENT(properties_element) ||
7765 IS_GROUP_ELEMENT(properties_element) ||
7766 IS_EMPTY_ELEMENT(properties_element))
7767 MapLevelEditorToolboxCustomGadgets();
7770 static void UnmapLevelEditorToolboxCustomGadgets(void)
7772 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
7775 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
7779 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
7781 if (i != GADGET_ID_SINGLE_ITEMS &&
7782 i != GADGET_ID_PICK_ELEMENT)
7784 struct GadgetInfo *gi = level_editor_gadget[i];
7792 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
7793 struct GraphicInfo *gd = &graphic_info[graphic];
7797 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
7798 gi->width, gi->height, gi->x, gi->y);
7800 redraw_mask |= REDRAW_DOOR_3;
7806 static void MapLevelEditorToolboxDrawingGadgets(void)
7808 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
7811 static void UnmapLevelEditorToolboxDrawingGadgets(void)
7813 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
7816 static void UnmapDrawingArea(int id)
7818 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
7821 static void UnmapLevelEditorFieldGadgets(void)
7825 for (i = 0; i < num_editor_gadgets; i++)
7826 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
7827 level_editor_gadget[i]->y))
7828 UnmapGadget(level_editor_gadget[i]);
7831 void UnmapLevelEditorGadgets(void)
7835 for (i = 0; i < num_editor_gadgets; i++)
7836 UnmapGadget(level_editor_gadget[i]);
7839 static void ResetUndoBuffer(void)
7841 undo_buffer_position = -1;
7842 undo_buffer_steps = -1;
7843 redo_buffer_steps = 0;
7845 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7847 level.changed = FALSE;
7850 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
7852 if (remap_toolbox_gadgets)
7854 ModifyEditorElementList();
7855 RedrawDrawingElements();
7858 if (edit_mode == ED_MODE_LEVELCONFIG)
7859 DrawLevelConfigWindow();
7860 else if (edit_mode == ED_MODE_PROPERTIES)
7861 DrawPropertiesWindow();
7862 else if (edit_mode == ED_MODE_PALETTE)
7863 DrawPaletteWindow();
7864 else // edit_mode == ED_MODE_DRAWING
7865 DrawDrawingWindowExt(remap_toolbox_gadgets);
7868 static void DrawEditModeWindow(void)
7870 DrawEditModeWindowExt(TRUE);
7873 static void DrawEditModeWindow_PlayfieldOnly(void)
7875 DrawEditModeWindowExt(FALSE);
7878 static void ChangeEditModeWindow(int new_edit_mode)
7880 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
7882 DrawEditModeWindow();
7885 static boolean LevelChanged(void)
7887 boolean field_changed = FALSE;
7890 for (y = 0; y < lev_fieldy; y++)
7891 for (x = 0; x < lev_fieldx; x++)
7892 if (Tile[x][y] != level.field[x][y])
7893 field_changed = TRUE;
7895 return (level.changed || field_changed);
7898 static boolean PrepareSavingIntoPersonalLevelSet(void)
7900 static LevelDirTree *last_copied_leveldir = NULL;
7901 static LevelDirTree *last_written_leveldir = NULL;
7902 static int last_copied_level_nr = -1;
7903 static int last_written_level_nr = -1;
7904 LevelDirTree *leveldir_former = leveldir_current;
7905 int level_nr_former = level_nr;
7908 // remember last mod/save so that for current session, we write
7909 // back to the same personal copy, asking only about overwrite.
7910 if (leveldir_current == last_copied_leveldir &&
7911 level_nr == last_copied_level_nr)
7913 // "cd" to personal level set dir (as used when writing last copy)
7914 leveldir_current = last_written_leveldir;
7915 level_nr = last_written_level_nr;
7920 if (!Request("This level is read-only! "
7921 "Save into personal level set?", REQ_ASK))
7924 // "cd" to personal level set dir (for writing copy the first time)
7926 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
7928 // this may happen if "setup.internal.create_user_levelset" is FALSE
7929 // or if file "levelinfo.conf" is missing in personal user level set
7930 if (leveldir_current == NULL)
7932 Request("Cannot find personal level set?!", REQ_CONFIRM);
7934 leveldir_current = leveldir_former;
7939 // find unused level number
7940 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
7942 static char *level_filename = NULL;
7944 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
7946 if (!fileExists(level_filename))
7950 last_copied_leveldir = leveldir_former;
7951 last_copied_level_nr = level_nr_former;
7953 last_written_leveldir = leveldir_current;
7954 last_written_level_nr = level_nr = new_level_nr;
7959 static void ModifyLevelConfigForSavingIntoPersonalLevelSet(char *former_name)
7961 static char *filename_levelinfo = NULL, *mod_name = NULL;
7964 // annotate this copy-and-mod in personal levelinfo.conf
7965 setString(&filename_levelinfo,
7966 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
7968 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
7970 fprintf(file, "\n");
7971 fprintf(file, "# level %d was modified from:\n", level_nr);
7972 fprintf(file, "# - previous level set name: %s\n",
7974 fprintf(file, "# - level within previous set: %d \"%s\"\n",
7975 level.file_info.nr, level.name);
7976 fprintf(file, "# - previous author: %s\n",
7978 fprintf(file, "# - previous save date: ");
7980 if (level.creation_date.src == DATE_SRC_LEVELFILE)
7982 fprintf(file, "%04d-%02d-%02d\n",
7983 level.creation_date.year,
7984 level.creation_date.month,
7985 level.creation_date.day);
7989 fprintf(file, "not recorded\n");
7995 if (level_nr > leveldir_current->last_level)
7996 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
7998 // else: allow the save even if annotation failed
8000 // now... spray graffiti on the old level vital statistics
8001 // user can change these; just trying to set a good baseline
8003 // don't truncate names for fear of making offensive or silly:
8004 // long-named original author only recorded in levelinfo.conf.
8005 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
8006 if (!strEqual(level.author, leveldir_current->author))
8008 setString(&mod_name, getStringCat3(leveldir_current->author,
8009 " after ", level.author));
8011 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8012 setString(&mod_name,
8013 getStringCat2(leveldir_current->author, " (ed.)"));
8015 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
8016 setString(&mod_name, leveldir_current->author);
8018 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
8020 // less worried about truncation here
8021 setString(&mod_name, getStringCat2("Mod: ", level.name));
8022 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
8026 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
8027 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8031 for (x = 0; x < lev_fieldx; x++)
8032 for (y = 0; y < lev_fieldy; y++)
8033 dst[x][y] = src[x][y];
8036 static int setSelectboxValue(int selectbox_id, int new_value)
8038 int new_index_value = 0;
8041 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8042 if (selectbox_info[selectbox_id].options[i].value == new_value)
8043 new_index_value = i;
8045 *selectbox_info[selectbox_id].value =
8046 selectbox_info[selectbox_id].options[new_index_value].value;
8048 return new_index_value;
8051 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8055 // change action mode and arg variables according to action type variable
8056 for (i = 0; action_arg_options[i].value != -1; i++)
8058 if (action_arg_options[i].value == custom_element_change.action_type)
8060 int mode = action_arg_options[i].mode;
8062 // only change if corresponding selectbox has changed
8063 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8064 action_arg_modes[mode])
8065 custom_element_change.action_mode = -1;
8067 // only change if corresponding selectbox has changed
8068 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8069 action_arg_options[i].options)
8070 custom_element_change.action_arg = -1;
8077 static void setSelectboxSpecialActionOptions(void)
8081 // change action mode and arg selectbox according to action type selectbox
8082 for (i = 0; action_arg_options[i].value != -1; i++)
8084 if (action_arg_options[i].value == custom_element_change.action_type)
8086 int mode = action_arg_options[i].mode;
8088 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8089 action_arg_modes[mode]);
8090 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8091 custom_element_change.action_mode);
8093 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8094 action_arg_options[i].options);
8095 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8096 custom_element_change.action_arg);
8102 static void copy_custom_element_settings(int element_from, int element_to)
8104 struct ElementInfo *ei_from = &element_info[element_from];
8105 struct ElementInfo *ei_to = &element_info[element_to];
8107 copyElementInfo(ei_from, ei_to);
8110 static void replace_custom_element_in_settings(int element_from,
8115 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8117 struct ElementInfo *ei = &element_info[i];
8119 for (y = 0; y < 3; y++)
8120 for (x = 0; x < 3; x++)
8121 if (ei->content.e[x][y] == element_from)
8122 ei->content.e[x][y] = element_to;
8124 for (j = 0; j < ei->num_change_pages; j++)
8126 struct ElementChangeInfo *change = &ei->change_page[j];
8128 if (change->target_element == element_from)
8129 change->target_element = element_to;
8131 if (change->initial_trigger_element == element_from)
8132 change->initial_trigger_element = element_to;
8134 if (change->action_element == element_from)
8135 change->action_element = element_to;
8137 for (y = 0; y < 3; y++)
8138 for (x = 0; x < 3; x++)
8139 if (change->target_content.e[x][y] == element_from)
8140 change->target_content.e[x][y] = element_to;
8143 if (ei->group != NULL) // group or internal
8144 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8145 if (ei->group->element[j] == element_from)
8146 ei->group->element[j] = element_to;
8150 static void replace_custom_element_in_playfield(int element_from,
8155 for (x = 0; x < lev_fieldx; x++)
8156 for (y = 0; y < lev_fieldy; y++)
8157 if (Tile[x][y] == element_from)
8158 Tile[x][y] = element_to;
8161 static boolean CopyCustomElement(int element_old, int element_new,
8164 int copy_mode_orig = copy_mode;
8166 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8168 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8169 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8170 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8172 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8174 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8175 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8176 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8178 level.changed = TRUE;
8180 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8182 Request("Please choose custom element!", REQ_CONFIRM);
8186 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8188 Request("Please choose group element!", REQ_CONFIRM);
8192 else if (IS_EMPTY_ELEMENT(element_old) && !IS_EMPTY_ELEMENT(element_new))
8194 Request("Please choose empty element!", REQ_CONFIRM);
8200 level.changed = TRUE;
8203 // when modifying custom/group element, ask for copying level template
8204 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8206 if (!AskToCopyAndModifyLevelTemplate())
8210 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8212 copy_custom_element_settings(element_new, element_old);
8214 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8216 copy_custom_element_settings(element_old, element_new);
8218 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8220 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8221 copy_custom_element_settings(element_new, element_old);
8222 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8224 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8225 replace_custom_element_in_settings(element_new, element_old);
8226 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8228 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8229 replace_custom_element_in_playfield(element_new, element_old);
8230 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8233 UpdateCustomElementGraphicGadgets();
8234 DrawPropertiesWindow();
8239 static void CopyCustomElementPropertiesToEditor(int element)
8242 int current_change_page = element_info[element].current_change_page;
8244 // dynamically (re)build selectbox for selecting change page
8245 for (i = 0; i < element_info[element].num_change_pages; i++)
8247 sprintf(options_change_page_strings[i], "%d", i + 1);
8249 options_change_page[i].value = i;
8250 options_change_page[i].text = options_change_page_strings[i];
8253 options_change_page[i].value = -1;
8254 options_change_page[i].text = NULL;
8256 // needed here to initialize combined element properties
8257 InitElementPropertiesEngine(level.game_version);
8259 element_info[element].change =
8260 &element_info[element].change_page[current_change_page];
8262 custom_element = element_info[element];
8263 custom_element_change = *element_info[element].change;
8265 // needed to initially set selectbox options for special action options
8266 setSelectboxSpecialActionOptions();
8268 // needed to initially set selectbox value variables to reliable defaults
8269 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8270 setSelectboxValue(i, *selectbox_info[i].value);
8272 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8273 custom_element_properties[i] = HAS_PROPERTY(element, i);
8275 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8276 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8278 // ---------- element settings: configure (custom elements) -----------------
8280 // set accessible layer selectbox help value
8281 custom_element.access_type =
8282 (IS_WALKABLE(element) ? EP_WALKABLE :
8283 IS_PASSABLE(element) ? EP_PASSABLE :
8284 custom_element.access_type);
8285 custom_element.access_layer =
8286 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8287 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8288 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8289 custom_element.access_layer);
8290 custom_element.access_protected =
8291 (IS_PROTECTED(element) ? 1 : 0);
8292 custom_element_properties[EP_ACCESSIBLE] =
8293 (IS_ACCESSIBLE_OVER(element) ||
8294 IS_ACCESSIBLE_INSIDE(element) ||
8295 IS_ACCESSIBLE_UNDER(element));
8297 // set walk-to-object action selectbox help value
8298 custom_element.walk_to_action =
8299 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8300 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8301 IS_DROPPABLE(element) ? EP_DROPPABLE :
8302 IS_THROWABLE(element) ? EP_THROWABLE :
8303 IS_PUSHABLE(element) ? EP_PUSHABLE :
8304 custom_element.walk_to_action);
8305 custom_element_properties[EP_WALK_TO_OBJECT] =
8306 (IS_DIGGABLE(element) ||
8307 IS_COLLECTIBLE_ONLY(element) ||
8308 IS_DROPPABLE(element) ||
8309 IS_THROWABLE(element) ||
8310 IS_PUSHABLE(element));
8312 // set smash targets selectbox help value
8313 custom_element.smash_targets =
8314 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8315 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8316 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8317 custom_element.smash_targets);
8318 custom_element_properties[EP_CAN_SMASH] =
8319 (CAN_SMASH_EVERYTHING(element) ||
8320 CAN_SMASH_ENEMIES(element) ||
8321 CAN_SMASH_PLAYER(element));
8323 // set deadliness selectbox help value
8324 custom_element.deadliness =
8325 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8326 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8327 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8328 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8329 custom_element.deadliness);
8330 custom_element_properties[EP_DEADLY] =
8331 (DONT_TOUCH(element) ||
8332 DONT_GET_HIT_BY(element) ||
8333 DONT_COLLIDE_WITH(element) ||
8334 DONT_RUN_INTO(element));
8336 // ---------- element settings: advanced (custom elements) ------------------
8338 // set "change by direct action" selectbox help value
8339 custom_element_change.direct_action =
8340 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
8341 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8342 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8343 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8344 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8345 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8346 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8347 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8348 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8349 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8350 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8351 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8352 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8353 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8354 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8355 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8356 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8357 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8358 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8359 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
8360 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
8361 custom_element_change.direct_action);
8363 // set "change by other element action" selectbox help value
8364 custom_element_change.other_action =
8365 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
8366 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8367 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8368 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8369 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8370 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8371 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8372 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8373 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8374 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8375 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8376 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
8377 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8378 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8379 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8380 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8381 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8382 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8383 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8384 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8385 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8386 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8387 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8388 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8389 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8390 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
8391 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
8392 custom_element_change.other_action);
8395 static void CopyGroupElementPropertiesToEditor(int element)
8397 group_element_info = *element_info[element].group;
8398 custom_element = element_info[element]; // needed for description
8401 static void CopyEmptyElementPropertiesToEditor(int element)
8403 custom_element = element_info[element];
8406 static void CopyClassicElementPropertiesToEditor(int element)
8408 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8409 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
8410 getMoveIntoAcidProperty(&level, element);
8412 if (MAYBE_DONT_COLLIDE_WITH(element))
8413 custom_element_properties[EP_DONT_COLLIDE_WITH] =
8414 getDontCollideWithProperty(&level, element);
8417 static void CopyElementPropertiesToEditor(int element)
8419 if (IS_CUSTOM_ELEMENT(element))
8420 CopyCustomElementPropertiesToEditor(element);
8421 else if (IS_GROUP_ELEMENT(element))
8422 CopyGroupElementPropertiesToEditor(element);
8423 else if (IS_EMPTY_ELEMENT(element))
8424 CopyEmptyElementPropertiesToEditor(element);
8426 CopyClassicElementPropertiesToEditor(element);
8429 static boolean AskToCopyAndModifyLevelTemplate(void)
8431 if (Request("Copy and modify settings from level template?", REQ_ASK))
8433 level.use_custom_template = FALSE;
8435 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
8436 GDI_CHECKED, FALSE, GDI_END);
8437 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
8438 GDI_CHECKED, FALSE, GDI_END);
8444 LoadLevelTemplate(-1); // this resets all element modifications ...
8446 DrawEditModeWindow(); // ... and copies them to 'custom_element'
8452 static void CopyCustomElementPropertiesToGame(int element)
8455 int access_type_and_layer;
8457 // mark that this custom element has been modified
8458 custom_element.modified_settings = TRUE;
8459 level.changed = TRUE;
8461 if (level.use_custom_template)
8462 AskToCopyAndModifyLevelTemplate();
8464 element_info[element] = custom_element;
8465 *element_info[element].change = custom_element_change;
8467 // ---------- element settings: configure (custom elements) -----------------
8469 // set accessible property from checkbox and selectbox
8470 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
8471 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
8472 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
8473 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
8474 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
8475 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
8476 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
8477 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
8478 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
8479 custom_element_properties[access_type_and_layer] =
8480 custom_element_properties[EP_ACCESSIBLE];
8481 custom_element_properties[EP_PROTECTED] =
8482 (custom_element.access_protected != 0 &&
8483 custom_element_properties[EP_ACCESSIBLE]);
8485 // set walk-to-object property from checkbox and selectbox
8486 custom_element_properties[EP_DIGGABLE] = FALSE;
8487 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
8488 custom_element_properties[EP_DROPPABLE] = FALSE;
8489 custom_element_properties[EP_THROWABLE] = FALSE;
8490 custom_element_properties[EP_PUSHABLE] = FALSE;
8491 custom_element_properties[custom_element.walk_to_action] =
8492 custom_element_properties[EP_WALK_TO_OBJECT];
8494 // set smash property from checkbox and selectbox
8495 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
8496 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
8497 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
8498 custom_element_properties[custom_element.smash_targets] =
8499 custom_element_properties[EP_CAN_SMASH];
8501 // set deadliness property from checkbox and selectbox
8502 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
8503 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
8504 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
8505 custom_element_properties[EP_DONT_TOUCH] = FALSE;
8506 custom_element_properties[custom_element.deadliness] =
8507 custom_element_properties[EP_DEADLY];
8509 // ---------- element settings: advanced (custom elements) ------------------
8511 // set player change event from checkbox and selectbox
8512 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
8513 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
8514 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
8515 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
8516 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
8517 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
8518 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
8519 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
8520 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
8521 custom_element_change_events[CE_SWITCHED] = FALSE;
8522 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
8523 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
8524 custom_element_change_events[CE_BLOCKED] = FALSE;
8525 custom_element_change_events[CE_IMPACT] = FALSE;
8526 custom_element_change_events[CE_SMASHED] = FALSE;
8527 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
8528 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
8529 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
8530 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
8531 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
8532 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
8533 custom_element_change_events[custom_element_change.direct_action] =
8534 custom_element_change_events[CE_BY_DIRECT_ACTION];
8536 // set other element action change event from checkbox and selectbox
8537 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
8538 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
8539 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
8540 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
8541 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
8542 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
8543 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
8544 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
8545 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
8546 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
8547 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
8548 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
8549 custom_element_change_events[CE_TOUCHING_X] = FALSE;
8550 custom_element_change_events[CE_HITTING_X] = FALSE;
8551 custom_element_change_events[CE_DIGGING_X] = FALSE;
8552 custom_element_change_events[CE_HIT_BY_X] = FALSE;
8553 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
8554 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
8555 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
8556 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
8557 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
8558 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
8559 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
8560 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
8561 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
8562 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
8563 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
8564 custom_element_change_events[custom_element_change.other_action] =
8565 custom_element_change_events[CE_BY_OTHER_ACTION];
8567 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8568 SET_PROPERTY(element, i, custom_element_properties[i]);
8570 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8571 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
8573 // copy change events also to special level editor variable
8574 custom_element = element_info[element];
8575 custom_element_change = *element_info[element].change;
8577 // needed here to restore runtime value "element_info[element].gfx_element"
8578 InitElementPropertiesGfxElement();
8581 static void CopyGroupElementPropertiesToGame(int element)
8583 // mark that this group element has been modified
8584 custom_element.modified_settings = TRUE;
8585 level.changed = TRUE;
8587 if (level.use_custom_template)
8588 AskToCopyAndModifyLevelTemplate();
8590 element_info[element] = custom_element;
8591 *element_info[element].group = group_element_info;
8593 // needed here to restore runtime value "element_info[element].gfx_element"
8594 InitElementPropertiesGfxElement();
8597 static void CopyEmptyElementPropertiesToGame(int element)
8599 // mark that this empty element has been modified
8600 custom_element.modified_settings = TRUE;
8601 level.changed = TRUE;
8603 if (level.use_custom_template)
8604 AskToCopyAndModifyLevelTemplate();
8606 element_info[element] = custom_element;
8608 // needed here to restore runtime value "element_info[element].gfx_element"
8609 InitElementPropertiesGfxElement();
8612 static void CopyClassicElementPropertiesToGame(int element)
8614 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8615 setMoveIntoAcidProperty(&level, element,
8616 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
8618 if (MAYBE_DONT_COLLIDE_WITH(element))
8619 setDontCollideWithProperty(&level, element,
8620 custom_element_properties[EP_DONT_COLLIDE_WITH]);
8623 static void CopyElementPropertiesToGame(int element)
8625 if (IS_CUSTOM_ELEMENT(element))
8626 CopyCustomElementPropertiesToGame(element);
8627 else if (IS_GROUP_ELEMENT(element))
8628 CopyGroupElementPropertiesToGame(element);
8629 else if (IS_EMPTY_ELEMENT(element))
8630 CopyEmptyElementPropertiesToGame(element);
8632 CopyClassicElementPropertiesToGame(element);
8636 static void CheckElementDescriptions(void)
8640 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8641 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
8642 Warn("no element description file for element '%s'", EL_NAME(i));
8646 static int getMaxEdFieldX(boolean has_scrollbar)
8648 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
8649 int sxsize = SXSIZE - scrollbar_width;
8650 int max_ed_fieldx = sxsize / ed_tilesize;
8652 return max_ed_fieldx;
8655 static int getMaxEdFieldY(boolean has_scrollbar)
8657 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
8658 INFOTEXT_YSIZE_FULL : 0);
8659 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
8660 int sysize = SYSIZE - scrollbar_height - infotext_height;
8661 int max_ed_fieldy = sysize / ed_tilesize;
8663 return max_ed_fieldy;
8666 static void InitZoomLevelSettings(int zoom_tilesize)
8668 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
8670 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
8672 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
8673 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
8675 // make sure that tile size is always a power of 2
8676 ed_tilesize = (1 << log_2(ed_tilesize));
8678 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8680 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
8681 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
8685 last_game_engine_type = level.game_engine_type;
8687 // limit zoom tilesize by upper and lower bound
8688 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
8690 // store zoom tilesize in auto setup file only if it was manually changed
8691 if (zoom_tilesize != -1)
8692 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
8694 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
8695 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
8698 static void InitDrawingElements(void)
8700 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
8702 if (level.game_engine_type == game_engine_type_last)
8705 if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
8707 new_element1 = EL_SP_CHIP_SINGLE;
8708 new_element2 = EL_EMPTY;
8709 new_element3 = EL_SP_BASE;
8711 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8713 new_element1 = EL_MM_MIRROR_START;
8714 new_element2 = EL_EMPTY;
8715 new_element3 = EL_MM_WOODEN_WALL;
8719 new_element1 = EL_WALL;
8720 new_element2 = EL_EMPTY;
8721 new_element3 = EL_SAND;
8724 game_engine_type_last = level.game_engine_type;
8727 static void InitLevelSetInfo(void)
8729 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
8730 "%s", leveldir_current->name);
8731 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
8732 "%s", leveldir_current->author);
8734 levelset_num_levels = leveldir_current->levels;
8736 levelset_use_levelset_artwork = FALSE;
8737 levelset_copy_level_template = FALSE;
8739 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
8742 static void ChangeEditorToLevelSet(char *levelset_subdir)
8744 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
8746 // the previous level set might have used custom artwork
8747 ReloadCustomArtwork(0);
8749 LoadLevelSetup_SeriesInfo();
8751 SaveLevelSetup_LastSeries();
8752 SaveLevelSetup_SeriesInfo();
8756 LoadLevel(level_nr);
8757 LoadScore(level_nr);
8762 static boolean useEditorDoorAnimation(void)
8764 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
8765 boolean door_1_viewport_unchanged =
8766 (vp_door_1->x == DX &&
8767 vp_door_1->y == DY &&
8768 vp_door_1->width == DXSIZE &&
8769 vp_door_1->height == DYSIZE);
8770 boolean door_1_contains_toolbox =
8773 EX + EXSIZE <= DX + DXSIZE &&
8774 EY + EYSIZE <= DY + DYSIZE);
8776 return (door_1_viewport_unchanged && door_1_contains_toolbox);
8779 static void DrawEditorDoorBackground(int graphic, int x, int y,
8780 int width, int height)
8782 struct GraphicInfo *g = &graphic_info[graphic];
8784 if (g->bitmap != NULL)
8785 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
8786 MIN(width, g->width), MIN(height, g->height), x, y);
8788 ClearRectangle(drawto, x, y, width, height);
8791 static void DrawEditorDoorContent(void)
8793 // needed for gadgets drawn on background (like palette scrollbar)
8794 SetDoorBackgroundImage(IMG_UNDEFINED);
8796 // copy default editor door content to main double buffer
8797 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
8800 DrawSpecialEditorDoor();
8802 // draw new control window
8803 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
8805 // draw all toolbox gadgets to editor doors
8806 MapControlButtons();
8808 // when returning from test game to properties page, redraw toolbox gadgets
8809 if (edit_mode == ED_MODE_PROPERTIES)
8811 UnmapLevelEditorToolboxDrawingGadgets();
8812 UnmapLevelEditorToolboxCustomGadgets();
8814 MapLevelEditorToolboxCustomGadgetsIfNeeded();
8817 // draw all palette gadgets to editor doors
8818 ModifyEditorElementList();
8819 RedrawDrawingElements();
8821 // copy actual editor door content to door double buffer for OpenDoor()
8822 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
8825 void DrawLevelEd(void)
8827 int fade_mask = REDRAW_FIELD;
8829 FadeSoundsAndMusic();
8832 fade_mask = REDRAW_ALL;
8836 // needed if different viewport properties defined for editor
8837 ChangeViewportPropertiesIfNeeded();
8841 InitZoomLevelSettings(-1);
8842 InitDrawingElements();
8846 CheckElementDescriptions();
8849 if (level_editor_test_game)
8851 CopyPlayfield(level.field, Tile);
8852 CopyPlayfield(TileBackup, level.field);
8854 level_editor_test_game = FALSE;
8858 edit_mode = ED_MODE_DRAWING;
8859 edit_mode_levelconfig = ED_MODE_LEVELCONFIG_LEVEL;
8860 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
8868 // redraw_mask |= REDRAW_ALL;
8870 FreeLevelEditorGadgets();
8871 CreateLevelEditorGadgets();
8873 ReinitializeElementList(); // update dynamic level element list
8874 ReinitializeElementListButtons(); // custom element may look different
8876 InitElementPropertiesGfxElement();
8880 DrawEditModeWindow_PlayfieldOnly();
8882 DrawMaskedBorder(fade_mask);
8884 // use door animation if door 1 viewport is unchanged and contains toolbox
8885 if (useEditorDoorAnimation())
8889 DrawEditorDoorContent();
8891 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
8895 DrawEditorDoorContent();
8900 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
8903 static void AdjustDrawingAreaGadgets(void)
8905 int ed_xsize = lev_fieldx + 2;
8906 int ed_ysize = lev_fieldy + 2;
8907 int max_ed_fieldx = MAX_ED_FIELDX;
8908 int max_ed_fieldy = MAX_ED_FIELDY;
8909 boolean horizontal_scrollbar_needed;
8910 boolean vertical_scrollbar_needed;
8911 int x, y, width, height;
8913 if (suppressBorderElement())
8915 ed_xsize = max_ed_fieldx;
8916 ed_ysize = max_ed_fieldy;
8919 // check if we need any scrollbars
8920 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8921 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8923 // check if we have a smaller editor field because of scrollbars
8924 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8925 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8927 // check again if we now need more scrollbars because of less space
8928 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8929 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8931 // check if editor field gets even smaller after adding new scrollbars
8932 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8933 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8935 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
8936 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
8938 x = SX + ed_fieldx * ed_tilesize;
8939 y = SY + ed_fieldy * ed_tilesize;
8941 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
8942 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
8944 // adjust drawing area gadget
8945 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
8946 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
8947 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
8950 // adjust horizontal scrollbar gadgets
8951 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
8954 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
8955 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
8958 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8961 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
8964 // adjust vertical scrollbar gadgets
8965 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
8968 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
8970 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
8972 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8975 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
8979 static void AdjustLevelScrollPosition(void)
8981 if (level_xpos < -1)
8983 if (level_xpos > lev_fieldx - ed_fieldx + 1)
8984 level_xpos = lev_fieldx - ed_fieldx + 1;
8985 if (lev_fieldx < ed_fieldx - 2)
8988 if (level_ypos < -1)
8990 if (level_ypos > lev_fieldy - ed_fieldy + 1)
8991 level_ypos = lev_fieldy - ed_fieldy + 1;
8992 if (lev_fieldy < ed_fieldy - 2)
8995 if (suppressBorderElement())
9002 static void AdjustEditorScrollbar(int id)
9004 struct GadgetInfo *gi = level_editor_gadget[id];
9005 int items_max, items_visible, item_position;
9007 if (id == GADGET_ID_SCROLL_HORIZONTAL)
9009 items_max = MAX(lev_fieldx + 2, ed_fieldx);
9010 items_visible = ed_fieldx;
9011 item_position = level_xpos + 1;
9015 items_max = MAX(lev_fieldy + 2, ed_fieldy);
9016 items_visible = ed_fieldy;
9017 item_position = level_ypos + 1;
9020 if (item_position > items_max - items_visible)
9021 item_position = items_max - items_visible;
9023 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9024 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9027 static void AdjustElementListScrollbar(void)
9029 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
9030 int items_max, items_visible, item_position;
9032 // correct position of element list scrollbar
9033 if (element_shift < 0)
9035 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
9036 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
9038 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
9039 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
9040 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
9042 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
9043 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
9044 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9047 static void ModifyEditorCounterValue(int counter_id, int new_value)
9049 int *counter_value = counterbutton_info[counter_id].value;
9050 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9051 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9053 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9055 if (counter_value != NULL)
9056 *counter_value = gi->textinput.number_value;
9059 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9061 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9062 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9064 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9066 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9067 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9069 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9070 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9072 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9073 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9078 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9080 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9081 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9082 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9084 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9087 static void ModifyEditorSelectboxOptions(int selectbox_id,
9088 struct ValueTextInfo *options)
9090 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9091 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9093 selectbox_info[selectbox_id].options = options;
9095 // set index to zero -- list may be shorter now (correct later, if needed)
9096 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9097 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9100 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9102 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9103 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9105 drawingarea_info[drawingarea_id].area_xsize = xsize;
9106 drawingarea_info[drawingarea_id].area_ysize = ysize;
9108 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9111 static void ModifyEditorElementList(void)
9115 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9118 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9120 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9121 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9122 struct GadgetDesign *gd = &gi->deco.design;
9123 int element = editor_elements[element_shift + i];
9124 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9128 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9130 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9136 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9138 int graphic = el2edimg(element);
9139 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9145 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9148 static void ModifyDrawingElementButton(int element, int id)
9150 struct GadgetInfo *gi = level_editor_gadget[id];
9151 Bitmap *deco_bitmap;
9153 int tile_size = gi->deco.width;
9155 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9157 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9160 static void PickDrawingElement(int button, int element)
9165 struct XYTileSize *pos;
9167 } de, drawing_elements[] =
9169 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9170 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9171 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9174 if (button < 1 || button > 3)
9177 if (IS_MM_WALL(element))
9178 element = map_mm_wall_element(element);
9180 de = drawing_elements[button - 1];
9182 *de.new_element = element; // update global drawing element variable
9184 DrawDrawingElementGraphic(element, de.pos);
9185 ModifyDrawingElementButton(element, de.id);
9187 redraw_mask |= REDRAW_DOOR_1;
9190 static void RedrawDrawingElements(void)
9192 PickDrawingElement(1, new_element1);
9193 PickDrawingElement(2, new_element2);
9194 PickDrawingElement(3, new_element3);
9197 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9199 stick_element_properties_window = FALSE;
9201 SetMainBackgroundImage(IMG_UNDEFINED);
9204 UnmapLevelEditorFieldGadgets();
9206 AdjustDrawingAreaGadgets();
9207 AdjustLevelScrollPosition();
9208 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9209 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9211 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9213 MapMainDrawingArea();
9215 if (remap_toolbox_gadgets)
9217 UnmapLevelEditorToolboxCustomGadgets();
9218 MapLevelEditorToolboxDrawingGadgets();
9222 static void DrawDrawingWindow(void)
9224 DrawDrawingWindowExt(TRUE);
9227 static int getTabulatorBarWidth(void)
9229 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9230 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9232 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9235 static int getTabulatorBarHeight(void)
9237 return ED_TAB_BAR_HEIGHT;
9240 static Pixel getTabulatorBarColor(void)
9242 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9243 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9244 int gd_x = gd->x + gd_gi1->border.width / 2;
9245 int gd_y = gd->y + gd_gi1->height - 1;
9247 return GetPixel(gd->bitmap, gd_x, gd_y);
9250 static void DrawLevelConfigTabulatorGadgets(void)
9252 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELCONFIG_LEVEL];
9253 Pixel tab_color = getTabulatorBarColor();
9254 int id_first = ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST;
9255 int id_last = ED_TAB_BUTTON_ID_LEVELCONFIG_LAST;
9258 for (i = id_first; i <= id_last; i++)
9260 int gadget_id = textbutton_info[i].gadget_id;
9261 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9262 boolean active = (i != edit_mode_levelconfig);
9264 // draw background line below tabulator button
9265 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9267 // draw solid line below inactive tabulator buttons
9268 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9269 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9270 ED_GADGET_TINY_DISTANCE, tab_color);
9272 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9273 MapTextbuttonGadget(i);
9276 // draw little border line below tabulator buttons
9277 if (tab_color != BLACK_PIXEL) // black => transparent
9278 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9279 ED_GADGET_TINY_DISTANCE,
9280 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9283 static void DrawPropertiesTabulatorGadgets(void)
9285 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9286 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9287 int gd_x = gd->x + gd_gi1->border.width / 2;
9288 int gd_y = gd->y + gd_gi1->height - 1;
9289 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9290 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9291 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9294 // draw two config tabulators for player elements
9295 if (IS_PLAYER_ELEMENT(properties_element))
9296 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9298 // draw two config and one "change" tabulator for custom elements
9299 if (IS_CUSTOM_ELEMENT(properties_element))
9300 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9302 for (i = id_first; i <= id_last; i++)
9304 int gadget_id = textbutton_info[i].gadget_id;
9305 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9306 boolean active = (i != edit_mode_properties);
9308 // use "config 1" and "config 2" instead of "config" for players and CEs
9309 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9310 (IS_PLAYER_ELEMENT(properties_element) ||
9311 IS_CUSTOM_ELEMENT(properties_element)))
9314 // draw background line below tabulator button
9315 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9317 // draw solid line below inactive tabulator buttons
9318 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9319 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9320 ED_GADGET_TINY_DISTANCE, tab_color);
9322 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9323 MapTextbuttonGadget(i);
9326 // draw little border line below tabulator buttons
9327 if (tab_color != BLACK_PIXEL) // black => transparent
9328 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9329 ED_GADGET_TINY_DISTANCE,
9330 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9333 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9335 DrawText(SX + xpos, SY + ypos, text, font_nr);
9338 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9341 int font_width = getFontWidth(font_nr);
9342 int font_height = getFontHeight(font_nr);
9343 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9344 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9346 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9347 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9348 TRUE, FALSE, FALSE);
9351 static void DrawLevelConfigLevel(void)
9355 // draw counter gadgets
9356 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9357 MapCounterButtons(i);
9359 // draw checkbutton gadgets
9360 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9361 MapCheckbuttonGadget(i);
9363 // draw selectbox gadgets
9364 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9365 MapSelectboxGadget(i);
9367 // draw text input gadgets
9368 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9369 MapTextInputGadget(i);
9372 static char *getLevelSubdirFromSaveMode(int save_mode)
9374 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9375 return getNewUserLevelSubdir();
9377 return leveldir_current->subdir;
9380 static void DrawLevelConfigLevelSet_DirectoryInfo(void)
9382 char *directory_text = "Level set directory:";
9383 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9384 int font1_nr = FONT_TEXT_1;
9385 int font2_nr = FONT_TEXT_2;
9386 int font1_height = getFontHeight(font1_nr);
9387 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
9388 int x = ED_LEVEL_SETTINGS_X(0);
9389 int y = ED_LEVEL_SETTINGS_Y(6);
9391 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
9392 PrintInfoText(directory_name, font2_nr, x, y);
9395 static void DrawLevelConfigLevelSet(void)
9397 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
9398 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
9401 // draw counter gadgets
9402 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
9403 MapCounterButtons(i);
9405 // draw checkbutton gadgets
9406 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
9408 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
9409 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
9410 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
9413 MapCheckbuttonGadget(i);
9416 // draw selectbox gadgets
9417 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
9418 MapSelectboxGadget(i);
9420 // draw text input gadgets
9421 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
9422 MapTextInputGadget(i);
9424 // draw textbutton gadgets
9425 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
9428 DrawLevelConfigLevelSet_DirectoryInfo();
9431 static void DrawLevelConfigEditor(void)
9435 // draw counter gadgets
9436 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
9437 MapCounterButtons(i);
9439 // draw checkbutton gadgets
9440 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
9441 MapCheckbuttonGadget(i);
9443 // draw radiobutton gadgets
9444 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
9445 MapRadiobuttonGadget(i);
9447 // draw drawing area
9448 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
9450 // draw textbutton gadgets
9451 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
9454 static void DrawLevelConfigWindow(void)
9456 char *text = "Global Settings";
9457 int font_nr = FONT_TITLE_1;
9458 struct MenuPosInfo *pos = &editor.settings.headline;
9459 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
9460 int sy = SY + pos->y;
9462 stick_element_properties_window = FALSE;
9464 SetAutomaticNumberOfGemsNeeded();
9466 UnmapLevelEditorFieldGadgets();
9468 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9471 DrawText(sx, sy, text, font_nr);
9473 DrawLevelConfigTabulatorGadgets();
9475 if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVEL)
9476 DrawLevelConfigLevel();
9477 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_LEVELSET)
9478 DrawLevelConfigLevelSet();
9479 else if (edit_mode_levelconfig == ED_MODE_LEVELCONFIG_EDITOR)
9480 DrawLevelConfigEditor();
9483 static void DrawCustomContentArea(void)
9485 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
9486 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9487 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
9488 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
9489 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
9490 int xoffset = ED_GADGET_SPACE_DISTANCE;
9492 // add distance for potential left text (without drawing area border)
9493 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
9495 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9497 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
9500 static void DrawCustomChangeContentArea(void)
9502 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
9503 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9504 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
9505 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
9506 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
9507 int xoffset = ED_GADGET_SPACE_DISTANCE;
9509 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9514 static void RemoveElementContentArea(int id, int font_height)
9516 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9518 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
9519 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
9520 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9521 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
9522 ED_GADGET_TEXT_DISTANCE + font_height);
9525 static void DrawYamYamContentAreas(void)
9527 int font_nr = FONT_TEXT_1;
9528 int font_height = getFontHeight(font_nr);
9529 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9530 int yoffset = (tilesize - font_height) / 2;
9531 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
9532 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
9535 // display counter to choose number of element content areas
9536 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
9538 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9540 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
9542 if (i < level.num_yamyam_contents)
9548 UnmapDrawingArea(id);
9550 // delete content areas in case of reducing number of them
9551 RemoveElementContentArea(id, font_height);
9555 DrawText(x, y + 0 * tilesize, "content", font_nr);
9556 DrawText(x, y + 1 * tilesize, "when", font_nr);
9557 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
9560 static void DrawMagicBallContentAreas(void)
9562 int font_nr = FONT_TEXT_1;
9563 int font_height = getFontHeight(font_nr);
9564 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9565 int yoffset = (tilesize - font_height) / 2;
9566 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
9567 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
9570 // display counter to choose number of element content areas
9571 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
9573 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9575 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
9577 if (i < level.num_ball_contents)
9583 UnmapDrawingArea(id);
9585 // delete content areas in case of reducing number of them
9586 RemoveElementContentArea(id, font_height);
9590 DrawText(x, y + 0 * tilesize, "generated", font_nr);
9591 DrawText(x, y + 1 * tilesize, "when", font_nr);
9592 DrawText(x, y + 2 * tilesize, "active", font_nr);
9595 static void DrawAndroidElementArea(void)
9597 int id = ED_DRAWING_ID_ANDROID_CONTENT;
9598 int num_elements = level.num_android_clone_elements;
9599 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9600 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9601 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9602 int xsize = MAX_ANDROID_ELEMENTS;
9605 // display counter to choose number of element areas
9606 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
9608 if (drawingarea_info[id].text_left != NULL)
9609 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9611 UnmapDrawingArea(id);
9613 ModifyEditorDrawingArea(id, num_elements, 1);
9615 // delete content areas in case of reducing number of them
9616 DrawBackground(sx, sy,
9617 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9618 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9623 static void DrawGroupElementArea(void)
9625 int id = ED_DRAWING_ID_GROUP_CONTENT;
9626 int num_elements = group_element_info.num_elements;
9627 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9628 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9629 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9630 int xsize = MAX_ELEMENTS_IN_GROUP;
9633 if (drawingarea_info[id].text_left != NULL)
9634 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9636 UnmapDrawingArea(id);
9638 ModifyEditorDrawingArea(id, num_elements, 1);
9640 // delete content areas in case of reducing number of them
9641 DrawBackground(sx, sy,
9642 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9643 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9648 static void DrawPlayerInitialInventoryArea(int element)
9650 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
9651 int player_nr = GET_PLAYER_NR(element);
9652 int num_elements = level.initial_inventory_size[player_nr];
9653 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9654 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9655 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9656 int xsize = MAX_INITIAL_INVENTORY_SIZE;
9659 // determine horizontal position to the right of specified gadget
9660 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
9661 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
9662 ED_DRAWINGAREA_TEXT_DISTANCE);
9664 // determine horizontal offset for leading text
9665 if (drawingarea_info[id].text_left != NULL)
9666 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9668 UnmapDrawingArea(id);
9670 ModifyEditorDrawingArea(id, num_elements, 1);
9672 // delete content areas in case of reducing number of them
9673 DrawBackground(sx, sy,
9674 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9675 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9680 static void DrawMMBallContentArea(void)
9682 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
9683 int num_elements = level.num_mm_ball_contents;
9684 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9685 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9686 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9687 int xsize = MAX_MM_BALL_CONTENTS;
9690 if (drawingarea_info[id].text_left != NULL)
9691 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9693 UnmapDrawingArea(id);
9695 ModifyEditorDrawingArea(id, num_elements, 1);
9697 // delete content areas in case of reducing number of them
9698 DrawBackground(sx, sy,
9699 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9700 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9705 static void DrawEnvelopeTextArea(int envelope_nr)
9707 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
9708 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
9712 DrawBackground(gi->x, gi->y,
9713 gi->textarea.crop_width, gi->textarea.crop_height);
9715 if (envelope_nr != -1)
9716 textarea_info[id].value = level.envelope[envelope_nr].text;
9718 ModifyGadget(gi, GDI_AREA_SIZE,
9719 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
9720 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
9723 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
9726 static void DrawPropertiesInfo(void)
9735 // configurable properties
9737 { EP_WALKABLE_OVER, "- player can walk over it" },
9738 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
9739 { EP_WALKABLE_UNDER, "- player can walk under it" },
9740 { EP_PASSABLE_OVER, "- player can pass over it" },
9741 { EP_PASSABLE_INSIDE, "- player can pass through it" },
9742 { EP_PASSABLE_UNDER, "- player can pass under it" },
9743 { EP_PROTECTED, "- player is protected by it" },
9745 { EP_DIGGABLE, "- can be digged away" },
9746 { EP_COLLECTIBLE, "- can be collected" },
9747 { EP_DROPPABLE, "- can be dropped after collecting" },
9748 { EP_THROWABLE, "- can be thrown after collecting" },
9749 { EP_PUSHABLE, "- can be pushed" },
9751 { EP_CAN_FALL, "- can fall" },
9752 { EP_CAN_MOVE, "- can move" },
9754 { EP_CAN_SMASH_PLAYER, "- can smash player" },
9756 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
9758 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
9760 { EP_SLIPPERY, "- slippery for falling elements" },
9761 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
9763 { EP_DONT_RUN_INTO, "- deadly when running into" },
9764 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
9765 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
9766 { EP_DONT_TOUCH, "- deadly when touching" },
9768 { EP_INDESTRUCTIBLE, "- indestructible" },
9770 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
9771 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
9772 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
9774 { EP_CAN_CHANGE, "- can change to other element" },
9776 // pre-defined properties
9777 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
9778 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
9779 { EP_SWITCHABLE, "- can be switched" },
9781 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
9786 char *filename = getElementDescriptionFilename(properties_element);
9787 char *num_elements_text = "In this level: ";
9788 char *num_similar_text = "Similar tiles: ";
9789 char *properties_text = "Standard properties: ";
9790 char *description_text = "Description:";
9791 char *no_description_text = "No description available.";
9792 char *none_text = "None";
9794 int num_elements_in_level = 0;
9795 int num_similar_in_level = 0;
9796 int num_hires_tiles_in_level = 0;
9797 int num_standard_properties = 0;
9798 int font1_nr = FONT_TEXT_1;
9799 int font2_nr = FONT_TEXT_2;
9800 int font1_width = getFontWidth(font1_nr);
9801 int font1_height = getFontHeight(font1_nr);
9802 int font2_height = getFontHeight(font2_nr);
9803 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
9804 int font2_yoffset = (font1_height - font2_height) / 2;
9805 int num_elements_text_len = strlen(num_elements_text) * font1_width;
9806 int num_similar_text_len = strlen(num_similar_text) * font1_width;
9807 int properties_text_len = strlen(properties_text) * font1_width;
9808 int xpos = ED_ELEMENT_SETTINGS_X(0);
9809 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9812 if (setup.editor.show_element_token)
9814 int font3_nr = FONT_TEXT_3;
9815 int font3_height = getFontHeight(font3_nr);
9817 DrawTextF(xpos, ypos, font3_nr,
9818 "[%s]", element_info[properties_element].token_name);
9820 ypos += 2 * font3_height;
9823 // ----- print number of elements / percentage of this element in level
9825 for (y = 0; y < lev_fieldy; y++)
9827 for (x = 0; x < lev_fieldx; x++)
9829 if (Tile[x][y] == properties_element)
9831 num_elements_in_level++;
9833 else if (IS_MM_WALL(Tile[x][y]) &&
9834 map_mm_wall_element(Tile[x][y]) == properties_element)
9836 num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
9841 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
9843 DrawTextS(xpos, ypos, font1_nr, num_elements_text);
9845 if (num_hires_tiles_in_level > 0)
9846 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
9847 "%d wall tiles", num_hires_tiles_in_level);
9848 else if (num_elements_in_level > 0)
9849 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
9850 "%d (%.2f %%)", num_elements_in_level, percentage);
9852 DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
9855 // ----- print number of similar elements / percentage of them in level
9857 for (y = 0; y < lev_fieldy; y++)
9859 for (x = 0; x < lev_fieldx; x++)
9861 if (strEqual(element_info[Tile[x][y]].class_name,
9862 element_info[properties_element].class_name))
9864 num_similar_in_level++;
9869 if (num_similar_in_level != num_elements_in_level)
9871 ypos += 1 * MAX(font1_height, font2_height);
9873 percentage = num_similar_in_level * 100.0 / (lev_fieldx * lev_fieldy);
9875 DrawTextS(xpos, ypos, font1_nr, num_similar_text);
9877 if (num_similar_in_level > 0)
9878 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
9879 "%d (%.2f %%)", num_similar_in_level, percentage);
9881 DrawTextF(xpos + num_similar_text_len, ypos + font2_yoffset, font2_nr,
9885 ypos += 2 * MAX(font1_height, font2_height);
9887 // ----- print standard properties of this element
9889 DrawTextS(xpos, ypos, font1_nr, properties_text);
9891 ypos += line1_height;
9893 for (i = 0; properties[i].value != -1; i++)
9895 if (!HAS_PROPERTY(properties_element, properties[i].value))
9898 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
9900 ypos += font2_height;
9902 num_standard_properties++;
9905 if (num_standard_properties == 0)
9907 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
9908 font2_nr, none_text);
9910 ypos -= (line1_height - font1_height);
9913 ypos += MAX(font1_height, font2_height);
9915 // ----- print special description of this element
9917 PrintInfoText(description_text, font1_nr, xpos, ypos);
9919 ypos += line1_height;
9921 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
9922 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
9925 #define TEXT_COLLECTING "Score for collecting"
9926 #define TEXT_SMASHING "Score for smashing"
9927 #define TEXT_SLURPING "Score for slurping robot"
9928 #define TEXT_CRACKING "Score for cracking"
9929 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
9930 #define TEXT_DURATION "Duration when activated"
9931 #define TEXT_DELAY_ON "Delay before activating"
9932 #define TEXT_DELAY_OFF "Delay before deactivating"
9933 #define TEXT_DELAY_CHANGING "Delay before changing"
9934 #define TEXT_DELAY_EXPLODING "Delay before exploding"
9935 #define TEXT_DELAY_MOVING "Delay before moving"
9936 #define TEXT_BALL_DELAY "Element generation delay"
9937 #define TEXT_MOVE_SPEED "Speed of android moving"
9938 #define TEXT_CLONE_SPEED "Speed of android cloning"
9939 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
9940 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
9941 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
9942 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
9943 #define TEXT_TIME_BONUS "Extra time to solve level"
9950 } elements_with_counter[] =
9952 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
9953 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
9954 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
9955 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
9956 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9957 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
9958 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
9959 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
9960 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
9961 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
9962 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
9963 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
9964 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9965 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9966 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
9967 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
9968 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
9969 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9970 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9971 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
9972 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9973 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9974 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9975 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9976 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9977 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9978 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
9979 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9980 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9981 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9982 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9983 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9984 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9985 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9986 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
9987 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
9988 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9989 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
9990 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9991 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9992 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9993 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9994 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9995 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
9996 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9997 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9998 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE], TEXT_COLLECTING },
9999 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10000 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
10001 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
10002 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
10003 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
10004 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10005 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10006 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10007 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10008 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
10009 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
10010 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
10011 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
10012 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
10013 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
10014 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
10015 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
10016 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
10017 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
10018 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
10019 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
10020 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
10021 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
10022 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
10023 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
10024 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
10025 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
10026 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10027 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10028 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10029 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10030 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
10031 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10032 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10033 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
10034 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
10036 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
10037 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
10038 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
10039 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
10040 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
10041 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
10042 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
10043 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
10044 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
10045 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
10046 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
10047 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
10048 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
10049 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
10050 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
10051 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
10053 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
10054 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
10055 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
10056 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
10057 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
10058 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
10059 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
10060 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
10061 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
10062 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
10063 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
10064 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
10065 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_CHANGING },
10066 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10067 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
10072 static boolean checkPropertiesConfig(int element)
10076 if (IS_GEM(element) ||
10077 IS_CUSTOM_ELEMENT(element) ||
10078 IS_GROUP_ELEMENT(element) ||
10079 IS_EMPTY_ELEMENT(element) ||
10080 IS_BALLOON_ELEMENT(element) ||
10081 IS_ENVELOPE(element) ||
10082 IS_MM_ENVELOPE(element) ||
10083 IS_MM_MCDUFFIN(element) ||
10084 IS_DF_LASER(element) ||
10085 IS_PLAYER_ELEMENT(element) ||
10086 HAS_EDITOR_CONTENT(element) ||
10087 CAN_GROW(element) ||
10088 COULD_MOVE_INTO_ACID(element) ||
10089 MAYBE_DONT_COLLIDE_WITH(element) ||
10090 element == EL_SOKOBAN_OBJECT ||
10091 element == EL_SOKOBAN_FIELD_EMPTY ||
10092 element == EL_SOKOBAN_FIELD_FULL)
10095 for (i = 0; elements_with_counter[i].element != -1; i++)
10096 if (elements_with_counter[i].element == element)
10102 static void SetAutomaticNumberOfGemsNeeded(void)
10106 if (!level.auto_count_gems)
10109 level.gems_needed = 0;
10111 for (x = 0; x < lev_fieldx; x++)
10113 for (y = 0; y < lev_fieldy; y++)
10115 int element = Tile[x][y];
10120 case EL_EMERALD_YELLOW:
10121 case EL_EMERALD_RED:
10122 case EL_EMERALD_PURPLE:
10123 case EL_BD_DIAMOND:
10124 case EL_WALL_EMERALD:
10125 case EL_WALL_EMERALD_YELLOW:
10126 case EL_WALL_EMERALD_RED:
10127 case EL_WALL_EMERALD_PURPLE:
10128 case EL_WALL_BD_DIAMOND:
10130 case EL_SP_INFOTRON:
10133 level.gems_needed++;
10137 case EL_WALL_DIAMOND:
10138 level.gems_needed += 3;
10142 case EL_WALL_PEARL:
10143 level.gems_needed += 5;
10147 case EL_WALL_CRYSTAL:
10148 level.gems_needed += 8;
10157 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10160 static void DrawPropertiesConfig(void)
10162 boolean draw_footer_line = FALSE;
10163 int max_num_element_counters = 4;
10164 int num_element_counters = 0;
10167 if (!checkPropertiesConfig(properties_element))
10169 int xpos = ED_ELEMENT_SETTINGS_X(0);
10170 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10172 PrintInfoText("No configuration options available.",
10173 FONT_TEXT_1, xpos, ypos);
10178 // check if there are elements where a value can be chosen for
10179 for (i = 0; elements_with_counter[i].element != -1; i++)
10181 if (elements_with_counter[i].element == properties_element)
10183 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10185 counterbutton_info[counter_id].y =
10186 ED_ELEMENT_SETTINGS_YPOS(
10187 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10188 (CAN_GROW(properties_element) ? 1 : 0) +
10189 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10190 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10191 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10192 num_element_counters);
10194 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10195 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
10197 if (properties_element == EL_GAME_OF_LIFE ||
10198 properties_element == EL_BIOMAZE)
10200 counterbutton_info[counter_id].min_value = 0; // min neighbours
10201 counterbutton_info[counter_id].max_value = 8; // max neighbours
10205 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10206 counterbutton_info[counter_id].min_value = MIN_SCORE;
10207 counterbutton_info[counter_id].max_value = MAX_SCORE;
10210 MapCounterButtons(counter_id);
10212 num_element_counters++;
10213 if (num_element_counters >= max_num_element_counters)
10218 if (HAS_EDITOR_CONTENT(properties_element))
10220 // draw stickybutton gadget
10221 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10223 if (IS_AMOEBOID(properties_element))
10224 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10225 else if (properties_element == EL_YAMYAM ||
10226 properties_element == EL_YAMYAM_LEFT ||
10227 properties_element == EL_YAMYAM_RIGHT ||
10228 properties_element == EL_YAMYAM_UP ||
10229 properties_element == EL_YAMYAM_DOWN)
10230 DrawYamYamContentAreas();
10231 else if (properties_element == EL_EMC_MAGIC_BALL)
10233 DrawMagicBallContentAreas();
10235 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10236 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10238 else if (properties_element == EL_EMC_ANDROID)
10239 DrawAndroidElementArea();
10240 else if (properties_element == EL_MM_GRAY_BALL)
10242 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
10243 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
10244 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
10245 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EXPLODE_MM_BALL);
10247 DrawMMBallContentArea();
10251 if (IS_PLAYER_ELEMENT(properties_element))
10253 int player_nr = GET_PLAYER_NR(properties_element);
10255 // these properties can be set for every player individually
10257 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10259 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
10260 &level.start_element[player_nr];
10261 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
10262 &level.artwork_element[player_nr];
10263 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
10264 &level.explosion_element[player_nr];
10266 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10267 &level.use_start_element[player_nr];
10268 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10269 &level.use_artwork_element[player_nr];
10270 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10271 &level.use_explosion_element[player_nr];
10272 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10273 &level.initial_player_gravity[player_nr];
10275 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10276 &level.initial_player_stepsize[player_nr];
10278 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
10279 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
10280 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
10281 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
10282 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
10283 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
10284 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
10285 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
10286 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
10287 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
10288 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
10289 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
10290 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
10291 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
10292 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
10294 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
10295 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
10296 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
10298 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
10300 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10302 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
10303 &level.initial_inventory_content[player_nr][0];
10305 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
10306 &level.initial_inventory_size[player_nr];
10308 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
10309 &level.use_initial_inventory[player_nr];
10311 // draw checkbutton gadgets
10312 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
10313 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
10314 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
10316 // draw counter gadgets
10317 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
10319 // draw drawing area gadgets
10320 DrawPlayerInitialInventoryArea(properties_element);
10324 if (IS_GEM(properties_element))
10325 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
10327 if (properties_element == EL_EM_DYNAMITE)
10328 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
10330 if (COULD_MOVE_INTO_ACID(properties_element) &&
10331 !IS_PLAYER_ELEMENT(properties_element) &&
10332 (!IS_CUSTOM_ELEMENT(properties_element) ||
10333 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
10335 // set position for checkbutton for "can move into acid"
10336 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
10337 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
10338 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
10339 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
10340 IS_BALLOON_ELEMENT(properties_element) ||
10341 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10343 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
10346 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
10347 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
10349 if (properties_element == EL_SPRING ||
10350 properties_element == EL_SPRING_LEFT ||
10351 properties_element == EL_SPRING_RIGHT)
10352 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
10354 if (properties_element == EL_TIME_ORB_FULL)
10355 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
10357 if (properties_element == EL_GAME_OF_LIFE ||
10358 properties_element == EL_BIOMAZE)
10359 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
10361 if (CAN_GROW(properties_element))
10363 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
10364 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10366 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
10369 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
10370 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
10372 if (properties_element == EL_SOKOBAN_OBJECT)
10373 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
10375 if (properties_element == EL_SOKOBAN_OBJECT ||
10376 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
10377 properties_element == EL_SOKOBAN_FIELD_FULL)
10379 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
10380 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
10383 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
10386 if (IS_BALLOON_ELEMENT(properties_element))
10387 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
10389 if (IS_ENVELOPE(properties_element) ||
10390 IS_MM_ENVELOPE(properties_element))
10392 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
10393 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
10394 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
10395 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
10396 int envelope_nr = ENVELOPE_NR(properties_element);
10398 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
10399 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
10401 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
10402 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
10404 // display counter to choose size of envelope text area
10405 MapCounterButtons(counter1_id);
10406 MapCounterButtons(counter2_id);
10408 // display checkbuttons to choose auto-wrap and alignment properties
10409 MapCheckbuttonGadget(button1_id);
10410 MapCheckbuttonGadget(button2_id);
10412 DrawEnvelopeTextArea(envelope_nr);
10415 if (IS_MM_MCDUFFIN(properties_element))
10417 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
10418 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
10419 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
10422 if (IS_DF_LASER(properties_element))
10424 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
10425 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
10426 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
10429 if (IS_CUSTOM_ELEMENT(properties_element))
10431 // draw stickybutton gadget
10432 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10434 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10436 // draw checkbutton gadgets
10437 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
10438 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
10439 MapCheckbuttonGadget(i);
10441 // draw counter gadgets
10442 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
10443 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
10444 MapCounterButtons(i);
10446 // draw selectbox gadgets
10447 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
10448 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
10449 MapSelectboxGadget(i);
10451 // draw textbutton gadgets
10452 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10454 // draw text input gadgets
10455 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10457 // draw drawing area gadgets
10458 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10460 draw_footer_line = TRUE;
10462 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10464 // draw checkbutton gadgets
10465 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
10466 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
10467 MapCheckbuttonGadget(i);
10469 // draw counter gadgets
10470 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
10471 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
10472 MapCounterButtons(i);
10474 // draw selectbox gadgets
10475 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
10476 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
10477 MapSelectboxGadget(i);
10479 // draw drawing area gadgets
10480 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
10481 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
10482 DrawCustomContentArea();
10485 else if (IS_GROUP_ELEMENT(properties_element))
10487 // draw stickybutton gadget
10488 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10490 // draw checkbutton gadgets
10491 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10492 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10494 // draw counter gadgets
10495 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
10497 // draw selectbox gadgets
10498 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
10500 // draw textbutton gadgets
10501 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10503 // draw drawing area gadgets
10504 DrawGroupElementArea();
10506 // draw text input gadgets
10507 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10509 // draw drawing area gadgets
10510 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10512 draw_footer_line = TRUE;
10514 else if (IS_EMPTY_ELEMENT(properties_element))
10516 // draw stickybutton gadget
10517 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10519 // draw checkbutton gadgets
10520 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10521 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10523 // draw textbutton gadgets
10524 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10526 // draw drawing area gadgets
10527 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10529 draw_footer_line = TRUE;
10532 // draw little footer border line above CE/GE use/save template gadgets
10533 if (draw_footer_line)
10535 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
10536 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
10537 int gd_x = gd->x + gd_gi1->border.width / 2;
10538 int gd_y = gd->y + gd_gi1->height - 1;
10539 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
10541 if (tab_color != BLACK_PIXEL) // black => transparent
10542 FillRectangle(drawto,
10543 SX + ED_ELEMENT_SETTINGS_X(0),
10544 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
10546 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10550 static void DrawPropertiesChangeDrawingAreas(void)
10552 if (IS_CUSTOM_ELEMENT(properties_element))
10554 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
10555 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
10556 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
10558 DrawCustomChangeContentArea();
10561 redraw_mask |= REDRAW_FIELD;
10564 static void DrawPropertiesChange(void)
10568 // needed to initially set selectbox options for special action options
10569 setSelectboxSpecialActionOptions();
10571 // draw stickybutton gadget
10572 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10574 // draw checkbutton gadgets
10575 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
10576 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
10577 MapCheckbuttonGadget(i);
10579 // draw counter gadgets
10580 for (i = ED_COUNTER_ID_CHANGE_FIRST;
10581 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
10582 MapCounterButtons(i);
10584 // draw selectbox gadgets
10585 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
10586 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
10587 MapSelectboxGadget(i);
10589 // draw textbutton gadgets
10590 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
10591 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
10592 MapTextbuttonGadget(i);
10594 // draw graphicbutton gadgets
10595 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
10596 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
10597 MapGraphicbuttonGadget(i);
10599 // draw drawing area gadgets
10600 DrawPropertiesChangeDrawingAreas();
10603 static void DrawEditorElementAnimation(int x, int y)
10605 int graphic = el2img(properties_element);
10606 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
10607 custom_element.ce_value_fixed_initial :
10608 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
10609 custom_element.collect_score_initial : FrameCounter);
10611 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
10614 static void DrawEditorElementName(int x, int y, int font_nr)
10616 char *element_name = getElementInfoText(properties_element);
10617 int font_width = getFontWidth(font_nr);
10618 int font_height = getFontHeight(font_nr);
10619 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
10620 int max_chars_per_line = max_text_width / font_width;
10622 if (strlen(element_name) <= max_chars_per_line)
10623 DrawTextS(x, y, font_nr, element_name);
10626 char buffer[max_chars_per_line + 1];
10627 int next_pos = max_chars_per_line;
10629 strncpy(buffer, element_name, max_chars_per_line);
10630 buffer[max_chars_per_line] = '\0';
10632 if (element_name[max_chars_per_line] == ' ')
10638 for (i = max_chars_per_line - 1; i >= 0; i--)
10639 if (buffer[i] == ' ')
10642 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
10649 DrawTextS(x, y - font_height / 2, font_nr, buffer);
10651 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
10652 buffer[max_chars_per_line] = '\0';
10654 DrawTextS(x, y + font_height / 2, font_nr, buffer);
10658 static void DrawPropertiesWindow(void)
10660 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
10661 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
10662 int border_size = gd->border_size;
10663 int font_nr = FONT_TEXT_1;
10664 int font_height = getFontHeight(font_nr);
10665 int xoffset = TILEX + element_border + 3 * border_size;
10666 int yoffset = (TILEY - font_height) / 2;
10667 int x1 = editor.settings.element_graphic.x + element_border;
10668 int y1 = editor.settings.element_graphic.y + element_border;
10669 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
10670 editor.settings.element_name.x);
10671 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
10672 editor.settings.element_name.y);
10673 char *text = "Element Settings";
10674 int font2_nr = FONT_TITLE_1;
10675 struct MenuPosInfo *pos = &editor.settings.headline;
10676 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
10677 int sy = SY + pos->y;
10679 stick_element_properties_window = FALSE;
10681 // make sure that previous properties edit mode exists for this element
10682 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
10683 !IS_CUSTOM_ELEMENT(properties_element))
10684 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
10686 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
10687 !IS_PLAYER_ELEMENT(properties_element) &&
10688 !IS_CUSTOM_ELEMENT(properties_element))
10689 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
10691 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
10692 (IS_PLAYER_ELEMENT(properties_element) ||
10693 IS_CUSTOM_ELEMENT(properties_element)))
10694 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
10696 CopyElementPropertiesToEditor(properties_element);
10698 UnmapLevelEditorFieldGadgets();
10699 UnmapLevelEditorToolboxDrawingGadgets();
10700 UnmapLevelEditorToolboxCustomGadgets();
10702 MapLevelEditorToolboxCustomGadgetsIfNeeded();
10704 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10707 DrawText(sx, sy, text, font2_nr);
10709 FrameCounter = 0; // restart animation frame counter
10711 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
10712 DrawEditorElementAnimation(SX + x1, SY + y1);
10713 DrawEditorElementName(x2, y2, font_nr);
10715 DrawPropertiesTabulatorGadgets();
10717 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
10718 DrawPropertiesInfo();
10719 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
10720 DrawPropertiesChange();
10721 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
10722 DrawPropertiesConfig();
10725 static void DrawPaletteWindow(void)
10729 UnmapLevelEditorFieldGadgets();
10731 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10734 // map buttons to select elements
10735 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
10736 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
10737 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
10738 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
10739 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
10742 static void UpdateCustomElementGraphicGadgets(void)
10746 InitElementPropertiesGfxElement();
10748 ModifyEditorElementList();
10749 RedrawDrawingElements();
10751 // force redraw of all mapped drawing area gadgets
10752 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
10754 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
10761 static int getOpenDirectionFromTube(int element)
10765 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
10766 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
10767 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
10768 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
10769 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
10770 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
10771 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
10772 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
10773 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
10774 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
10775 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
10781 static int getTubeFromOpenDirection(int direction)
10785 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
10786 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
10787 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
10788 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
10789 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
10790 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
10791 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
10792 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
10793 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
10794 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
10795 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
10797 // if only one direction, fall back to simple tube with that direction
10798 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
10799 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
10800 case (MV_UP): return EL_TUBE_VERTICAL;
10801 case (MV_DOWN): return EL_TUBE_VERTICAL;
10807 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
10809 int element_new = getTubeFromOpenDirection(direction);
10811 return (element_new != EL_EMPTY ? element_new : element_old);
10814 static int getOpenDirectionFromBelt(int element)
10816 int belt_dir = getBeltDirFromBeltElement(element);
10818 return (belt_dir == MV_LEFT ? MV_RIGHT :
10819 belt_dir == MV_RIGHT ? MV_LEFT :
10820 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
10823 static int getBeltFromNrAndOpenDirection(int nr, int direction)
10825 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
10826 direction == MV_RIGHT ? MV_LEFT :
10827 direction == MV_HORIZONTAL ? MV_NONE : direction);
10829 if (direction == MV_NONE)
10832 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
10835 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
10838 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
10840 return (element_new != EL_EMPTY ? element_new : element_old);
10843 static int getOpenDirectionFromPool(int element)
10847 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
10848 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
10849 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
10850 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
10851 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
10852 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
10858 static int getPoolFromOpenDirection(int direction)
10862 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
10863 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
10864 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
10865 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
10866 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
10867 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
10873 static int getPoolFromOpenDirectionExt(int direction, int help_element)
10875 int element = getPoolFromOpenDirection(direction);
10876 int help_direction = getOpenDirectionFromPool(help_element);
10878 if (element == EL_EMPTY)
10880 int help_direction_vertical = help_direction & MV_VERTICAL;
10882 element = getPoolFromOpenDirection(direction | help_direction_vertical);
10885 if (element == EL_EMPTY)
10887 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
10889 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
10895 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
10897 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
10899 return (element_new != EL_EMPTY ? element_new : element_old);
10902 static int getOpenDirectionFromPillar(int element)
10906 case EL_EMC_WALL_1: return (MV_DOWN);
10907 case EL_EMC_WALL_2: return (MV_VERTICAL);
10908 case EL_EMC_WALL_3: return (MV_UP);
10914 static int getPillarFromOpenDirection(int direction)
10918 case (MV_DOWN): return EL_EMC_WALL_1;
10919 case (MV_VERTICAL): return EL_EMC_WALL_2;
10920 case (MV_UP): return EL_EMC_WALL_3;
10926 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
10928 int element_new = getPillarFromOpenDirection(direction);
10930 return (element_new != EL_EMPTY ? element_new : element_old);
10933 static int getOpenDirectionFromSteel2(int element)
10937 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
10938 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
10939 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
10940 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
10941 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
10942 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
10943 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
10944 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
10950 static int getSteel2FromOpenDirection(int direction)
10954 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
10955 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
10956 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
10957 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
10958 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
10959 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
10960 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
10961 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
10967 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
10969 int element_new = getSteel2FromOpenDirection(direction);
10971 return (element_new != EL_EMPTY ? element_new : element_old);
10974 static int getOpenDirectionFromChip(int element)
10978 case EL_SP_CHIP_SINGLE: return (MV_NONE);
10979 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
10980 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
10981 case EL_SP_CHIP_TOP: return (MV_DOWN);
10982 case EL_SP_CHIP_BOTTOM: return (MV_UP);
10988 static int getChipFromOpenDirection(int direction)
10992 case (MV_NONE): return EL_SP_CHIP_SINGLE;
10993 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
10994 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
10995 case (MV_UP): return EL_SP_CHIP_BOTTOM;
10996 case (MV_DOWN): return EL_SP_CHIP_TOP;
11002 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
11004 int element_new = getChipFromOpenDirection(direction);
11006 return (element_new != EL_EMPTY ? element_new : element_old);
11009 static int getClosedTube(int x, int y)
11011 struct XY *xy = xy_directions;
11012 int element_old = IntelliDrawBuffer[x][y];
11013 int direction_old = getOpenDirectionFromTube(element_old);
11014 int direction_new = MV_NONE;
11017 for (i = 0; i < NUM_DIRECTIONS; i++)
11019 int xx = x + xy[i].x;
11020 int yy = y + xy[i].y;
11021 int dir = MV_DIR_FROM_BIT(i);
11022 int dir_opposite = MV_DIR_OPPOSITE(dir);
11024 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
11025 (direction_old & dir) &&
11026 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11027 direction_new |= dir;
11030 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
11033 static int getClosedBelt(int x, int y)
11035 struct XY *xy = xy_directions;
11036 int element_old = IntelliDrawBuffer[x][y];
11037 int nr = getBeltNrFromBeltElement(element_old);
11038 int direction_old = getOpenDirectionFromBelt(element_old);
11039 int direction_new = MV_NONE;
11042 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11044 int xx = x + xy[i].x;
11045 int yy = y + xy[i].y;
11046 int dir = MV_DIR_FROM_BIT(i);
11047 int dir_opposite = MV_DIR_OPPOSITE(dir);
11049 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
11050 (direction_old & dir) &&
11051 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11052 direction_new |= dir;
11055 return getBeltFromNrAndOpenDirection(nr, direction_new);
11058 static int getClosedPool(int x, int y)
11060 struct XY *xy = xy_directions;
11061 int element_old = IntelliDrawBuffer[x][y];
11062 int direction_old = getOpenDirectionFromPool(element_old);
11063 int direction_new = MV_NONE;
11066 for (i = 0; i < NUM_DIRECTIONS; i++)
11068 int xx = x + xy[i].x;
11069 int yy = y + xy[i].y;
11070 int dir = MV_DIR_FROM_BIT(i);
11071 int dir_opposite = MV_DIR_OPPOSITE(dir);
11073 if (IN_LEV_FIELD(xx, yy) &&
11074 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
11075 (direction_old & dir) &&
11076 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11077 direction_new |= dir;
11080 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
11083 static int getClosedPillar(int x, int y)
11085 struct XY *xy = xy_directions;
11086 int element_old = IntelliDrawBuffer[x][y];
11087 int direction_old = getOpenDirectionFromPillar(element_old);
11088 int direction_new = MV_NONE;
11091 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11093 int xx = x + xy[i].x;
11094 int yy = y + xy[i].y;
11095 int dir = MV_DIR_FROM_BIT(i);
11096 int dir_opposite = MV_DIR_OPPOSITE(dir);
11098 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11099 (direction_old & dir) &&
11100 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11101 direction_new |= dir;
11104 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11107 static int getClosedSteel2(int x, int y)
11109 struct XY *xy = xy_directions;
11110 int element_old = IntelliDrawBuffer[x][y];
11111 int direction_old = getOpenDirectionFromSteel2(element_old);
11112 int direction_new = MV_NONE;
11115 for (i = 0; i < NUM_DIRECTIONS; i++)
11117 int xx = x + xy[i].x;
11118 int yy = y + xy[i].y;
11119 int dir = MV_DIR_FROM_BIT(i);
11120 int dir_opposite = MV_DIR_OPPOSITE(dir);
11122 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11123 (direction_old & dir) &&
11124 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11125 direction_new |= dir;
11128 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11131 static int getClosedChip(int x, int y)
11133 struct XY *xy = xy_directions;
11134 int element_old = IntelliDrawBuffer[x][y];
11135 int direction_old = getOpenDirectionFromChip(element_old);
11136 int direction_new = MV_NONE;
11139 for (i = 0; i < NUM_DIRECTIONS; i++)
11141 int xx = x + xy[i].x;
11142 int yy = y + xy[i].y;
11143 int dir = MV_DIR_FROM_BIT(i);
11144 int dir_opposite = MV_DIR_OPPOSITE(dir);
11146 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11147 (direction_old & dir) &&
11148 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11149 direction_new |= dir;
11152 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11155 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11156 boolean change_level)
11158 int sx = x - level_xpos;
11159 int sy = y - level_ypos;
11160 int old_element = Tile[x][y];
11161 int new_element = element;
11162 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11163 boolean draw_masked = FALSE;
11165 if (IS_MM_WALL_EDITOR(element))
11167 element = map_mm_wall_element_editor(element) | new_bitmask;
11169 if (IS_MM_WALL(old_element))
11170 element |= MM_WALL_BITS(old_element);
11173 draw_masked = TRUE;
11175 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11177 int element_changed = old_element & ~new_bitmask;
11179 if (MM_WALL_BITS(element_changed) != 0)
11180 element = element_changed;
11183 IntelliDrawBuffer[x][y] = element;
11186 Tile[x][y] = element;
11188 if (IN_ED_FIELD(sx, sy))
11190 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11191 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11192 else if (draw_masked)
11193 DrawEditorElementThruMask(sx, sy, element);
11195 DrawEditorElement(sx, sy, element);
11199 static void SetElementSimple(int x, int y, int element, boolean change_level)
11201 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11204 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11205 int x2, int y2, int *element2,
11206 int (*close_function)(int, int),
11207 boolean change_level)
11209 // set neighbour elements to newly determined connections
11210 SetElementSimple(x1, y1, *element1, change_level);
11211 SetElementSimple(x2, y2, *element2, change_level);
11213 // remove all open connections of neighbour elements
11214 *element1 = close_function(x1, y1);
11215 *element2 = close_function(x2, y2);
11217 // set neighbour elements to new, minimized connections
11218 SetElementSimple(x1, y1, *element1, change_level);
11219 SetElementSimple(x2, y2, *element2, change_level);
11222 static void SetElementIntelliDraw(int x, int y, int dx, int dy, int new_element,
11223 boolean change_level, int button)
11225 struct XY *xy = xy_directions;
11226 static int last_x = -1;
11227 static int last_y = -1;
11229 if (new_element == EL_UNDEFINED)
11237 int old_element = IntelliDrawBuffer[x][y];
11239 if (IS_TUBE(new_element))
11241 int last_element_new = EL_UNDEFINED;
11242 int direction = MV_NONE;
11245 // if old element is of same kind, keep all existing directions
11246 if (IS_TUBE(old_element))
11247 direction |= getOpenDirectionFromTube(old_element);
11249 for (i = 0; i < NUM_DIRECTIONS; i++)
11251 int xx = x + xy[i].x;
11252 int yy = y + xy[i].y;
11254 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11255 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11257 int dir = MV_DIR_FROM_BIT(i);
11258 int dir_opposite = MV_DIR_OPPOSITE(dir);
11259 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11260 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11261 int last_direction_new = last_direction_old | dir_opposite;
11263 last_element_new = getTubeFromOpenDirection(last_direction_new);
11269 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
11271 if (last_element_new != EL_UNDEFINED)
11272 MergeAndCloseNeighbourElements(x, y, &new_element,
11273 last_x, last_y, &last_element_new,
11274 getClosedTube, change_level);
11276 else if (IS_BELT(new_element))
11278 int belt_nr = getBeltNrFromBeltElement(new_element);
11279 int last_element_new = EL_UNDEFINED;
11280 int direction = MV_NONE;
11283 // if old element is of same kind, keep all existing directions
11284 if (IS_BELT(old_element))
11285 direction |= getOpenDirectionFromBelt(old_element);
11287 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11289 int xx = x + xy[i].x;
11290 int yy = y + xy[i].y;
11292 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11293 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
11295 int dir = MV_DIR_FROM_BIT(i);
11296 int dir_opposite = MV_DIR_OPPOSITE(dir);
11297 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11298 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
11299 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
11300 int last_direction_new = last_direction_old | dir_opposite;
11302 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11303 last_direction_new);
11308 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
11310 if (last_element_new != EL_UNDEFINED)
11311 MergeAndCloseNeighbourElements(x, y, &new_element,
11312 last_x, last_y, &last_element_new,
11313 getClosedBelt, change_level);
11315 else if (IS_ACID_POOL_OR_ACID(new_element))
11317 int last_element_new = EL_UNDEFINED;
11318 int direction = MV_NONE;
11321 // if old element is of same kind, keep all existing directions
11322 if (IS_ACID_POOL_OR_ACID(old_element))
11323 direction |= getOpenDirectionFromPool(old_element);
11325 for (i = 0; i < NUM_DIRECTIONS; i++)
11327 int xx = x + xy[i].x;
11328 int yy = y + xy[i].y;
11330 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11331 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
11333 int dir = MV_DIR_FROM_BIT(i);
11334 int dir_opposite = MV_DIR_OPPOSITE(dir);
11335 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11336 int last_direction_old = getOpenDirectionFromPool(last_element_old);
11337 int last_direction_new = last_direction_old | dir_opposite;
11339 last_element_new = getPoolFromOpenDirection(last_direction_new);
11345 // special corrections needed for intuitively correct acid pool drawing
11346 if (last_element_new == EL_EMPTY)
11347 last_element_new = new_element;
11348 else if (last_element_new != EL_UNDEFINED)
11349 new_element = last_element_new;
11351 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
11353 if (last_element_new != EL_UNDEFINED)
11354 MergeAndCloseNeighbourElements(x, y, &new_element,
11355 last_x, last_y, &last_element_new,
11356 getClosedPool, change_level);
11358 else if (IS_EMC_PILLAR(new_element))
11360 int last_element_new = EL_UNDEFINED;
11361 int direction = MV_NONE;
11364 // if old element is of same kind, keep all existing directions
11365 if (IS_EMC_PILLAR(old_element))
11366 direction |= getOpenDirectionFromPillar(old_element);
11368 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11370 int xx = x + xy[i].x;
11371 int yy = y + xy[i].y;
11373 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11374 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
11376 int dir = MV_DIR_FROM_BIT(i);
11377 int dir_opposite = MV_DIR_OPPOSITE(dir);
11378 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11379 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
11380 int last_direction_new = last_direction_old | dir_opposite;
11382 last_element_new = getPillarFromOpenDirection(last_direction_new);
11388 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
11390 if (last_element_new != EL_UNDEFINED)
11391 MergeAndCloseNeighbourElements(x, y, &new_element,
11392 last_x, last_y, &last_element_new,
11393 getClosedPillar, change_level);
11395 else if (IS_DC_STEELWALL_2(new_element))
11397 int last_element_new = EL_UNDEFINED;
11398 int direction = MV_NONE;
11401 // if old element is of same kind, keep all existing directions
11402 if (IS_DC_STEELWALL_2(old_element))
11403 direction |= getOpenDirectionFromSteel2(old_element);
11405 for (i = 0; i < NUM_DIRECTIONS; i++)
11407 int xx = x + xy[i].x;
11408 int yy = y + xy[i].y;
11410 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11411 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
11413 int dir = MV_DIR_FROM_BIT(i);
11414 int dir_opposite = MV_DIR_OPPOSITE(dir);
11415 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11416 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
11417 int last_direction_new = last_direction_old | dir_opposite;
11419 last_element_new = getSteel2FromOpenDirection(last_direction_new);
11425 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
11427 if (last_element_new != EL_UNDEFINED)
11428 MergeAndCloseNeighbourElements(x, y, &new_element,
11429 last_x, last_y, &last_element_new,
11430 getClosedSteel2, change_level);
11432 else if (IS_SP_CHIP(new_element))
11434 int last_element_new = EL_UNDEFINED;
11435 int direction = MV_NONE;
11438 // (do not keep existing directions, regardless of kind of old element)
11440 for (i = 0; i < NUM_DIRECTIONS; i++)
11442 int xx = x + xy[i].x;
11443 int yy = y + xy[i].y;
11445 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11446 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
11448 int dir = MV_DIR_FROM_BIT(i);
11449 int dir_opposite = MV_DIR_OPPOSITE(dir);
11450 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11451 int last_direction_old = getOpenDirectionFromChip(last_element_old);
11452 int last_direction_new = last_direction_old | dir_opposite;
11454 if (last_direction_old == MV_NONE)
11456 last_element_new = getChipFromOpenDirection(last_direction_new);
11459 else if (last_direction_old & (dir | dir_opposite))
11461 direction |= MV_DIR_OPPOSITE(last_direction_old);
11465 direction |= MV_DIR_OPPOSITE(dir);
11470 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
11472 if (last_element_new != EL_UNDEFINED)
11473 MergeAndCloseNeighbourElements(x, y, &new_element,
11474 last_x, last_y, &last_element_new,
11475 getClosedChip, change_level);
11477 else if (IS_SP_HARDWARE_BASE(new_element))
11479 int nr = GetSimpleRandom(6);
11481 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
11482 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
11483 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
11484 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
11485 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
11487 else if (new_element == EL_SP_HARDWARE_GREEN ||
11488 new_element == EL_SP_HARDWARE_BLUE ||
11489 new_element == EL_SP_HARDWARE_RED)
11491 int nr = GetSimpleRandom(3);
11493 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
11494 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
11496 else if (IS_GROUP_ELEMENT(new_element))
11498 boolean connected_drawing = FALSE;
11501 for (i = 0; i < NUM_DIRECTIONS; i++)
11503 int xx = x + xy[i].x;
11504 int yy = y + xy[i].y;
11506 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11507 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
11508 connected_drawing = TRUE;
11511 if (!connected_drawing)
11512 ResolveGroupElement(new_element);
11514 new_element = GetElementFromGroupElement(new_element);
11516 else if (IS_BELT_SWITCH(old_element))
11518 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
11519 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
11521 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
11522 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
11524 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
11528 static int swappable_elements[][2] =
11530 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
11531 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
11532 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
11533 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
11534 { EL_EMERALD, EL_WALL_EMERALD },
11535 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
11536 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
11537 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
11538 { EL_DIAMOND, EL_WALL_DIAMOND },
11539 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
11540 { EL_GATE_1, EL_GATE_1_GRAY },
11541 { EL_GATE_2, EL_GATE_2_GRAY },
11542 { EL_GATE_3, EL_GATE_3_GRAY },
11543 { EL_GATE_4, EL_GATE_4_GRAY },
11544 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
11545 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
11546 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
11547 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
11548 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
11549 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
11550 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
11551 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
11552 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
11553 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
11554 { EL_LAMP, EL_LAMP_ACTIVE },
11555 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
11556 { EL_SP_BASE, EL_SP_BUGGY_BASE },
11557 { EL_PEARL, EL_WALL_PEARL },
11558 { EL_CRYSTAL, EL_WALL_CRYSTAL },
11559 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
11560 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
11561 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
11562 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
11563 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
11564 { EL_LANDMINE, EL_DC_LANDMINE },
11565 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
11566 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
11567 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
11568 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
11569 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
11570 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
11571 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
11572 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
11573 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
11577 static int rotatable_elements_4[][4] =
11587 EL_SPACESHIP_RIGHT,
11592 EL_BD_BUTTERFLY_UP,
11593 EL_BD_BUTTERFLY_RIGHT,
11594 EL_BD_BUTTERFLY_DOWN,
11595 EL_BD_BUTTERFLY_LEFT
11599 EL_BD_FIREFLY_RIGHT,
11600 EL_BD_FIREFLY_DOWN,
11628 EL_SP_GRAVITY_PORT_UP,
11629 EL_SP_GRAVITY_PORT_RIGHT,
11630 EL_SP_GRAVITY_PORT_DOWN,
11631 EL_SP_GRAVITY_PORT_LEFT
11634 EL_SP_GRAVITY_ON_PORT_UP,
11635 EL_SP_GRAVITY_ON_PORT_RIGHT,
11636 EL_SP_GRAVITY_ON_PORT_DOWN,
11637 EL_SP_GRAVITY_ON_PORT_LEFT
11640 EL_SP_GRAVITY_OFF_PORT_UP,
11641 EL_SP_GRAVITY_OFF_PORT_RIGHT,
11642 EL_SP_GRAVITY_OFF_PORT_DOWN,
11643 EL_SP_GRAVITY_OFF_PORT_LEFT
11652 EL_BALLOON_SWITCH_UP,
11653 EL_BALLOON_SWITCH_RIGHT,
11654 EL_BALLOON_SWITCH_DOWN,
11655 EL_BALLOON_SWITCH_LEFT
11659 EL_MM_MCDUFFIN_RIGHT,
11660 EL_MM_MCDUFFIN_DOWN,
11661 EL_MM_MCDUFFIN_LEFT
11664 EL_MM_MIRROR_FIXED_1,
11665 EL_MM_MIRROR_FIXED_4,
11666 EL_MM_MIRROR_FIXED_3,
11667 EL_MM_MIRROR_FIXED_2
11670 EL_MM_STEEL_GRID_FIXED_1,
11671 EL_MM_STEEL_GRID_FIXED_4,
11672 EL_MM_STEEL_GRID_FIXED_2,
11673 EL_MM_STEEL_GRID_FIXED_3
11676 EL_MM_WOODEN_GRID_FIXED_1,
11677 EL_MM_WOODEN_GRID_FIXED_4,
11678 EL_MM_WOODEN_GRID_FIXED_2,
11679 EL_MM_WOODEN_GRID_FIXED_3
11682 EL_MM_POLARIZER_CROSS_1,
11683 EL_MM_POLARIZER_CROSS_4,
11684 EL_MM_POLARIZER_CROSS_3,
11685 EL_MM_POLARIZER_CROSS_2
11689 EL_MM_PACMAN_RIGHT,
11701 EL_DF_RECEIVER_RIGHT,
11702 EL_DF_RECEIVER_DOWN,
11703 EL_DF_RECEIVER_LEFT
11710 static int rotatable_elements_8[][8] =
11713 EL_DF_STEEL_GRID_FIXED_1,
11714 EL_DF_STEEL_GRID_FIXED_8,
11715 EL_DF_STEEL_GRID_FIXED_7,
11716 EL_DF_STEEL_GRID_FIXED_6,
11717 EL_DF_STEEL_GRID_FIXED_5,
11718 EL_DF_STEEL_GRID_FIXED_4,
11719 EL_DF_STEEL_GRID_FIXED_3,
11720 EL_DF_STEEL_GRID_FIXED_2
11723 EL_DF_WOODEN_GRID_FIXED_1,
11724 EL_DF_WOODEN_GRID_FIXED_8,
11725 EL_DF_WOODEN_GRID_FIXED_7,
11726 EL_DF_WOODEN_GRID_FIXED_6,
11727 EL_DF_WOODEN_GRID_FIXED_5,
11728 EL_DF_WOODEN_GRID_FIXED_4,
11729 EL_DF_WOODEN_GRID_FIXED_3,
11730 EL_DF_WOODEN_GRID_FIXED_2
11733 EL_DF_STEEL_GRID_ROTATING_1,
11734 EL_DF_STEEL_GRID_ROTATING_8,
11735 EL_DF_STEEL_GRID_ROTATING_7,
11736 EL_DF_STEEL_GRID_ROTATING_6,
11737 EL_DF_STEEL_GRID_ROTATING_5,
11738 EL_DF_STEEL_GRID_ROTATING_4,
11739 EL_DF_STEEL_GRID_ROTATING_3,
11740 EL_DF_STEEL_GRID_ROTATING_2
11743 EL_DF_WOODEN_GRID_ROTATING_1,
11744 EL_DF_WOODEN_GRID_ROTATING_8,
11745 EL_DF_WOODEN_GRID_ROTATING_7,
11746 EL_DF_WOODEN_GRID_ROTATING_6,
11747 EL_DF_WOODEN_GRID_ROTATING_5,
11748 EL_DF_WOODEN_GRID_ROTATING_4,
11749 EL_DF_WOODEN_GRID_ROTATING_3,
11750 EL_DF_WOODEN_GRID_ROTATING_2
11757 static int rotatable_elements_16[][16] =
11778 EL_MM_TELEPORTER_5,
11779 EL_MM_TELEPORTER_4,
11780 EL_MM_TELEPORTER_3,
11781 EL_MM_TELEPORTER_2,
11782 EL_MM_TELEPORTER_1,
11783 EL_MM_TELEPORTER_16,
11784 EL_MM_TELEPORTER_15,
11785 EL_MM_TELEPORTER_14,
11786 EL_MM_TELEPORTER_13,
11787 EL_MM_TELEPORTER_12,
11788 EL_MM_TELEPORTER_11,
11789 EL_MM_TELEPORTER_10,
11790 EL_MM_TELEPORTER_9,
11791 EL_MM_TELEPORTER_8,
11792 EL_MM_TELEPORTER_7,
11796 EL_MM_TELEPORTER_RED_5,
11797 EL_MM_TELEPORTER_RED_4,
11798 EL_MM_TELEPORTER_RED_3,
11799 EL_MM_TELEPORTER_RED_2,
11800 EL_MM_TELEPORTER_RED_1,
11801 EL_MM_TELEPORTER_RED_16,
11802 EL_MM_TELEPORTER_RED_15,
11803 EL_MM_TELEPORTER_RED_14,
11804 EL_MM_TELEPORTER_RED_13,
11805 EL_MM_TELEPORTER_RED_12,
11806 EL_MM_TELEPORTER_RED_11,
11807 EL_MM_TELEPORTER_RED_10,
11808 EL_MM_TELEPORTER_RED_9,
11809 EL_MM_TELEPORTER_RED_8,
11810 EL_MM_TELEPORTER_RED_7,
11811 EL_MM_TELEPORTER_RED_6
11814 EL_MM_TELEPORTER_YELLOW_5,
11815 EL_MM_TELEPORTER_YELLOW_4,
11816 EL_MM_TELEPORTER_YELLOW_3,
11817 EL_MM_TELEPORTER_YELLOW_2,
11818 EL_MM_TELEPORTER_YELLOW_1,
11819 EL_MM_TELEPORTER_YELLOW_16,
11820 EL_MM_TELEPORTER_YELLOW_15,
11821 EL_MM_TELEPORTER_YELLOW_14,
11822 EL_MM_TELEPORTER_YELLOW_13,
11823 EL_MM_TELEPORTER_YELLOW_12,
11824 EL_MM_TELEPORTER_YELLOW_11,
11825 EL_MM_TELEPORTER_YELLOW_10,
11826 EL_MM_TELEPORTER_YELLOW_9,
11827 EL_MM_TELEPORTER_YELLOW_8,
11828 EL_MM_TELEPORTER_YELLOW_7,
11829 EL_MM_TELEPORTER_YELLOW_6
11832 EL_MM_TELEPORTER_GREEN_5,
11833 EL_MM_TELEPORTER_GREEN_4,
11834 EL_MM_TELEPORTER_GREEN_3,
11835 EL_MM_TELEPORTER_GREEN_2,
11836 EL_MM_TELEPORTER_GREEN_1,
11837 EL_MM_TELEPORTER_GREEN_16,
11838 EL_MM_TELEPORTER_GREEN_15,
11839 EL_MM_TELEPORTER_GREEN_14,
11840 EL_MM_TELEPORTER_GREEN_13,
11841 EL_MM_TELEPORTER_GREEN_12,
11842 EL_MM_TELEPORTER_GREEN_11,
11843 EL_MM_TELEPORTER_GREEN_10,
11844 EL_MM_TELEPORTER_GREEN_9,
11845 EL_MM_TELEPORTER_GREEN_8,
11846 EL_MM_TELEPORTER_GREEN_7,
11847 EL_MM_TELEPORTER_GREEN_6
11850 EL_MM_TELEPORTER_BLUE_5,
11851 EL_MM_TELEPORTER_BLUE_4,
11852 EL_MM_TELEPORTER_BLUE_3,
11853 EL_MM_TELEPORTER_BLUE_2,
11854 EL_MM_TELEPORTER_BLUE_1,
11855 EL_MM_TELEPORTER_BLUE_16,
11856 EL_MM_TELEPORTER_BLUE_15,
11857 EL_MM_TELEPORTER_BLUE_14,
11858 EL_MM_TELEPORTER_BLUE_13,
11859 EL_MM_TELEPORTER_BLUE_12,
11860 EL_MM_TELEPORTER_BLUE_11,
11861 EL_MM_TELEPORTER_BLUE_10,
11862 EL_MM_TELEPORTER_BLUE_9,
11863 EL_MM_TELEPORTER_BLUE_8,
11864 EL_MM_TELEPORTER_BLUE_7,
11865 EL_MM_TELEPORTER_BLUE_6
11869 EL_MM_POLARIZER_16,
11870 EL_MM_POLARIZER_15,
11871 EL_MM_POLARIZER_14,
11872 EL_MM_POLARIZER_13,
11873 EL_MM_POLARIZER_12,
11874 EL_MM_POLARIZER_11,
11875 EL_MM_POLARIZER_10,
11904 EL_DF_MIRROR_ROTATING_1,
11905 EL_DF_MIRROR_ROTATING_16,
11906 EL_DF_MIRROR_ROTATING_15,
11907 EL_DF_MIRROR_ROTATING_14,
11908 EL_DF_MIRROR_ROTATING_13,
11909 EL_DF_MIRROR_ROTATING_12,
11910 EL_DF_MIRROR_ROTATING_11,
11911 EL_DF_MIRROR_ROTATING_10,
11912 EL_DF_MIRROR_ROTATING_9,
11913 EL_DF_MIRROR_ROTATING_8,
11914 EL_DF_MIRROR_ROTATING_7,
11915 EL_DF_MIRROR_ROTATING_6,
11916 EL_DF_MIRROR_ROTATING_5,
11917 EL_DF_MIRROR_ROTATING_4,
11918 EL_DF_MIRROR_ROTATING_3,
11919 EL_DF_MIRROR_ROTATING_2
11928 for (i = 0; swappable_elements[i][0] != -1; i++)
11930 int element1 = swappable_elements[i][0];
11931 int element2 = swappable_elements[i][1];
11933 if (old_element == element1 || old_element == element2)
11934 new_element = (old_element == element1 ? element2 : element1);
11937 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
11939 for (j = 0; j < 4; j++)
11941 int element = rotatable_elements_4[i][j];
11943 if (old_element == element)
11944 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
11945 button == 2 ? rotatable_elements_4[i][0] :
11946 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
11951 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
11953 for (j = 0; j < 8; j++)
11955 int element = rotatable_elements_8[i][j];
11957 if (old_element == element)
11958 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
11959 button == 2 ? rotatable_elements_8[i][0] :
11960 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
11965 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
11967 for (j = 0; j < 16; j++)
11969 int element = rotatable_elements_16[i][j];
11971 if (old_element == element)
11972 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
11973 button == 2 ? rotatable_elements_16[i][0] :
11974 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
11979 if (old_element != new_element)
11981 int max_infotext_len = getMaxInfoTextLength();
11982 char infotext[MAX_OUTPUT_LINESIZE + 1];
11984 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
11985 infotext[max_infotext_len] = '\0';
11987 ClearEditorGadgetInfoText();
11989 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
11994 if (IS_MM_WALL_EDITOR(new_element))
11995 SetElementSimpleExt(x, y, dx, dy, new_element, change_level);
11997 SetElementSimple(x, y, new_element, change_level);
12003 static void ResetIntelliDraw(void)
12007 for (x = 0; x < lev_fieldx; x++)
12008 for (y = 0; y < lev_fieldy; y++)
12009 IntelliDrawBuffer[x][y] = Tile[x][y];
12011 SetElementIntelliDraw(-1, -1, -1, -1, EL_UNDEFINED, FALSE, -1);
12014 static boolean draw_mode_hires = FALSE;
12016 static boolean isHiresTileElement(int element)
12018 return (IS_MM_WALL(element) || element == EL_EMPTY);
12021 static boolean isHiresDrawElement(int element)
12023 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
12026 static int numHiresTiles(int element)
12028 if (!IS_MM_WALL(element))
12031 int bits = MM_WALL_BITS(element);
12043 static void SetDrawModeHiRes(int element)
12046 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12047 isHiresDrawElement(element));
12050 static boolean getDrawModeHiRes(void)
12052 return draw_mode_hires;
12055 static int getLoResScreenPos(int pos)
12057 return (getDrawModeHiRes() ? pos / 2 : pos);
12060 static int getLoResScreenMod(int pos)
12062 return (getDrawModeHiRes() ? pos % 2 : 0);
12065 static void SetElementExt(int x, int y, int dx, int dy, int element,
12066 boolean change_level, int button)
12069 SetElementSimple(x, y, Tile[x][y], change_level);
12070 else if (GetKeyModState() & KMOD_Shift)
12071 SetElementIntelliDraw(x, y, dx, dy, element, change_level, button);
12073 SetElementSimpleExt(x, y, dx, dy, element, change_level);
12076 static void SetElement(int x, int y, int element)
12078 SetElementExt(x, y, 0, 0, element, TRUE, -1);
12081 static void SetElementButton(int x, int y, int dx, int dy, int element,
12084 SetElementExt(x, y, dx, dy, element, TRUE, button);
12087 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
12089 int lx = getLoResScreenPos(sx2) + level_xpos;
12090 int ly = getLoResScreenPos(sy2) + level_ypos;
12091 int dx = getLoResScreenMod(sx2);
12092 int dy = getLoResScreenMod(sy2);
12094 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
12097 static void SetLevelElementHiRes(int lx2, int ly2, int element)
12104 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
12107 static int getLevelElementHiRes(int lx2, int ly2)
12113 int element = Tile[lx][ly];
12114 unsigned int bitmask = (dx + 1) << (dy * 2);
12116 if (IS_MM_WALL(element))
12118 if (element & bitmask)
12119 return map_mm_wall_element(element);
12127 static void DrawLineElement(int x, int y, int element, boolean change_level)
12129 SetElementHiRes(x, y, element, change_level);
12132 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12133 int element, boolean change_level)
12135 int xsize = ABS(to_x - from_x);
12136 int ysize = ABS(to_y - from_y);
12137 int dx = (to_x < from_x ? -1 : +1);
12138 int dy = (to_y < from_y ? -1 : +1);
12141 if (from_y == to_y) // horizontal line
12143 for (i = 0; i <= xsize; i++)
12144 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12146 else if (from_x == to_x) // vertical line
12148 for (i = 0; i <= ysize; i++)
12149 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12151 else // diagonal line
12153 if (ysize < xsize) // a < 1
12155 float a = (float)ysize / (float)xsize;
12157 for (i = 0; i <= xsize; i++)
12160 int y = dy * (int)(a * i + 0.5);
12162 DrawLineElement(from_x + x, from_y + y, element, change_level);
12167 float a = (float)xsize / (float)ysize;
12169 for (i = 0; i <= ysize; i++)
12171 int x = dx * (int)(a * i + 0.5);
12174 DrawLineElement(from_x + x, from_y + y, element, change_level);
12180 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12181 int element, boolean change_level)
12183 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12184 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12185 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12186 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12189 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12190 int element, boolean change_level)
12195 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12197 for (y = from_y; y <= to_y; y++)
12198 DrawLine(from_x, y, to_x, y, element, change_level);
12201 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12202 int element, boolean change_level)
12204 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12205 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12206 int len_x = ABS(to_x - from_x);
12207 int len_y = ABS(to_y - from_y);
12210 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
12212 // not optimal (some points get drawn twice) but simple,
12213 // and fast enough for the few points we are drawing
12215 for (x = 0; x <= radius; x++)
12217 int sx, sy, sx2, sy2, lx, ly;
12219 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
12221 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12222 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12223 sx = getLoResScreenPos(sx2);
12224 sy = getLoResScreenPos(sy2);
12225 lx = sx + level_xpos;
12226 ly = sy + level_ypos;
12228 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12229 DrawLineElement(sx2, sy2, element, change_level);
12232 for (y = 0; y <= radius; y++)
12234 int sx, sy, sx2, sy2, lx, ly;
12236 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
12238 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12239 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12240 sx = getLoResScreenPos(sx2);
12241 sy = getLoResScreenPos(sy2);
12242 lx = sx + level_xpos;
12243 ly = sy + level_ypos;
12245 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12246 DrawLineElement(sx2, sy2, element, change_level);
12250 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
12251 int element, boolean change_level)
12253 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12254 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12256 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12259 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
12261 #if DRAW_CIRCLES_BUTTON_AVAILABLE
12262 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
12263 int element, boolean change_level)
12265 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12266 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12267 int mirror_to_x2 = from_x - (to_x2 - from_x);
12268 int mirror_to_y2 = from_y - (to_y2 - from_y);
12270 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12271 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
12272 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
12273 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element, change_level);
12277 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
12279 int from_sx, from_sy;
12283 swap_numbers(&from_x, &to_x);
12286 swap_numbers(&from_y, &to_y);
12288 from_sx = SX + from_x * ed_tilesize;
12289 from_sy = SY + from_y * ed_tilesize;
12290 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
12291 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
12293 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12294 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12295 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12296 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12298 if (from_x == to_x && from_y == to_y)
12299 MarkTileDirty(from_x/2, from_y/2);
12301 redraw_mask |= REDRAW_FIELD;
12304 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
12305 int element, boolean change_level)
12307 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
12310 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
12311 int element, boolean change_level)
12313 if (element == -1 || change_level)
12314 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
12316 DrawAreaBorder(from_x, from_y, to_x, to_y);
12319 // values for CopyBrushExt()
12320 #define CB_AREA_TO_BRUSH 0
12321 #define CB_BRUSH_TO_CURSOR 1
12322 #define CB_BRUSH_TO_LEVEL 2
12323 #define CB_DELETE_OLD_CURSOR 3
12324 #define CB_DUMP_BRUSH 4
12325 #define CB_DUMP_BRUSH_SMALL 5
12326 #define CB_CLIPBOARD_TO_BRUSH 6
12327 #define CB_BRUSH_TO_CLIPBOARD 7
12328 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
12329 #define CB_UPDATE_BRUSH_POSITION 9
12331 #define MAX_CB_PART_SIZE 10
12332 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
12333 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
12334 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
12335 MAX_CB_NUM_LINES * \
12338 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
12340 DrawLineElement(sx, sy, element, change_level);
12343 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
12344 int button, int mode)
12346 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12347 static int brush_width, brush_height;
12348 static int last_cursor_x = -1, last_cursor_y = -1;
12349 static boolean delete_old_brush = FALSE;
12350 int new_element = BUTTON_ELEMENT(button);
12353 if (mode == CB_DUMP_BRUSH ||
12354 mode == CB_DUMP_BRUSH_SMALL ||
12355 mode == CB_BRUSH_TO_CLIPBOARD ||
12356 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12358 if (edit_mode != ED_MODE_DRAWING)
12361 char part[MAX_CB_PART_SIZE + 1] = "";
12362 char text[MAX_CB_TEXT_SIZE + 1] = "";
12363 int width = (draw_with_brush ? brush_width : lev_fieldx);
12364 int height = (draw_with_brush ? brush_height : lev_fieldy);
12365 char *format = "%s%03d";
12367 for (y = 0; y < height; y++)
12368 for (x = 0; x < width; x++)
12369 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
12372 for (y = 0; y < height; y++)
12374 for (x = 0; x < width; x++)
12376 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
12377 char *prefix = (mode == CB_DUMP_BRUSH ||
12378 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
12380 if (element >= NUM_FILE_ELEMENTS)
12381 element = EL_UNKNOWN;
12383 // copy brush to level sketch text buffer for the R'n'D forum:
12384 // - large tiles: `xxx or `xxxx (0x60 ASCII)
12385 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
12386 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
12387 strcat(text, part);
12390 strcat(text, "\n");
12393 if (mode == CB_BRUSH_TO_CLIPBOARD ||
12394 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12395 SDL_SetClipboardText(text);
12397 Print("%s", text); // print brush data to console and log file
12402 if (mode == CB_CLIPBOARD_TO_BRUSH)
12404 if (edit_mode != ED_MODE_DRAWING)
12407 if (!SDL_HasClipboardText())
12409 Request("Clipboard is empty!", REQ_CONFIRM);
12414 boolean copy_to_brush = (draw_with_brush ||
12415 drawing_function == GADGET_ID_GRAB_BRUSH);
12417 // this will delete the old brush, if already drawing with a brush
12419 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
12421 // initialization is required for "odd" (incomplete) clipboard content
12422 for (x = 0; x < MAX_LEV_FIELDX; x++)
12423 for (y = 0; y < MAX_LEV_FIELDY; y++)
12424 brush_buffer[x][y] = EL_EMPTY;
12431 char *clipboard_text = SDL_GetClipboardText();
12432 char *ptr = clipboard_text;
12433 boolean allow_new_row = FALSE;
12434 boolean stop = FALSE;
12436 while (*ptr && !stop)
12438 boolean prefix_found = FALSE;
12439 boolean start_new_row = FALSE;
12441 // level sketch element number prefixes (may be multi-byte characters)
12442 char *prefix_list[] = { "`", "¸" };
12445 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
12447 char *prefix = prefix_list[i];
12449 // check if string is large enough for prefix
12450 if (strlen(ptr) < strlen(prefix))
12457 // check if string starts with prefix
12458 if (strPrefix(ptr, prefix))
12460 ptr += strlen(prefix);
12462 prefix_found = TRUE;
12468 // check if prefix found and followed by (at least) three digits
12469 if (prefix_found &&
12470 strlen(ptr) >= 3 &&
12471 ptr[0] >= '0' && ptr[0] <= '9' &&
12472 ptr[1] >= '0' && ptr[1] <= '9' &&
12473 ptr[2] >= '0' && ptr[2] <= '9')
12475 int element = ((ptr[0] - '0') * 100 +
12476 (ptr[1] - '0') * 10 +
12481 // level sketch element number might consist of four digits
12482 if (ptr[0] >= '0' && ptr[0] <= '9')
12484 element = element * 10 + (ptr[0] - '0');
12488 // remap some (historic, now obsolete) elements
12489 element = getMappedElement(element);
12491 if (element >= NUM_FILE_ELEMENTS)
12492 element = EL_UNKNOWN;
12494 brush_buffer[x][y] = element;
12496 brush_width = MAX(x + 1, brush_width);
12497 brush_height = MAX(y + 1, brush_height);
12501 if (x >= MAX_LEV_FIELDX)
12502 start_new_row = TRUE;
12504 allow_new_row = TRUE;
12508 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
12509 start_new_row = TRUE;
12511 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
12519 if (y >= MAX_LEV_FIELDY)
12522 allow_new_row = FALSE;
12526 SDL_free(clipboard_text);
12528 if (brush_width == 0 || brush_height == 0)
12530 Request("No level sketch found in clipboard!", REQ_CONFIRM);
12537 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
12540 SDL_GetMouseState(&mx, &my);
12542 // if inside drawing area, activate and draw brush at last mouse position
12543 if (mx >= gi->x && mx < gi->x + gi->width &&
12544 my >= gi->y && my < gi->y + gi->height)
12545 CopyBrushToCursor(last_cursor_x, last_cursor_y);
12547 draw_with_brush = TRUE;
12553 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
12554 brush_width, brush_height);
12556 if (!Request(request, REQ_ASK))
12559 for (x = 0; x < MAX_LEV_FIELDX; x++)
12560 for (y = 0; y < MAX_LEV_FIELDY; y++)
12561 Tile[x][y] = brush_buffer[x][y];
12563 lev_fieldx = level.fieldx = brush_width;
12564 lev_fieldy = level.fieldy = brush_height;
12566 boolean use_em_engine = TRUE;
12567 boolean use_sp_engine = TRUE;
12568 boolean use_mm_engine = TRUE;
12570 for (x = 0; x < MAX_LEV_FIELDX; x++)
12572 for (y = 0; y < MAX_LEV_FIELDY; y++)
12574 int element = Tile[x][y];
12576 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
12577 use_em_engine = FALSE;
12579 if (!IS_SP_ELEMENT(element))
12580 use_sp_engine = FALSE;
12582 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
12583 use_mm_engine = FALSE;
12587 level.game_engine_type = (use_em_engine ? GAME_ENGINE_TYPE_EM :
12588 use_sp_engine ? GAME_ENGINE_TYPE_SP :
12589 use_mm_engine ? GAME_ENGINE_TYPE_MM :
12590 GAME_ENGINE_TYPE_RND);
12592 // update element selection list
12593 ReinitializeElementList();
12594 ModifyEditorElementList();
12596 SetBorderElement();
12598 DrawEditModeWindow();
12599 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12605 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
12608 if (mode == CB_AREA_TO_BRUSH)
12610 int from_lx, from_ly;
12613 swap_numbers(&from_x, &to_x);
12616 swap_numbers(&from_y, &to_y);
12618 brush_width = to_x - from_x + 1;
12619 brush_height = to_y - from_y + 1;
12621 from_lx = from_x + level_xpos;
12622 from_ly = from_y + level_ypos;
12624 for (y = 0; y < brush_height; y++)
12626 for (x = 0; x < brush_width; x++)
12628 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
12631 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
12636 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12638 delete_old_brush = FALSE;
12640 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
12641 mode == CB_BRUSH_TO_LEVEL)
12643 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
12644 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
12645 int cursor_from_x = cursor_x - brush_width / 2;
12646 int cursor_from_y = cursor_y - brush_height / 2;
12647 int border_from_x = cursor_x, border_from_y = cursor_y;
12648 int border_to_x = cursor_x, border_to_y = cursor_y;
12650 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
12651 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12653 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
12654 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
12656 delete_old_brush = FALSE;
12661 for (y = 0; y < brush_height; y++)
12663 for (x = 0; x < brush_width; x++)
12665 int sx = cursor_from_x + x;
12666 int sy = cursor_from_y + y;
12667 int lx = sx + level_xpos;
12668 int ly = sy + level_ypos;
12669 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
12670 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
12671 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
12672 brush_buffer[x][y] : new_element);
12674 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12676 if (sx < border_from_x)
12677 border_from_x = sx;
12678 else if (sx > border_to_x)
12680 if (sy < border_from_y)
12681 border_from_y = sy;
12682 else if (sy > border_to_y)
12685 DrawBrushElement(sx, sy, element, change_level);
12690 if (mode != CB_DELETE_OLD_CURSOR)
12691 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
12693 last_cursor_x = cursor_x;
12694 last_cursor_y = cursor_y;
12696 delete_old_brush = TRUE;
12699 if (mode == CB_UPDATE_BRUSH_POSITION)
12701 last_cursor_x = from_x;
12702 last_cursor_y = from_y;
12706 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
12709 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
12712 static void CopyBrushToLevel(int x, int y, int button)
12714 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
12717 static void CopyBrushToCursor(int x, int y)
12719 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
12722 static void UpdateBrushPosition(int x, int y)
12724 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
12727 static void DeleteBrushFromCursor(void)
12729 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12732 void DumpBrush(void)
12734 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
12737 void DumpBrush_Small(void)
12739 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
12742 void CopyClipboardToBrush(void)
12744 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
12747 void CopyBrushToClipboard(void)
12749 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
12752 void CopyBrushToClipboard_Small(void)
12754 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
12757 void UndoLevelEditorOperation(void)
12759 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
12762 void RedoLevelEditorOperation(void)
12764 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
12767 static void FloodFill(int from_x, int from_y, int fill_element)
12769 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
12772 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
12774 int from_x = from_sx2 + 2 * level_xpos;
12775 int from_y = from_sy2 + 2 * level_ypos;
12776 int max_fillx = lev_fieldx * 2;
12777 int max_filly = lev_fieldy * 2;
12778 short Fill[max_fillx][max_filly];
12781 for (x = 0; x < max_fillx; x++)
12782 for (y = 0; y < max_filly; y++)
12783 Fill[x][y] = getLevelElementHiRes(x, y);
12785 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
12786 Fill, max_fillx, max_filly);
12788 for (x = 0; x < max_fillx; x++)
12789 for (y = 0; y < max_filly; y++)
12790 if (Fill[x][y] == fill_element)
12791 SetLevelElementHiRes(x, y, Fill[x][y]);
12794 // values for DrawLevelText() modes
12795 #define TEXT_INIT 0
12796 #define TEXT_SETCURSOR 1
12797 #define TEXT_WRITECHAR 2
12798 #define TEXT_BACKSPACE 3
12799 #define TEXT_NEWLINE 4
12801 #define TEXT_QUERY_TYPING 6
12803 static int DrawLevelText(int sx, int sy, char letter, int mode)
12805 static short delete_buffer[MAX_LEV_FIELDX];
12806 static int start_sx;
12807 static int last_sx, last_sy;
12808 static boolean typing = FALSE;
12809 int letter_element;
12810 int lx = 0, ly = 0;
12812 // map lower case letters to upper case and convert special characters
12813 if (letter >= 'a' && letter <= 'z')
12814 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
12815 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
12816 letter_element = EL_CHAR_AUMLAUT;
12817 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
12818 letter_element = EL_CHAR_OUMLAUT;
12819 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
12820 letter_element = EL_CHAR_UUMLAUT;
12821 else if (letter == '^')
12822 letter_element = EL_CHAR_COPYRIGHT;
12824 letter_element = EL_CHAR_ASCII0 + letter;
12826 if (mode != TEXT_INIT)
12831 if (mode != TEXT_SETCURSOR)
12837 lx = last_sx + level_xpos;
12838 ly = last_sy + level_ypos;
12845 DrawLevelText(0, 0, 0, TEXT_END);
12851 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
12854 case TEXT_SETCURSOR:
12855 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
12856 DrawAreaBorder(sx, sy, sx, sy);
12857 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
12858 ed_tilesize, ed_tilesize);
12863 case TEXT_WRITECHAR:
12864 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
12866 if (new_element1 >= EL_STEEL_CHAR_START &&
12867 new_element1 <= EL_STEEL_CHAR_END)
12868 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
12870 delete_buffer[sx - start_sx] = Tile[lx][ly];
12871 Tile[lx][ly] = letter_element;
12873 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
12874 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
12875 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12876 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12878 DrawLevelText(0, 0, 0, TEXT_END);
12880 level.changed = TRUE;
12884 case TEXT_BACKSPACE:
12887 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
12888 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
12889 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
12894 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12895 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12897 DrawLevelText(0, 0, 0, TEXT_END);
12901 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12902 DrawEditorElement(sx, sy, Tile[lx][ly]);
12907 case TEXT_QUERY_TYPING:
12917 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
12918 int element, boolean change_level)
12920 int lx = sx + level_xpos;
12921 int ly = sy + level_ypos;
12924 DrawEditorElement(sx, sy, Tile[lx][ly]);
12926 DrawAreaBorder(sx, sy, sx, sy);
12929 static void CheckLevelBorderElement(boolean redraw_playfield)
12931 int last_border_element = BorderElement;
12933 SetBorderElement();
12935 if (redraw_playfield && BorderElement != last_border_element)
12936 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12939 static void CopyLevelToUndoBuffer(int mode)
12941 static boolean accumulated_undo = FALSE;
12942 boolean new_undo_buffer_position = TRUE;
12945 if (undo_buffer_steps == 0)
12946 accumulated_undo = FALSE;
12950 case UNDO_IMMEDIATE:
12951 accumulated_undo = FALSE;
12954 case UNDO_ACCUMULATE:
12955 if (accumulated_undo)
12956 new_undo_buffer_position = FALSE;
12957 accumulated_undo = TRUE;
12964 if (new_undo_buffer_position)
12966 // advance position in undo buffer ring
12967 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
12969 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
12970 undo_buffer_steps++;
12973 // always reset redo buffer when storing level change into undo buffer
12974 redo_buffer_steps = 0;
12976 for (x = 0; x < lev_fieldx; x++)
12977 for (y = 0; y < lev_fieldy; y++)
12978 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
12980 // check if drawing operation forces change of border style
12981 CheckLevelBorderElement(TRUE);
12983 level.changed = TRUE;
12986 static void RandomPlacement(int new_element)
12988 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12989 int num_free_positions = 0;
12990 int num_percentage, num_elements;
12993 ResetIntelliDraw();
12995 // determine number of free positions for randomly placing the new element
12996 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
12998 free_position[x][y] =
12999 (random_placement_background_restricted ?
13000 Tile[x][y] == random_placement_background_element :
13001 Tile[x][y] != new_element);
13003 if (free_position[x][y])
13004 num_free_positions++;
13007 // determine number of new elements to place there
13008 num_percentage = num_free_positions * random_placement_value / 100;
13009 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
13010 num_percentage : random_placement_value);
13012 // if less free positions than elements to place, fill all these positions
13013 if (num_free_positions < num_elements)
13015 for (x = 0; x < lev_fieldx; x++)
13016 for (y = 0; y < lev_fieldy; y++)
13017 if (free_position[x][y])
13018 SetElement(x, y, new_element);
13022 while (num_elements > 0)
13024 x = GetSimpleRandom(lev_fieldx);
13025 y = GetSimpleRandom(lev_fieldy);
13027 // don't place element at the same position twice
13028 if (free_position[x][y])
13030 free_position[x][y] = FALSE;
13031 SetElement(x, y, new_element);
13037 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13038 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13041 static void WrapLevel(int dx, int dy)
13043 int wrap_dx = lev_fieldx - dx;
13044 int wrap_dy = lev_fieldy - dy;
13047 for (x = 0; x < lev_fieldx; x++)
13048 for (y = 0; y < lev_fieldy; y++)
13049 TileBackup[x][y] = Tile[x][y];
13051 for (x = 0; x < lev_fieldx; x++)
13052 for (y = 0; y < lev_fieldy; y++)
13054 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
13056 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13057 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
13060 static void DrawAreaElementHighlight(boolean highlighted)
13062 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13069 for (x = 0; x < ed_fieldx; x++)
13071 for (y = 0; y < ed_fieldy; y++)
13073 int lx = x + level_xpos;
13074 int ly = y + level_ypos;
13076 if (!IN_LEV_FIELD(lx, ly))
13079 if (Tile[lx][ly] != new_element1)
13082 int sx = SX + x * ed_tilesize;
13083 int sy = SY + y * ed_tilesize;
13086 int to_sx = sx + ed_tilesize - 1;
13087 int to_sy = sy + ed_tilesize - 1;
13089 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
13090 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
13091 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
13092 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
13097 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
13099 char *template_filename_old = getLocalLevelTemplateFilename();
13100 char *template_filename_new =
13101 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
13103 if (copyFile(template_filename_old, template_filename_new) != 0)
13104 Request("Cannot copy level template!", REQ_CONFIRM);
13106 free(template_filename_new);
13109 static void HandleDrawingAreas(struct GadgetInfo *gi)
13111 static boolean started_inside_drawing_area = FALSE;
13112 static int last_sx = -1;
13113 static int last_sy = -1;
13114 static int last_sx2 = -1;
13115 static int last_sy2 = -1;
13116 int id = gi->custom_id;
13117 int type_id = gi->custom_type_id;
13118 boolean button_press_event;
13119 boolean button_release_event;
13120 boolean inside_drawing_area = !gi->event.off_borders;
13121 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
13122 int actual_drawing_function;
13123 int button = gi->event.button;
13124 int new_element = BUTTON_ELEMENT(button);
13125 int sx = gi->event.x, sy = gi->event.y;
13126 int min_sx = 0, min_sy = 0;
13127 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
13128 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
13129 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
13130 int sx2 = gi->event.mx / mini_item_xsize;
13131 int sy2 = gi->event.my / mini_item_ysize;
13134 int lx = 0, ly = 0;
13137 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
13138 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
13140 // make sure to stay inside drawing area boundaries
13141 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
13142 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
13146 int min_lx = 0, min_ly = 0;
13147 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
13149 // get positions inside level field
13150 lx = sx + level_xpos;
13151 ly = sy + level_ypos;
13153 if (!IN_LEV_FIELD(lx, ly))
13154 inside_drawing_area = FALSE;
13156 // make sure to stay inside level field boundaries
13157 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
13158 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
13160 // correct drawing area positions accordingly
13161 sx = lx - level_xpos;
13162 sy = ly - level_ypos;
13165 // also correct MM wall-sized (double) drawing area positions accordingly
13166 if (sx2 / 2 < sx || sx2 / 2 > sx)
13168 dx = (sx2 / 2 < sx ? 0 : 1);
13171 if (sy2 / 2 < sy || sy2 / 2 > sy)
13173 dy = (sy2 / 2 < sy ? 0 : 1);
13177 if (!button_press_event && !button_release_event)
13179 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
13180 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
13181 isHiresTileElement(old_element) &&
13182 isHiresDrawElement(new_element));
13184 // prevent handling events for every pixel position when moving mouse
13185 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
13186 (sx2 == last_sx2 && sy2 == last_sy2))
13195 if (button_press_event)
13196 started_inside_drawing_area = inside_drawing_area;
13198 if (!started_inside_drawing_area)
13201 if (!IS_VALID_BUTTON(button))
13204 // handle info callback for each invocation of action callback
13205 gi->callback_info(gi);
13207 // automatically switch to 'single item' drawing mode, if needed
13208 actual_drawing_function =
13209 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
13210 drawing_function : GADGET_ID_SINGLE_ITEMS);
13212 // clicking into drawing area with pressed Control key picks element
13213 if (GetKeyModState() & KMOD_Control)
13215 last_drawing_function = drawing_function;
13216 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
13219 if (GetKeyModState() & KMOD_Shift)
13221 if (button_press_event || button_release_event)
13222 ResetIntelliDraw();
13225 SetDrawModeHiRes(-1); // reset to normal draw mode
13227 switch (actual_drawing_function)
13229 case GADGET_ID_SINGLE_ITEMS:
13232 if (button_release_event)
13234 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13236 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
13237 !inside_drawing_area)
13238 DeleteBrushFromCursor();
13243 if (draw_with_brush)
13245 CopyBrushToLevel(sx, sy, button);
13249 SetDrawModeHiRes(new_element);
13251 if (IS_PLAYER_ELEMENT(new_element) || IS_MM_MCDUFFIN(new_element))
13253 // remove player at old position
13254 for (y = 0; y < lev_fieldy; y++)
13256 for (x = 0; x < lev_fieldx; x++)
13258 int old_element = Tile[x][y];
13260 if (IS_PLAYER_ELEMENT(old_element) &&
13261 IS_PLAYER_ELEMENT(new_element))
13263 int replaced_with_element =
13264 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
13265 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
13267 old_element == EL_SOKOBAN_FIELD_PLAYER &&
13268 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
13270 new_element == EL_SOKOBAN_FIELD_PLAYER &&
13271 old_element == EL_PLAYER_1 ? EL_EMPTY :
13273 new_element >= EL_PLAYER_1 &&
13274 new_element <= EL_PLAYER_4 &&
13275 new_element == old_element ? EL_EMPTY :
13279 SetElement(x, y, replaced_with_element);
13281 else if (IS_MM_MCDUFFIN(old_element) &&
13282 IS_MM_MCDUFFIN(new_element))
13284 // remove McDuffin at old position
13285 SetElement(x, y, EL_EMPTY);
13291 SetElementButton(lx, ly, dx, dy, new_element, button);
13294 else if (!button_release_event)
13296 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13298 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
13299 DrawMiniGraphicExt(drawto,
13300 gi->x + sx * MINI_TILEX,
13301 gi->y + sy * MINI_TILEY,
13302 el2edimg(new_element));
13304 DrawFixedGraphicExt(drawto,
13305 gi->x + sx * TILEX,
13306 gi->y + sy * TILEY,
13307 el2edimg(new_element), 0);
13309 if (id == GADGET_ID_CUSTOM_GRAPHIC)
13310 new_element = GFX_ELEMENT(new_element);
13312 drawingarea_info[type_id].value[pos] = new_element;
13314 CopyElementPropertiesToGame(properties_element);
13316 if (id == GADGET_ID_CUSTOM_GRAPHIC)
13318 UpdateCustomElementGraphicGadgets();
13320 FrameCounter = 0; // restart animation frame counter
13325 case GADGET_ID_CONNECTED_ITEMS:
13327 static int last_sx = -1;
13328 static int last_sy = -1;
13330 if (button_release_event)
13331 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13333 SetDrawModeHiRes(new_element);
13335 if (getDrawModeHiRes())
13341 if (!button_press_event)
13342 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
13349 case GADGET_ID_LINE:
13350 case GADGET_ID_ARC:
13351 case GADGET_ID_RECTANGLE:
13352 case GADGET_ID_FILLED_BOX:
13353 SetDrawModeHiRes(new_element);
13355 if (getDrawModeHiRes())
13361 case GADGET_ID_GRAB_BRUSH:
13362 case GADGET_ID_TEXT:
13364 static int last_sx = -1;
13365 static int last_sy = -1;
13366 static int start_sx = -1;
13367 static int start_sy = -1;
13368 void (*draw_func)(int, int, int, int, int, boolean);
13370 if (drawing_function == GADGET_ID_LINE)
13371 draw_func = DrawLine;
13372 else if (drawing_function == GADGET_ID_ARC)
13373 draw_func = DrawArc;
13374 else if (drawing_function == GADGET_ID_RECTANGLE)
13375 draw_func = DrawBox;
13376 else if (drawing_function == GADGET_ID_FILLED_BOX)
13377 draw_func = DrawFilledBox;
13378 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
13379 draw_func = SelectArea;
13380 else // (drawing_function == GADGET_ID_TEXT)
13381 draw_func = SetTextCursor;
13383 if (button_press_event)
13385 draw_func(sx, sy, sx, sy, new_element, FALSE);
13386 start_sx = last_sx = sx;
13387 start_sy = last_sy = sy;
13389 if (drawing_function == GADGET_ID_TEXT)
13390 DrawLevelText(0, 0, 0, TEXT_END);
13392 else if (button_release_event)
13394 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
13395 if (drawing_function == GADGET_ID_GRAB_BRUSH)
13397 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
13398 CopyBrushToCursor(sx, sy);
13399 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
13401 draw_with_brush = TRUE;
13403 else if (drawing_function == GADGET_ID_TEXT)
13404 DrawLevelText(sx, sy, 0, TEXT_INIT);
13406 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13408 else if (last_sx != sx || last_sy != sy)
13410 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
13411 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
13412 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
13413 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
13420 case GADGET_ID_FLOOD_FILL:
13421 if (button_press_event && Tile[lx][ly] != new_element)
13423 if (IS_MM_WALL_EDITOR(new_element))
13424 FloodFillWall_MM(sx2, sy2, new_element);
13426 FloodFill(lx, ly, new_element);
13428 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13429 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13433 case GADGET_ID_PICK_ELEMENT:
13434 if (button_release_event)
13435 ClickOnGadget(level_editor_gadget[last_drawing_function],
13437 else if (draw_level)
13438 PickDrawingElement(button, Tile[lx][ly]);
13441 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13443 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
13450 // do not mark level as modified for certain non-level-changing gadgets
13451 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
13452 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
13453 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
13454 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
13457 level.changed = TRUE;
13460 static void HandleCounterButtons(struct GadgetInfo *gi)
13462 int gadget_id = gi->custom_id;
13463 int counter_id = gi->custom_type_id;
13464 int button = gi->event.button;
13465 int *counter_value = counterbutton_info[counter_id].value;
13466 int step = BUTTON_STEPSIZE(button) *
13467 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
13469 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
13471 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
13472 boolean released = (gi->event.type == GD_EVENT_RELEASED);
13473 boolean level_changed = LevelChanged();
13475 if ((level_changed && pressed) || (!level_changed && released))
13478 if (level_changed && !Request("Level has changed! Discard changes?",
13481 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
13482 ModifyEditorCounterValue(counter_id, *counter_value);
13488 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
13489 *counter_value = gi->textinput.number_value;
13491 ModifyEditorCounterValue(counter_id, *counter_value + step);
13493 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
13495 int last_game_engine_type = level.game_engine_type;
13497 LoadLevel(level_nr);
13498 LoadScore(level_nr);
13500 SaveLevelSetup_SeriesInfo();
13505 DrawEditModeWindow();
13507 if (level.game_engine_type != last_game_engine_type)
13509 // update element selection list
13510 ReinitializeElementList();
13511 ModifyEditorElementList();
13517 switch (counter_id)
13519 case ED_COUNTER_ID_YAMYAM_CONTENT:
13520 DrawYamYamContentAreas();
13523 case ED_COUNTER_ID_BALL_CONTENT:
13524 DrawMagicBallContentAreas();
13527 case ED_COUNTER_ID_ANDROID_CONTENT:
13528 DrawAndroidElementArea();
13531 case ED_COUNTER_ID_GROUP_CONTENT:
13532 DrawGroupElementArea();
13533 CopyGroupElementPropertiesToGame(properties_element);
13536 case ED_COUNTER_ID_INVENTORY_SIZE:
13537 DrawPlayerInitialInventoryArea(properties_element);
13540 case ED_COUNTER_ID_MM_BALL_CONTENT:
13541 DrawMMBallContentArea();
13544 case ED_COUNTER_ID_ENVELOPE_XSIZE:
13545 case ED_COUNTER_ID_ENVELOPE_YSIZE:
13546 DrawEnvelopeTextArea(-1);
13549 case ED_COUNTER_ID_LEVEL_XSIZE:
13550 case ED_COUNTER_ID_LEVEL_YSIZE:
13551 lev_fieldx = level.fieldx;
13552 lev_fieldy = level.fieldy;
13554 // check if resizing of level results in change of border border
13555 SetBorderElement();
13563 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
13564 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
13565 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
13566 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
13567 CopyElementPropertiesToGame(properties_element);
13569 // do not mark level as modified for certain non-level-changing gadgets
13570 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
13571 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
13572 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
13573 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
13576 level.changed = TRUE;
13579 static void HandleTextInputGadgets(struct GadgetInfo *gi)
13581 int type_id = gi->custom_type_id;
13583 strcpy(textinput_info[type_id].value, gi->textinput.value);
13585 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
13587 CopyElementPropertiesToGame(properties_element);
13589 ModifyEditorElementList(); // update changed button info text
13592 // do not mark level as modified for certain non-level-changing gadgets
13593 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
13594 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
13597 level.changed = TRUE;
13600 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
13602 int type_id = gi->custom_type_id;
13604 strncpy(textarea_info[type_id].value, gi->textarea.value,
13605 MAX_ENVELOPE_TEXT_LEN);
13606 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
13608 level.changed = TRUE;
13611 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
13613 int type_id = gi->custom_type_id;
13614 int value_old = *selectbox_info[type_id].value;
13615 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
13617 *selectbox_info[type_id].value = value_new;
13619 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
13621 DrawLevelConfigWindow();
13623 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
13625 element_info[properties_element].current_change_page = gi->selectbox.index;
13627 DrawPropertiesWindow();
13629 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
13630 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
13631 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
13632 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
13633 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
13635 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
13637 // when changing action type, also check action mode and action arg
13638 if (value_old != value_new)
13639 setSelectboxSpecialActionVariablesIfNeeded();
13641 DrawPropertiesChange();
13644 CopyElementPropertiesToGame(properties_element);
13646 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
13648 // update element selection list
13649 ReinitializeElementList();
13650 ModifyEditorElementList();
13653 // do not mark level as modified for certain non-level-changing gadgets
13654 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
13655 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
13658 level.changed = TRUE;
13661 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
13663 int type_id = gi->custom_type_id;
13666 if (type_id >= ED_TAB_BUTTON_ID_LEVELCONFIG_FIRST &&
13667 type_id <= ED_TAB_BUTTON_ID_LEVELCONFIG_LAST)
13669 edit_mode_levelconfig = gi->custom_type_id;
13671 DrawLevelConfigWindow();
13673 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
13674 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
13676 edit_mode_properties = gi->custom_type_id;
13678 DrawPropertiesWindow();
13680 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
13681 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
13683 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
13685 // backup original "level.field" (needed to track playfield changes)
13686 CopyPlayfield(level.field, TileBackup);
13688 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
13689 CopyPlayfield(Tile, level.field);
13691 if (new_template ||
13692 Request("Save this template and kill the old?", REQ_ASK))
13693 SaveLevelTemplate();
13696 Request("Template saved!", REQ_CONFIRM);
13698 // restore original "level.field" (needed to track playfield changes)
13699 CopyPlayfield(TileBackup, level.field);
13701 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
13703 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
13705 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
13706 leveldir_current->readonly)
13708 Request("This level set is read-only!", REQ_CONFIRM);
13713 if (strEqual(levelset_name, ""))
13715 Request("Please enter level set title!", REQ_CONFIRM);
13720 if (strEqual(levelset_author, ""))
13722 Request("Please enter level set author!", REQ_CONFIRM);
13727 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
13729 if (UpdateUserLevelSet(levelset_subdir,
13732 levelset_num_levels))
13734 Request("Level set updated!", REQ_CONFIRM);
13738 Request("Updating level set failed!", REQ_CONFIRM);
13741 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
13743 if (level.changed && !Request("Level has changed! Discard changes?",
13747 if (CreateUserLevelSet(levelset_subdir,
13750 levelset_num_levels,
13751 levelset_use_levelset_artwork))
13753 if (levelset_copy_level_template)
13754 CopyLevelTemplateToUserLevelSet(levelset_subdir);
13756 Request("New level set created!", REQ_CONFIRM);
13758 AddUserLevelSetToLevelInfo(levelset_subdir);
13759 ChangeEditorToLevelSet(levelset_subdir);
13763 Request("Creating new level set failed!", REQ_CONFIRM);
13767 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
13768 custom_element.num_change_pages < MAX_CHANGE_PAGES)
13770 struct ElementInfo *ei = &element_info[properties_element];
13772 // when modifying custom element, ask for copying level template
13773 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13776 setElementChangePages(ei, ei->num_change_pages + 1);
13778 // set new change page to be new current change page
13779 ei->current_change_page = ei->num_change_pages - 1;
13780 ei->change = &ei->change_page[ei->current_change_page];
13782 setElementChangeInfoToDefaults(ei->change);
13784 DrawPropertiesWindow();
13786 level.changed = TRUE;
13788 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
13789 custom_element.num_change_pages > MIN_CHANGE_PAGES)
13791 struct ElementInfo *ei = &element_info[properties_element];
13793 // when modifying custom element, ask for copying level template
13794 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13797 // copy all change pages after change page to be deleted
13798 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
13799 ei->change_page[i] = ei->change_page[i + 1];
13801 setElementChangePages(ei, ei->num_change_pages - 1);
13803 DrawPropertiesWindow();
13805 level.changed = TRUE;
13809 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
13811 int type_id = gi->custom_type_id;
13813 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
13814 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
13816 struct ElementInfo *ei = &element_info[properties_element];
13817 int step = BUTTON_STEPSIZE(gi->event.button);
13819 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
13820 ei->current_change_page += step;
13822 if (ei->current_change_page < 0)
13823 ei->current_change_page = 0;
13824 else if (ei->current_change_page >= ei->num_change_pages)
13825 ei->current_change_page = ei->num_change_pages - 1;
13827 DrawPropertiesWindow();
13829 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
13830 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13832 struct ElementInfo *ei = &element_info[properties_element];
13833 int current_change_page = ei->current_change_page;
13835 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
13837 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
13838 ei->change_page[current_change_page];
13840 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13842 // when modifying custom element, ask for copying level template
13843 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13846 ei->change_page[current_change_page] =
13847 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
13849 level.changed = TRUE;
13852 DrawPropertiesWindow();
13856 static void HandleRadiobuttons(struct GadgetInfo *gi)
13858 int type_id = gi->custom_type_id;
13860 *radiobutton_info[type_id].value =
13861 radiobutton_info[type_id].checked_value;
13863 // do not mark level as modified for certain non-level-changing gadgets
13864 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
13865 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
13868 level.changed = TRUE;
13871 static void HandleCheckbuttons(struct GadgetInfo *gi)
13873 int type_id = gi->custom_type_id;
13875 *checkbutton_info[type_id].value ^= TRUE;
13877 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
13878 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
13879 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
13880 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
13881 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
13882 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
13883 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
13884 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
13886 CopyElementPropertiesToGame(properties_element);
13889 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
13891 UpdateCustomElementGraphicGadgets();
13893 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
13894 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
13896 boolean template_related_changes_found = FALSE;
13899 // check if any custom, group or empty elements have been changed
13900 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
13901 if ((IS_CUSTOM_ELEMENT(i) ||
13902 IS_GROUP_ELEMENT(i) ||
13903 IS_EMPTY_ELEMENT(i)) &&
13904 element_info[i].modified_settings)
13905 template_related_changes_found = TRUE;
13907 if (level.use_custom_template &&
13908 !fileExists(getGlobalLevelTemplateFilename()))
13910 Request("No level template found!", REQ_CONFIRM);
13912 level.use_custom_template = FALSE;
13914 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13919 if (level.use_custom_template &&
13920 template_related_changes_found &&
13921 !Request("Discard changes and use level template?", REQ_ASK))
13923 level.use_custom_template = FALSE;
13925 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13930 if (!level.use_custom_template &&
13931 Request("Copy settings from level template?", REQ_ASK))
13936 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
13938 DrawEditModeWindow();
13940 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
13942 if (setup.editor.use_template_for_new_levels &&
13943 !fileExists(getGlobalLevelTemplateFilename()))
13945 Request("No level template found!", REQ_CONFIRM);
13950 if (setup.editor.use_template_for_new_levels &&
13952 !Request("Discard level and load template?", REQ_ASK))
13957 if (!setup.editor.use_template_for_new_levels &&
13959 !Request("Discard level and use empty level?", REQ_ASK))
13964 LoadLevel(level_nr);
13965 LoadScore(level_nr);
13970 DrawEditModeWindow();
13972 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
13974 SetAutomaticNumberOfGemsNeeded();
13977 // do not mark level as modified for certain non-level-changing gadgets
13978 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
13979 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
13980 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
13981 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
13982 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
13983 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
13986 level.changed = TRUE;
13989 static void HandleControlButtons(struct GadgetInfo *gi)
13991 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
13992 static int last_edit_mode = ED_MODE_DRAWING;
13993 static int last_custom_copy_mode = -1;
13994 static int last_button = 0;
13995 int id = gi->custom_id;
13996 int button = gi->event.button;
13997 int step = BUTTON_STEPSIZE(button);
13998 int new_element = BUTTON_ELEMENT(button);
13999 int last_properties_element = properties_element;
14002 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
14003 DrawLevelText(0, 0, 0, TEXT_END);
14005 if (id < ED_NUM_CTRL1_BUTTONS &&
14006 id != GADGET_ID_SINGLE_ITEMS &&
14007 id != GADGET_ID_PICK_ELEMENT &&
14008 edit_mode != ED_MODE_DRAWING &&
14009 drawing_function != GADGET_ID_PICK_ELEMENT &&
14010 !(GetKeyModState() & KMOD_Control))
14011 ChangeEditModeWindow(ED_MODE_DRAWING);
14013 // element copy mode active, but no element button pressed => deactivate
14014 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
14015 last_custom_copy_mode = -1;
14017 // when showing palette on element buttons, change element of button used
14018 if (editor.palette.show_on_element_buttons &&
14019 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
14021 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
14023 id = GADGET_ID_PALETTE;
14028 case GADGET_ID_SCROLL_LEFT:
14029 if (level_xpos >= 0)
14031 if (lev_fieldx < ed_fieldx - 2)
14034 level_xpos -= step;
14035 if (level_xpos < -1)
14038 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
14040 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14042 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14043 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14047 case GADGET_ID_SCROLL_RIGHT:
14048 if (level_xpos <= lev_fieldx - ed_fieldx)
14050 if (lev_fieldx < ed_fieldx - 2)
14053 level_xpos += step;
14054 if (level_xpos > lev_fieldx - ed_fieldx + 1)
14055 level_xpos = lev_fieldx - ed_fieldx + 1;
14057 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
14059 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14061 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
14062 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
14066 case GADGET_ID_SCROLL_UP:
14067 if (level_ypos >= 0)
14069 if (lev_fieldy < ed_fieldy - 2)
14072 level_ypos -= step;
14073 if (level_ypos < -1)
14076 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
14078 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14080 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
14081 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
14085 case GADGET_ID_SCROLL_DOWN:
14086 if (level_ypos <= lev_fieldy - ed_fieldy)
14088 if (lev_fieldy < ed_fieldy - 2)
14091 level_ypos += step;
14092 if (level_ypos > lev_fieldy - ed_fieldy + 1)
14093 level_ypos = lev_fieldy - ed_fieldy + 1;
14095 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
14097 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14099 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
14100 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
14104 case GADGET_ID_SCROLL_HORIZONTAL:
14105 level_xpos = gi->event.item_position - 1;
14107 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14112 case GADGET_ID_SCROLL_VERTICAL:
14113 level_ypos = gi->event.item_position - 1;
14115 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14120 case GADGET_ID_SCROLL_LIST_UP:
14121 case GADGET_ID_SCROLL_LIST_DOWN:
14122 case GADGET_ID_SCROLL_LIST_VERTICAL:
14123 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
14124 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
14127 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
14128 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
14130 if (element_shift < 0)
14132 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14133 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14135 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14136 GDI_SCROLLBAR_ITEM_POSITION,
14137 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14140 ModifyEditorElementList();
14144 case GADGET_ID_PROPERTIES:
14145 // always switch off element properties when they are already displayed
14146 last_properties_element = new_element;
14147 case GADGET_ID_ELEMENT_LEFT:
14148 case GADGET_ID_ELEMENT_MIDDLE:
14149 case GADGET_ID_ELEMENT_RIGHT:
14150 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
14151 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
14152 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
14155 if (edit_mode != ED_MODE_PROPERTIES)
14157 last_edit_mode = edit_mode;
14159 ChangeEditModeWindow(ED_MODE_PROPERTIES);
14161 last_level_drawing_function = drawing_function;
14162 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14165 else if (properties_element != last_properties_element)
14167 DrawEditModeWindow();
14171 ChangeEditModeWindow(ED_MODE_DRAWING);
14173 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
14178 case GADGET_ID_PALETTE:
14179 if (edit_mode != ED_MODE_PALETTE)
14181 last_edit_mode = edit_mode;
14183 ChangeEditModeWindow(ED_MODE_PALETTE);
14187 ChangeEditModeWindow(last_edit_mode);
14191 case GADGET_ID_WRAP_LEFT:
14192 WrapLevel(-step, 0);
14195 case GADGET_ID_WRAP_RIGHT:
14196 WrapLevel(step, 0);
14199 case GADGET_ID_WRAP_UP:
14200 WrapLevel(0, -step);
14203 case GADGET_ID_WRAP_DOWN:
14204 WrapLevel(0, step);
14207 case GADGET_ID_SINGLE_ITEMS:
14208 case GADGET_ID_CONNECTED_ITEMS:
14209 case GADGET_ID_LINE:
14210 case GADGET_ID_ARC:
14211 case GADGET_ID_TEXT:
14212 case GADGET_ID_RECTANGLE:
14213 case GADGET_ID_FILLED_BOX:
14214 case GADGET_ID_FLOOD_FILL:
14215 case GADGET_ID_GRAB_BRUSH:
14216 case GADGET_ID_PICK_ELEMENT:
14217 if (drawing_function != GADGET_ID_PICK_ELEMENT)
14218 last_drawing_function = drawing_function;
14219 drawing_function = id;
14220 draw_with_brush = FALSE;
14223 case GADGET_ID_RANDOM_PLACEMENT:
14224 RandomPlacement(new_element);
14227 case GADGET_ID_ZOOM:
14228 // zoom level editor tile size in or out (or reset to default size)
14229 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
14230 button == 2 ? ed_tilesize_default :
14231 button == 3 ? ed_tilesize / 2 : ed_tilesize);
14233 // when using touch device, cycle through all zoom tilesizes
14234 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
14235 ed_tilesize = MICRO_TILESIZE;
14237 // limit zoom level by upper and lower bound
14238 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
14240 InitZoomLevelSettings(ed_tilesize);
14242 if (edit_mode == ED_MODE_DRAWING)
14244 DrawDrawingWindow();
14246 // redraw zoom gadget info text
14247 PrintEditorGadgetInfoText(level_editor_gadget[id]);
14250 // save current editor zoom tilesize
14251 SaveSetup_AutoSetup();
14255 case GADGET_ID_CUSTOM_COPY_FROM:
14256 case GADGET_ID_CUSTOM_COPY_TO:
14257 case GADGET_ID_CUSTOM_EXCHANGE:
14258 last_custom_copy_mode = id;
14259 last_drawing_function = drawing_function;
14262 case GADGET_ID_CUSTOM_COPY:
14263 CopyCustomElement(properties_element, -1, id);
14266 case GADGET_ID_CUSTOM_PASTE:
14267 CopyCustomElement(-1, properties_element, id);
14270 case GADGET_ID_UNDO:
14271 if (button < 0) // keep button value (even if modifier keys are pressed)
14273 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
14276 if (button == 1 && undo_buffer_steps == 0)
14278 Request("Undo buffer empty!", REQ_CONFIRM);
14282 else if (button == 2)
14286 else if (button == 3 && redo_buffer_steps == 0)
14288 Request("Redo buffer empty!", REQ_CONFIRM);
14293 if (edit_mode != ED_MODE_DRAWING)
14294 ChangeEditModeWindow(ED_MODE_DRAWING);
14300 undo_buffer_position =
14301 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
14303 undo_buffer_steps--;
14304 redo_buffer_steps++;
14310 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
14312 undo_buffer_steps++;
14313 redo_buffer_steps--;
14316 for (x = 0; x < lev_fieldx; x++)
14317 for (y = 0; y < lev_fieldy; y++)
14318 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
14320 // check if undo operation forces change of border style
14321 CheckLevelBorderElement(FALSE);
14323 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14327 case GADGET_ID_CONF:
14328 if (edit_mode != ED_MODE_LEVELCONFIG)
14330 last_edit_mode = edit_mode;
14332 ChangeEditModeWindow(ED_MODE_LEVELCONFIG);
14336 ChangeEditModeWindow(ED_MODE_DRAWING);
14340 case GADGET_ID_CLEAR:
14341 if (edit_mode != ED_MODE_DRAWING)
14342 ChangeEditModeWindow(ED_MODE_DRAWING);
14344 for (x = 0; x < MAX_LEV_FIELDX; x++)
14345 for (y = 0; y < MAX_LEV_FIELDY; y++)
14346 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
14348 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
14350 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14353 case GADGET_ID_SAVE:
14355 // saving read-only levels into personal level set modifies global vars
14356 // "leveldir_current" and "level_nr"; restore them after saving level
14357 LevelDirTree *leveldir_former = leveldir_current;
14358 int level_nr_former = level_nr;
14359 char *level_filename;
14362 if (leveldir_current->readonly &&
14363 !PrepareSavingIntoPersonalLevelSet())
14366 level_filename = getDefaultLevelFilename(level_nr);
14367 new_level = !fileExists(level_filename);
14370 Request("Save this level and kill the old?", REQ_ASK))
14372 if (leveldir_former->readonly)
14373 ModifyLevelConfigForSavingIntoPersonalLevelSet(leveldir_former->name);
14375 SetAutomaticNumberOfGemsNeeded();
14377 CopyPlayfield(Tile, level.field);
14378 SaveLevel(level_nr);
14380 level.changed = FALSE;
14384 char level_saved_msg[64];
14386 if (leveldir_former->readonly)
14387 sprintf(level_saved_msg,
14388 "Level saved as level %d into personal level set!",
14391 strcpy(level_saved_msg, "Level saved!");
14393 Request(level_saved_msg, REQ_CONFIRM);
14397 // "cd" back to copied-from levelset (in case of saved read-only level)
14398 leveldir_current = leveldir_former;
14399 level_nr = level_nr_former;
14404 case GADGET_ID_TEST:
14405 if (LevelChanged())
14406 level.game_version = GAME_VERSION_ACTUAL;
14408 CopyPlayfield(level.field, TileBackup);
14409 CopyPlayfield(Tile, level.field);
14411 CopyNativeLevel_RND_to_Native(&level);
14413 UnmapLevelEditorGadgets();
14414 UndrawSpecialEditorDoor();
14416 CloseDoor(DOOR_CLOSE_ALL);
14418 // needed before playing if editor playfield area has different size
14419 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
14421 // redraw_mask = REDRAW_ALL;
14423 level_editor_test_game = TRUE;
14425 StartGameActions(FALSE, setup.autorecord, level.random_seed);
14429 case GADGET_ID_EXIT:
14430 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
14434 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
14435 id <= GADGET_ID_ELEMENTLIST_LAST)
14437 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
14439 new_element = editor_elements[element_position + element_shift];
14441 if (IS_EDITOR_CASCADE(new_element))
14445 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
14447 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
14448 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
14450 if (*cascade_element == new_element)
14452 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
14453 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
14455 // update element selection list
14456 ReinitializeElementList();
14457 ModifyEditorElementList();
14459 // update cascading gadget info text
14460 PrintEditorGadgetInfoText(level_editor_gadget[id]);
14462 // save current editor cascading state
14463 SaveSetup_EditorCascade();
14472 if (last_custom_copy_mode != -1)
14474 if (CopyCustomElement(properties_element, new_element,
14475 last_custom_copy_mode))
14477 ClickOnGadget(level_editor_gadget[last_drawing_function],
14480 last_custom_copy_mode = -1;
14486 // change element of button used to show palette
14487 if (editor.palette.show_on_element_buttons)
14488 button = last_button;
14490 PickDrawingElement(button, new_element);
14492 if (!stick_element_properties_window &&
14493 drawing_function != GADGET_ID_PICK_ELEMENT &&
14494 !(GetKeyModState() & KMOD_Control))
14496 properties_element = new_element;
14497 if (edit_mode == ED_MODE_PROPERTIES)
14498 DrawPropertiesWindow();
14501 if (drawing_function == GADGET_ID_PICK_ELEMENT)
14502 ClickOnGadget(level_editor_gadget[last_drawing_function],
14505 if (!use_permanent_palette)
14506 ChangeEditModeWindow(last_edit_mode);
14509 else if (gi->event.type == GD_EVENT_PRESSED)
14510 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
14511 else if (gi->event.type == GD_EVENT_RELEASED)
14512 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
14513 else if (gi->event.type == GD_EVENT_MOVING)
14514 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
14516 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
14522 void HandleLevelEditorKeyInput(Key key)
14524 char letter = getCharFromKey(key);
14526 if (drawing_function == GADGET_ID_TEXT &&
14527 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
14530 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
14531 else if (key == KSYM_Delete || key == KSYM_BackSpace)
14532 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
14533 else if (key == KSYM_Return)
14534 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
14535 else if (key == KSYM_Escape)
14536 DrawLevelText(0, 0, 0, TEXT_END);
14541 int id = GADGET_ID_NONE;
14542 int new_element_shift = element_shift;
14543 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
14544 int button = MB_LEFTBUTTON;
14550 id = GADGET_ID_SCROLL_LEFT;
14553 id = GADGET_ID_SCROLL_RIGHT;
14556 id = GADGET_ID_SCROLL_UP;
14559 id = GADGET_ID_SCROLL_DOWN;
14563 case KSYM_Page_Down:
14564 step *= (key == KSYM_Page_Up ? -1 : +1);
14565 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
14567 if (element_shift < 0)
14569 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14570 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14572 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14573 GDI_SCROLLBAR_ITEM_POSITION,
14574 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14576 ModifyEditorElementList();
14582 element_shift = (key == KSYM_Home ? 0 :
14583 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
14585 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14586 GDI_SCROLLBAR_ITEM_POSITION,
14587 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14589 ModifyEditorElementList();
14596 // this is needed to prevent interference with running "True X-Mouse"
14597 if (GetKeyModStateFromEvents() & KMOD_Control)
14600 // check for last or next editor cascade block in element list
14601 for (i = 0; i < num_editor_elements; i++)
14603 if ((key == KSYM_Insert && i == element_shift) ||
14604 (key == KSYM_Delete && new_element_shift > element_shift))
14607 // jump to next cascade block (or to start of element list)
14608 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
14609 new_element_shift = i;
14612 if (i < num_editor_elements)
14613 element_shift = new_element_shift;
14615 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14616 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14618 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14619 GDI_SCROLLBAR_ITEM_POSITION,
14620 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14622 ModifyEditorElementList();
14627 if (edit_mode == ED_MODE_DRAWING)
14628 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
14629 else if (edit_mode == ED_MODE_LEVELCONFIG)
14630 HandleControlButtons(level_editor_gadget[GADGET_ID_CONF]);
14631 else if (edit_mode == ED_MODE_PROPERTIES)
14632 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
14633 else if (edit_mode == ED_MODE_PALETTE)
14634 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
14635 else // should never happen
14636 ChangeEditModeWindow(ED_MODE_DRAWING);
14644 if (id != GADGET_ID_NONE)
14645 ClickOnGadget(level_editor_gadget[id], button);
14646 else if (letter == '1' || letter == '?')
14647 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
14648 else if (letter == '2')
14649 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
14650 else if (letter == '3')
14651 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
14652 else if (letter == '.')
14653 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
14654 else if (letter == 'U')
14655 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
14656 else if (letter == '-' || key == KSYM_KP_Subtract)
14657 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
14658 else if (letter == '0' || key == KSYM_KP_0)
14659 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
14660 else if (letter == '+' || key == KSYM_KP_Add ||
14661 letter == '=') // ("Shift-=" is "+" on US keyboards)
14662 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
14663 else if (key == KSYM_Return ||
14664 key == KSYM_space ||
14665 key == setup.shortcut.toggle_pause)
14666 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
14668 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
14669 if (letter && letter == controlbutton_info[i].shortcut)
14670 if (!anyTextGadgetActive())
14671 ClickOnGadget(level_editor_gadget[i], button);
14674 static void HandleLevelEditorIdle_Properties(void)
14676 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
14677 int x = editor.settings.element_graphic.x + element_border;
14678 int y = editor.settings.element_graphic.y + element_border;
14679 static DelayCounter action_delay = { 0 };
14682 action_delay.value = GameFrameDelay;
14684 if (!DelayReached(&action_delay))
14687 for (i = 0; i < ED_NUM_SELECTBOX; i++)
14689 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
14691 if (gi->mapped && gi->active && gi->selectbox.open)
14695 DrawEditorElementAnimation(SX + x, SY + y);
14697 redraw_mask |= REDRAW_FIELD;
14699 FrameCounter++; // increase animation frame counter
14702 static void HandleLevelEditorIdle_Drawing(void)
14704 static boolean last_highlighted = FALSE;
14705 boolean highlighted = (GetKeyModState() & KMOD_Alt);
14707 if (highlighted != last_highlighted)
14709 DrawAreaElementHighlight(highlighted);
14711 last_highlighted = highlighted;
14713 redraw_mask |= REDRAW_FIELD;
14717 void HandleLevelEditorIdle(void)
14719 if (edit_mode == ED_MODE_PROPERTIES)
14720 HandleLevelEditorIdle_Properties();
14721 else if (edit_mode == ED_MODE_DRAWING)
14722 HandleLevelEditorIdle_Drawing();
14725 static void ClearEditorGadgetInfoText(void)
14727 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
14730 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
14732 char infotext[MAX_OUTPUT_LINESIZE + 1];
14733 int max_infotext_len = getMaxInfoTextLength();
14735 if (gi == NULL || strlen(gi->info_text) == 0)
14738 strncpy(infotext, gi->info_text, max_infotext_len);
14739 infotext[max_infotext_len] = '\0';
14741 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
14743 int key = controlbutton_info[gi->custom_id].shortcut;
14747 char shortcut[MAX_OUTPUT_LINESIZE + 1];
14749 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
14750 sprintf(shortcut, " ('.' or '%c')", key);
14751 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
14752 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
14753 else if (gi->custom_id == GADGET_ID_TEST)
14754 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
14755 else if (gi->custom_id == GADGET_ID_UNDO)
14756 sprintf(shortcut, " ('%c/Shift-U')", key);
14757 else if (gi->custom_id == GADGET_ID_ZOOM)
14758 sprintf(shortcut, " ('%c', '0', '-')", key);
14760 sprintf(shortcut, " ('%s%c')",
14761 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
14763 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
14764 strcat(infotext, shortcut);
14768 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
14771 void HandleEditorGadgetInfoText(void *ptr)
14773 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
14775 if (game_status != GAME_MODE_EDITOR)
14778 ClearEditorGadgetInfoText();
14780 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
14783 // misuse this function to delete brush cursor, if needed
14784 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
14785 DeleteBrushFromCursor();
14787 PrintEditorGadgetInfoText(gi);
14790 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
14792 int id = gi->custom_id;
14793 int type_id = gi->custom_type_id;
14794 int sx = gi->event.x;
14795 int sy = gi->event.y;
14796 int lx = sx + level_xpos;
14797 int ly = sy + level_ypos;
14798 int min_sx = 0, min_sy = 0;
14799 int max_sx = gi->drawing.area_xsize - 1;
14800 int max_sy = gi->drawing.area_ysize - 1;
14801 int actual_drawing_function = drawing_function;
14802 int max_infotext_len = getMaxInfoTextLength();
14803 char infotext[MAX_OUTPUT_LINESIZE + 1];
14805 infotext[0] = '\0'; // start with empty info text
14807 // pressed Control key: simulate picking element
14808 if (GetKeyModState() & KMOD_Control)
14809 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14811 ClearEditorGadgetInfoText();
14813 if (gi->event.type == GD_EVENT_INFO_LEAVING)
14816 // make sure to stay inside drawing area boundaries
14817 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14818 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14820 if (id == GADGET_ID_DRAWING_LEVEL)
14824 int min_lx = 0, min_ly = 0;
14825 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14827 // get positions inside level field
14828 lx = sx + level_xpos;
14829 ly = sy + level_ypos;
14831 // make sure to stay inside level field boundaries
14832 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14833 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14835 // correct drawing area positions accordingly
14836 sx = lx - level_xpos;
14837 sy = ly - level_ypos;
14840 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
14842 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
14844 static int start_lx = 0;
14845 static int start_ly = 0;
14848 if (gi->event.type == GD_EVENT_PRESSED)
14854 switch (actual_drawing_function)
14856 case GADGET_ID_SINGLE_ITEMS:
14857 text = "Drawing single items";
14859 case GADGET_ID_CONNECTED_ITEMS:
14860 text = "Drawing connected items";
14862 case GADGET_ID_LINE:
14863 text = "Drawing line";
14865 case GADGET_ID_ARC:
14866 text = "Drawing arc";
14868 case GADGET_ID_TEXT:
14869 text = "Setting text cursor";
14871 case GADGET_ID_RECTANGLE:
14872 text = "Drawing rectangle";
14874 case GADGET_ID_FILLED_BOX:
14875 text = "Drawing filled box";
14877 case GADGET_ID_FLOOD_FILL:
14878 text = "Flood fill";
14880 case GADGET_ID_GRAB_BRUSH:
14881 text = "Grabbing brush";
14883 case GADGET_ID_PICK_ELEMENT:
14884 text = "Picking element";
14888 text = "Drawing position";
14892 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14893 sprintf(infotext, "%s: %d, %d", text, lx, ly);
14895 sprintf(infotext, "%s: %d, %d", text,
14896 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
14898 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14899 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
14901 sprintf(infotext, "Level position: %d, %d", lx, ly);
14904 // misuse this function to draw brush cursor, if needed
14905 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
14907 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
14908 CopyBrushToCursor(sx, sy);
14910 DeleteBrushFromCursor();
14913 if (!draw_with_brush)
14914 UpdateBrushPosition(sx, sy);
14916 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14918 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14919 int element = drawingarea_info[type_id].value[pos];
14921 strncpy(infotext, getElementInfoText(element), max_infotext_len);
14925 if (id == GADGET_ID_CUSTOM_CONTENT)
14926 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
14927 else if (id == GADGET_ID_GROUP_CONTENT)
14928 sprintf(infotext, "group element position: %d", sx + 1);
14929 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
14930 id <= GADGET_ID_YAMYAM_CONTENT_7)
14931 sprintf(infotext, "content area %d position: %d, %d",
14932 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
14933 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
14934 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
14935 sprintf(infotext, "content area %d position: %d, %d",
14936 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
14937 else if (id == GADGET_ID_ANDROID_CONTENT)
14938 sprintf(infotext, "android element position: %d", sx + 1);
14939 else if (drawingarea_info[type_id].infotext != NULL)
14940 strcpy(infotext, drawingarea_info[type_id].infotext);
14943 infotext[max_infotext_len] = '\0';
14945 if (strlen(infotext) > 0)
14946 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
14949 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
14950 boolean quick_quit)
14952 if (!ask_if_level_has_changed ||
14954 Request("Level has changed! Exit without saving?",
14955 REQ_ASK | REQ_STAY_OPEN))
14957 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
14958 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
14960 // draw normal door
14961 UndrawSpecialEditorDoor();
14963 // use door animation if door 1 viewport is unchanged and contains toolbox
14964 if (useEditorDoorAnimation())
14965 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
14967 // close editor doors if viewport definition is the same as in main menu
14968 if (vp_door_1->x == DX &&
14969 vp_door_1->y == DY &&
14970 vp_door_1->width == DXSIZE &&
14971 vp_door_1->height == DYSIZE &&
14972 vp_door_2->x == VX &&
14973 vp_door_2->y == VY &&
14974 vp_door_2->width == VXSIZE &&
14975 vp_door_2->height == VYSIZE)
14976 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
14978 SetDoorState(DOOR_CLOSE_2);
14983 FadeSkipNextFadeIn();
14985 SetGameStatus(GAME_MODE_MAIN);
14991 if (!global.use_envelope_request)
14993 CloseDoor(DOOR_CLOSE_1);
14994 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);