public void ParseMetaData() { var meta = new MetaData(); reader = new BinaryReader(this.Stream, Encoding.ASCII); var variableRecords = new List <VariableRecord>(); var valueLabelRecords = new List <ValueLabelRecord>(); var infoRecords = new InfoRecords(); RecordType nextRecordType = (RecordType)reader.ReadInt32(); while (nextRecordType != RecordType.End) { switch (nextRecordType) { case RecordType.HeaderRecord: meta.HeaderRecord = HeaderRecord.ParseNextRecord(reader); break; case RecordType.VariableRecord: variableRecords.Add(VariableRecord.ParseNextRecord(reader)); break; case RecordType.ValueLabelRecord: valueLabelRecords.Add(ValueLabelRecord.ParseNextRecord(reader)); break; case RecordType.DocumentRecord: meta.DocumentRecord = DocumentRecord.ParseNextRecord(reader); break; case RecordType.InfoRecord: infoRecords.AllRecords.Add(InfoRecord.ParseNextRecord(reader)); break; default: throw new UnexpectedFileFormatException(); } nextRecordType = (RecordType)reader.ReadInt32(); } meta.VariableRecords = new Collection <VariableRecord>(variableRecords); meta.ValueLabelRecords = new Collection <ValueLabelRecord>(valueLabelRecords); // Interpret known inforecords: infoRecords.ReadKnownRecords(meta.VariableCount); meta.InfoRecords = infoRecords; this.SysmisValue = meta.InfoRecords.MachineFloatingPointInfoRecord.SystemMissingValue; // Filler Record reader.ReadInt32(); this.dataStartPosition = this.Stream.Position; this.MetaData = meta; SetDataRecordStream(); this.MetaDataParsed = true; }
private void DisplayInfo(DialogRecord dialog, InfoRecord info) { // Replace any text defines with actual text var dialogText = TextDefineProcessor.ProcessText(info.Response, player, Npc); dialogText = CheckForTopicsInText(dialogText); dialogView.DisplayInfo(dialogText, dialog?.name); if (info.Result != null) { DialogResultProcessor.ProcessResult(this, info.Result, dialog, player, Npc); } }
private void ReadDictionary() { RecordType currentRecordType = (RecordType)this.BinaryReader.ReadInt32(); while (currentRecordType != RecordType.DictionaryTerminationRecord) { switch (currentRecordType) { case RecordType.FileHeaderRecord: this.SystemFile.FileHeaderRecord.ReadFromStream(this.BinaryReader); break; case RecordType.VariableRecord: VariableRecord v = new VariableRecord(this.SystemFile); v.ReadFromStream(this.BinaryReader); this.SystemFile.VariableRecords.Add(v); break; case RecordType.ValueLabelRecord: ValueLabelsRecord vl = new ValueLabelsRecord(this.SystemFile); vl.ReadFromStream(this.BinaryReader); this.SystemFile.ValueLabelsRecords.Add(vl); break; case RecordType.DocumentRecord: this.SystemFile.DocumentRecord.ReadFromStream(this.BinaryReader); break; case RecordType.InfoRecord: InfoRecord ir = new InfoRecord(this.SystemFile); ir.ReadFromStream(this.BinaryReader); this.SystemFile.InfoRecords.Add(ir); break; default: break; } currentRecordType = (RecordType)this.BinaryReader.ReadInt32(); this.ParseInfoRecords(); } }
public static void Create(BinaryReader reader) { var header = new RecordHeader(reader); switch (header.Type) { case RecordType.BirthSign: BirthSignRecord.Create(reader, header); break; case RecordType.BodyPart: BodyPartRecord.Create(reader, header); break; case RecordType.Cell: CellRecord.Create(reader, header); break; case RecordType.Dialogue: DialogRecord.Create(reader, header); break; case RecordType.GameSetting: GameSetting.Create(reader, header); break; case RecordType.Info: InfoRecord.Create(reader, header); break; case RecordType.Land: LandRecord.Create(reader, header); break; case RecordType.LandTexture: LandTextureRecord.Create(reader, header); break; case RecordType.MagicEffect: MagicEffectRecord.Create(reader, header); break; case RecordType.PathGrid: Pathgrid.Create(reader, header); break; case RecordType.Script: Script.Create(reader, header); break; case RecordType.Skill: SkillRecord.Create(reader, header); break; case RecordType.SoundGenerator: SoundGenerator.Create(reader, header); break; case RecordType.Tes3: Tes3Record.Create(reader, header); break; default: { var size = GotoSubrecord(SubRecordType.Id, header); var id = reader.ReadString(size); reader.BaseStream.Position = header.DataOffset + header.DataSize; var recordData = CreateRecordData(header.Type); recordData.Header = header; Records.Add(id, recordData); break; } } }