Exemple #1
0
        private static void CreatePackageResource(string file = "")
        {
            if (string.IsNullOrEmpty(file))
            {
                file = CommandLineActions.DestinationPath;
                CommandLineLogger.LogDebug($"Using destination path: {file}");
            }

            var options = new PackageCreationOptions();

            options.Version = CommandLineActions.PackageVersion;

            Dictionary <string, object> compressionOptions = CommandLineArguments.GetCompressionOptions(Path.GetExtension(file)?.ToLower() == ".lsv" ? "zlib" : Args.CompressionMethod, options.Version);

            options.Compression     = (CompressionMethod)compressionOptions["Compression"];
            options.FastCompression = (bool)compressionOptions["FastCompression"];

            var fast = options.FastCompression ? "Fast" : "Normal";

            CommandLineLogger.LogDebug($"Using compression method: {options.Compression.ToString()} ({fast})");

            var packager = new Packager();

            packager.CreatePackage(file, CommandLineActions.SourcePath, options);

            CommandLineLogger.LogInfo("Package created successfully.");
        }
Exemple #2
0
        /// <summary>
        /// Pack up unpacked savegame (lsx->lsv)
        /// </summary>
        public async Task PackSavegameAsync(IProgress <string> progress)
        {
            // update progress
            progress.Report("Compressing package.");
            await Task.Delay(1);

            // compress .lsx
            var global        = ResourceUtils.LoadResource(UnpackDirectory + Path.DirectorySeparatorChar + "globals.lsx");
            var outputVersion = GameVersion == Game.DivinityOriginalSin2
                ? FileVersion.VerExtendedNodes
                : FileVersion.VerChunkedCompress;

            ResourceUtils.SaveResource(global, UnpackDirectory + Path.DirectorySeparatorChar + "globals.lsf",
                                       ResourceFormat.LSF, outputVersion);

            // delete .lsx
            File.Delete(UnpackDirectory + Path.DirectorySeparatorChar + "globals.lsx");
            File.Delete(UnpackDirectory + Path.DirectorySeparatorChar + "meta.lsx");

            // update progress
            progress.Report("Packing savegame.");
            await Task.Delay(1);

            // packup to .lsv
            var packager = new Packager();

            packager.CreatePackage(SavegameFullFile, UnpackDirectory, PackageVersion.V13, CompressionMethod.LZ4, false);
        }
Exemple #3
0
 private static bool RunPackagingSequence(PreConfigurationState preConfigurationState, ApplicationData applicationData, out PackagedApplication packagedApplication)
 {
     try
     {
         var packager = new Packager(applicationData, preConfigurationState.InstallerOutputDestination);
         packagedApplication = packager.CreatePackage();
         return(true);
     }
     catch (Exception ex)
     {
         HostCore.Log.Error("Packaging failed", ex);
         MessageReporter.Show(FormatMessageFor(ex) + "\r\nCheck the log files or the extended information for troubleshooting.",
                              "Packaging failed!", ex, MessageBoxButtons.OK, MessageBoxIcon.Error);
         // ToDo: Clean up first!
         packagedApplication = null;
         return(false);
     }
 }
        /// <summary>
        /// Pack up unpacked savegame (lsx->lsv)
        /// </summary>
        public void PackSavegame()
        {
            // compress .lsx
            var global        = ResourceUtils.LoadResource(UnpackDirectory + Path.DirectorySeparatorChar + "globals.lsx");
            var outputVersion = GameVersion == Game.DivinityOriginalSin2
                ? FileVersion.VerExtendedNodes
                : FileVersion.VerChunkedCompress;

            ResourceUtils.SaveResource(global, UnpackDirectory + Path.DirectorySeparatorChar + "globals.lsf",
                                       ResourceFormat.LSF, outputVersion);

            // delete .lsx
            File.Delete(UnpackDirectory + Path.DirectorySeparatorChar + "globals.lsx");

            // packup to .lsv
            var packager = new Packager();

            packager.CreatePackage(SavegameFullFile, UnpackDirectory, PackageVersion.V13, CompressionMethod.LZ4, false);
        }
Exemple #5
0
        private static void CreatePackageResource(string file = "")
        {
            if (string.IsNullOrEmpty(file))
            {
                file = CommandLineActions.DestinationPath;
                CommandLineLogger.LogDebug($"Using destination path: {file}");
            }

            PackageVersion packageVersion = CommandLineActions.PackageVersion;
            Dictionary <string, object> compressionOptions = CommandLineArguments.GetCompressionOptions(Path.GetExtension(file)?.ToLower() == ".lsv" ? "zlib" : Args.CompressionMethod, packageVersion);

            CompressionMethod compressionMethod = (CompressionMethod)compressionOptions["Compression"];
            bool compressionSpeed = (bool)compressionOptions["FastCompression"];

            CommandLineLogger.LogDebug($"Using compression method: {compressionMethod.ToString()}");
            CommandLineLogger.LogDebug($"Using fast compression: {compressionSpeed}");

            Packager packager = new Packager();

            packager.CreatePackage(file, CommandLineActions.SourcePath, packageVersion, compressionMethod, compressionSpeed);

            CommandLineLogger.LogInfo("Package created successfully.");
        }
Exemple #6
0
        private void createPackageBtn_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(createSrcPath.Text) || String.IsNullOrEmpty(createPackagePath.Text))
            {
                MessageBox.Show("Please specify both Package and Destination paths first!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                createPackageBtn.Enabled = false;
                _displayTimer            = null;

                try
                {
                    var options = new PackageCreationOptions();
                    switch (packageVersion.SelectedIndex)
                    {
                    case 0:
                    case 1:
                    {
                        options.Version = PackageVersion.V13;
                        break;
                    }

                    case 2:
                    {
                        options.Version = PackageVersion.V10;
                        break;
                    }

                    case 3:
                    {
                        options.Version = PackageVersion.V9;
                        break;
                    }

                    case 4:
                    {
                        options.Version = PackageVersion.V7;
                        break;
                    }
                    }

                    switch (compressionMethod.SelectedIndex)
                    {
                    case 1:
                    {
                        options.Compression = CompressionMethod.Zlib;
                        break;
                    }

                    case 2:
                    {
                        options.Compression     = CompressionMethod.Zlib;
                        options.FastCompression = false;
                        break;
                    }

                    case 3:
                    {
                        options.Compression = CompressionMethod.LZ4;
                        break;
                    }

                    case 4:
                    {
                        options.Compression     = CompressionMethod.LZ4;
                        options.FastCompression = false;
                        break;
                    }
                    }

                    // Fallback to Zlib, if the package version doesn't support LZ4
                    if (options.Compression == CompressionMethod.LZ4 && options.Version <= PackageVersion.V9)
                    {
                        options.Compression = CompressionMethod.Zlib;
                    }

                    if (solid.Checked)
                    {
                        options.Flags |= PackageFlags.Solid;
                    }

                    if (allowMemoryMapping.Checked)
                    {
                        options.Flags |= PackageFlags.AllowMemoryMapping;
                    }

                    if (preloadIntoCache.Checked)
                    {
                        options.Flags |= PackageFlags.Preload;
                    }

                    options.Priority = (byte)packagePriority.Value;

                    var packager = new Packager();
                    packager.ProgressUpdate += PackageProgressUpdate;
                    packager.CreatePackage(createPackagePath.Text, createSrcPath.Text, options);

                    MessageBox.Show("Package created successfully.");
                }
                catch (Exception exc)
                {
                    MessageBox.Show($"Internal error!{Environment.NewLine}{Environment.NewLine}{exc}", "Package Build Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    packageProgressLabel.Text = "";
                    packageProgress.Value     = 0;
                    createPackageBtn.Enabled  = true;
                }
            }
        }
Exemple #7
0
        private void createPackageBtn_Click(object sender, EventArgs e)
        {
            createPackageBtn.Enabled = false;
            _displayTimer            = null;

            try
            {
                PackageVersion version = Package.CurrentVersion;
                switch (packageVersion.SelectedIndex)
                {
                case 0:
                {
                    version = PackageVersion.V13;
                    break;
                }

                case 1:
                {
                    version = PackageVersion.V10;
                    break;
                }

                case 2:
                {
                    version = PackageVersion.V9;
                    break;
                }

                case 3:
                {
                    version = PackageVersion.V7;
                    break;
                }
                }

                var compression     = CompressionMethod.None;
                var fastCompression = true;
                switch (compressionMethod.SelectedIndex)
                {
                case 1:
                {
                    compression = CompressionMethod.Zlib;
                    break;
                }

                case 2:
                {
                    compression     = CompressionMethod.Zlib;
                    fastCompression = false;
                    break;
                }

                case 3:
                {
                    compression = CompressionMethod.LZ4;
                    break;
                }

                case 4:
                {
                    compression     = CompressionMethod.LZ4;
                    fastCompression = false;
                    break;
                }
                }

                // Fallback to Zlib, if the package version doesn't support LZ4
                if (compression == CompressionMethod.LZ4 && version <= PackageVersion.V9)
                {
                    compression = CompressionMethod.Zlib;
                }

                var packager = new Packager();
                packager.ProgressUpdate += PackageProgressUpdate;
                packager.CreatePackage(createPackagePath.Text, createSrcPath.Text, version, compression, fastCompression);

                MessageBox.Show("Package created successfully.");
            }
            catch (Exception exc)
            {
                MessageBox.Show($"Internal error!{Environment.NewLine}{Environment.NewLine}{exc}", "Package Build Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                packageProgressLabel.Text = "";
                packageProgress.Value     = 0;
                createPackageBtn.Enabled  = true;
            }
        }
Exemple #8
0
        private void createPackageBtn_Click(object sender, EventArgs e)
        {
            createPackageBtn.Enabled = false;
            try
            {
                uint version = Package.CurrentVersion;
                switch (packageVersion.SelectedIndex)
                {
                case 0:
                    version = 13;
                    break;

                case 1:
                    version = 10;
                    break;

                case 2:
                    version = 9;
                    break;

                case 3:
                    version = 7;
                    break;
                }

                CompressionMethod compression = CompressionMethod.None;
                bool fastCompression          = true;
                switch (compressionMethod.SelectedIndex)
                {
                case 1:
                    compression = CompressionMethod.Zlib;
                    break;

                case 2:
                    compression     = CompressionMethod.Zlib;
                    fastCompression = false;
                    break;

                case 3:
                    compression = CompressionMethod.LZ4;
                    break;

                case 4:
                    compression     = CompressionMethod.LZ4;
                    fastCompression = false;
                    break;
                }

                // Fallback to Zlib, if the package version doesn't support LZ4
                if (compression == CompressionMethod.LZ4 && version <= 9)
                {
                    compression = CompressionMethod.Zlib;
                }

                var packager = new Packager();
                packager.progressUpdate += this.PackageProgressUpdate;
                packager.CreatePackage(packagePath.Text, extractionPath.Text, version, compression, fastCompression);
                MessageBox.Show("Package created successfully.");
            }
            catch (Exception exc)
            {
                MessageBox.Show("Internal error!\r\n\r\n" + exc.ToString(), "Package Build Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                packageProgressLabel.Text = "";
                packageProgress.Value     = 0;
                createPackageBtn.Enabled  = true;
            }
        }