public MSBF(FileBase file) { if (file.ReadString(0x8) != "MsgFlwBn") { throw new Exception("MSBF::MSBF() -- Not a valid MSBF file!"); } file.Skip(0x18); while (file.Position() != file.GetLength()) { string magic = file.ReadString(4); switch (magic) { case "FLW2": mFlow = new Flow(ref file); break; case "FEN1": mEntries = new Entry(ref file); break; case "REF1": throw new Exception("MSBF::MSBF() -- REF1 section found, but this is not supported."); } } }
public MSBT(FileBase file) { if (file.ReadString(8) != "MsgStdBn") { throw new Exception("MSBT::MSBT() -- Invalid MSBT file!"); } file.Skip(0x18); while (file.Position() != file.GetLength()) { string magic = file.ReadString(4); switch (magic) { case "LBL1": mLabels = new LBL1(ref file); break; case "ATR1": mAttributes = new ATR1(ref file); break; case "TXT2": mText = new TXT2(ref file); break; } } }
public BCSV(FileBase file) { mFile = file; mFields = new Dictionary <int, Field>(); mEntries = new List <Entry>(); if (mFile.GetLength() == 0) { return; } int entryCount = mFile.ReadInt32(); int fieldCount = mFile.ReadInt32(); int dataOffs = mFile.ReadInt32(); int entryDataSize = mFile.ReadInt32(); int stringTableOffs = (dataOffs + (entryCount * entryDataSize)); for (int i = 0; i < fieldCount; i++) { Field f = new Field(); mFile.Seek(0x10 + (0xC * i)); f.mHash = mFile.ReadInt32(); f.mMask = mFile.ReadInt32(); f.mEntryOffset = mFile.ReadUInt16(); f.mShiftAmount = mFile.ReadByte(); f.mType = mFile.ReadByte(); string fieldName = HashToFieldName(f.mHash); f.mName = fieldName; mFields.Add(f.mHash, f); } for (int i = 0; i < entryCount; i++) { Entry e = new Entry(); foreach (Field f in mFields.Values) { mFile.Seek(dataOffs + (i * entryDataSize) + f.mEntryOffset); object val = null; switch (f.mType) { case 0: case 3: val = Convert.ToInt32((mFile.ReadInt32() & f.mMask) >> f.mShiftAmount); break; case 4: val = (short)((mFile.ReadInt16() & f.mMask) >> f.mShiftAmount); break; case 5: val = Convert.ToByte((mFile.ReadByte() & f.mMask) >> f.mShiftAmount); break; case 2: val = mFile.ReadSingle(); break; case 6: int offs = mFile.ReadInt32(); mFile.Seek(stringTableOffs + offs); val = mFile.ReadString(); break; default: throw new Exception($"BCSV::BCSV() - Unknown field type {f.mType}."); } e[f.mHash] = val; } mEntries.Add(e); } }