#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
#define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
ED_ELEMENTLIST_BUTTONS_VERT)
+/* standard distances */
+#define ED_BORDER_SIZE 3
+#define ED_BORDER2_SIZE 5
+#define ED_GADGET_DISTANCE 2
+
/* 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_XOFFSET_CHECKBOX (ED_CHECKBUTTON_XSIZE + \
+ 2 * ED_GADGET_DISTANCE)
+
+#define ED_SETTINGS_XOFFSET ED_XOFFSET_CHECKBOX
+#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_PUSH_DELAY_RND_XPOS (ED_SETTINGS_XPOS(1) + 16 * MINI_TILEX)
+#define ED_COUNT_MOVE_DELAY_RND_XPOS ED_COUNT_PUSH_DELAY_RND_XPOS
+#define ED_COUNT_CHANGE_DELAY_RND_XPOS (ED_SETTINGS_XPOS(1) + 13 * 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_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(2) + \
+ ED_GADGET_DISTANCE)
+
+#define ED_AREA_ELEM_CONTENT3_XPOS (24 * MINI_TILEX)
+#define ED_AREA_ELEM_CONTENT3_YPOS (ED_SETTINGS_YPOS(1) + \
+ ED_GADGET_DISTANCE)
+
+#if 1
+#define ED_AREA_ELEM_CONTENT4_XPOS (29 * MINI_TILEX)
+#define ED_AREA_ELEM_CONTENT4_YPOS (ED_SETTINGS_YPOS(3) + \
+ ED_GADGET_DISTANCE - MINI_TILEY)
+#else
+#define ED_AREA_ELEM_CONTENT4_XPOS (17 * MINI_TILEX)
+#define ED_AREA_ELEM_CONTENT4_YPOS (ED_SETTINGS_YPOS(11) + \
+ ED_GADGET_DISTANCE - MINI_TILEY)
+#endif
+
/* 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 + \
+ 4 * (2 + ED_WIN_COUNT_YSIZE))
+#define ED_TEXTBUTTON_INACTIVE_YPOS ED_TEXTBUTTON_YPOS
+
+#define ED_TEXTBUTTON_TAB_XPOS ED_WIN_COUNT_XPOS
+#define ED_TEXTBUTTON_TAB_YPOS (ED_WIN_COUNT_YPOS + \
+ 2 * (2 + ED_WIN_COUNT_YSIZE))
+#define ED_TEXTBUTTON_TAB_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_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 27)
+#define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 28)
+#define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 29)
+#define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 30)
+#define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 31)
+#define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 32)
+#define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 33)
+#define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 34)
+#define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 35)
+#define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 36)
+#define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 37)
+#define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 38)
+#define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 39)
+#define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 40)
+#define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 41)
+#define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 42)
+#define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 43)
+#define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 44)
+#define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 45)
+#define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 46)
+#define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 47)
/* 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 + 48)
+
+#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)
+
+#define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0)
+#define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
+
+/* 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_CONSISTENCY (GADGET_ID_SELECTBOX_FIRST + 1)
+#define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 2)
+#define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 3)
+#define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 4)
+#define GADGET_ID_CUSTOM_WALKABLE_LAYER (GADGET_ID_SELECTBOX_FIRST + 5)
+#define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 6)
+#define GADGET_ID_CHANGE_PLAYER_ACTION (GADGET_ID_SELECTBOX_FIRST + 7)
+#define GADGET_ID_CHANGE_CAUSE (GADGET_ID_SELECTBOX_FIRST + 8)
+
+/* textbutton identifiers */
+#define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 9)
+
+#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)
+#define GADGET_ID_SAVE_AS_TEMPLATE (GADGET_ID_TEXTBUTTON_FIRST + 3)
/* 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_SCROLLING_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 4)
+
+#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_SCROLL_LIST_UP 67
-#define GADGET_ID_SCROLL_LIST_DOWN 68
-#define GADGET_ID_SCROLL_LIST_VERTICAL 69
-
-/* 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_EM_SLIPPERY_GEMS 76
-
-/* another drawing area for random placement */
-#define GADGET_ID_RANDOM_BACKGROUND 77
+#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)
+
+/* checkbuttons 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_EXPLODE_RESULT (GADGET_ID_CHECKBUTTON_FIRST + 7)
+#define GADGET_ID_CUSTOM_WALK_TO_OBJECT (GADGET_ID_CHECKBUTTON_FIRST + 8)
+#define GADGET_ID_CUSTOM_DEADLY (GADGET_ID_CHECKBUTTON_FIRST + 9)
+#define GADGET_ID_CUSTOM_CAN_MOVE (GADGET_ID_CHECKBUTTON_FIRST + 10)
+#define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 11)
+#define GADGET_ID_CUSTOM_CAN_SMASH (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_USE_TEMPLATE (GADGET_ID_CHECKBUTTON_FIRST + 16)
+#define GADGET_ID_CUSTOM_CHANGEABLE (GADGET_ID_CHECKBUTTON_FIRST + 17)
+#define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 18)
+#define GADGET_ID_CHANGE_BY_PLAYER (GADGET_ID_CHECKBUTTON_FIRST + 19)
/* gadgets for buttons in element list */
-#define GADGET_ID_ELEMENTLIST_FIRST 78
-#define GADGET_ID_ELEMENTLIST_LAST (78 + ED_NUM_ELEMENTLIST_BUTTONS - 1)
+#define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 20)
+#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_CUSTOM_SCORE 9
+#define ED_COUNTER_ID_PUSH_DELAY_FIX 10
+#define ED_COUNTER_ID_PUSH_DELAY_RND 11
+#define ED_COUNTER_ID_MOVE_DELAY_FIX 12
+#define ED_COUNTER_ID_MOVE_DELAY_RND 13
+#define ED_COUNTER_ID_CHANGE_DELAY_FIX 14
+#define ED_COUNTER_ID_CHANGE_DELAY_RND 15
+
+#define ED_NUM_COUNTERBUTTONS 16
#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_CUSTOM_FIRST ED_COUNTER_ID_CUSTOM_SCORE
+#define ED_COUNTER_ID_CUSTOM_LAST ED_COUNTER_ID_MOVE_DELAY_RND
+
+#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_CONSISTENCY 1
+#define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 2
+#define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 3
+#define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 4
+#define ED_SELECTBOX_ID_CUSTOM_WALKABLE_LAYER 5
+#define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 6
+#define ED_SELECTBOX_ID_CHANGE_PLAYER_ACTION 7
+#define ED_SELECTBOX_ID_CHANGE_CAUSE 8
+
+#define ED_NUM_SELECTBOX 9
+
+#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_TEXTBUTTON_ID_SAVE_AS_TEMPLATE 3
+
+#define ED_NUM_TEXTBUTTON 4
+
/* 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_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 4
-
-#define ED_NUM_CHECKBUTTONS 5
+#define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_RESULT 5
+#define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 6
+#define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 7
+#define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 8
+#define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 9
+#define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 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_USE_TEMPLATE 14
+#define ED_CHECKBUTTON_ID_CUSTOM_CHANGEABLE 15
+#define ED_CHECKBUTTON_ID_CHANGE_DELAY 16
+#define ED_CHECKBUTTON_ID_CHANGE_BY_PLAYER 17
+
+#define ED_NUM_CHECKBUTTONS 18
#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_EXPLODE_RESULT
+#define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM_WALKABLE
+
+#define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC
+#define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_BY_PLAYER
+
/* 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_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 ElementInfo custom_element;
static struct
{
int gadget_id_down, gadget_id_up;
int gadget_id_text;
int *value;
- char *infotext_above, *infotext_right;
+ char *text_above, *text_left, *text_right;
} 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, 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,
&level.fieldx,
- "playfield size", "width",
+ "playfield size", NULL, "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,
&level.fieldy,
- NULL, "height",
+ NULL, 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,
&level.gems_needed,
- "number of emeralds to collect", NULL
+ "number of emeralds to collect", NULL, 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,
&level.time,
- "time available to solve level", "(0 => no time limit)"
+ "time available to solve level", NULL, "(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],
- "score for each 10 seconds left", NULL
+ &level.score[SC_TIME_BONUS],
+ "score for each 10 seconds left", NULL, 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_placement_value,
- "random element placement", "in"
+ "random element placement", NULL, "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_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
+ 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 */
+ NULL, NULL, NULL
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(6),
+ 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,
+ NULL, NULL, "number of content areas"
+ },
+ {
+ ED_SETTINGS_XPOS(9), ED_SETTINGS_YPOS(4),
+ MIN_SCORE, MAX_SCORE,
+ GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
+ GADGET_ID_CUSTOM_SCORE_TEXT,
+ &custom_element.score,
+ NULL, "score", NULL
+ },
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5),
+ 0, 999,
+ GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP,
+ GADGET_ID_PUSH_DELAY_FIX_TEXT,
+ &custom_element.push_delay_fixed,
+ NULL, "push delay", NULL
+ },
+ {
+ ED_COUNT_PUSH_DELAY_RND_XPOS, ED_SETTINGS_YPOS(5),
+ 0, 999,
+ GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
+ GADGET_ID_PUSH_DELAY_RND_TEXT,
+ &custom_element.push_delay_random,
+ NULL, "+random", NULL
+ },
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(8),
+ 0, 999,
+ GADGET_ID_MOVE_DELAY_FIX_DOWN, GADGET_ID_MOVE_DELAY_FIX_UP,
+ GADGET_ID_MOVE_DELAY_FIX_TEXT,
+ &custom_element.move_delay_fixed,
+ NULL, "move delay", NULL
+ },
+ {
+ ED_COUNT_MOVE_DELAY_RND_XPOS, ED_SETTINGS_YPOS(8),
+ 0, 999,
+ GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
+ GADGET_ID_MOVE_DELAY_RND_TEXT,
+ &custom_element.move_delay_random,
+ NULL, "+random", NULL
+ },
+ {
+ ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(3),
+ 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, "delay", NULL,
+ },
+ {
+ ED_COUNT_CHANGE_DELAY_RND_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, "+random", NULL
}
};
} 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_pattern[] =
+{
+ { MV_LEFT, "left" },
+ { MV_RIGHT, "right" },
+ { MV_UP, "up" },
+ { MV_DOWN, "down" },
+ { MV_HORIZONTAL, "horizontal" },
+ { MV_VERTICAL, "vertical" },
+ { MV_ALL_DIRECTIONS, "all directions" },
+ { MV_TOWARDS_PLAYER, "towards player" },
+ { MV_AWAY_FROM_PLAYER, "away from player" },
+ { MV_ALONG_LEFT_SIDE, "along left side" },
+ { MV_ALONG_RIGHT_SIDE, "along right side" },
+ { -1, NULL }
+};
+static int index_move_pattern = 0;
+
+static struct ValueTextInfo options_move_direction[] =
+{
+ { MV_NO_MOVING, "automatic" },
+ { MV_LEFT, "left" },
+ { MV_RIGHT, "right" },
+ { MV_UP, "up" },
+ { MV_DOWN, "down" },
+ { -1, NULL }
+};
+static int index_move_direction = 0;
+
+static struct ValueTextInfo options_consistency[] =
+{
+ { EP_INDESTRUCTIBLE, "indestructible" },
+ { EP_CAN_EXPLODE_BY_FIRE, "can explode by fire" },
+ { EP_CAN_EXPLODE_SMASHED, "can explode when smashed" },
+ { EP_CAN_EXPLODE_IMPACT, "can explode on impact" },
+ { -1, NULL }
+};
+static int index_consistency = 0;
+
+static struct ValueTextInfo options_deadliness[] =
+{
+ { EP_DONT_RUN_INTO, "running into" },
+ { EP_DONT_COLLIDE_WITH, "colliding with" },
+ { EP_DONT_TOUCH, "touching" },
+ { -1, NULL }
+};
+static int index_deadliness = 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_player_action[] =
+{
+ { CE_PRESSED_BY_PLAYER, "pressed" },
+ { CE_TOUCHED_BY_PLAYER, "touched" },
+ { -1, NULL }
+};
+static int index_change_player_action = 0, value_change_player_action = 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; /* char size of selectbox or '-1' (dynamically determined) */
+ struct ValueTextInfo *options;
+ int *index, *value;
+ char *text_left, *text_right, *infotext;
+} selectbox_info[ED_NUM_SELECTBOX] =
+{
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(4),
+ GADGET_ID_CUSTOM_WALK_TO_ACTION,
+ -1,
+ options_walk_to_action, &index_walk_to_action,
+ &custom_element.walk_to_action,
+ NULL, NULL, "diggable/collectible/pushable"
+ },
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(3),
+ GADGET_ID_CUSTOM_CONSISTENCY,
+ -1,
+ options_consistency, &index_consistency,
+ &custom_element.consistency,
+ NULL, "to", "consistency/destructibility"
+ },
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(2),
+ GADGET_ID_CUSTOM_DEADLINESS,
+ -1,
+ options_deadliness, &index_deadliness,
+ &custom_element.deadliness,
+ "deadly when", NULL, "deadliness of element"
+ },
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(6),
+ GADGET_ID_CUSTOM_MOVE_PATTERN,
+ -1,
+ options_move_pattern, &index_move_pattern,
+ &custom_element.move_pattern,
+ "can move", NULL, "element move direction"
+ },
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(7),
+ GADGET_ID_CUSTOM_MOVE_DIRECTION,
+ -1,
+ options_move_direction, &index_move_direction,
+ &custom_element.move_direction_initial,
+ "starts moving", NULL, "initial element move direction"
+ },
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(13),
+ GADGET_ID_CUSTOM_WALKABLE_LAYER,
+ -1,
+ options_walkable_layer, &index_walkable_layer,
+ &custom_element.walkable_layer,
+ "player can walk", NULL, "layer where player can walk"
+ },
+ {
+ ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(4),
+ GADGET_ID_CHANGE_TIME_UNITS,
+ -1,
+ options_time_units, &index_time_units,
+ &custom_element.change.delay_frames,
+ "delay time given in", NULL, "delay time units for change"
+ },
+ {
+ ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(5),
+ GADGET_ID_CHANGE_PLAYER_ACTION,
+ -1,
+ options_change_player_action, &index_change_player_action,
+ &value_change_player_action,
+ NULL, "by player", "type of player contact"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(10),
+ GADGET_ID_CHANGE_CAUSE,
+ -1,
+ options_change_cause, &index_change_cause,
+ &value_change_cause,
+ "test:", NULL, "test-selectbox entry"
+ },
+};
+
+static struct
+{
+ int x, y;
+ int gadget_id;
+ int size;
+ char *text, *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"
+ },
+ {
+ ED_SETTINGS_XPOS(0) + 262, ED_SETTINGS_YPOS(12),
+ GADGET_ID_SAVE_AS_TEMPLATE,
+ -1, "Save as template", "Save current settings as new template"
+ },
+};
+
static struct
{
- int xpos, ypos;
+ int gd_x, gd_y;
int x, y;
int gadget_id;
char *infotext;
static struct
{
- int xpos, ypos;
+ int gd_x, gd_y;
int x, y;
int width, height;
int type;
int radio_button_nr;
int *value;
int checked_value;
- char *text, *infotext;
+ char *text_right, *infotext;
} 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,
int x, y;
int gadget_id;
boolean *value;
- char *text, *infotext;
+ char *text_right, *infotext;
} 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, ED_COUNTER_YPOS(4),
+ 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_EXPLODE_RESULT,
+ &custom_element_properties[EP_EXPLODE_RESULT],
+ NULL, "set consistency/destructibility"
+ },
+ {
+ 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(2),
+ GADGET_ID_CUSTOM_DEADLY,
+ &custom_element_properties[EP_DEADLY],
+ NULL, "element can kill the player"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(6),
+ 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(9),
+ GADGET_ID_CUSTOM_CAN_FALL,
+ &custom_element_properties[EP_CAN_FALL],
+ "can fall", "element can fall down"
+ },
+ {
+ ED_SETTINGS_XPOS(6), ED_SETTINGS_YPOS(9),
+ GADGET_ID_CUSTOM_CAN_SMASH,
+ &custom_element_properties[EP_CAN_SMASH],
+ "can smash on impact", "element can smash other elements"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(10),
+ GADGET_ID_CUSTOM_SLIPPERY,
+ &custom_element_properties[EP_SLIPPERY],
+ "slippery", "other elements can fall down from it"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(13),
+ GADGET_ID_CUSTOM_WALKABLE,
+ &custom_element_properties[EP_WALKABLE],
+ NULL, "player can walk on the same field"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1),
+ 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(12),
+ GADGET_ID_CUSTOM_USE_TEMPLATE,
+ &custom_element.use_template,
+ "use template", "use template for custom properties"
+ },
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
+ GADGET_ID_CUSTOM_CHANGEABLE,
+ &custom_element_properties[EP_CHANGEABLE],
+ "element changes to after/when:","element can change to other element"
+ },
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(3),
+ GADGET_ID_CHANGE_DELAY,
+ &custom_element_change_events[CE_DELAY],
+ NULL, "element changes after delay"
+ },
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5),
+ GADGET_ID_CHANGE_BY_PLAYER,
+ &custom_element_change_events[CE_BY_PLAYER],
+ NULL, "element changes by player contact"
+ },
};
-/* 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;
/* 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;
-
-int element_shift = 0;
+static 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_PLAYER1,
+ EL_PLAYER_1,
EL_EMPTY,
EL_SAND,
EL_STEELWALL,
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_PLAYER1,
- EL_PLAYER2,
- EL_PLAYER3,
- EL_PLAYER4,
+ EL_PLAYER_1,
+ EL_PLAYER_2,
+ EL_PLAYER_3,
+ EL_PLAYER_4,
- EL_PLAYER1,
+ EL_PLAYER_1,
EL_EMPTY,
EL_SAND,
EL_ROCK,
EL_SPACESHIP_DOWN,
EL_INVISIBLE_WALL,
- EL_ACIDPOOL_TOPLEFT,
+ EL_ACID_POOL_TOPLEFT,
EL_ACID,
- EL_ACIDPOOL_TOPRIGHT,
+ EL_ACID_POOL_TOPRIGHT,
EL_EMPTY,
- EL_ACIDPOOL_BOTTOMLEFT,
- EL_ACIDPOOL_BOTTOM,
- EL_ACIDPOOL_BOTTOMRIGHT,
+ EL_ACID_POOL_BOTTOMLEFT,
+ EL_ACID_POOL_BOTTOM,
+ EL_ACID_POOL_BOTTOMRIGHT,
EL_EMPTY,
EL_AMOEBA_DROP,
EL_AMOEBA_WET,
EL_AMOEBA_DRY,
- EL_EM_KEY1_FILE,
- EL_EM_KEY2_FILE,
- EL_EM_KEY3_FILE,
- EL_EM_KEY4_FILE,
+ EL_EM_KEY_1_FILE,
+ EL_EM_KEY_2_FILE,
+ EL_EM_KEY_3_FILE,
+ EL_EM_KEY_4_FILE,
- EL_EM_GATE1,
- EL_EM_GATE2,
- EL_EM_GATE3,
- EL_EM_GATE4,
+ EL_EM_GATE_1,
+ EL_EM_GATE_2,
+ EL_EM_GATE_3,
+ EL_EM_GATE_4,
- EL_EM_GATE1_GRAY,
- EL_EM_GATE2_GRAY,
- EL_EM_GATE3_GRAY,
- EL_EM_GATE4_GRAY,
+ 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_KEY1,
- EL_KEY2,
- EL_KEY3,
- EL_KEY4,
+ EL_KEY_1,
+ EL_KEY_2,
+ EL_KEY_3,
+ EL_KEY_4,
- EL_GATE1,
- EL_GATE2,
- EL_GATE3,
- EL_GATE4,
+ EL_GATE_1,
+ EL_GATE_2,
+ EL_GATE_3,
+ EL_GATE_4,
- EL_GATE1_GRAY,
- EL_GATE2_GRAY,
- EL_GATE3_GRAY,
- EL_GATE4_GRAY,
+ EL_GATE_1_GRAY,
+ EL_GATE_2_GRAY,
+ EL_GATE_3_GRAY,
+ EL_GATE_4_GRAY,
- EL_ARROW_BLUE_LEFT,
- EL_ARROW_BLUE_RIGHT,
- EL_ARROW_BLUE_UP,
- EL_ARROW_BLUE_DOWN,
+ EL_ARROW_LEFT,
+ EL_ARROW_RIGHT,
+ EL_ARROW_UP,
+ EL_ARROW_DOWN,
EL_AMOEBA_FULL,
EL_EMERALD_YELLOW,
EL_WALL_EMERALD_RED,
EL_WALL_EMERALD_PURPLE,
- EL_GAMEOFLIFE,
+ EL_GAME_OF_LIFE,
EL_PACMAN_UP,
EL_TIME_ORB_FULL,
EL_TIME_ORB_EMPTY,
EL_PACMAN_LEFT,
EL_DARK_YAMYAM,
EL_PACMAN_RIGHT,
- EL_WALL_GROWING,
+ EL_EXPANDABLE_WALL,
EL_BIOMAZE,
EL_PACMAN_DOWN,
EL_LAMP,
EL_LAMP_ACTIVE,
- EL_DYNABOMB_NR,
- EL_DYNABOMB_SZ,
- EL_DYNABOMB_XL,
+ EL_DYNABOMB_INCREASE_NUMBER,
+ EL_DYNABOMB_INCREASE_SIZE,
+ EL_DYNABOMB_INCREASE_POWER,
EL_STONEBLOCK,
EL_MOLE,
EL_EMPTY,
EL_MOLE_DOWN,
EL_BALLOON,
- EL_BALLOON_SEND_ANY_DIRECTION,
+ 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_SATELLITE,
- EL_WALL_GROWING_X,
- EL_WALL_GROWING_Y,
- EL_WALL_GROWING_XY,
+ EL_EXPANDABLE_WALL_HORIZONTAL,
+ EL_EXPANDABLE_WALL_VERTICAL,
+ EL_EXPANDABLE_WALL_ANY,
EL_INVISIBLE_STEELWALL,
EL_INVISIBLE_WALL,
EL_SPEED_PILL,
EL_BLACK_ORB,
- EL_EMC_STEELWALL1,
- EL_EMC_WALL_PILLAR_UPPER,
- EL_EMC_WALL_PILLAR_MIDDLE,
- EL_EMC_WALL_PILLAR_LOWER,
-
- EL_EMC_WALL4,
- EL_EMC_WALL5,
- EL_EMC_WALL6,
- EL_EMC_WALL7,
+ EL_EMC_STEELWALL_1,
+ EL_EMC_WALL_1,
+ EL_EMC_WALL_2,
+ EL_EMC_WALL_3,
+ EL_EMC_WALL_4,
+ 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_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_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_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_CONVEYOR_BELT1_LEFT,
- EL_CONVEYOR_BELT1_MIDDLE,
- EL_CONVEYOR_BELT1_RIGHT,
- EL_CONVEYOR_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_CONVEYOR_BELT2_LEFT,
- EL_CONVEYOR_BELT2_MIDDLE,
- EL_CONVEYOR_BELT2_RIGHT,
- EL_CONVEYOR_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_CONVEYOR_BELT3_LEFT,
- EL_CONVEYOR_BELT3_MIDDLE,
- EL_CONVEYOR_BELT3_RIGHT,
- EL_CONVEYOR_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_CONVEYOR_BELT4_LEFT,
- EL_CONVEYOR_BELT4_MIDDLE,
- EL_CONVEYOR_BELT4_RIGHT,
- EL_CONVEYOR_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_CONVEYOR_BELT1_SWITCH_LEFT,
- EL_CONVEYOR_BELT2_SWITCH_LEFT,
- EL_CONVEYOR_BELT3_SWITCH_LEFT,
- EL_CONVEYOR_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_CONVEYOR_BELT1_SWITCH_RIGHT,
- EL_CONVEYOR_BELT2_SWITCH_RIGHT,
- EL_CONVEYOR_BELT3_SWITCH_RIGHT,
- EL_CONVEYOR_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_SHIELD_DEADLY,
EL_EXTRA_TIME,
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_TUBE_HORIZONTAL,
EL_TUBE_VERTICAL_RIGHT,
- EL_TUBE_ALL,
+ EL_TUBE_ANY,
EL_TUBE_VERTICAL_LEFT,
EL_TUBE_VERTICAL,
EL_TRAP,
EL_DX_SUPABOMB,
EL_EMPTY,
- EL_EMPTY,
-
- /*
- 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
+};
+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_EMPTY,
- EL_EMPTY,
- EL_EMPTY,
- EL_EMPTY,
+ 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 int editor_el_custom[] =
+{
+ EL_CHAR('C'),
+ EL_CHAR('U'),
+ EL_CHAR('S'),
+ EL_CHAR('-'),
+
+ EL_CHAR('T'),
+ EL_CHAR('O'),
+ EL_CHAR('M'),
+ EL_CHAR(' '),
+
+ 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 = "unknown";
+ char *info_text = NULL;
if (element < NUM_FILE_ELEMENTS)
- info_text = element_info[element].editor_description;
- else
+ {
+ 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 CreateControlButtons()
{
- Bitmap *gd_bitmap = new_graphic_info[IMG_MENU_DOOR].bitmap;
+ Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
struct GadgetInfo *gi;
unsigned long event_mask;
int i;
y += DY;
width = ED_SCROLLBUTTON2_XSIZE;
height = ED_SCROLLBUTTON2_YSIZE;
- gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].xpos;
- gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].ypos;
+ gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
+ gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
gd_x2 = gd_x1 - ED_SCROLLBUTTON2_XSIZE;
gd_y2 = gd_y1;
}
y += SY;
width = ED_SCROLLBUTTON_XSIZE;
height = ED_SCROLLBUTTON_YSIZE;
- gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].xpos;
- gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].ypos;
+ gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].gd_x;
+ gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].gd_y;
gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
gd_y2 = gd_y1;
}
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(el2img(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++)
int j;
int xpos = SX + counterbutton_info[i].x; /* xpos of down count button */
int ypos = SY + counterbutton_info[i].y;
+ int xoffset = 0;
+
+ /* determine horizontal offset for leading counter text */
+ if (counterbutton_info[i].text_left != NULL)
+ xoffset = (getFontWidth(FONT_TEXT_1) *
+ strlen(counterbutton_info[i].text_left) +
+ 2 * ED_GADGET_DISTANCE);
for (j=0; j<2; j++)
{
- Bitmap *gd_bitmap = new_graphic_info[IMG_MENU_DOOR].bitmap;
+ 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;
xpos += 2 * ED_GADGET_DISTANCE;
ypos += ED_GADGET_DISTANCE;
- gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].xpos;
+ gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].gd_x;
gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
- gd_y = DOOR_GFX_PAGEY1 + scrollbutton_info[sid].ypos;
+ gd_y = DOOR_GFX_PAGEY1 + scrollbutton_info[sid].gd_y;
x_size = ED_SCROLLBUTTON_XSIZE;
y_size = ED_SCROLLBUTTON_YSIZE;
}
gi = CreateGadget(GDI_CUSTOM_ID, id,
GDI_CUSTOM_TYPE_ID, i,
GDI_INFO_TEXT, infotext,
- GDI_X, xpos,
+ GDI_X, xpos + xoffset,
GDI_Y, ypos,
GDI_WIDTH, x_size,
GDI_HEIGHT, y_size,
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;
gi = CreateGadget(GDI_CUSTOM_ID, id,
GDI_CUSTOM_TYPE_ID, i,
GDI_INFO_TEXT, "enter counter value",
- GDI_X, xpos,
+ GDI_X, xpos + xoffset,
GDI_Y, ypos,
GDI_TYPE, GD_TYPE_TEXTINPUT_NUMERIC,
GDI_NUMBER_VALUE, 0,
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 = new_graphic_info[IMG_MENU_DOOR].bitmap;
+ 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 == -1) /* dynamically determine size */
+ {
+ /* (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!) */
+ selectbox_info[i].size = 0;
+
+ 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_left != NULL)
+ xoffset = (getFontWidth(FONT_TEXT_1) *
+ strlen(selectbox_info[i].text_left) +
+ 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;
+
+ if (textbutton_info[i].size == -1) /* dynamically determine size */
+ textbutton_info[i].size = strlen(textbutton_info[i].text);
+
+ event_mask = GD_EVENT_RELEASED;
+
+ if (id >= GADGET_ID_PROPERTIES_INFO && id <= GADGET_ID_PROPERTIES_ADVANCED)
+ {
+ gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_TAB_XPOS;
+ gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_TAB_XPOS;
+ gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_YPOS;
+ gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_TAB_INACTIVE_YPOS;
+ }
+ else
+ {
+ 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].text,
+ 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 = new_graphic_info[IMG_MENU_DOOR].bitmap;
+ 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;
}
event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
- gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].xpos;
+ gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].gd_x;
gd_x2 = (gd_x1 - (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL ?
scrollbar_info[i].height : scrollbar_info[i].width));
- gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos;
- gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos;
+ gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
+ gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].gd_y;
gi = CreateGadget(GDI_CUSTOM_ID, id,
GDI_CUSTOM_TYPE_ID, i,
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 = new_graphic_info[IMG_MENU_DOOR].bitmap;
+ 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)
{
+ 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_left = 0;
+ int yoffset_left = ED_BORDER_SIZE;
+ int xoffset_right = getCounterGadgetWidth();
+ int yoffset_right = ED_BORDER_SIZE;
+ int x, y;
+
+ if (counterbutton_info[id].text_above)
+ {
+ x = SX + counterbutton_info[id].x + xoffset_above;
+ y = SY + counterbutton_info[id].y + yoffset_above;
+
+ sprintf(infotext, "%s:", counterbutton_info[id].text_above);
+ infotext[max_infotext_len] = '\0';
+ DrawText(x, y, infotext, FONT_TEXT_1);
+ }
+
+ if (counterbutton_info[id].text_left)
+ {
+ x = SX + counterbutton_info[id].x + xoffset_left;
+ y = SY + counterbutton_info[id].y + yoffset_left;
+
+ sprintf(infotext, "%s", counterbutton_info[id].text_left);
+ infotext[max_infotext_len] = '\0';
+ DrawText(x, y, infotext, FONT_TEXT_1);
+ }
+
+ if (counterbutton_info[id].text_right)
+ {
+ int gadget_id = counterbutton_info[id].gadget_id_down;
+
+ x = level_editor_gadget[gadget_id]->x + xoffset_right;
+ y = SY + counterbutton_info[id].y + yoffset_right;
+
+ sprintf(infotext, "%s", counterbutton_info[id].text_right);
+ infotext[max_infotext_len] = '\0';
+ DrawText(x, y, infotext, FONT_TEXT_1);
+ }
+
+ ModifyEditorCounter(id, *counterbutton_info[id].value);
+
MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_down]);
MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_text]);
MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_up]);
ModifyEditorCounterLimits(counter_id,
leveldir_current->first_level,
leveldir_current->last_level);
- ModifyEditorCounter(counter_id, *counterbutton_info[counter_id].value);
MapCounterButtons(counter_id);
}
static void MapTextInputGadget(int id)
{
+ char infotext[MAX_OUTPUT_LINESIZE + 1];
+ int max_infotext_len = getMaxInfoTextLength();
+ int xoffset_above = 0;
+ int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
+ int x = textinput_info[id].x + xoffset_above;
+ int y = textinput_info[id].y + yoffset_above;
+
+ sprintf(infotext, "%s:", textinput_info[id].infotext);
+ infotext[max_infotext_len] = '\0';
+ DrawTextF(x, y, FONT_TEXT_1, infotext);
+
+ ModifyGadget(level_editor_gadget[textinput_info[id].gadget_id],
+ GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
+
MapGadget(level_editor_gadget[textinput_info[id].gadget_id]);
}
+static void MapSelectboxGadget(int id)
+{
+ int xoffset_left = 0;
+ int yoffset_left = ED_BORDER_SIZE;
+ int xoffset_right = ED_BORDER_SIZE;
+ int yoffset_right = ED_BORDER_SIZE;
+ int x = selectbox_info[id].x + xoffset_left;
+ int y = selectbox_info[id].y + yoffset_left;
+
+ DrawTextF(x, y, FONT_TEXT_1, selectbox_info[id].text_left);
+
+ if (selectbox_info[id].text_right)
+ {
+ struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
+
+ x = gi->x + gi->width + xoffset_right;
+ y = SY + selectbox_info[id].y + yoffset_right;
+
+ DrawText(x, y, selectbox_info[id].text_right, FONT_TEXT_1);
+ }
+
+ ModifyEditorSelectbox(id, *selectbox_info[id].value);
+
+ 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)
{
+ int xoffset_right = ED_XOFFSET_CHECKBOX;
+ int yoffset_right = ED_BORDER_SIZE;
+ int x = radiobutton_info[id].x + xoffset_right;
+ int y = radiobutton_info[id].y + yoffset_right;
+ boolean checked =
+ (*radiobutton_info[id].value == radiobutton_info[id].checked_value);
+
+ DrawTextF(x, y, FONT_TEXT_1, radiobutton_info[id].text_right);
+ ModifyGadget(level_editor_gadget[radiobutton_info[id].gadget_id],
+ GDI_CHECKED, checked, GDI_END);
+
MapGadget(level_editor_gadget[radiobutton_info[id].gadget_id]);
}
static void MapCheckbuttonGadget(int id)
{
+ int xoffset_right = ED_XOFFSET_CHECKBOX;
+ int yoffset_right = ED_BORDER_SIZE;
+ int x = checkbutton_info[id].x + xoffset_right;
+ int y = checkbutton_info[id].y + yoffset_right;
+
+ DrawTextF(x, y, FONT_TEXT_1, checkbutton_info[id].text_right);
+ ModifyGadget(level_editor_gadget[checkbutton_info[id].gadget_id],
+ GDI_CHECKED, *checkbutton_info[id].value,
+ GDI_Y, SY + checkbutton_info[id].y, GDI_END);
+
MapGadget(level_editor_gadget[checkbutton_info[id].gadget_id]);
}
for(y=0; y<lev_fieldy; y++)
for(x=0; x<lev_fieldx; x++)
- if (Feld[x][y] == EL_PLAYER1 ||
+ 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;
+
+ custom_element = element_info[properties_element];
+
+ 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 :
+ IS_PUSHABLE(element) ? EP_PUSHABLE :
+ EP_DIGGABLE);
+ custom_element_properties[EP_WALK_TO_OBJECT] =
+ (IS_DIGGABLE(element) ||
+ IS_COLLECTIBLE(element) ||
+ IS_PUSHABLE(element));
+
+ /* set consistency selectbox help value */
+ custom_element.consistency =
+ (IS_INDESTRUCTIBLE(element) ? EP_INDESTRUCTIBLE :
+ CAN_EXPLODE_BY_FIRE(element) ? EP_CAN_EXPLODE_BY_FIRE :
+ EP_INDESTRUCTIBLE);
+ custom_element_properties[EP_EXPLODE_RESULT] =
+ (IS_INDESTRUCTIBLE(element) ||
+ CAN_EXPLODE_BY_FIRE(element));
+
+ /* set deadliness selectbox help value */
+ custom_element.deadliness =
+ (DONT_TOUCH(element) ? EP_DONT_TOUCH :
+ DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH :
+ DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO :
+ EP_DONT_RUN_INTO);
+ custom_element_properties[EP_DEADLY] =
+ (DONT_TOUCH(element) ||
+ DONT_COLLIDE_WITH(element) ||
+ DONT_RUN_INTO(element));
+
+ /* set walkable layer selectbox help value */
+ custom_element.walkable_layer =
+ (IS_WALKABLE_OVER(element) ? EP_WALKABLE_OVER :
+ IS_WALKABLE_INSIDE(element) ? EP_WALKABLE_INSIDE :
+ IS_WALKABLE_UNDER(element) ? EP_WALKABLE_UNDER :
+ EP_WALKABLE_OVER);
+ custom_element_properties[EP_WALKABLE] =
+ (IS_WALKABLE_OVER(element) ||
+ IS_WALKABLE_INSIDE(element) ||
+ IS_WALKABLE_UNDER(element));
+
+ /* set change by player selectbox help value */
+ value_change_player_action =
+ (HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
+ HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
+ CE_PRESSED_BY_PLAYER);
+}
+
+static void CopyCustomElementPropertiesToGame(int element)
+{
+ int i;
+
+ element_info[properties_element] = 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 consistency property from checkbox and selectbox */
+ custom_element_properties[EP_INDESTRUCTIBLE] = FALSE;
+ custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] = FALSE;
+ custom_element_properties[custom_element.consistency] =
+ custom_element_properties[EP_EXPLODE_RESULT];
+
+ /* set deadliness property from checkbox and selectbox */
+ custom_element_properties[EP_DONT_RUN_INTO] = FALSE;
+ custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE;
+ custom_element_properties[EP_DONT_TOUCH] = FALSE;
+ custom_element_properties[custom_element.deadliness] =
+ custom_element_properties[EP_DEADLY];
+
+ /* 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];
+
+ /* set player change event from checkbox and selectbox */
+ custom_element.change.events &= ~CE_PRESSED_BY_PLAYER;
+ custom_element.change.events &= ~CE_TOUCHED_BY_PLAYER;
+ custom_element.change.events |= value_change_player_action;
+
+ 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 */
+ custom_element = element_info[properties_element];
+}
+
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(new_graphic_info[IMG_MENU_DOOR].bitmap, 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,
DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
- el2img(new_element1));
+ el2edimg(new_element1));
DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
- el2img(new_element2));
+ el2edimg(new_element2));
DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
- el2img(new_element3));
+ el2edimg(new_element3));
/* draw bigger door */
DrawSpecialEditorDoor();
/* draw new control window */
- BlitBitmap(new_graphic_info[IMG_MENU_DOOR].bitmap, 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() */
DrawEditModeWindow();
- /*
- FadeToFront();
- */
-
-
OpenDoor(DOOR_OPEN_1);
-
- /*
- OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2);
- */
}
static void AdjustDrawingAreaGadgets()
GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
}
-static void ModifyEditorTextInput(int textinput_id, char *new_text)
-{
- int gadget_id = textinput_info[textinput_id].gadget_id;
- struct GadgetInfo *gi = level_editor_gadget[gadget_id];
-
- ModifyGadget(gi, GDI_TEXT_VALUE, new_text, GDI_END);
-}
-
static void ModifyEditorCounter(int counter_id, int new_value)
{
int *counter_value = counterbutton_info[counter_id].value;
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)
new_element1 = element;
DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
- el2img(new_element1));
+ el2edimg(new_element1));
}
else if (button == 2)
{
new_element2 = element;
DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
- el2img(new_element2));
+ el2edimg(new_element2));
}
else
{
new_element3 = element;
DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
- el2img(new_element3));
+ el2edimg(new_element3));
}
redraw_mask |= REDRAW_DOOR_1;
}
+static void RedrawDrawingElements()
+{
+ PickDrawingElement(1, new_element1);
+ PickDrawingElement(2, new_element2);
+ PickDrawingElement(3, new_element3);
+}
+
static void DrawDrawingWindow()
{
+ stick_element_properties_window = FALSE;
+
+ 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_SAND);
+ 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];
- int xoffset_above = 0;
- int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
- 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 font_color = FC_GREEN;
- int i, x, y;
+ int i;
+ stick_element_properties_window = FALSE;
+
+ 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++)
+ MapCounterButtons(i);
+
+ /* draw checkbutton gadgets */
+ for (i=ED_CHECKBUTTON_ID_LEVEL_FIRST; i<=ED_CHECKBUTTON_ID_LEVEL_LAST; i++)
+ MapCheckbuttonGadget(i);
+
+ /* draw radiobutton gadgets */
+ for (i=ED_RADIOBUTTON_ID_LEVEL_FIRST; i<=ED_RADIOBUTTON_ID_LEVEL_LAST; i++)
+ MapRadiobuttonGadget(i);
+
+ /* draw text input gadgets */
+ for (i=ED_TEXTINPUT_ID_LEVEL_FIRST; i<=ED_TEXTINPUT_ID_LEVEL_LAST; i++)
+ MapTextInputGadget(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];
+ int xpos = ED_AREA_ELEM_CONTENT3_XPOS;
+ int ypos = ED_AREA_ELEM_CONTENT3_YPOS;
+ int area_sx = SX + xpos;
+ int area_sy = SY + ypos;
+
+ if (!IS_CUSTOM_ELEMENT(properties_element))
{
- if (counterbutton_info[i].infotext_above)
- {
- x = counterbutton_info[i].x + xoffset_above;
- y = counterbutton_info[i].y + yoffset_above;
+ /* this should never happen */
+ Error(ERR_WARN, "element %d is no custom element", properties_element);
- sprintf(infotext, "%s:", counterbutton_info[i].infotext_above);
- infotext[MAX_INFOTEXT_LEN] = '\0';
- DrawTextF(x, y, font_color, infotext);
- }
+ return;
+ }
- if (counterbutton_info[i].infotext_right)
- {
- x = counterbutton_info[i].x + xoffset_right;
- y = counterbutton_info[i].y + yoffset_right;
+ DrawElementBorder(area_sx, area_sy, MINI_TILEX, MINI_TILEY, TRUE);
+ DrawMiniGraphicExt(drawto, gi->x, gi->y,
+ el2edimg(custom_element.gfx_element));
- sprintf(infotext, "%s", counterbutton_info[i].infotext_right);
- infotext[MAX_INFOTEXT_LEN] = '\0';
- DrawTextF(x, y, font_color, infotext);
- }
+ MapDrawingArea(GADGET_ID_CUSTOM_GRAPHIC);
+}
- ModifyEditorCounter(i, *counterbutton_info[i].value);
- MapCounterButtons(i);
+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;
}
- /* draw text input gadgets */
- for (i=ED_TEXTINPUT_ID_LEVEL_FIRST; i<=ED_TEXTINPUT_ID_LEVEL_LAST; i++)
+ 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];
+ int xpos = ED_AREA_ELEM_CONTENT2_XPOS;
+ int ypos = ED_AREA_ELEM_CONTENT2_YPOS;
+ 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 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 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 */
+ MapCounterButtons(ED_COUNTER_ID_ELEMENT_CONTENT);
+
+ /* 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) + ED_BORDER_SIZE;
+ 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))
{
- x = textinput_info[i].x + xoffset_above;
- y = textinput_info[i].y + yoffset_above;
+ 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;
- sprintf(infotext, "%s:", textinput_info[i].infotext);
- infotext[MAX_INFOTEXT_LEN] = '\0';
+ /* 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 */
- DrawTextF(x, y, font_color, infotext);
- ModifyEditorTextInput(i, textinput_info[i].value);
- MapTextInputGadget(i);
- }
+ strncpy(buffer, word_ptr, max_chars_per_line);
+ buffer[max_chars_per_line] = '\0';
+ word_ptr += max_chars_per_line;
+ print_buffer = TRUE;
+ }
- /* 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);
+ if (print_buffer)
+ {
+ if (!PrintInfoText(buffer, font_nr, screen_line + lines_printed))
+ return lines_printed;
- x = radiobutton_info[i].x + xoffset_right2;
- y = radiobutton_info[i].y + yoffset_right2;
+ last_line_was_empty = (buffer_len == 0);
+ lines_printed++;
- 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);
+ buffer[0] = '\0';
+ buffer_len = 0;
+ print_buffer = FALSE;
+ }
+ }
}
- /* 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;
+ fclose(file);
- 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);
- }
+ if (buffer_len > 0)
+ if (PrintInfoText(buffer, font_nr, screen_line + lines_printed))
+ lines_printed++;
- /* draw drawing area */
- DrawRandomPlacementBackgroundArea();
+ return lines_printed;
}
-static void DrawAmoebaContentArea()
+static void DrawPropertiesTabulatorGadgets()
{
- 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;
+ 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;
+#if 1
+ int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
+#else
+ int id_last = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
+#endif
+ int i;
- ElementContent[0][0][0] = level.amoeba_content;
+#if 0
+ /* draw additional "configure" tabulator for configurable elements */
+ if (checkPropertiesConfig())
+ id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
+#endif
- /* 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_SAND);
+ /* draw additional "advanced" tabulator for custom elements */
+ if (IS_CUSTOM_ELEMENT(properties_element))
+ id_last = ED_TEXTBUTTON_ID_PROPERTIES_ADVANCED;
- ClearRectangle(drawto,
- area_sx + MINI_TILEX/2 - 1, area_sy + MINI_TILEY/2 - 1,
- MINI_TILEX + 2, MINI_TILEY + 2);
+ 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);
- /* 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);
+ /* draw background line below tabulator button */
+ ClearRectangleOnBackground(drawto, gi->x, gi->y + gi->height, gi->width,1);
- DrawText(area_sx + TILEX, area_sy + 1, "Content of amoeba",
- FS_SMALL, font_color);
+ /* 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);
- DrawMiniElement(area_x, area_y, ElementContent[0][0][0]);
+ ModifyGadget(gi, GDI_ACTIVE, active, GDI_END);
+ MapTextbuttonGadget(i);
+ }
- MapDrawingArea(GADGET_ID_AMOEBA_CONTENT);
+ /* 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 DrawElementContentAreas()
+static void DrawPropertiesInfo()
{
- 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;
- int yoffset_right = ED_BORDER_SIZE;
- int font_color = FC_GREEN;
+ static struct
+ {
+ int value;
+ char *text;
+ }
+ properties[] =
+ {
+ /* configurable properties */
+ { EP_INDESTRUCTIBLE, "- undestructible" },
+ { EP_SLIPPERY, "- slippery for falling objects" },
+ { EP_EM_SLIPPERY_WALL, "- slippery for some gems (EM style)" },
+
+ { EP_DIGGABLE, "- diggable" },
+ { EP_COLLECTIBLE, "- collectible" },
+ { EP_PUSHABLE, "- pushable" },
+
+ { EP_CAN_MOVE, "- can move" },
+ { EP_CAN_FALL, "- can fall" },
+ { EP_CAN_SMASH, "- can smash other objects" },
+ { EP_CAN_EXPLODE_BY_FIRE, "- can explode (by fire/explosion)" },
+
+ { EP_DONT_RUN_INTO, "- deadly when running into" },
+ { EP_DONT_COLLIDE_WITH, "- deadly when colliding with" },
+ { EP_DONT_TOUCH, "- deadly when touching" },
+
+ { 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_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) + ED_BORDER_SIZE;
+ int screen_line = 0;
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];
+ /* ----- print number of elements / percentage of this element in level */
- for (i=0; i<MAX_ELEMENT_CONTENTS; i++)
- UnmapDrawingArea(GADGET_ID_ELEM_CONTENT_0 + i);
+ 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);
- /* 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");
+ 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);
- ModifyEditorCounter(counter_id, *counterbutton_info[counter_id].value);
- MapCounterButtons(counter_id);
+ screen_line++;
- /* delete content areas in case of reducing number of them */
- ClearRectangle(backbuffer,
- SX, area_sy - MINI_TILEX,
- SXSIZE, 12 * MINI_TILEY);
+ /* ----- print standard properties of this element */
- /* draw some decorative border for the objects */
- for (i=0; i<level.num_yam_contents; i++)
+ DrawTextF(pad_x, pad_y + screen_line++ * font2_height, font1_nr,
+ properties_text);
+
+ for (i=0; properties[i].value != -1; 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_SAND);
+ if (!HAS_PROPERTY(properties_element, properties[i].value))
+ continue;
- 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(pad_x, pad_y + screen_line++ * font2_height, font2_nr,
+ properties[i].text);
+ num_standard_properties++;
}
- /* 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);
+ if (num_standard_properties == 0)
+ DrawTextF(pad_x + strlen(properties_text) * font1_width,
+ pad_y + (screen_line - 1) * font2_height, font2_nr, "none");
- for (i=0; i<level.num_yam_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,
- ElementContent[i][x][y]);
+ screen_line++;
- 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);
- }
+ /* ----- print special description of this element */
- for (i=0; i<level.num_yam_contents; i++)
- MapDrawingArea(GADGET_ID_ELEM_CONTENT_0 + i);
+ 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_SPEED "Speed of amoeba growth"
#define TEXT_DURATION "Duration when activated"
-static void DrawPropertiesWindow()
+static struct
{
- 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_EMERALD, &level.score[SC_EDELSTEIN], TEXT_COLLECTING },
- { EL_BD_DIAMOND, &level.score[SC_EDELSTEIN], TEXT_COLLECTING },
- { EL_EMERALD_YELLOW,&level.score[SC_EDELSTEIN], TEXT_COLLECTING },
- { EL_EMERALD_RED, &level.score[SC_EDELSTEIN], TEXT_COLLECTING },
- { EL_EMERALD_PURPLE,&level.score[SC_EDELSTEIN], TEXT_COLLECTING },
- { EL_DIAMOND, &level.score[SC_DIAMANT], TEXT_COLLECTING },
- { EL_BUG_RIGHT, &level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_BUG_UP, &level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_BUG_LEFT, &level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_BUG_DOWN, &level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_BD_BUTTERFLY_RIGHT,&level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_BD_BUTTERFLY_UP, &level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_BD_BUTTERFLY_LEFT, &level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_BD_BUTTERFLY_DOWN, &level.score[SC_KAEFER], TEXT_SMASHING },
- { EL_SPACESHIP_RIGHT,&level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_SPACESHIP_UP, &level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_SPACESHIP_LEFT, &level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_SPACESHIP_DOWN, &level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_BD_FIREFLY_RIGHT,&level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_BD_FIREFLY_UP, &level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_BD_FIREFLY_LEFT, &level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_BD_FIREFLY_DOWN, &level.score[SC_FLIEGER], TEXT_SMASHING },
- { EL_YAMYAM, &level.score[SC_MAMPFER], TEXT_SMASHING },
- { EL_DARK_YAMYAM, &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_NUT, &level.score[SC_KOKOSNUSS], TEXT_CRACKING },
- { EL_DYNAMITE ,&level.score[SC_DYNAMIT], TEXT_COLLECTING },
- { EL_KEY1, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_KEY2, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_KEY3, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_KEY4, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_EM_KEY1_FILE, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_EM_KEY2_FILE, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_EM_KEY3_FILE, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_EM_KEY4_FILE, &level.score[SC_SCHLUESSEL], 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 }
- };
-
- ClearWindow();
- UnmapLevelEditorWindowGadgets();
-
- DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS_YPOS,
- "Element Settings", FS_BIG, FC_YELLOW);
-
- /* 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_SAND);
-
- ClearRectangle(drawto,
- SX + xstart * MINI_TILEX + MINI_TILEX/2 - 1,
- SY + ystart * MINI_TILEY + MINI_TILEY/2 - 1,
- TILEX + 2, TILEY + 2);
+ 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_SP_INFOTRON, &level.score[SC_EMERALD], TEXT_COLLECTING },
+ { EL_DIAMOND, &level.score[SC_DIAMOND], TEXT_COLLECTING },
+ { EL_CRYSTAL, &level.score[SC_CRYSTAL], TEXT_COLLECTING },
+ { EL_PEARL, &level.score[SC_PEARL], 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_SP_ELECTRON, &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_SP_SNIKSNAK, &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_DYNABOMB_INCREASE_NUMBER,&level.score[SC_DYNAMITE],TEXT_COLLECTING },
+ { EL_DYNABOMB_INCREASE_SIZE, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
+ { EL_DYNABOMB_INCREASE_POWER, &level.score[SC_DYNAMITE],TEXT_COLLECTING },
+ { EL_SHIELD_NORMAL, &level.score[SC_SHIELD], TEXT_COLLECTING },
+ { EL_SHIELD_DEADLY, &level.score[SC_SHIELD], TEXT_COLLECTING },
+ { EL_EXTRA_TIME, &level.score[SC_TIME_BONUS], 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 }
+};
- /* 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);
+static boolean checkPropertiesConfig()
+{
+ int i;
- DrawGraphic(xstart / 2, ystart / 2, el2img(properties_element), 0);
+ 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;
- /* 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);
+ return FALSE;
+}
- DrawTextF((xstart + 3) * MINI_TILEX, (ystart + 1) * MINI_TILEY,
- font_color, getElementInfoText(properties_element));
+static void DrawPropertiesConfig()
+{
+ int i;
- 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);
+ if (!checkPropertiesConfig())
+ {
+ PrintInfoText("No configuration options available.", FONT_TEXT_1, 0);
- 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);
+ return;
+ }
/* 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;
+ int counter_id = ED_COUNTER_ID_ELEMENT_SCORE;
counterbutton_info[counter_id].value = elements_with_counter[i].value;
- DrawTextF(x, y, font_color, elements_with_counter[i].text);
-
- ModifyEditorCounter(counter_id, *counterbutton_info[counter_id].value);
+ counterbutton_info[counter_id].text_right= elements_with_counter[i].text;
MapCounterButtons(counter_id);
+
break;
}
}
{
/* draw stickybutton gadget */
i = ED_CHECKBUTTON_ID_STICK_ELEMENT;
- x = checkbutton_info[i].x + xoffset_right2;
- y = checkbutton_info[i].y + yoffset_right2;
-
- 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);
+ checkbutton_info[i].y = ED_COUNTER_YPOS(4);
MapCheckbuttonGadget(i);
if (IS_AMOEBOID(properties_element))
}
if (IS_GEM(properties_element))
+ MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
+
+ if (IS_CUSTOM_ELEMENT(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;
+ /* draw stickybutton gadget */
+ i = ED_CHECKBUTTON_ID_STICK_ELEMENT;
+ checkbutton_info[i].y = ED_SETTINGS_YPOS(0);
+ MapCheckbuttonGadget(i);
+
+ /* draw checkbutton gadgets */
+ for (i = ED_CHECKBUTTON_ID_CUSTOM_FIRST;
+ i <= ED_CHECKBUTTON_ID_CUSTOM_LAST; i++)
+ MapCheckbuttonGadget(i);
+
+ /* draw counter gadgets */
+ for (i=ED_COUNTER_ID_CUSTOM_FIRST; i<=ED_COUNTER_ID_CUSTOM_LAST; i++)
+ MapCounterButtons(i);
- 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);
+ /* draw selectbox gadgets */
+ for (i=ED_SELECTBOX_ID_CUSTOM_FIRST; i <= ED_SELECTBOX_ID_CUSTOM_LAST; i++)
+ MapSelectboxGadget(i);
+
+ /* draw drawing area gadgets */
+ DrawCustomContentArea();
+ }
+}
+
+static void DrawPropertiesAdvanced()
+{
+ int i;
+
+ /* draw stickybutton gadget */
+ i = ED_CHECKBUTTON_ID_STICK_ELEMENT;
+ checkbutton_info[i].y = ED_SETTINGS_YPOS(0);
+ MapCheckbuttonGadget(i);
+
+ /* draw checkbutton gadgets */
+ for (i = ED_CHECKBUTTON_ID_CHANGE_FIRST;
+ i <= ED_CHECKBUTTON_ID_CHANGE_LAST; i++)
MapCheckbuttonGadget(i);
+
+ /* draw counter gadgets */
+ for (i=ED_COUNTER_ID_CHANGE_FIRST; i<=ED_COUNTER_ID_CHANGE_LAST; i++)
+ MapCounterButtons(i);
+
+ /* draw selectbox gadgets */
+ for (i=ED_SELECTBOX_ID_CHANGE_FIRST; i<=ED_SELECTBOX_ID_CHANGE_LAST; i++)
+ MapSelectboxGadget(i);
+
+ /* draw textbutton gadgets */
+ MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
+
+ /* draw drawing area gadgets */
+ DrawCustomGraphicElementArea();
+ DrawCustomChangedArea();
+}
+
+static void DrawElementName(int x, int y, int element)
+{
+ char *element_name = getElementInfoText(element);
+ int font_nr = FONT_TEXT_1;
+ int font_width = getFontWidth(font_nr);
+ int font_height = getFontHeight(font_nr);
+ int max_text_width = SXSIZE - x - ED_SETTINGS_XPOS(0);
+ int max_chars_per_line = max_text_width / font_width;
+ char buffer[max_chars_per_line + 1];
+
+ if (strlen(element_name) <= max_chars_per_line)
+ DrawTextF(x, y, font_nr, element_name);
+ else
+ {
+ int next_pos = max_chars_per_line;
+
+ strncpy(buffer, element_name, max_chars_per_line);
+ buffer[max_chars_per_line] = '\0';
+
+ if (element_name[max_chars_per_line] == ' ')
+ next_pos++;
+ else
+ {
+ int i;
+
+ for (i = max_chars_per_line - 1; i >= 0; i--)
+ if (buffer[i] == ' ')
+ break;
+
+ if (strlen(&element_name[i + 1]) <= max_chars_per_line)
+ {
+ buffer[i] = '\0';
+ next_pos = i + 1;
+ }
+ }
+
+ DrawTextF(x, y - font_height / 2, font_nr, buffer);
+
+ strncpy(buffer, &element_name[next_pos], max_chars_per_line);
+ buffer[max_chars_per_line] = '\0';
+
+ DrawTextF(x, y + font_height / 2, font_nr, buffer);
}
}
+static void DrawPropertiesWindow()
+{
+ int xstart = 2;
+ int ystart = 4;
+
+ stick_element_properties_window = FALSE;
+
+ /* 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;
+
+#if 0
+ if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
+ !checkPropertiesConfig())
+ edit_mode_properties = ED_MODE_PROPERTIES_INFO;
+#endif
+
+ if (IS_CUSTOM_ELEMENT(properties_element))
+ CopyCustomElementPropertiesToEditor(properties_element);
+
+ UnmapLevelEditorWindowGadgets();
+
+ SetMainBackgroundImage(IMG_BACKGROUND_EDITOR);
+ ClearWindow();
+
+ DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS1_YPOS,
+ "Element Settings", FONT_TITLE_1);
+
+ 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);
+
+ FrameCounter = 0; /* restart animation frame counter */
+
+ DrawElementName((xstart + 3) * MINI_TILEX, (ystart + 1) * MINI_TILEY,
+ properties_element);
+
+ DrawPropertiesTabulatorGadgets();
+
+ 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)
{
int lx = sx + level_xpos;
}
}
-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_COPYRIGHT;
else
SetBorderElement();
if (BorderElement != last_border_element)
DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
-
-#if 0
-#ifdef DEBUG
- printf("level saved to undo buffer\n");
-#endif
-#endif
}
static void RandomPlacement(int new_element)
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;
/* automatically switch to 'single item' drawing mode, if needed */
actual_drawing_function =
- (draw_level ? drawing_function : GADGET_ID_SINGLE_ITEMS);
+ (draw_level || drawing_function == GADGET_ID_PICK_ELEMENT ?
+ drawing_function : GADGET_ID_SINGLE_ITEMS);
switch (actual_drawing_function)
{
}
else if (new_element != Feld[lx][ly])
{
- if (new_element == EL_PLAYER1)
+ 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_PLAYER1)
+ if (Feld[x][y] == EL_PLAYER_1)
{
Feld[x][y] = EL_EMPTY;
if (x - level_xpos >= 0 && x - level_xpos < ed_fieldx &&
}
else
{
- DrawMiniGraphicExt(drawto,
- gi->x + sx * MINI_TILEX,
- gi->y + sy * MINI_TILEY,
- el2img(new_element));
- DrawMiniGraphicExt(window,
- gi->x + sx * MINI_TILEX,
- gi->y + sy * MINI_TILEY,
- el2img(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)
+ {
+ new_element = GFX_ELEMENT(new_element);
+ custom_element.gfx_element = new_element;
+ element_info[properties_element] = custom_element;
+
+ ModifyEditorElementList();
+ RedrawDrawingElements();
+
+ FrameCounter = 0; /* restart animation frame counter */
+ }
+ else if (id == GADGET_ID_CUSTOM_CONTENT)
+ {
+ custom_element.content[sx][sy] = new_element;
+ element_info[properties_element] = custom_element;
+ }
+ else if (id == GADGET_ID_CUSTOM_CHANGED)
+ {
+ custom_element.change.successor = new_element;
+ element_info[properties_element] = 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)
if (button_release_event)
ClickOnGadget(level_editor_gadget[last_drawing_function],
MB_LEFTBUTTON);
- else
+ else if (draw_level)
PickDrawingElement(button, Feld[lx][ly]);
+ else if (id == GADGET_ID_AMOEBA_CONTENT)
+ PickDrawingElement(button, level.amoeba_content);
+ else if (id == GADGET_ID_CUSTOM_GRAPHIC)
+ PickDrawingElement(button, custom_element.gfx_element);
+ else if (id == GADGET_ID_CUSTOM_CONTENT)
+ PickDrawingElement(button, custom_element.content[sx][sy]);
+ else if (id == GADGET_ID_CUSTOM_CHANGED)
+ PickDrawingElement(button, custom_element.change.successor);
+ else if (id == GADGET_ID_RANDOM_BACKGROUND)
+ PickDrawingElement(button, random_placement_background_element);
+ else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
+ id <= GADGET_ID_ELEMENT_CONTENT_7)
+ {
+ int i = id - GADGET_ID_ELEMENT_CONTENT_0;
+
+ PickDrawingElement(button, level.yamyam_content[i][sx][sy]);
+ }
break;
switch (counter_id)
{
- case ED_COUNTER_ID_ELEM_CONTENT:
+ case ED_COUNTER_ID_ELEMENT_CONTENT:
DrawElementContentAreas();
break;
default:
break;
}
+
+ if ((counter_id >= ED_COUNTER_ID_CUSTOM_FIRST &&
+ counter_id <= ED_COUNTER_ID_CUSTOM_LAST) ||
+ (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);
+}
+
+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();
+ RedrawDrawingElements();
+ }
}
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 (id < ED_NUM_CTRL1_BUTTONS && id != GADGET_ID_PROPERTIES &&
- edit_mode != ED_MODE_DRAWING)
+ id != GADGET_ID_PICK_ELEMENT && edit_mode != ED_MODE_DRAWING &&
+ drawing_function != GADGET_ID_PICK_ELEMENT)
{
DrawDrawingWindow();
edit_mode = ED_MODE_DRAWING;
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(el2img(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;
break;
}
+ if (edit_mode != ED_MODE_DRAWING)
+ {
+ DrawDrawingWindow();
+ edit_mode = ED_MODE_DRAWING;
+ }
+
undo_buffer_position =
(undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
undo_buffer_steps--;
break;
case GADGET_ID_CLEAR:
+ if (edit_mode != ED_MODE_DRAWING)
+ {
+ DrawDrawingWindow();
+ edit_mode = ED_MODE_DRAWING;
+ }
+
for(x=0; x<MAX_LEV_FIELDX; x++)
for(y=0; y<MAX_LEV_FIELDY; y++)
Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
{
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);
}
}
if (LevelChanged())
level.game_version = GAME_VERSION_ACTUAL;
- for(x=0; x<lev_fieldx; x++)
- for(y=0; y<lev_fieldy; y++)
- FieldBackup[x][y] = Ur[x][y];
-
- 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();
}
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 (!HAS_CONTENT(properties_element) ||
- !stick_element_properties_window)
+ if (!stick_element_properties_window &&
+ drawing_function != GADGET_ID_PICK_ELEMENT)
{
properties_element = new_element;
if (edit_mode == ED_MODE_PROPERTIES)
}
}
+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 == 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)
}
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);
}
DeleteBrushFromCursor();
}
}
- else if (id == GADGET_ID_AMOEBA_CONTENT)
- DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
- "Amoeba content");
- else if (id == GADGET_ID_RANDOM_BACKGROUND)
- DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
- "Random placement background");
+ else if (drawing_function == GADGET_ID_PICK_ELEMENT)
+ {
+ if (id == GADGET_ID_AMOEBA_CONTENT)
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
+ "%s", getElementInfoText(level.amoeba_content));
+ else if (id == GADGET_ID_CUSTOM_GRAPHIC)
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
+ "%s", getElementInfoText(custom_element.use_gfx_element));
+ else if (id == GADGET_ID_CUSTOM_CONTENT)
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
+ "%s", getElementInfoText(custom_element.content[sx][sy]));
+ else if (id == GADGET_ID_CUSTOM_CHANGED)
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
+ "%s", getElementInfoText(custom_element.change.successor));
+ else if (id == GADGET_ID_RANDOM_BACKGROUND)
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
+ "%s", getElementInfoText(random_placement_background_element));
+ else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
+ id <= GADGET_ID_ELEMENT_CONTENT_7)
+ {
+ int i = id - GADGET_ID_ELEMENT_CONTENT_0;
+
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
+ "%s", getElementInfoText(level.yamyam_content[i][sx][sy]));
+ }
+ }
else
- DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
- "Content area %d position: %d, %d",
- id - GADGET_ID_ELEM_CONTENT_0 + 1, sx, sy);
+ {
+ if (id == GADGET_ID_AMOEBA_CONTENT)
+ 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, FONT_TEXT_2,
+ "Random placement background");
+ else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
+ id <= GADGET_ID_ELEMENT_CONTENT_7)
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2,
+ "Content area %d position: %d, %d",
+ id - GADGET_ID_ELEMENT_CONTENT_0 + 1, sx, sy);
+ }
}
void RequestExitLevelEditor(boolean ask_if_level_has_changed)
/*
CloseDoor(DOOR_CLOSE_ALL);
*/
- game_status = MAINMENU;
+ game_status = GAME_MODE_MAIN;
DrawMainMenu();
}
else