private void extractAllToolStripMenuItem_Click(object sender, EventArgs e) { if (treeView.SelectedNode == null) { return; } EntryTreeNode node = (EntryTreeNode)treeView.SelectedNode; Forge forge = node.GetForge(); if (forge != null && forge.FileEntries.Length > 0) { using (FolderBrowserDialog dialog = new FolderBrowserDialog()) { if (dialog.ShowDialog() == DialogResult.OK) { BeginMarquee(); Parallel.ForEach(forge.FileEntries, (fe) => { string name = fe.NameTable.Name; byte[] data = forge.GetRawData(fe); File.WriteAllBytes(Path.Combine(dialog.SelectedPath, name), data); }); EndMarquee(); MessageBox.Show($"Extracted all of {forge.Name}.", "Done"); } } } }
// end Datafile // Forge private void createFilelistToolStripMenuItem_Click(object sender, EventArgs e) { if (treeView.SelectedNode == null) { return; } EntryTreeNode node = (EntryTreeNode)treeView.SelectedNode; Forge forge = node.GetForge(); if (forge != null) { string filelist = forge.CreateFilelist(); if (filelist.Length > 0) { using (SaveFileDialog dialog = new SaveFileDialog()) { dialog.FileName = $"{forge.Name}-filelist.txt"; dialog.Filter = "Text Files|*.txt|All Files|*.*"; if (dialog.ShowDialog() == DialogResult.OK) { File.WriteAllText(dialog.FileName, filelist); MessageBox.Show("Created filelist.", "Done"); } } } } }
// Datafile private void saveRawDataAsToolStripMenuItem_Click(object sender, EventArgs e) { if (treeView.SelectedNode == null) { return; } EntryTreeNode node = (EntryTreeNode)treeView.SelectedNode; Forge forge = node.GetForge(); saveFileDialog.FileName = $"{node.Text}.dat"; saveFileDialog.Filter = "Raw Data|*.dat|All Files|*.*"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { Forge.FileEntry entry = forge.GetFileEntry(node.Text); byte[] data = forge.GetRawData(entry); try { File.WriteAllBytes(saveFileDialog.FileName, data); } catch (IOException ee) { Console.WriteLine(ee); } finally { MessageBox.Show("Extracted decompressed data.", "Success"); } } }
private void saveDecompressedDataAsToolStripMenuItem_Click(object sender, EventArgs e) { if (treeView.SelectedNode == null) { return; } EntryTreeNode node = (EntryTreeNode)treeView.SelectedNode; Forge forge = node.GetForge(); string text = node.Text; byte[] decompressedData = null; BeginMarquee(); Helpers.DoBackgroundWork(() => { Forge.FileEntry entry = forge.GetFileEntry(text); byte[] rawData = forge.GetRawData(entry); decompressedData = Odyssey.ReadFile(rawData); }, () => { EndMarquee(); // failure if (decompressedData.Length == 0 || decompressedData == null) { MessageBox.Show("Could not decompress data.", "Failure"); return; } saveFileDialog.FileName = string.Concat(node.Text, ".", Helpers.ExtensionForGame(node.Game)); saveFileDialog.Filter = $"{Helpers.NameOfGame(node.Game)} Data|*.{Helpers.ExtensionForGame(node.Game)}|All Files|*.*"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { try { File.WriteAllBytes(saveFileDialog.FileName, decompressedData); } catch (IOException ee) { Console.WriteLine(ee); } finally { MessageBox.Show("Done"); } } }); }
private List <EntryTreeNode> PopulateEntry(EntryTreeNode node) { // extract the contents from the forge Forge forge = node.GetForge(); byte[] data = forge.GetRawData(node.Offset, node.Size); // decompress string file = $"{node.Text}.{Helpers.ExtensionForGame(node.Game)}"; if (node.Game == Game.ODYSSEY) { Helpers.WriteToFile(file, Odyssey.ReadFile(data), true); } else if (node.Game == Game.ORIGINS) { Helpers.WriteToFile(file, Odyssey.ReadFile(data), true); } else if (node.Game == Game.STEEP) { Helpers.WriteToFile(file, Steep.ReadFile(data), true); } // path will hold the file name node.Path = file; // get resource locations and create nodes List <EntryTreeNode> nodes = new List <EntryTreeNode>(); using (Stream stream = new FileStream(Helpers.GetTempPath(file), FileMode.Open, FileAccess.Read, FileShare.Read)) { using (BinaryReader reader = new BinaryReader(stream)) { Helpers.ResourceLocation[] locations = Helpers.LocateResourceIdentifiers(reader); foreach (Helpers.ResourceLocation location in locations) { nodes.Add(new EntryTreeNode { Game = node.Game, Path = file, ResourceType = location.Type, Text = location.Type.ToString(), Type = EntryTreeNodeType.SUBENTRY }); } } } return(nodes); }