rnd-20020611-1-src
authorHolger Schemel <info@artsoft.org>
Tue, 11 Jun 2002 08:52:37 +0000 (10:52 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:37:58 +0000 (10:37 +0200)
src/init.c
src/libgame/setup.c
src/libgame/system.h
src/screens.c
src/timestamp.h

index f89f107d8eefb2b59b8081af3bf195dafd3cb2db..4da3ddb1366698fa4530b86d139e6bf3a152af72 100644 (file)
@@ -411,19 +411,29 @@ void InitGfxBackground()
 
 void ReloadCustomArtwork()
 {
-  static char *leveldir_current_name = NULL;
+  static char *leveldir_current_filename = NULL;
   static boolean last_override_level_graphics = FALSE;
   static boolean last_override_level_sounds = FALSE;
   static boolean last_override_level_music = FALSE;
 
-  if (leveldir_current_name != leveldir_current->name)
+  if (leveldir_current_filename != leveldir_current->filename)
   {
-    /* force reload of custom artwork after new level series was selected */
-    artwork.graphics_set_current_name = NULL;
-    artwork.sounds_set_current_name = NULL;
-    artwork.music_set_current_name = NULL;
-
-    leveldir_current_name = leveldir_current->name;
+    char *filename_old = leveldir_current_filename;
+    char *filename_new = leveldir_current->filename;
+
+    /* force reload of custom artwork after new level series was selected,
+       but reload only that part of the artwork that really has changed */
+    if (getTreeInfoFromFilename(artwork.gfx_first, filename_old) !=
+       getTreeInfoFromFilename(artwork.gfx_first, filename_new))
+      artwork.graphics_set_current_name = NULL;
+    if (getTreeInfoFromFilename(artwork.snd_first, filename_old) !=
+       getTreeInfoFromFilename(artwork.snd_first, filename_new))
+      artwork.sounds_set_current_name = NULL;
+    if (getTreeInfoFromFilename(artwork.mus_first, filename_new) !=
+       getTreeInfoFromFilename(artwork.mus_first, filename_new))
+      artwork.music_set_current_name = NULL;
+
+    leveldir_current_filename = leveldir_current->filename;
   }
 
   if (artwork.graphics_set_current_name != artwork.gfx_current->name ||
@@ -443,7 +453,9 @@ void ReloadCustomArtwork()
     InitTileClipmasks();
     InitGfxBackground();
 
-    SetDoorState(DOOR_OPEN_1 | DOOR_CLOSE_2);
+    /* force redraw of (open or closed) door graphics */
+    SetDoorState(DOOR_OPEN_ALL);
+    CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
 
     artwork.graphics_set_current_name = artwork.gfx_current->name;
     last_override_level_graphics = setup.override_level_graphics;
index f6688b1ddf71d0b6fa3536f7ca48e09fea146a73..6c49cac933aeff7402e042bb24677325ee9f1357 100644 (file)
@@ -553,13 +553,9 @@ boolean validLevelSeries(TreeInfo *node)
 TreeInfo *getFirstValidTreeInfoEntry(TreeInfo *node)
 {
   if (node == NULL)
-  {
-    if (node->node_top)                /* start with first tree entry */
-      return getFirstValidTreeInfoEntry(*node->node_top);
-    else
-      return NULL;
-  }
-  else if (node->node_group)   /* enter level group (step down into tree) */
+    return NULL;
+
+  if (node->node_group)                /* enter level group (step down into tree) */
     return getFirstValidTreeInfoEntry(node->node_group);
   else if (node->parent_link)  /* skip start entry of level group */
   {
@@ -642,6 +638,12 @@ TreeInfo *getTreeInfoFromFilenameExt(TreeInfo *node, char *filename)
     {
       if (strcmp(filename, node->filename) == 0)
        return node;
+
+      /* special case when looking for level series artwork:
+        node->name_short contains level series filename */
+      if (strcmp(node->filename, ".") == 0 &&
+         strcmp(filename, node->name_short) == 0)
+       return node;
     }
 
     node = node->next;
@@ -1631,7 +1633,9 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first,
       artwork_new->name = getStringCopy(artwork_new->filename);
     }
 
+#if 0
     DrawInitText(artwork_new->name, 150, FC_YELLOW);
+#endif
 
     if (artwork_new->name_short == NULL)
       artwork_new->name_short = getStringCopy(artwork_new->name);
@@ -1686,6 +1690,8 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first,
     artwork_new->name_sorting = getStringCopy(artwork_new->name);
   }
 
+  DrawInitText(artwork_new->name, 150, FC_YELLOW);
+
   pushTreeInfo(node_first, artwork_new);
 
   freeSetupFileList(setup_file_list);
@@ -1752,6 +1758,27 @@ static void LoadArtworkInfoFromArtworkDir(TreeInfo **node_first,
          base_directory);
 }
 
+static TreeInfo *getDummyArtworkInfo(int type)
+{
+  /* this is only needed when there is completely no artwork available */
+  TreeInfo *artwork_new = newTreeInfo();
+
+  setTreeInfoToDefaults(artwork_new, type);
+
+  artwork_new->filename = getStringCopy(NOT_AVAILABLE);
+  artwork_new->fullpath = getStringCopy(NOT_AVAILABLE);
+  artwork_new->basepath = getStringCopy(NOT_AVAILABLE);
+
+  if (artwork_new->name != NULL)
+    free(artwork_new->name);
+
+  artwork_new->name         = getStringCopy(NOT_AVAILABLE);
+  artwork_new->name_short   = getStringCopy(NOT_AVAILABLE);
+  artwork_new->name_sorting = getStringCopy(NOT_AVAILABLE);
+
+  return artwork_new;
+}
+
 void LoadArtworkInfo()
 {
   DrawInitText("Looking for custom artwork:", 120, FC_GREEN);
@@ -1777,6 +1804,13 @@ void LoadArtworkInfo()
                                getUserMusicDir(),
                                TREE_TYPE_MUSIC_DIR);
 
+  if (artwork.gfx_first == NULL)
+    artwork.gfx_first = getDummyArtworkInfo(TREE_TYPE_GRAPHICS_DIR);
+  if (artwork.snd_first == NULL)
+    artwork.snd_first = getDummyArtworkInfo(TREE_TYPE_SOUNDS_DIR);
+  if (artwork.mus_first == NULL)
+    artwork.mus_first = getDummyArtworkInfo(TREE_TYPE_MUSIC_DIR);
+
   /* before sorting, the first entries will be from the user directory */
   artwork.gfx_current =
     getTreeInfoFromFilename(artwork.gfx_first, setup.graphics_set);
@@ -1786,12 +1820,12 @@ void LoadArtworkInfo()
   artwork.snd_current =
     getTreeInfoFromFilename(artwork.snd_first, setup.sounds_set);
   if (artwork.snd_current == NULL)
-  artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first);
+    artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first);
 
   artwork.mus_current =
     getTreeInfoFromFilename(artwork.mus_first, setup.music_set);
   if (artwork.mus_current == NULL)
-  artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first);
+    artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first);
 
   artwork.graphics_set_current_name = artwork.gfx_current->name;
   artwork.sounds_set_current_name = artwork.snd_current->name;
index 1ade3147a3705ae787d2fca34cdb78b71982a5b3..6fe5f12f7d19ea40f63183bbf316ad289b4c0f68 100644 (file)
 /* default name for unknown player names */
 #define ANONYMOUS_NAME         "anonymous"
 
+/* default text for non-existant artwork */
+#define NOT_AVAILABLE          "(not available)"
+
 /* default name for new levels */
 #define NAMELESS_LEVEL_NAME    "nameless level"
 
index a04d75dc3e6b204e7538d9c384ccd323ea8a62fe..de9c097383a4626dd85ce693d189903dd4b81e0f 100644 (file)
@@ -155,7 +155,7 @@ void DrawMainMenu()
   /* needed if last screen was the setup screen and fullscreen state changed */
   ToggleFullscreenIfNeeded();
 
-  /* needed if last screen (setup/level) changed graphics, sounds or music */
+  /* needed if last screen (level choice) changed graphics, sounds or music */
   ReloadCustomArtwork();
 
 #ifdef TARGET_SDL
@@ -1370,23 +1370,25 @@ static void execSetupGame()
 
 static void execSetupGraphics()
 {
-  setup.graphics_set = artwork.gfx_current->name;
-
   setup_mode = SETUP_MODE_GRAPHICS;
   DrawSetupScreen();
 }
 
 static void execSetupSound()
 {
-  setup.sounds_set = artwork.snd_current->name;
-  setup.music_set = artwork.mus_current->name;
-
   setup_mode = SETUP_MODE_SOUND;
   DrawSetupScreen();
 }
 
 static void execSetupArtwork()
 {
+  /* needed if last screen (setup choice) changed graphics, sounds or music */
+  ReloadCustomArtwork();
+
+  setup.graphics_set = artwork.gfx_current->name;
+  setup.sounds_set = artwork.snd_current->name;
+  setup.music_set = artwork.mus_current->name;
+
   setup_mode = SETUP_MODE_ARTWORK;
   DrawSetupScreen();
 }
@@ -1661,7 +1663,7 @@ static void DrawSetupScreen_Generic()
   else if (setup_mode == SETUP_MODE_ARTWORK)
   {
     setup_info = setup_info_artwork;
-    title_string = "Setup Sound";
+    title_string = "Custom Artwork";
   }
   else if (setup_mode == SETUP_MODE_SHORTCUT)
   {
index 76ab4cc97aa33b42b1eec66aa2f4a1ce682ccda8..1c0e46dea77f3674afd55e48c06f84e8755f4c0e 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2002-06-10 01:52]"
+#define COMPILE_DATE_STRING "[2002-06-11 01:11]"