Ejemplo n.º 1
0
        /// <summary>
        /// Processes a file for export.  "source" is a string that will
        /// contain a fileName (full path)
        ///
        /// NOTE! : Called from the Progress Window on a SEPARATE THREAD!  Meaning, we cannot
        /// update any controls directly from this function!  Use MethodInvoker or delegate.BeginInvoke
        /// instead!
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        private bool ProcessFileExport(object sender, object source)
        {
            List <Platform> platforms = new List <Platform>(mPlatformsListBox.CheckedItems.Cast <Platform>());

            if (platforms.Count == 0)
            {
                return(false);
            }

            return(mExporter.Export(source, platforms));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Processes the command line
        /// </summary>
        /// <param name="args"></param>
        private static void ProcessCommandLine(CommandLineArgs commandLineArgs)
        {
            // Perform some validation
            if (commandLineArgs.mExport)
            {
                Otter.Interface.Graphics.Instance = new Otter.Interface.Graphics(0);
                int renderContext = Otter.Interface.Graphics.Instance.CreateContext(0, 10, 10);

                ImporterExporter exporter = new ImporterExporter();

                // We need a valid project specified
                if (!System.IO.File.Exists(commandLineArgs.mProject))
                {
                    System.Console.WriteLine("Invalid or no project specified.");
                    Otter.Interface.Graphics.Instance.DestroyContext(renderContext);
                    return;
                }

                // Open the project
                GUIProject.CurrentProject = GUIProject.Load(commandLineArgs.mProject);

                // We need a valid platform specified
                Platform targetPlatform = null;
                foreach (Platform platform in GUIProject.CurrentProject.Platforms)
                {
                    if (platform.Name == commandLineArgs.mPlatform)
                    {
                        targetPlatform = platform;
                        break;
                    }
                }

                if (targetPlatform == null)
                {
                    System.Console.WriteLine("Invalid or no platform specified");
                    Otter.Interface.Graphics.Instance.DestroyContext(renderContext);
                    return;
                }

                // See if we have an output directory override
                string outputDir = targetPlatform.OutputDirectory;
                if (commandLineArgs.mOutputDir != "")
                {
                    outputDir = commandLineArgs.mOutputDir;
                    targetPlatform.OutputDirectory = outputDir;
                }

                // Determine the output directory.  If it's not rooted, we need to construct
                // the rooted path
                string projectDir = System.IO.Path.GetDirectoryName(commandLineArgs.mProject);
                if (!System.IO.Path.IsPathRooted(outputDir))
                {
                    outputDir = projectDir + "\\" + outputDir;
                }

                // Create the output directory and verify that it exists
                System.IO.Directory.CreateDirectory(outputDir);
                if (!System.IO.Directory.Exists(outputDir))
                {
                    System.Console.WriteLine("Invalid output directory for platform " + targetPlatform.Name + " : " + outputDir);
                    Otter.Interface.Graphics.Instance.DestroyContext(renderContext);
                    return;
                }

                ArrayList       itemsToExport = ImporterExporter.GetItemsToExport(GUIProject.CurrentProject.Entries);
                List <Platform> platforms     = new List <Platform>(new Platform[] { targetPlatform });

                // Finally, export.
                foreach (object item in itemsToExport)
                {
                    System.Console.Write("Exporting.. %s : " + item.ToString());
                    bool bSuccess = exporter.Export(item, platforms);
                    System.Console.WriteLine(bSuccess ? " success" : " FAILED");
                }

                Otter.Interface.Graphics.Instance.DestroyContext(renderContext);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Processes the command line
        /// </summary>
        /// <param name="args"></param>
        private static void ProcessCommandLine(CommandLineArgs commandLineArgs)
        {
            // Perform some validation
            if (commandLineArgs.mExport)
            {
                ImporterExporter exporter = new ImporterExporter();

                // We need a valid project specified
                if (!System.IO.File.Exists(commandLineArgs.mProject))
                {
                    System.Console.WriteLine("Invalid or no project specified.");
                    return;
                }

                // Open the project
                GUIProject.CurrentProject = GUIProject.Load(commandLineArgs.mProject);

                // We need a valid platform specified
                Platform targetPlatform = null;
                foreach (Platform platform in GUIProject.CurrentProject.Platforms)
                {
                    if (platform.Name == commandLineArgs.mPlatform)
                    {
                        targetPlatform = platform;
                        break;
                    }
                }

                if (targetPlatform == null)
                {
                    System.Console.WriteLine("Invalid or no platform specified");
                    return;
                }

                // See if we have an output directory override
                string outputDir = targetPlatform.OutputDirectory;
                if (commandLineArgs.mOutputDir != "")
                {
                    outputDir = commandLineArgs.mOutputDir;
                    targetPlatform.OutputDirectory = outputDir;
                }

                // Determine the output directory.  If it's not rooted, we need to construct
                // the rooted path
                string projectDir = System.IO.Path.GetDirectoryName(commandLineArgs.mProject);
                if (!System.IO.Path.IsPathRooted(outputDir))
                    outputDir = projectDir + "\\" + outputDir;

                // Create the output directory and verify that it exists
                System.IO.Directory.CreateDirectory(outputDir);
                if (!System.IO.Directory.Exists(outputDir))
                {
                    System.Console.WriteLine("Invalid output directory for platform " + targetPlatform.Name + " : " + outputDir);
                    return;
                }

                ArrayList itemsToExport = ImporterExporter.GetItemsToExport(GUIProject.CurrentProject.Entries);
                List<Platform> platforms = new List<Platform>(new Platform[] { targetPlatform });

                // Finally, export.
                foreach (object item in itemsToExport)
                {
                    System.Console.Write("Exporting.. %s : " + item.ToString());
                    bool bSuccess = exporter.Export(item, platforms);
                    System.Console.WriteLine(bSuccess ? " success" : " FAILED");
                }
            }
        }