public Entry(ref FileBase file) { mTable = new Dictionary <string, uint>(); mEntries = new List <TableEntry>(); int size = file.ReadInt32(); file.Skip(0x8); int loc = file.Position(); uint count = file.ReadUInt32(); for (int i = 0; i < count; i++) { TableEntry e = new TableEntry(); e.mIsValid = file.ReadUInt32(); e.mPtr = file.ReadInt32(); mEntries.Add(e); if (e.mIsValid == 1) { string str = file.ReadStringAt(loc + e.mPtr); uint val = file.ReadUInt32At(loc + e.mPtr + str.Length + 1); mTable.Add(str, val); } } file.Seek(loc + size); while ((file.Position() % 0x10) != 0) { file.Skip(0x1); } }
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 LBL1(ref FileBase file) { int start = file.ReadInt32(); file.Skip(0x8); int baseOffs = file.Position(); uint count = file.ReadUInt32(); mEntries = new List <LabelEntry>(); for (int i = 0; i < count; i++) { LabelEntry e = new LabelEntry(); e.PairCount = file.ReadUInt32(); int offs = file.ReadInt32(); List <LabelPair> pairs = new List <LabelPair>(); int pos = file.Position(); file.Seek(baseOffs + offs); for (int j = 0; j < e.PairCount; j++) { LabelPair p = new LabelPair(); p.Label = file.ReadStringLenPrefix(); p.TextOffset = file.ReadUInt32(); pairs.Add(p); } file.Seek(pos); e.Pairs = pairs; mEntries.Add(e); } file.Seek(start + baseOffs); while (file.Position() % 0x10 != 0) { file.Skip(0x1); } }
public ATR1(ref FileBase file) { int start = file.ReadInt32(); file.Skip(0x8); int baseOffset = file.Position(); int entryCount = file.ReadInt32(); file.Skip(0x4); mAttributes = new List <AttributeEntry>(); for (int i = 0; i < entryCount; i++) { AttributeEntry e = new AttributeEntry { _0 = file.ReadByte(), _1 = file.ReadByte(), _2 = file.ReadByte(), _3 = file.ReadByte(), _4 = file.ReadByte(), _5 = file.ReadByte(), _6 = file.ReadByte(), _7 = file.ReadByte() }; int offs = file.ReadInt32(); int orig = file.Position(); file.Seek(baseOffset + offs); e.mString = file.ReadStringUTF16(); file.Seek(orig); } file.Seek(start + baseOffset); while (file.Position() % 0x10 != 0) { file.Skip(0x1); } }
public Flow(ref FileBase file) { mNodes = new List <Node>(); file.Skip(0xC); ushort flowCount = file.ReadUInt16(); ushort labelCount = file.ReadUInt16(); file.Skip(0x4); for (int i = 0; i < flowCount; i++) { Node.NodeType type = (Node.NodeType)file.ReadUInt16(); switch (type) { case Node.NodeType.NodeType_Message: mNodes.Add(new MessageNode(ref file)); break; case Node.NodeType.NodeType_Entry: mNodes.Add(new EntryNode(ref file)); break; case Node.NodeType.NodeType_Event: mNodes.Add(new EventNode(ref file)); break; case Node.NodeType.NodeType_Branch: mNodes.Add(new BranchNode(ref file)); break; default: Console.WriteLine($"Unsupported type: {(int)type}"); break; } } mLabels = new List <ushort>(); for (int i = 0; i < labelCount; i++) { mLabels.Add(file.ReadUInt16()); } while (file.Position() % 0x10 != 0) { file.Skip(0x1); } }
public TXT2(ref FileBase file) { int start = file.ReadInt32(); file.Skip(0x8); int dataStartOffs = file.Position(); int count = file.ReadInt32(); mMessages = new Dictionary <uint, List <MessageBase> >(); for (uint i = 0; i < count; i++) { List <MessageBase> msgs = new List <MessageBase>(); file.Seek(Convert.ToInt32(dataStartOffs + (i * 4) + 4)); int offs = file.ReadInt32(); file.Seek(offs + dataStartOffs); short cur = -1; while (cur != 0) { cur = file.ReadInt16(); if (cur == 0) { mMessages.Add(i, msgs); break; } switch (cur) { // new command case 0xE: ushort opcode = file.ReadUInt16(); switch (opcode) { case 0: msgs.Add(new SystemGroup(ref file)); break; case 1: msgs.Add(new DisplayGroup(ref file)); break; case 2: msgs.Add(new SoundGroup(ref file)); break; case 3: msgs.Add(new PictureGroup(ref file)); break; case 4: msgs.Add(new FontSizeGroup(ref file)); break; case 5: msgs.Add(new LocalizeGroup(ref file)); break; case 6: msgs.Add(new NumberGroup(ref file)); break; default: Console.WriteLine($"Unsupported opcode {opcode}"); break; } break; default: // normal char msgs.Add(new Character(cur)); break; } } } file.Seek(start + dataStartOffs); while (file.Position() % 0x10 != 0) { file.Skip(0x1); } }