rnd-20030104-1-src
[rocksndiamonds.git] / src / editor.c
index db1a37e8705064866c79be94d87ea00baf298a9b..e8201e302b6f3ddcfaa6993a0a5867c1092cdf56 100644 (file)
@@ -737,7 +737,7 @@ static int counter_xsize = DXSIZE + FONT2_XSIZE - 2 * ED_GADGET_DISTANCE;
 
 int element_shift = 0;
 
-int editor_element[] =
+int editor_el_boulderdash[] =
 {
   EL_CHAR('B'),
   EL_CHAR('O'),
@@ -778,7 +778,11 @@ int editor_element[] =
   EL_BD_BUTTERFLY_DOWN,
   EL_BD_FIREFLY_DOWN,
   EL_EMPTY,
+};
+int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash);
 
+int editor_el_emerald_mine[] =
+{
   EL_CHAR('E'),
   EL_CHAR('M'),
   EL_CHAR('E'),
@@ -868,7 +872,11 @@ int editor_element[] =
   EL_EM_GATE2_GRAY,
   EL_EM_GATE3_GRAY,
   EL_EM_GATE4_GRAY,
+};
+int num_editor_el_emerald_mine = SIZEOF_ARRAY_INT(editor_el_emerald_mine);
 
+int editor_el_more[] =
+{
   EL_CHAR('M'),
   EL_CHAR('O'),
   EL_CHAR('R'),
@@ -968,8 +976,11 @@ int editor_element[] =
   EL_EMC_WALL5,
   EL_EMC_WALL6,
   EL_EMC_WALL7,
+};
+int num_editor_el_more = SIZEOF_ARRAY_INT(editor_el_more);
 
-
+int editor_el_sokoban[] =
+{
   EL_CHAR('S'),
   EL_CHAR('O'),
   EL_CHAR('K'),
@@ -984,7 +995,11 @@ int editor_element[] =
   EL_SOKOBAN_FIELD_EMPTY,
   EL_SOKOBAN_FIELD_FULL,
   EL_STEELWALL,
+};
+int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban);
 
+int editor_el_supaplex[] =
+{
   EL_CHAR('S'),
   EL_CHAR('U'),
   EL_CHAR('P'),
@@ -1044,7 +1059,11 @@ int editor_element[] =
   EL_SP_HARD_BASE6,
   EL_SP_CHIP_UPPER,
   EL_SP_CHIP_LOWER,
+};
+int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex);
 
+int editor_el_diamond_caves[] =
+{
   EL_CHAR('D'),
   EL_CHAR('I'),
   EL_CHAR('A'),
@@ -1124,7 +1143,11 @@ int editor_element[] =
   EL_SHIELD_DEADLY,
   EL_EXTRA_TIME,
   EL_EMPTY,
+};
+int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves);
 
+int editor_el_dx_boulderdash[] =
+{
   EL_CHAR('D'),
   EL_CHAR('X'),
   EL_CHAR('-'),
@@ -1163,29 +1186,16 @@ int editor_element[] =
   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
+};
+int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash);
 
-  EL_CHAR_MINUS,
+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('!'),
@@ -1265,15 +1275,298 @@ int editor_element[] =
   EL_CHAR('Ö'),
   EL_CHAR('Ü'),
   EL_CHAR('^'),
-  EL_CHAR(' ')
+  EL_CHAR('_'),
+
+  EL_CHAR(' '),
+  EL_CHAR('°'),
+  EL_CHAR('´'),
+  EL_CHAR('|')
 };
-int elements_in_list = sizeof(editor_element)/sizeof(int);
+int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars);
+
+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
+};
+int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom);
+
+int *editor_elements = NULL;   /* dynamically allocated */
+int num_editor_elements = 0;   /* dynamically determined */
+
+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                                                               }
+};
+
+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 char *getElementInfoText(int element)
 {
   char *info_text = "unknown";
 
-  if (element < NUM_FILE_ELEMENTS)
+  if (element < NUM_FILE_ELEMENTS &&
+      element_info[element].editor_description != NULL)
     info_text = element_info[element].editor_description;
   else
     Error(ERR_WARN, "no element description for element %d", element);
@@ -1298,13 +1591,13 @@ static void ScrollMiniLevel(int from_x, int from_y, int scroll)
   {
     x = (dx == 1 ? 0 : ed_fieldx - 1);
     for(y=0; y<ed_fieldy; y++)
-      DrawNewMiniElementOrWall(x, y, from_x, from_y);
+      DrawMiniElementOrWall(x, y, from_x, from_y);
   }
   else if (dy)
   {
     y = (dy == 1 ? 0 : ed_fieldy - 1);
     for(x=0; x<ed_fieldx; x++)
-      DrawNewMiniElementOrWall(x, y, from_x, from_y);
+      DrawMiniElementOrWall(x, y, from_x, from_y);
   }
 
   redraw_mask |= REDRAW_FIELD;
@@ -1313,7 +1606,7 @@ static void ScrollMiniLevel(int from_x, int from_y, int scroll)
 
 static void CreateControlButtons()
 {
-  Bitmap *gd_bitmap = pix[PIX_DOOR];
+  Bitmap *gd_bitmap = new_graphic_info[IMG_MENU_DOOR].bitmap;
   struct GadgetInfo *gi;
   unsigned long event_mask;
   int i;
@@ -1480,6 +1773,7 @@ static void CreateControlButtons()
     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;
 
@@ -1490,14 +1784,13 @@ static void CreateControlButtons()
     gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
     gd_y  = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
 
-    getNewMiniGraphicSource(el2img(editor_element[i]),
-                           &deco_bitmap, &deco_x, &deco_y);
+    getMiniGraphicSource(el2img(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,
@@ -1534,7 +1827,7 @@ static void CreateCounterButtons()
 
     for (j=0; j<2; j++)
     {
-      Bitmap *gd_bitmap = pix[PIX_DOOR];
+      Bitmap *gd_bitmap = new_graphic_info[IMG_MENU_DOOR].bitmap;
       struct GadgetInfo *gi;
       int id = (j == 0 ?
                counterbutton_info[i].gadget_id_down :
@@ -1756,7 +2049,7 @@ static void CreateTextInputGadgets()
 
   for (i=0; i<ED_NUM_TEXTINPUT; i++)
   {
-    Bitmap *gd_bitmap = pix[PIX_DOOR];
+    Bitmap *gd_bitmap = new_graphic_info[IMG_MENU_DOOR].bitmap;
     int gd_x, gd_y;
     struct GadgetInfo *gi;
     unsigned long event_mask;
@@ -1803,7 +2096,7 @@ static void CreateScrollbarGadgets()
   for (i=0; i<ED_NUM_SCROLLBARS; i++)
   {
     int id = scrollbar_info[i].gadget_id;
-    Bitmap *gd_bitmap = pix[PIX_DOOR];
+    Bitmap *gd_bitmap = new_graphic_info[IMG_MENU_DOOR].bitmap;
     int gd_x1, gd_x2, gd_y1, gd_y2;
     struct GadgetInfo *gi;
     int items_max, items_visible, item_position;
@@ -1811,7 +2104,7 @@ static void CreateScrollbarGadgets()
 
     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;
     }
@@ -1868,7 +2161,7 @@ static void CreateScrollbarGadgets()
 
 static void CreateCheckbuttonGadgets()
 {
-  Bitmap *gd_bitmap = pix[PIX_DOOR];
+  Bitmap *gd_bitmap = new_graphic_info[IMG_MENU_DOOR].bitmap;
   struct GadgetInfo *gi;
   unsigned long event_mask;
   int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
@@ -1951,6 +2244,8 @@ static void CreateCheckbuttonGadgets()
 
 void CreateLevelEditorGadgets()
 {
+  ReinitializeElementList();
+
   CreateControlButtons();
   CreateCounterButtons();
   CreateDrawingAreas();
@@ -1959,6 +2254,14 @@ void CreateLevelEditorGadgets()
   CreateCheckbuttonGadgets();
 }
 
+void FreeLevelEditorGadgets()
+{
+  int i;
+
+  for (i=0; i<NUM_EDITOR_GADGETS; i++)
+    FreeGadget(level_editor_gadget[i]);
+}
+
 static void MapCounterButtons(int id)
 {
   MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_down]);
@@ -2137,17 +2440,17 @@ void DrawLevelEd()
   }
 
   /* copy default editor door content to main double buffer */
-  BlitBitmap(pix[PIX_DOOR], drawto,
+  BlitBitmap(new_graphic_info[IMG_MENU_DOOR].bitmap, drawto,
             DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
 
   /* draw mouse button brush elements */
-  DrawNewMiniGraphicExt(drawto,
+  DrawMiniGraphicExt(drawto,
                     DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
                     el2img(new_element1));
-  DrawNewMiniGraphicExt(drawto,
+  DrawMiniGraphicExt(drawto,
                     DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
                     el2img(new_element2));
-  DrawNewMiniGraphicExt(drawto,
+  DrawMiniGraphicExt(drawto,
                     DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
                     el2img(new_element3));
 
@@ -2155,15 +2458,18 @@ void DrawLevelEd()
   DrawSpecialEditorDoor();
 
   /* draw new control window */
-  BlitBitmap(pix[PIX_DOOR], drawto,
+  BlitBitmap(new_graphic_info[IMG_MENU_DOOR].bitmap, drawto,
             DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY);
 
   redraw_mask |= REDRAW_ALL;
 
+  ReinitializeElementListButtons();    /* only needed after setup changes */
+
+  UnmapTapeButtons();
   MapControlButtons();
 
   /* copy actual editor door content to door double buffer for OpenDoor() */
-  BlitBitmap(drawto, pix[PIX_DB_DOOR],
+  BlitBitmap(drawto, bitmap_db_door,
             DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
 
   DrawEditModeWindow();
@@ -2320,21 +2626,21 @@ static void PickDrawingElement(int button, int element)
   if (button == 1)
   {
     new_element1 = element;
-    DrawNewMiniGraphicExt(drawto,
+    DrawMiniGraphicExt(drawto,
                       DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
                       el2img(new_element1));
   }
   else if (button == 2)
   {
     new_element2 = element;
-    DrawNewMiniGraphicExt(drawto,
+    DrawMiniGraphicExt(drawto,
                       DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
                       el2img(new_element2));
   }
   else
   {
     new_element3 = element;
-    DrawNewMiniGraphicExt(drawto,
+    DrawMiniGraphicExt(drawto,
                       DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
                       el2img(new_element3));
   }
@@ -2350,7 +2656,7 @@ static void DrawDrawingWindow()
   AdjustLevelScrollPosition();
   AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
   AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
-  DrawNewMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+  DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
   MapMainDrawingArea();
 }
 
@@ -2367,7 +2673,7 @@ static void DrawRandomPlacementBackgroundArea()
   /* draw decorative border for the object */
   for (y=0; y<2; y++)
     for (x=0; x<2; x++)
-      DrawNewMiniElement(area_x + x, area_y + y, EL_SAND);
+      DrawMiniElement(area_x + x, area_y + y, EL_SAND);
 
   ClearRectangle(drawto,
                 area_sx + MINI_TILEX/2 - 1, area_sy + MINI_TILEY/2 - 1,
@@ -2378,7 +2684,7 @@ static void DrawRandomPlacementBackgroundArea()
             area_sx, area_sy, 3 * MINI_TILEX, 3 * MINI_TILEY,
             area_sx - MINI_TILEX/2, area_sy - MINI_TILEY/2);
 
-  DrawNewMiniElement(area_x, area_y, ElementContent[0][0][0]);
+  DrawMiniElement(area_x, area_y, ElementContent[0][0][0]);
 
   MapDrawingArea(GADGET_ID_RANDOM_BACKGROUND);
 }
@@ -2489,7 +2795,7 @@ static void DrawAmoebaContentArea()
   /* draw decorative border for the object */
   for (y=0; y<2; y++)
     for (x=0; x<2; x++)
-      DrawNewMiniElement(area_x + x, area_y + y, EL_SAND);
+      DrawMiniElement(area_x + x, area_y + y, EL_SAND);
 
   ClearRectangle(drawto,
                 area_sx + MINI_TILEX/2 - 1, area_sy + MINI_TILEY/2 - 1,
@@ -2503,7 +2809,7 @@ static void DrawAmoebaContentArea()
   DrawText(area_sx + TILEX, area_sy + 1, "Content of amoeba",
           FS_SMALL, font_color);
 
-  DrawNewMiniElement(area_x, area_y, ElementContent[0][0][0]);
+  DrawMiniElement(area_x, area_y, ElementContent[0][0][0]);
 
   MapDrawingArea(GADGET_ID_AMOEBA_CONTENT);
 }
@@ -2546,7 +2852,7 @@ static void DrawElementContentAreas()
   {
     for (y=0; y<4; y++)
       for (x=0; x<4; x++)
-       DrawNewMiniElement(area_x + 5 * (i % 4) + x, area_y + 6 * (i / 4) + y,
+       DrawMiniElement(area_x + 5 * (i % 4) + x, area_y + 6 * (i / 4) + y,
                        EL_SAND);
 
     ClearRectangle(drawto,
@@ -2571,7 +2877,7 @@ static void DrawElementContentAreas()
   {
     for (y=0; y<3; y++)
       for (x=0; x<3; x++)
-       DrawNewMiniElement(area_x + 5 * (i % 4) + x, area_y + 6 * (i / 4) + y,
+       DrawMiniElement(area_x + 5 * (i % 4) + x, area_y + 6 * (i / 4) + y,
                        ElementContent[i][x][y]);
 
     DrawTextF(area_sx - SX + 5 * (i % 4) * MINI_TILEX + MINI_TILEX + 1,
@@ -2583,6 +2889,43 @@ static void DrawElementContentAreas()
     MapDrawingArea(GADGET_ID_ELEM_CONTENT_0 + i);
 }
 
+#if 0
+static void DrawPropertiesElement(int xstart, int ystart, int element)
+{
+  int x, y;
+
+  /* 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);
+
+  /* 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);
+
+  DrawGraphicAnimation(xstart / 2, ystart / 2, el2img(element));
+
+  /* copy the whole stuff to the definitive location */
+  BlitBitmap(drawto, drawto,
+            SX + xstart * MINI_TILEX - MINI_TILEX/2,
+            SY + ystart * MINI_TILEY - MINI_TILEY,
+            2 * TILEX, 2 * TILEY,
+            SX + xstart * MINI_TILEX - MINI_TILEX/2,
+            SY + ystart * MINI_TILEY - MINI_TILEY/2);
+
+  FrameCounter++;      /* increase animation frame counter */
+}
+#endif
+
 #define TEXT_COLLECTING                "Score for collecting"
 #define TEXT_SMASHING          "Score for smashing"
 #define TEXT_CRACKING          "Score for cracking"
@@ -2663,10 +3006,11 @@ static void DrawPropertiesWindow()
   DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS_YPOS,
           "Element Settings", FS_BIG, FC_YELLOW);
 
+#if 1
   /* draw some decorative border for the object */
   for (y=0; y<3; y++)
     for (x=0; x<3; x++)
-      DrawNewMiniElement(xstart + x , ystart + y, EL_SAND);
+      DrawMiniElement(xstart + x , ystart + y, EL_SAND);
 
   ClearRectangle(drawto,
                 SX + xstart * MINI_TILEX + MINI_TILEX/2 - 1,
@@ -2681,7 +3025,11 @@ static void DrawPropertiesWindow()
             SX + xstart * MINI_TILEX - MINI_TILEX/2,
             SY + ystart * MINI_TILEY - MINI_TILEY/2);
 
-  DrawNewGraphic(xstart / 2, ystart / 2, el2img(properties_element), 0);
+#if 0
+  DrawGraphic(xstart / 2, ystart / 2, el2img(properties_element), 0);
+#else
+  DrawGraphicAnimation(xstart / 2, ystart / 2, el2img(properties_element));
+#endif
 
   /* copy the whole stuff to the definitive location */
   BlitBitmap(drawto, drawto,
@@ -2691,6 +3039,15 @@ static void DrawPropertiesWindow()
             SX + xstart * MINI_TILEX - MINI_TILEX/2,
             SY + ystart * MINI_TILEY - MINI_TILEY/2);
 
+  FrameCounter = 0;    /* restart animation frame counter */
+
+#else
+
+  FrameCounter = 0;    /* restart animation frame counter */
+  DrawPropertiesElement(xstart, ystart, properties_element);
+
+#endif
+
   DrawTextF((xstart + 3) * MINI_TILEX, (ystart + 1) * MINI_TILEY,
            font_color, getElementInfoText(properties_element));
 
@@ -2759,7 +3116,7 @@ static void DrawLineElement(int sx, int sy, int element, boolean change_level)
   int lx = sx + level_xpos;
   int ly = sy + level_ypos;
 
-  DrawNewMiniElement(sx, sy, (element < 0 ? Feld[lx][ly] : element));
+  DrawMiniElement(sx, sy, (element < 0 ? Feld[lx][ly] : element));
 
   if (change_level)
     Feld[lx][ly] = element;
@@ -3174,7 +3531,7 @@ static int DrawLevelText(int sx, int sy, char letter, int mode)
       break;
 
     case TEXT_SETCURSOR:
-      DrawNewMiniElement(last_sx, last_sy, Feld[lx][ly]);
+      DrawMiniElement(last_sx, last_sy, Feld[lx][ly]);
       DrawAreaBorder(sx, sy, sx, sy);
       last_sx = sx;
       last_sy = sy;
@@ -3199,7 +3556,7 @@ static int DrawLevelText(int sx, int sy, char letter, int mode)
       if (sx > start_sx)
       {
        Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
-       DrawNewMiniElement(sx - 1, sy, Feld[lx - 1][ly]);
+       DrawMiniElement(sx - 1, sy, Feld[lx - 1][ly]);
        DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
       }
       break;
@@ -3213,7 +3570,7 @@ static int DrawLevelText(int sx, int sy, char letter, int mode)
 
     case TEXT_END:
       CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
-      DrawNewMiniElement(sx, sy, Feld[lx][ly]);
+      DrawMiniElement(sx, sy, Feld[lx][ly]);
       typing = FALSE;
       break;
 
@@ -3234,7 +3591,7 @@ static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
   int ly = sy + level_ypos;
 
   if (element == -1)
-    DrawNewMiniElement(sx, sy, Feld[lx][ly]);
+    DrawMiniElement(sx, sy, Feld[lx][ly]);
   else
     DrawAreaBorder(sx, sy, sx, sy);
 }
@@ -3279,7 +3636,7 @@ static void CopyLevelToUndoBuffer(int mode)
   last_border_element = BorderElement;
   SetBorderElement();
   if (BorderElement != last_border_element)
-    DrawNewMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+    DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
 
 #if 0
 #ifdef DEBUG
@@ -3320,7 +3677,7 @@ static void RandomPlacement(int new_element)
       for (y=0; y<lev_fieldy; y++)
        Feld[x][y] = new_element;
 
-    DrawNewMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+    DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
     CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
     return;
   }
@@ -3339,7 +3696,7 @@ static void RandomPlacement(int new_element)
     }
   }
 
-  DrawNewMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+  DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
   CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
 }
 
@@ -3358,7 +3715,7 @@ void WrapLevel(int dx, int dy)
       Feld[x][y] =
        FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
 
-  DrawNewMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+  DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
   CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
 }
 
@@ -3458,7 +3815,7 @@ static void HandleDrawingAreas(struct GadgetInfo *gi)
                  Feld[x][y] = EL_EMPTY;
                  if (x - level_xpos >= 0 && x - level_xpos < ed_fieldx &&
                      y - level_ypos >= 0 && y - level_ypos < ed_fieldy)
-                   DrawNewMiniElement(x - level_xpos, y - level_ypos,
+                   DrawMiniElement(x - level_xpos, y - level_ypos,
                                    EL_EMPTY);
                }
              }
@@ -3466,16 +3823,16 @@ static void HandleDrawingAreas(struct GadgetInfo *gi)
          }
 
          Feld[lx][ly] = new_element;
-         DrawNewMiniElement(sx, sy, new_element);
+         DrawMiniElement(sx, sy, new_element);
        }
       }
       else
       {
-       DrawNewMiniGraphicExt(drawto,
+       DrawMiniGraphicExt(drawto,
                           gi->x + sx * MINI_TILEX,
                           gi->y + sy * MINI_TILEY,
                           el2img(new_element));
-       DrawNewMiniGraphicExt(window,
+       DrawMiniGraphicExt(window,
                           gi->x + sx * MINI_TILEX,
                           gi->y + sy * MINI_TILEY,
                           el2img(new_element));
@@ -3575,7 +3932,7 @@ static void HandleDrawingAreas(struct GadgetInfo *gi)
       if (button_press_event && Feld[lx][ly] != new_element)
       {
        FloodFill(lx, ly, new_element);
-       DrawNewMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+       DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
        CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
       }
       break;
@@ -3698,7 +4055,7 @@ static void HandleControlButtons(struct GadgetInfo *gi)
        if (button == 1)
          ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
        else
-         DrawNewMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+         DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
 
        ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
                     GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
@@ -3717,7 +4074,7 @@ static void HandleControlButtons(struct GadgetInfo *gi)
        if (button == 1)
          ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
        else
-         DrawNewMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+         DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
 
        ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
                     GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
@@ -3736,7 +4093,7 @@ static void HandleControlButtons(struct GadgetInfo *gi)
        if (button == 1)
          ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
        else
-         DrawNewMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+         DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
 
        ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
                     GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
@@ -3755,7 +4112,7 @@ static void HandleControlButtons(struct GadgetInfo *gi)
        if (button == 1)
          ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP);
        else
-         DrawNewMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+         DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
 
        ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
                     GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
@@ -3764,12 +4121,12 @@ static void HandleControlButtons(struct GadgetInfo *gi)
 
     case GADGET_ID_SCROLL_HORIZONTAL:
       level_xpos = gi->event.item_position - 1;
-      DrawNewMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+      DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
       break;
 
     case GADGET_ID_SCROLL_VERTICAL:
       level_ypos = gi->event.item_position - 1;
-      DrawNewMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+      DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
       break;
 
     case GADGET_ID_SCROLL_LIST_UP:
@@ -3784,8 +4141,8 @@ static void HandleControlButtons(struct GadgetInfo *gi)
 
        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,
@@ -3797,10 +4154,10 @@ static void HandleControlButtons(struct GadgetInfo *gi)
        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];
+       int element = editor_elements[element_shift + i];
 
        UnmapGadget(gi);
-       getNewMiniGraphicSource(el2img(element), &gd->bitmap, &gd->x, &gd->y);
+       getMiniGraphicSource(el2img(element), &gd->bitmap, &gd->x, &gd->y);
        ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END);
        MapGadget(gi);
       }
@@ -3869,7 +4226,7 @@ static void HandleControlButtons(struct GadgetInfo *gi)
       for(x=0; x<lev_fieldx; x++)
        for(y=0; y<lev_fieldy; y++)
          Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
-      DrawNewMiniLevel(ed_fieldx, ed_fieldy, level_xpos,level_ypos);
+      DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos,level_ypos);
       break;
 
     case GADGET_ID_INFO:
@@ -3891,7 +4248,7 @@ static void HandleControlButtons(struct GadgetInfo *gi)
          Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
       CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
 
-      DrawNewMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+      DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
       break;
 
     case GADGET_ID_SAVE:
@@ -3957,7 +4314,7 @@ static void HandleControlButtons(struct GadgetInfo *gi)
          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);
 
@@ -4061,6 +4418,32 @@ void HandleLevelEditorKeyInput(Key key)
   }
 }
 
+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;
+
+  FY += MINI_TILEY / 2;
+#if 1
+  DrawGraphicAnimation(xpos, ypos, el2img(properties_element));
+#else
+  DrawGraphicAnimation(xpos, ypos, el_dir_act2img(properties_element,
+                                                 MV_NO_MOVING,
+                                                 ...));
+#endif
+  FY -= MINI_TILEY / 2;
+  MarkTileDirty(xpos, ypos + 1);
+
+  FrameCounter++;      /* increase animation frame counter */
+}
+
 void ClearEditorGadgetInfoText()
 {
   ClearRectangle(drawto,
@@ -4258,7 +4641,7 @@ void RequestExitLevelEditor(boolean ask_if_level_has_changed)
   else
   {
     CloseDoor(DOOR_CLOSE_1);
-    BlitBitmap(pix[PIX_DB_DOOR], pix[PIX_DB_DOOR],
+    BlitBitmap(bitmap_db_door, bitmap_db_door,
               DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
               DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
     OpenDoor(DOOR_OPEN_1);