def loadMultifilePrcFiles(self, mf, root): """ Loads any prc files in the root of the indicated Multifile, which is presumed to have been mounted already under root. """ # We have to load these prc files explicitly, since the # ConfigPageManager can't directly look inside the vfs. Use # the Multifile interface to find the prc files, rather than # vfs.scanDirectory(), so we only pick up the files in this # particular multifile. cpMgr = ConfigPageManager.getGlobalPtr() for f in mf.getSubfileNames(): fn = Filename(f) if fn.getDirname() == '' and fn.getExtension() == 'prc': pathname = '%s/%s' % (root, f) alreadyLoaded = False for cpi in range(cpMgr.getNumImplicitPages()): if cpMgr.getImplicitPage(cpi).getName() == pathname: # No need to load this file twice. alreadyLoaded = True break if not alreadyLoaded: data = file.open(Filename(pathname), 'r').read() cp = loadPrcFileData(pathname, data) # Set it to sort value 20, behind the implicit pages. cp.setSort(20)
def loaderPhaseChecker(self, path, loaderOptions): if 'audio/' in path: return 1 file = Filename(path) if not file.getExtension(): file.setExtension('bam') mp = getModelPath() path = mp.findFile(file).cStr() if not path: return match = re.match('.*phase_([^/]+)/', path) if not match: if 'dmodels' in path: return else: self.errorAccumulatorBuffer += 'file not in phase (%s, %s)\n' % ( file, path) return basePhase = float(match.groups()[0]) if not launcher.getPhaseComplete(basePhase): self.errorAccumulatorBuffer += 'phase is not loaded for this model %s\n' % path model = loader.loader.loadSync(Filename(path), loaderOptions) if model: model = NodePath(model) for tex in model.findAllTextures(): texPath = tex.getFullpath().cStr() match = re.match('.*phase_([^/]+)/', texPath) if match: texPhase = float(match.groups()[0]) if texPhase > basePhase: self.errorAccumulatorBuffer += 'texture phase is higher than the models (%s, %s)\n' % ( path, texPath)
def loaderPhaseChecker(self, path, loaderOptions): if 'audio/' in path: return 1 file = Filename(path) if not file.getExtension(): file.setExtension('bam') mp = getModelPath() path = mp.findFile(file).cStr() if not path: return match = re.match('.*phase_([^/]+)/', path) if not match: if 'dmodels' in path: return else: self.errorAccumulatorBuffer += 'file not in phase (%s, %s)\n' % (file, path) return basePhase = float(match.groups()[0]) if not launcher.getPhaseComplete(basePhase): self.errorAccumulatorBuffer += 'phase is not loaded for this model %s\n' % path model = loader.loader.loadSync(Filename(path), loaderOptions) if model: model = NodePath(model) for tex in model.findAllTextures(): texPath = tex.getFullpath().cStr() match = re.match('.*phase_([^/]+)/', texPath) if match: texPhase = float(match.groups()[0]) if texPhase > basePhase: self.errorAccumulatorBuffer += 'texture phase is higher than the models (%s, %s)\n' % (path, texPath)
def buildAPP(self, output, platform): output = Filename(output) if output.isDirectory() and output.getExtension() != 'app': output = Filename(output, "%s.app" % self.fullname) Installer.notify.info("Creating %s..." % output) # Create the executable for the application bundle exefile = Filename(output, "Contents/MacOS/" + self.shortname) exefile.makeDir() if self.includeRequires: extraTokens = {"host_dir": "../Resources"} else: extraTokens = {} self.standalone.build(exefile, platform, extraTokens) hostDir = Filename(output, "Contents/Resources/") hostDir.makeDir() self.installPackagesInto(hostDir, platform) # Create the application plist file. # Although it might make more sense to use Python's plistlib module here, # it is not available on non-OSX systems before Python 2.6. plist = open( Filename(output, "Contents/Info.plist").toOsSpecific(), "w") print >> plist, '<?xml version="1.0" encoding="UTF-8"?>' print >> plist, '<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' print >> plist, '<plist version="1.0">' print >> plist, '<dict>' print >> plist, '\t<key>CFBundleDevelopmentRegion</key>' print >> plist, '\t<string>English</string>' print >> plist, '\t<key>CFBundleDisplayName</key>' print >> plist, '\t<string>%s</string>' % self.fullname print >> plist, '\t<key>CFBundleExecutable</key>' print >> plist, '\t<string>%s</string>' % exefile.getBasename() print >> plist, '\t<key>CFBundleIdentifier</key>' print >> plist, '\t<string>%s.%s</string>' % (self.authorid, self.shortname) print >> plist, '\t<key>CFBundleInfoDictionaryVersion</key>' print >> plist, '\t<string>6.0</string>' print >> plist, '\t<key>CFBundleName</key>' print >> plist, '\t<string>%s</string>' % self.shortname print >> plist, '\t<key>CFBundlePackageType</key>' print >> plist, '\t<string>APPL</string>' print >> plist, '\t<key>CFBundleShortVersionString</key>' print >> plist, '\t<string>%s</string>' % self.version print >> plist, '\t<key>CFBundleVersion</key>' print >> plist, '\t<string>%s</string>' % self.version print >> plist, '\t<key>LSHasLocalizedDisplayName</key>' print >> plist, '\t<false/>' print >> plist, '\t<key>NSAppleScriptEnabled</key>' print >> plist, '\t<false/>' print >> plist, '\t<key>NSPrincipalClass</key>' print >> plist, '\t<string>NSApplication</string>' print >> plist, '</dict>' print >> plist, '</plist>' plist.close() return output
def buildAPP(self, output, platform): output = Filename(output) if output.isDirectory() and output.getExtension() != "app": output = Filename(output, "%s.app" % self.fullname) Installer.notify.info("Creating %s..." % output) # Create the executable for the application bundle exefile = Filename(output, "Contents/MacOS/" + self.shortname) exefile.makeDir() if self.includeRequires: extraTokens = {"host_dir": "../Resources"} else: extraTokens = {} self.standalone.build(exefile, platform, extraTokens) hostDir = Filename(output, "Contents/Resources/") hostDir.makeDir() self.installPackagesInto(hostDir, platform) # Create the application plist file. # Although it might make more sense to use Python's plistlib module here, # it is not available on non-OSX systems before Python 2.6. plist = open(Filename(output, "Contents/Info.plist").toOsSpecific(), "w") print >> plist, '<?xml version="1.0" encoding="UTF-8"?>' print >> plist, '<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' print >> plist, '<plist version="1.0">' print >> plist, "<dict>" print >> plist, "\t<key>CFBundleDevelopmentRegion</key>" print >> plist, "\t<string>English</string>" print >> plist, "\t<key>CFBundleDisplayName</key>" print >> plist, "\t<string>%s</string>" % self.fullname print >> plist, "\t<key>CFBundleExecutable</key>" print >> plist, "\t<string>%s</string>" % exefile.getBasename() print >> plist, "\t<key>CFBundleIdentifier</key>" print >> plist, "\t<string>%s.%s</string>" % (self.authorid, self.shortname) print >> plist, "\t<key>CFBundleInfoDictionaryVersion</key>" print >> plist, "\t<string>6.0</string>" print >> plist, "\t<key>CFBundleName</key>" print >> plist, "\t<string>%s</string>" % self.shortname print >> plist, "\t<key>CFBundlePackageType</key>" print >> plist, "\t<string>APPL</string>" print >> plist, "\t<key>CFBundleShortVersionString</key>" print >> plist, "\t<string>%s</string>" % self.version print >> plist, "\t<key>CFBundleVersion</key>" print >> plist, "\t<string>%s</string>" % self.version print >> plist, "\t<key>LSHasLocalizedDisplayName</key>" print >> plist, "\t<false/>" print >> plist, "\t<key>NSAppleScriptEnabled</key>" print >> plist, "\t<false/>" print >> plist, "\t<key>NSPrincipalClass</key>" print >> plist, "\t<string>NSApplication</string>" print >> plist, "</dict>" print >> plist, "</plist>" plist.close() return output
def loadMultifilePrcFiles(self, mf, root): """ Loads any prc files in the root of the indicated Multifile, which is presumed to have been mounted already under root. """ # We have to load these prc files explicitly, since the # ConfigPageManager can't directly look inside the vfs. Use # the Multifile interface to find the prc files, rather than # vfs.scanDirectory(), so we only pick up the files in this # particular multifile. for f in mf.getSubfileNames(): fn = Filename(f) if fn.getDirname() == '' and fn.getExtension() == 'prc': pathname = '%s/%s' % (root, f) data = file.open(Filename(pathname), 'r').read() loadPrcFileData(pathname, data)
def loaderPhaseChecker(self, path, loaderOptions): # See if this path is in the phase system # It should look something like "phase_5/models/char/joe" # HACK: let's try .bam if it has no extension # Other way to do this: after we load the model, call model.node().getFullpath() if ("audio/" in path): return 1 file = Filename(path) if not file.getExtension(): file.setExtension('bam') mp = getModelPath() path = mp.findFile(file).cStr() if not path: return match = re.match(".*phase_([^/]+)/", path) if (not match): if ('dmodels' in path): return else: self.errorAccumulatorBuffer += "file not in phase (%s, %s)\n" % ( file, path) return basePhase = float(match.groups()[0]) if (not launcher.getPhaseComplete(basePhase)): self.errorAccumulatorBuffer += "phase is not loaded for this model %s\n" % ( path) #grab the model model = loader.loader.loadSync(Filename(path), loaderOptions) if (model): model = NodePath(model) for tex in model.findAllTextures(): texPath = tex.getFullpath().cStr() match = re.match(".*phase_([^/]+)/", texPath) if (match): texPhase = float(match.groups()[0]) if (texPhase > basePhase): self.errorAccumulatorBuffer += "texture phase is higher than the models (%s, %s)\n" % ( path, texPath)