diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index 001090cf..4e753ebf 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 6f69a3d6..5bd5ed24 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 d2316cfe..7727e823 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/BFRES/Bfres Structs/SubFiles/FMAA.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMAA.cs index 256b5179..0c303c6d 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMAA.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMAA.cs @@ -720,7 +720,7 @@ namespace Bfres.Structs } else if (ext == ".yaml") { - System.IO.File.WriteAllText(FileName, YamlFmaa.ToYaml(FileName, this)); + System.IO.File.WriteAllText(FileName, YamlFmaa.ToYaml(FileName, MaterialAnim)); } } public override void Replace(string FileName) diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FTXP.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FTXP.cs index 2953eddf..2cf6a1c7 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FTXP.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FTXP.cs @@ -226,7 +226,21 @@ namespace Bfres.Structs public override void Export(string FileName) { - TexPatternAnim.Export(FileName, GetResFile()); + string ext = Utils.GetExtension(FileName); + if (ext == ".bftxp") + { + TexPatternAnim.Export(FileName, GetResFile()); + } + else if (ext == ".bfmaa") + { + var fmaa = BfresPlatformConverter.FTXPConvertWiiUToSwitch(TexPatternAnim); + fmaa.Export(FileName, new Syroot.NintenTools.NSW.Bfres.ResFile()); + } + else if (ext == ".yaml") + { + var yaml = YamlFmaa.ToYaml(FileName, BfresPlatformConverter.FTXPConvertWiiUToSwitch(TexPatternAnim)); + System.IO.File.WriteAllText(FileName, yaml); + } } public override void Replace(string FileName) { @@ -239,10 +253,25 @@ namespace Bfres.Structs if (ext == ".bftxp") { - TexPatternAnim.Import(FileName, resFile); + bool IsSwitch = BfresUtilies.IsSubSectionSwitch(FileName); + if (IsSwitch) + { + var fmaa = new Syroot.NintenTools.NSW.Bfres.MaterialAnim(); + fmaa.Import(FileName); + TexPatternAnim = BfresPlatformConverter.FTXPConvertSwitchToWiiU(fmaa); + } + else + TexPatternAnim.Import(FileName, resFile); + TexPatternAnim.Name = Text; LoadAnim(TexPatternAnim); } + else if (ext == ".yaml") + { + var fmaa = new Syroot.NintenTools.NSW.Bfres.MaterialAnim(); + fmaa = YamlFmaa.FromYaml(FileName); + TexPatternAnim = BfresPlatformConverter.FTXPConvertSwitchToWiiU(fmaa); + } else if (ext == ".gif") { BFRESGroupNode ftexFolder = PluginRuntime.ftexContainers[0]; diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/PlatformConverter/BfresPlatformConverter.cs b/Switch_FileFormatsMain/FileFormats/BFRES/PlatformConverter/BfresPlatformConverter.cs index cf653394..3de2a9eb 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/PlatformConverter/BfresPlatformConverter.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/PlatformConverter/BfresPlatformConverter.cs @@ -131,6 +131,51 @@ namespace FirstPlugin return matAnim; } + public static ResU.TexPatternAnim FTXPConvertSwitchToWiiU(ResNX.MaterialAnim materialAnim) + { + var texPatternAnim = new ResU.TexPatternAnim(); + + //Different versions use different lists + if (texPatternAnim.TextureRefNames == null) + texPatternAnim.TextureRefNames = new List(); + if (texPatternAnim.TextureRefs == null) + texPatternAnim.TextureRefs = new ResU.ResDict(); + + texPatternAnim.Name = materialAnim.Name; + texPatternAnim.Path = materialAnim.Path; + texPatternAnim.BindIndices = materialAnim.BindIndices; + + //Fill both lists. On save only one will be used depending on version + foreach (var texName in materialAnim.TextureNames) + { + texPatternAnim.TextureRefNames.Add(new ResU.TextureRef() { Name = texName }); + texPatternAnim.TextureRefs.Add(texName, new ResU.TextureRef() { Name = texName }); + } + + for (int m = 0; m < materialAnim.MaterialAnimDataList.Count; m++) + { + ResU.TexPatternMatAnim matAnimData = new ResU.TexPatternMatAnim(); + matAnimData.Name = materialAnim.MaterialAnimDataList[m].Name; + matAnimData.Curves = ConvertAnimCurveSwitchToWiiU(materialAnim.MaterialAnimDataList[m].Curves); + + foreach (var constants in materialAnim.MaterialAnimDataList[m].Constants) + { + matAnimData.BaseDataList.Add((ushort)(int)constants.Value); + } + + foreach (var patternInfoNX in materialAnim.MaterialAnimDataList[m].TexturePatternAnimInfos) + { + var patternInfoU = new ResU.PatternAnimInfo(); + patternInfoU.Name = patternInfoNX.Name; + patternInfoU.CurveIndex = (sbyte)patternInfoNX.CurveIndex; + patternInfoU.SubBindIndex = patternInfoNX.SubBindIndex; + matAnimData.PatternAnimInfos.Add(patternInfoU); + } + } + + return texPatternAnim; + } + public static ResNX.MaterialAnim FTXPConvertWiiUToSwitch(ResU.TexPatternAnim texPatternAnim) { //Different versions use different lists diff --git a/Switch_FileFormatsMain/NodeWrappers/BfresFilters.cs b/Switch_FileFormatsMain/NodeWrappers/BfresFilters.cs index ddcdeb94..d53c53f5 100644 --- a/Switch_FileFormatsMain/NodeWrappers/BfresFilters.cs +++ b/Switch_FileFormatsMain/NodeWrappers/BfresFilters.cs @@ -35,7 +35,7 @@ namespace FirstPlugin public static string FCLH = GetFilter(".bfcsh"); public static string FSTH = GetFilter(".bfsth"); - public static string FTXP = GetFilter(".bftxp", ".gif"); + public static string FTXP = GetFilter(".bftxp", ".yaml", ".gif"); public static string FMTV = GetFilter(".bfmvi"); public static string FBNV = GetFilter(".bfbvi"); public static string FSCN = GetFilter(".bfscn"); @@ -134,6 +134,7 @@ namespace FirstPlugin case ".chr0": filters.Add(ext, "CHR0 Animation"); break; case ".anim": filters.Add(ext, "Maya Animation"); break; case ".yaml": filters.Add(ext, "Yet Another Markup Language"); break; + case ".gif": filters.Add(ext, "Graphics Interchange Format"); break; default: filters.Add(ext, ""); break; } diff --git a/Switch_FileFormatsMain/YAML/YamlFmaa.cs b/Switch_FileFormatsMain/YAML/YamlFmaa.cs index 23d1be95..9b414111 100644 --- a/Switch_FileFormatsMain/YAML/YamlFmaa.cs +++ b/Switch_FileFormatsMain/YAML/YamlFmaa.cs @@ -308,7 +308,7 @@ namespace FirstPlugin return config.FromYaml(); } - public static string ToYaml(string Name, FMAA anim) + public static string ToYaml(string Name, MaterialAnim MatAnim) { var serializerSettings = new SerializerSettings() { @@ -319,7 +319,6 @@ namespace FirstPlugin serializerSettings.ComparerForKeySorting = null; serializerSettings.RegisterTagMapping("AnimConfig", typeof(AnimConfig)); - var MatAnim = anim.MaterialAnim; var config = new AnimConfig(); config.ToYaml(MatAnim); diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index f50740a6..c363e087 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 d2e4621a..086708db 100644 Binary files a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache and b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache differ