Search in sources :

Example 6 with Type

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;
}
Also used : LinkedHashMap(java.util.LinkedHashMap) Parameters(com.beust.jcommander.Parameters) TableModel(info.ata4.disunity.cli.util.TableModel) TableBuilder(info.ata4.disunity.cli.util.TableBuilder) Map(java.util.Map) Formatters(info.ata4.disunity.cli.util.Formatters) TextTableFormat(info.ata4.disunity.cli.util.TextTableFormat) DataBlock(info.ata4.util.io.DataBlock) SerializedFile(info.ata4.junity.serialize.SerializedFile) Formatters(info.ata4.disunity.cli.util.Formatters) TextTableFormat(info.ata4.disunity.cli.util.TextTableFormat) TableBuilder(info.ata4.disunity.cli.util.TableBuilder) DataBlock(info.ata4.util.io.DataBlock) TableModel(info.ata4.disunity.cli.util.TableModel) LinkedHashMap(java.util.LinkedHashMap)

Example 7 with Type

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());
}
Also used : FileIdentifier(info.ata4.junity.serialize.fileidentifier.FileIdentifier) TableBuilder(info.ata4.disunity.cli.util.TableBuilder) TableModel(info.ata4.disunity.cli.util.TableModel)

Example 8 with Type

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);
}
Also used : ObjectInfoTableV1(info.ata4.junity.serialize.objectinfo.ObjectInfoTableV1) ObjectInfoTableV2(info.ata4.junity.serialize.objectinfo.ObjectInfoTableV2) FileIdentifierTable(info.ata4.junity.serialize.fileidentifier.FileIdentifierTable) TypeTreeV3(info.ata4.junity.serialize.typetree.TypeTreeV3) TypeV2(info.ata4.junity.serialize.typetree.TypeV2) TypeTreeV2(info.ata4.junity.serialize.typetree.TypeTreeV2) TypeTreeV1(info.ata4.junity.serialize.typetree.TypeTreeV1) ObjectInfoV3(info.ata4.junity.serialize.objectinfo.ObjectInfoV3) ObjectIdentifierTable(info.ata4.junity.serialize.objectidentifier.ObjectIdentifierTable) FileIdentifierV2(info.ata4.junity.serialize.fileidentifier.FileIdentifierV2) FileIdentifierV1(info.ata4.junity.serialize.fileidentifier.FileIdentifierV1)

Aggregations

TableBuilder (info.ata4.disunity.cli.util.TableBuilder)3 TableModel (info.ata4.disunity.cli.util.TableModel)3 Map (java.util.Map)3 Formatters (info.ata4.disunity.cli.util.Formatters)2 TextTableFormat (info.ata4.disunity.cli.util.TextTableFormat)2 ObjectInfo (info.ata4.junity.serialize.objectinfo.ObjectInfo)2 Type (info.ata4.junity.serialize.typetree.Type)2 Node (info.ata4.util.collection.Node)2 DataBlock (info.ata4.util.io.DataBlock)2 LinkedHashMap (java.util.LinkedHashMap)2 Parameters (com.beust.jcommander.Parameters)1 BiMap (com.google.common.collect.BiMap)1 DataReader (info.ata4.io.DataReader)1 DataWriter (info.ata4.io.DataWriter)1 UnityHash128 (info.ata4.junity.UnityHash128)1 UnityVersion (info.ata4.junity.UnityVersion)1 SerializedFile (info.ata4.junity.serialize.SerializedFile)1 SerializedFileException (info.ata4.junity.serialize.SerializedFileException)1 SerializedFileMetadata (info.ata4.junity.serialize.SerializedFileMetadata)1 FileIdentifier (info.ata4.junity.serialize.fileidentifier.FileIdentifier)1