Search in sources :

Example 1 with TableBuilder

use of info.ata4.disunity.cli.util.TableBuilder in project disunity by ata4.

the class AssetObjects method tableModel.

@Override
protected TableModel tableModel(SerializedFile serialized) {
    SerializedFileMetadata metadata = serialized.metadata();
    TableBuilder table = new TableBuilder();
    table.row("Path ID", "Offset", "Length", "Type ID", "Class ID");
    Class<ObjectInfo> factory = metadata.objectInfoTable().elementFactory();
    boolean typeTreePresent = metadata.typeTree().embedded();
    boolean v2 = ObjectInfoV2.class.isAssignableFrom(factory);
    boolean v3 = ObjectInfoV3.class.isAssignableFrom(factory);
    if (typeTreePresent) {
        table.append("Class Name");
    }
    if (v2) {
        table.append("Script Type ID");
    }
    if (v3) {
        table.append("Stripped");
    }
    metadata.objectInfoTable().infoMap().entrySet().stream().forEach(e -> {
        ObjectInfo info = e.getValue();
        table.row(e.getKey(), info.offset(), info.length(), info.typeID(), info.classID());
        if (typeTreePresent) {
            TypeRoot<Type> baseClass = metadata.typeTree().typeMap().get(info.typeID());
            String className = baseClass.nodes().data().typeName();
            table.append(className);
        }
        if (v2) {
            table.append(((ObjectInfoV2) info).scriptTypeIndex());
        }
        if (v3) {
            table.append(((ObjectInfoV3) info).isStripped());
        }
    });
    TableModel model = new TableModel("Objects", table.get());
    TextTableFormat format = model.format();
    format.columnFormatter(1, Formatters::hex);
    return model;
}
Also used : SerializedFileMetadata(info.ata4.junity.serialize.SerializedFileMetadata) Type(info.ata4.junity.serialize.typetree.Type) Formatters(info.ata4.disunity.cli.util.Formatters) TextTableFormat(info.ata4.disunity.cli.util.TextTableFormat) TableBuilder(info.ata4.disunity.cli.util.TableBuilder) ObjectInfo(info.ata4.junity.serialize.objectinfo.ObjectInfo) TableModel(info.ata4.disunity.cli.util.TableModel)

Example 2 with TableBuilder

use of info.ata4.disunity.cli.util.TableBuilder in project disunity by ata4.

the class BundleInfo method buildHeaderTable.

private Table<Integer, Integer, Object> buildHeaderTable(BundleHeader header) {
    TableBuilder table = new TableBuilder();
    table.row("Field", "Value");
    table.row("signature", header.signature());
    table.row("streamVersion", header.streamVersion());
    table.row("unityVersion", header.unityVersion());
    table.row("unityRevision", header.unityRevision());
    table.row("minimumStreamedBytes", header.minimumStreamedBytes());
    table.row("headerSize", header.headerSize());
    table.row("numberOfLevelsToDownload", header.numberOfLevelsToDownload());
    table.row("numberOfLevels", header.numberOfLevels());
    List<Pair<Long, Long>> levelByteEnds = header.levelByteEnd();
    for (int i = 0; i < levelByteEnds.size(); i++) {
        Pair<Long, Long> levelByteEnd = levelByteEnds.get(i);
        table.row("levelByteEnd[" + i + "][0]", levelByteEnd.getLeft());
        table.row("levelByteEnd[" + i + "][1]", levelByteEnd.getRight());
    }
    if (header.streamVersion() >= 2) {
        table.row("completeFileSize", header.completeFileSize());
    }
    if (header.streamVersion() >= 3) {
        table.row("dataHeaderSize", header.dataHeaderSize());
    }
    return table.get();
}
Also used : TableBuilder(info.ata4.disunity.cli.util.TableBuilder) Pair(org.apache.commons.lang3.tuple.Pair)

Example 3 with TableBuilder

use of info.ata4.disunity.cli.util.TableBuilder 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 4 with TableBuilder

use of info.ata4.disunity.cli.util.TableBuilder 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 5 with TableBuilder

use of info.ata4.disunity.cli.util.TableBuilder in project disunity by ata4.

the class AssetObjectIDs method tableModel.

@Override
protected TableModel tableModel(SerializedFile serialized) {
    TableBuilder table = new TableBuilder();
    table.row("Asset Index", "ID in file");
    serialized.metadata().objectIDTable().elements().forEach(objectID -> {
        table.row(objectID.serializedFileIndex(), objectID.identifierInFile());
    });
    return new TableModel("Object IDs", table.get());
}
Also used : TableBuilder(info.ata4.disunity.cli.util.TableBuilder) TableModel(info.ata4.disunity.cli.util.TableModel)

Aggregations

TableBuilder (info.ata4.disunity.cli.util.TableBuilder)7 TableModel (info.ata4.disunity.cli.util.TableModel)5 Formatters (info.ata4.disunity.cli.util.Formatters)2 TextTableFormat (info.ata4.disunity.cli.util.TextTableFormat)2 Parameters (com.beust.jcommander.Parameters)1 SerializedFile (info.ata4.junity.serialize.SerializedFile)1 SerializedFileHeader (info.ata4.junity.serialize.SerializedFileHeader)1 SerializedFileMetadata (info.ata4.junity.serialize.SerializedFileMetadata)1 FileIdentifier (info.ata4.junity.serialize.fileidentifier.FileIdentifier)1 ObjectInfo (info.ata4.junity.serialize.objectinfo.ObjectInfo)1 Type (info.ata4.junity.serialize.typetree.Type)1 DataBlock (info.ata4.util.io.DataBlock)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Pair (org.apache.commons.lang3.tuple.Pair)1