public override void Load(Stream fileStream) { // Header var reader = new BINAReader(fileStream); reader.ReadHeader(); string sig = reader.ReadSignature(4); if (sig != Signature) { throw new InvalidSignatureException(Signature, sig); } uint texturePos = reader.ReadUInt32(); uint placeholderEntries = reader.ReadUInt32(); reader.JumpTo(reader.ReadUInt32(), false); long pos = reader.BaseStream.Position; // Texture reader.JumpTo(texturePos, false); string texture = reader.ReadNullTerminatedString(); reader.JumpTo(pos, true); // Placeholders for (uint i = 0; i < placeholderEntries; ++i) { S06FontPictureUV fontPicture = new S06FontPictureUV(); Texture = texture; uint placeholderEntry = reader.ReadUInt32(); fontPicture.X = reader.ReadUInt16(); fontPicture.Y = reader.ReadUInt16(); fontPicture.Width = reader.ReadUInt16(); fontPicture.Height = reader.ReadUInt16(); pos = reader.BaseStream.Position; reader.JumpTo(placeholderEntry, false); fontPicture.Placeholder = reader.ReadNullTerminatedString(); reader.JumpTo(pos, true); Entries.Add(fontPicture); } }
public void ImportXML(string filePath) { var xml = XDocument.Load(filePath); // Texture foreach (var textureElem in xml.Root.Elements("Texture")) { Texture = textureElem.Attribute("File").Value; // Placeholders foreach (var pictureElem in textureElem.Elements("Picture")) { S06FontPictureUV entry = new S06FontPictureUV(); ushort.TryParse(pictureElem.Attribute("X").Value, out entry.X); ushort.TryParse(pictureElem.Attribute("Y").Value, out entry.Y); ushort.TryParse(pictureElem.Attribute("Width").Value, out entry.Width); ushort.TryParse(pictureElem.Attribute("Height").Value, out entry.Height); entry.Placeholder = pictureElem.Value; Entries.Add(entry); } } }