1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
14 #include "libgame/libgame.h"
25 #define INFOTEXT_UNKNOWN_ELEMENT "unknown"
28 // ----------------------------------------------------------------------------
29 // screen and artwork graphic pixel position definitions
30 // ----------------------------------------------------------------------------
32 // values for the control window
33 #define ED_CTRL1_BUTTONS_HORIZ 4 // toolbox
34 #define ED_CTRL1_BUTTONS_VERT 4
35 #define ED_CTRL2_BUTTONS_HORIZ 3 // level
36 #define ED_CTRL2_BUTTONS_VERT 2
37 #define ED_CTRL3_BUTTONS_HORIZ 3 // CE and GE
38 #define ED_CTRL3_BUTTONS_VERT 1
39 #define ED_CTRL4_BUTTONS_HORIZ 2 // CE and GE
40 #define ED_CTRL4_BUTTONS_VERT 1
41 #define ED_CTRL5_BUTTONS_HORIZ 1 // properties
42 #define ED_CTRL5_BUTTONS_VERT 1
43 #define ED_CTRL6_BUTTONS_HORIZ 3 // properties
44 #define ED_CTRL6_BUTTONS_VERT 1
45 #define ED_CTRL7_BUTTONS_HORIZ 1 // palette
46 #define ED_CTRL7_BUTTONS_VERT 1
48 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
49 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
50 #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT)
51 #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT)
52 #define ED_NUM_CTRL5_BUTTONS (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT)
53 #define ED_NUM_CTRL6_BUTTONS (ED_CTRL6_BUTTONS_HORIZ * ED_CTRL6_BUTTONS_VERT)
54 #define ED_NUM_CTRL7_BUTTONS (ED_CTRL7_BUTTONS_HORIZ * ED_CTRL7_BUTTONS_VERT)
55 #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
56 #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS)
57 #define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS)
58 #define ED_NUM_CTRL1_5_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS)
59 #define ED_NUM_CTRL1_6_BUTTONS (ED_NUM_CTRL1_5_BUTTONS + ED_NUM_CTRL6_BUTTONS)
60 #define ED_NUM_CTRL1_7_BUTTONS (ED_NUM_CTRL1_6_BUTTONS + ED_NUM_CTRL7_BUTTONS)
61 #define ED_NUM_CTRL_BUTTONS ED_NUM_CTRL1_7_BUTTONS
63 // values for the element list
64 #define ED_ELEMENTLIST_XPOS (editor.palette.x)
65 #define ED_ELEMENTLIST_YPOS (editor.palette.y)
66 #define ED_ELEMENTLIST_XSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
67 #define ED_ELEMENTLIST_YSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
68 #define ED_ELEMENTLIST_COLS MAX(1, editor.palette.cols)
69 #define ED_ELEMENTLIST_ROWS MAX(1, editor.palette.rows)
70 #define ED_ELEMENTLIST_BUTTONS_HORIZ (ED_ELEMENTLIST_COLS)
71 #define ED_ELEMENTLIST_BUTTONS_VERT (ED_ELEMENTLIST_ROWS)
72 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
73 ED_ELEMENTLIST_BUTTONS_VERT)
76 #define ED_GADGET_NORMAL_DISTANCE (editor.gadget.normal_spacing)
77 #define ED_GADGET_SMALL_DISTANCE (editor.gadget.small_spacing)
78 #define ED_GADGET_TINY_DISTANCE (editor.gadget.tiny_spacing)
79 #define ED_GADGET_LINE_DISTANCE (editor.gadget.line_spacing)
80 #define ED_GADGET_TEXT_DISTANCE (editor.gadget.text_spacing)
81 #define ED_TAB_BAR_HEIGHT (editor.gadget.separator_line.height)
82 #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \
83 ED_DRAWINGAREA_BORDER_SIZE)
84 #define ED_GADGET_SPACE_DISTANCE (getFontWidth(FONT_TEXT_1))
86 // values for drawingarea gadgets
87 #define IMG_BORDER_1 IMG_EDITOR_ELEMENT_BORDER
88 #define IMG_BORDER_2 IMG_EDITOR_ELEMENT_BORDER_INPUT
89 #define ED_ELEMENT_BORDER (graphic_info[IMG_BORDER_1].border_size)
90 #define ED_DRAWINGAREA_BORDER_SIZE (graphic_info[IMG_BORDER_2].border_size)
91 #define ED_DRAWINGAREA_TILE_SIZE (editor.drawingarea.tile_size)
93 // values for checkbutton gadgets
94 #define ED_CHECKBUTTON_XSIZE (graphic_info[IMG_EDITOR_CHECKBOX].width)
95 #define ED_CHECKBUTTON_YSIZE (graphic_info[IMG_EDITOR_CHECKBOX].height)
97 #define ED_TABBUTTON_XSIZE (graphic_info[IMG_EDITOR_TABBUTTON].width)
98 #define ED_TABBUTTON_YSIZE (graphic_info[IMG_EDITOR_TABBUTTON].height)
100 #define ED_SETTINGS_LEVEL_TABS_X (editor.settings.tabs.x)
101 #define ED_SETTINGS_LEVEL_TABS_Y (editor.settings.tabs.y)
102 #define ED_SETTINGS_ELEMENT_TABS_X (editor.settings.tabs.x)
103 #define ED_SETTINGS_ELEMENT_TABS_Y (editor.settings.tabs.y + \
104 editor.settings.tabs.yoffset2)
106 #define ED_SETTINGS_TABS_XOFFSET (editor.settings.tabs.draw_xoffset)
107 #define ED_SETTINGS_TABS_YOFFSET (editor.settings.tabs.draw_yoffset)
109 #define ED_LEVEL_TABS_XSTART (ED_SETTINGS_LEVEL_TABS_X)
110 #define ED_LEVEL_TABS_YSTART (ED_SETTINGS_LEVEL_TABS_Y)
111 #define ED_LEVEL_SETTINGS_XSTART (ED_SETTINGS_LEVEL_TABS_X + \
112 ED_SETTINGS_TABS_XOFFSET)
113 #define ED_LEVEL_SETTINGS_YSTART (ED_SETTINGS_LEVEL_TABS_Y + \
114 ED_TABBUTTON_YSIZE + \
115 ED_GADGET_TINY_DISTANCE + \
116 ED_TAB_BAR_HEIGHT + \
117 ED_SETTINGS_TABS_YOFFSET + \
118 getFontHeight(FONT_TEXT_1) + \
119 ED_GADGET_TEXT_DISTANCE)
120 #define ED_ELEMENT_TABS_XSTART (ED_SETTINGS_ELEMENT_TABS_X)
121 #define ED_ELEMENT_TABS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y)
122 #define ED_ELEMENT_SETTINGS_XSTART (ED_SETTINGS_ELEMENT_TABS_X + \
123 ED_SETTINGS_TABS_XOFFSET)
124 #define ED_ELEMENT_SETTINGS_YSTART (ED_SETTINGS_ELEMENT_TABS_Y + \
125 ED_TABBUTTON_YSIZE + \
126 ED_GADGET_TINY_DISTANCE + \
127 ED_TAB_BAR_HEIGHT + \
128 ED_SETTINGS_TABS_YOFFSET)
130 #define ED_SETTINGS_XOFFSET (ED_CHECKBUTTON_XSIZE + \
131 ED_GADGET_TEXT_DISTANCE)
132 #define ED_SETTINGS_YOFFSET (ED_CHECKBUTTON_YSIZE + \
133 ED_GADGET_LINE_DISTANCE)
135 #define ED_POS_RANGE (10000)
136 #define ED_POS_LEVEL_TABS_FIRST (1 * ED_POS_RANGE)
137 #define ED_POS_LEVEL_TABS_LAST (2 * ED_POS_RANGE - 1)
138 #define ED_POS_LEVEL_SETTINGS_FIRST (2 * ED_POS_RANGE)
139 #define ED_POS_LEVEL_SETTINGS_LAST (3 * ED_POS_RANGE - 1)
140 #define ED_POS_ELEMENT_TABS_FIRST (3 * ED_POS_RANGE)
141 #define ED_POS_ELEMENT_TABS_LAST (4 * ED_POS_RANGE - 1)
142 #define ED_POS_ELEMENT_SETTINGS_FIRST (4 * ED_POS_RANGE)
143 #define ED_POS_ELEMENT_SETTINGS_LAST (5 * ED_POS_RANGE - 1)
145 #define ED_LEVEL_TABS_XPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
146 #define ED_LEVEL_TABS_YPOS(n) (ED_POS_LEVEL_TABS_FIRST + (n))
148 #define ED_LEVEL_SETTINGS_XPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
149 #define ED_LEVEL_SETTINGS_YPOS(n) (ED_POS_LEVEL_SETTINGS_FIRST + (n))
151 #define ED_ELEMENT_TABS_XPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
152 #define ED_ELEMENT_TABS_YPOS(n) (ED_POS_ELEMENT_TABS_FIRST + (n))
154 #define ED_ELEMENT_SETTINGS_XPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
155 #define ED_ELEMENT_SETTINGS_YPOS(n) (ED_POS_ELEMENT_SETTINGS_FIRST + (n))
157 #define IS_POS_LEVEL_TABS(n) ((n) >= ED_POS_LEVEL_TABS_FIRST && \
158 (n) <= ED_POS_LEVEL_TABS_LAST)
159 #define IS_POS_LEVEL_SETTINGS(n) ((n) >= ED_POS_LEVEL_SETTINGS_FIRST && \
160 (n) <= ED_POS_LEVEL_SETTINGS_LAST)
161 #define IS_POS_ELEMENT_TABS(n) ((n) >= ED_POS_ELEMENT_TABS_FIRST && \
162 (n) <= ED_POS_ELEMENT_TABS_LAST)
163 #define IS_POS_ELEMENT_SETTINGS(n) ((n) >= ED_POS_ELEMENT_SETTINGS_FIRST && \
164 (n) <= ED_POS_ELEMENT_SETTINGS_LAST)
166 #define ED_LEVEL_TABS_LINE(n) ((n) - ED_POS_LEVEL_TABS_FIRST)
167 #define ED_LEVEL_SETTINGS_LINE(n) ((n) - ED_POS_LEVEL_SETTINGS_FIRST)
168 #define ED_ELEMENT_TABS_LINE(n) ((n) - ED_POS_ELEMENT_TABS_FIRST)
169 #define ED_ELEMENT_SETTINGS_LINE(n) ((n) - ED_POS_ELEMENT_SETTINGS_FIRST)
171 #define ED_LEVEL_TABS_X(n) (ED_LEVEL_TABS_XSTART + \
172 (n) * ED_SETTINGS_TABS_XOFFSET)
173 #define ED_LEVEL_TABS_Y(n) (ED_LEVEL_TABS_YSTART + \
174 (n) * ED_SETTINGS_TABS_YOFFSET)
176 #define ED_LEVEL_SETTINGS_X(n) (ED_LEVEL_SETTINGS_XSTART + \
177 (n) * ED_SETTINGS_XOFFSET)
178 #define ED_LEVEL_SETTINGS_Y(n) (ED_LEVEL_SETTINGS_YSTART + \
179 (n) * ED_SETTINGS_YOFFSET)
181 #define ED_ELEMENT_TABS_X(n) (ED_ELEMENT_TABS_XSTART + \
182 (n) * ED_SETTINGS_TABS_XOFFSET)
183 #define ED_ELEMENT_TABS_Y(n) (ED_ELEMENT_TABS_YSTART + \
184 (n) * ED_SETTINGS_TABS_YOFFSET)
186 #define ED_ELEMENT_SETTINGS_X(n) (ED_ELEMENT_SETTINGS_XSTART + \
187 (n) * ED_SETTINGS_XOFFSET)
188 #define ED_ELEMENT_SETTINGS_Y(n) (ED_ELEMENT_SETTINGS_YSTART + \
189 (n) * ED_SETTINGS_YOFFSET)
191 #define ED_POS_TO_LEVEL_TABS_X(n) \
192 (ED_LEVEL_TABS_X(ED_LEVEL_TABS_LINE(n)))
193 #define ED_POS_TO_LEVEL_TABS_Y(n) \
194 (ED_LEVEL_TABS_Y(ED_LEVEL_TABS_LINE(n)))
196 #define ED_POS_TO_LEVEL_SETTINGS_X(n) \
197 (ED_LEVEL_SETTINGS_X(ED_LEVEL_SETTINGS_LINE(n)))
198 #define ED_POS_TO_LEVEL_SETTINGS_Y(n) \
199 (ED_LEVEL_SETTINGS_Y(ED_LEVEL_SETTINGS_LINE(n)))
201 #define ED_POS_TO_ELEMENT_TABS_X(n) \
202 (ED_ELEMENT_TABS_X(ED_ELEMENT_TABS_LINE(n)))
203 #define ED_POS_TO_ELEMENT_TABS_Y(n) \
204 (ED_ELEMENT_TABS_Y(ED_ELEMENT_TABS_LINE(n)))
206 #define ED_POS_TO_ELEMENT_SETTINGS_X(n) \
207 (ED_ELEMENT_SETTINGS_X(ED_ELEMENT_SETTINGS_LINE(n)))
208 #define ED_POS_TO_ELEMENT_SETTINGS_Y(n) \
209 (ED_ELEMENT_SETTINGS_Y(ED_ELEMENT_SETTINGS_LINE(n)))
211 #define ED_SETTINGS_X(n) (IS_POS_LEVEL_TABS(n) ? \
212 ED_POS_TO_LEVEL_TABS_X(n) : \
213 IS_POS_LEVEL_SETTINGS(n) ? \
214 ED_POS_TO_LEVEL_SETTINGS_X(n) : \
215 IS_POS_ELEMENT_TABS(n) ? \
216 ED_POS_TO_ELEMENT_TABS_X(n) : \
217 IS_POS_ELEMENT_SETTINGS(n) ? \
218 ED_POS_TO_ELEMENT_SETTINGS_X(n) : (n))
219 #define ED_SETTINGS_Y(n) (IS_POS_LEVEL_TABS(n) ? \
220 ED_POS_TO_LEVEL_TABS_Y(n) : \
221 IS_POS_LEVEL_SETTINGS(n) ? \
222 ED_POS_TO_LEVEL_SETTINGS_Y(n) : \
223 IS_POS_ELEMENT_TABS(n) ? \
224 ED_POS_TO_ELEMENT_TABS_Y(n) : \
225 IS_POS_ELEMENT_SETTINGS(n) ? \
226 ED_POS_TO_ELEMENT_SETTINGS_Y(n) : (n))
228 #define ED_SETTINGS_XOFF(n) (5 * ((n) % 4) * \
229 ED_DRAWINGAREA_TILE_SIZE)
230 #define ED_SETTINGS_YOFF(n) (5 * ((n) / 4) * \
231 ED_DRAWINGAREA_TILE_SIZE)
233 #define ED_AREA_XOFFSET_1(n) ((n) != 0 ? \
234 ED_DRAWINGAREA_BORDER_SIZE : 0)
235 #define ED_AREA_YOFFSET_1(n) ((n) != 0 ? \
236 (ED_CHECKBUTTON_YSIZE - \
237 ED_DRAWINGAREA_TILE_SIZE) / 2 : 0)
239 #define ED_AREA_XOFFSET_2(n) (0)
240 #define ED_AREA_YOFFSET_2(n) ((n) == 3 ? \
241 ((n) - 1) * ED_DRAWINGAREA_TILE_SIZE / 2 : 0)
243 #define ED_AREA_SETTINGS_X(i) (ED_SETTINGS_X((i).x) + \
244 ED_SETTINGS_XOFF((i).xoffset) + \
245 ED_AREA_XOFFSET_1((i).x) - \
246 ED_AREA_XOFFSET_2((i).area_xsize))
247 #define ED_AREA_SETTINGS_Y(i) (ED_SETTINGS_Y((i).y) + \
248 ED_SETTINGS_YOFF((i).yoffset) + \
249 ED_AREA_YOFFSET_1((i).y) - \
250 ED_AREA_YOFFSET_2((i).area_ysize))
252 // values for element content drawing areas
253 #define ED_AREA_1X1_LSETTINGS_XPOS(n) ED_LEVEL_SETTINGS_XPOS(n)
254 #define ED_AREA_1X1_LSETTINGS_YPOS(n) ED_LEVEL_SETTINGS_YPOS(n)
255 #define ED_AREA_1X1_LSETTINGS_XOFF (0)
256 #define ED_AREA_1X1_LSETTINGS_YOFF (0)
258 #define ED_AREA_1X1_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
259 #define ED_AREA_1X1_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
260 #define ED_AREA_1X1_SETTINGS_XOFF (0)
261 #define ED_AREA_1X1_SETTINGS_YOFF (0)
263 #define ED_AREA_3X3_SETTINGS_XPOS(n) ED_ELEMENT_SETTINGS_XPOS(n)
264 #define ED_AREA_3X3_SETTINGS_YPOS(n) ED_ELEMENT_SETTINGS_YPOS(n)
265 #define ED_AREA_3X3_SETTINGS_XOFF (0)
266 #define ED_AREA_3X3_SETTINGS_YOFF (0)
269 #define ED_AREA_ELEMENT_CONTENT_XOFF(n) (n)
270 #define ED_AREA_ELEMENT_CONTENT_YOFF(n) (n)
273 #define ED_XPOS_YAM 0
274 #define ED_YPOS_YAM 5
275 #define ED_AREA_YAMYAM_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_YAM)
276 #define ED_AREA_YAMYAM_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_YAM)
277 #define ED_AREA_YAMYAM_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
278 #define ED_AREA_YAMYAM_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
279 #define ED_AREA_YAMYAM_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_YAM) + \
281 #define ED_AREA_YAMYAM_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_YAM) + \
282 ED_SETTINGS_YOFF(n) + \
283 ED_AREA_YOFFSET_1(ED_YPOS_YAM) - \
284 ED_AREA_YOFFSET_2(3))
286 // magic ball content
287 #define ED_XPOS_BALL 0
288 #define ED_YPOS_BALL 6
289 #define ED_AREA_MAGIC_BALL_CONTENT_XPOS ED_ELEMENT_SETTINGS_XPOS(ED_XPOS_BALL)
290 #define ED_AREA_MAGIC_BALL_CONTENT_YPOS ED_ELEMENT_SETTINGS_YPOS(ED_YPOS_BALL)
291 #define ED_AREA_MAGIC_BALL_CONTENT_XOFF(n) ED_AREA_ELEMENT_CONTENT_XOFF(n)
292 #define ED_AREA_MAGIC_BALL_CONTENT_YOFF(n) ED_AREA_ELEMENT_CONTENT_YOFF(n)
293 #define ED_AREA_MAGIC_BALL_CONTENT_X(n) (ED_ELEMENT_SETTINGS_X(ED_XPOS_BALL) + \
295 #define ED_AREA_MAGIC_BALL_CONTENT_Y(n) (ED_ELEMENT_SETTINGS_Y(ED_YPOS_BALL) + \
296 ED_SETTINGS_YOFF(n) + \
297 ED_AREA_YOFFSET_1(ED_YPOS_BALL) - \
298 ED_AREA_YOFFSET_2(3))
300 // values for scrolling gadgets for drawing area
301 #define ED_SCROLLBUTTON_XSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].width)
302 #define ED_SCROLLBUTTON_YSIZE (graphic_info[IMG_EDITOR_PLAYFIELD_SCROLLBAR].height)
304 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
305 #define ED_SCROLL_UP_YPOS (0)
306 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
307 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
308 #define ED_SCROLL_LEFT_XPOS (0)
309 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
310 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
311 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
312 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + \
313 ED_SCROLLBUTTON_XSIZE)
314 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
315 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
316 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
317 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
318 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + \
319 ED_SCROLLBUTTON_YSIZE)
320 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
321 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
323 // values for scrolling gadgets for element list
324 #define ED_SCROLLBUTTON2_XSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width)
325 #define ED_SCROLLBUTTON2_YSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height)
327 #define ED_SCROLL2_UP_XPOS (ED_ELEMENTLIST_XPOS + \
328 ED_ELEMENTLIST_BUTTONS_HORIZ * \
329 ED_ELEMENTLIST_XSIZE)
330 #define ED_SCROLL2_UP_YPOS ED_ELEMENTLIST_YPOS
331 #define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
332 #define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
333 ED_ELEMENTLIST_BUTTONS_VERT * \
334 ED_ELEMENTLIST_YSIZE - \
335 ED_SCROLLBUTTON2_YSIZE)
336 #define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
337 #define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
338 ED_SCROLLBUTTON2_YSIZE)
339 #define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
340 #define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
341 ED_ELEMENTLIST_YSIZE - \
342 2 * ED_SCROLLBUTTON2_YSIZE)
344 // values for ClearEditorGadgetInfoText() and HandleEditorGadgetInfoText()
345 #define INFOTEXT_FONT FONT_TEXT_2
346 #define INFOTEXT_XSIZE SXSIZE
347 #define INFOTEXT_YSIZE getFontHeight(INFOTEXT_FONT)
348 #define INFOTEXT_YSIZE_FULL (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE)
349 #define INFOTEXT_X (editor.settings.tooltip.x)
350 #define INFOTEXT_Y (editor.settings.tooltip.y)
351 #define INFOTEXT_XY_REDEFINED (INFOTEXT_X != -1 || INFOTEXT_Y != -1)
352 #define INFOTEXT_XPOS SX + (INFOTEXT_XY_REDEFINED ? INFOTEXT_X : 0)
353 #define INFOTEXT_YPOS SY + (INFOTEXT_XY_REDEFINED ? INFOTEXT_Y : \
354 SYSIZE - INFOTEXT_YSIZE)
357 // ----------------------------------------------------------------------------
358 // editor gadget definitions
359 // ----------------------------------------------------------------------------
365 // drawing toolbox buttons
367 GADGET_ID_SINGLE_ITEMS,
368 GADGET_ID_CONNECTED_ITEMS,
372 GADGET_ID_FILLED_BOX,
375 GADGET_ID_FLOOD_FILL,
378 GADGET_ID_WRAP_RIGHT,
379 GADGET_ID_RANDOM_PLACEMENT,
380 GADGET_ID_GRAB_BRUSH,
382 GADGET_ID_PICK_ELEMENT,
391 GADGET_ID_CUSTOM_COPY_FROM,
392 GADGET_ID_CUSTOM_COPY_TO,
393 GADGET_ID_CUSTOM_EXCHANGE,
394 GADGET_ID_CUSTOM_COPY,
395 GADGET_ID_CUSTOM_PASTE,
397 GADGET_ID_PROPERTIES,
398 GADGET_ID_ELEMENT_LEFT,
399 GADGET_ID_ELEMENT_MIDDLE,
400 GADGET_ID_ELEMENT_RIGHT,
403 // counter gadget identifiers
405 GADGET_ID_SELECT_LEVEL_DOWN,
406 GADGET_ID_SELECT_LEVEL_TEXT,
407 GADGET_ID_SELECT_LEVEL_UP,
408 GADGET_ID_LEVEL_XSIZE_DOWN,
409 GADGET_ID_LEVEL_XSIZE_TEXT,
410 GADGET_ID_LEVEL_XSIZE_UP,
411 GADGET_ID_LEVEL_YSIZE_DOWN,
412 GADGET_ID_LEVEL_YSIZE_TEXT,
413 GADGET_ID_LEVEL_YSIZE_UP,
414 GADGET_ID_LEVEL_RANDOM_DOWN,
415 GADGET_ID_LEVEL_RANDOM_TEXT,
416 GADGET_ID_LEVEL_RANDOM_UP,
417 GADGET_ID_LEVEL_GEMSLIMIT_DOWN,
418 GADGET_ID_LEVEL_GEMSLIMIT_TEXT,
419 GADGET_ID_LEVEL_GEMSLIMIT_UP,
420 GADGET_ID_LEVEL_TIMELIMIT_DOWN,
421 GADGET_ID_LEVEL_TIMELIMIT_TEXT,
422 GADGET_ID_LEVEL_TIMELIMIT_UP,
423 GADGET_ID_LEVEL_TIMESCORE_DOWN,
424 GADGET_ID_LEVEL_TIMESCORE_TEXT,
425 GADGET_ID_LEVEL_TIMESCORE_UP,
426 GADGET_ID_LEVEL_RANDOM_SEED_DOWN,
427 GADGET_ID_LEVEL_RANDOM_SEED_TEXT,
428 GADGET_ID_LEVEL_RANDOM_SEED_UP,
429 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN,
430 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT,
431 GADGET_ID_LEVELSET_NUM_LEVELS_UP,
432 GADGET_ID_ELEMENT_VALUE1_DOWN,
433 GADGET_ID_ELEMENT_VALUE1_TEXT,
434 GADGET_ID_ELEMENT_VALUE1_UP,
435 GADGET_ID_ELEMENT_VALUE2_DOWN,
436 GADGET_ID_ELEMENT_VALUE2_TEXT,
437 GADGET_ID_ELEMENT_VALUE2_UP,
438 GADGET_ID_ELEMENT_VALUE3_DOWN,
439 GADGET_ID_ELEMENT_VALUE3_TEXT,
440 GADGET_ID_ELEMENT_VALUE3_UP,
441 GADGET_ID_ELEMENT_VALUE4_DOWN,
442 GADGET_ID_ELEMENT_VALUE4_TEXT,
443 GADGET_ID_ELEMENT_VALUE4_UP,
444 GADGET_ID_YAMYAM_CONTENT_DOWN,
445 GADGET_ID_YAMYAM_CONTENT_TEXT,
446 GADGET_ID_YAMYAM_CONTENT_UP,
447 GADGET_ID_BALL_CONTENT_DOWN,
448 GADGET_ID_BALL_CONTENT_TEXT,
449 GADGET_ID_BALL_CONTENT_UP,
450 GADGET_ID_ANDROID_CONTENT_DOWN,
451 GADGET_ID_ANDROID_CONTENT_TEXT,
452 GADGET_ID_ANDROID_CONTENT_UP,
453 GADGET_ID_ENVELOPE_XSIZE_DOWN,
454 GADGET_ID_ENVELOPE_XSIZE_TEXT,
455 GADGET_ID_ENVELOPE_XSIZE_UP,
456 GADGET_ID_ENVELOPE_YSIZE_DOWN,
457 GADGET_ID_ENVELOPE_YSIZE_TEXT,
458 GADGET_ID_ENVELOPE_YSIZE_UP,
459 GADGET_ID_INVENTORY_SIZE_DOWN,
460 GADGET_ID_INVENTORY_SIZE_TEXT,
461 GADGET_ID_INVENTORY_SIZE_UP,
462 GADGET_ID_MM_BALL_CONTENT_DOWN,
463 GADGET_ID_MM_BALL_CONTENT_TEXT,
464 GADGET_ID_MM_BALL_CONTENT_UP,
465 GADGET_ID_CUSTOM_SCORE_DOWN,
466 GADGET_ID_CUSTOM_SCORE_TEXT,
467 GADGET_ID_CUSTOM_SCORE_UP,
468 GADGET_ID_CUSTOM_GEMCOUNT_DOWN,
469 GADGET_ID_CUSTOM_GEMCOUNT_TEXT,
470 GADGET_ID_CUSTOM_GEMCOUNT_UP,
471 GADGET_ID_CUSTOM_VALUE_FIX_DOWN,
472 GADGET_ID_CUSTOM_VALUE_FIX_TEXT,
473 GADGET_ID_CUSTOM_VALUE_FIX_UP,
474 GADGET_ID_CUSTOM_VALUE_RND_DOWN,
475 GADGET_ID_CUSTOM_VALUE_RND_TEXT,
476 GADGET_ID_CUSTOM_VALUE_RND_UP,
477 GADGET_ID_PUSH_DELAY_FIX_DOWN,
478 GADGET_ID_PUSH_DELAY_FIX_TEXT,
479 GADGET_ID_PUSH_DELAY_FIX_UP,
480 GADGET_ID_PUSH_DELAY_RND_DOWN,
481 GADGET_ID_PUSH_DELAY_RND_TEXT,
482 GADGET_ID_PUSH_DELAY_RND_UP,
483 GADGET_ID_DROP_DELAY_FIX_DOWN,
484 GADGET_ID_DROP_DELAY_FIX_TEXT,
485 GADGET_ID_DROP_DELAY_FIX_UP,
486 GADGET_ID_DROP_DELAY_RND_DOWN,
487 GADGET_ID_DROP_DELAY_RND_TEXT,
488 GADGET_ID_DROP_DELAY_RND_UP,
489 GADGET_ID_MOVE_DELAY_FIX_DOWN,
490 GADGET_ID_MOVE_DELAY_FIX_TEXT,
491 GADGET_ID_MOVE_DELAY_FIX_UP,
492 GADGET_ID_MOVE_DELAY_RND_DOWN,
493 GADGET_ID_MOVE_DELAY_RND_TEXT,
494 GADGET_ID_MOVE_DELAY_RND_UP,
495 GADGET_ID_STEP_DELAY_FIX_DOWN,
496 GADGET_ID_STEP_DELAY_FIX_TEXT,
497 GADGET_ID_STEP_DELAY_FIX_UP,
498 GADGET_ID_STEP_DELAY_RND_DOWN,
499 GADGET_ID_STEP_DELAY_RND_TEXT,
500 GADGET_ID_STEP_DELAY_RND_UP,
501 GADGET_ID_EXPLOSION_DELAY_DOWN,
502 GADGET_ID_EXPLOSION_DELAY_TEXT,
503 GADGET_ID_EXPLOSION_DELAY_UP,
504 GADGET_ID_IGNITION_DELAY_DOWN,
505 GADGET_ID_IGNITION_DELAY_TEXT,
506 GADGET_ID_IGNITION_DELAY_UP,
507 GADGET_ID_CHANGE_DELAY_FIX_DOWN,
508 GADGET_ID_CHANGE_DELAY_FIX_TEXT,
509 GADGET_ID_CHANGE_DELAY_FIX_UP,
510 GADGET_ID_CHANGE_DELAY_RND_DOWN,
511 GADGET_ID_CHANGE_DELAY_RND_TEXT,
512 GADGET_ID_CHANGE_DELAY_RND_UP,
513 GADGET_ID_CHANGE_CONT_RND_DOWN,
514 GADGET_ID_CHANGE_CONT_RND_TEXT,
515 GADGET_ID_CHANGE_CONT_RND_UP,
516 GADGET_ID_GROUP_CONTENT_DOWN,
517 GADGET_ID_GROUP_CONTENT_TEXT,
518 GADGET_ID_GROUP_CONTENT_UP,
520 // drawing area identifiers
522 GADGET_ID_DRAWING_LEVEL,
523 GADGET_ID_YAMYAM_CONTENT_0,
524 GADGET_ID_YAMYAM_CONTENT_1,
525 GADGET_ID_YAMYAM_CONTENT_2,
526 GADGET_ID_YAMYAM_CONTENT_3,
527 GADGET_ID_YAMYAM_CONTENT_4,
528 GADGET_ID_YAMYAM_CONTENT_5,
529 GADGET_ID_YAMYAM_CONTENT_6,
530 GADGET_ID_YAMYAM_CONTENT_7,
531 GADGET_ID_MAGIC_BALL_CONTENT_0,
532 GADGET_ID_MAGIC_BALL_CONTENT_1,
533 GADGET_ID_MAGIC_BALL_CONTENT_2,
534 GADGET_ID_MAGIC_BALL_CONTENT_3,
535 GADGET_ID_MAGIC_BALL_CONTENT_4,
536 GADGET_ID_MAGIC_BALL_CONTENT_5,
537 GADGET_ID_MAGIC_BALL_CONTENT_6,
538 GADGET_ID_MAGIC_BALL_CONTENT_7,
539 GADGET_ID_ANDROID_CONTENT,
540 GADGET_ID_AMOEBA_CONTENT,
541 GADGET_ID_START_ELEMENT,
542 GADGET_ID_ARTWORK_ELEMENT,
543 GADGET_ID_EXPLOSION_ELEMENT,
544 GADGET_ID_INVENTORY_CONTENT,
545 GADGET_ID_MM_BALL_CONTENT,
546 GADGET_ID_CUSTOM_GRAPHIC,
547 GADGET_ID_CUSTOM_CONTENT,
548 GADGET_ID_CUSTOM_MOVE_ENTER,
549 GADGET_ID_CUSTOM_MOVE_LEAVE,
550 GADGET_ID_CUSTOM_CHANGE_TARGET,
551 GADGET_ID_CUSTOM_CHANGE_CONTENT,
552 GADGET_ID_CUSTOM_CHANGE_TRIGGER,
553 GADGET_ID_CUSTOM_CHANGE_ACTION,
554 GADGET_ID_GROUP_CONTENT,
555 GADGET_ID_RANDOM_BACKGROUND,
557 // text input identifiers
559 GADGET_ID_LEVEL_NAME,
560 GADGET_ID_LEVEL_AUTHOR,
561 GADGET_ID_LEVELSET_NAME,
562 GADGET_ID_LEVELSET_AUTHOR,
563 GADGET_ID_ELEMENT_NAME,
565 // text area identifiers
567 GADGET_ID_ENVELOPE_INFO,
569 // selectbox identifiers
571 GADGET_ID_TIME_OR_STEPS,
572 GADGET_ID_TIME_SCORE_BASE,
573 GADGET_ID_GAME_ENGINE_TYPE,
574 GADGET_ID_LEVELSET_SAVE_MODE,
575 GADGET_ID_WIND_DIRECTION,
576 GADGET_ID_PLAYER_SPEED,
577 GADGET_ID_MM_BALL_CHOICE_MODE,
578 GADGET_ID_CUSTOM_WALK_TO_ACTION,
579 GADGET_ID_CUSTOM_EXPLOSION_TYPE,
580 GADGET_ID_CUSTOM_DEADLINESS,
581 GADGET_ID_CUSTOM_MOVE_PATTERN,
582 GADGET_ID_CUSTOM_MOVE_DIRECTION,
583 GADGET_ID_CUSTOM_MOVE_STEPSIZE,
584 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
585 GADGET_ID_CUSTOM_SMASH_TARGETS,
586 GADGET_ID_CUSTOM_SLIPPERY_TYPE,
587 GADGET_ID_CUSTOM_ACCESS_TYPE,
588 GADGET_ID_CUSTOM_ACCESS_LAYER,
589 GADGET_ID_CUSTOM_ACCESS_PROTECTED,
590 GADGET_ID_CUSTOM_ACCESS_DIRECTION,
591 GADGET_ID_CHANGE_TIME_UNITS,
592 GADGET_ID_CHANGE_DIRECT_ACTION,
593 GADGET_ID_CHANGE_OTHER_ACTION,
594 GADGET_ID_CHANGE_SIDE,
595 GADGET_ID_CHANGE_PLAYER,
596 GADGET_ID_CHANGE_PAGE,
597 GADGET_ID_CHANGE_REPLACE_WHEN,
598 GADGET_ID_ACTION_TYPE,
599 GADGET_ID_ACTION_MODE,
600 GADGET_ID_ACTION_ARG,
601 GADGET_ID_SELECT_CHANGE_PAGE,
602 GADGET_ID_GROUP_CHOICE_MODE,
604 // textbutton identifiers
606 GADGET_ID_LEVELINFO_LEVEL,
607 GADGET_ID_LEVELINFO_LEVELSET,
608 GADGET_ID_LEVELINFO_EDITOR,
609 GADGET_ID_PROPERTIES_INFO,
610 GADGET_ID_PROPERTIES_CONFIG,
611 GADGET_ID_PROPERTIES_CONFIG_1,
612 GADGET_ID_PROPERTIES_CONFIG_2,
613 GADGET_ID_PROPERTIES_CHANGE,
614 GADGET_ID_SAVE_AS_TEMPLATE_1,
615 GADGET_ID_SAVE_AS_TEMPLATE_2,
616 GADGET_ID_SAVE_LEVELSET,
617 GADGET_ID_ADD_CHANGE_PAGE,
618 GADGET_ID_DEL_CHANGE_PAGE,
620 // graphicbutton identifiers
622 GADGET_ID_PREV_CHANGE_PAGE,
623 GADGET_ID_NEXT_CHANGE_PAGE,
624 GADGET_ID_COPY_CHANGE_PAGE,
625 GADGET_ID_PASTE_CHANGE_PAGE,
627 // gadgets for scrolling of drawing area
630 GADGET_ID_SCROLL_DOWN,
631 GADGET_ID_SCROLL_LEFT,
632 GADGET_ID_SCROLL_RIGHT,
633 GADGET_ID_SCROLL_HORIZONTAL,
634 GADGET_ID_SCROLL_VERTICAL,
636 // gadgets for scrolling element list
638 GADGET_ID_SCROLL_LIST_UP,
639 GADGET_ID_SCROLL_LIST_DOWN,
640 GADGET_ID_SCROLL_LIST_VERTICAL,
642 // checkbuttons/radiobuttons for level/element properties
644 GADGET_ID_AUTO_COUNT_GEMS,
645 GADGET_ID_RATE_TIME_OVER_SCORE,
646 GADGET_ID_USE_LEVELSET_ARTWORK,
647 GADGET_ID_COPY_LEVEL_TEMPLATE,
648 GADGET_ID_RANDOM_PERCENTAGE,
649 GADGET_ID_RANDOM_QUANTITY,
650 GADGET_ID_RANDOM_RESTRICTED,
651 GADGET_ID_STICK_ELEMENT,
652 GADGET_ID_EM_SLIPPERY_GEMS,
653 GADGET_ID_EM_EXPLODES_BY_FIRE,
654 GADGET_ID_USE_SPRING_BUG,
655 GADGET_ID_USE_TIME_ORB_BUG,
656 GADGET_ID_USE_LIFE_BUGS,
657 GADGET_ID_RANDOM_BALL_CONTENT,
658 GADGET_ID_INITIAL_BALL_ACTIVE,
659 GADGET_ID_GROW_INTO_DIGGABLE,
660 GADGET_ID_SB_FIELDS_NEEDED,
661 GADGET_ID_SB_OBJECTS_NEEDED,
662 GADGET_ID_AUTO_EXIT_SOKOBAN,
663 GADGET_ID_SOLVED_BY_ONE_PLAYER,
664 GADGET_ID_FINISH_DIG_COLLECT,
665 GADGET_ID_KEEP_WALKABLE_CE,
666 GADGET_ID_CONTINUOUS_SNAPPING,
667 GADGET_ID_BLOCK_SNAP_FIELD,
668 GADGET_ID_BLOCK_LAST_FIELD,
669 GADGET_ID_SP_BLOCK_LAST_FIELD,
670 GADGET_ID_INSTANT_RELOCATION,
671 GADGET_ID_SHIFTED_RELOCATION,
672 GADGET_ID_LAZY_RELOCATION,
673 GADGET_ID_USE_START_ELEMENT,
674 GADGET_ID_USE_ARTWORK_ELEMENT,
675 GADGET_ID_USE_EXPLOSION_ELEMENT,
676 GADGET_ID_INITIAL_GRAVITY,
677 GADGET_ID_USE_INITIAL_INVENTORY,
678 GADGET_ID_CAN_PASS_TO_WALKABLE,
679 GADGET_ID_CAN_FALL_INTO_ACID,
680 GADGET_ID_CAN_MOVE_INTO_ACID,
681 GADGET_ID_DONT_COLLIDE_WITH,
682 GADGET_ID_ENVELOPE_AUTOWRAP,
683 GADGET_ID_ENVELOPE_CENTERED,
684 GADGET_ID_MM_LASER_RED,
685 GADGET_ID_MM_LASER_GREEN,
686 GADGET_ID_MM_LASER_BLUE,
687 GADGET_ID_DF_LASER_RED,
688 GADGET_ID_DF_LASER_GREEN,
689 GADGET_ID_DF_LASER_BLUE,
690 GADGET_ID_ROTATE_MM_BALL_CONTENT,
691 GADGET_ID_CUSTOM_INDESTRUCTIBLE,
692 GADGET_ID_CUSTOM_CAN_EXPLODE,
693 GADGET_ID_CUSTOM_EXPLODE_FIRE,
694 GADGET_ID_CUSTOM_EXPLODE_SMASH,
695 GADGET_ID_CUSTOM_EXPLODE_IMPACT,
696 GADGET_ID_CUSTOM_WALK_TO_OBJECT,
697 GADGET_ID_CUSTOM_DEADLY,
698 GADGET_ID_CUSTOM_CAN_MOVE,
699 GADGET_ID_CUSTOM_CAN_FALL,
700 GADGET_ID_CUSTOM_CAN_SMASH,
701 GADGET_ID_CUSTOM_SLIPPERY,
702 GADGET_ID_CUSTOM_ACCESSIBLE,
703 GADGET_ID_CUSTOM_GRAV_REACHABLE,
704 GADGET_ID_CUSTOM_USE_LAST_VALUE,
705 GADGET_ID_CUSTOM_USE_GRAPHIC,
706 GADGET_ID_CUSTOM_USE_TEMPLATE_1,
707 GADGET_ID_CUSTOM_USE_TEMPLATE_2,
708 GADGET_ID_CUSTOM_USE_TEMPLATE_3,
709 GADGET_ID_CUSTOM_CAN_CHANGE,
710 GADGET_ID_CHANGE_USE_CONTENT,
711 GADGET_ID_CHANGE_USE_EXPLOSION,
712 GADGET_ID_CHANGE_ONLY_COMPLETE,
713 GADGET_ID_CHANGE_USE_RANDOM,
714 GADGET_ID_CHANGE_HAS_ACTION,
715 GADGET_ID_CHANGE_DELAY,
716 GADGET_ID_CHANGE_BY_DIRECT_ACT,
717 GADGET_ID_CHANGE_BY_OTHER_ACT,
719 NUM_STATIC_GADGET_IDS
722 // gadgets for buttons in element list (dynamic)
723 #define GADGET_ID_ELEMENTLIST_FIRST (NUM_STATIC_GADGET_IDS)
724 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
725 ED_NUM_ELEMENTLIST_BUTTONS - 1)
727 #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
729 // radio button numbers
733 RADIO_NR_DRAWING_TOOLBOX,
734 RADIO_NR_RANDOM_ELEMENTS
737 // values for counter gadgets
740 ED_COUNTER_ID_SELECT_LEVEL,
741 ED_COUNTER_ID_LEVEL_XSIZE,
742 ED_COUNTER_ID_LEVEL_YSIZE,
743 ED_COUNTER_ID_LEVEL_GEMSLIMIT,
744 ED_COUNTER_ID_LEVEL_TIMELIMIT,
745 ED_COUNTER_ID_LEVEL_TIMESCORE,
746 ED_COUNTER_ID_LEVEL_RANDOM_SEED,
747 ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
748 ED_COUNTER_ID_LEVEL_RANDOM,
749 ED_COUNTER_ID_ELEMENT_VALUE1,
750 ED_COUNTER_ID_ELEMENT_VALUE2,
751 ED_COUNTER_ID_ELEMENT_VALUE3,
752 ED_COUNTER_ID_ELEMENT_VALUE4,
753 ED_COUNTER_ID_YAMYAM_CONTENT,
754 ED_COUNTER_ID_BALL_CONTENT,
755 ED_COUNTER_ID_ANDROID_CONTENT,
756 ED_COUNTER_ID_ENVELOPE_XSIZE,
757 ED_COUNTER_ID_ENVELOPE_YSIZE,
758 ED_COUNTER_ID_INVENTORY_SIZE,
759 ED_COUNTER_ID_MM_BALL_CONTENT,
760 ED_COUNTER_ID_CUSTOM_SCORE,
761 ED_COUNTER_ID_CUSTOM_GEMCOUNT,
762 ED_COUNTER_ID_CUSTOM_VALUE_FIX,
763 ED_COUNTER_ID_CUSTOM_VALUE_RND,
764 ED_COUNTER_ID_PUSH_DELAY_FIX,
765 ED_COUNTER_ID_PUSH_DELAY_RND,
766 ED_COUNTER_ID_DROP_DELAY_FIX,
767 ED_COUNTER_ID_DROP_DELAY_RND,
768 ED_COUNTER_ID_MOVE_DELAY_FIX,
769 ED_COUNTER_ID_MOVE_DELAY_RND,
770 ED_COUNTER_ID_STEP_DELAY_FIX,
771 ED_COUNTER_ID_STEP_DELAY_RND,
772 ED_COUNTER_ID_EXPLOSION_DELAY,
773 ED_COUNTER_ID_IGNITION_DELAY,
774 ED_COUNTER_ID_GROUP_CONTENT,
775 ED_COUNTER_ID_CHANGE_DELAY_FIX,
776 ED_COUNTER_ID_CHANGE_DELAY_RND,
777 ED_COUNTER_ID_CHANGE_CONT_RND,
779 ED_NUM_COUNTERBUTTONS
782 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
783 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM_SEED
784 #define ED_COUNTER_ID_LEVELSET_FIRST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
785 #define ED_COUNTER_ID_LEVELSET_LAST ED_COUNTER_ID_LEVELSET_NUM_LEVELS
786 #define ED_COUNTER_ID_EDITOR_FIRST ED_COUNTER_ID_LEVEL_RANDOM
787 #define ED_COUNTER_ID_EDITOR_LAST ED_COUNTER_ID_LEVEL_RANDOM
789 #define ED_COUNTER_ID_CUSTOM1_FIRST ED_COUNTER_ID_CUSTOM_SCORE
790 #define ED_COUNTER_ID_CUSTOM1_LAST ED_COUNTER_ID_DROP_DELAY_RND
791 #define ED_COUNTER_ID_CUSTOM2_FIRST ED_COUNTER_ID_MOVE_DELAY_FIX
792 #define ED_COUNTER_ID_CUSTOM2_LAST ED_COUNTER_ID_IGNITION_DELAY
793 #define ED_COUNTER_ID_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM1_FIRST
794 #define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_CUSTOM2_LAST
796 #define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
797 #define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_CONT_RND
799 // values for scrollbutton gadgets
802 ED_SCROLLBUTTON_ID_AREA_UP,
803 ED_SCROLLBUTTON_ID_AREA_DOWN,
804 ED_SCROLLBUTTON_ID_AREA_LEFT,
805 ED_SCROLLBUTTON_ID_AREA_RIGHT,
806 ED_SCROLLBUTTON_ID_LIST_UP,
807 ED_SCROLLBUTTON_ID_LIST_DOWN,
812 #define ED_SCROLLBUTTON_ID_AREA_FIRST ED_SCROLLBUTTON_ID_AREA_UP
813 #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
815 // values for scrollbar gadgets
818 ED_SCROLLBAR_ID_AREA_HORIZONTAL,
819 ED_SCROLLBAR_ID_AREA_VERTICAL,
820 ED_SCROLLBAR_ID_LIST_VERTICAL,
825 #define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
826 #define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
828 // values for text input gadgets
831 ED_TEXTINPUT_ID_LEVEL_NAME,
832 ED_TEXTINPUT_ID_LEVEL_AUTHOR,
833 ED_TEXTINPUT_ID_LEVELSET_NAME,
834 ED_TEXTINPUT_ID_LEVELSET_AUTHOR,
835 ED_TEXTINPUT_ID_ELEMENT_NAME,
840 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
841 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
843 #define ED_TEXTINPUT_ID_LEVELSET_FIRST ED_TEXTINPUT_ID_LEVELSET_NAME
844 #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR
846 // values for text area gadgets
849 ED_TEXTAREA_ID_ENVELOPE_INFO,
854 #define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
855 #define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
857 // values for selectbox gadgets
860 ED_SELECTBOX_ID_TIME_OR_STEPS,
861 ED_SELECTBOX_ID_TIME_SCORE_BASE,
862 ED_SELECTBOX_ID_GAME_ENGINE_TYPE,
863 ED_SELECTBOX_ID_LEVELSET_SAVE_MODE,
864 ED_SELECTBOX_ID_WIND_DIRECTION,
865 ED_SELECTBOX_ID_PLAYER_SPEED,
866 ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE,
867 ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE,
868 ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER,
869 ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED,
870 ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION,
871 ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION,
872 ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN,
873 ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION,
874 ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE,
875 ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE,
876 ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS,
877 ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE,
878 ED_SELECTBOX_ID_CUSTOM_DEADLINESS,
879 ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE,
880 ED_SELECTBOX_ID_CHANGE_TIME_UNITS,
881 ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION,
882 ED_SELECTBOX_ID_CHANGE_OTHER_ACTION,
883 ED_SELECTBOX_ID_CHANGE_SIDE,
884 ED_SELECTBOX_ID_CHANGE_PLAYER,
885 ED_SELECTBOX_ID_CHANGE_PAGE,
886 ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN,
887 ED_SELECTBOX_ID_ACTION_TYPE,
888 ED_SELECTBOX_ID_ACTION_MODE,
889 ED_SELECTBOX_ID_ACTION_ARG,
890 ED_SELECTBOX_ID_SELECT_CHANGE_PAGE,
891 ED_SELECTBOX_ID_GROUP_CHOICE_MODE,
896 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS
897 #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE
899 #define ED_SELECTBOX_ID_LEVELSET_FIRST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
900 #define ED_SELECTBOX_ID_LEVELSET_LAST ED_SELECTBOX_ID_LEVELSET_SAVE_MODE
902 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
903 #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
904 #define ED_SELECTBOX_ID_CUSTOM2_FIRST ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN
905 #define ED_SELECTBOX_ID_CUSTOM2_LAST ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE
906 #define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM1_FIRST
907 #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM2_LAST
909 #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
910 #define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
912 // values for textbutton gadgets
915 ED_TEXTBUTTON_ID_LEVELINFO_LEVEL,
916 ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET,
917 ED_TEXTBUTTON_ID_LEVELINFO_EDITOR,
918 ED_TEXTBUTTON_ID_PROPERTIES_INFO,
919 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG,
920 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1,
921 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2,
922 ED_TEXTBUTTON_ID_PROPERTIES_CHANGE,
923 ED_TEXTBUTTON_ID_SAVE_LEVELSET,
924 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2,
925 ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1,
926 ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE,
927 ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE,
932 #define ED_TAB_BUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
933 #define ED_TAB_BUTTON_ID_LEVELINFO_LAST ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
935 #define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
936 #define ED_TAB_BUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
938 #define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
939 #define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
941 // values for graphicbutton gadgets
944 ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE,
945 ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE,
946 ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE,
947 ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE,
949 ED_NUM_GRAPHICBUTTONS
952 #define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
953 #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE
955 // values for checkbutton gadgets
958 ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS,
959 ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE,
960 ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK,
961 ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE,
962 ED_CHECKBUTTON_ID_RANDOM_RESTRICTED,
963 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3,
964 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2,
965 ED_CHECKBUTTON_ID_STICK_ELEMENT,
966 ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS,
967 ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE,
968 ED_CHECKBUTTON_ID_USE_SPRING_BUG,
969 ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG,
970 ED_CHECKBUTTON_ID_USE_LIFE_BUGS,
971 ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
972 ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE,
973 ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
974 ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
975 ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
976 ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
977 ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
978 ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT,
979 ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE,
980 ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
981 ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD,
982 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD,
983 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD,
984 ED_CHECKBUTTON_ID_INSTANT_RELOCATION,
985 ED_CHECKBUTTON_ID_SHIFTED_RELOCATION,
986 ED_CHECKBUTTON_ID_LAZY_RELOCATION,
987 ED_CHECKBUTTON_ID_USE_START_ELEMENT,
988 ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT,
989 ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT,
990 ED_CHECKBUTTON_ID_INITIAL_GRAVITY,
991 ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY,
992 ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE,
993 ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
994 ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
995 ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
996 ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
997 ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
998 ED_CHECKBUTTON_ID_MM_LASER_RED,
999 ED_CHECKBUTTON_ID_MM_LASER_GREEN,
1000 ED_CHECKBUTTON_ID_MM_LASER_BLUE,
1001 ED_CHECKBUTTON_ID_DF_LASER_RED,
1002 ED_CHECKBUTTON_ID_DF_LASER_GREEN,
1003 ED_CHECKBUTTON_ID_DF_LASER_BLUE,
1004 ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT,
1005 ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC,
1006 ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1,
1007 ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE,
1008 ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE,
1009 ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE,
1010 ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT,
1011 ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE,
1012 ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE,
1013 ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL,
1014 ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH,
1015 ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY,
1016 ED_CHECKBUTTON_ID_CUSTOM_DEADLY,
1017 ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE,
1018 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE,
1019 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH,
1020 ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT,
1021 ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE,
1022 ED_CHECKBUTTON_ID_CHANGE_DELAY,
1023 ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT,
1024 ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT,
1025 ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION,
1026 ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT,
1027 ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE,
1028 ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM,
1029 ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION,
1034 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS
1035 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RATE_TIME_OVER_SCORE
1037 #define ED_CHECKBUTTON_ID_LEVELSET_FIRST ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK
1038 #define ED_CHECKBUTTON_ID_LEVELSET_LAST ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE
1040 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
1041 #define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2
1043 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
1044 #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
1045 #define ED_CHECKBUTTON_ID_CUSTOM2_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE
1046 #define ED_CHECKBUTTON_ID_CUSTOM2_LAST ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT
1047 #define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM1_FIRST
1048 #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST
1050 #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE
1051 #define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION
1053 // values for radiobutton gadgets
1056 ED_RADIOBUTTON_ID_PERCENTAGE,
1057 ED_RADIOBUTTON_ID_QUANTITY,
1062 #define ED_RADIOBUTTON_ID_EDITOR_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
1063 #define ED_RADIOBUTTON_ID_EDITOR_LAST ED_RADIOBUTTON_ID_QUANTITY
1065 // values for drawing area gadgets
1068 ED_DRAWING_ID_DRAWING_LEVEL,
1069 ED_DRAWING_ID_YAMYAM_CONTENT_0,
1070 ED_DRAWING_ID_YAMYAM_CONTENT_1,
1071 ED_DRAWING_ID_YAMYAM_CONTENT_2,
1072 ED_DRAWING_ID_YAMYAM_CONTENT_3,
1073 ED_DRAWING_ID_YAMYAM_CONTENT_4,
1074 ED_DRAWING_ID_YAMYAM_CONTENT_5,
1075 ED_DRAWING_ID_YAMYAM_CONTENT_6,
1076 ED_DRAWING_ID_YAMYAM_CONTENT_7,
1077 ED_DRAWING_ID_MAGIC_BALL_CONTENT_0,
1078 ED_DRAWING_ID_MAGIC_BALL_CONTENT_1,
1079 ED_DRAWING_ID_MAGIC_BALL_CONTENT_2,
1080 ED_DRAWING_ID_MAGIC_BALL_CONTENT_3,
1081 ED_DRAWING_ID_MAGIC_BALL_CONTENT_4,
1082 ED_DRAWING_ID_MAGIC_BALL_CONTENT_5,
1083 ED_DRAWING_ID_MAGIC_BALL_CONTENT_6,
1084 ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
1085 ED_DRAWING_ID_ANDROID_CONTENT,
1086 ED_DRAWING_ID_AMOEBA_CONTENT,
1087 ED_DRAWING_ID_START_ELEMENT,
1088 ED_DRAWING_ID_ARTWORK_ELEMENT,
1089 ED_DRAWING_ID_EXPLOSION_ELEMENT,
1090 ED_DRAWING_ID_INVENTORY_CONTENT,
1091 ED_DRAWING_ID_MM_BALL_CONTENT,
1092 ED_DRAWING_ID_CUSTOM_GRAPHIC,
1093 ED_DRAWING_ID_CUSTOM_CONTENT,
1094 ED_DRAWING_ID_CUSTOM_MOVE_ENTER,
1095 ED_DRAWING_ID_CUSTOM_MOVE_LEAVE,
1096 ED_DRAWING_ID_CUSTOM_CHANGE_TARGET,
1097 ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT,
1098 ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER,
1099 ED_DRAWING_ID_CUSTOM_CHANGE_ACTION,
1100 ED_DRAWING_ID_GROUP_CONTENT,
1101 ED_DRAWING_ID_RANDOM_BACKGROUND,
1103 ED_NUM_DRAWING_AREAS
1106 #define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
1107 #define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
1110 // ----------------------------------------------------------------------------
1111 // some internally used definitions
1112 // ----------------------------------------------------------------------------
1114 // values for CopyLevelToUndoBuffer()
1115 #define UNDO_IMMEDIATE 0
1116 #define UNDO_ACCUMULATE 1
1118 // values for scrollbars
1119 #define ED_SCROLL_NO 0
1120 #define ED_SCROLL_LEFT 1
1121 #define ED_SCROLL_RIGHT 2
1122 #define ED_SCROLL_UP 4
1123 #define ED_SCROLL_DOWN 8
1125 // screens in the level editor
1126 #define ED_MODE_DRAWING 0
1127 #define ED_MODE_INFO 1
1128 #define ED_MODE_PROPERTIES 2
1129 #define ED_MODE_PALETTE 3
1131 // sub-screens in the global settings section
1132 #define ED_MODE_LEVELINFO_LEVEL ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
1133 #define ED_MODE_LEVELINFO_LEVELSET ED_TEXTBUTTON_ID_LEVELINFO_LEVELSET
1134 #define ED_MODE_LEVELINFO_EDITOR ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
1136 // sub-screens in the element properties section
1137 #define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
1138 #define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
1139 #define ED_MODE_PROPERTIES_CONFIG_1 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1
1140 #define ED_MODE_PROPERTIES_CONFIG_2 ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2
1141 #define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
1143 // how many steps can be cancelled
1144 #define NUM_UNDO_STEPS (64 + 1)
1146 // values for elements with score for certain actions
1148 #define MAX_SCORE 999
1150 // values for elements with count for collecting
1151 #define MIN_COLLECT_COUNT 0
1152 #define MAX_COLLECT_COUNT 999
1154 // values for random placement
1155 #define RANDOM_USE_PERCENTAGE 0
1156 #define RANDOM_USE_QUANTITY 1
1158 // values for level set save mode
1159 #define LEVELSET_SAVE_MODE_UPDATE 0
1160 #define LEVELSET_SAVE_MODE_CREATE 1
1162 // default value for element tile size in drawing area
1163 #define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
1164 #define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
1167 // ----------------------------------------------------------------------------
1168 // some internally used data structure definitions
1169 // ----------------------------------------------------------------------------
1175 struct XYTileSize *pos;
1179 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
1181 // note: some additional characters are already reserved for "cheat mode"
1182 // shortcuts (":XYZ" style) -- for details, see "events.c"
1184 // ---------- toolbox control buttons ---------------------------------------
1187 IMG_GFX_EDITOR_BUTTON_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS,
1188 &editor.button.draw_single, GD_TYPE_RADIO_BUTTON,
1189 "draw single items", 's'
1192 IMG_GFX_EDITOR_BUTTON_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS,
1193 &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON,
1194 "draw connected items", 'd'
1197 IMG_GFX_EDITOR_BUTTON_DRAW_LINE, GADGET_ID_LINE,
1198 &editor.button.draw_line, GD_TYPE_RADIO_BUTTON,
1202 IMG_GFX_EDITOR_BUTTON_DRAW_ARC, GADGET_ID_ARC,
1203 &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON,
1207 IMG_GFX_EDITOR_BUTTON_DRAW_RECTANGLE, GADGET_ID_RECTANGLE,
1208 &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON,
1209 "draw outline rectangles", 'r'
1212 IMG_GFX_EDITOR_BUTTON_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX,
1213 &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON,
1214 "draw filled rectangles", 'R'
1217 IMG_GFX_EDITOR_BUTTON_ROTATE_UP, GADGET_ID_WRAP_UP,
1218 &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON,
1219 "wrap (rotate) level up", 0
1222 IMG_GFX_EDITOR_BUTTON_DRAW_TEXT, GADGET_ID_TEXT,
1223 &editor.button.draw_text, GD_TYPE_RADIO_BUTTON,
1224 "enter text elements", 't'
1227 IMG_GFX_EDITOR_BUTTON_FLOOD_FILL, GADGET_ID_FLOOD_FILL,
1228 &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON,
1232 IMG_GFX_EDITOR_BUTTON_ROTATE_LEFT, GADGET_ID_WRAP_LEFT,
1233 &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON,
1234 "wrap (rotate) level left", 0
1237 IMG_GFX_EDITOR_BUTTON_ZOOM_LEVEL, GADGET_ID_ZOOM,
1238 &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON,
1239 "zoom level tile size", '+'
1242 IMG_GFX_EDITOR_BUTTON_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT,
1243 &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON,
1244 "wrap (rotate) level right", 0
1247 IMG_GFX_EDITOR_BUTTON_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT,
1248 &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON,
1249 "random element placement", 0
1252 IMG_GFX_EDITOR_BUTTON_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH,
1253 &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON,
1257 IMG_GFX_EDITOR_BUTTON_ROTATE_DOWN, GADGET_ID_WRAP_DOWN,
1258 &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON,
1259 "wrap (rotate) level down", 0
1262 IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT,
1263 &editor.button.pick_element, GD_TYPE_RADIO_BUTTON,
1264 "pick drawing element", ','
1267 // ---------- level control buttons -----------------------------------------
1270 IMG_GFX_EDITOR_BUTTON_UNDO, GADGET_ID_UNDO,
1271 &editor.button.undo, GD_TYPE_NORMAL_BUTTON,
1272 "undo/redo last operation", 'u'
1275 IMG_GFX_EDITOR_BUTTON_CONF, GADGET_ID_INFO,
1276 &editor.button.conf, GD_TYPE_NORMAL_BUTTON,
1277 "properties of level", 'I'
1280 IMG_GFX_EDITOR_BUTTON_SAVE, GADGET_ID_SAVE,
1281 &editor.button.save, GD_TYPE_NORMAL_BUTTON,
1285 IMG_GFX_EDITOR_BUTTON_CLEAR, GADGET_ID_CLEAR,
1286 &editor.button.clear, GD_TYPE_NORMAL_BUTTON,
1290 IMG_GFX_EDITOR_BUTTON_TEST, GADGET_ID_TEST,
1291 &editor.button.test, GD_TYPE_NORMAL_BUTTON,
1295 IMG_GFX_EDITOR_BUTTON_EXIT, GADGET_ID_EXIT,
1296 &editor.button.exit, GD_TYPE_NORMAL_BUTTON,
1297 "exit level editor", 'E'
1300 // ---------- CE and GE control buttons -------------------------------------
1303 IMG_GFX_EDITOR_BUTTON_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM,
1304 &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON,
1305 "copy settings from other element", 0
1308 IMG_GFX_EDITOR_BUTTON_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO,
1309 &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON,
1310 "copy settings to other element", 0
1313 IMG_GFX_EDITOR_BUTTON_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE,
1314 &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON,
1315 "exchange element with other element", 0
1318 IMG_GFX_EDITOR_BUTTON_CE_COPY, GADGET_ID_CUSTOM_COPY,
1319 &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON,
1320 "copy settings from this element", 0
1323 IMG_GFX_EDITOR_BUTTON_CE_PASTE, GADGET_ID_CUSTOM_PASTE,
1324 &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON,
1325 "paste settings to this element", 0
1328 // ---------- palette control buttons ---------------------------------------
1331 IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES,
1332 &editor.button.properties, GD_TYPE_NORMAL_BUTTON,
1333 "properties of drawing element", 'p'
1336 IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT,
1337 &editor.button.element_left, GD_TYPE_NORMAL_BUTTON,
1338 "properties of drawing element 1", '1'
1341 IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE,
1342 &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON,
1343 "properties of drawing element 2", '2'
1346 IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT,
1347 &editor.button.element_right, GD_TYPE_NORMAL_BUTTON,
1348 "properties of drawing element 3", '3'
1351 IMG_GFX_EDITOR_BUTTON_PALETTE, GADGET_ID_PALETTE,
1352 &editor.button.palette, GD_TYPE_NORMAL_BUTTON,
1353 "show list of elements", 'e'
1357 static int random_placement_value = 10;
1358 static int random_placement_method = RANDOM_USE_QUANTITY;
1359 static int random_placement_background_element = EL_SAND;
1360 static boolean random_placement_background_restricted = FALSE;
1361 static boolean stick_element_properties_window = FALSE;
1362 static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
1363 static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
1364 static struct ElementChangeInfo custom_element_change;
1365 static struct ElementGroupInfo group_element_info;
1366 static struct ElementInfo custom_element;
1368 static char levelset_name[MAX_LEVEL_NAME_LEN + 1];
1369 static char levelset_author[MAX_LEVEL_AUTHOR_LEN + 1];
1370 static int levelset_num_levels = 100;
1371 static boolean levelset_use_levelset_artwork = FALSE;
1372 static boolean levelset_copy_level_template = FALSE;
1373 static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
1378 int min_value, max_value;
1379 int gadget_id_down, gadget_id_up;
1381 int gadget_id_align;
1383 char *text_above, *text_left, *text_right;
1384 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
1386 // ---------- current level number ------------------------------------------
1389 -1, -1, // these values are not constant, but can change at runtime
1391 GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
1392 GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE,
1397 // ---------- level and editor settings -------------------------------------
1400 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1401 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
1402 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
1403 GADGET_ID_LEVEL_XSIZE_TEXT, GADGET_ID_NONE,
1405 "playfield size:", NULL, "width",
1408 -1, ED_LEVEL_SETTINGS_YPOS(4),
1409 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
1410 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
1411 GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
1413 NULL, " ", "height",
1416 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
1418 GADGET_ID_LEVEL_GEMSLIMIT_DOWN, GADGET_ID_LEVEL_GEMSLIMIT_UP,
1419 GADGET_ID_LEVEL_GEMSLIMIT_TEXT, GADGET_ID_NONE,
1421 NULL, "number of gems to collect:", NULL
1424 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
1426 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
1427 GADGET_ID_LEVEL_TIMELIMIT_TEXT, GADGET_ID_NONE,
1429 "time or step limit to solve level:", NULL, NULL
1432 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
1434 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
1435 GADGET_ID_LEVEL_TIMESCORE_TEXT, GADGET_ID_NONE,
1436 &level.score[SC_TIME_BONUS],
1437 "score for time or steps left:", NULL, NULL
1440 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(13),
1442 GADGET_ID_LEVEL_RANDOM_SEED_DOWN, GADGET_ID_LEVEL_RANDOM_SEED_UP,
1443 GADGET_ID_LEVEL_RANDOM_SEED_TEXT, GADGET_ID_NONE,
1445 NULL, "random seed:", "(0 => random)"
1448 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
1450 GADGET_ID_LEVELSET_NUM_LEVELS_DOWN, GADGET_ID_LEVELSET_NUM_LEVELS_UP,
1451 GADGET_ID_LEVELSET_NUM_LEVELS_TEXT, GADGET_ID_NONE,
1452 &levelset_num_levels,
1453 "number of levels:", NULL, NULL,
1456 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1458 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
1459 GADGET_ID_LEVEL_RANDOM_TEXT, GADGET_ID_NONE,
1460 &random_placement_value,
1461 "random element placement:", NULL, "in"
1464 // ---------- element settings: configure (various elements) ----------------
1467 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1468 MIN_SCORE, MAX_SCORE,
1469 GADGET_ID_ELEMENT_VALUE1_DOWN, GADGET_ID_ELEMENT_VALUE1_UP,
1470 GADGET_ID_ELEMENT_VALUE1_TEXT, GADGET_ID_NONE,
1471 NULL, // will be set when used
1475 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
1476 MIN_SCORE, MAX_SCORE,
1477 GADGET_ID_ELEMENT_VALUE2_DOWN, GADGET_ID_ELEMENT_VALUE2_UP,
1478 GADGET_ID_ELEMENT_VALUE2_TEXT, GADGET_ID_NONE,
1479 NULL, // will be set when used
1483 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1484 MIN_SCORE, MAX_SCORE,
1485 GADGET_ID_ELEMENT_VALUE3_DOWN, GADGET_ID_ELEMENT_VALUE3_UP,
1486 GADGET_ID_ELEMENT_VALUE3_TEXT, GADGET_ID_NONE,
1487 NULL, // will be set when used
1491 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1492 MIN_SCORE, MAX_SCORE,
1493 GADGET_ID_ELEMENT_VALUE4_DOWN, GADGET_ID_ELEMENT_VALUE4_UP,
1494 GADGET_ID_ELEMENT_VALUE4_TEXT, GADGET_ID_NONE,
1495 NULL, // will be set when used
1499 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1500 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1501 GADGET_ID_YAMYAM_CONTENT_DOWN, GADGET_ID_YAMYAM_CONTENT_UP,
1502 GADGET_ID_YAMYAM_CONTENT_TEXT, GADGET_ID_NONE,
1503 &level.num_yamyam_contents,
1504 NULL, NULL, "number of content areas"
1507 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1508 MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
1509 GADGET_ID_BALL_CONTENT_DOWN, GADGET_ID_BALL_CONTENT_UP,
1510 GADGET_ID_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1511 &level.num_ball_contents,
1512 NULL, NULL, "number of content areas"
1515 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
1516 MIN_ANDROID_ELEMENTS, MAX_ANDROID_ELEMENTS,
1517 GADGET_ID_ANDROID_CONTENT_DOWN, GADGET_ID_ANDROID_CONTENT_UP,
1518 GADGET_ID_ANDROID_CONTENT_TEXT, GADGET_ID_NONE,
1519 &level.num_android_clone_elements,
1520 NULL, NULL, "number of clonable elements"
1523 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
1524 MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
1525 GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
1526 GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
1527 NULL, // will be set when used
1528 NULL, NULL, "width",
1531 -1, ED_ELEMENT_SETTINGS_YPOS(0),
1532 MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
1533 GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
1534 GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
1535 NULL, // will be set when used
1536 NULL, " ", "height",
1539 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
1540 MIN_INITIAL_INVENTORY_SIZE, MAX_INITIAL_INVENTORY_SIZE,
1541 GADGET_ID_INVENTORY_SIZE_DOWN, GADGET_ID_INVENTORY_SIZE_UP,
1542 GADGET_ID_INVENTORY_SIZE_TEXT, GADGET_ID_NONE,
1543 &level.initial_inventory_size[0],
1544 NULL, NULL, "number of inventory elements"
1547 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1548 MIN_ELEMENTS_IN_GROUP, MAX_MM_BALL_CONTENTS,
1549 GADGET_ID_MM_BALL_CONTENT_DOWN, GADGET_ID_MM_BALL_CONTENT_UP,
1550 GADGET_ID_MM_BALL_CONTENT_TEXT, GADGET_ID_NONE,
1551 &level.num_mm_ball_contents,
1552 NULL, NULL, "number of content elements"
1555 // ---------- element settings: configure 1 (custom elements) ---------------
1558 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1559 MIN_SCORE, MAX_SCORE,
1560 GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
1561 GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
1562 &custom_element.collect_score_initial,
1563 NULL, "CE score", " "
1566 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1567 MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
1568 GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
1569 GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
1570 &custom_element.collect_count_initial,
1571 NULL, "CE count", NULL
1574 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1576 GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1577 GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE,
1578 &custom_element.ce_value_fixed_initial,
1579 NULL, "CE value", NULL
1582 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
1584 GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP,
1585 GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP,
1586 &custom_element.ce_value_random_initial,
1587 NULL, "+random", NULL
1590 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1592 GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
1593 GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE,
1594 &custom_element.push_delay_fixed,
1595 NULL, "push delay", NULL
1598 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1600 GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
1601 GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
1602 &custom_element.push_delay_random,
1603 NULL, "+random", NULL
1606 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7),
1608 GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP,
1609 GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1610 &custom_element.drop_delay_fixed,
1611 NULL, "drop delay", NULL
1614 -1, ED_ELEMENT_SETTINGS_YPOS(7),
1616 GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP,
1617 GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP,
1618 &custom_element.drop_delay_random,
1619 NULL, "+random", NULL
1622 // ---------- element settings: configure 2 (custom elements) ---------------
1625 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
1627 GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
1628 GADGET_ID_MOVE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1629 &custom_element.move_delay_fixed,
1630 NULL, "move delay", NULL
1633 -1, ED_ELEMENT_SETTINGS_YPOS(5),
1635 GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
1636 GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
1637 &custom_element.move_delay_random,
1638 NULL, "+random", NULL
1641 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6),
1643 GADGET_ID_STEP_DELAY_FIX_DOWN, GADGET_ID_STEP_DELAY_FIX_UP,
1644 GADGET_ID_STEP_DELAY_FIX_TEXT, GADGET_ID_NONE,
1645 &custom_element.step_delay_fixed,
1646 NULL, "step delay", NULL
1649 -1, ED_ELEMENT_SETTINGS_YPOS(6),
1651 GADGET_ID_STEP_DELAY_RND_DOWN, GADGET_ID_STEP_DELAY_RND_UP,
1652 GADGET_ID_STEP_DELAY_RND_TEXT, GADGET_ID_STEP_DELAY_FIX_UP,
1653 &custom_element.step_delay_random,
1654 NULL, "+random", NULL
1657 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
1659 GADGET_ID_EXPLOSION_DELAY_DOWN, GADGET_ID_EXPLOSION_DELAY_UP,
1660 GADGET_ID_EXPLOSION_DELAY_TEXT, GADGET_ID_NONE,
1661 &custom_element.explosion_delay,
1662 NULL, "explosion delay", NULL
1665 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
1667 GADGET_ID_IGNITION_DELAY_DOWN, GADGET_ID_IGNITION_DELAY_UP,
1668 GADGET_ID_IGNITION_DELAY_TEXT, GADGET_ID_NONE,
1669 &custom_element.ignition_delay,
1670 NULL, "ignition delay", "(by fire)"
1673 // ---------- element settings: configure (group elements) ------------------
1676 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1677 MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP,
1678 GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP,
1679 GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE,
1680 &group_element_info.num_elements,
1681 NULL, NULL, "number of elements in group"
1684 // ---------- element settings: advanced (custom elements) ------------------
1687 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(2),
1689 GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
1690 GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
1691 &custom_element_change.delay_fixed,
1692 NULL, "CE delay", NULL,
1695 -1, ED_ELEMENT_SETTINGS_YPOS(2),
1697 GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
1698 GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
1699 &custom_element_change.delay_random,
1700 NULL, "+random", NULL
1703 ED_ELEMENT_SETTINGS_XPOS(3), ED_ELEMENT_SETTINGS_YPOS(12),
1705 GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
1706 GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
1707 &custom_element_change.random_percentage,
1708 NULL, "use random replace:", "%"
1718 char *text_above, *infotext;
1719 } textinput_info[ED_NUM_TEXTINPUT] =
1722 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1723 GADGET_ID_LEVEL_NAME,
1726 "Title:", "Title for this level"
1729 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1730 GADGET_ID_LEVEL_AUTHOR,
1731 MAX_LEVEL_AUTHOR_LEN,
1733 "Author:", "Author for this level"
1736 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(0),
1737 GADGET_ID_LEVELSET_NAME,
1740 "Title:", "Title for this or new level set"
1743 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(2),
1744 GADGET_ID_LEVELSET_AUTHOR,
1745 MAX_LEVEL_AUTHOR_LEN,
1747 "Author:", "Author for this or new level set"
1750 -1, -1, // these values are not constant, but can change at runtime
1751 GADGET_ID_ELEMENT_NAME,
1752 MAX_ELEMENT_NAME_LEN - 2, // currently 2 chars less editable
1753 custom_element.description,
1754 NULL, "Element name"
1764 char *text_above, *text_above_cropped, *infotext;
1765 } textarea_info[ED_NUM_TEXTAREAS] =
1768 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
1769 GADGET_ID_ENVELOPE_INFO,
1770 MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
1772 "Envelope Content:", "Envelope Content (cropped):", "Envelope Content"
1776 static struct ValueTextInfo options_time_or_steps[] =
1784 static struct ValueTextInfo options_time_score_base[] =
1786 { 1, "per second/step" },
1787 { 10, "per 10 seconds/steps" },
1792 static struct ValueTextInfo options_game_engine_type[] =
1794 { GAME_ENGINE_TYPE_RND, "Rocks'n'Diamonds" },
1795 { GAME_ENGINE_TYPE_EM, "Emerald Mine" },
1796 { GAME_ENGINE_TYPE_SP, "Supaplex" },
1797 { GAME_ENGINE_TYPE_MM, "Mirror Magic" },
1802 static struct ValueTextInfo options_levelset_save_mode[] =
1804 { LEVELSET_SAVE_MODE_UPDATE, "Update this level set" },
1805 { LEVELSET_SAVE_MODE_CREATE, "Create new level set" },
1810 static struct ValueTextInfo options_wind_direction[] =
1812 { MV_START_NONE, "none" },
1813 { MV_START_LEFT, "left" },
1814 { MV_START_RIGHT, "right" },
1815 { MV_START_UP, "up" },
1816 { MV_START_DOWN, "down" },
1821 static struct ValueTextInfo options_player_speed[] =
1828 { 16, "very fast" },
1829 { 32, "ultrafast" },
1834 static struct ValueTextInfo options_access_type[] =
1836 { EP_WALKABLE, "walkable" },
1837 { EP_PASSABLE, "passable" },
1842 static struct ValueTextInfo options_access_layer[] =
1844 { EP_ACCESSIBLE_OVER, "over" },
1845 { EP_ACCESSIBLE_INSIDE, "inside" },
1846 { EP_ACCESSIBLE_UNDER, "under" },
1851 static struct ValueTextInfo options_access_protected[] =
1853 { 0, "unprotected" },
1859 static struct ValueTextInfo options_access_direction[] =
1861 { MV_NO_DIRECTION, "no direction" },
1862 { MV_LEFT, "left" },
1863 { MV_RIGHT, "right" },
1865 { MV_DOWN, "down" },
1866 { MV_LEFT | MV_UP, "left + up" },
1867 { MV_LEFT | MV_DOWN, "left + down" },
1868 { MV_RIGHT | MV_UP, "right + up" },
1869 { MV_RIGHT | MV_DOWN, "right + down" },
1870 { MV_HORIZONTAL, "horizontal" },
1871 { MV_VERTICAL, "vertical" },
1872 { MV_HORIZONTAL | MV_UP, "horizontal + up" },
1873 { MV_HORIZONTAL | MV_DOWN, "horizontal + down" },
1874 { MV_VERTICAL | MV_LEFT, "vertical + left" },
1875 { MV_VERTICAL | MV_RIGHT, "vertical + right" },
1876 { MV_ALL_DIRECTIONS, "all directions" },
1881 static struct ValueTextInfo options_walk_to_action[] =
1883 { EP_DIGGABLE, "diggable" },
1884 { EP_COLLECTIBLE_ONLY, "collectible" },
1885 { EP_DROPPABLE, "collectible & droppable" },
1886 { EP_THROWABLE, "collectible & throwable" },
1887 { EP_PUSHABLE, "pushable" },
1892 static struct ValueTextInfo options_move_pattern[] =
1894 { MV_LEFT, "left" },
1895 { MV_RIGHT, "right" },
1897 { MV_DOWN, "down" },
1898 { MV_HORIZONTAL, "horizontal" },
1899 { MV_VERTICAL, "vertical" },
1900 { MV_ALL_DIRECTIONS, "all directions" },
1901 { MV_WIND_DIRECTION, "wind direction" },
1902 { MV_TOWARDS_PLAYER, "towards player" },
1903 { MV_AWAY_FROM_PLAYER, "away from player" },
1904 { MV_ALONG_LEFT_SIDE, "along left side" },
1905 { MV_ALONG_RIGHT_SIDE, "along right side" },
1906 { MV_TURNING_LEFT, "turning left" },
1907 { MV_TURNING_RIGHT, "turning right" },
1908 { MV_TURNING_LEFT_RIGHT, "turning left, right" },
1909 { MV_TURNING_RIGHT_LEFT, "turning right, left" },
1910 { MV_TURNING_RANDOM, "turning random" },
1911 { MV_MAZE_RUNNER, "maze runner style" },
1912 { MV_MAZE_HUNTER, "maze hunter style" },
1913 { MV_WHEN_PUSHED, "when pushed" },
1914 { MV_WHEN_DROPPED, "when dropped/thrown" },
1919 static struct ValueTextInfo options_move_direction[] =
1921 { MV_START_AUTOMATIC, "automatic" },
1922 { MV_START_LEFT, "left" },
1923 { MV_START_RIGHT, "right" },
1924 { MV_START_UP, "up" },
1925 { MV_START_DOWN, "down" },
1926 { MV_START_RANDOM, "random" },
1927 { MV_START_PREVIOUS, "previous" },
1932 static struct ValueTextInfo options_move_stepsize[] =
1934 { 0, "not moving" },
1939 { 16, "very fast" },
1940 { 32, "even faster" },
1945 static struct ValueTextInfo options_move_leave_type[] =
1947 { LEAVE_TYPE_UNLIMITED, "leave behind" },
1948 { LEAVE_TYPE_LIMITED, "change it to" },
1953 static struct ValueTextInfo options_smash_targets[] =
1955 { EP_CAN_SMASH_PLAYER, "player" },
1957 { EP_CAN_SMASH_ENEMIES, "enemies" },
1959 { EP_CAN_SMASH_EVERYTHING, "everything" },
1964 static struct ValueTextInfo options_slippery_type[] =
1966 { SLIPPERY_ANY_RANDOM, "random" },
1967 { SLIPPERY_ANY_LEFT_RIGHT, "left, right" },
1968 { SLIPPERY_ANY_RIGHT_LEFT, "right, left" },
1969 { SLIPPERY_ONLY_LEFT, "only left" },
1970 { SLIPPERY_ONLY_RIGHT, "only right" },
1975 static struct ValueTextInfo options_deadliness[] =
1977 { EP_DONT_RUN_INTO, "running into" },
1978 { EP_DONT_COLLIDE_WITH, "colliding with" },
1979 { EP_DONT_GET_HIT_BY, "getting hit by" },
1980 { EP_DONT_TOUCH, "touching" },
1985 static struct ValueTextInfo options_explosion_type[] =
1987 { EXPLODES_3X3, "3x3" },
1988 { EXPLODES_CROSS, "3+3" },
1989 { EXPLODES_1X1, "1x1" },
1994 static struct ValueTextInfo options_time_units[] =
1997 { FRAMES_PER_SECOND, "seconds" },
2002 static struct ValueTextInfo options_change_direct_action[] =
2004 { CE_TOUCHED_BY_PLAYER, "touched by player" },
2005 { CE_PRESSED_BY_PLAYER, "pressed by player" },
2006 { CE_SWITCHED_BY_PLAYER, "switched by player" },
2007 { CE_SNAPPED_BY_PLAYER, "snapped by player" },
2008 { CE_PUSHED_BY_PLAYER, "pushed by player" },
2009 { CE_ENTERED_BY_PLAYER, "entered by player" },
2010 { CE_LEFT_BY_PLAYER, "left by player" },
2011 { CE_DROPPED_BY_PLAYER, "dropped/thrown by player" },
2012 { CE_SWITCHED, "switched" },
2013 { CE_HITTING_SOMETHING, "hitting something" },
2014 { CE_HIT_BY_SOMETHING, "hit by something" },
2016 { CE_BLOCKED, "blocked" },
2018 { CE_IMPACT, "impact (on something)" },
2019 { CE_SMASHED, "smashed (from above)" },
2021 { CE_VALUE_CHANGES, "CE value changes" },
2022 { CE_SCORE_CHANGES, "CE score changes" },
2024 { CE_VALUE_GETS_ZERO, "CE value gets 0" },
2025 { CE_SCORE_GETS_ZERO, "CE score gets 0" },
2026 { CE_UNDEFINED, " " },
2027 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2028 { CE_CLICKED_BY_MOUSE, "clicked by mouse" },
2029 { CE_PRESSED_BY_MOUSE, "pressed by mouse" },
2030 { CE_UNDEFINED, " " },
2031 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2032 { CE_NEXT_TO_PLAYER, "next to player" },
2037 static struct ValueTextInfo options_change_other_action[] =
2039 { CE_PLAYER_TOUCHES_X, "player touches" },
2040 { CE_PLAYER_PRESSES_X, "player presses" },
2041 { CE_PLAYER_SWITCHES_X, "player switches" },
2042 { CE_PLAYER_SNAPS_X, "player snaps" },
2043 { CE_PLAYER_PUSHES_X, "player pushes" },
2044 { CE_PLAYER_ENTERS_X, "player enters" },
2045 { CE_PLAYER_LEAVES_X, "player leaves" },
2046 { CE_PLAYER_DIGS_X, "player digs" },
2047 { CE_PLAYER_COLLECTS_X, "player collects" },
2048 { CE_PLAYER_DROPS_X, "player drops/throws" },
2049 { CE_TOUCHING_X, "touching" },
2050 { CE_HITTING_X, "hitting" },
2051 { CE_DIGGING_X, "digging" },
2052 { CE_HIT_BY_X, "hit by" },
2053 { CE_SWITCH_OF_X, "switch of" },
2054 { CE_CHANGE_OF_X, "change by page of" },
2055 { CE_EXPLOSION_OF_X, "explosion of" },
2056 { CE_MOVE_OF_X, "move of" },
2057 { CE_CREATION_OF_X, "creation of" },
2058 { CE_VALUE_CHANGES_OF_X, "CE value changes of" },
2059 { CE_SCORE_CHANGES_OF_X, "CE score changes of" },
2060 { CE_VALUE_GETS_ZERO_OF_X, "CE value gets 0 of" },
2061 { CE_SCORE_GETS_ZERO_OF_X, "CE score gets 0 of" },
2062 { CE_UNDEFINED, " " },
2063 { CE_HEADLINE_SPECIAL_EVENTS, "[mouse events]" },
2064 { CE_MOUSE_CLICKED_ON_X, "mouse clicked on" },
2065 { CE_MOUSE_PRESSED_ON_X, "mouse pressed on" },
2066 { CE_UNDEFINED, " " },
2067 { CE_HEADLINE_SPECIAL_EVENTS, "[static states]" },
2068 { CE_PLAYER_NEXT_TO_X, "player next to" },
2069 { CE_NEXT_TO_X, "next to" },
2074 static struct ValueTextInfo options_change_trigger_side[] =
2076 { CH_SIDE_LEFT, "left" },
2077 { CH_SIDE_RIGHT, "right" },
2078 { CH_SIDE_TOP, "top" },
2079 { CH_SIDE_BOTTOM, "bottom" },
2080 { CH_SIDE_LEFT_RIGHT, "left/right" },
2081 { CH_SIDE_TOP_BOTTOM, "top/bottom" },
2082 { CH_SIDE_ANY, "any" },
2087 static struct ValueTextInfo options_change_trigger_player[] =
2089 { CH_PLAYER_1, "1" },
2090 { CH_PLAYER_2, "2" },
2091 { CH_PLAYER_3, "3" },
2092 { CH_PLAYER_4, "4" },
2093 { CH_PLAYER_ANY, "any" },
2098 static struct ValueTextInfo options_change_trigger_page[] =
2109 { (1u << 9), "10" },
2110 { (1u << 10), "11" },
2111 { (1u << 11), "12" },
2112 { (1u << 12), "13" },
2113 { (1u << 13), "14" },
2114 { (1u << 14), "15" },
2115 { (1u << 15), "16" },
2116 { (1u << 16), "17" },
2117 { (1u << 17), "18" },
2118 { (1u << 18), "19" },
2119 { (1u << 19), "20" },
2120 { (1u << 20), "21" },
2121 { (1u << 21), "22" },
2122 { (1u << 22), "23" },
2123 { (1u << 23), "24" },
2124 { (1u << 24), "25" },
2125 { (1u << 25), "26" },
2126 { (1u << 26), "27" },
2127 { (1u << 27), "28" },
2128 { (1u << 28), "29" },
2129 { (1u << 29), "30" },
2130 { (1u << 30), "31" },
2131 { (1u << 31), "32" },
2132 { CH_PAGE_ANY, "any" },
2137 static struct ValueTextInfo options_change_replace_when[] =
2139 { CP_WHEN_EMPTY, "empty" },
2140 { CP_WHEN_WALKABLE, "walkable" },
2141 { CP_WHEN_DIGGABLE, "diggable" },
2142 { CP_WHEN_COLLECTIBLE, "collectible" },
2143 { CP_WHEN_REMOVABLE, "removable" },
2144 { CP_WHEN_DESTRUCTIBLE, "destructible" },
2149 static struct ValueTextInfo options_action_type[] =
2151 { CA_NO_ACTION, "no action" },
2152 { CA_UNDEFINED, " " },
2153 { CA_HEADLINE_LEVEL_ACTIONS, "[level]" },
2154 { CA_RESTART_LEVEL, "restart level" },
2155 { CA_SHOW_ENVELOPE, "show envelope" },
2156 { CA_SET_LEVEL_TIME, "set time" },
2157 { CA_SET_LEVEL_SCORE, "set score" },
2158 { CA_SET_LEVEL_GEMS, "set gems" },
2159 { CA_SET_LEVEL_WIND, "set wind dir." },
2160 { CA_SET_LEVEL_RANDOM_SEED, "set random seed" },
2161 { CA_UNDEFINED, " " },
2162 { CA_HEADLINE_PLAYER_ACTIONS, "[player]" },
2163 { CA_MOVE_PLAYER, "move player" },
2164 { CA_MOVE_PLAYER_NEW, "move player new" },
2165 { CA_EXIT_PLAYER, "exit player" },
2166 { CA_KILL_PLAYER, "kill player" },
2167 { CA_SET_PLAYER_KEYS, "set keys" },
2168 { CA_SET_PLAYER_SPEED, "set speed" },
2169 { CA_SET_PLAYER_SHIELD, "set shield" },
2170 { CA_SET_PLAYER_GRAVITY, "set gravity" },
2171 { CA_SET_PLAYER_ARTWORK, "set artwork" },
2172 { CA_SET_PLAYER_INVENTORY, "set inventory" },
2173 { CA_UNDEFINED, " " },
2174 { CA_HEADLINE_CE_ACTIONS, "[CE]" },
2175 { CA_SET_CE_VALUE, "set CE value" },
2176 { CA_SET_CE_SCORE, "set CE score" },
2177 { CA_SET_CE_ARTWORK, "set CE artwork" },
2178 { CA_UNDEFINED, " " },
2179 { CA_HEADLINE_ENGINE_ACTIONS, "[engine]" },
2180 { CA_SET_ENGINE_SCAN_MODE, "set scan mode" },
2185 static struct ValueTextInfo options_action_mode_none[] =
2187 { CA_MODE_UNDEFINED, " " },
2192 static struct ValueTextInfo options_action_mode_assign[] =
2194 { CA_MODE_SET, "=" },
2199 static struct ValueTextInfo options_action_mode_add_remove[] =
2201 { CA_MODE_ADD, "+" },
2202 { CA_MODE_SUBTRACT, "-" },
2207 static struct ValueTextInfo options_action_mode_calculate[] =
2209 { CA_MODE_SET, "=" },
2210 { CA_MODE_ADD, "+" },
2211 { CA_MODE_SUBTRACT, "-" },
2212 { CA_MODE_MULTIPLY, "*" },
2213 { CA_MODE_DIVIDE, "/" },
2214 { CA_MODE_MODULO, "%" },
2219 static struct ValueTextInfo options_action_arg_none[] =
2221 { CA_ARG_UNDEFINED, " " },
2226 static struct ValueTextInfo options_action_arg_player[] =
2228 { CA_ARG_PLAYER_HEADLINE, "[player]" },
2229 { CA_ARG_PLAYER_1, "1" },
2230 { CA_ARG_PLAYER_2, "2" },
2231 { CA_ARG_PLAYER_3, "3" },
2232 { CA_ARG_PLAYER_4, "4" },
2233 { CA_ARG_PLAYER_ANY, "any" },
2234 { CA_ARG_PLAYER_TRIGGER, "trigger" },
2235 { CA_ARG_PLAYER_ACTION, "action ->" },
2240 static struct ValueTextInfo options_action_arg_number[] =
2242 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2249 { CA_ARG_10, "10" },
2250 { CA_ARG_100, "100" },
2251 { CA_ARG_1000, "1000" },
2252 { CA_ARG_UNDEFINED, " " },
2253 { CA_ARG_NUMBER_MIN, "min" },
2254 { CA_ARG_NUMBER_MAX, "max" },
2255 { CA_ARG_UNDEFINED, " " },
2256 { CA_ARG_NUMBER_RESET, "reset" },
2257 { CA_ARG_UNDEFINED, " " },
2258 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2259 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2260 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2261 { CA_ARG_UNDEFINED, " " },
2262 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2263 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2264 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2265 { CA_ARG_UNDEFINED, " " },
2266 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2267 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2268 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2269 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2270 { CA_ARG_UNDEFINED, " " },
2271 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2272 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2273 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2274 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2279 static struct ValueTextInfo options_action_arg_value[] =
2281 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2288 { CA_ARG_10, "10" },
2289 { CA_ARG_100, "100" },
2290 { CA_ARG_1000, "1000" },
2291 { CA_ARG_UNDEFINED, " " },
2292 { CA_ARG_NUMBER_MIN, "min" },
2293 { CA_ARG_NUMBER_MAX, "max" },
2294 { CA_ARG_UNDEFINED, " " },
2295 { CA_ARG_NUMBER_RESET, "reset" },
2296 { CA_ARG_UNDEFINED, " " },
2297 { CA_ARG_NUMBER_CE_VALUE, "CE value" },
2298 { CA_ARG_NUMBER_CE_SCORE, "CE score" },
2299 { CA_ARG_NUMBER_CE_DELAY, "CE delay" },
2300 { CA_ARG_UNDEFINED, " " },
2301 { CA_ARG_NUMBER_LEVEL_TIME, "time" },
2302 { CA_ARG_NUMBER_LEVEL_GEMS, "gems" },
2303 { CA_ARG_NUMBER_LEVEL_SCORE, "score" },
2304 { CA_ARG_UNDEFINED, " " },
2305 { CA_ARG_ELEMENT_CV_HEADLINE, "[CE value]" },
2306 { CA_ARG_ELEMENT_CV_TARGET, "target" },
2307 { CA_ARG_ELEMENT_CV_TRIGGER, "trigger" },
2308 { CA_ARG_ELEMENT_CV_ACTION, "action ->" },
2309 { CA_ARG_UNDEFINED, " " },
2310 { CA_ARG_ELEMENT_CS_HEADLINE, "[CE score]" },
2311 { CA_ARG_ELEMENT_CS_TARGET, "target" },
2312 { CA_ARG_ELEMENT_CS_TRIGGER, "trigger" },
2313 { CA_ARG_ELEMENT_CS_ACTION, "action ->" },
2314 { CA_ARG_UNDEFINED, " " },
2315 { CA_ARG_ELEMENT_NR_HEADLINE, "[element]" },
2316 { CA_ARG_ELEMENT_NR_TARGET, "target" },
2317 { CA_ARG_ELEMENT_NR_TRIGGER, "trigger" },
2318 { CA_ARG_ELEMENT_NR_ACTION, "action ->" },
2323 static struct ValueTextInfo options_action_arg_envelope[] =
2325 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2330 { CA_ARG_UNDEFINED, " " },
2331 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2332 { CA_ARG_ELEMENT_TARGET, "target" },
2333 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2334 { CA_ARG_ELEMENT_ACTION, "action ->" },
2339 static struct ValueTextInfo options_action_arg_key[] =
2341 { CA_ARG_NUMBER_HEADLINE, "[number]" },
2350 { CA_ARG_UNDEFINED, " " },
2351 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2352 { CA_ARG_ELEMENT_TARGET, "target" },
2353 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2354 { CA_ARG_ELEMENT_ACTION, "action ->" },
2359 static struct ValueTextInfo options_action_arg_speed[] =
2361 { CA_ARG_SPEED_HEADLINE, "[speed]" },
2362 { CA_ARG_SPEED_NOT_MOVING, "frozen" },
2363 { CA_ARG_SPEED_VERY_SLOW, "very slow" },
2364 { CA_ARG_SPEED_SLOW, "slow" },
2365 { CA_ARG_SPEED_NORMAL, "normal" },
2366 { CA_ARG_SPEED_FAST, "fast" },
2367 { CA_ARG_SPEED_VERY_FAST, "very fast" },
2368 { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" },
2369 { CA_ARG_UNDEFINED, " " },
2370 { CA_ARG_SPEED_SLOWER, "slower" },
2371 { CA_ARG_SPEED_FASTER, "faster" },
2372 { CA_ARG_UNDEFINED, " " },
2373 { CA_ARG_SPEED_RESET, "reset" },
2378 static struct ValueTextInfo options_action_arg_shield[] =
2380 { CA_ARG_SHIELD_HEADLINE, "[shield]" },
2381 { CA_ARG_SHIELD_OFF, "off" },
2382 { CA_ARG_SHIELD_NORMAL, "normal" },
2383 { CA_ARG_SHIELD_DEADLY, "deadly" },
2388 static struct ValueTextInfo options_action_arg_artwork[] =
2390 { CA_ARG_ELEMENT_HEADLINE, "[element]" },
2391 { CA_ARG_ELEMENT_TARGET, "target" },
2392 { CA_ARG_ELEMENT_TRIGGER, "trigger" },
2393 { CA_ARG_ELEMENT_ACTION, "action ->" },
2394 { CA_ARG_UNDEFINED, " " },
2395 { CA_ARG_ELEMENT_RESET, "reset" },
2400 static struct ValueTextInfo options_action_arg_gravity[] =
2402 { CA_ARG_GRAVITY_HEADLINE, "[gravity]" },
2403 { CA_ARG_GRAVITY_ON, "on" },
2404 { CA_ARG_GRAVITY_OFF, "off" },
2405 { CA_ARG_GRAVITY_TOGGLE, "toggle" },
2410 static struct ValueTextInfo options_action_arg_direction[] =
2412 { CA_ARG_DIRECTION_HEADLINE, "[dir.]" },
2413 { CA_ARG_DIRECTION_NONE, "none" },
2414 { CA_ARG_DIRECTION_LEFT, "left" },
2415 { CA_ARG_DIRECTION_RIGHT, "right" },
2416 { CA_ARG_DIRECTION_UP, "up" },
2417 { CA_ARG_DIRECTION_DOWN, "down" },
2418 { CA_ARG_DIRECTION_TRIGGER, "trigger" },
2419 { CA_ARG_DIRECTION_TRIGGER_BACK, "-trigger" },
2424 static struct ValueTextInfo options_action_arg_scan_mode[] =
2426 { CA_ARG_SCAN_MODE_HEADLINE, "[mode]" },
2427 { CA_ARG_SCAN_MODE_NORMAL, "normal" },
2428 { CA_ARG_SCAN_MODE_REVERSE, "reverse" },
2433 static struct ValueTextInfo options_action_arg_inventory[] =
2435 { CA_ARG_INVENTORY_HEADLINE, "[add]" },
2436 { CA_ARG_ELEMENT_TARGET, "+ target" },
2437 { CA_ARG_ELEMENT_TRIGGER, "+ trigger" },
2438 { CA_ARG_ELEMENT_ACTION, "+ action" },
2439 { CA_ARG_UNDEFINED, " " },
2440 { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]" },
2441 { CA_ARG_INVENTORY_RM_TARGET, "- target" },
2442 { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger" },
2443 { CA_ARG_INVENTORY_RM_ACTION, "- action" },
2444 { CA_ARG_INVENTORY_RM_FIRST, "- first" },
2445 { CA_ARG_INVENTORY_RM_LAST, "- last" },
2446 { CA_ARG_INVENTORY_RM_ALL, "- all" },
2447 { CA_ARG_UNDEFINED, " " },
2448 { CA_ARG_INVENTORY_RESET, "reset" },
2453 static char options_change_page_strings[MAX_CHANGE_PAGES][10];
2454 static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
2459 static struct ValueTextInfo options_group_choice_mode[] =
2461 { ANIM_RANDOM, "random" },
2462 { ANIM_LOOP, "loop" },
2463 { ANIM_LINEAR, "linear" },
2464 { ANIM_PINGPONG, "pingpong" },
2465 { ANIM_PINGPONG2, "pingpong 2" },
2470 static struct ValueTextInfo *action_arg_modes[] =
2472 options_action_mode_none,
2473 options_action_mode_assign,
2474 options_action_mode_add_remove,
2475 options_action_mode_calculate,
2482 struct ValueTextInfo *options;
2484 action_arg_options[] =
2486 { CA_NO_ACTION, 0, options_action_arg_none, },
2487 { CA_EXIT_PLAYER, 0, options_action_arg_player, },
2488 { CA_KILL_PLAYER, 0, options_action_arg_player, },
2489 { CA_MOVE_PLAYER, 0, options_action_arg_direction, },
2490 { CA_MOVE_PLAYER_NEW, 0, options_action_arg_direction, },
2491 { CA_RESTART_LEVEL, 0, options_action_arg_none, },
2492 { CA_SHOW_ENVELOPE, 0, options_action_arg_envelope, },
2493 { CA_SET_LEVEL_TIME, 3, options_action_arg_number, },
2494 { CA_SET_LEVEL_GEMS, 3, options_action_arg_number, },
2495 { CA_SET_LEVEL_SCORE, 3, options_action_arg_number, },
2496 { CA_SET_LEVEL_WIND, 1, options_action_arg_direction, },
2497 { CA_SET_LEVEL_RANDOM_SEED, 1, options_action_arg_number, },
2498 { CA_SET_PLAYER_KEYS, 2, options_action_arg_key, },
2499 { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, },
2500 { CA_SET_PLAYER_SHIELD, 1, options_action_arg_shield, },
2501 { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, },
2502 { CA_SET_PLAYER_ARTWORK, 1, options_action_arg_artwork, },
2503 { CA_SET_PLAYER_INVENTORY, 0, options_action_arg_inventory, },
2504 { CA_SET_CE_VALUE, 3, options_action_arg_value, },
2505 { CA_SET_CE_SCORE, 3, options_action_arg_value, },
2506 { CA_SET_CE_ARTWORK, 1, options_action_arg_artwork, },
2507 { CA_SET_ENGINE_SCAN_MODE, 1, options_action_arg_scan_mode, },
2516 int gadget_id_align;
2517 int size; // char size of selectbox or '-1' (dynamically determined)
2518 struct ValueTextInfo *options;
2520 char *text_above, *text_left, *text_right, *infotext;
2521 } selectbox_info[ED_NUM_SELECTBOX] =
2523 // ---------- level and editor settings -------------------------------------
2526 -1, ED_LEVEL_SETTINGS_YPOS(8),
2527 GADGET_ID_TIME_OR_STEPS, GADGET_ID_LEVEL_TIMELIMIT_UP,
2529 options_time_or_steps,
2530 &level.use_step_counter,
2531 NULL, NULL, "(0 => no limit)", "time or step limit"
2534 -1, ED_LEVEL_SETTINGS_YPOS(10),
2535 GADGET_ID_TIME_SCORE_BASE, GADGET_ID_LEVEL_TIMESCORE_UP,
2537 options_time_score_base,
2538 &level.time_score_base,
2539 NULL, NULL, NULL, "time score for 1 or 10 seconds/steps"
2542 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(12),
2543 GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE,
2545 options_game_engine_type,
2546 &level.game_engine_type,
2547 NULL, "game engine:", NULL, "game engine"
2550 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2551 GADGET_ID_LEVELSET_SAVE_MODE, GADGET_ID_NONE,
2553 options_levelset_save_mode,
2554 &levelset_save_mode,
2555 "Action:", NULL, NULL, "action when saving level set"
2558 // ---------- element settings: configure (several elements) ----------------
2561 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
2562 GADGET_ID_WIND_DIRECTION, GADGET_ID_NONE,
2564 options_wind_direction,
2565 &level.wind_direction_initial,
2566 NULL, "initial wind direction:", NULL, "initial wind direction"
2569 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(7),
2570 GADGET_ID_PLAYER_SPEED, GADGET_ID_NONE,
2572 options_player_speed,
2573 &level.initial_player_stepsize[0],
2574 NULL, "initial player speed:", NULL, "initial player speed"
2577 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2578 GADGET_ID_MM_BALL_CHOICE_MODE, GADGET_ID_NONE,
2580 options_group_choice_mode,
2581 &level.mm_ball_choice_mode,
2582 NULL, "choice type:", NULL, "type of content choice"
2585 // ---------- element settings: configure 1 (custom elements) ---------------
2588 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2589 GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE,
2591 options_access_type,
2592 &custom_element.access_type,
2593 NULL, NULL, NULL, "type of access to this field"
2596 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2597 GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
2599 options_access_layer,
2600 &custom_element.access_layer,
2601 NULL, NULL, NULL, "layer of access for this field"
2604 -1, ED_ELEMENT_SETTINGS_YPOS(2),
2605 GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER,
2607 options_access_protected,
2608 &custom_element.access_protected,
2609 NULL, NULL, NULL, "protected access for this field"
2612 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2613 GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE,
2615 options_access_direction,
2616 &custom_element.access_direction,
2617 NULL, "from", NULL, "access direction for this field"
2620 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2621 GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE,
2623 options_walk_to_action,
2624 &custom_element.walk_to_action,
2625 NULL, NULL, NULL, "diggable/collectible/pushable"
2628 // ---------- element settings: configure 2 (custom elements) ---------------
2631 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(1),
2632 GADGET_ID_CUSTOM_MOVE_PATTERN, GADGET_ID_NONE,
2634 options_move_pattern,
2635 &custom_element.move_pattern,
2636 NULL, "can move", NULL, "element move pattern"
2639 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
2640 GADGET_ID_CUSTOM_MOVE_DIRECTION, GADGET_ID_NONE,
2642 options_move_direction,
2643 &custom_element.move_direction_initial,
2644 NULL, "starts moving", NULL, "initial element move direction"
2647 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
2648 GADGET_ID_CUSTOM_MOVE_STEPSIZE, GADGET_ID_NONE,
2650 options_move_stepsize,
2651 &custom_element.move_stepsize,
2652 NULL, "move/fall speed", NULL, "speed of element movement"
2655 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3),
2656 GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE, GADGET_ID_NONE,
2658 options_move_leave_type,
2659 &custom_element.move_leave_type,
2660 // left text with leading spaces to place gadget next to "can dig" gadget
2661 // (needed because drawing area gadgets created after selectbox gadgets)
2662 // NULL, "can dig: can", ":", "leave behind or change element"
2663 NULL, " can", ":", "leave behind or change element"
2666 -1, ED_ELEMENT_SETTINGS_YPOS(8),
2667 GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
2669 options_smash_targets,
2670 &custom_element.smash_targets,
2671 NULL, "can smash", NULL, "elements that can be smashed"
2674 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
2675 GADGET_ID_CUSTOM_SLIPPERY_TYPE, GADGET_ID_NONE,
2677 options_slippery_type,
2678 &custom_element.slippery_type,
2679 NULL, "slippery", NULL, "where other elements fall down"
2682 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(10),
2683 GADGET_ID_CUSTOM_DEADLINESS, GADGET_ID_NONE,
2686 &custom_element.deadliness,
2687 NULL, "deadly when", NULL, "deadliness of element"
2690 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(11),
2691 GADGET_ID_CUSTOM_EXPLOSION_TYPE, GADGET_ID_NONE,
2693 options_explosion_type,
2694 &custom_element.explosion_type,
2695 NULL, "can explode", NULL, "explosion type"
2698 // ---------- element settings: advanced (custom elements) ------------------
2701 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(3),
2702 GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
2705 &custom_element_change.delay_frames,
2706 NULL, "delay time given in", NULL, "delay time units for change"
2709 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(4),
2710 GADGET_ID_CHANGE_DIRECT_ACTION, GADGET_ID_NONE,
2712 options_change_direct_action,
2713 &custom_element_change.direct_action,
2714 NULL, NULL, NULL, "type of direct action"
2717 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(5),
2718 GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
2720 options_change_other_action,
2721 &custom_element_change.other_action,
2722 NULL, NULL, "element:", "type of other element action"
2725 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(6),
2726 GADGET_ID_CHANGE_SIDE, GADGET_ID_NONE,
2728 options_change_trigger_side,
2729 &custom_element_change.trigger_side,
2730 NULL, "at", "side", "element side triggering change"
2733 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2734 GADGET_ID_CHANGE_PLAYER, GADGET_ID_NONE,
2736 options_change_trigger_player,
2737 &custom_element_change.trigger_player,
2738 NULL, "player:", " ", "player that causes change"
2741 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(7),
2742 GADGET_ID_CHANGE_PAGE, GADGET_ID_CHANGE_PLAYER,
2744 options_change_trigger_page,
2745 &custom_element_change.trigger_page,
2746 NULL, "page:", NULL, "change page that causes change"
2749 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(10),
2750 GADGET_ID_CHANGE_REPLACE_WHEN, GADGET_ID_NONE,
2752 options_change_replace_when,
2753 &custom_element_change.replace_when,
2754 NULL, "replace when", NULL, "which elements can be replaced"
2757 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13),
2758 GADGET_ID_ACTION_TYPE, GADGET_ID_NONE,
2760 options_action_type,
2761 &custom_element_change.action_type,
2762 NULL, NULL, NULL, "action on specified condition"
2765 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2766 GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE,
2768 options_action_mode_none,
2769 &custom_element_change.action_mode,
2770 NULL, NULL, NULL, "action operator"
2773 -1, ED_ELEMENT_SETTINGS_YPOS(13),
2774 GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE,
2776 options_action_arg_none,
2777 &custom_element_change.action_arg,
2778 NULL, NULL, NULL, "action parameter"
2781 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14),
2782 GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
2784 options_change_page,
2785 &custom_element.current_change_page,
2786 NULL, NULL, NULL, "element change page"
2789 // ---------- element settings: configure (group elements) ------------------
2792 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
2793 GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE,
2795 options_group_choice_mode,
2796 &group_element_info.choice_mode,
2797 NULL, "choice type:", NULL, "type of group element choice"
2805 int gadget_id_align;
2808 char *text_above, *text_left, *text_right, *infotext;
2809 } textbutton_info[ED_NUM_TEXTBUTTONS] =
2811 // ---------- level and editor settings (tabs) ------------------------------
2814 ED_LEVEL_TABS_XPOS(0), ED_LEVEL_TABS_YPOS(0),
2815 GADGET_ID_LEVELINFO_LEVEL, GADGET_ID_NONE,
2817 NULL, NULL, NULL, "Configure level properties"
2821 GADGET_ID_LEVELINFO_LEVELSET, GADGET_ID_LEVELINFO_LEVEL,
2823 NULL, NULL, NULL, "Update this or create new level set"
2827 GADGET_ID_LEVELINFO_EDITOR, GADGET_ID_LEVELINFO_LEVELSET,
2829 NULL, NULL, NULL, "Configure editor properties"
2832 // ---------- element settings (tabs) ---------------------------------------
2835 ED_ELEMENT_TABS_XPOS(0), ED_ELEMENT_TABS_YPOS(0),
2836 GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
2838 NULL, NULL, NULL, "Show information about element"
2842 GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_PROPERTIES_INFO,
2844 NULL, NULL, NULL, "Configure element properties"
2848 GADGET_ID_PROPERTIES_CONFIG_1, GADGET_ID_PROPERTIES_INFO,
2850 NULL, NULL, NULL, "Configure element properties, part 1"
2854 GADGET_ID_PROPERTIES_CONFIG_2, GADGET_ID_PROPERTIES_CONFIG_1,
2856 NULL, NULL, NULL, "Configure element properties, part 2"
2860 GADGET_ID_PROPERTIES_CHANGE, GADGET_ID_PROPERTIES_CONFIG_2,
2862 NULL, NULL, NULL, "Configure custom element change pages"
2865 // ---------- level and editor settings (buttons) ---------------------------
2868 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(10),
2869 GADGET_ID_SAVE_LEVELSET, GADGET_ID_LEVELSET_SAVE_MODE,
2871 NULL, NULL, NULL, "Update or create level set"
2874 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
2875 GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE,
2877 NULL, NULL, "this level as level template",
2878 "Save current settings as new template"
2881 // ---------- element settings (buttons) ------------------------------------
2885 GADGET_ID_SAVE_AS_TEMPLATE_1, GADGET_ID_CUSTOM_USE_TEMPLATE_1,
2887 NULL, " ", "As Template",
2888 "Save current settings as new template"
2892 GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_PASTE_CHANGE_PAGE,
2894 NULL, NULL, NULL, "Add new change page"
2898 GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
2900 NULL, NULL, NULL, "Delete current change page"
2909 int gadget_id_align;
2910 char *text_left, *text_right, *infotext;
2911 } graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
2914 IMG_EDITOR_COUNTER_DOWN,
2915 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
2916 GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
2917 NULL, NULL, "select previous change page"
2920 IMG_EDITOR_COUNTER_UP,
2921 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2922 GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
2923 NULL, "change page", "select next change page"
2926 IMG_GFX_EDITOR_BUTTON_CP_COPY,
2927 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2928 GADGET_ID_COPY_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
2929 " ", NULL, "copy settings from this change page"
2932 IMG_GFX_EDITOR_BUTTON_CP_PASTE,
2933 -1, ED_ELEMENT_SETTINGS_YPOS(14),
2934 GADGET_ID_PASTE_CHANGE_PAGE, GADGET_ID_COPY_CHANGE_PAGE,
2935 NULL, NULL, "paste settings to this change page"
2942 } scrollbutton_pos[ED_NUM_SCROLLBUTTONS];
2949 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
2952 IMG_EDITOR_PLAYFIELD_SCROLL_UP,
2953 GADGET_ID_SCROLL_UP,
2954 "scroll level editing area up"
2957 IMG_EDITOR_PLAYFIELD_SCROLL_DOWN,
2958 GADGET_ID_SCROLL_DOWN,
2959 "scroll level editing area down"
2962 IMG_EDITOR_PLAYFIELD_SCROLL_LEFT,
2963 GADGET_ID_SCROLL_LEFT,
2964 "scroll level editing area left"
2967 IMG_EDITOR_PLAYFIELD_SCROLL_RIGHT,
2968 GADGET_ID_SCROLL_RIGHT,
2969 "scroll level editing area right"
2972 IMG_EDITOR_PALETTE_SCROLL_UP,
2973 GADGET_ID_SCROLL_LIST_UP,
2974 "scroll element list up ('Page Up')"
2977 IMG_EDITOR_PALETTE_SCROLL_DOWN,
2978 GADGET_ID_SCROLL_LIST_DOWN,
2979 "scroll element list down ('Page Down')"
2987 int wheel_x, wheel_y;
2988 int wheel_width, wheel_height;
2989 } scrollbar_pos[ED_NUM_SCROLLBARS];
2997 } scrollbar_info[ED_NUM_SCROLLBARS] =
3000 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3001 GD_TYPE_SCROLLBAR_HORIZONTAL,
3002 GADGET_ID_SCROLL_HORIZONTAL,
3003 "scroll level editing area horizontally"
3006 IMG_EDITOR_PLAYFIELD_SCROLLBAR,
3007 GD_TYPE_SCROLLBAR_VERTICAL,
3008 GADGET_ID_SCROLL_VERTICAL,
3009 "scroll level editing area vertically"
3012 IMG_EDITOR_PALETTE_SCROLLBAR,
3013 GD_TYPE_SCROLLBAR_VERTICAL,
3014 GADGET_ID_SCROLL_LIST_VERTICAL,
3015 "scroll element list vertically"
3024 int gadget_id_align;
3025 int radio_button_nr;
3028 char *text_left, *text_right, *infotext;
3029 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
3032 -1, ED_LEVEL_SETTINGS_YPOS(0),
3033 GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
3034 RADIO_NR_RANDOM_ELEMENTS,
3035 &random_placement_method, RANDOM_USE_PERCENTAGE,
3036 " ", "percentage", "use percentage for random elements"
3039 -1, ED_LEVEL_SETTINGS_YPOS(0),
3040 GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
3041 RADIO_NR_RANDOM_ELEMENTS,
3042 &random_placement_method, RANDOM_USE_QUANTITY,
3043 " ", "quantity", "use quantity for random elements"
3051 int gadget_id_align;
3053 char *text_above, *text_left, *text_right, *infotext;
3054 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
3056 // ---------- level and editor settings -------------------------------------
3059 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(6),
3060 GADGET_ID_AUTO_COUNT_GEMS, GADGET_ID_NONE,
3061 &level.auto_count_gems,
3063 "automatically count gems needed", "set counter to number of gems"
3066 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(11),
3067 GADGET_ID_RATE_TIME_OVER_SCORE, GADGET_ID_NONE,
3068 &level.rate_time_over_score,
3070 "rate time/steps used over score", "sort high scores by playing time/steps"
3073 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(7),
3074 GADGET_ID_USE_LEVELSET_ARTWORK, GADGET_ID_NONE,
3075 &levelset_use_levelset_artwork,
3077 "use current custom artwork", "use custom artwork of this level set"
3080 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(8),
3081 GADGET_ID_COPY_LEVEL_TEMPLATE, GADGET_ID_NONE,
3082 &levelset_copy_level_template,
3084 "copy current level template", "copy level template of this level set"
3087 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(1),
3088 GADGET_ID_RANDOM_RESTRICTED, GADGET_ID_NONE,
3089 &random_placement_background_restricted,
3091 "restrict random placement to:", "set random placement restriction"
3094 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(4),
3095 GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE,
3096 &setup.editor.use_template_for_new_levels,
3097 "Template for new levels and CE/GE:", NULL,
3098 "use template for new levels", "use template for level properties"
3101 ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5),
3102 GADGET_ID_CUSTOM_USE_TEMPLATE_2, GADGET_ID_NONE,
3103 &level.use_custom_template,
3105 "use template for custom elements", "use template for custom properties"
3108 // ---------- element settings: configure (various elements) ----------------
3111 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3112 GADGET_ID_STICK_ELEMENT, GADGET_ID_NONE,
3113 &stick_element_properties_window,
3115 "stick this screen to edit content","stick this screen to edit content"
3118 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3119 GADGET_ID_EM_SLIPPERY_GEMS, GADGET_ID_NONE,
3120 &level.em_slippery_gems,
3122 "slip down from certain flat walls","use EM/DC style slipping behaviour"
3125 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3126 GADGET_ID_EM_EXPLODES_BY_FIRE, GADGET_ID_NONE,
3127 &level.em_explodes_by_fire,
3129 "explodes with chain reaction", "use R'n'D style explosion behaviour"
3132 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3133 GADGET_ID_USE_SPRING_BUG, GADGET_ID_NONE,
3134 &level.use_spring_bug,
3136 "use spring pushing bug", "use odd spring pushing behaviour"
3139 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3140 GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_NONE,
3141 &level.use_time_orb_bug,
3143 "use time orb bug", "use odd time orb behaviour"
3146 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3147 GADGET_ID_USE_LIFE_BUGS, GADGET_ID_NONE,
3148 &level.use_life_bugs,
3150 "use buggy element behaviour", "use odd (historic) element behaviour"
3153 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3154 GADGET_ID_RANDOM_BALL_CONTENT, GADGET_ID_NONE,
3157 "create single random element", "only create one element from content"
3160 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3161 GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE,
3162 &level.ball_active_initial,
3164 "magic ball initially activated", "activate magic ball after level start"
3167 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3168 GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_NONE,
3169 &level.grow_into_diggable,
3171 "can grow into anything diggable", "grow into more than just sand"
3174 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3175 GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_NONE,
3176 &level.sb_fields_needed,
3178 "all fields need to be filled", "require all SB fields to be solved"
3181 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3182 GADGET_ID_SB_OBJECTS_NEEDED, GADGET_ID_NONE,
3183 &level.sb_objects_needed,
3185 "all objects need to be placed", "require all SB objects to be solved"
3188 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3189 GADGET_ID_AUTO_EXIT_SOKOBAN, GADGET_ID_NONE,
3190 &level.auto_exit_sokoban,
3192 "exit level if all tasks solved", "automatically finish Sokoban levels"
3195 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3196 GADGET_ID_SOLVED_BY_ONE_PLAYER, GADGET_ID_NONE,
3197 &level.solved_by_one_player,
3199 "only one player must enter exit", "level solved by first player in exit"
3202 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3203 GADGET_ID_FINISH_DIG_COLLECT, GADGET_ID_NONE,
3204 &level.finish_dig_collect,
3206 "CE action on finished dig/collect", "only finished dig/collect triggers CE"
3209 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3210 GADGET_ID_KEEP_WALKABLE_CE, GADGET_ID_NONE,
3211 &level.keep_walkable_ce,
3213 "keep walkable CE changed to player", "keep CE changing to player if walkable"
3216 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3217 GADGET_ID_CONTINUOUS_SNAPPING, GADGET_ID_NONE,
3218 &level.continuous_snapping,
3220 "continuous snapping", "use snapping without releasing key"
3223 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3224 GADGET_ID_BLOCK_SNAP_FIELD, GADGET_ID_NONE,
3225 &level.block_snap_field,
3227 "block snapped field when snapping", "use snapping delay to show animation"
3230 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3231 GADGET_ID_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3232 &level.block_last_field,
3234 "block last field when moving", "player blocks last field when moving"
3237 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3238 GADGET_ID_SP_BLOCK_LAST_FIELD, GADGET_ID_NONE,
3239 &level.sp_block_last_field,
3241 "block last field when moving", "player blocks last field when moving"
3244 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3245 GADGET_ID_INSTANT_RELOCATION, GADGET_ID_NONE,
3246 &level.instant_relocation,
3248 "no scrolling when relocating", "player gets relocated without delay"
3251 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3252 GADGET_ID_SHIFTED_RELOCATION, GADGET_ID_NONE,
3253 &level.shifted_relocation,
3255 "no centering when relocating", "level not centered after relocation"
3258 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3259 GADGET_ID_LAZY_RELOCATION, GADGET_ID_NONE,
3260 &level.lazy_relocation,
3262 "only redraw off-screen relocation","no redraw if relocation target visible"
3265 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3266 GADGET_ID_USE_START_ELEMENT, GADGET_ID_NONE,
3267 &level.use_start_element[0],
3269 "use level start element:", "start level at this element's position"
3272 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3273 GADGET_ID_USE_ARTWORK_ELEMENT, GADGET_ID_NONE,
3274 &level.use_artwork_element[0],
3276 "use artwork from element:", "use player artwork from other element"
3279 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12),
3280 GADGET_ID_USE_EXPLOSION_ELEMENT, GADGET_ID_NONE,
3281 &level.use_explosion_element[0],
3283 "use explosion from element:", "use explosion properties from element"
3286 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3287 GADGET_ID_INITIAL_GRAVITY, GADGET_ID_NONE,
3288 &level.initial_player_gravity[0],
3290 "use initial gravity", "set initial player gravity"
3293 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3294 GADGET_ID_USE_INITIAL_INVENTORY, GADGET_ID_NONE,
3295 &level.use_initial_inventory[0],
3297 "use initial inventory:", "use collected elements on level start"
3300 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6),
3301 GADGET_ID_CAN_PASS_TO_WALKABLE, GADGET_ID_NONE,
3302 &level.can_pass_to_walkable,
3304 "can pass to walkable element", "player can pass to empty or walkable"
3307 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3308 GADGET_ID_CAN_FALL_INTO_ACID, GADGET_ID_NONE,
3309 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3311 "can fall into acid (with gravity)","player can fall into acid pool"
3314 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0),
3315 GADGET_ID_CAN_MOVE_INTO_ACID, GADGET_ID_NONE,
3316 &custom_element_properties[EP_CAN_MOVE_INTO_ACID],
3318 "can move into acid", "element can move into acid pool"
3321 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3322 GADGET_ID_DONT_COLLIDE_WITH, GADGET_ID_NONE,
3323 &custom_element_properties[EP_DONT_COLLIDE_WITH],
3325 "deadly when colliding with", "element is deadly when hitting player"
3328 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3329 GADGET_ID_ENVELOPE_AUTOWRAP, GADGET_ID_NONE,
3330 &level.envelope[0].autowrap,
3332 "auto-wrap", "automatically wrap envelope text"
3335 -1, ED_ELEMENT_SETTINGS_YPOS(1),
3336 GADGET_ID_ENVELOPE_CENTERED, GADGET_ID_ENVELOPE_AUTOWRAP,
3337 &level.envelope[0].centered,
3339 "centered", "automatically center envelope text"
3342 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3343 GADGET_ID_MM_LASER_RED, GADGET_ID_NONE,
3344 &level.mm_laser_red,
3345 "choose color components for laser:", NULL,
3346 "red", "use red color components in laser"
3349 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3350 GADGET_ID_MM_LASER_GREEN, GADGET_ID_NONE,
3351 &level.mm_laser_green,
3353 "green", "use green color components in laser"
3356 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3357 GADGET_ID_MM_LASER_BLUE, GADGET_ID_NONE,
3358 &level.mm_laser_blue,
3360 "blue", "use blue color components in laser"
3363 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3364 GADGET_ID_DF_LASER_RED, GADGET_ID_NONE,
3365 &level.df_laser_red,
3366 "choose color components for laser:", NULL,
3367 "red", "use red color components in laser"
3370 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3371 GADGET_ID_DF_LASER_GREEN, GADGET_ID_NONE,
3372 &level.df_laser_green,
3374 "green", "use green color components in laser"
3377 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3),
3378 GADGET_ID_DF_LASER_BLUE, GADGET_ID_NONE,
3379 &level.df_laser_blue,
3381 "blue", "use blue color components in laser"
3384 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5),
3385 GADGET_ID_ROTATE_MM_BALL_CONTENT, GADGET_ID_NONE,
3386 &level.rotate_mm_ball_content,
3388 "randomly rotate created content", "randomly rotate newly created content"
3391 // ---------- element settings: configure 1 (custom elements) ---------------
3394 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3395 GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE,
3396 &custom_element.use_gfx_element,
3398 "use graphic of element:", "use existing element graphic"
3401 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14),
3402 GADGET_ID_CUSTOM_USE_TEMPLATE_1, GADGET_ID_NONE,
3403 &level.use_custom_template,
3405 "use template", "use template for custom properties"
3408 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2),
3409 GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE,
3410 &custom_element_properties[EP_ACCESSIBLE],
3412 NULL, "player can walk to or pass this field"
3415 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3416 GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE,
3417 &custom_element_properties[EP_GRAVITY_REACHABLE],
3419 "reachable despite gravity", "player can walk/dig despite gravity"
3422 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3423 GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE,
3424 &custom_element.use_last_ce_value,
3426 "use last CE value after change", "use last CE value after change"
3429 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4),
3430 GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE,
3431 &custom_element_properties[EP_WALK_TO_OBJECT],
3433 NULL, "player can dig/collect/push element"
3436 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3437 GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE,
3438 &custom_element_properties[EP_INDESTRUCTIBLE],
3440 "indestructible", "element is indestructible"
3443 // ---------- element settings: configure 2 (custom elements) ---------------
3446 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3447 GADGET_ID_CUSTOM_CAN_MOVE, GADGET_ID_NONE,
3448 &custom_element_properties[EP_CAN_MOVE],
3450 NULL, "element can move with some pattern"
3453 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8),
3454 GADGET_ID_CUSTOM_CAN_FALL, GADGET_ID_NONE,
3455 &custom_element_properties[EP_CAN_FALL],
3457 "can fall", "element can fall down"
3460 -1, ED_ELEMENT_SETTINGS_YPOS(8),
3461 GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
3462 &custom_element_properties[EP_CAN_SMASH],
3464 NULL, "element can smash other elements"
3467 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9),
3468 GADGET_ID_CUSTOM_SLIPPERY, GADGET_ID_NONE,
3469 &custom_element_properties[EP_SLIPPERY],
3471 NULL, "other elements can fall down from it"
3474 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10),
3475 GADGET_ID_CUSTOM_DEADLY, GADGET_ID_NONE,
3476 &custom_element_properties[EP_DEADLY],
3478 NULL, "element can kill the player"
3481 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11),
3482 GADGET_ID_CUSTOM_CAN_EXPLODE, GADGET_ID_NONE,
3483 &custom_element_properties[EP_CAN_EXPLODE],
3485 NULL, "element can explode"
3488 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(12),
3489 GADGET_ID_CUSTOM_EXPLODE_FIRE, GADGET_ID_NONE,
3490 &custom_element_properties[EP_EXPLODES_BY_FIRE],
3492 "by fire", "element can explode by fire/explosion"
3495 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3496 GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
3497 &custom_element_properties[EP_EXPLODES_SMASHED],
3499 "smashed", "element can explode when smashed"
3502 -1, ED_ELEMENT_SETTINGS_YPOS(12),
3503 GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
3504 &custom_element_properties[EP_EXPLODES_IMPACT],
3506 "impact", "element can explode on impact"
3509 // ---------- element settings: advanced (custom elements) ------------------
3512 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1),
3513 GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE,
3514 &custom_element_change.can_change,
3516 "element changes to:", "change element on specified condition"
3519 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2),
3520 GADGET_ID_CHANGE_DELAY, GADGET_ID_NONE,
3521 &custom_element_change_events[CE_DELAY],
3523 NULL, "element changes after delay"
3526 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4),
3527 GADGET_ID_CHANGE_BY_DIRECT_ACT, GADGET_ID_NONE,
3528 &custom_element_change_events[CE_BY_DIRECT_ACTION],
3530 NULL, "element changes by direct action"
3533 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5),
3534 GADGET_ID_CHANGE_BY_OTHER_ACT, GADGET_ID_NONE,
3535 &custom_element_change_events[CE_BY_OTHER_ACTION],
3537 NULL, "element changes by other element"
3540 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8),
3541 GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
3542 &custom_element_change.explode,
3544 "explode instead of change", "element explodes instead of change"
3547 ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(9),
3548 GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
3549 &custom_element_change.use_target_content,
3551 "use extended change target:", "element changes to more elements"
3554 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(11),
3555 GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
3556 &custom_element_change.only_if_complete,
3558 "replace all or nothing", "only replace when all can be changed"
3561 ED_ELEMENT_SETTINGS_XPOS(2), ED_ELEMENT_SETTINGS_YPOS(12),
3562 GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
3563 &custom_element_change.use_random_replace,
3565 NULL, "use percentage for random replace"
3568 ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13),
3569 GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE,
3570 &custom_element_change.has_action,
3572 NULL, "execute action on specified condition"
3579 int xoffset, yoffset;
3581 int gadget_id_align;
3583 int area_xsize, area_ysize;
3584 char *text_left, *text_right, *text_above, *text_below, *infotext;
3585 } drawingarea_info[ED_NUM_DRAWING_AREAS] =
3587 // ---------- level playfield content ---------------------------------------
3592 GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE,
3594 -1, -1, // these values are not constant, but can change at runtime
3595 NULL, NULL, NULL, NULL, NULL
3598 // ---------- yam yam content -----------------------------------------------
3601 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3602 ED_AREA_YAMYAM_CONTENT_XOFF(0), ED_AREA_YAMYAM_CONTENT_YOFF(0),
3603 GADGET_ID_YAMYAM_CONTENT_0, GADGET_ID_NONE,
3604 &level.yamyam_content[0].e[0][0], 3, 3,
3605 NULL, NULL, NULL, "1", NULL
3608 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3609 ED_AREA_YAMYAM_CONTENT_XOFF(1), ED_AREA_YAMYAM_CONTENT_YOFF(1),
3610 GADGET_ID_YAMYAM_CONTENT_1, GADGET_ID_NONE,
3611 &level.yamyam_content[1].e[0][0], 3, 3,
3612 NULL, NULL, NULL, "2", NULL
3615 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3616 ED_AREA_YAMYAM_CONTENT_XOFF(2), ED_AREA_YAMYAM_CONTENT_YOFF(2),
3617 GADGET_ID_YAMYAM_CONTENT_2, GADGET_ID_NONE,
3618 &level.yamyam_content[2].e[0][0], 3, 3,
3619 NULL, NULL, NULL, "3", NULL
3622 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3623 ED_AREA_YAMYAM_CONTENT_XOFF(3), ED_AREA_YAMYAM_CONTENT_YOFF(3),
3624 GADGET_ID_YAMYAM_CONTENT_3, GADGET_ID_NONE,
3625 &level.yamyam_content[3].e[0][0], 3, 3,
3626 NULL, NULL, NULL, "4", NULL
3629 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3630 ED_AREA_YAMYAM_CONTENT_XOFF(4), ED_AREA_YAMYAM_CONTENT_YOFF(4),
3631 GADGET_ID_YAMYAM_CONTENT_4, GADGET_ID_NONE,
3632 &level.yamyam_content[4].e[0][0], 3, 3,
3633 NULL, NULL, NULL, "5", NULL
3636 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3637 ED_AREA_YAMYAM_CONTENT_XOFF(5), ED_AREA_YAMYAM_CONTENT_YOFF(5),
3638 GADGET_ID_YAMYAM_CONTENT_5, GADGET_ID_NONE,
3639 &level.yamyam_content[5].e[0][0], 3, 3,
3640 NULL, NULL, NULL, "6", NULL
3643 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3644 ED_AREA_YAMYAM_CONTENT_XOFF(6), ED_AREA_YAMYAM_CONTENT_YOFF(6),
3645 GADGET_ID_YAMYAM_CONTENT_6, GADGET_ID_NONE,
3646 &level.yamyam_content[6].e[0][0], 3, 3,
3647 NULL, NULL, NULL, "7", NULL
3650 ED_AREA_YAMYAM_CONTENT_XPOS, ED_AREA_YAMYAM_CONTENT_YPOS,
3651 ED_AREA_YAMYAM_CONTENT_XOFF(7), ED_AREA_YAMYAM_CONTENT_YOFF(7),
3652 GADGET_ID_YAMYAM_CONTENT_7, GADGET_ID_NONE,
3653 &level.yamyam_content[7].e[0][0], 3, 3,
3654 NULL, NULL, NULL, "8", NULL
3657 // ---------- magic ball content --------------------------------------------
3660 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3661 ED_AREA_MAGIC_BALL_CONTENT_XOFF(0), ED_AREA_MAGIC_BALL_CONTENT_YOFF(0),
3662 GADGET_ID_MAGIC_BALL_CONTENT_0, GADGET_ID_NONE,
3663 &level.ball_content[0].e[0][0], 3, 3,
3664 NULL, NULL, NULL, "1", NULL
3667 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3668 ED_AREA_MAGIC_BALL_CONTENT_XOFF(1), ED_AREA_MAGIC_BALL_CONTENT_YOFF(1),
3669 GADGET_ID_MAGIC_BALL_CONTENT_1, GADGET_ID_NONE,
3670 &level.ball_content[1].e[0][0], 3, 3,
3671 NULL, NULL, NULL, "2", NULL
3674 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3675 ED_AREA_MAGIC_BALL_CONTENT_XOFF(2), ED_AREA_MAGIC_BALL_CONTENT_YOFF(2),
3676 GADGET_ID_MAGIC_BALL_CONTENT_2, GADGET_ID_NONE,
3677 &level.ball_content[2].e[0][0], 3, 3,
3678 NULL, NULL, NULL, "3", NULL
3681 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3682 ED_AREA_MAGIC_BALL_CONTENT_XOFF(3), ED_AREA_MAGIC_BALL_CONTENT_YOFF(3),
3683 GADGET_ID_MAGIC_BALL_CONTENT_3, GADGET_ID_NONE,
3684 &level.ball_content[3].e[0][0], 3, 3,
3685 NULL, NULL, NULL, "4", NULL
3688 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3689 ED_AREA_MAGIC_BALL_CONTENT_XOFF(4), ED_AREA_MAGIC_BALL_CONTENT_YOFF(4),
3690 GADGET_ID_MAGIC_BALL_CONTENT_4, GADGET_ID_NONE,
3691 &level.ball_content[4].e[0][0], 3, 3,
3692 NULL, NULL, NULL, "5", NULL
3695 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3696 ED_AREA_MAGIC_BALL_CONTENT_XOFF(5), ED_AREA_MAGIC_BALL_CONTENT_YOFF(5),
3697 GADGET_ID_MAGIC_BALL_CONTENT_5, GADGET_ID_NONE,
3698 &level.ball_content[5].e[0][0], 3, 3,
3699 NULL, NULL, NULL, "6", NULL
3702 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3703 ED_AREA_MAGIC_BALL_CONTENT_XOFF(6), ED_AREA_MAGIC_BALL_CONTENT_YOFF(6),
3704 GADGET_ID_MAGIC_BALL_CONTENT_6, GADGET_ID_NONE,
3705 &level.ball_content[6].e[0][0], 3, 3,
3706 NULL, NULL, NULL, "7", NULL
3709 ED_AREA_MAGIC_BALL_CONTENT_XPOS, ED_AREA_MAGIC_BALL_CONTENT_YPOS,
3710 ED_AREA_MAGIC_BALL_CONTENT_XOFF(7), ED_AREA_MAGIC_BALL_CONTENT_YOFF(7),
3711 GADGET_ID_MAGIC_BALL_CONTENT_7, GADGET_ID_NONE,
3712 &level.ball_content[7].e[0][0], 3, 3,
3713 NULL, NULL, NULL, "8", NULL
3716 // ---------- android content -----------------------------------------------
3719 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(6),
3720 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3721 GADGET_ID_ANDROID_CONTENT, GADGET_ID_NONE,
3722 &level.android_clone_element[0], MAX_ANDROID_ELEMENTS, 1,
3723 NULL, NULL, "elements:", NULL, "elements android can clone"
3726 // ---------- amoeba content ------------------------------------------------
3729 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(3),
3730 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3731 GADGET_ID_AMOEBA_CONTENT, GADGET_ID_NONE,
3732 &level.amoeba_content, 1, 1,
3733 "content:", NULL, NULL, NULL, "amoeba content"
3736 // ---------- level start element -------------------------------------------
3739 -1, ED_AREA_1X1_SETTINGS_YPOS(10),
3740 0, ED_AREA_1X1_SETTINGS_YOFF,
3741 GADGET_ID_START_ELEMENT, GADGET_ID_USE_START_ELEMENT,
3742 &level.start_element[0], 1, 1,
3743 NULL, NULL, NULL, NULL, "level start element"
3746 // ---------- player artwork element ----------------------------------------
3749 -1, ED_AREA_1X1_SETTINGS_YPOS(11),
3750 0, ED_AREA_1X1_SETTINGS_YOFF,
3751 GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_USE_ARTWORK_ELEMENT,
3752 &level.artwork_element[0], 1, 1,
3753 NULL, NULL, NULL, NULL, "element for player artwork"
3756 // ---------- player explosion element --------------------------------------
3759 -1, ED_AREA_1X1_SETTINGS_YPOS(12),
3760 0, ED_AREA_1X1_SETTINGS_YOFF,
3761 GADGET_ID_EXPLOSION_ELEMENT, GADGET_ID_USE_EXPLOSION_ELEMENT,
3762 &level.explosion_element[0], 1, 1,
3763 NULL, NULL, NULL, NULL, "element for player explosion"
3766 // ---------- player initial inventory --------------------------------------
3769 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3770 0, ED_AREA_1X1_SETTINGS_YOFF,
3771 GADGET_ID_INVENTORY_CONTENT, GADGET_ID_USE_INITIAL_INVENTORY,
3772 &level.initial_inventory_content[0][0], MAX_INITIAL_INVENTORY_SIZE, 1,
3773 NULL, NULL, NULL, NULL, "content for initial inventory"
3776 // ---------- gray ball content -----------------------------------------
3779 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3780 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3781 GADGET_ID_MM_BALL_CONTENT, GADGET_ID_NONE,
3782 &level.mm_ball_content[0], MAX_MM_BALL_CONTENTS, 1,
3783 "content:", NULL, NULL, NULL, "content for gray ball"
3786 // ---------- element settings: configure 1 (custom elements) ---------------
3788 // ---------- custom graphic ------------------------------------------------
3791 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3792 0, ED_AREA_1X1_SETTINGS_YOFF,
3793 GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
3794 &custom_element.gfx_element_initial,1, 1,
3795 NULL, NULL, NULL, NULL, "custom graphic element"
3798 // ---------- element settings: configure 2 (custom elements) ---------------
3800 // ---------- custom content (when exploding) -------------------------------
3803 -1, ED_AREA_3X3_SETTINGS_YPOS(11),
3804 0, ED_AREA_3X3_SETTINGS_YOFF,
3805 GADGET_ID_CUSTOM_CONTENT, GADGET_ID_NONE, // align three rows
3806 &custom_element.content.e[0][0], 3, 3,
3807 "content:", NULL, NULL, NULL, NULL
3810 // ---------- custom enter and leave element (when moving) ------------------
3813 ED_AREA_1X1_SETTINGS_XPOS(1), ED_AREA_1X1_SETTINGS_YPOS(3),
3814 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3815 GADGET_ID_CUSTOM_MOVE_ENTER, GADGET_ID_NONE,
3816 &custom_element.move_enter_element, 1, 1,
3817 "can dig:", " ", NULL, NULL, "element that can be digged/collected"
3820 -1, ED_AREA_1X1_SETTINGS_YPOS(3),
3821 0, ED_AREA_1X1_SETTINGS_YOFF,
3822 GADGET_ID_CUSTOM_MOVE_LEAVE, GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE,
3823 &custom_element.move_leave_element, 1, 1,
3824 NULL, NULL, NULL, NULL, "element that will be left behind"
3827 // ---------- element settings: advanced (custom elements) ------------------
3829 // ---------- custom change target ------------------------------------------
3832 -1, ED_AREA_1X1_SETTINGS_YPOS(1),
3833 0, ED_AREA_1X1_SETTINGS_YOFF,
3834 GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
3835 &custom_element_change.target_element, 1, 1,
3836 NULL, "after/when:", NULL, NULL, "new target element after change"
3839 // ---------- custom change content (extended change target) ----------------
3842 -1, ED_AREA_3X3_SETTINGS_YPOS(9),
3843 0, ED_AREA_3X3_SETTINGS_YOFF,
3844 GADGET_ID_CUSTOM_CHANGE_CONTENT, GADGET_ID_NONE, // align three rows
3845 &custom_element_change.target_content.e[0][0], 3, 3,
3846 NULL, NULL, NULL, NULL, "new extended elements after change"
3849 // ---------- custom change trigger (element causing change) ----------------
3852 -1, ED_AREA_1X1_SETTINGS_YPOS(5),
3853 0, ED_AREA_1X1_SETTINGS_YOFF,
3854 GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
3855 &custom_element_change.initial_trigger_element, 1, 1,
3856 NULL, NULL, NULL, NULL, "other element triggering change"
3859 // ---------- custom change action (element used for action) ----------------
3862 -1, ED_AREA_1X1_SETTINGS_YPOS(13),
3863 0, ED_AREA_1X1_SETTINGS_YOFF,
3864 GADGET_ID_CUSTOM_CHANGE_ACTION, GADGET_ID_ACTION_ARG,
3865 &custom_element_change.action_element, 1, 1,
3866 NULL, NULL, NULL, NULL, "element used as action parameter"
3869 // ---------- group element content -----------------------------------------
3872 ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2),
3873 ED_AREA_1X1_SETTINGS_XOFF, ED_AREA_1X1_SETTINGS_YOFF,
3874 GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE,
3875 &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1,
3876 "content:", NULL, NULL, NULL, NULL
3879 // ---------- random background (for random painting) -----------------------
3882 -1, ED_AREA_1X1_LSETTINGS_YPOS(1),
3883 0, ED_AREA_1X1_LSETTINGS_YOFF,
3884 GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
3885 &random_placement_background_element, 1, 1,
3886 NULL, NULL, NULL, NULL, "random placement background"
3891 // ----------------------------------------------------------------------------
3892 // some internally used variables
3893 // ----------------------------------------------------------------------------
3895 // maximal size of level editor drawing area
3896 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
3898 // actual size of level editor drawing area
3899 static int ed_fieldx, ed_fieldy;
3901 // actual position of level editor drawing area in level playfield
3902 static int level_xpos = -1, level_ypos = -1;
3904 // actual tile size used to display playfield drawing area
3905 static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
3906 static int ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
3908 #define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
3910 // drawing elements on the three mouse buttons
3911 static int new_element1 = EL_WALL;
3912 static int new_element2 = EL_EMPTY;
3913 static int new_element3 = EL_SAND;
3915 #define IS_VALID_BUTTON(button) (button >= 1 && button <= 3)
3916 #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
3917 (button) == 2 ? new_element2 : \
3918 (button) == 3 ? new_element3 : EL_EMPTY)
3920 #define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE)
3922 static int use_permanent_palette = TRUE;
3924 #define PX (use_permanent_palette ? DX : SX)
3925 #define PY (use_permanent_palette ? DY : SY)
3926 #define PXSIZE (use_permanent_palette ? DXSIZE : SXSIZE)
3927 #define PYSIZE (use_permanent_palette ? DYSIZE : SYSIZE)
3929 // forward declaration for internal use
3930 static void CopyBrushToCursor(int, int);
3931 static void DeleteBrushFromCursor(void);
3932 static void ModifyEditorCounterValue(int, int);
3933 static void ModifyEditorCounterLimits(int, int, int);
3934 static void ModifyEditorSelectboxValue(int, int);
3935 static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *);
3936 static void ModifyEditorDrawingArea(int, int, int);
3937 static void ModifyEditorElementList(void);
3938 static void AdjustElementListScrollbar(void);
3939 static void RedrawDrawingElements(void);
3940 static void DrawDrawingWindowExt(boolean);
3941 static void DrawDrawingWindow(void);
3942 static void DrawLevelInfoWindow(void);
3943 static void DrawPropertiesWindow(void);
3944 static void DrawPaletteWindow(void);
3945 static void UpdateCustomElementGraphicGadgets(void);
3946 static boolean checkPropertiesConfig(int);
3947 static void SetAutomaticNumberOfGemsNeeded(void);
3948 static void ClearEditorGadgetInfoText(void);
3949 static void CopyLevelToUndoBuffer(int);
3950 static void HandleDrawingAreas(struct GadgetInfo *);
3951 static void HandleCounterButtons(struct GadgetInfo *);
3952 static void HandleTextInputGadgets(struct GadgetInfo *);
3953 static void HandleTextAreaGadgets(struct GadgetInfo *);
3954 static void HandleSelectboxGadgets(struct GadgetInfo *);
3955 static void HandleTextbuttonGadgets(struct GadgetInfo *);
3956 static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
3957 static void HandleRadiobuttons(struct GadgetInfo *);
3958 static void HandleCheckbuttons(struct GadgetInfo *);
3959 static void HandleControlButtons(struct GadgetInfo *);
3960 static void HandleDrawingAreaInfo(struct GadgetInfo *);
3961 static void PrintEditorGadgetInfoText(struct GadgetInfo *);
3962 static boolean AskToCopyAndModifyLevelTemplate(void);
3963 static boolean getDrawModeHiRes(void);
3964 static int getTabulatorBarWidth(void);
3965 static int getTabulatorBarHeight(void);
3966 static Pixel getTabulatorBarColor(void);
3968 static int num_editor_gadgets = 0; // dynamically determined
3970 static struct GadgetInfo **level_editor_gadget = NULL;
3971 static int *right_gadget_border = NULL;
3973 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
3974 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
3975 static boolean draw_with_brush = FALSE;
3976 static int properties_element = 0;
3978 static short TileBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3979 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3980 static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3981 static int undo_buffer_position = 0;
3982 static int undo_buffer_steps = 0;
3983 static int redo_buffer_steps = 0;
3985 static int edit_mode;
3986 static int edit_mode_levelinfo;
3987 static int edit_mode_properties;
3989 static int element_shift = 0;
3991 static int editor_el_players[] =
3998 static int *editor_el_players_ptr = editor_el_players;
3999 static int num_editor_el_players = ARRAY_SIZE(editor_el_players);
4001 static int editor_hl_boulderdash[] =
4003 EL_INTERNAL_CASCADE_BD_ACTIVE,
4009 static int editor_el_boulderdash[] =
4018 EL_BD_EXPANDABLE_WALL,
4026 EL_BD_BUTTERFLY_LEFT,
4028 EL_BD_BUTTERFLY_RIGHT,
4029 EL_BD_FIREFLY_RIGHT,
4032 EL_BD_BUTTERFLY_DOWN,
4036 static int *editor_hl_boulderdash_ptr = editor_hl_boulderdash;
4037 static int *editor_el_boulderdash_ptr = editor_el_boulderdash;
4038 static int num_editor_hl_boulderdash = ARRAY_SIZE(editor_hl_boulderdash);
4039 static int num_editor_el_boulderdash = ARRAY_SIZE(editor_el_boulderdash);
4041 static int editor_hl_emerald_mine[] =
4043 EL_INTERNAL_CASCADE_EM_ACTIVE,
4049 static int editor_el_emerald_mine[] =
4067 EL_EM_DYNAMITE_ACTIVE,
4086 EL_ACID_POOL_TOPLEFT,
4088 EL_ACID_POOL_TOPRIGHT,
4091 EL_ACID_POOL_BOTTOMLEFT,
4092 EL_ACID_POOL_BOTTOM,
4093 EL_ACID_POOL_BOTTOMRIGHT,
4111 static int *editor_hl_emerald_mine_ptr = editor_hl_emerald_mine;
4112 static int *editor_el_emerald_mine_ptr = editor_el_emerald_mine;
4113 static int num_editor_hl_emerald_mine = ARRAY_SIZE(editor_hl_emerald_mine);
4114 static int num_editor_el_emerald_mine = ARRAY_SIZE(editor_el_emerald_mine);
4116 static int editor_hl_emerald_mine_club[] =
4118 EL_INTERNAL_CASCADE_EMC_ACTIVE,
4124 static int editor_el_emerald_mine_club[] =
4151 EL_EMC_WALL_SLIPPERY_1,
4152 EL_EMC_WALL_SLIPPERY_2,
4153 EL_EMC_WALL_SLIPPERY_3,
4154 EL_EMC_WALL_SLIPPERY_4,
4177 EL_EMC_MAGIC_BALL_SWITCH,
4184 EL_EMC_SPRING_BUMPER,
4188 EL_BALLOON_SWITCH_UP,
4189 EL_BALLOON_SWITCH_ANY,
4192 EL_BALLOON_SWITCH_LEFT,
4194 EL_BALLOON_SWITCH_RIGHT,
4198 EL_BALLOON_SWITCH_DOWN,
4199 EL_BALLOON_SWITCH_NONE,
4201 static int *editor_hl_emerald_mine_club_ptr = editor_hl_emerald_mine_club;
4202 static int *editor_el_emerald_mine_club_ptr = editor_el_emerald_mine_club;
4203 static int num_editor_hl_emerald_mine_club = ARRAY_SIZE(editor_hl_emerald_mine_club);
4204 static int num_editor_el_emerald_mine_club = ARRAY_SIZE(editor_el_emerald_mine_club);
4206 static int editor_hl_rnd[] =
4208 EL_INTERNAL_CASCADE_RND_ACTIVE,
4214 static int editor_el_rnd[] =
4217 EL_DYNAMITE_ACTIVE, // RND
4251 EL_WALL_EMERALD_YELLOW,
4252 EL_WALL_EMERALD_RED,
4253 EL_WALL_EMERALD_PURPLE,
4271 EL_DYNABOMB_INCREASE_NUMBER,
4272 EL_DYNABOMB_INCREASE_SIZE,
4273 EL_DYNABOMB_INCREASE_POWER,
4293 EL_INVISIBLE_STEELWALL,
4297 EL_EXPANDABLE_WALL_HORIZONTAL,
4298 EL_EXPANDABLE_WALL_VERTICAL,
4299 EL_EXPANDABLE_WALL_ANY,
4301 static int *editor_hl_rnd_ptr = editor_hl_rnd;
4302 static int *editor_el_rnd_ptr = editor_el_rnd;
4303 static int num_editor_hl_rnd = ARRAY_SIZE(editor_hl_rnd);
4304 static int num_editor_el_rnd = ARRAY_SIZE(editor_el_rnd);
4306 static int editor_hl_sokoban[] =
4308 EL_INTERNAL_CASCADE_SB_ACTIVE,
4314 static int editor_el_sokoban[] =
4317 EL_SOKOBAN_FIELD_EMPTY,
4318 EL_SOKOBAN_FIELD_FULL,
4319 EL_SOKOBAN_FIELD_PLAYER,
4321 static int *editor_hl_sokoban_ptr = editor_hl_sokoban;
4322 static int *editor_el_sokoban_ptr = editor_el_sokoban;
4323 static int num_editor_hl_sokoban = ARRAY_SIZE(editor_hl_sokoban);
4324 static int num_editor_el_sokoban = ARRAY_SIZE(editor_el_sokoban);
4326 static int editor_hl_supaplex[] =
4328 EL_INTERNAL_CASCADE_SP_ACTIVE,
4334 static int editor_el_supaplex[] =
4352 EL_SP_PORT_HORIZONTAL,
4353 EL_SP_PORT_VERTICAL,
4361 EL_SP_GRAVITY_PORT_LEFT,
4362 EL_SP_GRAVITY_PORT_RIGHT,
4363 EL_SP_GRAVITY_PORT_UP,
4364 EL_SP_GRAVITY_PORT_DOWN,
4366 EL_SP_GRAVITY_ON_PORT_LEFT,
4367 EL_SP_GRAVITY_ON_PORT_RIGHT,
4368 EL_SP_GRAVITY_ON_PORT_UP,
4369 EL_SP_GRAVITY_ON_PORT_DOWN,
4371 EL_SP_GRAVITY_OFF_PORT_LEFT,
4372 EL_SP_GRAVITY_OFF_PORT_RIGHT,
4373 EL_SP_GRAVITY_OFF_PORT_UP,
4374 EL_SP_GRAVITY_OFF_PORT_DOWN,
4376 EL_SP_HARDWARE_GRAY,
4377 EL_SP_HARDWARE_GREEN,
4378 EL_SP_HARDWARE_BLUE,
4381 EL_SP_HARDWARE_BASE_1,
4382 EL_SP_HARDWARE_BASE_2,
4383 EL_SP_HARDWARE_BASE_3,
4384 EL_SP_HARDWARE_BASE_4,
4386 EL_SP_HARDWARE_BASE_5,
4387 EL_SP_HARDWARE_BASE_6,
4388 EL_SP_HARDWARE_YELLOW,
4396 static int *editor_hl_supaplex_ptr = editor_hl_supaplex;
4397 static int *editor_el_supaplex_ptr = editor_el_supaplex;
4398 static int num_editor_hl_supaplex = ARRAY_SIZE(editor_hl_supaplex);
4399 static int num_editor_el_supaplex = ARRAY_SIZE(editor_el_supaplex);
4401 static int editor_hl_diamond_caves[] =
4403 EL_INTERNAL_CASCADE_DC_ACTIVE,
4409 static int editor_el_diamond_caves[] =
4411 EL_EM_STEEL_EXIT_CLOSED, // DC2
4412 EL_EM_STEEL_EXIT_OPEN, // DC2
4413 EL_WALL_EMERALD, // DC2
4414 EL_WALL_DIAMOND, // DC2
4421 EL_CONVEYOR_BELT_1_LEFT,
4422 EL_CONVEYOR_BELT_1_MIDDLE,
4423 EL_CONVEYOR_BELT_1_RIGHT,
4424 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
4426 EL_CONVEYOR_BELT_2_LEFT,
4427 EL_CONVEYOR_BELT_2_MIDDLE,
4428 EL_CONVEYOR_BELT_2_RIGHT,
4429 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
4431 EL_CONVEYOR_BELT_3_LEFT,
4432 EL_CONVEYOR_BELT_3_MIDDLE,
4433 EL_CONVEYOR_BELT_3_RIGHT,
4434 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
4436 EL_CONVEYOR_BELT_4_LEFT,
4437 EL_CONVEYOR_BELT_4_MIDDLE,
4438 EL_CONVEYOR_BELT_4_RIGHT,
4439 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
4441 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
4442 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
4443 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
4444 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
4446 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
4447 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
4448 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
4449 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
4454 EL_DC_TIMEGATE_SWITCH,
4456 EL_SWITCHGATE_CLOSED,
4458 EL_SWITCHGATE_SWITCH_UP,
4459 EL_SWITCHGATE_SWITCH_DOWN,
4462 EL_LIGHT_SWITCH_ACTIVE,
4463 EL_DC_SWITCHGATE_SWITCH_UP,
4464 EL_DC_SWITCHGATE_SWITCH_DOWN,
4466 EL_STEEL_EXIT_CLOSED,
4468 EL_STEELWALL_SLIPPERY,
4471 EL_QUICKSAND_FAST_EMPTY,
4472 EL_QUICKSAND_FAST_FULL,
4486 EL_SIGN_RADIOACTIVITY,
4492 EL_SIGN_ENTRY_FORBIDDEN,
4493 EL_SIGN_EMERGENCY_EXIT,
4518 EL_DC_STEELWALL_2_SINGLE,
4519 EL_DC_STEELWALL_2_TOP,
4520 EL_SIGN_EXCLAMATION,
4523 EL_DC_STEELWALL_2_LEFT,
4524 EL_DC_STEELWALL_2_MIDDLE,
4525 EL_DC_STEELWALL_2_HORIZONTAL,
4526 EL_DC_STEELWALL_2_RIGHT,
4528 EL_DC_STEELWALL_1_TOPLEFT,
4529 EL_DC_STEELWALL_2_VERTICAL,
4530 EL_DC_STEELWALL_1_TOPRIGHT,
4533 EL_DC_STEELWALL_1_VERTICAL,
4534 EL_DC_STEELWALL_2_BOTTOM,
4536 EL_DC_GATE_WHITE_GRAY,
4538 EL_DC_STEELWALL_1_BOTTOMLEFT,
4539 EL_DC_STEELWALL_1_HORIZONTAL,
4540 EL_DC_STEELWALL_1_BOTTOMRIGHT,
4541 EL_DC_GATE_FAKE_GRAY,
4543 EL_DC_STEELWALL_1_BOTTOMRIGHT_2,
4544 EL_DC_STEELWALL_1_BOTTOM,
4545 EL_DC_STEELWALL_1_BOTTOMLEFT_2,
4546 EL_EXPANDABLE_STEELWALL_HORIZONTAL,
4548 EL_DC_STEELWALL_1_RIGHT,
4550 EL_DC_STEELWALL_1_LEFT,
4551 EL_EXPANDABLE_STEELWALL_VERTICAL,
4553 EL_DC_STEELWALL_1_TOPRIGHT_2,
4554 EL_DC_STEELWALL_1_TOP,
4555 EL_DC_STEELWALL_1_TOPLEFT_2,
4556 EL_EXPANDABLE_STEELWALL_ANY,
4558 static int *editor_hl_diamond_caves_ptr = editor_hl_diamond_caves;
4559 static int *editor_el_diamond_caves_ptr = editor_el_diamond_caves;
4560 static int num_editor_hl_diamond_caves = ARRAY_SIZE(editor_hl_diamond_caves);
4561 static int num_editor_el_diamond_caves = ARRAY_SIZE(editor_el_diamond_caves);
4563 static int editor_hl_dx_boulderdash[] =
4565 EL_INTERNAL_CASCADE_DX_ACTIVE,
4571 static int editor_el_dx_boulderdash[] =
4575 EL_TUBE_HORIZONTAL_DOWN,
4579 EL_TUBE_VERTICAL_RIGHT,
4581 EL_TUBE_VERTICAL_LEFT,
4585 EL_TUBE_HORIZONTAL_UP,
4593 static int *editor_hl_dx_boulderdash_ptr = editor_hl_dx_boulderdash;
4594 static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
4595 static int num_editor_hl_dx_boulderdash = ARRAY_SIZE(editor_hl_dx_boulderdash);
4596 static int num_editor_el_dx_boulderdash = ARRAY_SIZE(editor_el_dx_boulderdash);
4598 static int editor_hl_mirror_magic[] =
4600 EL_INTERNAL_CASCADE_MM_ACTIVE,
4606 static int editor_el_mirror_magic[] =
4608 EL_MM_MCDUFFIN_RIGHT,
4610 EL_MM_MCDUFFIN_LEFT,
4611 EL_MM_MCDUFFIN_DOWN,
4614 EL_MM_MIRROR_FIXED_START,
4615 EL_MM_POLARIZER_START,
4616 EL_MM_POLARIZER_CROSS_START,
4618 EL_MM_TELEPORTER_RED_START,
4619 EL_MM_TELEPORTER_YELLOW_START,
4620 EL_MM_TELEPORTER_GREEN_START,
4621 EL_MM_TELEPORTER_BLUE_START,
4634 EL_MM_LIGHTBULB_ACTIVE,
4648 EL_MM_STEEL_GRID_FIXED_1,
4649 EL_MM_STEEL_GRID_FIXED_2,
4650 EL_MM_STEEL_GRID_FIXED_3,
4651 EL_MM_STEEL_GRID_FIXED_4,
4653 EL_MM_WOODEN_GRID_FIXED_1,
4654 EL_MM_WOODEN_GRID_FIXED_2,
4655 EL_MM_WOODEN_GRID_FIXED_3,
4656 EL_MM_WOODEN_GRID_FIXED_4,
4663 static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
4664 static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
4665 static int num_editor_hl_mirror_magic = ARRAY_SIZE(editor_hl_mirror_magic);
4666 static int num_editor_el_mirror_magic = ARRAY_SIZE(editor_el_mirror_magic);
4668 static int editor_hl_deflektor[] =
4670 EL_INTERNAL_CASCADE_DF_ACTIVE,
4676 static int editor_el_deflektor[] =
4683 EL_DF_RECEIVER_RIGHT,
4685 EL_DF_RECEIVER_LEFT,
4686 EL_DF_RECEIVER_DOWN,
4689 EL_DF_MIRROR_ROTATING_START,
4693 EL_DF_FIBRE_OPTIC_RED_1,
4694 EL_DF_FIBRE_OPTIC_YELLOW_1,
4695 EL_DF_FIBRE_OPTIC_GREEN_1,
4696 EL_DF_FIBRE_OPTIC_BLUE_1,
4698 EL_DF_STEEL_GRID_FIXED_START,
4699 EL_DF_STEEL_GRID_ROTATING_START,
4700 EL_DF_WOODEN_GRID_FIXED_START,
4701 EL_DF_WOODEN_GRID_ROTATING_START,
4708 static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
4709 static int *editor_el_deflektor_ptr = editor_el_deflektor;
4710 static int num_editor_hl_deflektor = ARRAY_SIZE(editor_hl_deflektor);
4711 static int num_editor_el_deflektor = ARRAY_SIZE(editor_el_deflektor);
4713 static int editor_hl_chars[] =
4715 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
4721 static int editor_el_chars[] =
4803 EL_CHAR(CHAR_BYTE_COPYRIGHT),
4804 EL_CHAR(CHAR_BYTE_UMLAUT_A),
4805 EL_CHAR(CHAR_BYTE_UMLAUT_O),
4806 EL_CHAR(CHAR_BYTE_UMLAUT_U),
4808 EL_CHAR(CHAR_BYTE_DEGREE),
4809 EL_CHAR(CHAR_BYTE_REGISTERED),
4810 EL_CHAR(FONT_ASCII_CURSOR),
4811 EL_CHAR(FONT_ASCII_BUTTON),
4813 EL_CHAR(FONT_ASCII_UP),
4814 EL_CHAR(FONT_ASCII_DOWN),
4818 static int *editor_hl_chars_ptr = editor_hl_chars;
4819 static int *editor_el_chars_ptr = editor_el_chars;
4820 static int num_editor_hl_chars = ARRAY_SIZE(editor_hl_chars);
4821 static int num_editor_el_chars = ARRAY_SIZE(editor_el_chars);
4823 static int editor_hl_steel_chars[] =
4825 EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
4831 static int editor_el_steel_chars[] =
4841 EL_STEEL_CHAR('\''),
4908 EL_STEEL_CHAR('\\'),
4913 EL_STEEL_CHAR(CHAR_BYTE_COPYRIGHT),
4914 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_A),
4915 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_O),
4916 EL_STEEL_CHAR(CHAR_BYTE_UMLAUT_U),
4918 EL_STEEL_CHAR(CHAR_BYTE_DEGREE),
4919 EL_STEEL_CHAR(CHAR_BYTE_REGISTERED),
4920 EL_STEEL_CHAR(FONT_ASCII_CURSOR),
4921 EL_STEEL_CHAR(FONT_ASCII_BUTTON),
4923 EL_STEEL_CHAR(FONT_ASCII_UP),
4924 EL_STEEL_CHAR(FONT_ASCII_DOWN),
4928 static int *editor_hl_steel_chars_ptr = editor_hl_steel_chars;
4929 static int *editor_el_steel_chars_ptr = editor_el_steel_chars;
4930 static int num_editor_hl_steel_chars = ARRAY_SIZE(editor_hl_steel_chars);
4931 static int num_editor_el_steel_chars = ARRAY_SIZE(editor_el_steel_chars);
4933 static int editor_hl_custom[] =
4935 EL_INTERNAL_CASCADE_CE_ACTIVE,
4941 static int editor_el_custom[] =
4943 EL_CUSTOM_START + 0,
4944 EL_CUSTOM_START + 1,
4945 EL_CUSTOM_START + 2,
4946 EL_CUSTOM_START + 3,
4948 EL_CUSTOM_START + 4,
4949 EL_CUSTOM_START + 5,
4950 EL_CUSTOM_START + 6,
4951 EL_CUSTOM_START + 7,
4953 EL_CUSTOM_START + 8,
4954 EL_CUSTOM_START + 9,
4955 EL_CUSTOM_START + 10,
4956 EL_CUSTOM_START + 11,
4958 EL_CUSTOM_START + 12,
4959 EL_CUSTOM_START + 13,
4960 EL_CUSTOM_START + 14,
4961 EL_CUSTOM_START + 15,
4963 EL_CUSTOM_START + 16,
4964 EL_CUSTOM_START + 17,
4965 EL_CUSTOM_START + 18,
4966 EL_CUSTOM_START + 19,
4968 EL_CUSTOM_START + 20,
4969 EL_CUSTOM_START + 21,
4970 EL_CUSTOM_START + 22,
4971 EL_CUSTOM_START + 23,
4973 EL_CUSTOM_START + 24,
4974 EL_CUSTOM_START + 25,
4975 EL_CUSTOM_START + 26,
4976 EL_CUSTOM_START + 27,
4978 EL_CUSTOM_START + 28,
4979 EL_CUSTOM_START + 29,
4980 EL_CUSTOM_START + 30,
4981 EL_CUSTOM_START + 31,
4983 EL_CUSTOM_START + 32,
4984 EL_CUSTOM_START + 33,
4985 EL_CUSTOM_START + 34,
4986 EL_CUSTOM_START + 35,
4988 EL_CUSTOM_START + 36,
4989 EL_CUSTOM_START + 37,
4990 EL_CUSTOM_START + 38,
4991 EL_CUSTOM_START + 39,
4993 EL_CUSTOM_START + 40,
4994 EL_CUSTOM_START + 41,
4995 EL_CUSTOM_START + 42,
4996 EL_CUSTOM_START + 43,
4998 EL_CUSTOM_START + 44,
4999 EL_CUSTOM_START + 45,
5000 EL_CUSTOM_START + 46,
5001 EL_CUSTOM_START + 47,
5003 EL_CUSTOM_START + 48,
5004 EL_CUSTOM_START + 49,
5005 EL_CUSTOM_START + 50,
5006 EL_CUSTOM_START + 51,
5008 EL_CUSTOM_START + 52,
5009 EL_CUSTOM_START + 53,
5010 EL_CUSTOM_START + 54,
5011 EL_CUSTOM_START + 55,
5013 EL_CUSTOM_START + 56,
5014 EL_CUSTOM_START + 57,
5015 EL_CUSTOM_START + 58,
5016 EL_CUSTOM_START + 59,
5018 EL_CUSTOM_START + 60,
5019 EL_CUSTOM_START + 61,
5020 EL_CUSTOM_START + 62,
5021 EL_CUSTOM_START + 63,
5023 EL_CUSTOM_START + 64,
5024 EL_CUSTOM_START + 65,
5025 EL_CUSTOM_START + 66,
5026 EL_CUSTOM_START + 67,
5028 EL_CUSTOM_START + 68,
5029 EL_CUSTOM_START + 69,
5030 EL_CUSTOM_START + 70,
5031 EL_CUSTOM_START + 71,
5033 EL_CUSTOM_START + 72,
5034 EL_CUSTOM_START + 73,
5035 EL_CUSTOM_START + 74,
5036 EL_CUSTOM_START + 75,
5038 EL_CUSTOM_START + 76,
5039 EL_CUSTOM_START + 77,
5040 EL_CUSTOM_START + 78,
5041 EL_CUSTOM_START + 79,
5043 EL_CUSTOM_START + 80,
5044 EL_CUSTOM_START + 81,
5045 EL_CUSTOM_START + 82,
5046 EL_CUSTOM_START + 83,
5048 EL_CUSTOM_START + 84,
5049 EL_CUSTOM_START + 85,
5050 EL_CUSTOM_START + 86,
5051 EL_CUSTOM_START + 87,
5053 EL_CUSTOM_START + 88,
5054 EL_CUSTOM_START + 89,
5055 EL_CUSTOM_START + 90,
5056 EL_CUSTOM_START + 91,
5058 EL_CUSTOM_START + 92,
5059 EL_CUSTOM_START + 93,
5060 EL_CUSTOM_START + 94,
5061 EL_CUSTOM_START + 95,
5063 EL_CUSTOM_START + 96,
5064 EL_CUSTOM_START + 97,
5065 EL_CUSTOM_START + 98,
5066 EL_CUSTOM_START + 99,
5068 EL_CUSTOM_START + 100,
5069 EL_CUSTOM_START + 101,
5070 EL_CUSTOM_START + 102,
5071 EL_CUSTOM_START + 103,
5073 EL_CUSTOM_START + 104,
5074 EL_CUSTOM_START + 105,
5075 EL_CUSTOM_START + 106,
5076 EL_CUSTOM_START + 107,
5078 EL_CUSTOM_START + 108,
5079 EL_CUSTOM_START + 109,
5080 EL_CUSTOM_START + 110,
5081 EL_CUSTOM_START + 111,
5083 EL_CUSTOM_START + 112,
5084 EL_CUSTOM_START + 113,
5085 EL_CUSTOM_START + 114,
5086 EL_CUSTOM_START + 115,
5088 EL_CUSTOM_START + 116,
5089 EL_CUSTOM_START + 117,
5090 EL_CUSTOM_START + 118,
5091 EL_CUSTOM_START + 119,
5093 EL_CUSTOM_START + 120,
5094 EL_CUSTOM_START + 121,
5095 EL_CUSTOM_START + 122,
5096 EL_CUSTOM_START + 123,
5098 EL_CUSTOM_START + 124,
5099 EL_CUSTOM_START + 125,
5100 EL_CUSTOM_START + 126,
5101 EL_CUSTOM_START + 127,
5103 EL_CUSTOM_START + 128,
5104 EL_CUSTOM_START + 129,
5105 EL_CUSTOM_START + 130,
5106 EL_CUSTOM_START + 131,
5108 EL_CUSTOM_START + 132,
5109 EL_CUSTOM_START + 133,
5110 EL_CUSTOM_START + 134,
5111 EL_CUSTOM_START + 135,
5113 EL_CUSTOM_START + 136,
5114 EL_CUSTOM_START + 137,
5115 EL_CUSTOM_START + 138,
5116 EL_CUSTOM_START + 139,
5118 EL_CUSTOM_START + 140,
5119 EL_CUSTOM_START + 141,
5120 EL_CUSTOM_START + 142,
5121 EL_CUSTOM_START + 143,
5123 EL_CUSTOM_START + 144,
5124 EL_CUSTOM_START + 145,
5125 EL_CUSTOM_START + 146,
5126 EL_CUSTOM_START + 147,
5128 EL_CUSTOM_START + 148,
5129 EL_CUSTOM_START + 149,
5130 EL_CUSTOM_START + 150,
5131 EL_CUSTOM_START + 151,
5133 EL_CUSTOM_START + 152,
5134 EL_CUSTOM_START + 153,
5135 EL_CUSTOM_START + 154,
5136 EL_CUSTOM_START + 155,
5138 EL_CUSTOM_START + 156,
5139 EL_CUSTOM_START + 157,
5140 EL_CUSTOM_START + 158,
5141 EL_CUSTOM_START + 159,
5143 EL_CUSTOM_START + 160,
5144 EL_CUSTOM_START + 161,
5145 EL_CUSTOM_START + 162,
5146 EL_CUSTOM_START + 163,
5148 EL_CUSTOM_START + 164,
5149 EL_CUSTOM_START + 165,
5150 EL_CUSTOM_START + 166,
5151 EL_CUSTOM_START + 167,
5153 EL_CUSTOM_START + 168,
5154 EL_CUSTOM_START + 169,
5155 EL_CUSTOM_START + 170,
5156 EL_CUSTOM_START + 171,
5158 EL_CUSTOM_START + 172,
5159 EL_CUSTOM_START + 173,
5160 EL_CUSTOM_START + 174,
5161 EL_CUSTOM_START + 175,
5163 EL_CUSTOM_START + 176,
5164 EL_CUSTOM_START + 177,
5165 EL_CUSTOM_START + 178,
5166 EL_CUSTOM_START + 179,
5168 EL_CUSTOM_START + 180,
5169 EL_CUSTOM_START + 181,
5170 EL_CUSTOM_START + 182,
5171 EL_CUSTOM_START + 183,
5173 EL_CUSTOM_START + 184,
5174 EL_CUSTOM_START + 185,
5175 EL_CUSTOM_START + 186,
5176 EL_CUSTOM_START + 187,
5178 EL_CUSTOM_START + 188,
5179 EL_CUSTOM_START + 189,
5180 EL_CUSTOM_START + 190,
5181 EL_CUSTOM_START + 191,
5183 EL_CUSTOM_START + 192,
5184 EL_CUSTOM_START + 193,
5185 EL_CUSTOM_START + 194,
5186 EL_CUSTOM_START + 195,
5188 EL_CUSTOM_START + 196,
5189 EL_CUSTOM_START + 197,
5190 EL_CUSTOM_START + 198,
5191 EL_CUSTOM_START + 199,
5193 EL_CUSTOM_START + 200,
5194 EL_CUSTOM_START + 201,
5195 EL_CUSTOM_START + 202,
5196 EL_CUSTOM_START + 203,
5198 EL_CUSTOM_START + 204,
5199 EL_CUSTOM_START + 205,
5200 EL_CUSTOM_START + 206,
5201 EL_CUSTOM_START + 207,
5203 EL_CUSTOM_START + 208,
5204 EL_CUSTOM_START + 209,
5205 EL_CUSTOM_START + 210,
5206 EL_CUSTOM_START + 211,
5208 EL_CUSTOM_START + 212,
5209 EL_CUSTOM_START + 213,
5210 EL_CUSTOM_START + 214,
5211 EL_CUSTOM_START + 215,
5213 EL_CUSTOM_START + 216,
5214 EL_CUSTOM_START + 217,
5215 EL_CUSTOM_START + 218,
5216 EL_CUSTOM_START + 219,
5218 EL_CUSTOM_START + 220,
5219 EL_CUSTOM_START + 221,
5220 EL_CUSTOM_START + 222,
5221 EL_CUSTOM_START + 223,
5223 EL_CUSTOM_START + 224,
5224 EL_CUSTOM_START + 225,
5225 EL_CUSTOM_START + 226,
5226 EL_CUSTOM_START + 227,
5228 EL_CUSTOM_START + 228,
5229 EL_CUSTOM_START + 229,
5230 EL_CUSTOM_START + 230,
5231 EL_CUSTOM_START + 231,
5233 EL_CUSTOM_START + 232,
5234 EL_CUSTOM_START + 233,
5235 EL_CUSTOM_START + 234,
5236 EL_CUSTOM_START + 235,
5238 EL_CUSTOM_START + 236,
5239 EL_CUSTOM_START + 237,
5240 EL_CUSTOM_START + 238,
5241 EL_CUSTOM_START + 239,
5243 EL_CUSTOM_START + 240,
5244 EL_CUSTOM_START + 241,
5245 EL_CUSTOM_START + 242,
5246 EL_CUSTOM_START + 243,
5248 EL_CUSTOM_START + 244,
5249 EL_CUSTOM_START + 245,
5250 EL_CUSTOM_START + 246,
5251 EL_CUSTOM_START + 247,
5253 EL_CUSTOM_START + 248,
5254 EL_CUSTOM_START + 249,
5255 EL_CUSTOM_START + 250,
5256 EL_CUSTOM_START + 251,
5258 EL_CUSTOM_START + 252,
5259 EL_CUSTOM_START + 253,
5260 EL_CUSTOM_START + 254,
5261 EL_CUSTOM_START + 255
5263 static int *editor_hl_custom_ptr = editor_hl_custom;
5264 static int *editor_el_custom_ptr = editor_el_custom;
5265 static int num_editor_hl_custom = ARRAY_SIZE(editor_hl_custom);
5266 static int num_editor_el_custom = ARRAY_SIZE(editor_el_custom);
5268 static int editor_hl_group[] =
5270 EL_INTERNAL_CASCADE_GE_ACTIVE,
5276 static int editor_el_group[] =
5290 EL_GROUP_START + 10,
5291 EL_GROUP_START + 11,
5293 EL_GROUP_START + 12,
5294 EL_GROUP_START + 13,
5295 EL_GROUP_START + 14,
5296 EL_GROUP_START + 15,
5298 EL_GROUP_START + 16,
5299 EL_GROUP_START + 17,
5300 EL_GROUP_START + 18,
5301 EL_GROUP_START + 19,
5303 EL_GROUP_START + 20,
5304 EL_GROUP_START + 21,
5305 EL_GROUP_START + 22,
5306 EL_GROUP_START + 23,
5308 EL_GROUP_START + 24,
5309 EL_GROUP_START + 25,
5310 EL_GROUP_START + 26,
5311 EL_GROUP_START + 27,
5313 EL_GROUP_START + 28,
5314 EL_GROUP_START + 29,
5315 EL_GROUP_START + 30,
5318 static int *editor_hl_group_ptr = editor_hl_group;
5319 static int *editor_el_group_ptr = editor_el_group;
5320 static int num_editor_hl_group = ARRAY_SIZE(editor_hl_group);
5321 static int num_editor_el_group = ARRAY_SIZE(editor_el_group);
5323 static int editor_hl_empty_space[] =
5325 EL_INTERNAL_CASCADE_ES_ACTIVE,
5331 static int editor_el_empty_space[] =
5353 static int *editor_hl_empty_space_ptr = editor_hl_empty_space;
5354 static int *editor_el_empty_space_ptr = editor_el_empty_space;
5355 static int num_editor_hl_empty_space = ARRAY_SIZE(editor_hl_empty_space);
5356 static int num_editor_el_empty_space = ARRAY_SIZE(editor_el_empty_space);
5358 static int editor_hl_reference[] =
5360 EL_INTERNAL_CASCADE_REF_ACTIVE,
5366 static int editor_el_reference[] =
5370 EL_TRIGGER_CE_VALUE,
5371 EL_TRIGGER_CE_SCORE,
5375 EL_CURRENT_CE_VALUE,
5376 EL_CURRENT_CE_SCORE,
5398 static int *editor_hl_reference_ptr = editor_hl_reference;
5399 static int *editor_el_reference_ptr = editor_el_reference;
5400 static int num_editor_hl_reference = ARRAY_SIZE(editor_hl_reference);
5401 static int num_editor_el_reference = ARRAY_SIZE(editor_el_reference);
5403 static int editor_hl_user_defined[] =
5405 EL_INTERNAL_CASCADE_USER_ACTIVE,
5411 static int *editor_hl_user_defined_ptr = editor_hl_user_defined;
5412 static int *editor_el_user_defined_ptr = NULL;
5413 static int num_editor_hl_user_defined = ARRAY_SIZE(editor_hl_user_defined);
5414 static int num_editor_el_user_defined = 0;
5416 static int editor_hl_dynamic[] =
5418 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
5424 static int *editor_hl_dynamic_ptr = editor_hl_dynamic;
5425 static int *editor_el_dynamic_ptr = NULL;
5426 static int num_editor_hl_dynamic = ARRAY_SIZE(editor_hl_dynamic);
5427 static int num_editor_el_dynamic = 0;
5429 static int editor_hl_empty[] = { EL_EMPTY };
5430 static int *editor_el_empty = NULL; // dynamically allocated
5432 static int *editor_hl_empty_ptr = editor_hl_empty;
5433 static int *editor_el_empty_ptr = NULL;
5434 static int num_editor_hl_empty = 0;
5435 static int num_editor_el_empty = 0; // dynamically determined, if needed
5437 static boolean use_el_empty = FALSE;
5439 static int *editor_elements = NULL; // dynamically allocated
5440 static int num_editor_elements = 0; // dynamically determined
5442 static boolean setup_editor_cascade_never = FALSE;
5444 static boolean setup_editor_el_players = TRUE;
5445 static boolean setup_editor_el_boulderdash = TRUE;
5446 static boolean setup_editor_el_emerald_mine = TRUE;
5447 static boolean setup_editor_el_emerald_mine_club = TRUE;
5448 static boolean setup_editor_el_more = TRUE;
5449 static boolean setup_editor_el_sokoban = TRUE;
5450 static boolean setup_editor_el_supaplex = TRUE;
5451 static boolean setup_editor_el_diamond_caves = TRUE;
5452 static boolean setup_editor_el_dx_boulderdash = TRUE;
5453 static boolean setup_editor_el_mirror_magic = TRUE;
5454 static boolean setup_editor_el_deflektor = TRUE;
5455 static boolean setup_editor_el_chars = TRUE;
5456 static boolean setup_editor_el_steel_chars = TRUE;
5457 static boolean setup_editor_el_custom = TRUE;
5458 static boolean setup_editor_el_user_defined = TRUE;
5459 static boolean setup_editor_el_dynamic = TRUE;
5461 static int editor_hl_unused[] = { EL_EMPTY };
5462 static int *editor_hl_unused_ptr = editor_hl_unused;
5463 static int num_editor_hl_unused = 0;
5467 boolean *setup_value;
5468 boolean *setup_cascade_value;
5470 int **headline_list;
5471 int *headline_list_size;
5474 int *element_list_size;
5476 boolean last_setup_value;
5478 editor_elements_info[] =
5481 &setup_editor_el_players,
5482 &setup_editor_cascade_never,
5483 &editor_hl_unused_ptr, &num_editor_hl_unused,
5484 &editor_el_players_ptr, &num_editor_el_players
5487 &setup_editor_el_boulderdash,
5488 &setup.editor_cascade.el_bd,
5489 &editor_hl_boulderdash_ptr, &num_editor_hl_boulderdash,
5490 &editor_el_boulderdash_ptr, &num_editor_el_boulderdash
5493 &setup_editor_el_emerald_mine,
5494 &setup.editor_cascade.el_em,
5495 &editor_hl_emerald_mine_ptr, &num_editor_hl_emerald_mine,
5496 &editor_el_emerald_mine_ptr, &num_editor_el_emerald_mine
5499 &setup_editor_el_emerald_mine_club,
5500 &setup.editor_cascade.el_emc,
5501 &editor_hl_emerald_mine_club_ptr, &num_editor_hl_emerald_mine_club,
5502 &editor_el_emerald_mine_club_ptr, &num_editor_el_emerald_mine_club
5505 &setup_editor_el_more,
5506 &setup.editor_cascade.el_rnd,
5507 &editor_hl_rnd_ptr, &num_editor_hl_rnd,
5508 &editor_el_rnd_ptr, &num_editor_el_rnd
5511 &setup_editor_el_sokoban,
5512 &setup.editor_cascade.el_sb,
5513 &editor_hl_sokoban_ptr, &num_editor_hl_sokoban,
5514 &editor_el_sokoban_ptr, &num_editor_el_sokoban
5517 &setup_editor_el_supaplex,
5518 &setup.editor_cascade.el_sp,
5519 &editor_hl_supaplex_ptr, &num_editor_hl_supaplex,
5520 &editor_el_supaplex_ptr, &num_editor_el_supaplex
5523 &setup_editor_el_diamond_caves,
5524 &setup.editor_cascade.el_dc,
5525 &editor_hl_diamond_caves_ptr, &num_editor_hl_diamond_caves,
5526 &editor_el_diamond_caves_ptr, &num_editor_el_diamond_caves
5529 &setup_editor_el_dx_boulderdash,
5530 &setup.editor_cascade.el_dx,
5531 &editor_hl_dx_boulderdash_ptr, &num_editor_hl_dx_boulderdash,
5532 &editor_el_dx_boulderdash_ptr, &num_editor_el_dx_boulderdash
5535 &setup_editor_el_mirror_magic,
5536 &setup.editor_cascade.el_mm,
5537 &editor_hl_mirror_magic_ptr, &num_editor_hl_mirror_magic,
5538 &editor_el_mirror_magic_ptr, &num_editor_el_mirror_magic
5541 &setup_editor_el_deflektor,
5542 &setup.editor_cascade.el_df,
5543 &editor_hl_deflektor_ptr, &num_editor_hl_deflektor,
5544 &editor_el_deflektor_ptr, &num_editor_el_deflektor
5547 &setup_editor_el_chars,
5548 &setup.editor_cascade.el_chars,
5549 &editor_hl_chars_ptr, &num_editor_hl_chars,
5550 &editor_el_chars_ptr, &num_editor_el_chars
5553 &setup_editor_el_steel_chars,
5554 &setup.editor_cascade.el_steel_chars,
5555 &editor_hl_steel_chars_ptr, &num_editor_hl_steel_chars,
5556 &editor_el_steel_chars_ptr, &num_editor_el_steel_chars
5559 &setup_editor_el_custom,
5560 &setup.editor_cascade.el_ce,
5561 &editor_hl_custom_ptr, &num_editor_hl_custom,
5562 &editor_el_custom_ptr, &num_editor_el_custom
5565 &setup_editor_el_custom,
5566 &setup.editor_cascade.el_ge,
5567 &editor_hl_group_ptr, &num_editor_hl_group,
5568 &editor_el_group_ptr, &num_editor_el_group
5571 &setup_editor_el_custom,
5572 &setup.editor_cascade.el_es,
5573 &editor_hl_empty_space_ptr, &num_editor_hl_empty_space,
5574 &editor_el_empty_space_ptr, &num_editor_el_empty_space
5577 &setup_editor_el_custom,
5578 &setup.editor_cascade.el_ref,
5579 &editor_hl_reference_ptr, &num_editor_hl_reference,
5580 &editor_el_reference_ptr, &num_editor_el_reference
5583 &setup_editor_el_user_defined,
5584 &setup.editor_cascade.el_user,
5585 &editor_hl_user_defined_ptr, &num_editor_hl_user_defined,
5586 &editor_el_user_defined_ptr, &num_editor_el_user_defined
5589 &setup_editor_el_dynamic,
5590 &setup.editor_cascade.el_dynamic,
5591 &editor_hl_dynamic_ptr, &num_editor_hl_dynamic,
5592 &editor_el_dynamic_ptr, &num_editor_el_dynamic,
5597 &editor_hl_empty_ptr, &num_editor_hl_empty,
5598 &editor_el_empty_ptr, &num_editor_el_empty,
5608 static struct XY xy_directions[] =
5617 // ----------------------------------------------------------------------------
5619 // ----------------------------------------------------------------------------
5621 static int getMaxInfoTextLength(void)
5623 return (SXSIZE / getFontWidth(INFOTEXT_FONT));
5626 static int getTextWidthForGadget(char *text)
5631 return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE);
5634 static int getTextWidthForDrawingArea(char *text)
5639 return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE);
5642 static int getRightGadgetBorder(struct GadgetInfo *gi, char *text)
5644 return (gi->x + gi->width + getTextWidthForGadget(text));
5647 static char *getElementInfoText(int element)
5649 char *info_text = NULL;
5651 if (element < MAX_NUM_ELEMENTS)
5653 if (strlen(element_info[element].description) > 0)
5654 info_text = element_info[element].description;
5655 else if (element_info[element].custom_description != NULL)
5656 info_text = element_info[element].custom_description;
5657 else if (element_info[element].editor_description != NULL)
5658 info_text = element_info[element].editor_description;
5661 if (info_text == NULL)
5662 info_text = INFOTEXT_UNKNOWN_ELEMENT;
5667 static char *getElementDescriptionFilenameExt(char *basename)
5669 char *elements_subdir = ELEMENTS_DIRECTORY;
5670 static char *elements_subdir2 = NULL;
5671 static char *filename = NULL;
5673 if (elements_subdir2 == NULL)
5674 elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir);
5676 checked_free(filename);
5678 // 1st try: look for element description in current level set directory
5679 filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename);
5680 if (fileExists(filename))
5685 // 2nd try: look for element description in the game's base directory
5686 filename = getPath3(options.docs_directory, elements_subdir, basename);
5687 if (fileExists(filename))
5693 static char *getElementDescriptionFilename(int element)
5695 char basename[MAX_FILENAME_LEN];
5698 // 1st try: look for element description file for exactly this element
5699 sprintf(basename, "%s.txt", element_info[element].token_name);
5700 filename = getElementDescriptionFilenameExt(basename);
5701 if (filename != NULL)
5704 // 2nd try: look for element description file for this element's class
5705 sprintf(basename, "%s.txt", element_info[element].class_name);
5706 filename = getElementDescriptionFilenameExt(basename);
5707 if (filename != NULL)
5710 // 3rd try: look for generic fallback text file for any element
5711 filename = getElementDescriptionFilenameExt(FALLBACK_TEXT_FILENAME);
5712 if (filename != NULL)
5718 static boolean suppressBorderElement(void)
5720 return (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
5721 lev_fieldx <= MAX_ED_FIELDX &&
5722 lev_fieldy <= MAX_ED_FIELDY);
5725 static void InitDynamicEditorElementList(int **elements, int *num_elements)
5727 boolean element_found[NUM_FILE_ELEMENTS];
5730 // initialize list of used elements to "not used"
5731 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5732 element_found[i] = FALSE;
5734 // find all elements used in current level
5735 for (y = 0; y < lev_fieldy; y++)
5736 for (x = 0; x < lev_fieldx; x++)
5737 if (Tile[x][y] < NUM_FILE_ELEMENTS) // should always be true
5738 element_found[Tile[x][y]] = TRUE;
5742 // count number of elements used in current level
5743 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5744 if (element_found[i])
5747 // add space for up to 3 more elements for padding that may be needed
5750 // free memory for old list of elements, if needed
5751 checked_free(*elements);
5753 // allocate memory for new list of elements
5754 *elements = checked_malloc(*num_elements * sizeof(int));
5758 // add all elements used in current level (non-custom/group elements)
5759 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5760 if (element_found[i] && !(IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5761 (*elements)[(*num_elements)++] = i;
5763 // add all elements used in current level (custom/group elements)
5764 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
5765 if (element_found[i] && (IS_CUSTOM_ELEMENT(i) || IS_GROUP_ELEMENT(i)))
5766 (*elements)[(*num_elements)++] = i;
5768 while (*num_elements % 4) // pad with empty elements, if needed
5769 (*elements)[(*num_elements)++] = EL_EMPTY;
5772 static void ReinitializeElementList_EnableSections(void)
5774 // default: enable all element sections
5776 setup_editor_el_players = TRUE;
5777 setup_editor_el_boulderdash = TRUE;
5778 setup_editor_el_emerald_mine = TRUE;
5779 setup_editor_el_emerald_mine_club = TRUE;
5780 setup_editor_el_more = TRUE;
5781 setup_editor_el_sokoban = TRUE;
5782 setup_editor_el_supaplex = TRUE;
5783 setup_editor_el_diamond_caves = TRUE;
5784 setup_editor_el_dx_boulderdash = TRUE;
5785 setup_editor_el_mirror_magic = TRUE;
5786 setup_editor_el_deflektor = TRUE;
5787 setup_editor_el_chars = TRUE;
5788 setup_editor_el_steel_chars = TRUE;
5790 setup_editor_el_custom = TRUE;
5791 setup_editor_el_user_defined = TRUE;
5792 setup_editor_el_dynamic = TRUE;
5794 // now disable all element sections not to be displayed
5796 if (!setup.editor.el_classic)
5798 setup_editor_el_players = FALSE;
5799 setup_editor_el_boulderdash = FALSE;
5800 setup_editor_el_emerald_mine = FALSE;
5801 setup_editor_el_emerald_mine_club = FALSE;
5802 setup_editor_el_more = FALSE;
5803 setup_editor_el_sokoban = FALSE;
5804 setup_editor_el_supaplex = FALSE;
5805 setup_editor_el_diamond_caves = FALSE;
5806 setup_editor_el_dx_boulderdash = FALSE;
5807 setup_editor_el_mirror_magic = FALSE;
5808 setup_editor_el_deflektor = FALSE;
5809 setup_editor_el_chars = FALSE;
5810 setup_editor_el_steel_chars = FALSE;
5813 if (!setup.editor.el_custom)
5815 setup_editor_el_custom = FALSE;
5818 if (!setup.editor.el_user_defined)
5820 setup_editor_el_user_defined = FALSE;
5823 if (!setup.editor.el_dynamic)
5825 setup_editor_el_dynamic = FALSE;
5828 if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
5830 setup_editor_el_mirror_magic = FALSE;
5831 setup_editor_el_deflektor = FALSE;
5833 else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
5835 setup_editor_el_boulderdash = FALSE;
5836 setup_editor_el_more = FALSE;
5837 setup_editor_el_sokoban = FALSE;
5838 setup_editor_el_supaplex = FALSE;
5839 setup_editor_el_diamond_caves = FALSE;
5840 setup_editor_el_dx_boulderdash = FALSE;
5841 setup_editor_el_mirror_magic = FALSE;
5842 setup_editor_el_deflektor = FALSE;
5843 setup_editor_el_steel_chars = FALSE;
5845 setup_editor_el_custom = FALSE;
5847 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
5849 setup_editor_el_players = FALSE;
5850 setup_editor_el_boulderdash = FALSE;
5851 setup_editor_el_emerald_mine = FALSE;
5852 setup_editor_el_emerald_mine_club = FALSE;
5853 setup_editor_el_more = FALSE;
5854 setup_editor_el_sokoban = FALSE;
5855 setup_editor_el_diamond_caves = FALSE;
5856 setup_editor_el_dx_boulderdash = FALSE;
5857 setup_editor_el_mirror_magic = FALSE;
5858 setup_editor_el_deflektor = FALSE;
5859 setup_editor_el_chars = FALSE;
5860 setup_editor_el_steel_chars = FALSE;
5862 setup_editor_el_custom = FALSE;
5864 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
5866 setup_editor_el_players = FALSE;
5867 setup_editor_el_boulderdash = FALSE;
5868 setup_editor_el_emerald_mine = FALSE;
5869 setup_editor_el_emerald_mine_club = FALSE;
5870 setup_editor_el_more = FALSE;
5871 setup_editor_el_sokoban = FALSE;
5872 setup_editor_el_supaplex = FALSE;
5873 setup_editor_el_diamond_caves = FALSE;
5874 setup_editor_el_dx_boulderdash = FALSE;
5875 setup_editor_el_steel_chars = FALSE;
5877 setup_editor_el_custom = FALSE;
5881 static void ReinitializeElementList(void)
5883 static boolean initialization_needed = TRUE;
5887 ReinitializeElementList_EnableSections();
5889 if (initialization_needed)
5891 LoadSetup_EditorCascade(); // load last editor cascade state
5893 // initialize editor cascade element from saved cascade state
5894 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5896 int *cascade_element = &(*editor_elements_info[i].headline_list)[0];
5897 boolean cascade_value = *editor_elements_info[i].setup_cascade_value;
5899 if (IS_EDITOR_CASCADE(*cascade_element))
5901 (cascade_value ? EL_CASCADE_ACTIVE(*cascade_element) :
5902 EL_CASCADE_INACTIVE(*cascade_element));
5905 initialization_needed = FALSE;
5908 checked_free(editor_elements);
5910 // reload optional user defined element list for each invocation of editor
5911 LoadUserDefinedEditorElementList(&editor_el_user_defined_ptr,
5912 &num_editor_el_user_defined);
5914 // initialize dynamic level element list for each invocation of editor
5915 InitDynamicEditorElementList(&editor_el_dynamic_ptr,
5916 &num_editor_el_dynamic);
5918 // initialize list of empty elements (used for padding, if needed)
5919 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
5920 editor_el_empty[i] = EL_EMPTY;
5922 // do some sanity checks for each element from element list
5923 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5925 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
5927 int element = (*editor_elements_info[i].element_list)[j];
5929 if (element >= NUM_FILE_ELEMENTS)
5930 Warn("editor element %d is runtime element", element);
5932 if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
5933 Warn("no element description text for element %d", element);
5937 num_editor_elements = 0;
5938 use_el_empty = FALSE;
5940 // determine size of element list
5941 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5943 if (*editor_elements_info[i].setup_value)
5945 boolean found_inactive_cascade = FALSE;
5947 if (setup.editor.el_headlines)
5949 // required for correct padding of palette headline buttons
5950 if (*editor_elements_info[i].headline_list_size > 0)
5951 num_editor_elements += ED_ELEMENTLIST_COLS;
5953 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
5955 int element = (*editor_elements_info[i].headline_list)[j];
5957 if (IS_EDITOR_CASCADE_INACTIVE(element))
5958 found_inactive_cascade = TRUE;
5962 if (found_inactive_cascade)
5965 // required for correct padding of palette element buttons
5966 int element_list_size = *editor_elements_info[i].element_list_size;
5968 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
5969 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
5971 num_editor_elements += element_buttons;
5975 if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
5977 // offer at least as many elements as element buttons exist
5978 use_el_empty = TRUE;
5979 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS - num_editor_elements;
5981 num_editor_elements += num_editor_el_empty;
5985 num_editor_el_empty = 0;
5988 editor_elements = checked_malloc(num_editor_elements * sizeof(int));
5990 // fill element list
5991 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
5993 boolean found_inactive_cascade = FALSE;
5995 if (*editor_elements_info[i].setup_value)
5997 if (setup.editor.el_headlines)
5999 // required for correct padding of palette headline buttons
6000 int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
6001 ED_ELEMENTLIST_COLS : 0);
6003 for (j = 0; j < headline_size; j++)
6005 // use empty elements for padding of palette headline buttons
6006 int element = (j < *editor_elements_info[i].headline_list_size ?
6007 (*editor_elements_info[i].headline_list)[j] :
6008 editor_el_empty[0]);
6010 editor_elements[pos++] = element;
6012 if (IS_EDITOR_CASCADE_INACTIVE(element))
6013 found_inactive_cascade = TRUE;
6017 if (found_inactive_cascade)
6020 // required for correct padding of palette element buttons
6021 int element_list_size = *editor_elements_info[i].element_list_size;
6023 (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
6024 int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
6026 // copy all elements from element list
6027 for (j = 0; j < element_list_size; j++)
6028 editor_elements[pos++] = (*editor_elements_info[i].element_list)[j];
6030 // use empty elements for padding of palette element buttons
6031 for (j = 0; j < element_buttons - element_list_size; j++)
6032 editor_elements[pos++] = editor_el_empty[0];
6036 // (this function is also called before editor gadgets are initialized!)
6037 AdjustElementListScrollbar();
6040 void PrintEditorElementList(void)
6042 boolean *stop = &setup_editor_el_user_defined;
6045 for (i = 0; editor_elements_info[i].setup_value != stop; i++)
6047 int cascade_element = (*editor_elements_info[i].headline_list)[0];
6049 if (IS_EDITOR_CASCADE(cascade_element))
6051 int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element);
6052 char *headline = element_info[cascade_element_show].editor_description;
6054 PrintLineWithPrefix("# ", "-", 77);
6055 Print("# %s\n", headline);
6056 PrintLineWithPrefix("# ", "-", 77);
6059 for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
6061 int element = (*editor_elements_info[i].headline_list)[j];
6063 if (IS_EDITOR_CASCADE(element))
6064 element = EL_CHAR_MINUS;
6066 Print("# %s\n", element_info[element].token_name);
6072 for (j = 0; j < *editor_elements_info[i].element_list_size; j++)
6074 int element = (*editor_elements_info[i].element_list)[j];
6076 Print("# %s\n", element_info[element].token_name);
6084 static void ReinitializeElementListButtons(void)
6086 static boolean last_setup_value_headlines = FALSE;
6087 static boolean initialization_needed = TRUE;
6090 if (!initialization_needed) // check if editor element setup has changed
6092 if (last_setup_value_headlines != setup.editor.el_headlines)
6093 initialization_needed = TRUE;
6095 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6096 if (editor_elements_info[i].last_setup_value !=
6097 *editor_elements_info[i].setup_value)
6098 initialization_needed = TRUE;
6101 if (!initialization_needed)
6104 FreeLevelEditorGadgets();
6105 CreateLevelEditorGadgets();
6107 // store current setup values for next invocation of this function
6108 last_setup_value_headlines = setup.editor.el_headlines;
6109 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
6110 editor_elements_info[i].last_setup_value =
6111 *editor_elements_info[i].setup_value;
6113 initialization_needed = FALSE;
6116 static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
6119 int border_graphic =
6120 (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
6121 struct GraphicInfo *g = &graphic_info[border_graphic];
6122 Bitmap *src_bitmap = g->bitmap;
6123 int src_x = g->src_x;
6124 int src_y = g->src_y;
6125 int border_size = g->border_size;
6126 int border_xpos = g->width - border_size;
6127 int border_ypos = g->height - border_size;
6128 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6131 BlitBitmap(src_bitmap, drawto, src_x, src_y,
6132 border_size, border_size,
6133 dest_x - border_size, dest_y - border_size);
6134 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y,
6135 border_size, border_size,
6136 dest_x + width, dest_y - border_size);
6137 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_ypos,
6138 border_size, border_size,
6139 dest_x - border_size, dest_y + height);
6140 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_ypos,
6141 border_size, border_size,
6142 dest_x + width, dest_y + height);
6144 for (i = 0; i < width / tilesize; i++)
6146 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y,
6147 tilesize, border_size,
6148 dest_x + i * tilesize, dest_y - border_size);
6149 BlitBitmap(src_bitmap, drawto, src_x + border_size, src_y + border_ypos,
6150 tilesize, border_size,
6151 dest_x + i * tilesize, dest_y + height);
6154 for (i = 0; i < height / tilesize; i++)
6156 BlitBitmap(src_bitmap, drawto, src_x, src_y + border_size,
6157 border_size, tilesize,
6158 dest_x - border_size, dest_y + i * tilesize);
6159 BlitBitmap(src_bitmap, drawto, src_x + border_xpos, src_y + border_size,
6160 border_size, tilesize,
6161 dest_x + width, dest_y + i * tilesize);
6164 ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
6167 static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize)
6169 int xsize_tile = MAX(ed_tilesize, xsize);
6170 int ysize_tile = MAX(ed_tilesize, ysize);
6171 int xsize_full = xsize + 1;
6172 int ysize_full = ysize + 1;
6173 int xsize_thin = (xsize < ed_tilesize ? 1 : xsize);
6174 int ysize_thin = (ysize < ed_tilesize ? 1 : ysize);
6175 Pixel line_color = getTabulatorBarColor();
6177 if (line_color == BLACK_PIXEL) // black => transparent
6180 FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL);
6181 FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color);
6182 FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL);
6185 static void DrawEditorLevelBorderLinesIfNeeded(void)
6187 int xsize = lev_fieldx * ed_tilesize;
6188 int ysize = lev_fieldy * ed_tilesize;
6189 int line_size = getTabulatorBarHeight();
6191 if (!suppressBorderElement())
6194 // draw little border line around editable level playfield
6197 DrawEditorLevelBorderLine(xsize, 0, line_size, ysize);
6200 DrawEditorLevelBorderLine(0, ysize, xsize, line_size);
6202 if (xsize < SXSIZE && ysize < SYSIZE)
6203 DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size);
6206 static void DrawEditorElement(int x, int y, int element)
6208 DrawSizedElement(x, y, element, ed_tilesize);
6211 static void DrawEditorElementThruMask(int x, int y, int element)
6213 DrawSizedElementThruMask(x, y, element, ed_tilesize);
6216 static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
6218 DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
6221 static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
6223 DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
6224 DrawEditorLevelBorderLinesIfNeeded();
6227 static void DrawDrawingArea(int id)
6229 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
6232 int *value = drawingarea_info[id].value;
6233 int area_xsize = drawingarea_info[id].area_xsize;
6234 int area_ysize = drawingarea_info[id].area_ysize;
6235 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
6237 for (x = 0; x < area_xsize; x++)
6238 for (y = 0; y < area_ysize; y++)
6239 DrawSizedGraphicExt(drawto,
6240 gi->x + x * tilesize,
6241 gi->y + y * tilesize,
6242 el2edimg(value[x * area_ysize + y]), 0, tilesize);
6245 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
6248 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
6249 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
6251 BlitBitmap(drawto, drawto,
6252 SX + (dx == -1 ? ed_tilesize : 0),
6253 SY + (dy == -1 ? ed_tilesize : 0),
6254 (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
6255 (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
6256 SX + (dx == +1 ? ed_tilesize : 0),
6257 SY + (dy == +1 ? ed_tilesize : 0));
6261 x = (dx == 1 ? 0 : ed_fieldx - 1);
6262 for (y = 0; y < ed_fieldy; y++)
6263 DrawEditorElementOrWall(x, y, from_x, from_y);
6267 y = (dy == 1 ? 0 : ed_fieldy - 1);
6268 for (x = 0; x < ed_fieldx; x++)
6269 DrawEditorElementOrWall(x, y, from_x, from_y);
6272 redraw_mask |= REDRAW_FIELD;
6276 static void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap,
6279 getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y);
6282 static void CreateControlButtons(void)
6284 struct GadgetInfo *gi;
6287 // create toolbox buttons
6288 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
6290 int id = controlbutton_info[i].gadget_id;
6291 int type = controlbutton_info[i].gadget_type;
6292 int graphic = controlbutton_info[i].graphic;
6293 struct XYTileSize *pos = controlbutton_info[i].pos;
6294 struct GraphicInfo *gd = &graphic_info[graphic];
6295 Bitmap *deco_bitmap = NULL;
6296 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6297 int tile_size = 0, deco_shift = 0;
6298 boolean deco_masked = FALSE;
6299 int gd_x1 = gd->src_x;
6300 int gd_y1 = gd->src_y;
6301 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6302 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6303 int gd_x1a = gd->src_x + gd->active_xoffset;
6304 int gd_y1a = gd->src_y + gd->active_yoffset;
6305 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
6306 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
6309 unsigned int event_mask;
6310 int radio_button_nr = RADIO_NR_NONE;
6311 boolean checked = FALSE;
6313 if (type == GD_TYPE_RADIO_BUTTON)
6315 event_mask = GD_EVENT_PRESSED;
6316 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
6318 if (id == drawing_function)
6323 if (id == GADGET_ID_WRAP_LEFT ||
6324 id == GADGET_ID_WRAP_RIGHT ||
6325 id == GADGET_ID_WRAP_UP ||
6326 id == GADGET_ID_WRAP_DOWN)
6327 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6329 event_mask = GD_EVENT_RELEASED;
6332 if (id == GADGET_ID_PROPERTIES ||
6333 id == GADGET_ID_PALETTE)
6338 else if (id == GADGET_ID_ELEMENT_LEFT ||
6339 id == GADGET_ID_ELEMENT_MIDDLE ||
6340 id == GADGET_ID_ELEMENT_RIGHT)
6345 int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
6346 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
6347 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY);
6349 tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ?
6350 editor.button.element_left.tile_size :
6351 id == GADGET_ID_ELEMENT_MIDDLE ?
6352 editor.button.element_middle.tile_size :
6353 id == GADGET_ID_ELEMENT_RIGHT ?
6354 editor.button.element_right.tile_size : 0);
6356 // make sure that decoration does not overlap gadget border
6357 tile_size = MIN(tile_size, MIN(gd->width, gd->height));
6359 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y);
6361 deco_xpos = (gd->width - tile_size) / 2;
6362 deco_ypos = (gd->height - tile_size) / 2;
6364 deco_masked = gd->draw_masked;
6372 gi = CreateGadget(GDI_CUSTOM_ID, id,
6373 GDI_CUSTOM_TYPE_ID, i,
6374 GDI_IMAGE_ID, graphic,
6375 GDI_INFO_TEXT, controlbutton_info[i].infotext,
6378 GDI_WIDTH, gd->width,
6379 GDI_HEIGHT, gd->height,
6381 GDI_STATE, GD_BUTTON_UNPRESSED,
6382 GDI_RADIO_NR, radio_button_nr,
6383 GDI_CHECKED, checked,
6384 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6385 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6386 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6387 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
6388 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6389 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6390 GDI_DECORATION_SIZE, tile_size, tile_size,
6391 GDI_DECORATION_SHIFTING, deco_shift, deco_shift,
6392 GDI_DECORATION_MASKED, deco_masked,
6393 GDI_EVENT_MASK, event_mask,
6394 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6395 GDI_CALLBACK_ACTION, HandleControlButtons,
6399 Fail("cannot create gadget");
6401 level_editor_gadget[id] = gi;
6404 // these values are not constant, but can change at runtime
6405 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS;
6406 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS;
6407 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS;
6408 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS;
6409 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS;
6410 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS;
6411 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
6412 scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
6413 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].x = ED_SCROLL2_UP_XPOS;
6414 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_UP].y = ED_SCROLL2_UP_YPOS;
6415 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].x = ED_SCROLL2_DOWN_XPOS;
6416 scrollbutton_pos[ED_SCROLLBUTTON_ID_LIST_DOWN].y = ED_SCROLL2_DOWN_YPOS;
6418 // create buttons for scrolling of drawing area and element list
6419 for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
6421 int id = scrollbutton_info[i].gadget_id;
6422 int graphic = scrollbutton_info[i].graphic;
6423 struct GraphicInfo *gd = &graphic_info[graphic];
6424 Bitmap *gd_bitmap = gd->bitmap;
6425 int gd_x1 = gd->src_x;
6426 int gd_y1 = gd->src_y;
6427 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6428 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6429 int width = gd->width;
6430 int height = gd->height;
6431 int x = scrollbutton_pos[i].x;
6432 int y = scrollbutton_pos[i].y;
6433 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6435 if (id == GADGET_ID_SCROLL_LIST_UP ||
6436 id == GADGET_ID_SCROLL_LIST_DOWN)
6447 gi = CreateGadget(GDI_CUSTOM_ID, id,
6448 GDI_CUSTOM_TYPE_ID, i,
6449 GDI_IMAGE_ID, graphic,
6450 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6455 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6456 GDI_STATE, GD_BUTTON_UNPRESSED,
6457 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6458 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6459 GDI_EVENT_MASK, event_mask,
6460 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6461 GDI_CALLBACK_ACTION, HandleControlButtons,
6465 Fail("cannot create gadget");
6467 level_editor_gadget[id] = gi;
6470 // create buttons for element list
6471 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
6473 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
6474 int graphic = IMG_EDITOR_PALETTE_BUTTON;
6475 struct GraphicInfo *gd = &graphic_info[graphic];
6476 Bitmap *gd_bitmap = gd->bitmap;
6477 Bitmap *deco_bitmap;
6478 int deco_x, deco_y, deco_xpos, deco_ypos;
6479 int gd_x1 = gd->src_x;
6480 int gd_y1 = gd->src_y;
6481 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6482 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6483 int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
6484 int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
6485 int x = PX + ED_ELEMENTLIST_XPOS + xx * gd->width;
6486 int y = PY + ED_ELEMENTLIST_YPOS + yy * gd->height;
6487 int element = editor_elements[i];
6488 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
6489 unsigned int event_mask = GD_EVENT_RELEASED;
6491 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
6493 deco_xpos = (gd->width - tile_size) / 2;
6494 deco_ypos = (gd->height - tile_size) / 2;
6496 gi = CreateGadget(GDI_CUSTOM_ID, id,
6497 GDI_CUSTOM_TYPE_ID, i,
6498 GDI_IMAGE_ID, graphic,
6499 GDI_INFO_TEXT, getElementInfoText(element),
6502 GDI_WIDTH, gd->width,
6503 GDI_HEIGHT, gd->height,
6504 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6505 GDI_STATE, GD_BUTTON_UNPRESSED,
6506 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
6507 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
6508 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6509 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6510 GDI_DECORATION_SIZE, tile_size, tile_size,
6511 GDI_DECORATION_SHIFTING, 1, 1,
6512 GDI_EVENT_MASK, event_mask,
6513 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6514 GDI_CALLBACK_ACTION, HandleControlButtons,
6518 Fail("cannot create gadget");
6520 level_editor_gadget[id] = gi;
6524 static void CreateCounterButtons(void)
6526 int max_infotext_len = getMaxInfoTextLength();
6529 for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
6532 int x = SX + ED_SETTINGS_X(counterbutton_info[i].x); // down count button
6533 int y = SY + ED_SETTINGS_Y(counterbutton_info[i].y);
6535 // determine horizontal position to the right of specified gadget
6536 if (counterbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6537 x = (right_gadget_border[counterbutton_info[i].gadget_id_align] +
6538 ED_GADGET_TEXT_DISTANCE);
6540 // determine horizontal offset for leading text
6541 if (counterbutton_info[i].text_left != NULL)
6542 x += getTextWidthForGadget(counterbutton_info[i].text_left);
6544 for (j = 0; j < 2; j++)
6546 struct GadgetInfo *gi;
6548 counterbutton_info[i].gadget_id_down :
6549 counterbutton_info[i].gadget_id_up);
6551 struct GraphicInfo *gd;
6552 int gd_x1, gd_x2, gd_y1, gd_y2;
6553 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6554 char infotext[max_infotext_len + 1];
6556 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6559 IMG_GFX_EDITOR_BUTTON_PREV_LEVEL :
6560 IMG_GFX_EDITOR_BUTTON_NEXT_LEVEL);
6562 event_mask |= GD_EVENT_RELEASED;
6566 x = DX + editor.button.prev_level.x;
6567 y = DY + editor.button.prev_level.y;
6571 x = DX + editor.button.next_level.x;
6572 y = DY + editor.button.next_level.y;
6578 IMG_EDITOR_COUNTER_DOWN :
6579 IMG_EDITOR_COUNTER_UP);
6582 gd = &graphic_info[graphic];
6586 gd_x2 = gd->src_x + gd->pressed_xoffset;
6587 gd_y2 = gd->src_y + gd->pressed_yoffset;
6589 sprintf(infotext, "%s counter value by 1, 5 or 10",
6590 (j == 0 ? "decrease" : "increase"));
6592 gi = CreateGadget(GDI_CUSTOM_ID, id,
6593 GDI_CUSTOM_TYPE_ID, i,
6594 GDI_IMAGE_ID, graphic,
6595 GDI_INFO_TEXT, infotext,
6598 GDI_WIDTH, gd->width,
6599 GDI_HEIGHT, gd->height,
6600 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6601 GDI_STATE, GD_BUTTON_UNPRESSED,
6602 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6603 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6604 GDI_EVENT_MASK, event_mask,
6605 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6606 GDI_CALLBACK_ACTION, HandleCounterButtons,
6610 Fail("cannot create gadget");
6612 level_editor_gadget[id] = gi;
6613 right_gadget_border[id] =
6614 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6616 x += gi->width + ED_GADGET_SMALL_DISTANCE; // text count button
6620 int font_type = FONT_INPUT_1;
6621 int font_type_active = FONT_INPUT_1_ACTIVE;
6623 id = counterbutton_info[i].gadget_id_text;
6625 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6627 if (i == ED_COUNTER_ID_SELECT_LEVEL)
6629 graphic = IMG_GFX_EDITOR_INPUT_LEVEL_NUMBER;
6631 font_type = FONT_LEVEL_NUMBER;
6632 font_type_active = FONT_LEVEL_NUMBER_ACTIVE;
6634 x = DX + editor.input.level_number.x;
6635 y = DY + editor.input.level_number.y;
6639 graphic = IMG_EDITOR_COUNTER_INPUT;
6642 gd = &graphic_info[graphic];
6646 gd_x2 = gd->src_x + gd->active_xoffset;
6647 gd_y2 = gd->src_y + gd->active_yoffset;
6649 gi = CreateGadget(GDI_CUSTOM_ID, id,
6650 GDI_CUSTOM_TYPE_ID, i,
6651 GDI_IMAGE_ID, graphic,
6652 GDI_INFO_TEXT, "enter counter value",
6655 GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
6656 GDI_NUMBER_VALUE, 0,
6657 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
6658 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
6659 GDI_TEXT_SIZE, 3, // minimal counter text size
6660 GDI_TEXT_FONT, font_type,
6661 GDI_TEXT_FONT_ACTIVE, font_type_active,
6662 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6663 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6664 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6665 GDI_DESIGN_WIDTH, gd->width,
6666 GDI_EVENT_MASK, event_mask,
6667 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6668 GDI_CALLBACK_ACTION, HandleCounterButtons,
6672 Fail("cannot create gadget");
6674 level_editor_gadget[id] = gi;
6675 right_gadget_border[id] =
6676 getRightGadgetBorder(gi, counterbutton_info[i].text_right);
6678 x += gi->width + ED_GADGET_SMALL_DISTANCE; // up count button
6684 static void CreateDrawingAreas(void)
6688 // these values are not constant, but can change at runtime
6689 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
6690 drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
6692 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
6694 struct GadgetInfo *gi;
6695 int id = drawingarea_info[i].gadget_id;
6696 int x = SX + ED_AREA_SETTINGS_X(drawingarea_info[i]);
6697 int y = SY + ED_AREA_SETTINGS_Y(drawingarea_info[i]);
6698 int area_xsize = drawingarea_info[i].area_xsize;
6699 int area_ysize = drawingarea_info[i].area_ysize;
6700 int item_size = (id == GADGET_ID_DRAWING_LEVEL ?
6701 ed_tilesize : ED_DRAWINGAREA_TILE_SIZE);
6702 unsigned int event_mask =
6703 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
6704 GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
6706 // determine horizontal position to the right of specified gadget
6707 if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
6708 x = (right_gadget_border[drawingarea_info[i].gadget_id_align] +
6709 ED_DRAWINGAREA_TEXT_DISTANCE);
6711 // determine horizontal offset for leading text
6712 if (drawingarea_info[i].text_left != NULL)
6713 x += getTextWidthForDrawingArea(drawingarea_info[i].text_left);
6715 gi = CreateGadget(GDI_CUSTOM_ID, id,
6716 GDI_CUSTOM_TYPE_ID, i,
6719 GDI_TYPE, GD_TYPE_DRAWING_AREA,
6720 GDI_AREA_SIZE, area_xsize, area_ysize,
6721 GDI_ITEM_SIZE, item_size, item_size,
6722 GDI_EVENT_MASK, event_mask,
6723 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
6724 GDI_CALLBACK_ACTION, HandleDrawingAreas,
6728 Fail("cannot create gadget");
6730 level_editor_gadget[id] = gi;
6731 right_gadget_border[id] =
6732 getRightGadgetBorder(gi, drawingarea_info[i].text_right);
6736 static void CreateTextInputGadgets(void)
6738 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
6739 int max_infotext_len = getMaxInfoTextLength();
6742 for (i = 0; i < ED_NUM_TEXTINPUT; i++)
6744 int gd_x1 = gd->src_x;
6745 int gd_y1 = gd->src_y;
6746 int gd_x2 = gd->src_x + gd->active_xoffset;
6747 int gd_y2 = gd->src_y + gd->active_yoffset;
6748 struct GadgetInfo *gi;
6749 unsigned int event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6750 char infotext[MAX_OUTPUT_LINESIZE + 1];
6751 int id = textinput_info[i].gadget_id;
6754 if (i == ED_TEXTINPUT_ID_ELEMENT_NAME)
6756 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
6757 int border_size = gd->border_size;
6758 int font_nr = FONT_INPUT_1;
6759 int font_height = getFontHeight(font_nr);
6760 int xoffset = element_border + TILEX + element_border + 3 * border_size;
6761 int yoffset = element_border + (TILEY - font_height) / 2;
6763 x = (editor.settings.element_name.x != -1 ?
6764 editor.settings.element_name.x :
6765 editor.settings.element_graphic.x + xoffset) - border_size;
6766 y = (editor.settings.element_name.y != -1 ?
6767 editor.settings.element_name.y :
6768 editor.settings.element_graphic.y + yoffset) - border_size;
6772 x = ED_SETTINGS_X(textinput_info[i].x);
6773 y = ED_SETTINGS_Y(textinput_info[i].y);
6776 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
6777 infotext[max_infotext_len] = '\0';
6779 gi = CreateGadget(GDI_CUSTOM_ID, id,
6780 GDI_CUSTOM_TYPE_ID, i,
6781 GDI_INFO_TEXT, infotext,
6784 GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
6785 GDI_TEXT_VALUE, textinput_info[i].value,
6786 GDI_TEXT_SIZE, textinput_info[i].size,
6787 GDI_TEXT_FONT, FONT_INPUT_1,
6788 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6789 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6790 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6791 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6792 GDI_DESIGN_WIDTH, gd->width,
6793 GDI_EVENT_MASK, event_mask,
6794 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6795 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
6799 Fail("cannot create gadget");
6801 level_editor_gadget[id] = gi;
6805 static void CreateTextAreaGadgets(void)
6807 int max_infotext_len = getMaxInfoTextLength();
6810 for (i = 0; i < ED_NUM_TEXTAREAS; i++)
6812 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXTAREA];
6813 int gd_x1 = gd->src_x;
6814 int gd_y1 = gd->src_y;
6815 int gd_x2 = gd->src_x + gd->active_xoffset;
6816 int gd_y2 = gd->src_y + gd->active_yoffset;
6817 struct GadgetInfo *gi;
6818 unsigned int event_mask = GD_EVENT_TEXT_LEAVING;
6819 char infotext[MAX_OUTPUT_LINESIZE + 1];
6820 int id = textarea_info[i].gadget_id;
6821 int area_xsize = textarea_info[i].xsize;
6822 int area_ysize = textarea_info[i].ysize;
6824 sprintf(infotext, "Enter %s", textarea_info[i].infotext);
6825 infotext[max_infotext_len] = '\0';
6827 gi = CreateGadget(GDI_CUSTOM_ID, id,
6828 GDI_CUSTOM_TYPE_ID, i,
6829 GDI_INFO_TEXT, infotext,
6830 GDI_X, SX + ED_SETTINGS_X(textarea_info[i].x),
6831 GDI_Y, SY + ED_SETTINGS_Y(textarea_info[i].y),
6832 GDI_TYPE, GD_TYPE_TEXT_AREA,
6833 GDI_AREA_SIZE, area_xsize, area_ysize,
6834 GDI_TEXT_FONT, FONT_INPUT_1,
6835 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6836 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6837 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6838 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6839 GDI_DESIGN_WIDTH, gd->width,
6840 GDI_EVENT_MASK, event_mask,
6841 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6842 GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
6846 Fail("cannot create gadget");
6848 level_editor_gadget[id] = gi;
6852 static void CreateSelectboxGadgets(void)
6854 int max_infotext_len = getMaxInfoTextLength();
6857 for (i = 0; i < ED_NUM_SELECTBOX; i++)
6859 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_SELECTBOX_INPUT];
6860 struct GraphicInfo *gd2 = &graphic_info[IMG_EDITOR_SELECTBOX_BUTTON];
6861 int gd_x1 = gd->src_x;
6862 int gd_y1 = gd->src_y;
6863 int gd_x2 = gd->src_x + gd->active_xoffset;
6864 int gd_y2 = gd->src_y + gd->active_yoffset;
6865 int selectbox_button_xsize = gd2->width;
6866 struct GadgetInfo *gi;
6867 char infotext[MAX_OUTPUT_LINESIZE + 1];
6868 int id = selectbox_info[i].gadget_id;
6869 int x = SX + ED_SETTINGS_X(selectbox_info[i].x);
6870 int y = SY + ED_SETTINGS_Y(selectbox_info[i].y);
6871 unsigned int event_mask =
6872 GD_EVENT_RELEASED | GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
6874 if (selectbox_info[i].size == -1) // dynamically determine size
6876 // (we cannot use -1 for uninitialized values if we directly compare
6877 // with results from strlen(), because the '<' and '>' operation will
6878 // implicitely cast -1 to an unsigned integer value!)
6879 selectbox_info[i].size = 0;
6881 for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
6882 if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
6883 selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
6885 selectbox_info[i].size++; // add one character empty space
6888 // determine horizontal position to the right of specified gadget
6889 if (selectbox_info[i].gadget_id_align != GADGET_ID_NONE)
6890 x = (right_gadget_border[selectbox_info[i].gadget_id_align] +
6891 ED_GADGET_TEXT_DISTANCE);
6893 // determine horizontal offset for leading text
6894 if (selectbox_info[i].text_left != NULL)
6895 x += getTextWidthForGadget(selectbox_info[i].text_left);
6897 sprintf(infotext, "Select %s", selectbox_info[i].infotext);
6898 infotext[max_infotext_len] = '\0';
6900 gi = CreateGadget(GDI_CUSTOM_ID, id,
6901 GDI_CUSTOM_TYPE_ID, i,
6902 GDI_INFO_TEXT, infotext,
6905 GDI_TYPE, GD_TYPE_SELECTBOX,
6906 GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
6907 GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
6908 GDI_TEXT_SIZE, selectbox_info[i].size,
6909 GDI_TEXT_FONT, FONT_INPUT_1,
6910 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
6911 GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
6912 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6913 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6914 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
6915 GDI_BORDER_SIZE_SELECTBUTTON, selectbox_button_xsize,
6916 GDI_DESIGN_WIDTH, gd->width,
6917 GDI_EVENT_MASK, event_mask,
6918 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
6919 GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
6923 Fail("cannot create gadget");
6925 level_editor_gadget[id] = gi;
6926 right_gadget_border[id] =
6927 getRightGadgetBorder(gi, selectbox_info[i].text_right);
6931 static void CreateTextbuttonGadgets(void)
6933 int max_infotext_len = getMaxInfoTextLength();
6936 for (i = 0; i < ED_NUM_TEXTBUTTONS; i++)
6938 int id = textbutton_info[i].gadget_id;
6940 ((id >= GADGET_ID_LEVELINFO_LEVEL && id <= GADGET_ID_LEVELINFO_EDITOR) ||
6941 (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_CHANGE));
6943 (is_tab_button ? IMG_EDITOR_TABBUTTON : IMG_EDITOR_TEXTBUTTON);
6944 int gadget_distance =
6945 (is_tab_button ? ED_GADGET_SMALL_DISTANCE : ED_GADGET_TEXT_DISTANCE);
6946 struct GraphicInfo *gd = &graphic_info[graphic];
6947 int gd_x1 = gd->src_x;
6948 int gd_y1 = gd->src_y;
6949 int gd_x2 = gd->src_x + gd->pressed_xoffset;
6950 int gd_y2 = gd->src_y + gd->pressed_yoffset;
6951 int gd_x1a = gd->src_x + gd->active_xoffset;
6952 int gd_y1a = gd->src_y + gd->active_yoffset;
6953 int border_xsize = gd->border_size + gd->draw_xoffset;
6954 int border_ysize = gd->border_size;
6955 struct GadgetInfo *gi;
6956 unsigned int event_mask = GD_EVENT_RELEASED;
6957 char infotext[MAX_OUTPUT_LINESIZE + 1];
6958 int x = SX + ED_SETTINGS_X(textbutton_info[i].x);
6959 int y = SY + ED_SETTINGS_Y(textbutton_info[i].y);
6961 if (textbutton_info[i].size == -1) // dynamically determine size
6962 textbutton_info[i].size = strlen(textbutton_info[i].text);
6964 sprintf(infotext, "%s", textbutton_info[i].infotext);
6965 infotext[max_infotext_len] = '\0';
6967 // determine horizontal position to the right of specified gadget
6968 if (textbutton_info[i].gadget_id_align != GADGET_ID_NONE)
6970 int gadget_id_align = textbutton_info[i].gadget_id_align;
6972 x = right_gadget_border[gadget_id_align] + gadget_distance;
6974 if (textbutton_info[i].y == -1)
6975 y = level_editor_gadget[gadget_id_align]->y;
6978 // determine horizontal offset for leading text
6979 if (textbutton_info[i].text_left != NULL)
6980 x += getTextWidthForGadget(textbutton_info[i].text_left);
6982 gi = CreateGadget(GDI_CUSTOM_ID, id,
6983 GDI_CUSTOM_TYPE_ID, i,
6984 GDI_IMAGE_ID, graphic,
6985 GDI_INFO_TEXT, infotext,
6988 GDI_TYPE, GD_TYPE_TEXT_BUTTON,
6989 GDI_TEXT_VALUE, textbutton_info[i].text,
6990 GDI_TEXT_SIZE, textbutton_info[i].size,
6991 GDI_TEXT_FONT, FONT_INPUT_2,
6992 GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2_ACTIVE,
6993 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
6994 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
6995 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
6996 GDI_BORDER_SIZE, border_xsize, border_ysize,
6997 GDI_DESIGN_WIDTH, gd->width,
6998 GDI_DECORATION_SHIFTING, 1, 1,
6999 GDI_EVENT_MASK, event_mask,
7000 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7001 GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
7005 Fail("cannot create gadget");
7007 level_editor_gadget[id] = gi;
7008 right_gadget_border[id] =
7009 getRightGadgetBorder(gi, textbutton_info[i].text_right);
7013 static void CreateGraphicbuttonGadgets(void)
7015 struct GadgetInfo *gi;
7018 // create buttons for scrolling of drawing area and element list
7019 for (i = 0; i < ED_NUM_GRAPHICBUTTONS; i++)
7021 int id = graphicbutton_info[i].gadget_id;
7022 int x = SX + ED_SETTINGS_X(graphicbutton_info[i].x);
7023 int y = SY + ED_SETTINGS_Y(graphicbutton_info[i].y);
7024 int graphic = graphicbutton_info[i].graphic;
7025 struct GraphicInfo *gd = &graphic_info[graphic];
7026 int gd_x1 = gd->src_x;
7027 int gd_y1 = gd->src_y;
7028 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7029 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7030 unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7032 // determine horizontal position to the right of specified gadget
7033 if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7034 x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
7035 ED_GADGET_TEXT_DISTANCE);
7037 // determine horizontal offset for leading text
7038 if (graphicbutton_info[i].text_left != NULL)
7039 x += getTextWidthForGadget(graphicbutton_info[i].text_left);
7041 gi = CreateGadget(GDI_CUSTOM_ID, id,
7042 GDI_CUSTOM_TYPE_ID, i,
7043 GDI_IMAGE_ID, graphic,
7044 GDI_INFO_TEXT, graphicbutton_info[i].infotext,
7047 GDI_WIDTH, gd->width,
7048 GDI_HEIGHT, gd->height,
7049 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7050 GDI_STATE, GD_BUTTON_UNPRESSED,
7051 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7052 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7053 GDI_EVENT_MASK, event_mask,
7054 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7055 GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
7059 Fail("cannot create gadget");
7061 level_editor_gadget[id] = gi;
7062 right_gadget_border[id] =
7063 getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
7067 static void CreateScrollbarGadgets(void)
7071 // these values are not constant, but can change at runtime
7072 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
7073 SX + ED_SCROLL_HORIZONTAL_XPOS;
7074 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
7075 SY + ED_SCROLL_HORIZONTAL_YPOS;
7076 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
7077 ED_SCROLL_HORIZONTAL_XSIZE;
7078 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
7079 ED_SCROLL_HORIZONTAL_YSIZE;
7080 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX;
7081 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY;
7082 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE;
7083 scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
7085 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
7086 SX + ED_SCROLL_VERTICAL_XPOS;
7087 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
7088 SY + ED_SCROLL_VERTICAL_YPOS;
7089 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
7090 ED_SCROLL_VERTICAL_XSIZE;
7091 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
7092 ED_SCROLL_VERTICAL_YSIZE;
7093 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX;
7094 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY;
7095 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE;
7096 scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
7098 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
7099 PX + ED_SCROLL2_VERTICAL_XPOS;
7100 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
7101 PY + ED_SCROLL2_VERTICAL_YPOS;
7102 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].width =
7103 ED_SCROLL2_VERTICAL_XSIZE;
7104 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].height =
7105 ED_SCROLL2_VERTICAL_YSIZE;
7106 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = PX;
7107 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = PY;
7108 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_width = PXSIZE;
7109 scrollbar_pos[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_height = PYSIZE;
7111 for (i = 0; i < ED_NUM_SCROLLBARS; i++)
7113 int id = scrollbar_info[i].gadget_id;
7114 int graphic = scrollbar_info[i].graphic;
7115 struct GraphicInfo *gd = &graphic_info[graphic];
7116 int gd_x1 = gd->src_x;
7117 int gd_y1 = gd->src_y;
7118 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7119 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7120 struct GadgetInfo *gi;
7121 int items_max, items_visible, item_position;
7122 unsigned int event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7124 if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
7126 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
7127 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
7128 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
7130 else // drawing area scrollbars
7132 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
7134 items_max = MAX(lev_fieldx + 2, ed_fieldx);
7135 items_visible = ed_fieldx;
7140 items_max = MAX(lev_fieldy + 2, ed_fieldy);
7141 items_visible = ed_fieldy;
7146 gi = CreateGadget(GDI_CUSTOM_ID, id,
7147 GDI_CUSTOM_TYPE_ID, i,
7148 GDI_IMAGE_ID, graphic,
7149 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7150 GDI_X, scrollbar_pos[i].x,
7151 GDI_Y, scrollbar_pos[i].y,
7152 GDI_WIDTH, scrollbar_pos[i].width,
7153 GDI_HEIGHT, scrollbar_pos[i].height,
7154 GDI_TYPE, scrollbar_info[i].type,
7155 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7156 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7157 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7158 GDI_WHEEL_AREA_X, scrollbar_pos[i].wheel_x,
7159 GDI_WHEEL_AREA_Y, scrollbar_pos[i].wheel_y,
7160 GDI_WHEEL_AREA_WIDTH, scrollbar_pos[i].wheel_width,
7161 GDI_WHEEL_AREA_HEIGHT, scrollbar_pos[i].wheel_height,
7162 GDI_STATE, GD_BUTTON_UNPRESSED,
7163 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7164 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7165 GDI_BORDER_SIZE, gd->border_size, gd->border_size,
7166 GDI_EVENT_MASK, event_mask,
7167 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7168 GDI_CALLBACK_ACTION, HandleControlButtons,
7172 Fail("cannot create gadget");
7174 level_editor_gadget[id] = gi;
7178 static void CreateCheckbuttonGadgets(void)
7180 struct GadgetInfo *gi;
7183 for (i = 0; i < ED_NUM_CHECKBUTTONS; i++)
7185 int id = checkbutton_info[i].gadget_id;
7186 int graphic = (id == GADGET_ID_STICK_ELEMENT ? IMG_EDITOR_STICKYBUTTON :
7187 IMG_EDITOR_CHECKBOX);
7188 struct GraphicInfo *gd = &graphic_info[graphic];
7189 int gd_x1 = gd->src_x;
7190 int gd_y1 = gd->src_y;
7191 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7192 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7193 int gd_x1a = gd->src_x + gd->active_xoffset;
7194 int gd_y1a = gd->src_y + gd->active_yoffset;
7195 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7196 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7197 int x = SX + ED_SETTINGS_X(checkbutton_info[i].x);
7198 int y = SY + ED_SETTINGS_Y(checkbutton_info[i].y);
7199 unsigned int event_mask = GD_EVENT_PRESSED;
7201 // determine horizontal position to the right of specified gadget
7202 if (checkbutton_info[i].gadget_id_align != GADGET_ID_NONE)
7203 x = (right_gadget_border[checkbutton_info[i].gadget_id_align] +
7204 ED_GADGET_TEXT_DISTANCE);
7206 // determine horizontal offset for leading text
7207 if (checkbutton_info[i].text_left != NULL)
7208 x += getTextWidthForGadget(checkbutton_info[i].text_left);
7210 gi = CreateGadget(GDI_CUSTOM_ID, id,
7211 GDI_CUSTOM_TYPE_ID, i,
7212 GDI_IMAGE_ID, graphic,
7213 GDI_INFO_TEXT, checkbutton_info[i].infotext,
7216 GDI_WIDTH, gd->width,
7217 GDI_HEIGHT, gd->height,
7218 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
7219 GDI_CHECKED, *checkbutton_info[i].value,
7220 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7221 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7222 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7223 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7224 GDI_EVENT_MASK, event_mask,
7225 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7226 GDI_CALLBACK_ACTION, HandleCheckbuttons,
7230 Fail("cannot create gadget");
7232 level_editor_gadget[id] = gi;
7233 right_gadget_border[id] =
7234 getRightGadgetBorder(gi, checkbutton_info[i].text_right);
7238 static void CreateRadiobuttonGadgets(void)
7240 int graphic = IMG_EDITOR_RADIOBUTTON;
7241 struct GraphicInfo *gd = &graphic_info[graphic];
7242 int gd_x1 = gd->src_x;
7243 int gd_y1 = gd->src_y;
7244 int gd_x2 = gd->src_x + gd->pressed_xoffset;
7245 int gd_y2 = gd->src_y + gd->pressed_yoffset;
7246 int gd_x1a = gd->src_x + gd->active_xoffset;
7247 int gd_y1a = gd->src_y + gd->active_yoffset;
7248 int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset;
7249 int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset;
7250 struct GadgetInfo *gi;
7253 for (i = 0; i < ED_NUM_RADIOBUTTONS; i++)
7255 int id = radiobutton_info[i].gadget_id;
7256 int x = SX + ED_SETTINGS_X(radiobutton_info[i].x);
7257 int y = SY + ED_SETTINGS_Y(radiobutton_info[i].y);
7258 unsigned int event_mask = GD_EVENT_PRESSED;
7261 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
7263 // determine horizontal position to the right of specified gadget
7264 if (radiobutton_info[i].gadget_id_align != GADGET_ID_NONE)
7265 x = (right_gadget_border[radiobutton_info[i].gadget_id_align] +
7266 ED_GADGET_TEXT_DISTANCE);
7268 // determine horizontal offset for leading text
7269 if (radiobutton_info[i].text_left != NULL)
7270 x += getTextWidthForGadget(radiobutton_info[i].text_left);
7272 gi = CreateGadget(GDI_CUSTOM_ID, id,
7273 GDI_CUSTOM_TYPE_ID, i,
7274 GDI_IMAGE_ID, graphic,
7275 GDI_INFO_TEXT, radiobutton_info[i].infotext,
7278 GDI_WIDTH, gd->width,
7279 GDI_HEIGHT, gd->height,
7280 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
7281 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
7282 GDI_CHECKED, checked,
7283 GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
7284 GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
7285 GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a,
7286 GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a,
7287 GDI_EVENT_MASK, event_mask,
7288 GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
7289 GDI_CALLBACK_ACTION, HandleRadiobuttons,
7293 Fail("cannot create gadget");
7295 level_editor_gadget[id] = gi;
7296 right_gadget_border[id] =
7297 getRightGadgetBorder(gi, radiobutton_info[i].text_right);
7301 void CreateLevelEditorGadgets(void)
7303 // force EDITOR font inside level editor
7304 SetFontStatus(GAME_MODE_EDITOR);
7306 // these values are not constant, but can change at runtime
7307 ed_fieldx = MAX_ED_FIELDX - 1;
7308 ed_fieldy = MAX_ED_FIELDY - 1;
7310 num_editor_gadgets = NUM_EDITOR_GADGETS;
7312 // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets);
7314 level_editor_gadget =
7315 checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *));
7316 right_gadget_border =
7317 checked_calloc(num_editor_gadgets * sizeof(int));
7319 // set number of empty (padding) element buttons to maximum number of buttons
7320 num_editor_el_empty = ED_NUM_ELEMENTLIST_BUTTONS;
7322 editor_el_empty = checked_calloc(num_editor_el_empty * sizeof(int));
7323 editor_el_empty_ptr = editor_el_empty;
7325 use_permanent_palette = !editor.palette.show_as_separate_screen;
7327 InitGadgetScreenBorders(-1, INFOTEXT_YPOS);
7329 ReinitializeElementList();
7331 CreateControlButtons();
7332 CreateScrollbarGadgets();
7334 // order of function calls is important because of cross-references
7335 CreateCheckbuttonGadgets();
7336 CreateCounterButtons();
7337 CreateRadiobuttonGadgets();
7338 CreateTextInputGadgets();
7339 CreateTextAreaGadgets();
7340 CreateSelectboxGadgets();
7341 CreateGraphicbuttonGadgets();
7342 CreateTextbuttonGadgets();
7343 CreateDrawingAreas();
7348 void FreeLevelEditorGadgets(void)
7352 // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets);
7354 for (i = 0; i < num_editor_gadgets; i++)
7356 FreeGadget(level_editor_gadget[i]);
7358 level_editor_gadget[i] = NULL;
7361 checked_free(level_editor_gadget);
7362 checked_free(right_gadget_border);
7364 checked_free(editor_el_empty);
7367 static void MapCounterButtons(int id)
7369 int font_nr = FONT_TEXT_1;
7370 int font_height = getFontHeight(font_nr);
7371 int gadget_id_down = counterbutton_info[id].gadget_id_down;
7372 int gadget_id_text = counterbutton_info[id].gadget_id_text;
7373 int gadget_id_up = counterbutton_info[id].gadget_id_up;
7374 struct GadgetInfo *gi_down = level_editor_gadget[gadget_id_down];
7375 struct GadgetInfo *gi_text = level_editor_gadget[gadget_id_text];
7376 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
7377 int xoffset_left = getTextWidthForGadget(counterbutton_info[id].text_left);
7378 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7379 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7380 int yoffset = (gi_down->height - font_height) / 2;
7381 int x_left = gi_down->x - xoffset_left;
7382 int x_right; // set after gadget position was modified
7383 int y_above = gi_down->y - yoffset_above;
7385 int y; // set after gadget position was modified
7387 // counter limits must be changed first to prevent value truncation
7388 ModifyEditorCounterLimits(id, counterbutton_info[id].min_value,
7389 counterbutton_info[id].max_value);
7391 // right text position might have changed after setting position above
7392 x_right = gi_up->x + gi_up->width + xoffset_right;
7394 ModifyEditorCounterValue(id, *counterbutton_info[id].value);
7396 // set position for "value[1,2,3,4]" counter gadgets (score in most cases)
7397 if (id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
7398 id <= ED_COUNTER_ID_ELEMENT_VALUE4)
7400 ModifyGadget(gi_down, GDI_Y,
7401 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7402 ModifyGadget(gi_text, GDI_Y,
7403 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7404 ModifyGadget(gi_up, GDI_Y,
7405 SY + ED_SETTINGS_Y(counterbutton_info[id].y), GDI_END);
7408 // vertical position might have changed after setting position above
7409 y = gi_up->y + yoffset;
7411 if (counterbutton_info[id].text_above)
7412 DrawText(x, y_above, counterbutton_info[id].text_above, font_nr);
7414 if (counterbutton_info[id].text_left)
7415 DrawText(x_left, y, counterbutton_info[id].text_left, font_nr);
7417 if (counterbutton_info[id].text_right)
7418 DrawText(x_right, y, counterbutton_info[id].text_right, font_nr);
7425 static void MapControlButtons(void)
7430 // map toolbox buttons (excluding special CE toolbox buttons)
7431 for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++)
7432 MapGadget(level_editor_gadget[i]);
7434 // map toolbox buttons (element properties buttons)
7435 for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_7_BUTTONS; i++)
7436 MapGadget(level_editor_gadget[i]);
7438 if (use_permanent_palette)
7440 // map buttons to select elements
7441 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
7442 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
7443 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
7444 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
7445 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
7448 // map buttons to select level
7449 counter_id = ED_COUNTER_ID_SELECT_LEVEL;
7450 counterbutton_info[counter_id].min_value = leveldir_current->first_level;
7451 counterbutton_info[counter_id].max_value = leveldir_current->last_level;
7452 MapCounterButtons(counter_id);
7455 static void MapDrawingArea(int id)
7457 int font_nr = FONT_TEXT_1;
7458 int font_height = getFontHeight(font_nr);
7459 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
7460 int area_xsize = gi->drawing.area_xsize;
7461 int area_ysize = gi->drawing.area_ysize;
7462 int xoffset_left = getTextWidthForDrawingArea(drawingarea_info[id].text_left);
7463 int xoffset_below = getTextWidth(drawingarea_info[id].text_below, font_nr);
7464 int x_left = gi->x - xoffset_left;
7465 int x_right = gi->x + gi->width + ED_DRAWINGAREA_TEXT_DISTANCE;
7466 int x_above = gi->x - ED_DRAWINGAREA_BORDER_SIZE;
7467 int x_below = gi->x + (gi->width - xoffset_below) / 2;
7468 int y_side = gi->y + (gi->height - font_height) / 2;
7469 int y_above = gi->y - font_height - ED_DRAWINGAREA_TEXT_DISTANCE;
7470 int y_below = gi->y + gi->height + ED_DRAWINGAREA_TEXT_DISTANCE;
7472 if (drawingarea_info[id].text_left)
7473 DrawText(x_left, y_side, drawingarea_info[id].text_left, font_nr);
7475 if (drawingarea_info[id].text_right)
7476 DrawText(x_right, y_side, drawingarea_info[id].text_right, font_nr);
7478 if (drawingarea_info[id].text_above)
7479 DrawText(x_above, y_above, drawingarea_info[id].text_above, font_nr);
7481 if (drawingarea_info[id].text_below)
7482 DrawText(x_below, y_below, drawingarea_info[id].text_below, font_nr);
7484 if (id != ED_DRAWING_ID_DRAWING_LEVEL)
7486 DrawElementBorder(gi->x, gi->y,
7487 area_xsize * ED_DRAWINGAREA_TILE_SIZE,
7488 area_ysize * ED_DRAWINGAREA_TILE_SIZE, TRUE);
7490 DrawDrawingArea(id);
7496 static void MapTextInputGadget(int id)
7498 int font_nr = FONT_TEXT_1;
7499 int font_height = getFontHeight(font_nr);
7500 struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
7501 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7502 int x_above = ED_SETTINGS_X(textinput_info[id].x);
7503 int y_above = ED_SETTINGS_Y(textinput_info[id].y) - yoffset_above;
7505 if (textinput_info[id].text_above)
7506 DrawTextS(x_above, y_above, font_nr, textinput_info[id].text_above);
7508 ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
7513 static void MapTextAreaGadget(int id)
7515 int font_nr = FONT_TEXT_1;
7516 int font_height = getFontHeight(font_nr);
7517 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
7518 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7519 int x_above = ED_SETTINGS_X(textarea_info[id].x);
7520 int y_above = ED_SETTINGS_Y(textarea_info[id].y) - yoffset_above;
7521 char *text_above = textarea_info[id].text_above;
7523 if (gi->textarea.cropped && textarea_info[id].text_above_cropped)
7524 text_above = textarea_info[id].text_above_cropped;
7527 DrawTextS(x_above, y_above, font_nr, text_above);
7529 ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
7534 static void MapSelectboxGadget(int id)
7536 int font_nr = FONT_TEXT_1;
7537 int font_height = getFontHeight(font_nr);
7538 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
7539 int xoffset_left = getTextWidthForGadget(selectbox_info[id].text_left);
7540 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7541 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7542 int yoffset = (gi->height - font_height) / 2;
7543 int x_left = gi->x - xoffset_left;
7544 int x_right = gi->x + gi->width + xoffset_right;
7545 int y_above = gi->y - yoffset_above;
7547 int y = gi->y + yoffset;
7549 if (selectbox_info[id].text_above)
7550 DrawText(x, y_above, selectbox_info[id].text_above, font_nr);
7552 if (selectbox_info[id].text_left)
7553 DrawText(x_left, y, selectbox_info[id].text_left, font_nr);
7555 if (selectbox_info[id].text_right)
7556 DrawText(x_right, y, selectbox_info[id].text_right, font_nr);
7558 ModifyEditorSelectboxValue(id, *selectbox_info[id].value);
7563 static void MapTextbuttonGadget(int id)
7565 int font_nr = FONT_TEXT_1;
7566 int font_height = getFontHeight(font_nr);
7567 struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
7568 int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
7569 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7570 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7571 int yoffset = (gi->height - font_height) / 2;
7572 int x_left = gi->x - xoffset_left;
7573 int x_right = gi->x + gi->width + xoffset_right;
7574 int y_above = gi->y - yoffset_above;
7576 int y = gi->y + yoffset;
7578 // only show button to delete change pages when more than minimum pages
7579 if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
7580 custom_element.num_change_pages == MIN_CHANGE_PAGES)
7583 if (textbutton_info[id].text_above)
7584 DrawText(x, y_above, textbutton_info[id].text_above, font_nr);
7586 if (textbutton_info[id].text_left)
7587 DrawText(x_left, y, textbutton_info[id].text_left, font_nr);
7589 if (textbutton_info[id].text_right)
7590 DrawText(x_right, y, textbutton_info[id].text_right, font_nr);
7595 static void MapGraphicbuttonGadget(int id)
7597 int font_nr = FONT_TEXT_1;
7598 int font_height = getFontHeight(font_nr);
7599 struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
7600 int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
7601 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7602 int yoffset = (gi->height - font_height) / 2;
7603 int x_left = gi->x - xoffset_left;
7604 int x_right = gi->x + gi->width + xoffset_right;
7605 int y = gi->y + yoffset;
7607 if (graphicbutton_info[id].text_left)
7608 DrawText(x_left, y, graphicbutton_info[id].text_left, font_nr);
7610 if (graphicbutton_info[id].text_right)
7611 DrawText(x_right, y, graphicbutton_info[id].text_right, font_nr);
7616 static void MapRadiobuttonGadget(int id)
7618 int font_nr = FONT_TEXT_1;
7619 int font_height = getFontHeight(font_nr);
7620 struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
7621 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7622 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7623 int yoffset = (gi->height - font_height) / 2;
7624 int x_left = gi->x - xoffset_left;
7625 int x_right = gi->x + gi->width + xoffset_right;
7626 int y = gi->y + yoffset;
7628 (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
7630 if (radiobutton_info[id].text_left)
7631 DrawText(x_left, y, radiobutton_info[id].text_left, font_nr);
7633 if (radiobutton_info[id].text_right)
7634 DrawText(x_right, y, radiobutton_info[id].text_right, font_nr);
7636 ModifyGadget(gi, GDI_CHECKED, checked, GDI_END);
7641 static void MapCheckbuttonGadget(int id)
7643 int font_nr = FONT_TEXT_1;
7644 int font_height = getFontHeight(font_nr);
7645 struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
7646 int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
7647 int xoffset_right = ED_GADGET_TEXT_DISTANCE;
7648 int yoffset_above = font_height + ED_GADGET_LINE_DISTANCE;
7649 int yoffset = (gi->height - font_height) / 2;
7650 int y_above = gi->y - yoffset_above;
7652 int x_left, x_right, y; // set after gadget position was modified
7654 // set position for gadgets with dynamically determined position
7655 if (checkbutton_info[id].x != -1) // do not change dynamic positions
7656 ModifyGadget(gi, GDI_X, SX + ED_SETTINGS_X(checkbutton_info[id].x),GDI_END);
7657 ModifyGadget(gi, GDI_Y, SY + ED_SETTINGS_Y(checkbutton_info[id].y), GDI_END);
7659 x_left = gi->x - xoffset_left;
7660 x_right = gi->x + gi->width + xoffset_right;
7661 y = gi->y + yoffset;
7663 if (checkbutton_info[id].text_above)
7664 DrawText(x, y_above, checkbutton_info[id].text_above, font_nr);
7666 if (checkbutton_info[id].text_left)
7667 DrawText(x_left, y, checkbutton_info[id].text_left, font_nr);
7669 if (checkbutton_info[id].text_right)
7670 DrawText(x_right, y, checkbutton_info[id].text_right, font_nr);
7672 ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END);
7677 static void MapMainDrawingArea(void)
7679 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
7680 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
7683 if (suppressBorderElement())
7685 no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx);
7686 no_vertical_scrollbar = (lev_fieldy <= ed_fieldy);
7689 for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++)
7691 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
7692 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
7693 no_horizontal_scrollbar) ||
7694 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
7695 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
7696 no_vertical_scrollbar))
7699 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
7702 for (i = ED_SCROLLBAR_ID_AREA_FIRST; i <= ED_SCROLLBAR_ID_AREA_LAST; i++)
7704 if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
7705 (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
7708 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
7711 MapDrawingArea(ED_DRAWING_ID_DRAWING_LEVEL);
7714 static void MapOrUnmapLevelEditorToolboxCustomGadgets(boolean map)
7718 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
7720 if (i == GADGET_ID_CUSTOM_COPY_FROM ||
7721 i == GADGET_ID_CUSTOM_COPY_TO ||
7722 i == GADGET_ID_CUSTOM_EXCHANGE ||
7723 i == GADGET_ID_CUSTOM_COPY ||
7724 i == GADGET_ID_CUSTOM_PASTE)
7727 MapGadget(level_editor_gadget[i]);
7729 UnmapGadget(level_editor_gadget[i]);
7734 static void MapLevelEditorToolboxCustomGadgets(void)
7736 MapOrUnmapLevelEditorToolboxCustomGadgets(TRUE);
7739 static void UnmapLevelEditorToolboxCustomGadgets(void)
7741 MapOrUnmapLevelEditorToolboxCustomGadgets(FALSE);
7744 static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map)
7748 for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++)
7750 if (i != GADGET_ID_SINGLE_ITEMS &&
7751 i != GADGET_ID_PICK_ELEMENT)
7753 struct GadgetInfo *gi = level_editor_gadget[i];
7761 int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON;
7762 struct GraphicInfo *gd = &graphic_info[graphic];
7766 BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y,
7767 gi->width, gi->height, gi->x, gi->y);
7769 redraw_mask |= REDRAW_DOOR_3;
7775 static void MapLevelEditorToolboxDrawingGadgets(void)
7777 MapOrUnmapLevelEditorToolboxDrawingGadgets(TRUE);
7780 static void UnmapLevelEditorToolboxDrawingGadgets(void)
7782 MapOrUnmapLevelEditorToolboxDrawingGadgets(FALSE);
7785 static void UnmapDrawingArea(int id)
7787 UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]);
7790 static void UnmapLevelEditorFieldGadgets(void)
7794 for (i = 0; i < num_editor_gadgets; i++)
7795 if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x,
7796 level_editor_gadget[i]->y))
7797 UnmapGadget(level_editor_gadget[i]);
7800 void UnmapLevelEditorGadgets(void)
7804 for (i = 0; i < num_editor_gadgets; i++)
7805 UnmapGadget(level_editor_gadget[i]);
7808 static void ResetUndoBuffer(void)
7810 undo_buffer_position = -1;
7811 undo_buffer_steps = -1;
7812 redo_buffer_steps = 0;
7814 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
7816 level.changed = FALSE;
7819 static void DrawEditModeWindowExt(boolean remap_toolbox_gadgets)
7821 if (remap_toolbox_gadgets)
7823 ModifyEditorElementList();
7824 RedrawDrawingElements();
7827 if (edit_mode == ED_MODE_INFO)
7828 DrawLevelInfoWindow();
7829 else if (edit_mode == ED_MODE_PROPERTIES)
7830 DrawPropertiesWindow();
7831 else if (edit_mode == ED_MODE_PALETTE)
7832 DrawPaletteWindow();
7833 else // edit_mode == ED_MODE_DRAWING
7834 DrawDrawingWindowExt(remap_toolbox_gadgets);
7837 static void DrawEditModeWindow(void)
7839 DrawEditModeWindowExt(TRUE);
7842 static void DrawEditModeWindow_PlayfieldOnly(void)
7844 DrawEditModeWindowExt(FALSE);
7847 static void ChangeEditModeWindow(int new_edit_mode)
7849 edit_mode = (new_edit_mode != edit_mode ? new_edit_mode : ED_MODE_DRAWING);
7851 DrawEditModeWindow();
7854 static boolean LevelChanged(void)
7856 boolean field_changed = FALSE;
7859 for (y = 0; y < lev_fieldy; y++)
7860 for (x = 0; x < lev_fieldx; x++)
7861 if (Tile[x][y] != level.field[x][y])
7862 field_changed = TRUE;
7864 return (level.changed || field_changed);
7867 static boolean PrepareSavingIntoPersonalLevelSet(void)
7869 static LevelDirTree *last_copied_leveldir = NULL;
7870 static LevelDirTree *last_written_leveldir = NULL;
7871 static int last_copied_level_nr = -1;
7872 static int last_written_level_nr = -1;
7873 LevelDirTree *leveldir_former = leveldir_current;
7874 int level_nr_former = level_nr;
7877 // remember last mod/save so that for current session, we write
7878 // back to the same personal copy, asking only about overwrite.
7879 if (leveldir_current == last_copied_leveldir &&
7880 level_nr == last_copied_level_nr)
7882 // "cd" to personal level set dir (as used when writing last copy)
7883 leveldir_current = last_written_leveldir;
7884 level_nr = last_written_level_nr;
7889 if (!Request("This level is read-only! "
7890 "Save into personal level set?", REQ_ASK))
7893 // "cd" to personal level set dir (for writing copy the first time)
7895 getTreeInfoFromIdentifier(leveldir_first, getLoginName());
7897 // this may happen if "setup.internal.create_user_levelset" is FALSE
7898 // or if file "levelinfo.conf" is missing in personal user level set
7899 if (leveldir_current == NULL)
7901 Request("Cannot find personal level set?!", REQ_CONFIRM);
7903 leveldir_current = leveldir_former;
7908 // find unused level number
7909 for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
7911 static char *level_filename = NULL;
7913 setString(&level_filename, getDefaultLevelFilename(new_level_nr));
7915 if (!fileExists(level_filename))
7919 last_copied_leveldir = leveldir_former;
7920 last_copied_level_nr = level_nr_former;
7922 last_written_leveldir = leveldir_current;
7923 last_written_level_nr = level_nr = new_level_nr;
7928 static void ModifyLevelInfoForSavingIntoPersonalLevelSet(char *former_name)
7930 static char *filename_levelinfo = NULL, *mod_name = NULL;
7933 // annotate this copy-and-mod in personal levelinfo.conf
7934 setString(&filename_levelinfo,
7935 getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME));
7937 if ((file = fopen(filename_levelinfo, MODE_APPEND)))
7939 fprintf(file, "\n");
7940 fprintf(file, "# level %d was modified from:\n", level_nr);
7941 fprintf(file, "# - previous level set name: %s\n",
7943 fprintf(file, "# - level within previous set: %d \"%s\"\n",
7944 level.file_info.nr, level.name);
7945 fprintf(file, "# - previous author: %s\n",
7947 fprintf(file, "# - previous save date: ");
7949 if (level.creation_date.src == DATE_SRC_LEVELFILE)
7951 fprintf(file, "%04d-%02d-%02d\n",
7952 level.creation_date.year,
7953 level.creation_date.month,
7954 level.creation_date.day);
7958 fprintf(file, "not recorded\n");
7964 if (level_nr > leveldir_current->last_level)
7965 UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9);
7967 // else: allow the save even if annotation failed
7969 // now... spray graffiti on the old level vital statistics
7970 // user can change these; just trying to set a good baseline
7972 // don't truncate names for fear of making offensive or silly:
7973 // long-named original author only recorded in levelinfo.conf.
7974 // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe"
7975 if (!strEqual(level.author, leveldir_current->author))
7977 setString(&mod_name, getStringCat3(leveldir_current->author,
7978 " after ", level.author));
7980 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7981 setString(&mod_name,
7982 getStringCat2(leveldir_current->author, " (ed.)"));
7984 if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN)
7985 setString(&mod_name, leveldir_current->author);
7987 strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN);
7989 // less worried about truncation here
7990 setString(&mod_name, getStringCat2("Mod: ", level.name));
7991 strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN);
7995 static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
7996 short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
8000 for (x = 0; x < lev_fieldx; x++)
8001 for (y = 0; y < lev_fieldy; y++)
8002 dst[x][y] = src[x][y];
8005 static int setSelectboxValue(int selectbox_id, int new_value)
8007 int new_index_value = 0;
8010 for (i = 0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
8011 if (selectbox_info[selectbox_id].options[i].value == new_value)
8012 new_index_value = i;
8014 *selectbox_info[selectbox_id].value =
8015 selectbox_info[selectbox_id].options[new_index_value].value;
8017 return new_index_value;
8020 static void setSelectboxSpecialActionVariablesIfNeeded(void)
8024 // change action mode and arg variables according to action type variable
8025 for (i = 0; action_arg_options[i].value != -1; i++)
8027 if (action_arg_options[i].value == custom_element_change.action_type)
8029 int mode = action_arg_options[i].mode;
8031 // only change if corresponding selectbox has changed
8032 if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options !=
8033 action_arg_modes[mode])
8034 custom_element_change.action_mode = -1;
8036 // only change if corresponding selectbox has changed
8037 if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options !=
8038 action_arg_options[i].options)
8039 custom_element_change.action_arg = -1;
8046 static void setSelectboxSpecialActionOptions(void)
8050 // change action mode and arg selectbox according to action type selectbox
8051 for (i = 0; action_arg_options[i].value != -1; i++)
8053 if (action_arg_options[i].value == custom_element_change.action_type)
8055 int mode = action_arg_options[i].mode;
8057 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE,
8058 action_arg_modes[mode]);
8059 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE,
8060 custom_element_change.action_mode);
8062 ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG,
8063 action_arg_options[i].options);
8064 ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG,
8065 custom_element_change.action_arg);
8071 static void copy_custom_element_settings(int element_from, int element_to)
8073 struct ElementInfo *ei_from = &element_info[element_from];
8074 struct ElementInfo *ei_to = &element_info[element_to];
8076 copyElementInfo(ei_from, ei_to);
8079 static void replace_custom_element_in_settings(int element_from,
8084 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8086 struct ElementInfo *ei = &element_info[i];
8088 for (y = 0; y < 3; y++)
8089 for (x = 0; x < 3; x++)
8090 if (ei->content.e[x][y] == element_from)
8091 ei->content.e[x][y] = element_to;
8093 for (j = 0; j < ei->num_change_pages; j++)
8095 struct ElementChangeInfo *change = &ei->change_page[j];
8097 if (change->target_element == element_from)
8098 change->target_element = element_to;
8100 if (change->initial_trigger_element == element_from)
8101 change->initial_trigger_element = element_to;
8103 if (change->action_element == element_from)
8104 change->action_element = element_to;
8106 for (y = 0; y < 3; y++)
8107 for (x = 0; x < 3; x++)
8108 if (change->target_content.e[x][y] == element_from)
8109 change->target_content.e[x][y] = element_to;
8112 if (ei->group != NULL) // group or internal
8113 for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
8114 if (ei->group->element[j] == element_from)
8115 ei->group->element[j] = element_to;
8119 static void replace_custom_element_in_playfield(int element_from,
8124 for (x = 0; x < lev_fieldx; x++)
8125 for (y = 0; y < lev_fieldy; y++)
8126 if (Tile[x][y] == element_from)
8127 Tile[x][y] = element_to;
8130 static boolean CopyCustomElement(int element_old, int element_new,
8133 int copy_mode_orig = copy_mode;
8135 if (copy_mode == GADGET_ID_CUSTOM_COPY)
8137 element_new = (IS_CUSTOM_ELEMENT(element_old) ?
8138 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8139 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8141 else if (copy_mode == GADGET_ID_CUSTOM_PASTE)
8143 element_old = (IS_CUSTOM_ELEMENT(element_new) ?
8144 EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
8145 copy_mode = GADGET_ID_CUSTOM_COPY_TO;
8147 level.changed = TRUE;
8149 else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
8151 Request("Please choose custom element!", REQ_CONFIRM);
8155 else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new))
8157 Request("Please choose group element!", REQ_CONFIRM);
8163 level.changed = TRUE;
8166 // when modifying custom/group element, ask for copying level template
8167 if (copy_mode_orig != GADGET_ID_CUSTOM_COPY && level.use_custom_template)
8169 if (!AskToCopyAndModifyLevelTemplate())
8173 if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
8175 copy_custom_element_settings(element_new, element_old);
8177 else if (copy_mode == GADGET_ID_CUSTOM_COPY_TO)
8179 copy_custom_element_settings(element_old, element_new);
8181 else if (copy_mode == GADGET_ID_CUSTOM_EXCHANGE)
8183 copy_custom_element_settings(element_old, EL_INTERNAL_DUMMY);
8184 copy_custom_element_settings(element_new, element_old);
8185 copy_custom_element_settings(EL_INTERNAL_DUMMY, element_new);
8187 replace_custom_element_in_settings(element_old, EL_INTERNAL_DUMMY);
8188 replace_custom_element_in_settings(element_new, element_old);
8189 replace_custom_element_in_settings(EL_INTERNAL_DUMMY, element_new);
8191 replace_custom_element_in_playfield(element_old, EL_INTERNAL_DUMMY);
8192 replace_custom_element_in_playfield(element_new, element_old);
8193 replace_custom_element_in_playfield(EL_INTERNAL_DUMMY, element_new);
8196 UpdateCustomElementGraphicGadgets();
8197 DrawPropertiesWindow();
8202 static void CopyCustomElementPropertiesToEditor(int element)
8205 int current_change_page = element_info[element].current_change_page;
8207 // dynamically (re)build selectbox for selecting change page
8208 for (i = 0; i < element_info[element].num_change_pages; i++)
8210 sprintf(options_change_page_strings[i], "%d", i + 1);
8212 options_change_page[i].value = i;
8213 options_change_page[i].text = options_change_page_strings[i];
8216 options_change_page[i].value = -1;
8217 options_change_page[i].text = NULL;
8219 // needed here to initialize combined element properties
8220 InitElementPropertiesEngine(level.game_version);
8222 element_info[element].change =
8223 &element_info[element].change_page[current_change_page];
8225 custom_element = element_info[element];
8226 custom_element_change = *element_info[element].change;
8228 // needed to initially set selectbox options for special action options
8229 setSelectboxSpecialActionOptions();
8231 // needed to initially set selectbox value variables to reliable defaults
8232 for (i = 0; i < ED_NUM_SELECTBOX; i++)
8233 setSelectboxValue(i, *selectbox_info[i].value);
8235 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8236 custom_element_properties[i] = HAS_PROPERTY(element, i);
8238 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8239 custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
8241 // ---------- element settings: configure (custom elements) -----------------
8243 // set accessible layer selectbox help value
8244 custom_element.access_type =
8245 (IS_WALKABLE(element) ? EP_WALKABLE :
8246 IS_PASSABLE(element) ? EP_PASSABLE :
8247 custom_element.access_type);
8248 custom_element.access_layer =
8249 (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER :
8250 IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE :
8251 IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER :
8252 custom_element.access_layer);
8253 custom_element.access_protected =
8254 (IS_PROTECTED(element) ? 1 : 0);
8255 custom_element_properties[EP_ACCESSIBLE] =
8256 (IS_ACCESSIBLE_OVER(element) ||
8257 IS_ACCESSIBLE_INSIDE(element) ||
8258 IS_ACCESSIBLE_UNDER(element));
8260 // set walk-to-object action selectbox help value
8261 custom_element.walk_to_action =
8262 (IS_DIGGABLE(element) ? EP_DIGGABLE :
8263 IS_COLLECTIBLE_ONLY(element) ? EP_COLLECTIBLE_ONLY :
8264 IS_DROPPABLE(element) ? EP_DROPPABLE :
8265 IS_THROWABLE(element) ? EP_THROWABLE :
8266 IS_PUSHABLE(element) ? EP_PUSHABLE :
8267 custom_element.walk_to_action);
8268 custom_element_properties[EP_WALK_TO_OBJECT] =
8269 (IS_DIGGABLE(element) ||
8270 IS_COLLECTIBLE_ONLY(element) ||
8271 IS_DROPPABLE(element) ||
8272 IS_THROWABLE(element) ||
8273 IS_PUSHABLE(element));
8275 // set smash targets selectbox help value
8276 custom_element.smash_targets =
8277 (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING :
8278 CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES :
8279 CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER :
8280 custom_element.smash_targets);
8281 custom_element_properties[EP_CAN_SMASH] =
8282 (CAN_SMASH_EVERYTHING(element) ||
8283 CAN_SMASH_ENEMIES(element) ||
8284 CAN_SMASH_PLAYER(element));
8286 // set deadliness selectbox help value
8287 custom_element.deadliness =
8288 (DONT_TOUCH(element) ? EP_DONT_TOUCH :
8289 DONT_GET_HIT_BY(element) ? EP_DONT_GET_HIT_BY :
8290 DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
8291 DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
8292 custom_element.deadliness);
8293 custom_element_properties[EP_DEADLY] =
8294 (DONT_TOUCH(element) ||
8295 DONT_GET_HIT_BY(element) ||
8296 DONT_COLLIDE_WITH(element) ||
8297 DONT_RUN_INTO(element));
8299 // ---------- element settings: advanced (custom elements) ------------------
8301 // set "change by direct action" selectbox help value
8302 custom_element_change.direct_action =
8303 (HAS_CHANGE_EVENT(element, CE_NEXT_TO_PLAYER) ? CE_NEXT_TO_PLAYER :
8304 HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
8305 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
8306 HAS_CHANGE_EVENT(element, CE_SWITCHED_BY_PLAYER) ? CE_SWITCHED_BY_PLAYER :
8307 HAS_CHANGE_EVENT(element, CE_SNAPPED_BY_PLAYER) ? CE_SNAPPED_BY_PLAYER :
8308 HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
8309 HAS_CHANGE_EVENT(element, CE_ENTERED_BY_PLAYER) ? CE_ENTERED_BY_PLAYER :
8310 HAS_CHANGE_EVENT(element, CE_LEFT_BY_PLAYER) ? CE_LEFT_BY_PLAYER :
8311 HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
8312 HAS_CHANGE_EVENT(element, CE_SWITCHED) ? CE_SWITCHED :
8313 HAS_CHANGE_EVENT(element, CE_HITTING_SOMETHING) ? CE_HITTING_SOMETHING :
8314 HAS_CHANGE_EVENT(element, CE_HIT_BY_SOMETHING) ? CE_HIT_BY_SOMETHING :
8315 HAS_CHANGE_EVENT(element, CE_BLOCKED) ? CE_BLOCKED :
8316 HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
8317 HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
8318 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES) ? CE_VALUE_CHANGES :
8319 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES) ? CE_SCORE_CHANGES :
8320 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO) ? CE_VALUE_GETS_ZERO :
8321 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO) ? CE_SCORE_GETS_ZERO :
8322 HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ? CE_CLICKED_BY_MOUSE :
8323 HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ? CE_PRESSED_BY_MOUSE :
8324 custom_element_change.direct_action);
8326 // set "change by other element action" selectbox help value
8327 custom_element_change.other_action =
8328 (HAS_CHANGE_EVENT(element, CE_PLAYER_NEXT_TO_X) ? CE_PLAYER_NEXT_TO_X :
8329 HAS_CHANGE_EVENT(element, CE_PLAYER_TOUCHES_X) ? CE_PLAYER_TOUCHES_X :
8330 HAS_CHANGE_EVENT(element, CE_PLAYER_PRESSES_X) ? CE_PLAYER_PRESSES_X :
8331 HAS_CHANGE_EVENT(element, CE_PLAYER_SWITCHES_X) ? CE_PLAYER_SWITCHES_X :
8332 HAS_CHANGE_EVENT(element, CE_PLAYER_SNAPS_X) ? CE_PLAYER_SNAPS_X :
8333 HAS_CHANGE_EVENT(element, CE_PLAYER_PUSHES_X) ? CE_PLAYER_PUSHES_X :
8334 HAS_CHANGE_EVENT(element, CE_PLAYER_ENTERS_X) ? CE_PLAYER_ENTERS_X :
8335 HAS_CHANGE_EVENT(element, CE_PLAYER_LEAVES_X) ? CE_PLAYER_LEAVES_X :
8336 HAS_CHANGE_EVENT(element, CE_PLAYER_DIGS_X) ? CE_PLAYER_DIGS_X :
8337 HAS_CHANGE_EVENT(element, CE_PLAYER_COLLECTS_X) ? CE_PLAYER_COLLECTS_X :
8338 HAS_CHANGE_EVENT(element, CE_PLAYER_DROPS_X) ? CE_PLAYER_DROPS_X :
8339 HAS_CHANGE_EVENT(element, CE_NEXT_TO_X) ? CE_NEXT_TO_X :
8340 HAS_CHANGE_EVENT(element, CE_TOUCHING_X) ? CE_TOUCHING_X :
8341 HAS_CHANGE_EVENT(element, CE_HITTING_X) ? CE_HITTING_X :
8342 HAS_CHANGE_EVENT(element, CE_DIGGING_X) ? CE_DIGGING_X :
8343 HAS_CHANGE_EVENT(element, CE_HIT_BY_X) ? CE_HIT_BY_X :
8344 HAS_CHANGE_EVENT(element, CE_SWITCH_OF_X) ? CE_SWITCH_OF_X :
8345 HAS_CHANGE_EVENT(element, CE_CHANGE_OF_X) ? CE_CHANGE_OF_X :
8346 HAS_CHANGE_EVENT(element, CE_EXPLOSION_OF_X) ? CE_EXPLOSION_OF_X :
8347 HAS_CHANGE_EVENT(element, CE_MOVE_OF_X) ? CE_MOVE_OF_X :
8348 HAS_CHANGE_EVENT(element, CE_CREATION_OF_X) ? CE_CREATION_OF_X :
8349 HAS_CHANGE_EVENT(element, CE_VALUE_CHANGES_OF_X) ? CE_VALUE_CHANGES_OF_X :
8350 HAS_CHANGE_EVENT(element, CE_SCORE_CHANGES_OF_X) ? CE_SCORE_CHANGES_OF_X :
8351 HAS_CHANGE_EVENT(element, CE_VALUE_GETS_ZERO_OF_X) ? CE_VALUE_GETS_ZERO_OF_X :
8352 HAS_CHANGE_EVENT(element, CE_SCORE_GETS_ZERO_OF_X) ? CE_SCORE_GETS_ZERO_OF_X :
8353 HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ? CE_MOUSE_CLICKED_ON_X :
8354 HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X) ? CE_MOUSE_PRESSED_ON_X :
8355 custom_element_change.other_action);
8358 static void CopyGroupElementPropertiesToEditor(int element)
8360 group_element_info = *element_info[element].group;
8361 custom_element = element_info[element]; // needed for description
8364 static void CopyEmptyElementPropertiesToEditor(int element)
8366 custom_element = element_info[element];
8369 static void CopyClassicElementPropertiesToEditor(int element)
8371 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8372 custom_element_properties[EP_CAN_MOVE_INTO_ACID] =
8373 getMoveIntoAcidProperty(&level, element);
8375 if (MAYBE_DONT_COLLIDE_WITH(element))
8376 custom_element_properties[EP_DONT_COLLIDE_WITH] =
8377 getDontCollideWithProperty(&level, element);
8380 static void CopyElementPropertiesToEditor(int element)
8382 if (IS_CUSTOM_ELEMENT(element))
8383 CopyCustomElementPropertiesToEditor(element);
8384 else if (IS_GROUP_ELEMENT(element))
8385 CopyGroupElementPropertiesToEditor(element);
8386 else if (IS_EMPTY_ELEMENT(element))
8387 CopyEmptyElementPropertiesToEditor(element);
8389 CopyClassicElementPropertiesToEditor(element);
8392 static boolean AskToCopyAndModifyLevelTemplate(void)
8394 if (Request("Copy and modify settings from level template?", REQ_ASK))
8396 level.use_custom_template = FALSE;
8398 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_1],
8399 GDI_CHECKED, FALSE, GDI_END);
8400 ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE_2],
8401 GDI_CHECKED, FALSE, GDI_END);
8407 LoadLevelTemplate(-1); // this resets all element modifications ...
8409 DrawEditModeWindow(); // ... and copies them to 'custom_element'
8415 static void CopyCustomElementPropertiesToGame(int element)
8418 int access_type_and_layer;
8420 // mark that this custom element has been modified
8421 custom_element.modified_settings = TRUE;
8422 level.changed = TRUE;
8424 if (level.use_custom_template)
8425 AskToCopyAndModifyLevelTemplate();
8427 element_info[element] = custom_element;
8428 *element_info[element].change = custom_element_change;
8430 // ---------- element settings: configure (custom elements) -----------------
8432 // set accessible property from checkbox and selectbox
8433 custom_element_properties[EP_WALKABLE_OVER] = FALSE;
8434 custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
8435 custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
8436 custom_element_properties[EP_PASSABLE_OVER] = FALSE;
8437 custom_element_properties[EP_PASSABLE_INSIDE] = FALSE;
8438 custom_element_properties[EP_PASSABLE_UNDER] = FALSE;
8439 access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ?
8440 EP_WALKABLE_OVER : EP_PASSABLE_OVER) +
8441 (custom_element.access_layer - EP_ACCESSIBLE_OVER));
8442 custom_element_properties[access_type_and_layer] =
8443 custom_element_properties[EP_ACCESSIBLE];
8444 custom_element_properties[EP_PROTECTED] =
8445 (custom_element.access_protected != 0 &&
8446 custom_element_properties[EP_ACCESSIBLE]);
8448 // set walk-to-object property from checkbox and selectbox
8449 custom_element_properties[EP_DIGGABLE] = FALSE;
8450 custom_element_properties[EP_COLLECTIBLE_ONLY] = FALSE;
8451 custom_element_properties[EP_DROPPABLE] = FALSE;
8452 custom_element_properties[EP_THROWABLE] = FALSE;
8453 custom_element_properties[EP_PUSHABLE] = FALSE;
8454 custom_element_properties[custom_element.walk_to_action] =
8455 custom_element_properties[EP_WALK_TO_OBJECT];
8457 // set smash property from checkbox and selectbox
8458 custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE;
8459 custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE;
8460 custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE;
8461 custom_element_properties[custom_element.smash_targets] =
8462 custom_element_properties[EP_CAN_SMASH];
8464 // set deadliness property from checkbox and selectbox
8465 custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
8466 custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
8467 custom_element_properties[EP_DONT_GET_HIT_BY] = FALSE;
8468 custom_element_properties[EP_DONT_TOUCH] = FALSE;
8469 custom_element_properties[custom_element.deadliness] =
8470 custom_element_properties[EP_DEADLY];
8472 // ---------- element settings: advanced (custom elements) ------------------
8474 // set player change event from checkbox and selectbox
8475 custom_element_change_events[CE_NEXT_TO_PLAYER] = FALSE;
8476 custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE;
8477 custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
8478 custom_element_change_events[CE_SWITCHED_BY_PLAYER] = FALSE;
8479 custom_element_change_events[CE_SNAPPED_BY_PLAYER] = FALSE;
8480 custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
8481 custom_element_change_events[CE_ENTERED_BY_PLAYER] = FALSE;
8482 custom_element_change_events[CE_LEFT_BY_PLAYER] = FALSE;
8483 custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
8484 custom_element_change_events[CE_SWITCHED] = FALSE;
8485 custom_element_change_events[CE_HITTING_SOMETHING] = FALSE;
8486 custom_element_change_events[CE_HIT_BY_SOMETHING] = FALSE;
8487 custom_element_change_events[CE_BLOCKED] = FALSE;
8488 custom_element_change_events[CE_IMPACT] = FALSE;
8489 custom_element_change_events[CE_SMASHED] = FALSE;
8490 custom_element_change_events[CE_VALUE_CHANGES] = FALSE;
8491 custom_element_change_events[CE_SCORE_CHANGES] = FALSE;
8492 custom_element_change_events[CE_VALUE_GETS_ZERO] = FALSE;
8493 custom_element_change_events[CE_SCORE_GETS_ZERO] = FALSE;
8494 custom_element_change_events[CE_CLICKED_BY_MOUSE] = FALSE;
8495 custom_element_change_events[CE_PRESSED_BY_MOUSE] = FALSE;
8496 custom_element_change_events[custom_element_change.direct_action] =
8497 custom_element_change_events[CE_BY_DIRECT_ACTION];
8499 // set other element action change event from checkbox and selectbox
8500 custom_element_change_events[CE_PLAYER_NEXT_TO_X] = FALSE;
8501 custom_element_change_events[CE_PLAYER_TOUCHES_X] = FALSE;
8502 custom_element_change_events[CE_PLAYER_PRESSES_X] = FALSE;
8503 custom_element_change_events[CE_PLAYER_SWITCHES_X] = FALSE;
8504 custom_element_change_events[CE_PLAYER_SNAPS_X] = FALSE;
8505 custom_element_change_events[CE_PLAYER_PUSHES_X] = FALSE;
8506 custom_element_change_events[CE_PLAYER_ENTERS_X] = FALSE;
8507 custom_element_change_events[CE_PLAYER_LEAVES_X] = FALSE;
8508 custom_element_change_events[CE_PLAYER_DIGS_X] = FALSE;
8509 custom_element_change_events[CE_PLAYER_COLLECTS_X] = FALSE;
8510 custom_element_change_events[CE_PLAYER_DROPS_X] = FALSE;
8511 custom_element_change_events[CE_NEXT_TO_X] = FALSE;
8512 custom_element_change_events[CE_TOUCHING_X] = FALSE;
8513 custom_element_change_events[CE_HITTING_X] = FALSE;
8514 custom_element_change_events[CE_DIGGING_X] = FALSE;
8515 custom_element_change_events[CE_HIT_BY_X] = FALSE;
8516 custom_element_change_events[CE_SWITCH_OF_X] = FALSE;
8517 custom_element_change_events[CE_CHANGE_OF_X] = FALSE;
8518 custom_element_change_events[CE_EXPLOSION_OF_X] = FALSE;
8519 custom_element_change_events[CE_MOVE_OF_X] = FALSE;
8520 custom_element_change_events[CE_CREATION_OF_X] = FALSE;
8521 custom_element_change_events[CE_VALUE_CHANGES_OF_X] = FALSE;
8522 custom_element_change_events[CE_SCORE_CHANGES_OF_X] = FALSE;
8523 custom_element_change_events[CE_VALUE_GETS_ZERO_OF_X] = FALSE;
8524 custom_element_change_events[CE_SCORE_GETS_ZERO_OF_X] = FALSE;
8525 custom_element_change_events[CE_MOUSE_CLICKED_ON_X] = FALSE;
8526 custom_element_change_events[CE_MOUSE_PRESSED_ON_X] = FALSE;
8527 custom_element_change_events[custom_element_change.other_action] =
8528 custom_element_change_events[CE_BY_OTHER_ACTION];
8530 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
8531 SET_PROPERTY(element, i, custom_element_properties[i]);
8533 for (i = 0; i < NUM_CHANGE_EVENTS; i++)
8534 SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
8536 // copy change events also to special level editor variable
8537 custom_element = element_info[element];
8538 custom_element_change = *element_info[element].change;
8540 // needed here to restore runtime value "element_info[element].gfx_element"
8541 InitElementPropertiesGfxElement();
8544 static void CopyGroupElementPropertiesToGame(int element)
8546 // mark that this group element has been modified
8547 custom_element.modified_settings = TRUE;
8548 level.changed = TRUE;
8550 if (level.use_custom_template)
8551 AskToCopyAndModifyLevelTemplate();
8553 element_info[element] = custom_element;
8554 *element_info[element].group = group_element_info;
8556 // needed here to restore runtime value "element_info[element].gfx_element"
8557 InitElementPropertiesGfxElement();
8560 static void CopyEmptyElementPropertiesToGame(int element)
8562 // mark that this empty element has been modified
8563 custom_element.modified_settings = TRUE;
8564 level.changed = TRUE;
8566 if (level.use_custom_template)
8567 AskToCopyAndModifyLevelTemplate();
8569 element_info[element] = custom_element;
8571 // needed here to restore runtime value "element_info[element].gfx_element"
8572 InitElementPropertiesGfxElement();
8575 static void CopyClassicElementPropertiesToGame(int element)
8577 if (IS_PLAYER_ELEMENT(element) || COULD_MOVE_INTO_ACID(element))
8578 setMoveIntoAcidProperty(&level, element,
8579 custom_element_properties[EP_CAN_MOVE_INTO_ACID]);
8581 if (MAYBE_DONT_COLLIDE_WITH(element))
8582 setDontCollideWithProperty(&level, element,
8583 custom_element_properties[EP_DONT_COLLIDE_WITH]);
8586 static void CopyElementPropertiesToGame(int element)
8588 if (IS_CUSTOM_ELEMENT(element))
8589 CopyCustomElementPropertiesToGame(element);
8590 else if (IS_GROUP_ELEMENT(element))
8591 CopyGroupElementPropertiesToGame(element);
8592 else if (IS_EMPTY_ELEMENT(element))
8593 CopyEmptyElementPropertiesToGame(element);
8595 CopyClassicElementPropertiesToGame(element);
8599 static void CheckElementDescriptions(void)
8603 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8604 if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
8605 Warn("no element description file for element '%s'", EL_NAME(i));
8609 static int getMaxEdFieldX(boolean has_scrollbar)
8611 int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
8612 int sxsize = SXSIZE - scrollbar_width;
8613 int max_ed_fieldx = sxsize / ed_tilesize;
8615 return max_ed_fieldx;
8618 static int getMaxEdFieldY(boolean has_scrollbar)
8620 int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ?
8621 INFOTEXT_YSIZE_FULL : 0);
8622 int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
8623 int sysize = SYSIZE - scrollbar_height - infotext_height;
8624 int max_ed_fieldy = sysize / ed_tilesize;
8626 return max_ed_fieldy;
8629 static void InitZoomLevelSettings(int zoom_tilesize)
8631 static int last_game_engine_type = GAME_ENGINE_TYPE_UNKNOWN;
8633 if (zoom_tilesize == -1 && level.game_engine_type != last_game_engine_type)
8635 ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
8636 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
8638 // make sure that tile size is always a power of 2
8639 ed_tilesize = (1 << log_2(ed_tilesize));
8641 if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8643 ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
8644 ed_tilesize_default = DEFAULT_EDITOR_TILESIZE_MM;
8648 last_game_engine_type = level.game_engine_type;
8650 // limit zoom tilesize by upper and lower bound
8651 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
8653 // store zoom tilesize in auto setup file only if it was manually changed
8654 if (zoom_tilesize != -1)
8655 setup.auto_setup.editor_zoom_tilesize = ed_tilesize;
8657 MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
8658 MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
8661 static void InitDrawingElements(void)
8663 static int game_engine_type_last = GAME_ENGINE_TYPE_UNKNOWN;
8665 if (level.game_engine_type == game_engine_type_last)
8668 if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
8670 new_element1 = EL_SP_CHIP_SINGLE;
8671 new_element2 = EL_EMPTY;
8672 new_element3 = EL_SP_BASE;
8674 else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
8676 new_element1 = EL_MM_MIRROR_START;
8677 new_element2 = EL_EMPTY;
8678 new_element3 = EL_MM_WOODEN_WALL;
8682 new_element1 = EL_WALL;
8683 new_element2 = EL_EMPTY;
8684 new_element3 = EL_SAND;
8687 game_engine_type_last = level.game_engine_type;
8690 static void InitLevelSetInfo(void)
8692 snprintf(levelset_name, MAX_LEVEL_NAME_LEN + 1,
8693 "%s", leveldir_current->name);
8694 snprintf(levelset_author, MAX_LEVEL_AUTHOR_LEN + 1,
8695 "%s", leveldir_current->author);
8697 levelset_num_levels = leveldir_current->levels;
8699 levelset_use_levelset_artwork = FALSE;
8700 levelset_copy_level_template = FALSE;
8702 levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE;
8705 static void ChangeEditorToLevelSet(char *levelset_subdir)
8707 leveldir_current = getTreeInfoFromIdentifier(leveldir_first, levelset_subdir);
8709 // the previous level set might have used custom artwork
8710 ReloadCustomArtwork(0);
8712 LoadLevelSetup_SeriesInfo();
8714 SaveLevelSetup_LastSeries();
8715 SaveLevelSetup_SeriesInfo();
8719 LoadLevel(level_nr);
8720 LoadScore(level_nr);
8725 static boolean useEditorDoorAnimation(void)
8727 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
8728 boolean door_1_viewport_unchanged =
8729 (vp_door_1->x == DX &&
8730 vp_door_1->y == DY &&
8731 vp_door_1->width == DXSIZE &&
8732 vp_door_1->height == DYSIZE);
8733 boolean door_1_contains_toolbox =
8736 EX + EXSIZE <= DX + DXSIZE &&
8737 EY + EYSIZE <= DY + DYSIZE);
8739 return (door_1_viewport_unchanged && door_1_contains_toolbox);
8742 static void DrawEditorDoorBackground(int graphic, int x, int y,
8743 int width, int height)
8745 struct GraphicInfo *g = &graphic_info[graphic];
8747 if (g->bitmap != NULL)
8748 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
8749 MIN(width, g->width), MIN(height, g->height), x, y);
8751 ClearRectangle(drawto, x, y, width, height);
8754 static void DrawEditorDoorContent(void)
8756 // needed for gadgets drawn on background (like palette scrollbar)
8757 SetDoorBackgroundImage(IMG_UNDEFINED);
8759 // copy default editor door content to main double buffer
8760 DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE);
8763 DrawSpecialEditorDoor();
8765 // draw new control window
8766 DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE);
8768 // draw all toolbox gadgets to editor doors
8769 MapControlButtons();
8771 // draw all palette gadgets to editor doors
8772 ModifyEditorElementList();
8773 RedrawDrawingElements();
8775 // copy actual editor door content to door double buffer for OpenDoor()
8776 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
8779 void DrawLevelEd(void)
8781 int fade_mask = REDRAW_FIELD;
8783 FadeSoundsAndMusic();
8786 fade_mask = REDRAW_ALL;
8790 // needed if different viewport properties defined for editor
8791 ChangeViewportPropertiesIfNeeded();
8795 InitZoomLevelSettings(-1);
8796 InitDrawingElements();
8800 CheckElementDescriptions();
8803 if (level_editor_test_game)
8805 CopyPlayfield(level.field, Tile);
8806 CopyPlayfield(TileBackup, level.field);
8808 level_editor_test_game = FALSE;
8812 edit_mode = ED_MODE_DRAWING;
8813 edit_mode_levelinfo = ED_MODE_LEVELINFO_LEVEL;
8814 edit_mode_properties = ED_MODE_PROPERTIES_INFO;
8822 // redraw_mask |= REDRAW_ALL;
8824 FreeLevelEditorGadgets();
8825 CreateLevelEditorGadgets();
8827 ReinitializeElementList(); // update dynamic level element list
8828 ReinitializeElementListButtons(); // custom element may look different
8830 InitElementPropertiesGfxElement();
8834 DrawEditModeWindow_PlayfieldOnly();
8836 DrawMaskedBorder(fade_mask);
8838 // use door animation if door 1 viewport is unchanged and contains toolbox
8839 if (useEditorDoorAnimation())
8843 DrawEditorDoorContent();
8845 OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM);
8849 DrawEditorDoorContent();
8854 SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2);
8857 static void AdjustDrawingAreaGadgets(void)
8859 int ed_xsize = lev_fieldx + 2;
8860 int ed_ysize = lev_fieldy + 2;
8861 int max_ed_fieldx = MAX_ED_FIELDX;
8862 int max_ed_fieldy = MAX_ED_FIELDY;
8863 boolean horizontal_scrollbar_needed;
8864 boolean vertical_scrollbar_needed;
8865 int x, y, width, height;
8867 if (suppressBorderElement())
8869 ed_xsize = max_ed_fieldx;
8870 ed_ysize = max_ed_fieldy;
8873 // check if we need any scrollbars
8874 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8875 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8877 // check if we have a smaller editor field because of scrollbars
8878 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8879 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8881 // check again if we now need more scrollbars because of less space
8882 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
8883 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
8885 // check if editor field gets even smaller after adding new scrollbars
8886 max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
8887 max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
8889 ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
8890 ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
8892 x = SX + ed_fieldx * ed_tilesize;
8893 y = SY + ed_fieldy * ed_tilesize;
8895 width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
8896 height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
8898 // adjust drawing area gadget
8899 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
8900 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
8901 GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
8904 // adjust horizontal scrollbar gadgets
8905 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
8908 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
8909 GDI_X, x - ED_SCROLLBUTTON_XSIZE,
8912 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
8915 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
8918 // adjust vertical scrollbar gadgets
8919 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
8922 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
8924 GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
8926 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
8929 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
8933 static void AdjustLevelScrollPosition(void)
8935 if (level_xpos < -1)
8937 if (level_xpos > lev_fieldx - ed_fieldx + 1)
8938 level_xpos = lev_fieldx - ed_fieldx + 1;
8939 if (lev_fieldx < ed_fieldx - 2)
8942 if (level_ypos < -1)
8944 if (level_ypos > lev_fieldy - ed_fieldy + 1)
8945 level_ypos = lev_fieldy - ed_fieldy + 1;
8946 if (lev_fieldy < ed_fieldy - 2)
8949 if (suppressBorderElement())
8956 static void AdjustEditorScrollbar(int id)
8958 struct GadgetInfo *gi = level_editor_gadget[id];
8959 int items_max, items_visible, item_position;
8961 if (id == GADGET_ID_SCROLL_HORIZONTAL)
8963 items_max = MAX(lev_fieldx + 2, ed_fieldx);
8964 items_visible = ed_fieldx;
8965 item_position = level_xpos + 1;
8969 items_max = MAX(lev_fieldy + 2, ed_fieldy);
8970 items_visible = ed_fieldy;
8971 item_position = level_ypos + 1;
8974 if (item_position > items_max - items_visible)
8975 item_position = items_max - items_visible;
8977 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8978 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
8981 static void AdjustElementListScrollbar(void)
8983 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL];
8984 int items_max, items_visible, item_position;
8986 // correct position of element list scrollbar
8987 if (element_shift < 0)
8989 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
8990 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
8992 items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
8993 items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
8994 item_position = element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ;
8996 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
8997 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
8998 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
9001 static void ModifyEditorCounterValue(int counter_id, int new_value)
9003 int *counter_value = counterbutton_info[counter_id].value;
9004 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9005 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9007 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
9009 if (counter_value != NULL)
9010 *counter_value = gi->textinput.number_value;
9013 static void ModifyEditorCounterLimits(int counter_id, int min, int max)
9015 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
9016 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9018 ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
9020 if (counter_id >= ED_COUNTER_ID_ELEMENT_VALUE1 &&
9021 counter_id <= ED_COUNTER_ID_ELEMENT_VALUE4)
9023 int gadget_id_up = counterbutton_info[counter_id].gadget_id_up;
9024 struct GadgetInfo *gi_up = level_editor_gadget[gadget_id_up];
9026 ModifyGadget(gi, GDI_TEXT_SIZE, (max < 10 ? 1 : 3), GDI_END);
9027 ModifyGadget(gi_up, GDI_X, gi->x + gi->width + ED_GADGET_SMALL_DISTANCE,
9032 static void ModifyEditorSelectboxValue(int selectbox_id, int new_value)
9034 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9035 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9036 int new_index_value = setSelectboxValue(selectbox_id, new_value);
9038 ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
9041 static void ModifyEditorSelectboxOptions(int selectbox_id,
9042 struct ValueTextInfo *options)
9044 int gadget_id = selectbox_info[selectbox_id].gadget_id;
9045 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9047 selectbox_info[selectbox_id].options = options;
9049 // set index to zero -- list may be shorter now (correct later, if needed)
9050 ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0,
9051 GDI_SELECTBOX_OPTIONS, options, GDI_END);
9054 static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize)
9056 int gadget_id = drawingarea_info[drawingarea_id].gadget_id;
9057 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9059 drawingarea_info[drawingarea_id].area_xsize = xsize;
9060 drawingarea_info[drawingarea_id].area_ysize = ysize;
9062 ModifyGadget(gi, GDI_AREA_SIZE, xsize, ysize, GDI_END);
9065 static void ModifyEditorElementList(void)
9069 if (!use_permanent_palette && edit_mode != ED_MODE_PALETTE)
9072 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
9074 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
9075 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9076 struct GadgetDesign *gd = &gi->deco.design;
9077 int element = editor_elements[element_shift + i];
9078 int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size);
9082 getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y);
9084 ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
9090 static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos)
9092 int graphic = el2edimg(element);
9093 int tile_size = BUTTON_TILE_SIZE(pos->tile_size);
9099 DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size);
9102 static void ModifyDrawingElementButton(int element, int id)
9104 struct GadgetInfo *gi = level_editor_gadget[id];
9105 Bitmap *deco_bitmap;
9107 int tile_size = gi->deco.width;
9109 getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y);
9111 ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END);
9114 static void PickDrawingElement(int button, int element)
9119 struct XYTileSize *pos;
9121 } de, drawing_elements[] =
9123 { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT },
9124 { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE },
9125 { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT },
9128 if (button < 1 || button > 3)
9131 if (IS_MM_WALL(element))
9132 element = map_mm_wall_element(element);
9134 de = drawing_elements[button - 1];
9136 *de.new_element = element; // update global drawing element variable
9138 DrawDrawingElementGraphic(element, de.pos);
9139 ModifyDrawingElementButton(element, de.id);
9141 redraw_mask |= REDRAW_DOOR_1;
9144 static void RedrawDrawingElements(void)
9146 PickDrawingElement(1, new_element1);
9147 PickDrawingElement(2, new_element2);
9148 PickDrawingElement(3, new_element3);
9151 static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
9153 stick_element_properties_window = FALSE;
9155 SetMainBackgroundImage(IMG_UNDEFINED);
9158 UnmapLevelEditorFieldGadgets();
9160 AdjustDrawingAreaGadgets();
9161 AdjustLevelScrollPosition();
9162 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
9163 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
9165 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
9167 MapMainDrawingArea();
9169 if (remap_toolbox_gadgets)
9171 UnmapLevelEditorToolboxCustomGadgets();
9172 MapLevelEditorToolboxDrawingGadgets();
9176 static void DrawDrawingWindow(void)
9178 DrawDrawingWindowExt(TRUE);
9181 static int getTabulatorBarWidth(void)
9183 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9184 struct GadgetInfo *gd_gi4 = level_editor_gadget[GADGET_ID_PROPERTIES_CHANGE];
9186 return gd_gi4->x - gd_gi1->x + gd_gi4->width;
9189 static int getTabulatorBarHeight(void)
9191 return ED_TAB_BAR_HEIGHT;
9194 static Pixel getTabulatorBarColor(void)
9196 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
9197 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9198 int gd_x = gd->x + gd_gi1->border.width / 2;
9199 int gd_y = gd->y + gd_gi1->height - 1;
9201 return GetPixel(gd->bitmap, gd_x, gd_y);
9204 static void DrawLevelInfoTabulatorGadgets(void)
9206 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL];
9207 Pixel tab_color = getTabulatorBarColor();
9208 int id_first = ED_TAB_BUTTON_ID_LEVELINFO_FIRST;
9209 int id_last = ED_TAB_BUTTON_ID_LEVELINFO_LAST;
9212 for (i = id_first; i <= id_last; i++)
9214 int gadget_id = textbutton_info[i].gadget_id;
9215 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9216 boolean active = (i != edit_mode_levelinfo);
9218 // draw background line below tabulator button
9219 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9221 // draw solid line below inactive tabulator buttons
9222 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9223 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9224 ED_GADGET_TINY_DISTANCE, tab_color);
9226 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9227 MapTextbuttonGadget(i);
9230 // draw little border line below tabulator buttons
9231 if (tab_color != BLACK_PIXEL) // black => transparent
9232 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9233 ED_GADGET_TINY_DISTANCE,
9234 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9237 static void DrawPropertiesTabulatorGadgets(void)
9239 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
9240 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
9241 int gd_x = gd->x + gd_gi1->border.width / 2;
9242 int gd_y = gd->y + gd_gi1->height - 1;
9243 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
9244 int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
9245 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
9248 // draw two config tabulators for player elements
9249 if (IS_PLAYER_ELEMENT(properties_element))
9250 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2;
9252 // draw two config and one "change" tabulator for custom elements
9253 if (IS_CUSTOM_ELEMENT(properties_element))
9254 id_last = ED_TEXTBUTTON_ID_PROPERTIES_CHANGE;
9256 for (i = id_first; i <= id_last; i++)
9258 int gadget_id = textbutton_info[i].gadget_id;
9259 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
9260 boolean active = (i != edit_mode_properties);
9262 // use "config 1" and "config 2" instead of "config" for players and CEs
9263 if (i == ED_TEXTBUTTON_ID_PROPERTIES_CONFIG &&
9264 (IS_PLAYER_ELEMENT(properties_element) ||
9265 IS_CUSTOM_ELEMENT(properties_element)))
9268 // draw background line below tabulator button
9269 ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width, 1);
9271 // draw solid line below inactive tabulator buttons
9272 if (!active && tab_color != BLACK_PIXEL) // black => transparent
9273 FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,
9274 ED_GADGET_TINY_DISTANCE, tab_color);
9276 ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
9277 MapTextbuttonGadget(i);
9280 // draw little border line below tabulator buttons
9281 if (tab_color != BLACK_PIXEL) // black => transparent
9282 FillRectangle(drawto, gd_gi1->x, gd_gi1->y + gd_gi1->height +
9283 ED_GADGET_TINY_DISTANCE,
9284 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
9287 static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
9289 DrawText(SX + xpos, SY + ypos, text, font_nr);
9292 static int PrintElementDescriptionFromFile(char *filename, int font_nr,
9295 int font_width = getFontWidth(font_nr);
9296 int font_height = getFontHeight(font_nr);
9297 int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
9298 int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
9300 return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
9301 max_chars_per_line, -1, max_lines_drawable, 0, -1,
9302 TRUE, FALSE, FALSE);
9305 static void DrawLevelInfoLevel(void)
9309 // draw counter gadgets
9310 for (i = ED_COUNTER_ID_LEVEL_FIRST; i <= ED_COUNTER_ID_LEVEL_LAST; i++)
9311 MapCounterButtons(i);
9313 // draw checkbutton gadgets
9314 for (i = ED_CHECKBUTTON_ID_LEVEL_FIRST; i<= ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
9315 MapCheckbuttonGadget(i);
9317 // draw selectbox gadgets
9318 for (i = ED_SELECTBOX_ID_LEVEL_FIRST; i <= ED_SELECTBOX_ID_LEVEL_LAST; i++)
9319 MapSelectboxGadget(i);
9321 // draw text input gadgets
9322 for (i = ED_TEXTINPUT_ID_LEVEL_FIRST; i <= ED_TEXTINPUT_ID_LEVEL_LAST; i++)
9323 MapTextInputGadget(i);
9326 static char *getLevelSubdirFromSaveMode(int save_mode)
9328 if (save_mode == LEVELSET_SAVE_MODE_CREATE)
9329 return getNewUserLevelSubdir();
9331 return leveldir_current->subdir;
9334 static void DrawLevelInfoLevelSet_DirectoryInfo(void)
9336 char *directory_text = "Level set directory:";
9337 char *directory_name = getLevelSubdirFromSaveMode(levelset_save_mode);
9338 int font1_nr = FONT_TEXT_1;
9339 int font2_nr = FONT_TEXT_2;
9340 int font1_height = getFontHeight(font1_nr);
9341 int yoffset_above = font1_height + ED_GADGET_LINE_DISTANCE;
9342 int x = ED_LEVEL_SETTINGS_X(0);
9343 int y = ED_LEVEL_SETTINGS_Y(6);
9345 PrintInfoText(directory_text, font1_nr, x, y - yoffset_above);
9346 PrintInfoText(directory_name, font2_nr, x, y);
9349 static void DrawLevelInfoLevelSet(void)
9351 boolean artwork_exists = checkIfCustomArtworkExistsForCurrentLevelSet();
9352 boolean template_exists = fileExists(getLocalLevelTemplateFilename());
9355 // draw counter gadgets
9356 for (i = ED_COUNTER_ID_LEVELSET_FIRST; i <= ED_COUNTER_ID_LEVELSET_LAST; i++)
9357 MapCounterButtons(i);
9359 // draw checkbutton gadgets
9360 for (i = ED_CHECKBUTTON_ID_LEVELSET_FIRST; i <= ED_CHECKBUTTON_ID_LEVELSET_LAST; i++)
9362 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE ||
9363 (i == ED_CHECKBUTTON_ID_USE_LEVELSET_ARTWORK && !artwork_exists) ||
9364 (i == ED_CHECKBUTTON_ID_COPY_LEVEL_TEMPLATE && !template_exists))
9367 MapCheckbuttonGadget(i);
9370 // draw selectbox gadgets
9371 for (i = ED_SELECTBOX_ID_LEVELSET_FIRST; i <= ED_SELECTBOX_ID_LEVELSET_LAST; i++)
9372 MapSelectboxGadget(i);
9374 // draw text input gadgets
9375 for (i = ED_TEXTINPUT_ID_LEVELSET_FIRST; i <= ED_TEXTINPUT_ID_LEVELSET_LAST; i++)
9376 MapTextInputGadget(i);
9378 // draw textbutton gadgets
9379 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_LEVELSET);
9382 DrawLevelInfoLevelSet_DirectoryInfo();
9385 static void DrawLevelInfoEditor(void)
9389 // draw counter gadgets
9390 for (i = ED_COUNTER_ID_EDITOR_FIRST; i <= ED_COUNTER_ID_EDITOR_LAST; i++)
9391 MapCounterButtons(i);
9393 // draw checkbutton gadgets
9394 for (i=ED_CHECKBUTTON_ID_EDITOR_FIRST; i<= ED_CHECKBUTTON_ID_EDITOR_LAST; i++)
9395 MapCheckbuttonGadget(i);
9397 // draw radiobutton gadgets
9398 for (i=ED_RADIOBUTTON_ID_EDITOR_FIRST; i<= ED_RADIOBUTTON_ID_EDITOR_LAST; i++)
9399 MapRadiobuttonGadget(i);
9401 // draw drawing area
9402 MapDrawingArea(ED_DRAWING_ID_RANDOM_BACKGROUND);
9404 // draw textbutton gadgets
9405 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2);
9408 static void DrawLevelInfoWindow(void)
9410 char *text = "Global Settings";
9411 int font_nr = FONT_TITLE_1;
9412 struct MenuPosInfo *pos = &editor.settings.headline;
9413 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align);
9414 int sy = SY + pos->y;
9416 stick_element_properties_window = FALSE;
9418 SetAutomaticNumberOfGemsNeeded();
9420 UnmapLevelEditorFieldGadgets();
9422 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
9425 DrawText(sx, sy, text, font_nr);
9427 DrawLevelInfoTabulatorGadgets();
9429 if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVEL)
9430 DrawLevelInfoLevel();
9431 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_LEVELSET)
9432 DrawLevelInfoLevelSet();
9433 else if (edit_mode_levelinfo == ED_MODE_LEVELINFO_EDITOR)
9434 DrawLevelInfoEditor();
9437 static void DrawCustomContentArea(void)
9439 int id = ED_DRAWING_ID_CUSTOM_CONTENT;
9440 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9441 int x1 = right_gadget_border[GADGET_ID_CUSTOM_DEADLINESS];
9442 int x2 = right_gadget_border[GADGET_ID_CUSTOM_EXPLOSION_TYPE];
9443 int x3 = right_gadget_border[GADGET_ID_CUSTOM_EXPLODE_IMPACT];
9444 int xoffset = ED_GADGET_SPACE_DISTANCE;
9446 // add distance for potential left text (without drawing area border)
9447 x2 += getTextWidthForGadget(drawingarea_info[id].text_left);
9449 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9451 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CONTENT);
9454 static void DrawCustomChangeContentArea(void)
9456 int id = ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT;
9457 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
9458 int x1 = right_gadget_border[GADGET_ID_CHANGE_USE_CONTENT];
9459 int x2 = right_gadget_border[GADGET_ID_CHANGE_REPLACE_WHEN];
9460 int x3 = right_gadget_border[GADGET_ID_CHANGE_ONLY_COMPLETE];
9461 int xoffset = ED_GADGET_SPACE_DISTANCE;
9463 ModifyGadget(gi, GDI_X, MAX(x1, MAX(x2, x3)) + xoffset, GDI_END);
9468 static void RemoveElementContentArea(int id, int font_height)
9470 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9472 DrawBackground(SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size,
9473 SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size,
9474 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9475 3 * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size +
9476 ED_GADGET_TEXT_DISTANCE + font_height);
9479 static void DrawYamYamContentAreas(void)
9481 int font_nr = FONT_TEXT_1;
9482 int font_height = getFontHeight(font_nr);
9483 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9484 int yoffset = (tilesize - font_height) / 2;
9485 int x = SX + ED_AREA_YAMYAM_CONTENT_X(3) + 4 * tilesize;
9486 int y = SY + ED_AREA_YAMYAM_CONTENT_Y(3) + yoffset;
9489 // display counter to choose number of element content areas
9490 MapCounterButtons(ED_COUNTER_ID_YAMYAM_CONTENT);
9492 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9494 int id = ED_DRAWING_ID_YAMYAM_CONTENT_0 + i;
9496 if (i < level.num_yamyam_contents)
9502 UnmapDrawingArea(id);
9504 // delete content areas in case of reducing number of them
9505 RemoveElementContentArea(id, font_height);
9509 DrawText(x, y + 0 * tilesize, "content", font_nr);
9510 DrawText(x, y + 1 * tilesize, "when", font_nr);
9511 DrawText(x, y + 2 * tilesize, "smashed", font_nr);
9514 static void DrawMagicBallContentAreas(void)
9516 int font_nr = FONT_TEXT_1;
9517 int font_height = getFontHeight(font_nr);
9518 int tilesize = ED_DRAWINGAREA_TILE_SIZE;
9519 int yoffset = (tilesize - font_height) / 2;
9520 int x = SX + ED_AREA_MAGIC_BALL_CONTENT_X(3) + 4 * tilesize;
9521 int y = SY + ED_AREA_MAGIC_BALL_CONTENT_Y(3) + yoffset;
9524 // display counter to choose number of element content areas
9525 MapCounterButtons(ED_COUNTER_ID_BALL_CONTENT);
9527 for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
9529 int id = ED_DRAWING_ID_MAGIC_BALL_CONTENT_0 + i;
9531 if (i < level.num_ball_contents)
9537 UnmapDrawingArea(id);
9539 // delete content areas in case of reducing number of them
9540 RemoveElementContentArea(id, font_height);
9544 DrawText(x, y + 0 * tilesize, "generated", font_nr);
9545 DrawText(x, y + 1 * tilesize, "when", font_nr);
9546 DrawText(x, y + 2 * tilesize, "active", font_nr);
9549 static void DrawAndroidElementArea(void)
9551 int id = ED_DRAWING_ID_ANDROID_CONTENT;
9552 int num_elements = level.num_android_clone_elements;
9553 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9554 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9555 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9556 int xsize = MAX_ANDROID_ELEMENTS;
9559 // display counter to choose number of element areas
9560 MapCounterButtons(ED_COUNTER_ID_ANDROID_CONTENT);
9562 if (drawingarea_info[id].text_left != NULL)
9563 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9565 UnmapDrawingArea(id);
9567 ModifyEditorDrawingArea(id, num_elements, 1);
9569 // delete content areas in case of reducing number of them
9570 DrawBackground(sx, sy,
9571 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9572 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9577 static void DrawGroupElementArea(void)
9579 int id = ED_DRAWING_ID_GROUP_CONTENT;
9580 int num_elements = group_element_info.num_elements;
9581 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9582 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9583 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9584 int xsize = MAX_ELEMENTS_IN_GROUP;
9587 if (drawingarea_info[id].text_left != NULL)
9588 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9590 UnmapDrawingArea(id);
9592 ModifyEditorDrawingArea(id, num_elements, 1);
9594 // delete content areas in case of reducing number of them
9595 DrawBackground(sx, sy,
9596 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9597 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9602 static void DrawPlayerInitialInventoryArea(int element)
9604 int id = ED_DRAWING_ID_INVENTORY_CONTENT;
9605 int player_nr = GET_PLAYER_NR(element);
9606 int num_elements = level.initial_inventory_size[player_nr];
9607 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9608 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9609 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9610 int xsize = MAX_INITIAL_INVENTORY_SIZE;
9613 // determine horizontal position to the right of specified gadget
9614 if (drawingarea_info[id].gadget_id_align != GADGET_ID_NONE)
9615 sx = (right_gadget_border[drawingarea_info[id].gadget_id_align] +
9616 ED_DRAWINGAREA_TEXT_DISTANCE);
9618 // determine horizontal offset for leading text
9619 if (drawingarea_info[id].text_left != NULL)
9620 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9622 UnmapDrawingArea(id);
9624 ModifyEditorDrawingArea(id, num_elements, 1);
9626 // delete content areas in case of reducing number of them
9627 DrawBackground(sx, sy,
9628 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9629 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9634 static void DrawMMBallContentArea(void)
9636 int id = ED_DRAWING_ID_MM_BALL_CONTENT;
9637 int num_elements = level.num_mm_ball_contents;
9638 int border_size = ED_DRAWINGAREA_BORDER_SIZE;
9639 int sx = SX + ED_AREA_SETTINGS_X(drawingarea_info[id]) - border_size;
9640 int sy = SY + ED_AREA_SETTINGS_Y(drawingarea_info[id]) - border_size;
9641 int xsize = MAX_MM_BALL_CONTENTS;
9644 if (drawingarea_info[id].text_left != NULL)
9645 sx += getTextWidthForDrawingArea(drawingarea_info[id].text_left);
9647 UnmapDrawingArea(id);
9649 ModifyEditorDrawingArea(id, num_elements, 1);
9651 // delete content areas in case of reducing number of them
9652 DrawBackground(sx, sy,
9653 xsize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size,
9654 ysize * ED_DRAWINGAREA_TILE_SIZE + 2 * border_size);
9659 static void DrawEnvelopeTextArea(int envelope_nr)
9661 int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
9662 struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
9666 DrawBackground(gi->x, gi->y,
9667 gi->textarea.crop_width, gi->textarea.crop_height);
9669 if (envelope_nr != -1)
9670 textarea_info[id].value = level.envelope[envelope_nr].text;
9672 ModifyGadget(gi, GDI_AREA_SIZE,
9673 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value,
9674 *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value,
9677 MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
9680 static void DrawPropertiesInfo(void)
9689 // configurable properties
9691 { EP_WALKABLE_OVER, "- player can walk over it" },
9692 { EP_WALKABLE_INSIDE, "- player can walk inside it" },
9693 { EP_WALKABLE_UNDER, "- player can walk under it" },
9694 { EP_PASSABLE_OVER, "- player can pass over it" },
9695 { EP_PASSABLE_INSIDE, "- player can pass through it" },
9696 { EP_PASSABLE_UNDER, "- player can pass under it" },
9697 { EP_PROTECTED, "- player is protected by it" },
9699 { EP_DIGGABLE, "- can be digged away" },
9700 { EP_COLLECTIBLE, "- can be collected" },
9701 { EP_DROPPABLE, "- can be dropped after collecting" },
9702 { EP_THROWABLE, "- can be thrown after collecting" },
9703 { EP_PUSHABLE, "- can be pushed" },
9705 { EP_CAN_FALL, "- can fall" },
9706 { EP_CAN_MOVE, "- can move" },
9708 { EP_CAN_SMASH_PLAYER, "- can smash player" },
9710 { EP_CAN_SMASH_ENEMIES, "- can smash good and bad guys" },
9712 { EP_CAN_SMASH_EVERYTHING, "- can smash everything smashable" },
9714 { EP_SLIPPERY, "- slippery for falling elements" },
9715 { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
9717 { EP_DONT_RUN_INTO, "- deadly when running into" },
9718 { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
9719 { EP_DONT_GET_HIT_BY, "- deadly when getting hit by" },
9720 { EP_DONT_TOUCH, "- deadly when touching" },
9722 { EP_INDESTRUCTIBLE, "- indestructible" },
9724 { EP_CAN_EXPLODE_BY_FIRE, "- can explode by fire or explosions" },
9725 { EP_CAN_EXPLODE_SMASHED, "- can explode when smashed" },
9726 { EP_CAN_EXPLODE_IMPACT, "- can explode on impact" },
9728 { EP_CAN_CHANGE, "- can change to other element" },
9730 // pre-defined properties
9731 { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
9732 { EP_CAN_PASS_DC_MAGIC_WALL,"- can pass magic walls (DC style)" },
9733 { EP_SWITCHABLE, "- can be switched" },
9735 { EP_HAS_EDITOR_CONTENT, "- can contain other elements" },
9740 char *filename = getElementDescriptionFilename(properties_element);
9741 char *percentage_text = "In this level: ";
9742 char *properties_text = "Standard properties: ";
9743 char *description_text = "Description:";
9744 char *no_description_text = "No description available.";
9745 char *none_text = "None";
9747 int num_elements_in_level;
9748 int num_standard_properties = 0;
9749 int font1_nr = FONT_TEXT_1;
9750 int font2_nr = FONT_TEXT_2;
9751 int font1_width = getFontWidth(font1_nr);
9752 int font1_height = getFontHeight(font1_nr);
9753 int font2_height = getFontHeight(font2_nr);
9754 int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
9755 int font2_yoffset = (font1_height - font2_height) / 2;
9756 int percentage_text_len = strlen(percentage_text) * font1_width;
9757 int properties_text_len = strlen(properties_text) * font1_width;
9758 int xpos = ED_ELEMENT_SETTINGS_X(0);
9759 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
9762 if (setup.editor.show_element_token)
9764 int font3_nr = FONT_TEXT_3;
9765 int font3_height = getFontHeight(font3_nr);
9767 DrawTextF(xpos, ypos, font3_nr,
9768 "[%s]", element_info[properties_element].token_name);
9770 ypos += 2 * font3_height;
9773 // ----- print number of elements / percentage of this element in level
9775 num_elements_in_level = 0;
9776 for (y = 0; y < lev_fieldy; y++)
9777 for (x = 0; x < lev_fieldx; x++)
9778 if (Tile[x][y] == properties_element)
9779 num_elements_in_level++;
9780 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
9782 DrawTextS(xpos, ypos, font1_nr, percentage_text);
9784 if (num_elements_in_level > 0)
9785 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9786 "%d (%.2f %%)", num_elements_in_level, percentage);
9788 DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
9791 ypos += 2 * MAX(font1_height, font2_height);
9793 // ----- print standard properties of this element
9795 DrawTextS(xpos, ypos, font1_nr, properties_text);
9797 ypos += line1_height;
9799 for (i = 0; properties[i].value != -1; i++)
9801 if (!HAS_PROPERTY(properties_element, properties[i].value))
9804 DrawTextS(xpos, ypos, font2_nr, properties[i].text);
9806 ypos += font2_height;
9808 num_standard_properties++;
9811 if (num_standard_properties == 0)
9813 DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
9814 font2_nr, none_text);
9816 ypos -= (line1_height - font1_height);
9819 ypos += MAX(font1_height, font2_height);
9821 // ----- print special description of this element
9823 PrintInfoText(description_text, font1_nr, xpos, ypos);
9825 ypos += line1_height;
9827 if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
9828 PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
9831 #define TEXT_COLLECTING "Score for collecting"
9832 #define TEXT_SMASHING "Score for smashing"
9833 #define TEXT_SLURPING "Score for slurping robot"
9834 #define TEXT_CRACKING "Score for cracking"
9835 #define TEXT_AMOEBA_SPEED "Speed of amoeba growth"
9836 #define TEXT_DURATION "Duration when activated"
9837 #define TEXT_DELAY_ON "Delay before activating"
9838 #define TEXT_DELAY_OFF "Delay before deactivating"
9839 #define TEXT_DELAY_EXPLODING "Delay before exploding"
9840 #define TEXT_DELAY_MOVING "Delay before moving"
9841 #define TEXT_BALL_DELAY "Element generation delay"
9842 #define TEXT_MOVE_SPEED "Speed of android moving"
9843 #define TEXT_CLONE_SPEED "Speed of android cloning"
9844 #define TEXT_GAME_OF_LIFE_1 "Min neighbours to survive"
9845 #define TEXT_GAME_OF_LIFE_2 "Max neighbours to survive"
9846 #define TEXT_GAME_OF_LIFE_3 "Min neighbours to create"
9847 #define TEXT_GAME_OF_LIFE_4 "Max neighbours to create"
9848 #define TEXT_TIME_BONUS "Extra time to solve level"
9855 } elements_with_counter[] =
9857 { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
9858 { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
9859 { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
9860 { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
9861 { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9862 { EL_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
9863 { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
9864 { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
9865 { EL_PEARL, &level.score[SC_PEARL], TEXT_COLLECTING },
9866 { EL_BUG, &level.score[SC_BUG], TEXT_SMASHING },
9867 { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
9868 { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
9869 { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9870 { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9871 { EL_BD_BUTTERFLY, &level.score[SC_BUG], TEXT_SMASHING },
9872 { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
9873 { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
9874 { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
9875 { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
9876 { EL_SP_ELECTRON, &level.score[SC_BUG], TEXT_SMASHING },
9877 { EL_SPACESHIP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9878 { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9879 { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9880 { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9881 { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9882 { EL_BD_FIREFLY, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9883 { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
9884 { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9885 { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9886 { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9887 { EL_SP_SNIKSNAK, &level.score[SC_SPACESHIP], TEXT_SMASHING },
9888 { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9889 { EL_YAMYAM_LEFT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9890 { EL_YAMYAM_RIGHT, &level.score[SC_YAMYAM], TEXT_SMASHING },
9891 { EL_YAMYAM_UP, &level.score[SC_YAMYAM], TEXT_SMASHING },
9892 { EL_YAMYAM_DOWN, &level.score[SC_YAMYAM], TEXT_SMASHING },
9893 { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
9894 { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
9895 { EL_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9896 { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9897 { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9898 { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9899 { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9900 { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
9901 { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9902 { EL_EM_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
9903 { EL_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
9904 { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9905 { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
9906 { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
9907 { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
9908 { EL_EXTRA_TIME, &level.extra_time_score, TEXT_COLLECTING },
9909 { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9910 { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9911 { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9912 { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9913 { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
9914 { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
9915 { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
9916 { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
9917 { EL_EMC_KEY_5, &level.score[SC_KEY], TEXT_COLLECTING },
9918 { EL_EMC_KEY_6, &level.score[SC_KEY], TEXT_COLLECTING },
9919 { EL_EMC_KEY_7, &level.score[SC_KEY], TEXT_COLLECTING },
9920 { EL_EMC_KEY_8, &level.score[SC_KEY], TEXT_COLLECTING },
9921 { EL_DC_KEY_WHITE, &level.score[SC_KEY], TEXT_COLLECTING },
9922 { EL_MM_KETTLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
9923 { EL_DF_CELL, &level.score[SC_EMERALD], TEXT_COLLECTING },
9924 { EL_MM_KEY, &level.score[SC_KEY], TEXT_COLLECTING },
9925 { EL_MM_LIGHTBALL, &level.score[SC_ELEM_BONUS], TEXT_COLLECTING },
9926 { EL_MM_PACMAN, &level.score[SC_PACMAN], TEXT_SMASHING },
9927 { EL_MM_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
9928 { EL_MM_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
9929 { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
9930 { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
9931 { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9932 { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9933 { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9934 { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9935 { EL_EMC_DRIPPER, &level.amoeba_speed, TEXT_AMOEBA_SPEED },
9936 { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9937 { EL_BD_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9938 { EL_DC_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
9939 { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
9941 { EL_TIMEGATE_SWITCH, &level.time_timegate, TEXT_DURATION },
9942 { EL_DC_TIMEGATE_SWITCH,&level.time_timegate, TEXT_DURATION },
9943 { EL_LIGHT_SWITCH, &level.time_light, TEXT_DURATION },
9944 { EL_LIGHT_SWITCH_ACTIVE, &level.time_light, TEXT_DURATION },
9945 { EL_SHIELD_NORMAL, &level.shield_normal_time, TEXT_DURATION },
9946 { EL_SHIELD_DEADLY, &level.shield_deadly_time, TEXT_DURATION },
9947 { EL_EXTRA_TIME, &level.extra_time, TEXT_TIME_BONUS },
9948 { EL_TIME_ORB_FULL, &level.time_orb_time, TEXT_TIME_BONUS },
9949 { EL_GAME_OF_LIFE, &level.game_of_life[0], TEXT_GAME_OF_LIFE_1 },
9950 { EL_GAME_OF_LIFE, &level.game_of_life[1], TEXT_GAME_OF_LIFE_2 },
9951 { EL_GAME_OF_LIFE, &level.game_of_life[2], TEXT_GAME_OF_LIFE_3 },
9952 { EL_GAME_OF_LIFE, &level.game_of_life[3], TEXT_GAME_OF_LIFE_4 },
9953 { EL_BIOMAZE, &level.biomaze[0], TEXT_GAME_OF_LIFE_1 },
9954 { EL_BIOMAZE, &level.biomaze[1], TEXT_GAME_OF_LIFE_2 },
9955 { EL_BIOMAZE, &level.biomaze[2], TEXT_GAME_OF_LIFE_3 },
9956 { EL_BIOMAZE, &level.biomaze[3], TEXT_GAME_OF_LIFE_4 },
9958 { EL_EMC_ANDROID, &level.android_move_time, TEXT_MOVE_SPEED },
9959 { EL_EMC_ANDROID, &level.android_clone_time, TEXT_CLONE_SPEED },
9960 { EL_EMC_MAGIC_BALL, &level.ball_time, TEXT_BALL_DELAY },
9961 { EL_EMC_LENSES, &level.lenses_score, TEXT_COLLECTING },
9962 { EL_EMC_MAGNIFIER, &level.magnify_score, TEXT_COLLECTING },
9963 { EL_SPRING, &level.slurp_score, TEXT_SLURPING },
9964 { EL_SPRING_LEFT, &level.slurp_score, TEXT_SLURPING },
9965 { EL_SPRING_RIGHT, &level.slurp_score, TEXT_SLURPING },
9966 { EL_EMC_LENSES, &level.lenses_time, TEXT_DURATION },
9967 { EL_EMC_MAGNIFIER, &level.magnify_time, TEXT_DURATION },
9968 { EL_MM_FUSE_ACTIVE, &level.mm_time_fuse, TEXT_DELAY_OFF },
9969 { EL_MM_BOMB, &level.mm_time_bomb, TEXT_DELAY_EXPLODING },
9970 { EL_MM_GRAY_BALL, &level.mm_time_ball, TEXT_DELAY_ON },
9971 { EL_MM_STEEL_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9972 { EL_MM_WOODEN_BLOCK, &level.mm_time_block, TEXT_DELAY_MOVING },
9977 static boolean checkPropertiesConfig(int element)
9981 if (IS_GEM(element) ||
9982 IS_CUSTOM_ELEMENT(element) ||
9983 IS_GROUP_ELEMENT(element) ||
9984 IS_EMPTY_ELEMENT(element) ||
9985 IS_BALLOON_ELEMENT(element) ||
9986 IS_ENVELOPE(element) ||
9987 IS_MM_ENVELOPE(element) ||
9988 IS_MM_MCDUFFIN(element) ||
9989 IS_DF_LASER(element) ||
9990 IS_PLAYER_ELEMENT(element) ||
9991 HAS_EDITOR_CONTENT(element) ||
9992 CAN_GROW(element) ||
9993 COULD_MOVE_INTO_ACID(element) ||
9994 MAYBE_DONT_COLLIDE_WITH(element) ||
9995 element == EL_SOKOBAN_OBJECT ||
9996 element == EL_SOKOBAN_FIELD_EMPTY ||
9997 element == EL_SOKOBAN_FIELD_FULL)
10000 for (i = 0; elements_with_counter[i].element != -1; i++)
10001 if (elements_with_counter[i].element == element)
10007 static void SetAutomaticNumberOfGemsNeeded(void)
10011 if (!level.auto_count_gems)
10014 level.gems_needed = 0;
10016 for (x = 0; x < lev_fieldx; x++)
10018 for (y = 0; y < lev_fieldy; y++)
10020 int element = Tile[x][y];
10025 case EL_EMERALD_YELLOW:
10026 case EL_EMERALD_RED:
10027 case EL_EMERALD_PURPLE:
10028 case EL_BD_DIAMOND:
10029 case EL_WALL_EMERALD:
10030 case EL_WALL_EMERALD_YELLOW:
10031 case EL_WALL_EMERALD_RED:
10032 case EL_WALL_EMERALD_PURPLE:
10033 case EL_WALL_BD_DIAMOND:
10035 case EL_SP_INFOTRON:
10038 level.gems_needed++;
10042 case EL_WALL_DIAMOND:
10043 level.gems_needed += 3;
10047 case EL_WALL_PEARL:
10048 level.gems_needed += 5;
10052 case EL_WALL_CRYSTAL:
10053 level.gems_needed += 8;
10062 ModifyEditorCounterValue(ED_COUNTER_ID_LEVEL_GEMSLIMIT, level.gems_needed);
10065 static void DrawPropertiesConfig(void)
10067 boolean draw_footer_line = FALSE;
10068 int max_num_element_counters = 4;
10069 int num_element_counters = 0;
10072 if (!checkPropertiesConfig(properties_element))
10074 int xpos = ED_ELEMENT_SETTINGS_X(0);
10075 int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
10077 PrintInfoText("No configuration options available.",
10078 FONT_TEXT_1, xpos, ypos);
10083 // check if there are elements where a value can be chosen for
10084 for (i = 0; elements_with_counter[i].element != -1; i++)
10086 if (elements_with_counter[i].element == properties_element)
10088 int counter_id = ED_COUNTER_ID_ELEMENT_VALUE1 + num_element_counters;
10090 counterbutton_info[counter_id].y =
10091 ED_ELEMENT_SETTINGS_YPOS(
10092 (HAS_EDITOR_CONTENT(properties_element) ? 1 : 0) +
10093 (CAN_GROW(properties_element) ? 1 : 0) +
10094 (COULD_MOVE_INTO_ACID(properties_element) ? 1 : 0) +
10095 (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
10096 (properties_element == EL_EMC_MAGIC_BALL ? 2 : 0) +
10097 num_element_counters);
10099 counterbutton_info[counter_id].value = elements_with_counter[i].value;
10100 counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
10102 if (properties_element == EL_GAME_OF_LIFE ||
10103 properties_element == EL_BIOMAZE)
10105 counterbutton_info[counter_id].min_value = 0; // min neighbours
10106 counterbutton_info[counter_id].max_value = 8; // max neighbours
10110 // !!! CHANGE THIS FOR CERTAIN ELEMENTS !!!
10111 counterbutton_info[counter_id].min_value = MIN_SCORE;
10112 counterbutton_info[counter_id].max_value = MAX_SCORE;
10115 MapCounterButtons(counter_id);
10117 num_element_counters++;
10118 if (num_element_counters >= max_num_element_counters)
10123 if (HAS_EDITOR_CONTENT(properties_element))
10125 // draw stickybutton gadget
10126 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10128 if (IS_AMOEBOID(properties_element))
10129 MapDrawingArea(ED_DRAWING_ID_AMOEBA_CONTENT);
10130 else if (properties_element == EL_YAMYAM ||
10131 properties_element == EL_YAMYAM_LEFT ||
10132 properties_element == EL_YAMYAM_RIGHT ||
10133 properties_element == EL_YAMYAM_UP ||
10134 properties_element == EL_YAMYAM_DOWN)
10135 DrawYamYamContentAreas();
10136 else if (properties_element == EL_EMC_MAGIC_BALL)
10138 DrawMagicBallContentAreas();
10140 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT);
10141 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE);
10143 else if (properties_element == EL_EMC_ANDROID)
10144 DrawAndroidElementArea();
10145 else if (properties_element == EL_MM_GRAY_BALL)
10147 MapCounterButtons(ED_COUNTER_ID_MM_BALL_CONTENT);
10148 MapSelectboxGadget(ED_SELECTBOX_ID_MM_BALL_CHOICE_MODE);
10149 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_ROTATE_MM_BALL_CONTENT);
10151 DrawMMBallContentArea();
10155 if (IS_PLAYER_ELEMENT(properties_element))
10157 int player_nr = GET_PLAYER_NR(properties_element);
10159 // these properties can be set for every player individually
10161 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10163 drawingarea_info[ED_DRAWING_ID_START_ELEMENT].value =
10164 &level.start_element[player_nr];
10165 drawingarea_info[ED_DRAWING_ID_ARTWORK_ELEMENT].value =
10166 &level.artwork_element[player_nr];
10167 drawingarea_info[ED_DRAWING_ID_EXPLOSION_ELEMENT].value =
10168 &level.explosion_element[player_nr];
10170 checkbutton_info[ED_CHECKBUTTON_ID_USE_START_ELEMENT].value =
10171 &level.use_start_element[player_nr];
10172 checkbutton_info[ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT].value =
10173 &level.use_artwork_element[player_nr];
10174 checkbutton_info[ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT].value =
10175 &level.use_explosion_element[player_nr];
10176 checkbutton_info[ED_CHECKBUTTON_ID_INITIAL_GRAVITY].value =
10177 &level.initial_player_gravity[player_nr];
10179 selectbox_info[ED_SELECTBOX_ID_PLAYER_SPEED].value =
10180 &level.initial_player_stepsize[player_nr];
10182 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID);
10183 MapCheckbuttonGadget(properties_element == EL_SP_MURPHY ?
10184 ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD :
10185 ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD);
10186 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD);
10187 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING);
10188 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INSTANT_RELOCATION);
10189 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SHIFTED_RELOCATION);
10190 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_LAZY_RELOCATION);
10191 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_START_ELEMENT);
10192 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT);
10193 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT);
10194 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_GRAVITY);
10195 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE);
10196 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER);
10198 MapDrawingArea(ED_DRAWING_ID_START_ELEMENT);
10199 MapDrawingArea(ED_DRAWING_ID_ARTWORK_ELEMENT);
10200 MapDrawingArea(ED_DRAWING_ID_EXPLOSION_ELEMENT);
10202 MapSelectboxGadget(ED_SELECTBOX_ID_PLAYER_SPEED);
10204 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10206 drawingarea_info[ED_DRAWING_ID_INVENTORY_CONTENT].value =
10207 &level.initial_inventory_content[player_nr][0];
10209 counterbutton_info[ED_COUNTER_ID_INVENTORY_SIZE].value =
10210 &level.initial_inventory_size[player_nr];
10212 checkbutton_info[ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY].value =
10213 &level.use_initial_inventory[player_nr];
10215 // draw checkbutton gadgets
10216 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY);
10217 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_FINISH_DIG_COLLECT);
10218 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_KEEP_WALKABLE_CE);
10220 // draw counter gadgets
10221 MapCounterButtons(ED_COUNTER_ID_INVENTORY_SIZE);
10223 // draw drawing area gadgets
10224 DrawPlayerInitialInventoryArea(properties_element);
10228 if (IS_GEM(properties_element))
10229 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
10231 if (properties_element == EL_EM_DYNAMITE)
10232 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
10234 if (COULD_MOVE_INTO_ACID(properties_element) &&
10235 !IS_PLAYER_ELEMENT(properties_element) &&
10236 (!IS_CUSTOM_ELEMENT(properties_element) ||
10237 edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
10239 // set position for checkbutton for "can move into acid"
10240 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].x =
10241 ED_ELEMENT_SETTINGS_XPOS(IS_CUSTOM_ELEMENT(properties_element) ? 1 : 0);
10242 checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y =
10243 ED_ELEMENT_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 7 :
10244 IS_BALLOON_ELEMENT(properties_element) ||
10245 HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10247 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID);
10250 if (MAYBE_DONT_COLLIDE_WITH(properties_element))
10251 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH);
10253 if (properties_element == EL_SPRING ||
10254 properties_element == EL_SPRING_LEFT ||
10255 properties_element == EL_SPRING_RIGHT)
10256 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_SPRING_BUG);
10258 if (properties_element == EL_TIME_ORB_FULL)
10259 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG);
10261 if (properties_element == EL_GAME_OF_LIFE ||
10262 properties_element == EL_BIOMAZE)
10263 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_USE_LIFE_BUGS);
10265 if (CAN_GROW(properties_element))
10267 checkbutton_info[ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE].y =
10268 ED_ELEMENT_SETTINGS_YPOS(HAS_EDITOR_CONTENT(properties_element) ? 1 : 0);
10270 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
10273 if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
10274 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
10276 if (properties_element == EL_SOKOBAN_OBJECT)
10277 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
10279 if (properties_element == EL_SOKOBAN_OBJECT ||
10280 properties_element == EL_SOKOBAN_FIELD_EMPTY ||
10281 properties_element == EL_SOKOBAN_FIELD_FULL)
10283 checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
10284 ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
10287 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
10290 if (IS_BALLOON_ELEMENT(properties_element))
10291 MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
10293 if (IS_ENVELOPE(properties_element) ||
10294 IS_MM_ENVELOPE(properties_element))
10296 int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE;
10297 int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE;
10298 int button1_id = ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP;
10299 int button2_id = ED_CHECKBUTTON_ID_ENVELOPE_CENTERED;
10300 int envelope_nr = ENVELOPE_NR(properties_element);
10302 counterbutton_info[counter1_id].value = &level.envelope[envelope_nr].xsize;
10303 counterbutton_info[counter2_id].value = &level.envelope[envelope_nr].ysize;
10305 checkbutton_info[button1_id].value = &level.envelope[envelope_nr].autowrap;
10306 checkbutton_info[button2_id].value = &level.envelope[envelope_nr].centered;
10308 // display counter to choose size of envelope text area
10309 MapCounterButtons(counter1_id);
10310 MapCounterButtons(counter2_id);
10312 // display checkbuttons to choose auto-wrap and alignment properties
10313 MapCheckbuttonGadget(button1_id);
10314 MapCheckbuttonGadget(button2_id);
10316 DrawEnvelopeTextArea(envelope_nr);
10319 if (IS_MM_MCDUFFIN(properties_element))
10321 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_RED);
10322 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_GREEN);
10323 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_MM_LASER_BLUE);
10326 if (IS_DF_LASER(properties_element))
10328 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_RED);
10329 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_GREEN);
10330 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_DF_LASER_BLUE);
10333 if (IS_CUSTOM_ELEMENT(properties_element))
10335 // draw stickybutton gadget
10336 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10338 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_1)
10340 // draw checkbutton gadgets
10341 for (i = ED_CHECKBUTTON_ID_CUSTOM1_FIRST;
10342 i <= ED_CHECKBUTTON_ID_CUSTOM1_LAST; i++)
10343 MapCheckbuttonGadget(i);
10345 // draw counter gadgets
10346 for (i = ED_COUNTER_ID_CUSTOM1_FIRST;
10347 i <= ED_COUNTER_ID_CUSTOM1_LAST; i++)
10348 MapCounterButtons(i);
10350 // draw selectbox gadgets
10351 for (i = ED_SELECTBOX_ID_CUSTOM1_FIRST;
10352 i <= ED_SELECTBOX_ID_CUSTOM1_LAST; i++)
10353 MapSelectboxGadget(i);
10355 // draw textbutton gadgets
10356 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10358 // draw text input gadgets
10359 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10361 // draw drawing area gadgets
10362 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10364 draw_footer_line = TRUE;
10366 else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
10368 // draw checkbutton gadgets
10369 for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST;
10370 i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++)
10371 MapCheckbuttonGadget(i);
10373 // draw counter gadgets
10374 for (i = ED_COUNTER_ID_CUSTOM2_FIRST;
10375 i <= ED_COUNTER_ID_CUSTOM2_LAST; i++)
10376 MapCounterButtons(i);
10378 // draw selectbox gadgets
10379 for (i = ED_SELECTBOX_ID_CUSTOM2_FIRST;
10380 i <= ED_SELECTBOX_ID_CUSTOM2_LAST; i++)
10381 MapSelectboxGadget(i);
10383 // draw drawing area gadgets
10384 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_ENTER);
10385 MapDrawingArea(ED_DRAWING_ID_CUSTOM_MOVE_LEAVE);
10386 DrawCustomContentArea();
10389 else if (IS_GROUP_ELEMENT(properties_element))
10391 // draw stickybutton gadget
10392 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10394 // draw checkbutton gadgets
10395 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10396 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10398 // draw counter gadgets
10399 MapCounterButtons(ED_COUNTER_ID_GROUP_CONTENT);
10401 // draw selectbox gadgets
10402 MapSelectboxGadget(ED_SELECTBOX_ID_GROUP_CHOICE_MODE);
10404 // draw textbutton gadgets
10405 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10407 // draw drawing area gadgets
10408 DrawGroupElementArea();
10410 // draw text input gadgets
10411 MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME);
10413 // draw drawing area gadgets
10414 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10416 draw_footer_line = TRUE;
10418 else if (IS_EMPTY_ELEMENT(properties_element))
10420 // draw stickybutton gadget
10421 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10423 // draw checkbutton gadgets
10424 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC);
10425 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1);
10427 // draw textbutton gadgets
10428 MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1);
10430 // draw drawing area gadgets
10431 MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
10433 draw_footer_line = TRUE;
10436 // draw little footer border line above CE/GE use/save template gadgets
10437 if (draw_footer_line)
10439 struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
10440 struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED];
10441 int gd_x = gd->x + gd_gi1->border.width / 2;
10442 int gd_y = gd->y + gd_gi1->height - 1;
10443 Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
10445 if (tab_color != BLACK_PIXEL) // black => transparent
10446 FillRectangle(drawto,
10447 SX + ED_ELEMENT_SETTINGS_X(0),
10448 SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET -
10450 getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color);
10454 static void DrawPropertiesChangeDrawingAreas(void)
10456 if (IS_CUSTOM_ELEMENT(properties_element))
10458 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TARGET);
10459 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER);
10460 MapDrawingArea(ED_DRAWING_ID_CUSTOM_CHANGE_ACTION);
10462 DrawCustomChangeContentArea();
10465 redraw_mask |= REDRAW_FIELD;
10468 static void DrawPropertiesChange(void)
10472 // needed to initially set selectbox options for special action options
10473 setSelectboxSpecialActionOptions();
10475 // draw stickybutton gadget
10476 MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT);
10478 // draw checkbutton gadgets
10479 for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
10480 i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
10481 MapCheckbuttonGadget(i);
10483 // draw counter gadgets
10484 for (i = ED_COUNTER_ID_CHANGE_FIRST;
10485 i <= ED_COUNTER_ID_CHANGE_LAST; i++)
10486 MapCounterButtons(i);
10488 // draw selectbox gadgets
10489 for (i = ED_SELECTBOX_ID_CHANGE_FIRST;
10490 i <= ED_SELECTBOX_ID_CHANGE_LAST; i++)
10491 MapSelectboxGadget(i);
10493 // draw textbutton gadgets
10494 for (i = ED_TEXTBUTTON_ID_CHANGE_FIRST;
10495 i <= ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
10496 MapTextbuttonGadget(i);
10498 // draw graphicbutton gadgets
10499 for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
10500 i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
10501 MapGraphicbuttonGadget(i);
10503 // draw drawing area gadgets
10504 DrawPropertiesChangeDrawingAreas();
10507 static void DrawEditorElementAnimation(int x, int y)
10509 int graphic = el2img(properties_element);
10510 int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ?
10511 custom_element.ce_value_fixed_initial :
10512 ANIM_MODE(graphic) == ANIM_CE_SCORE ?
10513 custom_element.collect_score_initial : FrameCounter);
10515 DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING);
10518 static void DrawEditorElementName(int x, int y, int font_nr)
10520 char *element_name = getElementInfoText(properties_element);
10521 int font_width = getFontWidth(font_nr);
10522 int font_height = getFontHeight(font_nr);
10523 int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
10524 int max_chars_per_line = max_text_width / font_width;
10526 if (strlen(element_name) <= max_chars_per_line)
10527 DrawTextS(x, y, font_nr, element_name);
10530 char buffer[max_chars_per_line + 1];
10531 int next_pos = max_chars_per_line;
10533 strncpy(buffer, element_name, max_chars_per_line);
10534 buffer[max_chars_per_line] = '\0';
10536 if (element_name[max_chars_per_line] == ' ')
10542 for (i = max_chars_per_line - 1; i >= 0; i--)
10543 if (buffer[i] == ' ')
10546 if (strlen(&element_name[i + 1]) <= max_chars_per_line)
10553 DrawTextS(x, y - font_height / 2, font_nr, buffer);
10555 strncpy(buffer, &element_name[next_pos], max_chars_per_line);
10556 buffer[max_chars_per_line] = '\0';
10558 DrawTextS(x, y + font_height / 2, font_nr, buffer);
10562 static void DrawPropertiesWindow(void)
10564 struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_TEXT];
10565 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
10566 int border_size = gd->border_size;
10567 int font_nr = FONT_TEXT_1;
10568 int font_height = getFontHeight(font_nr);
10569 int xoffset = TILEX + element_border + 3 * border_size;
10570 int yoffset = (TILEY - font_height) / 2;
10571 int x1 = editor.settings.element_graphic.x + element_border;
10572 int y1 = editor.settings.element_graphic.y + element_border;
10573 int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset :
10574 editor.settings.element_name.x);
10575 int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset :
10576 editor.settings.element_name.y);
10577 char *text = "Element Settings";
10578 int font2_nr = FONT_TITLE_1;
10579 struct MenuPosInfo *pos = &editor.settings.headline;
10580 int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align);
10581 int sy = SY + pos->y;
10583 stick_element_properties_window = FALSE;
10585 // make sure that previous properties edit mode exists for this element
10586 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG_2 &&
10587 !IS_CUSTOM_ELEMENT(properties_element))
10588 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_2;
10590 if (edit_mode_properties > ED_MODE_PROPERTIES_CONFIG &&
10591 !IS_PLAYER_ELEMENT(properties_element) &&
10592 !IS_CUSTOM_ELEMENT(properties_element))
10593 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
10595 if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
10596 (IS_PLAYER_ELEMENT(properties_element) ||
10597 IS_CUSTOM_ELEMENT(properties_element)))
10598 edit_mode_properties = ED_MODE_PROPERTIES_CONFIG_1;
10600 CopyElementPropertiesToEditor(properties_element);
10602 UnmapLevelEditorFieldGadgets();
10603 UnmapLevelEditorToolboxDrawingGadgets();
10604 UnmapLevelEditorToolboxCustomGadgets();
10606 if (IS_CUSTOM_ELEMENT(properties_element) ||
10607 IS_GROUP_ELEMENT(properties_element))
10608 MapLevelEditorToolboxCustomGadgets();
10610 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10613 DrawText(sx, sy, text, font2_nr);
10615 FrameCounter = 0; // restart animation frame counter
10617 DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE);
10618 DrawEditorElementAnimation(SX + x1, SY + y1);
10619 DrawEditorElementName(x2, y2, font_nr);
10621 DrawPropertiesTabulatorGadgets();
10623 if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
10624 DrawPropertiesInfo();
10625 else if (edit_mode_properties == ED_MODE_PROPERTIES_CHANGE)
10626 DrawPropertiesChange();
10627 else // (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG[_1|_2])
10628 DrawPropertiesConfig();
10631 static void DrawPaletteWindow(void)
10635 UnmapLevelEditorFieldGadgets();
10637 SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
10640 // map buttons to select elements
10641 for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++)
10642 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
10643 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
10644 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
10645 MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
10648 static void UpdateCustomElementGraphicGadgets(void)
10652 InitElementPropertiesGfxElement();
10654 ModifyEditorElementList();
10655 RedrawDrawingElements();
10657 // force redraw of all mapped drawing area gadgets
10658 for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
10660 struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[i].gadget_id];
10667 static int getOpenDirectionFromTube(int element)
10671 case EL_TUBE_LEFT_UP: return (MV_LEFT | MV_UP);
10672 case EL_TUBE_LEFT_DOWN: return (MV_LEFT | MV_DOWN);
10673 case EL_TUBE_RIGHT_UP: return (MV_RIGHT | MV_UP);
10674 case EL_TUBE_RIGHT_DOWN: return (MV_RIGHT | MV_DOWN);
10675 case EL_TUBE_HORIZONTAL: return (MV_HORIZONTAL);
10676 case EL_TUBE_HORIZONTAL_UP: return (MV_HORIZONTAL | MV_UP);
10677 case EL_TUBE_HORIZONTAL_DOWN: return (MV_HORIZONTAL | MV_DOWN);
10678 case EL_TUBE_VERTICAL: return (MV_VERTICAL);
10679 case EL_TUBE_VERTICAL_LEFT: return (MV_VERTICAL | MV_LEFT);
10680 case EL_TUBE_VERTICAL_RIGHT: return (MV_VERTICAL | MV_RIGHT);
10681 case EL_TUBE_ANY: return (MV_ANY_DIRECTION);
10687 static int getTubeFromOpenDirection(int direction)
10691 case (MV_LEFT | MV_UP): return EL_TUBE_LEFT_UP;
10692 case (MV_LEFT | MV_DOWN): return EL_TUBE_LEFT_DOWN;
10693 case (MV_RIGHT | MV_UP): return EL_TUBE_RIGHT_UP;
10694 case (MV_RIGHT | MV_DOWN): return EL_TUBE_RIGHT_DOWN;
10695 case (MV_HORIZONTAL): return EL_TUBE_HORIZONTAL;
10696 case (MV_HORIZONTAL | MV_UP): return EL_TUBE_HORIZONTAL_UP;
10697 case (MV_HORIZONTAL | MV_DOWN): return EL_TUBE_HORIZONTAL_DOWN;
10698 case (MV_VERTICAL): return EL_TUBE_VERTICAL;
10699 case (MV_VERTICAL | MV_LEFT): return EL_TUBE_VERTICAL_LEFT;
10700 case (MV_VERTICAL | MV_RIGHT): return EL_TUBE_VERTICAL_RIGHT;
10701 case (MV_ANY_DIRECTION): return EL_TUBE_ANY;
10703 // if only one direction, fall back to simple tube with that direction
10704 case (MV_LEFT): return EL_TUBE_HORIZONTAL;
10705 case (MV_RIGHT): return EL_TUBE_HORIZONTAL;
10706 case (MV_UP): return EL_TUBE_VERTICAL;
10707 case (MV_DOWN): return EL_TUBE_VERTICAL;
10713 static int getTubeFromOpenDirectionNotEmpty(int direction, int element_old)
10715 int element_new = getTubeFromOpenDirection(direction);
10717 return (element_new != EL_EMPTY ? element_new : element_old);
10720 static int getOpenDirectionFromBelt(int element)
10722 int belt_dir = getBeltDirFromBeltElement(element);
10724 return (belt_dir == MV_LEFT ? MV_RIGHT :
10725 belt_dir == MV_RIGHT ? MV_LEFT :
10726 belt_dir == MV_NONE ? MV_HORIZONTAL : belt_dir);
10729 static int getBeltFromNrAndOpenDirection(int nr, int direction)
10731 int belt_dir = (direction == MV_LEFT ? MV_RIGHT :
10732 direction == MV_RIGHT ? MV_LEFT :
10733 direction == MV_HORIZONTAL ? MV_NONE : direction);
10735 if (direction == MV_NONE)
10738 return getBeltElementFromBeltNrAndBeltDir(nr, belt_dir);
10741 static int getBeltFromNrAndOpenDirectionNotEmpty(int nr, int direction,
10744 int element_new = getBeltFromNrAndOpenDirection(nr, direction);
10746 return (element_new != EL_EMPTY ? element_new : element_old);
10749 static int getOpenDirectionFromPool(int element)
10753 case EL_ACID_POOL_TOPLEFT: return (MV_DOWN | MV_RIGHT);
10754 case EL_ACID_POOL_TOPRIGHT: return (MV_DOWN | MV_LEFT);
10755 case EL_ACID_POOL_BOTTOMLEFT: return (MV_UP | MV_RIGHT);
10756 case EL_ACID_POOL_BOTTOMRIGHT: return (MV_UP | MV_LEFT);
10757 case EL_ACID_POOL_BOTTOM: return (MV_HORIZONTAL | MV_UP);
10758 case EL_ACID: return (MV_HORIZONTAL | MV_DOWN);
10764 static int getPoolFromOpenDirection(int direction)
10768 case (MV_DOWN | MV_RIGHT): return EL_ACID_POOL_TOPLEFT;
10769 case (MV_DOWN | MV_LEFT): return EL_ACID_POOL_TOPRIGHT;
10770 case (MV_UP | MV_RIGHT): return EL_ACID_POOL_BOTTOMLEFT;
10771 case (MV_UP | MV_LEFT): return EL_ACID_POOL_BOTTOMRIGHT;
10772 case (MV_HORIZONTAL | MV_UP): return EL_ACID_POOL_BOTTOM;
10773 case (MV_HORIZONTAL | MV_DOWN): return EL_ACID;
10779 static int getPoolFromOpenDirectionExt(int direction, int help_element)
10781 int element = getPoolFromOpenDirection(direction);
10782 int help_direction = getOpenDirectionFromPool(help_element);
10784 if (element == EL_EMPTY)
10786 int help_direction_vertical = help_direction & MV_VERTICAL;
10788 element = getPoolFromOpenDirection(direction | help_direction_vertical);
10791 if (element == EL_EMPTY)
10793 int help_direction_horizontal = help_direction & MV_HORIZONTAL;
10795 element = getPoolFromOpenDirection(direction | help_direction_horizontal);
10801 static int getPoolFromOpenDirectionNotEmpty(int direction, int element_old)
10803 int element_new = getPoolFromOpenDirectionExt(direction, element_old);
10805 return (element_new != EL_EMPTY ? element_new : element_old);
10808 static int getOpenDirectionFromPillar(int element)
10812 case EL_EMC_WALL_1: return (MV_DOWN);
10813 case EL_EMC_WALL_2: return (MV_VERTICAL);
10814 case EL_EMC_WALL_3: return (MV_UP);
10820 static int getPillarFromOpenDirection(int direction)
10824 case (MV_DOWN): return EL_EMC_WALL_1;
10825 case (MV_VERTICAL): return EL_EMC_WALL_2;
10826 case (MV_UP): return EL_EMC_WALL_3;
10832 static int getPillarFromOpenDirectionNotEmpty(int direction, int element_old)
10834 int element_new = getPillarFromOpenDirection(direction);
10836 return (element_new != EL_EMPTY ? element_new : element_old);
10839 static int getOpenDirectionFromSteel2(int element)
10843 case EL_DC_STEELWALL_2_LEFT: return (MV_RIGHT);
10844 case EL_DC_STEELWALL_2_RIGHT: return (MV_LEFT);
10845 case EL_DC_STEELWALL_2_TOP: return (MV_DOWN);
10846 case EL_DC_STEELWALL_2_BOTTOM: return (MV_UP);
10847 case EL_DC_STEELWALL_2_HORIZONTAL: return (MV_HORIZONTAL);
10848 case EL_DC_STEELWALL_2_VERTICAL: return (MV_VERTICAL);
10849 case EL_DC_STEELWALL_2_MIDDLE: return (MV_ANY_DIRECTION);
10850 case EL_DC_STEELWALL_2_SINGLE: return (MV_NONE);
10856 static int getSteel2FromOpenDirection(int direction)
10860 case (MV_RIGHT): return EL_DC_STEELWALL_2_LEFT;
10861 case (MV_LEFT): return EL_DC_STEELWALL_2_RIGHT;
10862 case (MV_DOWN): return EL_DC_STEELWALL_2_TOP;
10863 case (MV_UP): return EL_DC_STEELWALL_2_BOTTOM;
10864 case (MV_HORIZONTAL): return EL_DC_STEELWALL_2_HORIZONTAL;
10865 case (MV_VERTICAL): return EL_DC_STEELWALL_2_VERTICAL;
10866 case (MV_ANY_DIRECTION): return EL_DC_STEELWALL_2_MIDDLE;
10867 case (MV_NONE): return EL_DC_STEELWALL_2_SINGLE;
10873 static int getSteel2FromOpenDirectionNotEmpty(int direction, int element_old)
10875 int element_new = getSteel2FromOpenDirection(direction);
10877 return (element_new != EL_EMPTY ? element_new : element_old);
10880 static int getOpenDirectionFromChip(int element)
10884 case EL_SP_CHIP_SINGLE: return (MV_NONE);
10885 case EL_SP_CHIP_LEFT: return (MV_RIGHT);
10886 case EL_SP_CHIP_RIGHT: return (MV_LEFT);
10887 case EL_SP_CHIP_TOP: return (MV_DOWN);
10888 case EL_SP_CHIP_BOTTOM: return (MV_UP);
10894 static int getChipFromOpenDirection(int direction)
10898 case (MV_NONE): return EL_SP_CHIP_SINGLE;
10899 case (MV_LEFT): return EL_SP_CHIP_RIGHT;
10900 case (MV_RIGHT): return EL_SP_CHIP_LEFT;
10901 case (MV_UP): return EL_SP_CHIP_BOTTOM;
10902 case (MV_DOWN): return EL_SP_CHIP_TOP;
10908 static int getChipFromOpenDirectionNotEmpty(int direction, int element_old)
10910 int element_new = getChipFromOpenDirection(direction);
10912 return (element_new != EL_EMPTY ? element_new : element_old);
10915 static int getClosedTube(int x, int y)
10917 struct XY *xy = xy_directions;
10918 int element_old = IntelliDrawBuffer[x][y];
10919 int direction_old = getOpenDirectionFromTube(element_old);
10920 int direction_new = MV_NONE;
10923 for (i = 0; i < NUM_DIRECTIONS; i++)
10925 int xx = x + xy[i].x;
10926 int yy = y + xy[i].y;
10927 int dir = MV_DIR_FROM_BIT(i);
10928 int dir_opposite = MV_DIR_OPPOSITE(dir);
10930 if (IN_LEV_FIELD(xx, yy) && IS_TUBE(IntelliDrawBuffer[xx][yy]) &&
10931 (direction_old & dir) &&
10932 (getOpenDirectionFromTube(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10933 direction_new |= dir;
10936 return getTubeFromOpenDirectionNotEmpty(direction_new, element_old);
10939 static int getClosedBelt(int x, int y)
10941 struct XY *xy = xy_directions;
10942 int element_old = IntelliDrawBuffer[x][y];
10943 int nr = getBeltNrFromBeltElement(element_old);
10944 int direction_old = getOpenDirectionFromBelt(element_old);
10945 int direction_new = MV_NONE;
10948 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
10950 int xx = x + xy[i].x;
10951 int yy = y + xy[i].y;
10952 int dir = MV_DIR_FROM_BIT(i);
10953 int dir_opposite = MV_DIR_OPPOSITE(dir);
10955 if (IN_LEV_FIELD(xx, yy) && IS_BELT(IntelliDrawBuffer[xx][yy]) &&
10956 (direction_old & dir) &&
10957 (getOpenDirectionFromBelt(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10958 direction_new |= dir;
10961 return getBeltFromNrAndOpenDirection(nr, direction_new);
10964 static int getClosedPool(int x, int y)
10966 struct XY *xy = xy_directions;
10967 int element_old = IntelliDrawBuffer[x][y];
10968 int direction_old = getOpenDirectionFromPool(element_old);
10969 int direction_new = MV_NONE;
10972 for (i = 0; i < NUM_DIRECTIONS; i++)
10974 int xx = x + xy[i].x;
10975 int yy = y + xy[i].y;
10976 int dir = MV_DIR_FROM_BIT(i);
10977 int dir_opposite = MV_DIR_OPPOSITE(dir);
10979 if (IN_LEV_FIELD(xx, yy) &&
10980 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[xx][yy]) &&
10981 (direction_old & dir) &&
10982 (getOpenDirectionFromPool(IntelliDrawBuffer[xx][yy]) & dir_opposite))
10983 direction_new |= dir;
10986 return getPoolFromOpenDirectionNotEmpty(direction_new, element_old);
10989 static int getClosedPillar(int x, int y)
10991 struct XY *xy = xy_directions;
10992 int element_old = IntelliDrawBuffer[x][y];
10993 int direction_old = getOpenDirectionFromPillar(element_old);
10994 int direction_new = MV_NONE;
10997 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
10999 int xx = x + xy[i].x;
11000 int yy = y + xy[i].y;
11001 int dir = MV_DIR_FROM_BIT(i);
11002 int dir_opposite = MV_DIR_OPPOSITE(dir);
11004 if (IN_LEV_FIELD(xx, yy) && IS_EMC_PILLAR(IntelliDrawBuffer[xx][yy]) &&
11005 (direction_old & dir) &&
11006 (getOpenDirectionFromPillar(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11007 direction_new |= dir;
11010 return getPillarFromOpenDirectionNotEmpty(direction_new, element_old);
11013 static int getClosedSteel2(int x, int y)
11015 struct XY *xy = xy_directions;
11016 int element_old = IntelliDrawBuffer[x][y];
11017 int direction_old = getOpenDirectionFromSteel2(element_old);
11018 int direction_new = MV_NONE;
11021 for (i = 0; i < NUM_DIRECTIONS; i++)
11023 int xx = x + xy[i].x;
11024 int yy = y + xy[i].y;
11025 int dir = MV_DIR_FROM_BIT(i);
11026 int dir_opposite = MV_DIR_OPPOSITE(dir);
11028 if (IN_LEV_FIELD(xx, yy) && IS_DC_STEELWALL_2(IntelliDrawBuffer[xx][yy]) &&
11029 (direction_old & dir) &&
11030 (getOpenDirectionFromSteel2(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11031 direction_new |= dir;
11034 return getSteel2FromOpenDirectionNotEmpty(direction_new, element_old);
11037 static int getClosedChip(int x, int y)
11039 struct XY *xy = xy_directions;
11040 int element_old = IntelliDrawBuffer[x][y];
11041 int direction_old = getOpenDirectionFromChip(element_old);
11042 int direction_new = MV_NONE;
11045 for (i = 0; i < NUM_DIRECTIONS; i++)
11047 int xx = x + xy[i].x;
11048 int yy = y + xy[i].y;
11049 int dir = MV_DIR_FROM_BIT(i);
11050 int dir_opposite = MV_DIR_OPPOSITE(dir);
11052 if (IN_LEV_FIELD(xx, yy) && IS_SP_CHIP(IntelliDrawBuffer[xx][yy]) &&
11053 (direction_old & dir) &&
11054 (getOpenDirectionFromChip(IntelliDrawBuffer[xx][yy]) & dir_opposite))
11055 direction_new |= dir;
11058 return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
11061 static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
11062 boolean change_level)
11064 int sx = x - level_xpos;
11065 int sy = y - level_ypos;
11066 int old_element = Tile[x][y];
11067 int new_element = element;
11068 unsigned int new_bitmask = (getDrawModeHiRes() ? (dx + 1) << (dy * 2) : 0x0f);
11069 boolean draw_masked = FALSE;
11071 if (IS_MM_WALL_EDITOR(element))
11073 element = map_mm_wall_element_editor(element) | new_bitmask;
11075 if (IS_MM_WALL(old_element))
11076 element |= MM_WALL_BITS(old_element);
11079 draw_masked = TRUE;
11081 else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
11083 int element_changed = old_element & ~new_bitmask;
11085 if (MM_WALL_BITS(element_changed) != 0)
11086 element = element_changed;
11089 IntelliDrawBuffer[x][y] = element;
11092 Tile[x][y] = element;
11094 if (IN_ED_FIELD(sx, sy))
11096 if (IS_MM_WALL(old_element) && new_element == EL_EMPTY)
11097 DrawSizedWallParts_MM(sx, sy, EL_EMPTY, ed_tilesize, FALSE, new_bitmask);
11098 else if (draw_masked)
11099 DrawEditorElementThruMask(sx, sy, element);
11101 DrawEditorElement(sx, sy, element);
11105 static void SetElementSimple(int x, int y, int element, boolean change_level)
11107 SetElementSimpleExt(x, y, 0, 0, element, change_level);
11110 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
11111 int x2, int y2, int *element2,
11112 int (*close_function)(int, int),
11113 boolean change_level)
11115 // set neighbour elements to newly determined connections
11116 SetElementSimple(x1, y1, *element1, change_level);
11117 SetElementSimple(x2, y2, *element2, change_level);
11119 // remove all open connections of neighbour elements
11120 *element1 = close_function(x1, y1);
11121 *element2 = close_function(x2, y2);
11123 // set neighbour elements to new, minimized connections
11124 SetElementSimple(x1, y1, *element1, change_level);
11125 SetElementSimple(x2, y2, *element2, change_level);
11128 static void SetElementIntelliDraw(int x, int y, int new_element,
11129 boolean change_level, int button)
11131 struct XY *xy = xy_directions;
11132 static int last_x = -1;
11133 static int last_y = -1;
11135 if (new_element == EL_UNDEFINED)
11143 int old_element = IntelliDrawBuffer[x][y];
11145 if (IS_TUBE(new_element))
11147 int last_element_new = EL_UNDEFINED;
11148 int direction = MV_NONE;
11151 // if old element is of same kind, keep all existing directions
11152 if (IS_TUBE(old_element))
11153 direction |= getOpenDirectionFromTube(old_element);
11155 for (i = 0; i < NUM_DIRECTIONS; i++)
11157 int xx = x + xy[i].x;
11158 int yy = y + xy[i].y;
11160 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11161 IS_TUBE(IntelliDrawBuffer[last_x][last_y]))
11163 int dir = MV_DIR_FROM_BIT(i);
11164 int dir_opposite = MV_DIR_OPPOSITE(dir);
11165 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11166 int last_direction_old = getOpenDirectionFromTube(last_element_old);
11167 int last_direction_new = last_direction_old | dir_opposite;
11169 last_element_new = getTubeFromOpenDirection(last_direction_new);
11175 new_element = getTubeFromOpenDirectionNotEmpty(direction, new_element);
11177 if (last_element_new != EL_UNDEFINED)
11178 MergeAndCloseNeighbourElements(x, y, &new_element,
11179 last_x, last_y, &last_element_new,
11180 getClosedTube, change_level);
11182 else if (IS_BELT(new_element))
11184 int belt_nr = getBeltNrFromBeltElement(new_element);
11185 int last_element_new = EL_UNDEFINED;
11186 int direction = MV_NONE;
11189 // if old element is of same kind, keep all existing directions
11190 if (IS_BELT(old_element))
11191 direction |= getOpenDirectionFromBelt(old_element);
11193 for (i = MV_BIT_LEFT; i <= MV_BIT_RIGHT; i++)
11195 int xx = x + xy[i].x;
11196 int yy = y + xy[i].y;
11198 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11199 IS_BELT(IntelliDrawBuffer[last_x][last_y]))
11201 int dir = MV_DIR_FROM_BIT(i);
11202 int dir_opposite = MV_DIR_OPPOSITE(dir);
11203 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11204 int last_belt_nr = getBeltNrFromBeltElement(last_element_old);
11205 int last_direction_old = getOpenDirectionFromBelt(last_element_old);
11206 int last_direction_new = last_direction_old | dir_opposite;
11208 last_element_new = getBeltFromNrAndOpenDirection(last_belt_nr,
11209 last_direction_new);
11214 new_element = getBeltFromNrAndOpenDirectionNotEmpty(belt_nr, direction,
11216 if (last_element_new != EL_UNDEFINED)
11217 MergeAndCloseNeighbourElements(x, y, &new_element,
11218 last_x, last_y, &last_element_new,
11219 getClosedBelt, change_level);
11221 else if (IS_ACID_POOL_OR_ACID(new_element))
11223 int last_element_new = EL_UNDEFINED;
11224 int direction = MV_NONE;
11227 // if old element is of same kind, keep all existing directions
11228 if (IS_ACID_POOL_OR_ACID(old_element))
11229 direction |= getOpenDirectionFromPool(old_element);
11231 for (i = 0; i < NUM_DIRECTIONS; i++)
11233 int xx = x + xy[i].x;
11234 int yy = y + xy[i].y;
11236 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11237 IS_ACID_POOL_OR_ACID(IntelliDrawBuffer[last_x][last_y]))
11239 int dir = MV_DIR_FROM_BIT(i);
11240 int dir_opposite = MV_DIR_OPPOSITE(dir);
11241 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11242 int last_direction_old = getOpenDirectionFromPool(last_element_old);
11243 int last_direction_new = last_direction_old | dir_opposite;
11245 last_element_new = getPoolFromOpenDirection(last_direction_new);
11251 // special corrections needed for intuitively correct acid pool drawing
11252 if (last_element_new == EL_EMPTY)
11253 last_element_new = new_element;
11254 else if (last_element_new != EL_UNDEFINED)
11255 new_element = last_element_new;
11257 new_element = getPoolFromOpenDirectionNotEmpty(direction, new_element);
11259 if (last_element_new != EL_UNDEFINED)
11260 MergeAndCloseNeighbourElements(x, y, &new_element,
11261 last_x, last_y, &last_element_new,
11262 getClosedPool, change_level);
11264 else if (IS_EMC_PILLAR(new_element))
11266 int last_element_new = EL_UNDEFINED;
11267 int direction = MV_NONE;
11270 // if old element is of same kind, keep all existing directions
11271 if (IS_EMC_PILLAR(old_element))
11272 direction |= getOpenDirectionFromPillar(old_element);
11274 for (i = MV_BIT_UP; i <= MV_BIT_DOWN; i++)
11276 int xx = x + xy[i].x;
11277 int yy = y + xy[i].y;
11279 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11280 IS_EMC_PILLAR(IntelliDrawBuffer[last_x][last_y]))
11282 int dir = MV_DIR_FROM_BIT(i);
11283 int dir_opposite = MV_DIR_OPPOSITE(dir);
11284 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11285 int last_direction_old = getOpenDirectionFromPillar(last_element_old);
11286 int last_direction_new = last_direction_old | dir_opposite;
11288 last_element_new = getPillarFromOpenDirection(last_direction_new);
11294 new_element = getPillarFromOpenDirectionNotEmpty(direction, new_element);
11296 if (last_element_new != EL_UNDEFINED)
11297 MergeAndCloseNeighbourElements(x, y, &new_element,
11298 last_x, last_y, &last_element_new,
11299 getClosedPillar, change_level);
11301 else if (IS_DC_STEELWALL_2(new_element))
11303 int last_element_new = EL_UNDEFINED;
11304 int direction = MV_NONE;
11307 // if old element is of same kind, keep all existing directions
11308 if (IS_DC_STEELWALL_2(old_element))
11309 direction |= getOpenDirectionFromSteel2(old_element);
11311 for (i = 0; i < NUM_DIRECTIONS; i++)
11313 int xx = x + xy[i].x;
11314 int yy = y + xy[i].y;
11316 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11317 IS_DC_STEELWALL_2(IntelliDrawBuffer[last_x][last_y]))
11319 int dir = MV_DIR_FROM_BIT(i);
11320 int dir_opposite = MV_DIR_OPPOSITE(dir);
11321 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11322 int last_direction_old = getOpenDirectionFromSteel2(last_element_old);
11323 int last_direction_new = last_direction_old | dir_opposite;
11325 last_element_new = getSteel2FromOpenDirection(last_direction_new);
11331 new_element = getSteel2FromOpenDirectionNotEmpty(direction, new_element);
11333 if (last_element_new != EL_UNDEFINED)
11334 MergeAndCloseNeighbourElements(x, y, &new_element,
11335 last_x, last_y, &last_element_new,
11336 getClosedSteel2, change_level);
11338 else if (IS_SP_CHIP(new_element))
11340 int last_element_new = EL_UNDEFINED;
11341 int direction = MV_NONE;
11344 // (do not keep existing directions, regardless of kind of old element)
11346 for (i = 0; i < NUM_DIRECTIONS; i++)
11348 int xx = x + xy[i].x;
11349 int yy = y + xy[i].y;
11351 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11352 IS_SP_CHIP(IntelliDrawBuffer[last_x][last_y]))
11354 int dir = MV_DIR_FROM_BIT(i);
11355 int dir_opposite = MV_DIR_OPPOSITE(dir);
11356 int last_element_old = IntelliDrawBuffer[last_x][last_y];
11357 int last_direction_old = getOpenDirectionFromChip(last_element_old);
11358 int last_direction_new = last_direction_old | dir_opposite;
11360 if (last_direction_old == MV_NONE)
11362 last_element_new = getChipFromOpenDirection(last_direction_new);
11365 else if (last_direction_old & (dir | dir_opposite))
11367 direction |= MV_DIR_OPPOSITE(last_direction_old);
11371 direction |= MV_DIR_OPPOSITE(dir);
11376 new_element = getChipFromOpenDirectionNotEmpty(direction, new_element);
11378 if (last_element_new != EL_UNDEFINED)
11379 MergeAndCloseNeighbourElements(x, y, &new_element,
11380 last_x, last_y, &last_element_new,
11381 getClosedChip, change_level);
11383 else if (IS_SP_HARDWARE_BASE(new_element))
11385 int nr = GetSimpleRandom(6);
11387 new_element = (nr == 0 ? EL_SP_HARDWARE_BASE_1 :
11388 nr == 1 ? EL_SP_HARDWARE_BASE_2 :
11389 nr == 2 ? EL_SP_HARDWARE_BASE_3 :
11390 nr == 3 ? EL_SP_HARDWARE_BASE_4 :
11391 nr == 4 ? EL_SP_HARDWARE_BASE_5 : EL_SP_HARDWARE_BASE_6);
11393 else if (new_element == EL_SP_HARDWARE_GREEN ||
11394 new_element == EL_SP_HARDWARE_BLUE ||
11395 new_element == EL_SP_HARDWARE_RED)
11397 int nr = GetSimpleRandom(3);
11399 new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN :
11400 nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED);
11402 else if (IS_GROUP_ELEMENT(new_element))
11404 boolean connected_drawing = FALSE;
11407 for (i = 0; i < NUM_DIRECTIONS; i++)
11409 int xx = x + xy[i].x;
11410 int yy = y + xy[i].y;
11412 if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) &&
11413 IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element))
11414 connected_drawing = TRUE;
11417 if (!connected_drawing)
11418 ResolveGroupElement(new_element);
11420 new_element = GetElementFromGroupElement(new_element);
11422 else if (IS_BELT_SWITCH(old_element))
11424 int belt_nr = getBeltNrFromBeltSwitchElement(old_element);
11425 int belt_dir = getBeltDirFromBeltSwitchElement(old_element);
11427 belt_dir = (belt_dir == MV_LEFT ? MV_NONE :
11428 belt_dir == MV_NONE ? MV_RIGHT : MV_LEFT);
11430 new_element = getBeltSwitchElementFromBeltNrAndBeltDir(belt_nr, belt_dir);
11434 static int swappable_elements[][2] =
11436 { EL_EXIT_CLOSED, EL_EXIT_OPEN },
11437 { EL_DYNAMITE, EL_DYNAMITE_ACTIVE },
11438 { EL_EM_DYNAMITE, EL_EM_DYNAMITE_ACTIVE },
11439 { EL_QUICKSAND_EMPTY, EL_QUICKSAND_FULL },
11440 { EL_EMERALD, EL_WALL_EMERALD },
11441 { EL_EMERALD_YELLOW, EL_WALL_EMERALD_YELLOW },
11442 { EL_EMERALD_RED, EL_WALL_EMERALD_RED },
11443 { EL_EMERALD_PURPLE, EL_WALL_EMERALD_PURPLE },
11444 { EL_DIAMOND, EL_WALL_DIAMOND },
11445 { EL_BD_DIAMOND, EL_WALL_BD_DIAMOND },
11446 { EL_GATE_1, EL_GATE_1_GRAY },
11447 { EL_GATE_2, EL_GATE_2_GRAY },
11448 { EL_GATE_3, EL_GATE_3_GRAY },
11449 { EL_GATE_4, EL_GATE_4_GRAY },
11450 { EL_EM_GATE_1, EL_EM_GATE_1_GRAY },
11451 { EL_EM_GATE_2, EL_EM_GATE_2_GRAY },
11452 { EL_EM_GATE_3, EL_EM_GATE_3_GRAY },
11453 { EL_EM_GATE_4, EL_EM_GATE_4_GRAY },
11454 { EL_EMC_GATE_5, EL_EMC_GATE_5_GRAY },
11455 { EL_EMC_GATE_6, EL_EMC_GATE_6_GRAY },
11456 { EL_EMC_GATE_7, EL_EMC_GATE_7_GRAY },
11457 { EL_EMC_GATE_8, EL_EMC_GATE_8_GRAY },
11458 { EL_DC_GATE_WHITE, EL_DC_GATE_WHITE_GRAY },
11459 { EL_TIME_ORB_EMPTY, EL_TIME_ORB_FULL },
11460 { EL_LAMP, EL_LAMP_ACTIVE },
11461 { EL_SOKOBAN_FIELD_EMPTY, EL_SOKOBAN_FIELD_FULL },
11462 { EL_SP_BASE, EL_SP_BUGGY_BASE },
11463 { EL_PEARL, EL_WALL_PEARL },
11464 { EL_CRYSTAL, EL_WALL_CRYSTAL },
11465 { EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN },
11466 { EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_OPEN },
11467 { EL_SWITCHGATE_SWITCH_UP, EL_SWITCHGATE_SWITCH_DOWN },
11468 { EL_DC_SWITCHGATE_SWITCH_UP, EL_DC_SWITCHGATE_SWITCH_DOWN },
11469 { EL_LIGHT_SWITCH, EL_LIGHT_SWITCH_ACTIVE },
11470 { EL_LANDMINE, EL_DC_LANDMINE },
11471 { EL_SHIELD_NORMAL, EL_SHIELD_DEADLY },
11472 { EL_STEEL_EXIT_CLOSED, EL_STEEL_EXIT_OPEN },
11473 { EL_EM_EXIT_CLOSED, EL_EM_EXIT_OPEN },
11474 { EL_EM_STEEL_EXIT_CLOSED, EL_EM_STEEL_EXIT_OPEN },
11475 { EL_QUICKSAND_FAST_EMPTY, EL_QUICKSAND_FAST_FULL },
11476 { EL_MM_EXIT_CLOSED, EL_MM_EXIT_OPEN },
11477 { EL_MM_FUSE, EL_MM_FUSE_ACTIVE },
11478 { EL_MM_LIGHTBULB, EL_MM_LIGHTBULB_ACTIVE },
11479 { EL_MM_FUEL_EMPTY, EL_MM_FUEL_FULL },
11483 static int rotatable_elements_4[][4] =
11493 EL_SPACESHIP_RIGHT,
11498 EL_BD_BUTTERFLY_UP,
11499 EL_BD_BUTTERFLY_RIGHT,
11500 EL_BD_BUTTERFLY_DOWN,
11501 EL_BD_BUTTERFLY_LEFT
11505 EL_BD_FIREFLY_RIGHT,
11506 EL_BD_FIREFLY_DOWN,
11534 EL_SP_GRAVITY_PORT_UP,
11535 EL_SP_GRAVITY_PORT_RIGHT,
11536 EL_SP_GRAVITY_PORT_DOWN,
11537 EL_SP_GRAVITY_PORT_LEFT
11540 EL_SP_GRAVITY_ON_PORT_UP,
11541 EL_SP_GRAVITY_ON_PORT_RIGHT,
11542 EL_SP_GRAVITY_ON_PORT_DOWN,
11543 EL_SP_GRAVITY_ON_PORT_LEFT
11546 EL_SP_GRAVITY_OFF_PORT_UP,
11547 EL_SP_GRAVITY_OFF_PORT_RIGHT,
11548 EL_SP_GRAVITY_OFF_PORT_DOWN,
11549 EL_SP_GRAVITY_OFF_PORT_LEFT
11558 EL_BALLOON_SWITCH_UP,
11559 EL_BALLOON_SWITCH_RIGHT,
11560 EL_BALLOON_SWITCH_DOWN,
11561 EL_BALLOON_SWITCH_LEFT
11565 EL_MM_MCDUFFIN_RIGHT,
11566 EL_MM_MCDUFFIN_DOWN,
11567 EL_MM_MCDUFFIN_LEFT
11570 EL_MM_MIRROR_FIXED_1,
11571 EL_MM_MIRROR_FIXED_4,
11572 EL_MM_MIRROR_FIXED_3,
11573 EL_MM_MIRROR_FIXED_2
11576 EL_MM_STEEL_GRID_FIXED_1,
11577 EL_MM_STEEL_GRID_FIXED_4,
11578 EL_MM_STEEL_GRID_FIXED_2,
11579 EL_MM_STEEL_GRID_FIXED_3
11582 EL_MM_WOODEN_GRID_FIXED_1,
11583 EL_MM_WOODEN_GRID_FIXED_4,
11584 EL_MM_WOODEN_GRID_FIXED_2,
11585 EL_MM_WOODEN_GRID_FIXED_3
11588 EL_MM_POLARIZER_CROSS_1,
11589 EL_MM_POLARIZER_CROSS_4,
11590 EL_MM_POLARIZER_CROSS_3,
11591 EL_MM_POLARIZER_CROSS_2
11595 EL_MM_PACMAN_RIGHT,
11607 EL_DF_RECEIVER_RIGHT,
11608 EL_DF_RECEIVER_DOWN,
11609 EL_DF_RECEIVER_LEFT
11616 static int rotatable_elements_8[][8] =
11619 EL_DF_STEEL_GRID_FIXED_1,
11620 EL_DF_STEEL_GRID_FIXED_8,
11621 EL_DF_STEEL_GRID_FIXED_7,
11622 EL_DF_STEEL_GRID_FIXED_6,
11623 EL_DF_STEEL_GRID_FIXED_5,
11624 EL_DF_STEEL_GRID_FIXED_4,
11625 EL_DF_STEEL_GRID_FIXED_3,
11626 EL_DF_STEEL_GRID_FIXED_2
11629 EL_DF_WOODEN_GRID_FIXED_1,
11630 EL_DF_WOODEN_GRID_FIXED_8,
11631 EL_DF_WOODEN_GRID_FIXED_7,
11632 EL_DF_WOODEN_GRID_FIXED_6,
11633 EL_DF_WOODEN_GRID_FIXED_5,
11634 EL_DF_WOODEN_GRID_FIXED_4,
11635 EL_DF_WOODEN_GRID_FIXED_3,
11636 EL_DF_WOODEN_GRID_FIXED_2
11639 EL_DF_STEEL_GRID_ROTATING_1,
11640 EL_DF_STEEL_GRID_ROTATING_8,
11641 EL_DF_STEEL_GRID_ROTATING_7,
11642 EL_DF_STEEL_GRID_ROTATING_6,
11643 EL_DF_STEEL_GRID_ROTATING_5,
11644 EL_DF_STEEL_GRID_ROTATING_4,
11645 EL_DF_STEEL_GRID_ROTATING_3,
11646 EL_DF_STEEL_GRID_ROTATING_2
11649 EL_DF_WOODEN_GRID_ROTATING_1,
11650 EL_DF_WOODEN_GRID_ROTATING_8,
11651 EL_DF_WOODEN_GRID_ROTATING_7,
11652 EL_DF_WOODEN_GRID_ROTATING_6,
11653 EL_DF_WOODEN_GRID_ROTATING_5,
11654 EL_DF_WOODEN_GRID_ROTATING_4,
11655 EL_DF_WOODEN_GRID_ROTATING_3,
11656 EL_DF_WOODEN_GRID_ROTATING_2
11663 static int rotatable_elements_16[][16] =
11684 EL_MM_TELEPORTER_5,
11685 EL_MM_TELEPORTER_4,
11686 EL_MM_TELEPORTER_3,
11687 EL_MM_TELEPORTER_2,
11688 EL_MM_TELEPORTER_1,
11689 EL_MM_TELEPORTER_16,
11690 EL_MM_TELEPORTER_15,
11691 EL_MM_TELEPORTER_14,
11692 EL_MM_TELEPORTER_13,
11693 EL_MM_TELEPORTER_12,
11694 EL_MM_TELEPORTER_11,
11695 EL_MM_TELEPORTER_10,
11696 EL_MM_TELEPORTER_9,
11697 EL_MM_TELEPORTER_8,
11698 EL_MM_TELEPORTER_7,
11702 EL_MM_TELEPORTER_RED_5,
11703 EL_MM_TELEPORTER_RED_4,
11704 EL_MM_TELEPORTER_RED_3,
11705 EL_MM_TELEPORTER_RED_2,
11706 EL_MM_TELEPORTER_RED_1,
11707 EL_MM_TELEPORTER_RED_16,
11708 EL_MM_TELEPORTER_RED_15,
11709 EL_MM_TELEPORTER_RED_14,
11710 EL_MM_TELEPORTER_RED_13,
11711 EL_MM_TELEPORTER_RED_12,
11712 EL_MM_TELEPORTER_RED_11,
11713 EL_MM_TELEPORTER_RED_10,
11714 EL_MM_TELEPORTER_RED_9,
11715 EL_MM_TELEPORTER_RED_8,
11716 EL_MM_TELEPORTER_RED_7,
11717 EL_MM_TELEPORTER_RED_6
11720 EL_MM_TELEPORTER_YELLOW_5,
11721 EL_MM_TELEPORTER_YELLOW_4,
11722 EL_MM_TELEPORTER_YELLOW_3,
11723 EL_MM_TELEPORTER_YELLOW_2,
11724 EL_MM_TELEPORTER_YELLOW_1,
11725 EL_MM_TELEPORTER_YELLOW_16,
11726 EL_MM_TELEPORTER_YELLOW_15,
11727 EL_MM_TELEPORTER_YELLOW_14,
11728 EL_MM_TELEPORTER_YELLOW_13,
11729 EL_MM_TELEPORTER_YELLOW_12,
11730 EL_MM_TELEPORTER_YELLOW_11,
11731 EL_MM_TELEPORTER_YELLOW_10,
11732 EL_MM_TELEPORTER_YELLOW_9,
11733 EL_MM_TELEPORTER_YELLOW_8,
11734 EL_MM_TELEPORTER_YELLOW_7,
11735 EL_MM_TELEPORTER_YELLOW_6
11738 EL_MM_TELEPORTER_GREEN_5,
11739 EL_MM_TELEPORTER_GREEN_4,
11740 EL_MM_TELEPORTER_GREEN_3,
11741 EL_MM_TELEPORTER_GREEN_2,
11742 EL_MM_TELEPORTER_GREEN_1,
11743 EL_MM_TELEPORTER_GREEN_16,
11744 EL_MM_TELEPORTER_GREEN_15,
11745 EL_MM_TELEPORTER_GREEN_14,
11746 EL_MM_TELEPORTER_GREEN_13,
11747 EL_MM_TELEPORTER_GREEN_12,
11748 EL_MM_TELEPORTER_GREEN_11,
11749 EL_MM_TELEPORTER_GREEN_10,
11750 EL_MM_TELEPORTER_GREEN_9,
11751 EL_MM_TELEPORTER_GREEN_8,
11752 EL_MM_TELEPORTER_GREEN_7,
11753 EL_MM_TELEPORTER_GREEN_6
11756 EL_MM_TELEPORTER_BLUE_5,
11757 EL_MM_TELEPORTER_BLUE_4,
11758 EL_MM_TELEPORTER_BLUE_3,
11759 EL_MM_TELEPORTER_BLUE_2,
11760 EL_MM_TELEPORTER_BLUE_1,
11761 EL_MM_TELEPORTER_BLUE_16,
11762 EL_MM_TELEPORTER_BLUE_15,
11763 EL_MM_TELEPORTER_BLUE_14,
11764 EL_MM_TELEPORTER_BLUE_13,
11765 EL_MM_TELEPORTER_BLUE_12,
11766 EL_MM_TELEPORTER_BLUE_11,
11767 EL_MM_TELEPORTER_BLUE_10,
11768 EL_MM_TELEPORTER_BLUE_9,
11769 EL_MM_TELEPORTER_BLUE_8,
11770 EL_MM_TELEPORTER_BLUE_7,
11771 EL_MM_TELEPORTER_BLUE_6
11775 EL_MM_POLARIZER_16,
11776 EL_MM_POLARIZER_15,
11777 EL_MM_POLARIZER_14,
11778 EL_MM_POLARIZER_13,
11779 EL_MM_POLARIZER_12,
11780 EL_MM_POLARIZER_11,
11781 EL_MM_POLARIZER_10,
11810 EL_DF_MIRROR_ROTATING_1,
11811 EL_DF_MIRROR_ROTATING_16,
11812 EL_DF_MIRROR_ROTATING_15,
11813 EL_DF_MIRROR_ROTATING_14,
11814 EL_DF_MIRROR_ROTATING_13,
11815 EL_DF_MIRROR_ROTATING_12,
11816 EL_DF_MIRROR_ROTATING_11,
11817 EL_DF_MIRROR_ROTATING_10,
11818 EL_DF_MIRROR_ROTATING_9,
11819 EL_DF_MIRROR_ROTATING_8,
11820 EL_DF_MIRROR_ROTATING_7,
11821 EL_DF_MIRROR_ROTATING_6,
11822 EL_DF_MIRROR_ROTATING_5,
11823 EL_DF_MIRROR_ROTATING_4,
11824 EL_DF_MIRROR_ROTATING_3,
11825 EL_DF_MIRROR_ROTATING_2
11834 for (i = 0; swappable_elements[i][0] != -1; i++)
11836 int element1 = swappable_elements[i][0];
11837 int element2 = swappable_elements[i][1];
11839 if (old_element == element1 || old_element == element2)
11840 new_element = (old_element == element1 ? element2 : element1);
11843 for (i = 0; rotatable_elements_4[i][0] != -1; i++)
11845 for (j = 0; j < 4; j++)
11847 int element = rotatable_elements_4[i][j];
11849 if (old_element == element)
11850 new_element = (button == 1 ? rotatable_elements_4[i][(j + 3) % 4] :
11851 button == 2 ? rotatable_elements_4[i][0] :
11852 button == 3 ? rotatable_elements_4[i][(j + 1) % 4] :
11857 for (i = 0; rotatable_elements_8[i][0] != -1; i++)
11859 for (j = 0; j < 8; j++)
11861 int element = rotatable_elements_8[i][j];
11863 if (old_element == element)
11864 new_element = (button == 1 ? rotatable_elements_8[i][(j + 7) % 8] :
11865 button == 2 ? rotatable_elements_8[i][0] :
11866 button == 3 ? rotatable_elements_8[i][(j + 1) % 8] :
11871 for (i = 0; rotatable_elements_16[i][0] != -1; i++)
11873 for (j = 0; j < 16; j++)
11875 int element = rotatable_elements_16[i][j];
11877 if (old_element == element)
11878 new_element = (button == 1 ? rotatable_elements_16[i][(j + 15) % 16] :
11879 button == 2 ? rotatable_elements_16[i][0] :
11880 button == 3 ? rotatable_elements_16[i][(j + 1) % 16] :
11885 if (old_element != new_element)
11887 int max_infotext_len = getMaxInfoTextLength();
11888 char infotext[MAX_OUTPUT_LINESIZE + 1];
11890 strncpy(infotext, getElementInfoText(new_element), max_infotext_len);
11891 infotext[max_infotext_len] = '\0';
11893 ClearEditorGadgetInfoText();
11895 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT,
11900 SetElementSimple(x, y, new_element, change_level);
11906 static void ResetIntelliDraw(void)
11910 for (x = 0; x < lev_fieldx; x++)
11911 for (y = 0; y < lev_fieldy; y++)
11912 IntelliDrawBuffer[x][y] = Tile[x][y];
11914 SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
11917 static boolean draw_mode_hires = FALSE;
11919 static boolean isHiresTileElement(int element)
11921 return (IS_MM_WALL(element) || element == EL_EMPTY);
11924 static boolean isHiresDrawElement(int element)
11926 return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
11929 static void SetDrawModeHiRes(int element)
11932 (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
11933 isHiresDrawElement(element));
11936 static boolean getDrawModeHiRes(void)
11938 return draw_mode_hires;
11941 static int getLoResScreenPos(int pos)
11943 return (getDrawModeHiRes() ? pos / 2 : pos);
11946 static int getLoResScreenMod(int pos)
11948 return (getDrawModeHiRes() ? pos % 2 : 0);
11951 static void SetElementExt(int x, int y, int dx, int dy, int element,
11952 boolean change_level, int button)
11955 SetElementSimple(x, y, Tile[x][y], change_level);
11956 else if (GetKeyModState() & KMOD_Shift && !IS_MM_WALL_EDITOR(element))
11957 SetElementIntelliDraw(x, y, element, change_level, button);
11959 SetElementSimpleExt(x, y, dx, dy, element, change_level);
11962 static void SetElement(int x, int y, int element)
11964 SetElementExt(x, y, 0, 0, element, TRUE, -1);
11967 static void SetElementButton(int x, int y, int dx, int dy, int element,
11970 SetElementExt(x, y, dx, dy, element, TRUE, button);
11973 static void SetElementHiRes(int sx2, int sy2, int element, boolean change_level)
11975 int lx = getLoResScreenPos(sx2) + level_xpos;
11976 int ly = getLoResScreenPos(sy2) + level_ypos;
11977 int dx = getLoResScreenMod(sx2);
11978 int dy = getLoResScreenMod(sy2);
11980 SetElementExt(lx, ly, dx, dy, element, change_level, -1);
11983 static void SetLevelElementHiRes(int lx2, int ly2, int element)
11990 SetElementExt(lx, ly, dx, dy, element, TRUE, -1);
11993 static int getLevelElementHiRes(int lx2, int ly2)
11999 int element = Tile[lx][ly];
12000 unsigned int bitmask = (dx + 1) << (dy * 2);
12002 if (IS_MM_WALL(element))
12004 if (element & bitmask)
12005 return map_mm_wall_element(element);
12013 static void DrawLineElement(int x, int y, int element, boolean change_level)
12015 SetElementHiRes(x, y, element, change_level);
12018 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
12019 int element, boolean change_level)
12021 int xsize = ABS(to_x - from_x);
12022 int ysize = ABS(to_y - from_y);
12023 int dx = (to_x < from_x ? -1 : +1);
12024 int dy = (to_y < from_y ? -1 : +1);
12027 if (from_y == to_y) // horizontal line
12029 for (i = 0; i <= xsize; i++)
12030 DrawLineElement(from_x + i * dx, from_y, element, change_level);
12032 else if (from_x == to_x) // vertical line
12034 for (i = 0; i <= ysize; i++)
12035 DrawLineElement(from_x, from_y + i * dy, element, change_level);
12037 else // diagonal line
12039 if (ysize < xsize) // a < 1
12041 float a = (float)ysize / (float)xsize;
12043 for (i = 0; i <= xsize; i++)
12046 int y = dy * (int)(a * i + 0.5);
12048 DrawLineElement(from_x + x, from_y + y, element, change_level);
12053 float a = (float)xsize / (float)ysize;
12055 for (i = 0; i <= ysize; i++)
12057 int x = dx * (int)(a * i + 0.5);
12060 DrawLineElement(from_x + x, from_y + y, element, change_level);
12066 static void DrawBox(int from_x, int from_y, int to_x, int to_y,
12067 int element, boolean change_level)
12069 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
12070 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
12071 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
12072 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
12075 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
12076 int element, boolean change_level)
12081 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
12083 for (y = from_y; y <= to_y; y++)
12084 DrawLine(from_x, y, to_x, y, element, change_level);
12087 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
12088 int element, boolean change_level)
12090 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
12091 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
12092 int len_x = ABS(to_x - from_x);
12093 int len_y = ABS(to_y - from_y);
12096 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
12098 // not optimal (some points get drawn twice) but simple,
12099 // and fast enough for the few points we are drawing
12101 for (x = 0; x <= radius; x++)
12103 int sx, sy, sx2, sy2, lx, ly;
12105 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
12107 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12108 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12109 sx = getLoResScreenPos(sx2);
12110 sy = getLoResScreenPos(sy2);
12111 lx = sx + level_xpos;
12112 ly = sy + level_ypos;
12114 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12115 DrawLineElement(sx2, sy2, element, change_level);
12118 for (y = 0; y <= radius; y++)
12120 int sx, sy, sx2, sy2, lx, ly;
12122 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
12124 sx2 = from_x + x * (from_x < to_x2 ? +1 : -1);
12125 sy2 = from_y + y * (from_y < to_y2 ? +1 : -1);
12126 sx = getLoResScreenPos(sx2);
12127 sy = getLoResScreenPos(sy2);
12128 lx = sx + level_xpos;
12129 ly = sy + level_ypos;
12131 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12132 DrawLineElement(sx2, sy2, element, change_level);
12136 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
12137 int element, boolean change_level)
12139 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12140 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12142 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12145 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
12147 #if DRAW_CIRCLES_BUTTON_AVAILABLE
12148 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
12149 int element, boolean change_level)
12151 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
12152 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
12153 int mirror_to_x2 = from_x - (to_x2 - from_x);
12154 int mirror_to_y2 = from_y - (to_y2 - from_y);
12156 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
12157 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
12158 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
12159 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
12163 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
12165 int from_sx, from_sy;
12169 swap_numbers(&from_x, &to_x);
12172 swap_numbers(&from_y, &to_y);
12174 from_sx = SX + from_x * ed_tilesize;
12175 from_sy = SY + from_y * ed_tilesize;
12176 to_sx = SX + (to_x + 1) * ed_tilesize - 1;
12177 to_sy = SY + (to_y + 1) * ed_tilesize - 1;
12179 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12180 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12181 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12182 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12184 if (from_x == to_x && from_y == to_y)
12185 MarkTileDirty(from_x/2, from_y/2);
12187 redraw_mask |= REDRAW_FIELD;
12190 static void DrawAreaBox(int from_x, int from_y, int to_x, int to_y,
12191 int element, boolean change_level)
12193 DrawBox(from_x, from_y, to_x, to_y, element, change_level);
12196 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
12197 int element, boolean change_level)
12199 if (element == -1 || change_level)
12200 DrawAreaBox(from_x, from_y, to_x, to_y, -1, FALSE);
12202 DrawAreaBorder(from_x, from_y, to_x, to_y);
12205 // values for CopyBrushExt()
12206 #define CB_AREA_TO_BRUSH 0
12207 #define CB_BRUSH_TO_CURSOR 1
12208 #define CB_BRUSH_TO_LEVEL 2
12209 #define CB_DELETE_OLD_CURSOR 3
12210 #define CB_DUMP_BRUSH 4
12211 #define CB_DUMP_BRUSH_SMALL 5
12212 #define CB_CLIPBOARD_TO_BRUSH 6
12213 #define CB_BRUSH_TO_CLIPBOARD 7
12214 #define CB_BRUSH_TO_CLIPBOARD_SMALL 8
12215 #define CB_UPDATE_BRUSH_POSITION 9
12217 #define MAX_CB_PART_SIZE 10
12218 #define MAX_CB_LINE_SIZE (MAX_LEV_FIELDX + 1) // text plus newline
12219 #define MAX_CB_NUM_LINES (MAX_LEV_FIELDY)
12220 #define MAX_CB_TEXT_SIZE (MAX_CB_LINE_SIZE * \
12221 MAX_CB_NUM_LINES * \
12224 static void DrawBrushElement(int sx, int sy, int element, boolean change_level)
12226 DrawLineElement(sx, sy, element, change_level);
12229 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
12230 int button, int mode)
12232 static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12233 static int brush_width, brush_height;
12234 static int last_cursor_x = -1, last_cursor_y = -1;
12235 static boolean delete_old_brush = FALSE;
12236 int new_element = BUTTON_ELEMENT(button);
12239 if (mode == CB_DUMP_BRUSH ||
12240 mode == CB_DUMP_BRUSH_SMALL ||
12241 mode == CB_BRUSH_TO_CLIPBOARD ||
12242 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12244 if (edit_mode != ED_MODE_DRAWING)
12247 char part[MAX_CB_PART_SIZE + 1] = "";
12248 char text[MAX_CB_TEXT_SIZE + 1] = "";
12249 int width = (draw_with_brush ? brush_width : lev_fieldx);
12250 int height = (draw_with_brush ? brush_height : lev_fieldy);
12251 char *format = "%s%03d";
12253 for (y = 0; y < height; y++)
12254 for (x = 0; x < width; x++)
12255 if ((draw_with_brush ? brush_buffer[x][y] : Tile[x][y]) > 999)
12258 for (y = 0; y < height; y++)
12260 for (x = 0; x < width; x++)
12262 int element = (draw_with_brush ? brush_buffer[x][y] : Tile[x][y]);
12263 char *prefix = (mode == CB_DUMP_BRUSH ||
12264 mode == CB_BRUSH_TO_CLIPBOARD ? "`" : "¸");
12266 if (element >= NUM_FILE_ELEMENTS)
12267 element = EL_UNKNOWN;
12269 // copy brush to level sketch text buffer for the R'n'D forum:
12270 // - large tiles: `xxx or `xxxx (0x60 ASCII)
12271 // - small tiles: ¸xxx or ¸xxxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
12272 snprintf(part, MAX_CB_PART_SIZE + 1, format, prefix, element);
12273 strcat(text, part);
12276 strcat(text, "\n");
12279 if (mode == CB_BRUSH_TO_CLIPBOARD ||
12280 mode == CB_BRUSH_TO_CLIPBOARD_SMALL)
12281 SDL_SetClipboardText(text);
12283 Print("%s", text); // print brush data to console and log file
12288 if (mode == CB_CLIPBOARD_TO_BRUSH)
12290 if (edit_mode != ED_MODE_DRAWING)
12293 if (!SDL_HasClipboardText())
12295 Request("Clipboard is empty!", REQ_CONFIRM);
12300 boolean copy_to_brush = (draw_with_brush ||
12301 drawing_function == GADGET_ID_GRAB_BRUSH);
12303 // this will delete the old brush, if already drawing with a brush
12305 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], MB_LEFTBUTTON);
12307 // initialization is required for "odd" (incomplete) clipboard content
12308 for (x = 0; x < MAX_LEV_FIELDX; x++)
12309 for (y = 0; y < MAX_LEV_FIELDY; y++)
12310 brush_buffer[x][y] = EL_EMPTY;
12317 char *clipboard_text = SDL_GetClipboardText();
12318 char *ptr = clipboard_text;
12319 boolean allow_new_row = FALSE;
12320 boolean stop = FALSE;
12322 while (*ptr && !stop)
12324 boolean prefix_found = FALSE;
12325 boolean start_new_row = FALSE;
12327 // level sketch element number prefixes (may be multi-byte characters)
12328 char *prefix_list[] = { "`", "¸" };
12331 for (i = 0; i < ARRAY_SIZE(prefix_list); i++)
12333 char *prefix = prefix_list[i];
12335 // check if string is large enough for prefix
12336 if (strlen(ptr) < strlen(prefix))
12343 // check if string starts with prefix
12344 if (strPrefix(ptr, prefix))
12346 ptr += strlen(prefix);
12348 prefix_found = TRUE;
12354 // check if prefix found and followed by (at least) three digits
12355 if (prefix_found &&
12356 strlen(ptr) >= 3 &&
12357 ptr[0] >= '0' && ptr[0] <= '9' &&
12358 ptr[1] >= '0' && ptr[1] <= '9' &&
12359 ptr[2] >= '0' && ptr[2] <= '9')
12361 int element = ((ptr[0] - '0') * 100 +
12362 (ptr[1] - '0') * 10 +
12367 // level sketch element number might consist of four digits
12368 if (ptr[0] >= '0' && ptr[0] <= '9')
12370 element = element * 10 + (ptr[0] - '0');
12374 // remap some (historic, now obsolete) elements
12375 element = getMappedElement(element);
12377 if (element >= NUM_FILE_ELEMENTS)
12378 element = EL_UNKNOWN;
12380 brush_buffer[x][y] = element;
12382 brush_width = MAX(x + 1, brush_width);
12383 brush_height = MAX(y + 1, brush_height);
12387 if (x >= MAX_LEV_FIELDX)
12388 start_new_row = TRUE;
12390 allow_new_row = TRUE;
12394 if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
12395 start_new_row = TRUE;
12397 ptr++; // !!! FIX THIS for real UTF-8 handling !!!
12405 if (y >= MAX_LEV_FIELDY)
12408 allow_new_row = FALSE;
12412 SDL_free(clipboard_text);
12414 if (brush_width == 0 || brush_height == 0)
12416 Request("No level sketch found in clipboard!", REQ_CONFIRM);
12423 struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_DRAWING_LEVEL];
12426 SDL_GetMouseState(&mx, &my);
12428 // if inside drawing area, activate and draw brush at last mouse position
12429 if (mx >= gi->x && mx < gi->x + gi->width &&
12430 my >= gi->y && my < gi->y + gi->height)
12431 CopyBrushToCursor(last_cursor_x, last_cursor_y);
12433 draw_with_brush = TRUE;
12439 sprintf(request, "Replace level with %dx%d level sketch from clipboard?",
12440 brush_width, brush_height);
12442 if (!Request(request, REQ_ASK))
12445 for (x = 0; x < MAX_LEV_FIELDX; x++)
12446 for (y = 0; y < MAX_LEV_FIELDY; y++)
12447 Tile[x][y] = brush_buffer[x][y];
12449 lev_fieldx = level.fieldx = brush_width;
12450 lev_fieldy = level.fieldy = brush_height;
12452 boolean use_em_engine = TRUE;
12453 boolean use_sp_engine = TRUE;
12454 boolean use_mm_engine = TRUE;
12456 for (x = 0; x < MAX_LEV_FIELDX; x++)
12458 for (y = 0; y < MAX_LEV_FIELDY; y++)
12460 int element = Tile[x][y];
12462 if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
12463 use_em_engine = FALSE;
12465 if (!IS_SP_ELEMENT(element))
12466 use_sp_engine = FALSE;
12468 if (!IS_MM_ELEMENT(element) && element != EL_EMPTY)
12469 use_mm_engine = FALSE;
12473 level.game_engine_type = (use_em_engine ? GAME_ENGINE_TYPE_EM :
12474 use_sp_engine ? GAME_ENGINE_TYPE_SP :
12475 use_mm_engine ? GAME_ENGINE_TYPE_MM :
12476 GAME_ENGINE_TYPE_RND);
12478 // update element selection list
12479 ReinitializeElementList();
12480 ModifyEditorElementList();
12482 SetBorderElement();
12484 DrawEditModeWindow();
12485 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12491 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
12494 if (mode == CB_AREA_TO_BRUSH)
12496 int from_lx, from_ly;
12499 swap_numbers(&from_x, &to_x);
12502 swap_numbers(&from_y, &to_y);
12504 brush_width = to_x - from_x + 1;
12505 brush_height = to_y - from_y + 1;
12507 from_lx = from_x + level_xpos;
12508 from_ly = from_y + level_ypos;
12510 for (y = 0; y < brush_height; y++)
12512 for (x = 0; x < brush_width; x++)
12514 brush_buffer[x][y] = Tile[from_lx + x][from_ly + y];
12517 DrawBrushElement(from_x + x, from_y + y, new_element, TRUE);
12522 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12524 delete_old_brush = FALSE;
12526 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
12527 mode == CB_BRUSH_TO_LEVEL)
12529 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
12530 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
12531 int cursor_from_x = cursor_x - brush_width / 2;
12532 int cursor_from_y = cursor_y - brush_height / 2;
12533 int border_from_x = cursor_x, border_from_y = cursor_y;
12534 int border_to_x = cursor_x, border_to_y = cursor_y;
12536 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
12537 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12539 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
12540 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
12542 delete_old_brush = FALSE;
12547 for (y = 0; y < brush_height; y++)
12549 for (x = 0; x < brush_width; x++)
12551 int sx = cursor_from_x + x;
12552 int sy = cursor_from_y + y;
12553 int lx = sx + level_xpos;
12554 int ly = sy + level_ypos;
12555 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
12556 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
12557 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
12558 brush_buffer[x][y] : new_element);
12560 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
12562 if (sx < border_from_x)
12563 border_from_x = sx;
12564 else if (sx > border_to_x)
12566 if (sy < border_from_y)
12567 border_from_y = sy;
12568 else if (sy > border_to_y)
12571 DrawBrushElement(sx, sy, element, change_level);
12576 if (mode != CB_DELETE_OLD_CURSOR)
12577 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
12579 last_cursor_x = cursor_x;
12580 last_cursor_y = cursor_y;
12582 delete_old_brush = TRUE;
12585 if (mode == CB_UPDATE_BRUSH_POSITION)
12587 last_cursor_x = from_x;
12588 last_cursor_y = from_y;
12592 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
12595 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
12598 static void CopyBrushToLevel(int x, int y, int button)
12600 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
12603 static void CopyBrushToCursor(int x, int y)
12605 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
12608 static void UpdateBrushPosition(int x, int y)
12610 CopyBrushExt(x, y, 0, 0, 0, CB_UPDATE_BRUSH_POSITION);
12613 static void DeleteBrushFromCursor(void)
12615 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
12618 void DumpBrush(void)
12620 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH);
12623 void DumpBrush_Small(void)
12625 CopyBrushExt(0, 0, 0, 0, 0, CB_DUMP_BRUSH_SMALL);
12628 void CopyClipboardToBrush(void)
12630 CopyBrushExt(0, 0, 0, 0, 0, CB_CLIPBOARD_TO_BRUSH);
12633 void CopyBrushToClipboard(void)
12635 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD);
12638 void CopyBrushToClipboard_Small(void)
12640 CopyBrushExt(0, 0, 0, 0, 0, CB_BRUSH_TO_CLIPBOARD_SMALL);
12643 void UndoLevelEditorOperation(void)
12645 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], -1);
12648 void RedoLevelEditorOperation(void)
12650 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
12653 static void FloodFill(int from_x, int from_y, int fill_element)
12655 FloodFillLevel(from_x, from_y, fill_element, Tile, lev_fieldx, lev_fieldy);
12658 static void FloodFillWall_MM(int from_sx2, int from_sy2, int fill_element)
12660 int from_x = from_sx2 + 2 * level_xpos;
12661 int from_y = from_sy2 + 2 * level_ypos;
12662 int max_fillx = lev_fieldx * 2;
12663 int max_filly = lev_fieldy * 2;
12664 short Fill[max_fillx][max_filly];
12667 for (x = 0; x < max_fillx; x++)
12668 for (y = 0; y < max_filly; y++)
12669 Fill[x][y] = getLevelElementHiRes(x, y);
12671 FloodFillLevelExt(from_x, from_y, fill_element, max_fillx, max_filly,
12672 Fill, max_fillx, max_filly);
12674 for (x = 0; x < max_fillx; x++)
12675 for (y = 0; y < max_filly; y++)
12676 if (Fill[x][y] == fill_element)
12677 SetLevelElementHiRes(x, y, Fill[x][y]);
12680 // values for DrawLevelText() modes
12681 #define TEXT_INIT 0
12682 #define TEXT_SETCURSOR 1
12683 #define TEXT_WRITECHAR 2
12684 #define TEXT_BACKSPACE 3
12685 #define TEXT_NEWLINE 4
12687 #define TEXT_QUERY_TYPING 6
12689 static int DrawLevelText(int sx, int sy, char letter, int mode)
12691 static short delete_buffer[MAX_LEV_FIELDX];
12692 static int start_sx;
12693 static int last_sx, last_sy;
12694 static boolean typing = FALSE;
12695 int letter_element;
12696 int lx = 0, ly = 0;
12698 // map lower case letters to upper case and convert special characters
12699 if (letter >= 'a' && letter <= 'z')
12700 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
12701 else if (letter == CHAR_BYTE_UMLAUT_a || letter == CHAR_BYTE_UMLAUT_A)
12702 letter_element = EL_CHAR_AUMLAUT;
12703 else if (letter == CHAR_BYTE_UMLAUT_o || letter == CHAR_BYTE_UMLAUT_O)
12704 letter_element = EL_CHAR_OUMLAUT;
12705 else if (letter == CHAR_BYTE_UMLAUT_u || letter == CHAR_BYTE_UMLAUT_U)
12706 letter_element = EL_CHAR_UUMLAUT;
12707 else if (letter == '^')
12708 letter_element = EL_CHAR_COPYRIGHT;
12710 letter_element = EL_CHAR_ASCII0 + letter;
12712 if (mode != TEXT_INIT)
12717 if (mode != TEXT_SETCURSOR)
12723 lx = last_sx + level_xpos;
12724 ly = last_sy + level_ypos;
12731 DrawLevelText(0, 0, 0, TEXT_END);
12737 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
12740 case TEXT_SETCURSOR:
12741 DrawEditorElement(last_sx, last_sy, Tile[lx][ly]);
12742 DrawAreaBorder(sx, sy, sx, sy);
12743 StartTextInput(SX + sx * ed_tilesize, SY + sy * ed_tilesize,
12744 ed_tilesize, ed_tilesize);
12749 case TEXT_WRITECHAR:
12750 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
12752 if (new_element1 >= EL_STEEL_CHAR_START &&
12753 new_element1 <= EL_STEEL_CHAR_END)
12754 letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
12756 delete_buffer[sx - start_sx] = Tile[lx][ly];
12757 Tile[lx][ly] = letter_element;
12759 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
12760 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
12761 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12762 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12764 DrawLevelText(0, 0, 0, TEXT_END);
12766 level.changed = TRUE;
12770 case TEXT_BACKSPACE:
12773 Tile[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
12774 DrawEditorElement(sx - 1, sy, Tile[lx - 1][ly]);
12775 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
12780 if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
12781 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
12783 DrawLevelText(0, 0, 0, TEXT_END);
12787 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12788 DrawEditorElement(sx, sy, Tile[lx][ly]);
12793 case TEXT_QUERY_TYPING:
12803 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
12804 int element, boolean change_level)
12806 int lx = sx + level_xpos;
12807 int ly = sy + level_ypos;
12810 DrawEditorElement(sx, sy, Tile[lx][ly]);
12812 DrawAreaBorder(sx, sy, sx, sy);
12815 static void CheckLevelBorderElement(boolean redraw_playfield)
12817 int last_border_element = BorderElement;
12819 SetBorderElement();
12821 if (redraw_playfield && BorderElement != last_border_element)
12822 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12825 static void CopyLevelToUndoBuffer(int mode)
12827 static boolean accumulated_undo = FALSE;
12828 boolean new_undo_buffer_position = TRUE;
12831 if (undo_buffer_steps == 0)
12832 accumulated_undo = FALSE;
12836 case UNDO_IMMEDIATE:
12837 accumulated_undo = FALSE;
12840 case UNDO_ACCUMULATE:
12841 if (accumulated_undo)
12842 new_undo_buffer_position = FALSE;
12843 accumulated_undo = TRUE;
12850 if (new_undo_buffer_position)
12852 // advance position in undo buffer ring
12853 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
12855 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
12856 undo_buffer_steps++;
12859 // always reset redo buffer when storing level change into undo buffer
12860 redo_buffer_steps = 0;
12862 for (x = 0; x < lev_fieldx; x++)
12863 for (y = 0; y < lev_fieldy; y++)
12864 UndoBuffer[undo_buffer_position][x][y] = Tile[x][y];
12866 // check if drawing operation forces change of border style
12867 CheckLevelBorderElement(TRUE);
12869 level.changed = TRUE;
12872 static void RandomPlacement(int new_element)
12874 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
12875 int num_free_positions = 0;
12876 int num_percentage, num_elements;
12879 ResetIntelliDraw();
12881 // determine number of free positions for randomly placing the new element
12882 for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++)
12884 free_position[x][y] =
12885 (random_placement_background_restricted ?
12886 Tile[x][y] == random_placement_background_element :
12887 Tile[x][y] != new_element);
12889 if (free_position[x][y])
12890 num_free_positions++;
12893 // determine number of new elements to place there
12894 num_percentage = num_free_positions * random_placement_value / 100;
12895 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
12896 num_percentage : random_placement_value);
12898 // if less free positions than elements to place, fill all these positions
12899 if (num_free_positions < num_elements)
12901 for (x = 0; x < lev_fieldx; x++)
12902 for (y = 0; y < lev_fieldy; y++)
12903 if (free_position[x][y])
12904 SetElement(x, y, new_element);
12908 while (num_elements > 0)
12910 x = GetSimpleRandom(lev_fieldx);
12911 y = GetSimpleRandom(lev_fieldy);
12913 // don't place element at the same position twice
12914 if (free_position[x][y])
12916 free_position[x][y] = FALSE;
12917 SetElement(x, y, new_element);
12923 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12924 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
12927 static void WrapLevel(int dx, int dy)
12929 int wrap_dx = lev_fieldx - dx;
12930 int wrap_dy = lev_fieldy - dy;
12933 for (x = 0; x < lev_fieldx; x++)
12934 for (y = 0; y < lev_fieldy; y++)
12935 TileBackup[x][y] = Tile[x][y];
12937 for (x = 0; x < lev_fieldx; x++)
12938 for (y = 0; y < lev_fieldy; y++)
12940 TileBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
12942 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12943 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
12946 static void DrawAreaElementHighlight(boolean highlighted)
12948 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
12955 for (x = 0; x < ed_fieldx; x++)
12957 for (y = 0; y < ed_fieldy; y++)
12959 int lx = x + level_xpos;
12960 int ly = y + level_ypos;
12962 if (!IN_LEV_FIELD(lx, ly))
12965 if (Tile[lx][ly] != new_element1)
12968 int sx = SX + x * ed_tilesize;
12969 int sy = SY + y * ed_tilesize;
12972 int to_sx = sx + ed_tilesize - 1;
12973 int to_sy = sy + ed_tilesize - 1;
12975 DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
12976 DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
12977 DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
12978 DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
12983 static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
12985 char *template_filename_old = getLocalLevelTemplateFilename();
12986 char *template_filename_new =
12987 getPath2(getUserLevelDir(levelset_subdir), LEVELTEMPLATE_FILENAME);
12989 if (copyFile(template_filename_old, template_filename_new) != 0)
12990 Request("Cannot copy level template!", REQ_CONFIRM);
12992 free(template_filename_new);
12995 static void HandleDrawingAreas(struct GadgetInfo *gi)
12997 static boolean started_inside_drawing_area = FALSE;
12998 int id = gi->custom_id;
12999 int type_id = gi->custom_type_id;
13000 boolean button_press_event;
13001 boolean button_release_event;
13002 boolean inside_drawing_area = !gi->event.off_borders;
13003 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
13004 int actual_drawing_function;
13005 int button = gi->event.button;
13006 int new_element = BUTTON_ELEMENT(button);
13007 int sx = gi->event.x, sy = gi->event.y;
13008 int min_sx = 0, min_sy = 0;
13009 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
13010 int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
13011 int mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
13012 int sx2 = gi->event.mx / mini_item_xsize;
13013 int sy2 = gi->event.my / mini_item_ysize;
13016 int lx = 0, ly = 0;
13019 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
13020 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
13022 // make sure to stay inside drawing area boundaries
13023 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
13024 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
13028 int min_lx = 0, min_ly = 0;
13029 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
13031 // get positions inside level field
13032 lx = sx + level_xpos;
13033 ly = sy + level_ypos;
13035 if (!IN_LEV_FIELD(lx, ly))
13036 inside_drawing_area = FALSE;
13038 // make sure to stay inside level field boundaries
13039 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
13040 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
13042 // correct drawing area positions accordingly
13043 sx = lx - level_xpos;
13044 sy = ly - level_ypos;
13047 // also correct MM wall-sized (double) drawing area positions accordingly
13048 if (sx2 / 2 < sx || sx2 / 2 > sx)
13050 dx = (sx2 / 2 < sx ? 0 : 1);
13053 if (sy2 / 2 < sy || sy2 / 2 > sy)
13055 dy = (sy2 / 2 < sy ? 0 : 1);
13059 if (!button_press_event && !button_release_event)
13061 static int last_sx = -1;
13062 static int last_sy = -1;
13063 static int last_sx2 = -1;
13064 static int last_sy2 = -1;
13065 int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
13066 boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
13067 isHiresTileElement(old_element) &&
13068 isHiresDrawElement(new_element));
13070 // prevent handling events for every pixel position when moving mouse
13071 if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
13072 (sx2 == last_sx2 && sy2 == last_sy2))
13081 if (button_press_event)
13082 started_inside_drawing_area = inside_drawing_area;
13084 if (!started_inside_drawing_area)
13087 if (!IS_VALID_BUTTON(button))
13090 // handle info callback for each invocation of action callback
13091 gi->callback_info(gi);
13093 // automatically switch to 'single item' drawing mode, if needed
13094 actual_drawing_function =
13095 (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
13096 drawing_function : GADGET_ID_SINGLE_ITEMS);
13098 // clicking into drawing area with pressed Control key picks element
13099 if (GetKeyModState() & KMOD_Control)
13101 last_drawing_function = drawing_function;
13102 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
13105 if (GetKeyModState() & KMOD_Shift)
13107 if (button_press_event || button_release_event)
13108 ResetIntelliDraw();
13111 SetDrawModeHiRes(-1); // reset to normal draw mode
13113 switch (actual_drawing_function)
13115 case GADGET_ID_SINGLE_ITEMS:
13118 if (button_release_event)
13120 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13122 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
13123 !inside_drawing_area)
13124 DeleteBrushFromCursor();
13129 if (draw_with_brush)
13131 CopyBrushToLevel(sx, sy, button);
13135 SetDrawModeHiRes(new_element);
13137 if (IS_PLAYER_ELEMENT(new_element))
13139 // remove player at old position
13140 for (y = 0; y < lev_fieldy; y++)
13142 for (x = 0; x < lev_fieldx; x++)
13144 int old_element = Tile[x][y];
13146 if (IS_PLAYER_ELEMENT(old_element))
13148 int replaced_with_element =
13149 (old_element == EL_SOKOBAN_FIELD_PLAYER &&
13150 new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY :
13152 old_element == EL_SOKOBAN_FIELD_PLAYER &&
13153 new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY :
13155 new_element == EL_SOKOBAN_FIELD_PLAYER &&
13156 old_element == EL_PLAYER_1 ? EL_EMPTY :
13158 new_element >= EL_PLAYER_1 &&
13159 new_element <= EL_PLAYER_4 &&
13160 new_element == old_element ? EL_EMPTY :
13164 SetElement(x, y, replaced_with_element);
13170 SetElementButton(lx, ly, dx, dy, new_element, button);
13173 else if (!button_release_event)
13175 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13177 if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
13178 DrawMiniGraphicExt(drawto,
13179 gi->x + sx * MINI_TILEX,
13180 gi->y + sy * MINI_TILEY,
13181 el2edimg(new_element));
13183 DrawFixedGraphicExt(drawto,
13184 gi->x + sx * TILEX,
13185 gi->y + sy * TILEY,
13186 el2edimg(new_element), 0);
13188 if (id == GADGET_ID_CUSTOM_GRAPHIC)
13189 new_element = GFX_ELEMENT(new_element);
13191 drawingarea_info[type_id].value[pos] = new_element;
13193 CopyElementPropertiesToGame(properties_element);
13195 if (id == GADGET_ID_CUSTOM_GRAPHIC)
13197 UpdateCustomElementGraphicGadgets();
13199 FrameCounter = 0; // restart animation frame counter
13204 case GADGET_ID_CONNECTED_ITEMS:
13206 static int last_sx = -1;
13207 static int last_sy = -1;
13209 if (button_release_event)
13210 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13212 SetDrawModeHiRes(new_element);
13214 if (getDrawModeHiRes())
13220 if (!button_press_event)
13221 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
13228 case GADGET_ID_LINE:
13229 case GADGET_ID_ARC:
13230 case GADGET_ID_RECTANGLE:
13231 case GADGET_ID_FILLED_BOX:
13232 SetDrawModeHiRes(new_element);
13234 if (getDrawModeHiRes())
13240 case GADGET_ID_GRAB_BRUSH:
13241 case GADGET_ID_TEXT:
13243 static int last_sx = -1;
13244 static int last_sy = -1;
13245 static int start_sx = -1;
13246 static int start_sy = -1;
13247 void (*draw_func)(int, int, int, int, int, boolean);
13249 if (drawing_function == GADGET_ID_LINE)
13250 draw_func = DrawLine;
13251 else if (drawing_function == GADGET_ID_ARC)
13252 draw_func = DrawArc;
13253 else if (drawing_function == GADGET_ID_RECTANGLE)
13254 draw_func = DrawBox;
13255 else if (drawing_function == GADGET_ID_FILLED_BOX)
13256 draw_func = DrawFilledBox;
13257 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
13258 draw_func = SelectArea;
13259 else // (drawing_function == GADGET_ID_TEXT)
13260 draw_func = SetTextCursor;
13262 if (button_press_event)
13264 draw_func(sx, sy, sx, sy, new_element, FALSE);
13265 start_sx = last_sx = sx;
13266 start_sy = last_sy = sy;
13268 if (drawing_function == GADGET_ID_TEXT)
13269 DrawLevelText(0, 0, 0, TEXT_END);
13271 else if (button_release_event)
13273 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
13274 if (drawing_function == GADGET_ID_GRAB_BRUSH)
13276 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
13277 CopyBrushToCursor(sx, sy);
13278 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
13280 draw_with_brush = TRUE;
13282 else if (drawing_function == GADGET_ID_TEXT)
13283 DrawLevelText(sx, sy, 0, TEXT_INIT);
13285 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13287 else if (last_sx != sx || last_sy != sy)
13289 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
13290 if (IS_MM_WALL_EDITOR(new_element)) // clear wall background
13291 draw_func(start_sx, start_sy, sx, sy, EL_EMPTY, FALSE);
13292 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
13299 case GADGET_ID_FLOOD_FILL:
13300 if (button_press_event && Tile[lx][ly] != new_element)
13302 if (IS_MM_WALL_EDITOR(new_element))
13303 FloodFillWall_MM(sx2, sy2, new_element);
13305 FloodFill(lx, ly, new_element);
13307 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13308 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
13312 case GADGET_ID_PICK_ELEMENT:
13313 if (button_release_event)
13314 ClickOnGadget(level_editor_gadget[last_drawing_function],
13316 else if (draw_level)
13317 PickDrawingElement(button, Tile[lx][ly]);
13320 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
13322 PickDrawingElement(button, drawingarea_info[type_id].value[pos]);
13329 // do not mark level as modified for certain non-level-changing gadgets
13330 if ((type_id >= ED_DRAWING_ID_EDITOR_FIRST &&
13331 type_id <= ED_DRAWING_ID_EDITOR_LAST) ||
13332 actual_drawing_function == GADGET_ID_GRAB_BRUSH ||
13333 actual_drawing_function == GADGET_ID_PICK_ELEMENT)
13336 level.changed = TRUE;
13339 static void HandleCounterButtons(struct GadgetInfo *gi)
13341 int gadget_id = gi->custom_id;
13342 int counter_id = gi->custom_type_id;
13343 int button = gi->event.button;
13344 int *counter_value = counterbutton_info[counter_id].value;
13345 int step = BUTTON_STEPSIZE(button) *
13346 (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
13348 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
13350 boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
13351 boolean released = (gi->event.type == GD_EVENT_RELEASED);
13352 boolean level_changed = LevelChanged();
13354 if ((level_changed && pressed) || (!level_changed && released))
13357 if (level_changed && !Request("Level has changed! Discard changes?",
13360 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
13361 ModifyEditorCounterValue(counter_id, *counter_value);
13367 if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
13368 *counter_value = gi->textinput.number_value;
13370 ModifyEditorCounterValue(counter_id, *counter_value + step);
13372 if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
13374 int last_game_engine_type = level.game_engine_type;
13376 LoadLevel(level_nr);
13377 LoadScore(level_nr);
13379 SaveLevelSetup_SeriesInfo();
13384 DrawEditModeWindow();
13386 if (level.game_engine_type != last_game_engine_type)
13388 // update element selection list
13389 ReinitializeElementList();
13390 ModifyEditorElementList();
13396 switch (counter_id)
13398 case ED_COUNTER_ID_YAMYAM_CONTENT:
13399 DrawYamYamContentAreas();
13402 case ED_COUNTER_ID_BALL_CONTENT:
13403 DrawMagicBallContentAreas();
13406 case ED_COUNTER_ID_ANDROID_CONTENT:
13407 DrawAndroidElementArea();
13410 case ED_COUNTER_ID_GROUP_CONTENT:
13411 DrawGroupElementArea();
13412 CopyGroupElementPropertiesToGame(properties_element);
13415 case ED_COUNTER_ID_INVENTORY_SIZE:
13416 DrawPlayerInitialInventoryArea(properties_element);
13419 case ED_COUNTER_ID_MM_BALL_CONTENT:
13420 DrawMMBallContentArea();
13423 case ED_COUNTER_ID_ENVELOPE_XSIZE:
13424 case ED_COUNTER_ID_ENVELOPE_YSIZE:
13425 DrawEnvelopeTextArea(-1);
13428 case ED_COUNTER_ID_LEVEL_XSIZE:
13429 case ED_COUNTER_ID_LEVEL_YSIZE:
13430 lev_fieldx = level.fieldx;
13431 lev_fieldy = level.fieldy;
13433 // check if resizing of level results in change of border border
13434 SetBorderElement();
13442 if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
13443 counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
13444 (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
13445 counter_id <= ED_COUNTER_ID_CHANGE_LAST))
13446 CopyElementPropertiesToGame(properties_element);
13448 // do not mark level as modified for certain non-level-changing gadgets
13449 if ((counter_id >= ED_COUNTER_ID_LEVELSET_FIRST &&
13450 counter_id <= ED_COUNTER_ID_LEVELSET_LAST) ||
13451 (counter_id >= ED_COUNTER_ID_EDITOR_FIRST &&
13452 counter_id <= ED_COUNTER_ID_EDITOR_LAST))
13455 level.changed = TRUE;
13458 static void HandleTextInputGadgets(struct GadgetInfo *gi)
13460 int type_id = gi->custom_type_id;
13462 strcpy(textinput_info[type_id].value, gi->textinput.value);
13464 if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
13466 CopyElementPropertiesToGame(properties_element);
13468 ModifyEditorElementList(); // update changed button info text
13471 // do not mark level as modified for certain non-level-changing gadgets
13472 if (type_id >= ED_TEXTINPUT_ID_LEVELSET_FIRST &&
13473 type_id <= ED_TEXTINPUT_ID_LEVELSET_LAST)
13476 level.changed = TRUE;
13479 static void HandleTextAreaGadgets(struct GadgetInfo *gi)
13481 int type_id = gi->custom_type_id;
13483 strncpy(textarea_info[type_id].value, gi->textarea.value,
13484 MAX_ENVELOPE_TEXT_LEN);
13485 textarea_info[type_id].value[MAX_ENVELOPE_TEXT_LEN] = '\0';
13487 level.changed = TRUE;
13490 static void HandleSelectboxGadgets(struct GadgetInfo *gi)
13492 int type_id = gi->custom_type_id;
13493 int value_old = *selectbox_info[type_id].value;
13494 int value_new = selectbox_info[type_id].options[gi->selectbox.index].value;
13496 *selectbox_info[type_id].value = value_new;
13498 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE)
13500 DrawLevelInfoWindow();
13502 else if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
13504 element_info[properties_element].current_change_page = gi->selectbox.index;
13506 DrawPropertiesWindow();
13508 else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
13509 type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
13510 (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
13511 type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
13512 (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
13514 if (type_id == ED_SELECTBOX_ID_ACTION_TYPE)
13516 // when changing action type, also check action mode and action arg
13517 if (value_old != value_new)
13518 setSelectboxSpecialActionVariablesIfNeeded();
13520 DrawPropertiesChange();
13523 CopyElementPropertiesToGame(properties_element);
13525 else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
13527 // update element selection list
13528 ReinitializeElementList();
13529 ModifyEditorElementList();
13532 // do not mark level as modified for certain non-level-changing gadgets
13533 if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
13534 type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
13537 level.changed = TRUE;
13540 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
13542 int type_id = gi->custom_type_id;
13545 if (type_id >= ED_TAB_BUTTON_ID_LEVELINFO_FIRST &&
13546 type_id <= ED_TAB_BUTTON_ID_LEVELINFO_LAST)
13548 edit_mode_levelinfo = gi->custom_type_id;
13550 DrawLevelInfoWindow();
13552 else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
13553 type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
13555 edit_mode_properties = gi->custom_type_id;
13557 DrawPropertiesWindow();
13559 else if (type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1 ||
13560 type_id == ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2)
13562 boolean new_template = !fileExists(getLocalLevelTemplateFilename());
13564 // backup original "level.field" (needed to track playfield changes)
13565 CopyPlayfield(level.field, TileBackup);
13567 // "SaveLevelTemplate()" uses "level.field", so copy editor playfield
13568 CopyPlayfield(Tile, level.field);
13570 if (new_template ||
13571 Request("Save this template and kill the old?", REQ_ASK))
13572 SaveLevelTemplate();
13575 Request("Template saved!", REQ_CONFIRM);
13577 // restore original "level.field" (needed to track playfield changes)
13578 CopyPlayfield(TileBackup, level.field);
13580 else if (type_id == ED_TEXTBUTTON_ID_SAVE_LEVELSET)
13582 char *levelset_subdir = getLevelSubdirFromSaveMode(levelset_save_mode);
13584 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE &&
13585 leveldir_current->readonly)
13587 Request("This level set is read-only!", REQ_CONFIRM);
13592 if (strEqual(levelset_name, ""))
13594 Request("Please enter level set title!", REQ_CONFIRM);
13599 if (strEqual(levelset_author, ""))
13601 Request("Please enter level set author!", REQ_CONFIRM);
13606 if (levelset_save_mode == LEVELSET_SAVE_MODE_UPDATE)
13608 if (UpdateUserLevelSet(levelset_subdir,
13611 levelset_num_levels))
13613 Request("Level set updated!", REQ_CONFIRM);
13617 Request("Updating level set failed!", REQ_CONFIRM);
13620 else if (levelset_save_mode == LEVELSET_SAVE_MODE_CREATE)
13622 if (level.changed && !Request("Level has changed! Discard changes?",
13626 if (CreateUserLevelSet(levelset_subdir,
13629 levelset_num_levels,
13630 levelset_use_levelset_artwork))
13632 if (levelset_copy_level_template)
13633 CopyLevelTemplateToUserLevelSet(levelset_subdir);
13635 Request("New level set created!", REQ_CONFIRM);
13637 AddUserLevelSetToLevelInfo(levelset_subdir);
13638 ChangeEditorToLevelSet(levelset_subdir);
13642 Request("Creating new level set failed!", REQ_CONFIRM);
13646 else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
13647 custom_element.num_change_pages < MAX_CHANGE_PAGES)
13649 struct ElementInfo *ei = &element_info[properties_element];
13651 // when modifying custom element, ask for copying level template
13652 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13655 setElementChangePages(ei, ei->num_change_pages + 1);
13657 // set new change page to be new current change page
13658 ei->current_change_page = ei->num_change_pages - 1;
13659 ei->change = &ei->change_page[ei->current_change_page];
13661 setElementChangeInfoToDefaults(ei->change);
13663 DrawPropertiesWindow();
13665 level.changed = TRUE;
13667 else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
13668 custom_element.num_change_pages > MIN_CHANGE_PAGES)
13670 struct ElementInfo *ei = &element_info[properties_element];
13672 // when modifying custom element, ask for copying level template
13673 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13676 // copy all change pages after change page to be deleted
13677 for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
13678 ei->change_page[i] = ei->change_page[i + 1];
13680 setElementChangePages(ei, ei->num_change_pages - 1);
13682 DrawPropertiesWindow();
13684 level.changed = TRUE;
13688 static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
13690 int type_id = gi->custom_type_id;
13692 if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ||
13693 type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
13695 struct ElementInfo *ei = &element_info[properties_element];
13696 int step = BUTTON_STEPSIZE(gi->event.button);
13698 step *= (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE ? -1 : +1);
13699 ei->current_change_page += step;
13701 if (ei->current_change_page < 0)
13702 ei->current_change_page = 0;
13703 else if (ei->current_change_page >= ei->num_change_pages)
13704 ei->current_change_page = ei->num_change_pages - 1;
13706 DrawPropertiesWindow();
13708 else if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE ||
13709 type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13711 struct ElementInfo *ei = &element_info[properties_element];
13712 int current_change_page = ei->current_change_page;
13714 if (type_id == ED_GRAPHICBUTTON_ID_COPY_CHANGE_PAGE)
13716 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
13717 ei->change_page[current_change_page];
13719 else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
13721 // when modifying custom element, ask for copying level template
13722 if (level.use_custom_template && !AskToCopyAndModifyLevelTemplate())
13725 ei->change_page[current_change_page] =
13726 element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
13728 level.changed = TRUE;
13731 DrawPropertiesWindow();
13735 static void HandleRadiobuttons(struct GadgetInfo *gi)
13737 int type_id = gi->custom_type_id;
13739 *radiobutton_info[type_id].value =
13740 radiobutton_info[type_id].checked_value;
13742 // do not mark level as modified for certain non-level-changing gadgets
13743 if (type_id >= ED_RADIOBUTTON_ID_EDITOR_FIRST &&
13744 type_id <= ED_RADIOBUTTON_ID_EDITOR_LAST)
13747 level.changed = TRUE;
13750 static void HandleCheckbuttons(struct GadgetInfo *gi)
13752 int type_id = gi->custom_type_id;
13754 *checkbutton_info[type_id].value ^= TRUE;
13756 if (type_id == ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID ||
13757 type_id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID ||
13758 type_id == ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH ||
13759 (((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
13760 type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
13761 (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
13762 type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST)) &&
13763 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1))
13765 CopyElementPropertiesToGame(properties_element);
13768 if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
13770 UpdateCustomElementGraphicGadgets();
13772 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 ||
13773 type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2)
13775 boolean template_related_changes_found = FALSE;
13778 // check if any custom, group or empty elements have been changed
13779 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
13780 if ((IS_CUSTOM_ELEMENT(i) ||
13781 IS_GROUP_ELEMENT(i) ||
13782 IS_EMPTY_ELEMENT(i)) &&
13783 element_info[i].modified_settings)
13784 template_related_changes_found = TRUE;
13786 if (level.use_custom_template &&
13787 !fileExists(getGlobalLevelTemplateFilename()))
13789 Request("No level template found!", REQ_CONFIRM);
13791 level.use_custom_template = FALSE;
13793 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13798 if (level.use_custom_template &&
13799 template_related_changes_found &&
13800 !Request("Discard changes and use level template?", REQ_ASK))
13802 level.use_custom_template = FALSE;
13804 ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
13809 if (!level.use_custom_template &&
13810 Request("Copy settings from level template?", REQ_ASK))
13815 LoadLevelTemplate(level.use_custom_template ? -1 : level_nr);
13817 DrawEditModeWindow();
13819 else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3)
13821 if (setup.editor.use_template_for_new_levels &&
13822 !fileExists(getGlobalLevelTemplateFilename()))
13824 Request("No level template found!", REQ_CONFIRM);
13829 if (setup.editor.use_template_for_new_levels &&
13831 !Request("Discard level and load template?", REQ_ASK))
13836 if (!setup.editor.use_template_for_new_levels &&
13838 !Request("Discard level and use empty level?", REQ_ASK))
13843 LoadLevel(level_nr);
13844 LoadScore(level_nr);
13849 DrawEditModeWindow();
13851 else if (type_id == ED_CHECKBUTTON_ID_AUTO_COUNT_GEMS)
13853 SetAutomaticNumberOfGemsNeeded();
13856 // do not mark level as modified for certain non-level-changing gadgets
13857 if ((type_id >= ED_CHECKBUTTON_ID_LEVELSET_FIRST &&
13858 type_id <= ED_CHECKBUTTON_ID_LEVELSET_LAST) ||
13859 (type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST &&
13860 type_id <= ED_CHECKBUTTON_ID_EDITOR_LAST &&
13861 type_id != ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2) ||
13862 type_id == ED_CHECKBUTTON_ID_STICK_ELEMENT)
13865 level.changed = TRUE;
13868 static void HandleControlButtons(struct GadgetInfo *gi)
13870 static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;
13871 static int last_edit_mode = ED_MODE_DRAWING;
13872 static int last_custom_copy_mode = -1;
13873 static int last_button = 0;
13874 int id = gi->custom_id;
13875 int button = gi->event.button;
13876 int step = BUTTON_STEPSIZE(button);
13877 int new_element = BUTTON_ELEMENT(button);
13878 int last_properties_element = properties_element;
13881 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
13882 DrawLevelText(0, 0, 0, TEXT_END);
13884 if (id < ED_NUM_CTRL1_BUTTONS &&
13885 id != GADGET_ID_SINGLE_ITEMS &&
13886 id != GADGET_ID_PICK_ELEMENT &&
13887 edit_mode != ED_MODE_DRAWING &&
13888 drawing_function != GADGET_ID_PICK_ELEMENT &&
13889 !(GetKeyModState() & KMOD_Control))
13890 ChangeEditModeWindow(ED_MODE_DRAWING);
13892 // element copy mode active, but no element button pressed => deactivate
13893 if (last_custom_copy_mode != -1 && id < ED_NUM_CTRL_BUTTONS)
13894 last_custom_copy_mode = -1;
13896 // when showing palette on element buttons, change element of button used
13897 if (editor.palette.show_on_element_buttons &&
13898 id >= GADGET_ID_ELEMENT_LEFT && id <= GADGET_ID_ELEMENT_RIGHT)
13900 last_button = id - GADGET_ID_ELEMENT_LEFT + 1;
13902 id = GADGET_ID_PALETTE;
13907 case GADGET_ID_SCROLL_LEFT:
13908 if (level_xpos >= 0)
13910 if (lev_fieldx < ed_fieldx - 2)
13913 level_xpos -= step;
13914 if (level_xpos < -1)
13917 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
13919 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13921 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
13922 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
13926 case GADGET_ID_SCROLL_RIGHT:
13927 if (level_xpos <= lev_fieldx - ed_fieldx)
13929 if (lev_fieldx < ed_fieldx - 2)
13932 level_xpos += step;
13933 if (level_xpos > lev_fieldx - ed_fieldx + 1)
13934 level_xpos = lev_fieldx - ed_fieldx + 1;
13936 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
13938 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13940 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
13941 GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
13945 case GADGET_ID_SCROLL_UP:
13946 if (level_ypos >= 0)
13948 if (lev_fieldy < ed_fieldy - 2)
13951 level_ypos -= step;
13952 if (level_ypos < -1)
13955 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
13957 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13959 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13960 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13964 case GADGET_ID_SCROLL_DOWN:
13965 if (level_ypos <= lev_fieldy - ed_fieldy)
13967 if (lev_fieldy < ed_fieldy - 2)
13970 level_ypos += step;
13971 if (level_ypos > lev_fieldy - ed_fieldy + 1)
13972 level_ypos = lev_fieldy - ed_fieldy + 1;
13974 ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
13976 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13978 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
13979 GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
13983 case GADGET_ID_SCROLL_HORIZONTAL:
13984 level_xpos = gi->event.item_position - 1;
13986 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13991 case GADGET_ID_SCROLL_VERTICAL:
13992 level_ypos = gi->event.item_position - 1;
13994 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
13999 case GADGET_ID_SCROLL_LIST_UP:
14000 case GADGET_ID_SCROLL_LIST_DOWN:
14001 case GADGET_ID_SCROLL_LIST_VERTICAL:
14002 if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
14003 element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
14006 step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
14007 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
14009 if (element_shift < 0)
14011 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14012 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14014 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14015 GDI_SCROLLBAR_ITEM_POSITION,
14016 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14019 ModifyEditorElementList();
14023 case GADGET_ID_PROPERTIES:
14024 // always switch off element properties when they are already displayed
14025 last_properties_element = new_element;
14026 case GADGET_ID_ELEMENT_LEFT:
14027 case GADGET_ID_ELEMENT_MIDDLE:
14028 case GADGET_ID_ELEMENT_RIGHT:
14029 properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 :
14030 id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 :
14031 id == GADGET_ID_ELEMENT_RIGHT ? new_element3 :
14034 if (edit_mode != ED_MODE_PROPERTIES)
14036 last_edit_mode = edit_mode;
14038 ChangeEditModeWindow(ED_MODE_PROPERTIES);
14040 last_level_drawing_function = drawing_function;
14041 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
14044 else if (properties_element != last_properties_element)
14046 DrawEditModeWindow();
14050 ChangeEditModeWindow(ED_MODE_DRAWING);
14052 ClickOnGadget(level_editor_gadget[last_level_drawing_function],
14057 case GADGET_ID_PALETTE:
14058 if (edit_mode != ED_MODE_PALETTE)
14060 last_edit_mode = edit_mode;
14062 ChangeEditModeWindow(ED_MODE_PALETTE);
14066 ChangeEditModeWindow(last_edit_mode);
14070 case GADGET_ID_WRAP_LEFT:
14071 WrapLevel(-step, 0);
14074 case GADGET_ID_WRAP_RIGHT:
14075 WrapLevel(step, 0);
14078 case GADGET_ID_WRAP_UP:
14079 WrapLevel(0, -step);
14082 case GADGET_ID_WRAP_DOWN:
14083 WrapLevel(0, step);
14086 case GADGET_ID_SINGLE_ITEMS:
14087 case GADGET_ID_CONNECTED_ITEMS:
14088 case GADGET_ID_LINE:
14089 case GADGET_ID_ARC:
14090 case GADGET_ID_TEXT:
14091 case GADGET_ID_RECTANGLE:
14092 case GADGET_ID_FILLED_BOX:
14093 case GADGET_ID_FLOOD_FILL:
14094 case GADGET_ID_GRAB_BRUSH:
14095 case GADGET_ID_PICK_ELEMENT:
14096 if (drawing_function != GADGET_ID_PICK_ELEMENT)
14097 last_drawing_function = drawing_function;
14098 drawing_function = id;
14099 draw_with_brush = FALSE;
14102 case GADGET_ID_RANDOM_PLACEMENT:
14103 RandomPlacement(new_element);
14106 case GADGET_ID_ZOOM:
14107 // zoom level editor tile size in or out (or reset to default size)
14108 ed_tilesize = (button == 1 ? ed_tilesize * 2 :
14109 button == 2 ? ed_tilesize_default :
14110 button == 3 ? ed_tilesize / 2 : ed_tilesize);
14112 // when using touch device, cycle through all zoom tilesizes
14113 if (runtime.uses_touch_device && ed_tilesize > TILESIZE)
14114 ed_tilesize = MICRO_TILESIZE;
14116 // limit zoom level by upper and lower bound
14117 ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
14119 InitZoomLevelSettings(ed_tilesize);
14121 if (edit_mode == ED_MODE_DRAWING)
14123 DrawDrawingWindow();
14125 // redraw zoom gadget info text
14126 PrintEditorGadgetInfoText(level_editor_gadget[id]);
14129 // save current editor zoom tilesize
14130 SaveSetup_AutoSetup();
14134 case GADGET_ID_CUSTOM_COPY_FROM:
14135 case GADGET_ID_CUSTOM_COPY_TO:
14136 case GADGET_ID_CUSTOM_EXCHANGE:
14137 last_custom_copy_mode = id;
14138 last_drawing_function = drawing_function;
14141 case GADGET_ID_CUSTOM_COPY:
14142 CopyCustomElement(properties_element, -1, id);
14145 case GADGET_ID_CUSTOM_PASTE:
14146 CopyCustomElement(-1, properties_element, id);
14149 case GADGET_ID_UNDO:
14150 if (button < 0) // keep button value (even if modifier keys are pressed)
14152 else if (button == 1 && GetKeyModState() & (KMOD_Shift | KMOD_Control))
14155 if (button == 1 && undo_buffer_steps == 0)
14157 Request("Undo buffer empty!", REQ_CONFIRM);
14161 else if (button == 2)
14165 else if (button == 3 && redo_buffer_steps == 0)
14167 Request("Redo buffer empty!", REQ_CONFIRM);
14172 if (edit_mode != ED_MODE_DRAWING)
14173 ChangeEditModeWindow(ED_MODE_DRAWING);
14179 undo_buffer_position =
14180 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
14182 undo_buffer_steps--;
14183 redo_buffer_steps++;
14189 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
14191 undo_buffer_steps++;
14192 redo_buffer_steps--;
14195 for (x = 0; x < lev_fieldx; x++)
14196 for (y = 0; y < lev_fieldy; y++)
14197 Tile[x][y] = UndoBuffer[undo_buffer_position][x][y];
14199 // check if undo operation forces change of border style
14200 CheckLevelBorderElement(FALSE);
14202 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14206 case GADGET_ID_INFO:
14207 if (edit_mode != ED_MODE_INFO)
14209 last_edit_mode = edit_mode;
14211 ChangeEditModeWindow(ED_MODE_INFO);
14215 ChangeEditModeWindow(ED_MODE_DRAWING);
14219 case GADGET_ID_CLEAR:
14220 if (edit_mode != ED_MODE_DRAWING)
14221 ChangeEditModeWindow(ED_MODE_DRAWING);
14223 for (x = 0; x < MAX_LEV_FIELDX; x++)
14224 for (y = 0; y < MAX_LEV_FIELDY; y++)
14225 Tile[x][y] = (button == 1 ? EL_EMPTY : new_element);
14227 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
14229 DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
14232 case GADGET_ID_SAVE:
14234 // saving read-only levels into personal level set modifies global vars
14235 // "leveldir_current" and "level_nr"; restore them after saving level
14236 LevelDirTree *leveldir_former = leveldir_current;
14237 int level_nr_former = level_nr;
14238 char *level_filename;
14241 if (leveldir_current->readonly &&
14242 !PrepareSavingIntoPersonalLevelSet())
14245 level_filename = getDefaultLevelFilename(level_nr);
14246 new_level = !fileExists(level_filename);
14249 Request("Save this level and kill the old?", REQ_ASK))
14251 if (leveldir_former->readonly)
14252 ModifyLevelInfoForSavingIntoPersonalLevelSet(leveldir_former->name);
14254 SetAutomaticNumberOfGemsNeeded();
14256 CopyPlayfield(Tile, level.field);
14257 SaveLevel(level_nr);
14259 level.changed = FALSE;
14263 char level_saved_msg[64];
14265 if (leveldir_former->readonly)
14266 sprintf(level_saved_msg,
14267 "Level saved as level %d into personal level set!",
14270 strcpy(level_saved_msg, "Level saved!");
14272 Request(level_saved_msg, REQ_CONFIRM);
14276 // "cd" back to copied-from levelset (in case of saved read-only level)
14277 leveldir_current = leveldir_former;
14278 level_nr = level_nr_former;
14283 case GADGET_ID_TEST:
14284 if (LevelChanged())
14285 level.game_version = GAME_VERSION_ACTUAL;
14287 CopyPlayfield(level.field, TileBackup);
14288 CopyPlayfield(Tile, level.field);
14290 CopyNativeLevel_RND_to_Native(&level);
14292 UnmapLevelEditorGadgets();
14293 UndrawSpecialEditorDoor();
14295 CloseDoor(DOOR_CLOSE_ALL);
14297 // needed before playing if editor playfield area has different size
14298 ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
14300 // redraw_mask = REDRAW_ALL;
14302 level_editor_test_game = TRUE;
14304 StartGameActions(FALSE, setup.autorecord, level.random_seed);
14308 case GADGET_ID_EXIT:
14309 RequestExitLevelEditor(TRUE, FALSE); // if level has changed, ask user
14313 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
14314 id <= GADGET_ID_ELEMENTLIST_LAST)
14316 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
14318 new_element = editor_elements[element_position + element_shift];
14320 if (IS_EDITOR_CASCADE(new_element))
14324 for (i = 0; editor_elements_info[i].setup_value != NULL; i++)
14326 int *cascade_element= &(*editor_elements_info[i].headline_list)[0];
14327 boolean *cascade_value=editor_elements_info[i].setup_cascade_value;
14329 if (*cascade_element == new_element)
14331 *cascade_element = EL_CASCADE_TOGGLE(*cascade_element);
14332 *cascade_value = IS_EDITOR_CASCADE_ACTIVE(*cascade_element);
14334 // update element selection list
14335 ReinitializeElementList();
14336 ModifyEditorElementList();
14338 // update cascading gadget info text
14339 PrintEditorGadgetInfoText(level_editor_gadget[id]);
14341 // save current editor cascading state
14342 SaveSetup_EditorCascade();
14351 if (last_custom_copy_mode != -1)
14353 if (CopyCustomElement(properties_element, new_element,
14354 last_custom_copy_mode))
14356 ClickOnGadget(level_editor_gadget[last_drawing_function],
14359 last_custom_copy_mode = -1;
14365 // change element of button used to show palette
14366 if (editor.palette.show_on_element_buttons)
14367 button = last_button;
14369 PickDrawingElement(button, new_element);
14371 if (!stick_element_properties_window &&
14372 drawing_function != GADGET_ID_PICK_ELEMENT &&
14373 !(GetKeyModState() & KMOD_Control))
14375 properties_element = new_element;
14376 if (edit_mode == ED_MODE_PROPERTIES)
14377 DrawPropertiesWindow();
14380 if (drawing_function == GADGET_ID_PICK_ELEMENT)
14381 ClickOnGadget(level_editor_gadget[last_drawing_function],
14384 if (!use_permanent_palette)
14385 ChangeEditModeWindow(last_edit_mode);
14388 else if (gi->event.type == GD_EVENT_PRESSED)
14389 Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id);
14390 else if (gi->event.type == GD_EVENT_RELEASED)
14391 Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id);
14392 else if (gi->event.type == GD_EVENT_MOVING)
14393 Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id);
14395 Debug("editor", "default: HandleControlButtons: ? (id == %d)", id);
14401 void HandleLevelEditorKeyInput(Key key)
14403 char letter = getCharFromKey(key);
14405 if (drawing_function == GADGET_ID_TEXT &&
14406 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
14409 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
14410 else if (key == KSYM_Delete || key == KSYM_BackSpace)
14411 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
14412 else if (key == KSYM_Return)
14413 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
14414 else if (key == KSYM_Escape)
14415 DrawLevelText(0, 0, 0, TEXT_END);
14420 int id = GADGET_ID_NONE;
14421 int new_element_shift = element_shift;
14422 int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
14423 int button = MB_LEFTBUTTON;
14429 id = GADGET_ID_SCROLL_LEFT;
14432 id = GADGET_ID_SCROLL_RIGHT;
14435 id = GADGET_ID_SCROLL_UP;
14438 id = GADGET_ID_SCROLL_DOWN;
14442 case KSYM_Page_Down:
14443 step *= (key == KSYM_Page_Up ? -1 : +1);
14444 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
14446 if (element_shift < 0)
14448 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14449 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14451 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14452 GDI_SCROLLBAR_ITEM_POSITION,
14453 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14455 ModifyEditorElementList();
14461 element_shift = (key == KSYM_Home ? 0 :
14462 num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS);
14464 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14465 GDI_SCROLLBAR_ITEM_POSITION,
14466 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14468 ModifyEditorElementList();
14475 // this is needed to prevent interference with running "True X-Mouse"
14476 if (GetKeyModStateFromEvents() & KMOD_Control)
14479 // check for last or next editor cascade block in element list
14480 for (i = 0; i < num_editor_elements; i++)
14482 if ((key == KSYM_Insert && i == element_shift) ||
14483 (key == KSYM_Delete && new_element_shift > element_shift))
14486 // jump to next cascade block (or to start of element list)
14487 if (i == 0 || IS_EDITOR_CASCADE(editor_elements[i]))
14488 new_element_shift = i;
14491 if (i < num_editor_elements)
14492 element_shift = new_element_shift;
14494 if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
14495 element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
14497 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
14498 GDI_SCROLLBAR_ITEM_POSITION,
14499 element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
14501 ModifyEditorElementList();
14506 if (edit_mode == ED_MODE_DRAWING)
14507 RequestExitLevelEditor(setup.ask_on_escape_editor, TRUE);
14508 else if (edit_mode == ED_MODE_INFO)
14509 HandleControlButtons(level_editor_gadget[GADGET_ID_INFO]);
14510 else if (edit_mode == ED_MODE_PROPERTIES)
14511 HandleControlButtons(level_editor_gadget[GADGET_ID_PROPERTIES]);
14512 else if (edit_mode == ED_MODE_PALETTE)
14513 HandleControlButtons(level_editor_gadget[GADGET_ID_PALETTE]);
14514 else // should never happen
14515 ChangeEditModeWindow(ED_MODE_DRAWING);
14523 if (id != GADGET_ID_NONE)
14524 ClickOnGadget(level_editor_gadget[id], button);
14525 else if (letter == '1' || letter == '?')
14526 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_LEFT], button);
14527 else if (letter == '2')
14528 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_MIDDLE], button);
14529 else if (letter == '3')
14530 ClickOnGadget(level_editor_gadget[GADGET_ID_ELEMENT_RIGHT], button);
14531 else if (letter == '.')
14532 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
14533 else if (letter == 'U')
14534 ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
14535 else if (letter == '-' || key == KSYM_KP_Subtract)
14536 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
14537 else if (letter == '0' || key == KSYM_KP_0)
14538 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
14539 else if (letter == '+' || key == KSYM_KP_Add ||
14540 letter == '=') // ("Shift-=" is "+" on US keyboards)
14541 ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
14542 else if (key == KSYM_Return ||
14543 key == KSYM_space ||
14544 key == setup.shortcut.toggle_pause)
14545 ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
14547 for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)
14548 if (letter && letter == controlbutton_info[i].shortcut)
14549 if (!anyTextGadgetActive())
14550 ClickOnGadget(level_editor_gadget[i], button);
14553 static void HandleLevelEditorIdle_Properties(void)
14555 int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
14556 int x = editor.settings.element_graphic.x + element_border;
14557 int y = editor.settings.element_graphic.y + element_border;
14558 static DelayCounter action_delay = { 0 };
14561 action_delay.value = GameFrameDelay;
14563 if (!DelayReached(&action_delay))
14566 for (i = 0; i < ED_NUM_SELECTBOX; i++)
14568 struct GadgetInfo *gi = level_editor_gadget[selectbox_info[i].gadget_id];
14570 if (gi->mapped && gi->active && gi->selectbox.open)
14574 DrawEditorElementAnimation(SX + x, SY + y);
14576 redraw_mask |= REDRAW_FIELD;
14578 FrameCounter++; // increase animation frame counter
14581 static void HandleLevelEditorIdle_Drawing(void)
14583 static boolean last_highlighted = FALSE;
14584 boolean highlighted = (GetKeyModState() & KMOD_Alt);
14586 if (highlighted != last_highlighted)
14588 DrawAreaElementHighlight(highlighted);
14590 last_highlighted = highlighted;
14592 redraw_mask |= REDRAW_FIELD;
14596 void HandleLevelEditorIdle(void)
14598 if (edit_mode == ED_MODE_PROPERTIES)
14599 HandleLevelEditorIdle_Properties();
14600 else if (edit_mode == ED_MODE_DRAWING)
14601 HandleLevelEditorIdle_Drawing();
14604 static void ClearEditorGadgetInfoText(void)
14606 DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
14609 void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
14611 char infotext[MAX_OUTPUT_LINESIZE + 1];
14612 int max_infotext_len = getMaxInfoTextLength();
14614 if (gi == NULL || strlen(gi->info_text) == 0)
14617 strncpy(infotext, gi->info_text, max_infotext_len);
14618 infotext[max_infotext_len] = '\0';
14620 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
14622 int key = controlbutton_info[gi->custom_id].shortcut;
14626 char shortcut[MAX_OUTPUT_LINESIZE + 1];
14628 if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
14629 sprintf(shortcut, " ('.' or '%c')", key);
14630 else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
14631 sprintf(shortcut, " ('%c' or 'Ctrl')", key);
14632 else if (gi->custom_id == GADGET_ID_TEST)
14633 sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
14634 else if (gi->custom_id == GADGET_ID_UNDO)
14635 sprintf(shortcut, " ('%c/Shift-U')", key);
14636 else if (gi->custom_id == GADGET_ID_ZOOM)
14637 sprintf(shortcut, " ('%c', '0', '-')", key);
14639 sprintf(shortcut, " ('%s%c')",
14640 (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
14642 if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
14643 strcat(infotext, shortcut);
14647 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, INFOTEXT_FONT);
14650 void HandleEditorGadgetInfoText(void *ptr)
14652 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
14654 if (game_status != GAME_MODE_EDITOR)
14657 ClearEditorGadgetInfoText();
14659 if (gi == NULL || gi->event.type == GD_EVENT_INFO_LEAVING)
14662 // misuse this function to delete brush cursor, if needed
14663 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
14664 DeleteBrushFromCursor();
14666 PrintEditorGadgetInfoText(gi);
14669 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
14671 int id = gi->custom_id;
14672 int type_id = gi->custom_type_id;
14673 int sx = gi->event.x;
14674 int sy = gi->event.y;
14675 int lx = sx + level_xpos;
14676 int ly = sy + level_ypos;
14677 int min_sx = 0, min_sy = 0;
14678 int max_sx = gi->drawing.area_xsize - 1;
14679 int max_sy = gi->drawing.area_ysize - 1;
14680 int actual_drawing_function = drawing_function;
14681 int max_infotext_len = getMaxInfoTextLength();
14682 char infotext[MAX_OUTPUT_LINESIZE + 1];
14684 infotext[0] = '\0'; // start with empty info text
14686 // pressed Control key: simulate picking element
14687 if (GetKeyModState() & KMOD_Control)
14688 actual_drawing_function = GADGET_ID_PICK_ELEMENT;
14690 ClearEditorGadgetInfoText();
14692 if (gi->event.type == GD_EVENT_INFO_LEAVING)
14695 // make sure to stay inside drawing area boundaries
14696 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
14697 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
14699 if (id == GADGET_ID_DRAWING_LEVEL)
14703 int min_lx = 0, min_ly = 0;
14704 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
14706 // get positions inside level field
14707 lx = sx + level_xpos;
14708 ly = sy + level_ypos;
14710 // make sure to stay inside level field boundaries
14711 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
14712 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
14714 // correct drawing area positions accordingly
14715 sx = lx - level_xpos;
14716 sy = ly - level_ypos;
14719 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
14721 if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
14723 static int start_lx = 0;
14724 static int start_ly = 0;
14727 if (gi->event.type == GD_EVENT_PRESSED)
14733 switch (actual_drawing_function)
14735 case GADGET_ID_SINGLE_ITEMS:
14736 text = "Drawing single items";
14738 case GADGET_ID_CONNECTED_ITEMS:
14739 text = "Drawing connected items";
14741 case GADGET_ID_LINE:
14742 text = "Drawing line";
14744 case GADGET_ID_ARC:
14745 text = "Drawing arc";
14747 case GADGET_ID_TEXT:
14748 text = "Setting text cursor";
14750 case GADGET_ID_RECTANGLE:
14751 text = "Drawing rectangle";
14753 case GADGET_ID_FILLED_BOX:
14754 text = "Drawing filled box";
14756 case GADGET_ID_FLOOD_FILL:
14757 text = "Flood fill";
14759 case GADGET_ID_GRAB_BRUSH:
14760 text = "Grabbing brush";
14762 case GADGET_ID_PICK_ELEMENT:
14763 text = "Picking element";
14767 text = "Drawing position";
14771 if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14772 sprintf(infotext, "%s: %d, %d", text, lx, ly);
14774 sprintf(infotext, "%s: %d, %d", text,
14775 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
14777 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14778 strncpy(infotext, getElementInfoText(Tile[lx][ly]), max_infotext_len);
14780 sprintf(infotext, "Level position: %d, %d", lx, ly);
14783 // misuse this function to draw brush cursor, if needed
14784 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
14786 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
14787 CopyBrushToCursor(sx, sy);
14789 DeleteBrushFromCursor();
14792 if (!draw_with_brush)
14793 UpdateBrushPosition(sx, sy);
14795 else if (actual_drawing_function == GADGET_ID_PICK_ELEMENT)
14797 int pos = sx * drawingarea_info[type_id].area_ysize + sy;
14798 int element = drawingarea_info[type_id].value[pos];
14800 strncpy(infotext, getElementInfoText(element), max_infotext_len);
14804 if (id == GADGET_ID_CUSTOM_CONTENT)
14805 sprintf(infotext, "custom element content position: %d, %d", sx, sy);
14806 else if (id == GADGET_ID_GROUP_CONTENT)
14807 sprintf(infotext, "group element position: %d", sx + 1);
14808 else if (id >= GADGET_ID_YAMYAM_CONTENT_0 &&
14809 id <= GADGET_ID_YAMYAM_CONTENT_7)
14810 sprintf(infotext, "content area %d position: %d, %d",
14811 id - GADGET_ID_YAMYAM_CONTENT_0 + 1, sx, sy);
14812 else if (id >= GADGET_ID_MAGIC_BALL_CONTENT_0 &&
14813 id <= GADGET_ID_MAGIC_BALL_CONTENT_7)
14814 sprintf(infotext, "content area %d position: %d, %d",
14815 id - GADGET_ID_MAGIC_BALL_CONTENT_0 + 1, sx, sy);
14816 else if (id == GADGET_ID_ANDROID_CONTENT)
14817 sprintf(infotext, "android element position: %d", sx + 1);
14818 else if (drawingarea_info[type_id].infotext != NULL)
14819 strcpy(infotext, drawingarea_info[type_id].infotext);
14822 infotext[max_infotext_len] = '\0';
14824 if (strlen(infotext) > 0)
14825 DrawTextS(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, INFOTEXT_FONT, infotext);
14828 void RequestExitLevelEditor(boolean ask_if_level_has_changed,
14829 boolean quick_quit)
14831 if (!ask_if_level_has_changed ||
14833 Request("Level has changed! Exit without saving?",
14834 REQ_ASK | REQ_STAY_OPEN))
14836 struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN];
14837 struct RectWithBorder *vp_door_2 = &viewport.door_2[GAME_MODE_MAIN];
14839 // draw normal door
14840 UndrawSpecialEditorDoor();
14842 // use door animation if door 1 viewport is unchanged and contains toolbox
14843 if (useEditorDoorAnimation())
14844 CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM);
14846 // close editor doors if viewport definition is the same as in main menu
14847 if (vp_door_1->x == DX &&
14848 vp_door_1->y == DY &&
14849 vp_door_1->width == DXSIZE &&
14850 vp_door_1->height == DYSIZE &&
14851 vp_door_2->x == VX &&
14852 vp_door_2->y == VY &&
14853 vp_door_2->width == VXSIZE &&
14854 vp_door_2->height == VYSIZE)
14855 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
14857 SetDoorState(DOOR_CLOSE_2);
14862 FadeSkipNextFadeIn();
14864 SetGameStatus(GAME_MODE_MAIN);
14870 if (!global.use_envelope_request)
14872 CloseDoor(DOOR_CLOSE_1);
14873 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);