added support for conveyor belt settings in BD engine to level editor
authorHolger Schemel <info@artsoft.org>
Fri, 22 Mar 2024 09:49:09 +0000 (10:49 +0100)
committerHolger Schemel <info@artsoft.org>
Fri, 22 Mar 2024 09:49:09 +0000 (10:49 +0100)
src/editor.c
src/files.c
src/main.h

index a3fc486f04d8e10a367493c20eac118646480796..ab2350d4a0ed6a3e6cec7695266a1753005d56eb 100644 (file)
@@ -731,6 +731,8 @@ enum
   GADGET_ID_BD_SLIME_IS_PREDICTABLE,
   GADGET_ID_BD_CHANGE_EXPANDING_WALL,
   GADGET_ID_BD_REPLICATORS_ACTIVE,
+  GADGET_ID_BD_CONVEYOR_BELTS_ACTIVE,
+  GADGET_ID_BD_CONVEYOR_BELTS_CHANGED,
   GADGET_ID_ENVELOPE_AUTOWRAP,
   GADGET_ID_ENVELOPE_CENTERED,
   GADGET_ID_MM_LASER_RED,
@@ -1078,6 +1080,8 @@ enum
   ED_CHECKBUTTON_ID_BD_SLIME_IS_PREDICTABLE,
   ED_CHECKBUTTON_ID_BD_CHANGE_EXPANDING_WALL,
   ED_CHECKBUTTON_ID_BD_REPLICATORS_ACTIVE,
+  ED_CHECKBUTTON_ID_BD_CONVEYOR_BELTS_ACTIVE,
+  ED_CHECKBUTTON_ID_BD_CONVEYOR_BELTS_CHANGED,
   ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
   ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
   ED_CHECKBUTTON_ID_MM_LASER_RED,
@@ -3830,6 +3834,22 @@ static struct
     NULL, NULL,
     "Active at start",                 "Replicators start in active state"
   },
+  {
+    ED_CHECKBUTTON_ID_BD_CONVEYOR_BELTS_ACTIVE,
+    ED_ELEMENT_SETTINGS_XPOS(0),       ED_ELEMENT_SETTINGS_YPOS(0),
+    GADGET_ID_BD_CONVEYOR_BELTS_ACTIVE,        GADGET_ID_NONE,
+    &level.bd_conveyor_belts_active,
+    NULL, NULL,
+    "Active at start",                 "Conveyor belts start in active state"
+  },
+  {
+    ED_CHECKBUTTON_ID_BD_CONVEYOR_BELTS_CHANGED,
+    ED_ELEMENT_SETTINGS_XPOS(0),       ED_ELEMENT_SETTINGS_YPOS(1),
+    GADGET_ID_BD_CONVEYOR_BELTS_CHANGED, GADGET_ID_NONE,
+    &level.bd_conveyor_belts_changed,
+    NULL, NULL,
+    "Change direction",                        "Switch conveyor belt direction"
+  },
   {
     ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
     ED_ELEMENT_SETTINGS_XPOS(0),       ED_ELEMENT_SETTINGS_YPOS(1),
@@ -11107,6 +11127,8 @@ static boolean checkPropertiesConfig(int element)
       IS_PLAYER_ELEMENT(element) ||
       IS_BD_PLAYER_ELEMENT(element) ||
       IS_BD_EXPANDABLE_WALL(properties_element) ||
+      IS_BD_CONVEYOR_BELT(properties_element) ||
+      IS_BD_CONVEYOR_BELT_SWITCH(properties_element) ||
       IS_SOKOBAN_OBJECT_OR_FIELD(element) ||
       HAS_EDITOR_CONTENT(element) ||
       CAN_GROW(element) ||
@@ -11475,6 +11497,13 @@ static void DrawPropertiesConfig(void)
     MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_REPLICATORS_ACTIVE);
   }
 
+  if (IS_BD_CONVEYOR_BELT(properties_element) ||
+      IS_BD_CONVEYOR_BELT_SWITCH(properties_element))
+  {
+    MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_CONVEYOR_BELTS_ACTIVE);
+    MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_CONVEYOR_BELTS_CHANGED);
+  }
+
   // 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 1260870372cf83bd6c03c9c061d7e33e772caf34..a164fdfd4e3452d41d5cdc8fa92fed903fab3df5 100644 (file)
@@ -759,6 +759,17 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] =
     &li.bd_replicator_create_delay,    4
   },
 
+  {
+    EL_BD_CONVEYOR_LEFT,               -1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(1),
+    &li.bd_conveyor_belts_active,      TRUE
+  },
+  {
+    EL_BD_CONVEYOR_LEFT,               -1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(2),
+    &li.bd_conveyor_belts_changed,     FALSE
+  },
+
   // (the following values are related to various game elements)
 
   {
@@ -4059,6 +4070,9 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level)
   cave->replicators_active             = level->bd_replicators_active;
   cave->replicator_delay_frame         = level->bd_replicator_create_delay;
 
+  cave->conveyor_belts_active          = level->bd_conveyor_belts_active;
+  cave->conveyor_belts_direction_changed= level->bd_conveyor_belts_changed;
+
   // level name
   strncpy(cave->name, level->name, sizeof(GdString));
   cave->name[sizeof(GdString) - 1] = '\0';
@@ -4163,6 +4177,9 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level)
   level->bd_replicators_active         = cave->replicators_active;
   level->bd_replicator_create_delay    = cave->replicator_delay_frame;
 
+  level->bd_conveyor_belts_active      = cave->conveyor_belts_active;
+  level->bd_conveyor_belts_changed     = cave->conveyor_belts_direction_changed;
+
   // level name
   char *cave_name = getStringPrint("%s / %d", cave->name, bd_level_nr + 1);
 
index 7d9bc3f1591bcbdc832d111d07a304d7e3e09b99..fdda65054a624fddbedde0f7b42ecf21af172ee9 100644 (file)
                                         (e) == EL_BD_EXPANDABLE_STEELWALL_VERTICAL ||  \
                                         (e) == EL_BD_EXPANDABLE_STEELWALL_ANY)
 
+#define IS_BD_CONVEYOR_BELT(e)         ((e) == EL_BD_CONVEYOR_LEFT ||                  \
+                                        (e) == EL_BD_CONVEYOR_LEFT_ACTIVE ||           \
+                                        (e) == EL_BD_CONVEYOR_RIGHT ||                 \
+                                        (e) == EL_BD_CONVEYOR_RIGHT_ACTIVE)
+
+#define IS_BD_CONVEYOR_BELT_SWITCH(e)  ((e) == EL_BD_CONVEYOR_SWITCH ||                \
+                                        (e) == EL_BD_CONVEYOR_SWITCH_ACTIVE ||         \
+                                        (e) == EL_BD_CONVEYOR_DIR_SWITCH_LEFT ||       \
+                                        (e) == EL_BD_CONVEYOR_DIR_SWITCH_RIGHT)
+
 #define IS_SOKOBAN_OBJECT_OR_FIELD(e)  ((e) == EL_SOKOBAN_OBJECT ||            \
                                         (e) == EL_SOKOBAN_FIELD_EMPTY ||       \
                                         (e) == EL_SOKOBAN_FIELD_FULL)
@@ -3550,6 +3560,8 @@ struct LevelInfo
   boolean bd_change_expanding_wall;    // BD expanding wall direction is changed if enabled
   boolean bd_replicators_active;       // BD replicators start in active state if enabled
   int bd_replicator_create_delay;      // BD replicator delay between replications (in BD frames)
+  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 em_slippery_gems;            // EM style "gems slip from wall" behaviour
   boolean em_explodes_by_fire;         // EM style chain explosion behaviour