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 displayWhisper(self, fromId, chatString, whisperType): sender = None sfx = self.soundWhisper if whisperType == WhisperPopup.WTNormal or whisperType == WhisperPopup.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) return
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 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 == WhisperPopup.WTNormal or whisperType == WhisperPopup.WTQuickTalker: chatString = senderName + ': ' + chatString whisper = WhisperPopup(chatString, OTPGlobals.getInterfaceFont(), whisperType) if sender != None: whisper.setClickable(senderName, fromId) whisper.manage(base.marginManager) base.playSfx(sfx) return
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)