X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsetup.c;h=ee7733fcd5216b97df49d184b9a0b1e87d2b8892;hb=dcfdc42ed1d7bc931b62ee9639af893858889219;hp=0cad9d8c4c0b087da76e21502c5c641c511158c1;hpb=df4dc8e0755fb2d7f651ce31aff28bc51cc8034a;p=rocksndiamonds.git diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 0cad9d8c..ee7733fc 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -19,6 +19,7 @@ #include "platform.h" #include "setup.h" +#include "sound.h" #include "joystick.h" #include "text.h" #include "misc.h" @@ -1253,7 +1254,58 @@ char *getCustomArtworkLevelConfigFilename(int type) return filename; } -char *getCustomMusicDirectory(void) +static boolean directoryExists_CheckMusic(char *directory, boolean check_music) +{ + if (!directoryExists(directory)) + return FALSE; + + if (!check_music) + return TRUE; + + Directory *dir; + DirectoryEntry *dir_entry; + int num_music = getMusicListSize(); + boolean music_found = FALSE; + + if ((dir = openDirectory(directory)) == NULL) + return FALSE; + + while ((dir_entry = readDirectory(dir)) != NULL) // loop all entries + { + char *basename = dir_entry->basename; + boolean music_already_used = FALSE; + int i; + + // skip all music files that are configured in music config file + for (i = 0; i < num_music; i++) + { + struct FileInfo *music = getMusicListEntry(i); + + if (strEqual(basename, music->filename)) + { + music_already_used = TRUE; + + break; + } + } + + if (music_already_used) + continue; + + if (FileIsMusic(dir_entry->filename)) + { + music_found = TRUE; + + break; + } + } + + closeDirectory(dir); + + return music_found; +} + +static char *getCustomMusicDirectoryExt(boolean check_music) { static char *directory = NULL; boolean skip_setup_artwork = FALSE; @@ -1264,7 +1316,7 @@ char *getCustomMusicDirectory(void) { // 1st try: look for special artwork in current level series directory directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY); - if (directoryExists(directory)) + if (directoryExists_CheckMusic(directory, check_music)) return directory; free(directory); @@ -1274,7 +1326,7 @@ char *getCustomMusicDirectory(void) { // 2nd try: look for special artwork configured in level series config directory = getStringCopy(getLevelArtworkDir(TREE_TYPE_MUSIC_DIR)); - if (directoryExists(directory)) + if (directoryExists_CheckMusic(directory, check_music)) return directory; free(directory); @@ -1288,7 +1340,7 @@ char *getCustomMusicDirectory(void) { // 3rd try: look for special artwork in configured artwork directory directory = getStringCopy(getSetupArtworkDir(artwork.mus_current)); - if (directoryExists(directory)) + if (directoryExists_CheckMusic(directory, check_music)) return directory; free(directory); @@ -1296,19 +1348,29 @@ char *getCustomMusicDirectory(void) // 4th try: look for default artwork in new default artwork directory directory = getStringCopy(getDefaultMusicDir(MUS_DEFAULT_SUBDIR)); - if (directoryExists(directory)) + if (directoryExists_CheckMusic(directory, check_music)) return directory; free(directory); // 5th try: look for default artwork in old default artwork directory directory = getStringCopy(options.music_directory); - if (directoryExists(directory)) + if (directoryExists_CheckMusic(directory, check_music)) return directory; return NULL; // cannot find specified artwork file anywhere } +char *getCustomMusicDirectory(void) +{ + return getCustomMusicDirectoryExt(FALSE); +} + +char *getCustomMusicDirectory_NoConf(void) +{ + return getCustomMusicDirectoryExt(TRUE); +} + void MarkTapeDirectoryUploadsAsComplete(char *level_subdir) { char *filename = getPath2(getTapeDir(level_subdir), UPLOADED_FILENAME); @@ -2741,8 +2803,9 @@ SetupFileHash *loadSetupFileHash(char *filename) #define LEVELINFO_TOKEN_TIME_LIMIT 30 #define LEVELINFO_TOKEN_SKIP_LEVELS 31 #define LEVELINFO_TOKEN_USE_EMC_TILES 32 +#define LEVELINFO_TOKEN_INFO_SCREENS_FROM_MAIN 33 -#define NUM_LEVELINFO_TOKENS 33 +#define NUM_LEVELINFO_TOKENS 34 static LevelDirTree ldi; @@ -2781,7 +2844,8 @@ static struct TokenInfo levelinfo_tokens[] = { TYPE_BOOLEAN, &ldi.handicap, "handicap" }, { TYPE_BOOLEAN, &ldi.time_limit, "time_limit" }, { TYPE_BOOLEAN, &ldi.skip_levels, "skip_levels" }, - { TYPE_BOOLEAN, &ldi.use_emc_tiles, "use_emc_tiles" } + { TYPE_BOOLEAN, &ldi.use_emc_tiles, "use_emc_tiles" }, + { TYPE_BOOLEAN, &ldi.info_screens_from_main, "info_screens_from_main" } }; static struct TokenInfo artworkinfo_tokens[] = @@ -2890,6 +2954,7 @@ static void setTreeInfoToDefaults(TreeInfo *ti, int type) ti->skip_levels = FALSE; ti->use_emc_tiles = FALSE; + ti->info_screens_from_main = FALSE; } } @@ -2976,6 +3041,7 @@ static void setTreeInfoToDefaultsFromParent(TreeInfo *ti, TreeInfo *parent) ti->skip_levels = parent->skip_levels; ti->use_emc_tiles = parent->use_emc_tiles; + ti->info_screens_from_main = parent->info_screens_from_main; } } @@ -3049,6 +3115,7 @@ static TreeInfo *getTreeInfoCopy(TreeInfo *ti) ti_copy->skip_levels = ti->skip_levels; ti_copy->use_emc_tiles = ti->use_emc_tiles; + ti_copy->info_screens_from_main = ti->info_screens_from_main; ti_copy->color = ti->color; ti_copy->class_desc = getStringCopy(ti->class_desc);