private List <string> ReadCurrentPolies() { var filePath = Path.Combine(this._config.InstallDir, "text.pak"); var idxFile = filePath.Replace(".pak", ".idx"); var indexes = PakTools.LoadIndexData(idxFile); var records = PakTools.CreateIndexRecords(indexes, true); var polyFile = new List <IndexRecord>(records).First(b => b.FileName == "monlist0-e.html"); List <string> polyContents; using (var fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read)) { byte[] numArray = new byte[polyFile.FileSize]; fileStream.Seek((long)polyFile.Offset, SeekOrigin.Begin); fileStream.Read(numArray, 0, polyFile.FileSize); numArray = PakTools.Decode(numArray, 0); polyContents = Encoding.GetEncoding("big5") .GetString(numArray).Split('\n').Select(b => Regex.Replace(b.Trim(), @"<[^>]*>", string.Empty).Trim()) .Where(b => b.Trim() != string.Empty && b != "Choose a monster." && !b.Contains("Release Polymorph")).ToList(); } // it is the default file, so return an empty list since they haven't customized if (polyContents[0].IndexOf("<p><font fg=ffffff> Choose a monster. </p>") > -1) { return(new List <string>()); } return(polyContents); }
private string GetUpdatedMonlistContent() { var filePath = Path.Combine(this._config.InstallDir, "text.pak"); var idxFile = filePath.Replace(".pak", ".idx"); var indexes = PakTools.LoadIndexData(idxFile); var records = PakTools.CreateIndexRecords(indexes, true); var polyFile = new List <IndexRecord>(records).First(b => b.FileName == "monlist-e.html"); using (var fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read)) { byte[] numArray = new byte[polyFile.FileSize]; fileStream.Seek((long)polyFile.Offset, SeekOrigin.Begin); fileStream.Read(numArray, 0, polyFile.FileSize); numArray = PakTools.Decode(numArray, 0); return(Encoding.GetEncoding("big5").GetString(numArray) .Replace("Ordinary Monsters", "Custom Polylist")); } }