1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
14 #include "libgame/libgame.h"
25 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
28 // ----------------------------------------------------------------------------
29 // screen and artwork graphic pixel position definitions
30 // ----------------------------------------------------------------------------
32 // values for the control window
33 #define ED_CTRL1_BUTTONS_HORIZ 4 // toolbox
34 #define ED_CTRL1_BUTTONS_VERT 4
35 #define ED_CTRL2_BUTTONS_HORIZ 3 // level
36 #define ED_CTRL2_BUTTONS_VERT 2
37 #define ED_CTRL3_BUTTONS_HORIZ 3 // CE and GE
38 #define ED_CTRL3_BUTTONS_VERT 1
39 #define ED_CTRL4_BUTTONS_HORIZ 2 // CE and GE
40 #define ED_CTRL4_BUTTONS_VERT 1
41 #define ED_CTRL5_BUTTONS_HORIZ 1 // properties
42 #define ED_CTRL5_BUTTONS_VERT 1
43 #define ED_CTRL6_BUTTONS_HORIZ 3 // properties
44 #define ED_CTRL6_BUTTONS_VERT 1
45 #define ED_CTRL7_BUTTONS_HORIZ 1 // palette
46 #define ED_CTRL7_BUTTONS_VERT 1
48 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
49 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
50 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
51 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
52 #define ED_NUM_CTRL5_BUTTONS (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT)
53 #define ED_NUM_CTRL6_BUTTONS (ED_CTRL6_BUTTONS_HORIZ * ED_CTRL6_BUTTONS_VERT)
54 #define ED_NUM_CTRL7_BUTTONS (ED_CTRL7_BUTTONS_HORIZ * ED_CTRL7_BUTTONS_VERT)
55 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
56 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
57 #define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS)
58 #define ED_NUM_CTRL1_5_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS)
59 #define ED_NUM_CTRL1_6_BUTTONS (ED_NUM_CTRL1_5_BUTTONS + ED_NUM_CTRL6_BUTTONS)
60 #define ED_NUM_CTRL1_7_BUTTONS (ED_NUM_CTRL1_6_BUTTONS + ED_NUM_CTRL7_BUTTONS)
61 #define ED_NUM_CTRL_BUTTONS ED_NUM_CTRL1_7_BUTTONS
63 // values for the element list
64 #define ED_ELEMENTLIST_XPOS (editor.palette.x)
65 #define ED_ELEMENTLIST_YPOS (editor.palette.y)
66 #define ED_ELEMENTLIST_XSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
67 #define ED_ELEMENTLIST_YSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
68 #define ED_ELEMENTLIST_COLS MAX(1, editor.palette.cols)
69 #define ED_ELEMENTLIST_ROWS MAX(1, editor.palette.rows)
70 #define ED_ELEMENTLIST_BUTTONS_HORIZ (ED_ELEMENTLIST_COLS)
71 #define ED_ELEMENTLIST_BUTTONS_VERT (ED_ELEMENTLIST_ROWS)
72 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
73 ED_ELEMENTLIST_BUTTONS_VERT)
76 #define ED_GADGET_NORMAL_DISTANCE (editor.gadget.normal_spacing)
77 #define ED_GADGET_SMALL_DISTANCE (editor.gadget.small_spacing)
78 #define ED_GADGET_TINY_DISTANCE (editor.gadget.tiny_spacing)
79 #define ED_GADGET_LINE_DISTANCE (editor.gadget.line_spacing)
80 #define ED_GADGET_TEXT_DISTANCE (editor.gadget.text_spacing)
81 #define ED_TAB_BAR_HEIGHT (editor.gadget.separator_line.height)
82 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
83 ED_DRAWINGAREA_BORDER_SIZE)
84 #define ED_GADGET_SPACE_DISTANCE (getFontWidth(FONT_TEXT_1))
86 // values for drawingarea gadgets
87 #define IMG_BORDER_1 IMG_EDITOR_ELEMENT_BORDER
88 #define IMG_BORDER_2 IMG_EDITOR_ELEMENT_BORDER_INPUT
89 #define ED_ELEMENT_BORDER (graphic_info[IMG_BORDER_1].border_size)
90 #define ED_DRAWINGAREA_BORDER_SIZE (graphic_info[IMG_BORDER_2].border_size)
91 #define ED_DRAWINGAREA_TILE_SIZE (editor.drawingarea.tile_size)
93 // values for checkbutton gadgets
94 #define ED_CHECKBUTTON_XSIZE (graphic_info[IMG_EDITOR_CHECKBOX].width)
95 #define ED_CHECKBUTTON_YSIZE (graphic_info[IMG_EDITOR_CHECKBOX].height)
97 #define ED_TABBUTTON_XSIZE (graphic_info[IMG_EDITOR_TABBUTTON].width)
98 #define ED_TABBUTTON_YSIZE (graphic_info[IMG_EDITOR_TABBUTTON].height)
100 #define ED_SETTINGS_LEVEL_TABS_X (editor.settings.tabs.x)
101 #define ED_SETTINGS_LEVEL_TABS_Y (editor.settings.tabs.y)
102 #define ED_SETTINGS_ELEMENT_TABS_X (editor.settings.tabs.x)
103 #define ED_SETTINGS_ELEMENT_TABS_Y (editor.settings.tabs.y + \
104 editor.settings.tabs.yoffset2)
106 #define ED_SETTINGS_TABS_XOFFSET (editor.settings.tabs.draw_xoffset)
107 #define ED_SETTINGS_TABS_YOFFSET (editor.settings.tabs.draw_yoffset)
109 #define ED_LEVEL_TABS_XSTART (ED_SETTINGS_LEVEL_TABS_X)
110 #define ED_LEVEL_TABS_YSTART (ED_SETTINGS_LEVEL_TABS_Y)
111 #define ED_LEVEL_SETTINGS_XSTART (ED_SETTINGS_LEVEL_TABS_X + \
112 ED_SETTINGS_TABS_XOFFSET)
113 #define ED_LEVEL_SETTINGS_YSTART (ED_SETTINGS_LEVEL_TABS_Y + \
114 ED_TABBUTTON_YSIZE + \
115 ED_GADGET_TINY_DISTANCE + \
116 ED_TAB_BAR_HEIGHT + \
117 ED_SETTINGS_TABS_YOFFSET + \
118 getFontHeight(FONT_TEXT_1) + \
119 ED_GADGET_TEXT_DISTANCE)
120 #define ED_ELEMENT_TABS_XSTART (ED_SETTINGS_ELEMENT_TABS_X)
121 #define ED_ELEMENT_TABS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y)
122 #define ED_ELEMENT_SETTINGS_XSTART (ED_SETTINGS_ELEMENT_TABS_X + \
123 ED_SETTINGS_TABS_XOFFSET)
124 #define ED_ELEMENT_SETTINGS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y + \
125 ED_TABBUTTON_YSIZE + \
126 ED_GADGET_TINY_DISTANCE + \
127 ED_TAB_BAR_HEIGHT + \
128 ED_SETTINGS_TABS_YOFFSET)
130 #define ED_SETTINGS_XOFFSET (ED_CHECKBUTTON_XSIZE + \
131 ED_GADGET_TEXT_DISTANCE)
132 #define ED_SETTINGS_YOFFSET (ED_CHECKBUTTON_YSIZE + \
133 ED_GADGET_LINE_DISTANCE)
135 #define ED_POS_RANGE (10000)
136 #define ED_POS_LEVEL_TABS_FIRST (1 * ED_POS_RANGE)
137 #define ED_POS_LEVEL_TABS_LAST (2 * ED_POS_RANGE - 1)
138 #define ED_POS_LEVEL_SETTINGS_FIRST (2 * ED_POS_RANGE)
139 #define ED_POS_LEVEL_SETTINGS_LAST (3 * ED_POS_RANGE - 1)
140 #define ED_POS_ELEMENT_TABS_FIRST (3 * ED_POS_RANGE)
141 #define ED_POS_ELEMENT_TABS_LAST (4 * ED_POS_RANGE - 1)
142 #define ED_POS_ELEMENT_SETTINGS_FIRST (4 * ED_POS_RANGE)
143 #define ED_POS_ELEMENT_SETTINGS_LAST (5 * ED_POS_RANGE - 1)
145 #define ED_LEVEL_TABS_XPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
146 #define ED_LEVEL_TABS_YPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
148 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
149 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
151 #define ED_ELEMENT_TABS_XPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
152 #define ED_ELEMENT_TABS_YPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
154 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
155 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
157 #define IS_POS_LEVEL_TABS(n) ((n) >= ED_POS_LEVEL_TABS_FIRST && \
158 (n) <= ED_POS_LEVEL_TABS_LAST)
159 #define IS_POS_LEVEL_SETTINGS(n) ((n) >= ED_POS_LEVEL_SETTINGS_FIRST && \
160 (n) <= ED_POS_LEVEL_SETTINGS_LAST)
161 #define IS_POS_ELEMENT_TABS(n) ((n) >= ED_POS_ELEMENT_TABS_FIRST && \
162 (n) <= ED_POS_ELEMENT_TABS_LAST)
163 #define IS_POS_ELEMENT_SETTINGS(n) ((n) >= ED_POS_ELEMENT_SETTINGS_FIRST && \
164 (n) <= ED_POS_ELEMENT_SETTINGS_LAST)
166 #define ED_LEVEL_TABS_LINE(n) ((n) - ED_POS_LEVEL_TABS_FIRST)
167 #define ED_LEVEL_SETTINGS_LINE(n) ((n) - ED_POS_LEVEL_SETTINGS_FIRST)
168 #define ED_ELEMENT_TABS_LINE(n) ((n) - ED_POS_ELEMENT_TABS_FIRST)
169 #define ED_ELEMENT_SETTINGS_LINE(n) ((n) - ED_POS_ELEMENT_SETTINGS_FIRST)
171 #define ED_LEVEL_TABS_X(n) (ED_LEVEL_TABS_XSTART + \
172 (n) * ED_SETTINGS_TABS_XOFFSET)
173 #define ED_LEVEL_TABS_Y(n) (ED_LEVEL_TABS_YSTART + \
174 (n) * ED_SETTINGS_TABS_YOFFSET)
176 #define ED_LEVEL_SETTINGS_X(n) (ED_LEVEL_SETTINGS_XSTART + \
177 (n) * ED_SETTINGS_XOFFSET)
178 #define ED_LEVEL_SETTINGS_Y(n) (ED_LEVEL_SETTINGS_YSTART + \
179 (n) * ED_SETTINGS_YOFFSET)
181 #define ED_ELEMENT_TABS_X(n) (ED_ELEMENT_TABS_XSTART + \
182 (n) * ED_SETTINGS_TABS_XOFFSET)
183 #define ED_ELEMENT_TABS_Y(n) (ED_ELEMENT_TABS_YSTART + \
184 (n) * ED_SETTINGS_TABS_YOFFSET)
186 #define ED_ELEMENT_SETTINGS_X(n) (ED_ELEMENT_SETTINGS_XSTART + \
187 (n) * ED_SETTINGS_XOFFSET)
188 #define ED_ELEMENT_SETTINGS_Y(n) (ED_ELEMENT_SETTINGS_YSTART + \
189 (n) * ED_SETTINGS_YOFFSET)
191 #define ED_POS_TO_LEVEL_TABS_X(n) \
192 (ED_LEVEL_TABS_X(ED_LEVEL_TABS_LINE(n)))
193 #define ED_POS_TO_LEVEL_TABS_Y(n) \
194 (ED_LEVEL_TABS_Y(ED_LEVEL_TABS_LINE(n)))
196 #define ED_POS_TO_LEVEL_SETTINGS_X(n) \
197 (ED_LEVEL_SETTINGS_X(ED_LEVEL_SETTINGS_LINE(n)))
198 #define ED_POS_TO_LEVEL_SETTINGS_Y(n) \
199 (ED_LEVEL_SETTINGS_Y(ED_LEVEL_SETTINGS_LINE(n)))
201 #define ED_POS_TO_ELEMENT_TABS_X(n) \
202 (ED_ELEMENT_TABS_X(ED_ELEMENT_TABS_LINE(n)))
203 #define ED_POS_TO_ELEMENT_TABS_Y(n) \
204 (ED_ELEMENT_TABS_Y(ED_ELEMENT_TABS_LINE(n)))
206 #define ED_POS_TO_ELEMENT_SETTINGS_X(n) \
207 (ED_ELEMENT_SETTINGS_X(ED_ELEMENT_SETTINGS_LINE(n)))
208 #define ED_POS_TO_ELEMENT_SETTINGS_Y(n) \
209 (ED_ELEMENT_SETTINGS_Y(ED_ELEMENT_SETTINGS_LINE(n)))
211 #define ED_SETTINGS_X(n) (IS_POS_LEVEL_TABS(n) ? \
212 ED_POS_TO_LEVEL_TABS_X(n) : \
213 IS_POS_LEVEL_SETTINGS(n) ? \
214 ED_POS_TO_LEVEL_SETTINGS_X(n) : \
215 IS_POS_ELEMENT_TABS(n) ? \
216 ED_POS_TO_ELEMENT_TABS_X(n) : \
217 IS_POS_ELEMENT_SETTINGS(n) ? \
218 ED_POS_TO_ELEMENT_SETTINGS_X(n) : (n))
219 #define ED_SETTINGS_Y(n) (IS_POS_LEVEL_TABS(n) ? \
220 ED_POS_TO_LEVEL_TABS_Y(n) : \
221 IS_POS_LEVEL_SETTINGS(n) ? \
222 ED_POS_TO_LEVEL_SETTINGS_Y(n) : \
223 IS_POS_ELEMENT_TABS(n) ? \
224 ED_POS_TO_ELEMENT_TABS_Y(n) : \
225 IS_POS_ELEMENT_SETTINGS(n) ? \
226 ED_POS_TO_ELEMENT_SETTINGS_Y(n) : (n))
228 #define ED_SETTINGS_XOFF(n) (5 * ((n) % 4) * \
229 ED_DRAWINGAREA_TILE_SIZE)
230 #define ED_SETTINGS_YOFF(n) (5 * ((n) / 4) * \
231 ED_DRAWINGAREA_TILE_SIZE)
233 #define ED_AREA_XOFFSET_1(n) ((n) != 0 ? \
234 ED_DRAWINGAREA_BORDER_SIZE : 0)
235 #define ED_AREA_YOFFSET_1(n) ((n) != 0 ? \
236 (ED_CHECKBUTTON_YSIZE - \
237 ED_DRAWINGAREA_TILE_SIZE) / 2 : 0)
239 #define ED_AREA_XOFFSET_2(n) (0)
240 #define ED_AREA_YOFFSET_2(n) ((n) == 3 ? \
241 ((n) - 1) * ED_DRAWINGAREA_TILE_SIZE / 2 : 0)
243 #define ED_AREA_SETTINGS_X(i) (ED_SETTINGS_X((i).x) + \
244 ED_SETTINGS_XOFF((i).xoffset) + \
245 ED_AREA_XOFFSET_1((i).x) - \
246 ED_AREA_XOFFSET_2((i).area_xsize))
247 #define ED_AREA_SETTINGS_Y(i) (ED_SETTINGS_Y((i).y) + \
248 ED_SETTINGS_YOFF((i).yoffset) + \
249 ED_AREA_YOFFSET_1((i).y) - \
250 ED_AREA_YOFFSET_2((i).area_ysize))
252 // values for element content drawing areas
253 #define ED_AREA_1X1_LSETTINGS_XPOS(n) ED_LEVEL_SETTINGS_XPOS(n)
254 #define ED_AREA_1X1_LSETTINGS_YPOS(n) ED_LEVEL_SETTINGS_YPOS(n)
255 #define ED_AREA_1X1_LSETTINGS_XOFF (0)
256 #define ED_AREA_1X1_LSETTINGS_YOFF (0)
258 #define ED_AREA_1X1_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
259 #define ED_AREA_1X1_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
260 #define ED_AREA_1X1_SETTINGS_XOFF (0)
261 #define ED_AREA_1X1_SETTINGS_YOFF (0)
263 #define ED_AREA_3X3_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
264 #define ED_AREA_3X3_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
265 #define ED_AREA_3X3_SETTINGS_XOFF (0)
266 #define ED_AREA_3X3_SETTINGS_YOFF (0)
269 #define ED_AREA_ELEMENT_CONTENT_XOFF(n) (n)
270 #define ED_AREA_ELEMENT_CONTENT_YOFF(n) (n)
273 #define ED_XPOS_YAM 0
274 #define ED_YPOS_YAM 5
275 #define ED_AREA_YAMYAM_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_YAM)
276 #define ED_AREA_YAMYAM_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_YAM)
277 #define ED_AREA_YAMYAM_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
278 #define ED_AREA_YAMYAM_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
279 #define ED_AREA_YAMYAM_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_YAM) + \
281 #define ED_AREA_YAMYAM_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_YAM) + \
282 ED_SETTINGS_YOFF(n) + \
283 ED_AREA_YOFFSET_1(ED_YPOS_YAM) - \
284 ED_AREA_YOFFSET_2(3))
286 // magic ball content
287 #define ED_XPOS_BALL 0
288 #define ED_YPOS_BALL 6
289 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_BALL)
290 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_BALL)
291 #define ED_AREA_MAGIC_BALL_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
292 #define ED_AREA_MAGIC_BALL_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
293 #define ED_AREA_MAGIC_BALL_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_BALL) + \
295 #define ED_AREA_MAGIC_BALL_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_BALL) + \
296 ED_SETTINGS_YOFF(n) + \
297 ED_AREA_YOFFSET_1(ED_YPOS_BALL) - \
298 ED_AREA_YOFFSET_2(3))
300 // values for scrolling gadgets for drawing area
301 #define ED_SCROLLBUTTON_XSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].width)
302 #define ED_SCROLLBUTTON_YSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].height)
304 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
305 #define ED_SCROLL_UP_YPOS (0)
306 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
307 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
308 #define ED_SCROLL_LEFT_XPOS (0)
309 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
310 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
311 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
312 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
313 ED_SCROLLBUTTON_XSIZE)
314 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
315 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
316 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
317 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
318 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
319 ED_SCROLLBUTTON_YSIZE)
320 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
321 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
323 // values for scrolling gadgets for element list
324 #define ED_SCROLLBUTTON2_XSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
325 #define ED_SCROLLBUTTON2_YSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
327 #define ED_SCROLL2_UP_XPOS (ED_ELEMENTLIST_XPOS + \
328 ED_ELEMENTLIST_BUTTONS_HORIZ * \
329 ED_ELEMENTLIST_XSIZE)
330 #define ED_SCROLL2_UP_YPOS ED_ELEMENTLIST_YPOS
331 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
332 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
333 ED_ELEMENTLIST_BUTTONS_VERT * \
334 ED_ELEMENTLIST_YSIZE - \
335 ED_SCROLLBUTTON2_YSIZE)
336 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
337 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
338 ED_SCROLLBUTTON2_YSIZE)
339 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
340 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
341 ED_ELEMENTLIST_YSIZE - \
342 2 * ED_SCROLLBUTTON2_YSIZE)
344 // values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText()
345 #define INFOTEXT_FONT FONT_TEXT_2
346 #define INFOTEXT_XSIZE SXSIZE
347 #define INFOTEXT_YSIZE getFontHeight(INFOTEXT_FONT)
348 #define INFOTEXT_YSIZE_FULL (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE)
349 #define INFOTEXT_X (editor.settings.tooltip.x)
350 #define INFOTEXT_Y (editor.settings.tooltip.y)
351 #define INFOTEXT_XY_REDEFINED (INFOTEXT_X != -1 || INFOTEXT_Y != -1)
352 #define INFOTEXT_XPOS SX + (INFOTEXT_XY_REDEFINED ? INFOTEXT_X : 0)
353 #define INFOTEXT_YPOS SY + (INFOTEXT_XY_REDEFINED ? INFOTEXT_Y : \
354 SYSIZE - INFOTEXT_YSIZE)
357 // ----------------------------------------------------------------------------
358 // editor gadget definitions
359 // ----------------------------------------------------------------------------
365 // drawing toolbox buttons
367 GADGET_ID_SINGLE_ITEMS,
368 GADGET_ID_CONNECTED_ITEMS,
372 GADGET_ID_FILLED_BOX,
375 GADGET_ID_FLOOD_FILL,
378 GADGET_ID_WRAP_RIGHT,
379 GADGET_ID_RANDOM_PLACEMENT,
380 GADGET_ID_GRAB_BRUSH,
382 GADGET_ID_PICK_ELEMENT,
391 GADGET_ID_CUSTOM_COPY_FROM,
392 GADGET_ID_CUSTOM_COPY_TO,
393 GADGET_ID_CUSTOM_EXCHANGE,
394 GADGET_ID_CUSTOM_COPY,
395 GADGET_ID_CUSTOM_PASTE,
397 GADGET_ID_PROPERTIES,
398 GADGET_ID_ELEMENT_LEFT,
399 GADGET_ID_ELEMENT_MIDDLE,
400 GADGET_ID_ELEMENT_RIGHT,
403 // counter gadget identifiers
405 GADGET_ID_SELECT_LEVEL_DOWN,
406 GADGET_ID_SELECT_LEVEL_TEXT,
407 GADGET_ID_SELECT_LEVEL_UP,
408 GADGET_ID_LEVEL_XSIZE_DOWN,
409 GADGET_ID_LEVEL_XSIZE_TEXT,
410 GADGET_ID_LEVEL_XSIZE_UP,
411 GADGET_ID_LEVEL_YSIZE_DOWN,
412 GADGET_ID_LEVEL_YSIZE_TEXT,
413 GADGET_ID_LEVEL_YSIZE_UP,
414 GADGET_ID_LEVEL_RANDOM_DOWN,
415 GADGET_ID_LEVEL_RANDOM_TEXT,
416 GADGET_ID_LEVEL_RANDOM_UP,
417 GADGET_ID_LEVEL_GEMSLIMIT_DOWN,
418 GADGET_ID_LEVEL_GEMSLIMIT_TEXT,
419 GADGET_ID_LEVEL_GEMSLIMIT_UP,
420 GADGET_ID_LEVEL_TIMELIMIT_DOWN,
421 GADGET_ID_LEVEL_TIMELIMIT_TEXT,
422 GADGET_ID_LEVEL_TIMELIMIT_UP,
423 GADGET_ID_LEVEL_TIMESCORE_DOWN,
424 GADGET_ID_LEVEL_TIMESCORE_TEXT,
425 GADGET_ID_LEVEL_TIMESCORE_UP,
426 GADGET_ID_LEVEL_RANDOM_SEED_DOWN,
427 GADGET_ID_LEVEL_RANDOM_SEED_TEXT,
428 GADGET_ID_LEVEL_RANDOM_SEED_UP,
429 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN,
430 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT,
431 GADGET_ID_LEVELSET_NUM_LEVELS_UP,
432 GADGET_ID_ELEMENT_VALUE1_DOWN,
433 GADGET_ID_ELEMENT_VALUE1_TEXT,
434 GADGET_ID_ELEMENT_VALUE1_UP,
435 GADGET_ID_ELEMENT_VALUE2_DOWN,
436 GADGET_ID_ELEMENT_VALUE2_TEXT,
437 GADGET_ID_ELEMENT_VALUE2_UP,
438 GADGET_ID_ELEMENT_VALUE3_DOWN,
439 GADGET_ID_ELEMENT_VALUE3_TEXT,
440 GADGET_ID_ELEMENT_VALUE3_UP,
441 GADGET_ID_ELEMENT_VALUE4_DOWN,
442 GADGET_ID_ELEMENT_VALUE4_TEXT,
443 GADGET_ID_ELEMENT_VALUE4_UP,
444 GADGET_ID_YAMYAM_CONTENT_DOWN,
445 GADGET_ID_YAMYAM_CONTENT_TEXT,
446 GADGET_ID_YAMYAM_CONTENT_UP,
447 GADGET_ID_BALL_CONTENT_DOWN,
448 GADGET_ID_BALL_CONTENT_TEXT,
449 GADGET_ID_BALL_CONTENT_UP,
450 GADGET_ID_ANDROID_CONTENT_DOWN,
451 GADGET_ID_ANDROID_CONTENT_TEXT,
452 GADGET_ID_ANDROID_CONTENT_UP,
453 GADGET_ID_ENVELOPE_XSIZE_DOWN,
454 GADGET_ID_ENVELOPE_XSIZE_TEXT,
455 GADGET_ID_ENVELOPE_XSIZE_UP,
456 GADGET_ID_ENVELOPE_YSIZE_DOWN,
457 GADGET_ID_ENVELOPE_YSIZE_TEXT,
458 GADGET_ID_ENVELOPE_YSIZE_UP,
459 GADGET_ID_INVENTORY_SIZE_DOWN,
460 GADGET_ID_INVENTORY_SIZE_TEXT,
461 GADGET_ID_INVENTORY_SIZE_UP,
462 GADGET_ID_CUSTOM_SCORE_DOWN,
463 GADGET_ID_CUSTOM_SCORE_TEXT,
464 GADGET_ID_CUSTOM_SCORE_UP,
465 GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
466 GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
467 GADGET_ID_CUSTOM_GEMCOUNT_UP,
468 GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
469 GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
470 GADGET_ID_CUSTOM_VALUE_FIX_UP,
471 GADGET_ID_CUSTOM_VALUE_RND_DOWN,
472 GADGET_ID_CUSTOM_VALUE_RND_TEXT,
473 GADGET_ID_CUSTOM_VALUE_RND_UP,
474 GADGET_ID_PUSH_DELAY_FIX_DOWN,
475 GADGET_ID_PUSH_DELAY_FIX_TEXT,
476 GADGET_ID_PUSH_DELAY_FIX_UP,
477 GADGET_ID_PUSH_DELAY_RND_DOWN,
478 GADGET_ID_PUSH_DELAY_RND_TEXT,
479 GADGET_ID_PUSH_DELAY_RND_UP,
480 GADGET_ID_DROP_DELAY_FIX_DOWN,
481 GADGET_ID_DROP_DELAY_FIX_TEXT,
482 GADGET_ID_DROP_DELAY_FIX_UP,
483 GADGET_ID_DROP_DELAY_RND_DOWN,
484 GADGET_ID_DROP_DELAY_RND_TEXT,
485 GADGET_ID_DROP_DELAY_RND_UP,
486 GADGET_ID_MOVE_DELAY_FIX_DOWN,
487 GADGET_ID_MOVE_DELAY_FIX_TEXT,
488 GADGET_ID_MOVE_DELAY_FIX_UP,
489 GADGET_ID_MOVE_DELAY_RND_DOWN,
490 GADGET_ID_MOVE_DELAY_RND_TEXT,
491 GADGET_ID_MOVE_DELAY_RND_UP,
492 GADGET_ID_EXPLOSION_DELAY_DOWN,
493 GADGET_ID_EXPLOSION_DELAY_TEXT,
494 GADGET_ID_EXPLOSION_DELAY_UP,
495 GADGET_ID_IGNITION_DELAY_DOWN,
496 GADGET_ID_IGNITION_DELAY_TEXT,
497 GADGET_ID_IGNITION_DELAY_UP,
498 GADGET_ID_CHANGE_DELAY_FIX_DOWN,
499 GADGET_ID_CHANGE_DELAY_FIX_TEXT,
500 GADGET_ID_CHANGE_DELAY_FIX_UP,
501 GADGET_ID_CHANGE_DELAY_RND_DOWN,
502 GADGET_ID_CHANGE_DELAY_RND_TEXT,
503 GADGET_ID_CHANGE_DELAY_RND_UP,
504 GADGET_ID_CHANGE_CONT_RND_DOWN,
505 GADGET_ID_CHANGE_CONT_RND_TEXT,
506 GADGET_ID_CHANGE_CONT_RND_UP,
507 GADGET_ID_GROUP_CONTENT_DOWN,
508 GADGET_ID_GROUP_CONTENT_TEXT,
509 GADGET_ID_GROUP_CONTENT_UP,
511 // drawing area identifiers
513 GADGET_ID_DRAWING_LEVEL,
514 GADGET_ID_YAMYAM_CONTENT_0,
515 GADGET_ID_YAMYAM_CONTENT_1,
516 GADGET_ID_YAMYAM_CONTENT_2,
517 GADGET_ID_YAMYAM_CONTENT_3,
518 GADGET_ID_YAMYAM_CONTENT_4,
519 GADGET_ID_YAMYAM_CONTENT_5,
520 GADGET_ID_YAMYAM_CONTENT_6,
521 GADGET_ID_YAMYAM_CONTENT_7,
522 GADGET_ID_MAGIC_BALL_CONTENT_0,
523 GADGET_ID_MAGIC_BALL_CONTENT_1,
524 GADGET_ID_MAGIC_BALL_CONTENT_2,
525 GADGET_ID_MAGIC_BALL_CONTENT_3,
526 GADGET_ID_MAGIC_BALL_CONTENT_4,
527 GADGET_ID_MAGIC_BALL_CONTENT_5,
528 GADGET_ID_MAGIC_BALL_CONTENT_6,
529 GADGET_ID_MAGIC_BALL_CONTENT_7,
530 GADGET_ID_ANDROID_CONTENT,
531 GADGET_ID_AMOEBA_CONTENT,
532 GADGET_ID_START_ELEMENT,
533 GADGET_ID_ARTWORK_ELEMENT,
534 GADGET_ID_EXPLOSION_ELEMENT,
535 GADGET_ID_INVENTORY_CONTENT,
536 GADGET_ID_CUSTOM_GRAPHIC,
537 GADGET_ID_CUSTOM_CONTENT,
538 GADGET_ID_CUSTOM_MOVE_ENTER,
539 GADGET_ID_CUSTOM_MOVE_LEAVE,
540 GADGET_ID_CUSTOM_CHANGE_TARGET,
541 GADGET_ID_CUSTOM_CHANGE_CONTENT,
542 GADGET_ID_CUSTOM_CHANGE_TRIGGER,
543 GADGET_ID_CUSTOM_CHANGE_ACTION,
544 GADGET_ID_GROUP_CONTENT,
545 GADGET_ID_RANDOM_BACKGROUND,
547 // text input identifiers
549 GADGET_ID_LEVEL_NAME,
550 GADGET_ID_LEVEL_AUTHOR,
551 GADGET_ID_LEVELSET_NAME,
552 GADGET_ID_LEVELSET_AUTHOR,
553 GADGET_ID_ELEMENT_NAME,
555 // text area identifiers
557 GADGET_ID_ENVELOPE_INFO,
559 // selectbox identifiers
561 GADGET_ID_TIME_OR_STEPS,
562 GADGET_ID_GAME_ENGINE_TYPE,
563 GADGET_ID_LEVELSET_SAVE_MODE,
564 GADGET_ID_WIND_DIRECTION,
565 GADGET_ID_PLAYER_SPEED,
566 GADGET_ID_CUSTOM_WALK_TO_ACTION,
567 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
568 GADGET_ID_CUSTOM_DEADLINESS,
569 GADGET_ID_CUSTOM_MOVE_PATTERN,
570 GADGET_ID_CUSTOM_MOVE_DIRECTION,
571 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
572 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
573 GADGET_ID_CUSTOM_SMASH_TARGETS,
574 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
575 GADGET_ID_CUSTOM_ACCESS_TYPE,
576 GADGET_ID_CUSTOM_ACCESS_LAYER,
577 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
578 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
579 GADGET_ID_CHANGE_TIME_UNITS,
580 GADGET_ID_CHANGE_DIRECT_ACTION,
581 GADGET_ID_CHANGE_OTHER_ACTION,
582 GADGET_ID_CHANGE_SIDE,
583 GADGET_ID_CHANGE_PLAYER,
584 GADGET_ID_CHANGE_PAGE,
585 GADGET_ID_CHANGE_REPLACE_WHEN,
586 GADGET_ID_ACTION_TYPE,
587 GADGET_ID_ACTION_MODE,
588 GADGET_ID_ACTION_ARG,
589 GADGET_ID_SELECT_CHANGE_PAGE,
590 GADGET_ID_GROUP_CHOICE_MODE,
592 // textbutton identifiers
594 GADGET_ID_LEVELINFO_LEVEL,
595 GADGET_ID_LEVELINFO_LEVELSET,
596 GADGET_ID_LEVELINFO_EDITOR,
597 GADGET_ID_PROPERTIES_INFO,
598 GADGET_ID_PROPERTIES_CONFIG,
599 GADGET_ID_PROPERTIES_CONFIG_1,
600 GADGET_ID_PROPERTIES_CONFIG_2,
601 GADGET_ID_PROPERTIES_CHANGE,
602 GADGET_ID_SAVE_AS_TEMPLATE_1,
603 GADGET_ID_SAVE_AS_TEMPLATE_2,
604 GADGET_ID_SAVE_LEVELSET,
605 GADGET_ID_ADD_CHANGE_PAGE,
606 GADGET_ID_DEL_CHANGE_PAGE,
608 // graphicbutton identifiers
610 GADGET_ID_PREV_CHANGE_PAGE,
611 GADGET_ID_NEXT_CHANGE_PAGE,
612 GADGET_ID_COPY_CHANGE_PAGE,
613 GADGET_ID_PASTE_CHANGE_PAGE,
615 // gadgets for scrolling of drawing area
618 GADGET_ID_SCROLL_DOWN,
619 GADGET_ID_SCROLL_LEFT,
620 GADGET_ID_SCROLL_RIGHT,
621 GADGET_ID_SCROLL_HORIZONTAL,
622 GADGET_ID_SCROLL_VERTICAL,
624 // gadgets for scrolling element list
626 GADGET_ID_SCROLL_LIST_UP,
627 GADGET_ID_SCROLL_LIST_DOWN,
628 GADGET_ID_SCROLL_LIST_VERTICAL,
630 // checkbuttons/radiobuttons for level/element properties
632 GADGET_ID_AUTO_COUNT_GEMS,
633 GADGET_ID_USE_LEVELSET_ARTWORK,
634 GADGET_ID_COPY_LEVEL_TEMPLATE,
635 GADGET_ID_RANDOM_PERCENTAGE,
636 GADGET_ID_RANDOM_QUANTITY,
637 GADGET_ID_RANDOM_RESTRICTED,
638 GADGET_ID_STICK_ELEMENT,
639 GADGET_ID_EM_SLIPPERY_GEMS,
640 GADGET_ID_EM_EXPLODES_BY_FIRE,
641 GADGET_ID_USE_SPRING_BUG,
642 GADGET_ID_USE_TIME_ORB_BUG,
643 GADGET_ID_USE_LIFE_BUGS,
644 GADGET_ID_RANDOM_BALL_CONTENT,
645 GADGET_ID_INITIAL_BALL_ACTIVE,
646 GADGET_ID_GROW_INTO_DIGGABLE,
647 GADGET_ID_SB_FIELDS_NEEDED,
648 GADGET_ID_SB_OBJECTS_NEEDED,
649 GADGET_ID_AUTO_EXIT_SOKOBAN,
650 GADGET_ID_SOLVED_BY_ONE_PLAYER,
651 GADGET_ID_CONTINUOUS_SNAPPING,
652 GADGET_ID_BLOCK_SNAP_FIELD,
653 GADGET_ID_BLOCK_LAST_FIELD,
654 GADGET_ID_SP_BLOCK_LAST_FIELD,
655 GADGET_ID_INSTANT_RELOCATION,
656 GADGET_ID_SHIFTED_RELOCATION,
657 GADGET_ID_LAZY_RELOCATION,
658 GADGET_ID_USE_START_ELEMENT,
659 GADGET_ID_USE_ARTWORK_ELEMENT,
660 GADGET_ID_USE_EXPLOSION_ELEMENT,
661 GADGET_ID_INITIAL_GRAVITY,
662 GADGET_ID_USE_INITIAL_INVENTORY,
663 GADGET_ID_CAN_PASS_TO_WALKABLE,
664 GADGET_ID_CAN_FALL_INTO_ACID,
665 GADGET_ID_CAN_MOVE_INTO_ACID,
666 GADGET_ID_DONT_COLLIDE_WITH,
667 GADGET_ID_ENVELOPE_AUTOWRAP,
668 GADGET_ID_ENVELOPE_CENTERED,
669 GADGET_ID_MM_LASER_RED,
670 GADGET_ID_MM_LASER_GREEN,
671 GADGET_ID_MM_LASER_BLUE,
672 GADGET_ID_DF_LASER_RED,
673 GADGET_ID_DF_LASER_GREEN,
674 GADGET_ID_DF_LASER_BLUE,
675 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
676 GADGET_ID_CUSTOM_CAN_EXPLODE,
677 GADGET_ID_CUSTOM_EXPLODE_FIRE,
678 GADGET_ID_CUSTOM_EXPLODE_SMASH,
679 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
680 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
681 GADGET_ID_CUSTOM_DEADLY,
682 GADGET_ID_CUSTOM_CAN_MOVE,
683 GADGET_ID_CUSTOM_CAN_FALL,
684 GADGET_ID_CUSTOM_CAN_SMASH,
685 GADGET_ID_CUSTOM_SLIPPERY,
686 GADGET_ID_CUSTOM_ACCESSIBLE,
687 GADGET_ID_CUSTOM_GRAV_REACHABLE,
688 GADGET_ID_CUSTOM_USE_LAST_VALUE,
689 GADGET_ID_CUSTOM_USE_GRAPHIC,
690 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
691 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
692 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
693 GADGET_ID_CUSTOM_CAN_CHANGE,
694 GADGET_ID_CHANGE_USE_CONTENT,
695 GADGET_ID_CHANGE_USE_EXPLOSION,
696 GADGET_ID_CHANGE_ONLY_COMPLETE,
697 GADGET_ID_CHANGE_USE_RANDOM,
698 GADGET_ID_CHANGE_HAS_ACTION,
699 GADGET_ID_CHANGE_DELAY,
700 GADGET_ID_CHANGE_BY_DIRECT_ACT,
701 GADGET_ID_CHANGE_BY_OTHER_ACT,
703 NUM_STATIC_GADGET_IDS
706 // gadgets for buttons in element list (dynamic)
707 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
708 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
709 ED_NUM_ELEMENTLIST_BUTTONS - 1)
711 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
713 // radio button numbers
717 RADIO_NR_DRAWING_TOOLBOX,
718 RADIO_NR_RANDOM_ELEMENTS
721 // values for counter gadgets
724 ED_COUNTER_ID_SELECT_LEVEL,
725 ED_COUNTER_ID_LEVEL_XSIZE,
726 ED_COUNTER_ID_LEVEL_YSIZE,
727 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
728 ED_COUNTER_ID_LEVEL_TIMELIMIT,
729 ED_COUNTER_ID_LEVEL_TIMESCORE,
730 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
731 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
732 ED_COUNTER_ID_LEVEL_RANDOM,
733 ED_COUNTER_ID_ELEMENT_VALUE1,
734 ED_COUNTER_ID_ELEMENT_VALUE2,
735 ED_COUNTER_ID_ELEMENT_VALUE3,
736 ED_COUNTER_ID_ELEMENT_VALUE4,
737 ED_COUNTER_ID_YAMYAM_CONTENT,
738 ED_COUNTER_ID_BALL_CONTENT,
739 ED_COUNTER_ID_ANDROID_CONTENT,
740 ED_COUNTER_ID_ENVELOPE_XSIZE,
741 ED_COUNTER_ID_ENVELOPE_YSIZE,
742 ED_COUNTER_ID_INVENTORY_SIZE,
743 ED_COUNTER_ID_CUSTOM_SCORE,
744 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
745 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
746 ED_COUNTER_ID_CUSTOM_VALUE_RND,
747 ED_COUNTER_ID_PUSH_DELAY_FIX,
748 ED_COUNTER_ID_PUSH_DELAY_RND,
749 ED_COUNTER_ID_DROP_DELAY_FIX,
750 ED_COUNTER_ID_DROP_DELAY_RND,
751 ED_COUNTER_ID_MOVE_DELAY_FIX,
752 ED_COUNTER_ID_MOVE_DELAY_RND,
753 ED_COUNTER_ID_EXPLOSION_DELAY,
754 ED_COUNTER_ID_IGNITION_DELAY,
755 ED_COUNTER_ID_GROUP_CONTENT,
756 ED_COUNTER_ID_CHANGE_DELAY_FIX,
757 ED_COUNTER_ID_CHANGE_DELAY_RND,
758 ED_COUNTER_ID_CHANGE_CONT_RND,
760 ED_NUM_COUNTERBUTTONS
763 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
764 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
765 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
766 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
767 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
768 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
770 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
771 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
772 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
773 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
774 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
775 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
777 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
778 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
780 // values for scrollbutton gadgets
783 ED_SCROLLBUTTON_ID_AREA_UP,
784 ED_SCROLLBUTTON_ID_AREA_DOWN,
785 ED_SCROLLBUTTON_ID_AREA_LEFT,
786 ED_SCROLLBUTTON_ID_AREA_RIGHT,
787 ED_SCROLLBUTTON_ID_LIST_UP,
788 ED_SCROLLBUTTON_ID_LIST_DOWN,
793 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
794 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
796 // values for scrollbar gadgets
799 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
800 ED_SCROLLBAR_ID_AREA_VERTICAL,
801 ED_SCROLLBAR_ID_LIST_VERTICAL,
806 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
807 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
809 // values for text input gadgets
812 ED_TEXTINPUT_ID_LEVEL_NAME,
813 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
814 ED_TEXTINPUT_ID_LEVELSET_NAME,
815 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
816 ED_TEXTINPUT_ID_ELEMENT_NAME,
821 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
822 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
824 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
825 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
827 // values for text area gadgets
830 ED_TEXTAREA_ID_ENVELOPE_INFO,
835 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
836 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
838 // values for selectbox gadgets
841 ED_SELECTBOX_ID_TIME_OR_STEPS,
842 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
843 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
844 ED_SELECTBOX_ID_WIND_DIRECTION,
845 ED_SELECTBOX_ID_PLAYER_SPEED,
846 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
847 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
848 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
849 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
850 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
851 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
852 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
853 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
854 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
855 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
856 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
857 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
858 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
859 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
860 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
861 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
862 ED_SELECTBOX_ID_CHANGE_SIDE,
863 ED_SELECTBOX_ID_CHANGE_PLAYER,
864 ED_SELECTBOX_ID_CHANGE_PAGE,
865 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
866 ED_SELECTBOX_ID_ACTION_TYPE,
867 ED_SELECTBOX_ID_ACTION_MODE,
868 ED_SELECTBOX_ID_ACTION_ARG,
869 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
870 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
875 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
876 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
878 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
879 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
881 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
882 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
883 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
884 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
885 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
886 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
888 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
889 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
891 // values for textbutton gadgets
894 ED_TEXTBUTTON_ID_LEVELINFO_LEVEL,
895 ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET,
896 ED_TEXTBUTTON_ID_LEVELINFO_EDITOR,
897 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
898 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
899 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
900 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
901 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
902 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
903 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
904 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
905 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
906 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
911 #define ED_TAB_BUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
912 #define ED_TAB_BUTTON_ID_LEVELINFO_LAST ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
914 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
915 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
917 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
918 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
920 // values for graphicbutton gadgets
923 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
924 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
925 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
926 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
928 ED_NUM_GRAPHICBUTTONS
931 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
932 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
934 // values for checkbutton gadgets
937 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
938 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
939 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
940 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
941 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
942 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
943 ED_CHECKBUTTON_ID_STICK_ELEMENT,
944 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
945 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
946 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
947 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
948 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
949 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
950 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
951 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
952 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
953 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
954 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
955 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
956 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
957 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
958 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
959 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
960 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
961 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
962 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
963 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
964 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
965 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
966 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
967 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
968 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
969 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
970 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
971 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
972 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
973 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
974 ED_CHECKBUTTON_ID_MM_LASER_RED,
975 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
976 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
977 ED_CHECKBUTTON_ID_DF_LASER_RED,
978 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
979 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
980 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
981 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
982 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
983 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
984 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
985 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
986 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
987 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
988 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
989 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
990 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
991 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
992 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
993 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
994 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
995 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
996 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
997 ED_CHECKBUTTON_ID_CHANGE_DELAY,
998 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
999 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1000 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1001 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1002 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1003 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1004 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1009 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1010 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1012 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1013 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1015 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1016 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1018 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1019 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1020 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1021 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1022 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1023 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1025 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1026 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1028 // values for radiobutton gadgets
1031 ED_RADIOBUTTON_ID_PERCENTAGE,
1032 ED_RADIOBUTTON_ID_QUANTITY,
1037 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1038 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1040 // values for drawing area gadgets
1043 ED_DRAWING_ID_DRAWING_LEVEL,
1044 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1045 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1046 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1047 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1048 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1049 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1050 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1051 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1052 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1053 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1054 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1055 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1056 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1057 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1058 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1059 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1060 ED_DRAWING_ID_ANDROID_CONTENT,
1061 ED_DRAWING_ID_AMOEBA_CONTENT,
1062 ED_DRAWING_ID_START_ELEMENT,
1063 ED_DRAWING_ID_ARTWORK_ELEMENT,
1064 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1065 ED_DRAWING_ID_INVENTORY_CONTENT,
1066 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1067 ED_DRAWING_ID_CUSTOM_CONTENT,
1068 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1069 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1070 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1071 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1072 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1073 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1074 ED_DRAWING_ID_GROUP_CONTENT,
1075 ED_DRAWING_ID_RANDOM_BACKGROUND,
1077 ED_NUM_DRAWING_AREAS
1080 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1081 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1084 // ----------------------------------------------------------------------------
1085 // some internally used definitions
1086 // ----------------------------------------------------------------------------
1088 // values for CopyLevelToUndoBuffer()
1089 #define UNDO_IMMEDIATE 0
1090 #define UNDO_ACCUMULATE 1
1092 // values for scrollbars
1093 #define ED_SCROLL_NO 0
1094 #define ED_SCROLL_LEFT 1
1095 #define ED_SCROLL_RIGHT 2
1096 #define ED_SCROLL_UP 4
1097 #define ED_SCROLL_DOWN 8
1099 // screens in the level editor
1100 #define ED_MODE_DRAWING 0
1101 #define ED_MODE_INFO 1
1102 #define ED_MODE_PROPERTIES 2
1103 #define ED_MODE_PALETTE 3
1105 // sub-screens in the global settings section
1106 #define ED_MODE_LEVELINFO_LEVEL ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
1107 #define ED_MODE_LEVELINFO_LEVELSET ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET
1108 #define ED_MODE_LEVELINFO_EDITOR ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
1110 // sub-screens in the element properties section
1111 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1112 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1113 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1114 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1115 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1117 // how many steps can be cancelled
1118 #define NUM_UNDO_STEPS (64 + 1)
1120 // values for elements with score for certain actions
1122 #define MAX_SCORE 999
1124 // values for elements with count for collecting
1125 #define MIN_COLLECT_COUNT 0
1126 #define MAX_COLLECT_COUNT 999
1128 // values for random placement
1129 #define RANDOM_USE_PERCENTAGE 0
1130 #define RANDOM_USE_QUANTITY 1
1132 // values for level set save mode
1133 #define LEVELSET_SAVE_MODE_UPDATE 0
1134 #define LEVELSET_SAVE_MODE_CREATE 1
1136 // default value for element tile size in drawing area
1137 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1138 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1141 // ----------------------------------------------------------------------------
1142 // some internally used data structure definitions
1143 // ----------------------------------------------------------------------------
1149 struct XYTileSize *pos;
1153 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1155 // note: some additional characters are already reserved for "cheat mode"
1156 // shortcuts (":XYZ" style) -- for details, see "events.c"
1158 // ---------- toolbox control buttons ---------------------------------------
1161 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1162 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1163 "draw single items", 's'
1166 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1167 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1168 "draw connected items", 'd'
1171 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1172 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1176 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1177 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1181 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1182 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1183 "draw outline rectangles", 'r'
1186 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1187 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1188 "draw filled rectangles", 'R'
1191 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1192 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1193 "wrap (rotate) level up", 0
1196 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1197 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1198 "enter text elements", 't'
1201 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1202 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1206 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1207 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1208 "wrap (rotate) level left", 0
1211 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1212 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1213 "zoom level tile size", '+'
1216 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1217 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1218 "wrap (rotate) level right", 0
1221 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1222 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1223 "random element placement", 0
1226 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1227 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1231 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1232 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1233 "wrap (rotate) level down", 0
1236 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1237 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1238 "pick drawing element", ','
1241 // ---------- level control buttons -----------------------------------------
1244 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1245 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1246 "undo/redo last operation", 'u'
1249 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_INFO,
1250 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1251 "properties of level", 'I'
1254 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1255 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1259 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1260 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1264 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1265 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1269 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1270 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1271 "exit level editor", 'E'
1274 // ---------- CE and GE control buttons -------------------------------------
1277 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1278 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1279 "copy settings from other element", 0
1282 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1283 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1284 "copy settings to other element", 0
1287 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1288 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1289 "exchange element with other element", 0
1292 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1293 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1294 "copy settings from this element", 0
1297 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1298 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1299 "paste settings to this element", 0
1302 // ---------- palette control buttons ---------------------------------------
1305 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1306 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1307 "properties of drawing element", 'p'
1310 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1311 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1312 "properties of drawing element 1", '1'
1315 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1316 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1317 "properties of drawing element 2", '2'
1320 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1321 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1322 "properties of drawing element 3", '3'
1325 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1326 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1327 "show list of elements", 'e'
1331 static int random_placement_value = 10;
1332 static int random_placement_method = RANDOM_USE_QUANTITY;
1333 static int random_placement_background_element = EL_SAND;
1334 static boolean random_placement_background_restricted = FALSE;
1335 static boolean stick_element_properties_window = FALSE;
1336 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1337 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1338 static struct ElementChangeInfo custom_element_change;
1339 static struct ElementGroupInfo group_element_info;
1340 static struct ElementInfo custom_element;
1342 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1343 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1344 static int levelset_num_levels = 100;
1345 static boolean levelset_use_levelset_artwork = FALSE;
1346 static boolean levelset_copy_level_template = FALSE;
1347 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1352 int min_value, max_value;
1353 int gadget_id_down, gadget_id_up;
1355 int gadget_id_align;
1357 char *text_above, *text_left, *text_right;
1358 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1360 // ---------- current level number ------------------------------------------
1363 -1, -1, // these values are not constant, but can change at runtime
1365 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1366 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1371 // ---------- level and editor settings -------------------------------------
1374 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1375 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1376 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1377 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1379 "playfield size:", NULL, "width",
1382 -1, ED_LEVEL_SETTINGS_YPOS(4),
1383 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1384 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1385 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1387 NULL, " ", "height",
1390 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1392 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1393 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1395 NULL, "number of gems to collect:", NULL
1398 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1400 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1401 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1403 "time or step limit to solve level:", NULL, NULL
1406 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1408 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1409 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1410 &level.score[SC_TIME_BONUS],
1411 "score for each second/step left:", NULL, NULL
1414 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
1416 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1417 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1419 NULL, "random seed:", "(0 => random)"
1422 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1424 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1425 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1426 &levelset_num_levels,
1427 "number of levels:", NULL, NULL,
1430 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1432 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1433 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1434 &random_placement_value,
1435 "random element placement:", NULL, "in"
1438 // ---------- element settings: configure (various elements) ----------------
1441 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1442 MIN_SCORE, MAX_SCORE,
1443 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1444 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1445 NULL, // will be set when used
1449 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1450 MIN_SCORE, MAX_SCORE,
1451 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1452 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1453 NULL, // will be set when used
1457 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1458 MIN_SCORE, MAX_SCORE,
1459 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1460 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1461 NULL, // will be set when used
1465 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1466 MIN_SCORE, MAX_SCORE,
1467 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1468 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1469 NULL, // will be set when used
1473 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1474 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1475 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1476 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1477 &level.num_yamyam_contents,
1478 NULL, NULL, "number of content areas"
1481 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1482 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1483 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1484 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1485 &level.num_ball_contents,
1486 NULL, NULL, "number of content areas"
1489 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1490 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1491 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1492 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1493 &level.num_android_clone_elements,
1494 NULL, NULL, "number of clonable elements"
1497 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1498 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1499 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1500 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1501 NULL, // will be set when used
1502 NULL, NULL, "width",
1505 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1506 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1507 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1508 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1509 NULL, // will be set when used
1510 NULL, " ", "height",
1513 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1514 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1515 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1516 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1517 &level.initial_inventory_size[0],
1518 NULL, NULL, "number of inventory elements"
1521 // ---------- element settings: configure 1 (custom elements) ---------------
1524 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1525 MIN_SCORE, MAX_SCORE,
1526 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1527 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1528 &custom_element.collect_score_initial,
1529 NULL, "CE score", " "
1532 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1533 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1534 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1535 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1536 &custom_element.collect_count_initial,
1537 NULL, "CE count", NULL
1540 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1542 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1543 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1544 &custom_element.ce_value_fixed_initial,
1545 NULL, "CE value", NULL
1548 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1550 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1551 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1552 &custom_element.ce_value_random_initial,
1553 NULL, "+random", NULL
1556 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1558 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1559 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1560 &custom_element.push_delay_fixed,
1561 NULL, "push delay", NULL
1564 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1566 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1567 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1568 &custom_element.push_delay_random,
1569 NULL, "+random", NULL
1572 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1574 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1575 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1576 &custom_element.drop_delay_fixed,
1577 NULL, "drop delay", NULL
1580 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1582 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1583 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1584 &custom_element.drop_delay_random,
1585 NULL, "+random", NULL
1588 // ---------- element settings: configure 2 (custom elements) ---------------
1591 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1593 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1594 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1595 &custom_element.move_delay_fixed,
1596 NULL, "move delay", NULL
1599 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1601 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1602 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1603 &custom_element.move_delay_random,
1604 NULL, "+random", NULL
1607 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
1609 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1610 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1611 &custom_element.explosion_delay,
1612 NULL, "explosion delay", NULL
1615 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1617 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1618 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1619 &custom_element.ignition_delay,
1620 NULL, "ignition delay", "(by fire)"
1623 // ---------- element settings: configure (group elements) ------------------
1626 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1627 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1628 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1629 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1630 &group_element_info.num_elements,
1631 NULL, NULL, "number of elements in group"
1634 // ---------- element settings: advanced (custom elements) ------------------
1637 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1639 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1640 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1641 &custom_element_change.delay_fixed,
1642 NULL, "CE delay", NULL,
1645 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1647 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1648 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1649 &custom_element_change.delay_random,
1650 NULL, "+random", NULL
1653 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1655 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1656 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1657 &custom_element_change.random_percentage,
1658 NULL, "use random replace:", "%"
1668 char *text_above, *infotext;
1669 } textinput_info[ED_NUM_TEXTINPUT] =
1672 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1673 GADGET_ID_LEVEL_NAME,
1676 "Title:", "Title for this level"
1679 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1680 GADGET_ID_LEVEL_AUTHOR,
1681 MAX_LEVEL_AUTHOR_LEN,
1683 "Author:", "Author for this level"
1686 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1687 GADGET_ID_LEVELSET_NAME,
1690 "Title:", "Title for this or new level set"
1693 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1694 GADGET_ID_LEVELSET_AUTHOR,
1695 MAX_LEVEL_AUTHOR_LEN,
1697 "Author:", "Author for this or new level set"
1700 -1, -1, // these values are not constant, but can change at runtime
1701 GADGET_ID_ELEMENT_NAME,
1702 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1703 custom_element.description,
1704 NULL, "Element name"
1714 char *text_above, *infotext;
1715 } textarea_info[ED_NUM_TEXTAREAS] =
1718 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1719 GADGET_ID_ENVELOPE_INFO,
1720 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1722 "Envelope Content:", "Envelope Content"
1726 static struct ValueTextInfo options_time_or_steps[] =
1734 static struct ValueTextInfo options_game_engine_type[] =
1736 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1737 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1738 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1739 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1744 static struct ValueTextInfo options_levelset_save_mode[] =
1746 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1747 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1752 static struct ValueTextInfo options_wind_direction[] =
1754 { MV_START_NONE, "none" },
1755 { MV_START_LEFT, "left" },
1756 { MV_START_RIGHT, "right" },
1757 { MV_START_UP, "up" },
1758 { MV_START_DOWN, "down" },
1763 static struct ValueTextInfo options_player_speed[] =
1770 { 16, "very fast" },
1771 { 32, "ultrafast" },
1776 static struct ValueTextInfo options_access_type[] =
1778 { EP_WALKABLE, "walkable" },
1779 { EP_PASSABLE, "passable" },
1784 static struct ValueTextInfo options_access_layer[] =
1786 { EP_ACCESSIBLE_OVER, "over" },
1787 { EP_ACCESSIBLE_INSIDE, "inside" },
1788 { EP_ACCESSIBLE_UNDER, "under" },
1793 static struct ValueTextInfo options_access_protected[] =
1795 { 0, "unprotected" },
1801 static struct ValueTextInfo options_access_direction[] =
1803 { MV_NO_DIRECTION, "no direction" },
1804 { MV_LEFT, "left" },
1805 { MV_RIGHT, "right" },
1807 { MV_DOWN, "down" },
1808 { MV_LEFT | MV_UP, "left + up" },
1809 { MV_LEFT | MV_DOWN, "left + down" },
1810 { MV_RIGHT | MV_UP, "right + up" },
1811 { MV_RIGHT | MV_DOWN, "right + down" },
1812 { MV_HORIZONTAL, "horizontal" },
1813 { MV_VERTICAL, "vertical" },
1814 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1815 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1816 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1817 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1818 { MV_ALL_DIRECTIONS, "all directions" },
1823 static struct ValueTextInfo options_walk_to_action[] =
1825 { EP_DIGGABLE, "diggable" },
1826 { EP_COLLECTIBLE_ONLY, "collectible" },
1827 { EP_DROPPABLE, "collectible & droppable" },
1828 { EP_THROWABLE, "collectible & throwable" },
1829 { EP_PUSHABLE, "pushable" },
1834 static struct ValueTextInfo options_move_pattern[] =
1836 { MV_LEFT, "left" },
1837 { MV_RIGHT, "right" },
1839 { MV_DOWN, "down" },
1840 { MV_HORIZONTAL, "horizontal" },
1841 { MV_VERTICAL, "vertical" },
1842 { MV_ALL_DIRECTIONS, "all directions" },
1843 { MV_WIND_DIRECTION, "wind direction" },
1844 { MV_TOWARDS_PLAYER, "towards player" },
1845 { MV_AWAY_FROM_PLAYER, "away from player" },
1846 { MV_ALONG_LEFT_SIDE, "along left side" },
1847 { MV_ALONG_RIGHT_SIDE, "along right side" },
1848 { MV_TURNING_LEFT, "turning left" },
1849 { MV_TURNING_RIGHT, "turning right" },
1850 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1851 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1852 { MV_TURNING_RANDOM, "turning random" },
1853 { MV_MAZE_RUNNER, "maze runner style" },
1854 { MV_MAZE_HUNTER, "maze hunter style" },
1855 { MV_WHEN_PUSHED, "when pushed" },
1856 { MV_WHEN_DROPPED, "when dropped/thrown" },
1861 static struct ValueTextInfo options_move_direction[] =
1863 { MV_START_AUTOMATIC, "automatic" },
1864 { MV_START_LEFT, "left" },
1865 { MV_START_RIGHT, "right" },
1866 { MV_START_UP, "up" },
1867 { MV_START_DOWN, "down" },
1868 { MV_START_RANDOM, "random" },
1869 { MV_START_PREVIOUS, "previous" },
1874 static struct ValueTextInfo options_move_stepsize[] =
1876 { 0, "not moving" },
1881 { 16, "very fast" },
1882 { 32, "even faster" },
1887 static struct ValueTextInfo options_move_leave_type[] =
1889 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1890 { LEAVE_TYPE_LIMITED, "change it to" },
1895 static struct ValueTextInfo options_smash_targets[] =
1897 { EP_CAN_SMASH_PLAYER, "player" },
1899 { EP_CAN_SMASH_ENEMIES, "enemies" },
1901 { EP_CAN_SMASH_EVERYTHING, "everything" },
1906 static struct ValueTextInfo options_slippery_type[] =
1908 { SLIPPERY_ANY_RANDOM, "random" },
1909 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1910 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1911 { SLIPPERY_ONLY_LEFT, "only left" },
1912 { SLIPPERY_ONLY_RIGHT, "only right" },
1917 static struct ValueTextInfo options_deadliness[] =
1919 { EP_DONT_RUN_INTO, "running into" },
1920 { EP_DONT_COLLIDE_WITH, "colliding with" },
1921 { EP_DONT_GET_HIT_BY, "getting hit by" },
1922 { EP_DONT_TOUCH, "touching" },
1927 static struct ValueTextInfo options_explosion_type[] =
1929 { EXPLODES_3X3, "3x3" },
1930 { EXPLODES_CROSS, "3+3" },
1931 { EXPLODES_1X1, "1x1" },
1936 static struct ValueTextInfo options_time_units[] =
1939 { FRAMES_PER_SECOND, "seconds" },
1944 static struct ValueTextInfo options_change_direct_action[] =
1946 { CE_TOUCHED_BY_PLAYER, "touched by player" },
1947 { CE_PRESSED_BY_PLAYER, "pressed by player" },
1948 { CE_SWITCHED_BY_PLAYER, "switched by player" },
1949 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
1950 { CE_PUSHED_BY_PLAYER, "pushed by player" },
1951 { CE_ENTERED_BY_PLAYER, "entered by player" },
1952 { CE_LEFT_BY_PLAYER, "left by player" },
1953 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
1954 { CE_SWITCHED, "switched" },
1955 { CE_HITTING_SOMETHING, "hitting something" },
1956 { CE_HIT_BY_SOMETHING, "hit by something" },
1958 { CE_BLOCKED, "blocked" },
1960 { CE_IMPACT, "impact (on something)" },
1961 { CE_SMASHED, "smashed (from above)" },
1963 { CE_VALUE_CHANGES, "CE value changes" },
1964 { CE_SCORE_CHANGES, "CE score changes" },
1966 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
1967 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
1968 { CE_UNDEFINED, " " },
1969 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
1970 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
1971 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
1976 static struct ValueTextInfo options_change_other_action[] =
1978 { CE_PLAYER_TOUCHES_X, "player touches" },
1979 { CE_PLAYER_PRESSES_X, "player presses" },
1980 { CE_PLAYER_SWITCHES_X, "player switches" },
1981 { CE_PLAYER_SNAPS_X, "player snaps" },
1982 { CE_PLAYER_PUSHES_X, "player pushes" },
1983 { CE_PLAYER_ENTERS_X, "player enters" },
1984 { CE_PLAYER_LEAVES_X, "player leaves" },
1985 { CE_PLAYER_DIGS_X, "player digs" },
1986 { CE_PLAYER_COLLECTS_X, "player collects" },
1987 { CE_PLAYER_DROPS_X, "player drops/throws" },
1988 { CE_TOUCHING_X, "touching" },
1989 { CE_HITTING_X, "hitting" },
1990 { CE_DIGGING_X, "digging" },
1991 { CE_HIT_BY_X, "hit by" },
1992 { CE_SWITCH_OF_X, "switch of" },
1993 { CE_CHANGE_OF_X, "change by page of" },
1994 { CE_EXPLOSION_OF_X, "explosion of" },
1995 { CE_MOVE_OF_X, "move of" },
1996 { CE_CREATION_OF_X, "creation of" },
1997 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
1998 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
1999 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2000 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2001 { CE_UNDEFINED, " " },
2002 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2003 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2004 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2009 static struct ValueTextInfo options_change_trigger_side[] =
2011 { CH_SIDE_LEFT, "left" },
2012 { CH_SIDE_RIGHT, "right" },
2013 { CH_SIDE_TOP, "top" },
2014 { CH_SIDE_BOTTOM, "bottom" },
2015 { CH_SIDE_LEFT_RIGHT, "left/right" },
2016 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2017 { CH_SIDE_ANY, "any" },
2022 static struct ValueTextInfo options_change_trigger_player[] =
2024 { CH_PLAYER_1, "1" },
2025 { CH_PLAYER_2, "2" },
2026 { CH_PLAYER_3, "3" },
2027 { CH_PLAYER_4, "4" },
2028 { CH_PLAYER_ANY, "any" },
2033 static struct ValueTextInfo options_change_trigger_page[] =
2045 { (1 << 10), "11" },
2046 { (1 << 11), "12" },
2047 { (1 << 12), "13" },
2048 { (1 << 13), "14" },
2049 { (1 << 14), "15" },
2050 { (1 << 15), "16" },
2051 { (1 << 16), "17" },
2052 { (1 << 17), "18" },
2053 { (1 << 18), "19" },
2054 { (1 << 19), "20" },
2055 { (1 << 20), "21" },
2056 { (1 << 21), "22" },
2057 { (1 << 22), "23" },
2058 { (1 << 23), "24" },
2059 { (1 << 24), "25" },
2060 { (1 << 25), "26" },
2061 { (1 << 26), "27" },
2062 { (1 << 27), "28" },
2063 { (1 << 28), "29" },
2064 { (1 << 29), "30" },
2065 { (1 << 30), "31" },
2066 { (1 << 31), "32" },
2067 { CH_PAGE_ANY, "any" },
2072 static struct ValueTextInfo options_change_replace_when[] =
2074 { CP_WHEN_EMPTY, "empty" },
2075 { CP_WHEN_WALKABLE, "walkable" },
2076 { CP_WHEN_DIGGABLE, "diggable" },
2077 { CP_WHEN_COLLECTIBLE, "collectible" },
2078 { CP_WHEN_REMOVABLE, "removable" },
2079 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2084 static struct ValueTextInfo options_action_type[] =
2086 { CA_NO_ACTION, "no action" },
2087 { CA_UNDEFINED, " " },
2088 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2089 { CA_RESTART_LEVEL, "restart level" },
2090 { CA_SHOW_ENVELOPE, "show envelope" },
2091 { CA_SET_LEVEL_TIME, "set time" },
2092 { CA_SET_LEVEL_SCORE, "set score" },
2093 { CA_SET_LEVEL_GEMS, "set gems" },
2094 { CA_SET_LEVEL_WIND, "set wind dir." },
2095 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2096 { CA_UNDEFINED, " " },
2097 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2098 { CA_MOVE_PLAYER, "move player" },
2099 { CA_MOVE_PLAYER_NEW, "move player new" },
2100 { CA_EXIT_PLAYER, "exit player" },
2101 { CA_KILL_PLAYER, "kill player" },
2102 { CA_SET_PLAYER_KEYS, "set keys" },
2103 { CA_SET_PLAYER_SPEED, "set speed" },
2104 { CA_SET_PLAYER_SHIELD, "set shield" },
2105 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2106 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2107 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2108 { CA_UNDEFINED, " " },
2109 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2110 { CA_SET_CE_VALUE, "set CE value" },
2111 { CA_SET_CE_SCORE, "set CE score" },
2112 { CA_SET_CE_ARTWORK, "set CE artwork" },
2113 { CA_UNDEFINED, " " },
2114 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2115 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2120 static struct ValueTextInfo options_action_mode_none[] =
2122 { CA_MODE_UNDEFINED, " " },
2127 static struct ValueTextInfo options_action_mode_assign[] =
2129 { CA_MODE_SET, "=" },
2134 static struct ValueTextInfo options_action_mode_add_remove[] =
2136 { CA_MODE_ADD, "+" },
2137 { CA_MODE_SUBTRACT, "-" },
2142 static struct ValueTextInfo options_action_mode_calculate[] =
2144 { CA_MODE_SET, "=" },
2145 { CA_MODE_ADD, "+" },
2146 { CA_MODE_SUBTRACT, "-" },
2147 { CA_MODE_MULTIPLY, "*" },
2148 { CA_MODE_DIVIDE, "/" },
2149 { CA_MODE_MODULO, "%" },
2154 static struct ValueTextInfo options_action_arg_none[] =
2156 { CA_ARG_UNDEFINED, " " },
2161 static struct ValueTextInfo options_action_arg_player[] =
2163 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2164 { CA_ARG_PLAYER_1, "1" },
2165 { CA_ARG_PLAYER_2, "2" },
2166 { CA_ARG_PLAYER_3, "3" },
2167 { CA_ARG_PLAYER_4, "4" },
2168 { CA_ARG_PLAYER_ANY, "any" },
2169 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2170 { CA_ARG_PLAYER_ACTION, "action ->" },
2175 static struct ValueTextInfo options_action_arg_number[] =
2177 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2184 { CA_ARG_10, "10" },
2185 { CA_ARG_100, "100" },
2186 { CA_ARG_1000, "1000" },
2187 { CA_ARG_UNDEFINED, " " },
2188 { CA_ARG_NUMBER_MIN, "min" },
2189 { CA_ARG_NUMBER_MAX, "max" },
2190 { CA_ARG_UNDEFINED, " " },
2191 { CA_ARG_NUMBER_RESET, "reset" },
2192 { CA_ARG_UNDEFINED, " " },
2193 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2194 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2195 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2196 { CA_ARG_UNDEFINED, " " },
2197 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2198 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2199 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2200 { CA_ARG_UNDEFINED, " " },
2201 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2202 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2203 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2204 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2205 { CA_ARG_UNDEFINED, " " },
2206 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2207 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2208 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2209 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2214 static struct ValueTextInfo options_action_arg_value[] =
2216 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2223 { CA_ARG_10, "10" },
2224 { CA_ARG_100, "100" },
2225 { CA_ARG_1000, "1000" },
2226 { CA_ARG_UNDEFINED, " " },
2227 { CA_ARG_NUMBER_MIN, "min" },
2228 { CA_ARG_NUMBER_MAX, "max" },
2229 { CA_ARG_UNDEFINED, " " },
2230 { CA_ARG_NUMBER_RESET, "reset" },
2231 { CA_ARG_UNDEFINED, " " },
2232 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2233 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2234 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2235 { CA_ARG_UNDEFINED, " " },
2236 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2237 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2238 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2239 { CA_ARG_UNDEFINED, " " },
2240 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2241 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2242 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2243 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2244 { CA_ARG_UNDEFINED, " " },
2245 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2246 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2247 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2248 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2249 { CA_ARG_UNDEFINED, " " },
2250 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2251 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2252 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2253 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2258 static struct ValueTextInfo options_action_arg_envelope[] =
2260 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2265 { CA_ARG_UNDEFINED, " " },
2266 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2267 { CA_ARG_ELEMENT_TARGET, "target" },
2268 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2269 { CA_ARG_ELEMENT_ACTION, "action ->" },
2274 static struct ValueTextInfo options_action_arg_key[] =
2276 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2285 { CA_ARG_UNDEFINED, " " },
2286 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2287 { CA_ARG_ELEMENT_TARGET, "target" },
2288 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2289 { CA_ARG_ELEMENT_ACTION, "action ->" },
2294 static struct ValueTextInfo options_action_arg_speed[] =
2296 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2297 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2298 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2299 { CA_ARG_SPEED_SLOW, "slow" },
2300 { CA_ARG_SPEED_NORMAL, "normal" },
2301 { CA_ARG_SPEED_FAST, "fast" },
2302 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2303 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2304 { CA_ARG_UNDEFINED, " " },
2305 { CA_ARG_SPEED_SLOWER, "slower" },
2306 { CA_ARG_SPEED_FASTER, "faster" },
2307 { CA_ARG_UNDEFINED, " " },
2308 { CA_ARG_SPEED_RESET, "reset" },
2313 static struct ValueTextInfo options_action_arg_shield[] =
2315 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2316 { CA_ARG_SHIELD_OFF, "off" },
2317 { CA_ARG_SHIELD_NORMAL, "normal" },
2318 { CA_ARG_SHIELD_DEADLY, "deadly" },
2323 static struct ValueTextInfo options_action_arg_artwork[] =
2325 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2326 { CA_ARG_ELEMENT_TARGET, "target" },
2327 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2328 { CA_ARG_ELEMENT_ACTION, "action ->" },
2329 { CA_ARG_UNDEFINED, " " },
2330 { CA_ARG_ELEMENT_RESET, "reset" },
2335 static struct ValueTextInfo options_action_arg_gravity[] =
2337 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2338 { CA_ARG_GRAVITY_ON, "on" },
2339 { CA_ARG_GRAVITY_OFF, "off" },
2340 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2345 static struct ValueTextInfo options_action_arg_direction[] =
2347 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2348 { CA_ARG_DIRECTION_NONE, "none" },
2349 { CA_ARG_DIRECTION_LEFT, "left" },
2350 { CA_ARG_DIRECTION_RIGHT, "right" },
2351 { CA_ARG_DIRECTION_UP, "up" },
2352 { CA_ARG_DIRECTION_DOWN, "down" },
2353 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2354 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2359 static struct ValueTextInfo options_action_arg_scan_mode[] =
2361 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2362 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2363 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2368 static struct ValueTextInfo options_action_arg_inventory[] =
2370 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2371 { CA_ARG_ELEMENT_TARGET, "+ target" },
2372 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2373 { CA_ARG_ELEMENT_ACTION, "+ action" },
2374 { CA_ARG_UNDEFINED, " " },
2375 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2376 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2377 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2378 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2379 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2380 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2381 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2382 { CA_ARG_UNDEFINED, " " },
2383 { CA_ARG_INVENTORY_RESET, "reset" },
2388 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2389 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2394 static struct ValueTextInfo options_group_choice_mode[] =
2396 { ANIM_RANDOM, "random" },
2397 { ANIM_LOOP, "loop" },
2398 { ANIM_LINEAR, "linear" },
2399 { ANIM_PINGPONG, "pingpong" },
2400 { ANIM_PINGPONG2, "pingpong 2" },
2405 static struct ValueTextInfo *action_arg_modes[] =
2407 options_action_mode_none,
2408 options_action_mode_assign,
2409 options_action_mode_add_remove,
2410 options_action_mode_calculate,
2417 struct ValueTextInfo *options;
2419 action_arg_options[] =
2421 { CA_NO_ACTION, 0, options_action_arg_none, },
2422 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2423 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2424 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2425 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2426 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2427 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2428 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2429 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2430 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2431 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2432 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2433 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2434 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2435 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2436 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2437 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2438 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2439 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2440 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2441 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2442 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2451 int gadget_id_align;
2452 int size; // char size of selectbox or '-1' (dynamically determined)
2453 struct ValueTextInfo *options;
2455 char *text_above, *text_left, *text_right, *infotext;
2456 } selectbox_info[ED_NUM_SELECTBOX] =
2458 // ---------- level and editor settings -------------------------------------
2461 -1, ED_LEVEL_SETTINGS_YPOS(8),
2462 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2464 options_time_or_steps,
2465 &level.use_step_counter,
2466 NULL, NULL, "(0 => no limit)", "time or step limit"
2469 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
2470 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2472 options_game_engine_type,
2473 &level.game_engine_type,
2474 NULL, "game engine:", NULL, "game engine"
2477 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2478 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2480 options_levelset_save_mode,
2481 &levelset_save_mode,
2482 "Action:", NULL, NULL, "action when saving level set"
2485 // ---------- element settings: configure (several elements) ----------------
2488 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2489 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2491 options_wind_direction,
2492 &level.wind_direction_initial,
2493 NULL, "initial wind direction:", NULL, "initial wind direction"
2496 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2497 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2499 options_player_speed,
2500 &level.initial_player_stepsize[0],
2501 NULL, "initial player speed:", NULL, "initial player speed"
2504 // ---------- element settings: configure 1 (custom elements) ---------------
2507 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2508 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2510 options_access_type,
2511 &custom_element.access_type,
2512 NULL, NULL, NULL, "type of access to this field"
2515 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2516 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2518 options_access_layer,
2519 &custom_element.access_layer,
2520 NULL, NULL, NULL, "layer of access for this field"
2523 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2524 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2526 options_access_protected,
2527 &custom_element.access_protected,
2528 NULL, NULL, NULL, "protected access for this field"
2531 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2532 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2534 options_access_direction,
2535 &custom_element.access_direction,
2536 NULL, "from", NULL, "access direction for this field"
2539 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2540 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2542 options_walk_to_action,
2543 &custom_element.walk_to_action,
2544 NULL, NULL, NULL, "diggable/collectible/pushable"
2547 // ---------- element settings: configure 2 (custom elements) ---------------
2550 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2551 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2553 options_move_pattern,
2554 &custom_element.move_pattern,
2555 NULL, "can move", NULL, "element move pattern"
2558 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2559 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2561 options_move_direction,
2562 &custom_element.move_direction_initial,
2563 NULL, "starts moving", NULL, "initial element move direction"
2566 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2567 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2569 options_move_stepsize,
2570 &custom_element.move_stepsize,
2571 NULL, "move/fall speed", NULL, "speed of element movement"
2574 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2575 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2577 options_move_leave_type,
2578 &custom_element.move_leave_type,
2579 // left text with leading spaces to place gadget next to "can dig" gadget
2580 // (needed because drawing area gadgets created after selectbox gadgets)
2581 // NULL, "can dig: can", ":", "leave behind or change element"
2582 NULL, " can", ":", "leave behind or change element"
2585 -1, ED_ELEMENT_SETTINGS_YPOS(7),
2586 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2588 options_smash_targets,
2589 &custom_element.smash_targets,
2590 NULL, "can smash", NULL, "elements that can be smashed"
2593 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
2594 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2596 options_slippery_type,
2597 &custom_element.slippery_type,
2598 NULL, "slippery", NULL, "where other elements fall down"
2601 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2602 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2605 &custom_element.deadliness,
2606 NULL, "deadly when", NULL, "deadliness of element"
2609 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2610 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2612 options_explosion_type,
2613 &custom_element.explosion_type,
2614 NULL, "can explode", NULL, "explosion type"
2617 // ---------- element settings: advanced (custom elements) ------------------
2620 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2621 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2624 &custom_element_change.delay_frames,
2625 NULL, "delay time given in", NULL, "delay time units for change"
2628 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2629 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2631 options_change_direct_action,
2632 &custom_element_change.direct_action,
2633 NULL, NULL, NULL, "type of direct action"
2636 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2637 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2639 options_change_other_action,
2640 &custom_element_change.other_action,
2641 NULL, NULL, "element:", "type of other element action"
2644 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2645 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2647 options_change_trigger_side,
2648 &custom_element_change.trigger_side,
2649 NULL, "at", "side", "element side triggering change"
2652 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2653 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2655 options_change_trigger_player,
2656 &custom_element_change.trigger_player,
2657 NULL, "player:", " ", "player that causes change"
2660 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2661 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2663 options_change_trigger_page,
2664 &custom_element_change.trigger_page,
2665 NULL, "page:", NULL, "change page that causes change"
2668 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2669 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2671 options_change_replace_when,
2672 &custom_element_change.replace_when,
2673 NULL, "replace when", NULL, "which elements can be replaced"
2676 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2677 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2679 options_action_type,
2680 &custom_element_change.action_type,
2681 NULL, NULL, NULL, "action on specified condition"
2684 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2685 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2687 options_action_mode_none,
2688 &custom_element_change.action_mode,
2689 NULL, NULL, NULL, "action operator"
2692 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2693 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2695 options_action_arg_none,
2696 &custom_element_change.action_arg,
2697 NULL, NULL, NULL, "action parameter"
2700 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2701 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2703 options_change_page,
2704 &custom_element.current_change_page,
2705 NULL, NULL, NULL, "element change page"
2708 // ---------- element settings: configure (group elements) ------------------
2711 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2712 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2714 options_group_choice_mode,
2715 &group_element_info.choice_mode,
2716 NULL, "choice type:", NULL, "type of group element choice"
2724 int gadget_id_align;
2727 char *text_above, *text_left, *text_right, *infotext;
2728 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2730 // ---------- level and editor settings (tabs) ------------------------------
2733 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2734 GADGET_ID_LEVELINFO_LEVEL, GADGET_ID_NONE,
2736 NULL, NULL, NULL, "Configure level properties"
2740 GADGET_ID_LEVELINFO_LEVELSET, GADGET_ID_LEVELINFO_LEVEL,
2742 NULL, NULL, NULL, "Update this or create new level set"
2746 GADGET_ID_LEVELINFO_EDITOR, GADGET_ID_LEVELINFO_LEVELSET,
2748 NULL, NULL, NULL, "Configure editor properties"
2751 // ---------- element settings (tabs) ---------------------------------------
2754 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2755 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2757 NULL, NULL, NULL, "Show information about element"
2761 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2763 NULL, NULL, NULL, "Configure element properties"
2767 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2769 NULL, NULL, NULL, "Configure element properties, part 1"
2773 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2775 NULL, NULL, NULL, "Configure element properties, part 2"
2779 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2781 NULL, NULL, NULL, "Configure custom element change pages"
2784 // ---------- level and editor settings (buttons) ---------------------------
2787 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2788 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
2790 NULL, NULL, NULL, "Update or create level set"
2793 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2794 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2796 NULL, NULL, "this level as level template",
2797 "Save current settings as new template"
2800 // ---------- element settings (buttons) ------------------------------------
2804 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2806 NULL, " ", "As Template",
2807 "Save current settings as new template"
2811 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2813 NULL, NULL, NULL, "Add new change page"
2817 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2819 NULL, NULL, NULL, "Delete current change page"
2828 int gadget_id_align;
2829 char *text_left, *text_right, *infotext;
2830 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2833 IMG_EDITOR_COUNTER_DOWN,
2834 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2835 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2836 NULL, NULL, "select previous change page"
2839 IMG_EDITOR_COUNTER_UP,
2840 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2841 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2842 NULL, "change page", "select next change page"
2845 IMG_GFX_EDITOR_BUTTON_CP_COPY,
2846 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2847 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2848 " ", NULL, "copy settings from this change page"
2851 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
2852 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2853 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2854 NULL, NULL, "paste settings to this change page"
2861 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2868 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2871 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2872 GADGET_ID_SCROLL_UP,
2873 "scroll level editing area up"
2876 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2877 GADGET_ID_SCROLL_DOWN,
2878 "scroll level editing area down"
2881 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2882 GADGET_ID_SCROLL_LEFT,
2883 "scroll level editing area left"
2886 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2887 GADGET_ID_SCROLL_RIGHT,
2888 "scroll level editing area right"
2891 IMG_EDITOR_PALETTE_SCROLL_UP,
2892 GADGET_ID_SCROLL_LIST_UP,
2893 "scroll element list up ('Page Up')"
2896 IMG_EDITOR_PALETTE_SCROLL_DOWN,
2897 GADGET_ID_SCROLL_LIST_DOWN,
2898 "scroll element list down ('Page Down')"
2906 int wheel_x, wheel_y;
2907 int wheel_width, wheel_height;
2908 } scrollbar_pos[ED_NUM_SCROLLBARS];
2916 } scrollbar_info[ED_NUM_SCROLLBARS] =
2919 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2920 GD_TYPE_SCROLLBAR_HORIZONTAL,
2921 GADGET_ID_SCROLL_HORIZONTAL,
2922 "scroll level editing area horizontally"
2925 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
2926 GD_TYPE_SCROLLBAR_VERTICAL,
2927 GADGET_ID_SCROLL_VERTICAL,
2928 "scroll level editing area vertically"
2931 IMG_EDITOR_PALETTE_SCROLLBAR,
2932 GD_TYPE_SCROLLBAR_VERTICAL,
2933 GADGET_ID_SCROLL_LIST_VERTICAL,
2934 "scroll element list vertically"
2943 int gadget_id_align;
2944 int radio_button_nr;
2947 char *text_left, *text_right, *infotext;
2948 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
2951 -1, ED_LEVEL_SETTINGS_YPOS(0),
2952 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
2953 RADIO_NR_RANDOM_ELEMENTS,
2954 &random_placement_method, RANDOM_USE_PERCENTAGE,
2955 " ", "percentage", "use percentage for random elements"
2958 -1, ED_LEVEL_SETTINGS_YPOS(0),
2959 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
2960 RADIO_NR_RANDOM_ELEMENTS,
2961 &random_placement_method, RANDOM_USE_QUANTITY,
2962 " ", "quantity", "use quantity for random elements"
2970 int gadget_id_align;
2972 char *text_above, *text_left, *text_right, *infotext;
2973 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
2975 // ---------- level and editor settings -------------------------------------
2978 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2979 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
2980 &level.auto_count_gems,
2982 "automatically count gems needed", "set counter to number of gems"
2985 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
2986 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
2987 &levelset_use_levelset_artwork,
2989 "use current custom artwork", "use custom artwork of this level set"
2992 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
2993 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
2994 &levelset_copy_level_template,
2996 "copy current level template", "copy level template of this level set"
2999 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3000 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3001 &random_placement_background_restricted,
3003 "restrict random placement to:", "set random placement restriction"
3006 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3007 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3008 &setup.editor.use_template_for_new_levels,
3009 "Template for new levels and CE/GE:", NULL,
3010 "use template for new levels", "use template for level properties"
3013 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3014 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3015 &level.use_custom_template,
3017 "use template for custom elements", "use template for custom properties"
3020 // ---------- element settings: configure (various elements) ----------------
3023 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3024 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3025 &stick_element_properties_window,
3027 "stick this screen to edit content","stick this screen to edit content"
3030 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3031 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3032 &level.em_slippery_gems,
3034 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3037 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3038 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3039 &level.em_explodes_by_fire,
3041 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3044 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3045 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3046 &level.use_spring_bug,
3048 "use spring pushing bug", "use odd spring pushing behaviour"
3051 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3052 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3053 &level.use_time_orb_bug,
3055 "use time orb bug", "use odd time orb behaviour"
3058 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3059 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3060 &level.use_life_bugs,
3062 "use buggy element behaviour", "use odd (historic) element behaviour"
3065 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3066 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3069 "create single random element", "only create one element from content"
3072 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3073 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3074 &level.ball_active_initial,
3076 "magic ball initially activated", "activate magic ball after level start"
3079 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3080 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3081 &level.grow_into_diggable,
3083 "can grow into anything diggable", "grow into more than just sand"
3086 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3087 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3088 &level.sb_fields_needed,
3090 "all fields need to be filled", "require all SB fields to be solved"
3093 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3094 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3095 &level.sb_objects_needed,
3097 "all objects need to be placed", "require all SB objects to be solved"
3100 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3101 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3102 &level.auto_exit_sokoban,
3104 "exit level if all tasks solved", "automatically finish Sokoban levels"
3107 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3108 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3109 &level.solved_by_one_player,
3111 "only one player must enter exit", "level solved by first player in exit"
3114 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3115 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3116 &level.continuous_snapping,
3118 "continuous snapping", "use snapping without releasing key"
3121 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3122 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3123 &level.block_snap_field,
3125 "block snapped field when snapping", "use snapping delay to show animation"
3128 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3129 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3130 &level.block_last_field,
3132 "block last field when moving", "player blocks last field when moving"
3135 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3136 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3137 &level.sp_block_last_field,
3139 "block last field when moving", "player blocks last field when moving"
3142 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3143 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3144 &level.instant_relocation,
3146 "no scrolling when relocating", "player gets relocated without delay"
3149 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3150 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3151 &level.shifted_relocation,
3153 "no centering when relocating", "level not centered after relocation"
3156 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3157 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3158 &level.lazy_relocation,
3160 "only redraw off-screen relocation","no redraw if relocation target visible"
3163 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3164 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3165 &level.use_start_element[0],
3167 "use level start element:", "start level at this element's position"
3170 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3171 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3172 &level.use_artwork_element[0],
3174 "use artwork from element:", "use player artwork from other element"
3177 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3178 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3179 &level.use_explosion_element[0],
3181 "use explosion from element:", "use explosion properties from element"
3184 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3185 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3186 &level.initial_player_gravity[0],
3188 "use initial gravity", "set initial player gravity"
3191 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3192 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3193 &level.use_initial_inventory[0],
3195 "use initial inventory:", "use collected elements on level start"
3198 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3199 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3200 &level.can_pass_to_walkable,
3202 "can pass to walkable element", "player can pass to empty or walkable"
3205 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3206 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3207 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3209 "can fall into acid (with gravity)","player can fall into acid pool"
3212 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3213 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3214 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3216 "can move into acid", "element can move into acid pool"
3219 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3220 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3221 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3223 "deadly when colliding with", "element is deadly when hitting player"
3226 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3227 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3228 &level.envelope[0].autowrap,
3230 "auto-wrap", "automatically wrap envelope text"
3233 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3234 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3235 &level.envelope[0].centered,
3237 "centered", "automatically center envelope text"
3240 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3241 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3242 &level.mm_laser_red,
3243 "choose color components for laser:", NULL,
3244 "red", "use red color components in laser"
3247 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3248 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3249 &level.mm_laser_green,
3251 "green", "use green color components in laser"
3254 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3255 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3256 &level.mm_laser_blue,
3258 "blue", "use blue color components in laser"
3261 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3262 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3263 &level.df_laser_red,
3264 "choose color components for laser:", NULL,
3265 "red", "use red color components in laser"
3268 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3269 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3270 &level.df_laser_green,
3272 "green", "use green color components in laser"
3275 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3276 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3277 &level.df_laser_blue,
3279 "blue", "use blue color components in laser"
3282 // ---------- element settings: configure 1 (custom elements) ---------------
3285 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3286 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3287 &custom_element.use_gfx_element,
3289 "use graphic of element:", "use existing element graphic"
3292 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3293 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3294 &level.use_custom_template,
3296 "use template", "use template for custom properties"
3299 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3300 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3301 &custom_element_properties[EP_ACCESSIBLE],
3303 NULL, "player can walk to or pass this field"
3306 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3307 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3308 &custom_element_properties[EP_GRAVITY_REACHABLE],
3310 "reachable despite gravity", "player can walk/dig despite gravity"
3313 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3314 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3315 &custom_element.use_last_ce_value,
3317 "use last CE value after change", "use last CE value after change"
3320 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3321 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3322 &custom_element_properties[EP_WALK_TO_OBJECT],
3324 NULL, "player can dig/collect/push element"
3327 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3328 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3329 &custom_element_properties[EP_INDESTRUCTIBLE],
3331 "indestructible", "element is indestructible"
3334 // ---------- element settings: configure 2 (custom elements) ---------------
3337 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3338 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3339 &custom_element_properties[EP_CAN_MOVE],
3341 NULL, "element can move with some pattern"
3344 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
3345 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3346 &custom_element_properties[EP_CAN_FALL],
3348 "can fall", "element can fall down"
3351 -1, ED_ELEMENT_SETTINGS_YPOS(7),
3352 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3353 &custom_element_properties[EP_CAN_SMASH],
3355 NULL, "element can smash other elements"
3358 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3359 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3360 &custom_element_properties[EP_SLIPPERY],
3362 NULL, "other elements can fall down from it"
3365 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3366 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3367 &custom_element_properties[EP_DEADLY],
3369 NULL, "element can kill the player"
3372 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3373 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3374 &custom_element_properties[EP_CAN_EXPLODE],
3376 NULL, "element can explode"
3379 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
3380 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3381 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3383 "by fire", "element can explode by fire/explosion"
3386 -1, ED_ELEMENT_SETTINGS_YPOS(11),
3387 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3388 &custom_element_properties[EP_EXPLODES_SMASHED],
3390 "smashed", "element can explode when smashed"
3393 -1, ED_ELEMENT_SETTINGS_YPOS(11),
3394 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3395 &custom_element_properties[EP_EXPLODES_IMPACT],
3397 "impact", "element can explode on impact"
3400 // ---------- element settings: advanced (custom elements) ------------------
3403 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3404 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3405 &custom_element_change.can_change,
3407 "element changes to:", "change element on specified condition"
3410 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3411 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3412 &custom_element_change_events[CE_DELAY],
3414 NULL, "element changes after delay"
3417 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3418 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3419 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3421 NULL, "element changes by direct action"
3424 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3425 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3426 &custom_element_change_events[CE_BY_OTHER_ACTION],
3428 NULL, "element changes by other element"
3431 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3432 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3433 &custom_element_change.explode,
3435 "explode instead of change", "element explodes instead of change"
3438 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3439 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3440 &custom_element_change.use_target_content,
3442 "use extended change target:", "element changes to more elements"
3445 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3446 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3447 &custom_element_change.only_if_complete,
3449 "replace all or nothing", "only replace when all can be changed"
3452 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3453 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3454 &custom_element_change.use_random_replace,
3456 NULL, "use percentage for random replace"
3459 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3460 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3461 &custom_element_change.has_action,
3463 NULL, "execute action on specified condition"
3470 int xoffset, yoffset;
3472 int gadget_id_align;
3474 int area_xsize, area_ysize;
3475 char *text_left, *text_right, *text_above, *text_below, *infotext;
3476 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3478 // ---------- level playfield content ---------------------------------------
3483 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3485 -1, -1, // these values are not constant, but can change at runtime
3486 NULL, NULL, NULL, NULL, NULL
3489 // ---------- yam yam content -----------------------------------------------
3492 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3493 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3494 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3495 &level.yamyam_content[0].e[0][0], 3, 3,
3496 NULL, NULL, NULL, "1", NULL
3499 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3500 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3501 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3502 &level.yamyam_content[1].e[0][0], 3, 3,
3503 NULL, NULL, NULL, "2", NULL
3506 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3507 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3508 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3509 &level.yamyam_content[2].e[0][0], 3, 3,
3510 NULL, NULL, NULL, "3", NULL
3513 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3514 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3515 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3516 &level.yamyam_content[3].e[0][0], 3, 3,
3517 NULL, NULL, NULL, "4", NULL
3520 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3521 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3522 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3523 &level.yamyam_content[4].e[0][0], 3, 3,
3524 NULL, NULL, NULL, "5", NULL
3527 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3528 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3529 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3530 &level.yamyam_content[5].e[0][0], 3, 3,
3531 NULL, NULL, NULL, "6", NULL
3534 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3535 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3536 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3537 &level.yamyam_content[6].e[0][0], 3, 3,
3538 NULL, NULL, NULL, "7", NULL
3541 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3542 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3543 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3544 &level.yamyam_content[7].e[0][0], 3, 3,
3545 NULL, NULL, NULL, "8", NULL
3548 // ---------- magic ball content --------------------------------------------
3551 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3552 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3553 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3554 &level.ball_content[0].e[0][0], 3, 3,
3555 NULL, NULL, NULL, "1", NULL
3558 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3559 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3560 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3561 &level.ball_content[1].e[0][0], 3, 3,
3562 NULL, NULL, NULL, "2", NULL
3565 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3566 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3567 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3568 &level.ball_content[2].e[0][0], 3, 3,
3569 NULL, NULL, NULL, "3", NULL
3572 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3573 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3574 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3575 &level.ball_content[3].e[0][0], 3, 3,
3576 NULL, NULL, NULL, "4", NULL
3579 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3580 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3581 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3582 &level.ball_content[4].e[0][0], 3, 3,
3583 NULL, NULL, NULL, "5", NULL
3586 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3587 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3588 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3589 &level.ball_content[5].e[0][0], 3, 3,
3590 NULL, NULL, NULL, "6", NULL
3593 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3594 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3595 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3596 &level.ball_content[6].e[0][0], 3, 3,
3597 NULL, NULL, NULL, "7", NULL
3600 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3601 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3602 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3603 &level.ball_content[7].e[0][0], 3, 3,
3604 NULL, NULL, NULL, "8", NULL
3607 // ---------- android content -----------------------------------------------
3610 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
3611 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3612 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3613 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3614 NULL, NULL, "elements:", NULL, "elements android can clone"
3617 // ---------- amoeba content ------------------------------------------------
3620 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3621 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3622 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3623 &level.amoeba_content, 1, 1,
3624 "content:", NULL, NULL, NULL, "amoeba content"
3627 // ---------- level start element -------------------------------------------
3630 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3631 0, ED_AREA_1X1_SETTINGS_YOFF,
3632 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3633 &level.start_element[0], 1, 1,
3634 NULL, NULL, NULL, NULL, "level start element"
3637 // ---------- player artwork element ----------------------------------------
3640 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3641 0, ED_AREA_1X1_SETTINGS_YOFF,
3642 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3643 &level.artwork_element[0], 1, 1,
3644 NULL, NULL, NULL, NULL, "element for player artwork"
3647 // ---------- player explosion element --------------------------------------
3650 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
3651 0, ED_AREA_1X1_SETTINGS_YOFF,
3652 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3653 &level.explosion_element[0], 1, 1,
3654 NULL, NULL, NULL, NULL, "element for player explosion"
3657 // ---------- player initial inventory --------------------------------------
3660 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3661 0, ED_AREA_1X1_SETTINGS_YOFF,
3662 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3663 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3664 NULL, NULL, NULL, NULL, "content for initial inventory"
3667 // ---------- element settings: configure 1 (custom elements) ---------------
3669 // ---------- custom graphic ------------------------------------------------
3672 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3673 0, ED_AREA_1X1_SETTINGS_YOFF,
3674 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3675 &custom_element.gfx_element_initial,1, 1,
3676 NULL, NULL, NULL, NULL, "custom graphic element"
3679 // ---------- element settings: configure 2 (custom elements) ---------------
3681 // ---------- custom content (when exploding) -------------------------------
3684 -1, ED_AREA_3X3_SETTINGS_YPOS(10),
3685 0, ED_AREA_3X3_SETTINGS_YOFF,
3686 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
3687 &custom_element.content.e[0][0], 3, 3,
3688 "content:", NULL, NULL, NULL, NULL
3691 // ---------- custom enter and leave element (when moving) ------------------
3694 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3695 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3696 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3697 &custom_element.move_enter_element, 1, 1,
3698 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
3701 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3702 0, ED_AREA_1X1_SETTINGS_YOFF,
3703 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3704 &custom_element.move_leave_element, 1, 1,
3705 NULL, NULL, NULL, NULL, "element that will be left behind"
3708 // ---------- element settings: advanced (custom elements) ------------------
3710 // ---------- custom change target ------------------------------------------
3713 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3714 0, ED_AREA_1X1_SETTINGS_YOFF,
3715 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3716 &custom_element_change.target_element, 1, 1,
3717 NULL, "after/when:", NULL, NULL, "new target element after change"
3720 // ---------- custom change content (extended change target) ----------------
3723 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3724 0, ED_AREA_3X3_SETTINGS_YOFF,
3725 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
3726 &custom_element_change.target_content.e[0][0], 3, 3,
3727 NULL, NULL, NULL, NULL, "new extended elements after change"
3730 // ---------- custom change trigger (element causing change) ----------------
3733 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3734 0, ED_AREA_1X1_SETTINGS_YOFF,
3735 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3736 &custom_element_change.initial_trigger_element, 1, 1,
3737 NULL, NULL, NULL, NULL, "other element triggering change"
3740 // ---------- custom change action (element used for action) ----------------
3743 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3744 0, ED_AREA_1X1_SETTINGS_YOFF,
3745 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3746 &custom_element_change.action_element, 1, 1,
3747 NULL, NULL, NULL, NULL, "element used as action parameter"
3750 // ---------- group element content -----------------------------------------
3753 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3754 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3755 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3756 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3757 "content:", NULL, NULL, NULL, NULL
3760 // ---------- random background (for random painting) -----------------------
3763 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
3764 0, ED_AREA_1X1_LSETTINGS_YOFF,
3765 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3766 &random_placement_background_element, 1, 1,
3767 NULL, NULL, NULL, NULL, "random placement background"
3772 // ----------------------------------------------------------------------------
3773 // some internally used variables
3774 // ----------------------------------------------------------------------------
3776 // maximal size of level editor drawing area
3777 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3779 // actual size of level editor drawing area
3780 static int ed_fieldx, ed_fieldy;
3782 // actual position of level editor drawing area in level playfield
3783 static int level_xpos = -1, level_ypos = -1;
3785 // actual tile size used to display playfield drawing area
3786 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3787 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
3789 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3791 // drawing elements on the three mouse buttons
3792 static int new_element1 = EL_WALL;
3793 static int new_element2 = EL_EMPTY;
3794 static int new_element3 = EL_SAND;
3796 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3797 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3798 (button) == 2 ? new_element2 : \
3799 (button) == 3 ? new_element3 : EL_EMPTY)
3801 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
3803 static int use_permanent_palette = TRUE;
3805 #define PX (use_permanent_palette ? DX : SX)
3806 #define PY (use_permanent_palette ? DY : SY)
3807 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
3808 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
3810 // forward declaration for internal use
3811 static void CopyBrushToCursor(int, int);
3812 static void DeleteBrushFromCursor(void);
3813 static void ModifyEditorCounterValue(int, int);
3814 static void ModifyEditorCounterLimits(int, int, int);
3815 static void ModifyEditorSelectboxValue(int, int);
3816 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3817 static void ModifyEditorDrawingArea(int, int, int);
3818 static void ModifyEditorElementList(void);
3819 static void AdjustElementListScrollbar(void);
3820 static void RedrawDrawingElements(void);
3821 static void DrawDrawingWindowExt(boolean);
3822 static void DrawDrawingWindow(void);
3823 static void DrawLevelInfoWindow(void);
3824 static void DrawPropertiesWindow(void);
3825 static void DrawPaletteWindow(void);
3826 static void UpdateCustomElementGraphicGadgets(void);
3827 static boolean checkPropertiesConfig(int);
3828 static void SetAutomaticNumberOfGemsNeeded(void);
3829 static void ClearEditorGadgetInfoText(void);
3830 static void CopyLevelToUndoBuffer(int);
3831 static void HandleDrawingAreas(struct GadgetInfo *);
3832 static void HandleCounterButtons(struct GadgetInfo *);
3833 static void HandleTextInputGadgets(struct GadgetInfo *);
3834 static void HandleTextAreaGadgets(struct GadgetInfo *);
3835 static void HandleSelectboxGadgets(struct GadgetInfo *);
3836 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3837 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3838 static void HandleRadiobuttons(struct GadgetInfo *);
3839 static void HandleCheckbuttons(struct GadgetInfo *);
3840 static void HandleControlButtons(struct GadgetInfo *);
3841 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3842 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3843 static boolean AskToCopyAndModifyLevelTemplate(void);
3844 static boolean getDrawModeHiRes(void);
3845 static int getTabulatorBarWidth(void);
3846 static int getTabulatorBarHeight(void);
3847 static Pixel getTabulatorBarColor(void);
3849 static int num_editor_gadgets = 0; // dynamically determined
3851 static struct GadgetInfo **level_editor_gadget = NULL;
3852 static int *right_gadget_border = NULL;
3854 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3855 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3856 static boolean draw_with_brush = FALSE;
3857 static int properties_element = 0;
3859 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3860 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3861 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3862 static int undo_buffer_position = 0;
3863 static int undo_buffer_steps = 0;
3864 static int redo_buffer_steps = 0;
3866 static int edit_mode;
3867 static int edit_mode_levelinfo;
3868 static int edit_mode_properties;
3870 static int element_shift = 0;
3872 static int editor_el_players[] =
3879 static int *editor_el_players_ptr = editor_el_players;
3880 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
3882 static int editor_hl_boulderdash[] =
3884 EL_INTERNAL_CASCADE_BD_ACTIVE,
3890 static int editor_el_boulderdash[] =
3899 EL_BD_EXPANDABLE_WALL,
3907 EL_BD_BUTTERFLY_LEFT,
3909 EL_BD_BUTTERFLY_RIGHT,
3910 EL_BD_FIREFLY_RIGHT,
3913 EL_BD_BUTTERFLY_DOWN,
3917 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
3918 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
3919 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
3920 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
3922 static int editor_hl_emerald_mine[] =
3924 EL_INTERNAL_CASCADE_EM_ACTIVE,
3930 static int editor_el_emerald_mine[] =
3948 EL_EM_DYNAMITE_ACTIVE,
3967 EL_ACID_POOL_TOPLEFT,
3969 EL_ACID_POOL_TOPRIGHT,
3972 EL_ACID_POOL_BOTTOMLEFT,
3973 EL_ACID_POOL_BOTTOM,
3974 EL_ACID_POOL_BOTTOMRIGHT,
3992 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
3993 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
3994 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
3995 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
3997 static int editor_hl_emerald_mine_club[] =
3999 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4005 static int editor_el_emerald_mine_club[] =
4032 EL_EMC_WALL_SLIPPERY_1,
4033 EL_EMC_WALL_SLIPPERY_2,
4034 EL_EMC_WALL_SLIPPERY_3,
4035 EL_EMC_WALL_SLIPPERY_4,
4058 EL_EMC_MAGIC_BALL_SWITCH,
4065 EL_EMC_SPRING_BUMPER,
4069 EL_BALLOON_SWITCH_UP,
4070 EL_BALLOON_SWITCH_ANY,
4073 EL_BALLOON_SWITCH_LEFT,
4075 EL_BALLOON_SWITCH_RIGHT,
4079 EL_BALLOON_SWITCH_DOWN,
4080 EL_BALLOON_SWITCH_NONE,
4082 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4083 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4084 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4085 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4087 static int editor_hl_rnd[] =
4089 EL_INTERNAL_CASCADE_RND_ACTIVE,
4095 static int editor_el_rnd[] =
4098 EL_DYNAMITE_ACTIVE, // RND
4132 EL_WALL_EMERALD_YELLOW,
4133 EL_WALL_EMERALD_RED,
4134 EL_WALL_EMERALD_PURPLE,
4152 EL_DYNABOMB_INCREASE_NUMBER,
4153 EL_DYNABOMB_INCREASE_SIZE,
4154 EL_DYNABOMB_INCREASE_POWER,
4174 EL_INVISIBLE_STEELWALL,
4178 EL_EXPANDABLE_WALL_HORIZONTAL,
4179 EL_EXPANDABLE_WALL_VERTICAL,
4180 EL_EXPANDABLE_WALL_ANY,
4182 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4183 static int *editor_el_rnd_ptr = editor_el_rnd;
4184 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4185 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4187 static int editor_hl_sokoban[] =
4189 EL_INTERNAL_CASCADE_SB_ACTIVE,
4195 static int editor_el_sokoban[] =
4198 EL_SOKOBAN_FIELD_EMPTY,
4199 EL_SOKOBAN_FIELD_FULL,
4200 EL_SOKOBAN_FIELD_PLAYER,
4202 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4203 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4204 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4205 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4207 static int editor_hl_supaplex[] =
4209 EL_INTERNAL_CASCADE_SP_ACTIVE,
4215 static int editor_el_supaplex[] =
4233 EL_SP_PORT_HORIZONTAL,
4234 EL_SP_PORT_VERTICAL,
4242 EL_SP_GRAVITY_PORT_LEFT,
4243 EL_SP_GRAVITY_PORT_RIGHT,
4244 EL_SP_GRAVITY_PORT_UP,
4245 EL_SP_GRAVITY_PORT_DOWN,
4247 EL_SP_GRAVITY_ON_PORT_LEFT,
4248 EL_SP_GRAVITY_ON_PORT_RIGHT,
4249 EL_SP_GRAVITY_ON_PORT_UP,
4250 EL_SP_GRAVITY_ON_PORT_DOWN,
4252 EL_SP_GRAVITY_OFF_PORT_LEFT,
4253 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4254 EL_SP_GRAVITY_OFF_PORT_UP,
4255 EL_SP_GRAVITY_OFF_PORT_DOWN,
4257 EL_SP_HARDWARE_GRAY,
4258 EL_SP_HARDWARE_GREEN,
4259 EL_SP_HARDWARE_BLUE,
4262 EL_SP_HARDWARE_BASE_1,
4263 EL_SP_HARDWARE_BASE_2,
4264 EL_SP_HARDWARE_BASE_3,
4265 EL_SP_HARDWARE_BASE_4,
4267 EL_SP_HARDWARE_BASE_5,
4268 EL_SP_HARDWARE_BASE_6,
4269 EL_SP_HARDWARE_YELLOW,
4277 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4278 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4279 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4280 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4282 static int editor_hl_diamond_caves[] =
4284 EL_INTERNAL_CASCADE_DC_ACTIVE,
4290 static int editor_el_diamond_caves[] =
4292 EL_EM_STEEL_EXIT_CLOSED, // DC2
4293 EL_EM_STEEL_EXIT_OPEN, // DC2
4294 EL_WALL_EMERALD, // DC2
4295 EL_WALL_DIAMOND, // DC2
4302 EL_CONVEYOR_BELT_1_LEFT,
4303 EL_CONVEYOR_BELT_1_MIDDLE,
4304 EL_CONVEYOR_BELT_1_RIGHT,
4305 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4307 EL_CONVEYOR_BELT_2_LEFT,
4308 EL_CONVEYOR_BELT_2_MIDDLE,
4309 EL_CONVEYOR_BELT_2_RIGHT,
4310 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4312 EL_CONVEYOR_BELT_3_LEFT,
4313 EL_CONVEYOR_BELT_3_MIDDLE,
4314 EL_CONVEYOR_BELT_3_RIGHT,
4315 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4317 EL_CONVEYOR_BELT_4_LEFT,
4318 EL_CONVEYOR_BELT_4_MIDDLE,
4319 EL_CONVEYOR_BELT_4_RIGHT,
4320 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4322 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4323 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4324 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4325 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4327 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4328 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4329 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4330 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4335 EL_DC_TIMEGATE_SWITCH,
4337 EL_SWITCHGATE_CLOSED,
4339 EL_SWITCHGATE_SWITCH_UP,
4340 EL_SWITCHGATE_SWITCH_DOWN,
4343 EL_LIGHT_SWITCH_ACTIVE,
4344 EL_DC_SWITCHGATE_SWITCH_UP,
4345 EL_DC_SWITCHGATE_SWITCH_DOWN,
4347 EL_STEEL_EXIT_CLOSED,
4349 EL_STEELWALL_SLIPPERY,
4352 EL_QUICKSAND_FAST_EMPTY,
4353 EL_QUICKSAND_FAST_FULL,
4367 EL_SIGN_RADIOACTIVITY,
4373 EL_SIGN_ENTRY_FORBIDDEN,
4374 EL_SIGN_EMERGENCY_EXIT,
4399 EL_DC_STEELWALL_2_SINGLE,
4400 EL_DC_STEELWALL_2_TOP,
4401 EL_SIGN_EXCLAMATION,
4404 EL_DC_STEELWALL_2_LEFT,
4405 EL_DC_STEELWALL_2_MIDDLE,
4406 EL_DC_STEELWALL_2_HORIZONTAL,
4407 EL_DC_STEELWALL_2_RIGHT,
4409 EL_DC_STEELWALL_1_TOPLEFT,
4410 EL_DC_STEELWALL_2_VERTICAL,
4411 EL_DC_STEELWALL_1_TOPRIGHT,
4414 EL_DC_STEELWALL_1_VERTICAL,
4415 EL_DC_STEELWALL_2_BOTTOM,
4417 EL_DC_GATE_WHITE_GRAY,
4419 EL_DC_STEELWALL_1_BOTTOMLEFT,
4420 EL_DC_STEELWALL_1_HORIZONTAL,
4421 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4422 EL_DC_GATE_FAKE_GRAY,
4424 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4425 EL_DC_STEELWALL_1_BOTTOM,
4426 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
4427 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
4429 EL_DC_STEELWALL_1_RIGHT,
4431 EL_DC_STEELWALL_1_LEFT,
4432 EL_EXPANDABLE_STEELWALL_VERTICAL,
4434 EL_DC_STEELWALL_1_TOPRIGHT_2,
4435 EL_DC_STEELWALL_1_TOP,
4436 EL_DC_STEELWALL_1_TOPLEFT_2,
4437 EL_EXPANDABLE_STEELWALL_ANY,
4439 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
4440 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
4441 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
4442 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
4444 static int editor_hl_dx_boulderdash[] =
4446 EL_INTERNAL_CASCADE_DX_ACTIVE,
4452 static int editor_el_dx_boulderdash[] =
4456 EL_TUBE_HORIZONTAL_DOWN,
4460 EL_TUBE_VERTICAL_RIGHT,
4462 EL_TUBE_VERTICAL_LEFT,
4466 EL_TUBE_HORIZONTAL_UP,
4474 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
4475 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
4476 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
4477 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
4479 static int editor_hl_mirror_magic[] =
4481 EL_INTERNAL_CASCADE_MM_ACTIVE,
4487 static int editor_el_mirror_magic[] =
4489 EL_MM_MCDUFFIN_RIGHT,
4491 EL_MM_MCDUFFIN_LEFT,
4492 EL_MM_MCDUFFIN_DOWN,
4495 EL_MM_MIRROR_FIXED_START,
4496 EL_MM_POLARIZER_START,
4497 EL_MM_POLARIZER_CROSS_START,
4499 EL_MM_TELEPORTER_RED_START,
4500 EL_MM_TELEPORTER_YELLOW_START,
4501 EL_MM_TELEPORTER_GREEN_START,
4502 EL_MM_TELEPORTER_BLUE_START,
4515 EL_MM_LIGHTBULB_ACTIVE,
4529 EL_MM_STEEL_GRID_FIXED_1,
4530 EL_MM_STEEL_GRID_FIXED_2,
4531 EL_MM_STEEL_GRID_FIXED_3,
4532 EL_MM_STEEL_GRID_FIXED_4,
4534 EL_MM_WOODEN_GRID_FIXED_1,
4535 EL_MM_WOODEN_GRID_FIXED_2,
4536 EL_MM_WOODEN_GRID_FIXED_3,
4537 EL_MM_WOODEN_GRID_FIXED_4
4539 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
4540 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
4541 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
4542 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
4544 static int editor_hl_deflektor[] =
4546 EL_INTERNAL_CASCADE_DF_ACTIVE,
4552 static int editor_el_deflektor[] =
4559 EL_DF_RECEIVER_RIGHT,
4561 EL_DF_RECEIVER_LEFT,
4562 EL_DF_RECEIVER_DOWN,
4565 EL_DF_MIRROR_ROTATING_START,
4569 EL_DF_FIBRE_OPTIC_RED_1,
4570 EL_DF_FIBRE_OPTIC_YELLOW_1,
4571 EL_DF_FIBRE_OPTIC_GREEN_1,
4572 EL_DF_FIBRE_OPTIC_BLUE_1,
4574 EL_DF_STEEL_GRID_FIXED_START,
4575 EL_DF_STEEL_GRID_ROTATING_START,
4576 EL_DF_WOODEN_GRID_FIXED_START,
4577 EL_DF_WOODEN_GRID_ROTATING_START,
4584 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
4585 static int *editor_el_deflektor_ptr = editor_el_deflektor;
4586 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
4587 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
4589 static int editor_hl_chars[] =
4591 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
4597 static int editor_el_chars[] =
4679 EL_CHAR(CHAR_BYTE_COPYRIGHT),
4680 EL_CHAR(CHAR_BYTE_UMLAUT_A),
4681 EL_CHAR(CHAR_BYTE_UMLAUT_O),
4682 EL_CHAR(CHAR_BYTE_UMLAUT_U),
4684 EL_CHAR(CHAR_BYTE_DEGREE),
4685 EL_CHAR(CHAR_BYTE_REGISTERED),
4686 EL_CHAR(FONT_ASCII_CURSOR),
4687 EL_CHAR(FONT_ASCII_BUTTON),
4689 EL_CHAR(FONT_ASCII_UP),
4690 EL_CHAR(FONT_ASCII_DOWN),
4694 static int *editor_hl_chars_ptr = editor_hl_chars;
4695 static int *editor_el_chars_ptr = editor_el_chars;
4696 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
4697 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
4699 static int editor_hl_steel_chars[] =
4701 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
4707 static int editor_el_steel_chars[] =
4717 EL_STEEL_CHAR('\''),
4784 EL_STEEL_CHAR('\\'),
4789 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
4790 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
4791 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
4792 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
4794 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
4795 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
4796 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4797 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4799 EL_STEEL_CHAR(FONT_ASCII_UP),
4800 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4804 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4805 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4806 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
4807 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
4809 static int editor_hl_custom[] =
4811 EL_INTERNAL_CASCADE_CE_ACTIVE,
4817 static int editor_el_custom[] =
4819 EL_CUSTOM_START + 0,
4820 EL_CUSTOM_START + 1,
4821 EL_CUSTOM_START + 2,
4822 EL_CUSTOM_START + 3,
4824 EL_CUSTOM_START + 4,
4825 EL_CUSTOM_START + 5,
4826 EL_CUSTOM_START + 6,
4827 EL_CUSTOM_START + 7,
4829 EL_CUSTOM_START + 8,
4830 EL_CUSTOM_START + 9,
4831 EL_CUSTOM_START + 10,
4832 EL_CUSTOM_START + 11,
4834 EL_CUSTOM_START + 12,
4835 EL_CUSTOM_START + 13,
4836 EL_CUSTOM_START + 14,
4837 EL_CUSTOM_START + 15,
4839 EL_CUSTOM_START + 16,
4840 EL_CUSTOM_START + 17,
4841 EL_CUSTOM_START + 18,
4842 EL_CUSTOM_START + 19,
4844 EL_CUSTOM_START + 20,
4845 EL_CUSTOM_START + 21,
4846 EL_CUSTOM_START + 22,
4847 EL_CUSTOM_START + 23,
4849 EL_CUSTOM_START + 24,
4850 EL_CUSTOM_START + 25,
4851 EL_CUSTOM_START + 26,
4852 EL_CUSTOM_START + 27,
4854 EL_CUSTOM_START + 28,
4855 EL_CUSTOM_START + 29,
4856 EL_CUSTOM_START + 30,
4857 EL_CUSTOM_START + 31,
4859 EL_CUSTOM_START + 32,
4860 EL_CUSTOM_START + 33,
4861 EL_CUSTOM_START + 34,
4862 EL_CUSTOM_START + 35,
4864 EL_CUSTOM_START + 36,
4865 EL_CUSTOM_START + 37,
4866 EL_CUSTOM_START + 38,
4867 EL_CUSTOM_START + 39,
4869 EL_CUSTOM_START + 40,
4870 EL_CUSTOM_START + 41,
4871 EL_CUSTOM_START + 42,
4872 EL_CUSTOM_START + 43,
4874 EL_CUSTOM_START + 44,
4875 EL_CUSTOM_START + 45,
4876 EL_CUSTOM_START + 46,
4877 EL_CUSTOM_START + 47,
4879 EL_CUSTOM_START + 48,
4880 EL_CUSTOM_START + 49,
4881 EL_CUSTOM_START + 50,
4882 EL_CUSTOM_START + 51,
4884 EL_CUSTOM_START + 52,
4885 EL_CUSTOM_START + 53,
4886 EL_CUSTOM_START + 54,
4887 EL_CUSTOM_START + 55,
4889 EL_CUSTOM_START + 56,
4890 EL_CUSTOM_START + 57,
4891 EL_CUSTOM_START + 58,
4892 EL_CUSTOM_START + 59,
4894 EL_CUSTOM_START + 60,
4895 EL_CUSTOM_START + 61,
4896 EL_CUSTOM_START + 62,
4897 EL_CUSTOM_START + 63,
4899 EL_CUSTOM_START + 64,
4900 EL_CUSTOM_START + 65,
4901 EL_CUSTOM_START + 66,
4902 EL_CUSTOM_START + 67,
4904 EL_CUSTOM_START + 68,
4905 EL_CUSTOM_START + 69,
4906 EL_CUSTOM_START + 70,
4907 EL_CUSTOM_START + 71,
4909 EL_CUSTOM_START + 72,
4910 EL_CUSTOM_START + 73,
4911 EL_CUSTOM_START + 74,
4912 EL_CUSTOM_START + 75,
4914 EL_CUSTOM_START + 76,
4915 EL_CUSTOM_START + 77,
4916 EL_CUSTOM_START + 78,
4917 EL_CUSTOM_START + 79,
4919 EL_CUSTOM_START + 80,
4920 EL_CUSTOM_START + 81,
4921 EL_CUSTOM_START + 82,
4922 EL_CUSTOM_START + 83,
4924 EL_CUSTOM_START + 84,
4925 EL_CUSTOM_START + 85,
4926 EL_CUSTOM_START + 86,
4927 EL_CUSTOM_START + 87,
4929 EL_CUSTOM_START + 88,
4930 EL_CUSTOM_START + 89,
4931 EL_CUSTOM_START + 90,
4932 EL_CUSTOM_START + 91,
4934 EL_CUSTOM_START + 92,
4935 EL_CUSTOM_START + 93,
4936 EL_CUSTOM_START + 94,
4937 EL_CUSTOM_START + 95,
4939 EL_CUSTOM_START + 96,
4940 EL_CUSTOM_START + 97,
4941 EL_CUSTOM_START + 98,
4942 EL_CUSTOM_START + 99,
4944 EL_CUSTOM_START + 100,
4945 EL_CUSTOM_START + 101,
4946 EL_CUSTOM_START + 102,
4947 EL_CUSTOM_START + 103,
4949 EL_CUSTOM_START + 104,
4950 EL_CUSTOM_START + 105,
4951 EL_CUSTOM_START + 106,
4952 EL_CUSTOM_START + 107,
4954 EL_CUSTOM_START + 108,
4955 EL_CUSTOM_START + 109,
4956 EL_CUSTOM_START + 110,
4957 EL_CUSTOM_START + 111,
4959 EL_CUSTOM_START + 112,
4960 EL_CUSTOM_START + 113,
4961 EL_CUSTOM_START + 114,
4962 EL_CUSTOM_START + 115,
4964 EL_CUSTOM_START + 116,
4965 EL_CUSTOM_START + 117,
4966 EL_CUSTOM_START + 118,
4967 EL_CUSTOM_START + 119,
4969 EL_CUSTOM_START + 120,
4970 EL_CUSTOM_START + 121,
4971 EL_CUSTOM_START + 122,
4972 EL_CUSTOM_START + 123,
4974 EL_CUSTOM_START + 124,
4975 EL_CUSTOM_START + 125,
4976 EL_CUSTOM_START + 126,
4977 EL_CUSTOM_START + 127,
4979 EL_CUSTOM_START + 128,
4980 EL_CUSTOM_START + 129,
4981 EL_CUSTOM_START + 130,
4982 EL_CUSTOM_START + 131,
4984 EL_CUSTOM_START + 132,
4985 EL_CUSTOM_START + 133,
4986 EL_CUSTOM_START + 134,
4987 EL_CUSTOM_START + 135,
4989 EL_CUSTOM_START + 136,
4990 EL_CUSTOM_START + 137,
4991 EL_CUSTOM_START + 138,
4992 EL_CUSTOM_START + 139,
4994 EL_CUSTOM_START + 140,
4995 EL_CUSTOM_START + 141,
4996 EL_CUSTOM_START + 142,
4997 EL_CUSTOM_START + 143,
4999 EL_CUSTOM_START + 144,
5000 EL_CUSTOM_START + 145,
5001 EL_CUSTOM_START + 146,
5002 EL_CUSTOM_START + 147,
5004 EL_CUSTOM_START + 148,
5005 EL_CUSTOM_START + 149,
5006 EL_CUSTOM_START + 150,
5007 EL_CUSTOM_START + 151,
5009 EL_CUSTOM_START + 152,
5010 EL_CUSTOM_START + 153,
5011 EL_CUSTOM_START + 154,
5012 EL_CUSTOM_START + 155,
5014 EL_CUSTOM_START + 156,
5015 EL_CUSTOM_START + 157,
5016 EL_CUSTOM_START + 158,
5017 EL_CUSTOM_START + 159,
5019 EL_CUSTOM_START + 160,
5020 EL_CUSTOM_START + 161,
5021 EL_CUSTOM_START + 162,
5022 EL_CUSTOM_START + 163,
5024 EL_CUSTOM_START + 164,
5025 EL_CUSTOM_START + 165,
5026 EL_CUSTOM_START + 166,
5027 EL_CUSTOM_START + 167,
5029 EL_CUSTOM_START + 168,
5030 EL_CUSTOM_START + 169,
5031 EL_CUSTOM_START + 170,
5032 EL_CUSTOM_START + 171,
5034 EL_CUSTOM_START + 172,
5035 EL_CUSTOM_START + 173,
5036 EL_CUSTOM_START + 174,
5037 EL_CUSTOM_START + 175,
5039 EL_CUSTOM_START + 176,
5040 EL_CUSTOM_START + 177,
5041 EL_CUSTOM_START + 178,
5042 EL_CUSTOM_START + 179,
5044 EL_CUSTOM_START + 180,
5045 EL_CUSTOM_START + 181,
5046 EL_CUSTOM_START + 182,
5047 EL_CUSTOM_START + 183,
5049 EL_CUSTOM_START + 184,
5050 EL_CUSTOM_START + 185,
5051 EL_CUSTOM_START + 186,
5052 EL_CUSTOM_START + 187,
5054 EL_CUSTOM_START + 188,
5055 EL_CUSTOM_START + 189,
5056 EL_CUSTOM_START + 190,
5057 EL_CUSTOM_START + 191,
5059 EL_CUSTOM_START + 192,
5060 EL_CUSTOM_START + 193,
5061 EL_CUSTOM_START + 194,
5062 EL_CUSTOM_START + 195,
5064 EL_CUSTOM_START + 196,
5065 EL_CUSTOM_START + 197,
5066 EL_CUSTOM_START + 198,
5067 EL_CUSTOM_START + 199,
5069 EL_CUSTOM_START + 200,
5070 EL_CUSTOM_START + 201,
5071 EL_CUSTOM_START + 202,
5072 EL_CUSTOM_START + 203,
5074 EL_CUSTOM_START + 204,
5075 EL_CUSTOM_START + 205,
5076 EL_CUSTOM_START + 206,
5077 EL_CUSTOM_START + 207,
5079 EL_CUSTOM_START + 208,
5080 EL_CUSTOM_START + 209,
5081 EL_CUSTOM_START + 210,
5082 EL_CUSTOM_START + 211,
5084 EL_CUSTOM_START + 212,
5085 EL_CUSTOM_START + 213,
5086 EL_CUSTOM_START + 214,
5087 EL_CUSTOM_START + 215,
5089 EL_CUSTOM_START + 216,
5090 EL_CUSTOM_START + 217,
5091 EL_CUSTOM_START + 218,
5092 EL_CUSTOM_START + 219,
5094 EL_CUSTOM_START + 220,
5095 EL_CUSTOM_START + 221,
5096 EL_CUSTOM_START + 222,
5097 EL_CUSTOM_START + 223,
5099 EL_CUSTOM_START + 224,
5100 EL_CUSTOM_START + 225,
5101 EL_CUSTOM_START + 226,
5102 EL_CUSTOM_START + 227,
5104 EL_CUSTOM_START + 228,
5105 EL_CUSTOM_START + 229,
5106 EL_CUSTOM_START + 230,
5107 EL_CUSTOM_START + 231,
5109 EL_CUSTOM_START + 232,
5110 EL_CUSTOM_START + 233,
5111 EL_CUSTOM_START + 234,
5112 EL_CUSTOM_START + 235,
5114 EL_CUSTOM_START + 236,
5115 EL_CUSTOM_START + 237,
5116 EL_CUSTOM_START + 238,
5117 EL_CUSTOM_START + 239,
5119 EL_CUSTOM_START + 240,
5120 EL_CUSTOM_START + 241,
5121 EL_CUSTOM_START + 242,
5122 EL_CUSTOM_START + 243,
5124 EL_CUSTOM_START + 244,
5125 EL_CUSTOM_START + 245,
5126 EL_CUSTOM_START + 246,
5127 EL_CUSTOM_START + 247,
5129 EL_CUSTOM_START + 248,
5130 EL_CUSTOM_START + 249,
5131 EL_CUSTOM_START + 250,
5132 EL_CUSTOM_START + 251,
5134 EL_CUSTOM_START + 252,
5135 EL_CUSTOM_START + 253,
5136 EL_CUSTOM_START + 254,
5137 EL_CUSTOM_START + 255
5139 static int *editor_hl_custom_ptr = editor_hl_custom;
5140 static int *editor_el_custom_ptr = editor_el_custom;
5141 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5142 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5144 static int editor_hl_group[] =
5146 EL_INTERNAL_CASCADE_GE_ACTIVE,
5152 static int editor_el_group[] =
5166 EL_GROUP_START + 10,
5167 EL_GROUP_START + 11,
5169 EL_GROUP_START + 12,
5170 EL_GROUP_START + 13,
5171 EL_GROUP_START + 14,
5172 EL_GROUP_START + 15,
5174 EL_GROUP_START + 16,
5175 EL_GROUP_START + 17,
5176 EL_GROUP_START + 18,
5177 EL_GROUP_START + 19,
5179 EL_GROUP_START + 20,
5180 EL_GROUP_START + 21,
5181 EL_GROUP_START + 22,
5182 EL_GROUP_START + 23,
5184 EL_GROUP_START + 24,
5185 EL_GROUP_START + 25,
5186 EL_GROUP_START + 26,
5187 EL_GROUP_START + 27,
5189 EL_GROUP_START + 28,
5190 EL_GROUP_START + 29,
5191 EL_GROUP_START + 30,
5194 static int *editor_hl_group_ptr = editor_hl_group;
5195 static int *editor_el_group_ptr = editor_el_group;
5196 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5197 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5199 static int editor_hl_reference[] =
5201 EL_INTERNAL_CASCADE_REF_ACTIVE,
5207 static int editor_el_reference[] =
5211 EL_TRIGGER_CE_VALUE,
5212 EL_TRIGGER_CE_SCORE,
5216 EL_CURRENT_CE_VALUE,
5217 EL_CURRENT_CE_SCORE,
5239 static int *editor_hl_reference_ptr = editor_hl_reference;
5240 static int *editor_el_reference_ptr = editor_el_reference;
5241 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5242 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5244 static int editor_hl_user_defined[] =
5246 EL_INTERNAL_CASCADE_USER_ACTIVE,
5252 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5253 static int *editor_el_user_defined_ptr = NULL;
5254 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5255 static int num_editor_el_user_defined = 0;
5257 static int editor_hl_dynamic[] =
5259 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5265 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5266 static int *editor_el_dynamic_ptr = NULL;
5267 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5268 static int num_editor_el_dynamic = 0;
5270 static int editor_hl_empty[] = { EL_EMPTY };
5271 static int *editor_el_empty = NULL; // dynamically allocated
5273 static int *editor_hl_empty_ptr = editor_hl_empty;
5274 static int *editor_el_empty_ptr = NULL;
5275 static int num_editor_hl_empty = 0;
5276 static int num_editor_el_empty = 0; // dynamically determined, if needed
5278 static boolean use_el_empty = FALSE;
5280 static int *editor_elements = NULL; // dynamically allocated
5281 static int num_editor_elements = 0; // dynamically determined
5283 static boolean setup_editor_cascade_never = FALSE;
5285 static boolean setup_editor_el_players = TRUE;
5286 static boolean setup_editor_el_boulderdash = TRUE;
5287 static boolean setup_editor_el_emerald_mine = TRUE;
5288 static boolean setup_editor_el_emerald_mine_club = TRUE;
5289 static boolean setup_editor_el_more = TRUE;
5290 static boolean setup_editor_el_sokoban = TRUE;
5291 static boolean setup_editor_el_supaplex = TRUE;
5292 static boolean setup_editor_el_diamond_caves = TRUE;
5293 static boolean setup_editor_el_dx_boulderdash = TRUE;
5294 static boolean setup_editor_el_mirror_magic = TRUE;
5295 static boolean setup_editor_el_deflektor = TRUE;
5296 static boolean setup_editor_el_chars = TRUE;
5297 static boolean setup_editor_el_steel_chars = TRUE;
5298 static boolean setup_editor_el_custom = TRUE;
5299 static boolean setup_editor_el_user_defined = TRUE;
5300 static boolean setup_editor_el_dynamic = TRUE;
5302 static int editor_hl_unused[] = { EL_EMPTY };
5303 static int *editor_hl_unused_ptr = editor_hl_unused;
5304 static int num_editor_hl_unused = 0;
5308 boolean *setup_value;
5309 boolean *setup_cascade_value;
5311 int **headline_list;
5312 int *headline_list_size;
5315 int *element_list_size;
5317 boolean last_setup_value;
5319 editor_elements_info[] =
5322 &setup_editor_el_players,
5323 &setup_editor_cascade_never,
5324 &editor_hl_unused_ptr, &num_editor_hl_unused,
5325 &editor_el_players_ptr, &num_editor_el_players
5328 &setup_editor_el_boulderdash,
5329 &setup.editor_cascade.el_bd,
5330 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5331 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5334 &setup_editor_el_emerald_mine,
5335 &setup.editor_cascade.el_em,
5336 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5337 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5340 &setup_editor_el_emerald_mine_club,
5341 &setup.editor_cascade.el_emc,
5342 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5343 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5346 &setup_editor_el_more,
5347 &setup.editor_cascade.el_rnd,
5348 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5349 &editor_el_rnd_ptr, &num_editor_el_rnd
5352 &setup_editor_el_sokoban,
5353 &setup.editor_cascade.el_sb,
5354 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5355 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5358 &setup_editor_el_supaplex,
5359 &setup.editor_cascade.el_sp,
5360 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5361 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5364 &setup_editor_el_diamond_caves,
5365 &setup.editor_cascade.el_dc,
5366 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5367 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5370 &setup_editor_el_dx_boulderdash,
5371 &setup.editor_cascade.el_dx,
5372 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5373 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
5376 &setup_editor_el_mirror_magic,
5377 &setup.editor_cascade.el_mm,
5378 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
5379 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
5382 &setup_editor_el_deflektor,
5383 &setup.editor_cascade.el_df,
5384 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
5385 &editor_el_deflektor_ptr, &num_editor_el_deflektor
5388 &setup_editor_el_chars,
5389 &setup.editor_cascade.el_chars,
5390 &editor_hl_chars_ptr, &num_editor_hl_chars,
5391 &editor_el_chars_ptr, &num_editor_el_chars
5394 &setup_editor_el_steel_chars,
5395 &setup.editor_cascade.el_steel_chars,
5396 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
5397 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
5400 &setup_editor_el_custom,
5401 &setup.editor_cascade.el_ce,
5402 &editor_hl_custom_ptr, &num_editor_hl_custom,
5403 &editor_el_custom_ptr, &num_editor_el_custom
5406 &setup_editor_el_custom,
5407 &setup.editor_cascade.el_ge,
5408 &editor_hl_group_ptr, &num_editor_hl_group,
5409 &editor_el_group_ptr, &num_editor_el_group
5412 &setup_editor_el_custom,
5413 &setup.editor_cascade.el_ref,
5414 &editor_hl_reference_ptr, &num_editor_hl_reference,
5415 &editor_el_reference_ptr, &num_editor_el_reference
5418 &setup_editor_el_user_defined,
5419 &setup.editor_cascade.el_user,
5420 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
5421 &editor_el_user_defined_ptr, &num_editor_el_user_defined
5424 &setup_editor_el_dynamic,
5425 &setup.editor_cascade.el_dynamic,
5426 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
5427 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
5432 &editor_hl_empty_ptr, &num_editor_hl_empty,
5433 &editor_el_empty_ptr, &num_editor_el_empty,
5444 // ----------------------------------------------------------------------------
5446 // ----------------------------------------------------------------------------
5448 static int getMaxInfoTextLength(void)
5450 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
5453 static int getTextWidthForGadget(char *text)
5458 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
5461 static int getTextWidthForDrawingArea(char *text)
5466 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
5469 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
5471 return (gi->x + gi->width + getTextWidthForGadget(text));
5474 static char *getElementInfoText(int element)
5476 char *info_text = NULL;
5478 if (element < MAX_NUM_ELEMENTS)
5480 if (strlen(element_info[element].description) > 0)
5481 info_text = element_info[element].description;
5482 else if (element_info[element].custom_description != NULL)
5483 info_text = element_info[element].custom_description;
5484 else if (element_info[element].editor_description != NULL)
5485 info_text = element_info[element].editor_description;
5488 if (info_text == NULL)
5489 info_text = INFOTEXT_UNKNOWN_ELEMENT;
5494 static char *getElementDescriptionFilenameExt(char *basename)
5496 char *elements_subdir = "elements";
5497 static char *elements_subdir2 = NULL;
5498 static char *filename = NULL;
5500 if (elements_subdir2 == NULL)
5501 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
5503 checked_free(filename);
5505 // 1st try: look for element description in current level set directory
5506 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
5507 if (fileExists(filename))
5512 // 2nd try: look for element description in the game's base directory
5513 filename = getPath3(options.docs_directory, elements_subdir, basename);
5514 if (fileExists(filename))
5520 static char *getElementDescriptionFilename(int element)
5522 char basename[MAX_FILENAME_LEN];
5525 // 1st try: look for element description file for exactly this element
5526 sprintf(basename, "%s.txt", element_info[element].token_name);
5527 filename = getElementDescriptionFilenameExt(basename);
5528 if (filename != NULL)
5531 // 2nd try: look for element description file for this element's class
5532 sprintf(basename, "%s.txt", element_info[element].class_name);
5533 filename = getElementDescriptionFilenameExt(basename);
5534 if (filename != NULL)
5540 static boolean suppressBorderElement(void)
5542 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
5543 lev_fieldx <= MAX_ED_FIELDX &&
5544 lev_fieldy <= MAX_ED_FIELDY);
5547 static void InitDynamicEditorElementList(int **elements, int *num_elements)
5549 boolean element_found[NUM_FILE_ELEMENTS];
5552 // initialize list of used elements to "not used"
5553 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5554 element_found[i] = FALSE;
5556 // find all elements used in current level
5557 for (y = 0; y < lev_fieldy; y++)
5558 for (x = 0; x < lev_fieldx; x++)
5559 if (Tile[x][y] < NUM_FILE_ELEMENTS) // should always be true
5560 element_found[Tile[x][y]] = TRUE;
5564 // count number of elements used in current level
5565 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5566 if (element_found[i])
5569 // add space for up to 3 more elements for padding that may be needed
5572 // free memory for old list of elements, if needed
5573 checked_free(*elements);
5575 // allocate memory for new list of elements
5576 *elements = checked_malloc(*num_elements * sizeof(int));
5580 // add all elements used in current level (non-custom/group elements)
5581 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5582 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5583 (*elements)[(*num_elements)++] = i;
5585 // add all elements used in current level (custom/group elements)
5586 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5587 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5588 (*elements)[(*num_elements)++] = i;
5590 while (*num_elements % 4) // pad with empty elements, if needed
5591 (*elements)[(*num_elements)++] = EL_EMPTY;
5594 static void ReinitializeElementList_EnableSections(void)
5596 // default: enable all element sections
5598 setup_editor_el_players = TRUE;
5599 setup_editor_el_boulderdash = TRUE;
5600 setup_editor_el_emerald_mine = TRUE;
5601 setup_editor_el_emerald_mine_club = TRUE;
5602 setup_editor_el_more = TRUE;
5603 setup_editor_el_sokoban = TRUE;
5604 setup_editor_el_supaplex = TRUE;
5605 setup_editor_el_diamond_caves = TRUE;
5606 setup_editor_el_dx_boulderdash = TRUE;
5607 setup_editor_el_mirror_magic = TRUE;
5608 setup_editor_el_deflektor = TRUE;
5609 setup_editor_el_chars = TRUE;
5610 setup_editor_el_steel_chars = TRUE;
5612 setup_editor_el_custom = TRUE;
5613 setup_editor_el_user_defined = TRUE;
5614 setup_editor_el_dynamic = TRUE;
5616 // now disable all element sections not to be displayed
5618 if (!setup.editor.el_classic)
5620 setup_editor_el_players = FALSE;
5621 setup_editor_el_boulderdash = FALSE;
5622 setup_editor_el_emerald_mine = FALSE;
5623 setup_editor_el_emerald_mine_club = FALSE;
5624 setup_editor_el_more = FALSE;
5625 setup_editor_el_sokoban = FALSE;
5626 setup_editor_el_supaplex = FALSE;
5627 setup_editor_el_diamond_caves = FALSE;
5628 setup_editor_el_dx_boulderdash = FALSE;
5629 setup_editor_el_mirror_magic = FALSE;
5630 setup_editor_el_deflektor = FALSE;
5631 setup_editor_el_chars = FALSE;
5632 setup_editor_el_steel_chars = FALSE;
5635 if (!setup.editor.el_custom)
5637 setup_editor_el_custom = FALSE;
5640 if (!setup.editor.el_user_defined)
5642 setup_editor_el_user_defined = FALSE;
5645 if (!setup.editor.el_dynamic)
5647 setup_editor_el_dynamic = FALSE;
5650 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
5652 setup_editor_el_mirror_magic = FALSE;
5653 setup_editor_el_deflektor = FALSE;
5655 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
5657 setup_editor_el_boulderdash = FALSE;
5658 setup_editor_el_more = FALSE;
5659 setup_editor_el_sokoban = FALSE;
5660 setup_editor_el_supaplex = FALSE;
5661 setup_editor_el_diamond_caves = FALSE;
5662 setup_editor_el_dx_boulderdash = FALSE;
5663 setup_editor_el_mirror_magic = FALSE;
5664 setup_editor_el_deflektor = FALSE;
5665 setup_editor_el_steel_chars = FALSE;
5667 setup_editor_el_custom = FALSE;
5669 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
5671 setup_editor_el_players = FALSE;
5672 setup_editor_el_boulderdash = FALSE;
5673 setup_editor_el_emerald_mine = FALSE;
5674 setup_editor_el_emerald_mine_club = FALSE;
5675 setup_editor_el_more = FALSE;
5676 setup_editor_el_sokoban = FALSE;
5677 setup_editor_el_diamond_caves = FALSE;
5678 setup_editor_el_dx_boulderdash = FALSE;
5679 setup_editor_el_mirror_magic = FALSE;
5680 setup_editor_el_deflektor = FALSE;
5681 setup_editor_el_chars = FALSE;
5682 setup_editor_el_steel_chars = FALSE;
5684 setup_editor_el_custom = FALSE;
5686 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
5688 setup_editor_el_players = FALSE;
5689 setup_editor_el_boulderdash = FALSE;
5690 setup_editor_el_emerald_mine = FALSE;
5691 setup_editor_el_emerald_mine_club = FALSE;
5692 setup_editor_el_more = FALSE;
5693 setup_editor_el_sokoban = FALSE;
5694 setup_editor_el_supaplex = FALSE;
5695 setup_editor_el_diamond_caves = FALSE;
5696 setup_editor_el_dx_boulderdash = FALSE;
5697 setup_editor_el_steel_chars = FALSE;
5699 setup_editor_el_custom = FALSE;
5703 static void ReinitializeElementList(void)
5705 static boolean initialization_needed = TRUE;
5709 ReinitializeElementList_EnableSections();
5711 if (initialization_needed)
5713 LoadSetup_EditorCascade(); // load last editor cascade state
5715 // initialize editor cascade element from saved cascade state
5716 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5718 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
5719 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
5721 if (IS_EDITOR_CASCADE(*cascade_element))
5723 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
5724 EL_CASCADE_INACTIVE(*cascade_element));
5727 initialization_needed = FALSE;
5730 checked_free(editor_elements);
5732 // reload optional user defined element list for each invocation of editor
5733 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
5734 &num_editor_el_user_defined);
5736 // initialize dynamic level element list for each invocation of editor
5737 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
5738 &num_editor_el_dynamic);
5740 // initialize list of empty elements (used for padding, if needed)
5741 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5742 editor_el_empty[i] = EL_EMPTY;
5744 // do some sanity checks for each element from element list
5745 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5747 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5749 int element = (*editor_elements_info[i].element_list)[j];
5751 if (element >= NUM_FILE_ELEMENTS)
5752 Warn("editor element %d is runtime element", element);
5754 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
5755 Warn("no element description text for element %d", element);
5759 num_editor_elements = 0;
5760 use_el_empty = FALSE;
5762 // determine size of element list
5763 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5765 boolean found_inactive_cascade = FALSE;
5767 if (*editor_elements_info[i].setup_value)
5769 if (setup.editor.el_headlines)
5771 // required for correct padding of palette headline buttons
5772 if (*editor_elements_info[i].headline_list_size > 0)
5773 num_editor_elements += ED_ELEMENTLIST_COLS;
5775 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5777 int element = (*editor_elements_info[i].headline_list)[j];
5779 if (IS_EDITOR_CASCADE_INACTIVE(element))
5780 found_inactive_cascade = TRUE;
5784 if (found_inactive_cascade)
5787 // required for correct padding of palette element buttons
5788 int element_list_size = *editor_elements_info[i].element_list_size;
5790 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
5791 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
5793 num_editor_elements += element_buttons;
5797 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
5799 // offer at least as many elements as element buttons exist
5800 use_el_empty = TRUE;
5801 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
5803 num_editor_elements += num_editor_el_empty;
5807 num_editor_el_empty = 0;
5810 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
5812 // fill element list
5813 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5815 boolean found_inactive_cascade = FALSE;
5817 if (*editor_elements_info[i].setup_value)
5819 if (setup.editor.el_headlines)
5821 // required for correct padding of palette headline buttons
5822 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
5823 ED_ELEMENTLIST_COLS : 0);
5825 for (j = 0; j < headline_size; j++)
5827 // use empty elements for padding of palette headline buttons
5828 int element = (j < *editor_elements_info[i].headline_list_size ?
5829 (*editor_elements_info[i].headline_list)[j] :
5830 editor_el_empty[0]);
5832 editor_elements[pos++] = element;
5834 if (IS_EDITOR_CASCADE_INACTIVE(element))
5835 found_inactive_cascade = TRUE;
5839 if (found_inactive_cascade)
5842 // required for correct padding of palette element buttons
5843 int element_list_size = *editor_elements_info[i].element_list_size;
5845 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
5846 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
5848 // copy all elements from element list
5849 for (j = 0; j < element_list_size; j++)
5850 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
5852 // use empty elements for padding of palette element buttons
5853 for (j = 0; j < element_buttons - element_list_size; j++)
5854 editor_elements[pos++] = editor_el_empty[0];
5858 // (this function is also called before editor gadgets are initialized!)
5859 AdjustElementListScrollbar();
5862 void PrintEditorElementList(void)
5864 boolean *stop = &setup_editor_el_user_defined;
5867 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
5869 int cascade_element = (*editor_elements_info[i].headline_list)[0];
5871 if (IS_EDITOR_CASCADE(cascade_element))
5873 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
5874 char *headline = element_info[cascade_element_show].editor_description;
5876 PrintLineWithPrefix("# ", "-", 77);
5877 Print("# %s\n", headline);
5878 PrintLineWithPrefix("# ", "-", 77);
5881 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5883 int element = (*editor_elements_info[i].headline_list)[j];
5885 if (IS_EDITOR_CASCADE(element))
5886 element = EL_CHAR_MINUS;
5888 Print("# %s\n", element_info[element].token_name);
5894 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5896 int element = (*editor_elements_info[i].element_list)[j];
5898 Print("# %s\n", element_info[element].token_name);
5906 static void ReinitializeElementListButtons(void)
5908 static boolean last_setup_value_headlines = FALSE;
5909 static boolean initialization_needed = TRUE;
5912 if (!initialization_needed) // check if editor element setup has changed
5914 if (last_setup_value_headlines != setup.editor.el_headlines)
5915 initialization_needed = TRUE;
5917 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5918 if (editor_elements_info[i].last_setup_value !=
5919 *editor_elements_info[i].setup_value)
5920 initialization_needed = TRUE;
5923 if (!initialization_needed)
5926 FreeLevelEditorGadgets();
5927 CreateLevelEditorGadgets();
5929 // store current setup values for next invocation of this function
5930 last_setup_value_headlines = setup.editor.el_headlines;
5931 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5932 editor_elements_info[i].last_setup_value =
5933 *editor_elements_info[i].setup_value;
5935 initialization_needed = FALSE;
5938 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
5941 int border_graphic =
5942 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
5943 struct GraphicInfo *g = &graphic_info[border_graphic];
5944 Bitmap *src_bitmap = g->bitmap;
5945 int src_x = g->src_x;
5946 int src_y = g->src_y;
5947 int border_size = g->border_size;
5948 int border_xpos = g->width - border_size;
5949 int border_ypos = g->height - border_size;
5950 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
5953 BlitBitmap(src_bitmap, drawto, src_x, src_y,
5954 border_size, border_size,
5955 dest_x - border_size, dest_y - border_size);
5956 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
5957 border_size, border_size,
5958 dest_x + width, dest_y - border_size);
5959 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
5960 border_size, border_size,
5961 dest_x - border_size, dest_y + height);
5962 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
5963 border_size, border_size,
5964 dest_x + width, dest_y + height);
5966 for (i = 0; i < width / tilesize; i++)
5968 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
5969 tilesize, border_size,
5970 dest_x + i * tilesize, dest_y - border_size);
5971 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
5972 tilesize, border_size,
5973 dest_x + i * tilesize, dest_y + height);
5976 for (i = 0; i < height / tilesize; i++)
5978 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
5979 border_size, tilesize,
5980 dest_x - border_size, dest_y + i * tilesize);
5981 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
5982 border_size, tilesize,
5983 dest_x + width, dest_y + i * tilesize);
5986 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
5989 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
5991 int xsize_tile = MAX(ed_tilesize, xsize);
5992 int ysize_tile = MAX(ed_tilesize, ysize);
5993 int xsize_full = xsize + 1;
5994 int ysize_full = ysize + 1;
5995 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
5996 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
5997 Pixel line_color = getTabulatorBarColor();
5999 if (line_color == BLACK_PIXEL) // black => transparent
6002 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6003 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6004 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6007 static void DrawEditorLevelBorderLinesIfNeeded(void)
6009 int xsize = lev_fieldx * ed_tilesize;
6010 int ysize = lev_fieldy * ed_tilesize;
6011 int line_size = getTabulatorBarHeight();
6013 if (!suppressBorderElement())
6016 // draw little border line around editable level playfield
6019 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6022 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6024 if (xsize < SXSIZE && ysize < SYSIZE)
6025 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6028 static void DrawEditorElement(int x, int y, int element)
6030 DrawSizedElement(x, y, element, ed_tilesize);
6033 static void DrawEditorElementThruMask(int x, int y, int element)
6035 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6038 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6040 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6043 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6045 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6046 DrawEditorLevelBorderLinesIfNeeded();
6049 static void DrawDrawingArea(int id)
6051 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6054 int *value = drawingarea_info[id].value;
6055 int area_xsize = drawingarea_info[id].area_xsize;
6056 int area_ysize = drawingarea_info[id].area_ysize;
6057 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6059 for (x = 0; x < area_xsize; x++)
6060 for (y = 0; y < area_ysize; y++)
6061 DrawSizedGraphicExt(drawto,
6062 gi->x + x * tilesize,
6063 gi->y + y * tilesize,
6064 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6067 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6070 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6071 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6073 BlitBitmap(drawto, drawto,
6074 SX + (dx == -1 ? ed_tilesize : 0),
6075 SY + (dy == -1 ? ed_tilesize : 0),
6076 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6077 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6078 SX + (dx == +1 ? ed_tilesize : 0),
6079 SY + (dy == +1 ? ed_tilesize : 0));
6083 x = (dx == 1 ? 0 : ed_fieldx - 1);
6084 for (y = 0; y < ed_fieldy; y++)
6085 DrawEditorElementOrWall(x, y, from_x, from_y);
6089 y = (dy == 1 ? 0 : ed_fieldy - 1);
6090 for (x = 0; x < ed_fieldx; x++)
6091 DrawEditorElementOrWall(x, y, from_x, from_y);
6094 redraw_mask |= REDRAW_FIELD;
6098 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6101 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6104 static void CreateControlButtons(void)
6106 struct GadgetInfo *gi;
6109 // create toolbox buttons
6110 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6112 int id = controlbutton_info[i].gadget_id;
6113 int type = controlbutton_info[i].gadget_type;
6114 int graphic = controlbutton_info[i].graphic;
6115 struct XYTileSize *pos = controlbutton_info[i].pos;
6116 struct GraphicInfo *gd = &graphic_info[graphic];
6117 Bitmap *deco_bitmap = NULL;
6118 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6119 int tile_size = 0, deco_shift = 0;
6120 boolean deco_masked = FALSE;
6121 int gd_x1 = gd->src_x;
6122 int gd_y1 = gd->src_y;
6123 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6124 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6125 int gd_x1a = gd->src_x + gd->active_xoffset;
6126 int gd_y1a = gd->src_y + gd->active_yoffset;
6127 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6128 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6131 unsigned int event_mask;
6132 int radio_button_nr = RADIO_NR_NONE;
6133 boolean checked = FALSE;
6135 if (type == GD_TYPE_RADIO_BUTTON)
6137 event_mask = GD_EVENT_PRESSED;
6138 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6140 if (id == drawing_function)
6145 if (id == GADGET_ID_WRAP_LEFT ||
6146 id == GADGET_ID_WRAP_RIGHT ||
6147 id == GADGET_ID_WRAP_UP ||
6148 id == GADGET_ID_WRAP_DOWN)
6149 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6151 event_mask = GD_EVENT_RELEASED;
6154 if (id == GADGET_ID_PROPERTIES ||
6155 id == GADGET_ID_PALETTE)
6160 else if (id == GADGET_ID_ELEMENT_LEFT ||
6161 id == GADGET_ID_ELEMENT_MIDDLE ||
6162 id == GADGET_ID_ELEMENT_RIGHT)
6167 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6168 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6169 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6171 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6172 editor.button.element_left.tile_size :
6173 id == GADGET_ID_ELEMENT_MIDDLE ?
6174 editor.button.element_middle.tile_size :
6175 id == GADGET_ID_ELEMENT_RIGHT ?
6176 editor.button.element_right.tile_size : 0);
6178 // make sure that decoration does not overlap gadget border
6179 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6181 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6183 deco_xpos = (gd->width - tile_size) / 2;
6184 deco_ypos = (gd->height - tile_size) / 2;
6186 deco_masked = gd->draw_masked;
6194 gi = CreateGadget(GDI_CUSTOM_ID, id,
6195 GDI_CUSTOM_TYPE_ID, i,
6196 GDI_IMAGE_ID, graphic,
6197 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6200 GDI_WIDTH, gd->width,
6201 GDI_HEIGHT, gd->height,
6203 GDI_STATE, GD_BUTTON_UNPRESSED,
6204 GDI_RADIO_NR, radio_button_nr,
6205 GDI_CHECKED, checked,
6206 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6207 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6208 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6209 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6210 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6211 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6212 GDI_DECORATION_SIZE, tile_size, tile_size,
6213 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6214 GDI_DECORATION_MASKED, deco_masked,
6215 GDI_EVENT_MASK, event_mask,
6216 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6217 GDI_CALLBACK_ACTION, HandleControlButtons,
6221 Error(ERR_EXIT, "cannot create gadget");
6223 level_editor_gadget[id] = gi;
6226 // these values are not constant, but can change at runtime
6227 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6228 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6229 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6230 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6231 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6232 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6233 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6234 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6235 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6236 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6237 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6238 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6240 // create buttons for scrolling of drawing area and element list
6241 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6243 int id = scrollbutton_info[i].gadget_id;
6244 int graphic = scrollbutton_info[i].graphic;
6245 struct GraphicInfo *gd = &graphic_info[graphic];
6246 Bitmap *gd_bitmap = gd->bitmap;
6247 int gd_x1 = gd->src_x;
6248 int gd_y1 = gd->src_y;
6249 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6250 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6251 int width = gd->width;
6252 int height = gd->height;
6253 int x = scrollbutton_pos[i].x;
6254 int y = scrollbutton_pos[i].y;
6255 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6257 if (id == GADGET_ID_SCROLL_LIST_UP ||
6258 id == GADGET_ID_SCROLL_LIST_DOWN)
6269 gi = CreateGadget(GDI_CUSTOM_ID, id,
6270 GDI_CUSTOM_TYPE_ID, i,
6271 GDI_IMAGE_ID, graphic,
6272 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6277 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6278 GDI_STATE, GD_BUTTON_UNPRESSED,
6279 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6280 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6281 GDI_EVENT_MASK, event_mask,
6282 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6283 GDI_CALLBACK_ACTION, HandleControlButtons,
6287 Error(ERR_EXIT, "cannot create gadget");
6289 level_editor_gadget[id] = gi;
6292 // create buttons for element list
6293 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6295 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6296 int graphic = IMG_EDITOR_PALETTE_BUTTON;
6297 struct GraphicInfo *gd = &graphic_info[graphic];
6298 Bitmap *gd_bitmap = gd->bitmap;
6299 Bitmap *deco_bitmap;
6300 int deco_x, deco_y, deco_xpos, deco_ypos;
6301 int gd_x1 = gd->src_x;
6302 int gd_y1 = gd->src_y;
6303 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6304 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6305 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
6306 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
6307 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
6308 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
6309 int element = editor_elements[i];
6310 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
6311 unsigned int event_mask = GD_EVENT_RELEASED;
6313 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
6315 deco_xpos = (gd->width - tile_size) / 2;
6316 deco_ypos = (gd->height - tile_size) / 2;
6318 gi = CreateGadget(GDI_CUSTOM_ID, id,
6319 GDI_CUSTOM_TYPE_ID, i,
6320 GDI_IMAGE_ID, graphic,
6321 GDI_INFO_TEXT, getElementInfoText(element),
6324 GDI_WIDTH, gd->width,
6325 GDI_HEIGHT, gd->height,
6326 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6327 GDI_STATE, GD_BUTTON_UNPRESSED,
6328 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6329 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6330 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6331 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6332 GDI_DECORATION_SIZE, tile_size, tile_size,
6333 GDI_DECORATION_SHIFTING, 1, 1,
6334 GDI_EVENT_MASK, event_mask,
6335 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6336 GDI_CALLBACK_ACTION, HandleControlButtons,
6340 Error(ERR_EXIT, "cannot create gadget");
6342 level_editor_gadget[id] = gi;
6346 static void CreateCounterButtons(void)
6348 int max_infotext_len = getMaxInfoTextLength();
6351 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
6354 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
6355 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
6357 // determine horizontal position to the right of specified gadget
6358 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6359 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
6360 ED_GADGET_TEXT_DISTANCE);
6362 // determine horizontal offset for leading text
6363 if (counterbutton_info[i].text_left != NULL)
6364 x += getTextWidthForGadget(counterbutton_info[i].text_left);
6366 for (j = 0; j < 2; j++)
6368 struct GadgetInfo *gi;
6370 counterbutton_info[i].gadget_id_down :
6371 counterbutton_info[i].gadget_id_up);
6373 struct GraphicInfo *gd;
6374 int gd_x1, gd_x2, gd_y1, gd_y2;
6375 unsigned int event_mask;
6376 char infotext[max_infotext_len + 1];
6378 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6380 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6383 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
6384 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
6386 event_mask |= GD_EVENT_RELEASED;
6390 x = DX + editor.button.prev_level.x;
6391 y = DY + editor.button.prev_level.y;
6395 x = DX + editor.button.next_level.x;
6396 y = DY + editor.button.next_level.y;
6402 IMG_EDITOR_COUNTER_DOWN :
6403 IMG_EDITOR_COUNTER_UP);
6406 gd = &graphic_info[graphic];
6410 gd_x2 = gd->src_x + gd->pressed_xoffset;
6411 gd_y2 = gd->src_y + gd->pressed_yoffset;
6413 sprintf(infotext, "%s counter value by 1, 5 or 10",
6414 (j == 0 ? "decrease" : "increase"));
6416 gi = CreateGadget(GDI_CUSTOM_ID, id,
6417 GDI_CUSTOM_TYPE_ID, i,
6418 GDI_IMAGE_ID, graphic,
6419 GDI_INFO_TEXT, infotext,
6422 GDI_WIDTH, gd->width,
6423 GDI_HEIGHT, gd->height,
6424 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6425 GDI_STATE, GD_BUTTON_UNPRESSED,
6426 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6427 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6428 GDI_EVENT_MASK, event_mask,
6429 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6430 GDI_CALLBACK_ACTION, HandleCounterButtons,
6434 Error(ERR_EXIT, "cannot create gadget");
6436 level_editor_gadget[id] = gi;
6437 right_gadget_border[id] =
6438 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6440 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
6444 int font_type = FONT_INPUT_1;
6445 int font_type_active = FONT_INPUT_1_ACTIVE;
6447 id = counterbutton_info[i].gadget_id_text;
6449 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6451 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6453 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
6455 font_type = FONT_LEVEL_NUMBER;
6456 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
6458 x = DX + editor.input.level_number.x;
6459 y = DY + editor.input.level_number.y;
6463 graphic = IMG_EDITOR_COUNTER_INPUT;
6466 gd = &graphic_info[graphic];
6470 gd_x2 = gd->src_x + gd->active_xoffset;
6471 gd_y2 = gd->src_y + gd->active_yoffset;
6473 gi = CreateGadget(GDI_CUSTOM_ID, id,
6474 GDI_CUSTOM_TYPE_ID, i,
6475 GDI_IMAGE_ID, graphic,
6476 GDI_INFO_TEXT, "enter counter value",
6479 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
6480 GDI_NUMBER_VALUE, 0,
6481 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
6482 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
6483 GDI_TEXT_SIZE, 3, // minimal counter text size
6484 GDI_TEXT_FONT, font_type,
6485 GDI_TEXT_FONT_ACTIVE, font_type_active,
6486 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6487 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6488 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6489 GDI_DESIGN_WIDTH, gd->width,
6490 GDI_EVENT_MASK, event_mask,
6491 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6492 GDI_CALLBACK_ACTION, HandleCounterButtons,
6496 Error(ERR_EXIT, "cannot create gadget");
6498 level_editor_gadget[id] = gi;
6499 right_gadget_border[id] =
6500 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6502 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
6508 static void CreateDrawingAreas(void)
6512 // these values are not constant, but can change at runtime
6513 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
6514 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
6516 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
6518 struct GadgetInfo *gi;
6519 unsigned int event_mask;
6520 int id = drawingarea_info[i].gadget_id;
6521 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
6522 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
6523 int area_xsize = drawingarea_info[i].area_xsize;
6524 int area_ysize = drawingarea_info[i].area_ysize;
6525 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
6526 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
6529 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
6530 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
6532 // determine horizontal position to the right of specified gadget
6533 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
6534 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
6535 ED_DRAWINGAREA_TEXT_DISTANCE);
6537 // determine horizontal offset for leading text
6538 if (drawingarea_info[i].text_left != NULL)
6539 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
6541 gi = CreateGadget(GDI_CUSTOM_ID, id,
6542 GDI_CUSTOM_TYPE_ID, i,
6545 GDI_TYPE, GD_TYPE_DRAWING_AREA,
6546 GDI_AREA_SIZE, area_xsize, area_ysize,
6547 GDI_ITEM_SIZE, item_size, item_size,
6548 GDI_EVENT_MASK, event_mask,
6549 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
6550 GDI_CALLBACK_ACTION, HandleDrawingAreas,
6554 Error(ERR_EXIT, "cannot create gadget");
6556 level_editor_gadget[id] = gi;
6557 right_gadget_border[id] =
6558 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
6562 static void CreateTextInputGadgets(void)
6564 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
6565 int max_infotext_len = getMaxInfoTextLength();
6568 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
6570 int gd_x1 = gd->src_x;
6571 int gd_y1 = gd->src_y;
6572 int gd_x2 = gd->src_x + gd->active_xoffset;
6573 int gd_y2 = gd->src_y + gd->active_yoffset;
6574 struct GadgetInfo *gi;
6575 unsigned int event_mask;
6576 char infotext[MAX_OUTPUT_LINESIZE + 1];
6577 int id = textinput_info[i].gadget_id;
6580 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
6582 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
6583 int border_size = gd->border_size;
6584 int font_nr = FONT_INPUT_1;
6585 int font_height = getFontHeight(font_nr);
6586 int xoffset = element_border + TILEX + element_border + 3 * border_size;
6587 int yoffset = element_border + (TILEY - font_height) / 2;
6589 x = (editor.settings.element_name.x != -1 ?
6590 editor.settings.element_name.x :
6591 editor.settings.element_graphic.x + xoffset) - border_size;
6592 y = (editor.settings.element_name.y != -1 ?
6593 editor.settings.element_name.y :
6594 editor.settings.element_graphic.y + yoffset) - border_size;
6598 x = ED_SETTINGS_X(textinput_info[i].x);
6599 y = ED_SETTINGS_Y(textinput_info[i].y);
6602 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6604 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
6605 infotext[max_infotext_len] = '\0';
6607 gi = CreateGadget(GDI_CUSTOM_ID, id,
6608 GDI_CUSTOM_TYPE_ID, i,
6609 GDI_INFO_TEXT, infotext,
6612 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
6613 GDI_TEXT_VALUE, textinput_info[i].value,
6614 GDI_TEXT_SIZE, textinput_info[i].size,
6615 GDI_TEXT_FONT, FONT_INPUT_1,
6616 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6617 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6618 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6619 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6620 GDI_DESIGN_WIDTH, gd->width,
6621 GDI_EVENT_MASK, event_mask,
6622 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6623 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
6627 Error(ERR_EXIT, "cannot create gadget");
6629 level_editor_gadget[id] = gi;
6633 static void CreateTextAreaGadgets(void)
6635 int max_infotext_len = getMaxInfoTextLength();
6638 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
6640 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
6641 int gd_x1 = gd->src_x;
6642 int gd_y1 = gd->src_y;
6643 int gd_x2 = gd->src_x + gd->active_xoffset;
6644 int gd_y2 = gd->src_y + gd->active_yoffset;
6645 struct GadgetInfo *gi;
6646 unsigned int event_mask;
6647 char infotext[MAX_OUTPUT_LINESIZE + 1];
6648 int id = textarea_info[i].gadget_id;
6649 int area_xsize = textarea_info[i].xsize;
6650 int area_ysize = textarea_info[i].ysize;
6652 event_mask = GD_EVENT_TEXT_LEAVING;
6654 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
6655 infotext[max_infotext_len] = '\0';
6657 gi = CreateGadget(GDI_CUSTOM_ID, id,
6658 GDI_CUSTOM_TYPE_ID, i,
6659 GDI_INFO_TEXT, infotext,
6660 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
6661 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
6662 GDI_TYPE, GD_TYPE_TEXT_AREA,
6663 GDI_AREA_SIZE, area_xsize, area_ysize,
6664 GDI_TEXT_FONT, FONT_INPUT_1,
6665 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6666 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6667 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6668 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6669 GDI_DESIGN_WIDTH, gd->width,
6670 GDI_EVENT_MASK, event_mask,
6671 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6672 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
6676 Error(ERR_EXIT, "cannot create gadget");
6678 level_editor_gadget[id] = gi;
6682 static void CreateSelectboxGadgets(void)
6684 int max_infotext_len = getMaxInfoTextLength();
6687 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6689 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
6690 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
6691 int gd_x1 = gd->src_x;
6692 int gd_y1 = gd->src_y;
6693 int gd_x2 = gd->src_x + gd->active_xoffset;
6694 int gd_y2 = gd->src_y + gd->active_yoffset;
6695 int selectbox_button_xsize = gd2->width;
6696 struct GadgetInfo *gi;
6697 unsigned int event_mask;
6698 char infotext[MAX_OUTPUT_LINESIZE + 1];
6699 int id = selectbox_info[i].gadget_id;
6700 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
6701 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
6703 if (selectbox_info[i].size == -1) // dynamically determine size
6705 // (we cannot use -1 for uninitialized values if we directly compare
6706 // with results from strlen(), because the '<' and '>' operation will
6707 // implicitely cast -1 to an unsigned integer value!)
6708 selectbox_info[i].size = 0;
6710 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
6711 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
6712 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
6714 selectbox_info[i].size++; // add one character empty space
6717 event_mask = GD_EVENT_RELEASED |
6718 GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6720 // determine horizontal position to the right of specified gadget
6721 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
6722 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
6723 ED_GADGET_TEXT_DISTANCE);
6725 // determine horizontal offset for leading text
6726 if (selectbox_info[i].text_left != NULL)
6727 x += getTextWidthForGadget(selectbox_info[i].text_left);
6729 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
6730 infotext[max_infotext_len] = '\0';
6732 gi = CreateGadget(GDI_CUSTOM_ID, id,
6733 GDI_CUSTOM_TYPE_ID, i,
6734 GDI_INFO_TEXT, infotext,
6737 GDI_TYPE, GD_TYPE_SELECTBOX,
6738 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
6739 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
6740 GDI_TEXT_SIZE, selectbox_info[i].size,
6741 GDI_TEXT_FONT, FONT_INPUT_1,
6742 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6743 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
6744 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6745 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6746 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6747 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
6748 GDI_DESIGN_WIDTH, gd->width,
6749 GDI_EVENT_MASK, event_mask,
6750 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6751 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
6755 Error(ERR_EXIT, "cannot create gadget");
6757 level_editor_gadget[id] = gi;
6758 right_gadget_border[id] =
6759 getRightGadgetBorder(gi, selectbox_info[i].text_right);
6763 static void CreateTextbuttonGadgets(void)
6765 int max_infotext_len = getMaxInfoTextLength();
6768 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
6770 int id = textbutton_info[i].gadget_id;
6772 ((id >= GADGET_ID_LEVELINFO_LEVEL && id <= GADGET_ID_LEVELINFO_EDITOR) ||
6773 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
6775 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
6776 int gadget_distance =
6777 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
6778 struct GraphicInfo *gd = &graphic_info[graphic];
6779 int gd_x1 = gd->src_x;
6780 int gd_y1 = gd->src_y;
6781 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6782 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6783 int gd_x1a = gd->src_x + gd->active_xoffset;
6784 int gd_y1a = gd->src_y + gd->active_yoffset;
6785 int border_xsize = gd->border_size + gd->draw_xoffset;
6786 int border_ysize = gd->border_size;
6787 struct GadgetInfo *gi;
6788 unsigned int event_mask;
6789 char infotext[MAX_OUTPUT_LINESIZE + 1];
6790 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
6791 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
6793 if (textbutton_info[i].size == -1) // dynamically determine size
6794 textbutton_info[i].size = strlen(textbutton_info[i].text);
6796 event_mask = GD_EVENT_RELEASED;
6798 sprintf(infotext, "%s", textbutton_info[i].infotext);
6799 infotext[max_infotext_len] = '\0';
6801 // determine horizontal position to the right of specified gadget
6802 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6804 int gadget_id_align = textbutton_info[i].gadget_id_align;
6806 x = right_gadget_border[gadget_id_align] + gadget_distance;
6808 if (textbutton_info[i].y == -1)
6809 y = level_editor_gadget[gadget_id_align]->y;
6812 // determine horizontal offset for leading text
6813 if (textbutton_info[i].text_left != NULL)
6814 x += getTextWidthForGadget(textbutton_info[i].text_left);
6816 gi = CreateGadget(GDI_CUSTOM_ID, id,
6817 GDI_CUSTOM_TYPE_ID, i,
6818 GDI_IMAGE_ID, graphic,
6819 GDI_INFO_TEXT, infotext,
6822 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
6823 GDI_TEXT_VALUE, textbutton_info[i].text,
6824 GDI_TEXT_SIZE, textbutton_info[i].size,
6825 GDI_TEXT_FONT, FONT_INPUT_2,
6826 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
6827 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6828 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6829 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6830 GDI_BORDER_SIZE, border_xsize, border_ysize,
6831 GDI_DESIGN_WIDTH, gd->width,
6832 GDI_DECORATION_SHIFTING, 1, 1,
6833 GDI_EVENT_MASK, event_mask,
6834 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6835 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
6839 Error(ERR_EXIT, "cannot create gadget");
6841 level_editor_gadget[id] = gi;
6842 right_gadget_border[id] =
6843 getRightGadgetBorder(gi, textbutton_info[i].text_right);
6847 static void CreateGraphicbuttonGadgets(void)
6849 struct GadgetInfo *gi;
6850 unsigned int event_mask;
6853 // create buttons for scrolling of drawing area and element list
6854 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
6856 int id = graphicbutton_info[i].gadget_id;
6857 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
6858 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
6859 int graphic = graphicbutton_info[i].graphic;
6860 struct GraphicInfo *gd = &graphic_info[graphic];
6861 int gd_x1 = gd->src_x;
6862 int gd_y1 = gd->src_y;
6863 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6864 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6866 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6868 // determine horizontal position to the right of specified gadget
6869 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6870 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
6871 ED_GADGET_TEXT_DISTANCE);
6873 // determine horizontal offset for leading text
6874 if (graphicbutton_info[i].text_left != NULL)
6875 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
6877 gi = CreateGadget(GDI_CUSTOM_ID, id,
6878 GDI_CUSTOM_TYPE_ID, i,
6879 GDI_IMAGE_ID, graphic,
6880 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
6883 GDI_WIDTH, gd->width,
6884 GDI_HEIGHT, gd->height,
6885 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6886 GDI_STATE, GD_BUTTON_UNPRESSED,
6887 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6888 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6889 GDI_EVENT_MASK, event_mask,
6890 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6891 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
6895 Error(ERR_EXIT, "cannot create gadget");
6897 level_editor_gadget[id] = gi;
6898 right_gadget_border[id] =
6899 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
6903 static void CreateScrollbarGadgets(void)
6907 // these values are not constant, but can change at runtime
6908 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
6909 SX + ED_SCROLL_HORIZONTAL_XPOS;
6910 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
6911 SY + ED_SCROLL_HORIZONTAL_YPOS;
6912 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
6913 ED_SCROLL_HORIZONTAL_XSIZE;
6914 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
6915 ED_SCROLL_HORIZONTAL_YSIZE;
6916 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
6917 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
6918 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
6919 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
6921 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
6922 SX + ED_SCROLL_VERTICAL_XPOS;
6923 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
6924 SY + ED_SCROLL_VERTICAL_YPOS;
6925 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
6926 ED_SCROLL_VERTICAL_XSIZE;
6927 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
6928 ED_SCROLL_VERTICAL_YSIZE;
6929 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
6930 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
6931 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
6932 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
6934 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
6935 PX + ED_SCROLL2_VERTICAL_XPOS;
6936 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
6937 PY + ED_SCROLL2_VERTICAL_YPOS;
6938 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
6939 ED_SCROLL2_VERTICAL_XSIZE;
6940 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
6941 ED_SCROLL2_VERTICAL_YSIZE;
6942 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
6943 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
6944 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
6945 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
6947 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
6949 int id = scrollbar_info[i].gadget_id;
6950 int graphic = scrollbar_info[i].graphic;
6951 struct GraphicInfo *gd = &graphic_info[graphic];
6952 int gd_x1 = gd->src_x;
6953 int gd_y1 = gd->src_y;
6954 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6955 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6956 struct GadgetInfo *gi;
6957 int items_max, items_visible, item_position;
6958 unsigned int event_mask;
6960 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
6962 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
6963 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
6964 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
6966 else // drawing area scrollbars
6968 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
6970 items_max = MAX(lev_fieldx + 2, ed_fieldx);
6971 items_visible = ed_fieldx;
6976 items_max = MAX(lev_fieldy + 2, ed_fieldy);
6977 items_visible = ed_fieldy;
6982 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6984 gi = CreateGadget(GDI_CUSTOM_ID, id,
6985 GDI_CUSTOM_TYPE_ID, i,
6986 GDI_IMAGE_ID, graphic,
6987 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6988 GDI_X, scrollbar_pos[i].x,
6989 GDI_Y, scrollbar_pos[i].y,
6990 GDI_WIDTH, scrollbar_pos[i].width,
6991 GDI_HEIGHT, scrollbar_pos[i].height,
6992 GDI_TYPE, scrollbar_info[i].type,
6993 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6994 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6995 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6996 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
6997 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
6998 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
6999 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7000 GDI_STATE, GD_BUTTON_UNPRESSED,
7001 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7002 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7003 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7004 GDI_EVENT_MASK, event_mask,
7005 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7006 GDI_CALLBACK_ACTION, HandleControlButtons,
7010 Error(ERR_EXIT, "cannot create gadget");
7012 level_editor_gadget[id] = gi;
7016 static void CreateCheckbuttonGadgets(void)
7018 struct GadgetInfo *gi;
7019 unsigned int event_mask;
7022 event_mask = GD_EVENT_PRESSED;
7024 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7026 int id = checkbutton_info[i].gadget_id;
7027 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7028 IMG_EDITOR_CHECKBOX);
7029 struct GraphicInfo *gd = &graphic_info[graphic];
7030 int gd_x1 = gd->src_x;
7031 int gd_y1 = gd->src_y;
7032 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7033 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7034 int gd_x1a = gd->src_x + gd->active_xoffset;
7035 int gd_y1a = gd->src_y + gd->active_yoffset;
7036 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7037 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7038 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7039 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7041 // determine horizontal position to the right of specified gadget
7042 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7043 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7044 ED_GADGET_TEXT_DISTANCE);
7046 // determine horizontal offset for leading text
7047 if (checkbutton_info[i].text_left != NULL)
7048 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7050 gi = CreateGadget(GDI_CUSTOM_ID, id,
7051 GDI_CUSTOM_TYPE_ID, i,
7052 GDI_IMAGE_ID, graphic,
7053 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7056 GDI_WIDTH, gd->width,
7057 GDI_HEIGHT, gd->height,
7058 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7059 GDI_CHECKED, *checkbutton_info[i].value,
7060 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7061 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7062 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7063 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7064 GDI_EVENT_MASK, event_mask,
7065 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7066 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7070 Error(ERR_EXIT, "cannot create gadget");
7072 level_editor_gadget[id] = gi;
7073 right_gadget_border[id] =
7074 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7078 static void CreateRadiobuttonGadgets(void)
7080 int graphic = IMG_EDITOR_RADIOBUTTON;
7081 struct GraphicInfo *gd = &graphic_info[graphic];
7082 int gd_x1 = gd->src_x;
7083 int gd_y1 = gd->src_y;
7084 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7085 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7086 int gd_x1a = gd->src_x + gd->active_xoffset;
7087 int gd_y1a = gd->src_y + gd->active_yoffset;
7088 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7089 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7090 struct GadgetInfo *gi;
7091 unsigned int event_mask;
7094 event_mask = GD_EVENT_PRESSED;
7096 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7098 int id = radiobutton_info[i].gadget_id;
7099 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7100 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7103 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7105 // determine horizontal position to the right of specified gadget
7106 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7107 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7108 ED_GADGET_TEXT_DISTANCE);
7110 // determine horizontal offset for leading text
7111 if (radiobutton_info[i].text_left != NULL)
7112 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7114 gi = CreateGadget(GDI_CUSTOM_ID, id,
7115 GDI_CUSTOM_TYPE_ID, i,
7116 GDI_IMAGE_ID, graphic,
7117 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7120 GDI_WIDTH, gd->width,
7121 GDI_HEIGHT, gd->height,
7122 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7123 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7124 GDI_CHECKED, checked,
7125 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7126 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7127 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7128 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7129 GDI_EVENT_MASK, event_mask,
7130 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7131 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7135 Error(ERR_EXIT, "cannot create gadget");
7137 level_editor_gadget[id] = gi;
7138 right_gadget_border[id] =
7139 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7143 void CreateLevelEditorGadgets(void)
7145 // force EDITOR font inside level editor
7146 SetFontStatus(GAME_MODE_EDITOR);
7148 // these values are not constant, but can change at runtime
7149 ed_fieldx = MAX_ED_FIELDX - 1;
7150 ed_fieldy = MAX_ED_FIELDY - 1;
7152 num_editor_gadgets = NUM_EDITOR_GADGETS;
7154 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7156 level_editor_gadget =
7157 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7158 right_gadget_border =
7159 checked_calloc(num_editor_gadgets * sizeof(int));
7161 // set number of empty (padding) element buttons to maximum number of buttons
7162 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7164 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7165 editor_el_empty_ptr = editor_el_empty;
7167 use_permanent_palette = !editor.palette.show_as_separate_screen;
7169 ReinitializeElementList();
7171 CreateControlButtons();
7172 CreateScrollbarGadgets();
7174 // order of function calls is important because of cross-references
7175 CreateCheckbuttonGadgets();
7176 CreateCounterButtons();
7177 CreateRadiobuttonGadgets();
7178 CreateTextInputGadgets();
7179 CreateTextAreaGadgets();
7180 CreateSelectboxGadgets();
7181 CreateGraphicbuttonGadgets();
7182 CreateTextbuttonGadgets();
7183 CreateDrawingAreas();
7188 void FreeLevelEditorGadgets(void)
7192 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
7194 for (i = 0; i < num_editor_gadgets; i++)
7196 FreeGadget(level_editor_gadget[i]);
7198 level_editor_gadget[i] = NULL;
7201 checked_free(level_editor_gadget);
7202 checked_free(right_gadget_border);
7204 checked_free(editor_el_empty);
7207 static void MapCounterButtons(int id)
7209 int font_nr = FONT_TEXT_1;
7210 int font_height = getFontHeight(font_nr);
7211 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7212 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7213 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7214 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7215 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7216 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7217 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7218 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7219 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7220 int yoffset = (gi_down->height - font_height) / 2;
7221 int x_left = gi_down->x - xoffset_left;
7222 int x_right; // set after gadget position was modified
7223 int y_above = gi_down->y - yoffset_above;
7225 int y; // set after gadget position was modified
7227 // counter limits must be changed first to prevent value truncation
7228 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7229 counterbutton_info[id].max_value);
7231 // right text position might have changed after setting position above
7232 x_right = gi_up->x + gi_up->width + xoffset_right;
7234 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7236 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
7237 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7238 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7240 ModifyGadget(gi_down, GDI_Y,
7241 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7242 ModifyGadget(gi_text, GDI_Y,
7243 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7244 ModifyGadget(gi_up, GDI_Y,
7245 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7248 // vertical position might have changed after setting position above
7249 y = gi_up->y + yoffset;
7251 if (counterbutton_info[id].text_above)
7252 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
7254 if (counterbutton_info[id].text_left)
7255 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7257 if (counterbutton_info[id].text_right)
7258 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7265 static void MapControlButtons(void)
7270 // map toolbox buttons (excluding special CE toolbox buttons)
7271 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7272 MapGadget(level_editor_gadget[i]);
7274 // map toolbox buttons (element properties buttons)
7275 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
7276 MapGadget(level_editor_gadget[i]);
7278 if (use_permanent_palette)
7280 // map buttons to select elements
7281 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7282 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
7283 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
7284 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
7285 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
7288 // map buttons to select level
7289 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
7290 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
7291 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
7292 MapCounterButtons(counter_id);
7295 static void MapDrawingArea(int id)
7297 int font_nr = FONT_TEXT_1;
7298 int font_height = getFontHeight(font_nr);
7299 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7300 int area_xsize = gi->drawing.area_xsize;
7301 int area_ysize = gi->drawing.area_ysize;
7302 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7303 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
7304 int x_left = gi->x - xoffset_left;
7305 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
7306 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
7307 int x_below = gi->x + (gi->width - xoffset_below) / 2;
7308 int y_side = gi->y + (gi->height - font_height) / 2;
7309 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
7310 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
7312 if (drawingarea_info[id].text_left)
7313 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
7315 if (drawingarea_info[id].text_right)
7316 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
7318 if (drawingarea_info[id].text_above)
7319 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
7321 if (drawingarea_info[id].text_below)
7322 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
7324 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
7326 DrawElementBorder(gi->x, gi->y,
7327 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
7328 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
7330 DrawDrawingArea(id);
7336 static void MapTextInputGadget(int id)
7338 int font_nr = FONT_TEXT_1;
7339 int font_height = getFontHeight(font_nr);
7340 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
7341 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7342 int x_above = ED_SETTINGS_X(textinput_info[id].x);
7343 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
7345 if (textinput_info[id].text_above)
7346 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
7348 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
7353 static void MapTextAreaGadget(int id)
7355 int font_nr = FONT_TEXT_1;
7356 int font_height = getFontHeight(font_nr);
7357 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7358 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7359 int x_above = ED_SETTINGS_X(textarea_info[id].x);
7360 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
7362 if (textarea_info[id].text_above)
7363 DrawTextS(x_above, y_above, font_nr, textarea_info[id].text_above);
7365 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
7370 static void MapSelectboxGadget(int id)
7372 int font_nr = FONT_TEXT_1;
7373 int font_height = getFontHeight(font_nr);
7374 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
7375 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
7376 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7377 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7378 int yoffset = (gi->height - font_height) / 2;
7379 int x_left = gi->x - xoffset_left;
7380 int x_right = gi->x + gi->width + xoffset_right;
7381 int y_above = gi->y - yoffset_above;
7383 int y = gi->y + yoffset;
7385 if (selectbox_info[id].text_above)
7386 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
7388 if (selectbox_info[id].text_left)
7389 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
7391 if (selectbox_info[id].text_right)
7392 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
7394 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
7399 static void MapTextbuttonGadget(int id)
7401 int font_nr = FONT_TEXT_1;
7402 int font_height = getFontHeight(font_nr);
7403 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
7404 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
7405 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7406 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7407 int yoffset = (gi->height - font_height) / 2;
7408 int x_left = gi->x - xoffset_left;
7409 int x_right = gi->x + gi->width + xoffset_right;
7410 int y_above = gi->y - yoffset_above;
7412 int y = gi->y + yoffset;
7414 // only show button to delete change pages when more than minimum pages
7415 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
7416 custom_element.num_change_pages == MIN_CHANGE_PAGES)
7419 if (textbutton_info[id].text_above)
7420 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
7422 if (textbutton_info[id].text_left)
7423 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
7425 if (textbutton_info[id].text_right)
7426 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
7431 static void MapGraphicbuttonGadget(int id)
7433 int font_nr = FONT_TEXT_1;
7434 int font_height = getFontHeight(font_nr);
7435 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
7436 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
7437 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7438 int yoffset = (gi->height - font_height) / 2;
7439 int x_left = gi->x - xoffset_left;
7440 int x_right = gi->x + gi->width + xoffset_right;
7441 int y = gi->y + yoffset;
7443 if (graphicbutton_info[id].text_left)
7444 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
7446 if (graphicbutton_info[id].text_right)
7447 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
7452 static void MapRadiobuttonGadget(int id)
7454 int font_nr = FONT_TEXT_1;
7455 int font_height = getFontHeight(font_nr);
7456 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
7457 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7458 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7459 int yoffset = (gi->height - font_height) / 2;
7460 int x_left = gi->x - xoffset_left;
7461 int x_right = gi->x + gi->width + xoffset_right;
7462 int y = gi->y + yoffset;
7464 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
7466 if (radiobutton_info[id].text_left)
7467 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
7469 if (radiobutton_info[id].text_right)
7470 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
7472 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
7477 static void MapCheckbuttonGadget(int id)
7479 int font_nr = FONT_TEXT_1;
7480 int font_height = getFontHeight(font_nr);
7481 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
7482 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7483 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7484 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7485 int yoffset = (gi->height - font_height) / 2;
7486 int y_above = gi->y - yoffset_above;
7488 int x_left, x_right, y; // set after gadget position was modified
7490 // set position for gadgets with dynamically determined position
7491 if (checkbutton_info[id].x != -1) // do not change dynamic positions
7492 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x),GDI_END);
7493 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
7495 x_left = gi->x - xoffset_left;
7496 x_right = gi->x + gi->width + xoffset_right;
7497 y = gi->y + yoffset;
7499 if (checkbutton_info[id].text_above)
7500 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
7502 if (checkbutton_info[id].text_left)
7503 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
7505 if (checkbutton_info[id].text_right)
7506 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
7508 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
7513 static void MapMainDrawingArea(void)
7515 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
7516 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
7519 if (suppressBorderElement())
7521 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
7522 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
7525 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
7527 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
7528 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
7529 no_horizontal_scrollbar) ||
7530 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
7531 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
7532 no_vertical_scrollbar))
7535 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
7538 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
7540 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
7541 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
7544 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
7547 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
7550 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
7554 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
7556 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
7557 i == GADGET_ID_CUSTOM_COPY_TO ||
7558 i == GADGET_ID_CUSTOM_EXCHANGE ||
7559 i == GADGET_ID_CUSTOM_COPY ||
7560 i == GADGET_ID_CUSTOM_PASTE)
7563 MapGadget(level_editor_gadget[i]);
7565 UnmapGadget(level_editor_gadget[i]);
7570 static void MapLevelEditorToolboxCustomGadgets(void)
7572 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
7575 static void UnmapLevelEditorToolboxCustomGadgets(void)
7577 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
7580 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
7584 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
7586 if (i != GADGET_ID_SINGLE_ITEMS &&
7587 i != GADGET_ID_PICK_ELEMENT)
7589 struct GadgetInfo *gi = level_editor_gadget[i];
7597 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
7598 struct GraphicInfo *gd = &graphic_info[graphic];
7602 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
7603 gi->width, gi->height, gi->x, gi->y);
7605 redraw_mask |= REDRAW_DOOR_3;
7611 static void MapLevelEditorToolboxDrawingGadgets(void)
7613 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
7616 static void UnmapLevelEditorToolboxDrawingGadgets(void)
7618 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
7621 static void UnmapDrawingArea(int id)
7623 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
7626 static void UnmapLevelEditorFieldGadgets(void)
7630 for (i = 0; i < num_editor_gadgets; i++)
7631 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
7632 level_editor_gadget[i]->y))
7633 UnmapGadget(level_editor_gadget[i]);
7636 void UnmapLevelEditorGadgets(void)
7640 for (i = 0; i < num_editor_gadgets; i++)
7641 UnmapGadget(level_editor_gadget[i]);
7644 static void ResetUndoBuffer(void)
7646 undo_buffer_position = -1;
7647 undo_buffer_steps = -1;
7648 redo_buffer_steps = 0;
7650 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7652 level.changed = FALSE;
7655 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
7657 if (remap_toolbox_gadgets)
7659 ModifyEditorElementList();
7660 RedrawDrawingElements();
7663 if (edit_mode == ED_MODE_INFO)
7664 DrawLevelInfoWindow();
7665 else if (edit_mode == ED_MODE_PROPERTIES)
7666 DrawPropertiesWindow();
7667 else if (edit_mode == ED_MODE_PALETTE)
7668 DrawPaletteWindow();
7669 else // edit_mode == ED_MODE_DRAWING
7670 DrawDrawingWindowExt(remap_toolbox_gadgets);
7673 static void DrawEditModeWindow(void)
7675 DrawEditModeWindowExt(TRUE);
7678 static void DrawEditModeWindow_PlayfieldOnly(void)
7680 DrawEditModeWindowExt(FALSE);
7683 static void ChangeEditModeWindow(int new_edit_mode)
7685 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
7687 DrawEditModeWindow();
7690 static boolean LevelChanged(void)
7692 boolean field_changed = FALSE;
7695 for (y = 0; y < lev_fieldy; y++)
7696 for (x = 0; x < lev_fieldx; x++)
7697 if (Tile[x][y] != level.field[x][y])
7698 field_changed = TRUE;
7700 return (level.changed || field_changed);
7703 static boolean PrepareSavingIntoPersonalLevelSet(void)
7705 static LevelDirTree *last_copied_leveldir = NULL;
7706 static LevelDirTree *last_written_leveldir = NULL;
7707 static int last_copied_level_nr = -1;
7708 static int last_written_level_nr = -1;
7709 LevelDirTree *leveldir_former = leveldir_current;
7710 int level_nr_former = level_nr;
7713 // remember last mod/save so that for current session, we write
7714 // back to the same personal copy, asking only about overwrite.
7715 if (leveldir_current == last_copied_leveldir &&
7716 level_nr == last_copied_level_nr)
7718 // "cd" to personal level set dir (as used when writing last copy)
7719 leveldir_current = last_written_leveldir;
7720 level_nr = last_written_level_nr;
7725 if (!Request("This level is read only! "
7726 "Save into personal level set?", REQ_ASK))
7729 // "cd" to personal level set dir (for writing copy the first time)
7731 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
7733 // this may happen if "setup.internal.create_user_levelset" is FALSE
7734 // or if file "levelinfo.conf" is missing in personal user level set
7735 if (leveldir_current == NULL)
7737 Request("Cannot find personal level set?!", REQ_CONFIRM);
7739 leveldir_current = leveldir_former;
7744 // find unused level number
7745 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
7747 static char *level_filename = NULL;
7749 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
7751 if (!fileExists(level_filename))
7755 last_copied_leveldir = leveldir_former;
7756 last_copied_level_nr = level_nr_former;
7758 last_written_leveldir = leveldir_current;
7759 last_written_level_nr = level_nr = new_level_nr;
7764 static void ModifyLevelInfoForSavingIntoPersonalLevelSet(char *former_name)
7766 static char *filename_levelinfo = NULL, *mod_name = NULL;
7769 // annotate this copy-and-mod in personal levelinfo.conf
7770 setString(&filename_levelinfo,
7771 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
7773 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
7775 fprintf(file, "\n");
7776 fprintf(file, "# level %d was modified from:\n", level_nr);
7777 fprintf(file, "# - previous level set name: %s\n",
7779 fprintf(file, "# - level within previous set: %d \"%s\"\n",
7780 level.file_info.nr, level.name);
7781 fprintf(file, "# - previous author: %s\n",
7783 fprintf(file, "# - previous save date: ");
7785 if (level.creation_date.src == DATE_SRC_LEVELFILE)
7787 fprintf(file, "%04d-%02d-%02d\n",
7788 level.creation_date.year,
7789 level.creation_date.month,
7790 level.creation_date.day);
7794 fprintf(file, "not recorded\n");
7800 if (level_nr > leveldir_current->last_level)
7801 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
7803 // else: allow the save even if annotation failed
7805 // now... spray graffiti on the old level vital statistics
7806 // user can change these; just trying to set a good baseline
7808 // don't truncate names for fear of making offensive or silly:
7809 // long-named original author only recorded in levelinfo.conf.
7810 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
7811 if (!strEqual(level.author, leveldir_current->author))
7813 setString(&mod_name, getStringCat3(leveldir_current->author,
7814 " after ", level.author));
7816 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7817 setString(&mod_name,
7818 getStringCat2(leveldir_current->author, " (ed.)"));
7820 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7821 setString(&mod_name, leveldir_current->author);
7823 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
7825 // less worried about truncation here
7826 setString(&mod_name, getStringCat2("Mod: ", level.name));
7827 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
7831 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
7832 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
7836 for (x = 0; x < lev_fieldx; x++)
7837 for (y = 0; y < lev_fieldy; y++)
7838 dst[x][y] = src[x][y];
7841 static int setSelectboxValue(int selectbox_id, int new_value)
7843 int new_index_value = 0;
7846 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
7847 if (selectbox_info[selectbox_id].options[i].value == new_value)
7848 new_index_value = i;
7850 *selectbox_info[selectbox_id].value =
7851 selectbox_info[selectbox_id].options[new_index_value].value;
7853 return new_index_value;
7856 static void setSelectboxSpecialActionVariablesIfNeeded(void)
7860 // change action mode and arg variables according to action type variable
7861 for (i = 0; action_arg_options[i].value != -1; i++)
7863 if (action_arg_options[i].value == custom_element_change.action_type)
7865 int mode = action_arg_options[i].mode;
7867 // only change if corresponding selectbox has changed
7868 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
7869 action_arg_modes[mode])
7870 custom_element_change.action_mode = -1;
7872 // only change if corresponding selectbox has changed
7873 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
7874 action_arg_options[i].options)
7875 custom_element_change.action_arg = -1;
7882 static void setSelectboxSpecialActionOptions(void)
7886 // change action mode and arg selectbox according to action type selectbox
7887 for (i = 0; action_arg_options[i].value != -1; i++)
7889 if (action_arg_options[i].value == custom_element_change.action_type)
7891 int mode = action_arg_options[i].mode;
7893 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
7894 action_arg_modes[mode]);
7895 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
7896 custom_element_change.action_mode);
7898 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
7899 action_arg_options[i].options);
7900 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
7901 custom_element_change.action_arg);
7907 static void copy_custom_element_settings(int element_from, int element_to)
7909 struct ElementInfo *ei_from = &element_info[element_from];
7910 struct ElementInfo *ei_to = &element_info[element_to];
7912 copyElementInfo(ei_from, ei_to);
7915 static void replace_custom_element_in_settings(int element_from,
7920 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
7922 struct ElementInfo *ei = &element_info[i];
7924 for (y = 0; y < 3; y++)
7925 for (x = 0; x < 3; x++)
7926 if (ei->content.e[x][y] == element_from)
7927 ei->content.e[x][y] = element_to;
7929 for (j = 0; j < ei->num_change_pages; j++)
7931 struct ElementChangeInfo *change = &ei->change_page[j];
7933 if (change->target_element == element_from)
7934 change->target_element = element_to;
7936 if (change->initial_trigger_element == element_from)
7937 change->initial_trigger_element = element_to;
7939 if (change->action_element == element_from)
7940 change->action_element = element_to;
7942 for (y = 0; y < 3; y++)
7943 for (x = 0; x < 3; x++)
7944 if (change->target_content.e[x][y] == element_from)
7945 change->target_content.e[x][y] = element_to;
7948 if (ei->group != NULL) // group or internal
7949 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
7950 if (ei->group->element[j] == element_from)
7951 ei->group->element[j] = element_to;
7955 static void replace_custom_element_in_playfield(int element_from,
7960 for (x = 0; x < lev_fieldx; x++)
7961 for (y = 0; y < lev_fieldy; y++)
7962 if (Tile[x][y] == element_from)
7963 Tile[x][y] = element_to;
7966 static boolean CopyCustomElement(int element_old, int element_new,
7969 int copy_mode_orig = copy_mode;
7971 if (copy_mode == GADGET_ID_CUSTOM_COPY)
7973 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
7974 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7975 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7977 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
7979 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
7980 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
7981 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
7983 level.changed = TRUE;
7985 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
7987 Request("Please choose custom element!", REQ_CONFIRM);
7991 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
7993 Request("Please choose group element!", REQ_CONFIRM);
7999 level.changed = TRUE;
8002 // when modifying custom/group element, ask for copying level template
8003 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8005 if (!AskToCopyAndModifyLevelTemplate())
8009 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8011 copy_custom_element_settings(element_new, element_old);
8013 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8015 copy_custom_element_settings(element_old, element_new);
8017 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8019 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8020 copy_custom_element_settings(element_new, element_old);
8021 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8023 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8024 replace_custom_element_in_settings(element_new, element_old);
8025 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8027 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8028 replace_custom_element_in_playfield(element_new, element_old);
8029 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8032 UpdateCustomElementGraphicGadgets();
8033 DrawPropertiesWindow();
8038 static void CopyCustomElementPropertiesToEditor(int element)
8041 int current_change_page = element_info[element].current_change_page;
8043 // dynamically (re)build selectbox for selecting change page
8044 for (i = 0; i < element_info[element].num_change_pages; i++)
8046 sprintf(options_change_page_strings[i], "%d", i + 1);
8048 options_change_page[i].value = i;
8049 options_change_page[i].text = options_change_page_strings[i];
8052 options_change_page[i].value = -1;
8053 options_change_page[i].text = NULL;
8055 // needed here to initialize combined element properties
8056 InitElementPropertiesEngine(level.game_version);
8058 element_info[element].change =
8059 &element_info[element].change_page[current_change_page];
8061 custom_element = element_info[element];
8062 custom_element_change = *element_info[element].change;
8064 // needed to initially set selectbox options for special action options
8065 setSelectboxSpecialActionOptions();
8067 // needed to initially set selectbox value variables to reliable defaults
8068 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8069 setSelectboxValue(i, *selectbox_info[i].value);
8071 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8072 custom_element_properties[i] = HAS_PROPERTY(element, i);
8074 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8075 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8077 // ---------- element settings: configure (custom elements) -----------------
8079 // set accessible layer selectbox help value
8080 custom_element.access_type =
8081 (IS_WALKABLE(element) ? EP_WALKABLE :
8082 IS_PASSABLE(element) ? EP_PASSABLE :
8083 custom_element.access_type);
8084 custom_element.access_layer =
8085 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8086 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8087 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8088 custom_element.access_layer);
8089 custom_element.access_protected =
8090 (IS_PROTECTED(element) ? 1 : 0);
8091 custom_element_properties[EP_ACCESSIBLE] =
8092 (IS_ACCESSIBLE_OVER(element) ||
8093 IS_ACCESSIBLE_INSIDE(element) ||
8094 IS_ACCESSIBLE_UNDER(element));
8096 // set walk-to-object action selectbox help value
8097 custom_element.walk_to_action =
8098 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8099 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8100 IS_DROPPABLE(element) ? EP_DROPPABLE :
8101 IS_THROWABLE(element) ? EP_THROWABLE :
8102 IS_PUSHABLE(element) ? EP_PUSHABLE :
8103 custom_element.walk_to_action);
8104 custom_element_properties[EP_WALK_TO_OBJECT] =
8105 (IS_DIGGABLE(element) ||
8106 IS_COLLECTIBLE_ONLY(element) ||
8107 IS_DROPPABLE(element) ||
8108 IS_THROWABLE(element) ||
8109 IS_PUSHABLE(element));
8111 // set smash targets selectbox help value
8112 custom_element.smash_targets =
8113 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8114 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8115 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8116 custom_element.smash_targets);
8117 custom_element_properties[EP_CAN_SMASH] =
8118 (CAN_SMASH_EVERYTHING(element) ||
8119 CAN_SMASH_ENEMIES(element) ||
8120 CAN_SMASH_PLAYER(element));
8122 // set deadliness selectbox help value
8123 custom_element.deadliness =
8124 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8125 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8126 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8127 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8128 custom_element.deadliness);
8129 custom_element_properties[EP_DEADLY] =
8130 (DONT_TOUCH(element) ||
8131 DONT_GET_HIT_BY(element) ||
8132 DONT_COLLIDE_WITH(element) ||
8133 DONT_RUN_INTO(element));
8135 // ---------- element settings: advanced (custom elements) ------------------
8137 // set "change by direct action" selectbox help value
8138 custom_element_change.direct_action =
8139 (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8140 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8141 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8142 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8143 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8144 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8145 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8146 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8147 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8148 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8149 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8150 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8151 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8152 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8153 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8154 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8155 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8156 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8157 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
8158 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
8159 custom_element_change.direct_action);
8161 // set "change by other element action" selectbox help value
8162 custom_element_change.other_action =
8163 (HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8164 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8165 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8166 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8167 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8168 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8169 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8170 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8171 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8172 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8173 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8174 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8175 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8176 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8177 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8178 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8179 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8180 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8181 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8182 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8183 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8184 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8185 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8186 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
8187 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
8188 custom_element_change.other_action);
8191 static void CopyGroupElementPropertiesToEditor(int element)
8193 group_element_info = *element_info[element].group;
8194 custom_element = element_info[element]; // needed for description
8197 static void CopyClassicElementPropertiesToEditor(int element)
8199 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
8200 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
8201 getMoveIntoAcidProperty(&level, element);
8203 if (MAYBE_DONT_COLLIDE_WITH(element))
8204 custom_element_properties[EP_DONT_COLLIDE_WITH] =
8205 getDontCollideWithProperty(&level, element);
8208 static void CopyElementPropertiesToEditor(int element)
8210 if (IS_CUSTOM_ELEMENT(element))
8211 CopyCustomElementPropertiesToEditor(element);
8212 else if (IS_GROUP_ELEMENT(element))
8213 CopyGroupElementPropertiesToEditor(element);
8215 CopyClassicElementPropertiesToEditor(element);
8218 static boolean AskToCopyAndModifyLevelTemplate(void)
8220 if (Request("Copy and modify settings from level template?", REQ_ASK))
8222 level.use_custom_template = FALSE;
8224 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
8225 GDI_CHECKED, FALSE, GDI_END);
8226 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
8227 GDI_CHECKED, FALSE, GDI_END);
8233 LoadLevelTemplate(-1); // this resets all element modifications ...
8235 DrawEditModeWindow(); // ... and copies them to 'custom_element'
8241 static void CopyCustomElementPropertiesToGame(int element)
8244 int access_type_and_layer;
8246 // mark that this custom element has been modified
8247 custom_element.modified_settings = TRUE;
8248 level.changed = TRUE;
8250 if (level.use_custom_template)
8251 AskToCopyAndModifyLevelTemplate();
8253 element_info[element] = custom_element;
8254 *element_info[element].change = custom_element_change;
8256 // ---------- element settings: configure (custom elements) -----------------
8258 // set accessible property from checkbox and selectbox
8259 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
8260 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
8261 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
8262 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
8263 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
8264 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
8265 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
8266 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
8267 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
8268 custom_element_properties[access_type_and_layer] =
8269 custom_element_properties[EP_ACCESSIBLE];
8270 custom_element_properties[EP_PROTECTED] =
8271 (custom_element.access_protected != 0 &&
8272 custom_element_properties[EP_ACCESSIBLE]);
8274 // set walk-to-object property from checkbox and selectbox
8275 custom_element_properties[EP_DIGGABLE] = FALSE;
8276 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
8277 custom_element_properties[EP_DROPPABLE] = FALSE;
8278 custom_element_properties[EP_THROWABLE] = FALSE;
8279 custom_element_properties[EP_PUSHABLE] = FALSE;
8280 custom_element_properties[custom_element.walk_to_action] =
8281 custom_element_properties[EP_WALK_TO_OBJECT];
8283 // set smash property from checkbox and selectbox
8284 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
8285 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
8286 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
8287 custom_element_properties[custom_element.smash_targets] =
8288 custom_element_properties[EP_CAN_SMASH];
8290 // set deadliness property from checkbox and selectbox
8291 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
8292 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
8293 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
8294 custom_element_properties[EP_DONT_TOUCH] = FALSE;
8295 custom_element_properties[custom_element.deadliness] =
8296 custom_element_properties[EP_DEADLY];
8298 // ---------- element settings: advanced (custom elements) ------------------
8300 // set player change event from checkbox and selectbox
8301 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
8302 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
8303 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
8304 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
8305 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
8306 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
8307 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
8308 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
8309 custom_element_change_events[CE_SWITCHED] = FALSE;
8310 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
8311 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
8312 custom_element_change_events[CE_BLOCKED] = FALSE;
8313 custom_element_change_events[CE_IMPACT] = FALSE;
8314 custom_element_change_events[CE_SMASHED] = FALSE;
8315 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
8316 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
8317 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
8318 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
8319 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
8320 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
8321 custom_element_change_events[custom_element_change.direct_action] =
8322 custom_element_change_events[CE_BY_DIRECT_ACTION];
8324 // set other element action change event from checkbox and selectbox
8325 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
8326 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
8327 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
8328 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
8329 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
8330 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
8331 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
8332 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
8333 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
8334 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
8335 custom_element_change_events[CE_TOUCHING_X] = FALSE;
8336 custom_element_change_events[CE_HITTING_X] = FALSE;
8337 custom_element_change_events[CE_DIGGING_X] = FALSE;
8338 custom_element_change_events[CE_HIT_BY_X] = FALSE;
8339 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
8340 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
8341 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
8342 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
8343 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
8344 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
8345 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
8346 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
8347 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
8348 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
8349 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
8350 custom_element_change_events[custom_element_change.other_action] =
8351 custom_element_change_events[CE_BY_OTHER_ACTION];
8353 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8354 SET_PROPERTY(element, i, custom_element_properties[i]);
8356 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8357 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
8359 // copy change events also to special level editor variable
8360 custom_element = element_info[element];
8361 custom_element_change = *element_info[element].change;
8363 // needed here to restore runtime value "element_info[element].gfx_element"
8364 InitElementPropertiesGfxElement();
8367 static void CopyGroupElementPropertiesToGame(int element)
8369 // mark that this group element has been modified
8370 custom_element.modified_settings = TRUE;
8371 level.changed = TRUE;
8373 if (level.use_custom_template)
8374 AskToCopyAndModifyLevelTemplate();
8376 element_info[element] = custom_element;
8377 *element_info[element].group = group_element_info;
8379 // needed here to restore runtime value "element_info[element].gfx_element"
8380 InitElementPropertiesGfxElement();
8383 static void CopyClassicElementPropertiesToGame(int element)
8385 if (ELEM_IS_PLAYER(element) || COULD_MOVE_INTO_ACID(element))
8386 setMoveIntoAcidProperty(&level, element,
8387 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
8389 if (MAYBE_DONT_COLLIDE_WITH(element))
8390 setDontCollideWithProperty(&level, element,
8391 custom_element_properties[EP_DONT_COLLIDE_WITH]);
8394 static void CopyElementPropertiesToGame(int element)
8396 if (IS_CUSTOM_ELEMENT(element))
8397 CopyCustomElementPropertiesToGame(element);
8398 else if (IS_GROUP_ELEMENT(element))
8399 CopyGroupElementPropertiesToGame(element);
8401 CopyClassicElementPropertiesToGame(element);
8405 static void CheckElementDescriptions(void)
8409 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8410 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
8411 Warn("no element description file for element '%s'", EL_NAME(i));
8415 static int getMaxEdFieldX(boolean has_scrollbar)
8417 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
8418 int sxsize = SXSIZE - scrollbar_width;
8419 int max_ed_fieldx = sxsize / ed_tilesize;
8421 return max_ed_fieldx;
8424 static int getMaxEdFieldY(boolean has_scrollbar)
8426 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
8427 INFOTEXT_YSIZE_FULL : 0);
8428 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
8429 int sysize = SYSIZE - scrollbar_height - infotext_height;
8430 int max_ed_fieldy = sysize / ed_tilesize;
8432 return max_ed_fieldy;
8435 static void InitZoomLevelSettings(int zoom_tilesize)
8437 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
8439 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
8441 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
8442 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
8444 // make sure that tile size is always a power of 2
8445 ed_tilesize = (1 << log_2(ed_tilesize));
8447 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8449 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
8450 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
8454 last_game_engine_type = level.game_engine_type;
8456 // limit zoom tilesize by upper and lower bound
8457 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
8459 // store zoom tilesize in auto setup file only if it was manually changed
8460 if (zoom_tilesize != -1)
8461 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
8463 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
8464 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
8467 static void InitDrawingElements(void)
8469 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
8471 if (level.game_engine_type == game_engine_type_last)
8474 if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
8476 new_element1 = EL_SP_CHIP_SINGLE;
8477 new_element2 = EL_EMPTY;
8478 new_element3 = EL_SP_BASE;
8480 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8482 new_element1 = EL_MM_MIRROR_START;
8483 new_element2 = EL_EMPTY;
8484 new_element3 = EL_MM_WOODEN_WALL;
8488 new_element1 = EL_WALL;
8489 new_element2 = EL_EMPTY;
8490 new_element3 = EL_SAND;
8493 game_engine_type_last = level.game_engine_type;
8496 static void InitLevelSetInfo(void)
8498 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
8499 "%s", leveldir_current->name);
8500 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
8501 "%s", leveldir_current->author);
8503 levelset_num_levels = leveldir_current->levels;
8505 levelset_use_levelset_artwork = FALSE;
8506 levelset_copy_level_template = FALSE;
8508 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
8511 static void ChangeEditorToLevelSet(char *levelset_subdir)
8513 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
8515 // the previous level set might have used custom artwork
8516 ReloadCustomArtwork(0);
8518 LoadLevelSetup_SeriesInfo();
8520 SaveLevelSetup_LastSeries();
8521 SaveLevelSetup_SeriesInfo();
8525 LoadLevel(level_nr);
8526 LoadScore(level_nr);
8531 static boolean useEditorDoorAnimation(void)
8533 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
8534 boolean door_1_viewport_unchanged =
8535 (vp_door_1->x == DX &&
8536 vp_door_1->y == DY &&
8537 vp_door_1->width == DXSIZE &&
8538 vp_door_1->height == DYSIZE);
8539 boolean door_1_contains_toolbox =
8542 EX + EXSIZE <= DX + DXSIZE &&
8543 EY + EYSIZE <= DY + DYSIZE);
8545 return (door_1_viewport_unchanged && door_1_contains_toolbox);
8548 static void DrawEditorDoorBackground(int graphic, int x, int y,
8549 int width, int height)
8551 struct GraphicInfo *g = &graphic_info[graphic];
8553 if (g->bitmap != NULL)
8554 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
8555 MIN(width, g->width), MIN(height, g->height), x, y);
8557 ClearRectangle(drawto, x, y, width, height);
8560 static void DrawEditorDoorContent(void)
8562 // needed for gadgets drawn on background (like palette scrollbar)
8563 SetDoorBackgroundImage(IMG_UNDEFINED);
8565 // copy default editor door content to main double buffer
8566 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
8569 DrawSpecialEditorDoor();
8571 // draw new control window
8572 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
8574 // draw all toolbox gadgets to editor doors
8575 MapControlButtons();
8577 // draw all palette gadgets to editor doors
8578 ModifyEditorElementList();
8579 RedrawDrawingElements();
8581 // copy actual editor door content to door double buffer for OpenDoor()
8582 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
8585 void DrawLevelEd(void)
8587 int fade_mask = REDRAW_FIELD;
8589 FadeSoundsAndMusic();
8592 fade_mask = REDRAW_ALL;
8596 // needed if different viewport properties defined for editor
8597 ChangeViewportPropertiesIfNeeded();
8601 InitZoomLevelSettings(-1);
8602 InitDrawingElements();
8606 CheckElementDescriptions();
8609 if (level_editor_test_game)
8611 CopyPlayfield(level.field, Tile);
8612 CopyPlayfield(TileBackup, level.field);
8614 level_editor_test_game = FALSE;
8618 edit_mode = ED_MODE_DRAWING;
8619 edit_mode_levelinfo = ED_MODE_LEVELINFO_LEVEL;
8620 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
8628 // redraw_mask |= REDRAW_ALL;
8630 FreeLevelEditorGadgets();
8631 CreateLevelEditorGadgets();
8633 ReinitializeElementList(); // update dynamic level element list
8634 ReinitializeElementListButtons(); // custom element may look different
8636 InitElementPropertiesGfxElement();
8640 DrawEditModeWindow_PlayfieldOnly();
8642 DrawMaskedBorder(fade_mask);
8644 // use door animation if door 1 viewport is unchanged and contains toolbox
8645 if (useEditorDoorAnimation())
8649 DrawEditorDoorContent();
8651 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
8655 DrawEditorDoorContent();
8660 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
8663 static void AdjustDrawingAreaGadgets(void)
8665 int ed_xsize = lev_fieldx + 2;
8666 int ed_ysize = lev_fieldy + 2;
8667 int max_ed_fieldx = MAX_ED_FIELDX;
8668 int max_ed_fieldy = MAX_ED_FIELDY;
8669 boolean horizontal_scrollbar_needed;
8670 boolean vertical_scrollbar_needed;
8671 int x, y, width, height;
8673 if (suppressBorderElement())
8675 ed_xsize = max_ed_fieldx;
8676 ed_ysize = max_ed_fieldy;
8679 // check if we need any scrollbars
8680 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8681 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8683 // check if we have a smaller editor field because of scrollbars
8684 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8685 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8687 // check again if we now need more scrollbars because of less space
8688 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8689 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8691 // check if editor field gets even smaller after adding new scrollbars
8692 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8693 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8695 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
8696 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
8698 x = SX + ed_fieldx * ed_tilesize;
8699 y = SY + ed_fieldy * ed_tilesize;
8701 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
8702 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
8704 // adjust drawing area gadget
8705 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
8706 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
8707 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
8710 // adjust horizontal scrollbar gadgets
8711 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
8714 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
8715 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
8718 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8721 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
8724 // adjust vertical scrollbar gadgets
8725 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
8728 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
8730 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
8732 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8735 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
8739 static void AdjustLevelScrollPosition(void)
8741 if (level_xpos < -1)
8743 if (level_xpos > lev_fieldx - ed_fieldx + 1)
8744 level_xpos = lev_fieldx - ed_fieldx + 1;
8745 if (lev_fieldx < ed_fieldx - 2)
8748 if (level_ypos < -1)
8750 if (level_ypos > lev_fieldy - ed_fieldy + 1)
8751 level_ypos = lev_fieldy - ed_fieldy + 1;
8752 if (lev_fieldy < ed_fieldy - 2)
8755 if (suppressBorderElement())
8762 static void AdjustEditorScrollbar(int id)
8764 struct GadgetInfo *gi = level_editor_gadget[id];
8765 int items_max, items_visible, item_position;
8767 if (id == GADGET_ID_SCROLL_HORIZONTAL)
8769 items_max = MAX(lev_fieldx + 2, ed_fieldx);
8770 items_visible = ed_fieldx;
8771 item_position = level_xpos + 1;
8775 items_max = MAX(lev_fieldy + 2, ed_fieldy);
8776 items_visible = ed_fieldy;
8777 item_position = level_ypos + 1;
8780 if (item_position > items_max - items_visible)
8781 item_position = items_max - items_visible;
8783 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8784 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8787 static void AdjustElementListScrollbar(void)
8789 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
8790 int items_max, items_visible, item_position;
8792 // correct position of element list scrollbar
8793 if (element_shift < 0)
8795 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
8796 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
8798 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
8799 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
8800 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
8802 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8803 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
8804 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8807 static void ModifyEditorCounterValue(int counter_id, int new_value)
8809 int *counter_value = counterbutton_info[counter_id].value;
8810 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8811 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8813 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
8815 if (counter_value != NULL)
8816 *counter_value = gi->textinput.number_value;
8819 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
8821 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
8822 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8824 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
8826 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
8827 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
8829 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
8830 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
8832 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
8833 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
8838 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
8840 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8841 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8842 int new_index_value = setSelectboxValue(selectbox_id, new_value);
8844 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
8847 static void ModifyEditorSelectboxOptions(int selectbox_id,
8848 struct ValueTextInfo *options)
8850 int gadget_id = selectbox_info[selectbox_id].gadget_id;
8851 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8853 selectbox_info[selectbox_id].options = options;
8855 // set index to zero -- list may be shorter now (correct later, if needed)
8856 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
8857 GDI_SELECTBOX_OPTIONS, options, GDI_END);
8860 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
8862 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
8863 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8865 drawingarea_info[drawingarea_id].area_xsize = xsize;
8866 drawingarea_info[drawingarea_id].area_ysize = ysize;
8868 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
8871 static void ModifyEditorElementList(void)
8875 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
8878 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
8880 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
8881 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
8882 struct GadgetDesign *gd = &gi->deco.design;
8883 int element = editor_elements[element_shift + i];
8884 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
8888 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
8890 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
8896 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
8898 int graphic = el2edimg(element);
8899 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
8905 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
8908 static void ModifyDrawingElementButton(int element, int id)
8910 struct GadgetInfo *gi = level_editor_gadget[id];
8911 Bitmap *deco_bitmap;
8913 int tile_size = gi->deco.width;
8915 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
8917 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
8920 static void PickDrawingElement(int button, int element)
8925 struct XYTileSize *pos;
8927 } de, drawing_elements[] =
8929 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
8930 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
8931 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
8934 if (button < 1 || button > 3)
8937 if (IS_MM_WALL(element))
8938 element = map_mm_wall_element(element);
8940 de = drawing_elements[button - 1];
8942 *de.new_element = element; // update global drawing element variable
8944 DrawDrawingElementGraphic(element, de.pos);
8945 ModifyDrawingElementButton(element, de.id);
8947 redraw_mask |= REDRAW_DOOR_1;
8950 static void RedrawDrawingElements(void)
8952 PickDrawingElement(1, new_element1);
8953 PickDrawingElement(2, new_element2);
8954 PickDrawingElement(3, new_element3);
8957 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
8959 stick_element_properties_window = FALSE;
8961 SetMainBackgroundImage(IMG_UNDEFINED);
8964 UnmapLevelEditorFieldGadgets();
8966 AdjustDrawingAreaGadgets();
8967 AdjustLevelScrollPosition();
8968 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
8969 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
8971 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
8973 MapMainDrawingArea();
8975 if (remap_toolbox_gadgets)
8977 UnmapLevelEditorToolboxCustomGadgets();
8978 MapLevelEditorToolboxDrawingGadgets();
8982 static void DrawDrawingWindow(void)
8984 DrawDrawingWindowExt(TRUE);
8987 static int getTabulatorBarWidth(void)
8989 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
8990 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
8992 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
8995 static int getTabulatorBarHeight(void)
8997 return ED_TAB_BAR_HEIGHT;
9000 static Pixel getTabulatorBarColor(void)
9002 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
9003 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9004 int gd_x = gd->x + gd_gi1->border.width / 2;
9005 int gd_y = gd->y + gd_gi1->height - 1;
9007 return GetPixel(gd->bitmap, gd_x, gd_y);
9010 static void DrawLevelInfoTabulatorGadgets(void)
9012 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
9013 Pixel tab_color = getTabulatorBarColor();
9014 int id_first = ED_TAB_BUTTON_ID_LEVELINFO_FIRST;
9015 int id_last = ED_TAB_BUTTON_ID_LEVELINFO_LAST;
9018 for (i = id_first; i <= id_last; i++)
9020 int gadget_id = textbutton_info[i].gadget_id;
9021 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9022 boolean active = (i != edit_mode_levelinfo);
9024 // draw background line below tabulator button
9025 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9027 // draw solid line below inactive tabulator buttons
9028 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9029 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9030 ED_GADGET_TINY_DISTANCE, tab_color);
9032 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9033 MapTextbuttonGadget(i);
9036 // draw little border line below tabulator buttons
9037 if (tab_color != BLACK_PIXEL) // black => transparent
9038 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9039 ED_GADGET_TINY_DISTANCE,
9040 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9043 static void DrawPropertiesTabulatorGadgets(void)
9045 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9046 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9047 int gd_x = gd->x + gd_gi1->border.width / 2;
9048 int gd_y = gd->y + gd_gi1->height - 1;
9049 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9050 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9051 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9054 // draw two config tabulators for player elements
9055 if (ELEM_IS_PLAYER(properties_element))
9056 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9058 // draw two config and one "change" tabulator for custom elements
9059 if (IS_CUSTOM_ELEMENT(properties_element))
9060 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9062 for (i = id_first; i <= id_last; i++)
9064 int gadget_id = textbutton_info[i].gadget_id;
9065 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9066 boolean active = (i != edit_mode_properties);
9068 // use "config 1" and "config 2" instead of "config" for players and CEs
9069 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9070 (ELEM_IS_PLAYER(properties_element) ||
9071 IS_CUSTOM_ELEMENT(properties_element)))
9074 // draw background line below tabulator button
9075 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9077 // draw solid line below inactive tabulator buttons
9078 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9079 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9080 ED_GADGET_TINY_DISTANCE, tab_color);
9082 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9083 MapTextbuttonGadget(i);
9086 // draw little border line below tabulator buttons
9087 if (tab_color != BLACK_PIXEL) // black => transparent
9088 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9089 ED_GADGET_TINY_DISTANCE,
9090 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9093 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9095 DrawText(SX + xpos, SY + ypos, text, font_nr);
9098 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9101 int font_width = getFontWidth(font_nr);
9102 int font_height = getFontHeight(font_nr);
9103 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9104 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9106 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9107 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9108 TRUE, FALSE, FALSE);
9111 static void DrawLevelInfoLevel(void)
9115 // draw counter gadgets
9116 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9117 MapCounterButtons(i);
9119 // draw checkbutton gadgets
9120 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9121 MapCheckbuttonGadget(i);
9123 // draw selectbox gadgets
9124 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9125 MapSelectboxGadget(i);
9127 // draw text input gadgets
9128 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9129 MapTextInputGadget(i);
9132 static char *getLevelSubdirFromSaveMode(int save_mode)
9134 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9135 return getNewUserLevelSubdir();
9137 return leveldir_current->subdir;
9140 static void DrawLevelInfoLevelSet_DirectoryInfo(void)
9142 char *directory_text = "Level set directory:";
9143 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9144 int font1_nr = FONT_TEXT_1;
9145 int font2_nr = FONT_TEXT_2;
9146 int font1_height = getFontHeight(font1_nr);
9147 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
9148 int x = ED_LEVEL_SETTINGS_X(0);
9149 int y = ED_LEVEL_SETTINGS_Y(6);
9151 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
9152 PrintInfoText(directory_name, font2_nr, x, y);
9155 static void DrawLevelInfoLevelSet(void)
9157 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
9158 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
9161 // draw counter gadgets
9162 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
9163 MapCounterButtons(i);
9165 // draw checkbutton gadgets
9166 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
9168 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
9169 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
9170 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
9173 MapCheckbuttonGadget(i);
9176 // draw selectbox gadgets
9177 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
9178 MapSelectboxGadget(i);
9180 // draw text input gadgets
9181 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
9182 MapTextInputGadget(i);
9184 // draw textbutton gadgets
9185 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
9188 DrawLevelInfoLevelSet_DirectoryInfo();
9191 static void DrawLevelInfoEditor(void)
9195 // draw counter gadgets
9196 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
9197 MapCounterButtons(i);
9199 // draw checkbutton gadgets
9200 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
9201 MapCheckbuttonGadget(i);
9203 // draw radiobutton gadgets
9204 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
9205 MapRadiobuttonGadget(i);
9207 // draw drawing area
9208 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
9210 // draw textbutton gadgets
9211 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
9214 static void DrawLevelInfoWindow(void)
9216 char *text = "Global Settings";
9217 int font_nr = FONT_TITLE_1;
9218 struct MenuPosInfo *pos = &editor.settings.headline;
9219 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
9220 int sy = SY + pos->y;
9222 stick_element_properties_window = FALSE;
9224 SetAutomaticNumberOfGemsNeeded();
9226 UnmapLevelEditorFieldGadgets();
9228 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9231 DrawText(sx, sy, text, font_nr);
9233 DrawLevelInfoTabulatorGadgets();
9235 if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVEL)
9236 DrawLevelInfoLevel();
9237 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVELSET)
9238 DrawLevelInfoLevelSet();
9239 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_EDITOR)
9240 DrawLevelInfoEditor();
9243 static void DrawCustomContentArea(void)
9245 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
9246 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9247 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
9248 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
9249 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
9250 int xoffset = ED_GADGET_SPACE_DISTANCE;
9252 // add distance for potential left text (without drawing area border)
9253 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
9255 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9257 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
9260 static void DrawCustomChangeContentArea(void)
9262 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
9263 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9264 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
9265 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
9266 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
9267 int xoffset = ED_GADGET_SPACE_DISTANCE;
9269 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9274 static void RemoveElementContentArea(int id, int font_height)
9276 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9278 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
9279 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
9280 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9281 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
9282 ED_GADGET_TEXT_DISTANCE + font_height);
9285 static void DrawYamYamContentAreas(void)
9287 int font_nr = FONT_TEXT_1;
9288 int font_height = getFontHeight(font_nr);
9289 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9290 int yoffset = (tilesize - font_height) / 2;
9291 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
9292 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
9295 // display counter to choose number of element content areas
9296 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
9298 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9300 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
9302 if (i < level.num_yamyam_contents)
9308 UnmapDrawingArea(id);
9310 // delete content areas in case of reducing number of them
9311 RemoveElementContentArea(id, font_height);
9315 DrawText(x, y + 0 * tilesize, "content", font_nr);
9316 DrawText(x, y + 1 * tilesize, "when", font_nr);
9317 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
9320 static void DrawMagicBallContentAreas(void)
9322 int font_nr = FONT_TEXT_1;
9323 int font_height = getFontHeight(font_nr);
9324 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9325 int yoffset = (tilesize - font_height) / 2;
9326 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
9327 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
9330 // display counter to choose number of element content areas
9331 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
9333 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9335 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
9337 if (i < level.num_ball_contents)
9343 UnmapDrawingArea(id);
9345 // delete content areas in case of reducing number of them
9346 RemoveElementContentArea(id, font_height);
9350 DrawText(x, y + 0 * tilesize, "generated", font_nr);
9351 DrawText(x, y + 1 * tilesize, "when", font_nr);
9352 DrawText(x, y + 2 * tilesize, "active", font_nr);
9355 static void DrawAndroidElementArea(int element)
9357 int id = ED_DRAWING_ID_ANDROID_CONTENT;
9358 int num_elements = level.num_android_clone_elements;
9359 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9360 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9361 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9362 int xsize = MAX_ANDROID_ELEMENTS;
9365 // display counter to choose number of element areas
9366 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
9368 if (drawingarea_info[id].text_left != NULL)
9369 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9371 UnmapDrawingArea(id);
9373 ModifyEditorDrawingArea(id, num_elements, 1);
9375 // delete content areas in case of reducing number of them
9376 DrawBackground(sx, sy,
9377 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9378 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9383 static void DrawGroupElementArea(int element)
9385 int id = ED_DRAWING_ID_GROUP_CONTENT;
9386 int num_elements = group_element_info.num_elements;
9387 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9388 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9389 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9390 int xsize = MAX_ELEMENTS_IN_GROUP;
9393 if (drawingarea_info[id].text_left != NULL)
9394 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9396 UnmapDrawingArea(id);
9398 ModifyEditorDrawingArea(id, num_elements, 1);
9400 // delete content areas in case of reducing number of them
9401 DrawBackground(sx, sy,
9402 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9403 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9408 static void DrawPlayerInitialInventoryArea(int element)
9410 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
9411 int player_nr = GET_PLAYER_NR(element);
9412 int num_elements = level.initial_inventory_size[player_nr];
9413 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9414 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9415 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9416 int xsize = MAX_INITIAL_INVENTORY_SIZE;
9419 // determine horizontal position to the right of specified gadget
9420 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
9421 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
9422 ED_DRAWINGAREA_TEXT_DISTANCE);
9424 // determine horizontal offset for leading text
9425 if (drawingarea_info[id].text_left != NULL)
9426 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9428 UnmapDrawingArea(id);
9430 ModifyEditorDrawingArea(id, num_elements, 1);
9432 // delete content areas in case of reducing number of them
9433 DrawBackground(sx, sy,
9434 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9435 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9440 static void DrawEnvelopeTextArea(int envelope_nr)
9442 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
9443 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
9446 DrawBackground(gi->x, gi->y, gi->width, gi->height);
9448 if (envelope_nr != -1)
9449 textarea_info[id].value = level.envelope[envelope_nr].text;
9451 ModifyGadget(gi, GDI_AREA_SIZE,
9452 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
9453 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
9456 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
9459 static void DrawPropertiesInfo(void)
9468 // configurable properties
9470 { EP_WALKABLE_OVER, "- player can walk over it" },
9471 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
9472 { EP_WALKABLE_UNDER, "- player can walk under it" },
9473 { EP_PASSABLE_OVER, "- player can pass over it" },
9474 { EP_PASSABLE_INSIDE, "- player can pass through it" },
9475 { EP_PASSABLE_UNDER, "- player can pass under it" },
9476 { EP_PROTECTED, "- player is protected by it" },
9478 { EP_DIGGABLE, "- can be digged away" },
9479 { EP_COLLECTIBLE, "- can be collected" },
9480 { EP_DROPPABLE, "- can be dropped after collecting" },
9481 { EP_THROWABLE, "- can be thrown after collecting" },
9482 { EP_PUSHABLE, "- can be pushed" },
9484 { EP_CAN_FALL, "- can fall" },
9485 { EP_CAN_MOVE, "- can move" },
9487 { EP_CAN_SMASH_PLAYER, "- can smash player" },
9489 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
9491 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
9493 { EP_SLIPPERY, "- slippery for falling elements" },
9494 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
9496 { EP_DONT_RUN_INTO, "- deadly when running into" },
9497 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
9498 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
9499 { EP_DONT_TOUCH, "- deadly when touching" },
9501 { EP_INDESTRUCTIBLE, "- indestructible" },
9503 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
9504 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
9505 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
9507 { EP_CAN_CHANGE, "- can change to other element" },
9509 // pre-defined properties
9510 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
9511 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
9512 { EP_SWITCHABLE, "- can be switched" },
9514 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
9519 char *filename = getElementDescriptionFilename(properties_element);
9520 char *percentage_text = "In this level: ";
9521 char *properties_text = "Standard properties: ";
9522 char *description_text = "Description:";
9523 char *no_description_text = "No description available.";
9524 char *none_text = "None";
9526 int num_elements_in_level;
9527 int num_standard_properties = 0;
9528 int font1_nr = FONT_TEXT_1;
9529 int font2_nr = FONT_TEXT_2;
9530 int font1_width = getFontWidth(font1_nr);
9531 int font1_height = getFontHeight(font1_nr);
9532 int font2_height = getFontHeight(font2_nr);
9533 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
9534 int font2_yoffset = (font1_height - font2_height) / 2;
9535 int percentage_text_len = strlen(percentage_text) * font1_width;
9536 int properties_text_len = strlen(properties_text) * font1_width;
9537 int xpos = ED_ELEMENT_SETTINGS_X(0);
9538 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9541 if (setup.editor.show_element_token)
9543 int font3_nr = FONT_TEXT_3;
9544 int font3_height = getFontHeight(font3_nr);
9546 DrawTextF(xpos, ypos, font3_nr,
9547 "[%s]", element_info[properties_element].token_name);
9549 ypos += 2 * font3_height;
9552 // ----- print number of elements / percentage of this element in level
9554 num_elements_in_level = 0;
9555 for (y = 0; y < lev_fieldy; y++)
9556 for (x = 0; x < lev_fieldx; x++)
9557 if (Tile[x][y] == properties_element)
9558 num_elements_in_level++;
9559 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
9561 DrawTextS(xpos, ypos, font1_nr, percentage_text);
9563 if (num_elements_in_level > 0)
9564 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9565 "%d (%.2f %%)", num_elements_in_level, percentage);
9567 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9570 ypos += 2 * MAX(font1_height, font2_height);
9572 // ----- print standard properties of this element
9574 DrawTextS(xpos, ypos, font1_nr, properties_text);
9576 ypos += line1_height;
9578 for (i = 0; properties[i].value != -1; i++)
9580 if (!HAS_PROPERTY(properties_element, properties[i].value))
9583 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
9585 ypos += font2_height;
9587 num_standard_properties++;
9590 if (num_standard_properties == 0)
9592 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
9593 font2_nr, none_text);
9595 ypos -= (line1_height - font1_height);
9598 ypos += MAX(font1_height, font2_height);
9600 // ----- print special description of this element
9602 PrintInfoText(description_text, font1_nr, xpos, ypos);
9604 ypos += line1_height;
9606 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
9607 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
9610 #define TEXT_COLLECTING "Score for collecting"
9611 #define TEXT_SMASHING "Score for smashing"
9612 #define TEXT_SLURPING "Score for slurping robot"
9613 #define TEXT_CRACKING "Score for cracking"
9614 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
9615 #define TEXT_DURATION "Duration when activated"
9616 #define TEXT_DELAY_ON "Delay before activating"
9617 #define TEXT_DELAY_OFF "Delay before deactivating"
9618 #define TEXT_DELAY_EXPLODING "Delay before exploding"
9619 #define TEXT_DELAY_MOVING "Delay before moving"
9620 #define TEXT_BALL_DELAY "Element generation delay"
9621 #define TEXT_MOVE_SPEED "Speed of android moving"
9622 #define TEXT_CLONE_SPEED "Speed of android cloning"
9623 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
9624 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
9625 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
9626 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
9627 #define TEXT_TIME_BONUS "Extra time to solve level"
9634 } elements_with_counter[] =
9636 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
9637 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
9638 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
9639 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
9640 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9641 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
9642 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
9643 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
9644 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
9645 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
9646 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
9647 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
9648 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9649 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9650 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
9651 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
9652 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
9653 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9654 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9655 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
9656 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9657 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9658 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9659 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9660 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9661 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9662 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
9663 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9664 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9665 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9666 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9667 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9668 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9669 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9670 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
9671 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
9672 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9673 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
9674 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9675 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9676 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9677 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9678 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9679 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
9680 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9681 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9682 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
9683 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9684 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9685 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
9686 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
9687 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
9688 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9689 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9690 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9691 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9692 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9693 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9694 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9695 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9696 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
9697 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
9698 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
9699 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
9700 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
9701 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9702 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
9703 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
9704 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
9705 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9706 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9707 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9708 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9709 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9710 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9711 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9712 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9713 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9714 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9715 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9716 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9717 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9718 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
9720 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
9721 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
9722 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
9723 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
9724 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
9725 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
9726 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
9727 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
9728 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
9729 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
9730 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
9731 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
9732 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
9733 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
9734 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
9735 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
9737 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
9738 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
9739 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
9740 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
9741 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
9742 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
9743 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
9744 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
9745 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
9746 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
9747 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
9748 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
9749 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_ON },
9750 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9751 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9756 static boolean checkPropertiesConfig(int element)
9760 if (IS_GEM(element) ||
9761 IS_CUSTOM_ELEMENT(element) ||
9762 IS_GROUP_ELEMENT(element) ||
9763 IS_BALLOON_ELEMENT(element) ||
9764 IS_ENVELOPE(element) ||
9765 IS_MM_MCDUFFIN(element) ||
9766 IS_DF_LASER(element) ||
9767 ELEM_IS_PLAYER(element) ||
9768 HAS_EDITOR_CONTENT(element) ||
9769 CAN_GROW(element) ||
9770 COULD_MOVE_INTO_ACID(element) ||
9771 MAYBE_DONT_COLLIDE_WITH(element) ||
9772 element == EL_SOKOBAN_OBJECT ||
9773 element == EL_SOKOBAN_FIELD_EMPTY ||
9774 element == EL_SOKOBAN_FIELD_FULL)
9777 for (i = 0; elements_with_counter[i].element != -1; i++)
9778 if (elements_with_counter[i].element == element)
9784 static void SetAutomaticNumberOfGemsNeeded(void)
9788 if (!level.auto_count_gems)
9791 level.gems_needed = 0;
9793 for (x = 0; x < lev_fieldx; x++)
9795 for (y = 0; y < lev_fieldy; y++)
9797 int element = Tile[x][y];
9802 case EL_EMERALD_YELLOW:
9803 case EL_EMERALD_RED:
9804 case EL_EMERALD_PURPLE:
9806 case EL_WALL_EMERALD:
9807 case EL_WALL_EMERALD_YELLOW:
9808 case EL_WALL_EMERALD_RED:
9809 case EL_WALL_EMERALD_PURPLE:
9810 case EL_WALL_BD_DIAMOND:
9812 case EL_SP_INFOTRON:
9815 level.gems_needed++;
9819 case EL_WALL_DIAMOND:
9820 level.gems_needed += 3;
9825 level.gems_needed += 5;
9829 case EL_WALL_CRYSTAL:
9830 level.gems_needed += 8;
9839 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
9842 static void DrawPropertiesConfig(void)
9844 boolean draw_footer_line = FALSE;
9845 int max_num_element_counters = 4;
9846 int num_element_counters = 0;
9849 if (!checkPropertiesConfig(properties_element))
9851 int xpos = ED_ELEMENT_SETTINGS_X(0);
9852 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9854 PrintInfoText("No configuration options available.",
9855 FONT_TEXT_1, xpos, ypos);
9860 // check if there are elements where a value can be chosen for
9861 for (i = 0; elements_with_counter[i].element != -1; i++)
9863 if (elements_with_counter[i].element == properties_element)
9865 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
9867 counterbutton_info[counter_id].y =
9868 ED_ELEMENT_SETTINGS_YPOS(
9869 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
9870 (CAN_GROW(properties_element) ? 1 : 0) +
9871 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
9872 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
9873 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
9874 num_element_counters);
9876 counterbutton_info[counter_id].value = elements_with_counter[i].value;
9877 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
9879 if (properties_element == EL_GAME_OF_LIFE ||
9880 properties_element == EL_BIOMAZE)
9882 counterbutton_info[counter_id].min_value = 0; // min neighbours
9883 counterbutton_info[counter_id].max_value = 8; // max neighbours
9887 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
9888 counterbutton_info[counter_id].min_value = MIN_SCORE;
9889 counterbutton_info[counter_id].max_value = MAX_SCORE;
9892 MapCounterButtons(counter_id);
9894 num_element_counters++;
9895 if (num_element_counters >= max_num_element_counters)
9900 if (HAS_EDITOR_CONTENT(properties_element))
9902 // draw stickybutton gadget
9903 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
9905 if (IS_AMOEBOID(properties_element))
9906 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
9907 else if (properties_element == EL_YAMYAM ||
9908 properties_element == EL_YAMYAM_LEFT ||
9909 properties_element == EL_YAMYAM_RIGHT ||
9910 properties_element == EL_YAMYAM_UP ||
9911 properties_element == EL_YAMYAM_DOWN)
9912 DrawYamYamContentAreas();
9913 else if (properties_element == EL_EMC_MAGIC_BALL)
9915 DrawMagicBallContentAreas();
9917 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
9918 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
9920 else if (properties_element == EL_EMC_ANDROID)
9921 DrawAndroidElementArea(properties_element);
9924 if (ELEM_IS_PLAYER(properties_element))
9926 int player_nr = GET_PLAYER_NR(properties_element);
9928 // these properties can be set for every player individually
9930 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
9932 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
9933 &level.start_element[player_nr];
9934 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
9935 &level.artwork_element[player_nr];
9936 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
9937 &level.explosion_element[player_nr];
9939 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
9940 &level.use_start_element[player_nr];
9941 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
9942 &level.use_artwork_element[player_nr];
9943 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
9944 &level.use_explosion_element[player_nr];
9945 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
9946 &level.initial_player_gravity[player_nr];
9948 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
9949 &level.initial_player_stepsize[player_nr];
9951 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
9952 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
9953 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
9954 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
9955 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
9956 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
9957 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
9958 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
9959 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
9960 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
9961 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
9962 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
9963 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
9964 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
9965 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
9967 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
9968 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
9969 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
9971 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
9973 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
9975 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
9976 &level.initial_inventory_content[player_nr][0];
9978 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
9979 &level.initial_inventory_size[player_nr];
9981 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
9982 &level.use_initial_inventory[player_nr];
9984 // draw checkbutton gadgets
9985 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
9987 // draw counter gadgets
9988 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
9990 // draw drawing area gadgets
9991 DrawPlayerInitialInventoryArea(properties_element);
9995 if (IS_GEM(properties_element))
9996 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
9998 if (properties_element == EL_EM_DYNAMITE)
9999 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
10001 if (COULD_MOVE_INTO_ACID(properties_element) &&
10002 !ELEM_IS_PLAYER(properties_element) &&
10003 (!IS_CUSTOM_ELEMENT(properties_element) ||
10004 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
10006 // set position for checkbutton for "can move into acid"
10007 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
10008 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
10009 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
10010 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 :
10011 IS_BALLOON_ELEMENT(properties_element) ||
10012 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10014 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
10017 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
10018 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
10020 if (properties_element == EL_SPRING ||
10021 properties_element == EL_SPRING_LEFT ||
10022 properties_element == EL_SPRING_RIGHT)
10023 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
10025 if (properties_element == EL_TIME_ORB_FULL)
10026 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
10028 if (properties_element == EL_GAME_OF_LIFE ||
10029 properties_element == EL_BIOMAZE)
10030 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
10032 if (CAN_GROW(properties_element))
10034 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
10035 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10037 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
10040 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
10041 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
10043 if (properties_element == EL_SOKOBAN_OBJECT)
10044 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
10046 if (properties_element == EL_SOKOBAN_OBJECT ||
10047 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
10048 properties_element == EL_SOKOBAN_FIELD_FULL)
10050 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
10051 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
10054 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
10057 if (IS_BALLOON_ELEMENT(properties_element))
10058 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
10060 if (IS_ENVELOPE(properties_element))
10062 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
10063 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
10064 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
10065 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
10066 int envelope_nr = properties_element - EL_ENVELOPE_1;
10068 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
10069 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
10071 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
10072 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
10074 // display counter to choose size of envelope text area
10075 MapCounterButtons(counter1_id);
10076 MapCounterButtons(counter2_id);
10078 // display checkbuttons to choose auto-wrap and alignment properties
10079 MapCheckbuttonGadget(button1_id);
10080 MapCheckbuttonGadget(button2_id);
10082 DrawEnvelopeTextArea(envelope_nr);
10085 if (IS_MM_MCDUFFIN(properties_element))
10087 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
10088 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
10089 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
10092 if (IS_DF_LASER(properties_element))
10094 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
10095 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
10096 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
10099 if (IS_CUSTOM_ELEMENT(properties_element))
10101 // draw stickybutton gadget
10102 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10104 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10106 // draw checkbutton gadgets
10107 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
10108 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
10109 MapCheckbuttonGadget(i);
10111 // draw counter gadgets
10112 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
10113 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
10114 MapCounterButtons(i);
10116 // draw selectbox gadgets
10117 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
10118 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
10119 MapSelectboxGadget(i);
10121 // draw textbutton gadgets
10122 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10124 // draw text input gadgets
10125 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10127 // draw drawing area gadgets
10128 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10130 draw_footer_line = TRUE;
10132 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10134 // draw checkbutton gadgets
10135 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
10136 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
10137 MapCheckbuttonGadget(i);
10139 // draw counter gadgets
10140 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
10141 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
10142 MapCounterButtons(i);
10144 // draw selectbox gadgets
10145 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
10146 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
10147 MapSelectboxGadget(i);
10149 // draw drawing area gadgets
10150 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
10151 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
10152 DrawCustomContentArea();
10155 else if (IS_GROUP_ELEMENT(properties_element))
10157 // draw stickybutton gadget
10158 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10160 // draw checkbutton gadgets
10161 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10162 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10164 // draw counter gadgets
10165 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
10167 // draw selectbox gadgets
10168 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
10170 // draw textbutton gadgets
10171 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10173 // draw drawing area gadgets
10174 DrawGroupElementArea(properties_element);
10176 // draw text input gadgets
10177 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10179 // draw drawing area gadgets
10180 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10182 draw_footer_line = TRUE;
10185 // draw little footer border line above CE/GE use/save template gadgets
10186 if (draw_footer_line)
10188 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
10189 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
10190 int gd_x = gd->x + gd_gi1->border.width / 2;
10191 int gd_y = gd->y + gd_gi1->height - 1;
10192 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
10194 if (tab_color != BLACK_PIXEL) // black => transparent
10195 FillRectangle(drawto,
10196 SX + ED_ELEMENT_SETTINGS_X(0),
10197 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
10199 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10203 static void DrawPropertiesChangeDrawingAreas(void)
10205 if (IS_CUSTOM_ELEMENT(properties_element))
10207 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
10208 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
10209 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
10211 DrawCustomChangeContentArea();
10214 redraw_mask |= REDRAW_FIELD;
10217 static void DrawPropertiesChange(void)
10221 // needed to initially set selectbox options for special action options
10222 setSelectboxSpecialActionOptions();
10224 // draw stickybutton gadget
10225 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10227 // draw checkbutton gadgets
10228 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
10229 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
10230 MapCheckbuttonGadget(i);
10232 // draw counter gadgets
10233 for (i = ED_COUNTER_ID_CHANGE_FIRST;
10234 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
10235 MapCounterButtons(i);
10237 // draw selectbox gadgets
10238 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
10239 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
10240 MapSelectboxGadget(i);
10242 // draw textbutton gadgets
10243 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
10244 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
10245 MapTextbuttonGadget(i);
10247 // draw graphicbutton gadgets
10248 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
10249 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
10250 MapGraphicbuttonGadget(i);
10252 // draw drawing area gadgets
10253 DrawPropertiesChangeDrawingAreas();
10256 static void DrawEditorElementAnimation(int x, int y)
10258 int graphic = el2img(properties_element);
10259 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
10260 custom_element.ce_value_fixed_initial :
10261 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
10262 custom_element.collect_score_initial : FrameCounter);
10264 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
10267 static void DrawEditorElementName(int x, int y, int font_nr)
10269 char *element_name = getElementInfoText(properties_element);
10270 int font_width = getFontWidth(font_nr);
10271 int font_height = getFontHeight(font_nr);
10272 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
10273 int max_chars_per_line = max_text_width / font_width;
10274 char buffer[max_chars_per_line + 1];
10276 if (strlen(element_name) <= max_chars_per_line)
10277 DrawTextS(x, y, font_nr, element_name);
10280 int next_pos = max_chars_per_line;
10282 strncpy(buffer, element_name, max_chars_per_line);
10283 buffer[max_chars_per_line] = '\0';
10285 if (element_name[max_chars_per_line] == ' ')
10291 for (i = max_chars_per_line - 1; i >= 0; i--)
10292 if (buffer[i] == ' ')
10295 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
10302 DrawTextS(x, y - font_height / 2, font_nr, buffer);
10304 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
10305 buffer[max_chars_per_line] = '\0';
10307 DrawTextS(x, y + font_height / 2, font_nr, buffer);
10311 static void DrawPropertiesWindow(void)
10313 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
10314 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
10315 int border_size = gd->border_size;
10316 int font_nr = FONT_TEXT_1;
10317 int font_height = getFontHeight(font_nr);
10318 int xoffset = TILEX + element_border + 3 * border_size;
10319 int yoffset = (TILEY - font_height) / 2;
10320 int x1 = editor.settings.element_graphic.x + element_border;
10321 int y1 = editor.settings.element_graphic.y + element_border;
10322 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
10323 editor.settings.element_name.x);
10324 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
10325 editor.settings.element_name.y);
10326 char *text = "Element Settings";
10327 int font2_nr = FONT_TITLE_1;
10328 struct MenuPosInfo *pos = &editor.settings.headline;
10329 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
10330 int sy = SY + pos->y;
10332 stick_element_properties_window = FALSE;
10334 // make sure that previous properties edit mode exists for this element
10335 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
10336 !IS_CUSTOM_ELEMENT(properties_element))
10337 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
10339 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
10340 !ELEM_IS_PLAYER(properties_element) &&
10341 !IS_CUSTOM_ELEMENT(properties_element))
10342 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
10344 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
10345 (ELEM_IS_PLAYER(properties_element) ||
10346 IS_CUSTOM_ELEMENT(properties_element)))
10347 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
10349 CopyElementPropertiesToEditor(properties_element);
10351 UnmapLevelEditorFieldGadgets();
10352 UnmapLevelEditorToolboxDrawingGadgets();
10353 UnmapLevelEditorToolboxCustomGadgets();
10355 if (IS_CUSTOM_ELEMENT(properties_element) ||
10356 IS_GROUP_ELEMENT(properties_element))
10357 MapLevelEditorToolboxCustomGadgets();
10359 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10362 DrawText(sx, sy, text, font2_nr);
10364 FrameCounter = 0; // restart animation frame counter
10366 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
10367 DrawEditorElementAnimation(SX + x1, SY + y1);
10368 DrawEditorElementName(x2, y2, font_nr);
10370 DrawPropertiesTabulatorGadgets();
10372 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
10373 DrawPropertiesInfo();
10374 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
10375 DrawPropertiesChange();
10376 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
10377 DrawPropertiesConfig();
10380 static void DrawPaletteWindow(void)
10384 UnmapLevelEditorFieldGadgets();
10386 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10389 // map buttons to select elements
10390 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
10391 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
10392 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
10393 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
10394 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
10397 static void UpdateCustomElementGraphicGadgets(void)
10401 InitElementPropertiesGfxElement();
10403 ModifyEditorElementList();
10404 RedrawDrawingElements();
10406 // force redraw of all mapped drawing area gadgets
10407 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
10409 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
10416 static int getOpenDirectionFromTube(int element)
10420 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
10421 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
10422 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
10423 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
10424 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
10425 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
10426 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
10427 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
10428 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
10429 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
10430 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
10436 static int getTubeFromOpenDirection(int direction)
10440 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
10441 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
10442 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
10443 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
10444 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
10445 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
10446 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
10447 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
10448 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
10449 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
10450 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
10452 // if only one direction, fall back to simple tube with that direction
10453 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
10454 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
10455 case (MV_UP): return EL_TUBE_VERTICAL;
10456 case (MV_DOWN): return EL_TUBE_VERTICAL;
10462 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
10464 int element_new = getTubeFromOpenDirection(direction);
10466 return (element_new != EL_EMPTY ? element_new : element_old);
10469 static int getOpenDirectionFromBelt(int element)
10471 int belt_dir = getBeltDirFromBeltElement(element);
10473 return (belt_dir == MV_LEFT ? MV_RIGHT :
10474 belt_dir == MV_RIGHT ? MV_LEFT :
10475 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
10478 static int getBeltFromNrAndOpenDirection(int nr, int direction)
10480 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
10481 direction == MV_RIGHT ? MV_LEFT :
10482 direction == MV_HORIZONTAL ? MV_NONE : direction);
10484 if (direction == MV_NONE)
10487 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
10490 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
10493 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
10495 return (element_new != EL_EMPTY ? element_new : element_old);
10498 static int getOpenDirectionFromPool(int element)
10502 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
10503 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
10504 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
10505 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
10506 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
10507 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
10513 static int getPoolFromOpenDirection(int direction)
10517 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
10518 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
10519 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
10520 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
10521 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
10522 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
10528 static int getPoolFromOpenDirectionExt(int direction, int help_element)
10530 int element = getPoolFromOpenDirection(direction);
10531 int help_direction = getOpenDirectionFromPool(help_element);
10533 if (element == EL_EMPTY)
10535 int help_direction_vertical = help_direction & MV_VERTICAL;
10537 element = getPoolFromOpenDirection(direction | help_direction_vertical);
10540 if (element == EL_EMPTY)
10542 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
10544 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
10550 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
10552 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
10554 return (element_new != EL_EMPTY ? element_new : element_old);
10557 static int getOpenDirectionFromPillar(int element)
10561 case EL_EMC_WALL_1: return (MV_DOWN);
10562 case EL_EMC_WALL_2: return (MV_VERTICAL);
10563 case EL_EMC_WALL_3: return (MV_UP);
10569 static int getPillarFromOpenDirection(int direction)
10573 case (MV_DOWN): return EL_EMC_WALL_1;
10574 case (MV_VERTICAL): return EL_EMC_WALL_2;
10575 case (MV_UP): return EL_EMC_WALL_3;
10581 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
10583 int element_new = getPillarFromOpenDirection(direction);
10585 return (element_new != EL_EMPTY ? element_new : element_old);
10588 static int getOpenDirectionFromSteel2(int element)
10592 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
10593 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
10594 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
10595 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
10596 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
10597 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
10598 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
10599 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
10605 static int getSteel2FromOpenDirection(int direction)
10609 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
10610 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
10611 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
10612 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
10613 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
10614 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
10615 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
10616 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
10622 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
10624 int element_new = getSteel2FromOpenDirection(direction);
10626 return (element_new != EL_EMPTY ? element_new : element_old);
10629 static int getOpenDirectionFromChip(int element)
10633 case EL_SP_CHIP_SINGLE: return (MV_NONE);
10634 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
10635 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
10636 case EL_SP_CHIP_TOP: return (MV_DOWN);
10637 case EL_SP_CHIP_BOTTOM: return (MV_UP);
10643 static int getChipFromOpenDirection(int direction)
10647 case (MV_NONE): return EL_SP_CHIP_SINGLE;
10648 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
10649 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
10650 case (MV_UP): return EL_SP_CHIP_BOTTOM;
10651 case (MV_DOWN): return EL_SP_CHIP_TOP;
10657 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
10659 int element_new = getChipFromOpenDirection(direction);
10661 return (element_new != EL_EMPTY ? element_new : element_old);
10664 static int getClosedTube(int x, int y)
10666 static int xy[4][2] =
10673 int element_old = IntelliDrawBuffer[x][y];
10674 int direction_old = getOpenDirectionFromTube(element_old);
10675 int direction_new = MV_NONE;
10678 for (i = 0; i < NUM_DIRECTIONS; i++)
10680 int xx = x + xy[i][0];
10681 int yy = y + xy[i][1];
10682 int dir = MV_DIR_FROM_BIT(i);
10683 int dir_opposite = MV_DIR_OPPOSITE(dir);
10685 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
10686 (direction_old & dir) &&
10687 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10688 direction_new |= dir;
10691 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
10694 static int getClosedBelt(int x, int y)
10696 static int xy[4][2] =
10703 int element_old = IntelliDrawBuffer[x][y];
10704 int nr = getBeltNrFromBeltElement(element_old);
10705 int direction_old = getOpenDirectionFromBelt(element_old);
10706 int direction_new = MV_NONE;
10709 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10711 int xx = x + xy[i][0];
10712 int yy = y + xy[i][1];
10713 int dir = MV_DIR_FROM_BIT(i);
10714 int dir_opposite = MV_DIR_OPPOSITE(dir);
10716 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
10717 (direction_old & dir) &&
10718 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10719 direction_new |= dir;
10722 return getBeltFromNrAndOpenDirection(nr, direction_new);
10725 static int getClosedPool(int x, int y)
10727 static int xy[4][2] =
10734 int element_old = IntelliDrawBuffer[x][y];
10735 int direction_old = getOpenDirectionFromPool(element_old);
10736 int direction_new = MV_NONE;
10739 for (i = 0; i < NUM_DIRECTIONS; i++)
10741 int xx = x + xy[i][0];
10742 int yy = y + xy[i][1];
10743 int dir = MV_DIR_FROM_BIT(i);
10744 int dir_opposite = MV_DIR_OPPOSITE(dir);
10746 if (IN_LEV_FIELD(xx, yy) &&
10747 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
10748 (direction_old & dir) &&
10749 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10750 direction_new |= dir;
10753 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
10756 static int getClosedPillar(int x, int y)
10758 static int xy[4][2] =
10765 int element_old = IntelliDrawBuffer[x][y];
10766 int direction_old = getOpenDirectionFromPillar(element_old);
10767 int direction_new = MV_NONE;
10770 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
10772 int xx = x + xy[i][0];
10773 int yy = y + xy[i][1];
10774 int dir = MV_DIR_FROM_BIT(i);
10775 int dir_opposite = MV_DIR_OPPOSITE(dir);
10777 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
10778 (direction_old & dir) &&
10779 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10780 direction_new |= dir;
10783 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
10786 static int getClosedSteel2(int x, int y)
10788 static int xy[4][2] =
10795 int element_old = IntelliDrawBuffer[x][y];
10796 int direction_old = getOpenDirectionFromSteel2(element_old);
10797 int direction_new = MV_NONE;
10800 for (i = 0; i < NUM_DIRECTIONS; i++)
10802 int xx = x + xy[i][0];
10803 int yy = y + xy[i][1];
10804 int dir = MV_DIR_FROM_BIT(i);
10805 int dir_opposite = MV_DIR_OPPOSITE(dir);
10807 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
10808 (direction_old & dir) &&
10809 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10810 direction_new |= dir;
10813 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
10816 static int getClosedChip(int x, int y)
10818 static int xy[4][2] =
10825 int element_old = IntelliDrawBuffer[x][y];
10826 int direction_old = getOpenDirectionFromChip(element_old);
10827 int direction_new = MV_NONE;
10830 for (i = 0; i < NUM_DIRECTIONS; i++)
10832 int xx = x + xy[i][0];
10833 int yy = y + xy[i][1];
10834 int dir = MV_DIR_FROM_BIT(i);
10835 int dir_opposite = MV_DIR_OPPOSITE(dir);
10837 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
10838 (direction_old & dir) &&
10839 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10840 direction_new |= dir;
10843 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
10846 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
10847 boolean change_level)
10849 int sx = x - level_xpos;
10850 int sy = y - level_ypos;
10851 int old_element = Tile[x][y];
10852 int new_element = element;
10853 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
10854 boolean draw_masked = FALSE;
10856 if (IS_MM_WALL_EDITOR(element))
10858 element = map_mm_wall_element_editor(element) | new_bitmask;
10860 if (IS_MM_WALL(old_element))
10861 element |= MM_WALL_BITS(old_element);
10864 draw_masked = TRUE;
10866 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
10868 int element_changed = old_element & ~new_bitmask;
10870 if (MM_WALL_BITS(element_changed) != 0)
10871 element = element_changed;
10874 IntelliDrawBuffer[x][y] = element;
10877 Tile[x][y] = element;
10879 if (IN_ED_FIELD(sx, sy))
10881 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
10882 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
10883 else if (draw_masked)
10884 DrawEditorElementThruMask(sx, sy, element);
10886 DrawEditorElement(sx, sy, element);
10890 static void SetElementSimple(int x, int y, int element, boolean change_level)
10892 SetElementSimpleExt(x, y, 0, 0, element, change_level);
10895 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
10896 int x2, int y2, int *element2,
10897 int (*close_function)(int, int),
10898 boolean change_level)
10900 // set neighbour elements to newly determined connections
10901 SetElementSimple(x1, y1, *element1, change_level);
10902 SetElementSimple(x2, y2, *element2, change_level);
10904 // remove all open connections of neighbour elements
10905 *element1 = close_function(x1, y1);
10906 *element2 = close_function(x2, y2);
10908 // set neighbour elements to new, minimized connections
10909 SetElementSimple(x1, y1, *element1, change_level);
10910 SetElementSimple(x2, y2, *element2, change_level);
10913 static void SetElementIntelliDraw(int x, int y, int new_element,
10914 boolean change_level, int button)
10916 static int xy[4][2] =
10923 static int last_x = -1;
10924 static int last_y = -1;
10926 if (new_element == EL_UNDEFINED)
10934 int old_element = IntelliDrawBuffer[x][y];
10936 if (IS_TUBE(new_element))
10938 int last_element_new = EL_UNDEFINED;
10939 int direction = MV_NONE;
10942 // if old element is of same kind, keep all existing directions
10943 if (IS_TUBE(old_element))
10944 direction |= getOpenDirectionFromTube(old_element);
10946 for (i = 0; i < NUM_DIRECTIONS; i++)
10948 int xx = x + xy[i][0];
10949 int yy = y + xy[i][1];
10951 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10952 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
10954 int dir = MV_DIR_FROM_BIT(i);
10955 int dir_opposite = MV_DIR_OPPOSITE(dir);
10956 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10957 int last_direction_old = getOpenDirectionFromTube(last_element_old);
10958 int last_direction_new = last_direction_old | dir_opposite;
10960 last_element_new = getTubeFromOpenDirection(last_direction_new);
10966 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
10968 if (last_element_new != EL_UNDEFINED)
10969 MergeAndCloseNeighbourElements(x, y, &new_element,
10970 last_x, last_y, &last_element_new,
10971 getClosedTube, change_level);
10973 else if (IS_BELT(new_element))
10975 int belt_nr = getBeltNrFromBeltElement(new_element);
10976 int last_element_new = EL_UNDEFINED;
10977 int direction = MV_NONE;
10980 // if old element is of same kind, keep all existing directions
10981 if (IS_BELT(old_element))
10982 direction |= getOpenDirectionFromBelt(old_element);
10984 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10986 int xx = x + xy[i][0];
10987 int yy = y + xy[i][1];
10989 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
10990 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
10992 int dir = MV_DIR_FROM_BIT(i);
10993 int dir_opposite = MV_DIR_OPPOSITE(dir);
10994 int last_element_old = IntelliDrawBuffer[last_x][last_y];
10995 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
10996 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
10997 int last_direction_new = last_direction_old | dir_opposite;
10999 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11000 last_direction_new);
11005 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
11007 if (last_element_new != EL_UNDEFINED)
11008 MergeAndCloseNeighbourElements(x, y, &new_element,
11009 last_x, last_y, &last_element_new,
11010 getClosedBelt, change_level);
11012 else if (IS_ACID_POOL_OR_ACID(new_element))
11014 int last_element_new = EL_UNDEFINED;
11015 int direction = MV_NONE;
11018 // if old element is of same kind, keep all existing directions
11019 if (IS_ACID_POOL_OR_ACID(old_element))
11020 direction |= getOpenDirectionFromPool(old_element);
11022 for (i = 0; i < NUM_DIRECTIONS; i++)
11024 int xx = x + xy[i][0];
11025 int yy = y + xy[i][1];
11027 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11028 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
11030 int dir = MV_DIR_FROM_BIT(i);
11031 int dir_opposite = MV_DIR_OPPOSITE(dir);
11032 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11033 int last_direction_old = getOpenDirectionFromPool(last_element_old);
11034 int last_direction_new = last_direction_old | dir_opposite;
11036 last_element_new = getPoolFromOpenDirection(last_direction_new);
11042 // special corrections needed for intuitively correct acid pool drawing
11043 if (last_element_new == EL_EMPTY)
11044 last_element_new = new_element;
11045 else if (last_element_new != EL_UNDEFINED)
11046 new_element = last_element_new;
11048 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
11050 if (last_element_new != EL_UNDEFINED)
11051 MergeAndCloseNeighbourElements(x, y, &new_element,
11052 last_x, last_y, &last_element_new,
11053 getClosedPool, change_level);
11055 else if (IS_EMC_PILLAR(new_element))
11057 int last_element_new = EL_UNDEFINED;
11058 int direction = MV_NONE;
11061 // if old element is of same kind, keep all existing directions
11062 if (IS_EMC_PILLAR(old_element))
11063 direction |= getOpenDirectionFromPillar(old_element);
11065 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11067 int xx = x + xy[i][0];
11068 int yy = y + xy[i][1];
11070 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11071 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
11073 int dir = MV_DIR_FROM_BIT(i);
11074 int dir_opposite = MV_DIR_OPPOSITE(dir);
11075 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11076 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
11077 int last_direction_new = last_direction_old | dir_opposite;
11079 last_element_new = getPillarFromOpenDirection(last_direction_new);
11085 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
11087 if (last_element_new != EL_UNDEFINED)
11088 MergeAndCloseNeighbourElements(x, y, &new_element,
11089 last_x, last_y, &last_element_new,
11090 getClosedPillar, change_level);
11092 else if (IS_DC_STEELWALL_2(new_element))
11094 int last_element_new = EL_UNDEFINED;
11095 int direction = MV_NONE;
11098 // if old element is of same kind, keep all existing directions
11099 if (IS_DC_STEELWALL_2(old_element))
11100 direction |= getOpenDirectionFromSteel2(old_element);
11102 for (i = 0; i < NUM_DIRECTIONS; i++)
11104 int xx = x + xy[i][0];
11105 int yy = y + xy[i][1];
11107 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11108 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
11110 int dir = MV_DIR_FROM_BIT(i);
11111 int dir_opposite = MV_DIR_OPPOSITE(dir);
11112 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11113 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
11114 int last_direction_new = last_direction_old | dir_opposite;
11116 last_element_new = getSteel2FromOpenDirection(last_direction_new);
11122 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
11124 if (last_element_new != EL_UNDEFINED)
11125 MergeAndCloseNeighbourElements(x, y, &new_element,
11126 last_x, last_y, &last_element_new,
11127 getClosedSteel2, change_level);
11129 else if (IS_SP_CHIP(new_element))
11131 int last_element_new = EL_UNDEFINED;
11132 int direction = MV_NONE;
11135 // (do not keep existing directions, regardless of kind of old element)
11137 for (i = 0; i < NUM_DIRECTIONS; i++)
11139 int xx = x + xy[i][0];
11140 int yy = y + xy[i][1];
11142 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11143 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
11145 int dir = MV_DIR_FROM_BIT(i);
11146 int dir_opposite = MV_DIR_OPPOSITE(dir);
11147 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11148 int last_direction_old = getOpenDirectionFromChip(last_element_old);
11149 int last_direction_new = last_direction_old | dir_opposite;
11151 if (last_direction_old == MV_NONE)
11153 last_element_new = getChipFromOpenDirection(last_direction_new);
11156 else if (last_direction_old & (dir | dir_opposite))
11158 direction |= MV_DIR_OPPOSITE(last_direction_old);
11162 direction |= MV_DIR_OPPOSITE(dir);
11167 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
11169 if (last_element_new != EL_UNDEFINED)
11170 MergeAndCloseNeighbourElements(x, y, &new_element,
11171 last_x, last_y, &last_element_new,
11172 getClosedChip, change_level);
11174 else if (IS_SP_HARDWARE_BASE(new_element))
11176 int nr = GetSimpleRandom(6);
11178 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
11179 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
11180 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
11181 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
11182 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
11184 else if (new_element == EL_SP_HARDWARE_GREEN ||
11185 new_element == EL_SP_HARDWARE_BLUE ||
11186 new_element == EL_SP_HARDWARE_RED)
11188 int nr = GetSimpleRandom(3);
11190 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
11191 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
11193 else if (IS_GROUP_ELEMENT(new_element))
11195 boolean connected_drawing = FALSE;
11198 for (i = 0; i < NUM_DIRECTIONS; i++)
11200 int xx = x + xy[i][0];
11201 int yy = y + xy[i][1];
11203 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11204 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
11205 connected_drawing = TRUE;
11208 if (!connected_drawing)
11209 ResolveGroupElement(new_element);
11211 new_element = GetElementFromGroupElement(new_element);
11213 else if (IS_BELT_SWITCH(old_element))
11215 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
11216 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
11218 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
11219 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
11221 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
11225 static int swappable_elements[][2] =
11227 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
11228 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
11229 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
11230 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
11231 { EL_EMERALD, EL_WALL_EMERALD },
11232 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
11233 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
11234 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
11235 { EL_DIAMOND, EL_WALL_DIAMOND },
11236 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
11237 { EL_GATE_1, EL_GATE_1_GRAY },
11238 { EL_GATE_2, EL_GATE_2_GRAY },
11239 { EL_GATE_3, EL_GATE_3_GRAY },
11240 { EL_GATE_4, EL_GATE_4_GRAY },
11241 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
11242 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
11243 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
11244 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
11245 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
11246 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
11247 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
11248 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
11249 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
11250 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
11251 { EL_LAMP, EL_LAMP_ACTIVE },
11252 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
11253 { EL_SP_BASE, EL_SP_BUGGY_BASE },
11254 { EL_PEARL, EL_WALL_PEARL },
11255 { EL_CRYSTAL, EL_WALL_CRYSTAL },
11256 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
11257 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
11258 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
11259 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
11260 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
11261 { EL_LANDMINE, EL_DC_LANDMINE },
11262 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
11263 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
11264 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
11265 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
11266 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
11267 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
11268 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
11269 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
11270 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
11274 static int rotatable_elements_4[][4] =
11284 EL_SPACESHIP_RIGHT,
11289 EL_BD_BUTTERFLY_UP,
11290 EL_BD_BUTTERFLY_RIGHT,
11291 EL_BD_BUTTERFLY_DOWN,
11292 EL_BD_BUTTERFLY_LEFT
11296 EL_BD_FIREFLY_RIGHT,
11297 EL_BD_FIREFLY_DOWN,
11325 EL_SP_GRAVITY_PORT_UP,
11326 EL_SP_GRAVITY_PORT_RIGHT,
11327 EL_SP_GRAVITY_PORT_DOWN,
11328 EL_SP_GRAVITY_PORT_LEFT
11331 EL_SP_GRAVITY_ON_PORT_UP,
11332 EL_SP_GRAVITY_ON_PORT_RIGHT,
11333 EL_SP_GRAVITY_ON_PORT_DOWN,
11334 EL_SP_GRAVITY_ON_PORT_LEFT
11337 EL_SP_GRAVITY_OFF_PORT_UP,
11338 EL_SP_GRAVITY_OFF_PORT_RIGHT,
11339 EL_SP_GRAVITY_OFF_PORT_DOWN,
11340 EL_SP_GRAVITY_OFF_PORT_LEFT
11349 EL_BALLOON_SWITCH_UP,
11350 EL_BALLOON_SWITCH_RIGHT,
11351 EL_BALLOON_SWITCH_DOWN,
11352 EL_BALLOON_SWITCH_LEFT
11356 EL_MM_MCDUFFIN_RIGHT,
11357 EL_MM_MCDUFFIN_DOWN,
11358 EL_MM_MCDUFFIN_LEFT
11361 EL_MM_MIRROR_FIXED_1,
11362 EL_MM_MIRROR_FIXED_4,
11363 EL_MM_MIRROR_FIXED_3,
11364 EL_MM_MIRROR_FIXED_2
11367 EL_MM_STEEL_GRID_FIXED_1,
11368 EL_MM_STEEL_GRID_FIXED_4,
11369 EL_MM_STEEL_GRID_FIXED_2,
11370 EL_MM_STEEL_GRID_FIXED_3
11373 EL_MM_WOODEN_GRID_FIXED_1,
11374 EL_MM_WOODEN_GRID_FIXED_4,
11375 EL_MM_WOODEN_GRID_FIXED_2,
11376 EL_MM_WOODEN_GRID_FIXED_3
11379 EL_MM_POLARIZER_CROSS_1,
11380 EL_MM_POLARIZER_CROSS_4,
11381 EL_MM_POLARIZER_CROSS_3,
11382 EL_MM_POLARIZER_CROSS_2
11386 EL_MM_PACMAN_RIGHT,
11398 EL_DF_RECEIVER_RIGHT,
11399 EL_DF_RECEIVER_DOWN,
11400 EL_DF_RECEIVER_LEFT
11407 static int rotatable_elements_8[][8] =
11410 EL_DF_STEEL_GRID_FIXED_1,
11411 EL_DF_STEEL_GRID_FIXED_8,
11412 EL_DF_STEEL_GRID_FIXED_7,
11413 EL_DF_STEEL_GRID_FIXED_6,
11414 EL_DF_STEEL_GRID_FIXED_5,
11415 EL_DF_STEEL_GRID_FIXED_4,
11416 EL_DF_STEEL_GRID_FIXED_3,
11417 EL_DF_STEEL_GRID_FIXED_2
11420 EL_DF_WOODEN_GRID_FIXED_1,
11421 EL_DF_WOODEN_GRID_FIXED_8,
11422 EL_DF_WOODEN_GRID_FIXED_7,
11423 EL_DF_WOODEN_GRID_FIXED_6,
11424 EL_DF_WOODEN_GRID_FIXED_5,
11425 EL_DF_WOODEN_GRID_FIXED_4,
11426 EL_DF_WOODEN_GRID_FIXED_3,
11427 EL_DF_WOODEN_GRID_FIXED_2
11430 EL_DF_STEEL_GRID_ROTATING_1,
11431 EL_DF_STEEL_GRID_ROTATING_8,
11432 EL_DF_STEEL_GRID_ROTATING_7,
11433 EL_DF_STEEL_GRID_ROTATING_6,
11434 EL_DF_STEEL_GRID_ROTATING_5,
11435 EL_DF_STEEL_GRID_ROTATING_4,
11436 EL_DF_STEEL_GRID_ROTATING_3,
11437 EL_DF_STEEL_GRID_ROTATING_2
11440 EL_DF_WOODEN_GRID_ROTATING_1,
11441 EL_DF_WOODEN_GRID_ROTATING_8,
11442 EL_DF_WOODEN_GRID_ROTATING_7,
11443 EL_DF_WOODEN_GRID_ROTATING_6,
11444 EL_DF_WOODEN_GRID_ROTATING_5,
11445 EL_DF_WOODEN_GRID_ROTATING_4,
11446 EL_DF_WOODEN_GRID_ROTATING_3,
11447 EL_DF_WOODEN_GRID_ROTATING_2
11454 static int rotatable_elements_16[][16] =
11475 EL_MM_TELEPORTER_5,
11476 EL_MM_TELEPORTER_4,
11477 EL_MM_TELEPORTER_3,
11478 EL_MM_TELEPORTER_2,
11479 EL_MM_TELEPORTER_1,
11480 EL_MM_TELEPORTER_16,
11481 EL_MM_TELEPORTER_15,
11482 EL_MM_TELEPORTER_14,
11483 EL_MM_TELEPORTER_13,
11484 EL_MM_TELEPORTER_12,
11485 EL_MM_TELEPORTER_11,
11486 EL_MM_TELEPORTER_10,
11487 EL_MM_TELEPORTER_9,
11488 EL_MM_TELEPORTER_8,
11489 EL_MM_TELEPORTER_7,
11493 EL_MM_TELEPORTER_RED_5,
11494 EL_MM_TELEPORTER_RED_4,
11495 EL_MM_TELEPORTER_RED_3,
11496 EL_MM_TELEPORTER_RED_2,
11497 EL_MM_TELEPORTER_RED_1,
11498 EL_MM_TELEPORTER_RED_16,
11499 EL_MM_TELEPORTER_RED_15,
11500 EL_MM_TELEPORTER_RED_14,
11501 EL_MM_TELEPORTER_RED_13,
11502 EL_MM_TELEPORTER_RED_12,
11503 EL_MM_TELEPORTER_RED_11,
11504 EL_MM_TELEPORTER_RED_10,
11505 EL_MM_TELEPORTER_RED_9,
11506 EL_MM_TELEPORTER_RED_8,
11507 EL_MM_TELEPORTER_RED_7,
11508 EL_MM_TELEPORTER_RED_6
11511 EL_MM_TELEPORTER_YELLOW_5,
11512 EL_MM_TELEPORTER_YELLOW_4,
11513 EL_MM_TELEPORTER_YELLOW_3,
11514 EL_MM_TELEPORTER_YELLOW_2,
11515 EL_MM_TELEPORTER_YELLOW_1,
11516 EL_MM_TELEPORTER_YELLOW_16,
11517 EL_MM_TELEPORTER_YELLOW_15,
11518 EL_MM_TELEPORTER_YELLOW_14,
11519 EL_MM_TELEPORTER_YELLOW_13,
11520 EL_MM_TELEPORTER_YELLOW_12,
11521 EL_MM_TELEPORTER_YELLOW_11,
11522 EL_MM_TELEPORTER_YELLOW_10,
11523 EL_MM_TELEPORTER_YELLOW_9,
11524 EL_MM_TELEPORTER_YELLOW_8,
11525 EL_MM_TELEPORTER_YELLOW_7,
11526 EL_MM_TELEPORTER_YELLOW_6
11529 EL_MM_TELEPORTER_GREEN_5,
11530 EL_MM_TELEPORTER_GREEN_4,
11531 EL_MM_TELEPORTER_GREEN_3,
11532 EL_MM_TELEPORTER_GREEN_2,
11533 EL_MM_TELEPORTER_GREEN_1,
11534 EL_MM_TELEPORTER_GREEN_16,
11535 EL_MM_TELEPORTER_GREEN_15,
11536 EL_MM_TELEPORTER_GREEN_14,
11537 EL_MM_TELEPORTER_GREEN_13,
11538 EL_MM_TELEPORTER_GREEN_12,
11539 EL_MM_TELEPORTER_GREEN_11,
11540 EL_MM_TELEPORTER_GREEN_10,
11541 EL_MM_TELEPORTER_GREEN_9,
11542 EL_MM_TELEPORTER_GREEN_8,
11543 EL_MM_TELEPORTER_GREEN_7,
11544 EL_MM_TELEPORTER_GREEN_6
11547 EL_MM_TELEPORTER_BLUE_5,
11548 EL_MM_TELEPORTER_BLUE_4,
11549 EL_MM_TELEPORTER_BLUE_3,
11550 EL_MM_TELEPORTER_BLUE_2,
11551 EL_MM_TELEPORTER_BLUE_1,
11552 EL_MM_TELEPORTER_BLUE_16,
11553 EL_MM_TELEPORTER_BLUE_15,
11554 EL_MM_TELEPORTER_BLUE_14,
11555 EL_MM_TELEPORTER_BLUE_13,
11556 EL_MM_TELEPORTER_BLUE_12,
11557 EL_MM_TELEPORTER_BLUE_11,
11558 EL_MM_TELEPORTER_BLUE_10,
11559 EL_MM_TELEPORTER_BLUE_9,
11560 EL_MM_TELEPORTER_BLUE_8,
11561 EL_MM_TELEPORTER_BLUE_7,
11562 EL_MM_TELEPORTER_BLUE_6
11566 EL_MM_POLARIZER_16,
11567 EL_MM_POLARIZER_15,
11568 EL_MM_POLARIZER_14,
11569 EL_MM_POLARIZER_13,
11570 EL_MM_POLARIZER_12,
11571 EL_MM_POLARIZER_11,
11572 EL_MM_POLARIZER_10,
11601 EL_DF_MIRROR_ROTATING_1,
11602 EL_DF_MIRROR_ROTATING_16,
11603 EL_DF_MIRROR_ROTATING_15,
11604 EL_DF_MIRROR_ROTATING_14,
11605 EL_DF_MIRROR_ROTATING_13,
11606 EL_DF_MIRROR_ROTATING_12,
11607 EL_DF_MIRROR_ROTATING_11,
11608 EL_DF_MIRROR_ROTATING_10,
11609 EL_DF_MIRROR_ROTATING_9,
11610 EL_DF_MIRROR_ROTATING_8,
11611 EL_DF_MIRROR_ROTATING_7,
11612 EL_DF_MIRROR_ROTATING_6,
11613 EL_DF_MIRROR_ROTATING_5,
11614 EL_DF_MIRROR_ROTATING_4,
11615 EL_DF_MIRROR_ROTATING_3,
11616 EL_DF_MIRROR_ROTATING_2
11625 for (i = 0; swappable_elements[i][0] != -1; i++)
11627 int element1 = swappable_elements[i][0];
11628 int element2 = swappable_elements[i][1];
11630 if (old_element == element1 || old_element == element2)
11631 new_element = (old_element == element1 ? element2 : element1);
11634 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
11636 for (j = 0; j < 4; j++)
11638 int element = rotatable_elements_4[i][j];
11640 if (old_element == element)
11641 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
11642 button == 2 ? rotatable_elements_4[i][0] :
11643 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
11648 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
11650 for (j = 0; j < 8; j++)
11652 int element = rotatable_elements_8[i][j];
11654 if (old_element == element)
11655 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
11656 button == 2 ? rotatable_elements_8[i][0] :
11657 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
11662 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
11664 for (j = 0; j < 16; j++)
11666 int element = rotatable_elements_16[i][j];
11668 if (old_element == element)
11669 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
11670 button == 2 ? rotatable_elements_16[i][0] :
11671 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
11676 if (old_element != new_element)
11678 int max_infotext_len = getMaxInfoTextLength();
11679 char infotext[MAX_OUTPUT_LINESIZE + 1];
11681 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
11682 infotext[max_infotext_len] = '\0';
11684 ClearEditorGadgetInfoText();
11686 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
11691 SetElementSimple(x, y, new_element, change_level);
11697 static void ResetIntelliDraw(void)
11701 for (x = 0; x < lev_fieldx; x++)
11702 for (y = 0; y < lev_fieldy; y++)
11703 IntelliDrawBuffer[x][y] = Tile[x][y];
11705 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
11708 static boolean draw_mode_hires = FALSE;
11710 static boolean isHiresTileElement(int element)
11712 return (IS_MM_WALL(element) || element == EL_EMPTY);
11715 static boolean isHiresDrawElement(int element)
11717 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
11720 static void SetDrawModeHiRes(int element)
11723 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
11724 isHiresDrawElement(element));
11727 static boolean getDrawModeHiRes(void)
11729 return draw_mode_hires;
11732 static int getLoResScreenPos(int pos)
11734 return (getDrawModeHiRes() ? pos / 2 : pos);
11737 static int getLoResScreenMod(int pos)
11739 return (getDrawModeHiRes() ? pos % 2 : 0);
11742 static void SetElementExt(int x, int y, int dx, int dy, int element,
11743 boolean change_level, int button)
11746 SetElementSimple(x, y, Tile[x][y], change_level);
11747 else if (GetKeyModState() & KMOD_Shift && !IS_MM_WALL_EDITOR(element))
11748 SetElementIntelliDraw(x, y, element, change_level, button);
11750 SetElementSimpleExt(x, y, dx, dy, element, change_level);
11753 static void SetElement(int x, int y, int element)
11755 SetElementExt(x, y, 0, 0, element, TRUE, -1);
11758 static void SetElementButton(int x, int y, int dx, int dy, int element,
11761 SetElementExt(x, y, dx, dy, element, TRUE, button);
11764 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
11766 int lx = getLoResScreenPos(sx2) + level_xpos;
11767 int ly = getLoResScreenPos(sy2) + level_ypos;
11768 int dx = getLoResScreenMod(sx2);
11769 int dy = getLoResScreenMod(sy2);
11771 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
11774 static void SetLevelElementHiRes(int lx2, int ly2, int element)
11781 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
11784 static int getLevelElementHiRes(int lx2, int ly2)
11790 int element = Tile[lx][ly];
11791 unsigned int bitmask = (dx + 1) << (dy * 2);
11793 if (IS_MM_WALL(element))
11795 if (element & bitmask)
11796 return map_mm_wall_element(element);
11804 static void DrawLineElement(int x, int y, int element, boolean change_level)
11806 SetElementHiRes(x, y, element, change_level);
11809 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
11810 int element, boolean change_level)
11812 int xsize = ABS(to_x - from_x);
11813 int ysize = ABS(to_y - from_y);
11814 int dx = (to_x < from_x ? -1 : +1);
11815 int dy = (to_y < from_y ? -1 : +1);
11818 if (from_y == to_y) // horizontal line
11820 for (i = 0; i <= xsize; i++)
11821 DrawLineElement(from_x + i * dx, from_y, element, change_level);
11823 else if (from_x == to_x) // vertical line
11825 for (i = 0; i <= ysize; i++)
11826 DrawLineElement(from_x, from_y + i * dy, element, change_level);
11828 else // diagonal line
11830 if (ysize < xsize) // a < 1
11832 float a = (float)ysize / (float)xsize;
11834 for (i = 0; i <= xsize; i++)
11837 int y = dy * (int)(a * i + 0.5);
11839 DrawLineElement(from_x + x, from_y + y, element, change_level);
11844 float a = (float)xsize / (float)ysize;
11846 for (i = 0; i <= ysize; i++)
11848 int x = dx * (int)(a * i + 0.5);
11851 DrawLineElement(from_x + x, from_y + y, element, change_level);
11857 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
11858 int element, boolean change_level)
11860 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
11861 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
11862 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
11863 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
11866 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
11867 int element, boolean change_level)
11872 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
11874 for (y = from_y; y <= to_y; y++)
11875 DrawLine(from_x, y, to_x, y, element, change_level);
11878 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
11879 int element, boolean change_level)
11881 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
11882 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
11883 int len_x = ABS(to_x - from_x);
11884 int len_y = ABS(to_y - from_y);
11887 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
11889 // not optimal (some points get drawn twice) but simple,
11890 // and fast enough for the few points we are drawing
11892 for (x = 0; x <= radius; x++)
11894 int sx, sy, sx2, sy2, lx, ly;
11896 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
11898 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
11899 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
11900 sx = getLoResScreenPos(sx2);
11901 sy = getLoResScreenPos(sy2);
11902 lx = sx + level_xpos;
11903 ly = sy + level_ypos;
11905 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11906 DrawLineElement(sx2, sy2, element, change_level);
11909 for (y = 0; y <= radius; y++)
11911 int sx, sy, sx2, sy2, lx, ly;
11913 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
11915 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
11916 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
11917 sx = getLoResScreenPos(sx2);
11918 sy = getLoResScreenPos(sy2);
11919 lx = sx + level_xpos;
11920 ly = sy + level_ypos;
11922 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
11923 DrawLineElement(sx2, sy2, element, change_level);
11927 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
11928 int element, boolean change_level)
11930 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
11931 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
11933 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
11936 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
11938 #if DRAW_CIRCLES_BUTTON_AVAILABLE
11939 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
11940 int element, boolean change_level)
11942 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
11943 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
11944 int mirror_to_x2 = from_x - (to_x2 - from_x);
11945 int mirror_to_y2 = from_y - (to_y2 - from_y);
11947 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
11948 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
11949 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
11950 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
11954 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
11956 int from_sx, from_sy;
11960 swap_numbers(&from_x, &to_x);
11963 swap_numbers(&from_y, &to_y);
11965 from_sx = SX + from_x * ed_tilesize;
11966 from_sy = SY + from_y * ed_tilesize;
11967 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
11968 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
11970 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
11971 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
11972 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
11973 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
11975 if (from_x == to_x && from_y == to_y)
11976 MarkTileDirty(from_x/2, from_y/2);
11978 redraw_mask |= REDRAW_FIELD;
11981 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
11982 int element, boolean change_level)
11984 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
11987 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
11988 int element, boolean change_level)
11990 if (element == -1 || change_level)
11991 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
11993 DrawAreaBorder(from_x, from_y, to_x, to_y);
11996 // values for CopyBrushExt()
11997 #define CB_AREA_TO_BRUSH 0
11998 #define CB_BRUSH_TO_CURSOR 1
11999 #define CB_BRUSH_TO_LEVEL 2
12000 #define CB_DELETE_OLD_CURSOR 3
12001 #define CB_DUMP_BRUSH 4
12002 #define CB_DUMP_BRUSH_SMALL 5
12003 #define CB_CLIPBOARD_TO_BRUSH 6
12004 #define CB_BRUSH_TO_CLIPBOARD 7
12005 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
12006 #define CB_UPDATE_BRUSH_POSITION 9
12008 #define MAX_CB_PART_SIZE 10
12009 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
12010 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
12011 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
12012 MAX_CB_NUM_LINES * \
12015 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
12017 DrawLineElement(sx, sy, element, change_level);
12020 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
12021 int button, int mode)
12023 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12024 static int brush_width, brush_height;
12025 static int last_cursor_x = -1, last_cursor_y = -1;
12026 static boolean delete_old_brush = FALSE;
12027 int new_element = BUTTON_ELEMENT(button);
12030 if (mode == CB_DUMP_BRUSH ||
12031 mode == CB_DUMP_BRUSH_SMALL ||
12032 mode == CB_BRUSH_TO_CLIPBOARD ||
12033 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12035 if (edit_mode != ED_MODE_DRAWING)
12038 char part[MAX_CB_PART_SIZE + 1] = "";
12039 char text[MAX_CB_TEXT_SIZE + 1] = "";
12040 int width = (draw_with_brush ? brush_width : lev_fieldx);
12041 int height = (draw_with_brush ? brush_height : lev_fieldy);
12042 char *format = "%s%03d";
12044 for (y = 0; y < height; y++)
12045 for (x = 0; x < width; x++)
12046 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
12049 for (y = 0; y < height; y++)
12051 for (x = 0; x < width; x++)
12053 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
12054 char *prefix = (mode == CB_DUMP_BRUSH ||
12055 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
12057 if (element >= NUM_FILE_ELEMENTS)
12058 element = EL_UNKNOWN;
12060 // copy brush to level sketch text buffer for the R'n'D forum:
12061 // - large tiles: `xxx or `xxxx (0x60 ASCII)
12062 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
12063 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
12064 strcat(text, part);
12067 strcat(text, "\n");
12070 if (mode == CB_BRUSH_TO_CLIPBOARD ||
12071 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12072 SDL_SetClipboardText(text);
12074 printf("%s", text); // print brush data to console
12079 if (mode == CB_CLIPBOARD_TO_BRUSH)
12081 if (edit_mode != ED_MODE_DRAWING)
12084 if (!SDL_HasClipboardText())
12086 Request("Clipboard is empty!", REQ_CONFIRM);
12091 boolean copy_to_brush = (draw_with_brush ||
12092 drawing_function == GADGET_ID_GRAB_BRUSH);
12094 // this will delete the old brush, if already drawing with a brush
12096 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
12098 // initialization is required for "odd" (incomplete) clipboard content
12099 for (x = 0; x < MAX_LEV_FIELDX; x++)
12100 for (y = 0; y < MAX_LEV_FIELDY; y++)
12101 brush_buffer[x][y] = EL_EMPTY;
12108 char *clipboard_text = SDL_GetClipboardText();
12109 char *ptr = clipboard_text;
12110 boolean allow_new_row = FALSE;
12111 boolean stop = FALSE;
12113 while (*ptr && !stop)
12115 boolean prefix_found = FALSE;
12116 boolean start_new_row = FALSE;
12118 // level sketch element number prefixes (may be multi-byte characters)
12119 char *prefix_list[] = { "`", "¸" };
12122 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
12124 char *prefix = prefix_list[i];
12126 // check if string is large enough for prefix
12127 if (strlen(ptr) < strlen(prefix))
12134 // check if string starts with prefix
12135 if (strPrefix(ptr, prefix))
12137 ptr += strlen(prefix);
12139 prefix_found = TRUE;
12145 // check if prefix found and followed by (at least) three digits
12146 if (prefix_found &&
12147 strlen(ptr) >= 3 &&
12148 ptr[0] >= '0' && ptr[0] <= '9' &&
12149 ptr[1] >= '0' && ptr[1] <= '9' &&
12150 ptr[2] >= '0' && ptr[2] <= '9')
12152 int element = ((ptr[0] - '0') * 100 +
12153 (ptr[1] - '0') * 10 +
12158 // level sketch element number might consist of four digits
12159 if (ptr[0] >= '0' && ptr[0] <= '9')
12161 element = element * 10 + (ptr[0] - '0');
12165 if (element >= NUM_FILE_ELEMENTS)
12166 element = EL_UNKNOWN;
12168 brush_buffer[x][y] = element;
12170 brush_width = MAX(x + 1, brush_width);
12171 brush_height = MAX(y + 1, brush_height);
12175 if (x >= MAX_LEV_FIELDX)
12176 start_new_row = TRUE;
12178 allow_new_row = TRUE;
12182 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
12183 start_new_row = TRUE;
12185 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
12193 if (y >= MAX_LEV_FIELDY)
12196 allow_new_row = FALSE;
12200 SDL_free(clipboard_text);
12202 if (brush_width == 0 || brush_height == 0)
12204 Request("No level sketch found in clipboard!", REQ_CONFIRM);
12211 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
12214 SDL_GetMouseState(&mx, &my);
12216 // if inside drawing area, activate and draw brush at last mouse position
12217 if (mx >= gi->x && mx < gi->x + gi->width &&
12218 my >= gi->y && my < gi->y + gi->height)
12219 CopyBrushToCursor(last_cursor_x, last_cursor_y);
12221 draw_with_brush = TRUE;
12227 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
12228 brush_width, brush_height);
12230 if (!Request(request, REQ_ASK))
12233 for (x = 0; x < MAX_LEV_FIELDX; x++)
12234 for (y = 0; y < MAX_LEV_FIELDY; y++)
12235 Tile[x][y] = brush_buffer[x][y];
12237 lev_fieldx = level.fieldx = brush_width;
12238 lev_fieldy = level.fieldy = brush_height;
12240 SetBorderElement();
12242 DrawEditModeWindow();
12243 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12249 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
12252 if (mode == CB_AREA_TO_BRUSH)
12254 int from_lx, from_ly;
12257 swap_numbers(&from_x, &to_x);
12260 swap_numbers(&from_y, &to_y);
12262 brush_width = to_x - from_x + 1;
12263 brush_height = to_y - from_y + 1;
12265 from_lx = from_x + level_xpos;
12266 from_ly = from_y + level_ypos;
12268 for (y = 0; y < brush_height; y++)
12270 for (x = 0; x < brush_width; x++)
12272 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
12275 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
12280 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12282 delete_old_brush = FALSE;
12284 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
12285 mode == CB_BRUSH_TO_LEVEL)
12287 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
12288 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
12289 int cursor_from_x = cursor_x - brush_width / 2;
12290 int cursor_from_y = cursor_y - brush_height / 2;
12291 int border_from_x = cursor_x, border_from_y = cursor_y;
12292 int border_to_x = cursor_x, border_to_y = cursor_y;
12294 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
12295 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12297 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
12298 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
12300 delete_old_brush = FALSE;
12305 for (y = 0; y < brush_height; y++)
12307 for (x = 0; x < brush_width; x++)
12309 int sx = cursor_from_x + x;
12310 int sy = cursor_from_y + y;
12311 int lx = sx + level_xpos;
12312 int ly = sy + level_ypos;
12313 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
12314 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
12315 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
12316 brush_buffer[x][y] : new_element);
12318 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12320 if (sx < border_from_x)
12321 border_from_x = sx;
12322 else if (sx > border_to_x)
12324 if (sy < border_from_y)
12325 border_from_y = sy;
12326 else if (sy > border_to_y)
12329 DrawBrushElement(sx, sy, element, change_level);
12334 if (mode != CB_DELETE_OLD_CURSOR)
12335 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
12337 last_cursor_x = cursor_x;
12338 last_cursor_y = cursor_y;
12340 delete_old_brush = TRUE;
12343 if (mode == CB_UPDATE_BRUSH_POSITION)
12345 last_cursor_x = from_x;
12346 last_cursor_y = from_y;
12350 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
12353 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
12356 static void CopyBrushToLevel(int x, int y, int button)
12358 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
12361 static void CopyBrushToCursor(int x, int y)
12363 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
12366 static void UpdateBrushPosition(int x, int y)
12368 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
12371 static void DeleteBrushFromCursor(void)
12373 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12376 void DumpBrush(void)
12378 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
12381 void DumpBrush_Small(void)
12383 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
12386 void CopyClipboardToBrush(void)
12388 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
12391 void CopyBrushToClipboard(void)
12393 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
12396 void CopyBrushToClipboard_Small(void)
12398 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
12401 void UndoLevelEditorOperation(void)
12403 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
12406 void RedoLevelEditorOperation(void)
12408 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
12411 static void FloodFill(int from_x, int from_y, int fill_element)
12413 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
12416 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
12418 int from_x = from_sx2 + 2 * level_xpos;
12419 int from_y = from_sy2 + 2 * level_ypos;
12420 int max_fillx = lev_fieldx * 2;
12421 int max_filly = lev_fieldy * 2;
12422 short Fill[max_fillx][max_filly];
12425 for (x = 0; x < max_fillx; x++)
12426 for (y = 0; y < max_filly; y++)
12427 Fill[x][y] = getLevelElementHiRes(x, y);
12429 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
12430 Fill, max_fillx, max_filly);
12432 for (x = 0; x < max_fillx; x++)
12433 for (y = 0; y < max_filly; y++)
12434 if (Fill[x][y] == fill_element)
12435 SetLevelElementHiRes(x, y, Fill[x][y]);
12438 // values for DrawLevelText() modes
12439 #define TEXT_INIT 0
12440 #define TEXT_SETCURSOR 1
12441 #define TEXT_WRITECHAR 2
12442 #define TEXT_BACKSPACE 3
12443 #define TEXT_NEWLINE 4
12445 #define TEXT_QUERY_TYPING 6
12447 static int DrawLevelText(int sx, int sy, char letter, int mode)
12449 static short delete_buffer[MAX_LEV_FIELDX];
12450 static int start_sx;
12451 static int last_sx, last_sy;
12452 static boolean typing = FALSE;
12453 int letter_element = EL_CHAR_ASCII0 + letter;
12454 int lx = 0, ly = 0;
12456 // map lower case letters to upper case and convert special characters
12457 if (letter >= 'a' && letter <= 'z')
12458 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
12459 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
12460 letter_element = EL_CHAR_AUMLAUT;
12461 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
12462 letter_element = EL_CHAR_OUMLAUT;
12463 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
12464 letter_element = EL_CHAR_UUMLAUT;
12465 else if (letter == '^')
12466 letter_element = EL_CHAR_COPYRIGHT;
12468 letter_element = EL_CHAR_ASCII0 + letter;
12470 if (mode != TEXT_INIT)
12475 if (mode != TEXT_SETCURSOR)
12481 lx = last_sx + level_xpos;
12482 ly = last_sy + level_ypos;
12489 DrawLevelText(0, 0, 0, TEXT_END);
12495 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
12498 case TEXT_SETCURSOR:
12499 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
12500 DrawAreaBorder(sx, sy, sx, sy);
12501 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
12502 ed_tilesize, ed_tilesize);
12507 case TEXT_WRITECHAR:
12508 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
12510 if (new_element1 >= EL_STEEL_CHAR_START &&
12511 new_element1 <= EL_STEEL_CHAR_END)
12512 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
12514 delete_buffer[sx - start_sx] = Tile[lx][ly];
12515 Tile[lx][ly] = letter_element;
12517 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
12518 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
12519 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12520 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12522 DrawLevelText(0, 0, 0, TEXT_END);
12524 level.changed = TRUE;
12528 case TEXT_BACKSPACE:
12531 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
12532 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
12533 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
12538 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12539 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12541 DrawLevelText(0, 0, 0, TEXT_END);
12545 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12546 DrawEditorElement(sx, sy, Tile[lx][ly]);
12551 case TEXT_QUERY_TYPING:
12561 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
12562 int element, boolean change_level)
12564 int lx = sx + level_xpos;
12565 int ly = sy + level_ypos;
12568 DrawEditorElement(sx, sy, Tile[lx][ly]);
12570 DrawAreaBorder(sx, sy, sx, sy);
12573 static void CheckLevelBorderElement(boolean redraw_playfield)
12575 int last_border_element = BorderElement;
12577 SetBorderElement();
12579 if (redraw_playfield && BorderElement != last_border_element)
12580 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12583 static void CopyLevelToUndoBuffer(int mode)
12585 static boolean accumulated_undo = FALSE;
12586 boolean new_undo_buffer_position = TRUE;
12589 if (undo_buffer_steps == 0)
12590 accumulated_undo = FALSE;
12594 case UNDO_IMMEDIATE:
12595 accumulated_undo = FALSE;
12598 case UNDO_ACCUMULATE:
12599 if (accumulated_undo)
12600 new_undo_buffer_position = FALSE;
12601 accumulated_undo = TRUE;
12608 if (new_undo_buffer_position)
12610 // advance position in undo buffer ring
12611 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
12613 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
12614 undo_buffer_steps++;
12617 // always reset redo buffer when storing level change into undo buffer
12618 redo_buffer_steps = 0;
12620 for (x = 0; x < lev_fieldx; x++)
12621 for (y = 0; y < lev_fieldy; y++)
12622 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
12624 // check if drawing operation forces change of border style
12625 CheckLevelBorderElement(TRUE);
12627 level.changed = TRUE;
12630 static void RandomPlacement(int new_element)
12632 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12633 int num_free_positions = 0;
12634 int num_percentage, num_elements;
12637 ResetIntelliDraw();
12639 // determine number of free positions for randomly placing the new element
12640 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
12642 free_position[x][y] =
12643 (random_placement_background_restricted ?
12644 Tile[x][y] == random_placement_background_element :
12645 Tile[x][y] != new_element);
12647 if (free_position[x][y])
12648 num_free_positions++;
12651 // determine number of new elements to place there
12652 num_percentage = num_free_positions * random_placement_value / 100;
12653 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
12654 num_percentage : random_placement_value);
12656 // if less free positions than elements to place, fill all these positions
12657 if (num_free_positions < num_elements)
12659 for (x = 0; x < lev_fieldx; x++)
12660 for (y = 0; y < lev_fieldy; y++)
12661 if (free_position[x][y])
12662 SetElement(x, y, new_element);
12666 while (num_elements > 0)
12668 x = GetSimpleRandom(lev_fieldx);
12669 y = GetSimpleRandom(lev_fieldy);
12671 // don't place element at the same position twice
12672 if (free_position[x][y])
12674 free_position[x][y] = FALSE;
12675 SetElement(x, y, new_element);
12681 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12682 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12685 static void WrapLevel(int dx, int dy)
12687 int wrap_dx = lev_fieldx - dx;
12688 int wrap_dy = lev_fieldy - dy;
12691 for (x = 0; x < lev_fieldx; x++)
12692 for (y = 0; y < lev_fieldy; y++)
12693 TileBackup[x][y] = Tile[x][y];
12695 for (x = 0; x < lev_fieldx; x++)
12696 for (y = 0; y < lev_fieldy; y++)
12698 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
12700 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12701 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
12704 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
12706 char *template_filename_old = getLocalLevelTemplateFilename();
12707 char *template_filename_new =
12708 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
12710 if (copyFile(template_filename_old, template_filename_new) != 0)
12711 Request("Cannot copy level template!", REQ_CONFIRM);
12713 free(template_filename_new);
12716 static void HandleDrawingAreas(struct GadgetInfo *gi)
12718 static boolean started_inside_drawing_area = FALSE;
12719 static int last_sx = -1, last_sy = -1;
12720 static int last_sx2 = -1, last_sy2 = -1;
12721 int id = gi->custom_id;
12722 int type_id = gi->custom_type_id;
12723 boolean button_press_event;
12724 boolean button_release_event;
12725 boolean inside_drawing_area = !gi->event.off_borders;
12726 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
12727 int actual_drawing_function;
12728 int button = gi->event.button;
12729 int new_element = BUTTON_ELEMENT(button);
12730 int sx = gi->event.x, sy = gi->event.y;
12731 int min_sx = 0, min_sy = 0;
12732 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
12733 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
12734 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
12735 int sx2 = gi->event.mx / mini_item_xsize;
12736 int sy2 = gi->event.my / mini_item_ysize;
12739 int lx = 0, ly = 0;
12740 int min_lx = 0, min_ly = 0;
12741 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
12744 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
12745 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
12747 // make sure to stay inside drawing area boundaries
12748 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
12749 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
12753 // get positions inside level field
12754 lx = sx + level_xpos;
12755 ly = sy + level_ypos;
12757 if (!IN_LEV_FIELD(lx, ly))
12758 inside_drawing_area = FALSE;
12760 // make sure to stay inside level field boundaries
12761 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
12762 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
12764 // correct drawing area positions accordingly
12765 sx = lx - level_xpos;
12766 sy = ly - level_ypos;
12769 // also correct MM wall-sized (double) drawing area positions accordingly
12770 if (sx2 / 2 < sx || sx2 / 2 > sx)
12772 dx = (sx2 / 2 < sx ? 0 : 1);
12775 if (sy2 / 2 < sy || sy2 / 2 > sy)
12777 dy = (sy2 / 2 < sy ? 0 : 1);
12781 if (button_release_event)
12788 else if (!button_press_event)
12790 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
12791 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
12792 isHiresTileElement(old_element) &&
12793 isHiresDrawElement(new_element));
12795 // prevent handling events for every pixel position when moving mouse
12796 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
12797 (sx2 == last_sx2 && sy2 == last_sy2))
12806 if (button_press_event)
12807 started_inside_drawing_area = inside_drawing_area;
12809 if (!started_inside_drawing_area)
12812 if (!IS_VALID_BUTTON(button))
12815 if (!button && !button_release_event)
12818 // handle info callback for each invocation of action callback
12819 gi->callback_info(gi);
12821 // automatically switch to 'single item' drawing mode, if needed
12822 actual_drawing_function =
12823 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
12824 drawing_function : GADGET_ID_SINGLE_ITEMS);
12826 // clicking into drawing area with pressed Control key picks element
12827 if (GetKeyModState() & KMOD_Control)
12829 last_drawing_function = drawing_function;
12830 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
12833 if (GetKeyModState() & KMOD_Shift)
12835 if (button_press_event || button_release_event)
12836 ResetIntelliDraw();
12839 SetDrawModeHiRes(-1); // reset to normal draw mode
12841 switch (actual_drawing_function)
12843 case GADGET_ID_SINGLE_ITEMS:
12846 if (button_release_event)
12848 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12850 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
12851 !inside_drawing_area)
12852 DeleteBrushFromCursor();
12855 if (!button || button_release_event)
12858 if (draw_with_brush)
12860 CopyBrushToLevel(sx, sy, button);
12864 SetDrawModeHiRes(new_element);
12866 if (ELEM_IS_PLAYER(new_element))
12868 // remove player at old position
12869 for (y = 0; y < lev_fieldy; y++)
12871 for (x = 0; x < lev_fieldx; x++)
12873 int old_element = Tile[x][y];
12875 if (ELEM_IS_PLAYER(old_element))
12877 int replaced_with_element =
12878 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
12879 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
12881 old_element == EL_SOKOBAN_FIELD_PLAYER &&
12882 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
12884 new_element == EL_SOKOBAN_FIELD_PLAYER &&
12885 old_element == EL_PLAYER_1 ? EL_EMPTY :
12887 new_element >= EL_PLAYER_1 &&
12888 new_element <= EL_PLAYER_4 &&
12889 new_element == old_element ? EL_EMPTY :
12893 SetElement(x, y, replaced_with_element);
12899 SetElementButton(lx, ly, dx, dy, new_element, button);
12902 else if (!button_release_event)
12904 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
12906 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
12907 DrawMiniGraphicExt(drawto,
12908 gi->x + sx * MINI_TILEX,
12909 gi->y + sy * MINI_TILEY,
12910 el2edimg(new_element));
12912 DrawFixedGraphicExt(drawto,
12913 gi->x + sx * TILEX,
12914 gi->y + sy * TILEY,
12915 el2edimg(new_element), 0);
12917 if (id == GADGET_ID_CUSTOM_GRAPHIC)
12918 new_element = GFX_ELEMENT(new_element);
12920 drawingarea_info[type_id].value[pos] = new_element;
12922 CopyElementPropertiesToGame(properties_element);
12924 if (id == GADGET_ID_CUSTOM_GRAPHIC)
12926 UpdateCustomElementGraphicGadgets();
12928 FrameCounter = 0; // restart animation frame counter
12933 case GADGET_ID_CONNECTED_ITEMS:
12935 static int last_sx = -1;
12936 static int last_sy = -1;
12938 if (button_release_event)
12939 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12943 SetDrawModeHiRes(new_element);
12945 if (getDrawModeHiRes())
12951 if (!button_press_event)
12952 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
12960 case GADGET_ID_LINE:
12961 case GADGET_ID_ARC:
12962 case GADGET_ID_RECTANGLE:
12963 case GADGET_ID_FILLED_BOX:
12964 SetDrawModeHiRes(new_element);
12966 if (getDrawModeHiRes())
12972 case GADGET_ID_GRAB_BRUSH:
12973 case GADGET_ID_TEXT:
12975 static int last_sx = -1;
12976 static int last_sy = -1;
12977 static int start_sx = -1;
12978 static int start_sy = -1;
12979 void (*draw_func)(int, int, int, int, int, boolean);
12981 if (drawing_function == GADGET_ID_LINE)
12982 draw_func = DrawLine;
12983 else if (drawing_function == GADGET_ID_ARC)
12984 draw_func = DrawArc;
12985 else if (drawing_function == GADGET_ID_RECTANGLE)
12986 draw_func = DrawBox;
12987 else if (drawing_function == GADGET_ID_FILLED_BOX)
12988 draw_func = DrawFilledBox;
12989 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
12990 draw_func = SelectArea;
12991 else // (drawing_function == GADGET_ID_TEXT)
12992 draw_func = SetTextCursor;
12994 if (button_press_event)
12996 draw_func(sx, sy, sx, sy, new_element, FALSE);
12997 start_sx = last_sx = sx;
12998 start_sy = last_sy = sy;
13000 if (drawing_function == GADGET_ID_TEXT)
13001 DrawLevelText(0, 0, 0, TEXT_END);
13003 else if (button_release_event)
13005 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
13006 if (drawing_function == GADGET_ID_GRAB_BRUSH)
13008 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
13009 CopyBrushToCursor(sx, sy);
13010 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
13012 draw_with_brush = TRUE;
13014 else if (drawing_function == GADGET_ID_TEXT)
13015 DrawLevelText(sx, sy, 0, TEXT_INIT);
13017 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13019 else if (last_sx != sx || last_sy != sy)
13021 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
13022 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
13023 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
13024 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
13031 case GADGET_ID_FLOOD_FILL:
13032 if (button_press_event && Tile[lx][ly] != new_element)
13034 if (IS_MM_WALL_EDITOR(new_element))
13035 FloodFillWall_MM(sx2, sy2, new_element);
13037 FloodFill(lx, ly, new_element);
13039 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13040 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13044 case GADGET_ID_PICK_ELEMENT:
13045 if (button_release_event)
13046 ClickOnGadget(level_editor_gadget[last_drawing_function],
13048 else if (draw_level)
13049 PickDrawingElement(button, Tile[lx][ly]);
13052 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13054 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
13061 // do not mark level as modified for certain non-level-changing gadgets
13062 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
13063 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
13064 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
13065 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
13068 level.changed = TRUE;
13071 static void HandleCounterButtons(struct GadgetInfo *gi)
13073 int gadget_id = gi->custom_id;
13074 int counter_id = gi->custom_type_id;
13075 int button = gi->event.button;
13076 int *counter_value = counterbutton_info[counter_id].value;
13077 int step = BUTTON_STEPSIZE(button) *
13078 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
13080 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
13082 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
13083 boolean released = (gi->event.type == GD_EVENT_RELEASED);
13084 boolean level_changed = LevelChanged();
13086 if ((level_changed && pressed) || (!level_changed && released))
13089 if (level_changed && !Request("Level has changed! Discard changes?",
13092 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
13093 ModifyEditorCounterValue(counter_id, *counter_value);
13099 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
13100 *counter_value = gi->textinput.number_value;
13102 ModifyEditorCounterValue(counter_id, *counter_value + step);
13104 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
13106 int last_game_engine_type = level.game_engine_type;
13108 LoadLevel(level_nr);
13109 LoadScore(level_nr);
13111 SaveLevelSetup_SeriesInfo();
13116 DrawEditModeWindow();
13118 if (level.game_engine_type != last_game_engine_type)
13120 // update element selection list
13121 ReinitializeElementList();
13122 ModifyEditorElementList();
13128 switch (counter_id)
13130 case ED_COUNTER_ID_YAMYAM_CONTENT:
13131 DrawYamYamContentAreas();
13134 case ED_COUNTER_ID_BALL_CONTENT:
13135 DrawMagicBallContentAreas();
13138 case ED_COUNTER_ID_ANDROID_CONTENT:
13139 DrawAndroidElementArea(properties_element);
13142 case ED_COUNTER_ID_GROUP_CONTENT:
13143 DrawGroupElementArea(properties_element);
13144 CopyGroupElementPropertiesToGame(properties_element);
13147 case ED_COUNTER_ID_INVENTORY_SIZE:
13148 DrawPlayerInitialInventoryArea(properties_element);
13151 case ED_COUNTER_ID_ENVELOPE_XSIZE:
13152 case ED_COUNTER_ID_ENVELOPE_YSIZE:
13153 DrawEnvelopeTextArea(-1);
13156 case ED_COUNTER_ID_LEVEL_XSIZE:
13157 case ED_COUNTER_ID_LEVEL_YSIZE:
13158 lev_fieldx = level.fieldx;
13159 lev_fieldy = level.fieldy;
13161 // check if resizing of level results in change of border border
13162 SetBorderElement();
13170 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
13171 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
13172 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
13173 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
13174 CopyElementPropertiesToGame(properties_element);
13176 // do not mark level as modified for certain non-level-changing gadgets
13177 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
13178 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
13179 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
13180 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
13183 level.changed = TRUE;
13186 static void HandleTextInputGadgets(struct GadgetInfo *gi)
13188 int type_id = gi->custom_type_id;
13190 strcpy(textinput_info[type_id].value, gi->textinput.value);
13192 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
13194 CopyElementPropertiesToGame(properties_element);
13196 ModifyEditorElementList(); // update changed button info text
13199 // do not mark level as modified for certain non-level-changing gadgets
13200 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
13201 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
13204 level.changed = TRUE;
13207 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
13209 int type_id = gi->custom_type_id;
13211 strncpy(textarea_info[type_id].value, gi->textarea.value,
13212 MAX_ENVELOPE_TEXT_LEN);
13213 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
13215 level.changed = TRUE;
13218 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
13220 int type_id = gi->custom_type_id;
13221 int value_old = *selectbox_info[type_id].value;
13222 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
13224 *selectbox_info[type_id].value = value_new;
13226 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
13228 DrawLevelInfoWindow();
13230 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
13232 element_info[properties_element].current_change_page = gi->selectbox.index;
13234 DrawPropertiesWindow();
13236 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
13237 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
13238 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
13239 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
13240 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
13242 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
13244 // when changing action type, also check action mode and action arg
13245 if (value_old != value_new)
13246 setSelectboxSpecialActionVariablesIfNeeded();
13248 DrawPropertiesChange();
13251 CopyElementPropertiesToGame(properties_element);
13253 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
13255 // update element selection list
13256 ReinitializeElementList();
13257 ModifyEditorElementList();
13260 // do not mark level as modified for certain non-level-changing gadgets
13261 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
13262 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
13265 level.changed = TRUE;
13268 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
13270 int type_id = gi->custom_type_id;
13273 if (type_id >= ED_TAB_BUTTON_ID_LEVELINFO_FIRST &&
13274 type_id <= ED_TAB_BUTTON_ID_LEVELINFO_LAST)
13276 edit_mode_levelinfo = gi->custom_type_id;
13278 DrawLevelInfoWindow();
13280 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
13281 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
13283 edit_mode_properties = gi->custom_type_id;
13285 DrawPropertiesWindow();
13287 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
13288 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
13290 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
13292 // backup original "level.field" (needed to track playfield changes)
13293 CopyPlayfield(level.field, TileBackup);
13295 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
13296 CopyPlayfield(Tile, level.field);
13298 if (new_template ||
13299 Request("Save this template and kill the old?", REQ_ASK))
13300 SaveLevelTemplate();
13303 Request("Template saved!", REQ_CONFIRM);
13305 // restore original "level.field" (needed to track playfield changes)
13306 CopyPlayfield(TileBackup, level.field);
13308 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
13310 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
13312 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
13313 leveldir_current->readonly)
13315 Request("This level set is read only!", REQ_CONFIRM);
13320 if (strEqual(levelset_name, ""))
13322 Request("Please enter level set title!", REQ_CONFIRM);
13327 if (strEqual(levelset_author, ""))
13329 Request("Please enter level set author!", REQ_CONFIRM);
13334 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
13336 if (UpdateUserLevelSet(levelset_subdir,
13339 levelset_num_levels))
13341 Request("Level set updated!", REQ_CONFIRM);
13345 Request("Updating level set failed!", REQ_CONFIRM);
13348 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
13350 if (level.changed && !Request("Level has changed! Discard changes?",
13354 if (CreateUserLevelSet(levelset_subdir,
13357 levelset_num_levels,
13358 levelset_use_levelset_artwork))
13360 if (levelset_copy_level_template)
13361 CopyLevelTemplateToUserLevelSet(levelset_subdir);
13363 Request("New level set created!", REQ_CONFIRM);
13365 AddUserLevelSetToLevelInfo(levelset_subdir);
13366 ChangeEditorToLevelSet(levelset_subdir);
13370 Request("Creating new level set failed!", REQ_CONFIRM);
13374 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
13375 custom_element.num_change_pages < MAX_CHANGE_PAGES)
13377 struct ElementInfo *ei = &element_info[properties_element];
13379 // when modifying custom element, ask for copying level template
13380 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13383 setElementChangePages(ei, ei->num_change_pages + 1);
13385 // set new change page to be new current change page
13386 ei->current_change_page = ei->num_change_pages - 1;
13387 ei->change = &ei->change_page[ei->current_change_page];
13389 setElementChangeInfoToDefaults(ei->change);
13391 DrawPropertiesWindow();
13393 level.changed = TRUE;
13395 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
13396 custom_element.num_change_pages > MIN_CHANGE_PAGES)
13398 struct ElementInfo *ei = &element_info[properties_element];
13400 // when modifying custom element, ask for copying level template
13401 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13404 // copy all change pages after change page to be deleted
13405 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
13406 ei->change_page[i] = ei->change_page[i + 1];
13408 setElementChangePages(ei, ei->num_change_pages - 1);
13410 DrawPropertiesWindow();
13412 level.changed = TRUE;
13416 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
13418 int type_id = gi->custom_type_id;
13420 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
13421 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
13423 struct ElementInfo *ei = &element_info[properties_element];
13424 int step = BUTTON_STEPSIZE(gi->event.button);
13426 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
13427 ei->current_change_page += step;
13429 if (ei->current_change_page < 0)
13430 ei->current_change_page = 0;
13431 else if (ei->current_change_page >= ei->num_change_pages)
13432 ei->current_change_page = ei->num_change_pages - 1;
13434 DrawPropertiesWindow();
13436 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
13437 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13439 struct ElementInfo *ei = &element_info[properties_element];
13440 int current_change_page = ei->current_change_page;
13442 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
13444 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
13445 ei->change_page[current_change_page];
13447 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13449 // when modifying custom element, ask for copying level template
13450 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13453 ei->change_page[current_change_page] =
13454 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
13456 level.changed = TRUE;
13459 DrawPropertiesWindow();
13463 static void HandleRadiobuttons(struct GadgetInfo *gi)
13465 int type_id = gi->custom_type_id;
13467 *radiobutton_info[type_id].value =
13468 radiobutton_info[type_id].checked_value;
13470 // do not mark level as modified for certain non-level-changing gadgets
13471 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
13472 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
13475 level.changed = TRUE;
13478 static void HandleCheckbuttons(struct GadgetInfo *gi)
13480 int type_id = gi->custom_type_id;
13482 *checkbutton_info[type_id].value ^= TRUE;
13484 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
13485 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
13486 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
13487 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
13488 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
13489 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
13490 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
13491 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
13493 CopyElementPropertiesToGame(properties_element);
13496 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
13498 UpdateCustomElementGraphicGadgets();
13500 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
13501 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
13503 boolean template_related_changes_found = FALSE;
13506 // check if any custom or group elements have been changed
13507 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
13508 if ((IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)) &&
13509 element_info[i].modified_settings)
13510 template_related_changes_found = TRUE;
13512 if (level.use_custom_template &&
13513 !fileExists(getGlobalLevelTemplateFilename()))
13515 Request("No level template found!", REQ_CONFIRM);
13517 level.use_custom_template = FALSE;
13519 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13524 if (level.use_custom_template &&
13525 template_related_changes_found &&
13526 !Request("Discard changes and use level template?", REQ_ASK))
13528 level.use_custom_template = FALSE;
13530 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13535 if (!level.use_custom_template &&
13536 Request("Copy settings from level template?", REQ_ASK))
13541 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
13543 DrawEditModeWindow();
13545 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
13547 if (setup.editor.use_template_for_new_levels &&
13548 !fileExists(getGlobalLevelTemplateFilename()))
13550 Request("No level template found!", REQ_CONFIRM);
13555 if (setup.editor.use_template_for_new_levels &&
13557 !Request("Discard level and load template?", REQ_ASK))
13562 if (!setup.editor.use_template_for_new_levels &&
13564 !Request("Discard level and use empty level?", REQ_ASK))
13569 LoadLevel(level_nr);
13570 LoadScore(level_nr);
13575 DrawEditModeWindow();
13577 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
13579 SetAutomaticNumberOfGemsNeeded();
13582 // do not mark level as modified for certain non-level-changing gadgets
13583 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
13584 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
13585 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
13586 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
13587 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
13588 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
13591 level.changed = TRUE;
13594 static void HandleControlButtons(struct GadgetInfo *gi)
13596 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
13597 static int last_edit_mode = ED_MODE_DRAWING;
13598 static int last_custom_copy_mode = -1;
13599 static int last_button = 0;
13600 int id = gi->custom_id;
13601 int button = gi->event.button;
13602 int step = BUTTON_STEPSIZE(button);
13603 int new_element = BUTTON_ELEMENT(button);
13604 int last_properties_element = properties_element;
13607 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
13608 DrawLevelText(0, 0, 0, TEXT_END);
13610 if (id < ED_NUM_CTRL1_BUTTONS &&
13611 id != GADGET_ID_SINGLE_ITEMS &&
13612 id != GADGET_ID_PICK_ELEMENT &&
13613 edit_mode != ED_MODE_DRAWING &&
13614 drawing_function != GADGET_ID_PICK_ELEMENT &&
13615 !(GetKeyModState() & KMOD_Control))
13616 ChangeEditModeWindow(ED_MODE_DRAWING);
13618 // element copy mode active, but no element button pressed => deactivate
13619 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
13620 last_custom_copy_mode = -1;
13622 // when showing palette on element buttons, change element of button used
13623 if (editor.palette.show_on_element_buttons &&
13624 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
13626 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
13628 id = GADGET_ID_PALETTE;
13633 case GADGET_ID_SCROLL_LEFT:
13634 if (level_xpos >= 0)
13636 if (lev_fieldx < ed_fieldx - 2)
13639 level_xpos -= step;
13640 if (level_xpos < -1)
13643 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
13645 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13647 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
13648 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
13652 case GADGET_ID_SCROLL_RIGHT:
13653 if (level_xpos <= lev_fieldx - ed_fieldx)
13655 if (lev_fieldx < ed_fieldx - 2)
13658 level_xpos += step;
13659 if (level_xpos > lev_fieldx - ed_fieldx + 1)
13660 level_xpos = lev_fieldx - ed_fieldx + 1;
13662 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
13664 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13666 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
13667 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
13671 case GADGET_ID_SCROLL_UP:
13672 if (level_ypos >= 0)
13674 if (lev_fieldy < ed_fieldy - 2)
13677 level_ypos -= step;
13678 if (level_ypos < -1)
13681 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
13683 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13685 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13686 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13690 case GADGET_ID_SCROLL_DOWN:
13691 if (level_ypos <= lev_fieldy - ed_fieldy)
13693 if (lev_fieldy < ed_fieldy - 2)
13696 level_ypos += step;
13697 if (level_ypos > lev_fieldy - ed_fieldy + 1)
13698 level_ypos = lev_fieldy - ed_fieldy + 1;
13700 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
13702 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13704 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13705 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13709 case GADGET_ID_SCROLL_HORIZONTAL:
13710 level_xpos = gi->event.item_position - 1;
13712 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13717 case GADGET_ID_SCROLL_VERTICAL:
13718 level_ypos = gi->event.item_position - 1;
13720 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13725 case GADGET_ID_SCROLL_LIST_UP:
13726 case GADGET_ID_SCROLL_LIST_DOWN:
13727 case GADGET_ID_SCROLL_LIST_VERTICAL:
13728 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
13729 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
13732 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
13733 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
13735 if (element_shift < 0)
13737 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
13738 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
13740 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
13741 GDI_SCROLLBAR_ITEM_POSITION,
13742 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
13745 ModifyEditorElementList();
13749 case GADGET_ID_PROPERTIES:
13750 // always switch off element properties when they are already displayed
13751 last_properties_element = new_element;
13752 case GADGET_ID_ELEMENT_LEFT:
13753 case GADGET_ID_ELEMENT_MIDDLE:
13754 case GADGET_ID_ELEMENT_RIGHT:
13755 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
13756 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
13757 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
13760 if (edit_mode != ED_MODE_PROPERTIES)
13762 last_edit_mode = edit_mode;
13764 ChangeEditModeWindow(ED_MODE_PROPERTIES);
13766 last_level_drawing_function = drawing_function;
13767 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
13770 else if (properties_element != last_properties_element)
13772 DrawEditModeWindow();
13776 ChangeEditModeWindow(last_edit_mode);
13778 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
13783 case GADGET_ID_PALETTE:
13784 if (edit_mode != ED_MODE_PALETTE)
13786 last_edit_mode = edit_mode;
13788 ChangeEditModeWindow(ED_MODE_PALETTE);
13792 ChangeEditModeWindow(last_edit_mode);
13796 case GADGET_ID_WRAP_LEFT:
13797 WrapLevel(-step, 0);
13800 case GADGET_ID_WRAP_RIGHT:
13801 WrapLevel(step, 0);
13804 case GADGET_ID_WRAP_UP:
13805 WrapLevel(0, -step);
13808 case GADGET_ID_WRAP_DOWN:
13809 WrapLevel(0, step);
13812 case GADGET_ID_SINGLE_ITEMS:
13813 case GADGET_ID_CONNECTED_ITEMS:
13814 case GADGET_ID_LINE:
13815 case GADGET_ID_ARC:
13816 case GADGET_ID_TEXT:
13817 case GADGET_ID_RECTANGLE:
13818 case GADGET_ID_FILLED_BOX:
13819 case GADGET_ID_FLOOD_FILL:
13820 case GADGET_ID_GRAB_BRUSH:
13821 case GADGET_ID_PICK_ELEMENT:
13822 if (drawing_function != GADGET_ID_PICK_ELEMENT)
13823 last_drawing_function = drawing_function;
13824 drawing_function = id;
13825 draw_with_brush = FALSE;
13828 case GADGET_ID_RANDOM_PLACEMENT:
13829 RandomPlacement(new_element);
13832 case GADGET_ID_ZOOM:
13833 // zoom level editor tile size in or out (or reset to default size)
13834 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
13835 button == 2 ? ed_tilesize_default :
13836 button == 3 ? ed_tilesize / 2 : ed_tilesize);
13838 // when using touch device, cycle through all zoom tilesizes
13839 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
13840 ed_tilesize = MICRO_TILESIZE;
13842 // limit zoom level by upper and lower bound
13843 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
13845 InitZoomLevelSettings(ed_tilesize);
13847 if (edit_mode == ED_MODE_DRAWING)
13849 DrawDrawingWindow();
13851 // redraw zoom gadget info text
13852 PrintEditorGadgetInfoText(level_editor_gadget[id]);
13855 // save current editor zoom tilesize
13856 SaveSetup_AutoSetup();
13860 case GADGET_ID_CUSTOM_COPY_FROM:
13861 case GADGET_ID_CUSTOM_COPY_TO:
13862 case GADGET_ID_CUSTOM_EXCHANGE:
13863 last_custom_copy_mode = id;
13864 last_drawing_function = drawing_function;
13867 case GADGET_ID_CUSTOM_COPY:
13868 CopyCustomElement(properties_element, -1, id);
13871 case GADGET_ID_CUSTOM_PASTE:
13872 CopyCustomElement(-1, properties_element, id);
13875 case GADGET_ID_UNDO:
13876 if (button < 0) // keep button value (even if modifier keys are pressed)
13878 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
13881 if (button == 1 && undo_buffer_steps == 0)
13883 Request("Undo buffer empty!", REQ_CONFIRM);
13887 else if (button == 2)
13891 else if (button == 3 && redo_buffer_steps == 0)
13893 Request("Redo buffer empty!", REQ_CONFIRM);
13898 if (edit_mode != ED_MODE_DRAWING)
13899 ChangeEditModeWindow(ED_MODE_DRAWING);
13905 undo_buffer_position =
13906 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
13908 undo_buffer_steps--;
13909 redo_buffer_steps++;
13915 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
13917 undo_buffer_steps++;
13918 redo_buffer_steps--;
13921 for (x = 0; x < lev_fieldx; x++)
13922 for (y = 0; y < lev_fieldy; y++)
13923 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
13925 // check if undo operation forces change of border style
13926 CheckLevelBorderElement(FALSE);
13928 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13932 case GADGET_ID_INFO:
13933 if (edit_mode != ED_MODE_INFO)
13935 last_edit_mode = edit_mode;
13937 ChangeEditModeWindow(ED_MODE_INFO);
13941 ChangeEditModeWindow(last_edit_mode);
13945 case GADGET_ID_CLEAR:
13946 if (edit_mode != ED_MODE_DRAWING)
13947 ChangeEditModeWindow(ED_MODE_DRAWING);
13949 for (x = 0; x < MAX_LEV_FIELDX; x++)
13950 for (y = 0; y < MAX_LEV_FIELDY; y++)
13951 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
13953 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
13955 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13958 case GADGET_ID_SAVE:
13960 // saving read-only levels into personal level set modifies global vars
13961 // "leveldir_current" and "level_nr"; restore them after saving level
13962 LevelDirTree *leveldir_former = leveldir_current;
13963 int level_nr_former = level_nr;
13964 char *level_filename;
13967 if (leveldir_current->readonly &&
13968 !PrepareSavingIntoPersonalLevelSet())
13971 level_filename = getDefaultLevelFilename(level_nr);
13972 new_level = !fileExists(level_filename);
13975 Request("Save this level and kill the old?", REQ_ASK))
13977 if (leveldir_former->readonly)
13978 ModifyLevelInfoForSavingIntoPersonalLevelSet(leveldir_former->name);
13980 SetAutomaticNumberOfGemsNeeded();
13982 CopyPlayfield(Tile, level.field);
13983 SaveLevel(level_nr);
13985 level.changed = FALSE;
13989 char level_saved_msg[64];
13991 if (leveldir_former->readonly)
13992 sprintf(level_saved_msg,
13993 "Level saved as level %d into personal level set!",
13996 strcpy(level_saved_msg, "Level saved!");
13998 Request(level_saved_msg, REQ_CONFIRM);
14002 // "cd" back to copied-from levelset (in case of saved read-only level)
14003 leveldir_current = leveldir_former;
14004 level_nr = level_nr_former;
14009 case GADGET_ID_TEST:
14010 if (LevelChanged())
14011 level.game_version = GAME_VERSION_ACTUAL;
14013 CopyPlayfield(level.field, TileBackup);
14014 CopyPlayfield(Tile, level.field);
14016 CopyNativeLevel_RND_to_Native(&level);
14018 UnmapLevelEditorGadgets();
14019 UndrawSpecialEditorDoor();
14021 CloseDoor(DOOR_CLOSE_ALL);
14023 // needed before playing if editor playfield area has different size
14024 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
14026 // redraw_mask = REDRAW_ALL;
14028 level_editor_test_game = TRUE;
14030 StartGameActions(FALSE, setup.autorecord, level.random_seed);
14034 case GADGET_ID_EXIT:
14035 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
14039 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
14040 id <= GADGET_ID_ELEMENTLIST_LAST)
14042 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
14043 int new_element = editor_elements[element_position + element_shift];
14045 if (IS_EDITOR_CASCADE(new_element))
14049 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
14051 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
14052 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
14054 if (*cascade_element == new_element)
14056 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
14057 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
14059 // update element selection list
14060 ReinitializeElementList();
14061 ModifyEditorElementList();
14063 // update cascading gadget info text
14064 PrintEditorGadgetInfoText(level_editor_gadget[id]);
14066 // save current editor cascading state
14067 SaveSetup_EditorCascade();
14076 if (last_custom_copy_mode != -1)
14078 if (CopyCustomElement(properties_element, new_element,
14079 last_custom_copy_mode))
14081 ClickOnGadget(level_editor_gadget[last_drawing_function],
14084 last_custom_copy_mode = -1;
14090 // change element of button used to show palette
14091 if (editor.palette.show_on_element_buttons)
14092 button = last_button;
14094 PickDrawingElement(button, new_element);
14096 if (!stick_element_properties_window &&
14097 drawing_function != GADGET_ID_PICK_ELEMENT &&
14098 !(GetKeyModState() & KMOD_Control))
14100 properties_element = new_element;
14101 if (edit_mode == ED_MODE_PROPERTIES)
14102 DrawPropertiesWindow();
14105 if (drawing_function == GADGET_ID_PICK_ELEMENT)
14106 ClickOnGadget(level_editor_gadget[last_drawing_function],
14109 if (!use_permanent_palette)
14110 ChangeEditModeWindow(last_edit_mode);
14113 else if (gi->event.type == GD_EVENT_PRESSED)
14114 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
14115 else if (gi->event.type == GD_EVENT_RELEASED)
14116 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
14117 else if (gi->event.type == GD_EVENT_MOVING)
14118 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
14120 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
14126 void HandleLevelEditorKeyInput(Key key)
14128 char letter = getCharFromKey(key);
14130 if (drawing_function == GADGET_ID_TEXT &&
14131 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
14134 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
14135 else if (key == KSYM_Delete || key == KSYM_BackSpace)
14136 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
14137 else if (key == KSYM_Return)
14138 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
14139 else if (key == KSYM_Escape)
14140 DrawLevelText(0, 0, 0, TEXT_END);
14145 int id = GADGET_ID_NONE;
14146 int new_element_shift = element_shift;
14147 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
14148 int button = MB_LEFTBUTTON;
14154 id = GADGET_ID_SCROLL_LEFT;
14157 id = GADGET_ID_SCROLL_RIGHT;
14160 id = GADGET_ID_SCROLL_UP;
14163 id = GADGET_ID_SCROLL_DOWN;
14167 case KSYM_Page_Down:
14168 step *= (key == KSYM_Page_Up ? -1 : +1);
14169 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
14171 if (element_shift < 0)
14173 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14174 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14176 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14177 GDI_SCROLLBAR_ITEM_POSITION,
14178 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14180 ModifyEditorElementList();
14186 element_shift = (key == KSYM_Home ? 0 :
14187 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
14189 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14190 GDI_SCROLLBAR_ITEM_POSITION,
14191 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14193 ModifyEditorElementList();
14200 // this is needed to prevent interference with running "True X-Mouse"
14201 if (GetKeyModStateFromEvents() & KMOD_Control)
14204 // check for last or next editor cascade block in element list
14205 for (i = 0; i < num_editor_elements; i++)
14207 if ((key == KSYM_Insert && i == element_shift) ||
14208 (key == KSYM_Delete && new_element_shift > element_shift))
14211 // jump to next cascade block (or to start of element list)
14212 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
14213 new_element_shift = i;
14216 if (i < num_editor_elements)
14217 element_shift = new_element_shift;
14219 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14220 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14222 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14223 GDI_SCROLLBAR_ITEM_POSITION,
14224 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14226 ModifyEditorElementList();
14231 if (edit_mode == ED_MODE_DRAWING)
14232 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
14233 else if (edit_mode == ED_MODE_INFO)
14234 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
14235 else if (edit_mode == ED_MODE_PROPERTIES)
14236 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
14237 else if (edit_mode == ED_MODE_PALETTE)
14238 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
14239 else // should never happen
14240 ChangeEditModeWindow(ED_MODE_DRAWING);
14248 if (id != GADGET_ID_NONE)
14249 ClickOnGadget(level_editor_gadget[id], button);
14250 else if (letter == '1' || letter == '?')
14251 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
14252 else if (letter == '2')
14253 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
14254 else if (letter == '3')
14255 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
14256 else if (letter == '.')
14257 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
14258 else if (letter == 'U')
14259 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
14260 else if (letter == '-' || key == KSYM_KP_Subtract)
14261 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
14262 else if (letter == '0' || key == KSYM_KP_0)
14263 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
14264 else if (letter == '+' || key == KSYM_KP_Add ||
14265 letter == '=') // ("Shift-=" is "+" on US keyboards)
14266 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
14267 else if (key == KSYM_Return ||
14268 key == KSYM_space ||
14269 key == setup.shortcut.toggle_pause)
14270 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
14272 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
14273 if (letter && letter == controlbutton_info[i].shortcut)
14274 if (!anyTextGadgetActive())
14275 ClickOnGadget(level_editor_gadget[i], button);
14278 void HandleLevelEditorIdle(void)
14280 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
14281 int x = editor.settings.element_graphic.x + element_border;
14282 int y = editor.settings.element_graphic.y + element_border;
14283 static unsigned int action_delay = 0;
14284 unsigned int action_delay_value = GameFrameDelay;
14287 if (edit_mode != ED_MODE_PROPERTIES)
14290 if (!DelayReached(&action_delay, action_delay_value))
14293 for (i = 0; i < ED_NUM_SELECTBOX; i++)
14295 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
14297 if (gi->mapped && gi->active && gi->selectbox.open)
14301 DrawEditorElementAnimation(SX + x, SY + y);
14303 redraw_mask |= REDRAW_FIELD;
14305 FrameCounter++; // increase animation frame counter
14308 static void ClearEditorGadgetInfoText(void)
14310 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
14313 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
14315 char infotext[MAX_OUTPUT_LINESIZE + 1];
14316 char shortcut[MAX_OUTPUT_LINESIZE + 1];
14317 int max_infotext_len = getMaxInfoTextLength();
14319 if (gi == NULL || strlen(gi->info_text) == 0)
14322 strncpy(infotext, gi->info_text, max_infotext_len);
14323 infotext[max_infotext_len] = '\0';
14325 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
14327 int key = controlbutton_info[gi->custom_id].shortcut;
14331 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
14332 sprintf(shortcut, " ('.' or '%c')", key);
14333 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
14334 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
14335 else if (gi->custom_id == GADGET_ID_TEST)
14336 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
14337 else if (gi->custom_id == GADGET_ID_UNDO)
14338 sprintf(shortcut, " ('%c/Shift-U')", key);
14339 else if (gi->custom_id == GADGET_ID_ZOOM)
14340 sprintf(shortcut, " ('%c', '0', '-')", key);
14342 sprintf(shortcut, " ('%s%c')",
14343 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
14345 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
14346 strcat(infotext, shortcut);
14350 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
14353 void HandleEditorGadgetInfoText(void *ptr)
14355 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
14357 if (game_status != GAME_MODE_EDITOR)
14360 ClearEditorGadgetInfoText();
14362 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
14365 // misuse this function to delete brush cursor, if needed
14366 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
14367 DeleteBrushFromCursor();
14369 PrintEditorGadgetInfoText(gi);
14372 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
14374 static int start_lx, start_ly;
14375 int id = gi->custom_id;
14376 int type_id = gi->custom_type_id;
14377 int sx = gi->event.x;
14378 int sy = gi->event.y;
14379 int lx = sx + level_xpos;
14380 int ly = sy + level_ypos;
14381 int min_sx = 0, min_sy = 0;
14382 int max_sx = gi->drawing.area_xsize - 1;
14383 int max_sy = gi->drawing.area_ysize - 1;
14384 int actual_drawing_function = drawing_function;
14385 int max_infotext_len = getMaxInfoTextLength();
14386 char infotext[MAX_OUTPUT_LINESIZE + 1];
14389 infotext[0] = '\0'; // start with empty info text
14391 // pressed Control key: simulate picking element
14392 if (GetKeyModState() & KMOD_Control)
14393 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14395 ClearEditorGadgetInfoText();
14397 if (gi->event.type == GD_EVENT_INFO_LEAVING)
14400 // make sure to stay inside drawing area boundaries
14401 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14402 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14404 if (id == GADGET_ID_DRAWING_LEVEL)
14408 int min_lx = 0, min_ly = 0;
14409 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14411 // get positions inside level field
14412 lx = sx + level_xpos;
14413 ly = sy + level_ypos;
14415 // make sure to stay inside level field boundaries
14416 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14417 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14419 // correct drawing area positions accordingly
14420 sx = lx - level_xpos;
14421 sy = ly - level_ypos;
14424 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
14426 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
14428 if (gi->event.type == GD_EVENT_PRESSED)
14434 switch (actual_drawing_function)
14436 case GADGET_ID_SINGLE_ITEMS:
14437 text = "Drawing single items";
14439 case GADGET_ID_CONNECTED_ITEMS:
14440 text = "Drawing connected items";
14442 case GADGET_ID_LINE:
14443 text = "Drawing line";
14445 case GADGET_ID_ARC:
14446 text = "Drawing arc";
14448 case GADGET_ID_TEXT:
14449 text = "Setting text cursor";
14451 case GADGET_ID_RECTANGLE:
14452 text = "Drawing rectangle";
14454 case GADGET_ID_FILLED_BOX:
14455 text = "Drawing filled box";
14457 case GADGET_ID_FLOOD_FILL:
14458 text = "Flood fill";
14460 case GADGET_ID_GRAB_BRUSH:
14461 text = "Grabbing brush";
14463 case GADGET_ID_PICK_ELEMENT:
14464 text = "Picking element";
14468 text = "Drawing position";
14472 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14473 sprintf(infotext, "%s: %d, %d", text, lx, ly);
14475 sprintf(infotext, "%s: %d, %d", text,
14476 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
14478 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14479 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
14481 sprintf(infotext, "Level position: %d, %d", lx, ly);
14484 // misuse this function to draw brush cursor, if needed
14485 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
14487 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
14488 CopyBrushToCursor(sx, sy);
14490 DeleteBrushFromCursor();
14493 if (!draw_with_brush)
14494 UpdateBrushPosition(sx, sy);
14496 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14498 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14499 int element = drawingarea_info[type_id].value[pos];
14501 strncpy(infotext, getElementInfoText(element), max_infotext_len);
14505 if (id == GADGET_ID_CUSTOM_CONTENT)
14506 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
14507 else if (id == GADGET_ID_GROUP_CONTENT)
14508 sprintf(infotext, "group element position: %d", sx + 1);
14509 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
14510 id <= GADGET_ID_YAMYAM_CONTENT_7)
14511 sprintf(infotext, "content area %d position: %d, %d",
14512 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
14513 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
14514 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
14515 sprintf(infotext, "content area %d position: %d, %d",
14516 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
14517 else if (id == GADGET_ID_ANDROID_CONTENT)
14518 sprintf(infotext, "android element position: %d", sx + 1);
14519 else if (drawingarea_info[type_id].infotext != NULL)
14520 strcpy(infotext, drawingarea_info[type_id].infotext);
14523 infotext[max_infotext_len] = '\0';
14525 if (strlen(infotext) > 0)
14526 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
14529 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
14530 boolean quick_quit)
14532 if (!ask_if_level_has_changed ||
14534 Request("Level has changed! Exit without saving?",
14535 REQ_ASK | REQ_STAY_OPEN))
14537 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
14538 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
14540 // draw normal door
14541 UndrawSpecialEditorDoor();
14543 // use door animation if door 1 viewport is unchanged and contains toolbox
14544 if (useEditorDoorAnimation())
14545 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
14547 // close editor doors if viewport definition is the same as in main menu
14548 if (vp_door_1->x == DX &&
14549 vp_door_1->y == DY &&
14550 vp_door_1->width == DXSIZE &&
14551 vp_door_1->height == DYSIZE &&
14552 vp_door_2->x == VX &&
14553 vp_door_2->y == VY &&
14554 vp_door_2->width == VXSIZE &&
14555 vp_door_2->height == VYSIZE)
14556 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
14558 SetDoorState(DOOR_CLOSE_2);
14563 FadeSkipNextFadeIn();
14565 SetGameStatus(GAME_MODE_MAIN);
14571 if (!global.use_envelope_request)
14573 CloseDoor(DOOR_CLOSE_1);
14574 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);