added editor settings if Sokoban fields and objects need to be solved
[rocksndiamonds.git] / src / editor.c
index 6a0e6be2afede472e3697a134d64e16370d5ecd6..57c791326e3321ace5af05976834fbdc7823684d 100644 (file)
 #define INFOTEXT_UNKNOWN_ELEMENT       "unknown"
 
 
-/*
-  -----------------------------------------------------------------------------
-  screen and artwork graphic pixel position definitions
-  -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// screen and artwork graphic pixel position definitions
+// ----------------------------------------------------------------------------
 
 // values for the control window
 #define ED_CTRL1_BUTTONS_HORIZ         4       // toolbox
                                      SYSIZE - INFOTEXT_YSIZE)
 
 
-/*
-  -----------------------------------------------------------------------------
-  editor gadget definitions
-  -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// editor gadget definitions
+// ----------------------------------------------------------------------------
 
 enum
 {
@@ -646,6 +642,8 @@ enum
   GADGET_ID_RANDOM_BALL_CONTENT,
   GADGET_ID_INITIAL_BALL_STATE,
   GADGET_ID_GROW_INTO_DIGGABLE,
+  GADGET_ID_SB_FIELDS_NEEDED,
+  GADGET_ID_SB_OBJECTS_NEEDED,
   GADGET_ID_AUTO_EXIT_SOKOBAN,
   GADGET_ID_SOLVED_BY_ONE_PLAYER,
   GADGET_ID_CONTINUOUS_SNAPPING,
@@ -949,6 +947,8 @@ enum
   ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT,
   ED_CHECKBUTTON_ID_INITIAL_BALL_STATE,
   ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE,
+  ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED,
+  ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED,
   ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN,
   ED_CHECKBUTTON_ID_SOLVED_BY_ONE_PLAYER,
   ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING,
@@ -1079,11 +1079,9 @@ enum
 #define ED_DRAWING_ID_EDITOR_LAST      ED_DRAWING_ID_RANDOM_BACKGROUND
 
 
-/*
-  -----------------------------------------------------------------------------
-  some internally used definitions
-  -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// some internally used definitions
+// ----------------------------------------------------------------------------
 
 // values for CopyLevelToUndoBuffer()
 #define UNDO_IMMEDIATE                 0
@@ -1138,11 +1136,9 @@ enum
 #define DEFAULT_EDITOR_TILESIZE_MM     TILESIZE
 
 
-/*
-  -----------------------------------------------------------------------------
-  some internally used data structure definitions
-  -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// some internally used data structure definitions
+// ----------------------------------------------------------------------------
 
 static struct
 {
@@ -1154,8 +1150,8 @@ static struct
   char shortcut;
 } controlbutton_info[ED_NUM_CTRL_BUTTONS] =
 {
-  /* note: some additional characters are already reserved for "cheat mode"
-     shortcuts (":XYZ" style) -- for details, see "events.c" */
+  // note: some additional characters are already reserved for "cheat mode"
+  // shortcuts (":XYZ" style) -- for details, see "events.c"
 
   // ---------- toolbox control buttons ---------------------------------------
 
@@ -3076,10 +3072,24 @@ static struct
   },
   {
     ED_ELEMENT_SETTINGS_XPOS(0),       ED_ELEMENT_SETTINGS_YPOS(0),
+    GADGET_ID_SB_FIELDS_NEEDED,                GADGET_ID_NONE,
+    &level.sb_fields_needed,
+    NULL, NULL,
+    "all fields need to be filled",    "require all SB fields to be solved"
+  },
+  {
+    ED_ELEMENT_SETTINGS_XPOS(0),       ED_ELEMENT_SETTINGS_YPOS(0),
+    GADGET_ID_SB_OBJECTS_NEEDED,       GADGET_ID_NONE,
+    &level.sb_objects_needed,
+    NULL, NULL,
+    "all objects need to be placed",   "require all SB objects to be solved"
+  },
+  {
+    ED_ELEMENT_SETTINGS_XPOS(0),       ED_ELEMENT_SETTINGS_YPOS(1),
     GADGET_ID_AUTO_EXIT_SOKOBAN,       GADGET_ID_NONE,
     &level.auto_exit_sokoban,
     NULL, NULL,
-    "exit level if all fields solved", "automatically finish Sokoban levels"
+    "exit level if all tasks solved",  "automatically finish Sokoban levels"
   },
   {
     ED_ELEMENT_SETTINGS_XPOS(0),       ED_ELEMENT_SETTINGS_YPOS(14),
@@ -3747,11 +3757,9 @@ static struct
 };
 
 
-/*
-  -----------------------------------------------------------------------------
-  some internally used variables
-  -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// some internally used variables
+// ----------------------------------------------------------------------------
 
 // maximal size of level editor drawing area
 static int MAX_ED_FIELDX, MAX_ED_FIELDY;
@@ -5419,11 +5427,9 @@ editor_elements_info[] =
 };
 
 
-/*
-  -----------------------------------------------------------------------------
-  functions
-  -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// functions
+// ----------------------------------------------------------------------------
 
 static int getMaxInfoTextLength(void)
 {
@@ -6682,9 +6688,9 @@ static void CreateSelectboxGadgets(void)
 
     if (selectbox_info[i].size == -1)  // dynamically determine size
     {
-      /* (we cannot use -1 for uninitialized values if we directly compare
-        with results from strlen(), because the '<' and '>' operation will
-        implicitely cast -1 to an unsigned integer value!) */
+      // (we cannot use -1 for uninitialized values if we directly compare
+      // with results from strlen(), because the '<' and '>' operation will
+      // implicitely cast -1 to an unsigned integer value!)
       selectbox_info[i].size = 0;
 
       for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
@@ -9943,10 +9949,22 @@ static void DrawPropertiesConfig(void)
     MapCheckbuttonGadget(ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE);
   }
 
+  if (properties_element == EL_SOKOBAN_FIELD_EMPTY)
+    MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED);
+
+  if (properties_element == EL_SOKOBAN_OBJECT)
+    MapCheckbuttonGadget(ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED);
+
   if (properties_element == EL_SOKOBAN_OBJECT ||
       properties_element == EL_SOKOBAN_FIELD_EMPTY ||
       properties_element == EL_SOKOBAN_FIELD_FULL)
+  {
+    checkbutton_info[ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN].y =
+      ED_ELEMENT_SETTINGS_XPOS(properties_element == EL_SOKOBAN_FIELD_FULL ?
+                              0 : 1);
+
     MapCheckbuttonGadget(ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN);
+  }
 
   if (IS_BALLOON_ELEMENT(properties_element))
     MapSelectboxGadget(ED_SELECTBOX_ID_WIND_DIRECTION);
@@ -11769,8 +11787,8 @@ static void DrawArcExt(int from_x, int from_y, int to_x2, int to_y2,
 
   radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
 
-  /* not optimal (some points get drawn twice) but simple,
-     and fast enough for the few points we are drawing */
+  // not optimal (some points get drawn twice) but simple,
+  // and fast enough for the few points we are drawing
 
   for (x = 0; x <= radius; x++)
   {
@@ -13571,8 +13589,8 @@ static void HandleControlButtons(struct GadgetInfo *gi)
 
     case GADGET_ID_SAVE:
     {
-      /* saving read-only levels into personal level set modifies global vars
-        "leveldir_current" and "level_nr"; restore them after saving level */
+      // saving read-only levels into personal level set modifies global vars
+      // "leveldir_current" and "level_nr"; restore them after saving level
       LevelDirTree *leveldir_former = leveldir_current;
       int level_nr_former = level_nr;
       char *level_filename;