X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsetup.c;h=24e2471b723632f30eff5a570000d2c63973a6a8;hb=684f9040af5b97bc73676f8f8198688d87c3ea25;hp=165b8a2afad7a9078f9dcfa5e6b285bc64761fa2;hpb=2ff21518535f914abaacf8ffc72bfbd2f319dcd5;p=rocksndiamonds.git diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 165b8a2a..24e2471b 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -268,6 +268,16 @@ static char *getDefaultMusicDir(char *music_subdir) return music_dir; } +static char *getDefaultArtworkDir(int type) +{ + return (type == TREE_TYPE_GRAPHICS_DIR ? + getDefaultGraphicsDir(GRAPHICS_SUBDIR) : + type == TREE_TYPE_SOUNDS_DIR ? + getDefaultSoundsDir(SOUNDS_SUBDIR) : + type == TREE_TYPE_MUSIC_DIR ? + getDefaultMusicDir(MUSIC_SUBDIR) : ""); +} + static char *getUserGraphicsDir() { static char *usergraphics_dir = NULL; @@ -328,13 +338,29 @@ void setLevelArtworkDir(TreeInfo *ti) ti->type == TREE_TYPE_SOUNDS_DIR ? leveldir_current->sounds_set : leveldir_current->music_set); - if ((level_artwork = getTreeInfoFromIdentifier(ti, artwork_set)) == NULL) - return; - if (*artwork_path_ptr != NULL) free(*artwork_path_ptr); - *artwork_path_ptr = getStringCopy(getSetupArtworkDir(level_artwork)); + if ((level_artwork = getTreeInfoFromIdentifier(ti, artwork_set))) + *artwork_path_ptr = getStringCopy(getSetupArtworkDir(level_artwork)); + else + { + /* No (or non-existing) artwork configured in "levelinfo.conf". This would + normally result in using the artwork configured in the setup menu. But + if an artwork subdirectory exists (which might contain custom artwork + or an artwork configuration file), this level artwork must be treated + as relative to the default "classic" artwork, not to the artwork that + is currently configured in the setup menu. */ + + char *dir = getPath2(getCurrentLevelDir(), ARTWORK_DIRECTORY(ti->type)); + + if (fileExists(dir)) + *artwork_path_ptr = getStringCopy(getDefaultArtworkDir(ti->type)); + else + *artwork_path_ptr = getStringCopy(UNDEFINED_FILENAME); + + free(dir); + } } static char *getLevelArtworkDir(int type) @@ -453,34 +479,49 @@ char *getCustomImageFilename(char *basename) if (!setup.override_level_graphics) { +#if 0 /* 1st try: look for special artwork configured in level series config */ filename = getPath2(getLevelArtworkDir(TREE_TYPE_GRAPHICS_DIR), basename); -#if 1 +#if 0 if (strcmp(basename, "RocksScreen.pcx") == 0) - printf("::: check 1: filename '%s'\n", filename); + printf("::: trying 1 '%s' ...\n", filename); #endif if (fileExists(filename)) return filename; free(filename); +#endif /* 2nd try: look for special artwork in current level series directory */ filename = getPath3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename); +#if 0 + if (strcmp(basename, "RocksScreen.pcx") == 0) + printf("::: trying 2 '%s' ...\n", filename); +#endif + if (fileExists(filename)) + return filename; + + free(filename); + #if 1 + /* 1st try: look for special artwork configured in level series config */ + filename = getPath2(getLevelArtworkDir(TREE_TYPE_GRAPHICS_DIR), basename); +#if 0 if (strcmp(basename, "RocksScreen.pcx") == 0) - printf("::: check 2: filename '%s'\n", filename); + printf("::: trying 2.1 '%s' ...\n", filename); #endif if (fileExists(filename)) return filename; free(filename); +#endif } /* 3rd try: look for special artwork in configured artwork directory */ filename = getPath2(getSetupArtworkDir(artwork.gfx_current), basename); -#if 1 - if (strcmp(basename, "RocksScreen.pcx") == 0) - printf("::: check 3: filename '%s'\n", filename); +#if 0 + if (strcmp(basename, "RocksScreen.pcx") == 0) + printf("::: trying 3 '%s' ...\n", filename); #endif if (fileExists(filename)) return filename; @@ -489,9 +530,9 @@ char *getCustomImageFilename(char *basename) /* 4th try: look for default artwork in new default artwork directory */ filename = getPath2(getDefaultGraphicsDir(GRAPHICS_SUBDIR), basename); -#if 1 - if (strcmp(basename, "RocksScreen.pcx") == 0) - printf("::: check 4: filename '%s'\n", filename); +#if 0 + if (strcmp(basename, "RocksScreen.pcx") == 0) + printf("::: trying 4 '%s' ...\n", filename); #endif if (fileExists(filename)) return filename; @@ -500,9 +541,9 @@ char *getCustomImageFilename(char *basename) /* 5th try: look for default artwork in old default artwork directory */ filename = getPath2(options.graphics_directory, basename); -#if 1 - if (strcmp(basename, "RocksScreen.pcx") == 0) - printf("::: check 5: filename '%s'\n", filename); +#if 0 + if (strcmp(basename, "RocksScreen.pcx") == 0) + printf("::: trying 5 '%s' ...\n", filename); #endif if (fileExists(filename)) return filename; @@ -519,12 +560,14 @@ char *getCustomSoundFilename(char *basename) if (!setup.override_level_sounds) { +#if 0 /* 1st try: look for special artwork configured in level series config */ filename = getPath2(getLevelArtworkDir(TREE_TYPE_SOUNDS_DIR), basename); if (fileExists(filename)) return filename; free(filename); +#endif /* 2nd try: look for special artwork in current level series directory */ filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename); @@ -532,6 +575,15 @@ char *getCustomSoundFilename(char *basename) return filename; free(filename); + +#if 1 + /* 1st try: look for special artwork configured in level series config */ + filename = getPath2(getLevelArtworkDir(TREE_TYPE_SOUNDS_DIR), basename); + if (fileExists(filename)) + return filename; + + free(filename); +#endif } /* 3rd try: look for special artwork in configured artwork directory */ @@ -571,6 +623,18 @@ char *getCustomArtworkConfigFilename(int type) return getCustomArtworkFilename(ARTWORKINFO_FILENAME(type), type); } +char *getCustomArtworkLevelConfigFilename(int type) +{ + static char *filename = NULL; + + if (filename != NULL) + free(filename); + + filename = getPath2(getLevelArtworkDir(type), ARTWORKINFO_FILENAME(type)); + + return filename; +} + char *getCustomMusicDirectory(void) { static char *directory = NULL; @@ -580,12 +644,14 @@ char *getCustomMusicDirectory(void) if (!setup.override_level_music) { +#if 0 /* 1st try: look for special artwork configured in level series config */ directory = getStringCopy(getLevelArtworkDir(TREE_TYPE_MUSIC_DIR)); if (fileExists(directory)) return directory; free(directory); +#endif /* 2nd try: look for special artwork in current level series directory */ directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY); @@ -593,6 +659,15 @@ char *getCustomMusicDirectory(void) return directory; free(directory); + +#if 1 + /* 1st try: look for special artwork configured in level series config */ + directory = getStringCopy(getLevelArtworkDir(TREE_TYPE_MUSIC_DIR)); + if (fileExists(directory)) + return directory; + + free(directory); +#endif } /* 3rd try: look for special artwork in configured artwork directory */ @@ -2042,16 +2117,25 @@ void LoadArtworkInfo() /* before sorting, the first entries will be from the user directory */ artwork.gfx_current = getTreeInfoFromIdentifier(artwork.gfx_first, setup.graphics_set); + if (artwork.gfx_current == NULL) + artwork.gfx_current = + getTreeInfoFromIdentifier(artwork.gfx_first, GRAPHICS_SUBDIR); if (artwork.gfx_current == NULL) artwork.gfx_current = getFirstValidTreeInfoEntry(artwork.gfx_first); artwork.snd_current = getTreeInfoFromIdentifier(artwork.snd_first, setup.sounds_set); + if (artwork.snd_current == NULL) + artwork.snd_current = + getTreeInfoFromIdentifier(artwork.snd_first, SOUNDS_SUBDIR); if (artwork.snd_current == NULL) artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first); artwork.mus_current = getTreeInfoFromIdentifier(artwork.mus_first, setup.music_set); + if (artwork.mus_current == NULL) + artwork.mus_current = + getTreeInfoFromIdentifier(artwork.mus_first, MUSIC_SUBDIR); if (artwork.mus_current == NULL) artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first); @@ -2136,6 +2220,9 @@ void LoadLevelArtworkInfo() { artwork.gfx_current = getTreeInfoFromIdentifier(artwork.gfx_first, setup.graphics_set); + if (artwork.gfx_current == NULL) + artwork.gfx_current = + getTreeInfoFromIdentifier(artwork.gfx_first, GRAPHICS_SUBDIR); if (artwork.gfx_current == NULL) artwork.gfx_current = getFirstValidTreeInfoEntry(artwork.gfx_first); } @@ -2144,6 +2231,9 @@ void LoadLevelArtworkInfo() { artwork.snd_current = getTreeInfoFromIdentifier(artwork.snd_first, setup.sounds_set); + if (artwork.snd_current == NULL) + artwork.snd_current = + getTreeInfoFromIdentifier(artwork.snd_first, SOUNDS_SUBDIR); if (artwork.snd_current == NULL) artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first); } @@ -2152,6 +2242,9 @@ void LoadLevelArtworkInfo() { artwork.mus_current = getTreeInfoFromIdentifier(artwork.mus_first, setup.music_set); + if (artwork.mus_current == NULL) + artwork.mus_current = + getTreeInfoFromIdentifier(artwork.mus_first, MUSIC_SUBDIR); if (artwork.mus_current == NULL) artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first); }