rnd-20021227-2-src
[rocksndiamonds.git] / src / editor.c
index 35d7021ed97eb0a27cb663e6222d8623ff041592..7850a4f590f4bf3dcdad8624b70f693b72d95f06 100644 (file)
@@ -1182,10 +1182,70 @@ int editor_element[] =
   EL_CHAR('R'),
   */
 
-  EL_EMPTY,
-  EL_EMPTY,
-  EL_EMPTY,
-  EL_EMPTY,
+  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_GENERIC_START + 0,
+  EL_GENERIC_START + 1,
+  EL_GENERIC_START + 2,
+  EL_GENERIC_START + 3,
+
+  EL_GENERIC_START + 4,
+  EL_GENERIC_START + 5,
+  EL_GENERIC_START + 6,
+  EL_GENERIC_START + 7,
+
+  EL_GENERIC_START + 8,
+  EL_GENERIC_START + 9,
+  EL_GENERIC_START + 10,
+  EL_GENERIC_START + 11,
+
+  EL_GENERIC_START + 12,
+  EL_GENERIC_START + 13,
+  EL_GENERIC_START + 14,
+  EL_GENERIC_START + 15,
+
+  EL_GENERIC_START + 16,
+  EL_GENERIC_START + 17,
+  EL_GENERIC_START + 18,
+  EL_GENERIC_START + 19,
+
+  EL_GENERIC_START + 20,
+  EL_GENERIC_START + 21,
+  EL_GENERIC_START + 22,
+  EL_GENERIC_START + 23,
+
+  EL_GENERIC_START + 24,
+  EL_GENERIC_START + 25,
+  EL_GENERIC_START + 26,
+  EL_GENERIC_START + 27,
+
+  EL_GENERIC_START + 28,
+  EL_GENERIC_START + 29,
+  EL_GENERIC_START + 30,
+  EL_GENERIC_START + 31,
+
+  EL_CHAR('T'),
+  EL_CHAR('E'),
+  EL_CHAR('X'),
+  EL_CHAR('T'),
 
   EL_CHAR(' '),
   EL_CHAR('!'),
@@ -1265,7 +1325,12 @@ 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);
 
@@ -1273,7 +1338,8 @@ 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);
@@ -1959,6 +2025,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]);
@@ -2583,6 +2657,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,6 +2774,7 @@ 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++)
@@ -2681,7 +2793,11 @@ static void DrawPropertiesWindow()
             SX + xstart * MINI_TILEX - MINI_TILEX/2,
             SY + ystart * MINI_TILEY - MINI_TILEY/2);
 
+#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 +2807,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));
 
@@ -4061,6 +4186,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,