コード例 #1
0
        // Iterate through all ranges of ExDFile under this ExH and execute given iterator function on each of them.
        // This does not iterate through language so the language code should be included in the fileNameFormat if applicable!
        public void Iterate(SqCache cache, string directoryName, string fileNameFormat, Action <ExDFile> iterator)
        {
            // Iterate through available ranges.
            for (int i = 0; i < Ranges.Length; i++)
            {
                ExHRange range = Ranges[i];

                iterator(new ExDFile(cache.GetFile(directoryName, string.Format(fileNameFormat, range.Start)), this));

                Program.ReportProgress(((double)i + 1) / Ranges.Length);
            }
        }
コード例 #2
0
        // Decode ExH from the raw data and create new ExH instance.
        public ExHFile(SqFile sqFile)
        {
            // Read the SqFile raw data.
            byte[] data = sqFile.ReadData();

            // Quit if no data is available.
            if (data == null || data.Length == 0)
            {
                return;
            }

            // Some big endian values from fixed offset.
            FixedSizeDataLength = ToUInt16(data, 0x6, true);
            Variant             = ToUInt16(data, 0x10, true);

            // Counts for various entries.
            ushort columnCount = ToUInt16(data, 0x8, true);
            ushort rangeCount  = ToUInt16(data, 0xa, true);
            ushort langCount   = ToUInt16(data, 0xc, true);

            // Only care about ExD data table type headers.
            if (Variant != 1)
            {
                return;
            }

            Columns = new ExHColumn[columnCount];
            for (int i = 0; i < columnCount; i++)
            {
                // Column offsets start after the fixed offset values (0x20).
                // Each column offset is 4 bytes long.
                int columnOffset = 0x20 + i * 0x4;
                Columns[i] = new ExHColumn()
                {
                    Type   = ToUInt16(data, columnOffset, true),
                    Offset = ToUInt16(data, columnOffset + 0x2, true)
                };
            }

            Ranges = new ExHRange[rangeCount];
            for (int i = 0; i < rangeCount; i++)
            {
                // Range offsets start after the column offsets.
                // Each range offset is 8 bytes long.
                int rangeOffset = (0x20 + columnCount * 0x4) + i * 0x8;
                Ranges[i] = new ExHRange()
                {
                    Start  = ToInt32(data, rangeOffset, true),
                    Length = ToInt32(data, rangeOffset + 0x4, true)
                };
            }

            Languages = new ExHLanguage[langCount];
            for (int i = 0; i < langCount; i++)
            {
                // Language offsets start after the range offsets.
                // Each language offset is 2 bytes long.
                int langOffset = ((0x20 + columnCount * 0x4) + rangeCount * 0x8) + i * 0x2;
                Languages[i] = new ExHLanguage()
                {
                    Value = data[langOffset]
                };
            }
        }