Ejemplo n.º 1
0
 /// <summary>
 /// Constructs a <see cref="SimisJinxFormat"/> from a <see cref="BnfFile"/>.
 /// </summary>
 /// <param name="bnf">The <see cref="BnfFile"/> to read Simis Jinx format data from.</param>
 internal SimisJinxFormat(BnfFile bnf)
 {
     Name      = bnf.BnfFileName;
     Extension = bnf.BnfFileExtension;
     Format    = bnf.BnfFileType + bnf.BnfFileTypeVersion;
     Roots     = bnf.BnfFileRoots;
     Bnf       = bnf.Bnf;
 }
Ejemplo n.º 2
0
        public SimisProvider(string directory)
        {
            var tokenNames = new Dictionary <uint, string>();
            var tokenIds   = new Dictionary <string, uint>();
            var formats    = new List <SimisJinxFormat>();

            foreach (var filename in Directory.GetFiles(directory, "*.bnf"))
            {
                var BNF = new BnfFile(filename);
                try {
                    BNF.ReadFile();
                } catch (FileException ex) {
                    if (ex.InnerException is InvalidDataException)
                    {
                        // BNF didn't specify all required stuff, skip it.
                        continue;
                    }
                    throw ex;
                }
                var simisFormat = new SimisJinxFormat(BNF);
                formats.Add(simisFormat);
            }
            formats.Sort((a, b) => StringComparer.InvariantCultureIgnoreCase.Compare(a.Name, b.Name));

            using (var tokens = new StreamReader(File.OpenRead(directory + @"\tokens.csv"), Encoding.ASCII)) {
                while (!tokens.EndOfStream)
                {
                    var csv = tokens.ReadLine().Split(',');
                    if ((csv.Length != 3) || !csv[0].StartsWith("0x") || !csv[1].StartsWith("0x"))
                    {
                        continue;
                    }
                    var tokenId = (uint)(ushort.Parse(csv[0].Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture) << 16) +
                                  ushort.Parse(csv[1].Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
                    tokenNames.Add(tokenId, csv[2]);
                    tokenIds.Add(csv[2], tokenId);
                }
            }

            TokenNames = tokenNames;
            TokenIds   = tokenIds;
            Formats    = formats;
        }
Ejemplo n.º 3
0
 public BnfParser(BnfFile file, StreamReader reader)
 {
     File   = file;
     Reader = reader;
 }