use of info.ata4.junity.serialize.typetree.Type in project disunity by ata4.
the class AssetBlocks method tableModel.
@Override
protected TableModel tableModel(SerializedFile serialized) {
Map<String, DataBlock> blocks = new LinkedHashMap<>();
blocks.put("Header", serialized.headerBlock());
blocks.put("Type Tree", serialized.metadata().typeTreeBlock());
blocks.put("Object Info", serialized.metadata().objectInfoBlock());
blocks.put("External Refs", serialized.metadata().externalsBlock());
blocks.put("Object Data", serialized.objectDataBlock());
TableBuilder table = new TableBuilder();
table.row("Name", "Offset", "Size");
blocks.entrySet().stream().sorted((e1, e2) -> Long.compare(e1.getValue().offset(), e2.getValue().offset())).forEach(e -> {
DataBlock block = e.getValue();
table.row(e.getKey(), block.offset(), block.length());
});
TableModel model = new TableModel("Blocks", table.get());
TextTableFormat format = model.format();
format.columnFormatter(1, Formatters::hex);
return model;
}
use of info.ata4.junity.serialize.typetree.Type in project disunity by ata4.
the class AssetExternalRefs method tableModel.
@Override
protected TableModel tableModel(SerializedFile serialized) {
FileIdentifierTable<FileIdentifier> externals = serialized.metadata().externals();
Class<FileIdentifier> factory = externals.elementFactory();
boolean v2 = FileIdentifierV2.class.isAssignableFrom(factory);
TableBuilder table = new TableBuilder();
table.row("File Path");
if (v2) {
table.append("Asset Path");
}
table.append("GUID", "Type");
externals.elements().forEach(external -> {
table.row(external.filePath());
if (v2) {
table.append(((FileIdentifierV2) external).assetPath());
}
table.append(external.guid(), external.type());
});
return new TableModel("External References", table.get());
}
use of info.ata4.junity.serialize.typetree.Type in project disunity by ata4.
the class SerializedFileMetadata method read.
@Override
public void read(DataReader in) throws IOException {
// load type tree
if (version > 13) {
typeTree = new TypeTreeV3(TypeV2.class);
} else if (version > 6) {
typeTree = new TypeTreeV2(TypeV1.class);
} else {
typeTree = new TypeTreeV1(TypeV1.class);
}
typeTreeBlock.markBegin(in);
in.readStruct(typeTree);
typeTreeBlock.markEnd(in);
L.log(Level.FINER, "typeTreeBlock: {0}", typeTreeBlock);
// load object info table
if (version > 14) {
objectInfoTable = new ObjectInfoTableV2(ObjectInfoV3.class);
} else if (version > 13) {
objectInfoTable = new ObjectInfoTableV2(ObjectInfoV2.class);
} else {
objectInfoTable = new ObjectInfoTableV1(ObjectInfoV1.class);
}
objectInfoBlock.markBegin(in);
in.readStruct(objectInfoTable);
objectInfoBlock.markEnd(in);
L.log(Level.FINER, "objectInfoBlock: {0}", objectInfoBlock);
// load object identifiers (Unity 5+ only)
objectIDTable = new ObjectIdentifierTable();
if (version > 10) {
objectIDBlock.markBegin(in);
in.readStruct(objectIDTable);
objectIDBlock.markEnd(in);
L.log(Level.FINER, "objectIDBlock: {0}", objectIDBlock);
}
// load external references
if (version > 5) {
externals = new FileIdentifierTable(FileIdentifierV2.class);
} else {
externals = new FileIdentifierTable(FileIdentifierV1.class);
}
externalsBlock.markBegin(in);
in.readStruct(externals);
externalsBlock.markEnd(in);
L.log(Level.FINER, "externalsBlock: {0}", externalsBlock);
}
Aggregations