+#if 1
+
+static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first,
+ TreeInfo *node_parent,
+ char *base_directory,
+ char *directory_name, int type)
+{
+ char *directory_path = getPath2(base_directory, directory_name);
+ char *filename = getPath2(directory_path, ARTWORKINFO_FILENAME(type));
+ SetupFileHash *setup_file_hash = NULL;
+ TreeInfo *artwork_new = NULL;
+ int i;
+
+ if (fileExists(filename))
+ setup_file_hash = loadSetupFileHash(filename);
+
+ if (setup_file_hash == NULL) /* no config file -- look for artwork files */
+ {
+ Directory *dir;
+ DirectoryEntry *dir_entry;
+ boolean valid_file_found = FALSE;
+
+ if ((dir = openDirectory(directory_path)) != NULL)
+ {
+ while ((dir_entry = readDirectory(dir)) != NULL)
+ {
+ char *entry_name = dir_entry->basename;
+
+ if (FileIsArtworkType(entry_name, type))
+ {
+ valid_file_found = TRUE;
+
+ break;
+ }
+ }
+
+ closeDirectory(dir);
+ }
+
+ if (!valid_file_found)
+ {
+ if (!strEqual(directory_name, "."))
+ Error(ERR_WARN, "ignoring artwork directory '%s'", directory_path);
+
+ free(directory_path);
+ free(filename);
+
+ return FALSE;
+ }
+ }
+
+ artwork_new = newTreeInfo();
+
+ if (node_parent)
+ setTreeInfoToDefaultsFromParent(artwork_new, node_parent);
+ else
+ setTreeInfoToDefaults(artwork_new, type);
+
+ artwork_new->subdir = getStringCopy(directory_name);
+
+ if (setup_file_hash) /* (before defining ".color" and ".class_desc") */
+ {
+#if 0
+ checkSetupFileHashIdentifier(setup_file_hash, filename, getCookie("..."));
+#endif
+
+ /* set all structure fields according to the token/value pairs */
+ ldi = *artwork_new;
+ for (i = 0; i < NUM_LEVELINFO_TOKENS; i++)
+ setSetupInfo(levelinfo_tokens, i,
+ getHashEntry(setup_file_hash, levelinfo_tokens[i].text));
+ *artwork_new = ldi;
+
+ if (strEqual(artwork_new->name, ANONYMOUS_NAME))
+ setString(&artwork_new->name, artwork_new->subdir);
+
+ if (artwork_new->identifier == NULL)
+ artwork_new->identifier = getStringCopy(artwork_new->subdir);
+
+ if (artwork_new->name_sorting == NULL)
+ artwork_new->name_sorting = getStringCopy(artwork_new->name);
+ }
+
+ if (node_parent == NULL) /* top level group */
+ {
+ artwork_new->basepath = getStringCopy(base_directory);
+ artwork_new->fullpath = getStringCopy(artwork_new->subdir);
+ }
+ else /* sub level group */
+ {
+ artwork_new->basepath = getStringCopy(node_parent->basepath);
+ artwork_new->fullpath = getPath2(node_parent->fullpath, directory_name);
+ }
+
+ artwork_new->in_user_dir =
+ (!strEqual(artwork_new->basepath, OPTIONS_ARTWORK_DIRECTORY(type)));
+
+ /* (may use ".sort_priority" from "setup_file_hash" above) */
+ artwork_new->color = ARTWORKCOLOR(artwork_new);
+
+ setString(&artwork_new->class_desc, getLevelClassDescription(artwork_new));
+
+ if (setup_file_hash == NULL) /* (after determining ".user_defined") */
+ {
+ if (strEqual(artwork_new->subdir, "."))
+ {
+ if (artwork_new->user_defined)
+ {
+ setString(&artwork_new->identifier, "private");
+ artwork_new->sort_priority = ARTWORKCLASS_PRIVATE;
+ }
+ else
+ {
+ setString(&artwork_new->identifier, "classic");
+ artwork_new->sort_priority = ARTWORKCLASS_CLASSICS;
+ }
+
+ /* set to new values after changing ".sort_priority" */
+ artwork_new->color = ARTWORKCOLOR(artwork_new);
+
+ setString(&artwork_new->class_desc,
+ getLevelClassDescription(artwork_new));
+ }
+ else
+ {
+ setString(&artwork_new->identifier, artwork_new->subdir);
+ }
+
+ setString(&artwork_new->name, artwork_new->identifier);
+ setString(&artwork_new->name_sorting, artwork_new->name);
+ }
+
+#if 0
+ DrawInitText(artwork_new->name, 150, FC_YELLOW);
+#endif
+
+ pushTreeInfo(node_first, artwork_new);
+
+ freeSetupFileHash(setup_file_hash);
+
+ free(directory_path);
+ free(filename);
+
+ return TRUE;
+}
+
+#else
+