Esempio n. 1
0
        private void SetupMidiIndices(CacheArchive archive)
        {
            var midiIdxStream = new DefaultJagexBuffer(archive.GetFile("midi_index"));
            var size          = midiIdxStream.Capacity();

            MidiIndex = new int[size];
            for (int i = 0; i < size; i++)
            {
                MidiIndex[i] = midiIdxStream.ReadUByte();
            }
        }
Esempio n. 2
0
        private void SetupAnimIndices(CacheArchive archive)
        {
            var animIdxStream = new DefaultJagexBuffer(archive.GetFile("anim_index"));
            var size          = animIdxStream.Capacity() / 2;

            AnimIndex = new int[size];
            for (int i = 0; i < size; i++)
            {
                AnimIndex[i] = animIdxStream.ReadUShort();
            }
        }
Esempio n. 3
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());
        }
Esempio n. 4
0
        private void SetupFileCrcs(CacheArchive archive)
        {
            for (var i = 0; i < CrcFiles.Length; i++)
            {
                var b = new DefaultJagexBuffer(archive.GetFile(CrcFiles[i]));

                FileCrcs[i] = new int[b.Capacity() / 4];
                for (int j = 0; j < FileCrcs[i].Length; j++)
                {
                    FileCrcs[i][j] = b.ReadInt();
                }
            }
        }
Esempio n. 5
0
        private void SetupFileInfo(CacheArchive archive)
        {
            for (var i = 0; i < VersionFiles.Length; i++)
            {
                var b     = new DefaultJagexBuffer(archive.GetFile(VersionFiles[i]));
                int count = b.Capacity() / 2;

                FileVersions[i]   = new int[count];
                FilePriorities[i] = new byte[count];

                for (int j = 0; j < count; j++)
                {
                    FileVersions[i][j] = b.ReadUShort();
                }
            }
        }
Esempio n. 6
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;
            }
        }