X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsetup.c;h=3e5392498dbdb63474df4b3e75b19c22488452d5;hb=401f78b66d66488fe465945bef36b10faa6b55ef;hp=7e621f434192736cce6fe13192d632a79421bb63;hpb=14f10ebaf067872a8a1412476c8923cb2414aee4;p=rocksndiamonds.git diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 7e621f43..3e539249 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -262,14 +262,14 @@ static char *getDefaultMusicDir(char *music_subdir) return music_dir; } -static char *getDefaultArtworkSet(int type) +static char *getClassicArtworkSet(int type) { return (type == TREE_TYPE_GRAPHICS_DIR ? GFX_CLASSIC_SUBDIR : type == TREE_TYPE_SOUNDS_DIR ? SND_CLASSIC_SUBDIR : type == TREE_TYPE_MUSIC_DIR ? MUS_CLASSIC_SUBDIR : ""); } -static char *getDefaultArtworkDir(int type) +static char *getClassicArtworkDir(int type) { return (type == TREE_TYPE_GRAPHICS_DIR ? getDefaultGraphicsDir(GFX_CLASSIC_SUBDIR) : @@ -334,15 +334,23 @@ char *setLevelArtworkDir(TreeInfo *ti) checked_free(*artwork_path_ptr); if ((level_artwork = getTreeInfoFromIdentifier(ti, *artwork_set_ptr))) + { *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. */ + /* + 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. + + Update: For "special" versions of R'n'D (like "R'n'D jue"), do not use + the "default" artwork (which would be "jue0" for "R'n'D jue"), but use + the real "classic" artwork from the original R'n'D (like "gfx_classic"). + */ char *dir = getPath2(getCurrentLevelDir(), ARTWORK_DIRECTORY(ti->type)); @@ -350,8 +358,8 @@ char *setLevelArtworkDir(TreeInfo *ti) if (fileExists(dir)) { - *artwork_path_ptr = getStringCopy(getDefaultArtworkDir(ti->type)); - *artwork_set_ptr = getStringCopy(getDefaultArtworkSet(ti->type)); + *artwork_path_ptr = getStringCopy(getClassicArtworkDir(ti->type)); + *artwork_set_ptr = getStringCopy(getClassicArtworkSet(ti->type)); } else { @@ -498,21 +506,80 @@ char *getLevelSetInfoFilename() return NULL; } -char *getLevelSetTitleMessageFilename(int nr, boolean initial) +char *getLevelSetTitleMessageBasename(int nr, boolean initial) { - static char *filename = NULL; - char basename[32]; + static char basename[32]; sprintf(basename, "%s_%d.txt", (initial ? "titlemessage_initial" : "titlemessage"), nr + 1); + return basename; +} + +char *getLevelSetTitleMessageFilename(int nr, boolean initial) +{ + static char *filename = NULL; + char *basename; + boolean skip_setup_artwork = FALSE; + checked_free(filename); - filename = getPath2(getCurrentLevelDir(), basename); + basename = getLevelSetTitleMessageBasename(nr, initial); + + if (!gfx.override_level_graphics) + { + /* 1st try: look for special artwork in current level series directory */ + filename = getPath3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename); + if (fileExists(filename)) + return filename; + + free(filename); + + /* 2nd try: look for message file in current level set directory */ + filename = getPath2(getCurrentLevelDir(), basename); + if (fileExists(filename)) + return filename; + + free(filename); + + /* check if there is special artwork configured in level series config */ + if (getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) != NULL) + { + /* 3rd try: look for special artwork configured in level series config */ + filename = getPath2(getLevelArtworkDir(ARTWORK_TYPE_GRAPHICS), basename); + if (fileExists(filename)) + return filename; + + free(filename); + + /* take missing artwork configured in level set config from default */ + skip_setup_artwork = TRUE; + } + } + + if (!skip_setup_artwork) + { + /* 4th try: look for special artwork in configured artwork directory */ + filename = getPath2(getSetupArtworkDir(artwork.gfx_current), basename); + if (fileExists(filename)) + return filename; + + free(filename); + } + + /* 5th try: look for default artwork in new default artwork directory */ + filename = getPath2(getDefaultGraphicsDir(GFX_DEFAULT_SUBDIR), basename); if (fileExists(filename)) return filename; - return NULL; + free(filename); + + /* 6th try: look for default artwork in old default artwork directory */ + filename = getPath2(options.graphics_directory, basename); + if (fileExists(filename)) + return filename; + + return NULL; /* cannot find specified artwork file anywhere */ } static char *getCorrectedArtworkBasename(char *basename) @@ -556,7 +623,7 @@ char *getCustomImageFilename(char *basename) basename = getCorrectedArtworkBasename(basename); - if (!setup.override_level_graphics) + if (!gfx.override_level_graphics) { /* 1st try: look for special artwork in current level series directory */ filename = getPath3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename); @@ -591,7 +658,7 @@ char *getCustomImageFilename(char *basename) } /* 4th try: look for default artwork in new default artwork directory */ - filename = getPath2(getDefaultGraphicsDir(GFX_CLASSIC_SUBDIR), basename); + filename = getPath2(getDefaultGraphicsDir(GFX_DEFAULT_SUBDIR), basename); if (fileExists(filename)) return filename; @@ -602,10 +669,14 @@ char *getCustomImageFilename(char *basename) if (fileExists(filename)) return filename; -#if CREATE_SPECIAL_EDITION +#if defined(CREATE_SPECIAL_EDITION) free(filename); + if (options.debug) + Error(ERR_WARN, "cannot find artwork file '%s' (using fallback)", basename); + /* 6th try: look for fallback artwork in old default artwork directory */ + /* (needed to prevent errors when trying to access unused artwork files) */ filename = getPath2(options.graphics_directory, GFX_FALLBACK_FILENAME); if (fileExists(filename)) return filename; @@ -623,7 +694,7 @@ char *getCustomSoundFilename(char *basename) basename = getCorrectedArtworkBasename(basename); - if (!setup.override_level_sounds) + if (!gfx.override_level_sounds) { /* 1st try: look for special artwork in current level series directory */ filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename); @@ -658,7 +729,7 @@ char *getCustomSoundFilename(char *basename) } /* 4th try: look for default artwork in new default artwork directory */ - filename = getPath2(getDefaultSoundsDir(SND_CLASSIC_SUBDIR), basename); + filename = getPath2(getDefaultSoundsDir(SND_DEFAULT_SUBDIR), basename); if (fileExists(filename)) return filename; @@ -669,10 +740,14 @@ char *getCustomSoundFilename(char *basename) if (fileExists(filename)) return filename; -#if CREATE_SPECIAL_EDITION +#if defined(CREATE_SPECIAL_EDITION) free(filename); + if (options.debug) + Error(ERR_WARN, "cannot find artwork file '%s' (using fallback)", basename); + /* 6th try: look for fallback artwork in old default artwork directory */ + /* (needed to prevent errors when trying to access unused artwork files) */ filename = getPath2(options.sounds_directory, SND_FALLBACK_FILENAME); if (fileExists(filename)) return filename; @@ -690,7 +765,7 @@ char *getCustomMusicFilename(char *basename) basename = getCorrectedArtworkBasename(basename); - if (!setup.override_level_music) + if (!gfx.override_level_music) { /* 1st try: look for special artwork in current level series directory */ filename = getPath3(getCurrentLevelDir(), MUSIC_DIRECTORY, basename); @@ -725,7 +800,7 @@ char *getCustomMusicFilename(char *basename) } /* 4th try: look for default artwork in new default artwork directory */ - filename = getPath2(getDefaultMusicDir(MUS_CLASSIC_SUBDIR), basename); + filename = getPath2(getDefaultMusicDir(MUS_DEFAULT_SUBDIR), basename); if (fileExists(filename)) return filename; @@ -736,10 +811,14 @@ char *getCustomMusicFilename(char *basename) if (fileExists(filename)) return filename; -#if CREATE_SPECIAL_EDITION +#if defined(CREATE_SPECIAL_EDITION) free(filename); + if (options.debug) + Error(ERR_WARN, "cannot find artwork file '%s' (using fallback)", basename); + /* 6th try: look for fallback artwork in old default artwork directory */ + /* (needed to prevent errors when trying to access unused artwork files) */ filename = getPath2(options.music_directory, MUS_FALLBACK_FILENAME); if (fileExists(filename)) return filename; @@ -783,7 +862,7 @@ char *getCustomMusicDirectory(void) checked_free(directory); - if (!setup.override_level_music) + if (!gfx.override_level_music) { /* 1st try: look for special artwork in current level series directory */ directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY); @@ -818,7 +897,7 @@ char *getCustomMusicDirectory(void) } /* 4th try: look for default artwork in new default artwork directory */ - directory = getStringCopy(getDefaultMusicDir(MUS_CLASSIC_SUBDIR)); + directory = getStringCopy(getDefaultMusicDir(MUS_DEFAULT_SUBDIR)); if (fileExists(directory)) return directory; @@ -2608,6 +2687,10 @@ void setSetupInfo(struct TokenInfo *token_info, *(boolean *)setup_value = get_boolean_from_string(token_value); break; + case TYPE_SWITCH3: + *(int *)setup_value = get_switch3_from_string(token_value); + break; + case TYPE_KEY: *(Key *)setup_value = getKeyFromKeyName(token_value); break; @@ -2920,8 +3003,10 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first, char *level_directory, char *directory_name) { +#if 0 static unsigned long progress_delay = 0; unsigned long progress_delay_value = 100; /* (in milliseconds) */ +#endif char *directory_path = getPath2(level_directory, directory_name); char *filename = getPath2(directory_path, LEVELINFO_FILENAME); SetupFileHash *setup_file_hash; @@ -3022,9 +3107,14 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first, leveldir_new->last_level : leveldir_new->first_level); #if 1 +#if 1 + DrawInitTextExt(leveldir_new->name, 150, FC_YELLOW, + leveldir_new->level_group); +#else if (leveldir_new->level_group || DelayReached(&progress_delay, progress_delay_value)) DrawInitText(leveldir_new->name, 150, FC_YELLOW); +#endif #else DrawInitText(leveldir_new->name, 150, FC_YELLOW); #endif @@ -3427,7 +3517,7 @@ void LoadArtworkInfo() getTreeInfoFromIdentifier(artwork.gfx_first, setup.graphics_set); if (artwork.gfx_current == NULL) artwork.gfx_current = - getTreeInfoFromIdentifier(artwork.gfx_first, GFX_CLASSIC_SUBDIR); + getTreeInfoFromIdentifier(artwork.gfx_first, GFX_DEFAULT_SUBDIR); if (artwork.gfx_current == NULL) artwork.gfx_current = getFirstValidTreeInfoEntry(artwork.gfx_first); @@ -3435,7 +3525,7 @@ void LoadArtworkInfo() getTreeInfoFromIdentifier(artwork.snd_first, setup.sounds_set); if (artwork.snd_current == NULL) artwork.snd_current = - getTreeInfoFromIdentifier(artwork.snd_first, SND_CLASSIC_SUBDIR); + getTreeInfoFromIdentifier(artwork.snd_first, SND_DEFAULT_SUBDIR); if (artwork.snd_current == NULL) artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first); @@ -3443,7 +3533,7 @@ void LoadArtworkInfo() getTreeInfoFromIdentifier(artwork.mus_first, setup.music_set); if (artwork.mus_current == NULL) artwork.mus_current = - getTreeInfoFromIdentifier(artwork.mus_first, MUS_CLASSIC_SUBDIR); + getTreeInfoFromIdentifier(artwork.mus_first, MUS_DEFAULT_SUBDIR); if (artwork.mus_current == NULL) artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first); @@ -3471,8 +3561,10 @@ void LoadArtworkInfo() void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node, LevelDirTree *level_node) { +#if 0 static unsigned long progress_delay = 0; unsigned long progress_delay_value = 100; /* (in milliseconds) */ +#endif int type = (*artwork_node)->type; /* recursively check all level directories for artwork sub-directories */ @@ -3518,6 +3610,9 @@ void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node, } #if 1 + DrawInitTextExt(level_node->name, 150, FC_YELLOW, + level_node->level_group); +#else if (level_node->level_group || DelayReached(&progress_delay, progress_delay_value)) DrawInitText(level_node->name, 150, FC_YELLOW); @@ -3548,7 +3643,7 @@ void LoadLevelArtworkInfo() getTreeInfoFromIdentifier(artwork.gfx_first, setup.graphics_set); if (artwork.gfx_current == NULL) artwork.gfx_current = - getTreeInfoFromIdentifier(artwork.gfx_first, GFX_CLASSIC_SUBDIR); + getTreeInfoFromIdentifier(artwork.gfx_first, GFX_DEFAULT_SUBDIR); if (artwork.gfx_current == NULL) artwork.gfx_current = getFirstValidTreeInfoEntry(artwork.gfx_first); } @@ -3559,7 +3654,7 @@ void LoadLevelArtworkInfo() getTreeInfoFromIdentifier(artwork.snd_first, setup.sounds_set); if (artwork.snd_current == NULL) artwork.snd_current = - getTreeInfoFromIdentifier(artwork.snd_first, SND_CLASSIC_SUBDIR); + getTreeInfoFromIdentifier(artwork.snd_first, SND_DEFAULT_SUBDIR); if (artwork.snd_current == NULL) artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first); } @@ -3570,7 +3665,7 @@ void LoadLevelArtworkInfo() getTreeInfoFromIdentifier(artwork.mus_first, setup.music_set); if (artwork.mus_current == NULL) artwork.mus_current = - getTreeInfoFromIdentifier(artwork.mus_first, MUS_CLASSIC_SUBDIR); + getTreeInfoFromIdentifier(artwork.mus_first, MUS_DEFAULT_SUBDIR); if (artwork.mus_current == NULL) artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first); } @@ -3658,10 +3753,20 @@ char *getSetupValue(int type, void *value) strcpy(value_string, (*(boolean *)value ? "on" : "off")); break; + case TYPE_SWITCH3: + strcpy(value_string, (*(int *)value == AUTO ? "auto" : + *(int *)value == FALSE ? "off" : "on")); + break; + case TYPE_YES_NO: strcpy(value_string, (*(boolean *)value ? "yes" : "no")); break; + case TYPE_YES_NO_AUTO: + strcpy(value_string, (*(int *)value == AUTO ? "auto" : + *(int *)value == FALSE ? "no" : "yes")); + break; + case TYPE_ECS_AGA: strcpy(value_string, (*(boolean *)value ? "AGA" : "ECS")); break; @@ -3746,6 +3851,13 @@ void LoadLevelSetup_LastSeries() /* always start with reliable default values */ leveldir_current = getFirstValidTreeInfoEntry(leveldir_first); +#if defined(CREATE_SPECIAL_EDITION_RND_JUE) + leveldir_current = getTreeInfoFromIdentifier(leveldir_first, + "jue_start"); + if (leveldir_current == NULL) + leveldir_current = getFirstValidTreeInfoEntry(leveldir_first); +#endif + if ((level_setup_hash = loadSetupFileHash(filename))) { char *last_level_series =