Exemple #1
0
 def packFolders(self, binfile):
     """ Generates the root folders
         Does not hook up data pointers except the head group,
         returns rootFolders
     """
     root_folders = []  # for storing Index Groups
     sections = self.sections
     # Create folder for each section the MDL0 has
     i = 0
     while i < len(sections):
         section = sections[i]
         if i == len(
                 sections
         ) - 3:  # special case for shaders: must add entry for each material
             section = sections[i - 1]
         if section:
             f = Folder(binfile, self.section_names[i])
             for x in section:
                 assert x
                 f.addEntry(x.name)
             root_folders.append(f)
             binfile.createRef(i,
                               False)  # create the ref from stored offsets
             f.pack(binfile)
         else:
             root_folders.append(None)  # create placeholder
         i += 1
     return root_folders
Exemple #2
0
 def generateRoot(self, subfiles):
     """ Generates the root folders
         Does not hook up data pointers except the head group,
         returns (rootFolders, bytesize)
     """
     rootFolders = []  # for storing Index Groups
     byteSize = 0
     # Create folder indexing folders
     rootFolder = Folder(self.binfile, 'root')
     rootFolders.append(rootFolder)
     offsets = []  # for tracking offsets from first group to others
     # Create folder for each section the brres has
     for i in range(len(subfiles)):
         folder_name, folder = subfiles[i]
         size = len(folder)
         if size:
             f = Folder(self.binfile, folder_name)
             for j in range(size):
                 f.addEntry(folder[j].name)  # might not have name?
             rootFolder.addEntry(f.name)
             rootFolders.append(f)
             offsets.append(byteSize)
             byteSize += f.byteSize()
     # now update the dataptrs
     rtsize = rootFolder.byteSize()
     entries = rootFolder.entries
     for i in range(len(offsets)):
         entries[i].dataPtr = offsets[i] + rtsize
     return rootFolders
Exemple #3
0
    def pack(self, pat0, binfile):
        super().pack(pat0, binfile)
        textures = pat0.getTextures()
        anims = pat0.mat_anims
        binfile.write('I4HI', 0, pat0.framecount, len(anims), len(textures), 0,
                      pat0.loop)
        binfile.createRef()  # section 0: data
        folder = Folder(binfile)  # index group
        for x in anims:
            folder.addEntry(x.name)
        folder.pack(binfile)
        packing = []
        for x in anims:  # Headers/flags
            folder.createEntryRefI()
            packing.append(PackPat0Animation(x, binfile))
        for x in packing:  # key frame lists
            x.pack_frames(binfile, textures)

        binfile.createRef()  # section 1: textures
        binfile.start()
        for x in textures:
            binfile.storeNameRef(x)
        binfile.end()
        binfile.createRef()  # section 2: palettes
        binfile.createRef()  # section 3: nulls
        binfile.advance(len(textures) * 4)
        binfile.createRef()  # section 4: palette ptr table
        binfile.end()
Exemple #4
0
 def pack(self, clr0, binfile):
     super().pack(clr0, binfile)
     animations = clr0.animations
     binfile.write('i2Hi', 0, clr0.framecount, len(animations), clr0.loop)
     binfile.createRef()  # section 0
     folder = Folder(binfile)
     for x in animations:
         folder.addEntry(x.name)
     folder.pack(binfile)
     for x in animations:
         folder.createEntryRefI()
         self.PackSub(x, binfile)
     binfile.end()
Exemple #5
0
 def pack(self, chr0, binfile):
     super().pack(chr0, binfile)
     binfile.write('I2H2I', 0, chr0.framecount, len(chr0.animations),
                   chr0.loop, chr0.scaling_rule)
     f = Folder(binfile)
     for x in chr0.animations:
         f.addEntry(x.name)
     binfile.createRef()
     f.pack(binfile)
     binfile.writeRemaining(chr0.data)
     for x in chr0.animations:  # hackish way of overwriting the string offsets
         binfile.offset = binfile.beginOffset + x.offset
         f.createEntryRefI()
         binfile.storeNameRef(x.name)
     binfile.end()
Exemple #6
0
 def pack_root(self, scn0, binfile, packing_items):
     binfile.createRef()  # section root
     root = Folder(binfile)
     index_groups = []
     for i in range(5):
         if packing_items[i]:
             root.addEntry(scn0.FOLDERS[i])
             f = Folder(binfile, scn0.FOLDERS[i])
             index_groups.append(f)
             for item in packing_items[i]:
                 f.addEntry(item.name)
     root.pack(binfile)
     for x in index_groups:
         root.createEntryRefI()
         x.pack(binfile)  # doesn't create data pointers
     return index_groups
Exemple #7
0
 def pack(self, shp0, binfile):
     super().pack(shp0, binfile)
     binfile.write('I2HI', 0, shp0.framecount, len(shp0.strings), shp0.loop)
     binfile.createRef()  # section 0
     folder = Folder(binfile)
     for x in shp0.animations:
         folder.addEntry(x.name)
     folder.pack(binfile)
     for x in shp0.animations:
         folder.createEntryRefI()
         self.PackSub(x, binfile)
     binfile.createRef()  # section 1
     binfile.start()
     for x in shp0.strings:
         binfile.storeNameRef(x)
     binfile.end()
     binfile.end()
Exemple #8
0
 def generateRoot(self, subfiles):
     """ Generates the root folders
         Does not hook up data pointers,
         returns (rootFolders, bytesize)
     """
     rootFolders = []  # for storing Index Groups
     # Create folder indexing folders
     self.rootFolder = rootFolder = Folder(self.binfile, 'root')
     # Create folder for each section the brres has
     for i in range(len(subfiles)):
         folder_name, folder = subfiles[i]
         size = len(folder)
         if size:
             f = Folder(self.binfile, folder_name)
             for j in range(size):
                 f.addEntry(folder[j].name)  # might not have name?
             rootFolder.addEntry(f.name)
             rootFolders.append(f)
     for uk in self.node.unknown:
         self.recursive_add_unknown(rootFolder, uk)
     return rootFolders
Exemple #9
0
 def pack(self, srt0, binfile):
     """ Packs the data for SRT file """
     super().pack(srt0, binfile)
     binfile.write("I2H2I", 0, srt0.framecount, len(srt0.matAnimations),
                   srt0.matrixmode, srt0.loop)
     binfile.createRef()  # create ref to section 0
     # create index group
     folder = Folder(binfile, "srt0root")
     for x in srt0.matAnimations:
         folder.addEntry(x.name)
     folder.pack(binfile)
     packers = []
     for x in srt0.matAnimations:
         folder.createEntryRefI()
         packers.append(PackSrt0Material(x, binfile))
     # Now for key frames
     key_frame_lists = {}  # map of offsets to frame lists
     for x in packers:
         x.consolidate(binfile, key_frame_lists)
     # binfile.createRef()  # section 1 (unknown)
     # binfile.writeRemaining(self.section1)
     binfile.end()