Beispiel #1
0
 public void Add(ExdLanguage language, Exd data)
 {
     foreach (T entry in data.Entries)
     {
         entries[language].Add(entry.Index, entry);
     }
 }
Beispiel #2
0
        private static readonly byte[] magic = { 0x45, 0x58, 0x48, 0x46 }; // EXHF

        public Exh(string name)
        {
            using (var steam = new MemoryStream(File.ReadAllBytes(name)))
            {
                using (var reader = new BinaryReaderBigEndian(steam))
                {
                    byte[] magicBytes = reader.ReadBytes(4);
                    Debug.Assert(magicBytes.SequenceEqual(magic));

                    ushort version = reader.ReadUInt16Be();
                    Debug.Assert(version == 3);

                    DataSize  = reader.ReadUInt16Be();
                    Columns   = new Column[reader.ReadUInt16Be()];
                    Pages     = new Page[reader.ReadUInt16Be()];
                    Languages = new ExdLanguage[reader.ReadUInt16Be()];
                    reader.ReadUInt16Be();
                    reader.ReadUInt32Be();
                    Entries = reader.ReadUInt32Be();
                    reader.Skip(8); // padding

                    for (uint i = 0u; i < Columns.Length; i++)
                    {
                        Columns[i] = new Column
                        {
                            Type   = (ExdDataType)reader.ReadUInt16Be(),
                            Offset = reader.ReadUInt16Be()
                        };
                    }

                    //Columns = Columns.OrderBy(c => c.Offset).ToArray();

                    for (uint i = 0u; i < Pages.Length; i++)
                    {
                        Pages[i] = new Page
                        {
                            Id      = reader.ReadUInt32Be(),
                            Entries = reader.ReadUInt32Be()
                        };
                    }

                    for (uint i = 0u; i < Languages.Length; i++)
                    {
                        Languages[i] = (ExdLanguage)reader.ReadUInt16();
                    }
                }
            }
        }
Beispiel #3
0
 public ReadOnlyCollection <T> GetValues(ExdLanguage language)
 {
     return(entries.ContainsKey(language) ? new ReadOnlyCollection <T>(entries[language].Values.ToList()) : null);
 }
Beispiel #4
0
 public T GetValue(uint id, ExdLanguage language)
 {
     return(entries[language][id]);
 }
Beispiel #5
0
 public bool TryGetValue(uint id, ExdLanguage language, out T entry)
 {
     entry = null;
     return(entries.ContainsKey(language) && entries[language].TryGetValue(id, out entry));
 }
Beispiel #6
0
 public bool Contains(uint id, ExdLanguage language)
 {
     return(entries.ContainsKey(language) && entries[language].ContainsKey(id));
 }