added command line option to drop file into program window
[rocksndiamonds.git] / src / init.c
index 2529a8baba97aa4f9b16bab81a2a764ae82ff1d9..e451d99ef862f9cd2d09d081c1ce136e0f8483db 100644 (file)
@@ -5196,6 +5196,7 @@ static void InitGlobal(void)
   global.autoplay_leveldir = NULL;
   global.patchtapes_leveldir = NULL;
   global.convert_leveldir = NULL;
+  global.dumplevelset_leveldir = NULL;
   global.dumplevel_leveldir = NULL;
   global.dumptape_leveldir = NULL;
   global.create_sketch_images_dir = NULL;
@@ -5307,6 +5308,23 @@ static void Execute_Command(char *command)
 
     exit(0);
   }
+  else if (strPrefix(command, "dump levelset "))
+  {
+    char *filename = &command[14];
+
+    if (fileExists(filename) && isLevelsetFilename_BD(filename))
+    {
+      DumpLevelsetFromFilename_BD(filename);
+
+      exit(0);
+    }
+
+    char *leveldir = getStringCopy(filename);  // read command parameters
+
+    global.dumplevelset_leveldir = leveldir;
+
+    program.headless = TRUE;
+  }
   else if (strPrefix(command, "dump level "))
   {
     char *filename = &command[11];
@@ -6691,6 +6709,11 @@ void OpenAll(void)
     ConvertLevels();
     return;
   }
+  else if (global.dumplevelset_leveldir)
+  {
+    DumpLevelset();
+    return;
+  }
   else if (global.dumplevel_leveldir)
   {
     DumpLevels();
@@ -6729,6 +6752,9 @@ void OpenAll(void)
 
   DrawMainMenu();
 
+  if (options.drop_file != NULL)
+    PushDropEvent(options.drop_file);
+
 #if 0
   Debug("internal:path", "SDL_GetBasePath() == '%s'",
        SDL_GetBasePath());