public BCLYT(ref EndianBinaryReader reader) { reader.SetEndianess(Endianess.Little); if (reader.ReadString(4) != "CLYT") { Console.WriteLine("Bad magic. Expected CLYT."); return; } mBOM = reader.ReadUInt16(); mHeaderLength = reader.ReadUInt16(); mRevision = reader.ReadUInt32(); mFileSize = reader.ReadUInt32(); mSectionCount = reader.ReadUInt32(); mLayoutParams = new LYT1(ref reader); mUserDataEntries = new List <USD1>(); LayoutBase prev = null; LayoutBase parent = null; // for groups LayoutBase previousGroup = null; LayoutBase groupParent = null; bool isRootPaneSet = false; bool isRootGroupSet = false; string magic = ""; for (uint i = 0; i < mSectionCount; i++) { magic = reader.ReadString(4); switch (magic) { case "txl1": mTextureList = new TXL1(ref reader); break; case "fnl1": mFontList = new FNL1(ref reader); break; case "mat1": mMaterialList = new MAT1(ref reader); break; case "pan1": PAN1 panel = new PAN1(ref reader); if (!isRootPaneSet) { mRootPanel = panel; isRootPaneSet = true; } if (parent != null) { parent.addChild(panel); panel.setParent(parent); } prev = panel; break; case "pic1": PIC1 pic = new PIC1(ref reader); if (parent != null) { parent.addChild(pic); pic.setParent(parent); } prev = pic; break; case "bnd1": BND1 bnd = new BND1(ref reader); if (parent != null) { parent.addChild(bnd); bnd.setParent(parent); } prev = bnd; break; case "txt1": TXT1 txt = new TXT1(ref reader); if (parent != null) { parent.addChild(txt); txt.setParent(parent); } prev = txt; break; case "usd1": USD1 usd = new USD1(ref reader); if (prev != null) { prev.addUserData(usd); } break; case "wnd1": WND1 window = new WND1(ref reader, ref mMaterialList); if (parent != null) { parent.addChild(window); window.setParent(parent); } prev = window; break; case "pas1": if (prev != null) { parent = prev; } reader.ReadUInt32(); break; case "pae1": prev = parent; parent = prev.getParent(); reader.ReadUInt32(); break; case "pts1": MessageBox.Show("PTS1 found! Do tell shibboleet about this..."); break; case "grp1": GRP1 group = new GRP1(ref reader); if (!isRootGroupSet) { mRootGroup = group; isRootGroupSet = true; } if (groupParent != null) { groupParent.addChild(group); group.setParent(groupParent); } previousGroup = group; break; case "grs1": if (previousGroup != null) { groupParent = previousGroup; } reader.ReadUInt32(); break; case "gre1": previousGroup = groupParent; groupParent = previousGroup.getParent(); reader.ReadUInt32(); break; default: Console.WriteLine("Unsupported magic " + magic); break; } } }
public BFLYT(ref EndianBinaryReader reader) : base() { if (reader.ReadString(4) != "FLYT") { Console.WriteLine("Bad magic. Expected FLYT."); return; } mBOM = reader.ReadUInt16(); if (mBOM == 0xFEFF) { reader.SetEndianess(utils.Endian.Endianess.Little); } else { reader.SetEndianess(utils.Endian.Endianess.Big); } mHeaderSize = reader.ReadUInt16(); mVersion = reader.ReadUInt32(); mVersionMajor = mVersion >> 24; mVersionMinor = (mVersion >> 16) & 0xFF; mVersionMicro = (mVersion >> 8) & 0xFF; mVersionMicro2 = mVersion & 0xFF; string str = String.Format("Version: {0}.{1}.{2}.{3}", mVersionMajor, mVersionMinor, mVersionMicro, mVersionMicro2); Console.WriteLine(str); mFileSize = reader.ReadUInt32(); mNumSections = reader.ReadUInt16(); reader.ReadUInt16(); mLayoutParams = new LYT1(ref reader); // for panels LayoutBase prev = null; LayoutBase parent = null; bool isRootPaneSet = false; bool isRootGroupSet = false; // for groups LayoutBase previousGroup = null; LayoutBase groupParent = null; string magic = ""; for (ushort i = 0; i < mNumSections - 1; i++) { magic = reader.ReadString(4); switch (magic) { case "txl1": mTextureList = new TXL1(ref reader); break; case "fnl1": mFontList = new FNL1(ref reader); break; case "mat1": mMaterialList = new MAT1(ref reader, mVersion); break; case "pan1": PAN1 panel = new PAN1(ref reader); if (!isRootPaneSet) { mRootPanel = panel; isRootPaneSet = true; } if (parent != null) { parent.addChild(panel); panel.setParent(parent); } prev = panel; break; case "pic1": PIC1 pic = new PIC1(ref reader, ref mMaterialList, mVersionMajor, mVersionMinor); if (parent != null) { parent.addChild(pic); pic.setParent(parent); } prev = pic; break; case "txt1": TXT1 txt = new TXT1(ref reader, ref mMaterialList, ref mFontList, mVersion); if (parent != null) { parent.addChild(txt); txt.setParent(parent); } prev = txt; break; case "bnd1": BND1 bnd = new BND1(ref reader); if (parent != null) { parent.addChild(bnd); bnd.setParent(parent); } prev = bnd; break; case "prt1": PRT1 prt = new PRT1(ref reader); if (parent != null) { parent.addChild(prt); prt.setParent(parent); } prev = prt; break; case "wnd1": WND1 window = new WND1(ref reader, ref mMaterialList); if (parent != null) { parent.addChild(window); window.setParent(parent); } prev = window; break; case "cnt1": CNT1 cnt = new CNT1(ref reader, mVersionMajor); if (parent != null) { parent.addChild(cnt); cnt.setParent(parent); } prev = cnt; break; case "usd1": USD1 usd = new USD1(ref reader); if (prev != null) { prev.addUserData(usd); } break; case "pas1": if (prev != null) { parent = prev; } reader.ReadUInt32(); break; case "pae1": prev = parent; parent = prev.getParent(); reader.ReadUInt32(); break; case "grp1": GRP1 group = new GRP1(ref reader, mVersionMajor); if (!isRootGroupSet) { mRootGroup = group; isRootGroupSet = true; } if (groupParent != null) { groupParent.addChild(group); group.setParent(groupParent); } previousGroup = group; break; case "grs1": if (previousGroup != null) { groupParent = previousGroup; } reader.ReadUInt32(); break; case "gre1": previousGroup = groupParent; groupParent = previousGroup.getParent(); reader.ReadUInt32(); break; default: Console.WriteLine("Unsupported magic " + magic); break; } } }
public BRLYT(ref EndianBinaryReader reader) : base() { reader.SetEndianess(Endianess.Big); base.setLayoutVersion(LayoutVersion.Wii); if (reader.ReadString(4) != "RLYT") { Console.WriteLine("Bad magic. Expected RLYT."); return; } mBOM = reader.ReadUInt16(); mVersion = reader.ReadUInt16(); mFileLength = reader.ReadUInt32(); mHeaderLength = reader.ReadUInt16(); mNumSections = reader.ReadUInt16(); mLayoutParams = new LYT1(ref reader); // for panels LayoutBase prev = null; LayoutBase parent = null; bool isRootPaneSet = false; bool isRootGroupSet = false; // for groups LayoutBase previousGroup = null; LayoutBase groupParent = null; for (int i = 0; i < mNumSections; i++) { string magic = reader.ReadString(4); switch (magic) { case "txl1": mTextureList = new TXL1(ref reader); break; case "fnl1": mFontList = new FNL1(ref reader); break; case "mat1": mMaterialList = new MAT1(ref reader); break; case "pan1": PAN1 panel = new PAN1(ref reader); // root panel *should* be the first thing in the list of elements // so if it isn't, then the layout is wrong if (!isRootPaneSet) { mRootPanel = panel; isRootPaneSet = true; } if (parent != null) { parent.addChild(panel); panel.setParent(parent); } prev = panel; break; case "pic1": PIC1 pic = new PIC1(ref reader, ref mMaterialList); if (parent != null) { parent.addChild(pic); pic.setParent(parent); } prev = pic; break; case "bnd1": BND1 bnd = new BND1(ref reader); if (parent != null) { parent.addChild(bnd); bnd.setParent(parent); } prev = bnd; break; case "txt1": TXT1 txt = new TXT1(ref reader, ref mMaterialList, ref mFontList); if (parent != null) { parent.addChild(txt); txt.setParent(parent); } prev = txt; break; case "usd1": // user data is assigned to the previous read element USD1 usd = new USD1(ref reader); if (prev != null) { prev.addUserData(usd); } break; case "wnd1": WND1 window = new WND1(ref reader, ref mMaterialList); if (parent != null) { parent.addChild(window); window.setParent(parent); } prev = window; break; case "pas1": if (prev != null) { parent = prev; } reader.ReadUInt32(); break; case "pae1": prev = parent; parent = prev.getParent(); reader.ReadUInt32(); break; case "grp1": GRP1 group = new GRP1(ref reader); if (!isRootGroupSet) { mRootGroup = group; isRootGroupSet = true; } if (groupParent != null) { groupParent.addChild(group); group.setParent(groupParent); } previousGroup = group; break; case "grs1": if (previousGroup != null) { groupParent = previousGroup; } reader.ReadUInt32(); break; case "gre1": previousGroup = groupParent; groupParent = previousGroup.getParent(); reader.ReadUInt32(); break; } } }
public BLO1(ref EndianBinaryReader reader) { reader.SetEndianess(Endian.Endianess.Big); reader.Seek(0xC); mSectionCount = reader.ReadUInt32(); reader.ReadBytes(0x10); mInfo = new INF1(ref reader); string magic = ""; LayoutBase prev = null; LayoutBase parent = null; mTextureNames = new List <string>(); bool isRootPaneSet = false; for (int i = 0; i < mSectionCount; i++) { magic = reader.ReadString(4); switch (magic) { case "PAN1": PAN1 panel = new PAN1(ref reader); if (!isRootPaneSet) { mRootPanel = panel; isRootPaneSet = true; } if (parent != null) { parent.addChild(panel); panel.setParent(parent); } prev = panel; break; case "PIC1": PIC1 pic = new PIC1(ref reader); if (parent != null) { parent.addChild(pic); pic.setParent(parent); } prev = pic; // we need to find the textures ourselves if (!mTextureNames.Contains(pic.getTextureName())) { mTextureNames.Add(pic.getTextureName()); } break; case "WIN1": WIN1 window = new WIN1(ref reader); if (parent != null) { parent.addChild(window); window.setParent(parent); } prev = window; break; case "TBX1": TBX1 text = new TBX1(ref reader); if (parent != null) { parent.addChild(text); text.setParent(parent); } prev = text; break; case "BGN1": if (prev != null) { parent = prev; } reader.ReadUInt32(); break; case "END1": prev = parent; parent = prev.getParent(); reader.ReadUInt32(); break; case "EXT1": reader.ReadUInt32(); reader.ReadAligned(0x20); break; default: Console.WriteLine("Section " + magic + " not supported."); break; } } }
public BLO2(ref EndianBinaryReader reader) { reader.SetEndianess(Endian.Endianess.Big); reader.Seek(0xC); mSectionCount = reader.ReadUInt32(); reader.ReadBytes(0x10); mInfo = new INF1(ref reader); string magic = ""; LayoutBase prev = null; LayoutBase parent = null; bool isRootPaneSet = false; for (int i = 0; i < mSectionCount; i++) { magic = reader.ReadString(4); switch (magic) { case "TEX1": mTextureList = new TEX1(ref reader); break; case "FNT1": mFontList = new FNT1(ref reader); break; case "MAT1": mMaterialList = new MAT1(ref reader); break; case "PAN2": PAN2 panel = new PAN2(ref reader); if (!isRootPaneSet) { mRootPanel = panel; isRootPaneSet = true; } if (parent != null) { parent.addChild(panel); panel.setParent(parent); } prev = panel; break; case "PIC2": PIC2 pic = new PIC2(ref reader); if (parent != null) { parent.addChild(pic); pic.setParent(parent); } prev = pic; break; case "TBX2": TBX2 txt = new TBX2(ref reader); if (parent != null) { parent.addChild(txt); txt.setParent(parent); } prev = txt; break; case "WIN2": WIN2 win = new WIN2(ref reader); if (parent != null) { parent.addChild(win); win.setParent(parent); } prev = win; break; case "BGN1": if (prev != null) { parent = prev; } reader.ReadUInt32(); break; case "END1": prev = parent; parent = prev.getParent(); reader.ReadUInt32(); break; case "EXT1": reader.ReadUInt32(); reader.ReadAligned(0x10); break; default: Console.WriteLine("Section " + magic + " not supported."); break; } } }