added support for snap element in BD engine to level editor
authorHolger Schemel <info@artsoft.org>
Sun, 17 Mar 2024 00:05:56 +0000 (01:05 +0100)
committerHolger Schemel <info@artsoft.org>
Sun, 17 Mar 2024 00:05:56 +0000 (01:05 +0100)
src/editor.c
src/files.c
src/main.h

index 6ca4145f54b06507482f5799778641afefa8bc28..0a682af53a6409a2b5cbccc7c68e3dd9a48b8258 100644 (file)
@@ -556,6 +556,7 @@ enum
   GADGET_ID_MAGIC_BALL_CONTENT_7,
   GADGET_ID_ANDROID_CONTENT,
   GADGET_ID_AMOEBA_CONTENT,
+  GADGET_ID_BD_SNAP_ELEMENT,
   GADGET_ID_BD_AMOEBA_CONTENT_TOO_BIG,
   GADGET_ID_BD_AMOEBA_CONTENT_ENCLOSED,
   GADGET_ID_BD_AMOEBA_2_CONTENT_TOO_BIG,
@@ -1162,6 +1163,7 @@ enum
   ED_DRAWING_ID_MAGIC_BALL_CONTENT_7,
   ED_DRAWING_ID_ANDROID_CONTENT,
   ED_DRAWING_ID_AMOEBA_CONTENT,
+  ED_DRAWING_ID_BD_SNAP_ELEMENT,
   ED_DRAWING_ID_BD_AMOEBA_CONTENT_TOO_BIG,
   ED_DRAWING_ID_BD_AMOEBA_CONTENT_ENCLOSED,
   ED_DRAWING_ID_BD_AMOEBA_2_CONTENT_TOO_BIG,
@@ -4261,7 +4263,18 @@ static struct
     "content:", NULL, NULL, NULL,      "amoeba content"
   },
 
-  // ---------- BD amoeba content ------------------------------------------------
+  // ---------- BD snap element -----------------------------------------------
+
+  {
+    ED_DRAWING_ID_BD_SNAP_ELEMENT,
+    ED_AREA_1X1_SETTINGS_XPOS(0),      ED_AREA_1X1_SETTINGS_YPOS(5),
+    ED_AREA_1X1_SETTINGS_XOFF,         ED_AREA_1X1_SETTINGS_YOFF,
+    GADGET_ID_BD_SNAP_ELEMENT,         GADGET_ID_NONE,
+    &level.bd_snap_element,            1, 1,
+    "snap element:", NULL, NULL, NULL, "element created when snapping"
+  },
+
+  // ---------- BD amoeba content ---------------------------------------------
 
   {
     ED_DRAWING_ID_BD_AMOEBA_CONTENT_TOO_BIG,
@@ -4280,7 +4293,7 @@ static struct
     "if enclosed, changes to:", NULL, NULL, NULL,      "BD amoeba content if enclosed"
   },
 
-  // ---------- BD amoeba 2 content ------------------------------------------------
+  // ---------- BD amoeba 2 content -------------------------------------------
 
   {
     ED_DRAWING_ID_BD_AMOEBA_2_CONTENT_TOO_BIG,
@@ -11291,6 +11304,9 @@ static void DrawPropertiesConfig(void)
     // draw counter gadgets
     MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB);
     MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET);
+
+    // draw drawing area gadgets
+    MapDrawingArea(ED_DRAWING_ID_BD_SNAP_ELEMENT);
   }
 
   if (properties_element == EL_BD_ROCK && level.game_engine_type == GAME_ENGINE_TYPE_BD)
index b4c2d7e4023af33ec725c199872b27ac137866e5..6bc53e5651a273a4ff3dd59942b232ff053c460b 100644 (file)
@@ -628,6 +628,11 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] =
     TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(5),
     &li.bd_push_mega_rock_with_sweet,  FALSE
   },
+  {
+    EL_BD_PLAYER,                      -1,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(6),
+    &li.bd_snap_element,               EL_EMPTY
+  },
 
   {
     EL_BD_DIAMOND,                     -1,
@@ -3927,6 +3932,7 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level)
   cave->pushing_stone_prob             = level->bd_pushing_prob            * 10000;
   cave->pushing_stone_prob_sweet       = level->bd_pushing_prob_with_sweet * 10000;
   cave->mega_stones_pushable_with_sweet        = level->bd_push_mega_rock_with_sweet;
+  cave->snap_element                   = map_element_RND_to_BD(level->bd_snap_element);
 
   // element properties
   cave->level_bonus_time[0]            = level->bd_clock_extra_time;
@@ -4009,6 +4015,7 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level)
   level->bd_pushing_prob               = cave->pushing_stone_prob       / 10000;
   level->bd_pushing_prob_with_sweet    = cave->pushing_stone_prob_sweet / 10000;
   level->bd_push_mega_rock_with_sweet  = cave->mega_stones_pushable_with_sweet;
+  level->bd_snap_element               = map_element_BD_to_RND(cave->snap_element);
 
   // element properties
   level->bd_clock_extra_time           = cave->level_bonus_time[0];
index 9abb886a5634f03c718f42610aaaf733ffc378ca..d650a5f78f3d1dde005523d83b4f251c0b3157dd 100644 (file)
@@ -3493,6 +3493,7 @@ struct LevelInfo
   boolean bd_intermission;             // BD level is intermission
   boolean bd_diagonal_movements;       // BD style diagonal movements
   boolean bd_topmost_player_active;    // BD engine uses first player found on playfield
+  int bd_snap_element;                 // BD element that is created when player is snapping
   int bd_pushing_prob;                 // BD player probability to push rocks
   int bd_pushing_prob_with_sweet;      // BD player probability to push rocks after eating sweet
   boolean bd_push_mega_rock_with_sweet;        // BD player can push mega rocks after eating sweet