コード例 #1
0
        public RSImage(SubArchive archive, DataBuffer image_data, int sprite_index = 0)
        {
            try
            {
                DataBuffer index_data = archive.ExtractFile("index.dat");
                if (index_data == null || image_data == null)
                {
                    return;
                }

                image_data.Location = 0;
                index_data.Location = image_data.ReadShort();
                WholeWidth          = index_data.ReadShort();
                WholeHeight         = index_data.ReadShort();
                Palette             = new Color[index_data.ReadByte()];
                for (int i = 0; i < Palette.Length - 1; i++)
                {
                    Palette[i + 1] = Color.FromArgb(index_data.ReadByte(), index_data.ReadByte(), index_data.ReadByte());
                }

                for (int i = 0; i < sprite_index; i++)
                {
                    index_data.Location += 2;                                               //x/y offset
                    image_data.Location += index_data.ReadShort() * index_data.ReadShort(); //width * height
                    index_data.Location++;                                                  //type
                }

                XOffset = index_data.ReadByte();
                YOffset = index_data.ReadByte();
                Width   = index_data.ReadShort();
                Height  = index_data.ReadShort();
                byte type = index_data.ReadByte();

                Pixels         = new Color[Width * Height];
                PaletteIndexes = new byte[Width * Height];
                if (type == 0)
                {
                    for (int i = 0; i < Pixels.Length; i++)
                    {
                        PaletteIndexes[i] = image_data.ReadByte();
                        Pixels[i]         = Palette[PaletteIndexes[i]];
                    }
                }
                else if (type == 1)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        for (int y = 0; y < Height; y++)
                        {
                            PaletteIndexes[x + y * Width] = image_data.ReadByte();
                            Pixels[x + y * Width]         = Palette[PaletteIndexes[x + y * Width]];
                        }
                    }
                }
            }
            catch (Exception)
            {
                Pixels = null;
            }
        }
コード例 #2
0
ファイル: Map.cs プロジェクト: Rune-Status/Lin20-cachesuite
        public static Point GetCoordinates(SubArchive archive, int index)
        {
            if (map_indices1 == null)
            {
                DataBuffer data = archive.ExtractFile("map_index");
                if (data == null)
                {
                    return(new Point(-1, -1));
                }
                map_indices1 = new int[data.Buffer.Length / 7];
                map_indices2 = new int[data.Buffer.Length / 7];
                map_indices3 = new int[data.Buffer.Length / 7];
                map_indices4 = new int[data.Buffer.Length / 7];

                for (int i = 0; i < data.Buffer.Length / 7; i++)
                {
                    map_indices1[i] = data.ReadShort();
                    map_indices2[i] = data.ReadShort();
                    map_indices3[i] = data.ReadShort();
                    map_indices4[i] = data.ReadByte();
                }
            }

            if (index < map_indices1.Length)
            {
                int value = map_indices1[index];
                return(new Point((value >> 8) & 0xFF, value & 0xFF));
            }

            return(new Point(-1, -1));
        }
コード例 #3
0
 public RSImage(SubArchive archive, string file, int sprite_index = 0)
     : this(archive, archive.ExtractFile(file), sprite_index)
 {
 }
コード例 #4
0
        /*private Model method206(int i, int j)
         * {
         *      Model model = (Model)aMRUNodes_264.insertFromCache((i << 16) + j);
         *      if (model != null)
         *              return model;
         *      if (i == 1)
         *              model = Model.method462(j);
         *      if (i == 2)
         *              model = EntityDef.forID(j).method160();
         *      if (i == 3)
         *              model = client.myPlayer.method453();
         *      if (i == 4)
         *              model = ItemDef.forID(j).method202(50);
         *      if (i == 5)
         *              model = null;
         *      if (model != null)
         *              aMRUNodes_264.removeFromCache(model, (i << 16) + j);
         *      return model;
         * }*/

        private static RSImage LoadSprite(int i, SubArchive sub_archive, String s)
        {
            //TODO: Caching
            return(new RSImage(sub_archive, s, i));
        }
コード例 #5
0
        public static void unpack(DataBuffer stream, RSFont[] textDrawingAreas, SubArchive streamLoader_1)
        {
            int i = -1;
            int j = stream.ReadShort();

            interfaceCache = new RSInterface[j];
            while (stream.Location < stream.Buffer.Length)
            {
                int k = stream.ReadShort();
                if (k == 65535)
                {
                    i = stream.ReadShort();
                    k = stream.ReadShort();
                }
                RSInterface rsInterface = interfaceCache[k] = new RSInterface();
                rsInterface.id           = k;
                rsInterface.parentID     = i;
                rsInterface.type         = stream.ReadByte();
                rsInterface.atActionType = stream.ReadByte();
                rsInterface.anInt214     = stream.ReadShort();
                rsInterface.width        = stream.ReadShort();
                rsInterface.height       = stream.ReadShort();
                rsInterface.aByte254     = (byte)stream.ReadByte();
                rsInterface.anInt230     = stream.ReadByte();
                if (rsInterface.anInt230 != 0)
                {
                    rsInterface.anInt230 = (rsInterface.anInt230 - 1 << 8) + stream.ReadByte();
                }
                else
                {
                    rsInterface.anInt230 = -1;
                }
                int i1 = stream.ReadByte();
                if (i1 > 0)
                {
                    rsInterface.anIntArray245 = new int[i1];
                    rsInterface.anIntArray212 = new int[i1];
                    for (int j1 = 0; j1 < i1; j1++)
                    {
                        rsInterface.anIntArray245[j1] = stream.ReadByte();
                        rsInterface.anIntArray212[j1] = stream.ReadShort();
                    }
                }
                int k1 = stream.ReadByte();
                if (k1 > 0)
                {
                    rsInterface.valueIndexArray = new int[k1][];
                    for (int l1 = 0; l1 < k1; l1++)
                    {
                        int i3 = stream.ReadShort();
                        rsInterface.valueIndexArray[l1] = new int[i3];
                        for (int l4 = 0; l4 < i3; l4++)
                        {
                            rsInterface.valueIndexArray[l1][l4] = stream.ReadShort();
                        }
                    }
                }
                if (rsInterface.type == 0)
                {
                    rsInterface.scrollMax   = stream.ReadShort();
                    rsInterface.aBoolean266 = stream.ReadByte() == 1;
                    int i2 = stream.ReadShort();
                    rsInterface.children = new int[i2];
                    rsInterface.childX   = new int[i2];
                    rsInterface.childY   = new int[i2];
                    for (int j3 = 0; j3 < i2; j3++)
                    {
                        rsInterface.children[j3] = stream.ReadShort();
                        rsInterface.childX[j3]   = stream.ReadSignedShort();
                        rsInterface.childY[j3]   = stream.ReadSignedShort();
                    }
                }
                if (rsInterface.type == 1)
                {
                    stream.ReadShort();
                    stream.ReadByte();
                }
                if (rsInterface.type == 2)
                {
                    rsInterface.inv                  = new int[rsInterface.width * rsInterface.height];
                    rsInterface.invStackSizes        = new int[rsInterface.width * rsInterface.height];
                    rsInterface.aBoolean259          = stream.ReadByte() == 1;
                    rsInterface.isInventoryInterface = stream.ReadByte() == 1;
                    rsInterface.usableItemInterface  = stream.ReadByte() == 1;
                    rsInterface.aBoolean235          = stream.ReadByte() == 1;
                    rsInterface.invSpritePadX        = stream.ReadByte();
                    rsInterface.invSpritePadY        = stream.ReadByte();
                    rsInterface.spritesX             = new int[20];
                    rsInterface.spritesY             = new int[20];
                    rsInterface.sprites              = new RSImage[20];
                    for (int j2 = 0; j2 < 20; j2++)
                    {
                        int k3 = stream.ReadByte();
                        if (k3 == 1)
                        {
                            rsInterface.spritesX[j2] = stream.ReadSignedShort();
                            rsInterface.spritesY[j2] = stream.ReadSignedShort();
                            String s1 = stream.ReadString();
                            if (streamLoader_1 != null && s1.Length > 0)
                            {
                                int i5 = s1.LastIndexOf(",");
                                rsInterface.sprites[j2] = LoadSprite(int.Parse(s1.Substring(i5 + 1)), streamLoader_1, s1.Substring(0, i5));
                            }
                        }
                    }

                    rsInterface.actions = new String[5];
                    for (int l3 = 0; l3 < 5; l3++)
                    {
                        rsInterface.actions[l3] = stream.ReadString();
                        if (rsInterface.actions[l3].Length == 0)
                        {
                            rsInterface.actions[l3] = null;
                        }
                    }
                }
                if (rsInterface.type == 3)
                {
                    rsInterface.aBoolean227 = stream.ReadByte() == 1;
                }
                if (rsInterface.type == 4 || rsInterface.type == 1)
                {
                    rsInterface.aBoolean223 = stream.ReadByte() == 1;
                    int k2 = stream.ReadByte();
                    if (textDrawingAreas != null)
                    {
                        rsInterface.textDrawingAreas = textDrawingAreas[k2];
                    }
                    rsInterface.aBoolean268 = stream.ReadByte() == 1;
                }
                if (rsInterface.type == 4)
                {
                    rsInterface.message    = stream.ReadString();
                    rsInterface.aString228 = stream.ReadString();
                }
                if (rsInterface.type == 1 || rsInterface.type == 3 || rsInterface.type == 4)
                {
                    rsInterface.textColor = stream.ReadInteger();
                }
                if (rsInterface.type == 3 || rsInterface.type == 4)
                {
                    rsInterface.anInt219 = stream.ReadInteger();
                    rsInterface.anInt216 = stream.ReadInteger();
                    rsInterface.anInt239 = stream.ReadInteger();
                }
                if (rsInterface.type == 5)
                {
                    String s = stream.ReadString();
                    if (streamLoader_1 != null && s.Length > 0)
                    {
                        int i4 = s.LastIndexOf(",");
                        rsInterface.sprite1 = LoadSprite(int.Parse(s.Substring(i4 + 1)), streamLoader_1, s.Substring(0, i4));
                    }
                    s = stream.ReadString();
                    if (streamLoader_1 != null && s.Length > 0)
                    {
                        int j4 = s.LastIndexOf(",");
                        rsInterface.sprite2 = LoadSprite(int.Parse(s.Substring(j4 + 1)), streamLoader_1, s.Substring(0, j4));
                    }
                }
                if (rsInterface.type == 6)
                {
                    int l = stream.ReadByte();
                    if (l != 0)
                    {
                        rsInterface.anInt233 = 1;
                        rsInterface.mediaID  = (l - 1 << 8) + stream.ReadByte();
                    }
                    l = stream.ReadByte();
                    if (l != 0)
                    {
                        rsInterface.anInt255 = 1;
                        rsInterface.anInt256 = (l - 1 << 8) + stream.ReadByte();
                    }
                    l = stream.ReadByte();
                    if (l != 0)
                    {
                        rsInterface.anInt257 = (l - 1 << 8) + stream.ReadByte();
                    }
                    else
                    {
                        rsInterface.anInt257 = -1;
                    }
                    l = stream.ReadByte();
                    if (l != 0)
                    {
                        rsInterface.anInt258 = (l - 1 << 8) + stream.ReadByte();
                    }
                    else
                    {
                        rsInterface.anInt258 = -1;
                    }
                    rsInterface.anInt269 = stream.ReadShort();
                    rsInterface.anInt270 = stream.ReadShort();
                    rsInterface.anInt271 = stream.ReadShort();
                }
                if (rsInterface.type == 7)
                {
                    rsInterface.inv           = new int[rsInterface.width * rsInterface.height];
                    rsInterface.invStackSizes = new int[rsInterface.width * rsInterface.height];
                    rsInterface.aBoolean223   = stream.ReadByte() == 1;
                    int l2 = stream.ReadByte();
                    if (textDrawingAreas != null)
                    {
                        rsInterface.textDrawingAreas = textDrawingAreas[l2];
                    }
                    rsInterface.aBoolean268          = stream.ReadByte() == 1;
                    rsInterface.textColor            = stream.ReadInteger();
                    rsInterface.invSpritePadX        = stream.ReadSignedShort();
                    rsInterface.invSpritePadY        = stream.ReadSignedShort();
                    rsInterface.isInventoryInterface = stream.ReadByte() == 1;
                    rsInterface.actions = new String[5];
                    for (int k4 = 0; k4 < 5; k4++)
                    {
                        rsInterface.actions[k4] = stream.ReadString();
                        if (rsInterface.actions[k4].Length == 0)
                        {
                            rsInterface.actions[k4] = null;
                        }
                    }
                }
                if (rsInterface.atActionType == 2 || rsInterface.type == 2)
                {
                    rsInterface.selectedActionName = stream.ReadString();
                    rsInterface.spellName          = stream.ReadString();
                    rsInterface.spellUsableOn      = stream.ReadShort();
                }

                if (rsInterface.type == 8)
                {
                    rsInterface.message = stream.ReadString();
                }

                if (rsInterface.atActionType == 1 || rsInterface.atActionType == 4 || rsInterface.atActionType == 5 || rsInterface.atActionType == 6)
                {
                    rsInterface.tooltip = stream.ReadString();
                    if (rsInterface.tooltip.Length == 0)
                    {
                        if (rsInterface.atActionType == 1)
                        {
                            rsInterface.tooltip = "Ok";
                        }
                        if (rsInterface.atActionType == 4)
                        {
                            rsInterface.tooltip = "Select";
                        }
                        if (rsInterface.atActionType == 5)
                        {
                            rsInterface.tooltip = "Select";
                        }
                        if (rsInterface.atActionType == 6)
                        {
                            rsInterface.tooltip = "Continue";
                        }
                    }
                }
            }
        }
コード例 #6
0
        public RSFont(bool flag, String s, SubArchive streamLoader)
        {
            aByteArrayArray1491 = new byte[256][];
            anIntArray1492      = new int[256];
            anIntArray1493      = new int[256];
            anIntArray1494      = new int[256];
            anIntArray1495      = new int[256];
            anIntArray1496      = new int[256];
            aRandom1498         = new Random();
            aBoolean1499        = false;
            DataBuffer stream   = streamLoader.ExtractFile(s + ".dat");
            DataBuffer stream_1 = streamLoader.ExtractFile("index.dat");

            stream_1.Location = stream.ReadShort() + 4;
            int k = stream_1.ReadByte();

            if (k > 0)
            {
                stream_1.Location += 3 * (k - 1);
            }
            for (int l = 0; l < 256; l++)
            {
                anIntArray1494[l] = stream_1.ReadByte();
                anIntArray1495[l] = stream_1.ReadByte();
                int i1 = anIntArray1492[l] = stream_1.ReadShort();
                int j1 = anIntArray1493[l] = stream_1.ReadShort();
                int k1 = stream_1.ReadByte();
                int l1 = i1 * j1;
                aByteArrayArray1491[l] = new byte[l1];
                if (k1 == 0)
                {
                    for (int i2 = 0; i2 < l1; i2++)
                    {
                        aByteArrayArray1491[l][i2] = stream.ReadByte();
                    }
                }
                else
                if (k1 == 1)
                {
                    for (int j2 = 0; j2 < i1; j2++)
                    {
                        for (int l2 = 0; l2 < j1; l2++)
                        {
                            aByteArrayArray1491[l][j2 + l2 * i1] = stream.ReadByte();
                        }
                    }
                }
                if (j1 > anInt1497 && l < 128)
                {
                    anInt1497 = j1;
                }
                anIntArray1494[l] = 1;
                anIntArray1496[l] = i1 + 2;
                int k2 = 0;
                for (int i3 = j1 / 7; i3 < j1; i3++)
                {
                    k2 += aByteArrayArray1491[l][i3 * i1];
                }

                if (k2 <= j1 / 7)
                {
                    anIntArray1496[l]--;
                    anIntArray1494[l] = 0;
                }
                k2 = 0;
                for (int j3 = j1 / 7; j3 < j1; j3++)
                {
                    k2 += aByteArrayArray1491[l][(i1 - 1) + j3 * i1];
                }

                if (k2 <= j1 / 7)
                {
                    anIntArray1496[l]--;
                }
            }

            if (flag)
            {
                anIntArray1496[32] = anIntArray1496[73];
            }
            else
            {
                anIntArray1496[32] = anIntArray1496[105];
            }
        }