コード例 #1
0
        private void lZBDeCompressorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter      = "LZB File (*.LZB)|*.LZB|OUT File (*.OUT)|*.OUT|Other Files|*.*";
            openFileDialog.FilterIndex = 0;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string extension = Path.GetExtension(openFileDialog.FileName).ToUpper();
                if (extension == ".LZB")
                {
                    LZBFile lzbFile = new LZBFile(openFileDialog.FileName);

                    TaskProgress progress = new TaskProgress();
                    progress.TaskDone += ProgressOnTaskDone;
                    Enabled            = false;
                    lzbFile.Decompress();
                    Enabled = true;
                }
                else if (extension == ".OUT")
                {
                    LZBFile lzbFile = new LZBFile();
                    lzbFile.DecompressedFile = new BaseFile(openFileDialog.FileName);
                    lzbFile.HeaderFile       = new BaseFile(Path.GetDirectoryName(openFileDialog.FileName) + "\\" + Path.GetFileNameWithoutExtension(openFileDialog.FileName) + ".HEADER");
                    lzbFile.FilePath         = Path.GetDirectoryName(openFileDialog.FileName) + "\\" + Path.GetFileNameWithoutExtension(openFileDialog.FileName);

                    TaskProgress progress = new TaskProgress();
                    progress.TaskDone += ProgressOnTaskDone;
                    Enabled            = false;
                    lzbFile.Compress();
                    Enabled = true;
                }
                else
                {
                    LZBFile          lzbFile          = new LZBFile();
                    SelectModeWindow selectModeWindow = new SelectModeWindow();
                    if (selectModeWindow.ShowDialog() == DialogResult.OK)
                    {
                        string headerPath = openFileDialog.FileName + ".HEADER";
                        using (BinaryWriter writer = new BinaryWriter(new FileStream(headerPath, FileMode.Create)))
                        {
                            writer.Write(LZSSHeader.Empty(selectModeWindow.Mode).GetBytes());
                        }
                        string outputPath = openFileDialog.FileName + ".OUT";
                        File.Copy(openFileDialog.FileName, outputPath);

                        lzbFile.HeaderFile       = new BaseFile(headerPath);
                        lzbFile.DecompressedFile = new BaseFile(outputPath);
                        lzbFile.FilePath         = openFileDialog.FileName + ".LZB";

                        TaskProgress progress = new TaskProgress();
                        progress.TaskDone += ProgressOnTaskDone;
                        Enabled            = false;
                        lzbFile.Compress();
                        Enabled = true;
                    }
                }
            }
        }
コード例 #2
0
        private void OnClickLZBCompress(object sender, EventArgs eventArgs)
        {
            LZBFile lzb = (LZBFile)treeView1.SelectedNode.Tag;

            Enabled = false;
            if (!lzb.Compress())
            {
                MessageBox.Show("There is nothing to compress!");
                Enabled = true;
                return;
            }
            _state.SaveProject();
            Enabled = true;

            //UpdateTreeNodes();
        }
コード例 #3
0
        public void CompressScripts()
        {
            if (ApplicationState.Instance.ProjectFile == null)
            {
                MessageBox.Show("Open a project file before compressing!", "Project file not found!");
                return;
            }

            for (int i = 0; i < ScriptFile.Scripts.Count; i++)
            {
                ScriptDocument scriptFile = ScriptFile.Scripts[i];

                //Don't touch those file! - (can) Softlock the engine, and we dont need to modify gamelogic to that degree
                if (scriptFile.Name == "FLAG.TXT")
                {
                    continue;
                }

                //Enforce correct end of file as done by other conan files (prevents softlock on EOF)
                scriptFile.TextBuffer += "\r\n\r\n\r\n\r\n";

                scriptFile.WriteToOriginalFile();
                if (scriptFile.BaseFile.GetType() == typeof(LZBFile))
                {
                    LZBFile lzbFile = (LZBFile)scriptFile.BaseFile;
                    lzbFile.Compress(false);
                }
                Invoke((MethodInvoker) delegate
                {
                    progressBar_Progress.Value = (int)((double)i / ScriptFile.Scripts.Count * 100);
                });
            }

            Invoke((MethodInvoker) delegate
            {
                progressBar_Progress.Value = 0;
                Enabled = true;
            });
        }
コード例 #4
0
        private void OnCompressClick(object sender, EventArgs eventArgs)
        {
            if (ScriptFile.Scripts.Count == 0)
            {
                MessageBox.Show("Decompress all first!");
                return;
            }
            if (listBox_ScriptFiles.SelectedIndex == -1)
            {
                return;
            }
            Enabled = false;
            ScriptDocument file = ScriptFile.Scripts[listBox_ScriptFiles.SelectedIndex];

            file.TextBuffer = richTextBox_ScriptFile.Text.Replace("\n", "\r\n");
            file.WriteToOriginalFile();
            if (file.BaseFile.GetType() == typeof(LZBFile))
            {
                LZBFile lzbFile = (LZBFile)file.BaseFile;
                lzbFile.Compress(false);
            }
            Enabled = true;
        }