def mountWithSignature(filename, name): if not os.path.isfile(filename): return False mf = Multifile() mf.openRead(Filename(filename)) if mf.getNumSignatures() != 1: return False if mf.getSignaturePublicKey(0) != OfflineGlobals.getmfcrt(): return False if name == 14 or name == 14.5: mf.setEncryptionPassword(OfflineGlobals.getmfkey(filename)) return vfs.mount(mf, Filename('/'), 0)
def mountMultifiles(self, resourcePackName=None): rsPackPath = None if not resourcePackName else 'resourcepacks/' + resourcePackName # This boolean flag is set false if pack.yaml is not found. allowResourcePackLoad = True if rsPackPath and os.path.exists(rsPackPath): if not os.path.exists(rsPackPath + '/pack.yaml'): self.notify.warning( 'You must have a \'pack.yaml\' configuration in the directory of your resource pack to use it.' ) allowResourcePackLoad = False else: self.resourcePack = ResourcePack(rsPackPath) allowResourcePackLoad = self.resourcePack.digest() if allowResourcePackLoad: author = '' if len(self.resourcePack.authors ) == 0 else self.resourcePack.authors[0] self.notify.info('Loading Resource Pack %s [%s] by %s...' % (self.resourcePack.name, self.resourcePack.version, author)) self.envConfig = self.resourcePack self.notify.info( 'Using Resource Pack Environment Configuration.') # This is a boolean flag that stores if we let the user know that a resource # pack directory was not found. warnedOfMissingPack = False vfs = VirtualFileSystem.getGlobalPtr() for phase in self.Phases: mf = Multifile() mf.setEncryptionPassword(metadata.RESOURCE_ENCRYPTION_PASSWORD) mf.openReadWrite(Filename(metadata.PHASE_DIRECTORY + phase + '.mf')) # Let's handle the mounting of certain file types from resource packs. rsPackMf = None loadedRsPackMf = False if allowResourcePackLoad: if rsPackPath and os.path.exists(rsPackPath): rsPhasePath = '%s/%s.mf' % (rsPackPath, phase) if os.path.exists(rsPhasePath): # This is the phase that exists within the resource pack. rsPackMf = Multifile() rsPackMf.openReadWrite(Filename(rsPhasePath)) # Let's remove the unneeded files from the default multifile for this phase. for subFile in mf.getSubfileNames(): ext = os.path.splitext(subFile)[1][1:] # This code removes files that are overwritten by the resource pack. if ext in self.LegalResourcePackExtensions and subFile in rsPackMf.getSubfileNames( ): mf.removeSubfile(subFile) # This code removes illegal files inside of the resource pack multifile. elif not ext in self.LegalResourcePackExtensions and subFile in rsPackMf.getSubfileNames( ): rsPackMf.removeSubfile(subFile) # Let's flag that we've loaded a resource pack multifile. loadedRsPackMf = True elif rsPackPath and not os.path.exists( rsPackPath) and not warnedOfMissingPack: self.notify.warning( 'Desired resource pack could not be found in the \'resourcepacks\' directory.' ) warnedOfMissingPack = True vfs.mount(mf, '.', 0) if loadedRsPackMf: vfs.mount(rsPackMf, '.', 0) self.notify.info('Mounted %s from resource pack.' % phase) else: self.notify.info('Mounted %s from default.' % phase) if phase == 'phase_3': self.notify.info( 'Loading Default Environment Configuration...') # Make an IO stream to the environment.yaml file. self.envConfigStream = io.BytesIO( vfs.readFile('phase_3/etc/environment.yaml', False)) # Create a new EnvironmentConfiguration object and read the data. self.envConfig = EnvironmentConfiguration( self.envConfigStream) self.envConfig.digest() # Now, close out the stream. self.envConfigStream.close() self.envConfigStream = None self.notify.info( 'Environment Configuration load complete!') self.progressScreen = CIProgressScreen() self.notify.info('All phases loaded! Ready to play!')
import __builtin__, os, sys if hasattr(NodePath, 'DtoolClassDict'): for dtool in ('children', 'parent', 'name'): if dtool in NodePath.DtoolClassDict: del NodePath.DtoolClassDict[dtool] vfs = VirtualFileSystem.getGlobalPtr() phases = [ 'phase_3', 'phase_3.5', 'phase_4', 'phase_5', 'phase_5.5', 'phase_6', 'phase_7', 'phase_8', 'phase_9', 'phase_10', 'phase_11', 'phase_12', 'phase_13', 'phase_0', 'phase_14' ] packExtensions = ['.jpg', '.jpeg', '.png', '.ogg', '.rgb', '.mid'] for phase in phases: mf = Multifile() mf.setEncryptionPassword('cio-03-06-16_lsphases') mf.openReadWrite(Filename(phase + '.mf')) packMf = None if os.path.exists('resourcepack/%s.mf' % phase): for subFile in mf.getSubfileNames(): ext = os.path.splitext(subFile)[1] if ext in packExtensions: mf.removeSubfile(subFile) packMf = Multifile() packMf.openReadWrite(Filename('resourcepack/%s.mf' % phase)) for subFile in packMf.getSubfileNames(): ext = os.path.splitext(subFile)[1] if ext not in packExtensions: packMf.removeSubfile(subFile)