def drawChatBalloon(self, model, modelWidth, modelHeight): if self.chatFont is None: # We can't draw this without a font. return if self.isClickable(): foreground, background = self.chatColor[self.clickState] else: foreground, background = self.chatColor[PGButton.SInactive] if self.chatType == NametagGlobals.SPEEDCHAT: background = self.speedChatColor if background[3] > self.CHAT_BALLOON_ALPHA: background = VBase4(background[0], background[1], background[2], self.CHAT_BALLOON_ALPHA) self.chatBalloon = ChatBalloon(model, modelWidth, modelHeight, self.chatTextNode, foreground=foreground, background=background, reversed=self.chatReversed, button=self.chatButton[self.clickState]) self.chatBalloon.reparentTo(self.contents) # Chat balloon Popup Effect # TODO: Anim toggle self.chatBalloon.setScale(0, 0, 0) Sequence( self.chatBalloon.scaleInterval(.2, VBase3(1.1, 1.1, 1.1), blendType='easeInOut'), self.chatBalloon.scaleInterval(.09, VBase3(1, 1, 1), blendType='easeInOut')).start()
def draw(self): if self.isClickable(): foreground, background = self.whisperColor[self.clickState] else: foreground, background = self.whisperColor[PGButton.SInactive] self.chatBalloon = ChatBalloon(NametagGlobals.chatBalloon2dModel, NametagGlobals.chatBalloon2dWidth, NametagGlobals.chatBalloon2dHeight, self.textNode, foreground=foreground, background=background) self.chatBalloon.reparentTo(self.contents) left, right, bottom, top = self.textNode.getFrameActual() center = self.contents.getRelativePoint(self.chatBalloon.textNodePath, ((left + right) / 2.0, 0, (bottom + top) / 2.0)) self.chatBalloon.setPos(self.chatBalloon, -center) self.quitButton = WhisperQuitButton(self) quitButtonNodePath = self.contents.attachNewNode(self.quitButton) quitButtonNodePath.setPos(self.contents.getRelativePoint(self.chatBalloon.textNodePath, (right, 0, top))) quitButtonNodePath.setPos(quitButtonNodePath, self.QUIT_BUTTON_SHIFT) self.quitButton.setClickEvent(self.quitEvent) Parallel(LerpColorScaleInterval(self.contents, 0.2, VBase4(1, 1, 1, 1), VBase4(1, 1, 1, 0)), Sequence(LerpScaleInterval(self.contents, 0.2, self.CONTENTS_SCALE + 0.01, 0), LerpScaleInterval(self.contents, 0.09, self.CONTENTS_SCALE))).start()
def drawChatBalloon(self, model, modelWidth, modelHeight): if self.chatFont is None: # We can't draw this without a font. return # Prefix the nametag text: self.chatTextNode.setText(self.getText() + ': ' + self.actualChatText) # Set our priority in the margin system: self.setPriority(MarginGlobals.MP_normal) if self.textNodePath is not None: self.textNodePath.removeNode() self.textNodePath = None if self.arrow is not None: self.arrow.removeNode() self.arrow = None if self.isClickable(): foreground, background = self.chatColor[self.clickState] else: foreground, background = self.chatColor[PGButton.SInactive] if self.chatType == NametagGlobals.SPEEDCHAT: background = self.speedChatColor if background[3] > self.CHAT_BALLOON_ALPHA: background = VBase4(background[0], background[1], background[2], self.CHAT_BALLOON_ALPHA) self.chatBalloon = ChatBalloon(model, modelWidth, modelHeight, self.chatTextNode, foreground=foreground, background=background, reversed=self.chatReversed, button=self.chatButton[self.clickState]) self.chatBalloon.reparentTo(self.contents) # Calculate the center of the TextNode: left, right, bottom, top = self.chatTextNode.getFrameActual() center = self.contents.getRelativePoint(self.chatBalloon.textNodePath, ((left + right) / 2.0, 0, (bottom + top) / 2.0)) # Translate the chat balloon along the inverse: self.chatBalloon.setPos(self.chatBalloon, -center)
def draw(self): if self.isClickable(): foreground, background = self.whisperColor[self.clickState] else: foreground, background = self.whisperColor[PGButton.SInactive] self.chatBalloon = ChatBalloon(NametagGlobals.chatBalloon2dModel, NametagGlobals.chatBalloon2dWidth, NametagGlobals.chatBalloon2dHeight, self.textNode, foreground=foreground, background=background) self.chatBalloon.reparentTo(self.contents) # Calculate the center of the TextNode: left, right, bottom, top = self.textNode.getFrameActual() center = self.contents.getRelativePoint(self.chatBalloon.textNodePath, ((left + right) / 2.0, 0, (bottom + top) / 2.0)) # Translate the chat balloon along the inverse: self.chatBalloon.setPos(self.chatBalloon, -center) # Draw the quit button: self.quitButton = WhisperQuitButton(self) quitButtonNodePath = self.contents.attachNewNode(self.quitButton) # Move the quit button to the top right of the TextNode: quitButtonNodePath.setPos( self.contents.getRelativePoint(self.chatBalloon.textNodePath, (right, 0, top))) # Apply the quit button shift: quitButtonNodePath.setPos(quitButtonNodePath, self.QUIT_BUTTON_SHIFT) # Allow the quit button to close this whisper: self.quitButton.setClickEvent(self.quitEvent) Parallel( LerpColorScaleInterval(self.contents, .2, VBase4(1, 1, 1, 1), VBase4(1, 1, 1, 0)), Sequence( LerpScaleInterval(self.contents, .2, (self.CONTENTS_SCALE + 0.01), (0)), LerpScaleInterval(self.contents, .09, (self.CONTENTS_SCALE)))).start()
def drawChatBalloon(self, model, modelWidth, modelHeight): if self.chatFont is None: # We can't draw this without a font. return if self.isClickable(): foreground, background = self.chatColor[self.clickState] else: foreground, background = self.chatColor[PGButton.SInactive] if self.chatType == NametagGlobals.SPEEDCHAT: background = self.speedChatColor if background[3] > self.CHAT_BALLOON_ALPHA: background = VBase4( background[0], background[1], background[2], self.CHAT_BALLOON_ALPHA) self.chatBalloon = ChatBalloon( model, modelWidth, modelHeight, self.chatTextNode, foreground=foreground, background=background, reversed=self.chatReversed, button=self.chatButton[self.clickState]) self.chatBalloon.reparentTo(self.contents)
def draw(self): if self.isClickable(): foreground, background = self.whisperColor[self.clickState] else: foreground, background = self.whisperColor[PGButton.SInactive] self.chatBalloon = ChatBalloon(NametagGlobals.chatBalloon2dModel, NametagGlobals.chatBalloon2dWidth, NametagGlobals.chatBalloon2dHeight, self.textNode, foreground=foreground, background=background) self.chatBalloon.reparentTo(self.contents) # Calculate the center of the TextNode: left, right, bottom, top = self.textNode.getFrameActual() center = self.contents.getRelativePoint(self.chatBalloon.textNodePath, ((left + right) / 2.0, 0, (bottom + top) / 2.0)) # Translate the chat balloon along the inverse: self.chatBalloon.setPos(self.chatBalloon, -center)