added basic support for MM style wall elements in level editor
[rocksndiamonds.git] / src / editor.c
index 29bf2c7bff7b785a3927e7193adb4cf5808d1ce2..d73b60c935a3d4a3a711ffb5fe86736d6133033e 100644 (file)
 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_1   4
 #define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG_2   5
 #define ED_TEXTBUTTON_ID_PROPERTIES_CHANGE     6
-#define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1    7
-#define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2    8
+#define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_2    7
+#define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE_1    8
 #define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE       9
 #define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE       10
 
 #define ED_NUM_TEXTBUTTONS                     11
 
-#define ED_TEXTBUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
-#define ED_TEXTBUTTON_ID_LEVELINFO_LAST  ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
+#define ED_TAB_BUTTON_ID_LEVELINFO_FIRST ED_TEXTBUTTON_ID_LEVELINFO_LEVEL
+#define ED_TAB_BUTTON_ID_LEVELINFO_LAST  ED_TEXTBUTTON_ID_LEVELINFO_EDITOR
 
-#define ED_TEXTBUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
-#define ED_TEXTBUTTON_ID_PROPERTIES_LAST  ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
+#define ED_TAB_BUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
+#define ED_TAB_BUTTON_ID_PROPERTIES_LAST  ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
 
 #define ED_TEXTBUTTON_ID_CHANGE_FIRST  ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE
 #define ED_TEXTBUTTON_ID_CHANGE_LAST   ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
@@ -1618,6 +1618,7 @@ static struct ValueTextInfo options_game_engine_type[] =
   { GAME_ENGINE_TYPE_RND,      "Rocks'n'Diamonds"              },
   { GAME_ENGINE_TYPE_EM,       "Emerald Mine"                  },
   { GAME_ENGINE_TYPE_SP,       "Supaplex"                      },
+  { GAME_ENGINE_TYPE_MM,       "Mirror Magic"                  },
 
   { -1,                                NULL                            }
 };
@@ -2630,20 +2631,23 @@ static struct
     NULL, NULL, NULL,                  "Configure custom element change pages"
   },
 
-  /* ---------- element settings (buttons) --------------------------------- */
+  /* ---------- level and editor settings (buttons) ------------------------ */
 
   {
-    -1,                                        -1,
-    GADGET_ID_SAVE_AS_TEMPLATE_1,      GADGET_ID_CUSTOM_USE_TEMPLATE_1,
+    ED_LEVEL_SETTINGS_XPOS(0),         ED_LEVEL_SETTINGS_YPOS(6),
+    GADGET_ID_SAVE_AS_TEMPLATE_2,      GADGET_ID_NONE,
     -1,                                        "Save",
-    NULL, " ",                         "As Template",
+    NULL, NULL,                                "this level as level template",
     "Save current settings as new template"
   },
+
+  /* ---------- element settings (buttons) --------------------------------- */
+
   {
-    ED_LEVEL_SETTINGS_XPOS(0),         ED_LEVEL_SETTINGS_YPOS(6),
-    GADGET_ID_SAVE_AS_TEMPLATE_2,      GADGET_ID_NONE,
+    -1,                                        -1,
+    GADGET_ID_SAVE_AS_TEMPLATE_1,      GADGET_ID_CUSTOM_USE_TEMPLATE_1,
     -1,                                        "Save",
-    NULL, NULL,                                "this level as level template",
+    NULL, " ",                         "As Template",
     "Save current settings as new template"
   },
   {
@@ -4212,6 +4216,116 @@ static int *editor_el_dx_boulderdash_ptr = editor_el_dx_boulderdash;
 static int num_editor_hl_dx_boulderdash = SIZEOF_ARRAY_INT(editor_hl_dx_boulderdash);
 static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
 
+static int editor_hl_mirror_magic[] =
+{
+  EL_INTERNAL_CASCADE_MM_ACTIVE,
+  EL_CHAR('M'),
+  EL_CHAR('M'),
+  EL_EMPTY,
+};
+
+static int editor_el_mirror_magic[] =
+{
+  EL_MM_MCDUFFIN_RIGHT,
+  EL_MM_MCDUFFIN_UP,
+  EL_MM_MCDUFFIN_LEFT,
+  EL_MM_MCDUFFIN_DOWN,
+
+  EL_MM_MIRROR_START,
+  EL_MM_MIRROR_FIXED_START,
+  EL_MM_POLARISATOR_START,
+  EL_MM_POLARISATOR_CROSS_START,
+
+  EL_MM_BEAMER_RED_START,
+  EL_MM_BEAMER_YELLOW_START,
+  EL_MM_BEAMER_GREEN_START,
+  EL_MM_BEAMER_BLUE_START,
+
+  EL_MM_PRISM,
+  EL_MM_FUSE_ACTIVE,
+  EL_MM_PACMAN_RIGHT,
+  EL_MM_EXIT_CLOSED,
+
+  EL_MM_KETTLE,
+  EL_MM_BOMB,
+  EL_MM_KEY,
+  EL_MM_FUEL_FULL,
+
+  EL_MM_LIGHTBULB,
+  EL_MM_LIGHTBULB_ACTIVE,
+  EL_MM_GRAY_BALL,
+  EL_MM_LIGHTBALL,
+
+  EL_MM_STEEL_WALL,
+  EL_MM_WOODEN_WALL,
+  EL_MM_ICE_WALL,
+  EL_MM_AMOEBA_WALL,
+
+  EL_MM_STEEL_LOCK,
+  EL_MM_WOODEN_LOCK,
+  EL_MM_STEEL_BLOCK,
+  EL_MM_WOODEN_BLOCK,
+
+  EL_MM_STEEL_GRID_FIXED_1,
+  EL_MM_STEEL_GRID_FIXED_2,
+  EL_MM_STEEL_GRID_FIXED_3,
+  EL_MM_STEEL_GRID_FIXED_4,
+
+  EL_MM_WOODEN_GRID_FIXED_1,
+  EL_MM_WOODEN_GRID_FIXED_2,
+  EL_MM_WOODEN_GRID_FIXED_3,
+  EL_MM_WOODEN_GRID_FIXED_4
+};
+static int *editor_hl_mirror_magic_ptr = editor_hl_mirror_magic;
+static int *editor_el_mirror_magic_ptr = editor_el_mirror_magic;
+static int num_editor_hl_mirror_magic = SIZEOF_ARRAY_INT(editor_hl_mirror_magic);
+static int num_editor_el_mirror_magic = SIZEOF_ARRAY_INT(editor_el_mirror_magic);
+
+static int editor_hl_deflektor[] =
+{
+  EL_INTERNAL_CASCADE_DF_ACTIVE,
+  EL_CHAR('D'),
+  EL_CHAR('F'),
+  EL_EMPTY,
+};
+
+static int editor_el_deflektor[] =
+{
+  EL_DF_LASER_RIGHT,
+  EL_DF_LASER_UP,
+  EL_DF_LASER_LEFT,
+  EL_DF_LASER_DOWN,
+
+  EL_DF_RECEIVER_RIGHT,
+  EL_DF_RECEIVER_UP,
+  EL_DF_RECEIVER_LEFT,
+  EL_DF_RECEIVER_DOWN,
+
+  EL_DF_MIRROR_START,
+  EL_DF_MIRROR_ROTATING_START,
+  EL_DF_CELL,
+  EL_DF_MINE,
+
+  EL_DF_FIBRE_OPTIC_RED_1,
+  EL_DF_FIBRE_OPTIC_YELLOW_1,
+  EL_DF_FIBRE_OPTIC_GREEN_1,
+  EL_DF_FIBRE_OPTIC_BLUE_1,
+
+  EL_DF_STEEL_GRID_FIXED_START,
+  EL_DF_STEEL_GRID_ROTATING_START,
+  EL_DF_WOODEN_GRID_FIXED_START,
+  EL_DF_WOODEN_GRID_ROTATING_START,
+
+  EL_DF_STEEL_WALL,
+  EL_DF_WOODEN_WALL,
+  EL_DF_REFRACTOR,
+  EL_EMPTY
+};
+static int *editor_hl_deflektor_ptr = editor_hl_deflektor;
+static int *editor_el_deflektor_ptr = editor_el_deflektor;
+static int num_editor_hl_deflektor = SIZEOF_ARRAY_INT(editor_hl_deflektor);
+static int num_editor_el_deflektor = SIZEOF_ARRAY_INT(editor_el_deflektor);
+
 static int editor_hl_chars[] =
 {
   EL_INTERNAL_CASCADE_CHARS_ACTIVE,
@@ -4908,6 +5022,23 @@ static int num_editor_elements = 0;      /* dynamically determined */
 
 static boolean setup_editor_cascade_never = FALSE;
 
+static boolean setup_editor_el_players                 = TRUE;
+static boolean setup_editor_el_boulderdash             = TRUE;
+static boolean setup_editor_el_emerald_mine            = TRUE;
+static boolean setup_editor_el_emerald_mine_club       = TRUE;
+static boolean setup_editor_el_more                    = TRUE;
+static boolean setup_editor_el_sokoban                 = TRUE;
+static boolean setup_editor_el_supaplex                        = TRUE;
+static boolean setup_editor_el_diamond_caves           = TRUE;
+static boolean setup_editor_el_dx_boulderdash          = TRUE;
+static boolean setup_editor_el_mirror_magic            = TRUE;
+static boolean setup_editor_el_deflektor               = TRUE;
+static boolean setup_editor_el_chars                   = TRUE;
+static boolean setup_editor_el_steel_chars             = TRUE;
+static boolean setup_editor_el_custom                  = TRUE;
+static boolean setup_editor_el_user_defined            = TRUE;
+static boolean setup_editor_el_dynamic                 = TRUE;
+
 static int editor_hl_unused[] = { EL_EMPTY };
 static int *editor_hl_unused_ptr = editor_hl_unused;
 static int num_editor_hl_unused = 0;
@@ -4928,97 +5059,109 @@ static struct
 editor_elements_info[] =
 {
   {
-    &setup.editor.el_classic,
+    &setup_editor_el_players,
     &setup_editor_cascade_never,
     &editor_hl_unused_ptr,             &num_editor_hl_unused,
     &editor_el_players_ptr,            &num_editor_el_players
   },
   {
-    &setup.editor.el_classic,
+    &setup_editor_el_boulderdash,
     &setup.editor_cascade.el_bd,
     &editor_hl_boulderdash_ptr,                &num_editor_hl_boulderdash,
     &editor_el_boulderdash_ptr,                &num_editor_el_boulderdash
   },
   {
-    &setup.editor.el_classic,
+    &setup_editor_el_emerald_mine,
     &setup.editor_cascade.el_em,
     &editor_hl_emerald_mine_ptr,       &num_editor_hl_emerald_mine,
     &editor_el_emerald_mine_ptr,       &num_editor_el_emerald_mine
   },
   {
-    &setup.editor.el_classic,
+    &setup_editor_el_emerald_mine_club,
     &setup.editor_cascade.el_emc,
     &editor_hl_emerald_mine_club_ptr,  &num_editor_hl_emerald_mine_club,
     &editor_el_emerald_mine_club_ptr,  &num_editor_el_emerald_mine_club
   },
   {
-    &setup.editor.el_classic,
+    &setup_editor_el_more,
     &setup.editor_cascade.el_rnd,
     &editor_hl_rnd_ptr,                        &num_editor_hl_rnd,
     &editor_el_rnd_ptr,                        &num_editor_el_rnd
   },
   {
-    &setup.editor.el_classic,
+    &setup_editor_el_sokoban,
     &setup.editor_cascade.el_sb,
     &editor_hl_sokoban_ptr,            &num_editor_hl_sokoban,
     &editor_el_sokoban_ptr,            &num_editor_el_sokoban
   },
   {
-    &setup.editor.el_classic,
+    &setup_editor_el_supaplex,
     &setup.editor_cascade.el_sp,
     &editor_hl_supaplex_ptr,           &num_editor_hl_supaplex,
     &editor_el_supaplex_ptr,           &num_editor_el_supaplex
   },
   {
-    &setup.editor.el_classic,
+    &setup_editor_el_diamond_caves,
     &setup.editor_cascade.el_dc,
     &editor_hl_diamond_caves_ptr,      &num_editor_hl_diamond_caves,
     &editor_el_diamond_caves_ptr,      &num_editor_el_diamond_caves
   },
   {
-    &setup.editor.el_classic,
+    &setup_editor_el_dx_boulderdash,
     &setup.editor_cascade.el_dx,
     &editor_hl_dx_boulderdash_ptr,     &num_editor_hl_dx_boulderdash,
     &editor_el_dx_boulderdash_ptr,     &num_editor_el_dx_boulderdash
   },
   {
-    &setup.editor.el_classic,
+    &setup_editor_el_mirror_magic,
+    &setup.editor_cascade.el_mm,
+    &editor_hl_mirror_magic_ptr,       &num_editor_hl_mirror_magic,
+    &editor_el_mirror_magic_ptr,       &num_editor_el_mirror_magic
+  },
+  {
+    &setup_editor_el_deflektor,
+    &setup.editor_cascade.el_df,
+    &editor_hl_deflektor_ptr,          &num_editor_hl_deflektor,
+    &editor_el_deflektor_ptr,          &num_editor_el_deflektor
+  },
+  {
+    &setup_editor_el_chars,
     &setup.editor_cascade.el_chars,
     &editor_hl_chars_ptr,              &num_editor_hl_chars,
     &editor_el_chars_ptr,              &num_editor_el_chars
   },
   {
-    &setup.editor.el_classic,
+    &setup_editor_el_steel_chars,
     &setup.editor_cascade.el_steel_chars,
     &editor_hl_steel_chars_ptr,                &num_editor_hl_steel_chars,
     &editor_el_steel_chars_ptr,                &num_editor_el_steel_chars
   },
   {
-    &setup.editor.el_custom,
+    &setup_editor_el_custom,
     &setup.editor_cascade.el_ce,
     &editor_hl_custom_ptr,             &num_editor_hl_custom,
     &editor_el_custom_ptr,             &num_editor_el_custom
   },
   {
-    &setup.editor.el_custom,
+    &setup_editor_el_custom,
     &setup.editor_cascade.el_ge,
     &editor_hl_group_ptr,              &num_editor_hl_group,
     &editor_el_group_ptr,              &num_editor_el_group
   },
   {
-    &setup.editor.el_custom,
+    &setup_editor_el_custom,
     &setup.editor_cascade.el_ref,
     &editor_hl_reference_ptr,          &num_editor_hl_reference,
     &editor_el_reference_ptr,          &num_editor_el_reference
   },
   {
-    &setup.editor.el_user_defined,
+    &setup_editor_el_user_defined,
     &setup.editor_cascade.el_user,
     &editor_hl_user_defined_ptr,       &num_editor_hl_user_defined,
     &editor_el_user_defined_ptr,       &num_editor_el_user_defined
   },
   {
-    &setup.editor.el_dynamic,
+    &setup_editor_el_dynamic,
     &setup.editor_cascade.el_dynamic,
     &editor_hl_dynamic_ptr,            &num_editor_hl_dynamic,
     &editor_el_dynamic_ptr,            &num_editor_el_dynamic,
@@ -5183,12 +5326,122 @@ static void InitDynamicEditorElementList(int **elements, int *num_elements)
     (*elements)[(*num_elements)++] = EL_EMPTY;
 }
 
+static void ReinitializeElementList_EnableSections()
+{
+  /* default: enable all element sections */
+
+  setup_editor_el_players              = TRUE;
+  setup_editor_el_boulderdash          = TRUE;
+  setup_editor_el_emerald_mine         = TRUE;
+  setup_editor_el_emerald_mine_club    = TRUE;
+  setup_editor_el_more                 = TRUE;
+  setup_editor_el_sokoban              = TRUE;
+  setup_editor_el_supaplex             = TRUE;
+  setup_editor_el_diamond_caves                = TRUE;
+  setup_editor_el_dx_boulderdash       = TRUE;
+  setup_editor_el_mirror_magic         = TRUE;
+  setup_editor_el_deflektor            = TRUE;
+  setup_editor_el_chars                        = TRUE;
+  setup_editor_el_steel_chars          = TRUE;
+
+  setup_editor_el_custom               = TRUE;
+  setup_editor_el_user_defined         = TRUE;
+  setup_editor_el_dynamic              = TRUE;
+
+  /* now disable all element sections not to be displayed */
+
+  if (!setup.editor.el_classic)
+  {
+    setup_editor_el_players            = FALSE;
+    setup_editor_el_boulderdash                = FALSE;
+    setup_editor_el_emerald_mine       = FALSE;
+    setup_editor_el_emerald_mine_club  = FALSE;
+    setup_editor_el_more               = FALSE;
+    setup_editor_el_sokoban            = FALSE;
+    setup_editor_el_supaplex           = FALSE;
+    setup_editor_el_diamond_caves      = FALSE;
+    setup_editor_el_dx_boulderdash     = FALSE;
+    setup_editor_el_mirror_magic       = FALSE;
+    setup_editor_el_deflektor          = FALSE;
+    setup_editor_el_chars              = FALSE;
+    setup_editor_el_steel_chars                = FALSE;
+  }
+
+  if (!setup.editor.el_custom)
+  {
+    setup_editor_el_custom             = FALSE;
+  }
+
+  if (!setup.editor.el_user_defined)
+  {
+    setup_editor_el_user_defined       = FALSE;
+  }
+
+  if (!setup.editor.el_dynamic)
+  {
+    setup_editor_el_dynamic            = FALSE;
+  }
+
+  if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
+  {
+    setup_editor_el_mirror_magic       = FALSE;
+    setup_editor_el_deflektor          = FALSE;
+  }
+  else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
+  {
+    setup_editor_el_boulderdash                = FALSE;
+    setup_editor_el_more               = FALSE;
+    setup_editor_el_sokoban            = FALSE;
+    setup_editor_el_supaplex           = FALSE;
+    setup_editor_el_dx_boulderdash     = FALSE;
+    setup_editor_el_mirror_magic       = FALSE;
+    setup_editor_el_deflektor          = FALSE;
+    setup_editor_el_steel_chars                = FALSE;
+
+    setup_editor_el_custom             = FALSE;
+  }
+  else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
+  {
+    setup_editor_el_players            = FALSE;
+    setup_editor_el_boulderdash                = FALSE;
+    setup_editor_el_emerald_mine       = FALSE;
+    setup_editor_el_emerald_mine_club  = FALSE;
+    setup_editor_el_more               = FALSE;
+    setup_editor_el_sokoban            = FALSE;
+    setup_editor_el_diamond_caves      = FALSE;
+    setup_editor_el_dx_boulderdash     = FALSE;
+    setup_editor_el_mirror_magic       = FALSE;
+    setup_editor_el_deflektor          = FALSE;
+    setup_editor_el_chars              = FALSE;
+    setup_editor_el_steel_chars                = FALSE;
+
+    setup_editor_el_custom             = FALSE;
+  }
+  else if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
+  {
+    setup_editor_el_players            = FALSE;
+    setup_editor_el_boulderdash                = FALSE;
+    setup_editor_el_emerald_mine       = FALSE;
+    setup_editor_el_emerald_mine_club  = FALSE;
+    setup_editor_el_more               = FALSE;
+    setup_editor_el_sokoban            = FALSE;
+    setup_editor_el_supaplex           = FALSE;
+    setup_editor_el_diamond_caves      = FALSE;
+    setup_editor_el_dx_boulderdash     = FALSE;
+    setup_editor_el_steel_chars                = FALSE;
+
+    setup_editor_el_custom             = FALSE;
+  }
+}
+
 static void ReinitializeElementList()
 {
   static boolean initialization_needed = TRUE;
   int pos = 0;
   int i, j;
 
+  ReinitializeElementList_EnableSections();
+
   if (initialization_needed)
   {
     LoadSetup_EditorCascade();         /* load last editor cascade state */
@@ -5233,7 +5486,7 @@ static void ReinitializeElementList()
        Error(ERR_WARN, "editor element %d is runtime element", element);
 
       if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT))
-       Error(ERR_WARN, "no element description for element %d", element);
+       Error(ERR_WARN, "no element description text for element %d", element);
     }
   }
 
@@ -5954,7 +6207,7 @@ static void CreateDrawingAreas()
 
     event_mask =
       GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING |
-      GD_EVENT_OFF_BORDERS;
+      GD_EVENT_OFF_BORDERS | GD_EVENT_PIXEL_PRECISE;
 
     /* determine horizontal position to the right of specified gadget */
     if (drawingarea_info[i].gadget_id_align != GADGET_ID_NONE)
@@ -7799,7 +8052,8 @@ void CheckElementDescriptions()
 
   for (i = 0; i < NUM_FILE_ELEMENTS; i++)
     if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i))
-      Error(ERR_WARN, "no element description for element '%s'", EL_NAME(i));
+      Error(ERR_WARN, "no element description file for element '%s'",
+           EL_NAME(i));
 }
 
 static int getMaxEdFieldX(boolean has_scrollbar)
@@ -8235,8 +8489,8 @@ static void DrawLevelInfoTabulatorGadgets()
   int gd_x = gd->x + gd_gi1->border.width / 2;
   int gd_y = gd->y + gd_gi1->height - 1;
   Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
-  int id_first = ED_TEXTBUTTON_ID_LEVELINFO_LEVEL;
-  int id_last  = ED_TEXTBUTTON_ID_LEVELINFO_EDITOR;
+  int id_first = ED_TAB_BUTTON_ID_LEVELINFO_FIRST;
+  int id_last  = ED_TAB_BUTTON_ID_LEVELINFO_LAST;
   int i;
 
   for (i = id_first; i <= id_last; i++)
@@ -8595,41 +8849,22 @@ static void DrawEnvelopeTextArea(int envelope_nr)
   MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
 }
 
-static boolean PrintInfoText(char *text, int font_nr, int start_line)
+static void PrintInfoText(char *text, int font_nr, int xpos, int ypos)
 {
-  int font_height = getFontHeight(font_nr);
-  int pad_x = ED_ELEMENT_SETTINGS_X(0);
-  int pad_y = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
-  int sx = SX + pad_x;
-  int sy = SY + pad_y;
-  int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
-
-  if (start_line >= max_lines_per_screen)
-    return FALSE;
-
-  DrawText(sx, sy + start_line * font_height, text, font_nr);
-
-  return TRUE;
+  DrawText(SX + xpos, SY + ypos, text, font_nr);
 }
 
-static int PrintElementDescriptionFromFile(char *filename, int start_line)
+static int PrintElementDescriptionFromFile(char *filename, int font_nr,
+                                          int xpos, int ypos)
 {
-  int font_nr = FONT_TEXT_2;
   int font_width = getFontWidth(font_nr);
   int font_height = getFontHeight(font_nr);
-  int pad_x = ED_ELEMENT_SETTINGS_X(0);
-  int pad_y = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
-  int sx = SX + pad_x;
-  int sy = SY + pad_y + start_line * font_height;
-  int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
-  int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
-  int max_lines_drawable = max_lines_per_screen - start_line;
-
-  if (start_line >= max_lines_per_screen)
-    return FALSE;
+  int max_chars_per_line = (SXSIZE - 2 * xpos) / font_width;
+  int max_lines_drawable = (SYSIZE - ypos) / font_height - 1;
 
-  return DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1,
-                     max_lines_drawable, 0, -1, TRUE, FALSE, FALSE);
+  return DrawTextFile(SX + xpos, SY + ypos, filename, font_nr,
+                     max_chars_per_line, -1, max_lines_drawable, 0, -1,
+                     TRUE, FALSE, FALSE);
 }
 
 static void DrawPropertiesInfo()
@@ -8695,23 +8930,34 @@ static void DrawPropertiesInfo()
   char *filename = getElementDescriptionFilename(properties_element);
   char *percentage_text = "In this level: ";
   char *properties_text = "Standard properties: ";
+  char *description_text = "Description:";
+  char *no_description_text = "No description available.";
+  char *none_text = "None";
   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 font1_height = getFontHeight(font1_nr);
   int font2_height = getFontHeight(font2_nr);
-  int pad_x = ED_ELEMENT_SETTINGS_X(0);
-  int pad_y = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
-  int screen_line = 0;
+  int line1_height = font1_height + ED_GADGET_LINE_DISTANCE;
+  int font2_yoffset = (font1_height - font2_height) / 2;
+  int percentage_text_len = strlen(percentage_text) * font1_width;
+  int properties_text_len = strlen(properties_text) * font1_width;
+  int xpos = ED_ELEMENT_SETTINGS_X(0);
+  int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
   int i, x, y;
 
   if (setup.editor.show_element_token)
   {
-    DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3,
+    int font3_nr = FONT_TEXT_3;
+    int font3_height = getFontHeight(font3_nr);
+
+    DrawTextF(xpos, ypos, font3_nr,
              "[%s]", element_info[properties_element].token_name);
-    screen_line++;
+
+    ypos += 2 * font3_height;
   }
 
   /* ----- print number of elements / percentage of this element in level */
@@ -8723,40 +8969,53 @@ static void DrawPropertiesInfo()
        num_elements_in_level++;
   percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
 
-  DrawTextS(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);
+  DrawTextS(xpos, ypos, font1_nr, percentage_text);
+
+  if (num_elements_in_level > 0)
+    DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
+             "%d (%.2f %%)", num_elements_in_level, percentage);
+  else
+    DrawTextF(xpos + percentage_text_len, ypos + font2_yoffset, font2_nr,
+             none_text);
 
-  screen_line++;
+  ypos += 2 * MAX(font1_height, font2_height);
 
   /* ----- print standard properties of this element */
 
-  DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font1_nr,
-           properties_text);
+  DrawTextS(xpos, ypos, font1_nr, properties_text);
+
+  ypos += line1_height;
 
   for (i = 0; properties[i].value != -1; i++)
   {
     if (!HAS_PROPERTY(properties_element, properties[i].value))
       continue;
 
-    DrawTextS(pad_x, pad_y + screen_line++ * font2_height, font2_nr,
-             properties[i].text);
+    DrawTextS(xpos, ypos, font2_nr, properties[i].text);
+
+    ypos += font2_height;
+
     num_standard_properties++;
   }
 
   if (num_standard_properties == 0)
-    DrawTextS(pad_x + strlen(properties_text) * font1_width,
-             pad_y + (screen_line - 1) * font2_height, font2_nr, "none");
+  {
+    DrawTextS(xpos + properties_text_len, ypos - line1_height + font2_yoffset,
+             font2_nr, none_text);
 
-  screen_line++;
+    ypos -= (line1_height - font1_height);
+  }
+
+  ypos += MAX(font1_height, font2_height);
 
   /* ----- print special description of this element */
 
-  PrintInfoText("Description:", FONT_TEXT_1, screen_line);
-  if (PrintElementDescriptionFromFile(filename, screen_line + 1) == 0)
-    PrintInfoText("No description available.", FONT_TEXT_1, screen_line);
+  PrintInfoText(description_text, font1_nr, xpos, ypos);
+
+  ypos += line1_height;
+
+  if (PrintElementDescriptionFromFile(filename, font2_nr, xpos, ypos) == 0)
+    PrintInfoText(no_description_text, font1_nr, xpos, ypos - line1_height);
 }
 
 #define TEXT_COLLECTING                "Score for collecting"
@@ -8919,7 +9178,11 @@ static void DrawPropertiesConfig()
 
   if (!checkPropertiesConfig(properties_element))
   {
-    PrintInfoText("No configuration options available.", FONT_TEXT_1, 0);
+    int xpos = ED_ELEMENT_SETTINGS_X(0);
+    int ypos = ED_ELEMENT_SETTINGS_Y(0) + ED_GADGET_SMALL_DISTANCE;
+
+    PrintInfoText("No configuration options available.",
+                 FONT_TEXT_1, xpos, ypos);
 
     return;
   }
@@ -9873,10 +10136,28 @@ static int getClosedChip(int x, int y)
   return getChipFromOpenDirectionNotEmpty(direction_new, element_old);
 }
 
-static void SetElementSimple(int x, int y, int element, boolean change_level)
+static void SetElementSimpleExt(int x, int y, int dx, int dy, int element,
+                               boolean change_level)
 {
   int sx = x - level_xpos;
   int sy = y - level_ypos;
+  int old_element = Feld[x][y];
+  unsigned int new_bitmask = (dx + 1) << (dy * 2);
+
+  if (IS_MM_WALL_EDITOR(element))
+  {
+    element = map_mm_wall_element_editor(element) | new_bitmask;
+
+    if (IS_MM_WALL(old_element))
+      element |= MM_WALL_BITS(old_element);
+  }
+  else if (IS_MM_WALL(old_element) && element == EL_EMPTY)
+  {
+    int element_changed = old_element & ~new_bitmask;
+
+    if (MM_WALL_BITS(element_changed) != 0)
+      element = element_changed;
+  }
 
   IntelliDrawBuffer[x][y] = element;
 
@@ -9887,6 +10168,11 @@ static void SetElementSimple(int x, int y, int element, boolean change_level)
     DrawEditorElement(sx, sy, element);
 }
 
+static void SetElementSimple(int x, int y, int element, boolean change_level)
+{
+  SetElementSimpleExt(x, y, 0, 0, element, change_level);
+}
+
 static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
                                           int x2, int y2, int *element2,
                                           int (*close_function)(int, int),
@@ -10404,25 +10690,26 @@ static void ResetIntelliDraw()
   SetElementIntelliDraw(-1, -1, EL_UNDEFINED, FALSE, -1);
 }
 
-static void SetElementExt(int x, int y, int element, boolean change_level,
-                         int button)
+static void SetElementExt(int x, int y, int dx, int dy, int element,
+                         boolean change_level, int button)
 {
   if (element < 0)
     SetElementSimple(x, y, Feld[x][y], change_level);
   else if (GetKeyModState() & KMOD_Shift)
     SetElementIntelliDraw(x, y, element, change_level, button);
   else
-    SetElementSimple(x, y, element, change_level);
+    SetElementSimpleExt(x, y, dx, dy, element, change_level);
 }
 
 static void SetElement(int x, int y, int element)
 {
-  SetElementExt(x, y, element, TRUE, -1);
+  SetElementExt(x, y, 0, 0, element, TRUE, -1);
 }
 
-static void SetElementButton(int x, int y, int element, int button)
+static void SetElementButton(int x, int y, int dx, int dy, int element,
+                            int button)
 {
-  SetElementExt(x, y, element, TRUE, button);
+  SetElementExt(x, y, dx, dy, element, TRUE, button);
 }
 
 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
@@ -10430,7 +10717,7 @@ static void DrawLineElement(int sx, int sy, int element, boolean change_level)
   int lx = sx + level_xpos;
   int ly = sy + level_ypos;
 
-  SetElementExt(lx, ly, element, change_level, -1);
+  SetElementExt(lx, ly, 0, 0, element, change_level, -1);
 }
 
 static void DrawLine(int from_x, int from_y, int to_x, int to_y,
@@ -11059,6 +11346,8 @@ void WrapLevel(int dx, int dy)
 static void HandleDrawingAreas(struct GadgetInfo *gi)
 {
   static boolean started_inside_drawing_area = FALSE;
+  static int last_sx = -1, last_sy = -1;
+  static int last_sx2 = -1, last_sy2 = -1;
   int id = gi->custom_id;
   int type_id = gi->custom_type_id;
   boolean button_press_event;
@@ -11072,17 +11361,42 @@ static void HandleDrawingAreas(struct GadgetInfo *gi)
   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 mini_item_xsize = item_xsize / 2, mini_item_ysize = item_ysize / 2;
+  int sx2 = gi->event.mx / mini_item_xsize;
+  int sy2 = gi->event.my / mini_item_ysize;
+  int dx = sx2 % 2;
+  int dy = sy2 % 2;
   int lx = 0, ly = 0;
   int min_lx = 0, min_ly = 0;
   int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
   int x, y;
 
-  /* handle info callback for each invocation of action callback */
-  gi->callback_info(gi);
-
   button_press_event = (gi->event.type == GD_EVENT_PRESSED);
   button_release_event = (gi->event.type == GD_EVENT_RELEASED);
 
+  if (button_release_event)
+  {
+    last_sx = -1;
+    last_sy = -1;
+    last_sx2 = -1;
+    last_sy2 = -1;
+  }
+  else if (!button_press_event)
+  {
+    if ((sx == last_sx && sy == last_sy &&
+        !IS_MM_WALL_EDITOR(new_element) && new_element != EL_EMPTY) ||
+       (sx2 == last_sx2 && sy2 == last_sy2))
+      return;
+  }
+
+  last_sx = sx;
+  last_sy = sy;
+  last_sx2 = sx2;
+  last_sy2 = sy2;
+
+  /* handle info callback for each invocation of action callback */
+  gi->callback_info(gi);
+
   /* make sure to stay inside drawing area boundaries */
   sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
   sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
@@ -11167,7 +11481,7 @@ static void HandleDrawingAreas(struct GadgetInfo *gi)
                  SetElement(x, y, EL_EMPTY);
          }
 
-         SetElementButton(lx, ly, new_element, button);
+         SetElementButton(lx, ly, dx, dy, new_element, button);
        }
       }
       else if (!button_release_event)
@@ -11354,6 +11668,8 @@ static void HandleCounterButtons(struct GadgetInfo *gi)
       LoadLevel(level_nr);
       LoadScore(level_nr);
 
+      SaveLevelSetup_SeriesInfo();
+
       TapeErase();
 
       ResetUndoBuffer();
@@ -11478,6 +11794,12 @@ static void HandleSelectboxGadgets(struct GadgetInfo *gi)
 
     level.changed = TRUE;
   }
+  else if (type_id == ED_SELECTBOX_ID_GAME_ENGINE_TYPE)
+  {
+    /* update element selection list */
+    ReinitializeElementList();
+    ModifyEditorElementList();
+  }
 }
 
 static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
@@ -11485,15 +11807,15 @@ static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
   int type_id = gi->custom_type_id;
   int i;
 
-  if (type_id >= ED_TEXTBUTTON_ID_LEVELINFO_FIRST &&
-      type_id <= ED_TEXTBUTTON_ID_LEVELINFO_LAST)
+  if (type_id >= ED_TAB_BUTTON_ID_LEVELINFO_FIRST &&
+      type_id <= ED_TAB_BUTTON_ID_LEVELINFO_LAST)
   {
     edit_mode_levelinfo = gi->custom_type_id;
 
     DrawLevelInfoWindow();
   }
-  else if (type_id >= ED_TEXTBUTTON_ID_PROPERTIES_FIRST &&
-          type_id <= ED_TEXTBUTTON_ID_PROPERTIES_LAST)
+  else if (type_id >= ED_TAB_BUTTON_ID_PROPERTIES_FIRST &&
+          type_id <= ED_TAB_BUTTON_ID_PROPERTIES_LAST)
   {
     edit_mode_properties = gi->custom_type_id;