added extracting level and artwork sets from zip files dropped into window
[rocksndiamonds.git] / src / events.c
index f8a888ade1161aafedc37b655bd711f8a5d9858b..90f6615a20f61ee0647a61f58f03b0b586d17791 100644 (file)
@@ -1529,6 +1529,21 @@ void HandleClientMessageEvent(ClientMessageEvent *event)
 static void HandleDropFileEventExt(char *filename)
 {
   Error(ERR_DEBUG, "DROP FILE EVENT: '%s'", filename);
 static void HandleDropFileEventExt(char *filename)
 {
   Error(ERR_DEBUG, "DROP FILE EVENT: '%s'", filename);
+
+  // check and extract dropped zip files into correct user data directory
+  if (strSuffixLower(filename, ".zip"))
+  {
+    int tree_type = GetZipFileTreeType(filename);
+    char *directory = TREE_USERDIR(tree_type);
+
+    if (directory == NULL)
+    {
+      Error(ERR_WARN, "zip file '%s' has invalid content!", filename);
+
+      return;
+    }
+
+    ExtractZipFileIntoDirectory(filename, directory, tree_type);
 }
 
 static void HandleDropTextEventExt(char *text)
 }
 
 static void HandleDropTextEventExt(char *text)