From: Holger Schemel Date: Sat, 30 Jan 2021 19:59:17 +0000 (+0100) Subject: changed custom artwork list to tree structure similar to level sets X-Git-Tag: 4.2.3.0~38 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=7c3347a9ee92b20ca85fb6d8f8f6ac9aa27eb83e;p=rocksndiamonds.git changed custom artwork list to tree structure similar to level sets Before, all available custom artwork sets were presented as a long list in the "custom artwork" setup menu. Now, all custom artwork sets that are part of level sets (including pseudo level sets that only contain custom artwork) are presented as a tree structure similar to the level set selection menu, so it is much easier now to find a custom artwork set related to a level set. --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 5a1b6c7d..aca52f7d 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -3914,6 +3914,7 @@ void LoadArtworkInfo(void) } static void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node, + ArtworkDirTree *node_parent, LevelDirTree *level_node) { int type = (*artwork_node)->type; @@ -3963,7 +3964,38 @@ static void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node, DrawInitText(level_node->name, 150, FC_YELLOW); if (level_node->node_group != NULL) - LoadArtworkInfoFromLevelInfo(artwork_node, level_node->node_group); + { + TreeInfo *artwork_new = newTreeInfo(); + + if (node_parent) + setTreeInfoToDefaultsFromParent(artwork_new, node_parent); + else + setTreeInfoToDefaults(artwork_new, type); + + artwork_new->level_group = TRUE; + + setString(&artwork_new->identifier, level_node->subdir); + setString(&artwork_new->name, level_node->name); + setString(&artwork_new->name_sorting, level_node->name_sorting); + + pushTreeInfo(artwork_node, artwork_new); + + // create node to link back to current custom artwork directory + createParentTreeInfoNode(artwork_new); + + // recursively step into sub-directory and look for more custom artwork + LoadArtworkInfoFromLevelInfo(&artwork_new->node_group, artwork_new, + level_node->node_group); + + // if sub-tree has no custom artwork at all, remove it + if (artwork_new->node_group->next == NULL) + { + *artwork_node = artwork_new->next; + artwork_new->next = NULL; + + freeTreeInfo(artwork_new); + } + } level_node = level_node->next; } @@ -3977,11 +4009,11 @@ void LoadLevelArtworkInfo(void) print_timestamp_time("DrawTimeText"); - LoadArtworkInfoFromLevelInfo(&artwork.gfx_first, leveldir_first_all); + LoadArtworkInfoFromLevelInfo(&artwork.gfx_first, NULL, leveldir_first_all); print_timestamp_time("LoadArtworkInfoFromLevelInfo (gfx)"); - LoadArtworkInfoFromLevelInfo(&artwork.snd_first, leveldir_first_all); + LoadArtworkInfoFromLevelInfo(&artwork.snd_first, NULL, leveldir_first_all); print_timestamp_time("LoadArtworkInfoFromLevelInfo (snd)"); - LoadArtworkInfoFromLevelInfo(&artwork.mus_first, leveldir_first_all); + LoadArtworkInfoFromLevelInfo(&artwork.mus_first, NULL, leveldir_first_all); print_timestamp_time("LoadArtworkInfoFromLevelInfo (mus)"); SaveArtworkInfoCache(); diff --git a/src/screens.c b/src/screens.c index c5df3694..a716f5ea 100644 --- a/src/screens.c +++ b/src/screens.c @@ -6329,6 +6329,23 @@ static void execSetupTouch(void) static void execSetupArtwork(void) { + static ArtworkDirTree *gfx_last_valid = NULL; + static ArtworkDirTree *snd_last_valid = NULL; + static ArtworkDirTree *mus_last_valid = NULL; + + // current artwork directory may be invalid (level group, parent link) + if (!validLevelSeries(artwork.gfx_current)) + artwork.gfx_current = getFirstValidTreeInfoEntry(gfx_last_valid); + if (!validLevelSeries(artwork.snd_current)) + artwork.snd_current = getFirstValidTreeInfoEntry(snd_last_valid); + if (!validLevelSeries(artwork.mus_current)) + artwork.mus_current = getFirstValidTreeInfoEntry(mus_last_valid); + + // store valid artwork directory information + gfx_last_valid = artwork.gfx_current; + snd_last_valid = artwork.snd_current; + mus_last_valid = artwork.mus_current; + #if 0 Debug("screens:execSetupArtwork", "'%s', '%s', '%s'", artwork.gfx_current->subdir,