From 84dcc875064a4119c26c42ae72eef4d297c28833 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Mon, 11 Oct 2021 17:00:33 -0400 Subject: [PATCH] Quick fix for mtxt right click saving --- .../FileFormats/Texture/MTXT.cs | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/File_Format_Library/FileFormats/Texture/MTXT.cs b/File_Format_Library/FileFormats/Texture/MTXT.cs index 402e48df..6d4d0aed 100644 --- a/File_Format_Library/FileFormats/Texture/MTXT.cs +++ b/File_Format_Library/FileFormats/Texture/MTXT.cs @@ -2,13 +2,13 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; +using System.Windows.Forms; using Toolbox.Library; using Toolbox.Library.IO; namespace FirstPlugin { - public class MTXT : TreeNodeFile, IFileFormat, ITextureContainer + public class MTXT : TreeNodeFile, IFileFormat, ITextureContainer, IContextMenuNode { public FileType FileType { get; set; } = FileType.Image; @@ -40,6 +40,26 @@ namespace FirstPlugin this.TreeView.SelectedNode = Nodes[0]; } + public ToolStripItem[] GetContextMenuItems() + { + return new ToolStripItem[] + { + new ToolStripMenuItem("Save", null, Save, Keys.Control | Keys.S), + }; + } + + private void Save(object sender, EventArgs args) + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.DefaultExt = "bctex"; + sfd.Filter = "Supported Formats|*.bctex;"; + sfd.FileName = FileName; + + if (sfd.ShowDialog() == DialogResult.OK) { + STFileSaver.SaveFileFormat(this, sfd.FileName); + } + } + public List TextureList { get; set; } public bool DisplayIcons => false; @@ -53,6 +73,7 @@ namespace FirstPlugin public void Load(System.IO.Stream stream) { Text = this.FileName; + Tag = this; using (var reader = new FileReader(stream)) { @@ -65,7 +86,6 @@ namespace FirstPlugin } - private void ReadTextureBinary(byte[] data) { using (var reader = new FileReader(data)) @@ -91,7 +111,6 @@ namespace FirstPlugin TextureFile = new XTX(); TextureFile.FileName = textureName; TextureFile.Load(stream); - this.Tag = TextureFile; foreach (STGenericTexture node in TextureFile.Nodes) Nodes.Add(node);