rnd-20020904-2-src
authorHolger Schemel <info@artsoft.org>
Wed, 4 Sep 2002 00:44:51 +0000 (02:44 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:38:15 +0000 (10:38 +0200)
src/conftime.h
src/init.c
src/libgame/image.c
src/libgame/image.h
src/main.c
src/main.h

index d5ca41392a79b47b08f10264b2c5ded539ea63c6..943ff27aa5413c7ea15298c70c71c7fe3da7e1b7 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2002-09-04 00:47]"
+#define COMPILE_DATE_STRING "[2002-09-04 02:07]"
index 53066410638a70567b0d43e9615353c4291bd3ef..183ba2b9a45862ff63d71ee25ca8666d2c405036 100644 (file)
@@ -46,7 +46,7 @@ static void InitLevelInfo(void);
 static void InitArtworkInfo(void);
 static void InitLevelArtworkInfo(void);
 static void InitNetworkServer(void);
-static void InitImageConfig();
+static void InitImages(void);
 static void InitMixer(void);
 static void InitSound(void);
 static void InitGfx(void);
@@ -87,7 +87,6 @@ void OpenAll(void)
   InitArtworkInfo();           /* needed before loading gfx, sound & music */
 
   InitCounter();
-  InitImageConfig();
   InitMixer();
   InitJoysticks();
   InitRND(NEW_RANDOMIZE);
@@ -106,6 +105,7 @@ void OpenAll(void)
   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();
@@ -174,9 +174,12 @@ void InitNetworkServer()
 #endif
 }
 
-static void InitImageConfig()
+static void InitImages()
 {
   InitImageList(image_config, NUM_IMAGE_CONFIG_ENTRIES);
+
+  /* load custom images */
+  ReloadCustomImages();
 }
 
 static void InitMixer()
@@ -274,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++)
   {
@@ -294,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++)
@@ -494,6 +496,8 @@ void ReloadCustomArtwork()
       ReloadCustomImage(pix[i], image_filename[i]);
     }
 
+    ReloadCustomImages();
+
     FreeTileClipmasks();
     InitTileClipmasks();
     InitGfxBackground();
@@ -2061,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"));
@@ -2092,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)
index 13cfce001e50e03caf5a01eee2241bbfccc4b9b5..73e077340e9a35429480a570692146b5a2be0127 100644 (file)
@@ -649,18 +649,74 @@ struct ImageInfo
 {
   char *source_filename;
   int num_references;
+
+  Bitmap *bitmap;
 };
 typedef struct ImageInfo ImageInfo;
 
-static ImageInfo **ImageList = NULL;
-static struct ArtworkConfigInfo *image_config = NULL;
-static int num_images = 0;
+static struct ArtworkListInfo *image_info = NULL;
+
+static void *Load_PCX(char *filename)
+{
+  ImageInfo *img_info;
+
+#if 0
+  printf("loading PCX file '%s'\n", filename);
+#endif
+
+  img_info = checked_calloc(sizeof(ImageInfo));
+
+  if ((img_info->bitmap = LoadImage(filename)) == NULL)
+  {
+    Error(ERR_WARN, "cannot read image file '%s': LoadImage() failed: %s",
+         filename, GetError());
+    free(img_info);
+    return NULL;
+  }
+
+  img_info->source_filename = getStringCopy(filename);
+
+  return img_info;
+}
+
+static void FreeImage(void *ptr)
+{
+  ImageInfo *image = (ImageInfo *)ptr;
+
+  if (image == NULL)
+    return;
+
+  if (image->bitmap)
+    FreeBitmap(image->bitmap);
+
+  if (image->source_filename)
+    free(image->source_filename);
+
+  free(image);
+}
 
 void InitImageList(struct ArtworkConfigInfo *config_list, int num_list_entries)
 {
-  if (ImageList == NULL)
-    ImageList = checked_calloc(num_list_entries * sizeof(ImageInfo *));
+  if (image_info == NULL)
+    image_info = checked_calloc(sizeof(struct ArtworkListInfo));
+
+  if (image_info->artwork_list == NULL)
+    image_info->artwork_list =
+      checked_calloc(num_list_entries * sizeof(ImageInfo *));
+
+  image_info->type = ARTWORK_TYPE_GRAPHICS;
+  image_info->num_list_entries = num_list_entries;
+  image_info->config_list = config_list;
+  image_info->file_list = NULL;
+  image_info->load_artwork = Load_PCX;
+  image_info->free_artwork = FreeImage;
+}
+
+void ReloadCustomImages()
+{
+#if 0
+  printf("DEBUG: reloading images '%s' ...\n", artwork.gfx_current_identifier);
+#endif
 
-  image_config = config_list;
-  num_images = num_list_entries;
+  ReloadCustomArtworkList(image_info);
 }
index 7900bd81d1ff83327e26a4ff81ba37f1d6de5729..8f998fba4e262c9161a27d65d005e2433d69610e 100644 (file)
@@ -73,5 +73,6 @@ int Read_PCX_to_Pixmap(Display *, Window, GC, char *, Pixmap *, Pixmap *);
 
 
 void InitImageList(struct ArtworkConfigInfo *, int);
+void ReloadCustomImages();
 
 #endif /* IMAGE_H */
index 51fa055d2aeaea7ed6755ed0c0665c6d45d14351..4cec054e76c2479219cbf577749e30ebbd9dfd37 100644 (file)
@@ -139,24 +139,7 @@ char *sound_name[NUM_SOUNDS] =
 struct ArtworkConfigInfo image_config[] =
 {
   /* graphics for Boulder Dash style elements and actions */
-  { "bd_empty_space.digging",          "empty.pcx"             },
-  { "bd_sand.digging",                 "schlurf.pcx"           },
-  { "bd_diamond.collecting",           "pong.pcx"              },
-  { "bd_diamond.impact",               "pling.pcx"             },
-  { "bd_rock.pushing",                 "pusch.pcx"             },
-  { "bd_rock.impact",                  "klopf.pcx"             },
-  { "bd_magic_wall.activating",                "quirk.pcx"             },
-  { "bd_magic_wall.changing",          "quirk.pcx"             },
-  { "bd_magic_wall.running",           "miep.pcx"              },
-  { "bd_amoeba.waiting",               "amoebe.pcx"            },
-  { "bd_amoeba.creating",              "amoebe.pcx"            },
-  { "bd_amoeba.turning_to_gem",                "pling.pcx"             },
-  { "bd_amoeba.turning_to_rock",       "klopf.pcx"             },
-  { "bd_butterfly.moving",             "klapper.pcx"           },
-  { "bd_butterfly.waiting",            "klapper.pcx"           },
-  { "bd_firefly.moving",               "roehr.pcx"             },
-  { "bd_firefly.waiting",              "roehr.pcx"             },
-  { "bd_exit.entering",                        "buing.pcx"             },
+  { "bd_diamond.waiting",              "bd_diamond.pcx"        },
 };
 
 struct ArtworkConfigInfo sound_config[] =
index fb8d277c198c8a4357f6d2c7fbc628570c7378ea..ba480f4214e5b91ee67b49f74748d309bb0ff0ac 100644 (file)
@@ -1459,26 +1459,9 @@ extern struct ArtworkConfigInfo  image_config[], sound_config[];
 
 
 /* values for image configuration */
-#define GFX_BD_EMPTY_SPACE_DIGGING             0
-#define GFX_BD_SAND_DIGGING                    1
-#define GFX_BD_DIAMOND_COLLECTING              2
-#define GFX_BD_DIAMOND_IMPACT                  3
-#define GFX_BD_ROCK_PUSHING                    4
-#define GFX_BD_ROCK_IMPACT                     5
-#define GFX_BD_MAGIC_WALL_ACTIVATING           6
-#define GFX_BD_MAGIC_WALL_CHANGING             7
-#define GFX_BD_MAGIC_WALL_RUNNING              8
-#define GFX_BD_AMOEBA_WAITING                  9
-#define GFX_BD_AMOEBA_CREATING                 10
-#define GFX_BD_AMOEBA_TURNING_TO_GEM           11
-#define GFX_BD_AMOEBA_TURNING_TO_ROCK          12
-#define GFX_BD_BUTTERFLY_MOVING                        13
-#define GFX_BD_BUTTERFLY_WAITING               14
-#define GFX_BD_FIREFLY_MOVING                  15
-#define GFX_BD_FIREFLY_WAITING                 16
-#define GFX_BD_EXIT_ENTERING                   17
-
-#define NUM_IMAGE_CONFIG_ENTRIES               18
+#define GFX_BD_DIAMOND_WAITING                 0
+
+#define NUM_IMAGE_CONFIG_ENTRIES               1
 
 
 /* values for sound configuration */