Пример #1
0
        private static void BatchConvertResource(string sourcePath, string destinationPath, ResourceFormat inputFormat, ResourceFormat outputFormat, FileVersion fileVersion)
        {
            try
            {
                CommandLineLogger.LogDebug($"Using destination extension: {outputFormat}");

                ResourceUtils resourceUtils = new ResourceUtils();
                resourceUtils.ConvertResources(sourcePath, destinationPath, inputFormat, outputFormat, fileVersion);

                CommandLineLogger.LogInfo($"Wrote resources to: {destinationPath}");
            }
            catch (Exception e)
            {
                CommandLineLogger.LogFatal($"Failed to batch convert resources: {e.Message}", 2);
                CommandLineLogger.LogTrace($"{e.StackTrace}");
            }
        }
Пример #2
0
        private void resourceBulkConvertBtn_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(resourceInputDir.Text) || String.IsNullOrEmpty(resourceOutputDir.Text))
            {
                MessageBox.Show("Please specify both input and output file path first!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                var inputFormat = ResourceFormat.LSX;
                switch (resourceInputFormatCb.SelectedIndex)
                {
                case 0:
                {
                    inputFormat = ResourceFormat.LSX;
                    break;
                }

                case 1:
                {
                    inputFormat = ResourceFormat.LSB;
                    break;
                }

                case 2:
                {
                    inputFormat = ResourceFormat.LSF;
                    break;
                }

                case 3:
                {
                    inputFormat = ResourceFormat.LSJ;
                    break;
                }
                }

                var         outputFormat  = ResourceFormat.LSF;
                FileVersion outputVersion = 0x0;

                switch (resourceOutputFormatCb.SelectedIndex)
                {
                case 0:
                {
                    outputFormat = ResourceFormat.LSX;
                    break;
                }

                case 1:
                {
                    outputFormat = ResourceFormat.LSB;
                    break;
                }

                case 2:
                {
                    outputFormat  = ResourceFormat.LSF;
                    outputVersion = _form.GetGame().IsDOS2() ? FileVersion.VerExtendedNodes : FileVersion.VerChunkedCompress;
                    break;
                }

                case 3:
                {
                    outputFormat = ResourceFormat.LSJ;
                    break;
                }
                }

                try
                {
                    resourceConvertBtn.Enabled = false;
                    var utils = new ResourceUtils();
                    utils.progressUpdate += ResourceProgressUpdate;
                    utils.ConvertResources(resourceInputDir.Text, resourceOutputDir.Text, inputFormat, outputFormat, outputVersion);

                    MessageBox.Show("Resources converted successfully.");
                }
                catch (Exception exc)
                {
                    MessageBox.Show($"Internal error!{Environment.NewLine}{Environment.NewLine}{exc}", "Conversion Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    resourceProgressLabel.Text       = "";
                    resourceConversionProgress.Value = 0;
                    resourceConvertBtn.Enabled       = true;
                }
            }
        }
Пример #3
0
        private void resourceBulkConvertBtn_Click(object sender, EventArgs e)
        {
            var inputFormat = ResourceFormat.LSX;

            switch (resourceInputFormatCb.SelectedIndex)
            {
            case 0:
            {
                inputFormat = ResourceFormat.LSX;
                break;
            }

            case 1:
            {
                inputFormat = ResourceFormat.LSB;
                break;
            }

            case 2:
            {
                inputFormat = ResourceFormat.LSF;
                break;
            }

            case 3:
            {
                inputFormat = ResourceFormat.LSJ;
                break;
            }
            }

            var         outputFormat  = ResourceFormat.LSF;
            FileVersion outputVersion = 0x0;

            switch (resourceOutputFormatCb.SelectedIndex)
            {
            case 0:
            {
                outputFormat = ResourceFormat.LSX;
                break;
            }

            case 1:
            {
                outputFormat = ResourceFormat.LSB;
                break;
            }

            case 2:
            {
                outputFormat  = ResourceFormat.LSF;
                outputVersion = _form.GetGame().LSFVersion();
                break;
            }

            case 3:
            {
                outputFormat = ResourceFormat.LSJ;
                break;
            }
            }

            try
            {
                resourceConvertBtn.Enabled = false;
                var utils = new ResourceUtils();
                utils.progressUpdate += ResourceProgressUpdate;
                utils.ConvertResources(resourceInputDir.Text, resourceOutputDir.Text, inputFormat, outputFormat, outputVersion);

                MessageBox.Show("Resources converted successfully.");
            }
            catch (Exception exc)
            {
                MessageBox.Show($"Internal error!{Environment.NewLine}{Environment.NewLine}{exc}", "Conversion Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                resourceProgressLabel.Text       = "";
                resourceConversionProgress.Value = 0;
                resourceConvertBtn.Enabled       = true;
            }
        }
Пример #4
0
        private void resourceBulkConvertBtn_Click(object sender, EventArgs e)
        {
            ResourceFormat inputFormat = ResourceFormat.LSX;

            switch (resourceInputFormatCb.SelectedIndex)
            {
            case 0:
                inputFormat = ResourceFormat.LSX;
                break;

            case 1:
                inputFormat = ResourceFormat.LSB;
                break;

            case 2:
                inputFormat = ResourceFormat.LSF;
                break;
            }

            ResourceFormat outputFormat  = ResourceFormat.LSF;
            int            outputVersion = -1;

            switch (resourceOutputFormatCb.SelectedIndex)
            {
            case 0:
                outputFormat = ResourceFormat.LSX;
                break;

            case 1:
                outputFormat = ResourceFormat.LSB;
                break;

            case 2:
                outputFormat = ResourceFormat.LSF;
                if (GetGame() == DivGame.DOS2)
                {
                    outputVersion = (int)FileVersion.VerExtendedNodes;
                }
                else
                {
                    outputVersion = (int)FileVersion.VerChunkedCompress;
                }
                break;
            }

            try
            {
                resourceConvertBtn.Enabled = false;
                var utils = new ResourceUtils();
                utils.progressUpdate += this.ResourceProgressUpdate;
                utils.ConvertResources(resourceInputDir.Text, resourceOutputDir.Text, inputFormat, outputFormat, outputVersion);
                MessageBox.Show("Resources converted successfully.");
            }
            catch (Exception exc)
            {
                MessageBox.Show("Internal error!\r\n\r\n" + exc.ToString(), "Conversion Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                resourceProgressLabel.Text       = "";
                resourceConversionProgress.Value = 0;
                resourceConvertBtn.Enabled       = true;
            }
        }
Пример #5
0
        private void resourceBulkConvertBtn_Click(object sender, EventArgs e)
        {
            ResourceFormat inputFormat = ResourceFormat.LSX;
            switch (resourceInputFormatCb.SelectedIndex)
            {
                case 0:
                    inputFormat = ResourceFormat.LSX;
                    break;

                case 1:
                    inputFormat = ResourceFormat.LSB;
                    break;

                case 2:
                    inputFormat = ResourceFormat.LSF;
                    break;
            }

            ResourceFormat outputFormat = ResourceFormat.LSF;
            int outputVersion = -1;
            switch (resourceOutputFormatCb.SelectedIndex)
            {
                case 0:
                    outputFormat = ResourceFormat.LSX;
                    break;

                case 1:
                    outputFormat = ResourceFormat.LSB;
                    break;

                case 2:
                    outputFormat = ResourceFormat.LSF;
                    if (GetGame() == DivGame.DOS2)
                    {
                        outputVersion = (int)FileVersion.VerExtendedNodes;
                    }
                    else
                    {
                        outputVersion = (int)FileVersion.VerChunkedCompress;
                    }
                    break;
            }

            try
            {
                resourceConvertBtn.Enabled = false;
                var utils = new ResourceUtils();
                utils.progressUpdate += this.ResourceProgressUpdate;
                utils.ConvertResources(resourceInputDir.Text, resourceOutputDir.Text, inputFormat, outputFormat, outputVersion);
                MessageBox.Show("Resources converted successfully.");
            }
            catch (Exception exc)
            {
                MessageBox.Show("Internal error!\r\n\r\n" + exc.ToString(), "Conversion Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                resourceProgressLabel.Text = "";
                resourceConversionProgress.Value = 0;
                resourceConvertBtn.Enabled = true;
            }
        }