def announceWinner(self, winString, avId): if avId == base.localAvatar.getDoId(): sound = Sequence(Wait(2.0), Parallel(SoundInterval(self.winSound), SoundInterval(self.happyDance))) sound.start() base.cr.playGame.getPlace().setState('walk') if winString == 'Chinese Checkers': whisper = WhisperPopup(TTLocalizer.ChineseCheckersYouWon, OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal) elif winString == 'Checkers': whisper = WhisperPopup(TTLocalizer.RegularCheckersYouWon, OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal) elif winString == 'Find Four': whisper = WhisperPopup('You won a game of Find Four!', OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal) elif self.cr.doId2do.has_key(avId): stateString = self.fsm.getCurrentState().getName() if stateString == 'sitting' or stateString == 'observing': base.cr.playGame.getPlace().setState('walk') av = self.cr.doId2do[avId] if winString == 'Chinese Checkers': whisper = WhisperPopup(av.getName() + TTLocalizer.ChineseCheckersGameOf + TTLocalizer.ChineseCheckers, OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal) elif winString == 'Checkers': whisper = WhisperPopup(av.getName() + TTLocalizer.RegularCheckersGameOf + TTLocalizer.RegularCheckers, OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal) elif winString == 'Find Four': whisper = WhisperPopup(av.getName() + ' has won a game of' + ' Find Four!', OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal) if self.cr.doId2do.has_key(avId): toon = self.cr.doId2do[avId] self.winTrack = Sequence(autoFinish=1) if self.outTrack.isPlaying(): self.winTrack.append(Wait(2.0)) if avId == base.localAvatar.getDoId(): self.winTrack.append(Func(self.stopToWalk)) self.winTrack.append(ActorInterval(toon, 'happy-dance')) if avId == base.localAvatar.getDoId(): self.winTrack.append(Func(self.allowToWalk)) self.winTrack.start() whisper.manage(base.marginManager)
def __init__(self, other = None): self.name = '' try: self.Avatar_initialized return except: self.Avatar_initialized = 1 Actor.__init__(self, None, None, other, flattenable=0, setFinal=0) ShadowCaster.__init__(self) self.__font = OTPGlobals.getInterfaceFont() self.__speechFont = OTPGlobals.getInterfaceFont() self.soundChatBubble = None self.avatarType = '' self.nametagNodePath = None self.__nameVisible = 1 self.nametag = NametagGroup() self.nametag.setAvatar(self) self.nametag.setFont(OTPGlobals.getInterfaceFont()) self.nametag.setSpeechFont(OTPGlobals.getInterfaceFont()) self.nametag2dContents = Nametag.CName | Nametag.CSpeech self.nametag2dDist = Nametag.CName | Nametag.CSpeech self.nametag2dNormalContents = Nametag.CName | Nametag.CSpeech self.nametag3d = self.attachNewNode('nametag3d') self.nametag3d.setTag('cam', 'nametag') self.nametag3d.setLightOff() if self.ManagesNametagAmbientLightChanged: self.acceptNametagAmbientLightChange() OTPRender.renderReflection(False, self.nametag3d, 'otp_avatar_nametag', None) self.getGeomNode().showThrough(OTPRender.ShadowCameraBitmask) self.nametag3d.hide(OTPRender.ShadowCameraBitmask) self.collTube = None self.battleTube = None self.scale = 1.0 self.nametagScale = 1.0 self.height = 0.0 self.battleTubeHeight = 0.0 self.battleTubeRadius = 0.0 self.style = None self.commonChatFlags = 0 self.understandable = 1 self.setPlayerType(NametagGroup.CCNormal) self.ghostMode = 0 self.__chatParagraph = None self.__chatMessage = None self.__chatFlags = 0 self.__chatPageNumber = None self.__chatAddressee = None self.__chatDialogueList = [] self.__chatSet = 0 self.__chatLocal = 0 self.__currentDialogue = None self.whitelistChatFlags = 0 self.wantAdminTag = True return
def __createNametag(self, parent): if self.nametagGroup == None: self.nametagGroup = NametagGroup() interfaceFont = OTPGlobals.getInterfaceFont() self.nametagGroup.setFont(interfaceFont) self.nametagGroup.setChatFont(interfaceFont) self.nametagGroup.setActive(False) self.nametagGroup.setAvatar(self.partyPlannerHead) self.nametagGroup.manage(base.marginManager) nametagColor = NametagGlobals.NametagColors[NametagGlobals.CCNonPlayer] self.nametagGroup.setNametagColor(nametagColor) self.nametagGroup.setArrowColor(nametagColor) chatColor = NametagGlobals.ChatColors[NametagGlobals.CCNonPlayer] self.nametagGroup.setChatColor(chatColor) nametag2d = self.nametagGroup.getNametag2d() nametag2d.hideNametag() nametag2d.hideChat() self.nametagNode = NametagFloat2d() self.nametagNode.hideChat() self.nametagGroup.add(self.nametagNode) self.nametagGroup.setText(base.cr.partyManager.getPartyPlannerName()) self.nametagNP = parent.attachNewNode(self.nametagNode) nametagPos = self.gui.find('**/step_01_partymanPeteNametag_locator').getPos() self.nametagNP.setPosHprScale(nametagPos[0], 0, nametagPos[2], 0, 0, 0, 0.1, 1, 0.1) self.chatNode = NametagFloat2d() self.chatNode.hideNametag() self.chatNode.showThought() self.nametagGroup.add(self.chatNode) self.nametagGroup.setChatText(TTLocalizer.PartyPlannerInstructions) self.chatNP = parent.attachNewNode(self.chatNode) chatPos = self.gui.find('**/step_01_partymanPeteText_locator').getPos() self.chatNP.setPosHprScale(chatPos[0], 0, chatPos[2], 0, 0, 0, 0.08, 1, 0.08) self.nametagGroup.updateAll()
def tie(self): self.tieSequence = Sequence(autoFinish=1) self.clockNode.stop() self.clockNode.hide() self.isMyTurn = False self.moveSequence.finish() if self.turnText: self.turnText.hide() for x in range(41): self.tieSequence.append( Parallel( LerpColorInterval( self.locatorList[x], 0.14999999999999999, Vec4(0.5, 0.5, 0.5, 0.5), Vec4(1, 1, 1, 1) ), LerpColorInterval( self.locatorList[x], 0.14999999999999999, Vec4(1, 1, 1, 1), Vec4(0.5, 0.5, 0.5, 0.5) ), ) ) whisper = WhisperPopup( "This Find Four game has resulted in a Tie!", OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal ) whisper.manage(base.marginManager) self.tieSequence.start()
def __init__(self, entryOptions, parent = None, **kw): FSM.FSM.__init__(self, 'ChatInputWhiteListFrame') self.receiverId = None DirectFrame.__init__(self, parent=aspect2dp, pos=(0, 0, 0.3), relief=None, image=DGG.getDefaultDialogGeom(), image_scale=(1.6, 1, 1.4), image_pos=(0, 0, -0.05), image_color=OTPGlobals.GlobalDialogColor, borderWidth=(0.01, 0.01)) optiondefs = {'parent': self, 'relief': DGG.SUNKEN, 'scale': 0.05, 'frameSize': (-0.2, 25.3, -0.5, 1.2), 'borderWidth': (0.1, 0.1), 'frameColor': (0.9, 0.9, 0.85, 0.8), 'pos': (-0.2, 0, 0.11), 'entryFont': OTPGlobals.getInterfaceFont(), 'width': 8.6, 'numLines': 3, 'cursorKeys': 1, 'backgroundFocus': 0, 'suppressKeys': 1, 'suppressMouse': 1, 'command': self.sendChat, 'focus': 0, 'text': '', 'sortOrder': DGG.FOREGROUND_SORT_INDEX} entryOptions['parent'] = self self.chatEntry = DirectEntry(**entryOptions) self.whisperId = None self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow) self.active = 0 self.autoOff = 0 self.sendBy = 'Mode' from direct.gui import DirectGuiGlobals self.chatEntry.bind(DirectGuiGlobals.TYPE, self.applyFilter) self.chatEntry.bind(DirectGuiGlobals.ERASE, self.applyFilter)
def loadSign(self): actNameForSign = self.activityName if self.activityId == PartyGlobals.ActivityIds.PartyJukebox40: actNameForSign = PartyGlobals.ActivityIds.getString(PartyGlobals.ActivityIds.PartyJukebox) elif self.activityId == PartyGlobals.ActivityIds.PartyDance20: actNameForSign = PartyGlobals.ActivityIds.getString(PartyGlobals.ActivityIds.PartyDance) self.sign = self.root.attachNewNode('%sSign' % self.activityName) self.signModel = self.party.defaultSignModel.copyTo(self.sign) self.signFlat = self.signModel.find('**/sign_flat') self.signFlatWithNote = self.signModel.find('**/sign_withNote') self.signTextLocator = self.signModel.find('**/signText_locator') textureNodePath = getPartyActivityIcon(self.party.activityIconsModel, actNameForSign) textureNodePath.setPos(0.0, -0.02, 2.2) textureNodePath.setScale(2.35) textureNodePath.copyTo(self.signFlat) textureNodePath.copyTo(self.signFlatWithNote) text = TextNode('noteText') text.setTextColor(0.2, 0.1, 0.7, 1.0) text.setAlign(TextNode.ACenter) text.setFont(OTPGlobals.getInterfaceFont()) text.setWordwrap(10.0) text.setText('') self.noteText = self.signFlatWithNote.attachNewNode(text) self.noteText.setPosHpr(self.signTextLocator, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0) self.noteText.setScale(0.2) self.signFlatWithNote.stash() self.signTextLocator.stash()
def systemMessage(self, message): whisper = WhisperPopup(message, OTPGlobals.getInterfaceFont(), WTSystem) whisper.manage(base.marginManager) if self.systemMessageSfx is None: self.systemMessageSfx = base.loadSfx('phase_3/audio/sfx/clock03.ogg') base.playSfx(self.systemMessageSfx)
def getFontByName(self, fontname): if fontname == 'default': return TextNode.getDefaultFont() elif fontname == 'interface': return OTPGlobals.getInterfaceFont() elif fontname == 'sign': return OTPGlobals.getSignFont() else: return None
def getFontByName(self, fontname): if fontname == "default": return TextNode.getDefaultFont() elif fontname == "interface": return OTPGlobals.getInterfaceFont() elif fontname == "sign": return OTPGlobals.getSignFont() else: return None return None
def __init__(self, entryOptions, parent = None, **kw): FSM.FSM.__init__(self, 'ChatInputWhiteListFrame') self.okayToSubmit = True self.receiverId = None DirectFrame.__init__(self, parent = aspect2dp, pos = (0, 0, 0.29999999999999999), relief = None, image = DGG.getDefaultDialogGeom(), image_scale = (1.6000000000000001, 1, 1.3999999999999999), image_pos = (0, 0, -0.050000000000000003), image_color = OTPGlobals.GlobalDialogColor, borderWidth = (0.01, 0.01)) optiondefs = { 'parent': self, 'relief': DGG.SUNKEN, 'scale': 0.050000000000000003, 'frameSize': (-0.20000000000000001, 25.300000000000001, -0.5, 1.2), 'borderWidth': (0.10000000000000001, 0.10000000000000001), 'frameColor': (0.90000000000000002, 0.90000000000000002, 0.84999999999999998, 0.80000000000000004), 'pos': (-0.20000000000000001, 0, 0.11), 'entryFont': OTPGlobals.getInterfaceFont(), 'width': 8.5999999999999996, 'numLines': 3, 'cursorKeys': 1, 'backgroundFocus': 0, 'suppressKeys': 1, 'suppressMouse': 1, 'command': self.sendChat, 'failedCommand': self.sendFailed, 'focus': 0, 'text': '', 'sortOrder': DGG.FOREGROUND_SORT_INDEX } entryOptions['parent'] = self self.chatEntry = DirectEntry(**None) self.whisperId = None self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow) wantHistory = 0 if __dev__: wantHistory = 1 self.wantHistory = base.config.GetBool('want-chat-history', wantHistory) self.history = [ ''] self.historySize = base.config.GetInt('chat-history-size', 10) self.historyIndex = 0 self.promoteWhiteList = 0 self.checkBeforeSend = base.config.GetBool('white-list-check-before-send', 0) self.whiteList = None self.active = 0 self.autoOff = 0 self.sendBy = 'Mode' self.prefilter = 1 DirectGuiGlobals = DirectGuiGlobals import direct.gui self.chatEntry.bind(DirectGuiGlobals.TYPE, self.applyFilter) self.chatEntry.bind(DirectGuiGlobals.ERASE, self.applyFilter) tpMgr = TextPropertiesManager.getGlobalPtr() Red = tpMgr.getProperties('red') Red.setTextColor(1.0, 0.0, 0.0, 1) tpMgr.setProperties('WLRed', Red) del tpMgr self.origFrameColor = self.chatEntry['frameColor']
def displayWhisper(self, fromId, chatString, whisperType): sender = None sfx = self.soundWhisper if whisperType == WTNormal or whisperType == WTQuickTalker: if sender == None: return chatString = sender.getName() + ': ' + chatString whisper = WhisperPopup(chatString, OTPGlobals.getInterfaceFont(), whisperType) if sender != None: whisper.setClickable(sender.getName(), fromId) whisper.manage(base.marginManager) base.playSfx(sfx)
def __init__(self, chatMgr): ChatInputNormal.ChatInputNormal.__init__(self, chatMgr) gui = loader.loadModel('phase_3.5/models/gui/chat_input_gui') self.chatFrame = DirectFrame( parent=aspect2dp, image=gui.find('**/Chat_Bx_FNL'), relief=None, pos=(-1.083, 0, 0.804), state=DGG.NORMAL, sortOrder=DGG.FOREGROUND_SORT_INDEX) self.chatFrame.hide() self.chatButton = DirectButton( parent=self.chatFrame, image=(gui.find('**/ChtBx_ChtBtn_UP'), gui.find('**/ChtBx_ChtBtn_DN'), gui.find('**/ChtBx_ChtBtn_RLVR')), pos=(0.182, 0, -0.088), relief=None, text=('', OTPLocalizer.ChatInputNormalSayIt, OTPLocalizer. ChatInputNormalSayIt), text_scale=0.06, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.09), textMayChange=0, command=self.chatButtonPressed) self.cancelButton = DirectButton( parent=self.chatFrame, image=(gui.find('**/CloseBtn_UP'), gui.find('**/CloseBtn_DN'), gui.find('**/CloseBtn_Rllvr')), pos=(-0.151, 0, -0.088), relief=None, text=('', OTPLocalizer.ChatInputNormalCancel, OTPLocalizer. ChatInputNormalCancel), text_scale=0.06, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.09), textMayChange=0, command=self.cancelButtonPressed) self.whisperLabel = DirectLabel( parent=self.chatFrame, pos=(0.02, 0, 0.23), relief=DGG.FLAT, frameColor=(1, 1, 0.5, 1), frameSize=(-0.23, 0.23, -0.07, 0.05), text=OTPLocalizer.ChatInputNormalWhisper, text_scale=0.04, text_fg=Vec4(0, 0, 0, 1), text_wordwrap=9.5, textMayChange=1) self.whisperLabel.hide() self.chatEntry = DirectEntry( parent=self.chatFrame, relief=None, scale=0.05, pos=(-0.2, 0, 0.11), entryFont=OTPGlobals.getInterfaceFont(), width=8.6, numLines=3, cursorKeys=0, backgroundFocus=0, command=self.sendChat) self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow) self.chatEntry.bind(DGG.TYPE, self.typeCallback) return
def __init__(self, other = None): Actor.__init__(self, None, None, other, flattenable=0, setFinal=1) ShadowCaster.__init__(self) self.__font = OTPGlobals.getInterfaceFont() self.name = '' self.soundChatBubble = None self.avatarType = '' self.nametagNodePath = None self.__nameVisible = 1 self.nametag = NametagGroup() self.nametag.setAvatar(self) self.nametag.setFont(OTPGlobals.getInterfaceFont()) self.nametag.setSpeechFont(OTPGlobals.getInterfaceFont()) self.nametag2dContents = Nametag.CName | Nametag.CSpeech self.nametag2dDist = Nametag.CName | Nametag.CSpeech self.nametag2dNormalContents = Nametag.CName | Nametag.CSpeech self.nametag3d = self.attachNewNode('nametag3d') self.nametag3d.setTag('cam', 'nametag') self.nametag3d.setLightOff() self.getGeomNode().showThrough(OTPRender.ShadowCameraBitmask) self.nametag3d.hide(OTPRender.ShadowCameraBitmask) self.collTube = None self.scale = 1.0 self.height = 0.0 self.style = None self.understandable = 1 self.setPlayerType(NametagGroup.CCNormal) self.ghostMode = 0 self.__chatParagraph = None self.__chatMessage = None self.__chatFlags = 0 self.__chatPageNumber = None self.__chatAddressee = None self.__chatDialogueList = [] self.__chatSet = 0 self.__chatLocal = 0 self.__currentDialogue = None self.wantAdminTag = True
def displayWhisperPlayer(self, fromId, chatString, whisperType): sender = None playerInfo = None sfx = self.soundWhisper playerInfo = base.cr.playerFriendsManager.playerId2Info.get(fromId, None) if playerInfo == None: return senderName = playerInfo.playerName if whisperType == WTNormal or whisperType == WTQuickTalker: chatString = senderName + ': ' + chatString whisper = WhisperPopup(chatString, OTPGlobals.getInterfaceFont(), whisperType) if sender != None: whisper.setClickable(senderName, fromId) whisper.manage(base.marginManager) base.playSfx(sfx)
def displayWhisper(self, fromId, chatString, whisperType): sender = None if isinstance(fromId, numbers.Number): sender = base.cr.identifyAvatar(fromId) if whisperType == WTNormal: chatString = '%s: %s' % (sender.getName(), chatString) whisper = WhisperPopup(chatString, OTPGlobals.getInterfaceFont(), whisperType) if sender or isinstance(fromId, basestring): whisper.setClickable(fromId) whisper.manage(base.marginManager) base.playSfx(self.soundSystemMessage if whisperType == WTSystem else self.soundWhisper)
def __init__(self, parent = None, **kw): entryOptions = {'parent': self, 'relief': DGG.SUNKEN, 'scale': 0.05, 'frameColor': (0.9, 0.9, 0.85, 0.0), 'pos': (-0.2, 0, 0.11), 'entryFont': OTPGlobals.getInterfaceFont(), 'width': 8.6, 'numLines': 3, 'cursorKeys': 0, 'backgroundFocus': 0, 'suppressKeys': 0, 'suppressMouse': 1, 'command': self.sendChat, 'failedCommand': self.sendFailed, 'focus': 0, 'text': '', 'sortOrder': DGG.FOREGROUND_SORT_INDEX} ChatInputWhiteListFrame.__init__(self, entryOptions, parent, **kw) self.whiteList = TTWhiteList() base.whiteList = self.whiteList base.ttwl = self self.autoOff = 1 self.sendBy = 'Data' self.prefilter = 0 self.promoteWhiteList = 1 self.typeGrabbed = 0 self.deactivate() gui = loader.loadModel('phase_3.5/models/gui/chat_input_gui') self.chatFrame = DirectFrame(parent=self, image=gui.find('**/Chat_Bx_FNL'), relief=None, pos=(0.0, 0, 0.0), state=DGG.NORMAL) self.chatButton = DirectButton(parent=self.chatFrame, image=(gui.find('**/ChtBx_ChtBtn_UP'), gui.find('**/ChtBx_ChtBtn_DN'), gui.find('**/ChtBx_ChtBtn_RLVR')), pos=(0.182, 0, -0.088), relief=None, text=('', OTPLocalizer.ChatInputNormalSayIt, OTPLocalizer.ChatInputNormalSayIt), text_scale=0.06, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.09), textMayChange=0, command=self.chatButtonPressed) self.cancelButton = DirectButton(parent=self.chatFrame, image=(gui.find('**/CloseBtn_UP'), gui.find('**/CloseBtn_DN'), gui.find('**/CloseBtn_Rllvr')), pos=(-0.151, 0, -0.088), relief=None, text=('', OTPLocalizer.ChatInputNormalCancel, OTPLocalizer.ChatInputNormalCancel), text_scale=0.06, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.09), textMayChange=0, command=self.cancelButtonPressed) self.whisperLabel = DirectLabel(parent=self.chatFrame, pos=(0.02, 0, 0.23), relief=DGG.FLAT, frameColor=(1, 1, 0.5, 1), frameSize=(-0.23, 0.23, -0.07, 0.05), text=OTPLocalizer.ChatInputNormalWhisper, text_scale=0.04, text_fg=Vec4(0, 0, 0, 1), text_wordwrap=9.5, textMayChange=1) self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow) self.chatEntry.bind(DGG.TYPE, self.typeCallback) self.trueFriendChat = 0 if base.config.GetBool('whisper-to-nearby-true-friends', 1): self.accept(self.TFToggleKey, self.shiftPressed) return
def finalize(self, dbArgs = { }): if not self.isDirty(): return None SCObject.finalize(self) if hasattr(self, 'button'): self.button.destroy() del self.button halfHeight = self.height / 2.0 textX = 0 if dbArgs.has_key('text_align'): if dbArgs['text_align'] == TextNode.ACenter: textX = self.width / 2.0 args = { 'text': self.getDisplayText(), 'frameColor': (0, 0, 0, 0), 'rolloverColor': self.getColorScheme().getRolloverColor() + (1,), 'pressedColor': self.getColorScheme().getPressedColor() + (1,), 'text_font': OTPGlobals.getInterfaceFont(), 'text_align': TextNode.ALeft, 'text_fg': self.getColorScheme().getTextColor() + (1,), 'text_pos': (textX, -0.25 - halfHeight, 0), 'relief': DGG.FLAT, 'pressEffect': 0 } args.update(dbArgs) rolloverColor = args['rolloverColor'] pressedColor = args['pressedColor'] del args['rolloverColor'] del args['pressedColor'] btn = DirectButton(parent = self, frameSize = (0, self.width, -(self.height), 0), **None) btn.frameStyle[DGG.BUTTON_ROLLOVER_STATE].setColor(*rolloverColor) btn.frameStyle[DGG.BUTTON_DEPRESSED_STATE].setColor(*pressedColor) btn.updateFrameStyle() btn.bind(DGG.ENTER, self.onMouseEnter) btn.bind(DGG.EXIT, self.onMouseLeave) btn.bind(DGG.B1PRESS, self.onMouseClick) self.button = btn self.lastWidth = self.width self.lastHeight = self.height self.validate()
def systemMessage(self, code, params): # First, format message: msg = OTPLocalizer.CRSystemMessages.get(code) if not msg: self.notify.warning('Got invalid system-message code: %d' % code) return try: message = msg % tuple(params) except TypeError: self.notify.warning( 'Got invalid parameters for system-message %d: %r' % (code, params)) return whisper = WhisperPopup(message, OTPGlobals.getInterfaceFont(), WhisperPopup.WTSystem) whisper.manage(base.marginManager) if not self.systemMessageSfx: self.systemMessageSfx = base.loadSfx('phase_3/audio/sfx/clock03.ogg') if self.systemMessageSfx: base.playSfx(self.systemMessageSfx)
def __createNametag(self, parent): if self.nametagGroup == None: self.nametagGroup = NametagGroup() self.nametagGroup.setFont(OTPGlobals.getInterfaceFont()) self.nametagGroup.setActive(0) self.nametagGroup.setAvatar(self.partyPlannerHead) self.nametagGroup.manage(base.marginManager) self.nametagGroup.setColorCode(self.nametagGroup.CCNonPlayer) self.nametagGroup.getNametag2d().setContents(0) self.nametagNode = NametagFloat2d() self.nametagNode.setContents(Nametag.CName) self.nametagGroup.addNametag(self.nametagNode) self.nametagGroup.setName(base.cr.partyManager.getPartyPlannerName()) self.nametagNP = parent.attachNewNode(self.nametagNode.upcastToPandaNode()) nametagPos = self.gui.find('**/step_01_partymanPeteNametag_locator').getPos() self.nametagNP.setPosHprScale(nametagPos[0], 0, nametagPos[2], 0, 0, 0, 0.1, 1, 0.1) self.chatNode = NametagFloat2d() self.chatNode.setContents(Nametag.CSpeech | Nametag.CThought) self.nametagGroup.addNametag(self.chatNode) self.nametagGroup.setChat(TTLocalizer.PartyPlannerInstructions, CFSpeech) self.chatNP = parent.attachNewNode(self.chatNode.upcastToPandaNode()) chatPos = self.gui.find('**/step_01_partymanPeteText_locator').getPos() self.chatNP.setPosHprScale(chatPos[0], 0, chatPos[2], 0, 0, 0, 0.08, 1, 0.08) return
def __init__(self, chatMgr): ChatInputNormal.ChatInputNormal.__init__(self, chatMgr) gui = loader.loadModel('phase_3.5/models/gui/chat_input_gui') self.chatFrame = DirectFrame(parent=aspect2dp, image=gui.find('**/Chat_Bx_FNL'), relief=None, pos=(-1.083, 0, 0.80400000000000005), state=DGG.NORMAL, sortOrder=DGG.FOREGROUND_SORT_INDEX) self.chatFrame.hide() self.chatButton = DirectButton( parent=self.chatFrame, image=(gui.find('**/ChtBx_ChtBtn_UP'), gui.find('**/ChtBx_ChtBtn_DN'), gui.find('**/ChtBx_ChtBtn_RLVR')), pos=(0.182, 0, -0.087999999999999995), relief=None, text=('', OTPLocalizer.ChatInputNormalSayIt, OTPLocalizer.ChatInputNormalSayIt), text_scale=0.059999999999999998, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.089999999999999997), textMayChange=0, command=self.chatButtonPressed) self.cancelButton = DirectButton( parent=self.chatFrame, image=(gui.find('**/CloseBtn_UP'), gui.find('**/CloseBtn_DN'), gui.find('**/CloseBtn_Rllvr')), pos=(-0.151, 0, -0.087999999999999995), relief=None, text=('', OTPLocalizer.ChatInputNormalCancel, OTPLocalizer.ChatInputNormalCancel), text_scale=0.059999999999999998, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.089999999999999997), textMayChange=0, command=self.cancelButtonPressed) self.whisperLabel = DirectLabel( parent=self.chatFrame, pos=(0.02, 0, 0.23000000000000001), relief=DGG.FLAT, frameColor=(1, 1, 0.5, 1), frameSize=(-0.23000000000000001, 0.23000000000000001, -0.070000000000000007, 0.050000000000000003), text=OTPLocalizer.ChatInputNormalWhisper, text_scale=0.040000000000000001, text_fg=Vec4(0, 0, 0, 1), text_wordwrap=9.5, textMayChange=1) self.whisperLabel.hide() self.chatEntry = DirectEntry(parent=self.chatFrame, relief=None, scale=0.050000000000000003, pos=(-0.20000000000000001, 0, 0.11), entryFont=OTPGlobals.getInterfaceFont(), width=8.5999999999999996, numLines=3, cursorKeys=0, backgroundFocus=0, command=self.sendChat) self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow) self.chatEntry.bind(DGG.TYPE, self.typeCallback)
def __init__(self, parent=None, **kw): entryOptions = { "parent": self, "relief": DGG.SUNKEN, "scale": 0.050000000000000003, "frameColor": (0.90000000000000002, 0.90000000000000002, 0.84999999999999998, 0.0), "pos": (-0.20000000000000001, 0, 0.11), "entryFont": OTPGlobals.getInterfaceFont(), "width": 8.5999999999999996, "numLines": 3, "cursorKeys": 0, "backgroundFocus": 0, "suppressKeys": 0, "suppressMouse": 1, "command": self.sendChat, "failedCommand": self.sendFailed, "focus": 0, "text": "", "sortOrder": DGG.FOREGROUND_SORT_INDEX, } ChatInputWhiteListFrame.__init__(self, entryOptions, parent, **None) self.whiteList = TTWhiteList() base.whiteList = self.whiteList base.ttwl = self self.autoOff = 1 self.sendBy = "Data" self.prefilter = 0 self.promoteWhiteList = 1 self.typeGrabbed = 0 self.deactivate() gui = loader.loadModel("phase_3.5/models/gui/chat_input_gui") self.chatFrame = DirectFrame( parent=self, image=gui.find("**/Chat_Bx_FNL"), relief=None, pos=(0.0, 0, 0.0), state=DGG.NORMAL ) self.chatButton = DirectButton( parent=self.chatFrame, image=(gui.find("**/ChtBx_ChtBtn_UP"), gui.find("**/ChtBx_ChtBtn_DN"), gui.find("**/ChtBx_ChtBtn_RLVR")), pos=(0.182, 0, -0.087999999999999995), relief=None, text=("", OTPLocalizer.ChatInputNormalSayIt, OTPLocalizer.ChatInputNormalSayIt), text_scale=0.059999999999999998, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.089999999999999997), textMayChange=0, command=self.chatButtonPressed, ) self.cancelButton = DirectButton( parent=self.chatFrame, image=(gui.find("**/CloseBtn_UP"), gui.find("**/CloseBtn_DN"), gui.find("**/CloseBtn_Rllvr")), pos=(-0.151, 0, -0.087999999999999995), relief=None, text=("", OTPLocalizer.ChatInputNormalCancel, OTPLocalizer.ChatInputNormalCancel), text_scale=0.059999999999999998, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.089999999999999997), textMayChange=0, command=self.cancelButtonPressed, ) self.whisperLabel = DirectLabel( parent=self.chatFrame, pos=(0.02, 0, 0.23000000000000001), relief=DGG.FLAT, frameColor=(1, 1, 0.5, 1), frameSize=(-0.23000000000000001, 0.23000000000000001, -0.070000000000000007, 0.050000000000000003), text=OTPLocalizer.ChatInputNormalWhisper, text_scale=0.040000000000000001, text_fg=Vec4(0, 0, 0, 1), text_wordwrap=9.5, textMayChange=1, ) self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow) self.chatEntry.bind(DGG.TYPE, self.typeCallback) self.trueFriendChat = 0 if base.config.GetBool("whisper-to-nearby-true-friends", 1): self.accept(self.TFToggleKey, self.shiftPressed)
def __init__(self, chatMgr): ChatInputNormal.ChatInputNormal.__init__(self, chatMgr) # load the chat balloon gui = loader.loadModel("phase_3.5/models/gui/chat_input_gui") self.chatFrame = DirectFrame( parent=aspect2dp, image=gui.find("**/Chat_Bx_FNL"), relief=None, pos=(-1.083, 0, 0.804), state=DGG.NORMAL, sortOrder=DGG.FOREGROUND_SORT_INDEX, ) self.chatFrame.hide() self.chatButton = DirectButton( parent=self.chatFrame, image=( gui.find("**/ChtBx_ChtBtn_UP"), gui.find("**/ChtBx_ChtBtn_DN"), gui.find("**/ChtBx_ChtBtn_RLVR"), ), pos=(0.182, 0, -0.088), relief=None, text=("", OTPLocalizer.ChatInputNormalSayIt, OTPLocalizer.ChatInputNormalSayIt), text_scale=0.06, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.09), textMayChange=0, command=self.chatButtonPressed, ) self.cancelButton = DirectButton( parent=self.chatFrame, image=( gui.find("**/CloseBtn_UP"), gui.find("**/CloseBtn_DN"), gui.find("**/CloseBtn_Rllvr"), ), pos=(-0.151, 0, -0.088), relief=None, text=("", OTPLocalizer.ChatInputNormalCancel, OTPLocalizer.ChatInputNormalCancel), text_scale=0.06, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.09), textMayChange=0, command=self.cancelButtonPressed, ) self.whisperLabel = DirectLabel( parent=self.chatFrame, pos=(0.02, 0, 0.23), relief=DGG.FLAT, frameColor=(1, 1, 0.5, 1), frameSize=(-0.23, 0.23, -0.07, 0.05), text=OTPLocalizer.ChatInputNormalWhisper, text_scale=0.04, text_fg=Vec4(0, 0, 0, 1), text_wordwrap=9.5, textMayChange=1, ) self.whisperLabel.hide() self.chatEntry = DirectEntry( parent=self.chatFrame, relief=None, scale=0.05, pos=(-0.2, 0, 0.11), entryFont=OTPGlobals.getInterfaceFont(), width=8.6, numLines=3, cursorKeys=0, backgroundFocus=0, # This will be turned on later by the chatMgr command=self.sendChat, ) self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow) self.chatEntry.bind(DGG.TYPE, self.typeCallback)
def __init__(self, parent = None, **kw): FSM.FSM.__init__(self, 'PChatInputTyped') optiondefs = (('parent', parent, None), ('relief', DGG.SUNKEN, None), ('scale', 0.029999999999999999, None), ('frameSize', (-0.20000000000000001, 25.300000000000001, -0.5, 1.2), None), ('borderWidth', (0.10000000000000001, 0.10000000000000001), None), ('frameColor', (0.90000000000000002, 0.90000000000000002, 0.84999999999999998, 0.80000000000000004), None), ('entryFont', OTPGlobals.getInterfaceFont(), None), ('width', 25, None), ('numLines', 1, None), ('cursorKeys', 1, None), ('backgroundFocus', 0, None), ('suppressKeys', 1, None), ('suppressMouse', 1, None), ('command', self.sendChat, None), ('focus', 0, None), ('text', '', None)) self.defineoptions(kw, optiondefs) DirectEntry.__init__(self, parent = parent, **None) self.initialiseoptions(PChatInputTyped) self.whisperId = None self.bind(DGG.OVERFLOW, self.chatOverflow) self.bind(DGG.ERASE, self.chatErased) wantHistory = 0 if __dev__: wantHistory = 1 if not __dev__ and base.config.GetBool('exec-chat', 0) and localAvatar.isGM() and base.cr.wantMagicWords: pass self.wantHistory = base.config.GetBool('want-chat-history', wantHistory) self.history = [ ''] self.historySize = base.config.GetInt('chat-history-size', 10) self.historyIndex = 0 self.wantSlidingWindow = base.config.GetBool('want-sliding-chat', 1) self.maxSavedLength = 100 self.slideDistance = 10 self.savedStringLeft = '' self.savedStringRight = '' self.fillToLength = 0
def whisperFrom(self, fromId, message): if base.cr.wantSwitchboardHacks: print 'received whisper on avatar: %s' % message whisper = WhisperPopup(message, OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal) whisper.manage(base.marginManager)
class SCElement(SCObject, NodePath): __module__ = __name__ font = OTPGlobals.getInterfaceFont() SerialNum = 0 def __init__(self, parentMenu=None): SCObject.__init__(self) self.SerialNum = SCElement.SerialNum SCElement.SerialNum += 1 node = hidden.attachNewNode('SCElement%s' % self.SerialNum) NodePath.__init__(self, node) self.FinalizeTaskName = 'SCElement%s_Finalize' % self.SerialNum self.parentMenu = parentMenu self.__active = 0 self.__viewable = 1 self.lastWidth = 0 self.lastHeight = 0 self.setDimensions(0, 0) self.padX = 0.25 self.padZ = 0.1 def destroy(self): if self.isActive(): self.exitActive() SCObject.destroy(self) if hasattr(self, 'button'): self.button.destroy() del self.button self.parentMenu = None self.detachNode() return def setParentMenu(self, parentMenu): self.parentMenu = parentMenu def getParentMenu(self): return self.parentMenu def getDisplayText(self): self.notify.error( 'getDisplayText is pure virtual, derived class must override') def onMouseEnter(self, event): if self.parentMenu is not None: self.parentMenu.memberGainedInputFocus(self) return def onMouseLeave(self, event): if self.parentMenu is not None: self.parentMenu.memberLostInputFocus(self) return def onMouseClick(self, event): pass def enterActive(self): self.__active = 1 def exitActive(self): self.__active = 0 def isActive(self): return self.__active def hasStickyFocus(self): return 0 def setViewable(self, viewable): if not boolEqual(self.__viewable, viewable): self.__viewable = viewable if self.parentMenu is not None: self.parentMenu.memberViewabilityChanged(self) return def isViewable(self): return self.__viewable def getMinDimensions(self): text = TextNode('SCTemp') text.setFont(SCElement.font) dText = self.getDisplayText() text.setText(dText) bounds = text.getCardActual() width = abs(bounds[1] - bounds[0]) + self.padX height = abs(bounds[3] - bounds[2]) + 2.0 * self.padZ return (width, height) def setDimensions(self, width, height): self.width = float(width) self.height = float(height) if (self.lastWidth, self.lastHeight) != (self.width, self.height): self.invalidate() def invalidate(self): SCObject.invalidate(self) parentMenu = self.getParentMenu() if parentMenu is not None: if not parentMenu.isFinalizing(): parentMenu.invalidate() return def enterVisible(self): SCObject.enterVisible(self) self.privScheduleFinalize() def exitVisible(self): SCObject.exitVisible(self) self.privCancelFinalize() def privScheduleFinalize(self): def finalizeElement(task, self=self): if self.parentMenu is not None: if self.parentMenu.isDirty(): return Task.done self.finalize() return Task.done taskMgr.remove(self.FinalizeTaskName) taskMgr.add(finalizeElement, self.FinalizeTaskName, priority=SCElementFinalizePriority) def privCancelFinalize(self): taskMgr.remove(self.FinalizeTaskName) def finalize(self, dbArgs={}): if not self.isDirty(): return SCObject.finalize(self) if hasattr(self, 'button'): self.button.destroy() del self.button halfHeight = self.height / 2.0 textX = 0 if dbArgs.has_key('text_align'): if dbArgs['text_align'] == TextNode.ACenter: textX = self.width / 2.0 args = { 'text': self.getDisplayText(), 'frameColor': (0, 0, 0, 0), 'rolloverColor': self.getColorScheme().getRolloverColor() + (1, ), 'pressedColor': self.getColorScheme().getPressedColor() + (1, ), 'text_font': OTPGlobals.getInterfaceFont(), 'text_align': TextNode.ALeft, 'text_fg': self.getColorScheme().getTextColor() + (1, ), 'text_pos': (textX, -0.25 - halfHeight, 0), 'relief': DGG.FLAT, 'pressEffect': 0 } args.update(dbArgs) rolloverColor = args['rolloverColor'] pressedColor = args['pressedColor'] del args['rolloverColor'] del args['pressedColor'] btn = DirectButton(parent=self, frameSize=(0, self.width, -self.height, 0), **args) btn.frameStyle[DGG.BUTTON_ROLLOVER_STATE].setColor(*rolloverColor) btn.frameStyle[DGG.BUTTON_DEPRESSED_STATE].setColor(*pressedColor) btn.updateFrameStyle() btn.bind(DGG.ENTER, self.onMouseEnter) btn.bind(DGG.EXIT, self.onMouseLeave) btn.bind(DGG.B1PRESS, self.onMouseClick) self.button = btn self.lastWidth = self.width self.lastHeight = self.height self.validate() def __str__(self): return '%s: %s' % (self.__class__.__name__, self.getDisplayText())
def __init__(self, entryOptions, parent=None, **kw): FSM.FSM.__init__(self, 'ChatInputWhiteListFrame') self.okayToSubmit = True self.receiverId = None DirectFrame.__init__(self, parent=aspect2dp, pos=(0, 0, 0.29999999999999999), relief=None, image=DGG.getDefaultDialogGeom(), image_scale=(1.6000000000000001, 1, 1.3999999999999999), image_pos=(0, 0, -0.050000000000000003), image_color=OTPGlobals.GlobalDialogColor, borderWidth=(0.01, 0.01)) optiondefs = { 'parent': self, 'relief': DGG.SUNKEN, 'scale': 0.050000000000000003, 'frameSize': (-0.20000000000000001, 25.300000000000001, -0.5, 1.2), 'borderWidth': (0.10000000000000001, 0.10000000000000001), 'frameColor': (0.90000000000000002, 0.90000000000000002, 0.84999999999999998, 0.80000000000000004), 'pos': (-0.20000000000000001, 0, 0.11), 'entryFont': OTPGlobals.getInterfaceFont(), 'width': 8.5999999999999996, 'numLines': 3, 'cursorKeys': 1, 'backgroundFocus': 0, 'suppressKeys': 1, 'suppressMouse': 1, 'command': self.sendChat, 'failedCommand': self.sendFailed, 'focus': 0, 'text': '', 'sortOrder': DGG.FOREGROUND_SORT_INDEX } entryOptions['parent'] = self self.chatEntry = DirectEntry(**None) self.whisperId = None self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow) wantHistory = 0 if __dev__: wantHistory = 1 self.wantHistory = base.config.GetBool('want-chat-history', wantHistory) self.history = [''] self.historySize = base.config.GetInt('chat-history-size', 10) self.historyIndex = 0 self.promoteWhiteList = 0 self.checkBeforeSend = base.config.GetBool( 'white-list-check-before-send', 0) self.whiteList = None self.active = 0 self.autoOff = 0 self.sendBy = 'Mode' self.prefilter = 1 DirectGuiGlobals = DirectGuiGlobals import direct.gui self.chatEntry.bind(DirectGuiGlobals.TYPE, self.applyFilter) self.chatEntry.bind(DirectGuiGlobals.ERASE, self.applyFilter) tpMgr = TextPropertiesManager.getGlobalPtr() Red = tpMgr.getProperties('red') Red.setTextColor(1.0, 0.0, 0.0, 1) tpMgr.setProperties('WLRed', Red) del tpMgr self.origFrameColor = self.chatEntry['frameColor']
def messageParticipants(self, message): whisper = WhisperPopup(message, OTPGlobals.getInterfaceFont(), WTSystem) whisper.manage(base.marginManager)
def __init__(self, parent = None, **kw): entryOptions = { 'parent' : self, 'relief': DGG.SUNKEN, 'scale': 0.05, #'frameSize' : (-0.2, 25.3, -0.5, 1.2), #'borderWidth' : (0.1, 0.1), 'frameColor' : (0.9, 0.9, 0.85, 0.0), 'pos' : (-0.2,0,0.11), 'entryFont' : OTPGlobals.getInterfaceFont(), 'width': 8.6, 'numLines' : 3, 'cursorKeys' : 0, 'backgroundFocus' : 0, 'suppressKeys' : 0, 'suppressMouse' : 1, 'command' : self.sendChat, 'failedCommand': self.sendFailed, 'focus' : 0, 'text' : '', 'sortOrder' : DGG.FOREGROUND_SORT_INDEX, } ChatInputWhiteListFrame.__init__(self, entryOptions, parent, **kw) #self.initialiseoptions(TTChatInputWhiteList) self.whiteList = TTWhiteList() base.whiteList = self.whiteList base.ttwl = self self.autoOff = 1 self.sendBy = "Data" self.prefilter = 0 self.promoteWhiteList = 1 self.typeGrabbed = 0 #self.request("off") self.deactivate() gui = loader.loadModel("phase_3.5/models/gui/chat_input_gui") self.chatFrame = DirectFrame( parent = self, image = gui.find("**/Chat_Bx_FNL"), relief = None, pos = (0.0, 0, 0.0), state = DGG.NORMAL, #sortOrder = DGG.FOREGROUND_SORT_INDEX, ) #self.chatFrame.hide() self.chatButton = DirectButton( parent = self.chatFrame, image = (gui.find("**/ChtBx_ChtBtn_UP"), gui.find("**/ChtBx_ChtBtn_DN"), gui.find("**/ChtBx_ChtBtn_RLVR"), ), pos = (0.182, 0, -0.088), relief = None, text = ("", OTPLocalizer.ChatInputNormalSayIt, OTPLocalizer.ChatInputNormalSayIt), text_scale = 0.06, text_fg = Vec4(1,1,1,1), text_shadow = Vec4(0,0,0,1), text_pos = (0,-0.09), textMayChange = 0, command = self.chatButtonPressed, ) self.cancelButton = DirectButton( parent = self.chatFrame, image = (gui.find("**/CloseBtn_UP"), gui.find("**/CloseBtn_DN"), gui.find("**/CloseBtn_Rllvr"), ), pos = (-0.151, 0, -0.088), relief = None, text = ("", OTPLocalizer.ChatInputNormalCancel, OTPLocalizer.ChatInputNormalCancel), text_scale = 0.06, text_fg = Vec4(1,1,1,1), text_shadow = Vec4(0,0,0,1), text_pos = (0,-0.09), textMayChange = 0, command = self.cancelButtonPressed, ) self.whisperLabel = DirectLabel( parent = self.chatFrame, pos = (0.02, 0, 0.23), relief = DGG.FLAT, frameColor = (1,1,0.5,1), frameSize = (-0.23, 0.23, -0.07, 0.05), text = OTPLocalizer.ChatInputNormalWhisper, text_scale = 0.04, text_fg = Vec4(0,0,0,1), text_wordwrap = 9.5, textMayChange = 1, ) #self.whisperLabel.hide() #self.setPos(-0.35, 0.0, 0.7) self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow) self.chatEntry.bind(DGG.TYPE, self.typeCallback) # self.accept("typeEntryGrab", self.handleTypeGrab) self.trueFriendChat = 0 if ConfigVariableBool('whisper-to-nearby-true-friends', 1).getValue(): self.accept(self.TFToggleKey, self.shiftPressed)
def __init__(self, parent=None, **kw): entryOptions = { 'parent': self, 'relief': DGG.SUNKEN, 'scale': 0.05, 'frameColor': (0.9, 0.9, 0.85, 0.0), 'pos': (-0.2, 0, 0.11), 'entryFont': OTPGlobals.getInterfaceFont(), 'width': 8.6, 'numLines': 3, 'cursorKeys': 0, 'backgroundFocus': 0, 'suppressKeys': 0, 'suppressMouse': 1, 'command': self.sendChat, 'failedCommand': self.sendFailed, 'focus': 0, 'text': '', 'sortOrder': DGG.FOREGROUND_SORT_INDEX } ChatInputWhiteListFrame.__init__(self, entryOptions, parent, **kw) self.whiteList = TTWhiteList() base.whiteList = self.whiteList base.ttwl = self self.autoOff = 1 self.sendBy = 'Data' self.prefilter = 0 self.promoteWhiteList = 1 self.typeGrabbed = 0 self.deactivate() gui = loader.loadModel('phase_3.5/models/gui/chat_input_gui') self.chatFrame = DirectFrame(parent=self, image=gui.find('**/Chat_Bx_FNL'), relief=None, pos=(0.0, 0, 0.0), state=DGG.NORMAL) self.chatButton = DirectButton( parent=self.chatFrame, image=(gui.find('**/ChtBx_ChtBtn_UP'), gui.find('**/ChtBx_ChtBtn_DN'), gui.find('**/ChtBx_ChtBtn_RLVR')), pos=(0.182, 0, -0.088), relief=None, text=('', OTPLocalizer.ChatInputNormalSayIt, OTPLocalizer.ChatInputNormalSayIt), text_scale=0.06, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.09), textMayChange=0, command=self.chatButtonPressed) self.cancelButton = DirectButton( parent=self.chatFrame, image=(gui.find('**/CloseBtn_UP'), gui.find('**/CloseBtn_DN'), gui.find('**/CloseBtn_Rllvr')), pos=(-0.151, 0, -0.088), relief=None, text=('', OTPLocalizer.ChatInputNormalCancel, OTPLocalizer.ChatInputNormalCancel), text_scale=0.06, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.09), textMayChange=0, command=self.cancelButtonPressed) self.whisperLabel = DirectLabel( parent=self.chatFrame, pos=(0.02, 0, 0.23), relief=DGG.FLAT, frameColor=(1, 1, 0.5, 1), frameSize=(-0.23, 0.23, -0.07, 0.05), text=OTPLocalizer.ChatInputNormalWhisper, text_scale=0.04, text_fg=Vec4(0, 0, 0, 1), text_wordwrap=9.5, textMayChange=1) self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow) self.chatEntry.bind(DGG.TYPE, self.typeCallback) self.trueFriendChat = 0 if base.config.GetBool('whisper-to-nearby-true-friends', 1): self.accept(self.TFToggleKey, self.shiftPressed) return
def announceWinner(self, winString, avId): if avId == base.localAvatar.getDoId(): sound = Sequence( Wait(2.0), Parallel(SoundInterval(self.winSound), SoundInterval(self.happyDance))) sound.start() base.cr.playGame.getPlace().setState( 'walk') #To stop Cohesion between EmptySlot and AnnounceWin if winString == "Chinese Checkers": whisper = WhisperPopup(TTLocalizer.ChineseCheckersYouWon, OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal) elif winString == "Checkers": whisper = WhisperPopup(TTLocalizer.RegularCheckersYouWon, OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal) elif winString == "Find Four": whisper = WhisperPopup("You won a game of Find Four!", OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal) else: if self.cr.doId2do.has_key(avId): stateString = self.fsm.getCurrentState().getName() if stateString == "sitting" or stateString == "observing": base.cr.playGame.getPlace().setState( 'walk' ) #To stop Cohesion between EmptySlot and AnnounceWin av = self.cr.doId2do[avId] if winString == "Chinese Checkers": whisper = WhisperPopup( av.getName() + TTLocalizer.ChineseCheckersGameOf + TTLocalizer.ChineseCheckers, OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal) elif winString == "Checkers": whisper = WhisperPopup( av.getName() + TTLocalizer.RegularCheckersGameOf + TTLocalizer.RegularCheckers, OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal) elif winString == "Find Four": whisper = WhisperPopup( av.getName() + " has won a game of" + " Find Four!", OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal) if self.cr.doId2do.has_key(avId): # If the toon exists, look it up toon = self.cr.doId2do[avId] #self.winTrack.finish() self.winTrack = Sequence(autoFinish=1) if self.outTrack.isPlaying(): #If toon is jumping out Wait a self.winTrack.append( Wait(2.0)) # duration till his anim is over to begin if avId == base.localAvatar.getDoId(): #stop him from walking locally #otherwise he will animate around while moving on other clients self.winTrack.append(Func(self.stopToWalk)) self.winTrack.append(ActorInterval(toon, 'happy-dance')) if avId == base.localAvatar.getDoId(): self.winTrack.append(Func(self.allowToWalk)) self.winTrack.start() #Display the whisper message whisper.manage(base.marginManager)
def whisperFrom(self, fromId, message): if base.cr.wantSwitchboardHacks: print 'received whisper on avatar: %s' % message whisper = WhisperPopup(message, OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal) whisper.manage(base.marginManager)
def __init__(self, parent = None, **kw): FSM.FSM.__init__(self, 'ChatInputWhiteList') optiondefs = (('parent', parent, None), ('relief', DGG.SUNKEN, None), ('text_scale', 0.029999999999999999, None), ('frameSize', (-0.20000000000000001, 25.300000000000001, -0.5, 1.2), None), ('borderWidth', (0.0030000000000000001, 0.0030000000000000001), None), ('frameColor', (0.90000000000000002, 0.90000000000000002, 0.84999999999999998, 0.80000000000000004), None), ('entryFont', OTPGlobals.getInterfaceFont(), None), ('width', 25, None), ('numLines', 1, None), ('cursorKeys', 1, None), ('backgroundFocus', 0, None), ('suppressKeys', 1, None), ('suppressMouse', 1, None), ('command', self.sendChat, None), ('failedCommand', self.sendFailed, None), ('focus', 0, None), ('text', '', None)) self.defineoptions(kw, optiondefs) DirectEntry.__init__(self, parent = parent) self.initialiseoptions(ChatInputWhiteList) self.whisperId = None wantHistory = 0 if __dev__: wantHistory = 1 self.wantHistory = base.config.GetBool('want-chat-history', wantHistory) self.history = [ ''] self.historySize = base.config.GetInt('chat-history-size', 10) self.historyIndex = 0 self.whiteList = None self.active = 0 self.autoOff = 0 self.alwaysSubmit = False self.bind(DirectGuiGlobals.TYPE, self.applyFilter) self.bind(DirectGuiGlobals.ERASE, self.applyFilter) tpMgr = TextPropertiesManager.getGlobalPtr() Red = tpMgr.getProperties('red') Red.setTextColor(1.0, 0.0, 0.0, 1) tpMgr.setProperties('WLRed', Red) del tpMgr self.origFrameColor = self['frameColor'] self.origTextScale = self['text_scale'] self.origFrameSize = self['frameSize']
def messageParticipants(self, message): whisper = WhisperPopup(message, OTPGlobals.getInterfaceFont(), WTSystem) whisper.manage(base.marginManager)
def __init__(self, parent = None, **kw): FSM.FSM.__init__(self, 'ChatInputWhiteList') optiondefs = (('parent', parent, None), ('relief', DGG.SUNKEN, None), ('text_scale', 0.029999999999999999, None), ('frameSize', (-0.20000000000000001, 25.300000000000001, -0.5, 1.2), None), ('borderWidth', (0.0030000000000000001, 0.0030000000000000001), None), ('frameColor', (0.90000000000000002, 0.90000000000000002, 0.84999999999999998, 0.80000000000000004), None), ('entryFont', OTPGlobals.getInterfaceFont(), None), ('width', 25, None), ('numLines', 1, None), ('cursorKeys', 1, None), ('backgroundFocus', 0, None), ('suppressKeys', 1, None), ('suppressMouse', 1, None), ('command', self.sendChat, None), ('failedCommand', self.sendFailed, None), ('focus', 0, None), ('text', '', None)) self.defineoptions(kw, optiondefs) DirectEntry.__init__(self, parent = parent, **None) self.initialiseoptions(ChatInputWhiteList) self.whisperId = None wantHistory = 0 if __dev__: wantHistory = 1 self.wantHistory = base.config.GetBool('want-chat-history', wantHistory) self.history = [ ''] self.historySize = base.config.GetInt('chat-history-size', 10) self.historyIndex = 0 self.whiteList = None self.active = 0 self.autoOff = 0 self.alwaysSubmit = False DirectGuiGlobals = DirectGuiGlobals import direct.gui self.bind(DirectGuiGlobals.TYPE, self.applyFilter) self.bind(DirectGuiGlobals.ERASE, self.applyFilter) tpMgr = TextPropertiesManager.getGlobalPtr() Red = tpMgr.getProperties('red') Red.setTextColor(1.0, 0.0, 0.0, 1) tpMgr.setProperties('WLRed', Red) del tpMgr self.origFrameColor = self['frameColor'] self.origTextScale = self['text_scale'] self.origFrameSize = self['frameSize']
class SCElement(SCObject, NodePath): """ SCElement is the base class for all entities that can appear as entries in a SpeedChat menu. """ font = OTPGlobals.getInterfaceFont() SerialNum = 0 def __init__(self, parentMenu=None): SCObject.__init__(self) self.SerialNum = SCElement.SerialNum SCElement.SerialNum += 1 node = hidden.attachNewNode('SCElement%s' % self.SerialNum) NodePath.__init__(self, node) self.FinalizeTaskName = 'SCElement%s_Finalize' % self.SerialNum self.parentMenu = parentMenu self.__active = 0 self.__viewable = 1 # these are used to detect changes to the size of this element # to avoid unnecessary button rebuilds self.lastWidth = 0 self.lastHeight = 0 self.setDimensions(0,0) # how much space to put in around the edges of the button self.padX = .25 self.padZ = .1 def destroy(self): if self.isActive(): self.exitActive() # this calls exitVisible if necessary SCObject.destroy(self) if hasattr(self, 'button'): self.button.destroy() del self.button self.parentMenu = None self.detachNode() def setParentMenu(self, parentMenu): self.parentMenu = parentMenu def getParentMenu(self): return self.parentMenu def getDisplayText(self): """ derived classes should override and return the text that should be visually displayed on this item. Note that elements that must do non-trivial processing to produce this text should cache the text when they can. """ self.notify.error( 'getDisplayText is pure virtual, derived class must override') # input event handlers that derived classes can override def onMouseEnter(self, event): """ the mouse has just entered this entity """ if self.parentMenu is not None: self.parentMenu.memberGainedInputFocus(self) def onMouseLeave(self, event): """ the mouse has just left this entity """ if self.parentMenu is not None: self.parentMenu.memberLostInputFocus(self) def onMouseClick(self, event): """ the user just clicked on this entity """ pass """ inheritors should override these methods and perform whatever actions are appropriate when this element becomes 'active' and 'inactive' (for example, menu holders should show/hide their menu; other element types might play some sort of animation on activation). 'active' generally corresponds to having the input focus, but not always; see 'hasStickyFocus' below. """ def enterActive(self): self.__active = 1 def exitActive(self): self.__active = 0 def isActive(self): return self.__active def hasStickyFocus(self): """ Inheritors should override and return non-zero if they should remain active until a sibling becomes active, even if they lose the input focus. For example, menu holders should remain open until a sibling becomes active, even if the user moves the mouse out of the menu holder, or even completely away from the SpeedChat menus. """ return 0 """ If this element is marked as 'not viewable', it will disappear from its parent menu, and it will not be possible for the user to interact with this element. """ def setViewable(self, viewable): if (not boolEqual(self.__viewable, viewable)): self.__viewable = viewable # inform our parent that our visibility state has changed if self.parentMenu is not None: self.parentMenu.memberViewabilityChanged(self) def isViewable(self): return self.__viewable def getMinDimensions(self): """ Should return the width/height that this element would ideally like to be. We may be asked to display ourselves larger than this, never smaller. returns (width, height) """ text = TextNode('SCTemp') text.setFont(SCElement.font) dText = self.getDisplayText() text.setText(dText) bounds = text.getCardActual() # there's already padding on the right, apparently width = abs(bounds[1] - bounds[0]) + self.padX # the height will always be the same regardless of the string height = abs(bounds[3] - bounds[2]) + 2.*self.padZ return width, height def setDimensions(self, width, height): """ Call this to tell this element how big it should be. Must be called before calling finalize. """ self.width = float(width) self.height = float(height) if (self.lastWidth, self.lastHeight) != (self.width, self.height): self.invalidate() def invalidate(self): """ call this if something about our appearance has changed and we need to re-create our button """ SCObject.invalidate(self) parentMenu = self.getParentMenu() if parentMenu is not None: # if our parent menu caused us to become invalid during its # finalization, don't re-invalidate it if not parentMenu.isFinalizing(): parentMenu.invalidate() # from SCObject def enterVisible(self): SCObject.enterVisible(self) self.privScheduleFinalize() def exitVisible(self): SCObject.exitVisible(self) self.privCancelFinalize() def privScheduleFinalize(self): # spawn a task to finalize ourselves before we render. def finalizeElement(task, self=self): # if our parent menu is dirty, it will be finalizing us shortly; # our size may change in the process, so don't bother # finalizing yet. if self.parentMenu is not None: if self.parentMenu.isDirty(): return Task.done self.finalize() return Task.done taskMgr.remove(self.FinalizeTaskName) taskMgr.add(finalizeElement, self.FinalizeTaskName, priority=SCElementFinalizePriority) def privCancelFinalize(self): taskMgr.remove(self.FinalizeTaskName) def finalize(self, dbArgs={}): """ 'dbArgs' can contain parameters (and parameter overrides) for the DirectButton. """ if not self.isDirty(): return SCObject.finalize(self) if hasattr(self, 'button'): self.button.destroy() del self.button halfHeight = self.height/2. # if we're given a 'center' value for the text alignment, # calculate the appropriate text X position textX = 0 if dbArgs.has_key('text_align'): if dbArgs['text_align'] == TextNode.ACenter: textX = self.width/2. args = { 'text': self.getDisplayText(), 'frameColor': (0,0,0,0), 'rolloverColor': self.getColorScheme().getRolloverColor()+(1,), 'pressedColor': self.getColorScheme().getPressedColor()+(1,), 'text_font': OTPGlobals.getInterfaceFont(), 'text_align': TextNode.ALeft, 'text_fg': self.getColorScheme().getTextColor()+(1,), 'text_pos': (textX,-.25-halfHeight,0), 'relief': DGG.FLAT, # disable the 'press effect' (slight scale-down) 'pressEffect': 0, } # add external parameters and apply any overrides args.update(dbArgs) # these can't be passed directly to DirectButton rolloverColor = args['rolloverColor'] pressedColor = args['pressedColor'] del args['rolloverColor'] del args['pressedColor'] """ from direct.gui.DirectGui import *;import OTPGlobals; btn.destroy();w=3;h=2;btn = DirectButton(parent=aspect2d,frameSize=(0,w,-h,0),text='TEST',frameColor=(.8,.8,1,1),text_font=OTPGlobals.getInterfaceFont(),text_align=TextNode.ALeft,text_fg=(0,0,0,1),text_pos=(0,-.25-(h/2.),0),image=('phase_3/models/props/page-arrow', 'poly'),image_pos=(w*.9,0,-h/2.),state=DGG.NORMAL,relief=DGG.RAISED);btn.setPos(-.5,0,0);btn.setScale(.5)""" btn = DirectButton( parent = self, frameSize = (0,self.width, -self.height,0), # this doesn't trigger until mouse-up. We want to trigger # on mouse-down; see the 'bind' calls below #command = self.onMouseClick, **args ) # Set frame color for rollover and pressed states btn.frameStyle[DGG.BUTTON_ROLLOVER_STATE].setColor(*rolloverColor) btn.frameStyle[DGG.BUTTON_DEPRESSED_STATE].setColor(*pressedColor) btn.updateFrameStyle() # listen for input events btn.bind(DGG.ENTER, self.onMouseEnter) btn.bind(DGG.EXIT, self.onMouseLeave) btn.bind(DGG.B1PRESS, self.onMouseClick) self.button = btn # store the new display params self.lastWidth = self.width self.lastHeight = self.height self.validate() def __str__(self): return '%s: %s' % (self.__class__.__name__, self.getDisplayText())
def __init__(self, other=None): """ Create the toon, suit, or char specified by the dna array """ self.name = "" # name is used in debugPrint. assert self.debugPrint("Avatar()") try: self.Avatar_initialized return except: self.Avatar_initialized = 1 # create an empty actor to add parts to Actor.__init__(self, None, None, other, flattenable=0, setFinal=1) ShadowCaster.__init__(self) # The default font. self.__font = OTPGlobals.getInterfaceFont() self.soundChatBubble = None # Holds Type of Avatar self.avatarType = "" self.nametagNodePath = None # Set up a nametag (actually, a group of nametags, # including a Nametag2d and a Nametag3d) for the avatar. # The nametag won't be visible until it is managed, which # will happen during addActive(). self.__nameVisible = 1 self.nametag = NametagGroup() self.nametag.setAvatar(self) self.nametag.setFont(OTPGlobals.getInterfaceFont()) self.nametag2dContents = Nametag.CName | Nametag.CSpeech # nametag2dDist is changed only by DistributedAvatar. self.nametag2dDist = Nametag.CName | Nametag.CSpeech self.nametag2dNormalContents = Nametag.CName | Nametag.CSpeech self.nametag3d = self.attachNewNode('nametag3d') self.nametag3d.setTag('cam', 'nametag') self.nametag3d.setLightOff() #Accept ambient lighting changes if not self.ManagesNametagAmbientLightChanged: self.acceptNametagAmbientLightChange() # do not display in reflections OTPRender.renderReflection(False, self.nametag3d, 'otp_avatar_nametag', None) # But do show in shadows, except for the nametag. self.getGeomNode().showThrough(OTPRender.ShadowCameraBitmask) self.nametag3d.hide(OTPRender.ShadowCameraBitmask) self.collTube = None self.battleTube = None # set some initial values self.scale = 1.0 self.nametagScale = 1.0 self.height = 0.0 self.battleTubeHeight = 0.0 self.battleTubeRadius = 0.0 self.style = None # commonChatFlags is a bitmask that may include the CommonChat # and SuperChat bits. self.commonChatFlags = 0 # This is either CCNonPlayer, CCSuit, or CCNormal, # according to whether there's a human behind the avatar # or not. This determines the color nametag that is # assigned, as well as whether chat messages from this # avatar will be garbled. self.understandable = 1 self.setPlayerType(NametagGroup.CCNormal) self.ghostMode = 0 # Page chat private vars self.__chatParagraph = None self.__chatMessage = None self.__chatFlags = 0 self.__chatPageNumber = None self.__chatAddressee = None self.__chatDialogueList = [] self.__chatSet = 0 self.__chatLocal = 0 # Record current dialogue so it can be interrupted the # next time the avatar talks self.__currentDialogue = None # since whiteListChatFlags is not a required field, init it just in case self.whitelistChatFlags = 0
def finalize(self, dbArgs={}): """ 'dbArgs' can contain parameters (and parameter overrides) for the DirectButton. """ if not self.isDirty(): return SCObject.finalize(self) if hasattr(self, 'button'): self.button.destroy() del self.button halfHeight = self.height/2. # if we're given a 'center' value for the text alignment, # calculate the appropriate text X position textX = 0 if dbArgs.has_key('text_align'): if dbArgs['text_align'] == TextNode.ACenter: textX = self.width/2. args = { 'text': self.getDisplayText(), 'frameColor': (0,0,0,0), 'rolloverColor': self.getColorScheme().getRolloverColor()+(1,), 'pressedColor': self.getColorScheme().getPressedColor()+(1,), 'text_font': OTPGlobals.getInterfaceFont(), 'text_align': TextNode.ALeft, 'text_fg': self.getColorScheme().getTextColor()+(1,), 'text_pos': (textX,-.25-halfHeight,0), 'relief': DGG.FLAT, # disable the 'press effect' (slight scale-down) 'pressEffect': 0, } # add external parameters and apply any overrides args.update(dbArgs) # these can't be passed directly to DirectButton rolloverColor = args['rolloverColor'] pressedColor = args['pressedColor'] del args['rolloverColor'] del args['pressedColor'] """ from direct.gui.DirectGui import *;import OTPGlobals; btn.destroy();w=3;h=2;btn = DirectButton(parent=aspect2d,frameSize=(0,w,-h,0),text='TEST',frameColor=(.8,.8,1,1),text_font=OTPGlobals.getInterfaceFont(),text_align=TextNode.ALeft,text_fg=(0,0,0,1),text_pos=(0,-.25-(h/2.),0),image=('phase_3/models/props/page-arrow', 'poly'),image_pos=(w*.9,0,-h/2.),state=DGG.NORMAL,relief=DGG.RAISED);btn.setPos(-.5,0,0);btn.setScale(.5)""" btn = DirectButton( parent = self, frameSize = (0,self.width, -self.height,0), # this doesn't trigger until mouse-up. We want to trigger # on mouse-down; see the 'bind' calls below #command = self.onMouseClick, **args ) # Set frame color for rollover and pressed states btn.frameStyle[DGG.BUTTON_ROLLOVER_STATE].setColor(*rolloverColor) btn.frameStyle[DGG.BUTTON_DEPRESSED_STATE].setColor(*pressedColor) btn.updateFrameStyle() # listen for input events btn.bind(DGG.ENTER, self.onMouseEnter) btn.bind(DGG.EXIT, self.onMouseLeave) btn.bind(DGG.B1PRESS, self.onMouseClick) self.button = btn # store the new display params self.lastWidth = self.width self.lastHeight = self.height self.validate()
def __init__(self, useImage = True, highlightNearEnd = True): if useImage: image = self.getImage() else: image = None DirectFrame.__init__(self, state=DGG.DISABLED, relief=None, scale=0.45, image=image, image_pos=(0, 0, 0), text='0', text_fg=(0, 0, 0, 1), text_font=OTPGlobals.getInterfaceFont(), text_pos=(-0.01, -0.15), text_scale=0.35) self.initialiseoptions(ToontownTimer) self.timerId = ToontownTimer.TimerId ToontownTimer.TimerId += 1 self.highlightNearEnd = highlightNearEnd self.countdownTask = None self.currentTime = 0 self.taskTime = 0.0 self.setFontColor(Vec4(0, 0, 0, 1)) return
def __init__(self, useImage=True, highlightNearEnd=True): if useImage: image = self.getImage() else: image = None DirectFrame.__init__(self, state=DGG.DISABLED, relief=None, scale=0.45, image=image, image_pos=(0, 0, 0), text='0', text_fg=(0, 0, 0, 1), text_font=OTPGlobals.getInterfaceFont(), text_pos=(-0.01, -0.15), text_scale=0.35) self.initialiseoptions(OTPTimer) self.timerId = OTPTimer.TimerId OTPTimer.TimerId += 1 self.highlightNearEnd = highlightNearEnd self.countdownTask = None self.currentTime = 0 self.taskTime = 0.0 self.setFontColor(Vec4(0, 0, 0, 1)) return