Example #1
0
        public override void Initialize()
        {
            base.Initialize();

            InstallLocation install = Install;

            _fileIndex = install.CreateFileIndex("texidx.mul", "texmaps.mul");
        }
Example #2
0
        public override void Initialize()
        {
            base.Initialize();

            InstallLocation install = Install;

            _fileIndex = install.IsUOPFormat
                                                         ? install.CreateFileIndex("artLegacyMUL.uop", 0x10000, false, ".tga")
                                                         : install.CreateFileIndex("artidx.mul", "art.mul");
        }
Example #3
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (_fileIndex != null)
            {
                _fileIndex.Close();
                _fileIndex = null;
            }
        }
Example #4
0
        public override void Initialize()
        {
            base.Initialize();

            InstallLocation install = Install;

            _fileIndex = install.IsUOPFormat
                                                         ? install.CreateFileIndex("soundLegacyMUL.uop", 0xFFF, false, ".dat")
                                                         : install.CreateFileIndex("soundidx.mul", "sound..mul");
        }
Example #5
0
        public override void Initialize()
        {
            base.Initialize();

            var install = Install;

            _fileIndex =
                install.IsUopFormat
                    ? install.CreateFileIndex("gumpartLegacyMUL.uop", 0xFFFF, true, ".tga")
                    : install.CreateFileIndex("gumpidx.mul", "gumpart.mul");
        }
Example #6
0
        private void ReadSkills(InstallLocation install)
        {
            FileIndexBase fileIndex = install.CreateFileIndex("skills.idx", "skills.mul");

            _skills = new Skill[fileIndex.Length];

            for (int i = 0; i < _skills.Length; i++)
            {
                Skill skill = ReadSkill(fileIndex, i);

                _skills[i] = skill;
            }
        }
Example #7
0
        public static void Initialize()
        {
            if (_isUOPFileIndex)
            {
                _fileIndex = CreateFileIndex("artLegacyMUL.uop", 0x10000, false, ".tga");
                _logger.Debug(_fileIndex.FilesExist.ToString());
            }
            else
            {
                _fileIndex = CreateFileIndex("artidx.mul", "art.mul");
            }

            _isInitialized = true;
        }
Example #8
0
        private Skill ReadSkill(FileIndexBase fileIndex, int index)
        {
            int length, extra;

            using (var stream = fileIndex.Seek(index, out length, out extra))
            {
                if (stream == null)
                {
                    return(null);
                }

                using (var bin = new BinaryReader(stream))
                {
                    var nameLength = length - 2;

                    var useBtn     = bin.ReadByte();
                    var nameBuffer = new byte[nameLength];
                    bin.Read(nameBuffer, 0, nameLength);
                    var unk = bin.ReadByte();

                    var sb = new StringBuilder(nameBuffer.Length);

                    for (var i = 0; i < nameBuffer.Length; i++)
                    {
                        sb.Append((char)nameBuffer[i]);
                    }

                    var category = _categories[0];

                    if (index < _categoryLookup.Length)
                    {
                        category = _categories[_categoryLookup[index]];
                    }

                    var skill = new Skill(new SkillData(index, sb.ToString(), useBtn > 0, extra, unk, category));

                    return(skill);
                }
            }
        }
Example #9
0
 public FileIndexWriteTransaction(FileIndexBase fileIndex)
 {
     _fileIndex         = fileIndex;
     _transactionWrites = new List <WriteEntry>();
 }
        public unsafe Frame <ImageSource>[] GetAnimation(int body, int action, int direction, int hue, bool preserveHue)
        {
            if (preserveHue)
            {
                Translate(ref body);
            }
            else
            {
                Translate(ref body, ref hue);
            }

            int           fileType  = _bodyConverter.Convert(ref body);
            FileIndexBase fileIndex = _fileIndices[fileType - 1];

            int index;

            switch (fileType)
            {
            default:
            {
                if (body < 200)
                {
                    index = body * 110;
                }
                else if (body < 400)
                {
                    index = 22000 + ((body - 200) * 65);
                }
                else
                {
                    index = 35000 + ((body - 400) * 175);
                }

                break;
            }

            case 2:
            {
                if (body < 200)
                {
                    index = body * 110;
                }
                else
                {
                    index = 22000 + ((body - 200) * 65);
                }

                break;
            }

            case 3:
            {
                if (body < 300)
                {
                    index = body * 65;
                }
                else if (body < 400)
                {
                    index = 33000 + ((body - 300) * 110);
                }
                else
                {
                    index = 35000 + ((body - 400) * 175);
                }

                break;
            }

            case 4:
            {
                if (body < 200)
                {
                    index = body * 110;
                }
                else if (body < 400)
                {
                    index = 22000 + ((body - 200) * 65);
                }
                else
                {
                    index = 35000 + ((body - 400) * 175);
                }

                break;
            }

            case 5:
            {
                if (body < 200 && body != 34)     // looks strange, though it works.
                {
                    index = body * 110;
                }
                else
                {
                    index = 35000 + ((body - 400) * 65);
                }

                break;
            }
            }

            if ((index + (action * 5)) > int.MaxValue)
            {
                throw new ArithmeticException();
            }

            index += action * 5;

            if (direction <= 4)
            {
                index += direction;
            }
            else
            {
                index += direction - (direction - 4) * 2;
            }

            int    length, extra;
            Stream stream = fileIndex.Seek(index, out length, out extra);

            if (stream == null)
            {
                return(null);
            }

            bool flip = (direction > 4);

            BinaryReader bin = new BinaryReader(stream);

            ushort[] palette = new ushort[0x100];

            for (int i = 0; i < 0x100; ++i)
            {
                palette[i] = (ushort)(bin.ReadUInt16() ^ 0x8000);
            }

            int start      = (int)bin.BaseStream.Position;
            int frameCount = bin.ReadInt32();

            int[] lookups = new int[frameCount];

            for (int i = 0; i < frameCount; ++i)
            {
                lookups[i] = start + bin.ReadInt32();
            }

            bool onlyHueGrayPixels = ((hue & 0x8000) == 0);

            hue = (hue & 0x3FFF) - 1;

            Hue hueObject = null;

            if (hue >= 0 && hue < _hues.Table.Length)
            {
                hueObject = _hues.Table[hue];
            }

            Frame <ImageSource>[] frames = new Frame <ImageSource> [frameCount];

            for (int i = 0; i < frameCount; ++i)
            {
                bin.BaseStream.Seek(lookups[i], SeekOrigin.Begin);

                int xCenter = bin.ReadInt16();
                int yCenter = bin.ReadInt16();

                int width  = bin.ReadUInt16();
                int height = bin.ReadUInt16();

                WriteableBitmap bmp = new WriteableBitmap(width, height, 96, 96, PixelFormats.Bgr555, null);
                bmp.Lock();

                ushort *line  = (ushort *)bmp.BackBuffer;
                int     delta = bmp.BackBufferStride >> 1;

                int header;

                int xBase = xCenter - 0x200;
                int yBase = (yCenter + height) - 0x200;

                if (!flip)
                {
                    line += xBase;
                    line += (yBase * delta);

                    while ((header = bin.ReadInt32()) != 0x7FFF7FFF)
                    {
                        header ^= DoubleXor;

                        ushort *cur = line + ((((header >> 12) & 0x3FF) * delta) + ((header >> 22) & 0x3FF));
                        ushort *end = cur + (header & 0xFFF);

                        while (cur < end)
                        {
                            *cur++ = palette[bin.ReadByte()];
                        }
                    }
                }
                else
                {
                    line -= xBase - width + 1;
                    line += (yBase * delta);

                    while ((header = bin.ReadInt32()) != 0x7FFF7FFF)
                    {
                        header ^= DoubleXor;

                        ushort *cur = line + ((((header >> 12) & 0x3FF) * delta) - ((header >> 22) & 0x3FF));
                        ushort *end = cur - (header & 0xFFF);

                        while (cur > end)
                        {
                            *cur-- = palette[bin.ReadByte()];
                        }
                    }

                    xCenter = width - xCenter;
                }

                bmp.AddDirtyRect(new Int32Rect(0, 0, width, height));
                bmp.Unlock();

                if (hueObject != null)
                {
                    ApplyHue(bmp, hueObject, onlyHueGrayPixels);
                }

                frames[i] = new Frame <ImageSource>(xCenter, yCenter, bmp);
            }

            return(frames);
        }
 public FileIndexWriteTransaction(FileIndexBase fileIndex)
 {
     _fileIndex = fileIndex;
     _transactionWrites = new List<WriteEntry>();
 }