Search in sources :

Example 1 with FramemapLoader

use of net.runelite.cache.definitions.loaders.FramemapLoader in project runelite by runelite.

the class FrameDumper method extract.

// @Test
public void extract() throws IOException {
    File base = StoreLocation.LOCATION, outDir = folder.newFolder();
    int count = 0;
    try (Store store = new Store(base)) {
        store.load();
        Storage storage = store.getStorage();
        Index frameIndex = store.getIndex(IndexType.FRAMES);
        Index framemapIndex = store.getIndex(IndexType.FRAMEMAPS);
        for (Archive archive : frameIndex.getArchives()) {
            List<FrameDefinition> frames = new ArrayList<>();
            byte[] archiveData = storage.loadArchive(archive);
            byte[] contents = archive.decompress(archiveData);
            int framemapArchiveId = (contents[0] & 0xff) << 8 | contents[1] & 0xff;
            Archive framemapArchive = framemapIndex.getArchives().get(framemapArchiveId);
            archiveData = storage.loadArchive(framemapArchive);
            byte[] framemapContents = framemapArchive.decompress(archiveData);
            FramemapLoader fmloader = new FramemapLoader();
            FramemapDefinition framemap = fmloader.load(0, framemapContents);
            FrameLoader frameLoader = new FrameLoader();
            FrameDefinition frame = frameLoader.load(framemap, contents);
            frames.add(frame);
            Files.write(gson.toJson(frames), new File(outDir, archive.getArchiveId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} frames to {}", count, outDir);
}
Also used : FrameDefinition(net.runelite.cache.definitions.FrameDefinition) Archive(net.runelite.cache.fs.Archive) ArrayList(java.util.ArrayList) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) FramemapLoader(net.runelite.cache.definitions.loaders.FramemapLoader) Storage(net.runelite.cache.fs.Storage) FrameLoader(net.runelite.cache.definitions.loaders.FrameLoader) File(java.io.File) FramemapDefinition(net.runelite.cache.definitions.FramemapDefinition)

Example 2 with FramemapLoader

use of net.runelite.cache.definitions.loaders.FramemapLoader in project runelite by runelite.

the class FramemapDumper method extract.

@Test
public void extract() throws IOException {
    File base = StoreLocation.LOCATION, outDir = folder.newFolder();
    int count = 0;
    try (Store store = new Store(base)) {
        store.load();
        Storage storage = store.getStorage();
        Index index = store.getIndex(IndexType.FRAMEMAPS);
        for (Archive archive : index.getArchives()) {
            byte[] archiveData = storage.loadArchive(archive);
            byte[] contents = archive.decompress(archiveData);
            FramemapLoader loader = new FramemapLoader();
            FramemapDefinition framemap = loader.load(0, contents);
            Files.write(gson.toJson(framemap), new File(outDir, archive.getArchiveId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} framemaps to {}", count, outDir);
}
Also used : FramemapLoader(net.runelite.cache.definitions.loaders.FramemapLoader) Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) File(java.io.File) FramemapDefinition(net.runelite.cache.definitions.FramemapDefinition) Test(org.junit.Test)

Aggregations

File (java.io.File)2 FramemapDefinition (net.runelite.cache.definitions.FramemapDefinition)2 FramemapLoader (net.runelite.cache.definitions.loaders.FramemapLoader)2 Archive (net.runelite.cache.fs.Archive)2 Index (net.runelite.cache.fs.Index)2 Storage (net.runelite.cache.fs.Storage)2 Store (net.runelite.cache.fs.Store)2 ArrayList (java.util.ArrayList)1 FrameDefinition (net.runelite.cache.definitions.FrameDefinition)1 FrameLoader (net.runelite.cache.definitions.loaders.FrameLoader)1 Test (org.junit.Test)1