Example #1
0
    /*
     * Loads the sprite data and index files from the cache location.
     * This can be edited to use an archive such as config or media to load from the cache.
     *
     * @param archive
     */
    public static void loadSprites(StreamLoader streamLoader)
    {
        //try {
        RS2Sharp.Stream index        = new RS2Sharp.Stream(UnityClient.ReadAllBytes(signlink.findcachedir() + "sprites.idx"));
        RS2Sharp.Stream data         = new RS2Sharp.Stream(UnityClient.ReadAllBytes(signlink.findcachedir() + "sprites.dat"));
        DataInputStream indexFile    = new DataInputStream(new Ionic.Zlib.GZipStream(new MemoryStream(index.buffer), Ionic.Zlib.CompressionMode.Decompress));
        DataInputStream dataFile     = new DataInputStream(new Ionic.Zlib.GZipStream(new MemoryStream(data.buffer), Ionic.Zlib.CompressionMode.Decompress));
        int             totalSprites = indexFile.ReadInt();

        UnityEngine.Debug.Log("Sprites loaded: " + totalSprites);
        if (cache == null)
        {
            cache   = new SpriteLoader[totalSprites];
            sprites = new Sprite[totalSprites];
        }
        for (int i = 0; i < totalSprites; i++)
        {
            int id = indexFile.ReadInt();
            if (cache[id] == null)
            {
                cache[id] = new SpriteLoader();
            }
            cache[id].readValues(indexFile, dataFile);
            createSprite(cache[id]);
        }
        //indexFile.Close();
        //dataFile.Close();
        //} catch (Exception e) {
        //	e.printStackTrace();
        //}
    }