def setEmbeddedFrameMode(self, access): if not self.hasEmbedded: return False if access == OTPGlobals.AccessVelvetRope: if launcher.getValue('GAME_SHOW_ADDS') != 'NO': self.inAdFrame = True return embedded.isMainWindowVisible() or self.showEmbeddedFrame() else: self.inAdFrame = False if embedded.isMainWindowVisible(): return self.hideEmbeddedFrame()
def setEmbeddedFrameMode(self, access): if not self.hasEmbedded: return False if access == OTPGlobals.AccessVelvetRope and launcher.getValue('GAME_SHOW_ADDS') != 'NO': self.inAdFrame = True if not embedded.isMainWindowVisible(): return self.showEmbeddedFrame() else: self.inAdFrame = False if embedded.isMainWindowVisible(): return self.hideEmbeddedFrame()
def __init__(self): OTPBase.__init__(self, windowType='none') self.hasEmbedded = hasEmbedded self.shipFactory = ShipFactory.ShipFactory(phasedLoading=True) self.isMainWindowOpen = False if __dev__: launcher.setValue('GAME_SHOW_ADDS', 'NO') if base.appRunner: launcher.setValue('GAME_SHOW_ADDS', 'NO') self.fourthOfJuly = base.config.GetBool('test-fourth-of-july', 0) if self.hasEmbedded: self.inAdFrame = embedded.isMainWindowVisible() else: self.inAdFrame = False self.bamCache = BamCache.getGlobalPtr() if self.config.GetBool('want-dev', 0): flavor = self.config.GetString('dev-branch-flavor', '') if flavor: cachePath = '/c/cache_%s' % (flavor, ) else: cachePath = '/c/cache' self.bamCache.setRoot(Filename(cachePath)) else: self.bamCache.setRoot(Filename('./cache')) self.bamCache.setActive(False) self.bamCache.setActive(True) self.bamCache.setCacheModels(False) self.bamCache.setCacheTextures(True) self.bamCache.setCacheCompressedTextures(True) base.effectsRoot = render.attachNewNode('Effects Root') self.musicMgr = None use_recommended_options = False options = Options() if __dev__: Options.DEFAULT_FILE_PATH = Filename.expandFrom( '$HOME/game_options.txt').toOsSpecific() Options.DEFAULT_API_FILE_PATH = Filename.expandFrom( '$HOME/game_api.txt').toOsSpecific() Options.WORKING_FILE_PATH = Filename.expandFrom( '$HOME/last_working_options.txt').toOsSpecific() Options.POSSIBLE_WORKING_FILE_PATH = Filename.expandFrom( '$HOME/p_working_options.txt').toOsSpecific() options_loaded = options.load(Options.DEFAULT_FILE_PATH) self.notify.info('Requested graphics API = %s' % options.api) if options.api == 'default' and self.config.GetBool( 'use-graphics-api-auto-select', True): base.makeDefaultPipe() options.automaticGraphicsApiSelection(base.pipe) self.notify.info('Auto-selected graphics API = %s' % options.api) if options.api in self.apiNames: selection = GraphicsPipeSelection.getGlobalPtr() pipe = selection.makeModulePipe(options.api) if pipe: base.pipe = pipe self.notify.info('Loaded requested graphics %s' % base.pipe.getType().getName()) if not base.pipe: base.makeDefaultPipe() if not base.pipe: self.notify.error('Could not find any graphics API.') self.notify.info('Loaded default graphics %s' % base.pipe.getType().getName()) bits_per_pixel = 32 if self.inAdFrame: self.getVelvetDisplayResolutions(bits_per_pixel, base.pipe) else: self.getDisplayResolutions(bits_per_pixel, base.pipe) if options_loaded: print 'state = %s' % options.state if __dev__: options.save(Options.DEFAULT_FILE_PATH, Options.WORKING_STATE) elif options.state == Options.DEFAULT_STATE or options.state == Options.NEW_STATE: options.save(Options.DEFAULT_FILE_PATH, Options.ATTEMPT_STATE) elif options.state == Options.ATTEMPT_STATE: working_options = Options() if working_options.load(Options.WORKING_FILE_PATH): options = working_options working_options.save(Options.DEFAULT_FILE_PATH, Options.ATTEMPT_WORKING_STATE) else: options.config_to_options() use_recommended_options = True elif options.state == Options.WORKING_STATE: options.save(Options.DEFAULT_FILE_PATH, Options.ATTEMPT_STATE) elif options.state == Options.ATTEMPT_WORKING_STATE: options.config_to_options() use_recommended_options = True else: options.save(Options.DEFAULT_FILE_PATH, Options.ATTEMPT_STATE) options.log('Loaded Game Options') else: options.config_to_options() if base.config.GetBool('want-dev', False): pass 1 use_recommended_options = True if use_recommended_options: options.recommendedOptions(base.pipe, False) options.log('Recommended Game Options') overwrite_options = True options.verifyOptions(base.pipe, overwrite_options) string = options.optionsToPrcData() loadPrcFileData('game_options', string) self.options = options self.shipsVisibleFromIsland = self.options.ocean_visibility self.overrideShipVisibility = False base.windowType = 'onscreen' self.detachedWP = WindowProperties() self.embeddedWP = WindowProperties() if self.hasEmbedded: if embedded.isMainWindowVisible(): self.showEmbeddedFrame() else: self.hideEmbeddedFrame() elif self.appRunner: self.openDefaultWindow() else: wp = WindowProperties() wp.setSize(options.getWidth(), options.getHeight()) wp.setFullscreen(options.getFullscreen()) self.openDefaultWindow(props=wp) self.eventMgr.doEvents() loadingMode = config.GetInt('loading-screen', 0) if loadingMode == 0: self.loadingScreen = LoadingScreen.LoadingScreen(None) else: self.loadingScreen = FancyLoadingScreen.FancyLoadingScreen(None) self.loadingScreen.showTarget(pickapirate=True) self.loadingScreen.show() if not self.isMainWindowOpen: try: launcher.setPandaErrorCode(7) except: pass sys.exit(1) options.options_to_config() options.setRuntimeOptions() if base.wantEnviroDR: base.cam.node().setCameraMask(OTPRender.MainCameraBitmask) self.setupEnviroCamera() self.setupAutoPixelZoom() else: base.cam.node().setCameraMask(OTPRender.MainCameraBitmask | OTPRender.EnviroCameraBitmask) self._PiratesBase__alreadyExiting = False self.exitFunc = self.userExit TextureStage.getDefault().setPriority(10) self.useDrive() self.disableMouse() #if self.mouseInterface: # self.mouseInterface.reparentTo(self.dataUnused) #if base.mouse2cam: # self.mouse2cam.reparentTo(self.dataUnused) if not base.config.GetBool('location-kiosk', 0): for key in PiratesGlobals.ScreenshotHotkeyList: self.accept(key, self.takeScreenShot) self.screenshotViewer = None if base.config.GetBool('want-screenshot-viewer', 0): self.accept(PiratesGlobals.ScreenshotViewerHotkey, self.showScreenshots) self.wantMarketingViewer = base.config.GetBool('want-marketing-viewer', 0) self.marketingViewerOn = False if self.wantMarketingViewer: for key in PiratesGlobals.MarketingHotkeyList: self.accept(key, self.toggleMarketingViewer) self.accept('panda3d-render-error', self.panda3dRenderError) camera.setPosHpr(0, 0, 0, 0, 0, 0) self.camLens.setMinFov(PiratesGlobals.DefaultCameraFov) self.camLens.setNearFar(PiratesGlobals.DefaultCameraNear, PiratesGlobals.DefaultCameraFar) farCullNode = PlaneNode('farCull') farCullNode.setPlane(Plane(Vec3(0, -1, 0), Point3(0, 0, 0))) farCullNode.setClipEffect(0) self.farCull = camera.attachNewNode(farCullNode) self.positionFarCull() globalClockMaxDt = base.config.GetFloat('pirates-max-dt', 0.20000000000000001) globalClock.setMaxDt(globalClockMaxDt) if self.config.GetBool('want-particles', 1): self.notify.debug('Enabling particles') self.enableParticles() self.notify.debug('Enabling new ship controls') self.avatarPhysicsMgr = PhysicsManager() integrator = LinearEulerIntegrator() self.avatarPhysicsMgr.attachLinearIntegrator(integrator) integrator = AngularEulerIntegrator() self.avatarPhysicsMgr.attachAngularIntegrator(integrator) self.taskMgr.add(self.doAvatarPhysics, 'physics-avatar') fn = ForceNode('ship viscosity') fnp = NodePath(fn) fnp.reparentTo(render) viscosity = LinearFrictionForce(0.0, 1.0, 0) viscosity.setCoef(0.5) viscosity.setAmplitude(2) fn.addForce(viscosity) self.avatarPhysicsMgr.addLinearForce(viscosity) fn = ForceNode('avatarControls') fnp = NodePath(fn) fnp.reparentTo(render) controlForce = LinearControlForce() self.controlForce = controlForce controlForce.setAmplitude(5) fn.addForce(controlForce) self.avatarPhysicsMgr.addLinearForce(controlForce) self.accept('PandaPaused', self.disableAllAudio) self.accept('PandaRestarted', self.enableAllAudio) self.emoteGender = None shadow = loader.loadModel('models/misc/drop_shadow.bam') taskMgr.setupTaskChain('phasePost', numThreads=0, threadPriority=TPHigh) #launcher.addPhasePostProcess(3, self.phase3Post, taskChain = 'phasePost') #launcher.addPhasePostProcess(4, self.phase4Post, taskChain = 'phasePost') #launcher.addPhasePostProcess(5, self.phase5Post, taskChain = 'phasePost') self.whiteList = PWhiteList() tpMgr = TextPropertiesManager.getGlobalPtr() WLDisplay = TextProperties() WLDisplay.setSlant(0.29999999999999999) WLEnter = TextProperties() WLEnter.setTextColor(1.0, 0.0, 0.0, 1) tpMgr.setProperties('WLDisplay', WLDisplay) tpMgr.setProperties('WLEnter', WLEnter) del tpMgr CullBinManager.getGlobalPtr().addBin('ShipRigging', CullBinEnums.BTBackToFront, 52) CullBinManager.getGlobalPtr().addBin('pre-additive', CullBinEnums.BTFixed, 53) CullBinManager.getGlobalPtr().addBin('additive', CullBinEnums.BTBackToFront, 54) self.showShipFlats = False self.hideShipNametags = False self.showGui = True self.memoryMonitorMinimumPercentage = 90 self.cpuSpeedDialog = None self.peakProcessMemory = 0 self.peakMemoryLoad = 0 self.maximumCpuFrequency = 0 self.currentCpuFrequency = 0 self.displayCpuFrequencyDialog = False self.taskMgr.doMethodLater(120.0, self.memoryMonitorTask, 'memory-monitor-task') self.useStencils = self.win.getGsg().getSupportsStencil() self.supportAlphaFb = self.win.getFbProperties().getAlphaBits() taskMgr.setupTaskChain('background', frameBudget=0.001, threadPriority=TPLow) gsg = base.win.getGsg() if gsg.getShaderModel() < gsg.SM20: base.options.shader_runtime = 0 self.noticeSystemOn = 1 self.lodTrav = CollisionTraverser('base.lodTrav') self.zoneLODEventHandler = CollisionHandlerEvent() self.zoneLODEventHandler.addInPattern('enter%in') self.zoneLODEventHandler.addOutPattern('exit%in') self.zoneLODTarget = None self.transitions.loadLetterbox() self.transitions.letterbox.setColorScale(0, 0, 0, 1)
def __init__(self): OTPBase.__init__(self, windowType = 'none') self.hasEmbedded = hasEmbedded self.shipFactory = ShipFactory.ShipFactory(phasedLoading = True) self.isMainWindowOpen = False if __dev__: launcher.setValue('GAME_SHOW_ADDS', 'NO') if base.appRunner: launcher.setValue('GAME_SHOW_ADDS', 'NO') self.fourthOfJuly = base.config.GetBool('test-fourth-of-july', 0) if self.hasEmbedded: self.inAdFrame = embedded.isMainWindowVisible() else: self.inAdFrame = False self.bamCache = BamCache.getGlobalPtr() if self.config.GetBool('want-dev', 0): flavor = self.config.GetString('dev-branch-flavor', '') if flavor: cachePath = '/c/cache_%s' % (flavor,) else: cachePath = '/c/cache' self.bamCache.setRoot(Filename(cachePath)) else: self.bamCache.setRoot(Filename('./cache')) self.bamCache.setActive(False) self.bamCache.setActive(True) self.bamCache.setCacheModels(False) self.bamCache.setCacheTextures(True) self.bamCache.setCacheCompressedTextures(True) base.effectsRoot = render.attachNewNode('Effects Root') self.musicMgr = None use_recommended_options = False options = Options() if __dev__: print ("PiratesBase: Developer mode enabled.") print (Filename.expandFrom('$HOME/game_options.txt').toOsSpecific()) Options.DEFAULT_FILE_PATH = Filename.expandFrom('$HOME/game_options.txt').toOsSpecific() Options.DEFAULT_API_FILE_PATH = Filename.expandFrom('$HOME/game_api.txt').toOsSpecific() Options.WORKING_FILE_PATH = Filename.expandFrom('$HOME/last_working_options.txt').toOsSpecific() Options.POSSIBLE_WORKING_FILE_PATH = Filename.expandFrom('$HOME/p_working_options.txt').toOsSpecific() options_loaded = options.load(Options.DEFAULT_FILE_PATH) self.notify.info('Requested graphics API = %s' % options.api) if options.api == 'default' and self.config.GetBool('use-graphics-api-auto-select', True): base.makeDefaultPipe() options.automaticGraphicsApiSelection(base.pipe) self.notify.info('Auto-selected graphics API = %s' % options.api) if options.api in self.apiNames: selection = GraphicsPipeSelection.getGlobalPtr() pipe = selection.makeModulePipe(options.api) if pipe: base.pipe = pipe self.notify.info('Loaded requested graphics %s' % base.pipe.getType().getName()) if not base.pipe: base.makeDefaultPipe() if not base.pipe: self.notify.error('Could not find any graphics API.') self.notify.info('Loaded default graphics %s' % base.pipe.getType().getName()) bits_per_pixel = 32 if self.inAdFrame: self.getVelvetDisplayResolutions(bits_per_pixel, base.pipe) else: self.getDisplayResolutions(bits_per_pixel, base.pipe) if options_loaded: print 'state = %s' % options.state if __dev__: options.save(Options.DEFAULT_FILE_PATH, Options.WORKING_STATE) elif options.state == Options.DEFAULT_STATE or options.state == Options.NEW_STATE: options.save(Options.DEFAULT_FILE_PATH, Options.ATTEMPT_STATE) elif options.state == Options.ATTEMPT_STATE: working_options = Options() if working_options.load(Options.WORKING_FILE_PATH): options = working_options working_options.save(Options.DEFAULT_FILE_PATH, Options.ATTEMPT_WORKING_STATE) else: options.config_to_options() use_recommended_options = True elif options.state == Options.WORKING_STATE: options.save(Options.DEFAULT_FILE_PATH, Options.ATTEMPT_STATE) elif options.state == Options.ATTEMPT_WORKING_STATE: options.config_to_options() use_recommended_options = True else: options.save(Options.DEFAULT_FILE_PATH, Options.ATTEMPT_STATE) options.log('Loaded Game Options') else: options.config_to_options() if base.config.GetBool('want-dev', False): pass 1 use_recommended_options = True if use_recommended_options: options.recommendedOptions(base.pipe, False) options.log('Recommended Game Options') overwrite_options = True options.verifyOptions(base.pipe, overwrite_options) string = options.optionsToPrcData() loadPrcFileData('game_options', string) self.options = options self.shipsVisibleFromIsland = self.options.ocean_visibility self.overrideShipVisibility = False base.windowType = 'onscreen' self.detachedWP = WindowProperties() self.embeddedWP = WindowProperties() if self.hasEmbedded: if embedded.isMainWindowVisible(): self.showEmbeddedFrame() else: self.hideEmbeddedFrame() elif self.appRunner: self.openDefaultWindow() else: wp = WindowProperties() wp.setSize(options.getWidth(), options.getHeight()) wp.setFullscreen(options.getFullscreen()) self.openDefaultWindow(props = wp) self.eventMgr.doEvents() loadingMode = config.GetInt('loading-screen', 0) if loadingMode == 0: self.loadingScreen = LoadingScreen.LoadingScreen(None) else: self.loadingScreen = FancyLoadingScreen.FancyLoadingScreen(None) self.loadingScreen.showTarget(pickapirate = True) self.loadingScreen.show() if not self.isMainWindowOpen: try: launcher.setPandaErrorCode(7) except: pass sys.exit(1) options.options_to_config() options.setRuntimeOptions() if base.wantEnviroDR: base.cam.node().setCameraMask(OTPRender.MainCameraBitmask) self.setupEnviroCamera() self.setupAutoPixelZoom() else: base.cam.node().setCameraMask(OTPRender.MainCameraBitmask | OTPRender.EnviroCameraBitmask) self._PiratesBase__alreadyExiting = False self.exitFunc = self.userExit TextureStage.getDefault().setPriority(10) self.useDrive() self.disableMouse() #if self.mouseInterface: # self.mouseInterface.reparentTo(self.dataUnused) #if base.mouse2cam: # self.mouse2cam.reparentTo(self.dataUnused) if not base.config.GetBool('location-kiosk', 0): for key in PiratesGlobals.ScreenshotHotkeyList: self.accept(key, self.takeScreenShot) self.screenshotViewer = None if base.config.GetBool('want-screenshot-viewer', 0): self.accept(PiratesGlobals.ScreenshotViewerHotkey, self.showScreenshots) self.wantMarketingViewer = base.config.GetBool('want-marketing-viewer', 0) self.marketingViewerOn = False if self.wantMarketingViewer: for key in PiratesGlobals.MarketingHotkeyList: self.accept(key, self.toggleMarketingViewer) self.accept('panda3d-render-error', self.panda3dRenderError) camera.setPosHpr(0, 0, 0, 0, 0, 0) self.camLens.setMinFov(PiratesGlobals.DefaultCameraFov) self.camLens.setNearFar(PiratesGlobals.DefaultCameraNear, PiratesGlobals.DefaultCameraFar) farCullNode = PlaneNode('farCull') farCullNode.setPlane(Plane(Vec3(0, -1, 0), Point3(0, 0, 0))) farCullNode.setClipEffect(0) self.farCull = camera.attachNewNode(farCullNode) self.positionFarCull() globalClockMaxDt = base.config.GetFloat('pirates-max-dt', 0.20000000000000001) globalClock.setMaxDt(globalClockMaxDt) if self.config.GetBool('want-particles', 1): self.notify.debug('Enabling particles') self.enableParticles() self.notify.debug('Enabling new ship controls') self.avatarPhysicsMgr = PhysicsManager() integrator = LinearEulerIntegrator() self.avatarPhysicsMgr.attachLinearIntegrator(integrator) integrator = AngularEulerIntegrator() self.avatarPhysicsMgr.attachAngularIntegrator(integrator) self.taskMgr.add(self.doAvatarPhysics, 'physics-avatar') fn = ForceNode('ship viscosity') fnp = NodePath(fn) fnp.reparentTo(render) viscosity = LinearFrictionForce(0.0, 1.0, 0) viscosity.setCoef(0.5) viscosity.setAmplitude(2) fn.addForce(viscosity) self.avatarPhysicsMgr.addLinearForce(viscosity) fn = ForceNode('avatarControls') fnp = NodePath(fn) fnp.reparentTo(render) controlForce = LinearControlForce() self.controlForce = controlForce controlForce.setAmplitude(5) fn.addForce(controlForce) self.avatarPhysicsMgr.addLinearForce(controlForce) self.accept('PandaPaused', self.disableAllAudio) self.accept('PandaRestarted', self.enableAllAudio) self.emoteGender = None shadow = loader.loadModel('models/misc/drop_shadow.bam') taskMgr.setupTaskChain('phasePost', numThreads = 0, threadPriority = TPHigh) #launcher.addPhasePostProcess(3, self.phase3Post, taskChain = 'phasePost') #launcher.addPhasePostProcess(4, self.phase4Post, taskChain = 'phasePost') #launcher.addPhasePostProcess(5, self.phase5Post, taskChain = 'phasePost') self.whiteList = PWhiteList() tpMgr = TextPropertiesManager.getGlobalPtr() WLDisplay = TextProperties() WLDisplay.setSlant(0.29999999999999999) WLEnter = TextProperties() WLEnter.setTextColor(1.0, 0.0, 0.0, 1) tpMgr.setProperties('WLDisplay', WLDisplay) tpMgr.setProperties('WLEnter', WLEnter) del tpMgr CullBinManager.getGlobalPtr().addBin('ShipRigging', CullBinEnums.BTBackToFront, 52) CullBinManager.getGlobalPtr().addBin('pre-additive', CullBinEnums.BTFixed, 53) CullBinManager.getGlobalPtr().addBin('additive', CullBinEnums.BTBackToFront, 54) self.showShipFlats = False self.hideShipNametags = False self.showGui = True self.memoryMonitorMinimumPercentage = 90 self.cpuSpeedDialog = None self.peakProcessMemory = 0 self.peakMemoryLoad = 0 self.maximumCpuFrequency = 0 self.currentCpuFrequency = 0 self.displayCpuFrequencyDialog = False self.taskMgr.doMethodLater(120.0, self.memoryMonitorTask, 'memory-monitor-task') self.useStencils = self.win.getGsg().getSupportsStencil() self.supportAlphaFb = self.win.getFbProperties().getAlphaBits() taskMgr.setupTaskChain('background', frameBudget = 0.001, threadPriority = TPLow) gsg = base.win.getGsg() if gsg.getShaderModel() < gsg.SM20: base.options.shader_runtime = 0 self.noticeSystemOn = 1 self.lodTrav = CollisionTraverser('base.lodTrav') self.zoneLODEventHandler = CollisionHandlerEvent() self.zoneLODEventHandler.addInPattern('enter%in') self.zoneLODEventHandler.addOutPattern('exit%in') self.zoneLODTarget = None self.transitions.loadLetterbox() self.transitions.letterbox.setColorScale(0, 0, 0, 1)