rnd-20030201-2-src
authorHolger Schemel <info@artsoft.org>
Sat, 1 Feb 2003 00:56:48 +0000 (01:56 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:40:10 +0000 (10:40 +0200)
src/conftime.h
src/editor.c
src/libgame/gadgets.c
src/main.h

index 0c8b51e32bf49768e331d6dcf57584ce0fa34c7d..89a8cef393306ab0a68bb401ba105e06b09a1bb3 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2003-02-01 00:10]"
+#define COMPILE_DATE_STRING "[2003-02-01 01:43]"
index 540b409238738ca0522c740d22abe555a16424ba..15a3b692ddc8b9464bdf84bf3417a1f9ec8b0385 100644 (file)
 #define GADGET_ID_ELEM_CONTENT_6       56
 #define GADGET_ID_ELEM_CONTENT_7       57
 #define GADGET_ID_AMOEBA_CONTENT       58
+#define GADGET_ID_RANDOM_BACKGROUND    59
 
 /* text input identifiers */
-#define GADGET_ID_LEVEL_NAME           59
-#define GADGET_ID_LEVEL_AUTHOR         60
+#define GADGET_ID_LEVEL_NAME           60
+#define GADGET_ID_LEVEL_AUTHOR         61
 
 /* gadgets for scrolling of drawing area */
-#define GADGET_ID_SCROLL_UP            61
-#define GADGET_ID_SCROLL_DOWN          62
-#define GADGET_ID_SCROLL_LEFT          63
-#define GADGET_ID_SCROLL_RIGHT         64
-#define GADGET_ID_SCROLL_HORIZONTAL    65
-#define GADGET_ID_SCROLL_VERTICAL      66
+#define GADGET_ID_SCROLL_UP            62
+#define GADGET_ID_SCROLL_DOWN          63
+#define GADGET_ID_SCROLL_LEFT          64
+#define GADGET_ID_SCROLL_RIGHT         65
+#define GADGET_ID_SCROLL_HORIZONTAL    66
+#define GADGET_ID_SCROLL_VERTICAL      67
 
 /* gadgets for scrolling element list */
-#define GADGET_ID_SCROLL_LIST_UP       67
-#define GADGET_ID_SCROLL_LIST_DOWN     68
-#define GADGET_ID_SCROLL_LIST_VERTICAL 69
-
-/* buttons for level settings */
-#define GADGET_ID_RANDOM_PERCENTAGE    70
-#define GADGET_ID_RANDOM_QUANTITY      71
-#define GADGET_ID_RANDOM_RESTRICTED    72
-#define GADGET_ID_DOUBLE_SPEED         73
-#define GADGET_ID_GRAVITY              74
-#define GADGET_ID_STICK_ELEMENT                75
-#define GADGET_ID_EM_SLIPPERY_GEMS     76
-
-/* another drawing area for random placement */
-#define GADGET_ID_RANDOM_BACKGROUND    77
+#define GADGET_ID_SCROLL_LIST_UP       68
+#define GADGET_ID_SCROLL_LIST_DOWN     69
+#define GADGET_ID_SCROLL_LIST_VERTICAL 70
+
+/* buttons for level/element properties */
+#define GADGET_ID_RANDOM_PERCENTAGE    71
+#define GADGET_ID_RANDOM_QUANTITY      72
+#define GADGET_ID_RANDOM_RESTRICTED    73
+#define GADGET_ID_DOUBLE_SPEED         74
+#define GADGET_ID_GRAVITY              75
+#define GADGET_ID_STICK_ELEMENT                76
+#define GADGET_ID_EM_SLIPPERY_GEMS     77
+#define GADGET_ID_CUSTOM_INDESTRUCTIBLE        78
+#define GADGET_ID_CUSTOM_CAN_FALL      79
+#define GADGET_ID_CUSTOM_SLIPPERY      80
 
 /* gadgets for buttons in element list */
-#define GADGET_ID_ELEMENTLIST_FIRST    78
-#define GADGET_ID_ELEMENTLIST_LAST     (78 + ED_NUM_ELEMENTLIST_BUTTONS - 1)
+#define GADGET_ID_ELEMENTLIST_FIRST    81
+#define GADGET_ID_ELEMENTLIST_LAST     (81 + ED_NUM_ELEMENTLIST_BUTTONS - 1)
 
 #define NUM_EDITOR_GADGETS             (GADGET_ID_ELEMENTLIST_LAST + 1)
 
 #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED    2
 #define ED_CHECKBUTTON_ID_STICK_ELEMENT                3
 #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS     4
+#define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE        5
+#define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL      6
+#define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY      7
 
-#define ED_NUM_CHECKBUTTONS                    5
+#define ED_NUM_CHECKBUTTONS                    8
 
 #define ED_CHECKBUTTON_ID_LEVEL_FIRST  ED_CHECKBUTTON_ID_DOUBLE_SPEED
 #define ED_CHECKBUTTON_ID_LEVEL_LAST   ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
@@ -424,6 +428,13 @@ static int random_placement_background_element = EL_SAND;
 static boolean random_placement_background_restricted = FALSE;
 static boolean stick_element_properties_window = FALSE;
 
+static struct
+{
+  boolean indestructible;
+  boolean can_fall;
+  boolean slippery;
+} custom_element_properties[NUM_CUSTOM_ELEMENTS];
+
 static struct
 {
   int x, y;
@@ -678,6 +689,24 @@ static struct
     GADGET_ID_EM_SLIPPERY_GEMS,
     &level.em_slippery_gems,
     "slip down from certain flat walls","use EM style slipping behaviour"
+  },
+  {
+    ED_SETTINGS_XPOS,                  ED_COUNTER_YPOS(4),
+    GADGET_ID_CUSTOM_INDESTRUCTIBLE,
+    &custom_element_properties[0].indestructible,
+    "indestructible",                  "element cannot be destroyed"
+  },
+  {
+    ED_SETTINGS_XPOS,                  ED_COUNTER_YPOS(5),
+    GADGET_ID_CUSTOM_CAN_FALL,
+    &custom_element_properties[0].can_fall,
+    "can fall",                                "element can fall down"
+  },
+  {
+    ED_SETTINGS_XPOS,                  ED_COUNTER_YPOS(6),
+    GADGET_ID_CUSTOM_SLIPPERY,
+    &custom_element_properties[0].slippery,
+    "slippery",                                "other elements can fall down from it"
   }
 };
 
@@ -3030,6 +3059,47 @@ static void DrawPropertiesWindow()
                 GDI_CHECKED, *checkbutton_info[i].value, GDI_END);
     MapCheckbuttonGadget(i);
   }
+
+  if (IS_CUSTOM_ELEMENT(properties_element))
+  {
+    int nr = properties_element - EL_CUSTOM_START;
+
+    /* draw checkbutton gadget */
+    i = ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE;
+    x = checkbutton_info[i].x + xoffset_right2;
+    y = checkbutton_info[i].y + yoffset_right2;
+
+    checkbutton_info[i].value = &custom_element_properties[nr].indestructible;
+
+    DrawTextF(x, y, font_color, checkbutton_info[i].text);
+    ModifyGadget(level_editor_gadget[checkbutton_info[i].gadget_id],
+                GDI_CHECKED, *checkbutton_info[i].value, GDI_END);
+    MapCheckbuttonGadget(i);
+
+    /* draw checkbutton gadget */
+    i = ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL;
+    x = checkbutton_info[i].x + xoffset_right2;
+    y = checkbutton_info[i].y + yoffset_right2;
+
+    checkbutton_info[i].value = &custom_element_properties[nr].can_fall;
+
+    DrawTextF(x, y, font_color, checkbutton_info[i].text);
+    ModifyGadget(level_editor_gadget[checkbutton_info[i].gadget_id],
+                GDI_CHECKED, *checkbutton_info[i].value, GDI_END);
+    MapCheckbuttonGadget(i);
+
+    /* draw checkbutton gadget */
+    i = ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY;
+    x = checkbutton_info[i].x + xoffset_right2;
+    y = checkbutton_info[i].y + yoffset_right2;
+
+    checkbutton_info[i].value = &custom_element_properties[nr].slippery;
+
+    DrawTextF(x, y, font_color, checkbutton_info[i].text);
+    ModifyGadget(level_editor_gadget[checkbutton_info[i].gadget_id],
+                GDI_CHECKED, *checkbutton_info[i].value, GDI_END);
+    MapCheckbuttonGadget(i);
+  }
 }
 
 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
@@ -4209,6 +4279,30 @@ static void HandleControlButtons(struct GadgetInfo *gi)
          for(y=0; y<lev_fieldy; y++)
            Ur[x][y] = Feld[x][y];
 
+       /* !!! ---------- ---------- ---------- ---------- ---------- */
+
+       for (i=0; i < NUM_CUSTOM_ELEMENTS; i++)
+       {
+         int element = EL_CUSTOM_START + i;
+
+         if (custom_element_properties[i].indestructible)
+           Properties1[element] |= EP_BIT_MASSIVE;
+         else
+           Properties1[element] &= ~EP_BIT_MASSIVE;
+
+         if (custom_element_properties[i].can_fall)
+           Properties1[element] |= EP_BIT_CAN_FALL;
+         else
+           Properties1[element] &= ~EP_BIT_CAN_FALL;
+
+         if (custom_element_properties[i].slippery)
+           Properties1[element] |= EP_BIT_SLIPPERY;
+         else
+           Properties1[element] &= ~EP_BIT_SLIPPERY;
+       }
+
+       /* !!! ---------- ---------- ---------- ---------- ---------- */
+
        UnmapLevelEditorGadgets();
        UndrawSpecialEditorDoor();
 
index 2c06d4bda99a31cdae41f239b992092fc0981a92..a371bb473505a3f8eccfd5425d8e4a7c68d8e10c 100644 (file)
@@ -618,7 +618,7 @@ void FreeGadget(struct GadgetInfo *gi)
 {
   struct GadgetInfo *gi_previous = gadget_list_first_entry;
 
-  while (gi_previous && gi_previous->next != gi)
+  while (gi_previous != NULL && gi_previous->next != gi)
     gi_previous = gi_previous->next;
 
   if (gi == gadget_list_first_entry)
@@ -627,7 +627,7 @@ void FreeGadget(struct GadgetInfo *gi)
   if (gi == gadget_list_last_entry)
     gadget_list_last_entry = gi_previous;
 
-  if (gi_previous)
+  if (gi_previous != NULL)
     gi_previous->next = gi->next;
 
   free(gi);
index 31264e0345dbc73b994973a000ee2883729a853e..24bcc8469af2aee49f7eb4a4784fe9daa6c992b5 100644 (file)
 #define IS_TUBE(e)             (Properties2[e] & EP_BIT_TUBE)
 #define IS_EM_SLIPPERY_WALL(e) (Properties2[e] & EP_BIT_EM_SLIPPERY_WALL)
 
+#define IS_CUSTOM_ELEMENT(e)   ((e) >= EL_CUSTOM_START &&      \
+                                (e) <= EL_CUSTOM_END)
+
 #define IS_PLAYER(x,y)         (ELEM_IS_PLAYER(StorePlayer[x][y]))
 
 #define IS_FREE(x,y)           (Feld[x][y] == EL_EMPTY && !IS_PLAYER(x,y))
 #define EL_CUSTOM_128                  (EL_CUSTOM_START + 127)
 #define EL_CUSTOM_END                  (EL_CUSTOM_START + 127)
 
+#define NUM_CUSTOM_ELEMENTS            128
 #define NUM_FILE_ELEMENTS              488