def enter(self): FSMState.enter(self) self.getGame().getInput().pushMappings('inventory') self.inventory = self.getGame().getInventory() self.inventoryView = self.getGame().getView().getInventoryView() self.inventoryView.redraw() self.inventoryView.clearText() # self.inventoryView.enableDebugRendering() self.inventoryView.show()
def enter(self): FSMState.enter(self) self.drawDebugViz = self.game.getConfig().getBool( PanoConstants.CVAR_DEBUG_HOTSPOTS, False) self.game.getInput().addMappings('explore') self.sounds = self.game.getSoundsFx() if self.activeNode is None: self.changeDisplayNode(self.game.getInitialNode()) else: self.changeDisplayNode(self.activeNode.name)
def enter(self): FSMState.enter(self) self.getGame().getInput().pushMappings('paused') # read config config = self.game.getConfig() self.msgKey = config.get(PanoConstants.CVAR_PAUSED_STATE_MESSAGE) self.fontName = config.get(PanoConstants.CVAR_PAUSED_STATE_FONT) self.fgColor = config.getVec4(PanoConstants.CVAR_PAUSED_STATE_FGCOLOR) self.scale = config.getFloat(PanoConstants.CVAR_PAUSED_STATE_SCALE) # translate message and font i18n = self.game.getI18n() localizedFont = i18n.getLocalizedFont(self.fontName) fontPath = self.game.getResources().getResourceFullPath( PanoConstants.RES_TYPE_FONTS, localizedFont) # if font is None, then Panda3D will use a default built-in font font = loader.loadFont(fontPath) self.translatedText = i18n.translate(self.msgKey) self.getMessenger().sendMessage(PanoConstants.EVENT_GAME_PAUSED) music = self.getGame().getMusic() self.wasMusicPlaying = not (music.isPaused() or music.isStopped()) music.setPaused(True) self.getGame().getView().panoRenderer.pauseAnimations() self.getGame().getView().mousePointer.hide() if self.textParent == None: self.textParent = aspect2d.attachNewNode("pausedText") if self.textNode == None: self.textNode = OnscreenText(text=self.translatedText, pos=(0.0, 0.0), scale=self.scale, fg=self.fgColor, align=TextNode.ACenter, font=font, parent=self.textParent, mayChange=False) self.textParent.show()
def enter(self): FSMState.enter(self) self.game.getView().fadeOut(1.0) self._configure() globalClock.setMode(ClockObject.MSlave) # create alpha mask that fades the top and bottom img = PNMImage(8, 8) img.addAlpha() img.fill(1) img.alphaFill(1) for x in range(img.getXSize()): for y in range(img.getYSize()): img.setAlpha( x, y, -.2 + 2.5 * math.sin(math.pi * y / img.getYSize())) self.alphaMask = img # create texture for applying the alpha mask self.tex = Texture() self.tex.load(self.alphaMask) self.tex.setWrapU(Texture.WMClamp) self.tex.setWrapV(Texture.WMClamp) # create scenegraph self.scene = NodePath('credits_scene_root') self.scene.setDepthTest(False) self.scene.setDepthWrite(False) self.textParent = self.scene.attachNewNode('text_parent') ts = TextureStage('') self.textParent.setTexGen(ts, TexGenAttrib.MWorldPosition) self.textParent.setTexScale(ts, .5, .5) self.textParent.setTexOffset(ts, .5, .5) self.textParent.setTexture(ts, self.tex) # background self.backgroundOSI = OnscreenImage( self.game.getResources().getResourceFullPath( PanoConstants.RES_TYPE_TEXTURES, self.background), parent=render2d) # create credits text i18n = self.game.getI18n() localizedFont = i18n.getLocalizedFont(self.fontName) fontPath = self.game.getResources().getResourceFullPath( PanoConstants.RES_TYPE_FONTS, localizedFont) fontRes = loader.loadFont(fontPath) self.creditsOST = TextNode('creditsTextNode') crNP = self.textParent.attachNewNode(self.creditsOST) crNP.setScale(self.fontScale * PandaUtil.getFontPixelPerfectScale(fontRes)) self.creditsOST.setFont(fontRes) self.creditsOST.setEncoding(TextEncoder.EUtf8) self.creditsOST.setText(self.credits) self.creditsOST.setTextColor( Vec4(self.fontColor[0], self.fontColor[1], self.fontColor[2], self.fontColor[3])) self.creditsOST.setAlign(TextNode.ACenter) crNP.setP(-90) crNP.flattenLight() b3 = self.textParent.getTightBounds() dims = b3[1] - b3[0] pixels = PandaUtil.unitsToPixelsY(dims[1] + 2.0 - 1.05) self.scrollTime = pixels / self.scrollSpeed self.log.debug('time to scroll: %f' % self.scrollTime) self.scrollInterval = LerpPosInterval(self.textParent, self.scrollTime, Point3(0, dims[1] + 2, 0), Point3(0, -1.05, 0)) # render scene through an orthographic camera self.camera = Camera('credits_camera') lens = OrthographicLens() lens.setFilmSize(2, 2) lens.setNearFar(-1000, 1000) self.camera.setLens(lens) self.camNP = NodePath(self.camera) self.camNP.reparentTo(self.scene) self.camNP.setP(-90) self.displayRegion = self.game.getView().getWindow().makeDisplayRegion( ) self.displayRegion.setClearColor(Vec4(0, 0, 0, 1)) self.displayRegion.setCamera(self.camNP) self.displayRegion.setSort(20) self.game.getInput().addMappings('credits') self.game.getView().fadeIn(.5) self.scrollInterval.start() globalClock.setMode(ClockObject.MNormal) if self.playlist is not None: self.game.getMusic().setPlaylist( self.game.getResources().loadPlaylist(self.playlist)) self.game.getMusic().play()
def enter(self): FSMState.enter(self) self.log.debug('entered console state') self.getGame().getInput().pushMappings('console')