added forcing user to restart program after adding level collection
authorHolger Schemel <info@artsoft.org>
Tue, 5 Dec 2023 18:05:08 +0000 (19:05 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 5 Dec 2023 18:05:29 +0000 (19:05 +0100)
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
src/libgame/setup.c

index d9ba05860c5c30011bd6591314127116e1766af6..87eaa2b9be911593392a6107d15413ee3ec6fab3 100644 (file)
@@ -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);
 
index 493fc74e53283bc6dacc901bc5e6e7ec783c4e5d..b419875a580e8fd1f87eab476ec4b496f232db7c 100644 (file)
@@ -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;