示例#1
0
        public Bitmap(CacheArchive archive, string imageArchive, int fileIndex)
        {
            JagexBuffer data = new DefaultJagexBuffer(archive.GetFile(imageArchive + ".dat"));
            JagexBuffer idx  = new DefaultJagexBuffer(archive.GetFile("index.dat"));

            idx.Position(data.ReadUShort());

            this.CropWidth  = idx.ReadUShort();
            this.CropHeight = idx.ReadUShort();

            this.Palette = new int[idx.ReadUByte()];

            for (int i = 0; i < this.Palette.Length - 1; i++)
            {
                this.Palette[i + 1] = idx.ReadTriByte();
            }

            for (int l = 0; l < fileIndex; l++)
            {
                idx.Position(idx.Position() + 2);
                data.Position(data.Position() + idx.ReadUShort() * idx.ReadUShort());
                idx.Position(idx.Position() + 1);
            }

            this.OffsetX = idx.ReadUByte();
            this.OffsetY = idx.ReadUByte();
            this.Width   = idx.ReadUShort();
            this.Height  = idx.ReadUShort();
            int type = idx.ReadUByte();

            this.Pixels = new sbyte[this.Width * this.Height];

            if (type == 0)
            {
                for (int i = 0; i < this.Pixels.Length; i++)
                {
                    this.Pixels[i] = (sbyte)data.ReadByte();
                    if (this.Palette[this.Pixels[i]] == 0)
                    {
                        HadTransparent = true;
                    }
                }
            }
            else if (type == 1)
            {
                for (int x = 0; x < this.Width; x++)
                {
                    for (int y = 0; y < this.Height; y++)
                    {
                        this.Pixels[x + (y * this.Width)] = (sbyte)data.ReadByte();
                        if (this.Palette[this.Pixels[x + (y * this.Width)]] == 0)
                        {
                            HadTransparent = true;
                        }
                    }
                }
            }
        }
示例#2
0
        private void SetupMapIndices(CacheArchive archive)
        {
            var mapIdxStream = new DefaultJagexBuffer(archive.GetFile("map_index"));
            var size         = mapIdxStream.Capacity() / 7;

            Debug.Log("Map count: " + size);

            MapIndices       = new int[size];
            ObjectFileIds    = new int[size];
            LandscapeFileIds = new int[size];
            MapMembers       = new int[size];

            for (int i = 0; i < size; i++)
            {
                MapIndices[i]       = mapIdxStream.ReadUShort();
                ObjectFileIds[i]    = mapIdxStream.ReadUShort();
                LandscapeFileIds[i] = mapIdxStream.ReadUShort();
                mapIdxStream.ReadByte();
            }

            Debug.Log(mapIdxStream.Position() + " " + mapIdxStream.Capacity());
        }
示例#3
0
        public BitmapFont(string name, CacheArchive archive)
        {
            Mask          = new int[256][];
            MaskWidth     = new int[256];
            MaskHeight    = new int[256];
            OffsetX       = new int[256];
            OffsetY       = new int[256];
            CharWidths    = new int[256];
            Strikethrough = false;

            var data = new DefaultJagexBuffer(archive.GetFile(name + ".dat"));
            var idx  = new DefaultJagexBuffer(archive.GetFile("index.dat"));

            idx.Position(data.ReadUShort() + 4);

            var offset = idx.ReadUByte();

            if (offset > 0)
            {
                idx.Position(idx.Position() + (3 * (offset - 1)));
            }

            for (var i = 0; i < 256; i++)
            {
                OffsetX[i] = idx.ReadByte();
                OffsetY[i] = idx.ReadByte();
                int width  = MaskWidth[i] = idx.ReadUShort();
                int height = MaskHeight[i] = idx.ReadUShort();
                int type   = idx.ReadUByte();
                Mask[i] = new int[width * height];

                if (type == 0)
                {
                    for (var j = 0; j < Mask[i].Length; j++)
                    {
                        Mask[i][j] = data.ReadByte();
                    }
                }
                else if (type == 1)
                {
                    for (var x = 0; x < width; x++)
                    {
                        for (var y = 0; y < height; y++)
                        {
                            Mask[i][x + y * width] = data.ReadByte();
                        }
                    }
                }

                if (height > CharHeight && i < 128)
                {
                    CharHeight = height;
                }

                OffsetX[i]    = 1;
                CharWidths[i] = (byte)(width + 2);

                var k2 = 0;
                for (var y = height / 7; y < height; y++)
                {
                    k2 += Mask[i][y * width];
                }

                if (k2 <= height / 7)
                {
                    CharWidths[i]--;
                    OffsetX[i] = 0;
                }

                k2 = 0;
                for (var y = height / 7; y < height; y++)
                {
                    k2 += Mask[i][(width - 1) + y * width];
                }

                if (k2 <= height / 7)
                {
                    CharWidths[i]--;
                }
            }

            if (name.Equals("q8_full"))
            {
                CharWidths[32] = CharWidths[73];
            }
            else
            {
                CharWidths[32] = CharWidths[105];
            }
        }
示例#4
0
        public WidgetConfigProvider(CacheArchive archive)
        {
            var b = new DefaultJagexBuffer(archive.GetFile("data"));

            configs = new WidgetConfig[b.ReadUShort()];

            int parent = -1;

            while (b.Position() < b.Capacity())
            {
                int index = b.ReadUShort();

                if (index == 65535)
                {
                    parent = b.ReadUShort();
                    index  = b.ReadUShort();
                }

                var w = new WidgetConfig();

                w.Index      = index;
                w.Parent     = parent;
                w.Type       = b.ReadByte();
                w.OptionType = b.ReadByte();
                w.ActionType = b.ReadUShort();
                w.Width      = b.ReadUShort();
                w.Height     = b.ReadUShort();
                w.Opacity    = b.ReadUByte();
                w.HoverIndex = b.ReadUByte();

                if (w.HoverIndex != 0)
                {
                    w.HoverIndex = (w.HoverIndex - 1 << 8) + b.ReadUByte();
                }
                else
                {
                    w.HoverIndex = -1;
                }

                w.LoadScript(b);

                if (w.Type == 0)
                {
                    w.ScrollHeight = b.ReadUShort();
                    w.Hidden       = b.ReadByte() == 1;

                    var count = b.ReadUShort();
                    w.ChildIds = new int[count];
                    w.ChildX   = new int[count];
                    w.ChildY   = new int[count];

                    for (var i = 0; i < count; i++)
                    {
                        w.ChildIds[i] = b.ReadUShort();
                        w.ChildX[i]   = b.ReadUShort();
                        w.ChildY[i]   = b.ReadUShort();
                    }
                }

                if (w.Type == 2)
                {
                    w.ItemIndices      = new int[w.Width * w.Height];
                    w.ItemAmounts      = new int[w.Width * w.Height];
                    w.ItemsDraggable   = b.ReadByte() == 1;
                    w.ItemsHaveActions = b.ReadByte() == 1;
                    w.ItemsUsable      = b.ReadByte() == 1;
                    w.ItemsSwappable   = b.ReadByte() == 1;
                    w.ItemMarginX      = (short)b.ReadUByte();
                    w.ItemMarginY      = (short)b.ReadUByte();
                    w.ItemSlotX        = new int[20];
                    w.ItemSlotY        = new int[20];
                    w.SlotImage        = new string[20];

                    for (int i = 0; i < 20; i++)
                    {
                        if (b.ReadUByte() == 1)
                        {
                            w.ItemSlotX[i] = (short)b.ReadUShort();
                            w.ItemSlotY[i] = (short)b.ReadUShort();
                            var str = b.ReadString(10);

                            w.SlotImage[i] = str;
                        }
                    }

                    w.ItemActions = new string[5];
                    for (int i = 0; i < 5; i++)
                    {
                        w.ItemActions[i] = b.ReadString(10);
                        if (w.ItemActions[i].Length == 0)
                        {
                            w.ItemActions[i] = null;
                        }
                    }
                }

                if (w.Type == 3)
                {
                    w.Filled = b.ReadByte() == 1;
                }

                if (w.Type == 4 || w.Type == 1)
                {
                    w.Centered = b.ReadByte() == 1;
                    w.FontIdx  = b.ReadUByte();
                    w.Shadow   = b.ReadByte() == 1;
                }

                if (w.Type == 4)
                {
                    w.MessageDisabled = b.ReadString(10);
                    w.MessageEnabled  = b.ReadString(10);
                }

                if (w.Type == 1 || w.Type == 3 || w.Type == 4)
                {
                    w.RGBDisabled = b.ReadInt();
                }

                if (w.Type == 3 || w.Type == 4)
                {
                    w.RGBEnabled         = b.ReadInt();
                    w.ColorHoverDisabled = b.ReadInt();
                    w.ColorHoverEnabled  = b.ReadInt();
                }

                if (w.Type == 5)
                {
                    var str = b.ReadString(10);
                    if (str.Length > 0)
                    {
                        w.ImageDisabled = str;
                    }

                    str = b.ReadString(10);
                    if (str.Length > 0)
                    {
                        w.ImageEnabled = str;
                    }
                }

                if (w.Type == 6)
                {
                    int i = b.ReadUByte();
                    if (i != 0)
                    {
                        w.ModelTypeDisabled  = 1;
                        w.ModelIndexDisabled = (i - 1 << 8) + b.ReadUByte();
                    }

                    i = b.ReadUByte();
                    if (i != 0)
                    {
                        w.ModelTypeEnabled  = 1;
                        w.ModelIndexEnabled = (i - 1 << 8) + b.ReadUByte();
                    }

                    i = b.ReadUByte();
                    if (i != 0)
                    {
                        w.AnimationIndexDisabled = (i - 1 << 8) + b.ReadUByte();
                    }
                    else
                    {
                        w.AnimationIndexDisabled = -1;
                    }

                    i = b.ReadUByte();
                    if (i != 0)
                    {
                        w.AnimationIndexEnabled = (i - 1 << 8) + b.ReadUByte();
                    }
                    else
                    {
                        w.AnimationIndexEnabled = -1;
                    }

                    w.ModelZoom  = b.ReadUShort();
                    w.ModelPitch = b.ReadUShort();
                    w.ModelYaw   = b.ReadUShort();
                }

                if (w.Type == 7)
                {
                    w.ItemIndices      = new int[w.Width * w.Height];
                    w.ItemAmounts      = new int[w.Width * w.Height];
                    w.Centered         = b.ReadUByte() == 1;
                    w.FontIdx          = b.ReadUByte();
                    w.Shadow           = b.ReadByte() == 1;
                    w.RGBDisabled      = b.ReadInt();
                    w.ItemMarginX      = b.ReadUShort();
                    w.ItemMarginY      = b.ReadUShort();
                    w.ItemsHaveActions = b.ReadByte() == 1;
                    w.ItemActions      = new string[5];

                    for (var i = 0; i < 5; i++)
                    {
                        w.ItemActions[i] = b.ReadString(10);
                        if (w.ItemActions[i].Length == 0)
                        {
                            w.ItemActions[i] = null;
                        }
                    }
                }

                if (w.OptionType == 2 || w.Type == 2)
                {
                    w.OptionPrefix = b.ReadString(10);
                    w.OptionSuffix = b.ReadString(10);
                    w.OptionAction = b.ReadUShort();
                }

                if (w.OptionType == 1 || w.OptionType == 4 || w.OptionType == 5 || w.OptionType == 6)
                {
                    w.Option = b.ReadString(10);
                    if (w.Option.Length == 0)
                    {
                        if (w.OptionType == 1)
                        {
                            w.Option = "Ok";
                        }
                        if (w.OptionType == 4)
                        {
                            w.Option = "Select";
                        }
                        if (w.OptionType == 5)
                        {
                            w.Option = "Select";
                        }
                        if (w.OptionType == 6)
                        {
                            w.Option = "Continue";
                        }
                    }
                }

                configs[index] = w;
            }
        }