rnd-20030215-1-src
[rocksndiamonds.git] / src / init.c
index 3d3a02cc286c95d245c24b7217de926c1c46fdd4..862365fa1259bf46ec62d09a9f8971d969efd2fe 100644 (file)
@@ -189,7 +189,7 @@ static void InitArtworkConfig()
     special_suffix[i] = special_suffix_info[i].suffix;
 
   InitImageList(image_config, NUM_IMAGE_FILES, image_config_suffix,
-               element_prefix, action_suffix,direction_suffix, special_suffix,
+               element_prefix, action_suffix, direction_suffix,special_suffix,
                ignore_image_tokens);
   InitSoundList(sound_config, NUM_SOUND_FILES, sound_config_suffix,
                sound_class_prefix, action_suffix, dummy, dummy, dummy);
@@ -861,11 +861,6 @@ void InitElementSpecialGraphicInfo()
   }
 }
 
-static void InitElementSoundInfo()
-{
-  /* !!! soon to come !!! */
-}
-
 static void set_graphic_parameters(int graphic, char **parameter_raw)
 {
   Bitmap *src_bitmap = getBitmapFromImageID(graphic);
@@ -982,13 +977,14 @@ static void set_graphic_parameters(int graphic, char **parameter_raw)
 
 static void InitGraphicInfo()
 {
-  static boolean clipmasks_initialized = FALSE;
   int fallback_graphic = IMG_CHAR_EXCLAM;
   struct FileInfo *fallback_image = getImageListEntry(fallback_graphic);
   Bitmap *fallback_bitmap = getBitmapFromImageID(fallback_graphic);
   int num_images = getImageListSize();
   int i;
+
 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
+  static boolean clipmasks_initialized = FALSE;
   Pixmap src_pixmap;
   XGCValues clip_gc_values;
   unsigned long clip_gc_valuemask;
@@ -1110,6 +1106,7 @@ static void InitGraphicInfo()
     clip_gc_values.graphics_exposures = False;
     clip_gc_values.clip_mask = graphic_info[i].clip_mask;
     clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
+
     graphic_info[i].clip_gc =
       XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
 #endif
@@ -1118,9 +1115,14 @@ static void InitGraphicInfo()
 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
   if (copy_clipmask_gc)
     XFreeGC(display, copy_clipmask_gc);
-#endif
 
   clipmasks_initialized = TRUE;
+#endif
+}
+
+static void InitElementSoundInfo()
+{
+  /* !!! soon to come !!! */
 }
 
 static void set_sound_parameters(int sound, char **parameter_raw)
@@ -1140,6 +1142,8 @@ static void set_sound_parameters(int sound, char **parameter_raw)
 
 static void InitSoundInfo()
 {
+  struct PropertyMapping *property_mapping = getSoundListPropertyMapping();
+  int num_property_mappings = getSoundListPropertyMappingSize();
   int *sound_effect_properties;
   int num_sounds = getSoundListSize();
   int i, j;
@@ -1205,6 +1209,37 @@ static void InitSoundInfo()
 
   free(sound_effect_properties);
 
+  /* initialize element/sound mapping from dynamic configuration */
+  for (i=0; i < num_property_mappings; i++)
+  {
+    int element   = property_mapping[i].base_index;
+    int action    = property_mapping[i].ext1_index;
+    int sound     = property_mapping[i].artwork_index;
+
+    if (action < 0)
+      action = ACTION_DEFAULT;
+
+    element_info[element].sound[action] = sound;
+  }
+
+#if 0
+  /* TEST ONLY */
+  {
+    int element = EL_CUSTOM_11;
+    int j = 0;
+
+    while (element_action_info[j].suffix)
+    {
+      printf("element %d, sound action '%s'  == %d\n",
+            element, element_action_info[j].suffix,
+            element_info[element].sound[j]);
+      j++;
+    }
+  }
+
+  PlaySoundLevelElementAction(0,0, EL_CUSTOM_11, ACTION_PUSHING);
+#endif
+
 #if 0
   /* TEST ONLY */
   {
@@ -1217,7 +1252,7 @@ static void InitSoundInfo()
       if (element_action_info[j].value == sound_action)
        printf("element %d, sound action '%s'  == %d\n",
               element, element_action_info[j].suffix,
-              element_info_[element].sound[sound_action]);
+              element_info[element].sound[sound_action]);
       j++;
     }
   }