added support for nut settings in BD engine to level editor
authorHolger Schemel <info@artsoft.org>
Sun, 24 Mar 2024 13:50:13 +0000 (14:50 +0100)
committerHolger Schemel <info@artsoft.org>
Sun, 24 Mar 2024 13:50:13 +0000 (14:50 +0100)
src/editor.c
src/files.c
src/init.c
src/main.h

index 54b5373bc63755f1f0c44e7a4b20ba5ff52e39e4..5420a477979da1fb48a00079652c81789e85d260 100644 (file)
@@ -574,6 +574,7 @@ enum
   GADGET_ID_BD_ACID_TURNS_TO_ELEMENT,
   GADGET_ID_BD_BITER_EATS_ELEMENT,
   GADGET_ID_BD_BLADDER_CONVERTS_BY_ELEMENT,
+  GADGET_ID_BD_NUT_CONTENT,
   GADGET_ID_START_ELEMENT,
   GADGET_ID_ARTWORK_ELEMENT,
   GADGET_ID_EXPLOSION_ELEMENT,
@@ -1204,6 +1205,7 @@ enum
   ED_DRAWING_ID_BD_ACID_TURNS_TO_ELEMENT,
   ED_DRAWING_ID_BD_BITER_EATS_ELEMENT,
   ED_DRAWING_ID_BD_BLADDER_CONVERTS_BY_ELEMENT,
+  ED_DRAWING_ID_BD_NUT_CONTENT,
   ED_DRAWING_ID_START_ELEMENT,
   ED_DRAWING_ID_ARTWORK_ELEMENT,
   ED_DRAWING_ID_EXPLOSION_ELEMENT,
@@ -4500,6 +4502,14 @@ static struct
     &level.bd_bladder_converts_by_element,     1, 1,
     "Turns to clock by touching:", NULL, NULL, NULL,   "Turns to clock by touching element"
   },
+  {
+    ED_DRAWING_ID_BD_NUT_CONTENT,
+    ED_AREA_1X1_SETTINGS_XPOS(0),      ED_AREA_1X1_SETTINGS_YPOS(1),
+    ED_AREA_1X1_SETTINGS_XOFF,         ED_AREA_1X1_SETTINGS_YOFF,
+    GADGET_ID_BD_NUT_CONTENT,          GADGET_ID_NONE,
+    &level.bd_nut_content,             1, 1,
+    "When breaking, changes to:", NULL, NULL, NULL,    "Element created when breaking nut"
+  },
 
   // ---------- level start element -------------------------------------------
 
@@ -4747,6 +4757,7 @@ static boolean getDrawModeHiRes(void);
 static int getTabulatorBarWidth(void);
 static int getTabulatorBarHeight(void);
 static Pixel getTabulatorBarColor(void);
+static void getEditorGraphicAndFrame(int, int *, int *, boolean);
 static int numHiresTiles(int);
 
 static int num_editor_gadgets = 0;     // dynamically determined
@@ -7391,11 +7402,21 @@ static void DrawDrawingArea(int id)
   int tilesize = ED_DRAWINGAREA_TILE_SIZE;
 
   for (x = 0; x < area_xsize; x++)
+  {
     for (y = 0; y < area_ysize; y++)
+    {
+      int element = value[x * area_ysize + y];
+      int graphic;
+      int frame;
+
+      getEditorGraphicAndFrame(element, &graphic, &frame, TRUE);
+
       DrawSizedGraphicExt(drawto,
                          gi->x + x * tilesize,
                          gi->y + y * tilesize,
-                         el2edimg(value[x * area_ysize + y]), 0, tilesize);
+                         graphic, frame, tilesize);
+    }
+  }
 }
 
 static void ScrollEditorLevel(int from_x, int from_y, int scroll)
@@ -11793,6 +11814,11 @@ static void DrawPropertiesConfig(void)
     MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_WATER_CANNOT_FLOW_DOWN);
   }
 
+  if (properties_element == EL_BD_NUT)
+  {
+    MapDrawingArea(ED_DRAWING_ID_BD_NUT_CONTENT);
+  }
+
   // special case: slippery walls option for gems only available in R'n'D game engine
   if (IS_GEM(properties_element) && level.game_engine_type == GAME_ENGINE_TYPE_RND)
     MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
index c7a523f69982e9e55cc5dd60a13c6828a6f99d57..1b6346906e00f28aa078dee3c5bf4907cd84f315 100644 (file)
@@ -811,6 +811,12 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] =
     &li.bd_water_cannot_flow_down,     FALSE
   },
 
+  {
+    EL_BD_NUT,                         -1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.bd_nut_content,                        EL_BD_NUT_BREAKING_1
+  },
+
   // (the following values are related to various game elements)
 
   {
@@ -4125,6 +4131,8 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level)
 
   cave->water_does_not_flow_down       = level->bd_water_cannot_flow_down;
 
+  cave->nut_turns_to_when_crushed      = map_element_RND_to_BD_cave(level->bd_nut_content);
+
   // level name
   strncpy(cave->name, level->name, sizeof(GdString));
   cave->name[sizeof(GdString) - 1] = '\0';
@@ -4243,6 +4251,8 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level)
 
   level->bd_water_cannot_flow_down     = cave->water_does_not_flow_down;
 
+  level->bd_nut_content                        = map_element_BD_to_RND_cave(cave->nut_turns_to_when_crushed);
+
   // level name
   char *cave_name = getStringPrint("%s / %d", cave->name, bd_level_nr + 1);
 
index 7c19e260bf3e6054ca6d5030e6de4dc52ad57aba..f7f7d383bcef7593367be358a3a9b36e94510f02 100644 (file)
@@ -4299,6 +4299,7 @@ void InitElementPropertiesStatic(void)
     EL_BD_BITER_LEFT,
     EL_BD_BITER_DOWN,
     EL_BD_BLADDER,
+    EL_BD_NUT,
     EL_EMC_MAGIC_BALL,
     EL_EMC_ANDROID,
     EL_MM_GRAY_BALL,
index 7191591934a3f0ea634eb5edc7dce246ef804570..c6b9ab99abc58e884ea99e26465a76b6d352935a 100644 (file)
@@ -3669,6 +3669,7 @@ struct LevelInfo
   boolean bd_conveyor_belts_active;    // BD conveyor belts start in active state if enabled
   boolean bd_conveyor_belts_changed;   // BD conveyor belts direction is changed if enabled
   boolean bd_water_cannot_flow_down;   // BD water does not flow downwards if enabled
+  boolean bd_nut_content;              // BD nut contains the specified game element
 
   boolean em_slippery_gems;            // EM style "gems slip from wall" behaviour
   boolean em_explodes_by_fire;         // EM style chain explosion behaviour