示例#1
0
    def traverseChildren(self, verbose=False):
        packer = DNAPacker(verbose=verbose)
        for child in self.children:
            packer += child.traverse(recursive=True, verbose=verbose)

        packer.pack('increment parent', 255, UINT8)
        return packer
示例#2
0
    def traverseChildren(self, verbose=False):
        packer = DNAPacker(verbose=verbose)
        for child in self.children:
            packer += child.traverse(recursive=True, verbose=verbose)

        packer.pack('increment parent', 255, UINT8)
        return packer
示例#3
0
    def traverse(self, recursive=True, verbose=False):
        packer = DNANode.traverse(self, recursive=False, verbose=verbose)
        packer.name = 'DNASignBaseline'  # Override the name for debugging.

        traversed_data = DNAPacker()

        for child in self.children:
            if recursive:
                traversed_data += child.traverse(recursive=recursive,
                                                 verbose=verbose)

        packer.pack('sign node code', self.code, STRING)
        packer.packColor('sign node color', *self.color)
        packer.pack('sign node flags', self.flags, STRING)
        packer.pack('sign node indent', self.indent, FLOAT32)
        packer.pack('sign node kern', self.kern, FLOAT32)
        packer.pack('sign node wiggle', self.wiggle, FLOAT32)
        packer.pack('sign node stumble', self.stumble, FLOAT32)
        packer.pack('sign node stomp', self.stomp, FLOAT32)
        packer.pack('sign node width', self.width, FLOAT32)
        packer.pack('sign node height', self.height, FLOAT32)

        if recursive:
            packer += traversed_data
            packer += b'\xFF'

        return packer
示例#4
0
    def traverse(self, recursive=True, verbose=False):
        packer = DNAPacker(name='DNAGroup', verbose=verbose)

        packer.pack('component code', self.COMPONENT_CODE, UINT8)
        packer.pack('name', self.name, STRING)

        parentName = ''
        if self.parent:
            parentName = self.parent.name
        packer.pack('parent name', parentName, STRING)

        visGroupName = ''
        if self.visGroup:
            visGroupName = self.visGroup.name
        packer.pack('vis group name', visGroupName, STRING)

        if recursive:
            packer += self.traverseChildren(verbose=verbose)
        return packer
示例#5
0
    def traverse(self, recursive=True, verbose=False):
        packer = DNAPacker(name='DNAGroup', verbose=verbose)

        packer.pack('component code', self.COMPONENT_CODE, UINT8)
        packer.pack('name', self.name, STRING)

        if recursive:
            packer += self.traverseChildren(verbose=verbose)
        return packer
示例#6
0
    def dump(self, verbose=False):
        packer = DNAPacker(name='DNAStorage', verbose=verbose)

        # Catalog codes...
        packer.pack('catalog code root count', len(self.catalogCodes), UINT16)
        for root, codes in self.catalogCodes.items():
            packer.pack('root', root, STRING)
            packer.pack('root code count', len(codes), UINT8)
            for code in codes:
                packer.pack('code', code, STRING)

        # Textures...
        packer.pack('texture count', len(self.textures), UINT16)
        for code, filename in self.textures.items():
            packer.pack('code', code, STRING)
            packer.pack('filename', filename, STRING)

        # Fonts are packed again now we have C++ signs
        packer.pack('font count', len(self.fonts), UINT16)
        for code, filename in self.fonts.items():
            packer.pack('code', code, STRING)
            packer.pack('filename', filename, STRING)

        # Nodes...
        packer.pack('node count', len(self.nodes), UINT16)
        for code, (filename, search) in self.nodes.items():
            packer.pack('code', code, STRING)
            packer.pack('filename', filename, STRING)
            packer.pack('search', search, STRING)

        # Hood nodes...
        packer.pack('hood node count', len(self.hoodNodes), UINT16)
        for code, (filename, search) in self.hoodNodes.items():
            packer.pack('code', code, STRING)
            packer.pack('filename', filename, STRING)
            packer.pack('search', search, STRING)

        # Place nodes...
        packer.pack('place node count', len(self.placeNodes), UINT16)
        for code, (filename, search) in self.placeNodes.items():
            packer.pack('code', code, STRING)
            packer.pack('filename', filename, STRING)
            packer.pack('search', search, STRING)

        # Blocks...
        packer.pack('block number count', len(self.blockNumbers), UINT16)
        for blockNumber in self.blockNumbers:
            packer.pack('number', blockNumber, UINT8)
            packer.pack('zone ID', self.blockZones[blockNumber], UINT16)
            title = self.blockTitles.get(blockNumber, '')
            packer.pack('title', title, STRING)
            article = self.blockArticles.get(blockNumber, '')
            packer.pack('article', article, STRING)
            buildingType = self.blockBuildingTypes.get(blockNumber, '')
            packer.pack('building type', buildingType, STRING)

        # Suit points...
        packer.pack('suit point count', len(self.suitPoints), UINT16)
        for point in self.suitPoints:
            packer.pack('index', point.index, UINT16)
            packer.pack('type', point.pointType, UINT8)
            for component in point.pos:
                packer.pack('position', int(component * 100), INT32)
            packer.pack('landmark building index',
                        point.landmarkBuildingIndex, INT16)

        # Suit edges...
        packer.pack('suit edge count', len(self.suitEdges), UINT16)
        for startPointIndex, edges in self.suitEdges.items():
            packer.pack('start point index', startPointIndex, UINT16)
            packer.pack('edge count', len(edges), UINT16)
            for edge in edges:
                packer.pack('end point', edge.endPoint.index, UINT16)
                packer.pack('zone ID', edge.zoneId, UINT16)

        return packer
    def dump(self, verbose=False):
        packer = DNAPacker(name='DNAStorage', verbose=verbose)

        # Catalog codes...
        packer.pack('catalog code root count', len(self.catalogCodes), UINT16)
        for root, codes in self.catalogCodes.items():
            packer.pack('root', root, STRING)
            packer.pack('root code count', len(codes), UINT8)
            for code in codes:
                packer.pack('code', code, STRING)

        # Textures...
        packer.pack('texture count', len(self.textures), UINT16)
        for code, filename in self.textures.items():
            packer.pack('code', code, STRING)
            packer.pack('filename', filename, STRING)

        # Fonts are packed again now we have C++ signs
        packer.pack('font count', len(self.fonts), UINT16)
        for code, filename in self.fonts.items():
            packer.pack('code', code, STRING)
            packer.pack('filename', filename, STRING)

        # Nodes...
        packer.pack('node count', len(self.nodes), UINT16)
        for code, (filename, search) in self.nodes.items():
            packer.pack('code', code, STRING)
            packer.pack('filename', filename, STRING)
            packer.pack('search', search, STRING)

        # Hood nodes...
        packer.pack('hood node count', len(self.hoodNodes), UINT16)
        for code, (filename, search) in self.hoodNodes.items():
            packer.pack('code', code, STRING)
            packer.pack('filename', filename, STRING)
            packer.pack('search', search, STRING)

        # Place nodes...
        packer.pack('place node count', len(self.placeNodes), UINT16)
        for code, (filename, search) in self.placeNodes.items():
            packer.pack('code', code, STRING)
            packer.pack('filename', filename, STRING)
            packer.pack('search', search, STRING)

        # Blocks...
        packer.pack('block number count', len(self.blockNumbers), UINT16)
        for blockNumber in self.blockNumbers:
            packer.pack('number', blockNumber, UINT8)
            packer.pack('zone ID', self.blockZones[blockNumber], UINT16)
            title = self.blockTitles.get(blockNumber, '')
            packer.pack('title', title, STRING)
            article = self.blockArticles.get(blockNumber, '')
            packer.pack('article', article, STRING)
            buildingType = self.blockBuildingTypes.get(blockNumber, '')
            packer.pack('building type', buildingType, STRING)

        # Suit points...
        packer.pack('suit point count', len(self.suitPoints), UINT16)
        for point in self.suitPoints:
            packer.pack('index', point.index, UINT16)
            packer.pack('type', point.pointType, UINT8)
            for component in point.pos:
                packer.pack('position', int(component * 100), INT32)
            packer.pack('landmark building index', point.landmarkBuildingIndex,
                        INT16)

        # Suit edges...
        packer.pack('suit edge count', len(self.suitEdges), UINT16)
        for startPointIndex, edges in self.suitEdges.items():
            packer.pack('start point index', startPointIndex, UINT16)
            packer.pack('edge count', len(edges), UINT16)
            for edge in edges:
                packer.pack('end point', edge.endPoint.index, UINT16)
                packer.pack('zone ID', edge.zoneId, UINT16)

        return packer