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 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 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; } } }