rnd-20020904-2-src
[rocksndiamonds.git] / src / init.c
index a06bd295bd99e5e53e82f37004be90b32498624e..183ba2b9a45862ff63d71ee25ca8666d2c405036 100644 (file)
@@ -46,13 +46,15 @@ static void InitLevelInfo(void);
 static void InitArtworkInfo(void);
 static void InitLevelArtworkInfo(void);
 static void InitNetworkServer(void);
+static void InitImages(void);
 static void InitMixer(void);
 static void InitSound(void);
 static void InitGfx(void);
 static void InitGfxBackground(void);
 static void InitGadgets(void);
-static void InitElementInfo(void);
 static void InitElementProperties(void);
+static void InitElementInfo(void);
+static void InitGraphicInfo(void);
 static void Execute_Debug_Command(char *);
 
 void OpenAll(void)
@@ -96,12 +98,14 @@ void OpenAll(void)
   InitEventFilter(FilterMouseMotionEvents);
 
   InitGfx();
-  InitElementInfo();
   InitElementProperties();     /* initializes IS_CHAR() for el2gfx() */
+  InitElementInfo();
+  InitGraphicInfo();
 
   InitLevelInfo();
   InitLevelArtworkInfo();
   InitGadgets();               /* needs to know number of level series */
+  InitImages();                        /* needs to know current level directory */
   InitSound();                 /* needs to know current level directory */
 
   InitGfxBackground();
@@ -170,10 +174,18 @@ void InitNetworkServer()
 #endif
 }
 
+static void InitImages()
+{
+  InitImageList(image_config, NUM_IMAGE_CONFIG_ENTRIES);
+
+  /* load custom images */
+  ReloadCustomImages();
+}
+
 static void InitMixer()
 {
   OpenAudio();
-  InitSoundList(sound_effects, NUM_SOUND_EFFECTS);
+  InitSoundList(sound_config, NUM_SOUND_CONFIG_ENTRIES);
 
   StartMixer();
 }
@@ -265,8 +277,8 @@ static void InitTileClipmasks()
 
   clip_gc_values.graphics_exposures = False;
   clip_gc_valuemask = GCGraphicsExposures;
-  tile_clip_gc =
-    XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
+  tile_clip_gc = XCreateGC(display, window->drawable,
+                          clip_gc_valuemask, &clip_gc_values);
 
   for(i=0; i<NUM_BITMAPS; i++)
   {
@@ -285,9 +297,8 @@ static void InitTileClipmasks()
   /* create graphic context structures needed for clipping */
   clip_gc_values.graphics_exposures = False;
   clip_gc_valuemask = GCGraphicsExposures;
-  copy_clipmask_gc =
-    XCreateGC(display, pix[PIX_BACK]->clip_mask,
-             clip_gc_valuemask, &clip_gc_values);
+  copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
+                              clip_gc_valuemask, &clip_gc_values);
 
   /* create only those clipping Pixmaps we really need */
   for(i=0; tile_needs_clipping[i].start>=0; i++)
@@ -485,6 +496,8 @@ void ReloadCustomArtwork()
       ReloadCustomImage(pix[i], image_filename[i]);
     }
 
+    ReloadCustomImages();
+
     FreeTileClipmasks();
     InitTileClipmasks();
     InitGfxBackground();
@@ -2052,17 +2065,26 @@ void Execute_Debug_Command(char *command)
 {
   if (strcmp(command, "create graphicsinfo.conf") == 0)
   {
-    printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
+    int i;
+
+    printf("# You can configure additional/alternative image files here.\n");
+    printf("# (The images below are default and therefore commented out.)\n");
     printf("\n");
     printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
     printf("\n");
     printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
+    printf("\n");
+
+    for (i=0; i<NUM_IMAGE_CONFIG_ENTRIES; i++)
+      printf("# %s\n",
+            getFormattedSetupEntry(image_config[i].token,
+                                   image_config[i].default_filename));
   }
   else if (strcmp(command, "create soundsinfo.conf") == 0)
   {
     int i;
 
-    printf("# You can configure additional/alternative sound effects here\n");
+    printf("# You can configure additional/alternative sound files here.\n");
     printf("# (The sounds below are default and therefore commented out.)\n");
     printf("\n");
     printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
@@ -2070,10 +2092,10 @@ void Execute_Debug_Command(char *command)
     printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
     printf("\n");
 
-    for (i=0; i<NUM_SOUND_EFFECTS; i++)
+    for (i=0; i<NUM_SOUND_CONFIG_ENTRIES; i++)
       printf("# %s\n",
-            getFormattedSetupEntry(sound_effects[i].text,
-                                   sound_effects[i].default_filename));
+            getFormattedSetupEntry(sound_config[i].token,
+                                   sound_config[i].default_filename));
   }
   else if (strcmp(command, "create musicinfo.conf") == 0)
   {
@@ -2083,6 +2105,13 @@ void Execute_Debug_Command(char *command)
     printf("\n");
     printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
   }
+  else if (strcmp(command, "help") == 0)
+  {
+    printf("The following commands are recognized:\n");
+    printf("   \"create graphicsinfo.conf\"\n");
+    printf("   \"create soundsinfo.conf\"\n");
+    printf("   \"create musicinfo.conf\"\n");
+  }
 }
 
 void CloseAllAndExit(int exit_value)