* setup.c *
***********************************************************/
-#include <dirent.h>
+#include <sys/types.h>
#include <sys/stat.h>
+#include <dirent.h>
#include <string.h>
#include <unistd.h>
IS_LEVELCLASS_USER(n) ? 7 : \
9)
+#define ARTWORKCOLOR(n) (IS_ARTWORKCLASS_CLASSICS(n) ? FC_RED : \
+ IS_ARTWORKCLASS_CONTRIBUTION(n) ? FC_YELLOW : \
+ IS_ARTWORKCLASS_LEVEL(n) ? FC_GREEN : \
+ IS_ARTWORKCLASS_USER(n) ? FC_RED : \
+ FC_BLUE)
+
+#define ARTWORKSORTING(n) (IS_ARTWORKCLASS_CLASSICS(n) ? 0 : \
+ IS_ARTWORKCLASS_CONTRIBUTION(n) ? 1 : \
+ IS_ARTWORKCLASS_LEVEL(n) ? 2 : \
+ IS_ARTWORKCLASS_USER(n) ? 3 : \
+ 9)
+
#define TOKEN_VALUE_POSITION 40
#define TOKEN_COMMENT_POSITION 60
return usermusic_dir;
}
+static char *getSetupArtworkDir(TreeInfo *ti)
+{
+ static char *artwork_dir = NULL;
+
+ if (artwork_dir != NULL)
+ free(artwork_dir);
+
+ artwork_dir = getPath2(ti->basepath, ti->fullpath);
+
+ return artwork_dir;
+}
+
+void setLevelArtworkDir(TreeInfo *ti)
+{
+ char **artwork_path_ptr, *artwork_set;
+ TreeInfo *level_artwork;
+
+ if (ti == NULL || leveldir_current == NULL)
+ return;
+
+ artwork_path_ptr =
+ (ti->type == TREE_TYPE_GRAPHICS_DIR ? &leveldir_current->graphics_path :
+ ti->type == TREE_TYPE_SOUNDS_DIR ? &leveldir_current->sounds_path :
+ &leveldir_current->music_path);
+
+ artwork_set =
+ (ti->type == TREE_TYPE_GRAPHICS_DIR ? leveldir_current->graphics_set :
+ 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));
+}
+
+static char *getLevelArtworkDir(int type)
+{
+ char *artwork_path;
+
+ if (leveldir_current == NULL)
+ return UNDEFINED_FILENAME;
+
+ artwork_path =
+ (type == TREE_TYPE_GRAPHICS_DIR ? leveldir_current->graphics_path :
+ type == TREE_TYPE_SOUNDS_DIR ? leveldir_current->sounds_path :
+ type == TREE_TYPE_MUSIC_DIR ? leveldir_current->music_path :
+ UNDEFINED_FILENAME);
+
+ return artwork_path;
+}
+
char *getLevelFilename(int nr)
{
static char *filename = NULL;
return filename;
}
-static char *getSetupArtworkDir(TreeInfo *ti)
-{
- static char *artwork_dir = NULL;
-
- if (artwork_dir != NULL)
- free(artwork_dir);
-
- artwork_dir = getPath2(ti->basepath, ti->fullpath);
-
- return artwork_dir;
-}
-
static char *getCorrectedImageBasename(char *basename)
{
- char *result = basename;
+ char *basename_corrected = basename;
#if defined(PLATFORM_MSDOS)
if (program.filename_prefix != NULL)
int prefix_len = strlen(program.filename_prefix);
if (strncmp(basename, program.filename_prefix, prefix_len) == 0)
- result = &basename[prefix_len];
+ basename_corrected = &basename[prefix_len];
+
+ /* if corrected filename is still longer than standard MS-DOS filename
+ size (8 characters + 1 dot + 3 characters file extension), shorten
+ filename by writing file extension after 8th basename character */
+ if (strlen(basename_corrected) > 8+1+3)
+ {
+ static char *msdos_filename = NULL;
+
+ if (msdos_filename != NULL)
+ free(msdos_filename);
+
+ msdos_filename = getStringCopy(basename_corrected);
+ strncpy(&msdos_filename[8], &basename[strlen(basename) - 1+3], 1+3 + 1);
+ }
}
#endif
- return result;
+ return basename_corrected;
}
static boolean fileExists(char *filename)
if (!setup.override_level_graphics)
{
- /* 1st try: look for special artwork in current level series directory */
+ /* 1st try: look for special artwork configured in level series config */
+ filename = getPath2(getLevelArtworkDir(TREE_TYPE_GRAPHICS_DIR), basename);
+ if (fileExists(filename))
+ return filename;
+
+ free(filename);
+
+ /* 2nd 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 special artwork in configured artwork directory */
+ /* 3rd try: look for special artwork in configured artwork directory */
filename = getPath2(getSetupArtworkDir(artwork.gfx_current), basename);
if (fileExists(filename))
return filename;
- /* 3rd try: look for default artwork in new default artwork directory */
+ free(filename);
+
+ /* 4th try: look for default artwork in new default artwork directory */
filename = getPath2(getDefaultGraphicsDir(GRAPHICS_SUBDIR), basename);
if (fileExists(filename))
return filename;
- /* 4th try: look for default artwork in old default artwork directory */
+ free(filename);
+
+ /* 5th try: look for default artwork in old default artwork directory */
filename = getPath2(options.graphics_directory, basename);
if (fileExists(filename))
return filename;
if (!setup.override_level_sounds)
{
- /* 1st try: look for special artwork in current level series directory */
+ /* 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);
+
+ /* 2nd try: look for special artwork in current level series directory */
filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename);
if (fileExists(filename))
return filename;
+
+ free(filename);
}
- /* 2nd try: look for special artwork in configured artwork directory */
+ /* 3rd try: look for special artwork in configured artwork directory */
filename = getPath2(getSetupArtworkDir(artwork.snd_current), basename);
if (fileExists(filename))
return filename;
- /* 3rd try: look for default artwork in new default artwork directory */
+ free(filename);
+
+ /* 4th try: look for default artwork in new default artwork directory */
filename = getPath2(getDefaultSoundsDir(SOUNDS_SUBDIR), basename);
if (fileExists(filename))
return filename;
- /* 4th try: look for default artwork in old default artwork directory */
+ free(filename);
+
+ /* 5th try: look for default artwork in old default artwork directory */
filename = getPath2(options.sounds_directory, basename);
if (fileExists(filename))
return filename;
return NULL; /* cannot find specified artwork file anywhere */
}
-char *getCustomSoundConfigFilename()
+char *getCustomArtworkFilename(char *basename, int type)
{
- return getCustomSoundFilename(SOUNDSINFO_FILENAME);
+ if (type == ARTWORK_TYPE_GRAPHICS)
+ return getCustomImageFilename(basename);
+ else if (type == ARTWORK_TYPE_SOUNDS)
+ return getCustomSoundFilename(basename);
+ else
+ return UNDEFINED_FILENAME;
+}
+
+char *getCustomArtworkConfigFilename(int type)
+{
+ return getCustomArtworkFilename(ARTWORKINFO_FILENAME(type), type);
}
char *getCustomMusicDirectory(void)
if (!setup.override_level_music)
{
- /* 1st try: look for special artwork in current level series directory */
+ /* 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);
+
+ /* 2nd try: look for special artwork in current level series directory */
directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY);
if (fileExists(directory))
return directory;
+
+ free(directory);
}
- /* 2nd try: look for special artwork in configured artwork directory */
+ /* 3rd try: look for special artwork in configured artwork directory */
directory = getStringCopy(getSetupArtworkDir(artwork.mus_current));
if (fileExists(directory))
return directory;
- /* 3rd try: look for default artwork in new default artwork directory */
+ free(directory);
+
+ /* 4th try: look for default artwork in new default artwork directory */
directory = getStringCopy(getDefaultMusicDir(MUSIC_SUBDIR));
if (fileExists(directory))
return directory;
- /* 4th try: look for default artwork in old default artwork directory */
+ free(directory);
+
+ /* 5th try: look for default artwork in old default artwork directory */
directory = getStringCopy(options.music_directory);
if (fileExists(directory))
return directory;
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 */
{
return node_default;
}
-TreeInfo *getTreeInfoFromFilenameExt(TreeInfo *node, char *filename)
+TreeInfo *getTreeInfoFromIdentifier(TreeInfo *node, char *identifier)
{
- if (filename == NULL)
+ if (identifier == NULL)
return NULL;
while (node)
{
TreeInfo *node_group;
- node_group = getTreeInfoFromFilenameExt(node->node_group, filename);
+ node_group = getTreeInfoFromIdentifier(node->node_group, identifier);
if (node_group)
return node_group;
}
else if (!node->parent_link)
{
- if (strcmp(filename, node->filename) == 0)
+ if (strcmp(identifier, node->identifier) == 0)
return node;
}
return NULL;
}
-TreeInfo *getTreeInfoFromFilename(TreeInfo *ti, char *filename)
-{
- return getTreeInfoFromFilenameExt(ti, filename);
-}
-
void dumpTreeInfo(TreeInfo *node, int depth)
{
int i;
for (i=0; i<(depth + 1) * 3; i++)
printf(" ");
- printf("filename == '%s' (%s) [%s]\n",
- node->filename, node->name, node->name_short);
+ printf("filename == '%s' (%s) [%s] (%d)\n",
+ node->filename, node->name, node->identifier, node->sort_priority);
if (node->node_group != NULL)
dumpTreeInfo(node->node_group, depth + 1);
/* setup file list handling functions */
/* ------------------------------------------------------------------------- */
-int get_string_integer_value(char *s)
-{
- static char *number_text[][3] =
- {
- { "0", "zero", "null", },
- { "1", "one", "first" },
- { "2", "two", "second" },
- { "3", "three", "third" },
- { "4", "four", "fourth" },
- { "5", "five", "fifth" },
- { "6", "six", "sixth" },
- { "7", "seven", "seventh" },
- { "8", "eight", "eighth" },
- { "9", "nine", "ninth" },
- { "10", "ten", "tenth" },
- { "11", "eleven", "eleventh" },
- { "12", "twelve", "twelfth" },
- };
-
- int i, j;
- char *s_lower = getStringToLower(s);
- int result = -1;
-
- for (i=0; i<13; i++)
- for (j=0; j<3; j++)
- if (strcmp(s_lower, number_text[i][j]) == 0)
- result = i;
-
- if (result == -1)
- result = atoi(s);
-
- free(s_lower);
-
- return result;
-}
-
-boolean get_string_boolean_value(char *s)
-{
- char *s_lower = getStringToLower(s);
- boolean result = FALSE;
-
- if (strcmp(s_lower, "true") == 0 ||
- strcmp(s_lower, "yes") == 0 ||
- strcmp(s_lower, "on") == 0 ||
- get_string_integer_value(s) == 1)
- result = TRUE;
-
- free(s_lower);
-
- return result;
-}
-
char *getFormattedSetupEntry(char *token, char *value)
{
int i;
void freeSetupFileList(struct SetupFileList *setup_file_list)
{
- if (!setup_file_list)
+ if (setup_file_list == NULL)
return;
if (setup_file_list->token)
free(setup_file_list);
}
-static struct SetupFileList *newSetupFileList(char *token, char *value)
+struct SetupFileList *newSetupFileList(char *token, char *value)
{
struct SetupFileList *new = checked_malloc(sizeof(struct SetupFileList));
- new->token = checked_malloc(strlen(token) + 1);
- strcpy(new->token, token);
-
- new->value = checked_malloc(strlen(value) + 1);
- strcpy(new->value, value);
+ new->token = getStringCopy(token);
+ new->value = getStringCopy(value);
new->next = NULL;
char *getTokenValue(struct SetupFileList *setup_file_list, char *token)
{
- if (!setup_file_list)
+ if (setup_file_list == NULL)
return NULL;
if (strcmp(setup_file_list->token, token) == 0)
return getTokenValue(setup_file_list->next, token);
}
-static void setTokenValue(struct SetupFileList *setup_file_list,
- char *token, char *value)
+void setTokenValue(struct SetupFileList *setup_file_list,
+ char *token, char *value)
{
- if (!setup_file_list)
+ if (setup_file_list == NULL)
return;
if (strcmp(setup_file_list->token, token) == 0)
{
- free(setup_file_list->value);
- setup_file_list->value = checked_malloc(strlen(value) + 1);
- strcpy(setup_file_list->value, value);
+ if (setup_file_list->value)
+ free(setup_file_list->value);
+
+ setup_file_list->value = getStringCopy(value);
}
else if (setup_file_list->next == NULL)
setup_file_list->next = newSetupFileList(token, value);
#define TOKEN_STR_HANDICAP_LEVEL "handicap_level"
/* level directory info */
-#define LEVELINFO_TOKEN_NAME 0
-#define LEVELINFO_TOKEN_NAME_SHORT 1
+#define LEVELINFO_TOKEN_IDENTIFIER 0
+#define LEVELINFO_TOKEN_NAME 1
#define LEVELINFO_TOKEN_NAME_SORTING 2
#define LEVELINFO_TOKEN_AUTHOR 3
#define LEVELINFO_TOKEN_IMPORTED_FROM 4
#define LEVELINFO_TOKEN_SORT_PRIORITY 7
#define LEVELINFO_TOKEN_LEVEL_GROUP 8
#define LEVELINFO_TOKEN_READONLY 9
+#define LEVELINFO_TOKEN_GRAPHICS_SET 10
+#define LEVELINFO_TOKEN_SOUNDS_SET 11
+#define LEVELINFO_TOKEN_MUSIC_SET 12
-#define NUM_LEVELINFO_TOKENS 10
+#define NUM_LEVELINFO_TOKENS 13
static LevelDirTree ldi;
static struct TokenInfo levelinfo_tokens[] =
{
/* level directory info */
+ { TYPE_STRING, &ldi.identifier, "identifier" },
{ TYPE_STRING, &ldi.name, "name" },
- { TYPE_STRING, &ldi.name_short, "name_short" },
{ TYPE_STRING, &ldi.name_sorting, "name_sorting" },
{ TYPE_STRING, &ldi.author, "author" },
{ TYPE_STRING, &ldi.imported_from, "imported_from" },
{ TYPE_INTEGER, &ldi.first_level, "first_level" },
{ TYPE_INTEGER, &ldi.sort_priority, "sort_priority" },
{ TYPE_BOOLEAN, &ldi.level_group, "level_group" },
- { TYPE_BOOLEAN, &ldi.readonly, "readonly" }
+ { TYPE_BOOLEAN, &ldi.readonly, "readonly" },
+ { TYPE_STRING, &ldi.graphics_set, "graphics_set" },
+ { TYPE_STRING, &ldi.sounds_set, "sounds_set" },
+ { TYPE_STRING, &ldi.music_set, "music_set" }
};
static void setTreeInfoToDefaults(TreeInfo *ldi, int type)
ldi->filename = NULL;
ldi->fullpath = NULL;
ldi->basepath = NULL;
+ ldi->identifier = NULL;
ldi->name = getStringCopy(ANONYMOUS_NAME);
- ldi->name_short = NULL;
ldi->name_sorting = NULL;
ldi->author = getStringCopy(ANONYMOUS_NAME);
if (ldi->type == TREE_TYPE_LEVEL_DIR)
{
ldi->imported_from = NULL;
+ ldi->graphics_set = NULL;
+ ldi->sounds_set = NULL;
+ ldi->music_set = NULL;
+ ldi->graphics_path = getStringCopy(UNDEFINED_FILENAME);
+ ldi->sounds_path = getStringCopy(UNDEFINED_FILENAME);
+ ldi->music_path = getStringCopy(UNDEFINED_FILENAME);
ldi->levels = 0;
ldi->first_level = 0;
ldi->last_level = 0;
ldi->filename = NULL;
ldi->fullpath = NULL;
ldi->basepath = NULL;
+ ldi->identifier = NULL;
ldi->name = getStringCopy(ANONYMOUS_NAME);
- ldi->name_short = NULL;
ldi->name_sorting = NULL;
ldi->author = getStringCopy(parent->author);
ldi->imported_from = getStringCopy(parent->imported_from);
{
case TYPE_BOOLEAN:
case TYPE_SWITCH:
- *(boolean *)setup_value = get_string_boolean_value(token_value);
+ *(boolean *)setup_value = get_boolean_from_string(token_value);
break;
case TYPE_KEY:
break;
case TYPE_INTEGER:
- *(int *)setup_value = get_string_integer_value(token_value);
+ *(int *)setup_value = get_integer_from_string(token_value);
break;
case TYPE_STRING:
{
const TreeInfo *entry1 = *((TreeInfo **)object1);
const TreeInfo *entry2 = *((TreeInfo **)object2);
+ int class_sorting1, class_sorting2;
int compare_result;
+ if (entry1->type == TREE_TYPE_LEVEL_DIR)
+ {
+ class_sorting1 = LEVELSORTING(entry1);
+ class_sorting2 = LEVELSORTING(entry2);
+ }
+ else
+ {
+ class_sorting1 = ARTWORKSORTING(entry1);
+ class_sorting2 = ARTWORKSORTING(entry2);
+ }
+
if (entry1->parent_link || entry2->parent_link)
compare_result = (entry1->parent_link ? -1 : +1);
else if (entry1->sort_priority == entry2->sort_priority)
free(name1);
free(name2);
}
- else if (LEVELSORTING(entry1) == LEVELSORTING(entry2))
+ else if (class_sorting1 == class_sorting2)
compare_result = entry1->sort_priority - entry2->sort_priority;
else
- compare_result = LEVELSORTING(entry1) - LEVELSORTING(entry2);
+ compare_result = class_sorting1 - class_sorting2;
return compare_result;
}
ti_new->node_parent = node_parent;
ti_new->parent_link = TRUE;
+ ti_new->identifier = getStringCopy(node_parent->identifier);
ti_new->name = ".. (parent directory)";
- ti_new->name_short = getStringCopy(ti_new->name);
ti_new->name_sorting = getStringCopy(ti_new->name);
ti_new->filename = "..";
DrawInitText(leveldir_new->name, 150, FC_YELLOW);
- if (leveldir_new->name_short == NULL)
- leveldir_new->name_short = getStringCopy(leveldir_new->name);
+ if (leveldir_new->identifier == NULL)
+ leveldir_new->identifier = getStringCopy(leveldir_new->filename);
if (leveldir_new->name_sorting == NULL)
leveldir_new->name_sorting = getStringCopy(leveldir_new->name);
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);
+ if (artwork_new->identifier == NULL)
+ artwork_new->identifier = getStringCopy(artwork_new->filename);
if (artwork_new->name_sorting == NULL)
artwork_new->name_sorting = getStringCopy(artwork_new->name);
(artwork_new->basepath == OPTIONS_ARTWORK_DIRECTORY(type) ? FALSE : TRUE);
/* (may use ".sort_priority" from "setup_file_list" above) */
- artwork_new->color = LEVELCOLOR(artwork_new);
+ artwork_new->color = ARTWORKCOLOR(artwork_new);
artwork_new->class_desc = getLevelClassDescription(artwork_new);
if (setup_file_list == NULL) /* (after determining ".user_defined") */
{
if (artwork_new->user_defined)
{
- artwork_new->name = getStringCopy("private");
- artwork_new->sort_priority = LEVELCLASS_USER;
+ artwork_new->identifier = getStringCopy("private");
+ artwork_new->sort_priority = ARTWORKCLASS_USER;
}
else
{
- artwork_new->name = getStringCopy("classic");
- artwork_new->sort_priority = LEVELCLASS_CLASSICS;
+ artwork_new->identifier = getStringCopy("classic");
+ artwork_new->sort_priority = ARTWORKCLASS_CLASSICS;
}
- artwork_new->color = LEVELCOLOR(artwork_new);
+ /* set to new values after changing ".sort_priority" */
+ artwork_new->color = ARTWORKCOLOR(artwork_new);
artwork_new->class_desc = getLevelClassDescription(artwork_new);
}
else
- artwork_new->name = getStringCopy(artwork_new->filename);
+ {
+ artwork_new->identifier = getStringCopy(artwork_new->filename);
+ }
- artwork_new->name_short = getStringCopy(artwork_new->name);
+ artwork_new->name = getStringCopy(artwork_new->identifier);
artwork_new->name_sorting = getStringCopy(artwork_new->name);
}
+ DrawInitText(artwork_new->name, 150, FC_YELLOW);
+
pushTreeInfo(node_first, artwork_new);
freeSetupFileList(setup_file_list);
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(UNDEFINED_FILENAME);
+ artwork_new->fullpath = getStringCopy(UNDEFINED_FILENAME);
+ artwork_new->basepath = getStringCopy(UNDEFINED_FILENAME);
+
+ if (artwork_new->name != NULL)
+ free(artwork_new->name);
+
+ artwork_new->identifier = getStringCopy(UNDEFINED_FILENAME);
+ artwork_new->name = getStringCopy(UNDEFINED_FILENAME);
+ artwork_new->name_sorting = getStringCopy(UNDEFINED_FILENAME);
+
+ return artwork_new;
+}
+
void LoadArtworkInfo()
{
DrawInitText("Looking for custom artwork:", 120, FC_GREEN);
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);
+ getTreeInfoFromIdentifier(artwork.gfx_first, setup.graphics_set);
if (artwork.gfx_current == NULL)
artwork.gfx_current = getFirstValidTreeInfoEntry(artwork.gfx_first);
artwork.snd_current =
- getTreeInfoFromFilename(artwork.snd_first, setup.sounds_set);
+ getTreeInfoFromIdentifier(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);
+ getTreeInfoFromIdentifier(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;
- artwork.music_set_current_name = artwork.mus_current->name;
+ artwork.gfx_current_identifier = artwork.gfx_current->identifier;
+ artwork.snd_current_identifier = artwork.snd_current->identifier;
+ artwork.mus_current_identifier = artwork.mus_current->identifier;
#if 0
- printf("graphics set == %s\n\n", artwork.graphics_set_current_name);
- printf("sounds set == %s\n\n", artwork.sounds_set_current_name);
- printf("music set == %s\n\n", artwork.music_set_current_name);
+ printf("graphics set == %s\n\n", artwork.gfx_current_identifier);
+ printf("sounds set == %s\n\n", artwork.snd_current_identifier);
+ printf("music set == %s\n\n", artwork.mus_current_identifier);
#endif
sortTreeInfo(&artwork.gfx_first, compareTreeInfoEntries);
if (topnode_last != *artwork_node)
{
+ free((*artwork_node)->identifier);
free((*artwork_node)->name);
free((*artwork_node)->name_sorting);
- free((*artwork_node)->name_short);
+ (*artwork_node)->identifier = getStringCopy(level_node->filename);
(*artwork_node)->name = getStringCopy(level_node->name);
(*artwork_node)->name_sorting = getStringCopy(level_node->name);
- (*artwork_node)->name_short = getStringCopy(level_node->filename);
(*artwork_node)->sort_priority = level_node->sort_priority;
(*artwork_node)->color = LEVELCOLOR((*artwork_node));
LoadArtworkInfoFromLevelInfo(&artwork.snd_first, leveldir_first);
LoadArtworkInfoFromLevelInfo(&artwork.mus_first, leveldir_first);
+ /* needed for reloading level artwork not known at ealier stage */
+ if (strcmp(artwork.gfx_current_identifier, setup.graphics_set) != 0)
+ {
+ artwork.gfx_current =
+ getTreeInfoFromIdentifier(artwork.gfx_first, setup.graphics_set);
+ if (artwork.gfx_current == NULL)
+ artwork.gfx_current = getFirstValidTreeInfoEntry(artwork.gfx_first);
+ }
+
+ if (strcmp(artwork.snd_current_identifier, setup.sounds_set) != 0)
+ {
+ artwork.snd_current =
+ getTreeInfoFromIdentifier(artwork.snd_first, setup.sounds_set);
+ if (artwork.snd_current == NULL)
+ artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first);
+ }
+
+ if (strcmp(artwork.mus_current_identifier, setup.music_set) != 0)
+ {
+ artwork.mus_current =
+ getTreeInfoFromIdentifier(artwork.mus_first, setup.music_set);
+ if (artwork.mus_current == NULL)
+ artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first);
+ }
+
sortTreeInfo(&artwork.gfx_first, compareTreeInfoEntries);
sortTreeInfo(&artwork.snd_first, compareTreeInfoEntries);
sortTreeInfo(&artwork.mus_first, compareTreeInfoEntries);
/* always start with reliable default values */
setTreeInfoToDefaults(&ldi, TREE_TYPE_LEVEL_DIR);
- ldi.name = getLoginName();
- ldi.author = getRealName();
+ ldi.name = getStringCopy(getLoginName());
+ ldi.author = getStringCopy(getRealName());
ldi.levels = 100;
ldi.first_level = 1;
ldi.sort_priority = LEVELCLASS_USER_START;
ldi.readonly = FALSE;
+ ldi.graphics_set = getStringCopy(GRAPHICS_SUBDIR);
+ ldi.sounds_set = getStringCopy(SOUNDS_SUBDIR);
+ ldi.music_set = getStringCopy(MUSIC_SUBDIR);
fprintf(file, "%s\n\n", getFormattedSetupEntry(TOKEN_STR_FILE_IDENTIFIER,
getCookie("LEVELINFO")));
for (i=0; i<NUM_LEVELINFO_TOKENS; i++)
- if (i != LEVELINFO_TOKEN_NAME_SHORT &&
+ if (i != LEVELINFO_TOKEN_IDENTIFIER &&
i != LEVELINFO_TOKEN_NAME_SORTING &&
i != LEVELINFO_TOKEN_IMPORTED_FROM)
fprintf(file, "%s\n", getSetupLine(levelinfo_tokens, "", i));
char *last_level_series =
getTokenValue(level_setup_list, TOKEN_STR_LAST_LEVEL_SERIES);
- leveldir_current = getTreeInfoFromFilename(leveldir_first,
- last_level_series);
+ leveldir_current = getTreeInfoFromIdentifier(leveldir_first,
+ last_level_series);
if (leveldir_current == NULL)
leveldir_current = getFirstValidTreeInfoEntry(leveldir_first);