rnd-20021211-1-src
[rocksndiamonds.git] / src / libgame / misc.c
index 811ef07e576484826ea0ebdc07889848cac8cbee..f6ea818788ea12d34855155862f717cae33209c7 100644 (file)
@@ -1536,9 +1536,29 @@ static void deleteArtworkListEntry(struct ArtworkListInfo *artwork_info,
 
 static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info,
                                    struct ListNodeInfo **listnode,
-                                   char *filename)
+                                   char *basename)
 {
+  char *init_text[] =
+  { "",
+    "Loading graphics:",
+    "Loading sounds:",
+    "Loading music:"
+  };
+
   ListNode *node;
+  char *filename = getCustomArtworkFilename(basename, artwork_info->type);
+
+  if (filename == NULL)
+  {
+    int error_mode = ERR_WARN;
+
+    /* we can get away without sounds and music, but not without graphics */
+    if (*listnode == NULL && artwork_info->type == ARTWORK_TYPE_GRAPHICS)
+      error_mode = ERR_EXIT;
+
+    Error(error_mode, "cannot find artwork file '%s'", basename);
+    return;
+  }
 
   /* check if the old and the new artwork file are the same */
   if (*listnode && strcmp((*listnode)->source_filename, filename) == 0)
@@ -1566,20 +1586,43 @@ static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info,
 
       *listnode = (struct ListNodeInfo *)node->content;
       (*listnode)->num_references++;
+
+      return;
   }
-  else if ((*listnode = artwork_info->load_artwork(filename)) != NULL)
+
+  DrawInitText(init_text[artwork_info->type], 120, FC_GREEN);
+  DrawInitText(basename, 150, FC_YELLOW);
+
+  if ((*listnode = artwork_info->load_artwork(filename)) != NULL)
   {
+#if 0
+      printf("[adding new artwork '%s']\n", filename);
+#endif
+
     (*listnode)->num_references = 1;
     addNodeToList(&artwork_info->content_list, (*listnode)->source_filename,
                  *listnode);
   }
+  else
+  {
+    int error_mode = ERR_WARN;
+
+    /* we can get away without sounds and music, but not without graphics */
+    if (artwork_info->type == ARTWORK_TYPE_GRAPHICS)
+      error_mode = ERR_EXIT;
+
+    Error(error_mode, "cannot load artwork file '%s'", basename);
+    return;
+  }
 }
 
 static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info,
                              struct ListNodeInfo **listnode,
                              char *basename)
 {
+#if 0
   char *filename = getCustomArtworkFilename(basename, artwork_info->type);
+#endif
 
 #if 0
   printf("GOT CUSTOM ARTWORK FILE '%s'\n", filename);
@@ -1591,6 +1634,7 @@ static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info,
     return;
   }
 
+#if 0
   if (filename == NULL)
   {
     Error(ERR_WARN, "cannot find artwork file '%s'", basename);
@@ -1598,6 +1642,9 @@ static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info,
   }
 
   replaceArtworkListEntry(artwork_info, listnode, filename);
+#else
+  replaceArtworkListEntry(artwork_info, listnode, basename);
+#endif
 }
 
 static void LoadArtworkToList(struct ArtworkListInfo *artwork_info,
@@ -1623,6 +1670,7 @@ static void LoadArtworkToList(struct ArtworkListInfo *artwork_info,
 
 void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info)
 {
+#if 0
   static struct
   {
     char *text;
@@ -1635,6 +1683,7 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info)
     { "Loading sounds:",       TRUE },
     { "Loading music:",                TRUE }
   };
+#endif
 
   int num_file_list_entries = artwork_info->num_file_list_entries;
   struct FileInfo *file_list = artwork_info->file_list;
@@ -1642,8 +1691,10 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info)
 
   LoadArtworkConfig(artwork_info);
 
+#if 0
   if (draw_init[artwork_info->type].do_it)
     DrawInitText(draw_init[artwork_info->type].text, 120, FC_GREEN);
+#endif
 
 #if 0
   printf("DEBUG: reloading %d artwork files ...\n", num_file_list_entries);
@@ -1651,13 +1702,21 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info)
 
   for(i=0; i<num_file_list_entries; i++)
   {
+#if 0
     if (draw_init[artwork_info->type].do_it)
       DrawInitText(file_list[i].token, 150, FC_YELLOW);
+#endif
 
     LoadArtworkToList(artwork_info, file_list[i].filename, i);
+
+#if 0
+    printf("DEBUG:   loading artwork file '%s'...\n", file_list[i].filename);
+#endif
   }
 
+#if 0
   draw_init[artwork_info->type].do_it = FALSE;
+#endif
 
   /*
   printf("list size == %d\n", getNumNodes(artwork_info->content_list));