/// <summary> /// /// </summary> /// <param name="fighter"></param> /// <param name="editor"></param> /// <param name="internalID"></param> private void RemoveUI(MEXFighterEntry fighter, MexDataEditor editor, int internalID) { Console.WriteLine("Removing UI"); var root = Path.GetDirectoryName(MainForm.Instance.FilePath); int GroupID = MEXIdConverter.ToExternalID(internalID, editor.FighterControl.FighterEntries.Count + 1) - 1; int stride = editor.FighterControl.FighterEntries.Count - 3 + 1; Console.WriteLine("Removing CSP"); /*var chrSelPath = Path.Combine(root, "MnSlChr.usd"); * if (File.Exists(chrSelPath)) * { * var cssFile = new HSDRawFile(chrSelPath); * * if (cssFile.Roots[0].Data is SBM_SelectChrDataTable cssTable) * { * foreach (var n in cssTable.SingleMenuMaterialAnimation.Children[9].Children) * RemoveMatAnim(n.MaterialAnimation.TextureAnimation, GroupID, stride, FighterPackageInstaller.MAX_COSTUME_COUNT); * * foreach (var n in cssTable.MenuMaterialAnimation.Children[6].Children) * RemoveMatAnim(n.MaterialAnimation.TextureAnimation, GroupID, stride, FighterPackageInstaller.MAX_COSTUME_COUNT); * * foreach (var n in cssTable.SingleMenuMaterialAnimation.Children[6].Children) * RemoveMatAnim(n.MaterialAnimation.TextureAnimation, GroupID, stride, FighterPackageInstaller.MAX_COSTUME_COUNT); * * foreach (var n in cssTable.PortraitMaterialAnimation.Children[2].Children) * RemoveMatAnim(n.MaterialAnimation.TextureAnimation, GroupID, stride, FighterPackageInstaller.MAX_COSTUME_COUNT); * * * foreach (var n in cssTable.MenuMaterialAnimation.Children[5].Children) * RemoveMatAnim(n.MaterialAnimation.Next.TextureAnimation, GroupID, stride, 1); * * foreach (var n in cssTable.SingleMenuMaterialAnimation.Children[5].Children) * RemoveMatAnim(n.MaterialAnimation.Next.TextureAnimation, GroupID, stride, 1); * * foreach (var n in cssTable.PortraitMaterialAnimation.Children[1].Children) * RemoveMatAnim(n.MaterialAnimation.Next.TextureAnimation, GroupID, stride, 1); * * } * * editedFiles.Add(new Tuple<HSDRawFile, string, bool>(cssFile, chrSelPath, true)); * }*/ Console.WriteLine("Removing Icons"); var ifallPath = Path.Combine(root, "IfAll.usd"); if (File.Exists(ifallPath)) { var datFile = new HSDRawFile(ifallPath); var mark = datFile.Roots.Find(e => e.Name.Equals("Stc_scemdls")).Data as HSDNullPointerArrayAccessor <HSD_JOBJDesc>; for (int i = 0; i < 7; i++) // first 7 { RemoveMatAnim(mark[0].MaterialAnimations[0].Children[i].MaterialAnimation.TextureAnimation, GroupID, stride, FighterPackageInstaller.MAX_COSTUME_COUNT); } var emblemGroup = datFile.Roots.Find(e => e.Name.Equals("DmgMrk_scene_models")).Data as HSDNullPointerArrayAccessor <HSD_JOBJDesc>; RemoveMatAnim(emblemGroup[0].MaterialAnimations[0].Child.MaterialAnimation.TextureAnimation, GroupID, stride, 1); editedFiles.Add(new Tuple <HSDRawFile, string, bool>(datFile, ifallPath, true)); } Console.WriteLine("Removing Result UI"); var gmrst = Path.Combine(root, "GmRst.usd"); if (File.Exists(gmrst)) { var datFile = new HSDRawFile(gmrst); var flmsce = datFile.Roots.Find(e => e.Name.Equals("flmsce")).Data as HSD_SOBJ; var pnlsce = datFile.Roots.Find(e => e.Name.Equals("pnlsce")).Data as HSD_SOBJ; // remove stock icons for (int i = 5; i <= 8; i++) // at 5-8, 2nd mat anim { RemoveMatAnim(pnlsce.JOBJDescs[0].MaterialAnimations[0].Children[i].MaterialAnimation.Next.TextureAnimation, GroupID, stride, FighterPackageInstaller.MAX_COSTUME_COUNT); } // remove emblem entries var matgroup = pnlsce.JOBJDescs[0].MaterialAnimations[0].Children[17]; for (int i = 0; i < 4; i++) { RemoveMatAnim(matgroup.Children[i].MaterialAnimation.TextureAnimation, GroupID, stride, 1); } // check if any other fighter is using this stock icon // if not, remove it and adjust ids if (!editor.FighterControl.FighterEntries.Any(e => e.InsigniaID == fighter.InsigniaID)) { var emblemGroup = flmsce.JOBJDescs[0]; emblemGroup.JointAnimations[0].Children[4].RemoveChildAt(fighter.InsigniaID); emblemGroup.MaterialAnimations[0].Children[4].RemoveChildAt(fighter.InsigniaID); emblemGroup.RootJoint.Children[4].RemoveChildAt(fighter.InsigniaID); foreach (var f in editor.FighterControl.FighterEntries) { if (f.InsigniaID > fighter.InsigniaID) { f.InsigniaID--; } } } // name textures var largenameGroup = pnlsce.JOBJDescs[0].MaterialAnimations[0].Children[0].Children[2].MaterialAnimation.Next.TextureAnimation; RemoveMatAnim(largenameGroup, GroupID, stride, 1); var smallnameGroup = pnlsce.JOBJDescs[0].MaterialAnimations[0]; for (int i = 9; i < 13; i++) { RemoveMatAnim(smallnameGroup.Children[i].Children[1].MaterialAnimation.TextureAnimation, GroupID, stride, 1); } editedFiles.Add(new Tuple <HSDRawFile, string, bool>(datFile, gmrst, true)); } }
/// <summary> /// /// </summary> private void InstallUI(ZipFile pack, MEXFighterEntry fighter) { Console.WriteLine($"Installing UI data..."); // LOAD Stock Icons var icons = pack.Where(e => Regex.IsMatch(e.FileName, "Icon/ico..\\.png")).ToArray(); HSD_TOBJ[] iconTOBJs = new HSD_TOBJ[icons.Length]; foreach (var c in icons) { var index = int.Parse(Regex.Match(c.FileName, @"\d\d").Value); using (MemoryStream stream = new MemoryStream(GetBytes(c))) using (var bmp = new System.Drawing.Bitmap(stream)) iconTOBJs[index] = TOBJConverter.BitmapToTOBJ(bmp, HSDRaw.GX.GXTexFmt.CI4, HSDRaw.GX.GXTlutFmt.RGB5A3); } // Load Menu Icon // Load Emblem var emblemPack = pack["UI/emblem.obj"]; HSD_TOBJ emblemTexture = null; HSD_JOBJ emblemModel = null; if (emblemPack != null) { EmblemModel model; using (MemoryStream stream = new MemoryStream()) { emblemPack.Extract(stream); stream.Position = 0; model = Converters.EmblemConverter.GenerateEmblemModelFromOBJ(stream); } emblemModel = Converters.EmblemConverter.GenerateEmblemModel(model); emblemTexture = Converters.EmblemConverter.GenerateEmblemIconImage(model); } // Load Misc Name Tags and icons var largeName = pack["UI/result_victory_name.png"]; var smallName = pack["UI/result_name.png"]; HSD_TOBJ largeNameTexture = null; HSD_TOBJ smallNameTexture = null; if (largeName != null) { using (MemoryStream stream = new MemoryStream(GetBytes(largeName))) using (var bmp = new System.Drawing.Bitmap(stream)) largeNameTexture = TOBJConverter.BitmapToTOBJ(bmp, HSDRaw.GX.GXTexFmt.I4, HSDRaw.GX.GXTlutFmt.IA8); } if (smallName != null) { using (MemoryStream stream = new MemoryStream(GetBytes(smallName))) using (var bmp = new System.Drawing.Bitmap(stream)) smallNameTexture = TOBJConverter.BitmapToTOBJ(bmp, HSDRaw.GX.GXTexFmt.I4, HSDRaw.GX.GXTlutFmt.IA8); } // -------------------------------------------------------------------------- var root = Path.GetDirectoryName(MainForm.Instance.FilePath); int stride = editor.FighterControl.FighterEntries.Count - 3; int internalID = editor.FighterControl.FighterEntries.IndexOf(fighter); var externalId = MEXIdConverter.ToExternalID(internalID, editor.FighterControl.FighterEntries.Count); int GroupID = externalId - (externalId > 18 ? 1 : 0); // Inject CSPs and Stock Icons into Character Select //var chrSelPath = Path.Combine(root, "MnSlChr.usd"); //if (File.Exists(chrSelPath)) // InjectCharSelectImages(pack, chrSelPath, iconTOBJs, emblemTexture, fighter, stride, GroupID); // Inject Stock Icons into IfAll, GmRst var ifallPath = Path.Combine(root, "IfAll.usd"); if (File.Exists(ifallPath)) { var datFile = new HSDRawFile(ifallPath); var mark = datFile.Roots.Find(e => e.Name.Equals("Stc_scemdls")).Data as HSDNullPointerArrayAccessor <HSD_JOBJDesc>; for (int i = 0; i < 7; i++) // first 7 { InjectIntoMatTexAnim(mark[0].MaterialAnimations[0].Children[i].MaterialAnimation.TextureAnimation, iconTOBJs, GroupID, stride, MAX_COSTUME_COUNT); } var emblemGroup = datFile.Roots.Find(e => e.Name.Equals("DmgMrk_scene_models")).Data as HSDNullPointerArrayAccessor <HSD_JOBJDesc>; InjectIntoMatTexAnim(emblemGroup[0].MaterialAnimations[0].Child.MaterialAnimation.TextureAnimation, new HSDRaw.Common.HSD_TOBJ[] { emblemTexture }, GroupID, stride, 1, fighter.InsigniaID); editedFiles.Add(new Tuple <HSDRawFile, string, bool>(datFile, ifallPath, true)); } var gmRst = Path.Combine(root, "GmRst.usd"); if (File.Exists(gmRst)) { var datFile = new HSDRawFile(gmRst); var flmsce = datFile.Roots.Find(e => e.Name.Equals("flmsce")).Data as HSD_SOBJ; var pnlsce = datFile.Roots.Find(e => e.Name.Equals("pnlsce")).Data as HSD_SOBJ; // Stock Icons------------------------------------- for (int i = 5; i <= 8; i++) // at 5-8, 2nd mat anim { InjectIntoMatTexAnim( pnlsce.JOBJDescs[0].MaterialAnimations[0].Children[i].MaterialAnimation.Next.TextureAnimation, iconTOBJs, GroupID, stride, MAX_COSTUME_COUNT); } // Emblem Textures-------------------------------------- var matgroup = pnlsce.JOBJDescs[0].MaterialAnimations[0].Children[17]; for (int i = 0; i < 4; i++) { InjectIntoMatTexAnim(matgroup.Children[i].MaterialAnimation.TextureAnimation, new HSDRaw.Common.HSD_TOBJ[] { emblemTexture }, GroupID, stride, 1, fighter.InsigniaID); } // Emblem Model-------------------------------------- var emblemGroup = flmsce.JOBJDescs[0]; if (emblemModel != null) { var modelIndex = emblemGroup.RootJoint.Children[4].Children.Length; fighter.InsigniaID = (byte)modelIndex; var jointClone = HSDAccessor.DeepClone <HSDRaw.Common.Animation.HSD_AnimJoint>(emblemGroup.JointAnimations[0].Children[4].Child); jointClone.Next = null; var matjointClone = HSDAccessor.DeepClone <HSDRaw.Common.Animation.HSD_MatAnimJoint>(emblemGroup.MaterialAnimations[0].Children[4].Child); matjointClone.Next = null; emblemGroup.JointAnimations[0].Children[4].AddChild(jointClone); emblemGroup.MaterialAnimations[0].Children[4].AddChild(matjointClone); emblemGroup.RootJoint.Children[4].AddChild(emblemModel); } // name textures var largenameGroup = pnlsce.JOBJDescs[0].MaterialAnimations[0].Children[0].Children[2].MaterialAnimation.Next.TextureAnimation; InjectIntoMatTexAnim(largenameGroup, new HSD_TOBJ[] { largeNameTexture }, GroupID, stride, 1); var smallnameGroup = pnlsce.JOBJDescs[0].MaterialAnimations[0]; for (int i = 9; i < 13; i++) { InjectIntoMatTexAnim(smallnameGroup.Children[i].Children[1].MaterialAnimation.TextureAnimation, new HSD_TOBJ[] { smallNameTexture }, GroupID, stride, 1); } editedFiles.Add(new Tuple <HSDRawFile, string, bool>(datFile, gmRst, true)); } // Inject Emblem // Generate Emblem Models and Inject // Inject Misc Name Tags and icons }