private void extractAllToolStripMenuItem_Click(object sender, EventArgs e) { FolderBrowserDialog fold = new FolderBrowserDialog(); fold.Description = "Select the directory to save the files to"; if (fold.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } for (int i = 0; i < _tpf.GetNumEntries(); i++) { ZipReader.ZipEntryFull ent = _tpf.GetEntry(i); ent.Extract(false, Path.Combine(fold.SelectedPath, ent.Filename)); } }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedIndex < 0) { return; } ZipReader.ZipEntryFull ent = _tpf.GetEntry(listBox1.SelectedIndex); rtb2.Text = ent.Filename + "\n\nCompressed Length: " + ent.ComprSize + "\nUncompressed Length: " + ent.UncomprSize + "\nCompression Ratio: " + ((float)ent.ComprSize / ent.UncomprSize) + "\nCRC-32: " + BitConverter.ToString(BitConverter.GetBytes(ent.CRC)) + "\nComment:\n"; if (String.IsNullOrEmpty(ent.Comment)) { rtb2.Text += "None"; } else { rtb2.Text += ent.Comment; } if (!_autoPreview) { return; } String extension = Path.GetExtension(ent.Filename); if (String.Compare(extension, ".def", true) != 0) { SearchHash(listBox1.SelectedIndex); } if (String.Compare(extension, ".dds", true) == 0) { PreviewTex(ent, true); } else if (String.Compare(extension, ".tga", true) == 0) { PreviewTex(ent, false); } else if (String.Compare(extension, ".def", true) == 0) { PreviewDef(ent); } else if (String.Compare(extension, ".jpg", true) == 0 || String.Compare(extension, ".gif", true) == 0 || String.Compare(extension, ".png", true) == 0) { PreviewImg(ent); } }
private void PreviewTex(ZipReader.ZipEntryFull ent, bool dds) { try { Bitmap img; if (dds) { byte[] data = ent.Extract(true); if (data == null) { throw new NullReferenceException("Data returned was null"); } DDSPreview ddsimg = new DDSPreview(data); //img = DDSImage.ToBitmap(ddsimg.GetMipData(), ddsimg.Format, (int)ddsimg.Width, (int)ddsimg.Height); img = ddsimg.ToBitmap(); } else { ent.Extract(false, "preview.tga"); img = new TargaImage("preview.tga").Image; File.Delete("preview.tga"); } if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); } if (_resize) { pictureBox1.Image = resizeImage(img, new System.Drawing.Size(512, 512)); } else { pictureBox1.Image = img; } pictureBox1.Visible = true; pictureBox1.Refresh(); } catch (Exception exc) { MessageBox.Show("An error occurred: " + exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void extractSelectedToolStripMenuItem_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex < 0) { return; } ZipReader.ZipEntryFull ent = _tpf.GetEntry(listBox1.SelectedIndex); SaveFileDialog saver = new SaveFileDialog(); saver.Title = "Enter the filename to save the extracted file to"; saver.FileName = ent.Filename; if (saver.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } ent.Extract(false, saver.FileName); }
private void PreviewDef(ZipReader.ZipEntryFull ent) { try { byte[] data = ent.Extract(true); if (data == null) { throw new NullReferenceException("Data returned was null"); } pictureBox1.Visible = false; char[] chars = new char[data.Length]; for (int i = 0; i < data.Length; i++) { chars[i] = (char)data[i]; } rtb1.Text = "Texmod.def contents:\n\n" + new string(chars); } catch (Exception exc) { MessageBox.Show("An error occurred: " + exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public TPFTexInfo(string file, ZipReader.ZipEntryFull entry, MEDirectories.MEDirectories gameDirecs) : this(gameDirecs) { ZipEntry = entry; if (Path.IsPathRooted(file)) { FilePath = Path.GetDirectoryName(file); FileName = Path.GetFileName(file); } else FileName = file; }
private void PreviewImg(ZipReader.ZipEntryFull ent) { }