+ return TREE_TYPE_UNDEFINED;
+ }
+
+ if (tree_type == TREE_TYPE_LEVEL_DIR &&
+ game_status == GAME_MODE_LEVELS &&
+ leveldir_current->node_parent != NULL)
+ {
+ // extract new level set next to currently selected level set
+ tree_node = leveldir_current;
+
+ // get parent directory of currently selected level set directory
+ directory = getLevelDirFromTreeInfo(leveldir_current->node_parent);
+
+ // use private level directory instead of top-level package level directory
+ if (strPrefix(directory, options.level_directory) &&
+ strEqual(leveldir_current->node_parent->fullpath, "."))
+ directory = getUserLevelDir(NULL);
+ }
+
+ // extract level or artwork set from zip file to target directory
+ char *top_dir = ExtractZipFileIntoDirectory(filename, directory, tree_type);
+
+ if (top_dir == NULL)
+ {
+ // error message already issued by "ExtractZipFileIntoDirectory()"
+
+ return TREE_TYPE_UNDEFINED;
+ }
+
+ // add extracted level or artwork set to tree info structure
+ AddTreeSetToTreeInfo(tree_node, directory, top_dir, tree_type);
+
+ // update menu screen (and possibly change current level set)
+ DrawScreenAfterAddingSet(top_dir, tree_type);
+
+ return tree_type;
+}
+
+static void HandleDropTextEvent(char *text)
+{
+ Error(ERR_DEBUG, "DROP TEXT EVENT: '%s'", text);
+}
+
+static void HandleDropCompleteEvent(int num_level_sets_succeeded,
+ int num_artwork_sets_succeeded,
+ int num_files_failed)
+{
+ // only show request dialog if no other request dialog already active
+ if (game.request_active)
+ return;
+
+ // this case can happen with drag-and-drop with older SDL versions
+ if (num_level_sets_succeeded == 0 &&
+ num_artwork_sets_succeeded == 0 &&
+ num_files_failed == 0)
+ return;
+
+ char message[100];
+
+ if (num_level_sets_succeeded > 0 || num_artwork_sets_succeeded > 0)
+ {
+ char message_part1[50];
+
+ sprintf(message_part1, "New %s set%s added",
+ (num_artwork_sets_succeeded == 0 ? "level" :
+ num_level_sets_succeeded == 0 ? "artwork" : "level and artwork"),
+ (num_level_sets_succeeded +
+ num_artwork_sets_succeeded > 1 ? "s" : ""));
+
+ if (num_files_failed > 0)
+ sprintf(message, "%s, but %d dropped file%s failed!",
+ message_part1, num_files_failed, num_files_failed > 1 ? "s" : "");
+ else
+ sprintf(message, "%s!", message_part1);
+ }
+ else if (num_files_failed > 0)
+ {
+ sprintf(message, "Failed to process dropped file%s!",
+ num_files_failed > 1 ? "s" : "");
+ }
+
+ Request(message, REQ_CONFIRM);
+}
+
+void HandleDropEvent(Event *event)
+{
+ static boolean confirm_on_drop_complete = FALSE;
+ static int num_level_sets_succeeded = 0;
+ static int num_artwork_sets_succeeded = 0;
+ static int num_files_failed = 0;
+
+ switch (event->type)
+ {
+ case SDL_DROPBEGIN: