Search in sources :

Example 1 with AreaDefinition

use of net.runelite.cache.definitions.AreaDefinition in project runelite by runelite.

the class AreaDumper 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();
        AreaManager areaManager = new AreaManager(store);
        areaManager.load();
        for (AreaDefinition area : areaManager.getAreas()) {
            Files.write(gson.toJson(area), new File(outDir, area.id + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} areas to {}", count, outDir);
}
Also used : AreaDefinition(net.runelite.cache.definitions.AreaDefinition) Store(net.runelite.cache.fs.Store) File(java.io.File) Test(org.junit.Test)

Example 2 with AreaDefinition

use of net.runelite.cache.definitions.AreaDefinition in project runelite by runelite.

the class MapImageDumper method drawMapIcons.

private void drawMapIcons(Graphics2D graphics, Region region, int z, int drawBaseX, int drawBaseY) {
    for (Location location : region.getLocations()) {
        int localZ = location.getPosition().getZ();
        if (z != 0 && localZ != z) {
            // draw all icons on z=0
            continue;
        }
        ObjectDefinition od = findObject(location.getId());
        assert od != null;
        int localX = location.getPosition().getX() - region.getBaseX();
        int localY = location.getPosition().getY() - region.getBaseY();
        int drawX = drawBaseX + localX;
        int drawY = drawBaseY + (Region.Y - 1 - localY);
        if (od.getMapAreaId() != -1) {
            AreaDefinition area = areas.getArea(od.getMapAreaId());
            assert area != null;
            int spriteId = area.spriteId;
            SpriteDefinition sprite = sprites.findSprite(spriteId, 0);
            assert sprite != null;
            BufferedImage iconImage = sprites.getSpriteImage(sprite);
            graphics.drawImage(iconImage, drawX * MAP_SCALE, drawY * MAP_SCALE, null);
        }
    }
}
Also used : AreaDefinition(net.runelite.cache.definitions.AreaDefinition) SpriteDefinition(net.runelite.cache.definitions.SpriteDefinition) ObjectDefinition(net.runelite.cache.definitions.ObjectDefinition) BufferedImage(java.awt.image.BufferedImage) Location(net.runelite.cache.region.Location)

Example 3 with AreaDefinition

use of net.runelite.cache.definitions.AreaDefinition in project runelite by runelite.

the class AreaManager method load.

public void load() throws IOException {
    Storage storage = store.getStorage();
    Index index = store.getIndex(IndexType.CONFIGS);
    Archive archive = index.getArchive(ConfigType.AREA.getId());
    byte[] archiveData = storage.loadArchive(archive);
    ArchiveFiles files = archive.getFiles(archiveData);
    for (FSFile file : files.getFiles()) {
        AreaLoader loader = new AreaLoader();
        AreaDefinition area = loader.load(file.getContents(), file.getFileId());
        areas.put(area.id, area);
    }
}
Also used : AreaDefinition(net.runelite.cache.definitions.AreaDefinition) Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) Index(net.runelite.cache.fs.Index) AreaLoader(net.runelite.cache.definitions.loaders.AreaLoader) FSFile(net.runelite.cache.fs.FSFile)

Example 4 with AreaDefinition

use of net.runelite.cache.definitions.AreaDefinition in project runelite by runelite.

the class AreaLoader method load.

public AreaDefinition load(byte[] b, int id) {
    InputStream in = new InputStream(b);
    AreaDefinition def = new AreaDefinition();
    def.id = id;
    for (; ; ) {
        int opcode = in.readUnsignedByte();
        if (opcode == 0) {
            break;
        }
        processOpcode(def, in, opcode);
    }
    return def;
}
Also used : AreaDefinition(net.runelite.cache.definitions.AreaDefinition) InputStream(net.runelite.cache.io.InputStream)

Aggregations

AreaDefinition (net.runelite.cache.definitions.AreaDefinition)4 BufferedImage (java.awt.image.BufferedImage)1 File (java.io.File)1 ObjectDefinition (net.runelite.cache.definitions.ObjectDefinition)1 SpriteDefinition (net.runelite.cache.definitions.SpriteDefinition)1 AreaLoader (net.runelite.cache.definitions.loaders.AreaLoader)1 Archive (net.runelite.cache.fs.Archive)1 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)1 FSFile (net.runelite.cache.fs.FSFile)1 Index (net.runelite.cache.fs.Index)1 Storage (net.runelite.cache.fs.Storage)1 Store (net.runelite.cache.fs.Store)1 InputStream (net.runelite.cache.io.InputStream)1 Location (net.runelite.cache.region.Location)1 Test (org.junit.Test)1