1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-98 Artsoft Entertainment *
8 * phone: ++49 +521 290471 *
9 * email: aeglos@valinor.owl.de *
10 *----------------------------------------------------------*
12 ***********************************************************/
25 /* positions in the level editor */
26 #define ED_WIN_MB_LEFT_XPOS 7
27 #define ED_WIN_MB_LEFT_YPOS 6
28 #define ED_WIN_LEVELNR_XPOS 77
29 #define ED_WIN_LEVELNR_YPOS 7
30 #define ED_WIN_MB_MIDDLE_XPOS 7
31 #define ED_WIN_MB_MIDDLE_YPOS 258
32 #define ED_WIN_MB_RIGHT_XPOS 77
33 #define ED_WIN_MB_RIGHT_YPOS 258
35 /* other constants for the editor */
36 #define ED_SCROLL_NO 0
37 #define ED_SCROLL_LEFT 1
38 #define ED_SCROLL_RIGHT 2
39 #define ED_SCROLL_UP 4
40 #define ED_SCROLL_DOWN 8
42 /* screens in the level editor */
43 #define ED_MODE_DRAWING 0
44 #define ED_MODE_INFO 1
45 #define ED_MODE_PROPERTIES 2
47 /* how many steps can be cancelled */
48 #define NUM_UNDO_STEPS (10 + 1)
50 /* values for elements with score */
54 /* values for elements with content */
55 #define MIN_ELEM_CONTENT 1
56 #define MAX_ELEM_CONTENT 8
58 /* values for the control window */
59 #define ED_CTRL_BUTTONS_GFX_YPOS 236
60 #define ED_CTRL_BUTTONS_ALT_GFX_YPOS 142
62 #define ED_CTRL1_BUTTONS_HORIZ 4
63 #define ED_CTRL1_BUTTONS_VERT 4
64 #define ED_CTRL1_BUTTON_XSIZE 22
65 #define ED_CTRL1_BUTTON_YSIZE 22
66 #define ED_CTRL1_BUTTONS_XPOS 6
67 #define ED_CTRL1_BUTTONS_YPOS 6
68 #define ED_CTRL2_BUTTONS_HORIZ 3
69 #define ED_CTRL2_BUTTONS_VERT 2
70 #define ED_CTRL2_BUTTON_XSIZE 30
71 #define ED_CTRL2_BUTTON_YSIZE 20
72 #define ED_CTRL2_BUTTONS_XPOS 5
73 #define ED_CTRL2_BUTTONS_YPOS 99
74 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT)
75 #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT)
76 #define ED_NUM_CTRL_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
78 /* values for the element list */
79 #define ED_ELEMENTLIST_UP_XPOS 35
80 #define ED_ELEMENTLIST_UP_YPOS 5
81 #define ED_ELEMENTLIST_UP_ALT_YPOS 140
82 #define ED_ELEMENTLIST_DOWN_XPOS 35
83 #define ED_ELEMENTLIST_DOWN_YPOS 250
84 #define ED_ELEMENTLIST_DOWN_ALT_YPOS 165
85 #define ED_ELEMENTLIST_UPDOWN_XSIZE 30
86 #define ED_ELEMENTLIST_UPDOWN_YSIZE 25
87 #define ED_ELEMENTLIST_XPOS 6
88 #define ED_ELEMENTLIST_YPOS 30
89 #define ED_ELEMENTLIST_ALT_YPOS 190
90 #define ED_ELEMENTLIST_XSIZE 22
91 #define ED_ELEMENTLIST_YSIZE 22
92 #define ED_ELEMENTLIST_BUTTONS_HORIZ 4
93 #define ED_ELEMENTLIST_BUTTONS_VERT 10
94 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
95 ED_ELEMENTLIST_BUTTONS_VERT)
97 /* values for the setting windows */
98 #define ED_SETTINGS_XPOS (MINI_TILEX + 8)
99 #define ED_SETTINGS2_XPOS MINI_TILEX
100 #define ED_SETTINGS_YPOS MINI_TILEY
101 #define ED_SETTINGS2_YPOS (ED_SETTINGS_YPOS + 12 * TILEY - 2)
103 /* values for counter gadgets */
104 #define ED_COUNT_ELEM_SCORE_XPOS ED_SETTINGS_XPOS
105 #define ED_COUNT_ELEM_SCORE_YPOS (14 * MINI_TILEY)
106 #define ED_COUNT_ELEM_CONTENT_XPOS ED_SETTINGS_XPOS
107 #define ED_COUNT_ELEM_CONTENT_YPOS (19 * MINI_TILEY)
109 #define ED_COUNTER_YSTART (ED_SETTINGS_YPOS + 2 * TILEY)
110 #define ED_COUNTER_YDISTANCE (3 * MINI_TILEY)
111 #define ED_COUNTER_YPOS(n) (ED_COUNTER_YSTART + \
112 n * ED_COUNTER_YDISTANCE)
113 #define ED_COUNTER2_YPOS(n) (ED_COUNTER_YSTART + \
114 n * ED_COUNTER_YDISTANCE - 2)
115 /* standard distances */
116 #define ED_BORDER_SIZE 3
117 #define ED_GADGET_DISTANCE 2
119 /* values for element content drawing areas */
120 #define ED_AREA_ELEM_CONTENT_XPOS ( 2 * MINI_TILEX)
121 #define ED_AREA_ELEM_CONTENT_YPOS (22 * MINI_TILEY)
123 /* values for random placement background drawing area */
124 #define ED_AREA_RANDOM_BACKGROUND_XPOS (29 * MINI_TILEX)
125 #define ED_AREA_RANDOM_BACKGROUND_YPOS (31 * MINI_TILEY)
127 /* values for scrolling gadgets */
128 #define ED_SCROLLBUTTON_XPOS 24
129 #define ED_SCROLLBUTTON_YPOS 0
130 #define ED_SCROLLBAR_XPOS 24
131 #define ED_SCROLLBAR_YPOS 64
133 #define ED_SCROLLBUTTON_XSIZE 16
134 #define ED_SCROLLBUTTON_YSIZE 16
136 #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE)
137 #define ED_SCROLL_UP_YPOS (0)
138 #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS
139 #define ED_SCROLL_DOWN_YPOS (SYSIZE - 3 * ED_SCROLLBUTTON_YSIZE)
140 #define ED_SCROLL_LEFT_XPOS (0)
141 #define ED_SCROLL_LEFT_YPOS (SYSIZE - 2 * ED_SCROLLBUTTON_YSIZE)
142 #define ED_SCROLL_RIGHT_XPOS (SXSIZE - 2 * ED_SCROLLBUTTON_XSIZE)
143 #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS
144 #define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + ED_SCROLLBUTTON_XSIZE)
145 #define ED_SCROLL_HORIZONTAL_YPOS ED_SCROLL_LEFT_YPOS
146 #define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - 3 * ED_SCROLLBUTTON_XSIZE)
147 #define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
148 #define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS
149 #define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + ED_SCROLLBUTTON_YSIZE)
150 #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
151 #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
153 /* values for checkbutton gadgets */
154 #define ED_CHECKBUTTON_XSIZE ED_BUTTON_COUNT_XSIZE
155 #define ED_CHECKBUTTON_YSIZE ED_BUTTON_COUNT_YSIZE
156 #define ED_CHECKBUTTON_UNCHECKED_XPOS ED_BUTTON_MINUS_XPOS
157 #define ED_CHECKBUTTON_CHECKED_XPOS ED_BUTTON_PLUS_XPOS
158 #define ED_CHECKBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 22)
159 #define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 88)
161 #define GADGET_ID_NONE -1
163 /* drawing toolbox buttons */
164 #define GADGET_ID_SINGLE_ITEMS 0
165 #define GADGET_ID_CONNECTED_ITEMS 1
166 #define GADGET_ID_LINE 2
167 #define GADGET_ID_ARC 3
168 #define GADGET_ID_RECTANGLE 4
169 #define GADGET_ID_FILLED_BOX 5
170 #define GADGET_ID_WRAP_UP 6
171 #define GADGET_ID_TEXT 7
172 #define GADGET_ID_FLOOD_FILL 8
173 #define GADGET_ID_WRAP_LEFT 9
174 #define GADGET_ID_PROPERTIES 10
175 #define GADGET_ID_WRAP_RIGHT 11
176 #define GADGET_ID_RANDOM_PLACEMENT 12
177 #define GADGET_ID_GRAB_BRUSH 13
178 #define GADGET_ID_WRAP_DOWN 14
179 #define GADGET_ID_PICK_ELEMENT 15
180 #define GADGET_ID_UNDO 16
181 #define GADGET_ID_INFO 17
182 #define GADGET_ID_SAVE 18
183 #define GADGET_ID_CLEAR 19
184 #define GADGET_ID_TEST 20
185 #define GADGET_ID_EXIT 21
187 /* counter button identifiers */
188 #define GADGET_ID_ELEM_SCORE_DOWN 22
189 #define GADGET_ID_ELEM_SCORE_TEXT 23
190 #define GADGET_ID_ELEM_SCORE_UP 24
191 #define GADGET_ID_ELEM_CONTENT_DOWN 25
192 #define GADGET_ID_ELEM_CONTENT_TEXT 26
193 #define GADGET_ID_ELEM_CONTENT_UP 27
194 #define GADGET_ID_LEVEL_XSIZE_DOWN 28
195 #define GADGET_ID_LEVEL_XSIZE_TEXT 29
196 #define GADGET_ID_LEVEL_XSIZE_UP 30
197 #define GADGET_ID_LEVEL_YSIZE_DOWN 31
198 #define GADGET_ID_LEVEL_YSIZE_TEXT 32
199 #define GADGET_ID_LEVEL_YSIZE_UP 33
200 #define GADGET_ID_LEVEL_RANDOM_DOWN 34
201 #define GADGET_ID_LEVEL_RANDOM_TEXT 35
202 #define GADGET_ID_LEVEL_RANDOM_UP 36
203 #define GADGET_ID_LEVEL_COLLECT_DOWN 37
204 #define GADGET_ID_LEVEL_COLLECT_TEXT 38
205 #define GADGET_ID_LEVEL_COLLECT_UP 39
206 #define GADGET_ID_LEVEL_TIMELIMIT_DOWN 40
207 #define GADGET_ID_LEVEL_TIMELIMIT_TEXT 41
208 #define GADGET_ID_LEVEL_TIMELIMIT_UP 42
209 #define GADGET_ID_LEVEL_TIMESCORE_DOWN 43
210 #define GADGET_ID_LEVEL_TIMESCORE_TEXT 44
211 #define GADGET_ID_LEVEL_TIMESCORE_UP 45
213 /* drawing area identifiers */
214 #define GADGET_ID_DRAWING_LEVEL 46
215 #define GADGET_ID_ELEM_CONTENT_0 47
216 #define GADGET_ID_ELEM_CONTENT_1 48
217 #define GADGET_ID_ELEM_CONTENT_2 49
218 #define GADGET_ID_ELEM_CONTENT_3 50
219 #define GADGET_ID_ELEM_CONTENT_4 51
220 #define GADGET_ID_ELEM_CONTENT_5 52
221 #define GADGET_ID_ELEM_CONTENT_6 53
222 #define GADGET_ID_ELEM_CONTENT_7 54
223 #define GADGET_ID_AMOEBA_CONTENT 55
225 /* text input identifiers */
226 #define GADGET_ID_LEVEL_NAME 56
227 #define GADGET_ID_LEVEL_AUTHOR 57
229 /* gadgets for scrolling of drawing area */
230 #define GADGET_ID_SCROLL_UP 58
231 #define GADGET_ID_SCROLL_DOWN 59
232 #define GADGET_ID_SCROLL_LEFT 60
233 #define GADGET_ID_SCROLL_RIGHT 61
234 #define GADGET_ID_SCROLL_HORIZONTAL 62
235 #define GADGET_ID_SCROLL_VERTICAL 63
237 /* gadgets for scrolling element list */
238 #define GADGET_ID_ELEMENTLIST_UP 64
239 #define GADGET_ID_ELEMENTLIST_DOWN 65
241 /* gadgets for buttons in element list */
242 #define GADGET_ID_ELEMENTLIST_FIRST 66
243 #define GADGET_ID_ELEMENTLIST_LAST 105
245 /* buttons for level settings */
246 #define GADGET_ID_RANDOM_PERCENTAGE 106
247 #define GADGET_ID_RANDOM_QUANTITY 107
248 #define GADGET_ID_RANDOM_RESTRICTED 108
249 #define GADGET_ID_DOUBLE_SPEED 109
250 #define GADGET_ID_STICK_ELEMENT 110
252 /* another drawing area for random placement */
253 #define GADGET_ID_RANDOM_BACKGROUND 111
255 #define NUM_EDITOR_GADGETS 112
257 /* radio button numbers */
258 #define RADIO_NR_NONE 0
259 #define RADIO_NR_DRAWING_TOOLBOX 1
260 #define RADIO_NR_RANDOM_ELEMENTS 2
262 /* values for counter gadgets */
263 #define ED_COUNTER_ID_ELEM_SCORE 0
264 #define ED_COUNTER_ID_ELEM_CONTENT 1
265 #define ED_COUNTER_ID_LEVEL_XSIZE 2
266 #define ED_COUNTER_ID_LEVEL_YSIZE 3
267 #define ED_COUNTER_ID_LEVEL_COLLECT 4
268 #define ED_COUNTER_ID_LEVEL_TIMELIMIT 5
269 #define ED_COUNTER_ID_LEVEL_TIMESCORE 6
270 #define ED_COUNTER_ID_LEVEL_RANDOM 7
272 #define ED_NUM_COUNTERBUTTONS 8
274 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
275 #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM
277 /* values for scrollbutton gadgets */
278 #define ED_SCROLLBUTTON_ID_AREA_UP 0
279 #define ED_SCROLLBUTTON_ID_AREA_DOWN 1
280 #define ED_SCROLLBUTTON_ID_AREA_LEFT 2
281 #define ED_SCROLLBUTTON_ID_AREA_RIGHT 3
282 #define ED_SCROLLBUTTON_ID_LIST_UP 4
283 #define ED_SCROLLBUTTON_ID_LIST_DOWN 5
285 #define ED_NUM_SCROLLBUTTONS 6
287 /* values for scrollbar gadgets */
288 #define ED_SCROLLBAR_ID_HORIZONTAL 0
289 #define ED_SCROLLBAR_ID_VERTICAL 1
291 #define ED_NUM_SCROLLBARS 2
293 /* values for text input gadgets */
294 #define ED_TEXTINPUT_ID_LEVEL_NAME 0
295 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1
297 #define ED_NUM_TEXTINPUT 2
299 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
300 #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
302 /* values for checkbutton gadgets */
303 #define ED_CHECKBUTTON_ID_DOUBLE_SPEED 0
304 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 1
305 #define ED_CHECKBUTTON_ID_STICK_ELEMENT 2
307 #define ED_NUM_CHECKBUTTONS 3
309 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_DOUBLE_SPEED
310 #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
312 /* values for radiobutton gadgets */
313 #define ED_RADIOBUTTON_ID_PERCENTAGE 0
314 #define ED_RADIOBUTTON_ID_QUANTITY 1
316 #define ED_NUM_RADIOBUTTONS 2
318 #define ED_RADIOBUTTON_ID_LEVEL_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
319 #define ED_RADIOBUTTON_ID_LEVEL_LAST ED_RADIOBUTTON_ID_QUANTITY
321 /* values for CopyLevelToUndoBuffer() */
322 #define UNDO_IMMEDIATE 0
323 #define UNDO_ACCUMULATE 1
325 /* values for ClearEditorGadgetInfoText() and HandleGadgetInfoText() */
326 #define INFOTEXT_XPOS SX
327 #define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2)
328 #define INFOTEXT_XSIZE SXSIZE
329 #define INFOTEXT_YSIZE MINI_TILEX
330 #define MAX_INFOTEXT_LEN (SXSIZE / FONT2_XSIZE)
336 } control_info[ED_NUM_CTRL_BUTTONS] =
338 { 's', "draw single items" },
339 { 'd', "draw connected items" },
340 { 'l', "draw lines" },
341 { 'a', "draw arcs" },
342 { 'r', "draw outline rectangles" },
343 { 'R', "draw filled rectangles" },
344 { '\0', "wrap (rotate) level up" },
345 { 't', "enter text elements" },
346 { 'f', "flood fill" },
347 { '\0', "wrap (rotate) level left" },
348 { '?', "properties of drawing element" },
349 { '\0', "wrap (rotate) level right" },
350 { '\0', "random element placement" },
351 { 'b', "grab brush" },
352 { '\0', "wrap (rotate) level down" },
353 { ',', "pick drawing element" },
354 { 'U', "undo last operation" },
355 { 'I', "level properties" },
356 { 'S', "save level" },
357 { 'C', "clear level" },
358 { 'T', "test level" },
359 { 'E', "exit level editor" }
362 /* pointers to counter values */
363 static int *gadget_elem_score_value = NULL;
364 static int *gadget_elem_content_value = NULL;
365 static int *gadget_level_xsize_value = NULL;
366 static int *gadget_level_ysize_value = NULL;
367 static int *gadget_level_random_value = NULL;
368 static int *gadget_level_collect_value = NULL;
369 static int *gadget_level_timelimit_value = NULL;
370 static int *gadget_level_timescore_value = NULL;
375 int min_value, max_value;
376 int gadget_id_down, gadget_id_up;
379 char *infotext_above, *infotext_right;
380 } counterbutton_info[ED_NUM_COUNTERBUTTONS] =
383 ED_COUNT_ELEM_SCORE_XPOS, ED_COUNT_ELEM_SCORE_YPOS,
384 MIN_SCORE, MAX_SCORE,
385 GADGET_ID_ELEM_SCORE_DOWN, GADGET_ID_ELEM_SCORE_UP,
386 GADGET_ID_ELEM_SCORE_TEXT,
387 &gadget_elem_score_value,
388 "element score", NULL
391 ED_COUNT_ELEM_CONTENT_XPOS, ED_COUNT_ELEM_CONTENT_YPOS,
392 MIN_ELEM_CONTENT, MAX_ELEM_CONTENT,
393 GADGET_ID_ELEM_CONTENT_DOWN, GADGET_ID_ELEM_CONTENT_UP,
394 GADGET_ID_ELEM_CONTENT_TEXT,
395 &gadget_elem_content_value,
396 "element content", NULL
399 ED_SETTINGS_XPOS, ED_COUNTER_YPOS(2),
400 MIN_LEV_FIELDX, MAX_LEV_FIELDX,
401 GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
402 GADGET_ID_LEVEL_XSIZE_TEXT,
403 &gadget_level_xsize_value,
404 "playfield size", "width",
407 ED_SETTINGS_XPOS + 2 * DXSIZE, ED_COUNTER_YPOS(2),
408 MIN_LEV_FIELDY, MAX_LEV_FIELDY,
409 GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
410 GADGET_ID_LEVEL_YSIZE_TEXT,
411 &gadget_level_ysize_value,
415 ED_SETTINGS_XPOS, ED_COUNTER_YPOS(3),
417 GADGET_ID_LEVEL_COLLECT_DOWN, GADGET_ID_LEVEL_COLLECT_UP,
418 GADGET_ID_LEVEL_COLLECT_TEXT,
419 &gadget_level_collect_value,
420 "number of emeralds to collect", NULL
423 ED_SETTINGS_XPOS, ED_COUNTER_YPOS(4),
425 GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
426 GADGET_ID_LEVEL_TIMELIMIT_TEXT,
427 &gadget_level_timelimit_value,
428 "time available to solve level", "(0 => no time limit)"
431 ED_SETTINGS_XPOS, ED_COUNTER_YPOS(5),
433 GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
434 GADGET_ID_LEVEL_TIMESCORE_TEXT,
435 &gadget_level_timescore_value,
436 "score for each 10 seconds left", NULL
439 ED_SETTINGS_XPOS, ED_COUNTER2_YPOS(8),
441 GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
442 GADGET_ID_LEVEL_RANDOM_TEXT,
443 &gadget_level_random_value,
444 "random element placement", "in"
455 } textinput_info[ED_NUM_TEXTINPUT] =
458 ED_SETTINGS_XPOS, ED_COUNTER_YPOS(0),
459 GADGET_ID_LEVEL_NAME,
465 ED_SETTINGS_XPOS, ED_COUNTER_YPOS(1),
466 GADGET_ID_LEVEL_AUTHOR,
467 MAX_LEVEL_AUTHOR_LEN,
479 } scrollbutton_info[ED_NUM_SCROLLBUTTONS] =
482 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE,
483 ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS,
485 "scroll level editing area up"
488 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE,
489 ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS,
490 GADGET_ID_SCROLL_DOWN,
491 "scroll level editing area down"
494 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE,
495 ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS,
496 GADGET_ID_SCROLL_LEFT,
497 "scroll level editing area left"
500 ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE,
501 ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS,
502 GADGET_ID_SCROLL_RIGHT,
503 "scroll level editing area right"
506 ED_ELEMENTLIST_UP_XPOS, ED_ELEMENTLIST_UP_ALT_YPOS,
507 ED_ELEMENTLIST_UP_XPOS, ED_ELEMENTLIST_UP_YPOS,
508 GADGET_ID_ELEMENTLIST_UP,
509 "scroll element list up ('Page Up')"
512 ED_ELEMENTLIST_DOWN_XPOS, ED_ELEMENTLIST_DOWN_ALT_YPOS,
513 ED_ELEMENTLIST_DOWN_XPOS, ED_ELEMENTLIST_DOWN_YPOS,
514 GADGET_ID_ELEMENTLIST_DOWN,
515 "scroll element list down ('Page Down')"
527 } scrollbar_info[ED_NUM_SCROLLBARS] =
530 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
531 ED_SCROLL_HORIZONTAL_XPOS, ED_SCROLL_HORIZONTAL_YPOS,
532 ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE,
533 GD_TYPE_SCROLLBAR_HORIZONTAL,
534 GADGET_ID_SCROLL_HORIZONTAL,
535 "scroll level editing area horizontally"
538 ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
539 ED_SCROLL_VERTICAL_XPOS, ED_SCROLL_VERTICAL_YPOS,
540 ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE,
541 GD_TYPE_SCROLLBAR_VERTICAL,
542 GADGET_ID_SCROLL_VERTICAL,
543 "scroll level editing area vertically"
547 /* values for random placement */
548 #define RANDOM_USE_PERCENTAGE 0
549 #define RANDOM_USE_QUANTITY 1
551 static int random_placement_value = 10;
552 static int random_placement_method = RANDOM_USE_QUANTITY;
553 static int random_placement_background_element = EL_ERDREICH;
554 static boolean random_placement_background_restricted = FALSE;
555 static boolean stick_element_properties_window = FALSE;
564 char *text, *infotext;
565 } radiobutton_info[ED_NUM_RADIOBUTTONS] =
568 ED_SETTINGS_XPOS + 160, ED_COUNTER2_YPOS(8),
569 GADGET_ID_RANDOM_PERCENTAGE,
570 RADIO_NR_RANDOM_ELEMENTS,
571 &random_placement_method, RANDOM_USE_PERCENTAGE,
572 "percentage", "use percentage for random elements"
575 ED_SETTINGS_XPOS + 340, ED_COUNTER2_YPOS(8),
576 GADGET_ID_RANDOM_QUANTITY,
577 RADIO_NR_RANDOM_ELEMENTS,
578 &random_placement_method, RANDOM_USE_QUANTITY,
579 "quantity", "use quantity for random elements"
588 char *text, *infotext;
589 } checkbutton_info[ED_NUM_CHECKBUTTONS] =
592 ED_SETTINGS_XPOS, ED_COUNTER_YPOS(6) - MINI_TILEY,
593 GADGET_ID_DOUBLE_SPEED,
595 "double speed movement", "set movement speed of player"
598 ED_SETTINGS_XPOS, ED_COUNTER2_YPOS(9) - MINI_TILEY,
599 GADGET_ID_RANDOM_RESTRICTED,
600 &random_placement_background_restricted,
601 "restrict random placement to", "set random placement restriction"
604 ED_SETTINGS_XPOS, ED_COUNTER_YPOS(4),
605 GADGET_ID_STICK_ELEMENT,
606 &stick_element_properties_window,
607 "stick window to edit content", "stick window to edit content"
611 /* maximal size of level editor drawing area */
612 #define MAX_ED_FIELDX (2 * SCR_FIELDX)
613 #define MAX_ED_FIELDY (2 * SCR_FIELDY - 1)
615 /* actual size of level editor drawing area */
616 static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1;
618 /* actual position of level editor drawing area in level playfield */
619 static int level_xpos = -1, level_ypos = -1;
621 #define IN_ED_FIELD(x,y) ((x)>=0 && (x)<ed_fieldx && (y)>=0 &&(y)<ed_fieldx)
623 /* drawing elements on the three mouse buttons */
624 static int new_element1 = EL_MAUERWERK;
625 static int new_element2 = EL_LEERRAUM;
626 static int new_element3 = EL_ERDREICH;
628 #define BUTTON_ELEMENT(button) (button == 1 ? new_element1 : \
629 button == 2 ? new_element2 : \
630 button == 3 ? new_element3 : EL_LEERRAUM)
632 /* forward declaration for internal use */
633 static void DrawDrawingWindow();
634 static void DrawLevelInfoWindow();
635 static void DrawPropertiesWindow();
636 static void CopyLevelToUndoBuffer(int);
637 static void HandleControlButtons(struct GadgetInfo *);
638 static void HandleCounterButtons(struct GadgetInfo *);
639 static void HandleDrawingAreas(struct GadgetInfo *);
640 static void HandleDrawingAreaInfo(struct GadgetInfo *);
641 static void HandleTextInputGadgets(struct GadgetInfo *);
643 static struct GadgetInfo *level_editor_gadget[NUM_EDITOR_GADGETS];
645 static int drawing_function = GADGET_ID_SINGLE_ITEMS;
646 static int last_drawing_function = GADGET_ID_SINGLE_ITEMS;
647 static boolean draw_with_brush = FALSE;
648 static int properties_element = 0;
650 static short ElementContent[MAX_ELEM_CONTENT][3][3];
651 static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
652 static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
653 static int undo_buffer_position = 0;
654 static int undo_buffer_steps = 0;
656 static int edit_mode;
658 static int counter_xsize = DXSIZE + FONT2_XSIZE - 2 * ED_GADGET_DISTANCE;
660 int element_shift = 0;
662 int editor_element[] =
875 EL_SOKOBAN_FELD_LEER,
876 EL_SOKOBAN_FELD_VOLL,
1046 int elements_in_list = sizeof(editor_element)/sizeof(int);
1048 static void ScrollMiniLevel(int from_x, int from_y, int scroll)
1051 int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
1052 int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
1054 XCopyArea(display, drawto, drawto, gc,
1055 SX + (dx == -1 ? MINI_TILEX : 0),
1056 SY + (dy == -1 ? MINI_TILEY : 0),
1057 (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
1058 (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
1059 SX + (dx == +1 ? MINI_TILEX : 0),
1060 SY + (dy == +1 ? MINI_TILEY : 0));
1063 x = (dx == 1 ? 0 : ed_fieldx - 1);
1064 for(y=0; y<ed_fieldy; y++)
1065 DrawMiniElementOrWall(x, y, from_x, from_y);
1069 y = (dy == 1 ? 0 : ed_fieldy - 1);
1070 for(x=0; x<ed_fieldx; x++)
1071 DrawMiniElementOrWall(x, y, from_x, from_y);
1074 redraw_mask |= REDRAW_FIELD;
1078 static void CreateControlButtons()
1080 Pixmap gd_pixmap = pix[PIX_DOOR];
1081 struct GadgetInfo *gi;
1082 unsigned long event_mask;
1085 /* create toolbox buttons */
1086 for (i=0; i<ED_NUM_CTRL_BUTTONS; i++)
1090 int gd_xoffset, gd_yoffset;
1091 int gd_x1, gd_x2, gd_y1, gd_y2;
1093 int radio_button_nr;
1096 if (id == GADGET_ID_SINGLE_ITEMS ||
1097 id == GADGET_ID_CONNECTED_ITEMS ||
1098 id == GADGET_ID_LINE ||
1099 id == GADGET_ID_ARC ||
1100 id == GADGET_ID_TEXT ||
1101 id == GADGET_ID_RECTANGLE ||
1102 id == GADGET_ID_FILLED_BOX ||
1103 id == GADGET_ID_FLOOD_FILL ||
1104 id == GADGET_ID_GRAB_BRUSH ||
1105 id == GADGET_ID_PICK_ELEMENT)
1107 button_type = GD_TYPE_RADIO_BUTTON;
1108 radio_button_nr = RADIO_NR_DRAWING_TOOLBOX;
1109 checked = (id == drawing_function ? TRUE : FALSE);
1110 event_mask = GD_EVENT_PRESSED;
1114 button_type = GD_TYPE_NORMAL_BUTTON;
1115 radio_button_nr = RADIO_NR_NONE;
1118 if (id == GADGET_ID_WRAP_LEFT ||
1119 id == GADGET_ID_WRAP_RIGHT ||
1120 id == GADGET_ID_WRAP_UP ||
1121 id == GADGET_ID_WRAP_DOWN)
1122 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
1124 event_mask = GD_EVENT_RELEASED;
1127 if (id < ED_NUM_CTRL1_BUTTONS)
1129 int x = i % ED_CTRL1_BUTTONS_HORIZ;
1130 int y = i / ED_CTRL1_BUTTONS_HORIZ;
1132 gd_xoffset = ED_CTRL1_BUTTONS_XPOS + x * ED_CTRL1_BUTTON_XSIZE;
1133 gd_yoffset = ED_CTRL1_BUTTONS_YPOS + y * ED_CTRL1_BUTTON_YSIZE;
1134 width = ED_CTRL1_BUTTON_XSIZE;
1135 height = ED_CTRL1_BUTTON_YSIZE;
1139 int x = (i - ED_NUM_CTRL1_BUTTONS) % ED_CTRL2_BUTTONS_HORIZ;
1140 int y = (i - ED_NUM_CTRL1_BUTTONS) / ED_CTRL2_BUTTONS_HORIZ;
1142 gd_xoffset = ED_CTRL2_BUTTONS_XPOS + x * ED_CTRL2_BUTTON_XSIZE;
1143 gd_yoffset = ED_CTRL2_BUTTONS_YPOS + y * ED_CTRL2_BUTTON_YSIZE;
1144 width = ED_CTRL2_BUTTON_XSIZE;
1145 height = ED_CTRL2_BUTTON_YSIZE;
1148 gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
1149 gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
1150 gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL_BUTTONS_GFX_YPOS + gd_yoffset;
1151 gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
1153 gi = CreateGadget(GDI_CUSTOM_ID, id,
1154 GDI_INFO_TEXT, control_info[i].text,
1155 GDI_X, EX + gd_xoffset,
1156 GDI_Y, EY + gd_yoffset,
1159 GDI_TYPE, button_type,
1160 GDI_STATE, GD_BUTTON_UNPRESSED,
1161 GDI_RADIO_NR, radio_button_nr,
1162 GDI_CHECKED, checked,
1163 GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1,
1164 GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y1,
1165 GDI_ALT_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y2,
1166 GDI_ALT_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2,
1167 GDI_EVENT_MASK, event_mask,
1168 GDI_CALLBACK_ACTION, HandleControlButtons,
1172 Error(ERR_EXIT, "cannot create gadget");
1174 level_editor_gadget[id] = gi;
1177 /* create buttons for scrolling of drawing area and element list */
1178 for (i=0; i<ED_NUM_SCROLLBUTTONS; i++)
1180 int id = scrollbutton_info[i].gadget_id;
1181 int x, y, width, height;
1182 int gd_x1, gd_x2, gd_y1, gd_y2;
1184 x = scrollbutton_info[i].x;
1185 y = scrollbutton_info[i].y;
1187 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
1189 if (id == GADGET_ID_ELEMENTLIST_UP ||
1190 id == GADGET_ID_ELEMENTLIST_DOWN)
1194 width = ED_ELEMENTLIST_UPDOWN_XSIZE;
1195 height = ED_ELEMENTLIST_UPDOWN_YSIZE;
1196 gd_x1 = DOOR_GFX_PAGEX6 + scrollbutton_info[i].xpos;
1197 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].y;
1199 gd_y2 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].ypos;
1205 width = ED_SCROLLBUTTON_XSIZE;
1206 height = ED_SCROLLBUTTON_YSIZE;
1207 gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].xpos;
1208 gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].ypos;
1209 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
1213 gi = CreateGadget(GDI_CUSTOM_ID, id,
1214 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
1219 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
1220 GDI_STATE, GD_BUTTON_UNPRESSED,
1221 GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1,
1222 GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2,
1223 GDI_EVENT_MASK, event_mask,
1224 GDI_CALLBACK_ACTION, HandleControlButtons,
1228 Error(ERR_EXIT, "cannot create gadget");
1230 level_editor_gadget[id] = gi;
1233 /* create buttons for element list */
1234 for (i=0; i<ED_NUM_ELEMENTLIST_BUTTONS; i++)
1237 int deco_x, deco_y, deco_xpos, deco_ypos;
1238 int gd_xoffset, gd_yoffset;
1239 int gd_x, gd_y1, gd_y2;
1240 int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
1241 int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
1242 int id = GADGET_ID_ELEMENTLIST_FIRST + i;
1244 event_mask = GD_EVENT_RELEASED;
1246 gd_xoffset = ED_ELEMENTLIST_XPOS + x * ED_ELEMENTLIST_XSIZE;
1247 gd_yoffset = ED_ELEMENTLIST_YPOS + y * ED_ELEMENTLIST_YSIZE;
1249 gd_x = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
1250 gd_y1 = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
1251 gd_y2 = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_ALT_YPOS;
1253 getMiniGraphicSource(el2gfx(editor_element[i]),
1254 &deco_pixmap, &deco_x, &deco_y);
1255 deco_xpos = (ED_ELEMENTLIST_XSIZE - MINI_TILEX) / 2;
1256 deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2;
1258 gi = CreateGadget(GDI_CUSTOM_ID, id,
1259 GDI_INFO_TEXT, element_info[editor_element[i]],
1260 GDI_X, DX + gd_xoffset,
1261 GDI_Y, DY + gd_yoffset,
1262 GDI_WIDTH, ED_ELEMENTLIST_XSIZE,
1263 GDI_HEIGHT, ED_ELEMENTLIST_YSIZE,
1264 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
1265 GDI_STATE, GD_BUTTON_UNPRESSED,
1266 GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x, gd_y1,
1267 GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y2,
1268 GDI_DECORATION_DESIGN, deco_pixmap, deco_x, deco_y,
1269 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
1270 GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
1271 GDI_DECORATION_SHIFTING, 1, 1,
1272 GDI_EVENT_MASK, event_mask,
1273 GDI_CALLBACK_ACTION, HandleControlButtons,
1277 Error(ERR_EXIT, "cannot create gadget");
1279 level_editor_gadget[id] = gi;
1283 static void CreateCounterButtons()
1287 for (i=0; i<ED_NUM_COUNTERBUTTONS; i++)
1290 int xpos = SX + counterbutton_info[i].x; /* xpos of down count button */
1291 int ypos = SY + counterbutton_info[i].y;
1295 Pixmap gd_pixmap = pix[PIX_DOOR];
1296 struct GadgetInfo *gi;
1298 counterbutton_info[i].gadget_id_down :
1299 counterbutton_info[i].gadget_id_up);
1301 int gd_x, gd_x1, gd_x2, gd_y;
1302 unsigned long event_mask;
1303 char infotext[MAX_INFOTEXT_LEN + 1];
1305 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
1307 gd_xoffset = (j == 0 ? ED_BUTTON_MINUS_XPOS : ED_BUTTON_PLUS_XPOS);
1308 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
1309 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
1310 gd_y = DOOR_GFX_PAGEY1 + ED_BUTTON_COUNT_YPOS;
1312 sprintf(infotext, "%s counter value by 1, 5 or 10",
1313 (j == 0 ? "decrease" : "increase"));
1315 gi = CreateGadget(GDI_CUSTOM_ID, id,
1316 GDI_INFO_TEXT, infotext,
1319 GDI_WIDTH, ED_BUTTON_COUNT_XSIZE,
1320 GDI_HEIGHT, ED_BUTTON_COUNT_YSIZE,
1321 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
1322 GDI_STATE, GD_BUTTON_UNPRESSED,
1323 GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y,
1324 GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y,
1325 GDI_EVENT_MASK, event_mask,
1326 GDI_CALLBACK_ACTION, HandleCounterButtons,
1330 Error(ERR_EXIT, "cannot create gadget");
1332 level_editor_gadget[id] = gi;
1333 xpos += gi->width + ED_GADGET_DISTANCE; /* xpos of text count button */
1337 id = counterbutton_info[i].gadget_id_text;
1338 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
1340 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
1341 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
1343 gi = CreateGadget(GDI_CUSTOM_ID, id,
1344 GDI_INFO_TEXT, "enter counter value",
1347 GDI_TYPE, GD_TYPE_TEXTINPUT_NUMERIC,
1348 GDI_NUMBER_VALUE, 0,
1349 GDI_NUMBER_MIN, counterbutton_info[i].min_value,
1350 GDI_NUMBER_MAX, counterbutton_info[i].max_value,
1352 GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x, gd_y,
1353 GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y,
1354 GDI_DESIGN_BORDER, ED_BORDER_SIZE,
1355 GDI_EVENT_MASK, event_mask,
1356 GDI_CALLBACK_ACTION, HandleCounterButtons,
1360 Error(ERR_EXIT, "cannot create gadget");
1362 level_editor_gadget[id] = gi;
1363 xpos += gi->width + ED_GADGET_DISTANCE; /* xpos of up count button */
1369 static void CreateDrawingAreas()
1371 struct GadgetInfo *gi;
1372 unsigned long event_mask;
1377 GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
1378 GD_EVENT_OFF_BORDERS;
1380 /* one for the level drawing area ... */
1381 id = GADGET_ID_DRAWING_LEVEL;
1382 gi = CreateGadget(GDI_CUSTOM_ID, id,
1385 GDI_TYPE, GD_TYPE_DRAWING_AREA,
1386 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
1387 GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
1388 GDI_EVENT_MASK, event_mask,
1389 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
1390 GDI_CALLBACK_ACTION, HandleDrawingAreas,
1394 Error(ERR_EXIT, "cannot create gadget");
1396 level_editor_gadget[id] = gi;
1398 /* ... up to eight areas for element content ... */
1399 for (i=0; i<MAX_ELEM_CONTENT; i++)
1401 int gx = SX + ED_AREA_ELEM_CONTENT_XPOS + 5 * (i % 4) * MINI_TILEX;
1402 int gy = SX + ED_AREA_ELEM_CONTENT_YPOS + 6 * (i / 4) * MINI_TILEY;
1404 id = GADGET_ID_ELEM_CONTENT_0 + i;
1405 gi = CreateGadget(GDI_CUSTOM_ID, id,
1408 GDI_WIDTH, 3 * MINI_TILEX,
1409 GDI_HEIGHT, 3 * MINI_TILEY,
1410 GDI_TYPE, GD_TYPE_DRAWING_AREA,
1411 GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
1412 GDI_EVENT_MASK, event_mask,
1413 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
1414 GDI_CALLBACK_ACTION, HandleDrawingAreas,
1418 Error(ERR_EXIT, "cannot create gadget");
1420 level_editor_gadget[id] = gi;
1423 /* ... one for the amoeba content */
1424 id = GADGET_ID_AMOEBA_CONTENT;
1425 gi = CreateGadget(GDI_CUSTOM_ID, id,
1426 GDI_X, SX + ED_AREA_ELEM_CONTENT_XPOS,
1427 GDI_Y, SY + ED_AREA_ELEM_CONTENT_YPOS,
1428 GDI_WIDTH, MINI_TILEX,
1429 GDI_HEIGHT, MINI_TILEY,
1430 GDI_TYPE, GD_TYPE_DRAWING_AREA,
1431 GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
1432 GDI_EVENT_MASK, event_mask,
1433 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
1434 GDI_CALLBACK_ACTION, HandleDrawingAreas,
1438 Error(ERR_EXIT, "cannot create gadget");
1440 level_editor_gadget[id] = gi;
1442 /* ... and one for random placement background restrictions */
1444 id = GADGET_ID_RANDOM_BACKGROUND;
1445 gi = CreateGadget(GDI_CUSTOM_ID, id,
1446 GDI_X, SX + ED_AREA_RANDOM_BACKGROUND_XPOS,
1447 GDI_Y, SY + ED_AREA_RANDOM_BACKGROUND_YPOS,
1448 GDI_WIDTH, MINI_TILEX,
1449 GDI_HEIGHT, MINI_TILEY,
1450 GDI_TYPE, GD_TYPE_DRAWING_AREA,
1451 GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
1452 GDI_EVENT_MASK, event_mask,
1453 GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
1454 GDI_CALLBACK_ACTION, HandleDrawingAreas,
1458 Error(ERR_EXIT, "cannot create gadget");
1460 level_editor_gadget[id] = gi;
1463 static void CreateTextInputGadgets()
1467 for (i=0; i<ED_NUM_TEXTINPUT; i++)
1469 Pixmap gd_pixmap = pix[PIX_DOOR];
1471 struct GadgetInfo *gi;
1472 unsigned long event_mask;
1473 char infotext[1024];
1474 int id = textinput_info[i].gadget_id;
1476 event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
1478 gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
1479 gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
1481 sprintf(infotext, "Enter %s", textinput_info[i].infotext);
1482 infotext[MAX_INFOTEXT_LEN] = '\0';
1484 gi = CreateGadget(GDI_CUSTOM_ID, id,
1485 GDI_INFO_TEXT, infotext,
1486 GDI_X, SX + textinput_info[i].x,
1487 GDI_Y, SY + textinput_info[i].y,
1488 GDI_TYPE, GD_TYPE_TEXTINPUT_ALPHANUMERIC,
1489 GDI_TEXT_VALUE, textinput_info[i].value,
1490 GDI_TEXT_SIZE, textinput_info[i].size,
1491 GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x, gd_y,
1492 GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y,
1493 GDI_DESIGN_BORDER, ED_BORDER_SIZE,
1494 GDI_EVENT_MASK, event_mask,
1495 GDI_CALLBACK_ACTION, HandleTextInputGadgets,
1499 Error(ERR_EXIT, "cannot create gadget");
1501 level_editor_gadget[id] = gi;
1505 static void CreateScrollbarGadgets()
1509 for (i=0; i<ED_NUM_SCROLLBARS; i++)
1511 int id = scrollbar_info[i].gadget_id;
1512 Pixmap gd_pixmap = pix[PIX_DOOR];
1513 int gd_x1, gd_x2, gd_y1, gd_y2;
1514 struct GadgetInfo *gi;
1515 int items_max, items_visible, item_position;
1516 unsigned long event_mask;
1518 if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
1520 items_max = MAX(lev_fieldx + 2, ed_fieldx);
1521 items_visible = ed_fieldx;
1526 items_max = MAX(lev_fieldy + 2, ed_fieldy);
1527 items_visible = ed_fieldy;
1531 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
1533 gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].xpos;
1534 gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
1535 gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos;
1536 gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos;
1538 gi = CreateGadget(GDI_CUSTOM_ID, id,
1539 GDI_INFO_TEXT, scrollbar_info[i].infotext,
1540 GDI_X, SX + scrollbar_info[i].x,
1541 GDI_Y, SY + scrollbar_info[i].y,
1542 GDI_WIDTH, scrollbar_info[i].width,
1543 GDI_HEIGHT, scrollbar_info[i].height,
1544 GDI_TYPE, scrollbar_info[i].type,
1545 GDI_SCROLLBAR_ITEMS_MAX, items_max,
1546 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
1547 GDI_SCROLLBAR_ITEM_POSITION, item_position,
1548 GDI_STATE, GD_BUTTON_UNPRESSED,
1549 GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1,
1550 GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2,
1551 GDI_DESIGN_BORDER, ED_BORDER_SIZE,
1552 GDI_EVENT_MASK, event_mask,
1553 GDI_CALLBACK_ACTION, HandleControlButtons,
1557 Error(ERR_EXIT, "cannot create gadget");
1559 level_editor_gadget[id] = gi;
1563 static void CreateCheckbuttonGadgets()
1565 Pixmap gd_pixmap = pix[PIX_DOOR];
1566 struct GadgetInfo *gi;
1567 unsigned long event_mask;
1568 int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
1572 event_mask = GD_EVENT_PRESSED;
1574 gd_x1 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_UNCHECKED_XPOS;
1575 gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
1576 gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
1577 gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
1578 gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS;
1580 for (i=0; i<ED_NUM_RADIOBUTTONS; i++)
1582 int id = radiobutton_info[i].gadget_id;
1585 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
1587 gi = CreateGadget(GDI_CUSTOM_ID, id,
1588 GDI_INFO_TEXT, radiobutton_info[i].infotext,
1589 GDI_X, SX + radiobutton_info[i].x,
1590 GDI_Y, SY + radiobutton_info[i].y,
1591 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
1592 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
1593 GDI_TYPE, GD_TYPE_RADIO_BUTTON,
1594 GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
1595 GDI_CHECKED, checked,
1596 GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y,
1597 GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y,
1598 GDI_ALT_DESIGN_UNPRESSED, gd_pixmap, gd_x3, gd_y,
1599 GDI_ALT_DESIGN_PRESSED, gd_pixmap, gd_x4, gd_y,
1600 GDI_EVENT_MASK, event_mask,
1601 GDI_CALLBACK_ACTION, HandleControlButtons,
1605 Error(ERR_EXIT, "cannot create gadget");
1607 level_editor_gadget[id] = gi;
1610 for (i=0; i<ED_NUM_CHECKBUTTONS; i++)
1612 int id = checkbutton_info[i].gadget_id;
1614 if (id == GADGET_ID_STICK_ELEMENT)
1615 gd_y = DOOR_GFX_PAGEY1 + ED_STICKYBUTTON_YPOS;
1617 gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS;
1619 gi = CreateGadget(GDI_CUSTOM_ID, id,
1620 GDI_INFO_TEXT, checkbutton_info[i].infotext,
1621 GDI_X, SX + checkbutton_info[i].x,
1622 GDI_Y, SY + checkbutton_info[i].y,
1623 GDI_WIDTH, ED_CHECKBUTTON_XSIZE,
1624 GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
1625 GDI_TYPE, GD_TYPE_CHECK_BUTTON,
1626 GDI_CHECKED, *checkbutton_info[i].value,
1627 GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y,
1628 GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y,
1629 GDI_ALT_DESIGN_UNPRESSED, gd_pixmap, gd_x3, gd_y,
1630 GDI_ALT_DESIGN_PRESSED, gd_pixmap, gd_x4, gd_y,
1631 GDI_EVENT_MASK, event_mask,
1632 GDI_CALLBACK_ACTION, HandleControlButtons,
1636 Error(ERR_EXIT, "cannot create gadget");
1638 level_editor_gadget[id] = gi;
1642 void CreateLevelEditorGadgets()
1644 CreateControlButtons();
1645 CreateCounterButtons();
1646 CreateDrawingAreas();
1647 CreateTextInputGadgets();
1648 CreateScrollbarGadgets();
1649 CreateCheckbuttonGadgets();
1652 static void MapControlButtons()
1656 for (i=0; i<ED_NUM_CTRL_BUTTONS; i++)
1657 MapGadget(level_editor_gadget[i]);
1658 for (i=0; i<ED_NUM_ELEMENTLIST_BUTTONS; i++)
1659 MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
1662 static void MapCounterButtons(int id)
1664 MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_down]);
1665 MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_text]);
1666 MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_up]);
1669 static void MapDrawingArea(int id)
1671 MapGadget(level_editor_gadget[id]);
1674 static void MapTextInputGadget(int id)
1676 MapGadget(level_editor_gadget[textinput_info[id].gadget_id]);
1679 static void MapRadiobuttonGadget(int id)
1681 MapGadget(level_editor_gadget[radiobutton_info[id].gadget_id]);
1684 static void MapCheckbuttonGadget(int id)
1686 MapGadget(level_editor_gadget[checkbutton_info[id].gadget_id]);
1689 static void MapMainDrawingArea()
1691 boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
1692 boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy);
1695 for (i=0; i<ED_NUM_SCROLLBUTTONS; i++)
1697 if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT ||
1698 i == ED_SCROLLBUTTON_ID_AREA_RIGHT) &&
1699 no_horizontal_scrollbar) ||
1700 ((i == ED_SCROLLBUTTON_ID_AREA_UP ||
1701 i == ED_SCROLLBUTTON_ID_AREA_DOWN) &&
1702 no_vertical_scrollbar))
1705 MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
1708 for (i=0; i<ED_NUM_SCROLLBARS; i++)
1710 if ((i == ED_SCROLLBAR_ID_HORIZONTAL && no_horizontal_scrollbar) ||
1711 (i == ED_SCROLLBAR_ID_VERTICAL && no_vertical_scrollbar))
1714 MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
1717 MapDrawingArea(GADGET_ID_DRAWING_LEVEL);
1720 static void UnmapDrawingArea(int id)
1722 UnmapGadget(level_editor_gadget[id]);
1725 void UnmapLevelEditorWindowGadgets()
1729 for (i=0; i<NUM_EDITOR_GADGETS; i++)
1730 if (level_editor_gadget[i]->x < DX)
1731 UnmapGadget(level_editor_gadget[i]);
1734 void UnmapLevelEditorGadgets()
1738 for (i=0; i<NUM_EDITOR_GADGETS; i++)
1739 UnmapGadget(level_editor_gadget[i]);
1744 int i, x, y, graphic;
1746 edit_mode = ED_MODE_DRAWING;
1748 CloseDoor(DOOR_CLOSE_ALL);
1750 OpenDoor(DOOR_OPEN_2 | DOOR_NO_DELAY);
1752 if (level_editor_test_game)
1754 for(x=0; x<lev_fieldx; x++)
1755 for(y=0; y<lev_fieldy; y++)
1756 Feld[x][y] = Ur[x][y];
1758 for(x=0; x<lev_fieldx; x++)
1759 for(y=0; y<lev_fieldy; y++)
1760 Ur[x][y] = FieldBackup[x][y];
1762 level_editor_test_game = FALSE;
1768 undo_buffer_position = -1;
1769 undo_buffer_steps = -1;
1770 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
1774 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
1778 XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
1779 DOOR_GFX_PAGEX6,DOOR_GFX_PAGEY1,
1781 DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1);
1782 XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
1783 DOOR_GFX_PAGEX6+ED_BUTTON_ELEM_XPOS,
1784 DOOR_GFX_PAGEY1+ED_BUTTON_ELEM_YPOS,
1785 4*ED_BUTTON_ELEM_XSIZE,5*ED_BUTTON_ELEM_YSIZE,
1786 DOOR_GFX_PAGEX1+ED_BUTTON_ELEM_XPOS,
1787 DOOR_GFX_PAGEY1+ED_BUTTON_EUP_Y2POS);
1789 for(i=0;i<MAX_ELEM_X*MAX_ELEM_Y;i++)
1791 if (i < elements_in_list)
1792 graphic = el2gfx(editor_element[i + element_shift]);
1794 graphic = GFX_LEERRAUM;
1796 DrawMiniGraphicExt(pix[PIX_DB_DOOR],gc,
1797 DOOR_GFX_PAGEX1+ED_BUTTON_ELEM_XPOS+3 +
1798 (i%MAX_ELEM_X)*ED_BUTTON_ELEM_XSIZE,
1799 DOOR_GFX_PAGEY1+ED_BUTTON_ELEM_YPOS+3 +
1800 (i/MAX_ELEM_X)*ED_BUTTON_ELEM_YSIZE,
1804 DrawMiniGraphicExt(pix[PIX_DB_DOOR],gc,
1805 DOOR_GFX_PAGEX1+ED_WIN_MB_LEFT_XPOS,
1806 DOOR_GFX_PAGEY1+ED_WIN_MB_LEFT_YPOS,
1807 el2gfx(new_element1));
1808 DrawMiniGraphicExt(pix[PIX_DB_DOOR],gc,
1809 DOOR_GFX_PAGEX1+ED_WIN_MB_MIDDLE_XPOS,
1810 DOOR_GFX_PAGEY1+ED_WIN_MB_MIDDLE_YPOS,
1811 el2gfx(new_element2));
1812 DrawMiniGraphicExt(pix[PIX_DB_DOOR],gc,
1813 DOOR_GFX_PAGEX1+ED_WIN_MB_RIGHT_XPOS,
1814 DOOR_GFX_PAGEY1+ED_WIN_MB_RIGHT_YPOS,
1815 el2gfx(new_element3));
1816 DrawTextExt(pix[PIX_DB_DOOR],gc,
1817 DOOR_GFX_PAGEX2+ED_WIN_LEVELNR_XPOS,
1818 DOOR_GFX_PAGEY1+ED_WIN_LEVELNR_YPOS,
1819 int2str(level_nr,2),FS_SMALL,FC_SPECIAL1);
1820 XCopyArea(display,pix[PIX_DB_DOOR],pix[PIX_DB_DOOR],gc,
1821 DOOR_GFX_PAGEX2+ED_WIN_LEVELNR_XPOS+3,
1822 DOOR_GFX_PAGEY1+ED_WIN_LEVELNR_YPOS,
1824 DOOR_GFX_PAGEX1+ED_WIN_LEVELNR_XPOS,
1825 DOOR_GFX_PAGEY1+ED_WIN_LEVELNR_YPOS);
1826 XCopyArea(display,pix[PIX_DB_DOOR],pix[PIX_DB_DOOR],gc,
1827 DOOR_GFX_PAGEX2+ED_WIN_LEVELNR_XPOS+14,
1828 DOOR_GFX_PAGEY1+ED_WIN_LEVELNR_YPOS,
1830 DOOR_GFX_PAGEX1+ED_WIN_LEVELNR_XPOS+9,
1831 DOOR_GFX_PAGEY1+ED_WIN_LEVELNR_YPOS);
1833 XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
1834 DOOR_GFX_PAGEX6,DOOR_GFX_PAGEY2,
1836 DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2);
1838 /* draw bigger door */
1839 XCopyArea(display, pix[PIX_DOOR], drawto, gc,
1844 /* draw new control window */
1845 XCopyArea(display, pix[PIX_DOOR], drawto, gc,
1846 DOOR_GFX_PAGEX8, 236,
1850 redraw_mask |= REDRAW_ALL;
1852 OpenDoor(DOOR_OPEN_1);
1854 strcpy(level_editor_gadget[GADGET_ID_LEVEL_NAME]->text.value, level.name);
1856 MapControlButtons();
1859 MapMainDrawingArea();
1862 DrawDrawingWindow();
1866 OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2);
1870 static void AdjustDrawingAreaGadgets()
1872 int ed_xsize = lev_fieldx + 2;
1873 int ed_ysize = lev_fieldy + 2;
1874 int max_ed_fieldx = MAX_ED_FIELDX;
1875 int max_ed_fieldy = MAX_ED_FIELDY;
1876 boolean horizontal_scrollbar_needed;
1877 boolean vertical_scrollbar_needed;
1878 int x, y, width, height;
1879 int xoffset, yoffset;
1881 /* check if we need any scrollbars */
1882 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
1883 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
1885 /* check if we have a smaller editor field because of scrollbars */
1886 if (horizontal_scrollbar_needed)
1887 max_ed_fieldy = MAX_ED_FIELDY - 1;
1888 if (vertical_scrollbar_needed)
1889 max_ed_fieldx = MAX_ED_FIELDX - 1;
1891 /* check again if we now need more scrollbars because of less space */
1892 horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
1893 vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
1895 /* check if editor field gets even smaller after adding new scrollbars */
1896 if (horizontal_scrollbar_needed)
1897 max_ed_fieldy = MAX_ED_FIELDY - 1;
1898 if (vertical_scrollbar_needed)
1899 max_ed_fieldx = MAX_ED_FIELDX - 1;
1901 ed_fieldx = (ed_xsize < MAX_ED_FIELDX ? ed_xsize : max_ed_fieldx);
1902 ed_fieldy = (ed_ysize < MAX_ED_FIELDY ? ed_ysize : max_ed_fieldy);
1904 ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL],
1905 GDI_WIDTH, ed_fieldx * MINI_TILEX,
1906 GDI_HEIGHT, ed_fieldy * MINI_TILEY,
1907 GDI_AREA_SIZE, ed_fieldx, ed_fieldy,
1910 xoffset = (ed_fieldx == MAX_ED_FIELDX ? ED_SCROLLBUTTON_XSIZE : 0);
1911 yoffset = (ed_fieldy == MAX_ED_FIELDY ? ED_SCROLLBUTTON_YSIZE : 0);
1913 x = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x + xoffset;
1914 y = SX + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y + yoffset;
1916 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT], GDI_X, x, GDI_END);
1917 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN], GDI_Y, y, GDI_END);
1919 width = scrollbar_info[ED_SCROLLBAR_ID_HORIZONTAL].width + xoffset;
1920 height = scrollbar_info[ED_SCROLLBAR_ID_VERTICAL].height + yoffset;
1922 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
1924 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
1926 ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
1928 GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
1932 static void AdjustLevelScrollPosition()
1934 if (level_xpos < -1)
1936 if (level_xpos > lev_fieldx - ed_fieldx + 1)
1937 level_xpos = lev_fieldx - ed_fieldx + 1;
1938 if (lev_fieldx < ed_fieldx - 2)
1941 if (level_ypos < -1)
1943 if (level_ypos > lev_fieldy - ed_fieldy + 1)
1944 level_ypos = lev_fieldy - ed_fieldy + 1;
1945 if (lev_fieldy < ed_fieldy - 2)
1949 static void AdjustEditorScrollbar(int id)
1951 struct GadgetInfo *gi = level_editor_gadget[id];
1952 int items_max, items_visible, item_position;
1954 if (id == GADGET_ID_SCROLL_HORIZONTAL)
1956 items_max = MAX(lev_fieldx + 2, ed_fieldx);
1957 items_visible = ed_fieldx;
1958 item_position = level_xpos + 1;
1962 items_max = MAX(lev_fieldy + 2, ed_fieldy);
1963 items_visible = ed_fieldy;
1964 item_position = level_ypos + 1;
1967 if (item_position > items_max - items_visible)
1968 item_position = items_max - items_visible;
1970 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
1971 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
1974 static void ModifyEditorTextInput(int textinput_id, char *new_text)
1976 int gadget_id = textinput_info[textinput_id].gadget_id;
1977 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
1979 ModifyGadget(gi, GDI_TEXT_VALUE, new_text, GDI_END);
1982 static void ModifyEditorCounter(int counter_id, int new_value)
1984 int *counter_value = *counterbutton_info[counter_id].counter_value;
1985 int gadget_id = counterbutton_info[counter_id].gadget_id_text;
1986 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
1988 ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
1990 if (counter_value != NULL)
1991 *counter_value = gi->text.number_value;
1994 static void PickDrawingElement(int button, int element)
1996 if (button < 1 || button > 3)
2001 new_element1 = element;
2002 DrawMiniGraphicExt(drawto, gc,
2003 DX + ED_WIN_MB_LEFT_XPOS,
2004 DY + ED_WIN_MB_LEFT_YPOS,
2005 el2gfx(new_element1));
2007 else if (button == 2)
2009 new_element2 = element;
2010 DrawMiniGraphicExt(drawto, gc,
2011 DX + ED_WIN_MB_MIDDLE_XPOS,
2012 DY + ED_WIN_MB_MIDDLE_YPOS,
2013 el2gfx(new_element2));
2017 new_element3 = element;
2018 DrawMiniGraphicExt(drawto, gc,
2019 DX + ED_WIN_MB_RIGHT_XPOS,
2020 DY + ED_WIN_MB_RIGHT_YPOS,
2021 el2gfx(new_element3));
2024 redraw_mask |= REDRAW_DOOR_1;
2027 static void DrawDrawingWindow()
2030 UnmapLevelEditorWindowGadgets();
2031 AdjustDrawingAreaGadgets();
2032 AdjustLevelScrollPosition();
2033 AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
2034 AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
2035 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
2036 MapMainDrawingArea();
2039 static void DrawRandomPlacementBackgroundArea()
2041 int area_x = ED_AREA_RANDOM_BACKGROUND_XPOS / MINI_TILEX;
2042 int area_y = ED_AREA_RANDOM_BACKGROUND_YPOS / MINI_TILEY;
2043 int area_sx = SX + ED_AREA_RANDOM_BACKGROUND_XPOS;
2044 int area_sy = SY + ED_AREA_RANDOM_BACKGROUND_YPOS;
2047 ElementContent[0][0][0] = random_placement_background_element;
2049 /* draw decorative border for the object */
2052 DrawMiniElement(area_x + x, area_y + y, EL_ERDREICH);
2054 XFillRectangle(display, drawto, gc,
2055 area_sx + MINI_TILEX/2 - 1, area_sy + MINI_TILEY/2 - 1,
2056 MINI_TILEX + 2, MINI_TILEY + 2);
2058 /* copy border to the right location */
2059 XCopyArea(display, drawto, drawto, gc,
2060 area_sx, area_sy, 3 * MINI_TILEX, 3 * MINI_TILEY,
2061 area_sx - MINI_TILEX/2, area_sy - MINI_TILEY/2);
2063 DrawMiniElement(area_x, area_y, ElementContent[0][0][0]);
2065 MapDrawingArea(GADGET_ID_RANDOM_BACKGROUND);
2068 static void DrawLevelInfoWindow()
2070 char infotext[1024];
2071 int xoffset_above = 0;
2072 int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
2073 int xoffset_right = counter_xsize;
2074 int yoffset_right = ED_BORDER_SIZE;
2075 int xoffset_right2 = ED_CHECKBUTTON_XSIZE + 2 * ED_GADGET_DISTANCE;
2076 int yoffset_right2 = ED_BORDER_SIZE;
2077 int font_color = FC_GREEN;
2081 UnmapLevelEditorWindowGadgets();
2083 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS_YPOS,
2084 "Level Settings", FS_BIG, FC_YELLOW);
2085 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS2_YPOS,
2086 "Editor Settings", FS_BIG, FC_YELLOW);
2088 gadget_level_xsize_value = &lev_fieldx;
2089 gadget_level_ysize_value = &lev_fieldy;
2090 gadget_level_random_value = &random_placement_value;
2091 gadget_level_collect_value = &level.edelsteine;
2092 gadget_level_timelimit_value = &level.time;
2093 gadget_level_timescore_value = &level.score[10];
2095 /* draw counter gadgets */
2096 for (i=ED_COUNTER_ID_LEVEL_FIRST; i<=ED_COUNTER_ID_LEVEL_LAST; i++)
2098 if (counterbutton_info[i].infotext_above)
2100 x = counterbutton_info[i].x + xoffset_above;
2101 y = counterbutton_info[i].y + yoffset_above;
2103 sprintf(infotext, "%s:", counterbutton_info[i].infotext_above);
2104 infotext[MAX_INFOTEXT_LEN] = '\0';
2105 DrawTextF(x, y, font_color, infotext);
2108 if (counterbutton_info[i].infotext_right)
2110 x = counterbutton_info[i].x + xoffset_right;
2111 y = counterbutton_info[i].y + yoffset_right;
2113 sprintf(infotext, "%s", counterbutton_info[i].infotext_right);
2114 infotext[MAX_INFOTEXT_LEN] = '\0';
2115 DrawTextF(x, y, font_color, infotext);
2118 ModifyEditorCounter(i, **counterbutton_info[i].counter_value);
2119 MapCounterButtons(i);
2122 /* draw text input gadgets */
2123 for (i=ED_TEXTINPUT_ID_LEVEL_FIRST; i<=ED_TEXTINPUT_ID_LEVEL_LAST; i++)
2125 x = textinput_info[i].x + xoffset_above;
2126 y = textinput_info[i].y + yoffset_above;
2128 sprintf(infotext, "%s:", textinput_info[i].infotext);
2129 infotext[MAX_INFOTEXT_LEN] = '\0';
2131 DrawTextF(x, y, font_color, infotext);
2132 ModifyEditorTextInput(i, textinput_info[i].value);
2133 MapTextInputGadget(i);
2136 /* draw radiobutton gadgets */
2137 for (i=ED_RADIOBUTTON_ID_LEVEL_FIRST; i<=ED_RADIOBUTTON_ID_LEVEL_LAST; i++)
2140 (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
2142 x = radiobutton_info[i].x + xoffset_right2;
2143 y = radiobutton_info[i].y + yoffset_right2;
2145 DrawTextF(x, y, font_color, radiobutton_info[i].text);
2146 ModifyGadget(level_editor_gadget[radiobutton_info[i].gadget_id],
2147 GDI_CHECKED, checked, GDI_END);
2148 MapRadiobuttonGadget(i);
2151 /* draw checkbutton gadgets */
2152 for (i=ED_CHECKBUTTON_ID_LEVEL_FIRST; i<=ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
2154 x = checkbutton_info[i].x + xoffset_right2;
2155 y = checkbutton_info[i].y + yoffset_right2;
2157 DrawTextF(x, y, font_color, checkbutton_info[i].text);
2158 ModifyGadget(level_editor_gadget[checkbutton_info[i].gadget_id],
2159 GDI_CHECKED, *checkbutton_info[i].value, GDI_END);
2160 MapCheckbuttonGadget(i);
2163 /* draw drawing area */
2164 DrawRandomPlacementBackgroundArea();
2167 static void DrawAmoebaContentArea()
2169 int area_x = ED_AREA_ELEM_CONTENT_XPOS / MINI_TILEX;
2170 int area_y = ED_AREA_ELEM_CONTENT_YPOS / MINI_TILEY;
2171 int area_sx = SX + ED_AREA_ELEM_CONTENT_XPOS;
2172 int area_sy = SY + ED_AREA_ELEM_CONTENT_YPOS;
2173 int font_color = FC_GREEN;
2176 ElementContent[0][0][0] = level.amoebe_inhalt;
2178 /* draw decorative border for the object */
2181 DrawMiniElement(area_x + x, area_y + y, EL_ERDREICH);
2183 XFillRectangle(display, drawto, gc,
2184 area_sx + MINI_TILEX/2 - 1, area_sy + MINI_TILEY/2 - 1,
2185 MINI_TILEX + 2, MINI_TILEY + 2);
2187 /* copy border to the right location */
2188 XCopyArea(display, drawto, drawto, gc,
2189 area_sx, area_sy, 3 * MINI_TILEX, 3 * MINI_TILEY,
2190 area_sx - MINI_TILEX/2, area_sy - MINI_TILEY/2);
2192 DrawText(area_sx + TILEX, area_sy + 1, "Content of amoeba",
2193 FS_SMALL, font_color);
2195 DrawMiniElement(area_x, area_y, ElementContent[0][0][0]);
2197 MapDrawingArea(GADGET_ID_AMOEBA_CONTENT);
2200 static void DrawElementContentAreas()
2202 int *num_areas = &MampferMax;
2203 int area_x = ED_AREA_ELEM_CONTENT_XPOS / MINI_TILEX;
2204 int area_y = ED_AREA_ELEM_CONTENT_YPOS / MINI_TILEY;
2205 int area_sx = SX + ED_AREA_ELEM_CONTENT_XPOS;
2206 int area_sy = SY + ED_AREA_ELEM_CONTENT_YPOS;
2207 int xoffset_right = counter_xsize;
2208 int yoffset_right = ED_BORDER_SIZE;
2209 int font_color = FC_GREEN;
2212 for (i=0; i<MAX_ELEM_CONTENT; i++)
2215 ElementContent[i][x][y] = level.mampfer_inhalt[i][x][y];
2217 for (i=0; i<MAX_ELEM_CONTENT; i++)
2218 UnmapDrawingArea(GADGET_ID_ELEM_CONTENT_0 + i);
2220 /* display counter to choose number of element content areas */
2221 gadget_elem_content_value = num_areas;
2223 x = counterbutton_info[ED_COUNTER_ID_ELEM_CONTENT].x + xoffset_right;
2224 y = counterbutton_info[ED_COUNTER_ID_ELEM_CONTENT].y + yoffset_right;
2225 DrawTextF(x, y, font_color, "number of content areas");
2226 ModifyEditorCounter(ED_COUNTER_ID_ELEM_CONTENT, *gadget_elem_content_value);
2227 MapCounterButtons(ED_COUNTER_ID_ELEM_CONTENT);
2229 /* delete content areas in case of reducing number of them */
2230 XFillRectangle(display, backbuffer, gc,
2231 SX, area_sy - MINI_TILEX,
2232 SXSIZE, 12 * MINI_TILEY);
2234 /* draw some decorative border for the objects */
2235 for (i=0; i<*num_areas; i++)
2239 DrawMiniElement(area_x + 5 * (i % 4) + x, area_y + 6 * (i / 4) + y,
2242 XFillRectangle(display, drawto, gc,
2243 area_sx + 5 * (i % 4) * MINI_TILEX + MINI_TILEX/2 - 1,
2244 area_sy + 6 * (i / 4) * MINI_TILEY + MINI_TILEY/2 - 1,
2245 3 * MINI_TILEX + 2, 3 * MINI_TILEY + 2);
2248 /* copy border to the right location */
2249 XCopyArea(display, drawto, drawto, gc,
2250 area_sx, area_sy, (5 * 4 + 1) * MINI_TILEX, 11 * MINI_TILEY,
2251 area_sx - MINI_TILEX/2, area_sy - MINI_TILEY/2);
2253 DrawText(area_sx + (5 * 4 - 1) * MINI_TILEX, area_sy + 0 * MINI_TILEY + 1,
2254 "Content", FS_SMALL, font_color);
2255 DrawText(area_sx + (5 * 4 - 1) * MINI_TILEX, area_sy + 1 * MINI_TILEY + 1,
2256 "when", FS_SMALL, font_color);
2257 DrawText(area_sx + (5 * 4 - 1) * MINI_TILEX, area_sy + 2 * MINI_TILEY + 1,
2258 "smashed", FS_SMALL, font_color);
2260 for (i=0; i<*num_areas; i++)
2264 DrawMiniElement(area_x + 5 * (i % 4) + x, area_y + 6 * (i / 4) + y,
2265 ElementContent[i][x][y]);
2267 DrawTextF(area_sx - SX + 5 * (i % 4) * MINI_TILEX + MINI_TILEX + 1,
2268 area_sy - SY + 6 * (i / 4) * MINI_TILEY + 4 * MINI_TILEY - 4,
2269 font_color, "%d", i + 1);
2272 for (i=0; i<*num_areas; i++)
2273 MapDrawingArea(GADGET_ID_ELEM_CONTENT_0 + i);
2276 #define TEXT_COLLECTING "Score for collecting"
2277 #define TEXT_SMASHING "Score for smashing"
2278 #define TEXT_CRACKING "Score for cracking"
2279 #define TEXT_SPEED "Speed of amoeba growth"
2280 #define TEXT_DURATION "Duration when activated"
2282 static void DrawPropertiesWindow()
2284 int num_elements_in_level;
2286 int xoffset_right = counter_xsize;
2287 int yoffset_right = ED_BORDER_SIZE;
2288 int xoffset_right2 = ED_CHECKBUTTON_XSIZE + 2 * ED_GADGET_DISTANCE;
2289 int yoffset_right2 = ED_BORDER_SIZE;
2292 int font_color = FC_GREEN;
2299 } elements_with_counter[] =
2301 { EL_EDELSTEIN, &level.score[0], TEXT_COLLECTING },
2302 { EL_EDELSTEIN_BD, &level.score[0], TEXT_COLLECTING },
2303 { EL_EDELSTEIN_GELB,&level.score[0], TEXT_COLLECTING },
2304 { EL_EDELSTEIN_ROT, &level.score[0], TEXT_COLLECTING },
2305 { EL_EDELSTEIN_LILA,&level.score[0], TEXT_COLLECTING },
2306 { EL_DIAMANT, &level.score[1], TEXT_COLLECTING },
2307 { EL_KAEFER_R, &level.score[2], TEXT_SMASHING },
2308 { EL_KAEFER_O, &level.score[2], TEXT_SMASHING },
2309 { EL_KAEFER_L, &level.score[2], TEXT_SMASHING },
2310 { EL_KAEFER_U, &level.score[2], TEXT_SMASHING },
2311 { EL_BUTTERFLY_R, &level.score[2], TEXT_SMASHING },
2312 { EL_BUTTERFLY_O, &level.score[2], TEXT_SMASHING },
2313 { EL_BUTTERFLY_L, &level.score[2], TEXT_SMASHING },
2314 { EL_BUTTERFLY_U, &level.score[2], TEXT_SMASHING },
2315 { EL_FLIEGER_R, &level.score[3], TEXT_SMASHING },
2316 { EL_FLIEGER_O, &level.score[3], TEXT_SMASHING },
2317 { EL_FLIEGER_L, &level.score[3], TEXT_SMASHING },
2318 { EL_FLIEGER_U, &level.score[3], TEXT_SMASHING },
2319 { EL_FIREFLY_R, &level.score[3], TEXT_SMASHING },
2320 { EL_FIREFLY_O, &level.score[3], TEXT_SMASHING },
2321 { EL_FIREFLY_L, &level.score[3], TEXT_SMASHING },
2322 { EL_FIREFLY_U, &level.score[3], TEXT_SMASHING },
2323 { EL_MAMPFER, &level.score[4], TEXT_SMASHING },
2324 { EL_MAMPFER2, &level.score[4], TEXT_SMASHING },
2325 { EL_ROBOT, &level.score[5], TEXT_SMASHING },
2326 { EL_PACMAN_R, &level.score[6], TEXT_SMASHING },
2327 { EL_PACMAN_O, &level.score[6], TEXT_SMASHING },
2328 { EL_PACMAN_L, &level.score[6], TEXT_SMASHING },
2329 { EL_PACMAN_U, &level.score[6], TEXT_SMASHING },
2330 { EL_KOKOSNUSS, &level.score[7], TEXT_CRACKING },
2331 { EL_DYNAMIT_AUS, &level.score[8], TEXT_COLLECTING },
2332 { EL_SCHLUESSEL1, &level.score[9], TEXT_COLLECTING },
2333 { EL_SCHLUESSEL2, &level.score[9], TEXT_COLLECTING },
2334 { EL_SCHLUESSEL3, &level.score[9], TEXT_COLLECTING },
2335 { EL_SCHLUESSEL4, &level.score[9], TEXT_COLLECTING },
2336 { EL_EM_KEY_1_FILE, &level.score[9], TEXT_COLLECTING },
2337 { EL_EM_KEY_2_FILE, &level.score[9], TEXT_COLLECTING },
2338 { EL_EM_KEY_3_FILE, &level.score[9], TEXT_COLLECTING },
2339 { EL_EM_KEY_4_FILE, &level.score[9], TEXT_COLLECTING },
2340 { EL_AMOEBE_NASS, &level.tempo_amoebe, TEXT_SPEED },
2341 { EL_AMOEBE_NORM, &level.tempo_amoebe, TEXT_SPEED },
2342 { EL_AMOEBE_VOLL, &level.tempo_amoebe, TEXT_SPEED },
2343 { EL_AMOEBE_BD, &level.tempo_amoebe, TEXT_SPEED },
2344 { EL_SIEB_INAKTIV, &level.dauer_sieb, TEXT_DURATION },
2345 { EL_ABLENK_AUS, &level.dauer_ablenk, TEXT_DURATION },
2350 UnmapLevelEditorWindowGadgets();
2352 DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS_YPOS,
2353 "Element Settings", FS_BIG, FC_YELLOW);
2355 /* draw some decorative border for the object */
2358 DrawMiniElement(xstart + x , ystart + y, EL_ERDREICH);
2360 XFillRectangle(display, drawto, gc,
2361 SX + xstart * MINI_TILEX + MINI_TILEX/2 - 1,
2362 SY + ystart * MINI_TILEY + MINI_TILEY/2 - 1,
2363 TILEX + 2, TILEY + 2);
2365 /* copy border to the right location */
2366 XCopyArea(display, drawto, drawto, gc,
2367 SX + xstart * MINI_TILEX,
2368 SY + ystart * MINI_TILEY,
2369 2 * TILEX, 2 * TILEY,
2370 SX + xstart * MINI_TILEX - MINI_TILEX/2,
2371 SY + ystart * MINI_TILEY - MINI_TILEY/2);
2373 DrawGraphic(xstart/2, ystart/2, el2gfx(properties_element));
2375 /* copy the whole stuff to the definitive location */
2376 XCopyArea(display, drawto, drawto, gc,
2377 SX + xstart * MINI_TILEX - MINI_TILEX/2,
2378 SY + ystart * MINI_TILEY - MINI_TILEY,
2379 2 * TILEX, 2 * TILEY,
2380 SX + xstart * MINI_TILEX - MINI_TILEX/2,
2381 SY + ystart * MINI_TILEY - MINI_TILEY/2);
2383 DrawTextF((xstart + 3) * MINI_TILEX, (ystart + 1) * MINI_TILEY,
2384 font_color, element_info[properties_element]);
2386 num_elements_in_level = 0;
2387 for (y=0; y<lev_fieldy; y++)
2388 for (x=0; x<lev_fieldx; x++)
2389 if (Feld[x][y] == properties_element)
2390 num_elements_in_level++;
2391 percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
2393 DrawTextF(ED_SETTINGS_XPOS, 5 * TILEY, font_color, "In this level:");
2394 DrawTextF(ED_SETTINGS_XPOS + 15 * FONT2_XSIZE, 5 * TILEY, FC_YELLOW,
2395 "%d (%.2f%%)", num_elements_in_level, percentage);
2397 /* check if there are elements where a score can be chosen for */
2398 for (i=0; elements_with_counter[i].element != -1; i++)
2400 if (elements_with_counter[i].element == properties_element)
2402 int x = counterbutton_info[ED_COUNTER_ID_ELEM_SCORE].x + xoffset_right;
2403 int y = counterbutton_info[ED_COUNTER_ID_ELEM_SCORE].y + yoffset_right;
2405 gadget_elem_score_value = elements_with_counter[i].counter_value;
2407 DrawTextF(x, y, font_color, elements_with_counter[i].text);
2408 ModifyEditorCounter(ED_COUNTER_ID_ELEM_SCORE, *gadget_elem_score_value);
2409 MapCounterButtons(ED_COUNTER_ID_ELEM_SCORE);
2414 if (HAS_CONTENT(properties_element))
2418 /* draw stickybutton gadget */
2419 i = ED_CHECKBUTTON_ID_STICK_ELEMENT;
2420 x = checkbutton_info[i].x + xoffset_right2;
2421 y = checkbutton_info[i].y + yoffset_right2;
2423 DrawTextF(x, y, font_color, checkbutton_info[i].text);
2424 ModifyGadget(level_editor_gadget[checkbutton_info[i].gadget_id],
2425 GDI_CHECKED, *checkbutton_info[i].value, GDI_END);
2426 MapCheckbuttonGadget(i);
2430 if (IS_AMOEBOID(properties_element))
2431 DrawAmoebaContentArea();
2433 DrawElementContentAreas();
2437 static void swap_numbers(int *i1, int *i2)
2445 static void swap_number_pairs(int *x1, int *y1, int *x2, int *y2)
2457 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
2459 int lx = sx + level_xpos;
2460 int ly = sy + level_ypos;
2462 DrawMiniElement(sx, sy, (element < 0 ? Feld[lx][ly] : element));
2465 Feld[lx][ly] = element;
2468 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
2469 int element, boolean change_level)
2471 if (from_y == to_y) /* horizontal line */
2477 swap_numbers(&from_x, &to_x);
2479 for (x=from_x; x<=to_x; x++)
2480 DrawLineElement(x, y, element, change_level);
2482 else if (from_x == to_x) /* vertical line */
2488 swap_numbers(&from_y, &to_y);
2490 for (y=from_y; y<=to_y; y++)
2491 DrawLineElement(x, y, element, change_level);
2493 else /* diagonal line */
2495 int len_x = ABS(to_x - from_x);
2496 int len_y = ABS(to_y - from_y);
2499 if (len_y < len_x) /* a < 1 */
2501 float a = (float)len_y / (float)len_x;
2504 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
2506 for (x=0; x<=len_x; x++)
2508 y = (int)(a * x + 0.5) * (to_y < from_y ? -1 : +1);
2509 DrawLineElement(from_x + x, from_y + y, element, change_level);
2514 float a = (float)len_x / (float)len_y;
2517 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
2519 for (y=0; y<=len_y; y++)
2521 x = (int)(a * y + 0.5) * (to_x < from_x ? -1 : +1);
2522 DrawLineElement(from_x + x, from_y + y, element, change_level);
2528 static void DrawRectangle(int from_x, int from_y, int to_x, int to_y,
2529 int element, boolean change_level)
2531 DrawLine(from_x, from_y, from_x, to_y, element, change_level);
2532 DrawLine(from_x, to_y, to_x, to_y, element, change_level);
2533 DrawLine(to_x, to_y, to_x, from_y, element, change_level);
2534 DrawLine(to_x, from_y, from_x, from_y, element, change_level);
2537 static void DrawFilledBox(int from_x, int from_y, int to_x, int to_y,
2538 int element, boolean change_level)
2543 swap_number_pairs(&from_x, &from_y, &to_x, &to_y);
2545 for (y=from_y; y<=to_y; y++)
2546 DrawLine(from_x, y, to_x, y, element, change_level);
2549 static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
2550 int element, boolean change_level)
2552 int to_x = to_x2 - (to_x2 > from_x ? +1 : -1);
2553 int to_y = to_y2 - (to_y2 > from_y ? +1 : -1);
2554 int len_x = ABS(to_x - from_x);
2555 int len_y = ABS(to_y - from_y);
2558 radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
2560 /* not optimal (some points get drawn twice) but simple,
2561 and fast enough for the few points we are drawing */
2563 for (x=0; x<=radius; x++)
2567 y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5);
2569 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
2570 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
2571 lx = sx + level_xpos;
2572 ly = sy + level_ypos;
2574 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
2575 DrawLineElement(sx, sy, element, change_level);
2578 for (y=0; y<=radius; y++)
2582 x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5);
2584 sx = from_x + x * (from_x < to_x2 ? +1 : -1);
2585 sy = from_y + y * (from_y < to_y2 ? +1 : -1);
2586 lx = sx + level_xpos;
2587 ly = sy + level_ypos;
2589 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
2590 DrawLineElement(sx, sy, element, change_level);
2594 static void DrawArc(int from_x, int from_y, int to_x, int to_y,
2595 int element, boolean change_level)
2597 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
2598 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
2600 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
2603 #define DRAW_CIRCLES_BUTTON_AVAILABLE 0
2604 #if DRAW_CIRCLES_BUTTON_AVAILABLE
2605 static void DrawCircle(int from_x, int from_y, int to_x, int to_y,
2606 int element, boolean change_level)
2608 int to_x2 = to_x + (to_x < from_x ? -1 : +1);
2609 int to_y2 = to_y + (to_y > from_y ? +1 : -1);
2610 int mirror_to_x2 = from_x - (to_x2 - from_x);
2611 int mirror_to_y2 = from_y - (to_y2 - from_y);
2613 DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level);
2614 DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level);
2615 DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level);
2616 DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level);
2620 static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
2622 int from_sx, from_sy;
2626 swap_numbers(&from_x, &to_x);
2629 swap_numbers(&from_y, &to_y);
2631 from_sx = SX + from_x * MINI_TILEX;
2632 from_sy = SY + from_y * MINI_TILEY;
2633 to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
2634 to_sy = SY + to_y * MINI_TILEY + MINI_TILEY - 1;
2636 XSetForeground(display, gc, WhitePixel(display, screen));
2638 XDrawLine(display, drawto, gc, from_sx, from_sy, to_sx, from_sy);
2639 XDrawLine(display, drawto, gc, to_sx, from_sy, to_sx, to_sy);
2640 XDrawLine(display, drawto, gc, to_sx, to_sy, from_sx, to_sy);
2641 XDrawLine(display, drawto, gc, from_sx, to_sy, from_sx, from_sy);
2643 XSetForeground(display, gc, BlackPixel(display, screen));
2645 if (from_x == to_x && from_y == to_y)
2646 MarkTileDirty(from_x/2, from_y/2);
2648 redraw_mask |= REDRAW_FIELD;
2651 static void SelectArea(int from_x, int from_y, int to_x, int to_y,
2652 int element, boolean change_level)
2654 if (element == -1 || change_level)
2655 DrawRectangle(from_x, from_y, to_x, to_y, -1, FALSE);
2657 DrawAreaBorder(from_x, from_y, to_x, to_y);
2660 /* values for CopyBrushExt() */
2661 #define CB_AREA_TO_BRUSH 0
2662 #define CB_BRUSH_TO_CURSOR 1
2663 #define CB_BRUSH_TO_LEVEL 2
2664 #define CB_DELETE_OLD_CURSOR 3
2666 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
2667 int button, int mode)
2669 static short brush_buffer[MAX_ED_FIELDX][MAX_ED_FIELDY];
2670 static int brush_width, brush_height;
2671 static int last_cursor_x = -1, last_cursor_y = -1;
2672 static boolean delete_old_brush;
2676 if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
2679 new_element = (button == 1 ? new_element1 :
2680 button == 2 ? new_element2 :
2681 button == 3 ? new_element3 : 0);
2683 if (mode == CB_AREA_TO_BRUSH)
2685 int from_lx, from_ly;
2688 swap_numbers(&from_x, &to_x);
2691 swap_numbers(&from_y, &to_y);
2693 brush_width = to_x - from_x + 1;
2694 brush_height = to_y - from_y + 1;
2696 from_lx = from_x + level_xpos;
2697 from_ly = from_y + level_ypos;
2699 for (y=0; y<brush_height; y++)
2701 for (x=0; x<brush_width; x++)
2703 brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
2706 DrawLineElement(from_x + x, from_y + y, new_element, TRUE);
2711 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
2713 delete_old_brush = FALSE;
2715 else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
2716 mode == CB_BRUSH_TO_LEVEL)
2718 int cursor_x = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_x : from_x);
2719 int cursor_y = (mode == CB_DELETE_OLD_CURSOR ? last_cursor_y : from_y);
2720 int cursor_from_x = cursor_x - brush_width / 2;
2721 int cursor_from_y = cursor_y - brush_height / 2;
2722 int border_from_x = cursor_x, border_from_y = cursor_y;
2723 int border_to_x = cursor_x, border_to_y = cursor_y;
2725 if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
2726 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
2728 if (!IN_ED_FIELD(cursor_x, cursor_y) ||
2729 !IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
2731 delete_old_brush = FALSE;
2735 for (y=0; y<brush_height; y++)
2737 for (x=0; x<brush_width; x++)
2739 int sx = cursor_from_x + x;
2740 int sy = cursor_from_y + y;
2741 int lx = sx + level_xpos;
2742 int ly = sy + level_ypos;
2743 boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
2744 int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
2745 mode == CB_BRUSH_TO_CURSOR || button == 1 ?
2746 brush_buffer[x][y] : new_element);
2748 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
2750 if (sx < border_from_x)
2752 else if (sx > border_to_x)
2754 if (sy < border_from_y)
2756 else if (sy > border_to_y)
2759 DrawLineElement(sx, sy, element, change_level);
2765 printf("%d, %d - %d, %d in level and screen\n",
2766 border_from_x, border_from_y, border_to_x, border_to_y);
2769 if (mode != CB_DELETE_OLD_CURSOR)
2770 DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
2773 if (mode == CB_BRUSH_TO_LEVEL)
2774 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
2777 last_cursor_x = cursor_x;
2778 last_cursor_y = cursor_y;
2779 delete_old_brush = TRUE;
2783 static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
2786 CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
2789 static void CopyBrushToLevel(int x, int y, int button)
2791 CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
2794 static void CopyBrushToCursor(int x, int y)
2796 CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
2799 static void DeleteBrushFromCursor()
2801 CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
2804 static void FloodFill(int from_x, int from_y, int fill_element)
2808 static int check[4][2] = { {-1,0}, {0,-1}, {1,0}, {0,1} };
2809 static int safety = 0;
2811 /* check if starting field still has the desired content */
2812 if (Feld[from_x][from_y] == fill_element)
2817 if (safety > lev_fieldx*lev_fieldy)
2818 Error(ERR_EXIT, "Something went wrong in 'FloodFill()'. Please debug.");
2820 old_element = Feld[from_x][from_y];
2821 Feld[from_x][from_y] = fill_element;
2825 x = from_x + check[i][0];
2826 y = from_y + check[i][1];
2828 if (IN_LEV_FIELD(x,y) && Feld[x][y] == old_element)
2829 FloodFill(x, y, fill_element);
2835 /* values for DrawLevelText() modes */
2837 #define TEXT_SETCURSOR 1
2838 #define TEXT_WRITECHAR 2
2839 #define TEXT_BACKSPACE 3
2840 #define TEXT_NEWLINE 4
2842 #define TEXT_QUERY_TYPING 6
2844 static int DrawLevelText(int sx, int sy, char letter, int mode)
2846 static short delete_buffer[MAX_LEV_FIELDX];
2847 static int start_sx, start_sy;
2848 static int last_sx, last_sy;
2849 static boolean typing = FALSE;
2850 int letter_element = EL_CHAR_ASCII0 + letter;
2853 /* map lower case letters to upper case and convert special characters */
2854 if (letter >= 'a' && letter <= 'z')
2855 letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
2856 else if (letter == 'ä' || letter == 'Ä')
2857 letter_element = EL_CHAR_AE;
2858 else if (letter == 'ö' || letter == 'Ö')
2859 letter_element = EL_CHAR_OE;
2860 else if (letter == 'ü' || letter == 'Ü')
2861 letter_element = EL_CHAR_UE;
2862 else if (letter == '^')
2863 letter_element = EL_CHAR_COPY;
2865 letter_element = EL_CHAR_ASCII0 + letter;
2867 if (mode != TEXT_INIT)
2872 if (mode != TEXT_SETCURSOR)
2878 lx = last_sx + level_xpos;
2879 ly = last_sy + level_ypos;
2886 DrawLevelText(0, 0, 0, TEXT_END);
2889 start_sx = last_sx = sx;
2890 start_sy = last_sy = sy;
2891 DrawLevelText(sx, sy, 0, TEXT_SETCURSOR);
2894 case TEXT_SETCURSOR:
2895 DrawMiniElement(last_sx, last_sy, Feld[lx][ly]);
2896 DrawAreaBorder(sx, sy, sx, sy);
2901 case TEXT_WRITECHAR:
2902 if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
2904 delete_buffer[sx - start_sx] = Feld[lx][ly];
2905 Feld[lx][ly] = letter_element;
2907 if (sx + 1 < ed_fieldx && lx + 1 < lev_fieldx)
2908 DrawLevelText(sx + 1, sy, 0, TEXT_SETCURSOR);
2909 else if (sy + 1 < ed_fieldy && ly + 1 < lev_fieldy)
2910 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
2912 DrawLevelText(0, 0, 0, TEXT_END);
2916 case TEXT_BACKSPACE:
2919 Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
2920 DrawMiniElement(sx - 1, sy, Feld[lx - 1][ly]);
2921 DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
2926 if (sy + 1 < ed_fieldy - 1 && ly + 1 < lev_fieldy - 1)
2927 DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
2929 DrawLevelText(0, 0, 0, TEXT_END);
2933 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
2934 DrawMiniElement(sx, sy, Feld[lx][ly]);
2938 case TEXT_QUERY_TYPING:
2948 static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
2949 int element, boolean change_level)
2951 int lx = sx + level_xpos;
2952 int ly = sy + level_ypos;
2955 DrawMiniElement(sx, sy, Feld[lx][ly]);
2957 DrawAreaBorder(sx, sy, sx, sy);
2960 static void CopyLevelToUndoBuffer(int mode)
2962 static boolean accumulated_undo = FALSE;
2963 boolean new_undo_buffer_position = TRUE;
2964 int last_border_element;
2969 case UNDO_IMMEDIATE:
2970 accumulated_undo = FALSE;
2973 case UNDO_ACCUMULATE:
2974 if (accumulated_undo)
2975 new_undo_buffer_position = FALSE;
2976 accumulated_undo = TRUE;
2983 if (new_undo_buffer_position)
2985 /* new position in undo buffer ring */
2986 undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
2988 if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
2989 undo_buffer_steps++;
2992 for(x=0; x<lev_fieldx; x++)
2993 for(y=0; y<lev_fieldy; y++)
2994 UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
2996 /* check if change of border style was forced by drawing operation */
2997 last_border_element = BorderElement;
2999 if (BorderElement != last_border_element)
3000 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
3004 printf("level saved to undo buffer\n");
3009 static void RandomPlacement(int new_element)
3011 static boolean free_position[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
3012 int num_free_positions;
3017 /* determine number of free positions for the new elements */
3018 /* (maybe this statement should be formatted a bit more readable...) */
3019 num_free_positions = 0;
3020 for (x=0; x<lev_fieldx; x++)
3021 for (y=0; y<lev_fieldy; y++)
3022 if ((free_position[x][y] =
3023 ((random_placement_background_restricted &&
3024 Feld[x][y] == random_placement_background_element) ||
3025 (!random_placement_background_restricted &&
3026 Feld[x][y] != new_element))) == TRUE)
3027 num_free_positions++;
3029 /* determine number of new elements to place there */
3030 num_percentage = num_free_positions * random_placement_value / 100;
3031 num_elements = (random_placement_method == RANDOM_USE_PERCENTAGE ?
3032 num_percentage : random_placement_value);
3034 /* if not more free positions than elements to place, fill whole level */
3035 if (num_elements >= num_free_positions)
3037 for (x=0; x<lev_fieldx; x++)
3038 for (y=0; y<lev_fieldy; y++)
3039 Feld[x][y] = new_element;
3041 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
3042 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
3046 while (num_elements > 0)
3048 x = RND(lev_fieldx);
3049 y = RND(lev_fieldy);
3051 /* don't place element at the same position twice */
3052 if (free_position[x][y])
3054 free_position[x][y] = FALSE;
3055 Feld[x][y] = new_element;
3060 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
3061 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
3064 void WrapLevel(int dx, int dy)
3066 int wrap_dx = lev_fieldx - dx;
3067 int wrap_dy = lev_fieldy - dy;
3070 for(x=0; x<lev_fieldx; x++)
3071 for(y=0; y<lev_fieldy; y++)
3072 FieldBackup[x][y] = Feld[x][y];
3074 for(x=0; x<lev_fieldx; x++)
3075 for(y=0; y<lev_fieldy; y++)
3077 FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
3079 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
3080 CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
3083 static void HandleDrawingAreas(struct GadgetInfo *gi)
3085 static boolean started_inside_drawing_area = FALSE;
3086 int id = gi->custom_id;
3087 boolean button_press_event;
3088 boolean button_release_event;
3089 boolean inside_drawing_area = !gi->event.off_borders;
3090 boolean draw_level = (id == GADGET_ID_DRAWING_LEVEL);
3091 int actual_drawing_function;
3092 int button = gi->event.button;
3093 int new_element = BUTTON_ELEMENT(button);
3094 int sx = gi->event.x, sy = gi->event.y;
3095 int min_sx = 0, min_sy = 0;
3096 int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
3098 int min_lx = 0, min_ly = 0;
3099 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
3102 /* handle info callback for each invocation of action callback */
3103 gi->callback_info(gi);
3106 if (edit_mode != ED_MODE_DRAWING)
3110 button_press_event = (gi->event.type == GD_EVENT_PRESSED);
3111 button_release_event = (gi->event.type == GD_EVENT_RELEASED);
3113 /* make sure to stay inside drawing area boundaries */
3114 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
3115 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
3119 /* get positions inside level field */
3120 lx = sx + level_xpos;
3121 ly = sy + level_ypos;
3123 if (!IN_LEV_FIELD(lx, ly))
3124 inside_drawing_area = FALSE;
3126 /* make sure to stay inside level field boundaries */
3127 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
3128 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
3130 /* correct drawing area positions accordingly */
3131 sx = lx - level_xpos;
3132 sy = ly - level_ypos;
3135 if (button_press_event)
3136 started_inside_drawing_area = inside_drawing_area;
3138 if (!started_inside_drawing_area)
3141 if (!button && !button_release_event)
3146 if (button_release_event)
3151 if (!draw_level && drawing_function != GADGET_ID_SINGLE_ITEMS)
3155 /* automatically switch to 'single item' drawing mode, if needed */
3156 actual_drawing_function =
3157 (draw_level ? drawing_function : GADGET_ID_SINGLE_ITEMS);
3159 switch (actual_drawing_function)
3161 case GADGET_ID_SINGLE_ITEMS:
3164 if (button_release_event)
3166 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
3168 if (edit_mode == ED_MODE_DRAWING && draw_with_brush &&
3169 !inside_drawing_area)
3170 DeleteBrushFromCursor();
3176 if (draw_with_brush)
3178 if (!button_release_event)
3179 CopyBrushToLevel(sx, sy, button);
3181 else if (new_element != Feld[lx][ly])
3183 if (new_element == EL_SPIELFIGUR)
3185 /* remove player at old position */
3186 for(y=0; y<lev_fieldy; y++)
3188 for(x=0; x<lev_fieldx; x++)
3190 if (Feld[x][y] == EL_SPIELFIGUR || Feld[x][y] == EL_SPIELER1)
3192 Feld[x][y] = EL_LEERRAUM;
3193 if (x - level_xpos >= 0 && x - level_xpos < ed_fieldx &&
3194 y - level_ypos >= 0 && y - level_ypos < ed_fieldy)
3195 DrawMiniElement(x - level_xpos, y - level_ypos,
3202 Feld[lx][ly] = new_element;
3203 DrawMiniElement(sx, sy, new_element);
3208 DrawMiniGraphicExt(drawto, gc,
3209 gi->x + sx * MINI_TILEX,
3210 gi->y + sy * MINI_TILEY,
3211 el2gfx(new_element));
3212 DrawMiniGraphicExt(window, gc,
3213 gi->x + sx * MINI_TILEX,
3214 gi->y + sy * MINI_TILEY,
3215 el2gfx(new_element));
3217 if (id == GADGET_ID_AMOEBA_CONTENT)
3218 level.amoebe_inhalt = new_element;
3219 else if (id == GADGET_ID_RANDOM_BACKGROUND)
3220 random_placement_background_element = new_element;
3221 else if (id >= GADGET_ID_ELEM_CONTENT_0 &&
3222 id <= GADGET_ID_ELEM_CONTENT_7)
3223 level.mampfer_inhalt[id - GADGET_ID_ELEM_CONTENT_0][sx][sy] =
3228 case GADGET_ID_CONNECTED_ITEMS:
3230 static int last_sx = -1;
3231 static int last_sy = -1;
3233 if (button_release_event)
3234 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
3238 if (!button_press_event)
3239 DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
3247 case GADGET_ID_LINE:
3249 case GADGET_ID_RECTANGLE:
3250 case GADGET_ID_FILLED_BOX:
3251 case GADGET_ID_GRAB_BRUSH:
3252 case GADGET_ID_TEXT:
3254 static int last_sx = -1;
3255 static int last_sy = -1;
3256 static int start_sx = -1;
3257 static int start_sy = -1;
3258 void (*draw_func)(int, int, int, int, int, boolean);
3260 if (drawing_function == GADGET_ID_LINE)
3261 draw_func = DrawLine;
3262 else if (drawing_function == GADGET_ID_ARC)
3263 draw_func = DrawArc;
3264 else if (drawing_function == GADGET_ID_RECTANGLE)
3265 draw_func = DrawRectangle;
3266 else if (drawing_function == GADGET_ID_FILLED_BOX)
3267 draw_func = DrawFilledBox;
3268 else if (drawing_function == GADGET_ID_GRAB_BRUSH)
3269 draw_func = SelectArea;
3270 else /* (drawing_function == GADGET_ID_TEXT) */
3271 draw_func = SetTextCursor;
3273 if (button_press_event)
3275 draw_func(sx, sy, sx, sy, new_element, FALSE);
3276 start_sx = last_sx = sx;
3277 start_sy = last_sy = sy;
3279 if (drawing_function == GADGET_ID_TEXT)
3280 DrawLevelText(0, 0, 0, TEXT_END);
3282 else if (button_release_event)
3284 draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
3285 if (drawing_function == GADGET_ID_GRAB_BRUSH)
3287 CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
3288 CopyBrushToCursor(sx, sy);
3289 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],MB_LEFT);
3290 draw_with_brush = TRUE;
3292 else if (drawing_function == GADGET_ID_TEXT)
3293 DrawLevelText(sx, sy, 0, TEXT_INIT);
3295 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
3297 else if (last_sx != sx || last_sy != sy)
3299 draw_func(start_sx, start_sy, last_sx, last_sy, -1, FALSE);
3300 draw_func(start_sx, start_sy, sx, sy, new_element, FALSE);
3307 case GADGET_ID_FLOOD_FILL:
3308 if (button_press_event && Feld[lx][ly] != new_element)
3310 FloodFill(lx, ly, new_element);
3311 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
3312 CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
3316 case GADGET_ID_PICK_ELEMENT:
3319 if (button_press_event)
3320 PickDrawingElement(button, Feld[lx][ly]);
3323 if (button_release_event)
3324 ClickOnGadget(level_editor_gadget[last_drawing_function], MB_LEFT);
3326 PickDrawingElement(button, Feld[lx][ly]);
3335 static void HandleCounterButtons(struct GadgetInfo *gi)
3337 int id = gi->custom_id;
3338 int button = gi->event.button;
3339 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3343 case GADGET_ID_ELEM_SCORE_DOWN:
3344 case GADGET_ID_ELEM_SCORE_UP:
3345 step *= (id == GADGET_ID_ELEM_SCORE_DOWN ? -1 : 1);
3346 ModifyEditorCounter(ED_COUNTER_ID_ELEM_SCORE,
3347 *gadget_elem_score_value + step);
3349 case GADGET_ID_ELEM_SCORE_TEXT:
3350 *gadget_elem_score_value = gi->text.number_value;
3353 case GADGET_ID_ELEM_CONTENT_DOWN:
3354 case GADGET_ID_ELEM_CONTENT_UP:
3355 step *= (id == GADGET_ID_ELEM_CONTENT_DOWN ? -1 : 1);
3356 ModifyEditorCounter(ED_COUNTER_ID_ELEM_CONTENT,
3357 *gadget_elem_content_value + step);
3358 DrawElementContentAreas();
3360 case GADGET_ID_ELEM_CONTENT_TEXT:
3361 *gadget_elem_content_value = gi->text.number_value;
3362 DrawElementContentAreas();
3365 case GADGET_ID_LEVEL_XSIZE_DOWN:
3366 case GADGET_ID_LEVEL_XSIZE_UP:
3367 step *= (id == GADGET_ID_LEVEL_XSIZE_DOWN ? -1 : 1);
3368 ModifyEditorCounter(ED_COUNTER_ID_LEVEL_XSIZE,
3369 *gadget_level_xsize_value + step);
3370 level.fieldx = lev_fieldx;
3372 case GADGET_ID_LEVEL_XSIZE_TEXT:
3373 *gadget_level_xsize_value = gi->text.number_value;
3374 level.fieldx = lev_fieldx;
3377 case GADGET_ID_LEVEL_YSIZE_DOWN:
3378 case GADGET_ID_LEVEL_YSIZE_UP:
3379 step *= (id == GADGET_ID_LEVEL_YSIZE_DOWN ? -1 : 1);
3380 ModifyEditorCounter(ED_COUNTER_ID_LEVEL_YSIZE,
3381 *gadget_level_ysize_value + step);
3382 level.fieldy = lev_fieldy;
3384 case GADGET_ID_LEVEL_YSIZE_TEXT:
3385 *gadget_level_ysize_value = gi->text.number_value;
3386 level.fieldy = lev_fieldy;
3389 case GADGET_ID_LEVEL_RANDOM_DOWN:
3390 case GADGET_ID_LEVEL_RANDOM_UP:
3391 step *= (id == GADGET_ID_LEVEL_RANDOM_DOWN ? -1 : 1);
3392 ModifyEditorCounter(ED_COUNTER_ID_LEVEL_RANDOM,
3393 *gadget_level_random_value + step);
3395 case GADGET_ID_LEVEL_RANDOM_TEXT:
3396 *gadget_level_random_value = gi->text.number_value;
3399 case GADGET_ID_LEVEL_COLLECT_DOWN:
3400 case GADGET_ID_LEVEL_COLLECT_UP:
3401 step *= (id == GADGET_ID_LEVEL_COLLECT_DOWN ? -1 : 1);
3402 ModifyEditorCounter(ED_COUNTER_ID_LEVEL_COLLECT,
3403 *gadget_level_collect_value + step);
3405 case GADGET_ID_LEVEL_COLLECT_TEXT:
3406 *gadget_level_collect_value = gi->text.number_value;
3409 case GADGET_ID_LEVEL_TIMELIMIT_DOWN:
3410 case GADGET_ID_LEVEL_TIMELIMIT_UP:
3411 step *= (id == GADGET_ID_LEVEL_TIMELIMIT_DOWN ? -1 : 1);
3412 ModifyEditorCounter(ED_COUNTER_ID_LEVEL_TIMELIMIT,
3413 *gadget_level_timelimit_value + step);
3415 case GADGET_ID_LEVEL_TIMELIMIT_TEXT:
3416 *gadget_level_timelimit_value = gi->text.number_value;
3419 case GADGET_ID_LEVEL_TIMESCORE_DOWN:
3420 case GADGET_ID_LEVEL_TIMESCORE_UP:
3421 step *= (id == GADGET_ID_LEVEL_TIMESCORE_DOWN ? -1 : 1);
3422 ModifyEditorCounter(ED_COUNTER_ID_LEVEL_TIMESCORE,
3423 *gadget_level_timescore_value + step);
3425 case GADGET_ID_LEVEL_TIMESCORE_TEXT:
3426 *gadget_level_timescore_value = gi->text.number_value;
3434 static void HandleTextInputGadgets(struct GadgetInfo *gi)
3436 int id = gi->custom_id;
3440 case GADGET_ID_LEVEL_NAME:
3441 strcpy(level.name, gi->text.value);
3444 case GADGET_ID_LEVEL_AUTHOR:
3445 strcpy(level.author, gi->text.value);
3453 static void HandleControlButtons(struct GadgetInfo *gi)
3455 int id = gi->custom_id;
3456 int button = gi->event.button;
3457 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3458 int new_element = BUTTON_ELEMENT(button);
3459 int player_present = FALSE;
3460 int level_changed = FALSE;
3463 if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
3464 DrawLevelText(0, 0, 0, TEXT_END);
3466 if (id < ED_NUM_CTRL1_BUTTONS && id != GADGET_ID_PROPERTIES &&
3467 edit_mode != ED_MODE_DRAWING)
3469 DrawDrawingWindow();
3470 edit_mode = ED_MODE_DRAWING;
3475 case GADGET_ID_SCROLL_LEFT:
3476 if (level_xpos >= 0)
3478 int gadget_id = GADGET_ID_SCROLL_HORIZONTAL;
3479 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
3481 if (lev_fieldx < ed_fieldx - 2)
3485 if (level_xpos < -1)
3488 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
3490 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
3492 ModifyGadget(gi, GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
3496 case GADGET_ID_SCROLL_RIGHT:
3497 if (level_xpos <= lev_fieldx - ed_fieldx)
3499 int gadget_id = GADGET_ID_SCROLL_HORIZONTAL;
3500 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
3502 if (lev_fieldx < ed_fieldx - 2)
3506 if (level_xpos > lev_fieldx - ed_fieldx + 1)
3507 level_xpos = lev_fieldx - ed_fieldx + 1;
3509 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
3511 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
3513 ModifyGadget(gi, GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
3517 case GADGET_ID_SCROLL_UP:
3518 if (level_ypos >= 0)
3520 int gadget_id = GADGET_ID_SCROLL_VERTICAL;
3521 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
3523 if (lev_fieldy < ed_fieldy - 2)
3527 if (level_ypos < -1)
3530 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
3532 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
3534 ModifyGadget(gi, GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
3538 case GADGET_ID_SCROLL_DOWN:
3539 if (level_ypos <= lev_fieldy - ed_fieldy)
3541 int gadget_id = GADGET_ID_SCROLL_VERTICAL;
3542 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
3544 if (lev_fieldy < ed_fieldy - 2)
3548 if (level_ypos > lev_fieldy - ed_fieldy + 1)
3549 level_ypos = lev_fieldy - ed_fieldy + 1;
3551 ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP);
3553 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
3555 ModifyGadget(gi, GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
3559 case GADGET_ID_SCROLL_HORIZONTAL:
3560 level_xpos = gi->event.item_position - 1;
3561 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
3564 case GADGET_ID_SCROLL_VERTICAL:
3565 level_ypos = gi->event.item_position - 1;
3566 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
3569 case GADGET_ID_ELEMENTLIST_UP:
3570 case GADGET_ID_ELEMENTLIST_DOWN:
3571 step *= (id == GADGET_ID_ELEMENTLIST_UP ? -1 : +1);
3572 element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
3574 if (element_shift < 0)
3576 if (element_shift > elements_in_list - ED_NUM_ELEMENTLIST_BUTTONS)
3577 element_shift = elements_in_list - ED_NUM_ELEMENTLIST_BUTTONS;
3579 for (i=0; i<ED_NUM_ELEMENTLIST_BUTTONS; i++)
3581 int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
3582 struct GadgetInfo *gi = level_editor_gadget[gadget_id];
3583 struct GadgetDesign *gd = &gi->deco.design;
3584 int element = editor_element[element_shift + i];
3587 getMiniGraphicSource(el2gfx(element), &gd->pixmap, &gd->x, &gd->y);
3588 ModifyGadget(gi, GDI_INFO_TEXT, element_info[element], GDI_END);
3593 case GADGET_ID_WRAP_LEFT:
3594 WrapLevel(-step, 0);
3597 case GADGET_ID_WRAP_RIGHT:
3601 case GADGET_ID_WRAP_UP:
3602 WrapLevel(0, -step);
3605 case GADGET_ID_WRAP_DOWN:
3609 case GADGET_ID_SINGLE_ITEMS:
3610 case GADGET_ID_CONNECTED_ITEMS:
3611 case GADGET_ID_LINE:
3613 case GADGET_ID_TEXT:
3614 case GADGET_ID_RECTANGLE:
3615 case GADGET_ID_FILLED_BOX:
3616 case GADGET_ID_FLOOD_FILL:
3617 case GADGET_ID_GRAB_BRUSH:
3618 case GADGET_ID_PICK_ELEMENT:
3619 last_drawing_function = drawing_function;
3620 drawing_function = id;
3621 draw_with_brush = FALSE;
3624 case GADGET_ID_RANDOM_PLACEMENT:
3625 RandomPlacement(new_element);
3628 case GADGET_ID_PROPERTIES:
3629 if (edit_mode != ED_MODE_PROPERTIES)
3631 properties_element = new_element;
3632 DrawPropertiesWindow();
3633 edit_mode = ED_MODE_PROPERTIES;
3637 DrawDrawingWindow();
3638 edit_mode = ED_MODE_DRAWING;
3642 case GADGET_ID_UNDO:
3643 if (undo_buffer_steps == 0)
3645 Request("Undo buffer empty !", REQ_CONFIRM);
3649 undo_buffer_position =
3650 (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
3651 undo_buffer_steps--;
3653 for(x=0; x<lev_fieldx; x++)
3654 for(y=0; y<lev_fieldy; y++)
3655 Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
3656 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos,level_ypos);
3659 case GADGET_ID_INFO:
3660 if (edit_mode != ED_MODE_INFO)
3662 DrawLevelInfoWindow();
3663 edit_mode = ED_MODE_INFO;
3667 DrawDrawingWindow();
3668 edit_mode = ED_MODE_DRAWING;
3672 case GADGET_ID_CLEAR:
3673 for(x=0; x<MAX_LEV_FIELDX; x++)
3674 for(y=0; y<MAX_LEV_FIELDY; y++)
3675 Feld[x][y] = (button == 1 ? EL_LEERRAUM : new_element);
3676 CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
3678 DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
3681 case GADGET_ID_SAVE:
3682 if (leveldir[leveldir_nr].readonly)
3684 Request("This level is read only !", REQ_CONFIRM);
3688 for(y=0; y<lev_fieldy; y++)
3689 for(x=0; x<lev_fieldx; x++)
3690 if (Feld[x][y] != Ur[x][y])
3691 level_changed = TRUE;
3693 if (0 && !level_changed)
3695 Request("Level has not changed !", REQ_CONFIRM);
3699 for(y=0; y<lev_fieldy; y++)
3700 for(x=0; x<lev_fieldx; x++)
3701 if (Feld[x][y] == EL_SPIELFIGUR ||
3702 Feld[x][y] == EL_SPIELER1 ||
3703 Feld[x][y] == EL_SP_MURPHY)
3704 player_present = TRUE;
3706 if (!player_present)
3707 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
3710 if (Request("Save this level and kill the old ?", REQ_ASK))
3712 for(x=0; x<lev_fieldx; x++)
3713 for(y=0; y<lev_fieldy; y++)
3714 Ur[x][y] = Feld[x][y];
3715 SaveLevel(level_nr);
3720 case GADGET_ID_TEST:
3721 for(y=0; y<lev_fieldy; y++)
3722 for(x=0; x<lev_fieldx; x++)
3723 if (Feld[x][y] == EL_SPIELFIGUR ||
3724 Feld[x][y] == EL_SPIELER1 ||
3725 Feld[x][y] == EL_SP_MURPHY)
3726 player_present = TRUE;
3728 if (!player_present)
3729 Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
3732 for(x=0; x<lev_fieldx; x++)
3733 for(y=0; y<lev_fieldy; y++)
3734 FieldBackup[x][y] = Ur[x][y];
3736 for(x=0; x<lev_fieldx; x++)
3737 for(y=0; y<lev_fieldy; y++)
3738 Ur[x][y] = Feld[x][y];
3740 UnmapLevelEditorGadgets();
3742 /* draw smaller door */
3743 XCopyArea(display, pix[PIX_DOOR], drawto, gc,
3744 DOOR_GFX_PAGEX7, 64,
3747 redraw_mask |= REDRAW_ALL;
3749 CloseDoor(DOOR_CLOSE_ALL);
3751 DrawCompleteVideoDisplay();
3753 if (setup.autorecord)
3754 TapeStartRecording();
3756 level_editor_test_game = TRUE;
3757 game_status = PLAYING;
3763 case GADGET_ID_EXIT:
3764 for(y=0; y<lev_fieldy; y++)
3765 for(x=0; x<lev_fieldx; x++)
3766 if (Feld[x][y] != Ur[x][y])
3767 level_changed = TRUE;
3769 if (!level_changed ||
3770 Request("Level has changed! Exit without saving ?",
3771 REQ_ASK | REQ_STAY_OPEN))
3773 CloseDoor(DOOR_CLOSE_1);
3776 CloseDoor(DOOR_CLOSE_ALL);
3779 /* draw smaller door */
3780 XCopyArea(display, pix[PIX_DOOR], drawto, gc,
3781 DOOR_GFX_PAGEX7, 64,
3784 redraw_mask |= REDRAW_ALL;
3786 game_status = MAINMENU;
3791 CloseDoor(DOOR_CLOSE_1);
3792 XCopyArea(display, pix[PIX_DB_DOOR], pix[PIX_DB_DOOR], gc,
3793 DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
3794 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
3795 OpenDoor(DOOR_OPEN_1);
3799 case GADGET_ID_RANDOM_PERCENTAGE:
3800 *radiobutton_info[ED_RADIOBUTTON_ID_PERCENTAGE].value =
3801 radiobutton_info[ED_RADIOBUTTON_ID_PERCENTAGE].checked_value;
3804 case GADGET_ID_RANDOM_QUANTITY:
3805 *radiobutton_info[ED_RADIOBUTTON_ID_QUANTITY].value =
3806 radiobutton_info[ED_RADIOBUTTON_ID_QUANTITY].checked_value;
3809 case GADGET_ID_RANDOM_RESTRICTED:
3810 *checkbutton_info[ED_CHECKBUTTON_ID_RANDOM_RESTRICTED].value ^= TRUE;
3813 case GADGET_ID_DOUBLE_SPEED:
3814 *checkbutton_info[ED_CHECKBUTTON_ID_DOUBLE_SPEED].value ^= TRUE;
3817 case GADGET_ID_STICK_ELEMENT:
3818 *checkbutton_info[ED_CHECKBUTTON_ID_STICK_ELEMENT].value ^= TRUE;
3822 if (id >= GADGET_ID_ELEMENTLIST_FIRST &&
3823 id <= GADGET_ID_ELEMENTLIST_LAST)
3825 int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
3826 int new_element = editor_element[element_position + element_shift];
3828 PickDrawingElement(button, new_element);
3830 if (!HAS_CONTENT(properties_element) ||
3831 !stick_element_properties_window)
3833 properties_element = new_element;
3834 if (edit_mode == ED_MODE_PROPERTIES)
3835 DrawPropertiesWindow();
3838 if (drawing_function == GADGET_ID_PICK_ELEMENT)
3839 ClickOnGadget(level_editor_gadget[last_drawing_function], MB_LEFT);
3842 else if (gi->event.type == GD_EVENT_PRESSED)
3843 printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id);
3844 else if (gi->event.type == GD_EVENT_RELEASED)
3845 printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id);
3846 else if (gi->event.type == GD_EVENT_MOVING)
3847 printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id);
3849 printf("default: HandleControlButtons: ? (id == %d)\n", id);
3855 void HandleLevelEditorKeyInput(KeySym key)
3857 char letter = getCharFromKeySym(key);
3858 int button = MB_LEFT;
3860 if (drawing_function == GADGET_ID_TEXT &&
3861 DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
3864 DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
3865 else if (key == XK_Delete || key == XK_BackSpace)
3866 DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
3867 else if (key == XK_Return)
3868 DrawLevelText(0, 0, 0, TEXT_NEWLINE);
3870 else if (button_status == MB_RELEASED)
3877 id = GADGET_ID_SCROLL_LEFT;
3880 id = GADGET_ID_SCROLL_RIGHT;
3883 id = GADGET_ID_SCROLL_UP;
3886 id = GADGET_ID_SCROLL_DOWN;
3889 id = GADGET_ID_ELEMENTLIST_UP;
3893 id = GADGET_ID_ELEMENTLIST_DOWN;
3898 id = GADGET_ID_NONE;
3902 if (id != GADGET_ID_NONE)
3903 ClickOnGadget(level_editor_gadget[id], button);
3904 else if (letter == '.')
3905 ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
3907 for (i=0; i<ED_NUM_CTRL_BUTTONS; i++)
3908 if (letter && letter == control_info[i].shortcut)
3909 if (!anyTextGadgetActive())
3910 ClickOnGadget(level_editor_gadget[i], button);
3914 void ClearEditorGadgetInfoText()
3916 XFillRectangle(display, drawto, gc,
3917 INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
3918 redraw_mask |= REDRAW_FIELD;
3921 void HandleEditorGadgetInfoText(void *ptr)
3923 struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
3924 char infotext[MAX_INFOTEXT_LEN + 1];
3927 ClearEditorGadgetInfoText();
3929 /* misuse this function to delete brush cursor, if needed */
3930 if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
3931 DeleteBrushFromCursor();
3933 if (gi == NULL || gi->info_text == NULL)
3936 strncpy(infotext, gi->info_text, MAX_INFOTEXT_LEN);
3937 infotext[MAX_INFOTEXT_LEN] = '\0';
3939 if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
3941 int key = control_info[gi->custom_id].shortcut;
3945 sprintf(shortcut, " ('%s%c')",
3946 (key >= 'A' && key <= 'Z' ? "Shift-" :
3947 gi->custom_id == GADGET_ID_SINGLE_ITEMS ? ".' or '" : ""),
3950 if (strlen(infotext) + strlen(shortcut) <= MAX_INFOTEXT_LEN)
3951 strcat(infotext, shortcut);
3955 DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FS_SMALL, FC_YELLOW);
3958 static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
3960 static int start_lx, start_ly;
3962 int id = gi->custom_id;
3963 int sx = gi->event.x;
3964 int sy = gi->event.y;
3965 int lx = sx + level_xpos;
3966 int ly = sy + level_ypos;
3967 int min_sx = 0, min_sy = 0;
3968 int max_sx = gi->drawing.area_xsize - 1;
3969 int max_sy = gi->drawing.area_ysize - 1;
3971 ClearEditorGadgetInfoText();
3973 /* make sure to stay inside drawing area boundaries */
3974 sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
3975 sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
3977 if (id == GADGET_ID_DRAWING_LEVEL)
3981 int min_lx = 0, min_ly = 0;
3982 int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
3984 /* get positions inside level field */
3985 lx = sx + level_xpos;
3986 ly = sy + level_ypos;
3988 /* make sure to stay inside level field boundaries */
3989 lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
3990 ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
3992 /* correct drawing area positions accordingly */
3993 sx = lx - level_xpos;
3994 sy = ly - level_ypos;
3997 if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
3999 if (button_status) /* if (gi->state == GD_BUTTON_PRESSED) */
4001 if (gi->event.type == GD_EVENT_PRESSED)
4007 switch (drawing_function)
4009 case GADGET_ID_SINGLE_ITEMS:
4010 infotext = "Drawing single items";
4012 case GADGET_ID_CONNECTED_ITEMS:
4013 infotext = "Drawing connected items";
4015 case GADGET_ID_LINE:
4016 infotext = "Drawing line";
4019 infotext = "Drawing arc";
4021 case GADGET_ID_TEXT:
4022 infotext = "Setting text cursor";
4024 case GADGET_ID_RECTANGLE:
4025 infotext = "Drawing rectangle";
4027 case GADGET_ID_FILLED_BOX:
4028 infotext = "Drawing filled box";
4030 case GADGET_ID_FLOOD_FILL:
4031 infotext = "Flood fill";
4033 case GADGET_ID_GRAB_BRUSH:
4034 infotext = "Grabbing brush";
4036 case GADGET_ID_PICK_ELEMENT:
4037 infotext = "Picking element";
4041 infotext = "Drawing position";
4045 if (drawing_function == GADGET_ID_PICK_ELEMENT)
4046 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
4047 "%s: %d, %d", infotext, lx, ly);
4049 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
4050 "%s: %d, %d", infotext,
4051 ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
4053 else if (drawing_function == GADGET_ID_PICK_ELEMENT)
4054 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
4055 "%s", element_info[Feld[lx][ly]]);
4057 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
4058 "Level position: %d, %d", lx, ly);
4061 /* misuse this function to draw brush cursor, if needed */
4062 if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status)
4064 if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly))
4065 CopyBrushToCursor(sx, sy);
4067 DeleteBrushFromCursor();
4070 else if (id == GADGET_ID_AMOEBA_CONTENT)
4071 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
4073 else if (id == GADGET_ID_RANDOM_BACKGROUND)
4074 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
4075 "Random placement background");
4077 DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
4078 "Content area %d position: %d, %d",
4079 id - GADGET_ID_ELEM_CONTENT_0 + 1, sx, sy);