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; }
private void OnClickPKNReset(object sender, EventArgs eventArgs) { TreeNode pknNode = treeView1.SelectedNode; pknNode.Nodes.Clear(); PKNFile pkn = (PKNFile)pknNode.Tag; pkn.Clear(); pkn.Unpack(); _state.SaveProject(); if (pkn.Files.Count != 0) { foreach (BaseFile file in pkn.Files) { TreeNode fileNode = new TreeNode(file.FileName); fileNode.Tag = file; pknNode.Nodes.Add(fileNode); } } pknNode.Expand(); }