From 375d84a0da3b1254915bd034fe327f094e87a4a1 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 5 Dec 2023 19:05:08 +0100 Subject: [PATCH] added forcing user to restart program after adding level collection When adding a level group or an artwork group by dropping a zip file into the program window, show a request dialog that the program has to be restarted to activate the new content. Unfortunately, this is currently required to rebuild the internal level and artwork set structures (and should be improved to be rebuild them on-the-fly without a program restart). Before, the program was just stopped with a user-unfriendly message reporting a fatal error. --- src/events.c | 9 +++++++++ src/libgame/setup.c | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/src/events.c b/src/events.c index d9ba0586..87eaa2b9 100644 --- a/src/events.c +++ b/src/events.c @@ -1551,6 +1551,15 @@ static int HandleDropFileEvent(char *filename) // add extracted level or artwork set to tree info structure AddTreeSetToTreeInfo(tree_node, directory, top_dir, tree_type); + // force restart after adding level collection + if (getTreeInfoFromIdentifier(TREE_FIRST_NODE(tree_type), top_dir) == NULL) + { + Request("Program must be restarted after adding a new level collection!", + REQ_CONFIRM); + + CloseAllAndExit(0); + } + // update menu screen (and possibly change current level set) DrawScreenAfterAddingSet(top_dir, tree_type); diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 493fc74e..b419875a 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -4594,6 +4594,12 @@ static boolean AddTreeSetToTreeInfoExt(TreeInfo *tree_node_old, char *tree_dir, TreeInfo *tree_node_new = getTreeInfoFromIdentifier(*tree_node_first, tree_subdir_new); + // if not found, check if added node is level group or artwork group + if (tree_node_new == NULL) + tree_node_new = getTreeInfoFromIdentifierExt(*tree_node_first, + tree_subdir_new, + TREE_NODE_TYPE_GROUP); + if (tree_node_new == NULL) // should not happen return FALSE; -- 2.34.1