public virtual bool ShowPane(BasePane pane) { if (pane is IObserver) { ((IObserver)pane).Subject = this._subject; } this.SuspendLayout(); this.PanePanel.SuspendLayout(); if (this._currentPane != null) { this._currentPane.Close(); if (!this._currentPane.Equals((object)pane)) { this.RemoveCurrentPane(); } } this.actionToolbar.Items.Clear(); this.actionToolbar.Visible = false; pane.Dock = DockStyle.Fill; if (pane.Parent != this.PanePanel) { this.PanePanel.Controls.Add((Control)pane); } this._currentPane = pane; this._currentPane.Open(); this.FocusFirstControl(); this.PanePanel.ResumeLayout(); this.ResumeLayout(); return(true); }
private void WritePanes(FileWriter writer, BasePane pane, LayoutHeader header, ref int sectionCount) { WriteSection(writer, pane.Signature, pane, () => pane.Write(writer, header)); sectionCount++; if (pane is IUserDataContainer && ((IUserDataContainer)pane).UserData != null && ((IUserDataContainer)pane).UserData.Entries.Count > 0) { var userData = ((IUserDataContainer)pane).UserData; WriteSection(writer, "usd1", userData, () => userData.Write(writer, this)); sectionCount++; } if (pane.HasChildern) { sectionCount += 2; //Write start of children section WriteSection(writer, "pas1", null); foreach (var child in pane.Childern) { WritePanes(writer, child, header, ref sectionCount); } //Write pae1 of children section WriteSection(writer, "pae1", null); } }
private void SetPane(BasePane pane, BasePane parentPane) { if (parentPane != null) { parentPane.Childern.Add(pane); pane.Parent = parentPane; } }
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); } }
public virtual BasePane Clone() { MemoryStream mem = new MemoryStream(); BinaryDataWriter bin = new BinaryDataWriter(mem); WritePane(bin); BasePane res = new BasePane(name, (byte[])data.Clone()); if (name != "usd1" && UserData != null) { res.UserData = (Usd1Pane)UserData.Clone(); } return(res); }
public IEnumerable <BasePane> EnumeratePanes(List <BasePane> source) { var ToProcess = new Queue <BasePane>(source); while (ToProcess.Count > 0) { BasePane item = ToProcess.Dequeue(); yield return(item); foreach (var c in item.Children) { ToProcess.Enqueue(c); } } }
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); }
private void RemoveCurrentPane() { if (this._currentPane == null) { return; } if (this._currentPane.ToolStrip != null) { this.PanePanel.Controls.Remove((Control)this._currentPane.ToolStrip); this._currentPane.ToolStrip.Parent = (Control)null; } this.PanePanel.Controls.Remove((Control)this._currentPane); this.actionToolbar.Items.Clear(); if (!this._currentPane.KeepOpen) { this._currentPane.Dispose(); } this._currentPane = (BasePane)null; }
private void WriteGroupPanes(FileWriter writer, BasePane pane, LayoutHeader header, ref int sectionCount) { WriteSection(writer, pane.Signature, pane, () => pane.Write(writer, header)); sectionCount++; if (pane.HasChildern) { sectionCount += 2; //Write start of children section WriteSection(writer, "grs1", null); foreach (var child in pane.Childern) { WriteGroupPanes(writer, child, header, ref sectionCount); } //Write pae1 of children section WriteSection(writer, "gre1", null); } }
public void Read(FileReader reader, BFLYT bflyt) { PaneLookup.Clear(); LayoutInfo = new LYT1(); TextureList = new TXL1(); MaterialList = new MAT1(); FontList = new FNL1(); RootPane = new PAN1(); RootGroup = new GRP1(); UserData = new USD1(); FileInfo = bflyt; reader.SetByteOrder(true); reader.ReadSignature(4, Magic); ByteOrderMark = reader.ReadUInt16(); reader.CheckByteOrderMark(ByteOrderMark); HeaderSize = reader.ReadUInt16(); Version = reader.ReadUInt32(); SetVersionInfo(); uint FileSize = reader.ReadUInt32(); ushort sectionCount = reader.ReadUInt16(); reader.ReadUInt16(); //Padding IsBigEndian = reader.ByteOrder == Syroot.BinaryData.ByteOrder.BigEndian; if (!IsBigEndian) { if (VersionMajor == 3) { TextureManager.Platform = TextureManager.PlatformType.ThreeDS; } else { TextureManager.Platform = TextureManager.PlatformType.Switch; } } else { TextureManager.Platform = TextureManager.PlatformType.WiiU; } TextureManager.LayoutFile = this; bool setRoot = false; bool setGroupRoot = false; BasePane currentPane = null; BasePane parentPane = null; BasePane currentGroupPane = null; BasePane parentGroupPane = null; reader.SeekBegin(HeaderSize); for (int i = 0; i < sectionCount; i++) { long pos = reader.Position; string Signature = reader.ReadString(4, Encoding.ASCII); uint SectionSize = reader.ReadUInt32(); SectionCommon section = new SectionCommon(Signature); switch (Signature) { case "lyt1": LayoutInfo = new LYT1(reader); break; case "txl1": TextureList = new TXL1(reader, this); break; case "fnl1": FontList = new FNL1(reader, this); break; case "mat1": MaterialList = new MAT1(reader, this); break; case "pan1": var panel = new PAN1(reader, this); AddPaneToTable(panel); if (!setRoot) { RootPane = panel; setRoot = true; } SetPane(panel, parentPane); currentPane = panel; break; case "pic1": var picturePanel = new PIC1(reader, this); AddPaneToTable(picturePanel); SetPane(picturePanel, parentPane); currentPane = picturePanel; break; case "txt1": var textPanel = new TXT1(reader, this); AddPaneToTable(textPanel); SetPane(textPanel, parentPane); currentPane = textPanel; break; case "bnd1": var boundsPanel = new BND1(reader, this); AddPaneToTable(boundsPanel); SetPane(boundsPanel, parentPane); currentPane = boundsPanel; break; case "prt1": var partsPanel = new PRT1(reader, this); AddPaneToTable(partsPanel); SetPane(partsPanel, parentPane); currentPane = partsPanel; break; case "wnd1": var windowPanel = new WND1(reader, this); AddPaneToTable(windowPanel); SetPane(windowPanel, parentPane); currentPane = windowPanel; break; case "scr1": var scissorPane = new SCR1(reader, this); AddPaneToTable(scissorPane); SetPane(scissorPane, parentPane); currentPane = scissorPane; break; case "ali1": var alignmentPane = new ALI1(reader, this); AddPaneToTable(alignmentPane); SetPane(alignmentPane, parentPane); currentPane = alignmentPane; break; case "pas1": if (currentPane != null) { parentPane = currentPane; } break; case "pae1": if (parentPane != null) { currentPane = parentPane; } parentPane = currentPane.Parent; break; case "grp1": var groupPanel = new GRP1(reader, this); if (!setGroupRoot) { RootGroup = groupPanel; setGroupRoot = true; } SetPane(groupPanel, parentGroupPane); currentGroupPane = groupPanel; break; case "grs1": if (currentGroupPane != null) { parentGroupPane = currentGroupPane; } break; case "gre1": currentGroupPane = parentGroupPane; parentGroupPane = currentGroupPane.Parent; break; /* case "cnt1": * Container = new CNT1(reader, this); * break;*/ case "usd1": long dataPos = reader.Position; if (currentPane != null) { ((PAN1)currentPane).UserData = new USD1(reader, this); reader.SeekBegin(dataPos); ((PAN1)currentPane).UserData.Data = reader.ReadBytes((int)SectionSize - 8); } else { //User data before panes UserData = new USD1(reader, this); reader.SeekBegin(dataPos); UserData.Data = reader.ReadBytes((int)SectionSize - 8); } break; //If the section is not supported store the raw bytes default: section.Data = reader.ReadBytes((int)SectionSize - 8); UnknownSections.Add(section); Console.WriteLine("Unknown section!" + Signature); break; } section.SectionSize = SectionSize; reader.SeekBegin(pos + SectionSize); } }
public void Read(FileReader reader, BLO bloFile) { FileInfo = bloFile; reader.SetByteOrder(true); reader.ReadSignature(4, "SCRN"); string version = reader.ReadString(4, Encoding.ASCII); switch (version) { case "blo0": Version = 0; break; case "blo1": Version = 1; break; case "blo2": Version = 2; break; default: throw new Exception("Unknown blo version! " + version); } uint fileSize = reader.ReadUInt32(); uint numSections = reader.ReadUInt32(); reader.Seek(0x10); //padding bool setRoot = false; bool setGroupRoot = false; BasePane currentPane = null; BasePane parentPane = null; this.RootGroup = new GroupPane(); for (int i = 0; i < numSections; i++) { long pos = reader.Position; string Signature = reader.ReadString(4, Encoding.ASCII); uint SectionSize = reader.ReadUInt32(); switch (Signature) { case "INF1": LayoutInfo = new INF1(reader, this); break; case "TEX1": textureList = StringList.Read(reader, this); break; case "FNT1": fontList = StringList.Read(reader, this); break; case "MAT1": var mats = MAT1.ReadMaterials(reader, this); foreach (var mat in mats) { materialList.Add(mat); } break; case "PAN1": { var panel = new PAN1(reader, this); AddPaneToTable(panel); if (!setRoot) { RootPane = panel; setRoot = true; } SetPane(panel, parentPane); currentPane = panel; } break; case "PAN2": { var panel = new PAN2(reader, this); AddPaneToTable(panel); if (!setRoot) { RootPane = panel; setRoot = true; } SetPane(panel, parentPane); currentPane = panel; } break; case "PIC1": { var picturePanel = new PIC1(reader, this); AddPaneToTable(picturePanel); if (picturePanel.TextureName != string.Empty && !textureList.Contains(picturePanel.TextureName)) { textureList.Add(picturePanel.TextureName); } SetPane(picturePanel, parentPane); currentPane = picturePanel; break; } case "PIC2": { reader.ReadUInt32(); //pan1 magic reader.ReadUInt32(); //pan1 size var picturePanel = new PIC2(reader, this); AddPaneToTable(picturePanel); SetPane(picturePanel, parentPane); currentPane = picturePanel; break; } case "WIN1": var windowPane = new WIN1(reader, this); AddPaneToTable(windowPane); SetPane(windowPane, parentPane); currentPane = windowPane; break; case "BGN1": if (currentPane != null) { parentPane = currentPane; } break; case "END1": if (parentPane != null) { currentPane = parentPane; } parentPane = currentPane.Parent; break; case "EXT1": // reader.ReadUInt32(); // reader.Align(0x20); break; default: Console.WriteLine("Unknown section!" + Signature); break; } reader.SeekBegin(pos + SectionSize); } }
public IEnumerable <BasePane> EnumeratePanes(BasePane source) => EnumeratePanes(new List <BasePane>() { source });