diff --git a/File_Format_Library/FileFormats/Archives/SARC.cs b/File_Format_Library/FileFormats/Archives/SARC.cs index 9526382e..6e9a3853 100644 --- a/File_Format_Library/FileFormats/Archives/SARC.cs +++ b/File_Format_Library/FileFormats/Archives/SARC.cs @@ -314,6 +314,7 @@ namespace FirstPlugin { ".byaml", "byaml" }, { ".bfres", "bfres" }, { ".sbfres", "bfres" }, + { ".bflim", "texture" }, { ".aamp", "aamp" }, }; } diff --git a/File_Format_Library/FileFormats/Grezzo/CMB.cs b/File_Format_Library/FileFormats/Grezzo/CMB.cs index 5f7b3d0e..b7c18e0e 100644 --- a/File_Format_Library/FileFormats/Grezzo/CMB.cs +++ b/File_Format_Library/FileFormats/Grezzo/CMB.cs @@ -10,7 +10,7 @@ using Toolbox.Library.IO; namespace FirstPlugin { - public class CMB : IFileFormat + public class CMB : TreeNodeFile, IFileFormat, ITextureIconLoader { public FileType FileType { get; set; } = FileType.Layout; @@ -39,12 +39,46 @@ namespace FirstPlugin } public Header header; + STTextureFolder texFolder; + + public List IconTextureList { get; set; } public void Load(System.IO.Stream stream) { + IconTextureList = new List(); + header = new Header(); header.Read(new FileReader(stream)); + + Text = header.Name; + + //Load textures + if (header.SectionData.TextureChunk != null) + { + texFolder = new STTextureFolder("Texture"); + Nodes.Add(texFolder); + + int texIndex = 0; + foreach (var tex in header.SectionData.TextureChunk.Textures) + { + var texWrapper = new CTXB.TextureWrapper(); + texWrapper.Text = $"Texture {texIndex++}"; + texWrapper.ImageKey = "texture"; + texWrapper.SelectedImageKey = texWrapper.ImageKey; + + if (tex.Name != string.Empty) + texWrapper.Text = tex.Name; + + texWrapper.Width = tex.Width; + texWrapper.Height = tex.Height; + texWrapper.Format = CTR_3DS.ConvertPICAToGenericFormat(tex.PicaFormat); + texWrapper.ImageData = tex.ImageData; + texFolder.Nodes.Add(texWrapper); + IconTextureList.Add(texWrapper); + } + } } + public void Unload() { @@ -67,15 +101,21 @@ namespace FirstPlugin public CMBVersion Version; + public uint ChunkCount; //Fixed count per game + + public uint Unknown; + + public SectionData SectionData; + public void Read(FileReader reader) { string magic = reader.ReadSignature(4, "cmb "); uint FileSize = reader.ReadUInt32(); - uint ChunkCount = reader.ReadUInt32(); - uint Unknown = reader.ReadUInt32(); + ChunkCount = reader.ReadUInt32(); + Unknown = reader.ReadUInt32(); Name = reader.ReadString(0x10).TrimEnd('\0'); - + //Check the chunk count used by the game if (ChunkCount == 0x0F) Version = CMBVersion.LM3DS; @@ -86,8 +126,226 @@ namespace FirstPlugin else throw new Exception("Unexpected chunk count! " + ChunkCount); - int chunkIdx = 0x04; + SectionData = new SectionData(); + SectionData.Read(reader, this); } + + public void Write(FileWriter writer) + { + writer.WriteSignature("cmb "); + writer.Write(uint.MaxValue); //Reserve space for file size offset + writer.Write(ChunkCount); + writer.Write(Unknown); + writer.WriteString(Name, 0x10); + + SectionData.Write(writer, this); + + //Write the total file size + using (writer.TemporarySeek(4, System.IO.SeekOrigin.Begin)) + { + writer.Write((uint)writer.BaseStream.Length); + } + } + } + + public class SectionData + { + public SkeletonChunk SkeletonChunk; + public QuadTreeChunk QuadTreeChunk; + public MaterialChunk MaterialChunk; + + public TextureChunk TextureChunk; + public SkeletalMeshChunk SkeletalMeshChunk; + public LUTSChunk LUTSChunk; + public VertexAttributesChunk VertexAttributesChunk; + + public void Read(FileReader reader, Header header) + { + uint numIndices = reader.ReadUInt32(); + SkeletonChunk = ReadChunkSection(reader, header); + if (header.Version >= CMBVersion.MM3DS) + QuadTreeChunk = ReadChunkSection(reader, header); + + MaterialChunk = ReadChunkSection(reader, header); + TextureChunk = ReadChunkSection(reader, header); + SkeletalMeshChunk = ReadChunkSection(reader, header); + LUTSChunk = ReadChunkSection(reader, header); + VertexAttributesChunk = ReadChunkSection(reader, header); + + uint indexBufferOffset = reader.ReadUInt32(); + uint textureDataOffset = reader.ReadUInt32(); + + if (header.Version >= CMBVersion.MM3DS) + reader.ReadUInt32(); //Padding? + + foreach (var tex in TextureChunk.Textures) + { + reader.SeekBegin(textureDataOffset + tex.DataOffset); + tex.ImageData = reader.ReadBytes((int)tex.ImageSize); + } + } + + public void Write(FileWriter writer, Header header) + { + + } + } + + public class SkeletalMeshChunk : IChunkCommon + { + private const string Magic = "sklm"; + + public void Read(FileReader reader, Header header) + { + reader.ReadSignature(4, Magic); + uint sectionSize = reader.ReadUInt32(); + } + + public void Write(FileWriter writer, Header header) + { + writer.WriteSignature(Magic); + writer.Write(uint.MaxValue);//SectionSize + } + } + + public class LUTSChunk : IChunkCommon + { + private const string Magic = "luts"; + + public void Read(FileReader reader, Header header) + { + reader.ReadSignature(4, Magic); + uint sectionSize = reader.ReadUInt32(); + } + + public void Write(FileWriter writer, Header header) + { + writer.WriteSignature(Magic); + writer.Write(uint.MaxValue);//SectionSize + } + } + + public class VertexAttributesChunk : IChunkCommon + { + private const string Magic = "vatr"; + + public void Read(FileReader reader, Header header) + { + reader.ReadSignature(4, Magic); + uint sectionSize = reader.ReadUInt32(); + } + + public void Write(FileWriter writer, Header header) + { + writer.WriteSignature(Magic); + writer.Write(uint.MaxValue);//SectionSize + } + } + + + + public class SkeletonChunk : IChunkCommon + { + private const string Magic = "skl "; + + public void Read(FileReader reader, Header header) + { + reader.ReadSignature(4, Magic); + uint sectionSize = reader.ReadUInt32(); + } + + public void Write(FileWriter writer, Header header) + { + writer.WriteSignature(Magic); + writer.Write(uint.MaxValue);//SectionSize + } + } + + public class QuadTreeChunk : IChunkCommon + { + private const string Magic = "qtrs"; + + public void Read(FileReader reader, Header header) + { + reader.ReadSignature(4, Magic); + uint sectionSize = reader.ReadUInt32(); + } + + public void Write(FileWriter writer, Header header) + { + writer.WriteSignature(Magic); + writer.Write(uint.MaxValue);//SectionSize + } + } + + public class MaterialChunk : IChunkCommon + { + private const string Magic = "mats"; + + public void Read(FileReader reader, Header header) + { + reader.ReadSignature(4, Magic); + uint sectionSize = reader.ReadUInt32(); + } + + public void Write(FileWriter writer, Header header) + { + writer.WriteSignature(Magic); + writer.Write(uint.MaxValue);//SectionSize + } + } + + public class TextureChunk : IChunkCommon + { + private const string Magic = "tex "; + + public List Textures = new List(); + + public void Read(FileReader reader, Header header) + { + reader.ReadSignature(4, Magic); + uint sectionSize = reader.ReadUInt32(); + uint TextureCount = reader.ReadUInt32(); + for (int i = 0; i < TextureCount; i++) + Textures.Add(new CTXB.Texture(reader)); + } + + public void Write(FileWriter writer, Header header) + { + long pos = writer.Position; + + writer.WriteSignature(Magic); + writer.Write(uint.MaxValue);//SectionSize + for (int i = 0; i < Textures.Count; i++) + Textures[i].Write(writer); + + //Write the total file size + writer.WriteSectionSizeU32(pos + 4, pos, writer.Position); + } + } + + public static T ReadChunkSection(FileReader reader, Header header) + where T : IChunkCommon, new() + { + long pos = reader.Position; + + //Read offset and seek it + uint offset = reader.ReadUInt32(); + reader.SeekBegin(offset); + + //Create chunk instance + T chunk = new T(); + chunk.Read(reader, header); + + //Seek back and shift 4 from reading offset + reader.SeekBegin(pos + 0x4); + return chunk; + } + + public interface IChunkCommon + { + void Read(FileReader reader, Header header); + void Write(FileWriter writer, Header header); } } } diff --git a/File_Format_Library/FileFormats/Texture/CTXB.cs b/File_Format_Library/FileFormats/Grezzo/CTXB.cs similarity index 50% rename from File_Format_Library/FileFormats/Texture/CTXB.cs rename to File_Format_Library/FileFormats/Grezzo/CTXB.cs index 834d679a..3b93f2db 100644 --- a/File_Format_Library/FileFormats/Texture/CTXB.cs +++ b/File_Format_Library/FileFormats/Grezzo/CTXB.cs @@ -113,81 +113,98 @@ namespace FirstPlugin Textures.Add(new Texture(reader)); } } + } - public class Texture + public class Texture + { + public ushort MaxLevel { get; set; } + public ushort Unknown { get; set; } + public ushort Width { get; set; } + public ushort Height { get; set; } + public string Name { get; set; } + + public uint ImageSize { get; set; } + public uint DataOffset { get; set; } + + public CTR_3DS.PICASurfaceFormat PicaFormat; + + public byte[] ImageData; + + public enum TextureFormat : uint { - public ushort MaxLevel { get; set; } - public ushort Unknown { get; set; } - public ushort Width { get; set; } - public ushort Height { get; set; } - public string Name { get; set; } - - public uint ImageSize { get; set; } - public uint DataOffset { get; set; } - - public CTR_3DS.PICASurfaceFormat PicaFormat; - - public enum TextureFormat : uint - { - ETC1 = 0x0000675A, - ETC1A4 = 0x0000675B, - RGBA8 = 0x14016752, - RGBA4444 = 0x80336752, - RGBA5551 = 0x80346752, - RGB565 = 0x83636754, - RGB8 = 0x14016754, - A8 = 0x14016756, - L8 = 0x14016757, - L4 = 0x67616757, - LA8 = 0x14016758, - } - - public Texture(FileReader reader) - { - ImageSize = reader.ReadUInt32(); - MaxLevel = reader.ReadUInt16(); - Unknown = reader.ReadUInt16(); - Width = reader.ReadUInt16(); - Height = reader.ReadUInt16(); - TextureFormat Format = reader.ReadEnum(true); - DataOffset = reader.ReadUInt32(); - Name = reader.LoadString(false, typeof(uint)); - - PicaFormat = ToPica(Format); - } - - private static CTR_3DS.PICASurfaceFormat ToPica(TextureFormat format) - { - switch (format) - { - case TextureFormat.A8: return CTR_3DS.PICASurfaceFormat.A8; - case TextureFormat.ETC1: return CTR_3DS.PICASurfaceFormat.ETC1; - case TextureFormat.ETC1A4: return CTR_3DS.PICASurfaceFormat.ETC1A4; - case TextureFormat.L4: return CTR_3DS.PICASurfaceFormat.L4; - case TextureFormat.L8: return CTR_3DS.PICASurfaceFormat.L8; - case TextureFormat.LA8: return CTR_3DS.PICASurfaceFormat.LA8; - case TextureFormat.RGB565: return CTR_3DS.PICASurfaceFormat.RGB565; - case TextureFormat.RGBA4444: return CTR_3DS.PICASurfaceFormat.RGBA4; - case TextureFormat.RGBA5551: return CTR_3DS.PICASurfaceFormat.RGBA5551; - case TextureFormat.RGBA8: return CTR_3DS.PICASurfaceFormat.RGBA8; - case TextureFormat.RGB8: return CTR_3DS.PICASurfaceFormat.RGB8; - default: - throw new Exception($"Unsupported format! {format}"); - } - } + ETC1 = 0x0000675A, + ETC1A4 = 0x0000675B, + RGBA8 = 0x14016752, + RGBA4444 = 0x80336752, + RGBA5551 = 0x80346752, + RGB565 = 0x83636754, + RGB8 = 0x14016754, + A8 = 0x14016756, + L8 = 0x14016757, + L4 = 0x67616757, + LA8 = 0x14016758, } - public class TextureWrapper : STGenericTexture + public Texture(FileReader reader) { - public byte[] ImageData; + ImageSize = reader.ReadUInt32(); + MaxLevel = reader.ReadUInt16(); + Unknown = reader.ReadUInt16(); + Width = reader.ReadUInt16(); + Height = reader.ReadUInt16(); + TextureFormat Format = reader.ReadEnum(true); + DataOffset = reader.ReadUInt32(); + Name = reader.ReadString(16).TrimEnd('\0'); - public override bool CanEdit { get; set; } = false; - public override TEX_FORMAT[] SupportedFormats + PicaFormat = ToPica(Format); + } + + public void Write(FileWriter writer) + { + TextureFormat Format = TextureFormat.A8; + + writer.Write(ImageSize); + writer.Write(MaxLevel); + writer.Write(Unknown); + writer.Write((ushort)Width); + writer.Write((ushort)Height); + writer.Write(Format, true); + writer.Write(DataOffset); + writer.Write(DataOffset); + } + + private static CTR_3DS.PICASurfaceFormat ToPica(TextureFormat format) + { + switch (format) { - get + case TextureFormat.A8: return CTR_3DS.PICASurfaceFormat.A8; + case TextureFormat.ETC1: return CTR_3DS.PICASurfaceFormat.ETC1; + case TextureFormat.ETC1A4: return CTR_3DS.PICASurfaceFormat.ETC1A4; + case TextureFormat.L4: return CTR_3DS.PICASurfaceFormat.L4; + case TextureFormat.L8: return CTR_3DS.PICASurfaceFormat.L8; + case TextureFormat.LA8: return CTR_3DS.PICASurfaceFormat.LA8; + case TextureFormat.RGB565: return CTR_3DS.PICASurfaceFormat.RGB565; + case TextureFormat.RGBA4444: return CTR_3DS.PICASurfaceFormat.RGBA4; + case TextureFormat.RGBA5551: return CTR_3DS.PICASurfaceFormat.RGBA5551; + case TextureFormat.RGBA8: return CTR_3DS.PICASurfaceFormat.RGBA8; + case TextureFormat.RGB8: return CTR_3DS.PICASurfaceFormat.RGB8; + default: + throw new Exception($"Unsupported format! {format}"); + } + } + } + + public class TextureWrapper : STGenericTexture + { + public byte[] ImageData; + + public override bool CanEdit { get; set; } = false; + public override TEX_FORMAT[] SupportedFormats + { + get + { + return new TEX_FORMAT[] { - return new TEX_FORMAT[] - { TEX_FORMAT.B5G6R5_UNORM, TEX_FORMAT.R8G8_UNORM, TEX_FORMAT.B5G5R5A1_UNORM, @@ -200,43 +217,43 @@ namespace FirstPlugin TEX_FORMAT.A4, TEX_FORMAT.ETC1_UNORM, TEX_FORMAT.ETC1_A4, - }; - } + }; } + } - public TextureWrapper() { - PlatformSwizzle = PlatformSwizzle.Platform_3DS; - } + public TextureWrapper() + { + PlatformSwizzle = PlatformSwizzle.Platform_3DS; + } - public override void OnClick(TreeView treeview) + public override void OnClick(TreeView treeview) + { + UpdateEditor(); + } + + private void UpdateEditor() + { + ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase)); + if (editor == null) { - UpdateEditor(); + editor = new ImageEditorBase(); + editor.Dock = DockStyle.Fill; + LibraryGUI.LoadEditor(editor); } - private void UpdateEditor() - { - ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase)); - if (editor == null) - { - editor = new ImageEditorBase(); - editor.Dock = DockStyle.Fill; - LibraryGUI.LoadEditor(editor); - } + editor.Text = Text; + editor.LoadProperties(GenericProperties); + editor.LoadImage(this); + } - editor.Text = Text; - editor.LoadProperties(GenericProperties); - editor.LoadImage(this); - } + public override void SetImageData(System.Drawing.Bitmap bitmap, int ArrayLevel) + { - public override void SetImageData(System.Drawing.Bitmap bitmap, int ArrayLevel) - { + } - } - - public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0) - { - return ImageData; - } + public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0) + { + return ImageData; } } } diff --git a/File_Format_Library/File_Format_Library.csproj b/File_Format_Library/File_Format_Library.csproj index 375aacb8..f0a0857f 100644 --- a/File_Format_Library/File_Format_Library.csproj +++ b/File_Format_Library/File_Format_Library.csproj @@ -274,7 +274,7 @@ - + @@ -286,6 +286,12 @@ BffntEditor.cs + + UserControl + + + LayoutEditor.cs + Form @@ -1007,6 +1013,9 @@ BffntEditor.cs + + LayoutEditor.cs + BatchEditBaseAnimDataForm.cs diff --git a/File_Format_Library/GUI/BFLYT/LayoutEditor.Designer.cs b/File_Format_Library/GUI/BFLYT/LayoutEditor.Designer.cs new file mode 100644 index 00000000..eb0a6e16 --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/LayoutEditor.Designer.cs @@ -0,0 +1,71 @@ +namespace FirstPlugin.LayoutEditor +{ + partial class LayoutEditor + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.stMenuStrip1 = new Toolbox.Library.Forms.STMenuStrip(); + this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.stMenuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // stMenuStrip1 + // + this.stMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.editToolStripMenuItem}); + this.stMenuStrip1.Location = new System.Drawing.Point(0, 0); + this.stMenuStrip1.Name = "stMenuStrip1"; + this.stMenuStrip1.Size = new System.Drawing.Size(836, 24); + this.stMenuStrip1.TabIndex = 0; + this.stMenuStrip1.Text = "stMenuStrip1"; + // + // editToolStripMenuItem + // + this.editToolStripMenuItem.Name = "editToolStripMenuItem"; + this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20); + this.editToolStripMenuItem.Text = "Edit"; + // + // LayoutEditor + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.stMenuStrip1); + this.Name = "LayoutEditor"; + this.Size = new System.Drawing.Size(836, 518); + this.stMenuStrip1.ResumeLayout(false); + this.stMenuStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Toolbox.Library.Forms.STMenuStrip stMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; + } +} diff --git a/File_Format_Library/GUI/BFLYT/LayoutEditor.cs b/File_Format_Library/GUI/BFLYT/LayoutEditor.cs new file mode 100644 index 00000000..a26d340a --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/LayoutEditor.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace FirstPlugin.LayoutEditor +{ + public partial class LayoutEditor : UserControl + { + public LayoutEditor() + { + InitializeComponent(); + } + } +} diff --git a/File_Format_Library/GUI/BFLYT/LayoutEditor.resx b/File_Format_Library/GUI/BFLYT/LayoutEditor.resx new file mode 100644 index 00000000..3db3609f --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/LayoutEditor.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/File_Format_Library/Main.cs b/File_Format_Library/Main.cs index 82cddca5..c3ae2d38 100644 --- a/File_Format_Library/Main.cs +++ b/File_Format_Library/Main.cs @@ -356,7 +356,7 @@ namespace FirstPlugin Formats.Add(typeof(CTXB)); Formats.Add(typeof(G1T)); Formats.Add(typeof(BFLYT)); - + Formats.Add(typeof(CMB)); //Unfinished wip formats not ready for use if (Runtime.DEVELOPER_DEBUG_MODE) diff --git a/Switch_Toolbox_Library/FileFormats/DDS/RGBAPixelDecoder.cs b/Switch_Toolbox_Library/FileFormats/DDS/RGBAPixelDecoder.cs new file mode 100644 index 00000000..83e15325 --- /dev/null +++ b/Switch_Toolbox_Library/FileFormats/DDS/RGBAPixelDecoder.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Toolbox.Library +{ + public class RGBAPixelDecoder + { + private static byte[] GetComponentsFromPixel(TEX_FORMAT format, int pixel) + { + byte[] comp = new byte[] { 0, 0xFF, 0, 0, 0, 0xFF }; + + switch (format) + { + case TEX_FORMAT.L8: + comp[2] = (byte)(pixel & 0xFF); + break; + case TEX_FORMAT.L4: + comp[2] = (byte)((pixel & 0xF) * 17); + comp[3] = (byte)(((pixel & 0xF0) >> 4) * 17); + break; + case TEX_FORMAT.LA8: + comp[2] = (byte)(pixel & 0xFF); + comp[3] = (byte)((pixel & 0xFF00) >> 8); + break; + case TEX_FORMAT.R5G5B5_UNORM: + comp[2] = (byte)((pixel & 0x1F) / 0x1F * 0xFF); + comp[3] = (byte)(((pixel & 0x7E0) >> 5) / 0x3F * 0xFF); + comp[4] = (byte)(((pixel & 0xF800) >> 11) / 0x1F * 0xFF); + break; + case TEX_FORMAT.B5G6R5_UNORM: + comp[2] = (byte)(((pixel & 0xF800) >> 11) / 0x1F * 0xFF); + comp[3] = (byte)(((pixel & 0x7E0) >> 5) / 0x3F * 0xFF); + comp[4] = (byte)((pixel & 0x1F) / 0x1F * 0xFF); + break; + } + + + return comp; + } + + //Method from https://github.com/aboood40091/BNTX-Editor/blob/master/formConv.py + public static byte[] Decode(byte[] data, int width, int height, TEX_FORMAT format) + { + uint bpp = STGenericTexture.GetBytesPerPixel(format); + int size = width * height * 4; + + byte[] output = new byte[size]; + + int inPos = 0; + int outPos = 0; + + byte[] compSel = new byte[4] {0,1,2,3 }; + + for (int Y = 0; Y < height; Y++) + { + for (int X = 0; X < width; X++) + { + inPos = (Y * width + X) * (int)bpp; + outPos = (Y * width + X) * 4; + + int pixel = 0; + for (int i = 0; i < bpp; i++) + pixel |= data[inPos + i] << (8 * i); + + byte[] comp = GetComponentsFromPixel(format, pixel); + + output[outPos + 3] = comp[compSel[3]]; + output[outPos + 2] = comp[compSel[2]]; + output[outPos + 1] = comp[compSel[1]]; + output[outPos + 0] = comp[compSel[0]]; + } + } + + return output; + } + } +} diff --git a/Switch_Toolbox_Library/Forms/Custom/TreeViewCustom.cs b/Switch_Toolbox_Library/Forms/Custom/TreeViewCustom.cs index b482be6f..f0fb8917 100644 --- a/Switch_Toolbox_Library/Forms/Custom/TreeViewCustom.cs +++ b/Switch_Toolbox_Library/Forms/Custom/TreeViewCustom.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; +using System.Threading; using System.Windows.Forms; using System.Drawing; using System.Runtime.InteropServices; @@ -80,10 +80,13 @@ namespace Toolbox.Library } } + public class TreeViewCustom : TreeView { private readonly Dictionary _treeNodes = new Dictionary(); + public List TextureIcons = new List(); + public TreeViewCustom() { ReloadImages(); @@ -99,13 +102,65 @@ namespace Toolbox.Library imgList.Images.Add(image); } - public int ImageWidth = 21; - public int ImageHeight = 21; - public void ReloadImages() + public void ReloadTextureIcons() + { + Thread Thread = new Thread((ThreadStart)(() => + { + foreach (var textureIconList in TextureIcons) + { + foreach (TreeNode node in textureIconList.IconTextureList) + { + if (node is STGenericTexture) + { + var image = ((STGenericTexture)node).GetBitmap(); + AddImageOnThread(image, node); + } + } + } + })); + Thread.Start(); + } + + public void ReloadTextureIcons(ITextureIconLoader textureIconList) + { + Thread Thread = new Thread((ThreadStart)(() => + { + foreach (TreeNode node in textureIconList.IconTextureList) + { + if (node is STGenericTexture) + { + var image = ((STGenericTexture)node).GetBitmap(); + AddImageOnThread(image, node); + } + } + })); + Thread.Start(); + } + + public void AddImageOnThread(Image image, TreeNode node) + { + if (this.InvokeRequired) + { + this.Invoke((MethodInvoker)delegate { + // Running on the UI thread + + node.ImageIndex = this.ImageList.Images.Count; + node.SelectedImageIndex = node.ImageIndex; + + this.ImageList.Images.Add(image); + var dummy = this.ImageList.Handle; + this.Refresh(); + + image.Dispose(); + }); + } + } + + public void ReloadImages(int Width = 22, int Height = 22) { imgList = new ImageList(); imgList.ColorDepth = ColorDepth.Depth32Bit; - imgList.ImageSize = new Size(ImageWidth, ImageHeight); + imgList.ImageSize = new Size(Width, Height); imgList.Images.Add("folder", Properties.Resources.Folder); imgList.Images.Add("resource", Properties.Resources.Folder); imgList.Images.Add("Texture", Properties.Resources.Texture); diff --git a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditor.cs b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditor.cs index 11650b97..afe83b36 100644 --- a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditor.cs +++ b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditor.cs @@ -5,7 +5,7 @@ using System.Data; using System.Drawing; using System.Linq; using System.Text; -using System.Threading.Tasks; +using System.Threading; using System.Windows.Forms; using GL_EditorFramework.Interfaces; using GL_EditorFramework.EditorDrawables; @@ -99,6 +99,10 @@ namespace Toolbox.Library.Forms stPanel1.Controls.Add(ObjectTree); AddNode((TreeNode)FileFormat); } + + if (FileFormat is ITextureIconLoader) { + ObjectTree.LoadGenericTextureIcons((ITextureIconLoader)FileFormat); + } } public void AddIArchiveFile(IFileFormat FileFormat){ diff --git a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.Designer.cs b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.Designer.cs index 0730480c..c4081c1e 100644 --- a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.Designer.cs +++ b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.Designer.cs @@ -32,6 +32,7 @@ this.splitter1 = new System.Windows.Forms.Splitter(); this.stPanel2 = new Toolbox.Library.Forms.STPanel(); this.stPanel1 = new Toolbox.Library.Forms.STPanel(); + this.nodeSizeCB = new Toolbox.Library.Forms.STComboBox(); this.stPanel4 = new Toolbox.Library.Forms.STPanel(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.treeViewCustom1 = new Toolbox.Library.TreeViewCustom(); @@ -79,6 +80,7 @@ // // stPanel1 // + this.stPanel1.Controls.Add(this.nodeSizeCB); this.stPanel1.Controls.Add(this.stPanel4); this.stPanel1.Controls.Add(this.stToolStrip1); this.stPanel1.Controls.Add(this.stPanel3); @@ -89,6 +91,20 @@ this.stPanel1.TabIndex = 11; this.stPanel1.Resize += new System.EventHandler(this.stPanel1_Resize); // + // nodeSizeCB + // + this.nodeSizeCB.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.nodeSizeCB.BorderColor = System.Drawing.Color.Empty; + this.nodeSizeCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid; + this.nodeSizeCB.ButtonColor = System.Drawing.Color.Empty; + this.nodeSizeCB.FormattingEnabled = true; + this.nodeSizeCB.Location = new System.Drawing.Point(172, 29); + this.nodeSizeCB.Name = "nodeSizeCB"; + this.nodeSizeCB.ReadOnly = true; + this.nodeSizeCB.Size = new System.Drawing.Size(136, 21); + this.nodeSizeCB.TabIndex = 5; + this.nodeSizeCB.SelectedIndexChanged += new System.EventHandler(this.nodeSizeCB_SelectedIndexChanged); + // // stPanel4 // this.stPanel4.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -106,6 +122,7 @@ this.splitContainer1.Location = new System.Drawing.Point(0, 0); this.splitContainer1.Name = "splitContainer1"; this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + this.splitContainer1.Panel1Collapsed = true; // // splitContainer1.Panel2 // @@ -113,7 +130,6 @@ this.splitContainer1.Size = new System.Drawing.Size(305, 485); this.splitContainer1.SplitterDistance = 201; this.splitContainer1.TabIndex = 1; - this.splitContainer1.Panel1Collapsed = true; // // treeViewCustom1 // @@ -125,7 +141,7 @@ this.treeViewCustom1.Location = new System.Drawing.Point(0, 0); this.treeViewCustom1.Name = "treeViewCustom1"; this.treeViewCustom1.SelectedImageIndex = 0; - this.treeViewCustom1.Size = new System.Drawing.Size(305, 280); + this.treeViewCustom1.Size = new System.Drawing.Size(305, 485); this.treeViewCustom1.TabIndex = 0; this.treeViewCustom1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewCustom1_AfterCheck); this.treeViewCustom1.DrawNode += new System.Windows.Forms.DrawTreeNodeEventHandler(this.treeViewCustom1_DrawNode); @@ -240,7 +256,7 @@ // sortToolStripMenuItem // this.sortToolStripMenuItem.Name = "sortToolStripMenuItem"; - this.sortToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.sortToolStripMenuItem.Size = new System.Drawing.Size(160, 22); this.sortToolStripMenuItem.Text = "Sort"; this.sortToolStripMenuItem.Click += new System.EventHandler(this.sortToolStripMenuItem_Click); // @@ -248,7 +264,7 @@ // this.dockSearchListToolStripMenuItem.CheckOnClick = true; this.dockSearchListToolStripMenuItem.Name = "dockSearchListToolStripMenuItem"; - this.dockSearchListToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.dockSearchListToolStripMenuItem.Size = new System.Drawing.Size(160, 22); this.dockSearchListToolStripMenuItem.Text = "Dock Search List"; this.dockSearchListToolStripMenuItem.Click += new System.EventHandler(this.dockSearchListToolStripMenuItem_Click); // @@ -302,5 +318,6 @@ private STPanel stPanel4; private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.ToolStripMenuItem dockSearchListToolStripMenuItem; + private STComboBox nodeSizeCB; } } \ No newline at end of file diff --git a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs index 62f1b20c..917b7f18 100644 --- a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs +++ b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs @@ -33,6 +33,14 @@ namespace Toolbox.Library.Forms } } + private enum TreeNodeSize + { + Small, + Normal, + Large, + ExtraLarge, + } + public ObjectEditor ObjectEditor; public void BeginUpdate() { treeViewCustom1.BeginUpdate(); } @@ -127,6 +135,11 @@ namespace Toolbox.Library.Forms treeViewCustom1.BackColor = FormThemes.BaseTheme.ObjectEditorBackColor; AddFilesToActiveEditor = Runtime.AddFilesToActiveObjectEditor; + + foreach (TreeNodeSize nodeSize in (TreeNodeSize[])Enum.GetValues(typeof(TreeNodeSize))) + nodeSizeCB.Items.Add(nodeSize); + + nodeSizeCB.SelectedIndex = 1; } public Viewport GetViewport() => viewport; @@ -309,21 +322,24 @@ namespace Toolbox.Library.Forms var result = MessageBox.Show("If you remove this file, any unsaved progress will be lost! Continue?", "Remove Dialog", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); - if (node is IFileFormat) + if (result == DialogResult.Yes) { - ((IFileFormat)node).Unload(); + if (node is IFileFormat) + { + ((IFileFormat)node).Unload(); + } + + treeViewCustom1.Nodes.Remove(node); + ResetEditor(); + + //Force garbage collection. + GC.Collect(); + + // Wait for all finalizers to complete before continuing. + GC.WaitForPendingFinalizers(); + + ((IUpdateForm)Runtime.MainForm).UpdateForm(); } - - treeViewCustom1.Nodes.Remove(node); - ResetEditor(); - - //Force garbage collection. - GC.Collect(); - - // Wait for all finalizers to complete before continuing. - GC.WaitForPendingFinalizers(); - - ((IUpdateForm)Runtime.MainForm).UpdateForm(); } } @@ -622,7 +638,6 @@ namespace Toolbox.Library.Forms UpdateSearchPanelDockState(); } - private void UpdateSearchPanelDockState() { if (IsSearchPanelDocked) @@ -640,5 +655,34 @@ namespace Toolbox.Library.Forms } } + public void LoadGenericTextureIcons(ITextureIconLoader iconList) { + treeViewCustom1.TextureIcons.Add(iconList); + treeViewCustom1.ReloadTextureIcons(iconList); + } + + private void nodeSizeCB_SelectedIndexChanged(object sender, EventArgs e) + { + var nodeSize = nodeSizeCB.SelectedItem; + if (nodeSize != null) + { + int Size = 22; + + switch ((TreeNodeSize)nodeSize) + { + case TreeNodeSize.Small: Size = 18; + break; + case TreeNodeSize.Normal: Size = 22; + break; + case TreeNodeSize.Large: Size = 30; + break; + case TreeNodeSize.ExtraLarge: Size = 35; + break; + } + + treeViewCustom1.ItemHeight = Size; + treeViewCustom1.ReloadImages(Size, Size); + treeViewCustom1.ReloadTextureIcons(); + } + } } } diff --git a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.resx b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.resx index b3ccea75..22477dcd 100644 --- a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.resx +++ b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.resx @@ -123,6 +123,9 @@ 17, 17 + + 17, 17 + 166, 17 diff --git a/Switch_Toolbox_Library/Forms/Editors/ObjectList.Designer.cs b/Switch_Toolbox_Library/Forms/Editors/ObjectList.Designer.cs index f5632b06..0ae96230 100644 --- a/Switch_Toolbox_Library/Forms/Editors/ObjectList.Designer.cs +++ b/Switch_Toolbox_Library/Forms/Editors/ObjectList.Designer.cs @@ -98,21 +98,18 @@ this.smallToolStripMenuItem.Name = "smallToolStripMenuItem"; this.smallToolStripMenuItem.Size = new System.Drawing.Size(119, 22); this.smallToolStripMenuItem.Text = "Small"; - this.smallToolStripMenuItem.Click += new System.EventHandler(this.smallToolStripMenuItem_Click); // // mediumToolStripMenuItem // this.mediumToolStripMenuItem.Name = "mediumToolStripMenuItem"; this.mediumToolStripMenuItem.Size = new System.Drawing.Size(119, 22); this.mediumToolStripMenuItem.Text = "Medium"; - this.mediumToolStripMenuItem.Click += new System.EventHandler(this.mediumToolStripMenuItem_Click); // // largeToolStripMenuItem // this.largeToolStripMenuItem.Name = "largeToolStripMenuItem"; this.largeToolStripMenuItem.Size = new System.Drawing.Size(119, 22); this.largeToolStripMenuItem.Text = "Large"; - this.largeToolStripMenuItem.Click += new System.EventHandler(this.largeToolStripMenuItem_Click); // // searchToolStripMenuItem // diff --git a/Switch_Toolbox_Library/Forms/Editors/ObjectList.cs b/Switch_Toolbox_Library/Forms/Editors/ObjectList.cs index 4152eb4b..20ab04f6 100644 --- a/Switch_Toolbox_Library/Forms/Editors/ObjectList.cs +++ b/Switch_Toolbox_Library/Forms/Editors/ObjectList.cs @@ -25,8 +25,6 @@ namespace Toolbox.Library public ObjectList() { InitializeComponent(); - ApplyThumbnailSetting(Runtime.thumbnailSize); - // treeView1.Sort(); } private void selectItem(object sender, TreeNodeMouseClickEventArgs e) @@ -93,47 +91,6 @@ namespace Toolbox.Library } } - private void ApplyThumbnailSetting(Runtime.ThumbnailSize size) - { - switch (size) - { - case Runtime.ThumbnailSize.Small: - treeView1.ImageHeight = 21; - treeView1.ImageWidth = 21; - smallToolStripMenuItem.BackColor = Color.FromArgb(80, 80, 80); - break; - case Runtime.ThumbnailSize.Medium: - treeView1.ImageHeight = 27; - treeView1.ImageWidth = 27; - mediumToolStripMenuItem.BackColor = Color.FromArgb(80, 80, 80); - break; - case Runtime.ThumbnailSize.Large: - treeView1.ImageHeight = 34; - treeView1.ImageWidth = 34; - largeToolStripMenuItem.BackColor = Color.FromArgb(80, 80, 80); - break; - } - treeView1.ReloadImages(); - } - - private void largeToolStripMenuItem_Click(object sender, EventArgs e) - { - Runtime.thumbnailSize = Runtime.ThumbnailSize.Large; - ApplyThumbnailSetting(Runtime.thumbnailSize); - } - - private void mediumToolStripMenuItem_Click(object sender, EventArgs e) - { - Runtime.thumbnailSize = Runtime.ThumbnailSize.Medium; - ApplyThumbnailSetting(Runtime.thumbnailSize); - } - - private void smallToolStripMenuItem_Click(object sender, EventArgs e) - { - Runtime.thumbnailSize = Runtime.ThumbnailSize.Small; - ApplyThumbnailSetting(Runtime.thumbnailSize); - } - private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { if (treeView1.SelectedNode is TreeNodeCustom) diff --git a/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs b/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs index 7b5ac997..733cb31f 100644 --- a/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs +++ b/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs @@ -417,7 +417,7 @@ namespace Toolbox.Library return BitmapExtension.GetBitmap(ETC1.ETC1Decompress(data, (int)width, (int)height, true), (int)width, (int)height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); case TEX_FORMAT.LA8: - return BitmapExtension.GetBitmap(DecodeLA8(data, (int)width, (int)height), + return BitmapExtension.GetBitmap(RGBAPixelDecoder.Decode(data, (int)width, (int)height, Format), (int)width, (int)height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); } @@ -449,44 +449,6 @@ namespace Toolbox.Library } } - //Method from https://github.com/aboood40091/BNTX-Editor/blob/master/formConv.py - private static byte[] DecodeLA8(byte[] Input, int Width, int Height) - { - int bpp = 16; - - if (Input.Length != Width * Height * bpp) - throw new Exception($"Unexpected size! {Input.Length}. Expected {Width * Height * bpp}"); - - byte[] Output = new byte[Width * Height * 4]; - - int inPos = 0; - int outPos = 0; - - for (int Y = 0; Y < Height; Y++) - { - for (int X = 0; X < Width; X++) - { - inPos = (Y * Width + X) * bpp; - outPos = (Y * Width + X) * 4; - - int pixel = 0; - for (int i = 0; i < bpp; i++) - pixel |= Input[inPos + i] << (8 * i); - - byte[] Components = new byte[4]; - Components[2] = (byte)(pixel & 0xFF); - Components[3] = (byte)((pixel & 0xFF00) >> 8); - - Output[outPos + 3] = Components[3]; - Output[outPos + 2] = Components[2]; - Output[outPos + 1] = Components[1]; - Output[outPos + 0] = Components[0]; - } - } - - return Output; - } - private Bitmap DecodeNotDirectXTex(byte[] data, uint Width, uint Height, TEX_FORMAT Format) { if (Format == TEX_FORMAT.R8G8B8A8_UNORM) @@ -575,6 +537,8 @@ namespace Toolbox.Library imageData = ASTCDecoder.DecodeToRGBA8888(data, (int)GetBlockWidth(Format), (int)GetBlockHeight(Format), 1, (int)Width, (int)Height, 1); else imageData = DDSCompressor.DecodePixelBlock(data, (int)Width, (int)Height, (DDS.DXGI_FORMAT)Format); + + // imageData = RGBAPixelDecoder.Decode(data, (int)Width, (int)Height, Format); } if (parameters.DontSwapRG || DontSwapRG) diff --git a/Switch_Toolbox_Library/IO/FileReader.cs b/Switch_Toolbox_Library/IO/FileReader.cs index aa08e07d..0e2cb3dd 100644 --- a/Switch_Toolbox_Library/IO/FileReader.cs +++ b/Switch_Toolbox_Library/IO/FileReader.cs @@ -127,9 +127,11 @@ namespace Toolbox.Library.IO ByteOrder = ByteOrder.LittleEndian; } - public string ReadSignature(int length, string ExpectedSignature) + public string ReadSignature(int length, string ExpectedSignature, bool TrimEnd = false) { - string RealSignature = ReadString(length, Encoding.ASCII); + string RealSignature = ReadString(length, Encoding.ASCII); + + if (TrimEnd) RealSignature = RealSignature.TrimEnd(' '); if (RealSignature != ExpectedSignature) throw new Exception($"Invalid signature {RealSignature}! Expected {ExpectedSignature}."); diff --git a/Switch_Toolbox_Library/IO/FileWriter.cs b/Switch_Toolbox_Library/IO/FileWriter.cs index e7481d98..effa6669 100644 --- a/Switch_Toolbox_Library/IO/FileWriter.cs +++ b/Switch_Toolbox_Library/IO/FileWriter.cs @@ -70,6 +70,22 @@ namespace Toolbox.Library.IO ByteOrder = ByteOrder.LittleEndian; } + public void WriteString(string text, uint fixedSize) + { + long pos = Position; + WriteString(text); + Seek(pos + fixedSize); + } + + //Writes the total size of a section as a uint. + public void WriteSectionSizeU32(long position, long startPosition, long endPosition) + { + using (TemporarySeek(position, System.IO.SeekOrigin.Begin)) + { + Write((uint)endPosition - startPosition); + } + } + // // RelativeOffsetPosition controls the relative position the offset starts at // diff --git a/Switch_Toolbox_Library/Interfaces/IArchiveFile.cs b/Switch_Toolbox_Library/Interfaces/FileFormatting/IArchiveFile.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/IArchiveFile.cs rename to Switch_Toolbox_Library/Interfaces/FileFormatting/IArchiveFile.cs diff --git a/Switch_Toolbox_Library/Interfaces/ICompressionFormat.cs b/Switch_Toolbox_Library/Interfaces/FileFormatting/ICompressionFormat.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/ICompressionFormat.cs rename to Switch_Toolbox_Library/Interfaces/FileFormatting/ICompressionFormat.cs diff --git a/Switch_Toolbox_Library/Interfaces/IConvertableTextFormat.cs b/Switch_Toolbox_Library/Interfaces/FileFormatting/IConvertableTextFormat.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/IConvertableTextFormat.cs rename to Switch_Toolbox_Library/Interfaces/FileFormatting/IConvertableTextFormat.cs diff --git a/Switch_Toolbox_Library/Interfaces/IDirectoryNode.cs b/Switch_Toolbox_Library/Interfaces/FileFormatting/IDirectoryNode.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/IDirectoryNode.cs rename to Switch_Toolbox_Library/Interfaces/FileFormatting/IDirectoryNode.cs diff --git a/Switch_Toolbox_Library/Interfaces/IFileFormat.cs b/Switch_Toolbox_Library/Interfaces/FileFormatting/IFileFormat.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/IFileFormat.cs rename to Switch_Toolbox_Library/Interfaces/FileFormatting/IFileFormat.cs diff --git a/Switch_Toolbox_Library/Interfaces/ILeaveOpenOnLoad.cs b/Switch_Toolbox_Library/Interfaces/FileFormatting/ILeaveOpenOnLoad.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/ILeaveOpenOnLoad.cs rename to Switch_Toolbox_Library/Interfaces/FileFormatting/ILeaveOpenOnLoad.cs diff --git a/Switch_Toolbox_Library/Interfaces/INode.cs b/Switch_Toolbox_Library/Interfaces/FileFormatting/INode.cs similarity index 82% rename from Switch_Toolbox_Library/Interfaces/INode.cs rename to Switch_Toolbox_Library/Interfaces/FileFormatting/INode.cs index 87681916..d4e97d0e 100644 --- a/Switch_Toolbox_Library/Interfaces/INode.cs +++ b/Switch_Toolbox_Library/Interfaces/FileFormatting/INode.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; namespace Toolbox.Library { + //Represents a node from an IArchive file public interface INode { string Name { get; set; } diff --git a/Switch_Toolbox_Library/Interfaces/IContextMenuNode.cs b/Switch_Toolbox_Library/Interfaces/Forms/IContextMenuNode.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/IContextMenuNode.cs rename to Switch_Toolbox_Library/Interfaces/Forms/IContextMenuNode.cs diff --git a/Switch_Toolbox_Library/Interfaces/IEditor.cs b/Switch_Toolbox_Library/Interfaces/Forms/IEditor.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/IEditor.cs rename to Switch_Toolbox_Library/Interfaces/Forms/IEditor.cs diff --git a/Switch_Toolbox_Library/Interfaces/IFIleEditor.cs b/Switch_Toolbox_Library/Interfaces/Forms/IFIleEditor.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/IFIleEditor.cs rename to Switch_Toolbox_Library/Interfaces/Forms/IFIleEditor.cs diff --git a/Switch_Toolbox_Library/Interfaces/IMdiContainer.cs b/Switch_Toolbox_Library/Interfaces/Forms/IMdiContainer.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/IMdiContainer.cs rename to Switch_Toolbox_Library/Interfaces/Forms/IMdiContainer.cs diff --git a/Switch_Toolbox_Library/Interfaces/IMenuExtension.cs b/Switch_Toolbox_Library/Interfaces/Forms/IMenuExtension.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/IMenuExtension.cs rename to Switch_Toolbox_Library/Interfaces/Forms/IMenuExtension.cs diff --git a/Switch_Toolbox_Library/Interfaces/IUpdateForm.cs b/Switch_Toolbox_Library/Interfaces/Forms/IUpdateForm.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/IUpdateForm.cs rename to Switch_Toolbox_Library/Interfaces/Forms/IUpdateForm.cs diff --git a/Switch_Toolbox_Library/Interfaces/IViewportContainer.cs b/Switch_Toolbox_Library/Interfaces/Forms/IViewportContainer.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/IViewportContainer.cs rename to Switch_Toolbox_Library/Interfaces/Forms/IViewportContainer.cs diff --git a/Switch_Toolbox_Library/Interfaces/IMeshContainer.cs b/Switch_Toolbox_Library/Interfaces/ModelData/IMeshContainer.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/IMeshContainer.cs rename to Switch_Toolbox_Library/Interfaces/ModelData/IMeshContainer.cs diff --git a/Switch_Toolbox_Library/Interfaces/ITexture.cs b/Switch_Toolbox_Library/Interfaces/Textures/ITexture.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/ITexture.cs rename to Switch_Toolbox_Library/Interfaces/Textures/ITexture.cs diff --git a/Switch_Toolbox_Library/Interfaces/ITextureContainer.cs b/Switch_Toolbox_Library/Interfaces/Textures/ITextureContainer.cs similarity index 100% rename from Switch_Toolbox_Library/Interfaces/ITextureContainer.cs rename to Switch_Toolbox_Library/Interfaces/Textures/ITextureContainer.cs diff --git a/Switch_Toolbox_Library/Interfaces/Textures/ITextureIconLoader.cs b/Switch_Toolbox_Library/Interfaces/Textures/ITextureIconLoader.cs new file mode 100644 index 00000000..bd2a809c --- /dev/null +++ b/Switch_Toolbox_Library/Interfaces/Textures/ITextureIconLoader.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Toolbox.Library +{ + //A texture list to display icons on a treeview + //Attach this to an IFileFormat + public interface ITextureIconLoader + { + List IconTextureList { get; set; } + } +} diff --git a/Switch_Toolbox_Library/Interfaces/ICloneableNode.cs b/Switch_Toolbox_Library/Interfaces/Utility/ICloneableNode.cs similarity index 88% rename from Switch_Toolbox_Library/Interfaces/ICloneableNode.cs rename to Switch_Toolbox_Library/Interfaces/Utility/ICloneableNode.cs index ba245cd0..a46583c5 100644 --- a/Switch_Toolbox_Library/Interfaces/ICloneableNode.cs +++ b/Switch_Toolbox_Library/Interfaces/Utility/ICloneableNode.cs @@ -7,6 +7,7 @@ using System.Windows.Forms; namespace Toolbox.Library { + //A custom clonable treenode public interface ICloneableNode { TreeNode CloneNode(); diff --git a/Switch_Toolbox_Library/Toolbox.Library.dll b/Switch_Toolbox_Library/Toolbox.Library.dll index 4fdbc921..cae8e055 100644 Binary files a/Switch_Toolbox_Library/Toolbox.Library.dll and b/Switch_Toolbox_Library/Toolbox.Library.dll differ diff --git a/Switch_Toolbox_Library/Toolbox.Library.pdb b/Switch_Toolbox_Library/Toolbox.Library.pdb index 0f73a87f..4a344d1d 100644 Binary files a/Switch_Toolbox_Library/Toolbox.Library.pdb and b/Switch_Toolbox_Library/Toolbox.Library.pdb differ diff --git a/Switch_Toolbox_Library/Toolbox_Library.csproj b/Switch_Toolbox_Library/Toolbox_Library.csproj index c52e66a6..8887463c 100644 --- a/Switch_Toolbox_Library/Toolbox_Library.csproj +++ b/Switch_Toolbox_Library/Toolbox_Library.csproj @@ -216,6 +216,7 @@ + Component @@ -245,11 +246,12 @@ - - - - - + + + + + + @@ -610,9 +612,9 @@ - - - + + + @@ -657,14 +659,14 @@ - - - - - - - - + + + + + + + + @@ -726,8 +728,8 @@ RenameDialog.cs - - + +