diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index 05a16c89..89a84fd2 100644 Binary files a/.vs/Switch_Toolbox/v15/.suo and b/.vs/Switch_Toolbox/v15/.suo differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide index 929538d8..77855f93 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal index ddf5028a..6e32f599 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal differ diff --git a/Switch_FileFormatsMain/FileFormats/Archives/SARC_OLD.cs b/Switch_FileFormatsMain/FileFormats/Archives/SARC_OLD.cs index 0723294c..bf3830b3 100644 --- a/Switch_FileFormatsMain/FileFormats/Archives/SARC_OLD.cs +++ b/Switch_FileFormatsMain/FileFormats/Archives/SARC_OLD.cs @@ -39,8 +39,9 @@ namespace FirstPlugin } } + public List Files = new List(); + public Dictionary OpenedFiles = new Dictionary(); - public Dictionary Files = new Dictionary(); public SarcData sarcData; public string SarcHash; @@ -61,7 +62,7 @@ namespace FirstPlugin Text = FileName; ContextMenuStrip = new STContextMenuStrip(); - ContextMenuStrip.Items.Add(new STToolStipMenuItem("Save", null, Save, Keys.Control | Keys.S)); + ContextMenuStrip.Items.Add(new STToolStipMenuItem("Save",null, Save, Keys.Control | Keys.S)); ContextMenuStrip.Items.Add(new STToolStipMenuItem("Rename Actor Files (Odyssey)", null, RenameActors, Keys.Control | Keys.S)); // ContextMenuStrip.Items.Add(new STToolStipMenuItem("Unpack to Folder", null, UnpackToFolder, Keys.Control | Keys.E)); @@ -102,7 +103,7 @@ namespace FirstPlugin } } } - + private void UnpackToFolder(object sender, EventArgs args) { @@ -113,8 +114,7 @@ namespace FirstPlugin } - private void Delete(object sender, EventArgs args) - { + private void Delete(object sender, EventArgs args) { Unload(); var editor = LibraryGUI.Instance.GetObjectEditor(); if (editor != null) @@ -127,16 +127,20 @@ namespace FirstPlugin TreeView.Sort(); } - public class FolderEntry : TreeNode + public class FolderEntry : TreeNode, IContextMenuNode { public FolderEntry(string text, int imageIndex, int selectedImageIndex) { Text = text; ImageIndex = imageIndex; SelectedImageIndex = selectedImageIndex; + } - ContextMenu = new ContextMenu(); - ContextMenu.MenuItems.Add(new MenuItem("Sort Childern", SortChildern)); + public ToolStripItem[] GetContextMenuItems() + { + List Items = new List(); + Items.Add(new ToolStripMenuItem("Sort Childern", null, SortChildern, Keys.Control | Keys.W)); + return Items.ToArray(); } private void SortChildern(object sender, EventArgs args) @@ -328,7 +332,7 @@ namespace FirstPlugin } } - public class SarcEntry : TreeNodeCustom + public class SarcEntry : TreeNodeCustom, IContextMenuNode { public SARC sarc; //Sarc file the entry is located in public byte[] Data; @@ -338,17 +342,22 @@ namespace FirstPlugin { ImageKey = "fileBlank"; SelectedImageKey = "fileBlank"; - - ContextMenuStrip = new STContextMenuStrip(); - ContextMenuStrip.Items.Add(new STToolStipMenuItem("Export Raw Data", null, Export, Keys.Control | Keys.E)); - ContextMenuStrip.Items.Add(new STToolStipMenuItem("Export Raw Data to File Location", null, ExportToFileLoc, Keys.Control | Keys.F)); - ContextMenuStrip.Items.Add(new STToolStipMenuItem("Replace Raw Data", null, Replace, Keys.Control | Keys.R)); - ContextMenuStrip.Items.Add(new STToolStripSeparator()); - ContextMenuStrip.Items.Add(new STToolStipMenuItem("Open With Text Editor", null, OpenTextEditor, Keys.Control | Keys.T)); - ContextMenuStrip.Items.Add(new STToolStripSeparator()); - ContextMenuStrip.Items.Add(new STToolStipMenuItem("Remove", null, Remove, Keys.Control | Keys.Delete)); - ContextMenuStrip.Items.Add(new STToolStipMenuItem("Rename", null, Rename, Keys.Control | Keys.N)); } + + public ToolStripItem[] GetContextMenuItems() + { + List Items = new List(); + Items.Add(new STToolStipMenuItem("Export Raw Data", null, Export, Keys.Control | Keys.E)); + Items.Add(new STToolStipMenuItem("Export Raw Data to File Location", null, ExportToFileLoc, Keys.Control | Keys.F)); + Items.Add(new STToolStipMenuItem("Replace Raw Data", null, Replace, Keys.Control | Keys.R)); + Items.Add(new STToolStripSeparator()); + Items.Add(new STToolStipMenuItem("Open With Text Editor", null, OpenTextEditor, Keys.Control | Keys.T)); + Items.Add(new STToolStripSeparator()); + Items.Add(new STToolStipMenuItem("Remove", null, Remove, Keys.Control | Keys.Delete)); + Items.Add(new STToolStipMenuItem("Rename", null, Rename, Keys.Control | Keys.N)); + return Items.ToArray(); + } + public override void OnClick(TreeView treeView) { UpdateHexView(); @@ -379,7 +388,7 @@ namespace FirstPlugin IFileFormat file = OpenFile(); if (file == null) //File returns null if no supported format is found - return; + return; if (Utils.HasInterface(file.GetType(), typeof(IEditor<>)) && !SuppressFormDialog) { @@ -596,7 +605,7 @@ namespace FirstPlugin sarcEntry.sarc = this; sarcEntry.Data = data; - Files.Add(fullName, data); + Files.Add(sarcEntry); string ext = Path.GetExtension(name); string SarcEx = SARCExt.SARC.GuessFileExtension(data); @@ -623,4 +632,4 @@ namespace FirstPlugin return sarcEntry; } } -} \ No newline at end of file +} diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs index cd96bcb1..28616c89 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs @@ -420,35 +420,65 @@ namespace Bfres.Structs private void SetCopiedMaterialData(CopyMaterialMenu menu, FMAT selectedMaterial, FMAT targetMaterial) { - targetMaterial.Material.Flags = selectedMaterial.Material.Flags; - targetMaterial.Material.UserDatas = selectedMaterial.Material.UserDatas; - targetMaterial.Material.UserDataDict = selectedMaterial.Material.UserDataDict; + if (targetMaterial.Material != null) + { + targetMaterial.Material.Flags = selectedMaterial.Material.Flags; + targetMaterial.Material.UserDatas = selectedMaterial.Material.UserDatas; + targetMaterial.Material.UserDataDict = selectedMaterial.Material.UserDataDict; - if (menu.chkBoxRenderInfo.Checked) - { - targetMaterial.Material.RenderInfoDict = selectedMaterial.Material.RenderInfoDict; - targetMaterial.Material.RenderInfos = selectedMaterial.Material.RenderInfos; + if (menu.chkBoxRenderInfo.Checked) + { + targetMaterial.Material.RenderInfoDict = selectedMaterial.Material.RenderInfoDict; + targetMaterial.Material.RenderInfos = selectedMaterial.Material.RenderInfos; + } + if (menu.chkBoxShaderOptions.Checked) + { + targetMaterial.Material.ShaderAssign = selectedMaterial.Material.ShaderAssign; + } + if (menu.chkBoxShaderParams.Checked) + { + targetMaterial.Material.ShaderParamData = selectedMaterial.Material.ShaderParamData; + targetMaterial.Material.ShaderParamDict = selectedMaterial.Material.ShaderParamDict; + targetMaterial.Material.ShaderParams = selectedMaterial.Material.ShaderParams; + targetMaterial.Material.VolatileFlags = selectedMaterial.Material.VolatileFlags; + } + if (menu.chkBoxTextures.Checked) + { + targetMaterial.Material.SamplerDict = selectedMaterial.Material.SamplerDict; + targetMaterial.Material.Samplers = selectedMaterial.Material.Samplers; + targetMaterial.Material.SamplerSlotArray = selectedMaterial.Material.SamplerSlotArray; + targetMaterial.Material.TextureSlotArray = selectedMaterial.Material.TextureSlotArray; + targetMaterial.Material.TextureRefs = selectedMaterial.Material.TextureRefs; + } + targetMaterial.ReadMaterial(targetMaterial.Material); } - if (menu.chkBoxShaderOptions.Checked) + else { - targetMaterial.Material.ShaderAssign = selectedMaterial.Material.ShaderAssign; + targetMaterial.MaterialU.Flags = selectedMaterial.MaterialU.Flags; + targetMaterial.MaterialU.UserData = selectedMaterial.MaterialU.UserData; + + if (menu.chkBoxRenderInfo.Checked) + { + targetMaterial.MaterialU.RenderState = selectedMaterial.MaterialU.RenderState; + targetMaterial.MaterialU.RenderInfos = selectedMaterial.MaterialU.RenderInfos; + } + if (menu.chkBoxShaderOptions.Checked) + { + targetMaterial.MaterialU.ShaderAssign = selectedMaterial.MaterialU.ShaderAssign; + } + if (menu.chkBoxShaderParams.Checked) + { + targetMaterial.MaterialU.ShaderParamData = selectedMaterial.MaterialU.ShaderParamData; + targetMaterial.MaterialU.ShaderParams = selectedMaterial.MaterialU.ShaderParams; + targetMaterial.MaterialU.VolatileFlags = selectedMaterial.MaterialU.VolatileFlags; + } + if (menu.chkBoxTextures.Checked) + { + targetMaterial.MaterialU.Samplers = selectedMaterial.MaterialU.Samplers; + targetMaterial.MaterialU.TextureRefs = selectedMaterial.MaterialU.TextureRefs; + } + targetMaterial.ReadMaterial(targetMaterial.MaterialU); } - if (menu.chkBoxShaderParams.Checked) - { - targetMaterial.Material.ShaderParamData = selectedMaterial.Material.ShaderParamData; - targetMaterial.Material.ShaderParamDict = selectedMaterial.Material.ShaderParamDict; - targetMaterial.Material.ShaderParams = selectedMaterial.Material.ShaderParams; - targetMaterial.Material.VolatileFlags = selectedMaterial.Material.VolatileFlags; - } - if (menu.chkBoxTextures.Checked) - { - targetMaterial.Material.SamplerDict = selectedMaterial.Material.SamplerDict; - targetMaterial.Material.Samplers = selectedMaterial.Material.Samplers; - targetMaterial.Material.SamplerSlotArray = selectedMaterial.Material.SamplerSlotArray; - targetMaterial.Material.TextureSlotArray = selectedMaterial.Material.TextureSlotArray; - targetMaterial.Material.TextureRefs = selectedMaterial.Material.TextureRefs; - } - targetMaterial.ReadMaterial(targetMaterial.Material); } private void TransformTool() { diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs index e60b4a89..6f58f205 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs @@ -960,7 +960,7 @@ namespace Bfres.Structs List BonesNotMatched = new List(); - if (ForceSkinCount && !ob.HasIndices) + if (ForceSkinCount && !ob.HasIndices && VertexSkinCount != 0) { var attributeIndex = new FSHP.VertexAttribute(); attributeIndex.Format = ResGFX.AttribFormat.Format_8_8_8_8_UInt; diff --git a/Switch_FileFormatsMain/FileFormats/Texture/BFLIM.cs b/Switch_FileFormatsMain/FileFormats/Texture/BFLIM.cs index 407b23bf..41e5a677 100644 --- a/Switch_FileFormatsMain/FileFormats/Texture/BFLIM.cs +++ b/Switch_FileFormatsMain/FileFormats/Texture/BFLIM.cs @@ -155,7 +155,7 @@ namespace FirstPlugin { public STToolStripItem[] NewFileMenuExtensions => null; public STToolStripItem[] NewFromFileMenuExtensions => newFileExt; - public STToolStripItem[] ToolsMenuExtensions => null; + public STToolStripItem[] ToolsMenuExtensions => toolExt; public STToolStripItem[] TitleBarExtensions => null; public STToolStripItem[] CompressionMenuExtensions => null; public STToolStripItem[] ExperimentalMenuExtensions => null; @@ -163,11 +163,77 @@ namespace FirstPlugin public ToolStripButton[] IconButtonMenuExtensions => null; STToolStripItem[] newFileExt = new STToolStripItem[1]; + STToolStripItem[] toolExt = new STToolStripItem[1]; public MenuExt() { + toolExt[0] = new STToolStripItem("Textures"); + toolExt[0].DropDownItems.Add(new STToolStripItem("Batch Export (BFLIM)", Export)); newFileExt[0] = new STToolStripItem("BFLIM From Image", CreateNew); } + private void Export(object sender, EventArgs args) + { + string formats = FileFilters.GTX; + + string[] forms = formats.Split('|'); + + List Formats = new List(); + for (int i = 0; i < forms.Length; i++) + { + if (i > 1 || i == (forms.Length - 1)) //Skip lines with all extensions + { + if (!forms[i].StartsWith("*")) + Formats.Add(forms[i]); + } + } + + BatchFormatExport form = new BatchFormatExport(Formats); + if (form.ShowDialog() == DialogResult.OK) + { + string Extension = form.GetSelectedExtension(); + + OpenFileDialog ofd = new OpenFileDialog(); + ofd.Multiselect = true; + ofd.Filter = Utils.GetAllFilters(typeof(BFLIM)); + + if (ofd.ShowDialog() == DialogResult.OK) + { + FolderSelectDialog folderDialog = new FolderSelectDialog(); + if (folderDialog.ShowDialog() == DialogResult.OK) + { + foreach (string file in ofd.FileNames) + { + var FileFormat = STFileLoader.OpenFileFormat(file); + if (FileFormat == null) + continue; + + SearchBinary(FileFormat, folderDialog.SelectedPath, Extension); + } + } + } + } + } + + private void SearchBinary(IFileFormat FileFormat, string Folder, string Extension) + { + if (FileFormat is SARC) + { + foreach (var file in ((SARC)FileFormat).Files) + { + var archiveFile = STFileLoader.OpenFileFormat(file.FullName, file.Data); + if (archiveFile == null) + continue; + + SearchBinary(archiveFile, Folder, Extension); + } + } + if (FileFormat is BFLIM) + { + ((BFLIM)FileFormat).Export(Folder + FileFormat.FileName + Extension); + } + + FileFormat.Unload(); + } public void CreateNew(object sender, EventArgs args) { diff --git a/Switch_FileFormatsMain/FileFormats/Texture/NUTEXB.cs b/Switch_FileFormatsMain/FileFormats/Texture/NUTEXB.cs index d5c8d187..5e5910b8 100644 --- a/Switch_FileFormatsMain/FileFormats/Texture/NUTEXB.cs +++ b/Switch_FileFormatsMain/FileFormats/Texture/NUTEXB.cs @@ -298,6 +298,7 @@ namespace FirstPlugin } } } + public uint unk; public int unk2; diff --git a/Switch_FileFormatsMain/Main.cs b/Switch_FileFormatsMain/Main.cs index 46d8143c..ed864669 100644 --- a/Switch_FileFormatsMain/Main.cs +++ b/Switch_FileFormatsMain/Main.cs @@ -213,10 +213,10 @@ namespace FirstPlugin { foreach (var file in ((SARC)FileFormat).Files) { - string ext = System.IO.Path.GetExtension(file.Key); + string ext = System.IO.Path.GetExtension(file.FullName); if (ext == ".bfres") { - bfresFiles.Add((BFRES)STFileLoader.OpenFileFormat(file.Key, file.Value)); + bfresFiles.Add((BFRES)STFileLoader.OpenFileFormat(file.FullName, file.Data)); } } } diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index 0208c649..a06b8caa 100644 Binary files a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache and b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache index 828e4b91..bcda3a7f 100644 Binary files a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache and b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache differ diff --git a/Switch_Toolbox_Library/Forms/Editors/UV/UVEditor.cs b/Switch_Toolbox_Library/Forms/Editors/UV/UVEditor.cs index c748ded0..5bcc5617 100644 --- a/Switch_Toolbox_Library/Forms/Editors/UV/UVEditor.cs +++ b/Switch_Toolbox_Library/Forms/Editors/UV/UVEditor.cs @@ -247,7 +247,6 @@ namespace Switch_Toolbox.Library.Forms if (ActiveObjects.Count <= 0 || ActiveMaterial == null || Runtime.OpenTKInitialized == false) return; - SetupRendering(1); gL_ControlLegacy2D1.MakeCurrent();