rnd-20030215-1-src
[rocksndiamonds.git] / src / init.c
index 60f6febb1d948eb5f7b8e2b1955ece08dfeac1e0..862365fa1259bf46ec62d09a9f8971d969efd2fe 100644 (file)
@@ -167,6 +167,14 @@ static void InitArtworkConfig()
   static char *direction_suffix[NUM_DIRECTIONS + 1];
   static char *special_suffix[NUM_SPECIAL_GFX_ARGS + 1];
   static char *dummy[1] = { NULL };
+  static char *ignore_image_tokens[] =
+  {
+    "name",
+    "sort_priority",
+    "menu.main.hide_static_text",
+    "global.num_toons",
+    NULL
+  };
   int i;
 
   for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
@@ -181,9 +189,10 @@ 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);
+               sound_class_prefix, action_suffix, dummy, dummy, dummy);
 }
 
 void InitLevelArtworkInfo()
@@ -257,10 +266,11 @@ static void ReinitializeMusic()
 static void InitImages()
 {
   ReloadCustomImages();
-  ReinitializeGraphics();
 
   LoadCustomElementDescriptions();
   LoadSpecialMenuDesignSettings();
+
+  ReinitializeGraphics();
 }
 
 static void InitSound()
@@ -585,11 +595,7 @@ void ReloadCustomArtwork()
 
     ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
 
-    ReloadCustomImages();
-    ReinitializeGraphics();
-
-    LoadCustomElementDescriptions();
-    LoadSpecialMenuDesignSettings();
+    InitImages();
 
     FreeTileClipmasks();
     InitTileClipmasks();
@@ -796,7 +802,7 @@ void InitElementGraphicInfo()
     }
   }
 
-#if 1
+#if 0
 #if DEBUG
   if (options.verbose)
   {
@@ -855,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);
@@ -976,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;
@@ -1104,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
@@ -1112,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)
@@ -1134,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;
@@ -1199,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 */
   {
@@ -1211,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++;
     }
   }