use of net.runelite.cache.definitions.InterfaceDefinition in project runelite by runelite.
the class InterfaceManager method export.
public void export(File out) throws IOException {
out.mkdirs();
for (InterfaceDefinition[] defs : interfaces) {
if (defs == null) {
continue;
}
for (InterfaceDefinition def : defs) {
if (def == null) {
continue;
}
InterfaceExporter exporter = new InterfaceExporter(def);
File folder = new File(out, "" + (def.id >>> 16));
folder.mkdirs();
File targ = new File(folder, (def.id & 0xffff) + ".json");
exporter.exportTo(targ);
}
}
}
use of net.runelite.cache.definitions.InterfaceDefinition in project runelite by runelite.
the class InterfaceManager method java.
public void java(File java) throws IOException {
System.setProperty("line.separator", "\n");
java.mkdirs();
File targ = new File(java, "InterfaceID.java");
try (PrintWriter fw = new PrintWriter(targ)) {
fw.println("/* This file is automatically generated. Do not edit. */");
fw.println("package net.runelite.api;");
fw.println("");
fw.println("public final class InterfaceID {");
for (InterfaceDefinition[] defs : interfaces) {
if (defs == null) {
continue;
}
for (InterfaceDefinition def : defs) {
if (def == null || def.name == null || def.name.equalsIgnoreCase("NULL")) {
continue;
}
String name = namer.name(def.name, def.id);
if (name == null) {
continue;
}
fw.println(" public static final int " + name + " = " + def.id + ";");
}
}
fw.println("}");
}
}
use of net.runelite.cache.definitions.InterfaceDefinition 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.InterfaceDefinition in project runelite by runelite.
the class InterfaceLoader method load.
public InterfaceDefinition load(int id, byte[] b) {
InterfaceDefinition iface = new InterfaceDefinition();
iface.id = id;
if (b[0] == -1) {
method3252(iface, new InputStream(b));
} else {
method3251(iface, new InputStream(b));
}
return iface;
}
use of net.runelite.cache.definitions.InterfaceDefinition 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