/***********************************************************
-* Rocks'n'Diamonds -- McDuffin Strikes Back! *
+* Rocks'n'Diamonds -- McDuffin Strikes Back! *
*----------------------------------------------------------*
-* (c) 1995-98 Artsoft Entertainment *
-* Holger Schemel *
-* Oststrasse 11a *
-* 33604 Bielefeld *
-* phone: ++49 +521 290471 *
-* email: aeglos@valinor.owl.de *
+* (c) 1995-2002 Artsoft Entertainment *
+* Holger Schemel *
+* Detmolder Strasse 189 *
+* 33604 Bielefeld *
+* Germany *
+* e-mail: info@artsoft.org *
*----------------------------------------------------------*
-* editor.c *
+* editor.c *
***********************************************************/
#include <math.h>
#include "game.h"
#include "tape.h"
+
+/*
+ -----------------------------------------------------------------------------
+ screen and artwork graphic pixel position definitions
+ -----------------------------------------------------------------------------
+*/
+
/* positions in the level editor */
#define ED_WIN_MB_LEFT_XPOS 6
#define ED_WIN_MB_LEFT_YPOS 258
#define ED_WIN_MB_RIGHT_XPOS 78
#define ED_WIN_MB_RIGHT_YPOS ED_WIN_MB_LEFT_YPOS
-/* other constants for the editor */
-#define ED_SCROLL_NO 0
-#define ED_SCROLL_LEFT 1
-#define ED_SCROLL_RIGHT 2
-#define ED_SCROLL_UP 4
-#define ED_SCROLL_DOWN 8
-
-/* screens in the level editor */
-#define ED_MODE_DRAWING 0
-#define ED_MODE_INFO 1
-#define ED_MODE_PROPERTIES 2
-
-/* how many steps can be cancelled */
-#define NUM_UNDO_STEPS (10 + 1)
-
-/* values for elements with score */
-#define MIN_SCORE 0
-#define MAX_SCORE 255
-
/* values for the control window */
#define ED_CTRL_BUTTONS_GFX_YPOS 236
#define ED_CTRL_BUTTONS_ALT_GFX_YPOS 142
ED_ELEMENTLIST_BUTTONS_VERT)
/* values for the setting windows */
-#define ED_SETTINGS_XPOS (MINI_TILEX + 8)
+#define ED_SETTINGS_XSTART (3 * MINI_TILEX / 2)
+#define ED_SETTINGS_YSTART (MINI_TILEY * 10)
+
+#define ED_SETTINGS_XOFFSET (ED_CHECKBUTTON_XSIZE + \
+ 2 * ED_GADGET_DISTANCE)
+#define ED_SETTINGS_YOFFSET (3 * MINI_TILEY / 2)
+
+#define ED_SETTINGS_XPOS(n) (ED_SETTINGS_XSTART + \
+ n * ED_SETTINGS_XOFFSET)
+#define ED_SETTINGS_YPOS(n) (ED_SETTINGS_YSTART + \
+ n * ED_SETTINGS_YOFFSET)
+
+#define ED_SETTINGS1_YPOS MINI_TILEY
#define ED_SETTINGS2_XPOS MINI_TILEX
-#define ED_SETTINGS_YPOS MINI_TILEY
-#define ED_SETTINGS2_YPOS (ED_SETTINGS_YPOS + 12 * TILEY - 2)
+#define ED_SETTINGS2_YPOS (ED_SETTINGS1_YPOS + 12 * TILEY - 2)
/* values for counter gadgets */
-#define ED_COUNT_ELEM_SCORE_XPOS ED_SETTINGS_XPOS
-#define ED_COUNT_ELEM_SCORE_YPOS (14 * MINI_TILEY)
-#define ED_COUNT_ELEM_CONTENT_XPOS ED_SETTINGS_XPOS
-#define ED_COUNT_ELEM_CONTENT_YPOS (19 * MINI_TILEY)
+#define ED_COUNT_ELEMENT_SCORE_XPOS ED_SETTINGS_XPOS(0)
+#define ED_COUNT_ELEMENT_SCORE_YPOS ED_SETTINGS_YPOS(0)
+#define ED_COUNT_ELEMENT_CONTENT_XPOS ED_SETTINGS_XPOS(0)
+#define ED_COUNT_ELEMENT_CONTENT_YPOS ED_SETTINGS_YPOS(6)
+
+#define ED_COUNT_CHANGE_DELAY_XPOS (ED_SETTINGS_XPOS(1) + 9 * MINI_TILEX)
-#define ED_COUNTER_YSTART (ED_SETTINGS_YPOS + 2 * TILEY)
+#define ED_COUNTER_YSTART (ED_SETTINGS1_YPOS + 2 * TILEY)
#define ED_COUNTER_YDISTANCE (3 * MINI_TILEY)
#define ED_COUNTER_YPOS(n) (ED_COUNTER_YSTART + \
n * ED_COUNTER_YDISTANCE)
#define ED_COUNTER2_YPOS(n) (ED_COUNTER_YSTART + \
n * ED_COUNTER_YDISTANCE - 2)
+
/* standard distances */
#define ED_BORDER_SIZE 3
+#define ED_BORDER2_SIZE 5
#define ED_GADGET_DISTANCE 2
/* values for element content drawing areas */
#define ED_AREA_ELEM_CONTENT_XPOS ( 2 * MINI_TILEX)
#define ED_AREA_ELEM_CONTENT_YPOS (22 * MINI_TILEY)
+#define ED_AREA_ELEM_CONTENT2_XPOS (20 * MINI_TILEX)
+#define ED_AREA_ELEM_CONTENT2_YPOS (ED_SETTINGS_YPOS(1) + \
+ ED_GADGET_DISTANCE)
+
+#define ED_AREA_ELEM_CONTENT3_XPOS (24 * MINI_TILEX)
+#define ED_AREA_ELEM_CONTENT3_YPOS (ED_SETTINGS_YPOS(2) + \
+ ED_GADGET_DISTANCE)
+
+#define ED_AREA_ELEM_CONTENT4_XPOS (17 * MINI_TILEX)
+#define ED_AREA_ELEM_CONTENT4_YPOS (ED_SETTINGS_YPOS(8) + \
+ ED_GADGET_DISTANCE - MINI_TILEY)
+
/* values for random placement background drawing area */
#define ED_AREA_RANDOM_BACKGROUND_XPOS (29 * MINI_TILEX)
#define ED_AREA_RANDOM_BACKGROUND_YPOS (31 * MINI_TILEY)
#define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 66)
/* some positions in the editor control window */
-#define ED_BUTTON_ELEM_XPOS 6
-#define ED_BUTTON_ELEM_YPOS 30
-#define ED_BUTTON_ELEM_XSIZE 22
-#define ED_BUTTON_ELEM_YSIZE 22
-
-/* some values for text input and counter gadgets */
-#define ED_BUTTON_COUNT_YPOS 60
-#define ED_BUTTON_COUNT_XSIZE 20
-#define ED_BUTTON_COUNT_YSIZE 20
-#define ED_WIN_COUNT_XPOS (2 + ED_BUTTON_COUNT_XSIZE + 2)
-#define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS
-#define ED_WIN_COUNT_XSIZE 52
-#define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE
-#define ED_WIN_COUNT2_XPOS 27
-#define ED_WIN_COUNT2_YPOS 3
-#define ED_WIN_COUNT2_XSIZE 46
-#define ED_WIN_COUNT2_YSIZE ED_BUTTON_COUNT_YSIZE
-
-#define ED_BUTTON_MINUS_XPOS 2
-#define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS
-#define ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE
-#define ED_BUTTON_MINUS_YSIZE ED_BUTTON_COUNT_YSIZE
-#define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS + ED_WIN_COUNT_XSIZE + 2)
-#define ED_BUTTON_PLUS_YPOS ED_BUTTON_COUNT_YPOS
-#define ED_BUTTON_PLUS_XSIZE ED_BUTTON_COUNT_XSIZE
-#define ED_BUTTON_PLUS_YSIZE ED_BUTTON_COUNT_YSIZE
-
-/* editor gadget identifiers */
+#define ED_BUTTON_ELEM_XPOS 6
+#define ED_BUTTON_ELEM_YPOS 30
+#define ED_BUTTON_ELEM_XSIZE 22
+#define ED_BUTTON_ELEM_YSIZE 22
+
+/* some values for text input, selectbox and counter gadgets */
+#define ED_BUTTON_COUNT_YPOS 60
+#define ED_BUTTON_COUNT_XSIZE 20
+#define ED_BUTTON_COUNT_YSIZE 20
+#define ED_WIN_COUNT_XPOS (2 + ED_BUTTON_COUNT_XSIZE + 2)
+#define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS
+#define ED_WIN_COUNT_XSIZE 52
+#define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE
+#define ED_WIN_COUNT2_XPOS 27
+#define ED_WIN_COUNT2_YPOS 3
+#define ED_WIN_COUNT2_XSIZE 46
+#define ED_WIN_COUNT2_YSIZE ED_BUTTON_COUNT_YSIZE
+
+#define ED_BUTTON_MINUS_XPOS 2
+#define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS
+#define ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE
+#define ED_BUTTON_MINUS_YSIZE ED_BUTTON_COUNT_YSIZE
+#define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS + \
+ ED_WIN_COUNT_XSIZE + 2)
+#define ED_BUTTON_PLUS_YPOS ED_BUTTON_COUNT_YPOS
+#define ED_BUTTON_PLUS_XSIZE ED_BUTTON_COUNT_XSIZE
+#define ED_BUTTON_PLUS_YSIZE ED_BUTTON_COUNT_YSIZE
+
+#define ED_SELECTBOX_XPOS ED_WIN_COUNT_XPOS
+#define ED_SELECTBOX_YPOS (ED_WIN_COUNT_YPOS + \
+ 2 + ED_WIN_COUNT_YSIZE)
+#define ED_SELECTBOX_XSIZE ED_WIN_COUNT_XSIZE
+#define ED_SELECTBOX_YSIZE ED_WIN_COUNT_YSIZE
+
+#define ED_TEXTBUTTON_XPOS ED_WIN_COUNT_XPOS
+#define ED_TEXTBUTTON_YPOS (ED_WIN_COUNT_YPOS + \
+ 2 * (2 + ED_WIN_COUNT_YSIZE))
+#define ED_TEXTBUTTON_INACTIVE_YPOS (ED_WIN_COUNT_YPOS + \
+ 3 * (2 + ED_WIN_COUNT_YSIZE))
+#define ED_TEXTBUTTON_XSIZE ED_WIN_COUNT_XSIZE
+#define ED_TEXTBUTTON_YSIZE ED_WIN_COUNT_YSIZE
+
+/* values for ClearEditorGadgetInfoText() and HandleGadgetInfoText() */
+#define INFOTEXT_XPOS SX
+#define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2)
+#define INFOTEXT_XSIZE SXSIZE
+#define INFOTEXT_YSIZE MINI_TILEX
+
+
+/*
+ -----------------------------------------------------------------------------
+ editor gadget definitions
+ -----------------------------------------------------------------------------
+*/
/* drawing toolbox buttons */
#define GADGET_ID_NONE -1
-#define GADGET_ID_SINGLE_ITEMS 0
-#define GADGET_ID_CONNECTED_ITEMS 1
-#define GADGET_ID_LINE 2
-#define GADGET_ID_ARC 3
-#define GADGET_ID_RECTANGLE 4
-#define GADGET_ID_FILLED_BOX 5
-#define GADGET_ID_WRAP_UP 6
-#define GADGET_ID_TEXT 7
-#define GADGET_ID_FLOOD_FILL 8
-#define GADGET_ID_WRAP_LEFT 9
-#define GADGET_ID_PROPERTIES 10
-#define GADGET_ID_WRAP_RIGHT 11
-#define GADGET_ID_RANDOM_PLACEMENT 12
-#define GADGET_ID_GRAB_BRUSH 13
-#define GADGET_ID_WRAP_DOWN 14
-#define GADGET_ID_PICK_ELEMENT 15
-#define GADGET_ID_UNDO 16
-#define GADGET_ID_INFO 17
-#define GADGET_ID_SAVE 18
-#define GADGET_ID_CLEAR 19
-#define GADGET_ID_TEST 20
-#define GADGET_ID_EXIT 21
+#define GADGET_ID_TOOLBOX_FIRST 0
+
+#define GADGET_ID_SINGLE_ITEMS (GADGET_ID_TOOLBOX_FIRST + 0)
+#define GADGET_ID_CONNECTED_ITEMS (GADGET_ID_TOOLBOX_FIRST + 1)
+#define GADGET_ID_LINE (GADGET_ID_TOOLBOX_FIRST + 2)
+#define GADGET_ID_ARC (GADGET_ID_TOOLBOX_FIRST + 3)
+#define GADGET_ID_RECTANGLE (GADGET_ID_TOOLBOX_FIRST + 4)
+#define GADGET_ID_FILLED_BOX (GADGET_ID_TOOLBOX_FIRST + 5)
+#define GADGET_ID_WRAP_UP (GADGET_ID_TOOLBOX_FIRST + 6)
+#define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7)
+#define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8)
+#define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9)
+#define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 10)
+#define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11)
+#define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12)
+#define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13)
+#define GADGET_ID_WRAP_DOWN (GADGET_ID_TOOLBOX_FIRST + 14)
+#define GADGET_ID_PICK_ELEMENT (GADGET_ID_TOOLBOX_FIRST + 15)
+#define GADGET_ID_UNDO (GADGET_ID_TOOLBOX_FIRST + 16)
+#define GADGET_ID_INFO (GADGET_ID_TOOLBOX_FIRST + 17)
+#define GADGET_ID_SAVE (GADGET_ID_TOOLBOX_FIRST + 18)
+#define GADGET_ID_CLEAR (GADGET_ID_TOOLBOX_FIRST + 19)
+#define GADGET_ID_TEST (GADGET_ID_TOOLBOX_FIRST + 20)
+#define GADGET_ID_EXIT (GADGET_ID_TOOLBOX_FIRST + 21)
/* counter button identifiers */
-#define GADGET_ID_ELEM_SCORE_DOWN 22
-#define GADGET_ID_ELEM_SCORE_TEXT 23
-#define GADGET_ID_ELEM_SCORE_UP 24
-#define GADGET_ID_ELEM_CONTENT_DOWN 25
-#define GADGET_ID_ELEM_CONTENT_TEXT 26
-#define GADGET_ID_ELEM_CONTENT_UP 27
-#define GADGET_ID_LEVEL_XSIZE_DOWN 28
-#define GADGET_ID_LEVEL_XSIZE_TEXT 29
-#define GADGET_ID_LEVEL_XSIZE_UP 30
-#define GADGET_ID_LEVEL_YSIZE_DOWN 31
-#define GADGET_ID_LEVEL_YSIZE_TEXT 32
-#define GADGET_ID_LEVEL_YSIZE_UP 33
-#define GADGET_ID_LEVEL_RANDOM_DOWN 34
-#define GADGET_ID_LEVEL_RANDOM_TEXT 35
-#define GADGET_ID_LEVEL_RANDOM_UP 36
-#define GADGET_ID_LEVEL_COLLECT_DOWN 37
-#define GADGET_ID_LEVEL_COLLECT_TEXT 38
-#define GADGET_ID_LEVEL_COLLECT_UP 39
-#define GADGET_ID_LEVEL_TIMELIMIT_DOWN 40
-#define GADGET_ID_LEVEL_TIMELIMIT_TEXT 41
-#define GADGET_ID_LEVEL_TIMELIMIT_UP 42
-#define GADGET_ID_LEVEL_TIMESCORE_DOWN 43
-#define GADGET_ID_LEVEL_TIMESCORE_TEXT 44
-#define GADGET_ID_LEVEL_TIMESCORE_UP 45
-#define GADGET_ID_SELECT_LEVEL_DOWN 46
-#define GADGET_ID_SELECT_LEVEL_TEXT 47
-#define GADGET_ID_SELECT_LEVEL_UP 48
+#define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 22)
+
+#define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0)
+#define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1)
+#define GADGET_ID_SELECT_LEVEL_UP (GADGET_ID_COUNTER_FIRST + 2)
+#define GADGET_ID_LEVEL_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 3)
+#define GADGET_ID_LEVEL_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 4)
+#define GADGET_ID_LEVEL_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 5)
+#define GADGET_ID_LEVEL_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 6)
+#define GADGET_ID_LEVEL_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 7)
+#define GADGET_ID_LEVEL_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 8)
+#define GADGET_ID_LEVEL_RANDOM_DOWN (GADGET_ID_COUNTER_FIRST + 9)
+#define GADGET_ID_LEVEL_RANDOM_TEXT (GADGET_ID_COUNTER_FIRST + 10)
+#define GADGET_ID_LEVEL_RANDOM_UP (GADGET_ID_COUNTER_FIRST + 11)
+#define GADGET_ID_LEVEL_COLLECT_DOWN (GADGET_ID_COUNTER_FIRST + 12)
+#define GADGET_ID_LEVEL_COLLECT_TEXT (GADGET_ID_COUNTER_FIRST + 13)
+#define GADGET_ID_LEVEL_COLLECT_UP (GADGET_ID_COUNTER_FIRST + 14)
+#define GADGET_ID_LEVEL_TIMELIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 15)
+#define GADGET_ID_LEVEL_TIMELIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 16)
+#define GADGET_ID_LEVEL_TIMELIMIT_UP (GADGET_ID_COUNTER_FIRST + 17)
+#define GADGET_ID_LEVEL_TIMESCORE_DOWN (GADGET_ID_COUNTER_FIRST + 18)
+#define GADGET_ID_LEVEL_TIMESCORE_TEXT (GADGET_ID_COUNTER_FIRST + 19)
+#define GADGET_ID_LEVEL_TIMESCORE_UP (GADGET_ID_COUNTER_FIRST + 20)
+#define GADGET_ID_ELEMENT_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 21)
+#define GADGET_ID_ELEMENT_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 22)
+#define GADGET_ID_ELEMENT_SCORE_UP (GADGET_ID_COUNTER_FIRST + 23)
+#define GADGET_ID_ELEMENT_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 24)
+#define GADGET_ID_ELEMENT_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 25)
+#define GADGET_ID_ELEMENT_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 26)
+#define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 27)
+#define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 28)
+#define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 29)
+#define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 30)
+#define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 31)
+#define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 32)
/* drawing area identifiers */
-#define GADGET_ID_DRAWING_LEVEL 49
-#define GADGET_ID_ELEM_CONTENT_0 50
-#define GADGET_ID_ELEM_CONTENT_1 51
-#define GADGET_ID_ELEM_CONTENT_2 52
-#define GADGET_ID_ELEM_CONTENT_3 53
-#define GADGET_ID_ELEM_CONTENT_4 54
-#define GADGET_ID_ELEM_CONTENT_5 55
-#define GADGET_ID_ELEM_CONTENT_6 56
-#define GADGET_ID_ELEM_CONTENT_7 57
-#define GADGET_ID_AMOEBA_CONTENT 58
+#define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 33)
+
+#define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
+#define GADGET_ID_ELEMENT_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
+#define GADGET_ID_ELEMENT_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2)
+#define GADGET_ID_ELEMENT_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3)
+#define GADGET_ID_ELEMENT_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4)
+#define GADGET_ID_ELEMENT_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5)
+#define GADGET_ID_ELEMENT_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6)
+#define GADGET_ID_ELEMENT_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7)
+#define GADGET_ID_ELEMENT_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8)
+#define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 9)
+#define GADGET_ID_CUSTOM_GRAPHIC (GADGET_ID_DRAWING_AREA_FIRST + 10)
+#define GADGET_ID_CUSTOM_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 11)
+#define GADGET_ID_CUSTOM_CHANGED (GADGET_ID_DRAWING_AREA_FIRST + 12)
+#define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 13)
/* text input identifiers */
-#define GADGET_ID_LEVEL_NAME 59
-#define GADGET_ID_LEVEL_AUTHOR 60
+#define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 14)
-/* gadgets for scrolling of drawing area */
-#define GADGET_ID_SCROLL_UP 61
-#define GADGET_ID_SCROLL_DOWN 62
-#define GADGET_ID_SCROLL_LEFT 63
-#define GADGET_ID_SCROLL_RIGHT 64
-#define GADGET_ID_SCROLL_HORIZONTAL 65
-#define GADGET_ID_SCROLL_VERTICAL 66
+#define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
+#define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
-/* gadgets for scrolling element list */
-#define GADGET_ID_SCROLL_LIST_UP 67
-#define GADGET_ID_SCROLL_LIST_DOWN 68
-#define GADGET_ID_SCROLL_LIST_VERTICAL 69
+/* selectbox identifiers */
+#define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 2)
+
+#define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 0)
+#define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 1)
+#define GADGET_ID_CUSTOM_WALKABLE_LAYER (GADGET_ID_SELECTBOX_FIRST + 2)
+#define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 3)
+#define GADGET_ID_CHANGE_CAUSE (GADGET_ID_SELECTBOX_FIRST + 4)
+
+/* textbutton identifiers */
+#define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 5)
-/* buttons for level settings */
-#define GADGET_ID_RANDOM_PERCENTAGE 70
-#define GADGET_ID_RANDOM_QUANTITY 71
-#define GADGET_ID_RANDOM_RESTRICTED 72
-#define GADGET_ID_DOUBLE_SPEED 73
-#define GADGET_ID_GRAVITY 74
-#define GADGET_ID_STICK_ELEMENT 75
+#define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 0)
+#define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 1)
+#define GADGET_ID_PROPERTIES_ADVANCED (GADGET_ID_TEXTBUTTON_FIRST + 2)
-/* another drawing area for random placement */
-#define GADGET_ID_RANDOM_BACKGROUND 76
+/* gadgets for scrolling of drawing area */
+#define GADGET_ID_SCROLLING_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 3)
+
+#define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
+#define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
+#define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2)
+#define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3)
+#define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4)
+#define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5)
+
+/* gadgets for scrolling element list */
+#define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6)
+
+#define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0)
+#define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1)
+#define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2)
+
+/* buttons for level/element properties */
+#define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3)
+
+#define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 0)
+#define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 1)
+#define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 2)
+#define GADGET_ID_DOUBLE_SPEED (GADGET_ID_CHECKBUTTON_FIRST + 3)
+#define GADGET_ID_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 4)
+#define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 5)
+#define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 6)
+#define GADGET_ID_CUSTOM_INDESTRUCTIBLE (GADGET_ID_CHECKBUTTON_FIRST + 7)
+#define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 8)
+#define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 9)
+#define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 10)
+#define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 11)
+#define GADGET_ID_CUSTOM_CAN_EXPLODE (GADGET_ID_CHECKBUTTON_FIRST + 12)
+#define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 13)
+#define GADGET_ID_CUSTOM_WALKABLE (GADGET_ID_CHECKBUTTON_FIRST + 14)
+#define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 15)
+#define GADGET_ID_CUSTOM_CHANGEABLE (GADGET_ID_CHECKBUTTON_FIRST + 16)
+#define GADGET_ID_CHANGE_DELAY_FIXED (GADGET_ID_CHECKBUTTON_FIRST + 17)
+#define GADGET_ID_CHANGE_DELAY_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 18)
/* gadgets for buttons in element list */
-#define GADGET_ID_ELEMENTLIST_FIRST 77
-#define GADGET_ID_ELEMENTLIST_LAST (77 + ED_NUM_ELEMENTLIST_BUTTONS - 1)
+#define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 19)
+#define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \
+ ED_NUM_ELEMENTLIST_BUTTONS - 1)
#define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
#define RADIO_NR_RANDOM_ELEMENTS 2
/* values for counter gadgets */
-#define ED_COUNTER_ID_ELEM_SCORE 0
-#define ED_COUNTER_ID_ELEM_CONTENT 1
-#define ED_COUNTER_ID_LEVEL_XSIZE 2
-#define ED_COUNTER_ID_LEVEL_YSIZE 3
-#define ED_COUNTER_ID_LEVEL_COLLECT 4
-#define ED_COUNTER_ID_LEVEL_TIMELIMIT 5
-#define ED_COUNTER_ID_LEVEL_TIMESCORE 6
-#define ED_COUNTER_ID_LEVEL_RANDOM 7
-#define ED_COUNTER_ID_SELECT_LEVEL 8
-
-#define ED_NUM_COUNTERBUTTONS 9
+#define ED_COUNTER_ID_SELECT_LEVEL 0
+#define ED_COUNTER_ID_LEVEL_XSIZE 1
+#define ED_COUNTER_ID_LEVEL_YSIZE 2
+#define ED_COUNTER_ID_LEVEL_COLLECT 3
+#define ED_COUNTER_ID_LEVEL_TIMELIMIT 4
+#define ED_COUNTER_ID_LEVEL_TIMESCORE 5
+#define ED_COUNTER_ID_LEVEL_RANDOM 6
+#define ED_COUNTER_ID_ELEMENT_SCORE 7
+#define ED_COUNTER_ID_ELEMENT_CONTENT 8
+#define ED_COUNTER_ID_CHANGE_DELAY_FIX 9
+#define ED_COUNTER_ID_CHANGE_DELAY_RND 10
+
+#define ED_NUM_COUNTERBUTTONS 11
#define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
#define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM
+#define ED_COUNTER_ID_CHANGE_FIRST ED_COUNTER_ID_CHANGE_DELAY_FIX
+#define ED_COUNTER_ID_CHANGE_LAST ED_COUNTER_ID_CHANGE_DELAY_RND
+
/* values for scrollbutton gadgets */
#define ED_SCROLLBUTTON_ID_AREA_UP 0
#define ED_SCROLLBUTTON_ID_AREA_DOWN 1
#define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
#define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
+/* values for selectbox gadgets */
+#define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 0
+#define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 1
+#define ED_SELECTBOX_ID_CUSTOM_WALKABLE_LAYER 2
+#define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 3
+#define ED_SELECTBOX_ID_CHANGE_CAUSE 4
+
+#define ED_NUM_SELECTBOX 5
+
+#define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION
+#define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM_WALKABLE_LAYER
+
+#define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
+#define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_CHANGE_CAUSE
+
+/* values for textbutton gadgets */
+#define ED_TEXTBUTTON_ID_PROPERTIES_INFO 0
+#define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 1
+#define ED_TEXTBUTTON_ID_PROPERTIES_ADVANCED 2
+
+#define ED_NUM_TEXTBUTTON 3
+
/* values for checkbutton gadgets */
#define ED_CHECKBUTTON_ID_DOUBLE_SPEED 0
#define ED_CHECKBUTTON_ID_GRAVITY 1
#define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 2
#define ED_CHECKBUTTON_ID_STICK_ELEMENT 3
-
-#define ED_NUM_CHECKBUTTONS 4
+#define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 4
+#define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 5
+#define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 6
+#define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 7
+#define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 8
+#define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 9
+#define ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE 10
+#define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 11
+#define ED_CHECKBUTTON_ID_CUSTOM_WALKABLE 12
+#define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 13
+#define ED_CHECKBUTTON_ID_CUSTOM_CHANGEABLE 14
+#define ED_CHECKBUTTON_ID_CHANGE_DELAY_FIXED 15
+#define ED_CHECKBUTTON_ID_CHANGE_DELAY_RANDOM 16
+
+#define ED_NUM_CHECKBUTTONS 17
#define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_DOUBLE_SPEED
#define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
+#define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE
+#define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
+
+#define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CHANGEABLE
+#define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_DELAY_RANDOM
+
/* values for radiobutton gadgets */
#define ED_RADIOBUTTON_ID_PERCENTAGE 0
#define ED_RADIOBUTTON_ID_QUANTITY 1
#define ED_RADIOBUTTON_ID_LEVEL_FIRST ED_RADIOBUTTON_ID_PERCENTAGE
#define ED_RADIOBUTTON_ID_LEVEL_LAST ED_RADIOBUTTON_ID_QUANTITY
+
+/*
+ -----------------------------------------------------------------------------
+ some internally used definitions
+ -----------------------------------------------------------------------------
+*/
+
/* values for CopyLevelToUndoBuffer() */
#define UNDO_IMMEDIATE 0
#define UNDO_ACCUMULATE 1
-/* values for ClearEditorGadgetInfoText() and HandleGadgetInfoText() */
-#define INFOTEXT_XPOS SX
-#define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2)
-#define INFOTEXT_XSIZE SXSIZE
-#define INFOTEXT_YSIZE MINI_TILEX
-#define MAX_INFOTEXT_LEN (SXSIZE / FONT2_XSIZE)
+/* values for scrollbars */
+#define ED_SCROLL_NO 0
+#define ED_SCROLL_LEFT 1
+#define ED_SCROLL_RIGHT 2
+#define ED_SCROLL_UP 4
+#define ED_SCROLL_DOWN 8
+
+/* screens in the level editor */
+#define ED_MODE_DRAWING 0
+#define ED_MODE_INFO 1
+#define ED_MODE_PROPERTIES 2
+
+/* sub-screens in the element properties section */
+#define ED_MODE_PROPERTIES_INFO ED_TEXTBUTTON_ID_PROPERTIES_INFO
+#define ED_MODE_PROPERTIES_CONFIG ED_TEXTBUTTON_ID_PROPERTIES_CONFIG
+#define ED_MODE_PROPERTIES_ADVANCED ED_TEXTBUTTON_ID_PROPERTIES_ADVANCED
+
+/* how many steps can be cancelled */
+#define NUM_UNDO_STEPS (10 + 1)
+
+/* values for elements with score */
+#define MIN_SCORE 0
+#define MAX_SCORE 255
+
+/* values for random placement */
+#define RANDOM_USE_PERCENTAGE 0
+#define RANDOM_USE_QUANTITY 1
+
+/* maximal size of level editor drawing area */
+#define MAX_ED_FIELDX (2 * SCR_FIELDX)
+#define MAX_ED_FIELDY (2 * SCR_FIELDY - 1)
+
+
+/*
+ -----------------------------------------------------------------------------
+ some internally used data structure definitions
+ -----------------------------------------------------------------------------
+*/
static struct
{
char *text;
} control_info[ED_NUM_CTRL_BUTTONS] =
{
- { 's', "draw single items" },
- { 'd', "draw connected items" },
- { 'l', "draw lines" },
- { 'a', "draw arcs" },
- { 'r', "draw outline rectangles" },
- { 'R', "draw filled rectangles" },
- { '\0', "wrap (rotate) level up" },
- { 't', "enter text elements" },
- { 'f', "flood fill" },
- { '\0', "wrap (rotate) level left" },
- { '?', "properties of drawing element" },
- { '\0', "wrap (rotate) level right" },
- { '\0', "random element placement" },
- { 'b', "grab brush" },
- { '\0', "wrap (rotate) level down" },
- { ',', "pick drawing element" },
- { 'U', "undo last operation" },
- { 'I', "level properties" },
- { 'S', "save level" },
- { 'C', "clear level" },
- { 'T', "test level" },
- { 'E', "exit level editor" }
+ { 's', "draw single items" },
+ { 'd', "draw connected items" },
+ { 'l', "draw lines" },
+ { 'a', "draw arcs" },
+ { 'r', "draw outline rectangles" },
+ { 'R', "draw filled rectangles" },
+ { '\0', "wrap (rotate) level up" },
+ { 't', "enter text elements" },
+ { 'f', "flood fill" },
+ { '\0', "wrap (rotate) level left" },
+ { '?', "properties of drawing element" },
+ { '\0', "wrap (rotate) level right" },
+ { '\0', "random element placement" },
+ { 'b', "grab brush" },
+ { '\0', "wrap (rotate) level down" },
+ { ',', "pick drawing element" },
+ { 'U', "undo last operation" },
+ { 'I', "level properties" },
+ { 'S', "save level" },
+ { 'C', "clear level" },
+ { 'T', "test level" },
+ { 'E', "exit level editor" }
};
-/* values for random placement */
-#define RANDOM_USE_PERCENTAGE 0
-#define RANDOM_USE_QUANTITY 1
-
static int random_placement_value = 10;
static int random_placement_method = RANDOM_USE_QUANTITY;
-static int random_placement_background_element = EL_ERDREICH;
+static int random_placement_background_element = EL_SAND;
static boolean random_placement_background_restricted = FALSE;
static boolean stick_element_properties_window = FALSE;
+static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
+static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
+static struct CustomElementInfo custom_element;
static struct
{
} counterbutton_info[ED_NUM_COUNTERBUTTONS] =
{
{
- ED_COUNT_ELEM_SCORE_XPOS, ED_COUNT_ELEM_SCORE_YPOS,
- MIN_SCORE, MAX_SCORE,
- GADGET_ID_ELEM_SCORE_DOWN, GADGET_ID_ELEM_SCORE_UP,
- GADGET_ID_ELEM_SCORE_TEXT,
- NULL, /* will be set when used */
- "element score", NULL
- },
- {
- ED_COUNT_ELEM_CONTENT_XPOS, ED_COUNT_ELEM_CONTENT_YPOS,
- MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
- GADGET_ID_ELEM_CONTENT_DOWN, GADGET_ID_ELEM_CONTENT_UP,
- GADGET_ID_ELEM_CONTENT_TEXT,
- &level.num_yam_contents,
- "element content", NULL
+ DX + 5 - SX, DY + 3 - SY,
+ 1, 100,
+ GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
+ GADGET_ID_SELECT_LEVEL_TEXT,
+ &level_nr,
+ NULL, NULL
},
{
- ED_SETTINGS_XPOS, ED_COUNTER_YPOS(2),
+ ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(2),
MIN_LEV_FIELDX, MAX_LEV_FIELDX,
GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP,
GADGET_ID_LEVEL_XSIZE_TEXT,
"playfield size", "width",
},
{
- ED_SETTINGS_XPOS + 2 * DXSIZE, ED_COUNTER_YPOS(2),
+ ED_SETTINGS_XPOS(0) + 2 * DXSIZE, ED_COUNTER_YPOS(2),
MIN_LEV_FIELDY, MAX_LEV_FIELDY,
GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
GADGET_ID_LEVEL_YSIZE_TEXT,
NULL, "height",
},
{
- ED_SETTINGS_XPOS, ED_COUNTER_YPOS(3),
+ ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(3),
0, 999,
GADGET_ID_LEVEL_COLLECT_DOWN, GADGET_ID_LEVEL_COLLECT_UP,
GADGET_ID_LEVEL_COLLECT_TEXT,
"number of emeralds to collect", NULL
},
{
- ED_SETTINGS_XPOS, ED_COUNTER_YPOS(4),
+ ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(4),
0, 999,
GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP,
GADGET_ID_LEVEL_TIMELIMIT_TEXT,
"time available to solve level", "(0 => no time limit)"
},
{
- ED_SETTINGS_XPOS, ED_COUNTER_YPOS(5),
+ ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(5),
0, 255,
GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP,
GADGET_ID_LEVEL_TIMESCORE_TEXT,
- &level.score[SC_ZEITBONUS],
+ &level.score[SC_TIME_BONUS],
"score for each 10 seconds left", NULL
},
{
- ED_SETTINGS_XPOS, ED_COUNTER2_YPOS(8),
+ ED_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(8),
1, 100,
GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP,
GADGET_ID_LEVEL_RANDOM_TEXT,
"random element placement", "in"
},
{
- DX + 5 - SX, DY + 3 - SY,
- 1, 100,
- GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
- GADGET_ID_SELECT_LEVEL_TEXT,
- &level_nr,
- NULL, NULL
+ ED_COUNT_ELEMENT_SCORE_XPOS, ED_COUNT_ELEMENT_SCORE_YPOS,
+ MIN_SCORE, MAX_SCORE,
+ GADGET_ID_ELEMENT_SCORE_DOWN, GADGET_ID_ELEMENT_SCORE_UP,
+ GADGET_ID_ELEMENT_SCORE_TEXT,
+ NULL, /* will be set when used */
+ "element score", NULL
+ },
+ {
+ ED_COUNT_ELEMENT_CONTENT_XPOS, ED_COUNT_ELEMENT_CONTENT_YPOS,
+ MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
+ GADGET_ID_ELEMENT_CONTENT_DOWN, GADGET_ID_ELEMENT_CONTENT_UP,
+ GADGET_ID_ELEMENT_CONTENT_TEXT,
+ &level.num_yamyam_contents,
+ "element content", NULL
+ },
+ {
+ ED_COUNT_CHANGE_DELAY_XPOS, ED_SETTINGS_YPOS(2),
+ 0, 999,
+ GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
+ GADGET_ID_CHANGE_DELAY_FIX_TEXT,
+ &custom_element.change.delay_fixed,
+ NULL, "units (fixed)"
+ },
+ {
+ ED_COUNT_CHANGE_DELAY_XPOS, ED_SETTINGS_YPOS(3),
+ 0, 999,
+ GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
+ GADGET_ID_CHANGE_DELAY_RND_TEXT,
+ &custom_element.change.delay_random,
+ NULL, "units (random)"
}
};
} textinput_info[ED_NUM_TEXTINPUT] =
{
{
- ED_SETTINGS_XPOS, ED_COUNTER_YPOS(0),
+ ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(0),
GADGET_ID_LEVEL_NAME,
MAX_LEVEL_NAME_LEN,
level.name,
"Title"
},
{
- ED_SETTINGS_XPOS, ED_COUNTER_YPOS(1),
+ ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
GADGET_ID_LEVEL_AUTHOR,
MAX_LEVEL_AUTHOR_LEN,
level.author,
}
};
+static struct ValueTextInfo options_walk_to_action[] =
+{
+ { EP_DIGGABLE, "diggable" },
+ { EP_COLLECTIBLE, "collectible" },
+ { EP_PUSHABLE, "pushable" },
+ { -1, NULL }
+};
+static int index_walk_to_action = 0;
+
+static struct ValueTextInfo options_move_direction[] =
+{
+ { EP_DIGGABLE, "left" },
+ { EP_COLLECTIBLE, "right" },
+ { EP_PUSHABLE, "up" },
+ { EP_PUSHABLE, "down" },
+ { EP_PUSHABLE, "horizontal" },
+ { EP_PUSHABLE, "vertical" },
+ { EP_PUSHABLE, "all directions" },
+ { EP_PUSHABLE, "towards player" },
+ { EP_PUSHABLE, "away from player" },
+ { EP_PUSHABLE, "along left side" },
+ { EP_PUSHABLE, "along right side" },
+ { -1, NULL }
+};
+static int index_move_direction = 0;
+
+static struct ValueTextInfo options_walkable_layer[] =
+{
+ { EP_WALKABLE_OVER, "over" },
+ { EP_WALKABLE_INSIDE, "inside" },
+ { EP_WALKABLE_UNDER, "under" },
+ { -1, NULL }
+};
+static int index_walkable_layer = 0;
+
+static struct ValueTextInfo options_time_units[] =
+{
+ { 50, "seconds" },
+ { 1, "frames" },
+ { -1, NULL }
+};
+static int index_time_units = 0;
+
+static struct ValueTextInfo options_change_cause[] =
+{
+ { 1, "specified delay" },
+ { 2, "impact (active)" },
+ { 3, "impact (passive)" },
+ { 4, "touched by player" },
+ { 5, "pressed by player" },
+ { -1, NULL }
+};
+static int index_change_cause = 0, value_change_cause = 0;
+
+static struct
+{
+ int x, y;
+ int gadget_id;
+ int size; /* size of selectbox (chars) or '0' (dynamically determined) */
+ struct ValueTextInfo *options;
+ int *index, *value;
+ char *text, *infotext;
+} selectbox_info[ED_NUM_SELECTBOX] =
+{
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(4),
+ GADGET_ID_CUSTOM_WALK_TO_ACTION,
+ 0,
+ options_walk_to_action, &index_walk_to_action,
+ &custom_element.walk_to_action,
+ NULL, "diggable/collectible/pushable"
+ },
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5),
+ GADGET_ID_CUSTOM_MOVE_DIRECTION,
+ 0,
+ options_move_direction, &index_move_direction,
+ &custom_element.move_direction,
+ "can move", "element move direction"
+ },
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(10),
+ GADGET_ID_CUSTOM_WALKABLE_LAYER,
+ 0,
+ options_walkable_layer, &index_walkable_layer,
+ &custom_element.walkable_layer,
+ "player can walk", "layer where player can walk"
+ },
+ {
+ ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(4),
+ GADGET_ID_CHANGE_TIME_UNITS,
+ 0,
+ options_time_units, &index_time_units,
+ &custom_element.change.delay_frames,
+ "delay time given in", "delay time units for change"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(8),
+ GADGET_ID_CHANGE_CAUSE,
+ 0,
+ options_change_cause, &index_change_cause,
+ &value_change_cause,
+ "test:", "test-selectbox entry"
+ },
+};
+
+static struct
+{
+ int x, y;
+ int gadget_id;
+ int size;
+ char *value;
+ char *infotext;
+} textbutton_info[ED_NUM_TEXTBUTTON] =
+{
+ {
+ ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
+ GADGET_ID_PROPERTIES_INFO,
+ 11, "Information",
+ "Show information about element"
+ },
+ {
+ ED_SETTINGS_XPOS(0) + 166, ED_COUNTER_YPOS(1),
+ GADGET_ID_PROPERTIES_CONFIG,
+ 11, "Configure",
+ "Configure element properties"
+ },
+ {
+ ED_SETTINGS_XPOS(0) + 332, ED_COUNTER_YPOS(1),
+ GADGET_ID_PROPERTIES_ADVANCED,
+ 11, "Advanced",
+ "Advanced element configuration"
+ },
+};
+
static struct
{
int xpos, ypos;
} radiobutton_info[ED_NUM_RADIOBUTTONS] =
{
{
- ED_SETTINGS_XPOS + 160, ED_COUNTER2_YPOS(8),
+ ED_SETTINGS_XPOS(0) + 160, ED_COUNTER2_YPOS(8),
GADGET_ID_RANDOM_PERCENTAGE,
RADIO_NR_RANDOM_ELEMENTS,
&random_placement_method, RANDOM_USE_PERCENTAGE,
"percentage", "use percentage for random elements"
},
{
- ED_SETTINGS_XPOS + 340, ED_COUNTER2_YPOS(8),
+ ED_SETTINGS_XPOS(0) + 340, ED_COUNTER2_YPOS(8),
GADGET_ID_RANDOM_QUANTITY,
RADIO_NR_RANDOM_ELEMENTS,
&random_placement_method, RANDOM_USE_QUANTITY,
} checkbutton_info[ED_NUM_CHECKBUTTONS] =
{
{
- ED_SETTINGS_XPOS, ED_COUNTER_YPOS(6) - MINI_TILEY,
+ ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(6) - MINI_TILEY,
GADGET_ID_DOUBLE_SPEED,
&level.double_speed,
"double speed movement", "set movement speed of player"
},
{
- ED_SETTINGS_XPOS + 340, ED_COUNTER_YPOS(6) - MINI_TILEY,
+ ED_SETTINGS_XPOS(0) + 340, ED_COUNTER_YPOS(6) - MINI_TILEY,
GADGET_ID_GRAVITY,
&level.gravity,
"gravity", "set level gravity"
},
{
- ED_SETTINGS_XPOS, ED_COUNTER2_YPOS(9) - MINI_TILEY,
+ ED_SETTINGS_XPOS(0), ED_COUNTER2_YPOS(9) - MINI_TILEY,
GADGET_ID_RANDOM_RESTRICTED,
&random_placement_background_restricted,
"restrict random placement to", "set random placement restriction"
},
{
- ED_SETTINGS_XPOS, ED_COUNTER_YPOS(4),
+ ED_SETTINGS_XPOS(0), 0, /* set at runtime */
GADGET_ID_STICK_ELEMENT,
&stick_element_properties_window,
- "stick window to edit content", "stick window to edit content"
+ "stick this screen to edit content","stick this screen to edit content"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(4),
+ GADGET_ID_EM_SLIPPERY_GEMS,
+ &level.em_slippery_gems,
+ "slip down from certain flat walls","use EM style slipping behaviour"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(3),
+ GADGET_ID_CUSTOM_INDESTRUCTIBLE,
+ &custom_element_properties[EP_INDESTRUCTIBLE],
+ "indestructible", "element cannot be destroyed"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(4),
+ GADGET_ID_CUSTOM_WALK_TO_OBJECT,
+ &custom_element_properties[EP_WALK_TO_OBJECT],
+ NULL, "player can dig/collect/push element"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(5),
+ GADGET_ID_CUSTOM_CAN_MOVE,
+ &custom_element_properties[EP_CAN_MOVE],
+ NULL, "element can move in some direction"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(6),
+ GADGET_ID_CUSTOM_CAN_FALL,
+ &custom_element_properties[EP_CAN_FALL],
+ "can fall", "element can fall down"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(7),
+ GADGET_ID_CUSTOM_CAN_SMASH,
+ &custom_element_properties[EP_CAN_SMASH],
+ "can smash", "element can smash other elements"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(8),
+ GADGET_ID_CUSTOM_CAN_EXPLODE,
+ &custom_element_properties[EP_CAN_EXPLODE],
+ "can explode to:", "element can explode to other elements"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(9),
+ GADGET_ID_CUSTOM_SLIPPERY,
+ &custom_element_properties[EP_SLIPPERY],
+ "slippery", "other elements can fall down from it"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(10),
+ GADGET_ID_CUSTOM_WALKABLE,
+ &custom_element_properties[EP_WALKABLE],
+ NULL, "player can walk on the same field"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
+ GADGET_ID_CUSTOM_USE_GRAPHIC,
+ &custom_element.use_gfx_element,
+ "use graphic of element:", "use graphic for custom element"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
+ GADGET_ID_CUSTOM_CHANGEABLE,
+ &custom_element_properties[EP_CHANGEABLE],
+ "element changes to after:", "element can change to other element"
+ },
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(2),
+ GADGET_ID_CHANGE_DELAY_FIXED,
+ &custom_element_change_events[CE_DELAY_FIXED],
+ "delay of", "element changes after fixed delay"
+ },
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(3),
+ GADGET_ID_CHANGE_DELAY_RANDOM,
+ &custom_element_change_events[CE_DELAY_RANDOM],
+ "delay of", "element changes after random delay"
}
};
-/* maximal size of level editor drawing area */
-#define MAX_ED_FIELDX (2 * SCR_FIELDX)
-#define MAX_ED_FIELDY (2 * SCR_FIELDY - 1)
+
+/*
+ -----------------------------------------------------------------------------
+ some internally used variables
+ -----------------------------------------------------------------------------
+*/
/* actual size of level editor drawing area */
static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1;
#define IN_ED_FIELD(x,y) ((x)>=0 && (x)<ed_fieldx && (y)>=0 &&(y)<ed_fieldy)
/* drawing elements on the three mouse buttons */
-static int new_element1 = EL_MAUERWERK;
-static int new_element2 = EL_LEERRAUM;
-static int new_element3 = EL_ERDREICH;
+static int new_element1 = EL_WALL;
+static int new_element2 = EL_EMPTY;
+static int new_element3 = EL_SAND;
#define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
(button) == 2 ? new_element2 : \
- (button) == 3 ? new_element3 : EL_LEERRAUM)
+ (button) == 3 ? new_element3 : EL_EMPTY)
#define BUTTON_STEPSIZE(button) ((button) == 1 ? 1 : (button) == 2 ? 5 : 10)
/* forward declaration for internal use */
static void ModifyEditorCounter(int, int);
static void ModifyEditorCounterLimits(int, int, int);
+static void ModifyEditorSelectbox(int, int);
+static void ModifyEditorElementList();
static void DrawDrawingWindow();
static void DrawLevelInfoWindow();
static void DrawPropertiesWindow();
+static boolean checkPropertiesConfig();
static void CopyLevelToUndoBuffer(int);
static void HandleDrawingAreas(struct GadgetInfo *);
static void HandleCounterButtons(struct GadgetInfo *);
static void HandleTextInputGadgets(struct GadgetInfo *);
+static void HandleSelectboxGadgets(struct GadgetInfo *);
+static void HandleTextbuttonGadgets(struct GadgetInfo *);
static void HandleRadiobuttons(struct GadgetInfo *);
static void HandleCheckbuttons(struct GadgetInfo *);
static void HandleControlButtons(struct GadgetInfo *);
static boolean draw_with_brush = FALSE;
static int properties_element = 0;
-static short ElementContent[MAX_ELEMENT_CONTENTS][3][3];
static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
static int undo_buffer_position = 0;
static int undo_buffer_steps = 0;
static int edit_mode;
+static int edit_mode_properties;
-static int counter_xsize = DXSIZE + FONT2_XSIZE - 2 * ED_GADGET_DISTANCE;
+static int element_shift = 0;
-int element_shift = 0;
-
-int editor_element[] =
+static int editor_el_boulderdash[] =
{
EL_CHAR('B'),
EL_CHAR('O'),
EL_CHAR('S'),
EL_CHAR('H'),
- EL_SPIELFIGUR,
- EL_LEERRAUM,
- EL_ERDREICH,
- EL_BETON,
+ EL_PLAYER_1,
+ EL_EMPTY,
+ EL_SAND,
+ EL_STEELWALL,
EL_BD_WALL,
- EL_MAGIC_WALL_BD_OFF,
- EL_AUSGANG_ZU,
- EL_AUSGANG_AUF,
+ EL_BD_MAGIC_WALL,
+ EL_EXIT_CLOSED,
+ EL_EXIT_OPEN,
- EL_EDELSTEIN_BD,
- EL_BUTTERFLY_UP,
- EL_FIREFLY_UP,
+ EL_BD_DIAMOND,
+ EL_BD_BUTTERFLY_UP,
+ EL_BD_FIREFLY_UP,
EL_BD_ROCK,
- EL_BUTTERFLY_LEFT,
- EL_FIREFLY_LEFT,
- EL_BUTTERFLY_RIGHT,
- EL_FIREFLY_RIGHT,
+ EL_BD_BUTTERFLY_LEFT,
+ EL_BD_FIREFLY_LEFT,
+ EL_BD_BUTTERFLY_RIGHT,
+ EL_BD_FIREFLY_RIGHT,
- EL_AMOEBE_BD,
- EL_BUTTERFLY_DOWN,
- EL_FIREFLY_DOWN,
- EL_LEERRAUM,
+ EL_BD_AMOEBA,
+ EL_BD_BUTTERFLY_DOWN,
+ EL_BD_FIREFLY_DOWN,
+ EL_EMPTY,
+};
+static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
+static int editor_el_emerald_mine[] =
+{
EL_CHAR('E'),
EL_CHAR('M'),
EL_CHAR('E'),
EL_CHAR('N'),
EL_CHAR('E'),
- EL_SPIELER1,
- EL_SPIELER2,
- EL_SPIELER3,
- EL_SPIELER4,
+ EL_PLAYER_1,
+ EL_PLAYER_2,
+ EL_PLAYER_3,
+ EL_PLAYER_4,
- EL_SPIELFIGUR,
- EL_LEERRAUM,
- EL_ERDREICH,
- EL_FELSBROCKEN,
+ EL_PLAYER_1,
+ EL_EMPTY,
+ EL_SAND,
+ EL_ROCK,
- EL_BETON,
- EL_MAUERWERK,
- EL_FELSBODEN,
- EL_MAGIC_WALL_OFF,
+ EL_STEELWALL,
+ EL_WALL,
+ EL_WALL_CRUMBLED,
+ EL_MAGIC_WALL,
- EL_EDELSTEIN,
- EL_DIAMANT,
- EL_KOKOSNUSS,
- EL_BOMBE,
+ EL_EMERALD,
+ EL_DIAMOND,
+ EL_NUT,
+ EL_BOMB,
- EL_ERZ_EDEL,
- EL_ERZ_DIAM,
- EL_MORAST_LEER,
- EL_MORAST_VOLL,
+ EL_WALL_EMERALD,
+ EL_WALL_DIAMOND,
+ EL_QUICKSAND_EMPTY,
+ EL_QUICKSAND_FULL,
- EL_DYNAMITE_INACTIVE,
+ EL_DYNAMITE,
EL_DYNAMITE_ACTIVE,
- EL_AUSGANG_ZU,
- EL_AUSGANG_AUF,
+ EL_EXIT_CLOSED,
+ EL_EXIT_OPEN,
- EL_MAMPFER,
- EL_KAEFER_UP,
- EL_FLIEGER_UP,
+ EL_YAMYAM,
+ EL_BUG_UP,
+ EL_SPACESHIP_UP,
EL_ROBOT,
- EL_KAEFER_LEFT,
- EL_FLIEGER_LEFT,
- EL_KAEFER_RIGHT,
- EL_FLIEGER_RIGHT,
+ EL_BUG_LEFT,
+ EL_SPACESHIP_LEFT,
+ EL_BUG_RIGHT,
+ EL_SPACESHIP_RIGHT,
- EL_ABLENK_AUS,
- EL_KAEFER_DOWN,
- EL_FLIEGER_DOWN,
- EL_UNSICHTBAR,
+ EL_ROBOT_WHEEL,
+ EL_BUG_DOWN,
+ EL_SPACESHIP_DOWN,
+ EL_INVISIBLE_WALL,
- EL_BADEWANNE1,
- EL_SALZSAEURE,
- EL_BADEWANNE2,
- EL_LEERRAUM,
+ EL_ACID_POOL_TOPLEFT,
+ EL_ACID,
+ EL_ACID_POOL_TOPRIGHT,
+ EL_EMPTY,
- EL_BADEWANNE3,
- EL_BADEWANNE4,
- EL_BADEWANNE5,
- EL_LEERRAUM,
+ EL_ACID_POOL_BOTTOMLEFT,
+ EL_ACID_POOL_BOTTOM,
+ EL_ACID_POOL_BOTTOMRIGHT,
+ EL_EMPTY,
- EL_TROPFEN,
- EL_AMOEBE_TOT,
- EL_AMOEBE_NASS,
- EL_AMOEBE_NORM,
+ EL_AMOEBA_DROP,
+ EL_AMOEBA_DEAD,
+ EL_AMOEBA_WET,
+ EL_AMOEBA_DRY,
EL_EM_KEY_1_FILE,
EL_EM_KEY_2_FILE,
EL_EM_GATE_3,
EL_EM_GATE_4,
- EL_EM_GATE_1X,
- EL_EM_GATE_2X,
- EL_EM_GATE_3X,
- EL_EM_GATE_4X,
+ EL_EM_GATE_1_GRAY,
+ EL_EM_GATE_2_GRAY,
+ EL_EM_GATE_3_GRAY,
+ EL_EM_GATE_4_GRAY,
+};
+static int num_editor_el_emerald_mine = SIZEOF_ARRAY_INT(editor_el_emerald_mine);
+static int editor_el_more[] =
+{
EL_CHAR('M'),
EL_CHAR('O'),
EL_CHAR('R'),
EL_CHAR('E'),
- EL_SCHLUESSEL1,
- EL_SCHLUESSEL2,
- EL_SCHLUESSEL3,
- EL_SCHLUESSEL4,
-
- EL_PFORTE1,
- EL_PFORTE2,
- EL_PFORTE3,
- EL_PFORTE4,
-
- EL_PFORTE1X,
- EL_PFORTE2X,
- EL_PFORTE3X,
- EL_PFORTE4X,
-
- EL_PFEIL_LEFT,
- EL_PFEIL_RIGHT,
- EL_PFEIL_UP,
- EL_PFEIL_DOWN,
-
- EL_AMOEBE_VOLL,
- EL_EDELSTEIN_GELB,
- EL_EDELSTEIN_ROT,
- EL_EDELSTEIN_LILA,
-
- EL_ERZ_EDEL_BD,
- EL_ERZ_EDEL_GELB,
- EL_ERZ_EDEL_ROT,
- EL_ERZ_EDEL_LILA,
-
- EL_LIFE,
+ EL_KEY_1,
+ EL_KEY_2,
+ EL_KEY_3,
+ EL_KEY_4,
+
+ EL_GATE_1,
+ EL_GATE_2,
+ EL_GATE_3,
+ EL_GATE_4,
+
+ EL_GATE_1_GRAY,
+ EL_GATE_2_GRAY,
+ EL_GATE_3_GRAY,
+ EL_GATE_4_GRAY,
+
+ EL_ARROW_LEFT,
+ EL_ARROW_RIGHT,
+ EL_ARROW_UP,
+ EL_ARROW_DOWN,
+
+ EL_AMOEBA_FULL,
+ EL_EMERALD_YELLOW,
+ EL_EMERALD_RED,
+ EL_EMERALD_PURPLE,
+
+ EL_WALL_BD_DIAMOND,
+ EL_WALL_EMERALD_YELLOW,
+ EL_WALL_EMERALD_RED,
+ EL_WALL_EMERALD_PURPLE,
+
+ EL_GAME_OF_LIFE,
EL_PACMAN_UP,
- EL_ZEIT_VOLL,
- EL_ZEIT_LEER,
+ EL_TIME_ORB_FULL,
+ EL_TIME_ORB_EMPTY,
EL_PACMAN_LEFT,
- EL_MAMPFER2,
+ EL_DARK_YAMYAM,
EL_PACMAN_RIGHT,
- EL_MAUER_LEBT,
+ EL_EXPANDABLE_WALL,
- EL_LIFE_ASYNC,
+ EL_BIOMAZE,
EL_PACMAN_DOWN,
- EL_BIRNE_AUS,
- EL_BIRNE_EIN,
+ EL_LAMP,
+ EL_LAMP_ACTIVE,
- EL_DYNABOMB_NR,
- EL_DYNABOMB_SZ,
- EL_DYNABOMB_XL,
- EL_BADEWANNE,
+ EL_DYNABOMB_INCREASE_NUMBER,
+ EL_DYNABOMB_INCREASE_SIZE,
+ EL_DYNABOMB_INCREASE_POWER,
+ EL_STONEBLOCK,
EL_MOLE,
- EL_PINGUIN,
- EL_SCHWEIN,
- EL_DRACHE,
+ EL_PENGUIN,
+ EL_PIG,
+ EL_DRAGON,
- EL_LEERRAUM,
+ EL_EMPTY,
EL_MOLE_UP,
- EL_LEERRAUM,
- EL_LEERRAUM,
+ EL_EMPTY,
+ EL_EMPTY,
EL_MOLE_LEFT,
- EL_LEERRAUM,
+ EL_EMPTY,
EL_MOLE_RIGHT,
- EL_LEERRAUM,
+ EL_EMPTY,
- EL_LEERRAUM,
+ EL_EMPTY,
EL_MOLE_DOWN,
EL_BALLOON,
- EL_BALLOON_SEND_ANY,
+ EL_BALLOON_SWITCH_ANY,
- EL_BALLOON_SEND_LEFT,
- EL_BALLOON_SEND_RIGHT,
- EL_BALLOON_SEND_UP,
- EL_BALLOON_SEND_DOWN,
+ EL_BALLOON_SWITCH_LEFT,
+ EL_BALLOON_SWITCH_RIGHT,
+ EL_BALLOON_SWITCH_UP,
+ EL_BALLOON_SWITCH_DOWN,
- EL_SONDE,
- EL_MAUER_X,
- EL_MAUER_Y,
- EL_MAUER_XY,
+ EL_SATELLITE,
+ EL_EXPANDABLE_WALL_HORIZONTAL,
+ EL_EXPANDABLE_WALL_VERTICAL,
+ EL_EXPANDABLE_WALL_ANY,
- EL_INVISIBLE_STEEL,
- EL_UNSICHTBAR,
+ EL_INVISIBLE_STEELWALL,
+ EL_INVISIBLE_WALL,
EL_SPEED_PILL,
EL_BLACK_ORB,
- EL_EMC_STEEL_WALL_1,
+ EL_EMC_STEELWALL_1,
EL_EMC_WALL_1,
EL_EMC_WALL_2,
EL_EMC_WALL_3,
EL_EMC_WALL_5,
EL_EMC_WALL_6,
EL_EMC_WALL_7,
+};
+static int num_editor_el_more = SIZEOF_ARRAY_INT(editor_el_more);
-
+static int editor_el_sokoban[] =
+{
EL_CHAR('S'),
EL_CHAR('O'),
EL_CHAR('K'),
EL_CHAR('A'),
EL_CHAR('N'),
- EL_SOKOBAN_OBJEKT,
- EL_SOKOBAN_FELD_LEER,
- EL_SOKOBAN_FELD_VOLL,
- EL_BETON,
+ EL_SOKOBAN_OBJECT,
+ EL_SOKOBAN_FIELD_EMPTY,
+ EL_SOKOBAN_FIELD_FULL,
+ EL_STEELWALL,
+};
+static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
+static int editor_el_supaplex[] =
+{
EL_CHAR('S'),
EL_CHAR('U'),
EL_CHAR('P'),
EL_SP_INFOTRON,
EL_SP_CHIP_SINGLE,
- EL_SP_HARD_GRAY,
- EL_SP_EXIT,
+ EL_SP_HARDWARE_GRAY,
+ EL_SP_EXIT_CLOSED,
EL_SP_DISK_ORANGE,
- EL_SP_PORT1_RIGHT,
- EL_SP_PORT1_DOWN,
- EL_SP_PORT1_LEFT,
+ EL_SP_PORT_RIGHT,
+ EL_SP_PORT_DOWN,
+ EL_SP_PORT_LEFT,
- EL_SP_PORT1_UP,
- EL_SP_PORT2_RIGHT,
- EL_SP_PORT2_DOWN,
- EL_SP_PORT2_LEFT,
+ EL_SP_PORT_UP,
+ EL_SP_GRAVITY_PORT_RIGHT,
+ EL_SP_GRAVITY_PORT_DOWN,
+ EL_SP_GRAVITY_PORT_LEFT,
- EL_SP_PORT2_UP,
+ EL_SP_GRAVITY_PORT_UP,
EL_SP_SNIKSNAK,
EL_SP_DISK_YELLOW,
EL_SP_TERMINAL,
EL_SP_DISK_RED,
- EL_SP_PORT_Y,
- EL_SP_PORT_X,
- EL_SP_PORT_XY,
+ EL_SP_PORT_VERTICAL,
+ EL_SP_PORT_HORIZONTAL,
+ EL_SP_PORT_ANY,
EL_SP_ELECTRON,
- EL_SP_BUG,
+ EL_SP_BUGGY_BASE,
EL_SP_CHIP_LEFT,
EL_SP_CHIP_RIGHT,
- EL_SP_HARD_BASE1,
- EL_SP_HARD_GREEN,
- EL_SP_HARD_BLUE,
- EL_SP_HARD_RED,
+ EL_SP_HARDWARE_BASE_1,
+ EL_SP_HARDWARE_GREEN,
+ EL_SP_HARDWARE_BLUE,
+ EL_SP_HARDWARE_RED,
- EL_SP_HARD_YELLOW,
- EL_SP_HARD_BASE2,
- EL_SP_HARD_BASE3,
- EL_SP_HARD_BASE4,
+ EL_SP_HARDWARE_YELLOW,
+ EL_SP_HARDWARE_BASE_2,
+ EL_SP_HARDWARE_BASE_3,
+ EL_SP_HARDWARE_BASE_4,
- EL_SP_HARD_BASE5,
- EL_SP_HARD_BASE6,
- EL_SP_CHIP_UPPER,
- EL_SP_CHIP_LOWER,
+ EL_SP_HARDWARE_BASE_5,
+ EL_SP_HARDWARE_BASE_6,
+ EL_SP_CHIP_TOP,
+ EL_SP_CHIP_BOTTOM,
+};
+static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
+static int editor_el_diamond_caves[] =
+{
EL_CHAR('D'),
EL_CHAR('I'),
EL_CHAR('A'),
EL_WALL_PEARL,
EL_WALL_CRYSTAL,
- EL_BELT1_LEFT,
- EL_BELT1_MIDDLE,
- EL_BELT1_RIGHT,
- EL_BELT1_SWITCH_MIDDLE,
+ EL_CONVEYOR_BELT_1_LEFT,
+ EL_CONVEYOR_BELT_1_MIDDLE,
+ EL_CONVEYOR_BELT_1_RIGHT,
+ EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
- EL_BELT2_LEFT,
- EL_BELT2_MIDDLE,
- EL_BELT2_RIGHT,
- EL_BELT2_SWITCH_MIDDLE,
+ EL_CONVEYOR_BELT_2_LEFT,
+ EL_CONVEYOR_BELT_2_MIDDLE,
+ EL_CONVEYOR_BELT_2_RIGHT,
+ EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
- EL_BELT3_LEFT,
- EL_BELT3_MIDDLE,
- EL_BELT3_RIGHT,
- EL_BELT3_SWITCH_MIDDLE,
+ EL_CONVEYOR_BELT_3_LEFT,
+ EL_CONVEYOR_BELT_3_MIDDLE,
+ EL_CONVEYOR_BELT_3_RIGHT,
+ EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
- EL_BELT4_LEFT,
- EL_BELT4_MIDDLE,
- EL_BELT4_RIGHT,
- EL_BELT4_SWITCH_MIDDLE,
+ EL_CONVEYOR_BELT_4_LEFT,
+ EL_CONVEYOR_BELT_4_MIDDLE,
+ EL_CONVEYOR_BELT_4_RIGHT,
+ EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
- EL_BELT1_SWITCH_LEFT,
- EL_BELT2_SWITCH_LEFT,
- EL_BELT3_SWITCH_LEFT,
- EL_BELT4_SWITCH_LEFT,
+ EL_CONVEYOR_BELT_1_SWITCH_LEFT,
+ EL_CONVEYOR_BELT_2_SWITCH_LEFT,
+ EL_CONVEYOR_BELT_3_SWITCH_LEFT,
+ EL_CONVEYOR_BELT_4_SWITCH_LEFT,
- EL_BELT1_SWITCH_RIGHT,
- EL_BELT2_SWITCH_RIGHT,
- EL_BELT3_SWITCH_RIGHT,
- EL_BELT4_SWITCH_RIGHT,
+ EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
+ EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
+ EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
+ EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
EL_SWITCHGATE_OPEN,
EL_SWITCHGATE_CLOSED,
- EL_SWITCHGATE_SWITCH_1,
+ EL_SWITCHGATE_SWITCH_UP,
EL_ENVELOPE,
EL_TIMEGATE_CLOSED,
EL_TIMEGATE_OPEN,
- EL_TIMEGATE_SWITCH_OFF,
- EL_LEERRAUM,
+ EL_TIMEGATE_SWITCH,
+ EL_EMPTY,
EL_LANDMINE,
- EL_SAND_INVISIBLE,
- EL_STEEL_SLANTED,
- EL_LEERRAUM,
+ EL_INVISIBLE_SAND,
+ EL_STEELWALL_SLANTED,
+ EL_EMPTY,
EL_SIGN_EXCLAMATION,
EL_SIGN_STOP,
- EL_LIGHT_SWITCH_OFF,
- EL_LIGHT_SWITCH_ON,
+ EL_LIGHT_SWITCH,
+ EL_LIGHT_SWITCH_ACTIVE,
- EL_SHIELD_PASSIVE,
- EL_SHIELD_ACTIVE,
+ EL_SHIELD_NORMAL,
+ EL_SHIELD_DEADLY,
EL_EXTRA_TIME,
- EL_LEERRAUM,
+ EL_EMPTY,
+};
+static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
+static int editor_el_dx_boulderdash[] =
+{
EL_CHAR('D'),
EL_CHAR('X'),
EL_CHAR('-'),
EL_SPRING,
EL_TUBE_RIGHT_DOWN,
- EL_TUBE_HORIZ_DOWN,
+ EL_TUBE_HORIZONTAL_DOWN,
EL_TUBE_LEFT_DOWN,
EL_TUBE_HORIZONTAL,
- EL_TUBE_VERT_RIGHT,
- EL_TUBE_CROSS,
- EL_TUBE_VERT_LEFT,
+ EL_TUBE_VERTICAL_RIGHT,
+ EL_TUBE_ANY,
+ EL_TUBE_VERTICAL_LEFT,
EL_TUBE_VERTICAL,
EL_TUBE_RIGHT_UP,
- EL_TUBE_HORIZ_UP,
+ EL_TUBE_HORIZONTAL_UP,
EL_TUBE_LEFT_UP,
- EL_TRAP_INACTIVE,
+ EL_TRAP,
EL_DX_SUPABOMB,
- EL_LEERRAUM,
- EL_LEERRAUM,
-
- /*
- EL_CHAR('D'),
- EL_CHAR('Y'),
- EL_CHAR('N'),
- EL_CHAR('A'),
-
- EL_CHAR('B'),
- EL_CHAR('L'),
- EL_CHAR('A'),
- EL_CHAR('S'),
+ EL_EMPTY,
+ EL_EMPTY
+};
+static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
- EL_CHAR_MINUS,
+static int editor_el_chars[] =
+{
EL_CHAR('T'),
EL_CHAR('E'),
- EL_CHAR('R'),
- */
-
- EL_LEERRAUM,
- EL_LEERRAUM,
- EL_LEERRAUM,
- EL_LEERRAUM,
+ EL_CHAR('X'),
+ EL_CHAR('T'),
EL_CHAR(' '),
EL_CHAR('!'),
EL_CHAR('X'),
EL_CHAR('Y'),
EL_CHAR('Z'),
- EL_CHAR('Ä'),
+ EL_CHAR('['),
+
+ EL_CHAR('\\'),
+ EL_CHAR(']'),
+ EL_CHAR('^'),
+ EL_CHAR('_'),
+ EL_CHAR('©'),
+ EL_CHAR('Ä'),
EL_CHAR('Ö'),
EL_CHAR('Ü'),
- EL_CHAR('^'),
+
+ EL_CHAR('°'),
+ EL_CHAR('®'),
+ EL_CHAR(FONT_ASCII_CURSOR),
EL_CHAR(' ')
};
-int elements_in_list = sizeof(editor_element)/sizeof(int);
+static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
-static char *getElementInfoText(int element)
+static int editor_el_custom[] =
{
- char *info_text = "unknown";
-
- if (element < num_element_info)
- info_text = element_info[element];
- else
- Error(ERR_WARN, "no element description for element %d", element);
+ EL_CHAR('C'),
+ EL_CHAR('U'),
+ EL_CHAR('S'),
+ EL_CHAR('-'),
- return info_text;
-}
+ EL_CHAR('T'),
+ EL_CHAR('O'),
+ EL_CHAR('M'),
+ EL_CHAR(' '),
-static void ScrollMiniLevel(int from_x, int from_y, int scroll)
-{
+ EL_CHAR('E'),
+ EL_CHAR('L'),
+ EL_CHAR('E'),
+ EL_CHAR('M'),
+
+ EL_CHAR('E'),
+ EL_CHAR('N'),
+ EL_CHAR('T'),
+ EL_CHAR('S'),
+
+ EL_CUSTOM_START + 0,
+ EL_CUSTOM_START + 1,
+ EL_CUSTOM_START + 2,
+ EL_CUSTOM_START + 3,
+
+ EL_CUSTOM_START + 4,
+ EL_CUSTOM_START + 5,
+ EL_CUSTOM_START + 6,
+ EL_CUSTOM_START + 7,
+
+ EL_CUSTOM_START + 8,
+ EL_CUSTOM_START + 9,
+ EL_CUSTOM_START + 10,
+ EL_CUSTOM_START + 11,
+
+ EL_CUSTOM_START + 12,
+ EL_CUSTOM_START + 13,
+ EL_CUSTOM_START + 14,
+ EL_CUSTOM_START + 15,
+
+ EL_CUSTOM_START + 16,
+ EL_CUSTOM_START + 17,
+ EL_CUSTOM_START + 18,
+ EL_CUSTOM_START + 19,
+
+ EL_CUSTOM_START + 20,
+ EL_CUSTOM_START + 21,
+ EL_CUSTOM_START + 22,
+ EL_CUSTOM_START + 23,
+
+ EL_CUSTOM_START + 24,
+ EL_CUSTOM_START + 25,
+ EL_CUSTOM_START + 26,
+ EL_CUSTOM_START + 27,
+
+ EL_CUSTOM_START + 28,
+ EL_CUSTOM_START + 29,
+ EL_CUSTOM_START + 30,
+ EL_CUSTOM_START + 31,
+
+ EL_CUSTOM_START + 32,
+ EL_CUSTOM_START + 33,
+ EL_CUSTOM_START + 34,
+ EL_CUSTOM_START + 35,
+
+ EL_CUSTOM_START + 36,
+ EL_CUSTOM_START + 37,
+ EL_CUSTOM_START + 38,
+ EL_CUSTOM_START + 39,
+
+ EL_CUSTOM_START + 40,
+ EL_CUSTOM_START + 41,
+ EL_CUSTOM_START + 42,
+ EL_CUSTOM_START + 43,
+
+ EL_CUSTOM_START + 44,
+ EL_CUSTOM_START + 45,
+ EL_CUSTOM_START + 46,
+ EL_CUSTOM_START + 47,
+
+ EL_CUSTOM_START + 48,
+ EL_CUSTOM_START + 49,
+ EL_CUSTOM_START + 50,
+ EL_CUSTOM_START + 51,
+
+ EL_CUSTOM_START + 52,
+ EL_CUSTOM_START + 53,
+ EL_CUSTOM_START + 54,
+ EL_CUSTOM_START + 55,
+
+ EL_CUSTOM_START + 56,
+ EL_CUSTOM_START + 57,
+ EL_CUSTOM_START + 58,
+ EL_CUSTOM_START + 59,
+
+ EL_CUSTOM_START + 60,
+ EL_CUSTOM_START + 61,
+ EL_CUSTOM_START + 62,
+ EL_CUSTOM_START + 63,
+
+ EL_CUSTOM_START + 64,
+ EL_CUSTOM_START + 65,
+ EL_CUSTOM_START + 66,
+ EL_CUSTOM_START + 67,
+
+ EL_CUSTOM_START + 68,
+ EL_CUSTOM_START + 69,
+ EL_CUSTOM_START + 70,
+ EL_CUSTOM_START + 71,
+
+ EL_CUSTOM_START + 72,
+ EL_CUSTOM_START + 73,
+ EL_CUSTOM_START + 74,
+ EL_CUSTOM_START + 75,
+
+ EL_CUSTOM_START + 76,
+ EL_CUSTOM_START + 77,
+ EL_CUSTOM_START + 78,
+ EL_CUSTOM_START + 79,
+
+ EL_CUSTOM_START + 80,
+ EL_CUSTOM_START + 81,
+ EL_CUSTOM_START + 82,
+ EL_CUSTOM_START + 83,
+
+ EL_CUSTOM_START + 84,
+ EL_CUSTOM_START + 85,
+ EL_CUSTOM_START + 86,
+ EL_CUSTOM_START + 87,
+
+ EL_CUSTOM_START + 88,
+ EL_CUSTOM_START + 89,
+ EL_CUSTOM_START + 90,
+ EL_CUSTOM_START + 91,
+
+ EL_CUSTOM_START + 92,
+ EL_CUSTOM_START + 93,
+ EL_CUSTOM_START + 94,
+ EL_CUSTOM_START + 95,
+
+ EL_CUSTOM_START + 96,
+ EL_CUSTOM_START + 97,
+ EL_CUSTOM_START + 98,
+ EL_CUSTOM_START + 99,
+
+ EL_CUSTOM_START + 100,
+ EL_CUSTOM_START + 101,
+ EL_CUSTOM_START + 102,
+ EL_CUSTOM_START + 103,
+
+ EL_CUSTOM_START + 104,
+ EL_CUSTOM_START + 105,
+ EL_CUSTOM_START + 106,
+ EL_CUSTOM_START + 107,
+
+ EL_CUSTOM_START + 108,
+ EL_CUSTOM_START + 109,
+ EL_CUSTOM_START + 110,
+ EL_CUSTOM_START + 111,
+
+ EL_CUSTOM_START + 112,
+ EL_CUSTOM_START + 113,
+ EL_CUSTOM_START + 114,
+ EL_CUSTOM_START + 115,
+
+ EL_CUSTOM_START + 116,
+ EL_CUSTOM_START + 117,
+ EL_CUSTOM_START + 118,
+ EL_CUSTOM_START + 119,
+
+ EL_CUSTOM_START + 120,
+ EL_CUSTOM_START + 121,
+ EL_CUSTOM_START + 122,
+ EL_CUSTOM_START + 123,
+
+ EL_CUSTOM_START + 124,
+ EL_CUSTOM_START + 125,
+ EL_CUSTOM_START + 126,
+ EL_CUSTOM_START + 127
+};
+static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
+
+static int *editor_elements = NULL; /* dynamically allocated */
+static int num_editor_elements = 0; /* dynamically determined */
+
+static struct
+{
+ boolean *setup_value;
+ int *element_list;
+ int *element_list_size;
+
+ boolean last_setup_value;
+}
+editor_elements_info[] =
+{
+ { &setup.editor.el_boulderdash, editor_el_boulderdash,
+ &num_editor_el_boulderdash },
+ { &setup.editor.el_emerald_mine, editor_el_emerald_mine,
+ &num_editor_el_emerald_mine },
+ { &setup.editor.el_more, editor_el_more,
+ &num_editor_el_more },
+ { &setup.editor.el_sokoban, editor_el_sokoban,
+ &num_editor_el_sokoban },
+ { &setup.editor.el_supaplex, editor_el_supaplex,
+ &num_editor_el_supaplex },
+ { &setup.editor.el_diamond_caves, editor_el_diamond_caves,
+ &num_editor_el_diamond_caves },
+ { &setup.editor.el_dx_boulderdash, editor_el_dx_boulderdash,
+ &num_editor_el_dx_boulderdash },
+ { &setup.editor.el_chars, editor_el_chars,
+ &num_editor_el_chars },
+ { &setup.editor.el_custom, editor_el_custom,
+ &num_editor_el_custom },
+ { NULL, NULL,
+ NULL }
+};
+
+
+/*
+ -----------------------------------------------------------------------------
+ functions
+ -----------------------------------------------------------------------------
+*/
+
+static void ReinitializeElementList()
+{
+ int pos = 0;
+ int i, j;
+
+ if (editor_elements != NULL)
+ free(editor_elements);
+
+ num_editor_elements = 0;
+
+ /* determine size of element list */
+ for (i=0; editor_elements_info[i].setup_value != NULL; i++)
+ if (*editor_elements_info[i].setup_value)
+ num_editor_elements += *editor_elements_info[i].element_list_size;
+
+ if (num_editor_elements < ED_NUM_ELEMENTLIST_BUTTONS)
+ {
+ /* workaround: offer at least as many elements as element buttons exist */
+ int list_nr = 1; /* see above: editor_elements_info for Emerald Mine */
+
+ *editor_elements_info[list_nr].setup_value = TRUE;
+ num_editor_elements += *editor_elements_info[list_nr].element_list_size;
+ }
+
+ editor_elements = checked_malloc(num_editor_elements * sizeof(int));
+
+ /* fill element list */
+ for (i=0; editor_elements_info[i].setup_value != NULL; i++)
+ if (*editor_elements_info[i].setup_value)
+ for (j=0; j<*editor_elements_info[i].element_list_size; j++)
+ editor_elements[pos++] = editor_elements_info[i].element_list[j];
+}
+
+static void ReinitializeElementListButtons()
+{
+ static boolean initialization_needed = TRUE;
+ int i;
+
+ if (!initialization_needed) /* check if editor element setup has changed */
+ for (i=0; editor_elements_info[i].setup_value != NULL; i++)
+ if (editor_elements_info[i].last_setup_value !=
+ *editor_elements_info[i].setup_value)
+ initialization_needed = TRUE;
+
+ if (!initialization_needed)
+ return;
+
+ FreeLevelEditorGadgets();
+ CreateLevelEditorGadgets();
+
+ /* store current setup values for next invocation of this function */
+ for (i=0; editor_elements_info[i].setup_value != NULL; i++)
+ editor_elements_info[i].last_setup_value =
+ *editor_elements_info[i].setup_value;
+
+ initialization_needed = FALSE;
+}
+
+static int getCounterGadgetWidth()
+{
+ return (DXSIZE + getFontWidth(FONT_INPUT_1) - 2 * ED_GADGET_DISTANCE);
+}
+
+static int getMaxInfoTextLength()
+{
+ return (SXSIZE / getFontWidth(FONT_TEXT_2));
+}
+
+static char *getElementInfoText(int element)
+{
+ char *info_text = NULL;
+
+ if (element < NUM_FILE_ELEMENTS)
+ {
+ if (element_info[element].custom_description != NULL)
+ info_text = element_info[element].custom_description;
+ else if (element_info[element].editor_description != NULL)
+ info_text = element_info[element].editor_description;
+ }
+
+ if (info_text == NULL)
+ {
+ info_text = "unknown";
+
+ Error(ERR_WARN, "no element description for element %d", element);
+ }
+
+ return info_text;
+}
+
+static void ScrollMiniLevel(int from_x, int from_y, int scroll)
+{
int x,y;
int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
static void CreateControlButtons()
{
- Bitmap gd_bitmap = pix[PIX_DOOR];
+ Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
struct GadgetInfo *gi;
unsigned long event_mask;
int i;
/* create buttons for element list */
for (i=0; i<ED_NUM_ELEMENTLIST_BUTTONS; i++)
{
- Bitmap deco_bitmap;
+ Bitmap *deco_bitmap;
int deco_x, deco_y, deco_xpos, deco_ypos;
int gd_xoffset, gd_yoffset;
int gd_x1, gd_x2, gd_y;
int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
int id = GADGET_ID_ELEMENTLIST_FIRST + i;
+ int element = editor_elements[i];
event_mask = GD_EVENT_RELEASED;
gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
gd_y = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
- getMiniGraphicSource(el2gfx(editor_element[i]),
- &deco_bitmap, &deco_x, &deco_y);
+ getMiniGraphicSource(el2edimg(element), &deco_bitmap, &deco_x, &deco_y);
deco_xpos = (ED_ELEMENTLIST_XSIZE - MINI_TILEX) / 2;
deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2;
gi = CreateGadget(GDI_CUSTOM_ID, id,
GDI_CUSTOM_TYPE_ID, i,
- GDI_INFO_TEXT, getElementInfoText(editor_element[i]),
+ GDI_INFO_TEXT, getElementInfoText(element),
GDI_X, DX + gd_xoffset,
GDI_Y, DY + gd_yoffset,
GDI_WIDTH, ED_ELEMENTLIST_XSIZE,
static void CreateCounterButtons()
{
+ int max_infotext_len = getMaxInfoTextLength();
int i;
for (i=0; i<ED_NUM_COUNTERBUTTONS; i++)
for (j=0; j<2; j++)
{
- Bitmap gd_bitmap = pix[PIX_DOOR];
+ Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
struct GadgetInfo *gi;
int id = (j == 0 ?
counterbutton_info[i].gadget_id_down :
int gd_x, gd_x1, gd_x2, gd_y;
int x_size, y_size;
unsigned long event_mask;
- char infotext[MAX_INFOTEXT_LEN + 1];
+ char infotext[max_infotext_len + 1];
event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
if (j == 0)
{
- int font_type = FC_YELLOW;
+ int font_type = FONT_INPUT_1;
+ int font_type_active = FONT_INPUT_1_ACTIVE;
int gd_width = ED_WIN_COUNT_XSIZE;
id = counterbutton_info[i].gadget_id_text;
if (i == ED_COUNTER_ID_SELECT_LEVEL)
{
- font_type = FC_SPECIAL3;
+ font_type = FONT_LEVEL_NUMBER;
+ font_type_active = FONT_LEVEL_NUMBER;
xpos += 2 * ED_GADGET_DISTANCE;
ypos -= ED_GADGET_DISTANCE;
GDI_NUMBER_MAX, counterbutton_info[i].max_value,
GDI_TEXT_SIZE, 3,
GDI_TEXT_FONT, font_type,
+ GDI_TEXT_FONT_ACTIVE, font_type_active,
GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
- GDI_BORDER_SIZE, ED_BORDER_SIZE,
- GDI_TEXTINPUT_DESIGN_WIDTH, gd_width,
+ GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
+ GDI_DESIGN_WIDTH, gd_width,
GDI_EVENT_MASK, event_mask,
GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleCounterButtons,
int gx = SX + ED_AREA_ELEM_CONTENT_XPOS + 5 * (i % 4) * MINI_TILEX;
int gy = SX + ED_AREA_ELEM_CONTENT_YPOS + 6 * (i / 4) * MINI_TILEY;
- id = GADGET_ID_ELEM_CONTENT_0 + i;
+ id = GADGET_ID_ELEMENT_CONTENT_0 + i;
gi = CreateGadget(GDI_CUSTOM_ID, id,
GDI_CUSTOM_TYPE_ID, i,
GDI_X, gx,
level_editor_gadget[id] = gi;
}
- /* ... one for the amoeba content */
+ /* ... one for the amoeba content ... */
id = GADGET_ID_AMOEBA_CONTENT;
gi = CreateGadget(GDI_CUSTOM_ID, id,
GDI_X, SX + ED_AREA_ELEM_CONTENT_XPOS,
level_editor_gadget[id] = gi;
+ /* ... one for each custom element optional graphic element ... */
+ id = GADGET_ID_CUSTOM_GRAPHIC;
+ gi = CreateGadget(GDI_CUSTOM_ID, id,
+ GDI_X, SX + ED_AREA_ELEM_CONTENT3_XPOS,
+ GDI_Y, SY + ED_AREA_ELEM_CONTENT3_YPOS,
+ GDI_WIDTH, MINI_TILEX,
+ GDI_HEIGHT, MINI_TILEY,
+ GDI_TYPE, GD_TYPE_DRAWING_AREA,
+ GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
+ GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
+ GDI_CALLBACK_ACTION, HandleDrawingAreas,
+ GDI_END);
+
+ if (gi == NULL)
+ Error(ERR_EXIT, "cannot create gadget");
+
+ level_editor_gadget[id] = gi;
+
+ /* ... one areas for custom element explosion content ... */
+ id = GADGET_ID_CUSTOM_CONTENT;
+ gi = CreateGadget(GDI_CUSTOM_ID, id,
+ GDI_CUSTOM_TYPE_ID, i,
+ GDI_X, SX + ED_AREA_ELEM_CONTENT4_XPOS,
+ GDI_Y, SX + ED_AREA_ELEM_CONTENT4_YPOS,
+ GDI_WIDTH, 3 * MINI_TILEX,
+ GDI_HEIGHT, 3 * MINI_TILEY,
+ GDI_TYPE, GD_TYPE_DRAWING_AREA,
+ GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
+ GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
+ GDI_CALLBACK_ACTION, HandleDrawingAreas,
+ GDI_END);
+
+ if (gi == NULL)
+ Error(ERR_EXIT, "cannot create gadget");
+
+ level_editor_gadget[id] = gi;
+
+ /* ... one for each custom element change target element ... */
+ id = GADGET_ID_CUSTOM_CHANGED;
+ gi = CreateGadget(GDI_CUSTOM_ID, id,
+ GDI_X, SX + ED_AREA_ELEM_CONTENT2_XPOS,
+ GDI_Y, SY + ED_AREA_ELEM_CONTENT2_YPOS,
+ GDI_WIDTH, MINI_TILEX,
+ GDI_HEIGHT, MINI_TILEY,
+ GDI_TYPE, GD_TYPE_DRAWING_AREA,
+ GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
+ GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
+ GDI_CALLBACK_ACTION, HandleDrawingAreas,
+ GDI_END);
+
+ if (gi == NULL)
+ Error(ERR_EXIT, "cannot create gadget");
+
+ level_editor_gadget[id] = gi;
+
/* ... and one for random placement background restrictions */
id = GADGET_ID_RANDOM_BACKGROUND;
static void CreateTextInputGadgets()
{
+ int max_infotext_len = getMaxInfoTextLength();
int i;
for (i=0; i<ED_NUM_TEXTINPUT; i++)
{
- Bitmap gd_bitmap = pix[PIX_DOOR];
+ Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
int gd_x, gd_y;
struct GadgetInfo *gi;
unsigned long event_mask;
- char infotext[1024];
+ char infotext[MAX_OUTPUT_LINESIZE + 1];
int id = textinput_info[i].gadget_id;
event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
sprintf(infotext, "Enter %s", textinput_info[i].infotext);
- infotext[MAX_INFOTEXT_LEN] = '\0';
+ infotext[max_infotext_len] = '\0';
gi = CreateGadget(GDI_CUSTOM_ID, id,
GDI_CUSTOM_TYPE_ID, i,
GDI_TYPE, GD_TYPE_TEXTINPUT_ALPHANUMERIC,
GDI_TEXT_VALUE, textinput_info[i].value,
GDI_TEXT_SIZE, textinput_info[i].size,
- GDI_TEXT_FONT, FC_YELLOW,
+ GDI_TEXT_FONT, FONT_INPUT_1,
+ GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
- GDI_BORDER_SIZE, ED_BORDER_SIZE,
- GDI_TEXTINPUT_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
+ GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
+ GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
GDI_EVENT_MASK, event_mask,
GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleTextInputGadgets,
}
}
+static void CreateSelectboxGadgets()
+{
+ int max_infotext_len = getMaxInfoTextLength();
+ int i, j;
+
+ for (i=0; i<ED_NUM_SELECTBOX; i++)
+ {
+ Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
+ int gd_x, gd_y;
+ int xoffset = 0;
+ struct GadgetInfo *gi;
+ unsigned long event_mask;
+ char infotext[MAX_OUTPUT_LINESIZE + 1];
+ int id = selectbox_info[i].gadget_id;
+
+ if (selectbox_info[i].size == 0) /* dynamically determined */
+ {
+ /* (we cannot use -1 for uninitialized values if we directly compare
+ with results from strlen(), because the '<' and '>' operation will
+ implicitely cast -1 to an unsigned integer value!) */
+
+ for (j=0; selectbox_info[i].options[j].text != NULL; j++)
+ if (strlen(selectbox_info[i].options[j].text) > selectbox_info[i].size)
+ selectbox_info[i].size = strlen(selectbox_info[i].options[j].text);
+
+ selectbox_info[i].size++; /* add one character empty space */
+ }
+
+ event_mask = GD_EVENT_RELEASED |
+ GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
+
+ gd_x = DOOR_GFX_PAGEX4 + ED_SELECTBOX_XPOS;
+ gd_y = DOOR_GFX_PAGEY1 + ED_SELECTBOX_YPOS;
+
+ /* determine horizontal offset for leading selectbox text */
+ if (selectbox_info[i].text != NULL)
+ xoffset = (getFontWidth(FONT_TEXT_1) * strlen(selectbox_info[i].text) +
+ 2 * ED_GADGET_DISTANCE);
+
+ sprintf(infotext, "Select %s", selectbox_info[i].infotext);
+ infotext[max_infotext_len] = '\0';
+
+ gi = CreateGadget(GDI_CUSTOM_ID, id,
+ GDI_CUSTOM_TYPE_ID, i,
+ GDI_INFO_TEXT, infotext,
+ GDI_X, SX + selectbox_info[i].x + xoffset,
+ GDI_Y, SY + selectbox_info[i].y,
+ GDI_TYPE, GD_TYPE_SELECTBOX,
+ GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
+ GDI_SELECTBOX_INDEX, selectbox_info[i].index,
+ GDI_TEXT_SIZE, selectbox_info[i].size,
+ GDI_TEXT_FONT, FONT_INPUT_1,
+ GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
+ GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
+ GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
+ GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
+ GDI_BORDER_SIZE_SELECTBUTTON, getFontWidth(FONT_INPUT_1),
+ GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
+ GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
+ GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
+ GDI_END);
+
+ if (gi == NULL)
+ Error(ERR_EXIT, "cannot create gadget");
+
+ level_editor_gadget[id] = gi;
+ }
+}
+
+static void CreateTextbuttonGadgets()
+{
+ int max_infotext_len = getMaxInfoTextLength();
+ int i;
+
+ for (i=0; i<ED_NUM_TEXTBUTTON; i++)
+ {
+ Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
+ int gd_x1, gd_x2, gd_y1, gd_y2;
+ struct GadgetInfo *gi;
+ unsigned long event_mask;
+ char infotext[MAX_OUTPUT_LINESIZE + 1];
+ int id = textbutton_info[i].gadget_id;
+
+ event_mask = GD_EVENT_RELEASED;
+
+ gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_XPOS;
+ gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_XPOS;
+ gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_YPOS;
+ gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_INACTIVE_YPOS;
+
+ sprintf(infotext, "%s", textbutton_info[i].infotext);
+ infotext[max_infotext_len] = '\0';
+
+ gi = CreateGadget(GDI_CUSTOM_ID, id,
+ GDI_CUSTOM_TYPE_ID, i,
+ GDI_INFO_TEXT, infotext,
+ GDI_X, SX + textbutton_info[i].x,
+ GDI_Y, SY + textbutton_info[i].y,
+ GDI_TYPE, GD_TYPE_TEXT_BUTTON,
+ GDI_TEXT_VALUE, textbutton_info[i].value,
+ GDI_TEXT_SIZE, textbutton_info[i].size,
+ GDI_TEXT_FONT, FONT_INPUT_2_ACTIVE,
+ GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2,
+ GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
+ GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
+ GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
+ GDI_BORDER_SIZE, ED_BORDER2_SIZE, ED_BORDER_SIZE,
+ GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
+ GDI_DECORATION_SHIFTING, 1, 1,
+ GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
+ GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
+ GDI_END);
+
+ if (gi == NULL)
+ Error(ERR_EXIT, "cannot create gadget");
+
+ level_editor_gadget[id] = gi;
+ }
+}
+
static void CreateScrollbarGadgets()
{
int i;
for (i=0; i<ED_NUM_SCROLLBARS; i++)
{
int id = scrollbar_info[i].gadget_id;
- Bitmap gd_bitmap = pix[PIX_DOOR];
+ Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
int gd_x1, gd_x2, gd_y1, gd_y2;
struct GadgetInfo *gi;
int items_max, items_visible, item_position;
if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
{
- items_max = elements_in_list / ED_ELEMENTLIST_BUTTONS_HORIZ;
+ items_max = num_editor_elements / ED_ELEMENTLIST_BUTTONS_HORIZ;
items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
item_position = 0;
}
GDI_STATE, GD_BUTTON_UNPRESSED,
GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
- GDI_BORDER_SIZE, ED_BORDER_SIZE,
+ GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
GDI_EVENT_MASK, event_mask,
GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleControlButtons,
static void CreateCheckbuttonGadgets()
{
- Bitmap gd_bitmap = pix[PIX_DOOR];
+ Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
struct GadgetInfo *gi;
unsigned long event_mask;
int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
void CreateLevelEditorGadgets()
{
+ int old_game_status = game_status;
+
+ /* setting 'game_status' is needed to get the right fonts for the editor */
+ game_status = GAME_MODE_EDITOR;
+
+ ReinitializeElementList();
+
CreateControlButtons();
CreateCounterButtons();
CreateDrawingAreas();
CreateTextInputGadgets();
+ CreateSelectboxGadgets();
+ CreateTextbuttonGadgets();
CreateScrollbarGadgets();
CreateCheckbuttonGadgets();
+
+ game_status = old_game_status;
+}
+
+void FreeLevelEditorGadgets()
+{
+ int i;
+
+ for (i=0; i<NUM_EDITOR_GADGETS; i++)
+ FreeGadget(level_editor_gadget[i]);
}
static void MapCounterButtons(int id)
MapGadget(level_editor_gadget[textinput_info[id].gadget_id]);
}
+static void MapSelectboxGadget(int id)
+{
+ MapGadget(level_editor_gadget[selectbox_info[id].gadget_id]);
+}
+
+static void MapTextbuttonGadget(int id)
+{
+ MapGadget(level_editor_gadget[textbutton_info[id].gadget_id]);
+}
+
static void MapRadiobuttonGadget(int id)
{
MapGadget(level_editor_gadget[radiobutton_info[id].gadget_id]);
for(y=0; y<lev_fieldy; y++)
for(x=0; x<lev_fieldx; x++)
- if (Feld[x][y] == EL_SPIELFIGUR ||
- Feld[x][y] == EL_SPIELER1 ||
+ if (Feld[x][y] == EL_PLAYER_1 ||
Feld[x][y] == EL_SP_MURPHY)
player_found = TRUE;
return player_found;
}
+static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
+ short dst[MAX_LEV_FIELDX][MAX_LEV_FIELDY])
+{
+ int x, y;
+
+ for(x=0; x<lev_fieldx; x++)
+ for(y=0; y<lev_fieldy; y++)
+ dst[x][y] = src[x][y];
+}
+
+static void CopyCustomElementPropertiesToEditor(int element)
+{
+ int i;
+
+ i = properties_element - EL_CUSTOM_START;
+ custom_element = level.custom_element[i];
+
+ for (i=0; i < NUM_ELEMENT_PROPERTIES; i++)
+ custom_element_properties[i] = HAS_PROPERTY(element, i);
+
+ for (i=0; i < NUM_CHANGE_EVENTS; i++)
+ custom_element_change_events[i] = HAS_CHANGE_EVENT(element, i);
+
+ /* set walk-to-object action selectbox help value */
+ custom_element.walk_to_action =
+ (IS_DIGGABLE(element) ? EP_DIGGABLE :
+ IS_COLLECTIBLE(element) ? EP_COLLECTIBLE :
+ EP_PUSHABLE);
+
+ /* set walkable layer selectbox help value */
+ custom_element.walkable_layer =
+ (IS_WALKABLE_OVER(element) ? EP_WALKABLE_OVER :
+ IS_WALKABLE_INSIDE(element) ? EP_WALKABLE_INSIDE :
+ EP_WALKABLE_UNDER);
+}
+
+static void CopyCustomElementPropertiesToGame(int element)
+{
+ int i;
+
+ i = properties_element - EL_CUSTOM_START;
+ level.custom_element[i] = custom_element;
+
+ /* set walk-to-object property from checkbox and selectbox */
+ custom_element_properties[EP_DIGGABLE] = FALSE;
+ custom_element_properties[EP_COLLECTIBLE] = FALSE;
+ custom_element_properties[EP_PUSHABLE] = FALSE;
+ custom_element_properties[custom_element.walk_to_action] =
+ custom_element_properties[EP_WALK_TO_OBJECT];
+
+ /* set walkable property from checkbox and selectbox */
+ custom_element_properties[EP_WALKABLE_OVER] = FALSE;
+ custom_element_properties[EP_WALKABLE_INSIDE] = FALSE;
+ custom_element_properties[EP_WALKABLE_UNDER] = FALSE;
+ custom_element_properties[custom_element.walkable_layer] =
+ custom_element_properties[EP_WALKABLE];
+
+ for (i=0; i < NUM_ELEMENT_PROPERTIES; i++)
+ SET_PROPERTY(element, i, custom_element_properties[i]);
+
+ for (i=0; i < NUM_CHANGE_EVENTS; i++)
+ SET_CHANGE_EVENT(element, i, custom_element_change_events[i]);
+
+ /* copy change events also to special level editor variable */
+ i = properties_element - EL_CUSTOM_START;
+ custom_element = level.custom_element[i];
+}
+
void DrawLevelEd()
{
CloseDoor(DOOR_CLOSE_ALL);
if (level_editor_test_game)
{
- int x, y;
-
- for(x=0; x<lev_fieldx; x++)
- for(y=0; y<lev_fieldy; y++)
- Feld[x][y] = Ur[x][y];
-
- for(x=0; x<lev_fieldx; x++)
- for(y=0; y<lev_fieldy; y++)
- Ur[x][y] = FieldBackup[x][y];
+ CopyPlayfield(Ur, Feld);
+ CopyPlayfield(FieldBackup, Ur);
level_editor_test_game = FALSE;
}
else
{
edit_mode = ED_MODE_DRAWING;
+ edit_mode_properties = ED_MODE_PROPERTIES_INFO;
ResetUndoBuffer();
+
level_xpos = -1;
level_ypos = -1;
}
/* copy default editor door content to main double buffer */
- BlitBitmap(pix[PIX_DOOR], drawto,
+ BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
/* draw mouse button brush elements */
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
- el2gfx(new_element1));
- DrawMiniGraphicExt(drawto, gc,
+ el2edimg(new_element1));
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
- el2gfx(new_element2));
- DrawMiniGraphicExt(drawto, gc,
+ el2edimg(new_element2));
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
- el2gfx(new_element3));
+ el2edimg(new_element3));
/* draw bigger door */
DrawSpecialEditorDoor();
/* draw new control window */
- BlitBitmap(pix[PIX_DOOR], drawto,
+ BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY);
redraw_mask |= REDRAW_ALL;
+ ReinitializeElementListButtons(); /* only needed after setup changes */
+
+ UnmapTapeButtons();
MapControlButtons();
/* copy actual editor door content to door double buffer for OpenDoor() */
- BlitBitmap(drawto, pix[PIX_DB_DOOR],
+ BlitBitmap(drawto, bitmap_db_door,
DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
DrawEditModeWindow();
- /*
- FadeToFront();
- */
-
-
OpenDoor(DOOR_OPEN_1);
-
- /*
- OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2);
- */
}
static void AdjustDrawingAreaGadgets()
ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END);
}
+static void ModifyEditorSelectbox(int selectbox_id, int new_value)
+{
+ int gadget_id = selectbox_info[selectbox_id].gadget_id;
+ struct GadgetInfo *gi = level_editor_gadget[gadget_id];
+ int new_index_value = 0;
+ int i;
+
+ for(i=0; selectbox_info[selectbox_id].options[i].text != NULL; i++)
+ if (selectbox_info[selectbox_id].options[i].value == new_value)
+ new_index_value = i;
+
+ *selectbox_info[selectbox_id].value =
+ selectbox_info[selectbox_id].options[new_index_value].value;
+
+ ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
+}
+
+static void ModifyEditorElementList()
+{
+ int i;
+
+ for (i=0; i<ED_NUM_ELEMENTLIST_BUTTONS; i++)
+ {
+ int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
+ struct GadgetInfo *gi = level_editor_gadget[gadget_id];
+ struct GadgetDesign *gd = &gi->deco.design;
+ int element = editor_elements[element_shift + i];
+
+ UnmapGadget(gi);
+ getMiniGraphicSource(el2edimg(element), &gd->bitmap, &gd->x, &gd->y);
+ ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
+ MapGadget(gi);
+ }
+}
+
static void PickDrawingElement(int button, int element)
{
if (button < 1 || button > 3)
if (button == 1)
{
new_element1 = element;
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
- el2gfx(new_element1));
+ el2edimg(new_element1));
}
else if (button == 2)
{
new_element2 = element;
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
- el2gfx(new_element2));
+ el2edimg(new_element2));
}
else
{
new_element3 = element;
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
- el2gfx(new_element3));
+ el2edimg(new_element3));
}
redraw_mask |= REDRAW_DOOR_1;
static void DrawDrawingWindow()
{
+ SetMainBackgroundImage(IMG_UNDEFINED);
ClearWindow();
UnmapLevelEditorWindowGadgets();
+
AdjustDrawingAreaGadgets();
AdjustLevelScrollPosition();
AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
+
DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
MapMainDrawingArea();
}
-static void DrawRandomPlacementBackgroundArea()
+static void DrawElementBorder(int dest_x, int dest_y, int width, int height,
+ boolean input)
{
- int area_x = ED_AREA_RANDOM_BACKGROUND_XPOS / MINI_TILEX;
- int area_y = ED_AREA_RANDOM_BACKGROUND_YPOS / MINI_TILEY;
- int area_sx = SX + ED_AREA_RANDOM_BACKGROUND_XPOS;
- int area_sy = SY + ED_AREA_RANDOM_BACKGROUND_YPOS;
+ int border_graphic =
+ (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER);
+ Bitmap *src_bitmap;
+ int src_x, src_y;
+ int num_mini_tilex = width / MINI_TILEX + 1;
+ int num_mini_tiley = width / MINI_TILEY + 1;
int x, y;
- ElementContent[0][0][0] = random_placement_background_element;
+ getMiniGraphicSource(border_graphic, &src_bitmap, &src_x, &src_y);
- /* draw decorative border for the object */
- for (y=0; y<2; y++)
- for (x=0; x<2; x++)
- DrawMiniElement(area_x + x, area_y + y, EL_ERDREICH);
+ for (y=0; y < num_mini_tiley; y++)
+ for (x=0; x < num_mini_tilex; x++)
+ BlitBitmap(src_bitmap, drawto, src_x, src_y, MINI_TILEX, MINI_TILEY,
+ dest_x - MINI_TILEX / 2 + x * MINI_TILEX,
+ dest_y - MINI_TILEY / 2 + y * MINI_TILEY);
- ClearRectangle(drawto,
- area_sx + MINI_TILEX/2 - 1, area_sy + MINI_TILEY/2 - 1,
- MINI_TILEX + 2, MINI_TILEY + 2);
+ ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
+}
- /* copy border to the right location */
- BlitBitmap(drawto, drawto,
- area_sx, area_sy, 3 * MINI_TILEX, 3 * MINI_TILEY,
- area_sx - MINI_TILEX/2, area_sy - MINI_TILEY/2);
+static void DrawRandomPlacementBackgroundArea()
+{
+ int area_x = ED_AREA_RANDOM_BACKGROUND_XPOS / MINI_TILEX;
+ int area_y = ED_AREA_RANDOM_BACKGROUND_YPOS / MINI_TILEY;
+ int area_sx = SX + ED_AREA_RANDOM_BACKGROUND_XPOS;
+ int area_sy = SY + ED_AREA_RANDOM_BACKGROUND_YPOS;
- DrawMiniElement(area_x, area_y, ElementContent[0][0][0]);
+ DrawElementBorder(area_sx, area_sy, MINI_TILEX, MINI_TILEY, TRUE);
+ DrawMiniElement(area_x, area_y, random_placement_background_element);
MapDrawingArea(GADGET_ID_RANDOM_BACKGROUND);
}
static void DrawLevelInfoWindow()
{
- char infotext[1024];
+ char infotext[MAX_OUTPUT_LINESIZE + 1];
+ int max_infotext_len = getMaxInfoTextLength();
int xoffset_above = 0;
int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
- int xoffset_right = counter_xsize;
+ int xoffset_right = getCounterGadgetWidth();
int yoffset_right = ED_BORDER_SIZE;
- int xoffset_right2 = ED_CHECKBUTTON_XSIZE + 2 * ED_GADGET_DISTANCE;
+ int xoffset_right2 = ED_SETTINGS_XOFFSET;
int yoffset_right2 = ED_BORDER_SIZE;
- int font_color = FC_GREEN;
int i, x, y;
+ SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
ClearWindow();
UnmapLevelEditorWindowGadgets();
- DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS_YPOS,
- "Level Settings", FS_BIG, FC_YELLOW);
+ DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
+ "Level Settings", FONT_TITLE_1);
DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS2_YPOS,
- "Editor Settings", FS_BIG, FC_YELLOW);
+ "Editor Settings", FONT_TITLE_1);
/* draw counter gadgets */
for (i=ED_COUNTER_ID_LEVEL_FIRST; i<=ED_COUNTER_ID_LEVEL_LAST; i++)
y = counterbutton_info[i].y + yoffset_above;
sprintf(infotext, "%s:", counterbutton_info[i].infotext_above);
- infotext[MAX_INFOTEXT_LEN] = '\0';
- DrawTextF(x, y, font_color, infotext);
+ infotext[max_infotext_len] = '\0';
+ DrawTextF(x, y, FONT_TEXT_1, infotext);
}
if (counterbutton_info[i].infotext_right)
{
- x = counterbutton_info[i].x + xoffset_right;
- y = counterbutton_info[i].y + yoffset_right;
+ x = counterbutton_info[i].x + xoffset_right;
+ y = counterbutton_info[i].y + yoffset_right;
+
+ sprintf(infotext, "%s", counterbutton_info[i].infotext_right);
+ infotext[max_infotext_len] = '\0';
+ DrawTextF(x, y, FONT_TEXT_1, infotext);
+ }
+
+ ModifyEditorCounter(i, *counterbutton_info[i].value);
+ MapCounterButtons(i);
+ }
+
+ /* draw text input gadgets */
+ for (i=ED_TEXTINPUT_ID_LEVEL_FIRST; i<=ED_TEXTINPUT_ID_LEVEL_LAST; i++)
+ {
+ x = textinput_info[i].x + xoffset_above;
+ y = textinput_info[i].y + yoffset_above;
+
+ sprintf(infotext, "%s:", textinput_info[i].infotext);
+ infotext[max_infotext_len] = '\0';
+
+ DrawTextF(x, y, FONT_TEXT_1, infotext);
+ ModifyEditorTextInput(i, textinput_info[i].value);
+ MapTextInputGadget(i);
+ }
+
+ /* draw radiobutton gadgets */
+ for (i=ED_RADIOBUTTON_ID_LEVEL_FIRST; i<=ED_RADIOBUTTON_ID_LEVEL_LAST; i++)
+ {
+ boolean checked =
+ (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
+
+ x = radiobutton_info[i].x + xoffset_right2;
+ y = radiobutton_info[i].y + yoffset_right2;
+
+ DrawTextF(x, y, FONT_TEXT_1, radiobutton_info[i].text);
+ ModifyGadget(level_editor_gadget[radiobutton_info[i].gadget_id],
+ GDI_CHECKED, checked, GDI_END);
+ MapRadiobuttonGadget(i);
+ }
+
+ /* draw checkbutton gadgets */
+ for (i=ED_CHECKBUTTON_ID_LEVEL_FIRST; i<=ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
+ {
+ x = checkbutton_info[i].x + xoffset_right2;
+ y = checkbutton_info[i].y + yoffset_right2;
+
+ DrawTextF(x, y, FONT_TEXT_1, checkbutton_info[i].text);
+ ModifyGadget(level_editor_gadget[checkbutton_info[i].gadget_id],
+ GDI_CHECKED, *checkbutton_info[i].value, GDI_END);
+ MapCheckbuttonGadget(i);
+ }
+
+ /* draw drawing area */
+ DrawRandomPlacementBackgroundArea();
+}
+
+static void DrawAmoebaContentArea()
+{
+ int area_x = ED_AREA_ELEM_CONTENT_XPOS / MINI_TILEX;
+ int area_y = ED_AREA_ELEM_CONTENT_YPOS / MINI_TILEY;
+ int area_sx = SX + ED_AREA_ELEM_CONTENT_XPOS;
+ int area_sy = SY + ED_AREA_ELEM_CONTENT_YPOS;
+
+ DrawElementBorder(area_sx, area_sy, MINI_TILEX, MINI_TILEY, TRUE);
+ DrawMiniElement(area_x, area_y, level.amoeba_content);
+
+ DrawText(area_sx + TILEX, area_sy + 1, "Content of amoeba", FONT_TEXT_1);
+
+ MapDrawingArea(GADGET_ID_AMOEBA_CONTENT);
+}
+
+static void DrawCustomGraphicElementArea()
+{
+ struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_CUSTOM_GRAPHIC];
+#if 0
+ int xoffset_right2 = ED_SETTINGS_XOFFSET;
+ int yoffset_right2 = ED_BORDER_SIZE;
+ int i = ED_CHECKBUTTON_ID_CUSTOM_GRAPHIC;
+ int text_len = strlen(checkbutton_info[i].text);
+ int text_width = text_len * getFontWidth(FONT_TEXT_1);
+ int xpos = checkbutton_info[i].x + 2 * xoffset_right2 + text_width;
+ int ypos = checkbutton_info[i].y + yoffset_right2;
+#else
+ int xpos = ED_AREA_ELEM_CONTENT3_XPOS;
+ int ypos = ED_AREA_ELEM_CONTENT3_YPOS;
+#endif
+ int area_sx = SX + xpos;
+ int area_sy = SY + ypos;
+
+ if (!IS_CUSTOM_ELEMENT(properties_element))
+ {
+ /* this should never happen */
+ Error(ERR_WARN, "element %d is no custom element", properties_element);
+
+ return;
+ }
+
+ DrawElementBorder(area_sx, area_sy, MINI_TILEX, MINI_TILEY, TRUE);
+ DrawMiniGraphicExt(drawto, gi->x, gi->y,
+ el2edimg(custom_element.gfx_element));
+
+ MapDrawingArea(GADGET_ID_CUSTOM_GRAPHIC);
+}
+
+static void DrawCustomContentArea()
+{
+ struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_CUSTOM_CONTENT];
+ int area_sx = SX + ED_AREA_ELEM_CONTENT4_XPOS;
+ int area_sy = SY + ED_AREA_ELEM_CONTENT4_YPOS;
+ int x, y;
+
+ if (!IS_CUSTOM_ELEMENT(properties_element))
+ {
+ /* this should never happen */
+ Error(ERR_WARN, "element %d is no custom element", properties_element);
+
+ return;
+ }
+
+ DrawElementBorder(area_sx, area_sy, 3 * MINI_TILEX, 3 * MINI_TILEY, TRUE);
+
+ for (y=0; y<3; y++)
+ for (x=0; x<3; x++)
+ DrawMiniGraphicExt(drawto, gi->x + x * MINI_TILEX,gi->y + y * MINI_TILEY,
+ el2edimg(custom_element.content[x][y]));
+
+ MapDrawingArea(GADGET_ID_CUSTOM_CONTENT);
+}
+
+static void DrawCustomChangedArea()
+{
+ struct GadgetInfo *gi = level_editor_gadget[GADGET_ID_CUSTOM_CHANGED];
+#if 0
+ int xoffset_right2 = ED_SETTINGS_XOFFSET;
+ int yoffset_right2 = ED_BORDER_SIZE;
+ int i = ED_CHECKBUTTON_ID_CUSTOM_CHANGEABLE;
+ int text_len = strlen(checkbutton_info[i].text);
+ int text_width = text_len * getFontWidth(FONT_TEXT_1);
+ int xpos = checkbutton_info[i].x + 2 * xoffset_right2 + text_width;
+ int ypos = checkbutton_info[i].y + yoffset_right2;
+#else
+ int xpos = ED_AREA_ELEM_CONTENT2_XPOS;
+ int ypos = ED_AREA_ELEM_CONTENT2_YPOS;
+#endif
+ int area_sx = SX + xpos;
+ int area_sy = SY + ypos;
+
+ if (!IS_CUSTOM_ELEMENT(properties_element))
+ {
+ /* this should never happen */
+ Error(ERR_WARN, "element %d is no custom element", properties_element);
+
+ return;
+ }
+
+ DrawElementBorder(area_sx, area_sy, MINI_TILEX, MINI_TILEY, TRUE);
+ DrawMiniGraphicExt(drawto, gi->x, gi->y,
+ el2edimg(custom_element.change.successor));
+
+ MapDrawingArea(GADGET_ID_CUSTOM_CHANGED);
+}
+
+static void DrawElementContentAreas()
+{
+ int counter_id = ED_COUNTER_ID_ELEMENT_CONTENT;
+ int area_x = ED_AREA_ELEM_CONTENT_XPOS / MINI_TILEX;
+ int area_y = ED_AREA_ELEM_CONTENT_YPOS / MINI_TILEY;
+ int area_sx = SX + ED_AREA_ELEM_CONTENT_XPOS;
+ int area_sy = SY + ED_AREA_ELEM_CONTENT_YPOS;
+ int xoffset_right = getCounterGadgetWidth();
+ int yoffset_right = ED_BORDER_SIZE;
+ int i, x, y;
+
+ for (i=0; i<MAX_ELEMENT_CONTENTS; i++)
+ UnmapDrawingArea(GADGET_ID_ELEMENT_CONTENT_0 + i);
+
+ /* display counter to choose number of element content areas */
+ x = counterbutton_info[counter_id].x + xoffset_right;
+ y = counterbutton_info[counter_id].y + yoffset_right;
+ DrawTextF(x, y, FONT_TEXT_1, "number of content areas");
+
+ ModifyEditorCounter(counter_id, *counterbutton_info[counter_id].value);
+ MapCounterButtons(counter_id);
+
+ /* delete content areas in case of reducing number of them */
+ DrawBackground(SX, area_sy - MINI_TILEX, SXSIZE, 12 * MINI_TILEY);
+
+ for (i=0; i<level.num_yamyam_contents; i++)
+ DrawElementBorder(area_sx + 5 * (i % 4) * MINI_TILEX,
+ area_sy + 6 * (i / 4) * MINI_TILEY,
+ 3 * MINI_TILEX, 3 * MINI_TILEY, TRUE);
+
+ DrawText(area_sx + (5 * 4 - 1) * MINI_TILEX, area_sy + 0 * MINI_TILEY + 1,
+ "Content", FONT_TEXT_1);
+ DrawText(area_sx + (5 * 4 - 1) * MINI_TILEX, area_sy + 1 * MINI_TILEY + 1,
+ "when", FONT_TEXT_1);
+ DrawText(area_sx + (5 * 4 - 1) * MINI_TILEX, area_sy + 2 * MINI_TILEY + 1,
+ "smashed", FONT_TEXT_1);
+
+ for (i=0; i<level.num_yamyam_contents; i++)
+ {
+ for (y=0; y<3; y++)
+ for (x=0; x<3; x++)
+ DrawMiniElement(area_x + 5 * (i % 4) + x, area_y + 6 * (i / 4) + y,
+ level.yamyam_content[i][x][y]);
+
+ DrawTextF(area_sx - SX + 5 * (i % 4) * MINI_TILEX + MINI_TILEX + 1,
+ area_sy - SY + 6 * (i / 4) * MINI_TILEY + 4 * MINI_TILEY - 4,
+ FONT_TEXT_1, "%d", i + 1);
+ }
+
+ for (i=0; i<level.num_yamyam_contents; i++)
+ MapDrawingArea(GADGET_ID_ELEMENT_CONTENT_0 + i);
+}
+
+char *getElementDescriptionFilename(int element)
+{
+ char *docs_dir = options.docs_directory;
+ char *elements_subdir = "elements";
+ static char *filename = NULL;
+ char basename[MAX_FILENAME_LEN];
+
+ if (filename != NULL)
+ free(filename);
+
+ /* 1st try: look for element description file for exactly this element */
+ sprintf(basename, "%s.txt", element_info[element].token_name);
+ filename = getPath3(docs_dir, elements_subdir, basename);
+ if (fileExists(filename))
+ return filename;
+
+ free(filename);
+
+ /* 2nd try: look for element description file for this element's class */
+ sprintf(basename, "%s.txt", element_info[element].class_name);
+ filename = getPath3(docs_dir, elements_subdir, basename);
+ if (fileExists(filename))
+ return filename;
+
+ return NULL;
+}
+
+static boolean PrintInfoText(char *text, int font_nr, int screen_line)
+{
+ int font_height = getFontHeight(font_nr);
+ int pad_x = ED_SETTINGS_XPOS(0);
+ int pad_y = ED_SETTINGS_YPOS(0);
+ int sx = SX + pad_x;
+ int sy = SY + pad_y;
+ int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
+
+ if (screen_line >= max_lines_per_screen)
+ return FALSE;
+
+ DrawText(sx, sy + screen_line * font_height, text, font_nr);
+
+ return TRUE;
+}
+
+static int PrintElementDescriptionFromFile(char *filename, int screen_line)
+{
+ int font_nr = FONT_TEXT_2;
+ int font_width = getFontWidth(font_nr);
+ int pad_x = ED_SETTINGS_XPOS(0);
+ int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
+ char line[MAX_LINE_LEN];
+ char buffer[max_chars_per_line + 1];
+ int buffer_len;
+ int lines_printed = 0;
+ FILE *file;
+
+ if (filename == NULL)
+ return 0;
+
+ if (!(file = fopen(filename, MODE_READ)))
+ return 0;
+
+ buffer[0] = '\0';
+ buffer_len = 0;
+
+ while(!feof(file))
+ {
+ char *line_ptr, *word_ptr;
+ boolean last_line_was_empty = TRUE;
+
+ /* read next line of input file */
+ if (!fgets(line, MAX_LINE_LEN, file))
+ break;
+
+ /* skip comments (lines directly beginning with '#') */
+ if (line[0] == '#')
+ continue;
+
+ /* cut trailing newline from input line */
+ for (line_ptr = line; *line_ptr; line_ptr++)
+ {
+ if (*line_ptr == '\n' || *line_ptr == '\r')
+ {
+ *line_ptr = '\0';
+ break;
+ }
+ }
+
+ if (strlen(line) == 0) /* special case: force empty line */
+ strcpy(line, "\n");
+
+ word_ptr = line;
+
+ while (*word_ptr)
+ {
+ boolean print_buffer = FALSE;
+ int word_len;
+
+ /* skip leading whitespaces */
+ while (*word_ptr == ' ' || *word_ptr == '\t')
+ word_ptr++;
+
+ line_ptr = word_ptr;
+ word_len = 0;
+
+ /* look for end of next word */
+ while (*line_ptr != ' ' && *line_ptr != '\t' && *line_ptr != '\0')
+ {
+ line_ptr++;
+ word_len++;
+ }
+
+ if (word_len == 0)
+ {
+ continue;
+ }
+ else if (*word_ptr == '\n') /* special case: force empty line */
+ {
+ if (buffer_len == 0)
+ word_ptr++;
+
+ /* prevent printing of multiple empty lines */
+ if (buffer_len > 0 || !last_line_was_empty)
+ print_buffer = TRUE;
+ }
+ else if (word_len < max_chars_per_line - buffer_len)
+ {
+ /* word fits into text buffer -- add word */
+
+ if (buffer_len > 0)
+ buffer[buffer_len++] = ' ';
+
+ strncpy(&buffer[buffer_len], word_ptr, word_len);
+ buffer_len += word_len;
+ buffer[buffer_len] = '\0';
+ word_ptr += word_len;
+ }
+ else if (buffer_len > 0)
+ {
+ /* not enough space left for word in text buffer -- print buffer */
+
+ print_buffer = TRUE;
+ }
+ else
+ {
+ /* word does not fit at all into empty text buffer -- cut word */
+
+ strncpy(buffer, word_ptr, max_chars_per_line);
+ buffer[max_chars_per_line] = '\0';
+ word_ptr += max_chars_per_line;
+ print_buffer = TRUE;
+ }
+
+ if (print_buffer)
+ {
+ if (!PrintInfoText(buffer, font_nr, screen_line + lines_printed))
+ return lines_printed;
+
+ last_line_was_empty = (buffer_len == 0);
+ lines_printed++;
+
+ buffer[0] = '\0';
+ buffer_len = 0;
+ print_buffer = FALSE;
+ }
+ }
+ }
+
+ fclose(file);
+
+ if (buffer_len > 0)
+ if (PrintInfoText(buffer, font_nr, screen_line + lines_printed))
+ lines_printed++;
+
+ return lines_printed;
+}
+
+static void DrawPropertiesTabulatorGadgets()
+{
+ struct GadgetInfo *gd_gi = level_editor_gadget[GADGET_ID_PROPERTIES_INFO];
+ struct GadgetDesign *gd = &gd_gi->alt_design[GD_BUTTON_UNPRESSED];
+ int gd_x = gd->x + gd_gi->border.width / 2;
+ int gd_y = gd->y + gd_gi->height - 1;
+ Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
+ int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
+ int id_last = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
+ int i;
+
+ /* draw additional "configure" tabulator for configurable elements */
+ if (checkPropertiesConfig())
+ id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
+
+ /* draw additional "advanced" tabulator for custom elements */
+ if (IS_CUSTOM_ELEMENT(properties_element))
+ id_last = ED_TEXTBUTTON_ID_PROPERTIES_ADVANCED;
+
+ for (i=id_first; i <= id_last; i++)
+ {
+ int gadget_id = textbutton_info[i].gadget_id;
+ struct GadgetInfo *gi = level_editor_gadget[gadget_id];
+ boolean active = (i != edit_mode_properties);
+
+ /* draw background line below tabulator button */
+ ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width,1);
+
+ /* draw solid line below inactive tabulator buttons */
+ if (!active && tab_color != BLACK_PIXEL) /* black => transparent */
+ FillRectangle(drawto, gi->x, gi->y + gi->height, gi->width,1, tab_color);
+
+ ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
+ MapTextbuttonGadget(i);
+ }
+
+ /* draw little border line below tabulator buttons */
+ if (tab_color != BLACK_PIXEL) /* black => transparent */
+ FillRectangle(drawto, gd_gi->x, gd_gi->y + gd_gi->height + 1,
+ 3 * gd_gi->width + 2 * ED_GADGET_DISTANCE,
+ ED_GADGET_DISTANCE, tab_color);
+}
+
+static void DrawPropertiesInfo()
+{
+ static struct
+ {
+ int value;
+ char *text;
+ }
+ properties[] =
+ {
+ /* configurable properties */
+ { EP_INDESTRUCTIBLE, "- undestructible" },
+ { EP_DIGGABLE, "- diggable" },
+ { EP_COLLECTIBLE, "- collectible" },
+ { EP_PUSHABLE, "- pushable" },
+ { EP_CAN_FALL, "- can fall" },
+ { EP_CAN_SMASH, "- can smash other objects" },
+ { EP_CAN_MOVE, "- can move" },
+ { EP_SLIPPERY, "- slippery for falling objects" },
+ { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
+ { EP_WALKABLE_OVER, "- player can walk over it" },
+ { EP_WALKABLE_INSIDE, "- player can walk inside it" },
+ { EP_WALKABLE_UNDER, "- player can walk under it" },
+ { EP_PASSABLE_OVER, "- player can pass over it" },
+ { EP_PASSABLE_INSIDE, "- player can pass through it" },
+ { EP_PASSABLE_UNDER, "- player can pass under it" },
+
+ /* pre-defined properties */
+ { EP_CAN_PASS_MAGIC_WALL, "- can pass magic walls" },
+ { EP_DONT_TOUCH, "- deadly when touched" },
+ { EP_ENEMY, "- can kill the player" },
+ { EP_DONT_GO_TO, "- deadly when walked to" },
+ { EP_CAN_EXPLODE, "- can explode" },
+ { EP_HAS_CONTENT, "- can contain other elements" },
+
+ { -1, NULL }
+ };
+ char *filename = getElementDescriptionFilename(properties_element);
+ char *percentage_text = "In this level:";
+ char *properties_text = "Standard properties:";
+ float percentage;
+ int num_elements_in_level;
+ int num_standard_properties = 0;
+ int font1_nr = FONT_TEXT_1;
+ int font2_nr = FONT_TEXT_2;
+ int font1_width = getFontWidth(font1_nr);
+ int font2_height = getFontHeight(font2_nr);
+ int pad_x = ED_SETTINGS_XPOS(0);
+ int pad_y = ED_SETTINGS_YPOS(0);
+ int screen_line = 0;
+ int i, x, y;
+
+ /* ----- print number of elements / percentage of this element in level */
+
+ num_elements_in_level = 0;
+ for (y=0; y<lev_fieldy; y++)
+ for (x=0; x<lev_fieldx; x++)
+ if (Feld[x][y] == properties_element)
+ num_elements_in_level++;
+ percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
+
+ DrawTextF(pad_x, pad_y + screen_line * font2_height, font1_nr,
+ percentage_text);
+ DrawTextF(pad_x + strlen(percentage_text) * font1_width,
+ pad_y + screen_line++ * font2_height, font2_nr,
+ "%d (%.2f%%)", num_elements_in_level, percentage);
+
+ screen_line++;
+
+ /* ----- print standard properties of this element */
+
+ DrawTextF(pad_x, pad_y + screen_line++ * font2_height, font1_nr,
+ properties_text);
+
+ for (i=0; properties[i].value != -1; i++)
+ {
+ if (!HAS_PROPERTY(properties_element, properties[i].value))
+ continue;
+
+ DrawTextF(pad_x, pad_y + screen_line++ * font2_height, font2_nr,
+ properties[i].text);
+ num_standard_properties++;
+ }
+
+ if (num_standard_properties == 0)
+ DrawTextF(pad_x + strlen(properties_text) * font1_width,
+ pad_y + (screen_line - 1) * font2_height, font2_nr, "none");
+
+ screen_line++;
+
+ /* ----- print special description of this element */
+
+ PrintInfoText("Description:", FONT_TEXT_1, screen_line);
+ if (PrintElementDescriptionFromFile(filename, screen_line + 1) == 0)
+ PrintInfoText("No description available.", FONT_TEXT_1, screen_line);
+}
+
+#define TEXT_COLLECTING "Score for collecting"
+#define TEXT_SMASHING "Score for smashing"
+#define TEXT_CRACKING "Score for cracking"
+#define TEXT_SPEED "Speed of amoeba growth"
+#define TEXT_DURATION "Duration when activated"
+
+static struct
+{
+ int element;
+ int *value;
+ char *text;
+} elements_with_counter[] =
+{
+ { EL_EMERALD, &level.score[SC_EMERALD], TEXT_COLLECTING },
+ { EL_BD_DIAMOND, &level.score[SC_EMERALD], TEXT_COLLECTING },
+ { EL_EMERALD_YELLOW, &level.score[SC_EMERALD], TEXT_COLLECTING },
+ { EL_EMERALD_RED, &level.score[SC_EMERALD], TEXT_COLLECTING },
+ { EL_EMERALD_PURPLE, &level.score[SC_EMERALD], TEXT_COLLECTING },
+ { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
+ { EL_BUG_RIGHT, &level.score[SC_BUG], TEXT_SMASHING },
+ { EL_BUG_UP, &level.score[SC_BUG], TEXT_SMASHING },
+ { EL_BUG_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
+ { EL_BUG_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
+ { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_BUG], TEXT_SMASHING },
+ { EL_BD_BUTTERFLY_UP, &level.score[SC_BUG], TEXT_SMASHING },
+ { EL_BD_BUTTERFLY_LEFT, &level.score[SC_BUG], TEXT_SMASHING },
+ { EL_BD_BUTTERFLY_DOWN, &level.score[SC_BUG], TEXT_SMASHING },
+ { EL_SPACESHIP_RIGHT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
+ { EL_SPACESHIP_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
+ { EL_SPACESHIP_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
+ { EL_SPACESHIP_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
+ { EL_BD_FIREFLY_RIGHT,&level.score[SC_SPACESHIP], TEXT_SMASHING },
+ { EL_BD_FIREFLY_UP, &level.score[SC_SPACESHIP], TEXT_SMASHING },
+ { EL_BD_FIREFLY_LEFT, &level.score[SC_SPACESHIP], TEXT_SMASHING },
+ { EL_BD_FIREFLY_DOWN, &level.score[SC_SPACESHIP], TEXT_SMASHING },
+ { EL_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
+ { EL_DARK_YAMYAM, &level.score[SC_YAMYAM], TEXT_SMASHING },
+ { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
+ { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
+ { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
+ { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
+ { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
+ { EL_NUT, &level.score[SC_NUT], TEXT_CRACKING },
+ { EL_DYNAMITE, &level.score[SC_DYNAMITE], TEXT_COLLECTING },
+ { EL_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING },
+ { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING },
+ { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING },
+ { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING },
+ { EL_EM_KEY_1_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
+ { EL_EM_KEY_2_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
+ { EL_EM_KEY_3_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
+ { EL_EM_KEY_4_FILE, &level.score[SC_KEY], TEXT_COLLECTING },
+ { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_SPEED },
+ { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_SPEED },
+ { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_SPEED },
+ { EL_BD_AMOEBA, &level.amoeba_speed, TEXT_SPEED },
+ { EL_MAGIC_WALL, &level.time_magic_wall, TEXT_DURATION },
+ { EL_ROBOT_WHEEL, &level.time_wheel, TEXT_DURATION },
+ { -1, NULL, NULL }
+};
+
+static boolean checkPropertiesConfig()
+{
+ int i;
+
+ if (IS_GEM(properties_element) ||
+ IS_CUSTOM_ELEMENT(properties_element) ||
+ HAS_CONTENT(properties_element))
+ return TRUE;
+ else
+ for (i=0; elements_with_counter[i].element != -1; i++)
+ if (elements_with_counter[i].element == properties_element)
+ return TRUE;
+
+ return FALSE;
+}
+
+static void DrawPropertiesConfig()
+{
+ boolean element_has_score = FALSE;
+ char *element_score_text = NULL;
+ static int temporary_dummy_score = 0;
+ int counter_id = ED_COUNTER_ID_ELEMENT_SCORE;
+ int xoffset_right = getCounterGadgetWidth();
+ int yoffset_right = ED_BORDER_SIZE;
+ int xoffset_right2 = ED_SETTINGS_XOFFSET;
+ int yoffset_right2 = ED_BORDER_SIZE;
+ int i, x, y;
+
+ /* check if there are elements where a score can be chosen for */
+ for (i=0; elements_with_counter[i].element != -1; i++)
+ {
+ if (elements_with_counter[i].element == properties_element)
+ {
+#if 1
+ counterbutton_info[counter_id].value = elements_with_counter[i].value;
+ element_score_text = elements_with_counter[i].text;
+ element_has_score = TRUE;
+#else
+ int x = counterbutton_info[counter_id].x + xoffset_right;
+ int y = counterbutton_info[counter_id].y + yoffset_right;
- sprintf(infotext, "%s", counterbutton_info[i].infotext_right);
- infotext[MAX_INFOTEXT_LEN] = '\0';
- DrawTextF(x, y, font_color, infotext);
+ counterbutton_info[counter_id].value = elements_with_counter[i].value;
+ DrawTextF(x, y, FONT_TEXT_1, elements_with_counter[i].text);
+
+ ModifyEditorCounter(counter_id, *counterbutton_info[counter_id].value);
+ MapCounterButtons(counter_id);
+#endif
+ break;
}
+ }
- ModifyEditorCounter(i, *counterbutton_info[i].value);
- MapCounterButtons(i);
+ if (IS_CUSTOM_ELEMENT(properties_element))
+ {
+ counterbutton_info[counter_id].value = &temporary_dummy_score;
+ element_score_text = "Score for certain actions";
+ element_has_score = TRUE;
}
- /* draw text input gadgets */
- for (i=ED_TEXTINPUT_ID_LEVEL_FIRST; i<=ED_TEXTINPUT_ID_LEVEL_LAST; i++)
+ if (element_has_score)
{
- x = textinput_info[i].x + xoffset_above;
- y = textinput_info[i].y + yoffset_above;
+ int x = counterbutton_info[counter_id].x + xoffset_right;
+ int y = counterbutton_info[counter_id].y + yoffset_right;
- sprintf(infotext, "%s:", textinput_info[i].infotext);
- infotext[MAX_INFOTEXT_LEN] = '\0';
+ DrawTextF(x, y, FONT_TEXT_1, element_score_text);
- DrawTextF(x, y, font_color, infotext);
- ModifyEditorTextInput(i, textinput_info[i].value);
- MapTextInputGadget(i);
+ ModifyEditorCounter(counter_id, *counterbutton_info[counter_id].value);
+ MapCounterButtons(counter_id);
}
- /* draw radiobutton gadgets */
- for (i=ED_RADIOBUTTON_ID_LEVEL_FIRST; i<=ED_RADIOBUTTON_ID_LEVEL_LAST; i++)
+ if (HAS_CONTENT(properties_element) ||
+ IS_CUSTOM_ELEMENT(properties_element))
{
- boolean checked =
- (*radiobutton_info[i].value == radiobutton_info[i].checked_value);
+ /* draw stickybutton gadget */
+ i = ED_CHECKBUTTON_ID_STICK_ELEMENT;
+ if (HAS_CONTENT(properties_element))
+ checkbutton_info[i].y = ED_COUNTER_YPOS(4);
+ else
+ checkbutton_info[i].y = ED_SETTINGS_YPOS(1);
+ x = checkbutton_info[i].x + xoffset_right2;
+ y = checkbutton_info[i].y + yoffset_right2;
- x = radiobutton_info[i].x + xoffset_right2;
- y = radiobutton_info[i].y + yoffset_right2;
+ DrawTextF(x, y, FONT_TEXT_1, checkbutton_info[i].text);
+ ModifyGadget(level_editor_gadget[checkbutton_info[i].gadget_id],
+ GDI_CHECKED, *checkbutton_info[i].value,
+ GDI_Y, SY + checkbutton_info[i].y, GDI_END);
+ MapCheckbuttonGadget(i);
- DrawTextF(x, y, font_color, radiobutton_info[i].text);
- ModifyGadget(level_editor_gadget[radiobutton_info[i].gadget_id],
- GDI_CHECKED, checked, GDI_END);
- MapRadiobuttonGadget(i);
+ if (IS_CUSTOM_ELEMENT(properties_element))
+ {
+ DrawCustomGraphicElementArea();
+ DrawCustomContentArea();
+ }
+ else if (IS_AMOEBOID(properties_element))
+ DrawAmoebaContentArea();
+ else
+ DrawElementContentAreas();
}
- /* draw checkbutton gadgets */
- for (i=ED_CHECKBUTTON_ID_LEVEL_FIRST; i<=ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
+ if (IS_GEM(properties_element))
{
+ /* draw checkbutton gadget */
+ i = ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS;
x = checkbutton_info[i].x + xoffset_right2;
y = checkbutton_info[i].y + yoffset_right2;
- DrawTextF(x, y, font_color, checkbutton_info[i].text);
+ DrawTextF(x, y, FONT_TEXT_1, checkbutton_info[i].text);
ModifyGadget(level_editor_gadget[checkbutton_info[i].gadget_id],
GDI_CHECKED, *checkbutton_info[i].value, GDI_END);
MapCheckbuttonGadget(i);
}
- /* draw drawing area */
- DrawRandomPlacementBackgroundArea();
-}
-
-static void DrawAmoebaContentArea()
-{
- int area_x = ED_AREA_ELEM_CONTENT_XPOS / MINI_TILEX;
- int area_y = ED_AREA_ELEM_CONTENT_YPOS / MINI_TILEY;
- int area_sx = SX + ED_AREA_ELEM_CONTENT_XPOS;
- int area_sy = SY + ED_AREA_ELEM_CONTENT_YPOS;
- int font_color = FC_GREEN;
- int x, y;
-
- ElementContent[0][0][0] = level.amoeba_content;
-
- /* draw decorative border for the object */
- for (y=0; y<2; y++)
- for (x=0; x<2; x++)
- DrawMiniElement(area_x + x, area_y + y, EL_ERDREICH);
-
- ClearRectangle(drawto,
- area_sx + MINI_TILEX/2 - 1, area_sy + MINI_TILEY/2 - 1,
- MINI_TILEX + 2, MINI_TILEY + 2);
+ if (IS_CUSTOM_ELEMENT(properties_element))
+ {
+ /* draw checkbutton gadgets */
+ for (i = ED_CHECKBUTTON_ID_CUSTOM_FIRST;
+ i <= ED_CHECKBUTTON_ID_CUSTOM_LAST; i++)
+ {
+ x = checkbutton_info[i].x + xoffset_right2;
+ y = checkbutton_info[i].y + yoffset_right2;
- /* copy border to the right location */
- BlitBitmap(drawto, drawto,
- area_sx, area_sy, 3 * MINI_TILEX, 3 * MINI_TILEY,
- area_sx - MINI_TILEX/2, area_sy - MINI_TILEY/2);
+ DrawTextF(x, y, FONT_TEXT_1, checkbutton_info[i].text);
+ ModifyGadget(level_editor_gadget[checkbutton_info[i].gadget_id],
+ GDI_CHECKED, *checkbutton_info[i].value, GDI_END);
+ MapCheckbuttonGadget(i);
+ }
- DrawText(area_sx + TILEX, area_sy + 1, "Content of amoeba",
- FS_SMALL, font_color);
+ /* draw selectbox gadgets */
+ for (i=ED_SELECTBOX_ID_CUSTOM_FIRST; i <= ED_SELECTBOX_ID_CUSTOM_LAST; i++)
+ {
+ int yoffset = ED_BORDER_SIZE;
- DrawMiniElement(area_x, area_y, ElementContent[0][0][0]);
+ x = selectbox_info[i].x;
+ y = selectbox_info[i].y + yoffset;
- MapDrawingArea(GADGET_ID_AMOEBA_CONTENT);
+ DrawTextF(x, y, FONT_TEXT_1, selectbox_info[i].text);
+ ModifyEditorSelectbox(i, *selectbox_info[i].value);
+ MapSelectboxGadget(i);
+ }
+ }
}
-static void DrawElementContentAreas()
+static void DrawPropertiesAdvanced()
{
- int counter_id = ED_COUNTER_ID_ELEM_CONTENT;
- int area_x = ED_AREA_ELEM_CONTENT_XPOS / MINI_TILEX;
- int area_y = ED_AREA_ELEM_CONTENT_YPOS / MINI_TILEY;
- int area_sx = SX + ED_AREA_ELEM_CONTENT_XPOS;
- int area_sy = SY + ED_AREA_ELEM_CONTENT_YPOS;
- int xoffset_right = counter_xsize;
+ char infotext[MAX_OUTPUT_LINESIZE + 1];
+ int max_infotext_len = getMaxInfoTextLength();
+ int xoffset_right = getCounterGadgetWidth();
int yoffset_right = ED_BORDER_SIZE;
- int font_color = FC_GREEN;
+ int xoffset_right2 = ED_SETTINGS_XOFFSET;
+ int yoffset_right2 = ED_BORDER_SIZE;
int i, x, y;
- for (i=0; i<MAX_ELEMENT_CONTENTS; i++)
- for (y=0; y<3; y++)
- for (x=0; x<3; x++)
- ElementContent[i][x][y] = level.yam_content[i][x][y];
+ /* draw stickybutton gadget */
+ i = ED_CHECKBUTTON_ID_STICK_ELEMENT;
+ checkbutton_info[i].y = ED_SETTINGS_YPOS(0);
+ x = checkbutton_info[i].x + xoffset_right2;
+ y = checkbutton_info[i].y + yoffset_right2;
- for (i=0; i<MAX_ELEMENT_CONTENTS; i++)
- UnmapDrawingArea(GADGET_ID_ELEM_CONTENT_0 + i);
+ DrawTextF(x, y, FONT_TEXT_1, checkbutton_info[i].text);
+ ModifyGadget(level_editor_gadget[checkbutton_info[i].gadget_id],
+ GDI_CHECKED, *checkbutton_info[i].value,
+ GDI_Y, SY + checkbutton_info[i].y, GDI_END);
+ MapCheckbuttonGadget(i);
- /* display counter to choose number of element content areas */
- x = counterbutton_info[counter_id].x + xoffset_right;
- y = counterbutton_info[counter_id].y + yoffset_right;
- DrawTextF(x, y, font_color, "number of content areas");
+ /* draw counter gadgets */
+ for (i=ED_COUNTER_ID_CHANGE_FIRST; i<=ED_COUNTER_ID_CHANGE_LAST; i++)
+ {
+ if (counterbutton_info[i].infotext_right)
+ {
+ x = counterbutton_info[i].x + xoffset_right;
+ y = counterbutton_info[i].y + yoffset_right;
- ModifyEditorCounter(counter_id, *counterbutton_info[counter_id].value);
- MapCounterButtons(counter_id);
+ sprintf(infotext, "%s", counterbutton_info[i].infotext_right);
+ infotext[max_infotext_len] = '\0';
+ DrawTextF(x, y, FONT_TEXT_1, infotext);
+ }
- /* delete content areas in case of reducing number of them */
- ClearRectangle(backbuffer,
- SX, area_sy - MINI_TILEX,
- SXSIZE, 12 * MINI_TILEY);
+ ModifyEditorCounter(i, *counterbutton_info[i].value);
+ MapCounterButtons(i);
+ }
- /* draw some decorative border for the objects */
- for (i=0; i<level.num_yam_contents; i++)
+ /* draw checkbutton gadgets */
+ for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
+ i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
{
- for (y=0; y<4; y++)
- for (x=0; x<4; x++)
- DrawMiniElement(area_x + 5 * (i % 4) + x, area_y + 6 * (i / 4) + y,
- EL_ERDREICH);
+ x = checkbutton_info[i].x + xoffset_right2;
+ y = checkbutton_info[i].y + yoffset_right2;
- ClearRectangle(drawto,
- area_sx + 5 * (i % 4) * MINI_TILEX + MINI_TILEX/2 - 1,
- area_sy + 6 * (i / 4) * MINI_TILEY + MINI_TILEY/2 - 1,
- 3 * MINI_TILEX + 2, 3 * MINI_TILEY + 2);
+ DrawTextF(x, y, FONT_TEXT_1, checkbutton_info[i].text);
+ ModifyGadget(level_editor_gadget[checkbutton_info[i].gadget_id],
+ GDI_CHECKED, *checkbutton_info[i].value, GDI_END);
+ MapCheckbuttonGadget(i);
}
- /* copy border to the right location */
- BlitBitmap(drawto, drawto,
- area_sx, area_sy, (5 * 4 + 1) * MINI_TILEX, 11 * MINI_TILEY,
- area_sx - MINI_TILEX/2, area_sy - MINI_TILEY/2);
-
- DrawText(area_sx + (5 * 4 - 1) * MINI_TILEX, area_sy + 0 * MINI_TILEY + 1,
- "Content", FS_SMALL, font_color);
- DrawText(area_sx + (5 * 4 - 1) * MINI_TILEX, area_sy + 1 * MINI_TILEY + 1,
- "when", FS_SMALL, font_color);
- DrawText(area_sx + (5 * 4 - 1) * MINI_TILEX, area_sy + 2 * MINI_TILEY + 1,
- "smashed", FS_SMALL, font_color);
-
- for (i=0; i<level.num_yam_contents; i++)
+ /* draw selectbox gadgets */
+ for (i=ED_SELECTBOX_ID_CHANGE_FIRST; i<=ED_SELECTBOX_ID_CHANGE_LAST; i++)
{
- for (y=0; y<3; y++)
- for (x=0; x<3; x++)
- DrawMiniElement(area_x + 5 * (i % 4) + x, area_y + 6 * (i / 4) + y,
- ElementContent[i][x][y]);
+ int yoffset = ED_BORDER_SIZE;
- DrawTextF(area_sx - SX + 5 * (i % 4) * MINI_TILEX + MINI_TILEX + 1,
- area_sy - SY + 6 * (i / 4) * MINI_TILEY + 4 * MINI_TILEY - 4,
- font_color, "%d", i + 1);
+ x = selectbox_info[i].x;
+ y = selectbox_info[i].y + yoffset;
+
+ DrawTextF(x, y, FONT_TEXT_1, selectbox_info[i].text);
+ ModifyEditorSelectbox(i, *selectbox_info[i].value);
+ MapSelectboxGadget(i);
}
- for (i=0; i<level.num_yam_contents; i++)
- MapDrawingArea(GADGET_ID_ELEM_CONTENT_0 + i);
+ DrawCustomChangedArea();
}
-#define TEXT_COLLECTING "Score for collecting"
-#define TEXT_SMASHING "Score for smashing"
-#define TEXT_CRACKING "Score for cracking"
-#define TEXT_SPEED "Speed of amoeba growth"
-#define TEXT_DURATION "Duration when activated"
-
static void DrawPropertiesWindow()
{
- int counter_id = ED_COUNTER_ID_ELEM_SCORE;
- int num_elements_in_level;
- float percentage;
- int xoffset_right = counter_xsize;
- int yoffset_right = ED_BORDER_SIZE;
- int xoffset_right2 = ED_CHECKBUTTON_XSIZE + 2 * ED_GADGET_DISTANCE;
- int yoffset_right2 = ED_BORDER_SIZE;
int xstart = 2;
int ystart = 4;
- int font_color = FC_GREEN;
- int i, x, y;
- static struct
- {
- int element;
- int *value;
- char *text;
- } elements_with_counter[] =
- {
- { EL_EDELSTEIN, &level.score[SC_EDELSTEIN], TEXT_COLLECTING },
- { EL_EDELSTEIN_BD, &level.score[SC_EDELSTEIN], TEXT_COLLECTING },
- { EL_EDELSTEIN_GELB,&level.score[SC_EDELSTEIN], TEXT_COLLECTING },
- { EL_EDELSTEIN_ROT, &level.score[SC_EDELSTEIN], TEXT_COLLECTING },
- { EL_EDELSTEIN_LILA,&level.score[SC_EDELSTEIN], TEXT_COLLECTING },
- { EL_DIAMANT, &level.score[SC_DIAMANT], TEXT_COLLECTING },
- { EL_KAEFER_RIGHT, &level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_KAEFER_UP, &level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_KAEFER_LEFT, &level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_KAEFER_DOWN, &level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_BUTTERFLY_RIGHT,&level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_BUTTERFLY_UP, &level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_BUTTERFLY_LEFT,&level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_BUTTERFLY_DOWN,&level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_FLIEGER_RIGHT, &level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_FLIEGER_UP, &level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_FLIEGER_LEFT, &level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_FLIEGER_DOWN, &level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_FIREFLY_RIGHT, &level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_FIREFLY_UP, &level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_FIREFLY_LEFT, &level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_FIREFLY_DOWN, &level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_MAMPFER, &level.score[SC_MAMPFER], TEXT_SMASHING },
- { EL_MAMPFER2, &level.score[SC_MAMPFER], TEXT_SMASHING },
- { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING },
- { EL_PACMAN_RIGHT, &level.score[SC_PACMAN], TEXT_SMASHING },
- { EL_PACMAN_UP, &level.score[SC_PACMAN], TEXT_SMASHING },
- { EL_PACMAN_LEFT, &level.score[SC_PACMAN], TEXT_SMASHING },
- { EL_PACMAN_DOWN, &level.score[SC_PACMAN], TEXT_SMASHING },
- { EL_KOKOSNUSS, &level.score[SC_KOKOSNUSS], TEXT_CRACKING },
- { EL_DYNAMITE_INACTIVE,&level.score[SC_DYNAMIT], TEXT_COLLECTING },
- { EL_SCHLUESSEL1, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_SCHLUESSEL2, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_SCHLUESSEL3, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_SCHLUESSEL4, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_EM_KEY_1_FILE, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_EM_KEY_2_FILE, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_EM_KEY_3_FILE, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_EM_KEY_4_FILE, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_AMOEBE_NASS, &level.amoeba_speed, TEXT_SPEED },
- { EL_AMOEBE_NORM, &level.amoeba_speed, TEXT_SPEED },
- { EL_AMOEBE_VOLL, &level.amoeba_speed, TEXT_SPEED },
- { EL_AMOEBE_BD, &level.amoeba_speed, TEXT_SPEED },
- { EL_MAGIC_WALL_OFF,&level.time_magic_wall, TEXT_DURATION },
- { EL_ABLENK_AUS, &level.time_wheel, TEXT_DURATION },
- { -1, NULL, NULL }
- };
-
- ClearWindow();
- UnmapLevelEditorWindowGadgets();
- DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS_YPOS,
- "Element Settings", FS_BIG, FC_YELLOW);
+ /* make sure that previous properties edit mode exists for this element */
+ if (edit_mode_properties == ED_MODE_PROPERTIES_ADVANCED &&
+ !IS_CUSTOM_ELEMENT(properties_element))
+ edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
- /* draw some decorative border for the object */
- for (y=0; y<3; y++)
- for (x=0; x<3; x++)
- DrawMiniElement(xstart + x , ystart + y, EL_ERDREICH);
-
- ClearRectangle(drawto,
- SX + xstart * MINI_TILEX + MINI_TILEX/2 - 1,
- SY + ystart * MINI_TILEY + MINI_TILEY/2 - 1,
- TILEX + 2, TILEY + 2);
-
- /* copy border to the right location */
- BlitBitmap(drawto, drawto,
- SX + xstart * MINI_TILEX,
- SY + ystart * MINI_TILEY,
- 2 * TILEX, 2 * TILEY,
- SX + xstart * MINI_TILEX - MINI_TILEX/2,
- SY + ystart * MINI_TILEY - MINI_TILEY/2);
-
- DrawGraphic(xstart/2, ystart/2, el2gfx(properties_element));
-
- /* copy the whole stuff to the definitive location */
- BlitBitmap(drawto, drawto,
- SX + xstart * MINI_TILEX - MINI_TILEX/2,
- SY + ystart * MINI_TILEY - MINI_TILEY,
- 2 * TILEX, 2 * TILEY,
- SX + xstart * MINI_TILEX - MINI_TILEX/2,
- SY + ystart * MINI_TILEY - MINI_TILEY/2);
+ if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
+ !checkPropertiesConfig())
+ edit_mode_properties = ED_MODE_PROPERTIES_INFO;
- DrawTextF((xstart + 3) * MINI_TILEX, (ystart + 1) * MINI_TILEY,
- font_color, getElementInfoText(properties_element));
+ if (IS_CUSTOM_ELEMENT(properties_element))
+ CopyCustomElementPropertiesToEditor(properties_element);
- num_elements_in_level = 0;
- for (y=0; y<lev_fieldy; y++)
- for (x=0; x<lev_fieldx; x++)
- if (Feld[x][y] == properties_element)
- num_elements_in_level++;
- percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
+ UnmapLevelEditorWindowGadgets();
- DrawTextF(ED_SETTINGS_XPOS, 5 * TILEY, font_color, "In this level:");
- DrawTextF(ED_SETTINGS_XPOS + 15 * FONT2_XSIZE, 5 * TILEY, FC_YELLOW,
- "%d (%.2f%%)", num_elements_in_level, percentage);
+ SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
+ ClearWindow();
- /* check if there are elements where a score can be chosen for */
- for (i=0; elements_with_counter[i].element != -1; i++)
- {
- if (elements_with_counter[i].element == properties_element)
- {
- int x = counterbutton_info[counter_id].x + xoffset_right;
- int y = counterbutton_info[counter_id].y + yoffset_right;
+ DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
+ "Element Settings", FONT_TITLE_1);
- counterbutton_info[counter_id].value = elements_with_counter[i].value;
- DrawTextF(x, y, font_color, elements_with_counter[i].text);
+ DrawElementBorder(SX + xstart * MINI_TILEX,
+ SY + ystart * MINI_TILEY + MINI_TILEY / 2,
+ TILEX, TILEY, FALSE);
+ DrawGraphicAnimationExt(drawto,
+ SX + xstart * MINI_TILEX,
+ SY + ystart * MINI_TILEY + MINI_TILEY / 2,
+ el2img(properties_element), -1, NO_MASKING);
- ModifyEditorCounter(counter_id, *counterbutton_info[counter_id].value);
- MapCounterButtons(counter_id);
- break;
- }
- }
+ FrameCounter = 0; /* restart animation frame counter */
- if (HAS_CONTENT(properties_element))
- {
- /* draw stickybutton gadget */
- i = ED_CHECKBUTTON_ID_STICK_ELEMENT;
- x = checkbutton_info[i].x + xoffset_right2;
- y = checkbutton_info[i].y + yoffset_right2;
+ DrawTextF((xstart + 3) * MINI_TILEX, (ystart + 1) * MINI_TILEY,
+ FONT_TEXT_1, getElementInfoText(properties_element));
- DrawTextF(x, y, font_color, checkbutton_info[i].text);
- ModifyGadget(level_editor_gadget[checkbutton_info[i].gadget_id],
- GDI_CHECKED, *checkbutton_info[i].value, GDI_END);
- MapCheckbuttonGadget(i);
+ DrawPropertiesTabulatorGadgets();
- if (IS_AMOEBOID(properties_element))
- DrawAmoebaContentArea();
- else
- DrawElementContentAreas();
- }
+ if (edit_mode_properties == ED_MODE_PROPERTIES_INFO)
+ DrawPropertiesInfo();
+ else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG)
+ DrawPropertiesConfig();
+ else /* edit_mode_properties == ED_MODE_PROPERTIES_ADVANCED */
+ DrawPropertiesAdvanced();
}
static void DrawLineElement(int sx, int sy, int element, boolean change_level)
}
}
-static void DrawRectangle(int from_x, int from_y, int to_x, int to_y,
- int element, boolean change_level)
+static void DrawBox(int from_x, int from_y, int to_x, int to_y,
+ int element, boolean change_level)
{
DrawLine(from_x, from_y, from_x, to_y, element, change_level);
DrawLine(from_x, to_y, to_x, to_y, element, change_level);
int element, boolean change_level)
{
if (element == -1 || change_level)
- DrawRectangle(from_x, from_y, to_x, to_y, -1, FALSE);
+ DrawBox(from_x, from_y, to_x, to_y, -1, FALSE);
else
DrawAreaBorder(from_x, from_y, to_x, to_y);
}
if (letter >= 'a' && letter <= 'z')
letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a');
else if (letter == 'ä' || letter == 'Ä')
- letter_element = EL_CHAR_AE;
+ letter_element = EL_CHAR_AUMLAUT;
else if (letter == 'ö' || letter == 'Ö')
- letter_element = EL_CHAR_OE;
+ letter_element = EL_CHAR_OUMLAUT;
else if (letter == 'ü' || letter == 'Ü')
- letter_element = EL_CHAR_UE;
+ letter_element = EL_CHAR_UUMLAUT;
else if (letter == '^')
- letter_element = EL_CHAR_COPY;
+ letter_element = EL_CHAR_COPYRIGHT;
else
letter_element = EL_CHAR_ASCII0 + letter;
int sx = gi->event.x, sy = gi->event.y;
int min_sx = 0, min_sy = 0;
int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
+ int item_xsize = gi->drawing.item_xsize, item_ysize = gi->drawing.item_ysize;
int lx = 0, ly = 0;
int min_lx = 0, min_ly = 0;
int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
}
else if (new_element != Feld[lx][ly])
{
- if (new_element == EL_SPIELFIGUR)
+ if (new_element == EL_PLAYER_1)
{
/* remove player at old position */
for(y=0; y<lev_fieldy; y++)
{
for(x=0; x<lev_fieldx; x++)
{
- if (Feld[x][y] == EL_SPIELFIGUR || Feld[x][y] == EL_SPIELER1)
+ if (Feld[x][y] == EL_PLAYER_1)
{
- Feld[x][y] = EL_LEERRAUM;
+ Feld[x][y] = EL_EMPTY;
if (x - level_xpos >= 0 && x - level_xpos < ed_fieldx &&
y - level_ypos >= 0 && y - level_ypos < ed_fieldy)
DrawMiniElement(x - level_xpos, y - level_ypos,
- EL_LEERRAUM);
+ EL_EMPTY);
}
}
}
}
else
{
- DrawMiniGraphicExt(drawto, gc,
- gi->x + sx * MINI_TILEX,
- gi->y + sy * MINI_TILEY,
- el2gfx(new_element));
- DrawMiniGraphicExt(window, gc,
- gi->x + sx * MINI_TILEX,
- gi->y + sy * MINI_TILEY,
- el2gfx(new_element));
+ if (item_xsize == MINI_TILEX && item_ysize == MINI_TILEY)
+ DrawMiniGraphicExt(drawto,
+ gi->x + sx * MINI_TILEX,
+ gi->y + sy * MINI_TILEY,
+ el2edimg(new_element));
+ else
+ DrawGraphicExt(drawto,
+ gi->x + sx * TILEX,
+ gi->y + sy * TILEY,
+ el2img(new_element), 0);
if (id == GADGET_ID_AMOEBA_CONTENT)
level.amoeba_content = new_element;
+ else if (id == GADGET_ID_CUSTOM_GRAPHIC)
+ {
+ int i = properties_element - EL_CUSTOM_START;
+
+ new_element = GFX_ELEMENT(new_element);
+ custom_element.gfx_element = new_element;
+ level.custom_element[i] = custom_element;
+
+ ModifyEditorElementList();
+
+ FrameCounter = 0; /* restart animation frame counter */
+ }
+ else if (id == GADGET_ID_CUSTOM_CONTENT)
+ {
+ int i = properties_element - EL_CUSTOM_START;
+
+ custom_element.content[sx][sy] = new_element;
+ level.custom_element[i] = custom_element;
+ }
+ else if (id == GADGET_ID_CUSTOM_CHANGED)
+ {
+ int i = properties_element - EL_CUSTOM_START;
+
+ custom_element.change.successor = new_element;
+ level.custom_element[i] = custom_element;
+ }
else if (id == GADGET_ID_RANDOM_BACKGROUND)
random_placement_background_element = new_element;
- else if (id >= GADGET_ID_ELEM_CONTENT_0 &&
- id <= GADGET_ID_ELEM_CONTENT_7)
- level.yam_content[id - GADGET_ID_ELEM_CONTENT_0][sx][sy] =
+ else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
+ id <= GADGET_ID_ELEMENT_CONTENT_7)
+ level.yamyam_content[id - GADGET_ID_ELEMENT_CONTENT_0][sx][sy] =
new_element;
}
break;
else if (drawing_function == GADGET_ID_ARC)
draw_func = DrawArc;
else if (drawing_function == GADGET_ID_RECTANGLE)
- draw_func = DrawRectangle;
+ draw_func = DrawBox;
else if (drawing_function == GADGET_ID_FILLED_BOX)
draw_func = DrawFilledBox;
else if (drawing_function == GADGET_ID_GRAB_BRUSH)
switch (counter_id)
{
- case ED_COUNTER_ID_ELEM_CONTENT:
+ case ED_COUNTER_ID_ELEMENT_CONTENT:
DrawElementContentAreas();
break;
case ED_COUNTER_ID_SELECT_LEVEL:
LoadLevel(level_nr);
+ TapeErase();
ResetUndoBuffer();
DrawEditModeWindow();
break;
default:
break;
}
+
+ if (counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
+ counter_id <= ED_COUNTER_ID_CHANGE_LAST)
+ CopyCustomElementPropertiesToGame(properties_element);
}
static void HandleTextInputGadgets(struct GadgetInfo *gi)
strcpy(textinput_info[gi->custom_type_id].value, gi->text.value);
}
+static void HandleSelectboxGadgets(struct GadgetInfo *gi)
+{
+ int type_id = gi->custom_type_id;
+
+ *selectbox_info[type_id].index = gi->selectbox.index;
+ *selectbox_info[type_id].value =
+ selectbox_info[type_id].options[gi->selectbox.index].value;
+
+ if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
+ type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
+ (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
+ type_id <= ED_SELECTBOX_ID_CHANGE_LAST))
+ CopyCustomElementPropertiesToGame(properties_element);
+
+#if 0
+ printf("Selected text value: '%s' [%d]\n",
+ selectbox_info[type_id].options[gi->selectbox.index].text,
+ selectbox_info[type_id].options[gi->selectbox.index].value);
+#endif
+}
+
+static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
+{
+ if (gi->custom_type_id >= ED_TEXTBUTTON_ID_PROPERTIES_INFO &&
+ gi->custom_type_id <= ED_TEXTBUTTON_ID_PROPERTIES_ADVANCED)
+ {
+ edit_mode_properties = gi->custom_type_id;
+
+ DrawPropertiesWindow();
+ }
+}
+
static void HandleRadiobuttons(struct GadgetInfo *gi)
{
*radiobutton_info[gi->custom_type_id].value =
static void HandleCheckbuttons(struct GadgetInfo *gi)
{
- *checkbutton_info[gi->custom_type_id].value ^= TRUE;
+ int type_id = gi->custom_type_id;
+
+ *checkbutton_info[type_id].value ^= TRUE;
+
+ if ((type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST &&
+ type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) ||
+ (type_id >= ED_CHECKBUTTON_ID_CHANGE_FIRST &&
+ type_id <= ED_CHECKBUTTON_ID_CHANGE_LAST))
+ CopyCustomElementPropertiesToGame(properties_element);
+
+ if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC)
+ ModifyEditorElementList();
}
static void HandleControlButtons(struct GadgetInfo *gi)
int button = gi->event.button;
int step = BUTTON_STEPSIZE(button);
int new_element = BUTTON_ELEMENT(button);
- int i, x, y;
+ int x, y;
if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT)
DrawLevelText(0, 0, 0, TEXT_END);
if (element_shift < 0)
element_shift = 0;
- if (element_shift > elements_in_list - ED_NUM_ELEMENTLIST_BUTTONS)
- element_shift = elements_in_list - ED_NUM_ELEMENTLIST_BUTTONS;
+ if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
+ element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
GDI_SCROLLBAR_ITEM_POSITION,
element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
}
- for (i=0; i<ED_NUM_ELEMENTLIST_BUTTONS; i++)
- {
- int gadget_id = GADGET_ID_ELEMENTLIST_FIRST + i;
- struct GadgetInfo *gi = level_editor_gadget[gadget_id];
- struct GadgetDesign *gd = &gi->deco.design;
- int element = editor_element[element_shift + i];
-
- UnmapGadget(gi);
- getMiniGraphicSource(el2gfx(element), &gd->bitmap, &gd->x, &gd->y);
- ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
- MapGadget(gi);
- }
+ ModifyEditorElementList();
+
break;
case GADGET_ID_WRAP_LEFT:
case GADGET_ID_FLOOD_FILL:
case GADGET_ID_GRAB_BRUSH:
case GADGET_ID_PICK_ELEMENT:
- last_drawing_function = drawing_function;
+ if (drawing_function != GADGET_ID_PICK_ELEMENT)
+ last_drawing_function = drawing_function;
drawing_function = id;
draw_with_brush = FALSE;
break;
case GADGET_ID_CLEAR:
for(x=0; x<MAX_LEV_FIELDX; x++)
for(y=0; y<MAX_LEV_FIELDY; y++)
- Feld[x][y] = (button == 1 ? EL_LEERRAUM : new_element);
+ Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
{
if (Request("Save this level and kill the old ?", REQ_ASK))
{
- for(x=0; x<lev_fieldx; x++)
- for(y=0; y<lev_fieldy; y++)
- Ur[x][y] = Feld[x][y];
+ CopyPlayfield(Feld, Ur);
+
SaveLevel(level_nr);
}
}
Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
else
{
- for(x=0; x<lev_fieldx; x++)
- for(y=0; y<lev_fieldy; y++)
- FieldBackup[x][y] = Ur[x][y];
+ if (LevelChanged())
+ level.game_version = GAME_VERSION_ACTUAL;
- for(x=0; x<lev_fieldx; x++)
- for(y=0; y<lev_fieldy; y++)
- Ur[x][y] = Feld[x][y];
+ CopyPlayfield(Ur, FieldBackup);
+ CopyPlayfield(Feld, Ur);
UnmapLevelEditorGadgets();
UndrawSpecialEditorDoor();
TapeStartRecording();
level_editor_test_game = TRUE;
- game_status = PLAYING;
+ game_status = GAME_MODE_PLAYING;
InitGame();
}
break;
case GADGET_ID_EXIT:
- if (!LevelChanged() ||
- Request("Level has changed! Exit without saving ?",
- REQ_ASK | REQ_STAY_OPEN))
- {
- CloseDoor(DOOR_CLOSE_1);
-
- /*
- CloseDoor(DOOR_CLOSE_ALL);
- */
-
- game_status = MAINMENU;
- DrawMainMenu();
- }
- else
- {
- CloseDoor(DOOR_CLOSE_1);
- BlitBitmap(pix[PIX_DB_DOOR], pix[PIX_DB_DOOR],
- DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
- DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
- OpenDoor(DOOR_OPEN_1);
- }
+ RequestExitLevelEditor(TRUE); /* if level has changed, ask user */
break;
default:
id <= GADGET_ID_ELEMENTLIST_LAST)
{
int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
- int new_element = editor_element[element_position + element_shift];
+ int new_element = editor_elements[element_position + element_shift];
PickDrawingElement(button, new_element);
+#if 1
+ if (!stick_element_properties_window)
+#else
if (!HAS_CONTENT(properties_element) ||
!stick_element_properties_window)
+#endif
{
properties_element = new_element;
if (edit_mode == ED_MODE_PROPERTIES)
DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
else if (key == KSYM_Return)
DrawLevelText(0, 0, 0, TEXT_NEWLINE);
+ else if (key == KSYM_Escape)
+ DrawLevelText(0, 0, 0, TEXT_END);
}
else if (button_status == MB_RELEASED)
{
- int i, id;
+ int i, id = GADGET_ID_NONE;
switch (key)
{
button = MB_RIGHTBUTTON;
break;
+ case KSYM_Escape:
+ if (edit_mode == ED_MODE_DRAWING)
+ {
+ RequestExitLevelEditor(setup.ask_on_escape);
+ }
+ else
+ {
+ DrawDrawingWindow();
+ edit_mode = ED_MODE_DRAWING;
+ }
+ break;
+
default:
- id = GADGET_ID_NONE;
break;
}
ClickOnGadget(level_editor_gadget[id], button);
else if (letter == '.')
ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
- else if (key == KSYM_space || key == KSYM_Return)
+ else if (key == KSYM_Return || key == setup.shortcut.toggle_pause)
ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
else
for (i=0; i<ED_NUM_CTRL_BUTTONS; i++)
}
}
+void HandleLevelEditorIdle()
+{
+ static unsigned long action_delay = 0;
+ unsigned long action_delay_value = GameFrameDelay;
+ int xpos = 1, ypos = 2;
+
+ if (edit_mode != ED_MODE_PROPERTIES)
+ return;
+
+ if (!DelayReached(&action_delay, action_delay_value))
+ return;
+
+ DrawGraphicAnimationExt(drawto,
+ SX + xpos * TILEX,
+ SY + ypos * TILEY + MINI_TILEY / 2,
+ el2img(properties_element), -1, NO_MASKING);
+
+ MarkTileDirty(xpos, ypos);
+ MarkTileDirty(xpos, ypos + 1);
+
+ FrameCounter++; /* increase animation frame counter */
+}
+
void ClearEditorGadgetInfoText()
{
- ClearRectangle(drawto,
- INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
- redraw_mask |= REDRAW_FIELD;
+ DrawBackground(INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
}
void HandleEditorGadgetInfoText(void *ptr)
{
struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
- char infotext[MAX_INFOTEXT_LEN + 1];
- char shortcut[MAX_INFOTEXT_LEN + 1];
+ char infotext[MAX_OUTPUT_LINESIZE + 1];
+ char shortcut[MAX_OUTPUT_LINESIZE + 1];
+ int max_infotext_len = getMaxInfoTextLength();
- if (game_status != LEVELED)
+ if (game_status != GAME_MODE_EDITOR)
return;
ClearEditorGadgetInfoText();
+ if (gi->event.type == GD_EVENT_INFO_LEAVING)
+ return;
+
/* misuse this function to delete brush cursor, if needed */
if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
DeleteBrushFromCursor();
if (gi == NULL || gi->info_text == NULL)
return;
- strncpy(infotext, gi->info_text, MAX_INFOTEXT_LEN);
- infotext[MAX_INFOTEXT_LEN] = '\0';
+ strncpy(infotext, gi->info_text, max_infotext_len);
+ infotext[max_infotext_len] = '\0';
if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
{
sprintf(shortcut, " ('%s%c')",
(key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
- if (strlen(infotext) + strlen(shortcut) <= MAX_INFOTEXT_LEN)
+ if (strlen(infotext) + strlen(shortcut) <= max_infotext_len)
strcat(infotext, shortcut);
}
}
- DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FS_SMALL, FC_YELLOW);
+ DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FONT_TEXT_2);
}
static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
ClearEditorGadgetInfoText();
+ if (gi->event.type == GD_EVENT_INFO_LEAVING)
+ return;
+
/* make sure to stay inside drawing area boundaries */
sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
}
if (drawing_function == GADGET_ID_PICK_ELEMENT)
- DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
"%s: %d, %d", infotext, lx, ly);
else
- DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
"%s: %d, %d", infotext,
ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1);
}
else if (drawing_function == GADGET_ID_PICK_ELEMENT)
- DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
"%s", getElementInfoText(Feld[lx][ly]));
else
- DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
"Level position: %d, %d", lx, ly);
}
}
}
else if (id == GADGET_ID_AMOEBA_CONTENT)
- DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
"Amoeba content");
+ else if (id == GADGET_ID_CUSTOM_GRAPHIC)
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
+ "Custom graphic element");
+ else if (id == GADGET_ID_CUSTOM_CONTENT)
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
+ "Custom element content position: %d, %d", sx, sy);
+ else if (id == GADGET_ID_CUSTOM_CHANGED)
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
+ "New element after change");
else if (id == GADGET_ID_RANDOM_BACKGROUND)
- DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
"Random placement background");
else
- DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
"Content area %d position: %d, %d",
- id - GADGET_ID_ELEM_CONTENT_0 + 1, sx, sy);
+ id - GADGET_ID_ELEMENT_CONTENT_0 + 1, sx, sy);
+}
+
+void RequestExitLevelEditor(boolean ask_if_level_has_changed)
+{
+ if (!ask_if_level_has_changed ||
+ !LevelChanged() ||
+ Request("Level has changed! Exit without saving ?",
+ REQ_ASK | REQ_STAY_OPEN))
+ {
+ CloseDoor(DOOR_CLOSE_1);
+ /*
+ CloseDoor(DOOR_CLOSE_ALL);
+ */
+ game_status = GAME_MODE_MAIN;
+ DrawMainMenu();
+ }
+ else
+ {
+ CloseDoor(DOOR_CLOSE_1);
+ BlitBitmap(bitmap_db_door, bitmap_db_door,
+ DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
+ DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
+ OpenDoor(DOOR_OPEN_1);
+ }
}