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 avId in self.cr.doId2do:
         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 avId in self.cr.doId2do:
         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 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 __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)
Ejemplo n.º 4
0
 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
 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 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 displayWhisper(self, fromId, chatString, whisperType):
     sender = None
     sfx = self.soundWhisper
     if whisperType == WTNormal:
         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)
Ejemplo n.º 9
0
 def displayWhisper(self, fromId, chatString, whisperType):
     sender = None
     sfx = self.soundWhisper
     if whisperType == WTNormal:
         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 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 xrange(41):
            self.tieSequence.append(Parallel(LerpColorInterval(self.locatorList[x], 0.15, Vec4(0.5, 0.5, 0.5, 0.5), Vec4(1, 1, 1, 1)), LerpColorInterval(self.locatorList[x], 0.15, 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, 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
Ejemplo n.º 12
0
 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
 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)
Ejemplo n.º 14
0
 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 'text_align' in dbArgs:
         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, -.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 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 'text_align' in dbArgs:
         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, -.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 __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,
      'focus': 0,
      'text': '',
      'sortOrder': DGG.FOREGROUND_SORT_INDEX}
     ChatInputWhiteListFrame.__init__(self, entryOptions, parent, **kw)
     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
Ejemplo n.º 17
0
    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 xrange(41):
            self.tieSequence.append(
                Parallel(
                    LerpColorInterval(self.locatorList[x], 0.15,
                                      Vec4(0.5, 0.5, 0.5, 0.5),
                                      Vec4(1, 1, 1, 1)),
                    LerpColorInterval(self.locatorList[x], 0.15,
                                      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, 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
Ejemplo n.º 19
0
class SCElement(SCObject, NodePath):
    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 'text_align' in dbArgs:
            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, -.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, 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,
         'focus': 0,
         'text': '',
         'sortOrder': DGG.FOREGROUND_SORT_INDEX
     }
     ChatInputWhiteListFrame.__init__(self, entryOptions, parent, **kw)
     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