Search in sources :

Example 26 with Storage

use of net.runelite.cache.fs.Storage in project runelite by runelite.

the class ItemManager method load.

public void load() throws IOException {
    ItemLoader loader = new ItemLoader();
    Storage storage = store.getStorage();
    Index index = store.getIndex(IndexType.CONFIGS);
    Archive archive = index.getArchive(ConfigType.ITEM.getId());
    byte[] archiveData = storage.loadArchive(archive);
    ArchiveFiles files = archive.getFiles(archiveData);
    for (FSFile f : files.getFiles()) {
        ItemDefinition def = loader.load(f.getFileId(), f.getContents());
        items.put(f.getFileId(), def);
    }
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) ItemDefinition(net.runelite.cache.definitions.ItemDefinition) Index(net.runelite.cache.fs.Index) ItemLoader(net.runelite.cache.definitions.loaders.ItemLoader) FSFile(net.runelite.cache.fs.FSFile)

Example 27 with Storage

use of net.runelite.cache.fs.Storage in project runelite by runelite.

the class MapImageDumper method loadUnderlays.

private void loadUnderlays(Store store) throws IOException {
    Storage storage = store.getStorage();
    Index index = store.getIndex(IndexType.CONFIGS);
    Archive archive = index.getArchive(ConfigType.UNDERLAY.getId());
    byte[] archiveData = storage.loadArchive(archive);
    ArchiveFiles files = archive.getFiles(archiveData);
    for (FSFile file : files.getFiles()) {
        UnderlayLoader loader = new UnderlayLoader();
        UnderlayDefinition underlay = loader.load(file.getFileId(), file.getContents());
        underlays.put(underlay.getId(), underlay);
    }
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) UnderlayDefinition(net.runelite.cache.definitions.UnderlayDefinition) Index(net.runelite.cache.fs.Index) UnderlayLoader(net.runelite.cache.definitions.loaders.UnderlayLoader) FSFile(net.runelite.cache.fs.FSFile)

Example 28 with Storage

use of net.runelite.cache.fs.Storage in project runelite by runelite.

the class MapImageDumper method loadOverlays.

private void loadOverlays(Store store) throws IOException {
    Storage storage = store.getStorage();
    Index index = store.getIndex(IndexType.CONFIGS);
    Archive archive = index.getArchive(ConfigType.OVERLAY.getId());
    byte[] archiveData = storage.loadArchive(archive);
    ArchiveFiles files = archive.getFiles(archiveData);
    for (FSFile file : files.getFiles()) {
        OverlayLoader loader = new OverlayLoader();
        OverlayDefinition overlay = loader.load(file.getFileId(), file.getContents());
        overlays.put(overlay.getId(), overlay);
    }
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) OverlayDefinition(net.runelite.cache.definitions.OverlayDefinition) Index(net.runelite.cache.fs.Index) OverlayLoader(net.runelite.cache.definitions.loaders.OverlayLoader) FSFile(net.runelite.cache.fs.FSFile)

Example 29 with Storage

use of net.runelite.cache.fs.Storage in project runelite by runelite.

the class MapImageDumper method loadSprites.

private void loadSprites() throws IOException {
    Storage storage = store.getStorage();
    Index index = store.getIndex(IndexType.SPRITES);
    final int mapsceneHash = Djb2.hash("mapscene");
    for (Archive a : index.getArchives()) {
        byte[] contents = a.decompress(storage.loadArchive(a));
        SpriteLoader loader = new SpriteLoader();
        SpriteDefinition[] sprites = loader.load(a.getArchiveId(), contents);
        for (SpriteDefinition sprite : sprites) {
            if (sprite.getHeight() <= 0 || sprite.getWidth() <= 0) {
                continue;
            }
            if (a.getNameHash() == mapsceneHash) {
                BufferedImage spriteImage = new BufferedImage(sprite.getWidth(), sprite.getHeight(), BufferedImage.TYPE_INT_ARGB);
                spriteImage.setRGB(0, 0, sprite.getWidth(), sprite.getHeight(), sprite.getPixels(), 0, sprite.getWidth());
                // scale image down so it fits
                Image scaledImage = spriteImage.getScaledInstance(MAPICON_MAX_WIDTH, MAPICON_MAX_HEIGHT, 0);
                assert scaledMapIcons.containsKey(sprite.getFrame()) == false;
                scaledMapIcons.put(sprite.getFrame(), scaledImage);
            }
        }
    }
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) SpriteDefinition(net.runelite.cache.definitions.SpriteDefinition) Index(net.runelite.cache.fs.Index) SpriteLoader(net.runelite.cache.definitions.loaders.SpriteLoader) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) BufferedImage(java.awt.image.BufferedImage)

Example 30 with Storage

use of net.runelite.cache.fs.Storage in project runelite by runelite.

the class CacheServerTest method addInitialFilesToStore.

private void addInitialFilesToStore(Store store) throws FileNotFoundException, IOException {
    Storage storage = store.getStorage();
    Index index = store.addIndex(0);
    Archive archive = index.addArchive(0);
    FileData[] files = new FileData[1];
    archive.setFileData(files);
    FileData file = files[0] = new FileData();
    file.setNameHash(7);
    byte[] data = "test".getBytes();
    Container container = new Container(archive.getCompression(), -1);
    container.compress(data, null);
    byte[] compressedData = container.data;
    storage.saveArchive(archive, compressedData);
}
Also used : Container(net.runelite.cache.fs.Container) Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) Index(net.runelite.cache.fs.Index) FileData(net.runelite.cache.index.FileData)

Aggregations

Archive (net.runelite.cache.fs.Archive)34 Storage (net.runelite.cache.fs.Storage)34 Index (net.runelite.cache.fs.Index)33 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)18 FSFile (net.runelite.cache.fs.FSFile)18 Store (net.runelite.cache.fs.Store)18 File (java.io.File)17 Test (org.junit.Test)17 IOException (java.io.IOException)4 FramemapDefinition (net.runelite.cache.definitions.FramemapDefinition)2 InterfaceDefinition (net.runelite.cache.definitions.InterfaceDefinition)2 InventoryDefinition (net.runelite.cache.definitions.InventoryDefinition)2 LocationsDefinition (net.runelite.cache.definitions.LocationsDefinition)2 MapDefinition (net.runelite.cache.definitions.MapDefinition)2 OverlayDefinition (net.runelite.cache.definitions.OverlayDefinition)2 SpriteDefinition (net.runelite.cache.definitions.SpriteDefinition)2 UnderlayDefinition (net.runelite.cache.definitions.UnderlayDefinition)2 FramemapLoader (net.runelite.cache.definitions.loaders.FramemapLoader)2 InterfaceLoader (net.runelite.cache.definitions.loaders.InterfaceLoader)2 InventoryLoader (net.runelite.cache.definitions.loaders.InventoryLoader)2