private void HandlePCKNode(EntryTreeNode node) { SoundpackBrowser browser = new SoundpackBrowser(); browser.LoadPack(node.Path); browser.Show(); }
private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node == null || e.Node.Tag == null) { return; } EntryTreeNode node = (EntryTreeNode)e.Node; Forge forge = node.Forge; TreeNode parent = (EntryTreeNode)node.Parent; string text = node.Text; string tag = (string)node.Tag; long size = node.Size; ResourceType type = node.ResourceType; // reset the picture box and rich text box // ToDo: empty 3D viewer pictureBox.ImageLocation = ""; richTextBox.Text = ""; if (tag.Contains(".forge")) { if (text.EndsWith(".forge")) // forge file { // dump resources used by currentForge if (currentForge != null) { currentForge.Dump(); } currentForge = new Forge(tag); node.Forge = currentForge; } else // forge entry/subentry { // forge subentry if (tag.Contains(FORGE_ENTRY_IDENTIFIER) && tag.Contains(FORGE_SUBENTRY_IDENTIFIER)) { if (type == ResourceType.TEXTURE_MAP) { string parentText = Helpers.GetTempPath(parent.Text); if (node.Game == Game.ODYSSEY || node.Game == Game.ORIGINS) { Odyssey.ExtractTextureMap(parentText, forge, () => { if (File.Exists($"{Helpers.GetTempPath(parent.Text)}.png")) { currentImgPath = $"{Helpers.GetTempPath(parent.Text)}.png"; } else if (File.Exists($"{Helpers.GetTempPath(parent.Text)}_TopMip_0.png")) { currentImgPath = $"{Helpers.GetTempPath(parent.Text)}_TopMip_0.png"; } Invoke(new Action(() => { if (!string.IsNullOrEmpty(currentImgPath)) { UpdatePictureBox(Image.FromFile(currentImgPath)); } zoomDropDownButton.Text = "Zoom Level: 100%"; tabControl.SelectedIndex = 1; })); }); } else { Steep.ExtractTextureMap(parentText, forge, () => { if (File.Exists($"{Helpers.GetTempPath(parent.Text)}.png")) { currentImgPath = $"{Helpers.GetTempPath(parent.Text)}.png"; } else if (File.Exists($"{Helpers.GetTempPath(parent.Text)}_Mip0.png")) { currentImgPath = $"{Helpers.GetTempPath(parent.Text)}_Mip0.png"; } Invoke(new Action(() => { if (!string.IsNullOrEmpty(currentImgPath)) { UpdatePictureBox(Image.FromFile(currentImgPath)); } zoomDropDownButton.Text = "Zoom Level: 100%"; tabControl.SelectedIndex = 1; })); }); } } } } } else if (text.EndsWith(".png")) { pictureBox.Image = Image.FromFile(tag); pictureBox.Refresh(); if (pictureBox.Image != null) { imageDimensStatusLabel.Text = $"Dimensions: {pictureBox.Image.Width}x{pictureBox.Image.Height}"; } tabControl.SelectedIndex = 1; } else if (text.EndsWith(".ini") || text.EndsWith(".txt") || text.EndsWith(".log")) { richTextBox.Text = string.Join("\n", File.ReadAllLines(tag)); tabControl.SelectedIndex = 2; } else if (text.EndsWith(".pck")) { SoundpackBrowser browser = new SoundpackBrowser(); browser.LoadPack(tag); browser.Show(); } // update path status label if (!tag.Contains(FORGE_ENTRY_IDENTIFIER)) { pathStatusLabel.Text = tag; } // update size status label if (size > -1) { sizeStatusLabel.Text = $"Size: {Helpers.BytesToString(size)}"; } }