Ejemplo n.º 1
0
        public override void Initialize()
        {
            base.Initialize();

            InstallLocation install = Install;

            List <AnimationData> animationData = new List <AnimationData>();

            using (FileStream stream = File.Open(install.GetPath("animdata.mul"), FileMode.Open))
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    int totalBlocks = (int)(reader.BaseStream.Length / 548);

                    for (int i = 0; i < totalBlocks; i++)
                    {
                        int    header    = reader.ReadInt32();
                        byte[] frameData = reader.ReadBytes(64);

                        AnimationData animData = new AnimationData {
                            FrameData     = new sbyte[64],
                            Unknown       = reader.ReadByte(),
                            FrameCount    = reader.ReadByte(),
                            FrameInterval = reader.ReadByte(),
                            FrameStart    = reader.ReadByte()
                        };

                        Buffer.BlockCopy(frameData, 0, animData.FrameData, 0, 64);
                        animationData.Add(animData);
                    }
                }

            _animationData = animationData.ToArray();
        }
        public override void Initialize()
        {
            base.Initialize();

            InstallLocation install = Install;

            _fileIndices = new[]
            {
                install.CreateFileIndex("anim.idx", "anim.mul"), install.CreateFileIndex("anim2.idx", "anim2.mul"),
                install.CreateFileIndex("anim3.idx", "anim3.mul"), install.CreateFileIndex("anim4.idx", "anim4.mul"),
                install.CreateFileIndex("anim5.idx", "anim5.mul")
            };

            _bodyTable     = new BodyTable(install.GetPath("body.def"));
            _bodyConverter = new BodyConverter(install.GetPath("bodyconv.def"));
            _hues          = new Hues(install);
        }
Ejemplo n.º 3
0
        public override void Initialize()
        {
            base.Initialize();

            InstallLocation install = Install;

            _fonts = new ASCIIFont[10];

            using (BinaryReader reader = new BinaryReader(File.Open(install.GetPath("fonts.mul"), FileMode.Open)))
            {
                for (int i = 0; i < 10; ++i)
                {
                    reader.ReadByte();                     //header

                    var chars      = new ASCIIChar[224];
                    int fontHeight = 0;

                    for (int k = 0; k < 224; ++k)
                    {
                        byte width  = reader.ReadByte();
                        byte height = reader.ReadByte();

                        reader.ReadByte();                         // delimeter?

                        if (width > 0 && height > 0)
                        {
                            if (height > fontHeight && k < 96)
                            {
                                fontHeight = height;
                            }

                            var pixels = new ushort[width * height];

                            for (int y = 0; y < height; ++y)
                            {
                                for (int x = 0; x < width; ++x)
                                {
                                    pixels[y * width + x] = (ushort)(reader.ReadByte() | (reader.ReadByte() << 8));
                                }
                            }

                            chars[k] = new ASCIIChar
                            {
                                Pixels = pixels,
                                Width  = width,
                                Height = height
                            };
                        }
                    }

                    _fonts[i] = new ASCIIFont(fontHeight, chars);
                }
            }
        }
Ejemplo n.º 4
0
        public void Populate()
        {
            var lines = File.ReadAllLines(_location.GetPath("suppinfo.txt"));

            for (int i = 2; i < lines.Length; i++)
            {
                var info = lines[i].Split('\t');
                if (!Positions.Keys.Contains(int.Parse(info[1])))
                {
                    Positions.Add(Int32.Parse(info[1]), GetPositionTile(info[0]));
                }
            }
        }
Ejemplo n.º 5
0
        private void ReadCategories(InstallLocation install)
        {
            List <SkillCategory> categories = new List <SkillCategory>();

            string grpPath = install.GetPath("skillgrp.mul");

            if (grpPath == null)
            {
                _categories = categories.ToArray();
                return;
            }

            using (FileStream stream = new FileStream(grpPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                BinaryReader bin = new BinaryReader(stream);

                int categoryCount = bin.ReadInt32();

                categories.Add(new SkillCategory(new SkillCategoryData(-17, 0, "Misc.")));

                for (int i = 1; i < categoryCount; i++)
                {
                    BinaryReader  nameReader  = new BinaryReader(stream);
                    StringBuilder nameBuilder = new StringBuilder();
                    byte[]        nameBuffer  = bin.ReadBytes(17);

                    for (int j = 0; j < 17; j++)
                    {
                        char ch = (char)nameBuffer[j];

                        if (char.IsLetterOrDigit(ch) || char.IsWhiteSpace(ch) || char.IsPunctuation(ch))
                        {
                            nameBuilder.Append(ch);
                        }
                    }

                    string name      = nameBuilder.ToString();
                    long   fileIndex = stream.Position - name.Length;
                    categories.Add(new SkillCategory(new SkillCategoryData(fileIndex, i, name)));
                }

                _categoryLookup = new int[(stream.Length - stream.Position) / 4];

                for (int i = 0; i < _categoryLookup.Length; i++)
                {
                    _categoryLookup[i] = bin.ReadInt32();
                }
            }

            _categories = categories.ToArray();
        }
        public override void Initialize()
        {
            base.Initialize();

            InstallLocation install = Install;

            var fonts = new List <UnicodeFont>();

            int    i    = 0;
            string path = install.GetPath(FILE_NAME_FORMAT, string.Empty);

            while (File.Exists(path))
            {
                UnicodeFont font = new UnicodeFont();

                int maxHeight = 0;

                using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    int length = (int)fs.Length;
                    var buffer = new byte[length];

                    int read = fs.Read(buffer, 0, buffer.Length);

                    using (MemoryStream stream = new MemoryStream(buffer))
                    {
                        using (BinaryReader bin = new BinaryReader(stream))
                        {
                            for (int c = 0; c < 0x10000; ++c)
                            {
                                font.Chars[c] = new UnicodeChar();
                                stream.Seek(((c) * 4), SeekOrigin.Begin);

                                int index = bin.ReadInt32();

                                if ((index >= fs.Length) || (index <= 0))
                                {
                                    continue;
                                }

                                stream.Seek(index, SeekOrigin.Begin);

                                sbyte xOffset = bin.ReadSByte();
                                sbyte yOffset = bin.ReadSByte();

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

                                maxHeight = Math.Max(height, maxHeight);

                                font.Chars[c].XOffset = xOffset;
                                font.Chars[c].YOffset = yOffset;
                                font.Chars[c].Width   = width;
                                font.Chars[c].Height  = height;

                                if (!((width == 0) || (height == 0)))
                                {
                                    font.Chars[c].Bytes = bin.ReadBytes(height * (((width - 1) / 8) + 1));
                                }
                            }
                        }
                    }
                }

                font.Height = maxHeight;
                fonts.Add(font);
                path = install.GetPath(FILE_NAME_FORMAT, ++i);
            }

            _fonts = fonts.ToArray();
        }