예제 #1
0
        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));
        }
예제 #2
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;
            }
        }
예제 #3
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;
            }
        }
예제 #4
0
 public static void UnpackVariables(Cache loaded_cache, DataBuffer data_file)
 {
     int cacheSize = data_file.ReadShort();
     if (cache == null)
         cache = new VarBit[cacheSize];
     Count = cacheSize;
     for (int j = 0; j < cacheSize; j++)
     {
         if (cache[j] == null)
             cache[j] = new VarBit();
         cache[j].ReadVariable(data_file);
         //if (cache[j].aBoolean651)
         //	Varp.cache[cache[j].anInt648].aBoolean713 = true;
     }
 }
예제 #5
0
        public bool Write(Cache cache, CacheItemNode node, DataBuffer original)
        {
            try
            {
                DataBuffer index_data = cache.SubArchives[node.SubArchive].ExtractFile("index.dat");
                original.Location   = 0;
                index_data.Location = original.ReadShort() + 4;
                byte pcount = index_data.ReadByte();
                if (pcount >= Palette.Length)
                {
                    index_data.Location -= 5;
                }
                else                 //move to back
                {
                    index_data.Location = index_data.Buffer.Length;
                    byte[] temp = new byte[index_data.Buffer.Length + 12 + Palette.Length * 3];
                    Array.Copy(index_data.Buffer, temp, index_data.Buffer.Length);
                    index_data.Buffer = temp;
                }
                IndexLocation = index_data.Location;
                index_data.WriteShort(WholeWidth);
                index_data.WriteShort(WholeHeight);
                index_data.WriteByte((byte)Palette.Length);
                for (int i = 0; i < Palette.Length - 1; i++)
                {
                    index_data.WriteByte(Palette[i].R);
                    index_data.WriteByte(Palette[i].G);
                    index_data.WriteByte(Palette[i].B);
                }
                index_data.WriteByte((byte)XOffset);
                index_data.WriteByte((byte)YOffset);
                index_data.WriteShort(Width);
                index_data.WriteShort(Height);

                index_data.WriteByte(0);                 //x, y (1 is y, x)
                byte[] data = new byte[Width * Height + 2];
                data[0] = (byte)(IndexLocation >> 8);
                data[1] = (byte)IndexLocation;
                for (int i = 0; i < Width * Height; i++)
                {
                    //todo: optimize
                    Color c = Pixels[i];
                    for (int k = 0; k < Palette.Length; k++)
                    {
                        if (Palette[k].R == c.R && Palette[k].G == c.G && Palette[k].B == c.B && Palette[k].A == c.A)
                        {
                            if (c.A == 0)
                            {
                                data[i + 2] = 0;
                            }
                            else
                            {
                                data[i + 2] = (byte)(k + 1);
                            }
                        }
                    }
                }

                cache.SubArchives[node.SubArchive].WriteFile("index.dat", index_data.Buffer);
                cache.SubArchives[node.SubArchive].WriteFile(node.FileIndex, data);
                cache.SubArchives[node.SubArchive].RewriteArchive();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #6
0
        public bool Write(Cache cache, CacheItemNode node, DataBuffer original)
        {
            try
            {
                DataBuffer index_data = cache.SubArchives[node.SubArchive].ExtractFile("index.dat");
                original.Location = 0;
                index_data.Location = original.ReadShort() + 4;
                byte pcount = index_data.ReadByte();
                if (pcount >= Palette.Length)
                    index_data.Location -= 5;
                else //move to back
                {
                    index_data.Location = index_data.Buffer.Length;
                    byte[] temp = new byte[index_data.Buffer.Length + 12 + Palette.Length * 3];
                    Array.Copy(index_data.Buffer, temp, index_data.Buffer.Length);
                    index_data.Buffer = temp;
                }
                IndexLocation = index_data.Location;
                index_data.WriteShort(WholeWidth);
                index_data.WriteShort(WholeHeight);
                index_data.WriteByte((byte)Palette.Length);
                for (int i = 0; i < Palette.Length - 1; i++)
                {
                    index_data.WriteByte(Palette[i].R);
                    index_data.WriteByte(Palette[i].G);
                    index_data.WriteByte(Palette[i].B);
                }
                index_data.WriteByte((byte)XOffset);
                index_data.WriteByte((byte)YOffset);
                index_data.WriteShort(Width);
                index_data.WriteShort(Height);

                index_data.WriteByte(0); //x, y (1 is y, x)
                byte[] data = new byte[Width * Height + 2];
                data[0] = (byte)(IndexLocation >> 8);
                data[1] = (byte)IndexLocation;
                for (int i = 0; i < Width * Height; i++)
                {
                    //todo: optimize
                    Color c = Pixels[i];
                    for (int k = 0; k < Palette.Length; k++)
                    {
                        if (Palette[k].R == c.R && Palette[k].G == c.G && Palette[k].B == c.B && Palette[k].A == c.A)
                        {
                            if (c.A == 0)
                                data[i + 2] = 0;
                            else
                                data[i + 2] = (byte)(k + 1);
                        }
                    }
                }

                cache.SubArchives[node.SubArchive].WriteFile("index.dat", index_data.Buffer);
                cache.SubArchives[node.SubArchive].WriteFile(node.FileIndex, data);
                cache.SubArchives[node.SubArchive].RewriteArchive();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
예제 #7
0
 private void ReadVariable(DataBuffer stream)
 {
     do
     {
         int j = stream.ReadByte();
         if (j == 0)
             return;
         if (j == 1)
         {
             Variable = stream.ReadShort();
             LowerBit = stream.ReadByte();
             UpperBit = stream.ReadByte();
         }
         else if (j == 10)
             stream.ReadString();
         else if (j == 2)
             aBoolean651 = true;
         else if (j == 3)
             stream.ReadInteger();
         else if (j == 4)
             stream.ReadInteger();
     } while (true);
 }
예제 #8
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";
                    }
                }
            }
        }
예제 #9
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";
                        }
                    }
                }
            }
        }
예제 #10
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];
            }
        }
예제 #11
0
        private void ReadObject(DataBuffer stream)
        {
            int i = -1;

            do
            {
                int j;
                do
                {
                    j = stream.ReadByte();
                    if (j == 0)
                        goto Finalize;
                    if (j == 1)
                    {
                        int k = stream.ReadByte();
                        if (k > 0)
                        {
                            if (ModelIndexes == null || lowMem)
                            {
                                anIntArray776 = new int[k];
                                ModelIndexes = new int[k];
                                for (int k1 = 0; k1 < k; k1++)
                                {
                                    ModelIndexes[k1] = stream.ReadShort();
                                    anIntArray776[k1] = stream.ReadByte();
                                }

                            }
                            else
                            {
                                stream.Location += k * 3;
                            }
                        }
                    }
                    else if (j == 2)
                        Name = stream.ReadString();
                    else if (j == 3)
                        Description = stream.ReadString();
                    else if (j == 5)
                    {
                        int l = stream.ReadByte();
                        if (l > 0)
                        {
                            if (ModelIndexes == null || lowMem)
                            {
                                anIntArray776 = null;
                                ModelIndexes = new int[l];
                                for (int l1 = 0; l1 < l; l1++)
                                    ModelIndexes[l1] = stream.ReadShort();

                            }
                            else
                            {
                                stream.Location += l * 2;
                            }
                        }
                    }
                    else if (j == 14)
                        TileSizeX = stream.ReadByte();
                    else if (j == 15)
                        TileSizeZ = stream.ReadByte();
                    else if (j == 17)
                        Clips = false;
                    else if (j == 18)
                        aBoolean757 = false;
                    else if (j == 19)
                    {
                        i = stream.ReadByte();
                        if (i == 1)
                            HasActions = true;
                    }
                    else if (j == 21)
                        RotateOnGround = true;
                    else if (j == 22)
                        FlatShading = true;
                    else if (j == 23)
                        aBoolean764 = true;
                    else if (j == 24)
                    {
                        AnimationID = stream.ReadShort();
                        if (AnimationID == 65535)
                            AnimationID = -1;
                    }
                    else if (j == 28)
                        anInt775 = stream.ReadByte();
                    else if (j == 29)
                        LightIntensity = stream.ReadSignedByte();
                    else if (j == 39)
                        LightDistance = stream.ReadSignedByte();
                    else if (j >= 30 && j < 39)
                    {
                        if (Actions == null)
                            Actions = new String[5];
                        Actions[j - 30] = stream.ReadString();
                        if (Actions[j - 30].ToLower().Equals("hidden"))
                            Actions[j - 30] = null;
                    }
                    else if (j == 40)
                    {
                        int i1 = stream.ReadByte();
                        ModelRecolorIndexes = new int[i1];
                        ModelRecolorColors = new int[i1];
                        for (int i2 = 0; i2 < i1; i2++)
                        {
                            ModelRecolorIndexes[i2] = stream.ReadShort();
                            ModelRecolorColors[i2] = stream.ReadShort();
                        }

                    }
                    else if (j == 60)
                        MinimapFunction = stream.ReadShort();
                    else if (j == 62)
                        MirrorAlongX = true;
                    else if (j == 64)
                        aBoolean779 = false;
                    else if (j == 65)
                        ScaleX = stream.ReadShort();
                    else if (j == 66)
                        ScaleY = stream.ReadShort();
                    else if (j == 67)
                        ScaleZ = stream.ReadShort();
                    else if (j == 68)
                        MinimapIcon = stream.ReadShort();
                    else if (j == 69)
                        anInt768 = stream.ReadByte();
                    else if (j == 70)
                        TranslationX = stream.ReadSignedShort();
                    else if (j == 71)
                        TranslationY = stream.ReadSignedShort();
                    else if (j == 72)
                        TranslationZ = stream.ReadSignedShort();
                    else if (j == 73)
                        aBoolean736 = true;
                    else if (j == 74)
                    {
                        aBoolean766 = true;
                    }
                    else
                    {
                        if (j != 75)
                            continue;
                        anInt760 = stream.ReadByte();
                    }
                    continue;
                } while (j != 77);

                anInt774 = stream.ReadShort();
                if (anInt774 == 65535)
                    anInt774 = -1;
                anInt749 = stream.ReadShort();
                if (anInt749 == 65535)
                    anInt749 = -1;
                int j1 = stream.ReadByte();
                SubObjectIDs = new int[j1 + 1];
                for (int j2 = 0; j2 <= j1; j2++)
                {
                    SubObjectIDs[j2] = stream.ReadShort();
                    if (SubObjectIDs[j2] == 65535)
                        SubObjectIDs[j2] = -1;
                }

            } while (true);

            Finalize:
            if (i == -1)
            {
                HasActions = ModelIndexes != null && (anIntArray776 == null || anIntArray776[0] == 10);
                if (Actions != null)
                    HasActions = true;
            }
            if (aBoolean766)
            {
                Clips = false;
                aBoolean757 = false;
            }
            if (anInt760 == -1)
                anInt760 = Clips ? 1 : 0;
        }