From ab00bcd09aae77a5af893267f984610cc8cb8c99 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Thu, 25 Jul 2019 09:43:34 -0400 Subject: [PATCH] Add batch export for lm2 textures --- .../FileFormats/Archives/LM2/TexturePOWE.cs | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/File_Format_Library/FileFormats/Archives/LM2/TexturePOWE.cs b/File_Format_Library/FileFormats/Archives/LM2/TexturePOWE.cs index 16c0d5a1..e7b0333f 100644 --- a/File_Format_Library/FileFormats/Archives/LM2/TexturePOWE.cs +++ b/File_Format_Library/FileFormats/Archives/LM2/TexturePOWE.cs @@ -10,6 +10,56 @@ using System.Windows.Forms; namespace FirstPlugin.LuigisMansion.DarkMoon { + public class TextureFolder : TreeNodeCustom, IContextMenuNode + { + public TextureFolder(string text) + { + Text = text; + } + + public ToolStripItem[] GetContextMenuItems() + { + List Items = new List(); + Items.Add(new ToolStripMenuItem("Export", null, ExportAll, Keys.Control | Keys.E)); + return Items.ToArray(); + } + + private void ExportAll(object sender, EventArgs args) + { + List Formats = new List(); + Formats.Add("Microsoft DDS (.dds)"); + Formats.Add("Portable Graphics Network (.png)"); + Formats.Add("Joint Photographic Experts Group (.jpg)"); + Formats.Add("Bitmap Image (.bmp)"); + Formats.Add("Tagged Image File Format (.tiff)"); + + FolderSelectDialog sfd = new FolderSelectDialog(); + + if (sfd.ShowDialog() == DialogResult.OK) + { + string folderPath = sfd.SelectedPath; + + BatchFormatExport form = new BatchFormatExport(Formats); + if (form.ShowDialog() == DialogResult.OK) + { + foreach (STGenericTexture tex in Nodes) + { + if (form.Index == 0) + tex.SaveDDS(folderPath + '\\' + tex.Text + ".dds"); + else if (form.Index == 1) + tex.SaveBitMap(folderPath + '\\' + tex.Text + ".png"); + else if (form.Index == 2) + tex.SaveBitMap(folderPath + '\\' + tex.Text + ".jpg"); + else if (form.Index == 3) + tex.SaveBitMap(folderPath + '\\' + tex.Text + ".bmp"); + else if (form.Index == 4) + tex.SaveBitMap(folderPath + '\\' + tex.Text + ".tiff"); + } + } + } + } + } + public class TexturePOWE : STGenericTexture { public static readonly uint Identifier = 0xE977D350;