public static bool PatchBgLayout(this BflytFile f, PatchTemplate patch) { #region DetectPatch if (f[patch.PatchIdentifier] != null) { return(true); } { var p = f["3x3lxBG"]; if (p != null) { f.RemovePane(p); f.GetTex.Textures[0] = "White1x1^r"; f.GetMat.Materials.RemoveAt(1); } } #endregion #region FindAndRemoveTargetBgPanels BasePane target = null; foreach (var t in patch.targetPanels) { var p = f[t]; if (p == null) { continue; } if (target == null) { target = p; } if (patch.DirectPatchPane) { ushort m = f.AddBgMat(patch.MaintextureName); var pe = p as Pic1Pane; pe.MaterialIndex = m; } else if (!patch.NoRemovePanel) { var pe = p as Pan1Pane; pe.Position = new Vector3(5000, 60000, 0); } } if (target == null) { return(false); } #endregion if (!patch.DirectPatchPane) { return(f.AddBgPanel(target, patch.MaintextureName, patch.PatchIdentifier)); } else { return(true); } }
static private bool AddBgPanel(this BflytFile f, BasePane target, string TexName, string Pic1Name) { #region add picture if (Pic1Name.Length > 0x18) { throw new Exception("Pic1Name should not be longer than 24 chars"); } var strm = new MemoryStream(); using (BinaryDataWriter bin = new BinaryDataWriter(strm)) { bin.ByteOrder = ByteOrder.LittleEndian; bin.Write((byte)0x01); bin.Write((byte)0x00); bin.Write((byte)0xFF); bin.Write((byte)0x04); bin.Write(Pic1Name, BinaryStringFormat.NoPrefixOrTermination); int zerCount = Pic1Name.Length; while (zerCount++ < 0x38) { bin.Write((byte)0x00); } bin.Write(1f); bin.Write(1f); bin.Write(1280f); bin.Write(720f); bin.Write((UInt32)0xFFFFFFFF); bin.Write((UInt32)0xFFFFFFFF); bin.Write((UInt32)0xFFFFFFFF); bin.Write((UInt32)0xFFFFFFFF); bin.Write((UInt16)f.AddBgMat(TexName)); bin.Write((UInt16)1); bin.Write((UInt32)0); bin.Write((UInt32)0); bin.Write(1f); bin.Write((UInt32)0); bin.Write((UInt32)0); bin.Write(1f); bin.Write(1f); bin.Write(1f); } #endregion BasePane p = new BasePane("pic1", 8); p.data = strm.ToArray(); target.Parent.Children.Insert(target.Parent.Children.IndexOf(target), p); return(true); }