diff --git a/File_Format_Library/FileFormats/Archives/GFPAK.cs b/File_Format_Library/FileFormats/Archives/GFPAK.cs index db399253..931fe3ba 100644 --- a/File_Format_Library/FileFormats/Archives/GFPAK.cs +++ b/File_Format_Library/FileFormats/Archives/GFPAK.cs @@ -36,7 +36,7 @@ namespace FirstPlugin else if (f.Matches("FLIM")) return ".bclim"; else if (f.Matches("FLAN")) return ".bflan"; else if (f.Matches("FSEQ")) return ".bfseq"; - else if (f.Matches("VFXB")) return ".pctl"; + else if (f.Matches("VFXB")) return ".ptcl"; else if (f.Matches("AAHS")) return ".sharc"; else if (f.Matches("BAHS")) return ".sharcb"; else if (f.Matches("BNTX")) return ".bntx"; @@ -46,7 +46,7 @@ namespace FirstPlugin else if (f.Matches("CFNT")) return ".bcfnt"; else if (f.Matches("CSTM")) return ".bcstm"; else if (f.Matches("FSTM")) return ".bfstm"; - else if (f.Matches("STM")) return ".bfsha"; + else if (f.Matches("STM")) return ".bstm"; else if (f.Matches("CWAV")) return ".bcwav"; else if (f.Matches("FWAV")) return ".bfwav"; else if (f.Matches("CTPK")) return ".ctpk"; @@ -217,6 +217,9 @@ namespace FirstPlugin case ".bnsh": fileEntry.FileName = $"Shaders/{fileEntry.FileName}"; break; + case ".ptcl": + fileEntry.FileName = $"Effects/{fileEntry.FileName}"; + break; default: fileEntry.FileName = $"OtherFiles/{fileEntry.FileName}"; break; diff --git a/File_Format_Library/FileFormats/Grezzo/CMB.cs b/File_Format_Library/FileFormats/Grezzo/CMB.cs index bf3752a7..a07bf64f 100644 --- a/File_Format_Library/FileFormats/Grezzo/CMB.cs +++ b/File_Format_Library/FileFormats/Grezzo/CMB.cs @@ -19,7 +19,7 @@ namespace FirstPlugin public bool CanSave { get; set; } public string[] Description { get; set; } = new string[] { "*CTR Model Binary" }; - public string[] Extension { get; set; } = new string[] { ".cmb" }; + public string[] Extension { get; set; } = new string[] { "*.cmb" }; public string FileName { get; set; } public string FilePath { get; set; } public IFileInfo IFileInfo { get; set; } @@ -1661,8 +1661,14 @@ namespace FirstPlugin public float BlendColorB { get; set; } public float BlendColorA { get; set; } + private byte[] data; + public void Read(FileReader reader, Header header, MaterialChunk materialChunkParent) { + int materialSize = 0x15C; + if (header.Version >= CMBVersion.MM3DS) + materialSize = 0x16C; + TextureMaps = new TextureMap[3]; TextureMaticies = new TextureMatrix[3]; TextureCombiners = new List(); @@ -1702,6 +1708,10 @@ namespace FirstPlugin TextureMaticies[j].Rotate = reader.ReadSingle(); } + long dataPos = reader.Position; + data = reader.ReadBytes(materialSize - (int)(dataPos - pos)); + reader.SeekBegin(dataPos); + uint unkColor0 = reader.ReadUInt32(); ConstantColors = new STColor[6]; @@ -1857,6 +1867,8 @@ namespace FirstPlugin writer.Write(TextureMaticies[j].Translate); writer.Write(TextureMaticies[j].Rotate); } + + writer.Write(data); } public override string ToString() @@ -1948,6 +1960,8 @@ namespace FirstPlugin writer.WriteSignature(Magic); writer.Write(uint.MaxValue);//SectionSize + writer.Write(Textures.Count); + for (int i = 0; i < Textures.Count; i++) Textures[i].Write(writer); diff --git a/File_Format_Library/FileFormats/NLG/LM3/LM3_DICT.cs b/File_Format_Library/FileFormats/NLG/LM3/LM3_DICT.cs index aaf9bddf..6f513a2c 100644 --- a/File_Format_Library/FileFormats/NLG/LM3/LM3_DICT.cs +++ b/File_Format_Library/FileFormats/NLG/LM3/LM3_DICT.cs @@ -63,6 +63,8 @@ namespace FirstPlugin.LuigisMansion3 private void SaveAction(object sender, EventArgs args) { + return; + SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = Utils.GetAllFilters(this); sfd.FileName = FileName; diff --git a/File_Format_Library/FileFormats/Pokemon/GFBANIM/GFBANM.cs b/File_Format_Library/FileFormats/Pokemon/GFBANIM/GFBANM.cs new file mode 100644 index 00000000..bd7d1c84 --- /dev/null +++ b/File_Format_Library/FileFormats/Pokemon/GFBANIM/GFBANM.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Toolbox; +using System.Windows.Forms; +using Toolbox.Library; +using Toolbox.Library.IO; +using OpenTK; + +namespace FirstPlugin +{ + public class GFBANM : IFileFormat + { + public FileType FileType { get; set; } = FileType.Model; + + public bool CanSave { get; set; } + public string[] Description { get; set; } = new string[] { "MDL" }; + public string[] Extension { get; set; } = new string[] { "*.mdl" }; + public string FileName { get; set; } + public string FilePath { get; set; } + public IFileInfo IFileInfo { get; set; } + + public bool Identify(System.IO.Stream stream) + { + return Utils.GetExtension(FileName) == ".gfbanm"; + } + + public Type[] Types + { + get + { + List types = new List(); + return types.ToArray(); + } + } + + public void Load(System.IO.Stream stream) + { + using (var reader = new FileReader(stream)) + { + + } + } + + public void Unload() + { + + } + + public void Save(System.IO.Stream stream) + { + } + + public class Header + { + public Config config; + + public void Read(FileReader reader) + { + reader.ReadUInt32(); + config = ParseSection(reader, this); + } + } + + private static T ParseSection(FileReader reader, Header header) + where T : GFSection, new() + { + var layoutOffset = reader.ReadOffset(true, typeof(uint)); + var dataOffset = reader.ReadOffset(true, typeof(uint)); + + T section = new T(); + using (reader.TemporarySeek(layoutOffset, System.IO.SeekOrigin.Begin)) + { + ushort layoutSize = reader.ReadUInt16(); + ushort layoutStride = reader.ReadUInt16(); + section.LayoutPointers = reader.ReadUInt16s((int)(layoutSize / 2)); + } + + using (reader.TemporarySeek(dataOffset, System.IO.SeekOrigin.Begin)) + { + section.Read(reader, header); + } + + return section; + } + + public class GFSection + { + public ushort[] LayoutPointers { get; set; } + + public virtual void Read(FileReader reader, Header header) + { + + } + } + + public class Config : GFSection + { + public int Unknown { get; set; } + public uint NumKeyFrames { get; set; } + public uint FramesPerSecond { get; set; } + } + + public class BoneList : GFSection + { + public List Bones = new List(); + public List BoneDefaults = new List(); + } + + public class Bone + { + public string Name { get; set; } + public byte ScaleType { get; set; } + } + + public class BoneDefaults + { + public int Unknown { get; set; } + + public Vector3 Scale { get; set; } + public Vector4 Rotation { get; set; } + public Vector3 Translation { get; set; } + } + + public class TriggerList + { + public List Triggers = new List(); + } + + public class Trigger + { + public string Name { get; set; } + public int StartFrame { get; set; } + public int EndFrame { get; set; } + } + + public class TriggerParameter + { + public string Name { get; set; } + public byte Type { get; set; } + + //float, byte, int, string + public object Value { get; set; } + } + } +} diff --git a/File_Format_Library/FileFormats/GFBMDL/GFBMDL.cs b/File_Format_Library/FileFormats/Pokemon/GFBMDL/GFBMDL.cs similarity index 100% rename from File_Format_Library/FileFormats/GFBMDL/GFBMDL.cs rename to File_Format_Library/FileFormats/Pokemon/GFBMDL/GFBMDL.cs diff --git a/File_Format_Library/FileFormats/GFBMDL/GFBMDL_Wrappers.cs b/File_Format_Library/FileFormats/Pokemon/GFBMDL/GFBMDL_Wrappers.cs similarity index 100% rename from File_Format_Library/FileFormats/GFBMDL/GFBMDL_Wrappers.cs rename to File_Format_Library/FileFormats/Pokemon/GFBMDL/GFBMDL_Wrappers.cs diff --git a/File_Format_Library/FileFormats/Texture/BNTX.cs b/File_Format_Library/FileFormats/Texture/BNTX.cs index 25d6affc..dcc88e5b 100644 --- a/File_Format_Library/FileFormats/Texture/BNTX.cs +++ b/File_Format_Library/FileFormats/Texture/BNTX.cs @@ -582,7 +582,8 @@ namespace FirstPlugin { TextureData texData = new TextureData(tex, BinaryTexFile); Nodes.Add(texData); - Textures.Add(tex.Name, texData); + if (!Textures.ContainsKey(tex.Name)) + Textures.Add(tex.Name, texData); } BinaryTexFile.Textures.Clear(); //We don't need these in memeory anymore BinaryTexFile.TextureDict.Clear(); diff --git a/File_Format_Library/File_Format_Library.csproj b/File_Format_Library/File_Format_Library.csproj index 38087b09..89d1ec01 100644 --- a/File_Format_Library/File_Format_Library.csproj +++ b/File_Format_Library/File_Format_Library.csproj @@ -355,6 +355,7 @@ + @@ -633,8 +634,8 @@ BMDModelImportSettings.cs - - + + diff --git a/File_Format_Library/GUI/Byaml/ByamlEditor.Designer.cs b/File_Format_Library/GUI/Byaml/ByamlEditor.Designer.cs index 660d0c25..4b194765 100644 --- a/File_Format_Library/GUI/Byaml/ByamlEditor.Designer.cs +++ b/File_Format_Library/GUI/Byaml/ByamlEditor.Designer.cs @@ -60,6 +60,7 @@ this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.copyDataAsTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.stPanel3 = new Toolbox.Library.Forms.STPanel(); this.contextMenuStrip1.SuspendLayout(); this.stPanel1.SuspendLayout(); this.stTabControl1.SuspendLayout(); @@ -226,6 +227,7 @@ this.columnHeader3}); this.listViewCustom1.Dock = System.Windows.Forms.DockStyle.Fill; this.listViewCustom1.FullRowSelect = true; + this.listViewCustom1.HideSelection = false; this.listViewCustom1.Location = new System.Drawing.Point(0, 0); this.listViewCustom1.Name = "listViewCustom1"; this.listViewCustom1.OwnerDraw = true; @@ -252,6 +254,7 @@ // // tabPage2 // + this.tabPage2.Controls.Add(this.stPanel3); this.tabPage2.Controls.Add(this.btnToXml); this.tabPage2.Controls.Add(this.stPanel2); this.tabPage2.Controls.Add(this.btnXmlToByaml); @@ -305,50 +308,60 @@ this.copyToolStripMenuItem, this.copyDataAsTextToolStripMenuItem}); this.stContextMenuStrip1.Name = "stContextMenuStrip1"; - this.stContextMenuStrip1.Size = new System.Drawing.Size(181, 158); + this.stContextMenuStrip1.Size = new System.Drawing.Size(166, 136); // // addItemToolStripMenuItem // this.addItemToolStripMenuItem.Name = "addItemToolStripMenuItem"; - this.addItemToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.addItemToolStripMenuItem.Size = new System.Drawing.Size(165, 22); this.addItemToolStripMenuItem.Text = "Add Item"; this.addItemToolStripMenuItem.Click += new System.EventHandler(this.addNodeToolStripMenuItem_Click); // // editToolStripMenuItem // this.editToolStripMenuItem.Name = "editToolStripMenuItem"; - this.editToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.editToolStripMenuItem.Size = new System.Drawing.Size(165, 22); this.editToolStripMenuItem.Text = "Edit"; this.editToolStripMenuItem.Click += new System.EventHandler(this.editValueNodeMenuItem_Click); // // renameToolStripMenuItem // this.renameToolStripMenuItem.Name = "renameToolStripMenuItem"; - this.renameToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.renameToolStripMenuItem.Size = new System.Drawing.Size(165, 22); this.renameToolStripMenuItem.Text = "Rename"; this.renameToolStripMenuItem.Click += new System.EventHandler(this.renameToolStripMenuItem_Click); // // deleteToolStripMenuItem // this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; - this.deleteToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(165, 22); this.deleteToolStripMenuItem.Text = "Delete"; this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); // // copyToolStripMenuItem // this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; - this.copyToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.copyToolStripMenuItem.Size = new System.Drawing.Size(165, 22); this.copyToolStripMenuItem.Text = "Copy item as text"; this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click); // // copyDataAsTextToolStripMenuItem // this.copyDataAsTextToolStripMenuItem.Name = "copyDataAsTextToolStripMenuItem"; - this.copyDataAsTextToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.copyDataAsTextToolStripMenuItem.Size = new System.Drawing.Size(165, 22); this.copyDataAsTextToolStripMenuItem.Text = "Copy data as text"; this.copyDataAsTextToolStripMenuItem.Click += new System.EventHandler(this.copyDataAsTextToolStripMenuItem_Click); // + // stPanel3 + // + this.stPanel3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.stPanel3.Location = new System.Drawing.Point(15, 35); + this.stPanel3.Name = "stPanel3"; + this.stPanel3.Size = new System.Drawing.Size(520, 328); + this.stPanel3.TabIndex = 3; + // // ByamlEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -404,5 +417,6 @@ private Toolbox.Library.Forms.STButton btnToXml; private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem copyDataAsTextToolStripMenuItem; + private Toolbox.Library.Forms.STPanel stPanel3; } } \ No newline at end of file diff --git a/File_Format_Library/GUI/Byaml/ByamlEditor.cs b/File_Format_Library/GUI/Byaml/ByamlEditor.cs index 3c9d38b9..7c3e4cab 100644 --- a/File_Format_Library/GUI/Byaml/ByamlEditor.cs +++ b/File_Format_Library/GUI/Byaml/ByamlEditor.cs @@ -92,7 +92,7 @@ namespace FirstPlugin ParseBymlFirstNode(); xmlEditor = new TextEditor(); - stPanel2.Controls.Add(xmlEditor); + stPanel3.Controls.Add(xmlEditor); xmlEditor.Dock = DockStyle.Fill; xmlEditor.IsXML = true; } diff --git a/File_Format_Library/Main.cs b/File_Format_Library/Main.cs index ca59617c..071045cc 100644 --- a/File_Format_Library/Main.cs +++ b/File_Format_Library/Main.cs @@ -347,6 +347,7 @@ namespace FirstPlugin Formats.Add(typeof(IGA_PAK)); Formats.Add(typeof(MKAGPDX_Model)); Formats.Add(typeof(GFBMDL)); + // Formats.Add(typeof(GFBANM)); Formats.Add(typeof(Turbo.Course_MapCamera_bin)); Formats.Add(typeof(SDF)); Formats.Add(typeof(IStorage)); diff --git a/Switch_Toolbox_Library/IO/FileWriter.cs b/Switch_Toolbox_Library/IO/FileWriter.cs index 34d7634e..befe78ef 100644 --- a/Switch_Toolbox_Library/IO/FileWriter.cs +++ b/Switch_Toolbox_Library/IO/FileWriter.cs @@ -119,7 +119,7 @@ namespace Toolbox.Library.IO { using (TemporarySeek(position, System.IO.SeekOrigin.Begin)) { - Write((uint)endPosition - startPosition); + Write((uint)(endPosition - startPosition)); } } diff --git a/Switch_Toolbox_Library/Interfaces/FileFormatting/IArchiveFile.cs b/Switch_Toolbox_Library/Interfaces/FileFormatting/IArchiveFile.cs index 22038b17..aa086a3f 100644 --- a/Switch_Toolbox_Library/Interfaces/FileFormatting/IArchiveFile.cs +++ b/Switch_Toolbox_Library/Interfaces/FileFormatting/IArchiveFile.cs @@ -809,7 +809,7 @@ namespace Toolbox.Library else if (f.Matches("FLIM")) return ".bclim"; else if (f.Matches("FLAN")) return ".bflan"; else if (f.Matches("FSEQ")) return ".bfseq"; - else if (f.Matches("VFXB")) return ".pctl"; + else if (f.Matches("VFXB")) return ".ptcl"; else if (f.Matches("AAHS")) return ".sharc"; else if (f.Matches("BAHS")) return ".sharcb"; else if (f.Matches("BNTX")) return ".bntx";