use of net.runelite.cache.definitions.loaders.InterfaceLoader in project runelite by runelite.
the class InterfaceManager method load.
public void load() throws IOException {
InterfaceLoader loader = new InterfaceLoader();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.INTERFACES);
int max = index.getArchives().stream().mapToInt(a -> a.getArchiveId()).max().getAsInt();
interfaces = new InterfaceDefinition[max + 1][];
for (Archive archive : index.getArchives()) {
int archiveId = archive.getArchiveId();
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
InterfaceDefinition[] ifaces = interfaces[archiveId];
if (ifaces == null) {
ifaces = interfaces[archiveId] = new InterfaceDefinition[archive.getFileData().length];
}
for (FSFile file : files.getFiles()) {
int fileId = file.getFileId();
int widgetId = (archiveId << 16) + fileId;
InterfaceDefinition iface = loader.load(widgetId, file.getContents());
ifaces[fileId] = iface;
}
}
}
use of net.runelite.cache.definitions.loaders.InterfaceLoader in project runelite by runelite.
the class InterfaceSaverTest method testSave.
@Test
public void testSave() throws Exception {
File base = StoreLocation.LOCATION;
try (Store store = new Store(base)) {
store.load();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.INTERFACES);
Archive archive = index.getArchive(149);
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
FSFile file = files.findFile(0);
byte[] contents = file.getContents();
InterfaceDefinition def = new InterfaceLoader().load(0, contents);
byte[] b = new InterfaceSaver().save(def);
assertArrayEquals(contents, b);
}
}
Aggregations