Пример #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
        public ScriptDocument(BaseFile baseFile)
        {
            BaseFile = baseFile;

            string filePath;

            if (baseFile.GetType() == typeof(LZBFile))
            {
                LZBFile lzbFile = (LZBFile)baseFile;
                if (lzbFile.DecompressedFile == null)
                {
                    lzbFile.Decompress();
                }
                filePath = lzbFile.DecompressedFile.FilePath;
            }
            else
            {
                filePath = baseFile.FilePath;
            }

            using (BinaryReader reader = new BinaryReader(new FileStream(filePath, FileMode.Open)))
            {
                byte[] charArray = new byte[reader.BaseStream.Length];
                reader.Read(charArray, 0, charArray.Length);
                TextBuffer = _shiftJist.GetString(charArray);
                TextBuffer = TextBuffer.Trim('\0');
            }
        }
Пример #3
0
        private void OnClickPKNUnpackDecompAll(object sender, EventArgs eventArgs)
        {
            if (treeView1.SelectedNode == null)
            {
                return;
            }
            if (treeView1.SelectedNode.Tag == null)
            {
                return;
            }

            Enabled = false;

            if (treeView1.SelectedNode.Tag.GetType() == typeof(PKNFile))
            {
                PKNFile pknFile = (PKNFile)treeView1.SelectedNode.Tag;
                foreach (BaseFile file in pknFile.Files)
                {
                    if (file.GetType() == typeof(LZBFile))
                    {
                        LZBFile lzbFile = (LZBFile)file;
                        lzbFile.Decompress();
                    }
                }
            }
            _state.SaveProject();
            Enabled = true;
        }
Пример #4
0
        private void OnClickLZBDecompress(object sender, EventArgs eventArgs)
        {
            TreeNode lzbNode = treeView1.SelectedNode;
            //lzbNode.Nodes.Clear();

            LZBFile lzb = (LZBFile)lzbNode.Tag;

            Enabled = false;
            lzb.Decompress();
            Enabled = true;
            _state.SaveProject();

            //UpdateTreeNodes();
        }
Пример #5
0
        public void DecompressScripts()
        {
            if (ApplicationState.Instance.ProjectFile == null)
            {
                MessageBox.Show("Open a project file before decompressing!", "Project file not found!");
                return;
            }
            PSXImage modifiedImage = ApplicationState.Instance.ProjectFile.ModifiedImage;

            _scriptPKN = modifiedImage.PKNFiles.Find(pkn => pkn.Name == "SCRIPT");
            if (_scriptPKN == null)
            {
                return;
            }
            if (_scriptPKN.Files.Count == 0) //cheap fix for when pkn files dont save files
            {
                _scriptPKN.Unpack();
            }
            Enabled = false;

            ScriptFile = new ScriptFile();

            richTextBox_ScriptFile.Text = "";
            for (int i = 0; i < _scriptPKN.Files.Count; i++)
            {
                BaseFile baseFile = _scriptPKN.Files[i];
                if (baseFile.GetType() == typeof(LZBFile))
                {
                    LZBFile lzbFile = (LZBFile)baseFile;
                    lzbFile.Decompress();
                }
                ScriptDocument scriptFile = new ScriptDocument(baseFile);
                ScriptFile.Scripts.Add(scriptFile);
                progressBar_Progress.Value = (int)((double)i / _scriptPKN.Files.Count * 100);
            }
            listBox_ScriptFiles.Items.Clear();
            foreach (ScriptDocument scriptFile in ScriptFile.Scripts)
            {
                listBox_ScriptFiles.Items.Add(scriptFile);
            }

            progressBar_Progress.Value = 0;
            Enabled = true;
        }